Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d25bd39
feat: 拆分 default_workdir 与 session workdir 并接入会话级切换
Cai-Tang-www Apr 3, 2026
2178e26
feat: 移除 legacy workdir 兼容并强制 default_workdir
Cai-Tang-www Apr 3, 2026
fb93f7e
feat(context,runtime): 落地 manual compact 与 transcript 持久化
wynxing Apr 3, 2026
ba7e26b
feat(config,tui): 接入 manual compact 配置、事件与 /compact
wynxing Apr 3, 2026
9229313
fix(context): 修复 compact rune 计数与规则发现错误处理
wynxing Apr 3, 2026
c374624
test(docs): 补齐 manual compact 覆盖并同步文档
wynxing Apr 3, 2026
13d9d85
test: 补齐 P0-3 工作目录分支覆盖率
Cai-Tang-www Apr 3, 2026
6955c22
fix(tui): 拦截空会话的 compact 请求
wynxing Apr 3, 2026
d8da168
feat: 移除 workdir 配置持久化并改为会话内存态
Cai-Tang-www Apr 3, 2026
4408951
feat: slash命令仅保留cwd并移除workspace
Cai-Tang-www Apr 3, 2026
25f28b5
test: 补齐runtime与cwd命令分支覆盖
Cai-Tang-www Apr 3, 2026
572c8c6
test: 修复runtime测试环境变量并行竞态
Cai-Tang-www Apr 3, 2026
5d9706f
Merge branch 'main' into P0-3
Cai-Tang-www Apr 3, 2026
59f5134
test: 修复合并后runtime测试配置入口引用
Cai-Tang-www Apr 3, 2026
4bc5ddc
Refine compact prompt ownership and session model binding
wynxing Apr 3, 2026
1c26c0f
docs: 更新 AGENTS.md 规则并移除重复的 agents.md
wynxing Apr 3, 2026
b486d8d
refactor: centralize context compact constants
wynxing Apr 3, 2026
fc78692
Merge pull request #131 from Cai-Tang-www/P0-3
minorcell Apr 3, 2026
42f089e
fix:修复了实现的不规范问题,并更新了文档说明
wynxing Apr 3, 2026
b86206e
feat(context,runtime): 落地 manual compact 与 transcript 持久化
wynxing Apr 3, 2026
85c0d55
feat(config,tui): 接入 manual compact 配置、事件与 /compact
wynxing Apr 3, 2026
add5caa
fix(context): 修复 compact rune 计数与规则发现错误处理
wynxing Apr 3, 2026
5be2e7d
test(docs): 补齐 manual compact 覆盖并同步文档
wynxing Apr 3, 2026
4000a6b
fix(tui): 拦截空会话的 compact 请求
wynxing Apr 3, 2026
a8c305d
Refine compact prompt ownership and session model binding
wynxing Apr 3, 2026
331d513
docs: 更新 AGENTS.md 规则并移除重复的 agents.md
wynxing Apr 3, 2026
e552ca0
refactor: centralize context compact constants
wynxing Apr 3, 2026
733529a
fix:修复了实现的不规范问题,并更新了文档说明
wynxing Apr 3, 2026
3d37bbb
Merge branch 'rebasetest' of https://github.com/Yumiue/neo-code into …
wynxing Apr 3, 2026
75d616a
test:添加测试
wynxing Apr 3, 2026
a180d94
docs(README):修正下载链接
wynxing Apr 3, 2026
1e24012
refactor: 收敛 compact 结构与文档说明
wynxing Apr 4, 2026
afeaeee
docs:加入过时的声明
wynxing Apr 4, 2026
f6d1479
docs:把过时文档的更改给撤销了
wynxing Apr 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ config.local.yaml
# Local data
data/
.cache/
.neocode/projects/**/.transcripts/

# Editor/IDE
.idea/
Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
- 导出标识符使用 `PascalCase`,未导出使用 `camelCase`。
- 使用制表符缩进,尽量将单行控制在约 120 字符内。
- 核心抽象上的导出类型、函数、接口应补充清晰注释,尤其是 `provider`、`runtime`、`tools`。
- 在非测试文件中新增函数时,必须紧邻函数定义补充便于解读的注释,注释内容使用中文并以 UTF-8 编码保存;注释应说明函数职责、关键行为或上下文,避免空泛的模板化表述。
- 避免硬编码路径、URL、模型名、超时、输出长度限制和环境差异项,优先通过配置、参数或具名常量注入。
- 避免硬编码业务语义字符串或状态值(例如消息角色、事件类型、协议字段值);如需复用,优先收敛到共享常量、类型或统一定义处。
- 优先写清晰、可替换的实现,不要为了“未来可能需要”提前引入复杂泛化。
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,7 @@ NeoCode 已经集成了 GoReleaser 与 GitHub Actions 的全自动化 CI/CD 流
## License

