@wnlen/agent-execution-template 0.8.18 → 0.8.19

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.
package/README.md CHANGED
@@ -161,7 +161,8 @@ The user can still give a natural-language goal, for example:
161
161
  Build the settings page with profile editing, notification toggles, and export entrypoint
162
162
  ```
163
163
 
164
- Before execution, the AI decomposes L1 tasks:
164
+ Before execution, the AI decomposes L1 tasks. Each L1 must be an independently
165
+ acceptable vertical slice, not a mechanical step checklist:
165
166
 
166
167
  ```text
167
168
  - [ ] L1-1 Profile editing Green
@@ -171,12 +172,19 @@ Before execution, the AI decomposes L1 tasks:
171
172
 
172
173
  Because there are two or more L1 tasks, the protocol automatically uses bounded
173
174
  continuous execution. Before each L1, the AI plans naturally derived L2/L3 work.
174
- After completing an L1, it checks and strikes the item, then writes status back
175
- to `execution_policy.task_tree` in `ai/project/task.md`.
175
+ After completing an L1, it checks and strikes the item. `task_tree` is written
176
+ back only at L1 start/done, Red/blocked, scope changes, or final wrap-up, so tiny
177
+ steps do not churn files.
176
178
 
177
179
  Only Red risk stops for confirmation. Green continues automatically, and Yellow
178
- continues after local low-risk correction. Every checkpoint must include
179
- evidence: changed files, commands run, and verification results.
180
+ only permits local low-risk correction inside the current L1/L2; it must not
181
+ change public interfaces, data models, permissions, security, architecture
182
+ direction, or acceptance. By default, users see L1, risk conclusions, evidence,
183
+ Red confirmations, and final results; internal protocol details are not shown.
184
+
185
+ If the AI just created or rewrote `ai/project/task.md` in the current run, it
186
+ must stop for confirmation. Execution is allowed only when an existing task is
187
+ explicitly `ready_to_execute`.
180
188
 
181
189
  ## Installed Layout
182
190
 
package/README.zh-CN.md CHANGED
@@ -171,7 +171,7 @@ npx -y @wnlen/agent-execution-template strategy
171
171
  实现设置页,包括资料编辑、通知开关和导出入口
172
172
  ```
173
173
 
174
- AI 会在执行前先拆 L1 任务:
174
+ AI 会在执行前先拆 L1 任务。L1 必须是可独立验收的垂直切片,不是机械步骤清单:
175
175
 
176
176
  ```text
177
177
  - [ ] L1-1 资料编辑 Green
@@ -180,11 +180,15 @@ AI 会在执行前先拆 L1 任务:
180
180
  ```
181
181
 
182
182
  因为 L1 有两个以上,协议会自动使用边界内连续执行。执行每个 L1 前,AI 再规划
183
- 自然衍生的 L2/L3;完成一个 L1 后,在清单中打勾并划掉,同时把状态写回
184
- `ai/project/task.md` 的 `execution_policy.task_tree`。
183
+ 自然衍生的 L2/L3;完成一个 L1 后,在清单中打勾并划掉。`task_tree` 只在
184
+ L1 开始/完成、Red/blocked、范围变化或最终收尾时写回,避免为微小步骤反复改文件。
185
185
 
186
- 只有 Red 风险会停下来让你确认。Green 自动继续,Yellow 只做局部低风险修正后继续。
187
- 每个 Checkpoint 都必须带证据:改了哪些文件、跑了哪些命令、验证结果是什么。
186
+ 只有 Red 风险会停下来让你确认。Green 自动继续,Yellow 只允许当前 L1/L2 内的
187
+ 局部低风险修正,不能改变公共接口、数据模型、权限、安全、架构方向或验收标准。
188
+ 用户默认只看 L1、风险结论、证据、Red 确认和最终结果;内部协议细节不默认展示。
189
+
190
+ 如果 AI 本轮刚新建或重写了 `ai/project/task.md`,必须先停下来交接确认;
191
+ 只有已有任务明确处于 `ready_to_execute` 时,才允许进入执行。
188
192
 
189
193
  ## 安装后的结构
190
194
 
package/docs/SPEC.md CHANGED
@@ -22,7 +22,7 @@ npx 安装协议 -> AI 整理项目上下文 -> 人类确认 -> AI 生成任务
22
22
 
23
23
  ```text
24
24
  Protocol: v0.8
25
- Package: @wnlen/agent-execution-template@0.8.18
25
+ Package: @wnlen/agent-execution-template@0.8.19
26
26
  中文安装: npx -y @wnlen/agent-execution-template init
27
27
  英文安装: npx -y @wnlen/agent-execution-template init --lang en
28
28
  ```
@@ -392,7 +392,7 @@ npx -y @wnlen/agent-execution-template doctor
392
392
  ```text
393
393
  Agent Execution Template 检查
394
394
 
395
- 模板版本: 0.8.18
395
+ 模板版本: 0.8.19
396
396
  模板语言: zh
397
397
 
398
398
  [通过] ai/template/LANG
@@ -664,7 +664,10 @@ ai/template/execution-policy.md
664
664
  执行前规划:
665
665
 
666
666
  - AI 根据用户目标、项目上下文和仓库事实推断目标、范围、验收、权限和验证方式;
667
+ - 只有 `ai/project/task.md.readiness = ready_to_execute` 时才进入执行;本轮新建或重写
668
+ `task.md` 时必须停在确认交接;
667
669
  - 先列 L1 任务清单,并给每个 L1 标注 Green / Yellow / Red;
670
+ - L1 必须是可独立验收的垂直切片,不是机械步骤清单;
668
671
  - L1 少于 2 个时使用 `normal`;
669
672
  - L1 为 2 个或更多时自动使用 `bounded_continuous`;
670
673
  - 任一 L1 为 Red 时停止等待人类确认;Green 和 Yellow 不阻塞启动。
@@ -675,16 +678,20 @@ ai/template/execution-policy.md
675
678
  - 默认最多 3 层,只有当 L3 仍过大、不可验证或不可回退时才动态增加 L4;
