@jun133/athlete 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +18 -13
  2. package/dist/cli.js +7474 -4084
  3. package/dist/cli.js.map +1 -1
  4. package/package.json +4 -1
  5. package/scripts/postinstall-playwright.mjs +10 -10
  6. package/spec/architecture//346/200/273/344/275/223/346/236/266/346/236/204.md +25 -21
  7. package/spec/architecture//347/212/266/346/200/201/344/270/216/347/234/237/347/233/270/346/272/220.md +20 -17
  8. package/spec/architecture//350/277/220/350/241/214/346/227/266/345/276/252/347/216/257.md +105 -48
  9. package/spec/implementation//347/233/256/345/275/225/347/273/223/346/236/204/345/210/260/344/273/243/347/240/201/346/226/207/344/273/266/346/230/240/345/260/204/350/241/250.md +141 -66
  10. package/spec/interfaces/InteractionShell.md +15 -7
  11. package/spec/modules/config-system.md +45 -19
  12. package/spec/modules/interactive-terminal.md +49 -22
  13. package/spec/modules/lightweight-context-runtime.md +34 -17
  14. package/spec/modules/provider-adapter.md +45 -20
  15. package/spec/modules/runtime-metrics.md +54 -24
  16. package/spec/modules/runtime-rules.md +52 -20
  17. package/spec/modules/session-resume-compact.md +20 -14
  18. package/spec/modules/task-state.md +25 -18
  19. package/spec/modules/telegram-private-chat.md +3 -3
  20. package/spec/modules/tool-registry.md +93 -35
  21. package/spec/modules//346/211/251/345/261/225/346/234/272/345/210/266.md +65 -29
  22. package/spec/overview/v0/350/214/203/345/233/264.md +7 -6
  23. package/spec/overview//344/272/247/345/223/201/345/256/232/344/271/211.md +14 -12
  24. package/spec/principles/P06-/344/270/212/344/270/213/346/226/207/350/246/201/350/203/275/345/216/213/347/274/251.md +5 -5
  25. package/spec/principles/P13-session/346/230/257/344/273/273/345/212/241/347/216/260/345/234/272.md +5 -5
  26. package/spec/principles/P15-provider/345/277/205/351/241/273/345/217/257/346/233/277/346/215/242.md +12 -10
  27. package/spec/principles/P18-/344/270/273/345/276/252/347/216/257/345/222/214/346/226/207/344/273/266/351/203/275/344/270/215/350/203/275/351/225/277/350/203/226.md +37 -36
  28. package/spec/principles/P20-/345/244/226/351/203/250/344/272/213/345/256/236/345/277/205/351/241/273/347/273/221/345/256/232/350/257/201/346/215/256.md +48 -0
  29. package/spec/principles/P21-/346/262/241/351/252/214/350/277/207/345/260/261/344/270/215/350/203/275/346/224/266/345/217/243.md +46 -0
  30. package/spec/principles/P22-/351/230/266/346/256/265/346/216/250/350/277/233/345/277/205/351/241/273/346/234/211/346/234/272/345/231/250/347/212/266/346/200/201.md +40 -0
  31. package/spec/principles/P23-/346/226/207/346/234/254/351/223/276/350/267/257/345/277/205/351/241/273/347/250/263/345/256/232/345/217/257/350/257/273.md +38 -0
  32. package/spec/principles/P24-/351/224/231/350/257/257/345/205/274/345/256/271/344/270/215/350/203/275/351/253/230/344/272/216/346/255/243/347/241/256/346/200/247.md +37 -0
  33. package/spec/principles/README.md +47 -39
  34. package/spec/testing//346/265/213/350/257/225/347/255/226/347/225/245.md +27 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jun133/athlete",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "A global terminal AI coding assistant.",
