@wnlen/agent-execution-template 0.8.18 → 0.8.20

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.
@@ -1,16 +1,13 @@
1
1
  # AI 上下文整合
2
2
 
3
3
  不要总结这个文件。
4
- 执行下面的上下文整合流程。
5
-
6
- 你正在把新的权威资料吸收到现有 Agent Execution Template 项目上下文中。
7
- 这不是重新引导,也不是全量覆盖。
4
+ 按下面流程把新权威资料吸收到现有项目上下文。不是重新引导,也不是全量覆盖。
8
5
 
9
6
  目标:合并新资料中的长期有效事实,修正过期或不准确的旧上下文,保留仍然正确的既有内容。
10
7
 
11
8
  ## 适用场景
12
9
 
13
- 当项目已经使用一段时间后,出现更完整、更权威的业务、产品、架构或流程资料时,使用本流程。
10
+ 当出现更完整、更权威的业务、产品、架构或流程资料时,使用本流程。
14
11
 
15
12
  新资料默认放在:
16
13
 
@@ -18,10 +15,10 @@
18
15
  - `ai/project/inbox/raw/*.md`
19
16
  - `docs/**`
20
17
 
21
- `ai/project/inbox/` 是待吸收资料区。资料被整合确认后,统一移动到
22
- `ai/project/inbox/processed/`,用于追溯并避免后续重复整合。
23
- 即使用户说“整合整个 inbox”,默认也只处理 `ai/project/inbox/*.md`
24
- `ai/project/inbox/raw/*.md`;不要递归读取 `processed/**` 或 `ideas/**`。
18
+ `ai/project/inbox/` 是待吸收区。资料确认整合后移到 `ai/project/inbox/processed/`,
19
+ 用于追溯并避免重复整合。即使用户说“整合整个 inbox”,也默认只处理
20
+ `ai/project/inbox/*.md` `ai/project/inbox/raw/*.md`;不要递归读取
21
+ `processed/**` 或 `ideas/**`。
25
22
 
26
23
  ## 先读
27
24
 
@@ -33,13 +30,13 @@
33
30
  6. 人类指定的新资料;未指定时,只读取 `ai/project/inbox/*.md`
34
31
  和 `ai/project/inbox/raw/*.md`
35
32
 
36
- 不要默认读取 `ai/project/inbox/processed/**`、`ai/project/inbox/ideas/**`、
37
- `ai/project/archive/**`、源码、测试、配置或依赖文件,除非人类明确要求用它们核对事实。
33
+ 不要默认读取 `processed/**`、`ideas/**`、`archive/**`、源码、测试、配置或依赖;
34
+ 除非人类明确要求用它们核对事实。
38
35
 
39
36
  ## 整合原则
40
37
 
41
- - 不要直接覆盖整套文件。
42
- - 保留仍然正确的既有上下文。
38
+ - 不整套覆盖。
39
+ - 保留仍正确的既有上下文。
43
40
  - 将新资料拆分进合适位置:
44
41
  - 项目身份、用户、稳定约定 -> `ai/project/project.md`
45
42
  - 当前仍有效的执行上下文 -> `ai/project/runtime.md`
@@ -50,10 +47,9 @@
50
47
  - 命令 -> `ai/project/refs/commands.md`
51
48
  - 约束 -> `ai/project/refs/constraints.md`
52
49
  - 持久决策 -> `ai/project/refs/decisions.md`
53
- - 不要把 `refs/*` 写成原文堆砌;只吸收结构化、长期有效、可复用的内容。
54
- - 如果新资料会改变北极星、模块地图或路线图的方向性内容,只能建议创建
55
- `strategy_update` 提案,不要在上下文整合中直接修改这些方向文件。
56
- - `task.md`、`result.json`、`result.md`、`metrics.json` 通常不参与业务上下文整合,除非人类明确要求吸收其中仍长期有效的事实。
50
+ - `refs/*` 不堆原文;只吸收结构化、长期有效、可复用的内容。
51
+ - 新资料若改变北极星、模块地图或路线图,只建议创建 `strategy_update`,不要直接改方向文件。
52
+ - `task.md`、`result.json`、`result.md`、`metrics.json` 通常不参与整合;除非人类明确要求吸收其中的长期事实。
57
53
 