676
679
  - 每个任务节点必须有风险评级、预期改动范围、验收方式和证据要求;
677
680
  - L1 清单必须用待办列表展示,每完成一个 L1 就打勾并划掉;
678
- - 执行前和执行中必须把任务树写回 `ai/project/task.md.execution_policy.task_tree`;
681
+ - `task_tree` 写回应集中在执行前、L1 开始/完成、Red、blocked、范围变化和最终收尾;
679
682
  - 默认按 `vertical_slice` 推进,每轮都要产生可检查增量;
683
+ - Checkpoint 只在风险从 Green 变 Yellow/Red、即将扩大范围或权限、完成 L1 垂直切片、
684
+ 验证失败后准备继续或最终收尾时输出;
680
685
  - 每个 Checkpoint 必须包含证据:已改文件、已运行命令、验证结果或无法验证原因;
681
686
  - Green 可自动继续;
682
- - Yellow 做局部低风险修正后继续;
687
+ - Yellow 只允许当前 L1/L2 内的局部低风险修正,不能改变公共接口、数据模型、权限、
688
+ 安全、架构方向或验收标准;
683
689
  - Red 必须停止等待人类确认;
690
+ - 用户可见输出默认只展示 L1、风险结论、证据、Red 确认和最终结果,不展示内部协议细节;
684
691
  - 目标、范围、验收和权限由 AI 推断,但不能越过项目规则、显式用户限制、
685
692
  `permission.modify.denied`、安全边界或破坏性操作限制;
686
- - 需要扩大权限、运行未允许命令、访问网络、执行破坏性操作、改变产品方向或核心架构时,
687
- 当前节点必须标为 Red。
693
+ - 需要扩大权限、运行未允许命令、访问网络、执行破坏性操作、改变产品方向、核心架构、
694
+ 公共 API、持久化数据结构、安全边界、支付、账号或权限时,当前节点必须标为 Red。
688
695
 
689
696
  它不适用于方向未定且无法推断、验收无法定义或高风险架构取舍任务;这些应直接评为 Red。
690
697
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wnlen/agent-execution-template",
3
- "version": "0.8.18",
3
+ "version": "0.8.19",
4
4
  "description": "Low-friction AI execution protocol template for coding agents.",