MIT

## Manual Compact

NeoCode 支持通过 `/compact` 手动压缩当前会话上下文。配置项见 `docs/guides/configuration.md`,流程和摘要约定见 `docs/context-compact.md`。
112 changes: 0 additions & 112 deletions agents.md

This file was deleted.

91 changes: 91 additions & 0 deletions docs/context-compact.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Context Compact

本文档说明 NeoCode 中 manual compact 的配置、执行链路和摘要约定。

## 概览

- 当前仅支持手动触发的 compact,不包含自动 compact。
- 用户通过 `/compact` 对当前会话执行一次上下文压缩。
- compact 前会先写入完整 transcript,随后生成并校验 compact summary,再回写会话消息。

## 配置

compact 相关配置位于:

```yaml
context:
compact:
manual_strategy: keep_recent
manual_keep_recent_messages: 10
max_summary_chars: 1200
```

- `manual_strategy`
控制手动 compact 的策略,支持 `keep_recent` 和 `full_replace`。
- `manual_keep_recent_messages`
在 `keep_recent` 模式下保留最近消息数量,并按 tool call 与 tool result 的原子块整体保留。
- `max_summary_chars`
控制 compact summary 的最大字符数。

## 执行链路

1. TUI 识别 `/compact` 并调用 `runtime.Compact(...)`。
2. runtime 发出 `compact_start` 事件。
3. compact runner 将原始消息写入 transcript(JSONL)。
4. compact runner 根据策略构造归档消息与保留消息。
5. runtime 选择用于生成 summary 的 provider 和 model:
优先复用会话记录的 `provider` / `model`,缺失时回退到当前配置。
6. summary generator 调用模型生成语义摘要。
7. runner 校验摘要结构与长度,必要时截断。
8. compact 成功时回写会话消息并发出 `compact_done`;失败时发出 `compact_error`。

## 摘要协议

compact summary 必须以如下结构返回:

```text
[compact_summary]

done:
- ...

in_progress:
- ...

decisions:
- ...

code_changes:
- ...

constraints:
- ...
```

- 必须包含固定起始标记 `[compact_summary]`。
- 必须包含 `done`、`in_progress`、`decisions`、`code_changes`、`constraints` 五个 section。
- 每个 section 至少包含一条非空 bullet。

## 保留原则

- 优先保留已完成事项及结果。
- 保留仍在进行中的状态、关键决策及原因、关键代码改动、用户约束。
- 默认忽略工具详细输出、重复背景、已解决错误的排查细节。

## 事件

manual compact 相关 runtime 事件包括:

- `compact_start`
- `compact_done`
- `compact_error`

`compact_done` payload 包含:

- `applied`
- `before_chars`
- `after_chars`
- `saved_ratio`
- `trigger_mode`
- `transcript_id`
- `transcript_path`
24 changes: 24 additions & 0 deletions docs/guides/configuration.md
Comment thread
wynxing marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,27 @@ echo $OPENAI_API_KEY
## 相关文档

- [添加新 Provider](./adding-providers.md)

## Context Compact

以下配置用于控制手动上下文压缩行为。

### 配置示例

```yaml
context:
compact:
manual_strategy: keep_recent
manual_keep_recent_messages: 10
max_summary_chars: 1200
```

### 字段说明

| 字段 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| `context.compact.manual_strategy` | string | `keep_recent` | 手动 `/compact` 策略,可选 `keep_recent` / `full_replace` |
| `context.compact.manual_keep_recent_messages` | int | `10` | `keep_recent` 模式下保留最近 N 条消息;会按 tool call 与 tool result 的原子块整体保留 |
| `context.compact.max_summary_chars` | int | `1200` | compact summary 最大字符数 |

更多行为说明见 [context-compact.md](../context-compact.md)。
3 changes: 3 additions & 0 deletions docs/neocode-coding-agent-mvp-architecture.md
Comment thread
wynxing marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# ⚠️ 已过时:旧版 API 文档(DEPRECATED)


# NeoCode Coding Agent MVP 架构设计

## 1. 目标
Expand Down
2 changes: 1 addition & 1 deletion internal/app/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestNewProgramNormalizesInvalidCurrentModelOnStartup(t *testing.T) {
}

configPath := filepath.Join(configDir, "config.yaml")
raw := []byte("selected_provider: openai\ncurrent_model: unsupported-current\nworkdir: .\nshell: powershell\n")
raw := []byte("selected_provider: openai\ncurrent_model: unsupported-current\nshell: powershell\n")
if err := os.WriteFile(configPath, raw, 0o644); err != nil {
t.Fatalf("write config: %v", err)
}
Expand Down
Loading
Loading