58
54
  ## 两阶段流程
59
55
 
@@ -70,13 +66,11 @@
70
66
  5. 需要人类确认的问题,最多 3 个
71
67
  6. 预计会更新的文件
72
68
 
73
- 如果没有需要确认的问题,明确写“无需额外确认”。
74
-
75
- 阶段 1 结束时必须停止,等待人类确认。
69
+ 无问题时写“无需额外确认”。阶段 1 结束必须停止,等待确认。
76
70
 
77
71
  ### 阶段 2:应用整合
78
72
 
79
- 只有在人类明确确认整合计划后,才更新文件。
73
+ 只有人类确认整合计划后才更新文件。
80
74
 
81
75
  允许更新:
82
76
 
@@ -97,15 +91,14 @@
97
91
  - `ai/project/metrics.json`
98
92
  - `ai/project/archive/**`
99
93
 
100
- 应用整合完成后,必须把本次已整合的 `ai/project/inbox/*.md` 和
101
- `ai/project/inbox/raw/*.md` 资料移动到 `ai/project/inbox/processed/`。保留相对路径:
102
- `ai/project/inbox/raw/file.md` 移动到 `ai/project/inbox/processed/raw/file.md`。
103
- 如果文件名冲突,保留原文件名并添加日期或序号。不要移动
104
- `ai/project/inbox/ideas/**`;方向灵感应继续走 `strategy_update`。
94
+ 整合完成后,把本次已整合的 `ai/project/inbox/*.md` 和 `ai/project/inbox/raw/*.md`
95
+ 移到 `ai/project/inbox/processed/`,保留相对路径:`ai/project/inbox/raw/file.md` ->
96
+ `ai/project/inbox/processed/raw/file.md`。文件名冲突时加日期或序号。不要移动 `ideas/**`;
97
+ 方向灵感继续走 `strategy_update`。
105
98
 
106
99
  ## 最终交接
107
100
 
108
- 应用整合后,最终回复必须包含:
101
+ 应用后,最终回复包含:
109
102
 
110
103
  ```text
111
104
  上下文整合已完成。
@@ -142,4 +135,4 @@
142
135
  - 修正:<你要改的地方>
143
136
  ```
144
137
 
145
- 不要让人类自己去文件管理器里寻找变化;文件路径只作为可追溯记录。
138
+ 不要让人类自己找变化;文件路径只作追溯。
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## 就绪门
4
4
 
5
- 编辑代码前,检查 `ai/project/task.md` 是否清楚定义:
5
+ 编辑前,确认 `ai/project/task.md` 已清楚定义:
6
6
 
7
7
  - 目标
8
8
  - 范围
@@ -18,8 +18,8 @@
18
18
 
19
19
  ## 引导门
20
20
 
21
- 如果 `ai/project/project.md` 为空、只有占位内容、不完整,或用户要求整理项目上下文,
22
- 先执行 `ai/template/bootstrap.md`,再进入执行。
21
+ `ai/project/project.md` 为空、占位、不完整,或用户要求整理上下文,先执行
22
+ `ai/template/bootstrap.md`。
23
23
 
24
24
  引导模式只能写项目上下文文件:
25
25
 
@@ -32,14 +32,13 @@
32
32
  - `ai/project/refs/constraints.md`
33
33
  - `ai/project/refs/decisions.md`
34
34
 
35
- 只有在人类同时提供当前任务目标时,引导模式才可以写 `ai/project/task.md`。
36
- 此时只能起草任务契约,不能进入实现。
35
+ 只有人类同时提供当前任务目标时,引导模式才可写 `ai/project/task.md`;只能起草,不实现。
37
36
 
38
- 引导模式不得编辑源码、测试、配置、依赖文件、生成文件、运行时文件、结果文件或指标文件。
37
+ 引导模式不得编辑源码、测试、配置、依赖、生成文件、运行时、结果或指标文件。
39
38
 