5
5
  "bin": {
6
6
  "agent-execution-template": "bin/agent-execution-template.js"
@@ -11,6 +11,8 @@ execution_policy:
11
11
  max_depth: 3
12
12
  allow_depth_4_when_needed: true
13
13
  progress_unit: "vertical_slice"
14
+ l1_granularity: "independently_acceptable_vertical_slice"
15
+ write_back_policy: "l1_start_done_red_blocked_scope_change_final"
14
16
  task_tree:
15
17
  - id: "L1-1"
16
18
  title: ""
@@ -86,6 +88,9 @@ permissions, and acceptance from the human goal, project context, and repository
86
88
  facts. If inference would cross permission or safety boundaries, or acceptance
87
89
  cannot be defined, set `readiness` to `blocked` or mark the relevant task node
88
90
  `Red` and wait for human confirmation.
91
+ If this run creates or rewrites the task contract, keep
92
+ `readiness = draft_for_confirmation` by default and stop at the handoff. Enter
93
+ execution only when an existing task is explicitly `ready_to_execute`.
89
94
 
90
95
  ## Goal
91
96
 
@@ -143,26 +148,36 @@ fewer than 2 L1 tasks, use `normal`; if it finds 2 or more L1 tasks, use
143
148
  before execution.
144
149
  - `readiness = blocked` means the task cannot execute and must produce a
145
150
  blocked result.
151
+ - If this run creates or rewrites `ai/project/task.md`, stop at the confirmation
152
+ handoff; do not execute while the task is still a draft.
146
153
  - Before execution, write the L1 checklist to `execution_policy.task_tree`.
147
154
  - Before execution, list the L1 task checklist; mark each L1 complete with a
148
155
  checked and struck-through item.
156
+ - Each L1 must be an independently acceptable vertical slice. Do not split a
157
+ single mechanical step into L1 tasks, and do not merge multiple independently
158
+ acceptable user-visible outcomes into one L1.
149
159
  - Before executing an L1, plan the naturally derived L2 tasks; if an L2 still
150
160
  needs decomposition, plan L3 tasks.
151
161
  - Default to at most 3 levels; add L4 dynamically only when leaving it out
152
162
  would make L3 too large or unverifiable.
153
163
  - The AI assigns Green / Yellow / Red risk to every task node.
154
164
  - Only Red stops for human confirmation; Green continues automatically, and
155
- Yellow continues after local low-risk correction.
165
+ Yellow only permits local low-risk correction inside the current L1/L2. It
166
+ must not change public interfaces, data models, permissions, security,
167
+ architecture direction, or acceptance.
156
168
  - `progress_unit` defaults to `vertical_slice`: each work loop should produce
157
169
  a reviewable increment.
158
170
  - `checkpoint_budget` is the maximum checkpoint budget, not a required count;
159
171
  do not report just to spend the budget.
160
- - Emit a checkpoint only when `checkpoint_triggers` fire, risk rises, or final
161
- review is about to start.
172
+ - Emit checkpoints only when risk changes from Green to Yellow/Red, scope or
173
+ permission is about to expand, an L1 vertical slice is complete, verification
174
+ failed but execution is about to continue, or final wrap-up is about to start.
162
175
  - Every checkpoint must include evidence: changed files, commands run,
163
176
  verification results, or why verification was not possible.
164
- - During execution, update `task_tree` node status: `pending`, `running`,
165
- `done`, or `blocked`.
177
+ - `task_tree` write-back frequency: write the L1 checklist before execution;
178
+ update an L1 when it starts or completes; write back immediately on Red,
179
+ blocked, scope change, or final wrap-up; do not write back every tiny L3
180
+ operation.
166
181
  - After completion, run one final review; only re-check Yellow, Red, failed
167
182
  verification, or high-impact modules.
168
183
  - Continuous execution does not change model policy; escalate through
@@ -192,7 +207,8 @@ Stop and write `ai/project/result.json`, `ai/project/result.md`, and `ai/project
192
207
  - Required command cannot be run.
193
208
  - Risk level is high without explicit authorization.
194
209
  - A Red checkpoint appears during continuous execution.
195
- - The task would change product direction, core architecture, data structures,
196
- security boundaries, payment, accounts, or permissions.
197
- - The task would delete many files, rewrite a core module, or require choosing
198
- between multiple high-cost options.
210
+ - The task would change product direction, core architecture, public API,
211
+ persistent data structures, security boundaries, payment, accounts, or
212
+ permissions.
213
+ - The task would delete files beyond the current L1's directly related files,
214
+ rewrite a core module, or require choosing between multiple high-cost options.
@@ -1 +1 @@
1
- 0.8.18
1
+ 0.8.19
@@ -13,7 +13,13 @@ Pre-execution planning must:
13
13
 
14
14
  - Infer goal, scope, acceptance, permissions, and verification method from the
15
15
  human goal, project context, and repository facts.
16
+ - Enter execution only when `ai/project/task.md` already exists and
17
+ `readiness = ready_to_execute`. If this run creates or rewrites the task
18
+ contract, stop at the confirmation handoff instead of executing from a draft.
16
19
  - List the L1 task checklist and assign Green / Yellow / Red risk to each L1.
20
+ - Each L1 must be an independently acceptable vertical slice. Do not split a
21
+ single mechanical step into L1 tasks, and do not merge multiple independently
22
+ acceptable user-visible outcomes into one L1.
17
23
  - Use `normal` if there are fewer than 2 L1 tasks.
18
24
  - Automatically use `bounded_continuous` if there are 2 or more L1 tasks.
19
25
  - Stop for human confirmation first if any L1 is Red; Green and Yellow do not
@@ -24,6 +30,10 @@ Pre-execution planning must:
24
30
 
25
31
  Execute the task tree in L1 -> L2 -> L3 order.
26
32
 
33
+ - L1 is a work increment that can be verified, rolled back, and explained to the
34
+ user after completion.
35
+ - L2 is an implementation substep needed to finish that L1.
36
+ - L3 is a local operation step used when an L2 is still too large.
27
37
  - Before executing an L1, plan its naturally derived L2 tasks.
28
38
  - Before executing an L2, plan L3 tasks if it still needs decomposition.
29
39
  - Default to at most 3 levels. Add L4 dynamically only when L3 would otherwise
@@ -32,8 +42,11 @@ Execute the task tree in L1 -> L2 -> L3 order.
32
42
  and evidence requirements.
33
43
  - Show the L1 checklist as task items; when an L1 is complete, check it off and
34
44
  strike it through.
35
- - During execution, update each `task_tree` node status: `pending`, `running`,
36
- `done`, or `blocked`.
45
+ - Task tree write-back rule: write the L1 checklist before execution; update an
46
+ L1 when it starts or completes; write back immediately on Red, blocked, scope
47
+ change, or final wrap-up. Do not write back every tiny L3 operation.
48
+ - During execution, use `pending`, `running`, `done`, or `blocked` for node
49
+ status.
37
50
 
38
51
  Recommended node shape:
39
52
 
@@ -65,16 +78,19 @@ Yellow:
65
78
  - Still inside current task scope;
66
79
  - local uncertainty or local verification failure exists;
67
80
  - a low-risk local correction can continue the work;
68
- - no permission, scope, command, or acceptance expansion is needed.
81
+ - the correction affects only the current L1/L2 local implementation and does
82
+ not change public interfaces, data models, permissions, security,
83
+ architecture direction, or acceptance;
84
+ - no permission, scope, command, network, or acceptance expansion is needed.
69
85
 
70
86
  Red:
71
87
 
72
88
  - Permission expansion, unallowed command, network access, or destructive action
73
89
  is needed;
74
- - product direction, core architecture, data structure, security boundary,
75
- payment, account, or permission would change;
76
- - many files must be deleted, a core module must be rewritten, or multiple
77
- high-cost options require judgment;
90
+ - product direction, core architecture, public APIs, persistent data structures,
91
+ security boundary, payment, account, or permission would change;
92
+ - files beyond the current L1's directly related files must be deleted, a core
93
+ module must be rewritten, or multiple high-cost options require judgment;
78
94
  - acceptance cannot be defined, or task goal materially conflicts with project direction.
79
95
 
80
96
  Only Red stops for human confirmation. Green continues automatically. Yellow
@@ -82,9 +98,10 @@ continues after local low-risk correction.
82
98
 
83
99
  ## Checkpoint
84
100
 
85
- Emit checkpoints only when risk rises, a boundary is about to change, a vertical
86
- slice is complete, or final review is about to start. Do not report just to
87
- spend checkpoint budget.
101
+ Emit checkpoints only when risk changes from Green to Yellow/Red, scope or
102
+ permission is about to expand, an L1 vertical slice is complete, verification
103
+ failed but execution is about to continue, or final review is about to start.
104
+ Do not report just to spend checkpoint budget.
88
105
 
89
106
  Every checkpoint must include:
90
107
 
@@ -102,6 +119,17 @@ Every checkpoint must include:
102
119
  Evidence must include changed files, commands run, verification results, or why
103
120
  verification was not possible. A purely subjective Green is not valid.
104
121
 
122
+ ## User-Visible Output
123
+
124
+ - Show the L1 checklist by default; do not show full L2/L3/L4 by default.
125
+ - Show risk conclusions and necessary reasons; do not output long internal reasoning.
126
+ - Show evidence; do not show internal protocol fields, full YAML,
127
+ `checkpoint_budget`, or `model_policy`.
128
+ - Say little for Green, be brief for Yellow, and stop with clear reasons and
129
+ options for Red.
130
+ - Final output must include status, completed items, verification results, and
131
+ result files.
132
+
105
133
  ## Model Policy
106
134
 
107
135
  Continuous execution does not change `model_policy`. Still escalate through
@@ -69,12 +69,12 @@ In Task Draft Mode:
69
69
  and write it to `execution_policy.task_tree`. Use `normal` if there are
70
70
  fewer than 2 L1 tasks; automatically use `bounded_continuous` if there are 2
71
71
  or more L1 tasks.
72
- 5. If no Red preflight item exists, set `readiness` to `ready_to_execute`; if
73
- human confirmation is needed, set it to `draft_for_confirmation`; if the task
74
- cannot execute, set it to `blocked`.
75
- 6. Stop for human confirmation only when a Red preflight item appears. If the
76
- human asked to execute or continue, and preflight contains only Green /
77
- Yellow, proceed directly to Execution Mode.
72
+ 5. If this run creates or rewrites `ai/project/task.md`, set `readiness` to
73
+ `draft_for_confirmation` and stop at the handoff; do not execute while the
74
+ task is still a draft.
75
+ 6. Enter Execution Mode only when an existing task is explicitly
76
+ `ready_to_execute` and no Red preflight item exists; if it cannot execute,
77
+ set it to `blocked`.
78
78
  7. Do not modify source or business files in Task Draft Mode.
79
79
 
80
80
  End Task Draft Mode with:
@@ -129,12 +129,17 @@ In Execution Mode, read:
129
129
  Then follow `ai/template/execution-policy.md` for pre-execution planning: list
130
130
  the L1 checklist, mark each L1 Green / Yellow / Red, and write it to
131
131
  `execution_policy.task_tree`. Automatically choose `normal` or
132
- `bounded_continuous` from the L1 count. Plan L2 before executing an L1, and
133
- plan L3 as needed before executing an L2; default to at most 3 levels, with L4
134
- allowed when needed. When an L1 is complete, check it off, strike it through,
135
- and update the `task_tree` node status. Only Red stops for human confirmation;
136
- Green continues automatically, and Yellow continues after local low-risk
137
- correction. Write results to:
132
+ `bounded_continuous` from the L1 count. Execute only when
133
+ `readiness = ready_to_execute`; if this run creates or rewrites the task
134
+ contract, stop at the confirmation handoff. Each L1 must be an independently
135
+ acceptable vertical slice. Plan L2 before executing an L1, and plan L3 as needed
136
+ before executing an L2; default to at most 3 levels, with L4 allowed when
137
+ needed. When an L1 is complete, check it off and strike it through; write back
138
+ `task_tree` when an L1 starts or completes, on Red/blocked, on scope change, or
139
+ at final wrap-up. Only Red stops for human confirmation; Green continues
140
+ automatically, and Yellow only permits local low-risk correction inside the
141
+ current L1/L2. User-visible output follows the "User-Visible Output" rules in
142
+ `ai/template/execution-policy.md`. Write results to:
138
143
 
139
144
  - `ai/project/result.json`
140
145
  - `ai/project/result.md`
@@ -54,11 +54,15 @@ Before task execution, read `ai/template/execution-policy.md`.
54
54
  The default execution policy is `auto`: the AI first decomposes L1 tasks and
55
55
  judges Green / Yellow / Red risk, then chooses `normal` or `bounded_continuous`.
56
56
  Use `normal` when there are fewer than 2 L1 tasks; automatically use
57
- `bounded_continuous` when there are 2 or more L1 tasks. Only Red stops for
58
- human confirmation.
59
-
60
- Task tree, risk rubric, checkpoint evidence, and `task_tree` status update
61
- rules are defined in `ai/template/execution-policy.md`.
57
+ `bounded_continuous` when there are 2 or more L1 tasks. Each L1 must be an
58
+ independently acceptable vertical slice. Execution is allowed only for an
59
+ existing task with `readiness = ready_to_execute`; if this run creates or
60
+ rewrites the task contract, stop at the confirmation handoff. Only Red stops for
61
+ human confirmation, and Yellow only permits local low-risk correction inside the
62
+ current L1/L2.
63
+
64
+ Task tree, risk rubric, checkpoint evidence, and `task_tree` write-back rules
65
+ are defined in `ai/template/execution-policy.md`.
62
66
 
63
67
  ## Bootstrap Mode
64
68
 
@@ -125,15 +125,24 @@ explicitly say "enable continuous execution".
125
125
 
126
126
  Hard gates:
127
127
 
128
+ - Execute only when `ai/project/task.md.readiness = ready_to_execute`; if this
129
+ run creates or rewrites `task.md`, stop at the confirmation handoff.
130
+ - L1 must be an independently acceptable vertical slice, not a mechanical step
131
+ checklist.
128
132
  - `execution_policy.task_tree` must record the L1 checklist and execution state.
129
133
  - Every task node must have Green / Yellow / Red risk.
134
+ - Yellow only permits local low-risk correction inside the current L1/L2. It
135
+ must not change public interfaces, data models, permissions, security,
136
+ architecture direction, or acceptance.
130
137
  - Every checkpoint must include evidence; a purely subjective Green is not valid.
131
138
  - Red must stop for human confirmation.
132
- - Any product direction, core architecture, data structure, security, payment,
133
- account, permission, large deletion, core rewrite, or high-cost option choice
134
- must stop.
139
+ - Any product direction, core architecture, public API, persistent data
140
+ structure, security, payment, account, permission, large deletion, core
141
+ rewrite, or high-cost option choice must stop.
135
142
  - Any need to expand scope, permission, commands, network access, or acceptance
136
143
  must stop.
144
+ - `task_tree` write-back should happen at L1 start/done, Red, blocked, scope
145
+ change, and final wrap-up; do not write back every tiny L3 operation.
137
146
 
138
147
  The AI infers goal, scope, acceptance, and permissions, but must not cross
139
148
  project rules, explicit human limits, `permission.modify.denied`, security
@@ -11,6 +11,8 @@ execution_policy:
11
11
  max_depth: 3
12
12
  allow_depth_4_when_needed: true
13
13
  progress_unit: "vertical_slice"
14
+ l1_granularity: "independently_acceptable_vertical_slice"
15
+ write_back_policy: "l1_start_done_red_blocked_scope_change_final"
14
16
  task_tree:
15
17
  - id: "L1-1"
16
18
  title: ""
@@ -83,6 +85,8 @@ permission:
83
85
  优先使用安全假设,少问额外问题。AI 应基于用户目标、项目上下文和仓库事实推断
84
86
  范围、风险、权限和验收;如果推断会越过权限、安全边界或验收无法定义,将
85
87
  `readiness` 标为 `blocked` 或将相关任务节点标为 `Red`,等待人类确认。
88
+ 如果本轮新建或重写了任务契约,默认保持 `draft_for_confirmation` 并停下来交接;
89
+ 只有已有任务明确处于 `ready_to_execute` 时,才进入执行。
86
90
 
87
91
  ## 目标
88
92
 
@@ -132,17 +136,23 @@ permission:
132
136
  - `readiness = ready_to_execute` 表示没有 Red 预检项,可以执行。
133
137
  - `readiness = draft_for_confirmation` 表示需要人类确认后才能执行。
134
138
  - `readiness = blocked` 表示当前任务不可执行,必须写 blocked 结果。
139
+ - 本轮如果新建或重写 `ai/project/task.md`,必须停在确认交接;不能在任务仍是草稿时执行。
135
140
  - 执行前必须把 L1 任务清单写入 `execution_policy.task_tree`。
136
141
  - 执行前必须列出 L1 任务清单;每个 L1 用待办列表表示,完成后打勾并划掉。
142
+ - L1 必须是可独立验收的垂直切片;不要把单个机械步骤拆成 L1,也不要把多个
143
+ 可独立验收的用户可见结果合并成一个 L1。
137
144
  - 执行某个 L1 前,AI 先规划自然衍生出的 L2;如果 L2 仍需拆分,再规划 L3。
138
145
  - 默认最多 3 层;只有当不拆 L4 会导致 L3 过大或不可验证时,才允许动态增加 L4。
139
146
  - 每个任务节点都由 AI 自己生成 Green / Yellow / Red 风险评级。
140
- - 只有 Red 停下来让人类确认;Green 自动继续,Yellow 先做局部低风险修正后继续。
147
+ - 只有 Red 停下来让人类确认;Green 自动继续,Yellow 只允许当前 L1/L2 内的局部
148
+ 低风险修正,不能改变公共接口、数据模型、权限、安全、架构方向或验收标准。
141
149
  - `progress_unit` 默认是 `vertical_slice`:每轮推进都应该产生可检查的工作增量。
142
150
  - `checkpoint_budget` 是最多可用检查点预算,不是必须用完的次数;不要为了消耗预算而汇报。
143
- - 只有在触发 `checkpoint_triggers`、风险升高或准备收尾时才输出 Checkpoint。
151
+ - 只有在风险从 Green 变 Yellow/Red、即将扩大范围或权限、完成 L1 垂直切片、
152
+ 验证失败后准备继续、准备最终收尾时才输出 Checkpoint。
144
153
  - 每个 Checkpoint 必须包含证据:已改文件、已运行命令、验证结果或无法验证的原因。
145
- - 执行中必须更新 `task_tree` 节点状态:`pending`、`running`、`done` `blocked`。
154
+ - `task_tree` 写回频率:执行前写入 L1 清单;开始或完成 L1 时更新该 L1 状态;
155
+ 出现 Red、blocked、范围变化或最终收尾时立即写回;不要为每个微小 L3 操作写回。
146
156
  - 完成后只做一次总复盘;只对 Yellow、Red、失败验证或高影响模块做二次抽检。
147
157
  - 连续执行不改变模型策略;涉及判断、架构、失败复盘或验收争议时仍按 `model_policy` 升级。
148
158
 
@@ -170,5 +180,5 @@ permission:
170
180
  - 必需命令无法运行。
171
181
  - 风险等级高但没有明确授权。
172
182
  - 连续执行中出现 Red 检查点。
173
- - 需要改变产品方向、核心架构、数据结构、安全边界、支付、账号或权限。
174
- - 需要删除大量文件、重写核心模块,或在多个高成本方案之间取舍。
183
+ - 需要改变产品方向、核心架构、公共 API、持久化数据结构、安全边界、支付、账号或权限。
184
+ - 需要删除超过当前 L1 直接相关的文件、重写核心模块,或在多个高成本方案之间取舍。
@@ -1 +1 @@
1
- 0.8.18
1
+ 0.8.19
@@ -11,7 +11,11 @@
11
11
  执行前规划必须:
12
12
 
13
13
  - 根据用户目标、项目上下文和仓库事实,推断目标、范围、验收、权限和验证方式。
14
+ - 只有 `ai/project/task.md` 已存在且 `readiness = ready_to_execute` 时才进入执行。
15
+ 如果本轮新建或重写任务契约,必须先停在确认交接,不能边写草稿边执行。
14
16
  - 列出 L1 任务清单,并为每个 L1 生成 Green / Yellow / Red 风险评级。
17
+ - L1 必须是可独立验收的垂直切片;不要把单个机械步骤拆成 L1,也不要把多个
18
+ 可独立验收的用户可见结果合并成一个 L1。
15
19
  - 如果 L1 少于 2 个,使用 `normal`。
16
20
  - 如果 L1 为 2 个或更多,自动启用 `bounded_continuous`。
17
21
  - 如果任一 L1 为 Red,先停止并让人类确认;Green 和 Yellow 不阻塞启动。
@@ -21,12 +25,17 @@
21
25
 
22
26
  任务树按 L1 -> L2 -> L3 执行。
23
27
 
28
+ - L1 表示一个完成后可验证、可回退、可向用户解释的工作增量。
29
+ - L2 表示完成该 L1 所需的实现子步骤。
30
+ - L3 表示 L2 仍过大时的局部操作步骤。
24
31
  - 执行某个 L1 前,先规划它自然衍生出的 L2。
25
32
  - 执行某个 L2 前,如果仍需拆分,再规划 L3。
26
33
  - 默认最多 3 层。只有当 L3 仍过大、不可验证或不可回退时,才动态增加 L4。
27
34
  - L1/L2/L3/L4 都必须有风险评级、预期改动范围、验收方式和证据要求。
28
35
  - L1 清单必须用待办列表展示;每完成一个 L1,就打勾并划掉。
29
- - 执行中必须更新 `task_tree` 节点状态:`pending`、`running`、`done` `blocked`。
36
+ - 任务树写回规则:执行前写入 L1 清单;开始或完成 L1 时更新该 L1 状态;
37
+ 出现 Red、blocked、范围变化或最终收尾时立即写回。不要为每个微小 L3 操作写回。
38
+ - 执行中使用 `pending`、`running`、`done` 或 `blocked` 表示节点状态。
30
39
 
31
40
  推荐节点结构:
32
41
 
@@ -57,20 +66,24 @@ Yellow:
57
66
  - 仍在当前任务范围内;
58
67
  - 存在局部不确定或局部验证失败;
59
68
  - 可以用低风险修正继续;
60
- - 不需要扩大权限、范围、命令或验收。
69
+ - 修正只影响当前 L1/L2 的局部实现,不改变公共接口、数据模型、权限、安全、
70
+ 架构方向或验收标准;
71
+ - 不需要扩大权限、范围、命令、网络或验收。
61
72
 
62
73
  Red:
63
74
 
64
75
  - 需要扩大权限、运行未允许命令、访问网络或执行破坏性操作;
65
- - 需要改变产品方向、核心架构、数据结构、安全边界、支付、账号或权限;
66
- - 需要删除大量文件、重写核心模块或在多个高成本方案之间取舍;
76
+ - 需要改变产品方向、核心架构、公共 API、持久化数据结构、安全边界、支付、
77
+ 账号或权限;
78
+ - 需要删除超过当前 L1 直接相关的文件、重写核心模块或在多个高成本方案之间取舍;
67
79
  - 验收不可定义,或任务目标和项目方向发生实质冲突。
68
80
 
69
81
  只有 Red 停止等待人类确认。Green 自动继续。Yellow 做局部低风险修正后继续。
70
82
 
71
83
  ## Checkpoint
72
84
 
73
- Checkpoint 只在风险升高、边界即将变化、完成垂直切片或准备收尾时输出。
85
+ Checkpoint 只在以下情况输出:风险从 Green 变 Yellow/Red、即将扩大范围或权限、
86
+ 完成一个 L1 垂直切片、验证失败后准备继续、准备最终收尾。
74
87
  不要为了消耗预算而汇报。
75
88
 
76
89
  每个 Checkpoint 必须包含:
@@ -89,6 +102,14 @@ Checkpoint 只在风险升高、边界即将变化、完成垂直切片或准备
89
102
  证据必须包含已改文件、已运行命令、验证结果,或无法验证的原因。
90
103
  不接受只有主观判断的 Green。
91
104
 
105
+ ## 用户可见输出
106
+
107
+ - 默认展示 L1 清单;不要默认展示完整 L2/L3/L4。
108
+ - 展示风险结论和必要原因;不要输出长篇内部推理。
109
+ - 展示证据;不要展示内部协议字段、完整 YAML、`checkpoint_budget` 或 `model_policy`。
110
+ - Green 少说,Yellow 简说,Red 停下并说明原因和选项。
111
+ - 最终必须给状态、完成项、验证结果和结果文件。
112
+
92
113
  ## 模型策略
93
114
 
94
115
  连续执行不改变 `model_policy`。遇到规划、架构、失败复盘或验收争议,
@@ -55,10 +55,10 @@
55
55
  4. 执行前列出 L1 任务清单并标注 Green / Yellow / Red,同时写入
56
56
  `execution_policy.task_tree`。L1 少于 2 个时使用 `normal`;L1 为 2 个或更多时
57
57
  自动使用 `bounded_continuous`。
58
- 5. 如果没有 Red 预检项,将 `readiness` 设为 `ready_to_execute`;如果需要人类确认,
59
- 设为 `draft_for_confirmation`;如果不可执行,设为 `blocked`。
60
- 6. 只有出现 Red 预检项时才停止等待人类确认。若用户要求的是执行或继续,且预检
61
- 只有 Green / Yellow,可以直接进入执行模式。
58
+ 5. 本轮如果新建或重写了 `ai/project/task.md`,将 `readiness` 设为
59
+ `draft_for_confirmation` 并停止交接;不要在任务仍是草稿时直接执行。
60
+ 6. 只有已有任务明确处于 `ready_to_execute`,且没有 Red 预检项时,才能进入执行模式;
61
+ 如果不可执行,设为 `blocked`。
62
62
  7. 不要在任务草稿模式中修改源码或业务文件。
63
63
 
64
64
  任务草稿模式必须以下面结构结束:
@@ -110,10 +110,13 @@
110
110
 
111
111
  然后按 `ai/template/execution-policy.md` 做执行前规划:列出 L1 清单,给每个 L1
112
112
  标注 Green / Yellow / Red,并写入 `execution_policy.task_tree`。根据 L1 数量自动选择
113
- `normal` 或 `bounded_continuous`。执行 L1 前规划 L2,执行 L2 前按需规划 L3;
114
- 默认最多 3 层,必要时允许 L4。每完成一个 L1,在清单中打勾并划掉,并更新
115
- `task_tree` 节点状态。只有 Red 停止等待人类确认;Green 自动继续,Yellow 做局部
116
- 低风险修正后继续。最后把结果写入:
113
+ `normal` 或 `bounded_continuous`。只有 `readiness = ready_to_execute` 才能执行;
114
+ 如果本轮新建或重写任务契约,先停在确认交接。L1 必须是可独立验收的垂直切片。
115
+ 执行 L1 前规划 L2,执行 L2 前按需规划 L3;默认最多 3 层,必要时允许 L4。
116
+ 每完成一个 L1,在清单中打勾并划掉;开始或完成 L1、出现 Red/blocked、范围变化
117
+ 或最终收尾时写回 `task_tree`。只有 Red 停止等待人类确认;Green 自动继续,Yellow
118
+ 只做当前 L1/L2 内的局部低风险修正。用户可见输出遵守
119
+ `ai/template/execution-policy.md` 的“用户可见输出”规则。最后把结果写入:
117
120
 
118
121
  - `ai/project/result.json`
119
122
  - `ai/project/result.md`
@@ -47,9 +47,12 @@ ai/project/task.md = 当前执行契约
47
47
 
48
48
  执行策略默认是 `auto`:AI 先拆 L1 任务并判断 Green / Yellow / Red,再决定使用
49
49
  `normal` 或 `bounded_continuous`。L1 少于 2 个使用 `normal`;L1 为 2 个或更多
50
- 自动启用 `bounded_continuous`。只有 Red 停止等待人类确认。
50
+ 自动启用 `bounded_continuous`。L1 必须是可独立验收的垂直切片。只有
51
+ `readiness = ready_to_execute` 的既有任务才能执行;本轮新建或重写任务契约时先
52
+ 停在确认交接。只有 Red 停止等待人类确认,Yellow 只允许当前 L1/L2 内的局部
53
+ 低风险修正。
51
54
 
52
- 任务树、风险分级、Checkpoint 证据和 `task_tree` 状态更新规则由
55
+ 任务树、风险分级、Checkpoint 证据和 `task_tree` 写回规则由
53
56
  `ai/template/execution-policy.md` 定义。
54
57
 
55
58
  ## 引导模式
@@ -108,13 +108,20 @@
108
108
 
109
109
  硬门禁:
110
110
 
111
+ - 只有 `ai/project/task.md.readiness = ready_to_execute` 才能执行;本轮新建或重写
112
+ `task.md` 时必须停在确认交接。
113
+ - L1 必须是可独立验收的垂直切片,不是机械步骤清单。
111
114
  - `execution_policy.task_tree` 必须记录 L1 清单和执行状态。
112
115
  - 每个任务节点必须有 Green / Yellow / Red 风险评级。
116
+ - Yellow 只允许当前 L1/L2 内的局部低风险修正,不能改变公共接口、数据模型、
117
+ 权限、安全、架构方向或验收标准。
113
118
  - 每个 Checkpoint 必须包含证据;不接受只有主观判断的 Green。
114
119
  - Red 必须停止等待人类确认。
115
- - 任何方向、核心架构、数据结构、安全、支付、账号、权限、大量删除、
120
+ - 任何方向、核心架构、公共 API、持久化数据结构、安全、支付、账号、权限、大量删除、
116
121
  核心重写或高成本方案取舍,都必须停止。
117
122
  - 需要扩大范围、权限、命令、网络或验收时,必须停止。
123
+ - `task_tree` 写回应集中在 L1 开始/完成、Red、blocked、范围变化和最终收尾,
124
+ 不要为每个微小 L3 操作写回。
118
125
 
119
126
  目标、范围、验收和权限由 AI 推断,但不能越过项目规则、显式用户限制、
120
127
  `permission.modify.denied`、安全边界或破坏性操作限制。
package/test/selftest.js CHANGED
@@ -84,13 +84,24 @@ function testInitUpdateDoctor() {
84
84
  assert(read(cwd, "ai/template/prompt.md").includes("默认也只处理 `ai/project/inbox/*.md`"), "execution prompt should narrow inbox reconciliation");
85
85
  assert(read(cwd, "ai/template/protocol.md").includes("`bounded_continuous`"), "protocol should include bounded continuous execution");
86
86
  assert(read(cwd, "ai/template/execution-policy.md").includes("垂直切片"), "protocol should require vertical-slice progress for continuous execution");
87
+ assert(read(cwd, "ai/template/execution-policy.md").includes("可独立验收的垂直切片"), "execution policy should define L1 granularity");
88
+ assert(read(cwd, "ai/template/execution-policy.md").includes("不能边写草稿边执行"), "execution policy should block execution from draft tasks");
89
+ assert(read(cwd, "ai/template/execution-policy.md").includes("不要为每个微小 L3 操作写回"), "execution policy should limit task tree write-back churn");
90
+ assert(read(cwd, "ai/template/execution-policy.md").includes("公共接口、数据模型、权限、安全"), "execution policy should constrain Yellow corrections");
91
+ assert(read(cwd, "ai/template/execution-policy.md").includes("用户可见输出"), "execution policy should define user-visible output rules");
92
+ assert(read(cwd, "ai/template/execution-policy.md").includes("不要默认展示完整 L2/L3/L4"), "execution policy should avoid exposing full subtask trees by default");
93
+ assert(read(cwd, "ai/template/execution-policy.md").includes("不要展示内部协议字段"), "execution policy should hide internal protocol details by default");
87
94
  assert(read(cwd, "ai/template/execution-policy.md").includes("L1 为 2 个或更多,自动启用"), "protocol should auto-enable continuous execution from L1 count");
88
95
  assert(read(cwd, "ai/template/execution-policy.md").includes("每个 Checkpoint 必须包含"), "protocol should require evidence-backed checkpoints");
89
96
  assert(read(cwd, "ai/template/rules/core.md").includes("边界内连续执行门"), "core rules should include bounded continuous execution gate");
97
+ assert(read(cwd, "ai/template/rules/core.md").includes("readiness = ready_to_execute"), "core rules should require ready task before execution");
98
+ assert(read(cwd, "ai/template/rules/core.md").includes("不是机械步骤清单"), "core rules should reject mechanical L1 task lists");
90
99
  assert(read(cwd, "ai/template/rules/core.md").includes("需要扩大范围、权限、命令、网络或验收时"), "core rules should stop continuous execution before boundary expansion");
91
100
  assert(read(cwd, "ai/project/task.md").includes("execution_policy:"), "task template should include execution policy");
92
101
  assert(read(cwd, "ai/project/task.md").includes("readiness:"), "task template should include readiness state");
93
102
  assert(read(cwd, "ai/project/task.md").includes("activation_rule: \"auto_enable_when_l1_count_gte_2\""), "task template should define automatic activation rule");
103
+ assert(read(cwd, "ai/project/task.md").includes("l1_granularity: \"independently_acceptable_vertical_slice\""), "task template should define L1 granularity");
104
+ 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
105
  assert(read(cwd, "ai/project/task.md").includes("risk_gate:"), "task template should define risk gate");
95
106
  assert(read(cwd, "ai/project/task.md").includes("status: \"pending | running | done | blocked\""), "task template should define task tree node status");
96
107
  assert(read(cwd, "ai/project/task.md").includes("progress_unit: \"vertical_slice\""), "task template should define continuous progress unit");
@@ -99,6 +110,8 @@ function testInitUpdateDoctor() {
99
110
  assert(read(cwd, "ai/template/prompt.md").includes("不要重新 bootstrap"), "execution prompt should reconcile inbox material when project context already exists");
100
111
  assert(read(cwd, "ai/template/prompt.md").includes("整合 ai/project/inbox/ 里的新资料"), "execution prompt should route natural reconcile entry");
101
112
  assert(read(cwd, "ai/template/prompt.md").includes("继续推进这个项目"), "execution prompt should route natural continue entry");
113
+ assert(read(cwd, "ai/template/prompt.md").includes("不要在任务仍是草稿时直接执行"), "execution prompt should stop after drafting a task");
114
+ assert(read(cwd, "ai/template/prompt.md").includes("用户可见输出"), "execution prompt should reference user-visible output rules");
102
115
  assert(read(cwd, "ai/template/prompt.md").includes("strategy_update"), "execution prompt should route strategy updates");
103
116
  assert(read(cwd, "ai/template/reconcile.md").includes("上下文整合"), "init should install reconcile prompt");
104
117
  assert(read(cwd, "ai/template/reconcile.md").includes("整合计划"), "reconcile prompt should require a plan first");
@@ -168,13 +181,24 @@ function testEnglishInitUpdateDoctor() {
168
181
  assert(read(cwd, "ai/template/prompt.md").includes("default to only `ai/project/inbox/*.md`"), "English execution prompt should narrow inbox reconciliation");
169
182
  assert(read(cwd, "ai/template/protocol.md").includes("`bounded_continuous`"), "English protocol should include bounded continuous execution");
170
183
  assert(read(cwd, "ai/template/execution-policy.md").includes("vertical"), "English protocol should require vertical-slice progress for continuous execution");
184
+ assert(read(cwd, "ai/template/execution-policy.md").includes("independently acceptable vertical slice"), "English execution policy should define L1 granularity");
185
+ assert(read(cwd, "ai/template/execution-policy.md").includes("executing from a draft"), "English execution policy should block execution from draft tasks");
186
+ assert(read(cwd, "ai/template/execution-policy.md").includes("every tiny L3 operation"), "English execution policy should limit task tree write-back churn");
187
+ assert(read(cwd, "ai/template/execution-policy.md").includes("public interfaces, data models, permissions"), "English execution policy should constrain Yellow corrections");
188
+ assert(read(cwd, "ai/template/execution-policy.md").includes("User-Visible Output"), "English execution policy should define user-visible output rules");
189
+ 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");
190
+ 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
191
  assert(read(cwd, "ai/template/execution-policy.md").includes("Automatically use `bounded_continuous`"), "English protocol should auto-enable continuous execution from L1 count");
172
192
  assert(read(cwd, "ai/template/execution-policy.md").includes("Every checkpoint must include"), "English protocol should require evidence-backed checkpoints");
173
193
  assert(read(cwd, "ai/template/rules/core.md").includes("Bounded Continuous Execution Gate"), "English core rules should include bounded continuous execution gate");
194
+ assert(read(cwd, "ai/template/rules/core.md").includes("readiness = ready_to_execute"), "English core rules should require ready task before execution");
195
+ assert(read(cwd, "ai/template/rules/core.md").includes("not a mechanical step"), "English core rules should reject mechanical L1 task lists");
174
196
  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
197
  assert(read(cwd, "ai/project/task.md").includes("execution_policy:"), "English task template should include execution policy");
176
198
  assert(read(cwd, "ai/project/task.md").includes("readiness:"), "English task template should include readiness state");
177
199
  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");
200
+ assert(read(cwd, "ai/project/task.md").includes("l1_granularity: \"independently_acceptable_vertical_slice\""), "English task template should define L1 granularity");
201
+ 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
202
  assert(read(cwd, "ai/project/task.md").includes("risk_gate:"), "English task template should define risk gate");
179
203
  assert(read(cwd, "ai/project/task.md").includes("status: \"pending | running | done | blocked\""), "English task template should define task tree node status");
180
204
  assert(read(cwd, "ai/project/task.md").includes("progress_unit: \"vertical_slice\""), "English task template should define continuous progress unit");
@@ -182,6 +206,8 @@ function testEnglishInitUpdateDoctor() {
182
206
  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
207
  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
208
  assert(read(cwd, "ai/template/prompt.md").includes("Continue this project"), "English execution prompt should route natural continue entry");
209
+ 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");
210
+ assert(read(cwd, "ai/template/prompt.md").includes("User-Visible Output"), "English execution prompt should reference user-visible output rules");
185
211
  assert(read(cwd, "ai/template/prompt.md").includes("strategy_update"), "English execution prompt should route strategy updates");
186
212
  assert(exists(cwd, "ai/project/refs/final-shape.md"), "English init should create project North Star");
187
213
  assert(exists(cwd, "ai/project/refs/module-map.md"), "English init should create module map");