5
5
  "keywords": [
6
6
  "athlete",
@@ -50,13 +50,16 @@
50
50
  "cfb": "^1.2.2",
51
51
  "chalk": "^5.6.2",
52
52
  "commander": "^14.0.1",
53
+ "cors": "^2.8.6",
53
54
  "diff": "^8.0.2",
54
55
  "docx": "^9.5.1",
55
56
  "dompurify": "^3.3.3",
56
57
  "dotenv": "^17.2.3",
57
58
  "env-paths": "^3.0.0",
58
59
  "execa": "^9.6.0",
60
+ "express": "^5.2.1",
59
61
  "fast-glob": "^3.3.3",
62
+ "lowdb": "^7.0.1",
60
63
  "mammoth": "^1.10.0",
61
64
  "marked": "^17.0.4",
62
65
  "openai": "^6.4.0",
@@ -34,20 +34,20 @@ if ((result.status ?? 1) !== 0) {
34
34
  console.warn(message);
35
35
  }
36
36
 
37
- function resolveInstallTarget(rawValue) {
38
- switch (String(rawValue ?? "").trim().toLowerCase()) {
39
- case "chrome":
40
- return "chrome";
37
+ function resolveInstallTarget(rawValue) {
38
+ switch (String(rawValue ?? "").trim().toLowerCase()) {
39
+ case "chrome":
40
+ return "chrome";
41
41
  case "firefox":
42
42
  return "firefox";
43
43
  case "webkit":
44
44
  return "webkit";
45
- case "msedge":
46
- return "msedge";
47
- default:
48
- return "chrome";
49
- }
50
- }
45
+ case "msedge":
46
+ return "msedge";
47
+ default:
48
+ return "chromium";
49
+ }
50
+ }
51
51
 
52
52
  function resolvePlaywrightCliPath() {
53
53
  const packageJsonPath = require.resolve("playwright/package.json");
@@ -28,12 +28,13 @@ Athlete 是一个终端里的智能体运行系统:
28
28
 
29
29
  目录:`src/tools/` `src/mcp/`
30
30
 
31
- 负责:
32
-
33
- - 向模型暴露动作
34
- - 参数解析
35
- - 机器约束检查
36
- - 调用底层能力
31
+ 负责:
32
+
33
+ - 向模型暴露动作
34
+ - 参数解析
35
+ - 机器约束检查
36
+ - 调用底层能力
37
+ - 统一治理 metadata、fail-closed 暴露过滤、routing hint 与 signal 校验
37
38
 
38
39
  ### 3. Skill Plane
39
40
 
@@ -70,18 +71,19 @@ Athlete 是一个终端里的智能体运行系统:
70
71
  - worktree 目录
71
72
  - MCP 浏览器
72
73
 
73
- ### 6. Orchestrator Layer
74
-
75
- 目录:`src/orchestrator/`
76
-
77
- 负责:
78
-
79
- - 复杂度判断
80
- - 最小任务图落盘
81
- - self / subagent / teammate / background 路由
82
- - lead slice 开始前的任务组织
83
-
84
- ## 当前最重要的架构边界
74
+ ### 6. Orchestrator Layer
75
+
76
+ 目录:`src/orchestrator/`
77
+
78
+ 负责:
79
+
80
+ - 复杂度判断
81
+ - 最小任务图落盘
82
+ - task / team / background / worktree 真相源派生任务 lifecycle
83
+ - self / subagent / teammate / background 路由
84
+ - lead slice 开始前的任务组织
85
+
86
+ ## 当前最重要的架构边界
85
87
 
86
88
  ### 控制面
87
89
 
@@ -106,6 +108,8 @@ Athlete 是一个终端里的智能体运行系统:
106
108
 
107
109
  1. 控制面不直接改文件。
108
110
  2. 执行面不发明控制面真相。
109
- 3. orchestrator 负责调度,不负责具体文件改写。
110
- 4. tools 提供动作,skills 提供 workflow,二者不互相替代。
111
- 5. 主循环只做调度;closeout、verification signal、workflow gating 这类长期规则要下沉到独立模块。
111
+ 3. orchestrator 负责调度,不负责具体文件改写。
112
+ 4. tools 提供动作,skills 提供 workflow,二者不互相替代。
113
+ 5. 主循环只做调度;closeout、verification signal、workflow gating 这类长期规则要下沉到独立模块。
114
+ 6. tool priority、browser-first、document routing、MCP fail-closed 之类策略属于机器层,不属于 prompt 路由表。
115
+ 7. task readiness、ownership、handoff legality、worktree binding reality 由机器从既有真相源派生,不靠 prompt 记忆。
@@ -8,17 +8,18 @@ Athlete 要跑长任务、协作任务和恢复任务,关键状态不能只放
8
8
 
9
9
  ## 当前真相源
10
10
 
11
- ### TaskStore
12
-
13
- 回答:
14
-
15
- - 有哪些任务
16
- - 哪些任务被阻塞
17
- - 谁被指派
18
- - 谁正在做
19
- - 任务绑定了哪个 worktree
20
-
21
- 状态目录:`.athlete/tasks/`
11
+ ### TaskStore
12
+
13
+ 回答:
14
+
15
+ - 有哪些任务
16
+ - 哪些任务被阻塞
17
+ - 谁被指派
18
+ - 谁正在做
19
+ - 任务绑定了哪个 worktree
20
+ - orchestrator task 的 objective / kind / handoff metadata 是什么
21
+
22
+ 状态目录:`.athlete/tasks/`
22
23
 
23
24
  ### TeamStore
24
25
 
@@ -109,9 +110,11 @@ Athlete 要跑长任务、协作任务和恢复任务,关键状态不能只放
109
110
  - 有 request / response 对应关系
110
111
  - 有持久化状态
111
112
 
112
- ## 当前规则
113
-
114
- 1. 新增状态前,先问是不是已有真相源应扩字段。
115
- 2. 能复用现有真相源,就不要新造平行 JSON 文件。
116
- 3. 任何需要跨 turn、跨 agent 保持一致的信息,都不能只存在 system prompt 里。
117
- 4. 普通消息不能代替正式审批。
113
+ ## 当前规则
114
+
115
+ 1. 新增状态前,先问是不是已有真相源应扩字段。
116
+ 2. 能复用现有真相源,就不要新造平行 JSON 文件。
117
+ 3. 任何需要跨 turn、跨 agent 保持一致的信息,都不能只存在 system prompt 里。
118
+ 4. 普通消息不能代替正式审批。
119
+ 5. task lifecycle 不是单独落盘的新 JSON;它由 `TaskStore` + `TeamStore` + `BackgroundJobStore` + `WorktreeStore` 的现有事实派生。
120
+ 6. handoff 缺失或冲突时必须 fail-closed,例如:缺失 teammate、缺失 background job、失效 worktree 绑定。
@@ -7,76 +7,133 @@
7
7
  1. 组装 system prompt
8
8
  2. 注入运行时状态
9
9
  3. 调模型
10
- 4. 执行工具
11
- 5. 判断继续、yield、暂停、结束
12
-
13
- 当前 lead 路径接法:
14
-
15
- - `runManagedAgentTurn`
16
- - `prepareLeadTurn`
17
- - `runAgentTurn`
18
-
19
- 也就是说:
20
-
21
- - orchestrator 在 lead slice 开始前先做任务组织与派工
22
- - `runTurn` 继续专注模型请求、工具执行、continuation、verification、compact
23
- - teammate / subagent loop 不走 lead orchestrator
10
+ 4. 执行工具
11
+ 5. 判断继续、yield、暂停、结束
12
+
13
+ 当前 lead 路径接法:
14
+
15
+ - `runManagedAgentTurn`
16
+ - `prepareLeadTurn`
17
+ - `runAgentTurn`
18
+
19
+ 也就是说:
20
+
21
+ - orchestrator 在 lead slice 开始前先做任务组织与派工
22
+ - 派工前先从 task / team / background / worktree 真相源派生任务 lifecycle
23
+ - `runTurn` 继续专注模型请求、工具执行、continuation、verification、compact
24
+ - teammate / subagent loop 不走 lead orchestrator
25
+
26
+ 当前 one-shot CLI 也走同一套 machine truth,只是终端外壳不同:
27
+
28
+ - `src/cli.ts`
29
+ - `src/cli/support.ts`
30
+
31
+ one-shot 结束时必须把 terminal transition / verification / acceptance 收敛成稳定 closeout contract 输出。
32
+
33
+ 交互式 CLI 退出时还有一条独立规则:
34
+
35
+ - 如果当前项目没有运行中的后台进程,`quit` 直接退出
36
+ - 如果有运行中的后台进程,必须先列出它们,再由用户二选一:
37
+ - kill 全部后台进程并退出
38
+ - 取消退出继续运行
39
+ - kill 不彻底时必须 fail-closed,不允许带着不可见孤儿进程假装退出成功
24
40
 
25
41
  ## 当前最重要的机器规则
26
42
 
27
- ### 计划规则
28
-
29
- 变更型动作默认要求先 `todo_write`。
43
+ ### 计划规则
44
+
45
+ 变更型动作默认要求先 `todo_write`。
46
+
47
+ ### 任务编排规则
48
+
49
+ lead 编排不再只看 task status 字段,而是看机器派生的 lifecycle:
50
+
51
+ - `blocked`
52
+ - `ready`
53
+ - `active`
54
+ - `completed`
55
+
56
+ 并同时判断:
57
+
58
+ - runnableBy 是 lead / teammate / nobody
59
+ - handoff 是否有合法控制面事实支撑
60
+ - worktree 绑定是否仍然有效
61
+
62
+ 如果 teammate / background / worktree 的事实缺失或冲突,lead 路径会阻断新的派工,而不是继续默许推进。
30
63
 
31
64
  ### inbox 规则
32
65
 
33
66
  lead 和 teammate 的 inbox 在 turn 开头统一注入。
34
67
 
35
- ### verification 规则
68
+ ### verification 规则
36
69
 
37
70
  发生文件改动或 mutating shell 后,会进入 verification 状态机。
38
71
 
39
72
  verification 不是无限提醒:
40
73
 
41
- - `pendingPaths` 会随 session 持久化,continuation 后仍然有效
42
- - 显式 build / test / verify 命令会记录为正式 verification attempt
43
- - 对轻量交付物(如 `validation/*.md`、`.txt`)的定向 `read_file` 检查,也会被记录为一次通过的轻量验证
44
- - 如果任务已经结束、输出文件已经存在且属于轻量交付物,finalize 会先尝试 auto-readback,再决定是否 pause 给用户
45
-
46
- ### 收口规则
47
-
48
- 当主目标已经满足时,runtime 会优先结束,而不是继续补做 task / todo / verification 文书动作。
49
-
50
- - 收口判断不只看模型文本,还看 `changedPaths`、`verificationState`、todo 完成度与本轮是否已有实质工具活动
74
+ - `pendingPaths` 会随 session 持久化,continuation 后仍然有效
75
+ - 显式 build / test / verify 命令会记录为正式 verification attempt
76
+ - 对轻量交付物(如 `validation/*.md`、`.txt`)的定向 `read_file` 检查,也会被记录为一次通过的轻量验证
77
+ - 如果任务已经结束、输出文件已经存在且属于轻量交付物,finalize 会先尝试 auto-readback,再决定是否 pause 给用户
78
+ - acceptance / verification 的跨生态判断统一经过 signal 层,不直接匹配某个 adapter 工具名
79
+
80
+ ### 收口规则
81
+
82
+ 当主目标已经满足时,runtime 会优先结束,而不是继续补做 task / todo / verification 文书动作。
83
+
84
+ - 收口判断不只看模型文本,还看 `changedPaths`、`verificationState`、todo 完成度与本轮是否已有实质工具活动
51
85
  - 一旦进入“应该收口”的区间,`task_list` / `task_get` / `task_update` 会在工具集里被隐藏
52
86
  - 当 todo 已全部完成时,`todo_write` 也会在收口阶段从工具集中移除,避免重复 closeout
53
87
  - 旧 todo 过时但真实工作已完成时,不再把 stale todo 当成 finalize 的硬阻塞
54
88
 
55
- ### continuation 规则
56
-
57
- 工具步数过多时,不中断任务,而是自动续跑。
58
-
59
- ### compact 规则
89
+ ### continuation 规则
90
+
91
+ 工具步数过多时,不中断任务,而是自动续跑。
92
+
93
+ ### runtime transition 规则
94
+
95
+ continue / recover / yield / pause / finalize 不再只靠零散布尔值和字符串拼接。
96
+
97
+ - runtime 会产出结构化 transition:`action + reason code + detail`
98
+ - `checkpoint.flow.lastTransition` 持久化最近一次关键 runtime 决策
99
+ - `checkpoint.flow.reason` 只是从结构化 transition 派生的紧凑视图,不再是独立真相源
100
+ - continuation / resume / recovery / closeout 都应优先读取这一层机器状态,而不是反推 prompt 文案
101
+
102
+ ### compact 规则
60
103
 
61
104
  上下文过长时,自动压缩请求上下文,不直接放弃任务。
62
105
 
63
- ### 浏览器 workflow 规则
64
-
65
- 在相关 skill 已加载且浏览器工具可用时:
66
-
67
- - 自然语言网页任务优先走 Playwright MCP 工具
68
- - shell 网页抓取只能作为 fallback
69
- - 在导航和 snapshot 之前,shell detour 会被 workflow guard 拦住
70
-
71
- ### 交互等待反馈
106
+ ### 浏览器 workflow 规则
107
+
108
+ 在相关 skill 已加载且浏览器工具可用时:
109
+
110
+ - 自然语言网页任务优先走 browser capability 工具
111
+ - shell 网页抓取只能作为 fallback
112
+ - 在导航和 snapshot 之前,shell detour 会被 workflow guard 拦住
113
+
114
+ 这里的“浏览器工具”可以由 Playwright MCP 提供,也可以由别的 adapter 提供;上层规则只认 browser capability / browser step。
115
+
116
+ ### 文档 workflow 规则
117
+
118
+ 当 file introspection 或 tool recovery 指向专用文档能力时:
119
+
120
+ - 上层优先走 `document.read` / `spreadsheet.read` capability
121
+ - 文档 phase 推进只认 `document_read_completed` signal
122
+ - 不把 MinerU 名字继续塞进 acceptance / phase / route-change 主体
123
+
124
+ ### 交互等待反馈
72
125
 
73
126
  交互模式下,用户发出输入后、模型真正开始输出前,会显示短暂 spinner。
74
127
 
75
128
  它属于 UI 层,不参与 agent 状态机本身。
76
129
 
77
- ## 设计要求
78
-
79
- 1. loop 只保留全局调度规则。
80
- 2. 具体模块细节下沉到各自目录。
81
- 3. 新增长期能力时,优先接到 runtime state、tool priority workflow guard,而不是直接堆 prompt。
82
- 4. “应该结束”的判断必须落在机器层,不能只靠 prompt 提醒模型自觉收口。
130
+ ## 设计要求
131
+
132
+ 1. loop 只保留全局调度规则。
133
+ 2. 具体模块细节下沉到各自目录。
134
+ 3. static system prompt 只承载高层 operating contract,不重复 machine-enforced 的 workflow / verification / closeout 细则。
135
+ 4. 新增长期能力时,优先接到 runtime state、tool priority 或 workflow guard,而不是直接堆 prompt
136
+ 5. “应该结束”的判断必须落在机器层,不能只靠 prompt 提醒模型自觉收口。
137
+ 6. runtime 的关键转移原因必须可持久化、可测试、可区分,不能只留在 status 文本里。
138
+ 7. lead orchestrator 只消费 task lifecycle 这种派生控制面事实,不新增平行 orchestration 真相源。
139
+ 8. provider / browser / document 的生态差异可以停留在 adapter 层,但不能上浮成主循环规则。
@@ -1,60 +1,101 @@
1
1
  # 目录结构到代码文件映射表
2
2
 
3
- ## 当前主要目录
4
-
5
- - `src/agent/`: 主循环、prompt、continuation、verification、closeout
6
- - `src/agent/checkpoint/`: checkpoint 归一化、推导、resume 输入、prompt block
7
- - `src/agent/runtimeMetrics/`: runtime metrics 累积与 runtime summary
8
- - `src/tools/`: 模型可见工具与 handler
9
- - `src/skills/`: skill schema、discovery、matching、loading、workflow guard
3
+ ## 当前主要目录
4
+
5
+ - `src/agent/`: 主循环与稳定 façade
6
+ - `src/agent/provider.ts`: provider capability profile、request body 组装、provider fallback / recovery model 选择
7
+ - `src/agent/checkpoint/`: checkpoint 归一化、推导、resume 输入、prompt block
8
+ - `src/agent/context/`: request context 组装与压缩
9
+ - `src/agent/session/`: session message / todo / task state / session store 真相整理
10
+ - `src/agent/toolResults/`: tool result preview、transport 压缩、externalize 落盘
11
+ - `src/agent/turn/`: managed turn、closeout、finalize、tool execution、loop / recovery 辅助
12
+ - `src/agent/verification/`: verification state 与 lightweight / auto-readback signals
13
+ - `src/agent/acceptance/signals.ts`: acceptance signal 归一化
14
+ - `src/agent/runtimeMetrics/`: runtime metrics 累积与 runtime summary
15
+ - `src/tools/`: 模型可见工具与 handler
16
+ - `src/tools/governance.ts`: 工具治理 metadata、fail-closed 默认、result signal 校验
17
+ - `src/tools/routing.ts`: 文档 / spreadsheet 专用工具路由 hint
18
+ - `src/skills/`: skill schema、discovery、matching、loading、workflow guard
10
19
  - `src/mcp/`: MCP 总接入层
11
20
  - `src/mcp/playwright/`: Playwright MCP 配置、路径、artifact、调用归一化
12
21
  - `src/context/`: repo root、state root、AGENTS、skills、ignore 发现
13
22
  - `src/config/`: 配置读取、环境变量、runtime config、app paths
14
- - `src/tasks/`: 持久化 task 真相源
15
- - `src/team/`: teammate、消息、协议、policy
16
- - `src/background/`: 后台任务
17
- - `src/worktrees/`: 目录隔离
18
- - `src/subagent/`: 一次性子智能体
19
- - `src/interaction/`: 共享交互控制层与 shell 契约
20
- - `src/shell/cli/`: CLI shell 输入、输出、turn 展示、intro
23
+ - `src/tasks/`: 持久化 task 真相源
24
+ - `src/team/`: teammate、消息、协议、policy
25
+ - `src/background/`: 后台任务
26
+ - `src/worktrees/`: 目录隔离
27
+ - `src/orchestrator/`: lead 编排、任务图、lifecycle 派生、route / dispatch
28
+ - `src/subagent/`: 一次性子智能体
29
+ - `src/interaction/`: 共享交互控制层与 shell 契约
30
+ - `src/interaction/exitGuard.ts`: 交互退出前的后台进程检查与 kill-or-continue 语义
31
+ - `src/shell/cli/`: CLI shell 输入、输出、turn 展示、intro
21
32
  - `src/ui/`: CLI 文本格式化、runtime summary 和兼容导出
22
33
  - `src/telegram/`: Telegram 私聊通道、delivery、附件、CLI、process lock
23
34
  - `src/weixin/`: Weixin 私聊通道、OpeniLink client、delivery、context_token、CLI、process lock
24
35
 
25
- ## 当前 lightweight context 对应代码
26
-
27
- - `src/agent/promptSections.ts`: static / dynamic prompt layer
28
- - `src/agent/toolResultStorage.ts`: externalized tool result 落盘
29
- - `src/agent/toolResultPreview.ts`: tool payload 预览与 transport 压缩
30
- - `src/tools/files/toolResultArtifact.ts`: `.athlete/tool-results/...` 的紧凑 artifact read
31
- - `src/agent/contextBuilder.ts`: 使用轻量 payload 的请求上下文构建
32
-
33
- ## 当前 checkpoint / continuation 对应代码
34
-
35
- - `src/agent/checkpoint.ts`: checkpoint 对外导出面
36
- - `src/agent/checkpoint/base.ts`: checkpoint 默认结构与从 session 派生
37
- - `src/agent/checkpoint/state.ts`: checkpoint 归一化与生命周期更新
38
- - `src/agent/checkpoint/derivation.ts`: completedSteps / nextStep / artifact 推导
39
- - `src/agent/checkpoint/prompt.ts`: checkpoint 恢复输入与 prompt block
40
- - `src/agent/turnPersistence.ts`: turn 开始、yield、recovery、tool batch 的 session 持久化接线
41
- - `src/agent/managedTurn.ts`: continuation 输入通过 checkpoint 生成
42
-
43
- ## 当前 runtime metrics / 仪表盘 对应代码
44
-
45
- - `src/agent/runtimeMetrics.ts`: runtime metrics 对外导出面
46
- - `src/agent/runtimeMetrics/state.ts`: `runtimeStats` 归一化与事件累积
47
- - `src/agent/runtimeMetrics/summary.ts`: session runtime summary 生成
48
- - `src/agent/api.ts`: provider request timing 与 provider usage 采集
49
- - `src/agent/runTurn.ts`: tool execution、compression、recovery 等运行事件统计接线
50
- - `src/ui/runtimeSummary.ts`: 交互态 runtime summary 文本格式化
51
- - `src/interaction/localCommands.ts`: 共享本地命令语义与 `/runtime` / `/stats` / `/仪表盘` 路由
52
- - `src/ui/localCommands.ts`: CLI 默认输出适配与兼容导出
53
-
54
- ## 当前交互 shell 对应代码
55
-
56
- - `src/interaction/sessionDriver.ts`: 共享交互 session loop、multiline、interrupt、turn 生命周期
57
- - `src/interaction/shell.ts`: `InteractionShell` / `ShellInputPort` / `ShellOutputPort` / `InteractionTurnDisplay`
36
+ ## 当前 lightweight context 对应代码
37
+
38
+ - `src/agent/promptSections.ts`: prompt facade,对外保留 static / dynamic layer 入口
39
+ - `src/agent/prompt/static.ts`: 静态 operating contract 分块
40
+ - `src/agent/prompt/dynamic.ts`: 动态 runtime 摘要与空状态瘦身
41
+ - `src/agent/prompt/format.ts`: prompt block 渲染与 memory append
42
+ - `src/agent/prompt/structured.ts`: 结构化字段/摘要 section 到 prompt block 的统一渲染
43
+ - `src/agent/prompt/metrics.ts`: prompt layer char / block metrics
44
+ - `src/agent/prompt/requestDiagnostics.ts`: request-time prompt/context diagnostics
45
+ - `src/agent/prompt/types.ts`: prompt layer 类型
46
+ - `src/agent/context.ts`: context / tool-results cluster 入口
47
+ - `src/agent/context/builder.ts`: 使用轻量 payload 的请求上下文构建
48
+ - `src/agent/toolResults/storage.ts`: externalized tool result 落盘
49
+ - `src/agent/toolResults/preview.ts`: tool payload 预览与 transport 压缩
50
+ - `src/tools/files/toolResultArtifact.ts`: `.athlete/tool-results/...` 的紧凑 artifact read
51
+
52
+ ## 当前 checkpoint / continuation 对应代码
53
+
54
+ - `src/agent/checkpoint.ts`: checkpoint 对外导出面
55
+ - `src/agent/checkpoint/base.ts`: checkpoint 默认结构与从 session 派生
56
+ - `src/agent/checkpoint/state.ts`: checkpoint 归一化与生命周期更新
57
+ - `src/agent/checkpoint/transitions.ts`: checkpoint 上的 yield / recovery / pause / finalize 等转移落盘
58
+ - `src/agent/checkpoint/derivation.ts`: completedSteps / nextStep / artifact 推导
59
+ - `src/agent/checkpoint/prompt.ts`: checkpoint 恢复输入与 prompt block
60
+ - `src/agent/turn.ts`: turn cluster 入口
61
+ - `src/agent/turn/persistence.ts`: turn 开始、yield、recovery、tool batch 的 session 持久化接线
62
+ - `src/agent/turn/managed.ts`: continuation 输入通过 checkpoint 生成
63
+
64
+ ## 当前 runtime transition 对应代码
65
+
66
+ - `src/agent/runtimeTransition.ts`: runtime transition 对外导出面
67
+ - `src/agent/runtimeTransition/flow.ts`: transition 归一化、checkpoint flow 派生、phase 计算
68
+ - `src/agent/runtimeTransition/builders.ts`: continue / recover / yield / pause / finalize 的结构化 reason builder
69
+ - `src/agent/runtimeTransition/shared.ts`: transition 归一化共享辅助
70
+
71
+ ## 当前 runtime metrics / 仪表盘 对应代码
72
+
73
+ - `src/agent/runtimeMetrics.ts`: runtime metrics 对外导出面
74
+ - `src/agent/runtimeMetrics/state.ts`: `runtimeStats` 归一化与事件累积
75
+ - `src/agent/runtimeMetrics/summary.ts`: session runtime summary 生成
76
+ - `src/agent/runtimeMetrics/diagnostics.ts`: durable truth / derived diagnostics 拆分与解释生成
77
+ - `src/agent/api.ts`: provider request timing 与 provider usage 采集
78
+ - `src/agent/provider.ts`: provider-specific request body / fallback / recovery policy 下沉
79
+ - `src/agent/runTurn.ts`: tool execution、compression、recovery 等运行事件统计接线
80
+ - `src/ui/runtimeSummary.ts`: 交互态 runtime summary 文本格式化
81
+ - `src/ui/runtimeSummaryData.ts`: `/runtime` 命令的 request-time prompt diagnostics 组装
82
+ - `src/interaction/localCommands.ts`: 共享本地命令语义与 `/runtime` / `/stats` / `/仪表盘` 路由
83
+ - `src/ui/localCommands.ts`: CLI 默认输出适配与薄导出
84
+
85
+ ## 当前 session / task-state 对应代码
86
+
87
+ - `src/agent/session.ts`: session cluster 入口
88
+ - `src/agent/session/messages.ts`: stored message / chat message 归一化
89
+ - `src/agent/session/store.ts`: session 落盘与恢复
90
+ - `src/agent/session/taskState.ts`: session task-state 提取与 internal reminder
91
+ - `src/agent/session/taskStateHistory.ts`: 从消息历史派生活跃文件、计划动作、完成动作、blocker
92
+ - `src/agent/session/todos.ts`: todo 真相提取、格式化与 normalize
93
+
94
+ ## 当前交互 shell 对应代码
95
+
96
+ - `src/interaction/sessionDriver.ts`: 共享交互 session loop、multiline、interrupt、turn 生命周期
97
+ - `src/interaction/exitGuard.ts`: 交互退出时列出 background job / teammate worker,并执行 kill-or-continue 分支
98
+ - `src/interaction/shell.ts`: `InteractionShell` / `ShellInputPort` / `ShellOutputPort` / `InteractionTurnDisplay`
58
99
  - `src/shell/cli/readlineInput.ts`: CLI 输入适配
59
100
  - `src/shell/cli/output.ts`: CLI 文本输出适配
60
101
  - `src/shell/cli/turnDisplay.ts`: CLI spinner + stream renderer 适配
@@ -68,18 +109,46 @@
68
109
  - `src/mcp/playwright/config.ts`: Playwright MCP 配置归一化与 server args
69
110
  - `src/mcp/playwright/paths.ts`: `.athlete/playwright-mcp/` 路径约定
70
111
  - `src/mcp/playwright/artifacts.ts`: artifact 目录准备、迁移、生成配置
71
- - `src/mcp/playwright/invoke.ts`: relative filename 归一化
72
- - `src/mcp/stdioClient.ts`: 真实 stdio MCP client
73
- - `src/mcp/toolAdapter.ts`: MCP tool 适配进 Athlete registry
74
- - `src/tools/runtimeRegistry.ts`: runtime registry 组装 built-in tools 与 MCP tools
75
-
76
- ## 当前 closeout / verification 对应代码
77
-
78
- - `src/agent/finalize.ts`: tool-less turn 的最终收口与 verification / pause 行为
79
- - `src/agent/closeout.ts`: closeout 阶段的工具过滤与 stale todo 容忍规则
80
- - `src/agent/verificationState.ts`: verification 真相源
81
- - `src/agent/verificationSignals.ts`: lightweight verification signals auto-readback
82
- - `src/agent/runTurn.ts`: 调度这些规则,但不持有它们的内部实现细节
112
+ - `src/mcp/playwright/invoke.ts`: relative filename 归一化
113
+ - `src/mcp/stdioClient.ts`: 真实 stdio MCP client
114
+ - `src/mcp/toolAdapter.ts`: MCP tool 适配进 Athlete registry,并补充治理所需 origin 信息
115
+ - `src/tools/runtimeRegistry.ts`: runtime registry 组装 built-in tools 与 MCP tools,并保留 blocked diagnostics
116
+ - `src/tools/registry.ts`: fail-closed tool registry、entries / blocked 暴露面与 result governance 校验
117
+
118
+ ## 当前 closeout / verification 对应代码
119
+
120
+ - `src/agent/turn.ts`: closeout / finalize cluster 入口
121
+ - `src/agent/turn/finalize.ts`: tool-less turn 的最终收口与 verification / pause 行为
122
+ - `src/agent/turn/closeout.ts`: closeout 阶段的工具过滤与 stale todo 容忍规则
123
+ - `src/agent/verification.ts`: verification cluster 入口
124
+ - `src/agent/verification/state.ts`: verification 真相源
125
+ - `src/agent/verification/signals.ts`: lightweight verification signals 与 auto-readback
126
+ - `src/agent/acceptance/signals.ts`: `http_endpoint_verified` / `web_page_verified` / `document_read_completed` / `structured_artifact_valid`
127
+ - `src/cli/support.ts`: one-shot closeout report 生成
128
+ - `src/cli.ts`: one-shot terminal closeout JSON 输出
129
+ - `src/agent/runTurn.ts`: 调度这些规则,但不持有它们的内部实现细节
130
+
131
+ ## 当前 turn / loop 辅助代码
132
+
133
+ - `src/agent/turn.ts`: turn / loop helper cluster 入口
134
+ - `src/agent/turn/recovery.ts`: API 重试、content-policy redaction、context shrink
135
+ - `src/agent/turn/planGate.ts`: mutating tool 的 todo 前置约束
136
+ - `src/agent/turn/loopGuard.ts`: 重复工具调用保护
137
+ - `src/agent/turn/toolExecutor.ts`: tool 执行与 recovery hint
138
+ - `src/agent/turn/toolless.ts`: 缺 skill / finalize 收口分发
139
+ - `src/agent/turn/state.ts`: request 内 turn 状态 prompt block 与进度提示
140
+
141
+ ## 当前任务编排 / lifecycle 对应代码
142
+
143
+ - `src/orchestrator/prepareLeadTurn.ts`: lead slice 开始前的 orchestrator 入口
144
+ - `src/orchestrator/analyze.ts`: objective / complexity / handoff 意图判断
145
+ - `src/orchestrator/taskPlanning.ts`: 最小任务图落盘
146
+ - `src/orchestrator/taskLifecycle.ts`: 从 task / team / background / worktree 真相源派生 task lifecycle
147
+ - `src/orchestrator/taskLifecycleShared.ts`: lifecycle 构造与 handoff 共享辅助
148
+ - `src/orchestrator/progress.ts`: 读取 durable truth 并构造 progress snapshot
149
+ - `src/orchestrator/route.ts`: 只消费 lifecycle 后的 ready / active / blocked 事实做 route
150
+ - `src/orchestrator/dispatch.ts`: 派工落盘与 fail-closed handoff 检查
151
+ - `src/tools/tasks/claimTaskTool.ts`: teammate claim + worktree fail-closed 入口
83
152
 
84
153
  ## 当前文档 / 验证位置
85
154
 
@@ -88,13 +157,19 @@
88
157
  - `spec/modules/lightweight-context-runtime.md`
89
158
  - `spec/modules/session-resume-compact.md`
90
159
  - `spec/modules/runtime-metrics.md`
91
- - `tests/playwright-mcp.test.ts`
92
- - `tests/browser-tool-priority.test.ts`
93
- - `tests/playwright-workflow-guard.test.ts`
94
- - `tests/agent-closeout.test.ts`
95
- - `tests/runtime-lightweight-context.test.ts`
96
- - `tests/runtime-checkpoint-resume.test.ts`
97
- - `tests/runtime-observability.test.ts`
160
+ - `tests/playwright-mcp.test.ts`
161
+ - `tests/browser-tool-priority.test.ts`
162
+ - `tests/playwright-workflow-guard.test.ts`
163
+ - `tests/browser-workflow-abstraction.test.ts`
164
+ - `tests/agent-closeout.test.ts`
165
+ - `tests/interaction-shell.test.ts`
166
+ - `tests/provider-capability.test.ts`
167
+ - `tests/document-workflow-abstraction.test.ts`
168
+ - `tests/acceptance-signal.test.ts`
169
+ - `tests/one-shot-cli-result-contract.test.ts`
170
+ - `tests/runtime-lightweight-context.test.ts`
171
+ - `tests/runtime-checkpoint-resume.test.ts`
172
+ - `tests/runtime-observability.test.ts`
98
173
  - `scripts/verify-runtime-lightweight-context-api.mjs`
99
174
  - `scripts/verify-runtime-checkpoint-api.mjs`
100
175
  - `scripts/verify-runtime-observability-api.mjs`
@@ -18,15 +18,16 @@
18
18
 
19
19
  ### 当前契约语义
20
20
 
21
- #### `ShellInputPort`
21
+ #### `ShellInputPort`
22
22
 
23
23
  负责:
24
24
 
25
25
  - 读取普通输入
26
26
  - 读取 multiline 输入
27
- - 绑定 interrupt 事件
28
-
29
- 不负责:
27
+ - 绑定 interrupt 事件
28
+ - 为共享 driver 提供退出确认时所需的普通输入
29
+
30
+ 不负责:
30
31
 
31
32
  - 决定 task / runtime 真相
32
33
  - 自己执行 agent turn
@@ -51,9 +52,16 @@
51
52
  - 展示流式 assistant / reasoning / tool 状态
52
53
  - 在 turn 结束或中断时 flush / dispose
53
54
 
54
- #### `InteractionShell`
55
-
56
- 负责把上面三部分组装给共享 driver 使用。
55
+ #### `InteractionShell`
56
+
57
+ 负责把上面三部分组装给共享 driver 使用。
58
+
59
+ 共享 driver 可以基于这套输入/输出契约实现:
60
+
61
+ - 普通命令输入
62
+ - multiline 输入
63
+ - interrupt
64
+ - quit 前二次确认
57
65
 
58
66
  ## 当前 CLI 实现
59
67