40
39
  写完引导草稿后,使用 `ai/template/bootstrap.md` 中的“引导后交接”停止。
41
40
  交接必须在聊天里给出可确认摘要和推荐下一步,不要只让人类打开文件检查。
42
- 如果人类已经提供当前任务目标,可以同轮起草 `ai/project/task.md`,但仍必须停止等待确认,不能进入实现。
41
+ 若人类已提供任务目标,可同轮起草 `task.md`,但仍必须停止确认,不能实现。
43
42
 
44
43
  ## 引导读取范围
45
44
 
@@ -60,9 +59,8 @@
60
59
 
61
60
  ## 任务草稿门
62
61
 
63
- 如果项目上下文已确认,但 `ai/project/task.md` 为空、只有占位内容、不完整,
64
- 或人类提供了新的任务目标,根据已确认的项目上下文起草 `ai/project/task.md`,
65
- 并在实现前停止等待人类确认。
62
+ 项目上下文已确认但 `task.md` 为空、占位、不完整,或人类提供新任务目标时,
63
+ 按已确认上下文起草 `task.md`,实现前停止确认。
66
64
 
67
65
  任务草稿模式只能写:
68
66
 
@@ -72,8 +70,8 @@
72
70
 
73
71
  ## 上下文整合门
74
72
 
75
- 如果用户提供新的权威业务、产品、架构或流程资料,并希望合并到既有上下文,
76
- 或说“整合 ai/project/inbox/ 里的新资料”,执行 `ai/template/reconcile.md`,
73
+ 用户提供新权威业务、产品、架构或流程资料并希望合并,或说
74
+ “整合 ai/project/inbox/ 里的新资料”时,执行 `ai/template/reconcile.md`。
77
75
  不要重新 bootstrap,也不要全量覆盖。
78
76
 
79
77
  新资料优先放在:
@@ -84,7 +82,7 @@
84
82
 
85
83
  已整合资料统一移动到 `ai/project/inbox/processed/`,默认不再触发上下文整合。
86
84
 
87
- 上下文整合必须先输出整合计划,等待人类确认后才更新文件。
85
+ 上下文整合必须先给计划,等确认后再更新文件。
88
86
 
89
87
  上下文整合默认只能更新:
90
88
 
@@ -92,8 +90,7 @@
92
90
  - `ai/project/runtime.md`
93
91
  - `ai/project/refs/*.md`
94
92
 
95
- 如果新资料会改变北极星、模块地图或路线图的方向性内容,只能建议创建
96
- `strategy_update` 提案,不能在上下文整合中直接修改:
93
+ 新资料若改变北极星、模块地图或路线图,只能建议创建 `strategy_update`,不能直接改:
97
94
 
98
95
  - `ai/project/refs/final-shape.md`
99
96
  - `ai/project/refs/module-map.md`
@@ -103,27 +100,32 @@
103
100
 
104
101
  ## 边界内连续执行门
105
102
 
106
- 每次执行前,AI 必须读取 `ai/template/execution-policy.md`,先做任务分解和风险判断,
107
- 而不是等待用户显式说“启用连续执行”。
103
+ 每次执行前,AI 必须读取 `ai/template/execution-policy.md`,先分解任务并判断风险,
104
+ 不等用户说“启用连续执行”。
108
105
 
109
106
  硬门禁:
110
107
 
108
+ - 只有 `task.md.readiness = ready_to_execute` 才能执行;本轮新建或重写 `task.md` 时必须停下确认。
109
+ - L1 必须是可独立验收的垂直切片,不是机械步骤清单。
111
110
  - `execution_policy.task_tree` 必须记录 L1 清单和执行状态。
112
111
  - 每个任务节点必须有 Green / Yellow / Red 风险评级。
112
+ - Yellow 只允许当前 L1/L2 内的局部低风险修正,不能改变公共接口、数据模型、
113
+ 权限、安全、架构方向或验收标准。
113
114
  - 每个 Checkpoint 必须包含证据;不接受只有主观判断的 Green。
114
115
  - Red 必须停止等待人类确认。
115
- - 任何方向、核心架构、数据结构、安全、支付、账号、权限、大量删除、
116
- 核心重写或高成本方案取舍,都必须停止。
116
+ - 涉及方向、核心架构、公共 API、持久化数据、安全、支付、账号、权限、大量删除、
117
+ 核心重写或高成本取舍时,必须停止。
117
118
  - 需要扩大范围、权限、命令、网络或验收时,必须停止。
119
+ - `task_tree` 写回应集中在 L1 开始/完成、Red、blocked、范围变化和最终收尾,
120
+ 不要为每个微小 L3 操作写回。
118
121
 
119
122
  目标、范围、验收和权限由 AI 推断,但不能越过项目规则、显式用户限制、
120
123
  `permission.modify.denied`、安全边界或破坏性操作限制。
121
124
 
122
125
  ## 策略修订门
123
126
 
124
- 如果用户要求更新项目北极星、最终形态、产品宪法、模块地图、路线图或项目方向,
125
- `ai/project/inbox/ideas/` 中存在 `.gitkeep` 之外的新灵感,执行
126
- `strategy_update`。
127
+ 用户要求更新北极星、最终形态、产品宪法、模块地图、路线图或项目方向,或
128
+ `ai/project/inbox/ideas/` 有新灵感时,执行 `strategy_update`。
127
129
 
128
130
  `strategy_update` 只能:
129
131
 
@@ -25,7 +25,9 @@
25
25
 
26
26
  ## 结果 Markdown
27
27
 
28
- `ai/project/result.md` 是给人看的摘要。保持简短:
28
+ `ai/project/result.md` 是给人看的摘要。保持简短,并默认使用 `ai/template/LANG`
29
+ 指定的安装语言。中文模板下,标题和说明默认用中文;代码、命令、文件路径和协议字段
30
+ 保留原文。
29
31
 
30
32
  ```md
31
33
  ## 状态
package/test/selftest.js CHANGED
@@ -54,6 +54,8 @@ function testInitUpdateDoctor() {
54
54
  assert(exists(cwd, "ai/template/execution-policy.md"), "init should create execution policy prompt");
55
55
  assert(exists(cwd, "ai/template/prompt.md"), "init should create template prompt");
56
56
  assert(exists(cwd, "ai/template/reconcile.md"), "init should create template reconcile prompt");
57
+ assert(exists(cwd, "ai/template/schemas/result.schema.json"), "init should create result schema");
58
+ assert(exists(cwd, "ai/template/schemas/metrics.schema.json"), "init should create metrics schema");
57
59
  assert(exists(cwd, "ai/project/inbox/.gitkeep"), "init should create inbox directory");
58
60
  assert(exists(cwd, "ai/project/project.md"), "init should create project.md");
59
61
  assert(exists(cwd, "ai/project/task.md"), "init should create task.md");
@@ -81,16 +83,29 @@ function testInitUpdateDoctor() {
81
83
  assert(read(cwd, "ai/template/prompt.md").includes("ai/template/execution-policy.md"), "execution prompt should read execution policy");
82
84
  assert(read(cwd, "ai/template/execution-policy.md").includes("风险分级"), "execution policy should include risk rubric");
83
85
  assert(read(cwd, "ai/template/execution-policy.md").includes("execution_policy.task_tree"), "execution policy should require task tree persistence");
84
- assert(read(cwd, "ai/template/prompt.md").includes("默认也只处理 `ai/project/inbox/*.md`"), "execution prompt should narrow inbox reconciliation");
86
+ assert(read(cwd, "ai/template/prompt.md").includes("也默认只处理 `ai/project/inbox/*.md`"), "execution prompt should narrow inbox reconciliation");
85
87
  assert(read(cwd, "ai/template/protocol.md").includes("`bounded_continuous`"), "protocol should include bounded continuous execution");
86
88
  assert(read(cwd, "ai/template/execution-policy.md").includes("垂直切片"), "protocol should require vertical-slice progress for continuous execution");
89
+ assert(read(cwd, "ai/template/execution-policy.md").includes("可独立验收的垂直切片"), "execution policy should define L1 granularity");
90
+ assert(read(cwd, "ai/template/execution-policy.md").includes("不能边写草稿边执行"), "execution policy should block execution from draft tasks");
91
+ assert(read(cwd, "ai/template/execution-policy.md").includes("不要为每个微小 L3 操作写回"), "execution policy should limit task tree write-back churn");
92
+ assert(read(cwd, "ai/template/execution-policy.md").includes("公共接口、数据模型、权限、安全"), "execution policy should constrain Yellow corrections");
93
+ assert(read(cwd, "ai/template/execution-policy.md").includes("用户可见输出"), "execution policy should define user-visible output rules");
94
+ assert(read(cwd, "ai/template/execution-policy.md").includes("用户可见的计划"), "execution policy should keep user-visible planning in the installed language");
95
+ assert(read(cwd, "ai/template/rules/output.md").includes("默认使用 `ai/template/LANG`"), "output rules should keep human-readable results in the installed language");
96
+ assert(read(cwd, "ai/template/execution-policy.md").includes("不要默认展示完整 L2/L3/L4"), "execution policy should avoid exposing full subtask trees by default");
97
+ assert(read(cwd, "ai/template/execution-policy.md").includes("不要展示内部协议字段"), "execution policy should hide internal protocol details by default");
87
98
  assert(read(cwd, "ai/template/execution-policy.md").includes("L1 为 2 个或更多,自动启用"), "protocol should auto-enable continuous execution from L1 count");
88
99
  assert(read(cwd, "ai/template/execution-policy.md").includes("每个 Checkpoint 必须包含"), "protocol should require evidence-backed checkpoints");
89
100
  assert(read(cwd, "ai/template/rules/core.md").includes("边界内连续执行门"), "core rules should include bounded continuous execution gate");
101
+ assert(read(cwd, "ai/template/rules/core.md").includes("readiness = ready_to_execute"), "core rules should require ready task before execution");
102
+ assert(read(cwd, "ai/template/rules/core.md").includes("不是机械步骤清单"), "core rules should reject mechanical L1 task lists");
90
103
  assert(read(cwd, "ai/template/rules/core.md").includes("需要扩大范围、权限、命令、网络或验收时"), "core rules should stop continuous execution before boundary expansion");
91
104
  assert(read(cwd, "ai/project/task.md").includes("execution_policy:"), "task template should include execution policy");
92
105
  assert(read(cwd, "ai/project/task.md").includes("readiness:"), "task template should include readiness state");
93
106
  assert(read(cwd, "ai/project/task.md").includes("activation_rule: \"auto_enable_when_l1_count_gte_2\""), "task template should define automatic activation rule");
107
+ assert(read(cwd, "ai/project/task.md").includes("l1_granularity: \"independently_acceptable_vertical_slice\""), "task template should define L1 granularity");
108
+ assert(read(cwd, "ai/project/task.md").includes("write_back_policy: \"l1_start_done_red_blocked_scope_change_final\""), "task template should define task tree write-back policy");
94
109
  assert(read(cwd, "ai/project/task.md").includes("risk_gate:"), "task template should define risk gate");
95
110
  assert(read(cwd, "ai/project/task.md").includes("status: \"pending | running | done | blocked\""), "task template should define task tree node status");
96
111
  assert(read(cwd, "ai/project/task.md").includes("progress_unit: \"vertical_slice\""), "task template should define continuous progress unit");
@@ -99,10 +114,12 @@ function testInitUpdateDoctor() {
99
114
  assert(read(cwd, "ai/template/prompt.md").includes("不要重新 bootstrap"), "execution prompt should reconcile inbox material when project context already exists");
100
115
  assert(read(cwd, "ai/template/prompt.md").includes("整合 ai/project/inbox/ 里的新资料"), "execution prompt should route natural reconcile entry");
101
116
  assert(read(cwd, "ai/template/prompt.md").includes("继续推进这个项目"), "execution prompt should route natural continue entry");
117
+ assert(read(cwd, "ai/template/prompt.md").includes("草稿不能直接执行"), "execution prompt should stop after drafting a task");
118
+ assert(read(cwd, "ai/template/prompt.md").includes("用户可见输出"), "execution prompt should reference user-visible output rules");
102
119
  assert(read(cwd, "ai/template/prompt.md").includes("strategy_update"), "execution prompt should route strategy updates");
103
120
  assert(read(cwd, "ai/template/reconcile.md").includes("上下文整合"), "init should install reconcile prompt");
104
121
  assert(read(cwd, "ai/template/reconcile.md").includes("整合计划"), "reconcile prompt should require a plan first");
105
- assert(read(cwd, "ai/template/reconcile.md").includes("不要递归读取 `processed/**` 或 `ideas/**`"), "reconcile prompt should exclude processed and ideas recursively");
122
+ assert(read(cwd, "ai/template/reconcile.md").includes("不要递归读取") && read(cwd, "ai/template/reconcile.md").includes("`processed/**` 或 `ideas/**`"), "reconcile prompt should exclude processed and ideas recursively");
106
123
  assert(read(cwd, "ai/template/reconcile.md").includes("ai/project/inbox/processed/raw/file.md"), "reconcile prompt should archive absorbed raw inbox material");
107
124
  assert(read(cwd, "ai/template/reconcile.md").includes("未吸收资料"), "reconcile handoff should audit unabsorbed material");
108
125
  assert(read(cwd, "ai/template/reconcile.md").includes("冲突处理"), "reconcile handoff should audit conflict handling");
@@ -140,7 +157,9 @@ function testInitUpdateDoctor() {
140
157
 
141
158
  const doctorOutput = run(["doctor"], cwd);
142
159
  assert(doctorOutput.includes("ai/project/result.json JSON"), "doctor should validate result JSON");
160
+ assert(doctorOutput.includes("ai/project/result.json schema"), "doctor should validate result schema");
143
161
  assert(doctorOutput.includes("ai/project/metrics.json JSON"), "doctor should validate metrics JSON");
162
+ assert(doctorOutput.includes("ai/project/metrics.json schema"), "doctor should validate metrics schema");
144
163
  assert(doctorOutput.includes("ai/project/task.md front matter"), "doctor should validate task front matter");
145
164
  }
146
165
 
@@ -150,6 +169,8 @@ function testEnglishInitUpdateDoctor() {
150
169
  const initOutput = run(["init", "--lang", "en"], cwd);
151
170
  assert(read(cwd, "ai/template/LANG") === "en\n", "init --lang en should install English template");
152
171
  assert(exists(cwd, "ai/template/execution-policy.md"), "English init should create execution policy prompt");
172
+ assert(exists(cwd, "ai/template/schemas/result.schema.json"), "English init should create result schema");
173
+ assert(exists(cwd, "ai/template/schemas/metrics.schema.json"), "English init should create metrics schema");
153
174
  assert(read(cwd, "ai/template/bootstrap.md").includes("Confirmation Dimensions"), "English init should install English bootstrap prompt");
154
175
  assert(read(cwd, "ai/template/bootstrap.md").includes("Do not summarize this file"), "English bootstrap prompt should prevent summary-only behavior");
155
176
  assert(read(cwd, "ai/template/bootstrap.md").includes("ai/project/refs/final-shape.md"), "English bootstrap prompt should initialize the North Star");
@@ -168,13 +189,26 @@ function testEnglishInitUpdateDoctor() {
168
189
  assert(read(cwd, "ai/template/prompt.md").includes("default to only `ai/project/inbox/*.md`"), "English execution prompt should narrow inbox reconciliation");
169
190
  assert(read(cwd, "ai/template/protocol.md").includes("`bounded_continuous`"), "English protocol should include bounded continuous execution");
170
191
  assert(read(cwd, "ai/template/execution-policy.md").includes("vertical"), "English protocol should require vertical-slice progress for continuous execution");
192
+ assert(read(cwd, "ai/template/execution-policy.md").includes("independently acceptable vertical slice"), "English execution policy should define L1 granularity");
193
+ assert(read(cwd, "ai/template/execution-policy.md").includes("executing from a draft"), "English execution policy should block execution from draft tasks");
194
+ assert(read(cwd, "ai/template/execution-policy.md").includes("every tiny L3 operation"), "English execution policy should limit task tree write-back churn");
195
+ assert(read(cwd, "ai/template/execution-policy.md").includes("public interfaces, data models, permissions"), "English execution policy should constrain Yellow corrections");
196
+ assert(read(cwd, "ai/template/execution-policy.md").includes("User-Visible Output"), "English execution policy should define user-visible output rules");
197
+ assert(read(cwd, "ai/template/execution-policy.md").includes("user-visible plans"), "English execution policy should keep user-visible planning in the installed language");
198
+ assert(read(cwd, "ai/template/rules/output.md").includes("installed language from `ai/template/LANG`"), "English output rules should keep human-readable results in the installed language");
199
+ assert(read(cwd, "ai/template/execution-policy.md").includes("do not show full L2/L3/L4 by default"), "English execution policy should avoid exposing full subtask trees by default");
200
+ assert(read(cwd, "ai/template/execution-policy.md").includes("do not show internal protocol fields"), "English execution policy should hide internal protocol details by default");
171
201
  assert(read(cwd, "ai/template/execution-policy.md").includes("Automatically use `bounded_continuous`"), "English protocol should auto-enable continuous execution from L1 count");
172
202
  assert(read(cwd, "ai/template/execution-policy.md").includes("Every checkpoint must include"), "English protocol should require evidence-backed checkpoints");
173
203
  assert(read(cwd, "ai/template/rules/core.md").includes("Bounded Continuous Execution Gate"), "English core rules should include bounded continuous execution gate");
204
+ assert(read(cwd, "ai/template/rules/core.md").includes("readiness = ready_to_execute"), "English core rules should require ready task before execution");
205
+ assert(read(cwd, "ai/template/rules/core.md").includes("not a mechanical step"), "English core rules should reject mechanical L1 task lists");
174
206
  assert(read(cwd, "ai/template/rules/core.md").includes("expand scope, permission, commands, network access, or acceptance"), "English core rules should stop continuous execution before boundary expansion");
175
207
  assert(read(cwd, "ai/project/task.md").includes("execution_policy:"), "English task template should include execution policy");
176
208
  assert(read(cwd, "ai/project/task.md").includes("readiness:"), "English task template should include readiness state");
177
209
  assert(read(cwd, "ai/project/task.md").includes("activation_rule: \"auto_enable_when_l1_count_gte_2\""), "English task template should define automatic activation rule");
210
+ assert(read(cwd, "ai/project/task.md").includes("l1_granularity: \"independently_acceptable_vertical_slice\""), "English task template should define L1 granularity");
211
+ assert(read(cwd, "ai/project/task.md").includes("write_back_policy: \"l1_start_done_red_blocked_scope_change_final\""), "English task template should define task tree write-back policy");
178
212
  assert(read(cwd, "ai/project/task.md").includes("risk_gate:"), "English task template should define risk gate");
179
213
  assert(read(cwd, "ai/project/task.md").includes("status: \"pending | running | done | blocked\""), "English task template should define task tree node status");
180
214
  assert(read(cwd, "ai/project/task.md").includes("progress_unit: \"vertical_slice\""), "English task template should define continuous progress unit");
@@ -182,6 +216,8 @@ function testEnglishInitUpdateDoctor() {
182
216
  assert(read(cwd, "ai/template/prompt.md").includes("instead of bootstrapping again"), "English execution prompt should reconcile inbox material when project context already exists");
183
217
  assert(read(cwd, "ai/template/prompt.md").includes("Reconcile the new material in ai/project/inbox/"), "English execution prompt should route natural reconcile entry");
184
218
  assert(read(cwd, "ai/template/prompt.md").includes("Continue this project"), "English execution prompt should route natural continue entry");
219
+ assert(read(cwd, "ai/template/prompt.md").includes("do not execute while the\n task is still a draft"), "English execution prompt should stop after drafting a task");
220
+ assert(read(cwd, "ai/template/prompt.md").includes("User-Visible Output"), "English execution prompt should reference user-visible output rules");
185
221
  assert(read(cwd, "ai/template/prompt.md").includes("strategy_update"), "English execution prompt should route strategy updates");
186
222
  assert(exists(cwd, "ai/project/refs/final-shape.md"), "English init should create project North Star");
187
223
  assert(exists(cwd, "ai/project/refs/module-map.md"), "English init should create module map");
@@ -215,6 +251,7 @@ function testEnglishInitUpdateDoctor() {
215
251
  const doctorOutput = run(["doctor"], cwd);
216
252
  assert(doctorOutput.includes("Template language: en"), "doctor should show installed English language");
217
253
  assert(doctorOutput.includes("ai/project/result.json JSON"), "English doctor should validate result JSON");
254
+ assert(doctorOutput.includes("ai/project/result.json schema"), "English doctor should validate result schema");
218
255
  assert(doctorOutput.includes("ai/project/task.md front matter"), "English doctor should validate task front matter");
219
256
  assert(doctorOutput.includes("[OK] Ready to run"), "doctor should use installed English language");
220
257
  const reconcileOutput = run(["reconcile"], cwd);
@@ -245,6 +282,60 @@ function testDoctorFailureAndWarning() {
245
282
  const invalidJsonOutput = run(["doctor"], invalidJsonCwd, 1);
246
283
  assert(invalidJsonOutput.includes("JSON 无效"), "doctor should fail invalid result JSON");
247
284
 
285
+ const invalidResultSchemaCwd = createTempProject("agent-execution-template-invalid-result-schema");
286
+ run(["init"], invalidResultSchemaCwd);
287
+ write(invalidResultSchemaCwd, "ai/project/result.json", JSON.stringify({
288
+ protocol_version: "0.8",
289
+ status: "success",
290
+ scope_followed: true,
291
+ files_read: [],
292
+ refs_read: [],
293
+ files_changed: [],
294
+ commands_run: [],
295
+ verification: {
296
+ level: "none",
297
+ passed: false,
298
+ evidence: []
299
+ },
300
+ assumptions: [],
301
+ issues: [],
302
+ next: [],
303
+ runtime_update: {
304
+ required: false,
305
+ changes: [],
306
+ reason: ""
307
+ }
308
+ }, null, 2));
309
+ const invalidResultSchemaOutput = run(["doctor"], invalidResultSchemaCwd, 1);
310
+ assert(invalidResultSchemaOutput.includes("不符合协议 schema"), "doctor should fail result schema violations");
311
+ assert(invalidResultSchemaOutput.includes("$.verification.passed must be true"), "doctor should enforce success verification");
312
+
313
+ const invalidMetricsSchemaCwd = createTempProject("agent-execution-template-invalid-metrics-schema");
314
+ run(["init"], invalidMetricsSchemaCwd);
315
+ write(invalidMetricsSchemaCwd, "ai/project/metrics.json", JSON.stringify({
316
+ protocol_version: "0.8",
317
+ task_id: "",
318
+ task_type: "",
319
+ model: "",
320
+ model_tier: "cheap",
321
+ escalated: true,
322
+ escalation_reason: "",
323
+ model_policy_followed: true,
324
+ escalation_trigger_hit: "",
325
+ strong_model_role: "",
326
+ input_tokens_estimated: 0,
327
+ output_tokens_estimated: 0,
328
+ duration_minutes: 0,
329
+ success: false,
330
+ human_fix_required: false,
331
+ failure_reason: "",
332
+ reuse_potential: "low",
333
+ notes: []
334
+ }, null, 2));
335
+ const invalidMetricsSchemaOutput = run(["doctor"], invalidMetricsSchemaCwd, 1);
336
+ assert(invalidMetricsSchemaOutput.includes("不符合协议 schema"), "doctor should fail metrics schema violations");
337
+ assert(invalidMetricsSchemaOutput.includes("$.escalation_reason must have length >= 1"), "doctor should enforce escalated metrics details");
338
+
248
339
  const taskWarnCwd = createTempProject("agent-execution-template-task-frontmatter");
249
340
  run(["init"], taskWarnCwd);
250
341
  write(taskWarnCwd, "ai/project/task.md", "# Task only\n");