@wnlen/agent-execution-template 0.8.19 → 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.
- package/bin/agent-execution-template.js +121 -17
- package/package.json +1 -1
- package/template/en/ai/template/VERSION +1 -1
- package/template/en/ai/template/execution-policy.md +5 -0
- package/template/en/ai/template/rules/output.md +4 -1
- package/template/zh/ai/project/runtime.md +11 -11
- package/template/zh/ai/project/task.md +20 -25
- package/template/zh/ai/template/VERSION +1 -1
- package/template/zh/ai/template/bootstrap.md +21 -27
- package/template/zh/ai/template/execution-policy.md +3 -0
- package/template/zh/ai/template/prompt.md +38 -50
- package/template/zh/ai/template/protocol.md +28 -33
- package/template/zh/ai/template/reconcile.md +21 -28
- package/template/zh/ai/template/rules/core.md +19 -24
- package/template/zh/ai/template/rules/output.md +3 -1
- package/test/selftest.js +68 -3
|
@@ -19,6 +19,8 @@ const REQUIRED_FILES = [
|
|
|
19
19
|
"ai/template/protocol.md",
|
|
20
20
|
"ai/template/rules/core.md",
|
|
21
21
|
"ai/template/rules/output.md",
|
|
22
|
+
"ai/template/schemas/result.schema.json",
|
|
23
|
+
"ai/template/schemas/metrics.schema.json",
|
|
22
24
|
"ai/project/inbox/.gitkeep",
|
|
23
25
|
"ai/project/project.md",
|
|
24
26
|
"ai/project/runtime.md",
|
|
@@ -39,11 +41,6 @@ const RECOMMENDED_FILES = [
|
|
|
39
41
|
"ai/project/refs/roadmap.md"
|
|
40
42
|
];
|
|
41
43
|
|
|
42
|
-
const JSON_HEALTH_FILES = [
|
|
43
|
-
"ai/project/result.json",
|
|
44
|
-
"ai/project/metrics.json"
|
|
45
|
-
];
|
|
46
|
-
|
|
47
44
|
const TASK_HEALTH_PATTERNS = [
|
|
48
45
|
/^task_id:\s*/m,
|
|
49
46
|
/^type:\s*/m,
|
|
@@ -132,6 +129,7 @@ const TEXT = {
|
|
|
132
129
|
fail: "失败",
|
|
133
130
|
empty: "为空",
|
|
134
131
|
invalidJson: "JSON 无效",
|
|
132
|
+
invalidSchema: "不符合协议 schema",
|
|
135
133
|
taskFrontMatterIncomplete: "任务 front matter 缺少关键字段",
|
|
136
134
|
versionMismatch: "模板版本与包版本不一致",
|
|
137
135
|
runInit: "请运行 npx -y @wnlen/agent-execution-template init",
|
|
@@ -241,6 +239,7 @@ Usage:
|
|
|
241
239
|
fail: "FAIL",
|
|
242
240
|
empty: "is empty",
|
|
243
241
|
invalidJson: "contains invalid JSON",
|
|
242
|
+
invalidSchema: "does not match protocol schema",
|
|
244
243
|
taskFrontMatterIncomplete: "task front matter is missing required fields",
|
|
245
244
|
versionMismatch: "template version does not match package version",
|
|
246
245
|
runInit: "Run npx -y @wnlen/agent-execution-template init",
|
|
@@ -701,6 +700,117 @@ function isPermissionError(error) {
|
|
|
701
700
|
return error && (error.code === "EACCES" || error.code === "EPERM");
|
|
702
701
|
}
|
|
703
702
|
|
|
703
|
+
function parseJsonFile(file) {
|
|
704
|
+
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
function valueMatchesType(value, type) {
|
|
708
|
+
if (type === "array") return Array.isArray(value);
|
|
709
|
+
if (type === "integer") return Number.isInteger(value);
|
|
710
|
+
if (type === "number") return typeof value === "number" && Number.isFinite(value);
|
|
711
|
+
if (type === "object") return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
712
|
+
return typeof value === type;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
function valuesEqual(left, right) {
|
|
716
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
function validateJsonSchema(value, schema, location = "$") {
|
|
720
|
+
const errors = [];
|
|
721
|
+
|
|
722
|
+
if (schema.const !== undefined && !valuesEqual(value, schema.const)) {
|
|
723
|
+
errors.push(`${location} must be ${JSON.stringify(schema.const)}`);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
if (schema.enum && !schema.enum.some((candidate) => valuesEqual(value, candidate))) {
|
|
727
|
+
errors.push(`${location} must be one of ${schema.enum.map((item) => JSON.stringify(item)).join(", ")}`);
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
if (schema.type && !valueMatchesType(value, schema.type)) {
|
|
731
|
+
errors.push(`${location} must be ${schema.type}`);
|
|
732
|
+
return errors;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
if (schema.minimum !== undefined && typeof value === "number" && value < schema.minimum) {
|
|
736
|
+
errors.push(`${location} must be >= ${schema.minimum}`);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
if (schema.minLength !== undefined && typeof value === "string" && value.length < schema.minLength) {
|
|
740
|
+
errors.push(`${location} must have length >= ${schema.minLength}`);
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
if (schema.required && valueMatchesType(value, "object")) {
|
|
744
|
+
for (const key of schema.required) {
|
|
745
|
+
if (!Object.prototype.hasOwnProperty.call(value, key)) {
|
|
746
|
+
errors.push(`${location}.${key} is required`);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
if (schema.properties && valueMatchesType(value, "object")) {
|
|
752
|
+
for (const [key, childSchema] of Object.entries(schema.properties)) {
|
|
753
|
+
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
|
754
|
+
errors.push(...validateJsonSchema(value[key], childSchema, `${location}.${key}`));
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
if (schema.items && Array.isArray(value)) {
|
|
760
|
+
value.forEach((item, index) => {
|
|
761
|
+
errors.push(...validateJsonSchema(item, schema.items, `${location}[${index}]`));
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
if (schema.allOf) {
|
|
766
|
+
for (const childSchema of schema.allOf) {
|
|
767
|
+
if (childSchema.if) {
|
|
768
|
+
if (validateJsonSchema(value, childSchema.if, location).length === 0 && childSchema.then) {
|
|
769
|
+
errors.push(...validateJsonSchema(value, childSchema.then, location));
|
|
770
|
+
}
|
|
771
|
+
} else {
|
|
772
|
+
errors.push(...validateJsonSchema(value, childSchema, location));
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
return errors;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
function printSchemaValidation(file, schemaFile, text) {
|
|
781
|
+
const fullPath = path.join(process.cwd(), file);
|
|
782
|
+
const schemaPath = path.join(process.cwd(), schemaFile);
|
|
783
|
+
if (!fs.existsSync(fullPath) || !fs.existsSync(schemaPath)) {
|
|
784
|
+
return 0;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
let value;
|
|
788
|
+
try {
|
|
789
|
+
value = parseJsonFile(fullPath);
|
|
790
|
+
console.log(`[${text.pass}] ${file} JSON`);
|
|
791
|
+
} catch {
|
|
792
|
+
console.log(`[${text.fail}] ${file} ${text.invalidJson}`);
|
|
793
|
+
return 1;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
let schema;
|
|
797
|
+
try {
|
|
798
|
+
schema = parseJsonFile(schemaPath);
|
|
799
|
+
} catch {
|
|
800
|
+
console.log(`[${text.fail}] ${schemaFile} ${text.invalidJson}`);
|
|
801
|
+
return 1;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
const errors = validateJsonSchema(value, schema);
|
|
805
|
+
if (errors.length > 0) {
|
|
806
|
+
console.log(`[${text.fail}] ${file} ${text.invalidSchema}: ${errors.slice(0, 3).join("; ")}`);
|
|
807
|
+
return 1;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
console.log(`[${text.pass}] ${file} schema`);
|
|
811
|
+
return 0;
|
|
812
|
+
}
|
|
813
|
+
|
|
704
814
|
function printFatal(error, lang) {
|
|
705
815
|
const text = getText(lang);
|
|
706
816
|
if (isPermissionError(error)) {
|
|
@@ -756,18 +866,12 @@ function doctor() {
|
|
|
756
866
|
console.log(`[${text.pass}] ${file}`);
|
|
757
867
|
}
|
|
758
868
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
JSON.parse(fs.readFileSync(fullPath, "utf8"));
|
|
766
|
-
console.log(`[${text.pass}] ${file} JSON`);
|
|
767
|
-
} catch {
|
|
768
|
-
console.log(`[${text.fail}] ${file} ${text.invalidJson}`);
|
|
769
|
-
missing += 1;
|
|
770
|
-
}
|
|
869
|
+
const schemaChecks = [
|
|
870
|
+
["ai/project/result.json", "ai/template/schemas/result.schema.json"],
|
|
871
|
+
["ai/project/metrics.json", "ai/template/schemas/metrics.schema.json"]
|
|
872
|
+
];
|
|
873
|
+
for (const [file, schemaFile] of schemaChecks) {
|
|
874
|
+
missing += printSchemaValidation(file, schemaFile, text);
|
|
771
875
|
}
|
|
772
876
|
|
|
773
877
|
const taskPath = path.join(process.cwd(), "ai/project/task.md");
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.8.
|
|
1
|
+
0.8.20
|
|
@@ -121,6 +121,11 @@ verification was not possible. A purely subjective Green is not valid.
|
|
|
121
121
|
|
|
122
122
|
## User-Visible Output
|
|
123
123
|
|
|
124
|
+
- Use the installed template language by default. When `ai/template/LANG` is
|
|
125
|
+
`en`, user-visible plans, L1 checklists, checkpoints, task draft handoffs,
|
|
126
|
+
blocked explanations, and final results should default to English. Use another
|
|
127
|
+
language only when the human explicitly asks, or when preserving code,
|
|
128
|
+
commands, file paths, or protocol field names.
|
|
124
129
|
- Show the L1 checklist by default; do not show full L2/L3/L4 by default.
|
|
125
130
|
- Show risk conclusions and necessary reasons; do not output long internal reasoning.
|
|
126
131
|
- Show evidence; do not show internal protocol fields, full YAML,
|
|
@@ -25,7 +25,10 @@ verification, assumptions, issues, next steps, and runtime update proposals.
|
|
|
25
25
|
|
|
26
26
|
## Result Markdown
|
|
27
27
|
|
|
28
|
-
`ai/project/result.md` is the human-readable summary. Keep it short
|
|
28
|
+
`ai/project/result.md` is the human-readable summary. Keep it short and use the
|
|
29
|
+
installed language from `ai/template/LANG` by default. In the English template,
|
|
30
|
+
headings and prose should default to English; preserve code, commands, file
|
|
31
|
+
paths, and protocol field names as written.
|
|
29
32
|
|
|
30
33
|
```md
|
|
31
34
|
## Status
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
## 当前状态
|
|
4
4
|
|
|
5
5
|
- 阶段:方向层与执行层一致性收口
|
|
6
|
-
-
|
|
6
|
+
- 重点:保持协议可安装、可升级、可审计,并让方向治理与执行约束一致。
|
|
7
7
|
- 阻塞:无
|
|
8
8
|
- 已知风险:
|
|
9
9
|
- 超出当前任务范围
|
|
10
|
-
-
|
|
10
|
+
- 询问可安全推断的细节
|
|
11
11
|
- 用历史过程笔记污染运行时上下文
|
|
12
12
|
- 没有验证证据就标记成功
|
|
13
13
|
- 在明确权限之外运行命令
|
|
14
|
-
-
|
|
14
|
+
- 只省 token,忽略可接受成本下的质量
|
|
15
15
|
- 方向层已升级但规则、runtime 或 doctor 仍停留在旧语义
|
|
16
16
|
|
|
17
17
|
## 硬规则
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
|
|
37
37
|
## 项目约束
|
|
38
38
|
|
|
39
|
-
-
|
|
40
|
-
-
|
|
39
|
+
- 引导读取集:`bootstrap.md`、`protocol.md`、`rules/core.md`、根文档、清单、项目文档、引用;文档不足时有限检查源码结构。
|
|
40
|
+
- 执行读取集:`prompt.md`、`protocol.md`、`rules/core.md`、`project.md`、`runtime.md`、`task.md`。
|
|
41
41
|
- `ai/project/refs/` 文件只在任务要求或任务类型触发时加载。
|
|
42
42
|
- `ai/project/refs/final-shape.md`、`module-map.md`、`roadmap.md` 属于方向层正式文档。
|
|
43
43
|
- 方向层正式文档不能被普通 reconcile 或普通执行任务直接修改。
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
## 当前上下文
|
|
54
54
|
|
|
55
55
|
这个项目是协议 / 模板,不是复杂 Agent 框架。
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
定位:面向 AI Coding Agent 的项目方向治理 + 可审计任务执行协议。
|
|
57
|
+
目标:减少人类交互和输入量,让任务随时间更精确,并降低长期方向漂移。
|
|
58
|
+
允许增加少量服务协议采用和治理闭环的 CLI;不要引入 UI、云同步或多 Agent 编排。
|
|
59
59
|
|
|
60
60
|
## 引用路由
|
|
61
61
|
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
|
|
70
70
|
## 运行时更新治理
|
|
71
71
|
|
|
72
|
-
除非 `
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
除非 `task.md` 明确允许,AI 不得直接更新本文件。
|
|
73
|
+
任务产生长期上下文时,写入 `result.json.runtime_update` 建议。
|
|
74
|
+
运行时更新应由单独任务应用,唯一目标是 `ai/project/runtime.md`。
|
|
@@ -79,14 +79,12 @@ permission:
|
|
|
79
79
|
|
|
80
80
|
# 任务
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
然后由人类在执行前检查。
|
|
82
|
+
当前执行契约。优先由引导模式根据人类目标和仓库上下文生成,执行前由人类检查。
|
|
84
83
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
`
|
|
88
|
-
|
|
89
|
-
只有已有任务明确处于 `ready_to_execute` 时,才进入执行。
|
|
84
|
+
优先安全假设,少问问题。AI 基于目标、上下文和仓库事实推断范围、风险、权限和验收;
|
|
85
|
+
若会越权、触碰安全边界或验收不可定义,将 `readiness` 设为 `blocked` 或把相关节点设为
|
|
86
|
+
`Red`,等待确认。本轮新建或重写任务契约时,默认保持 `draft_for_confirmation` 并停下交接;
|
|
87
|
+
只有既有任务为 `ready_to_execute` 时才执行。
|
|
90
88
|
|
|
91
89
|
## 目标
|
|
92
90
|
|
|
@@ -125,34 +123,32 @@ permission:
|
|
|
125
123
|
|
|
126
124
|
## 执行策略
|
|
127
125
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
自动使用 `bounded_continuous`。
|
|
126
|
+
默认 `auto`:AI 执行前规划并决定是否连续执行,不等用户口令。L1 < 2 用 `normal`;
|
|
127
|
+
L1 >= 2 自动用 `bounded_continuous`。
|
|
131
128
|
|
|
132
129
|
`bounded_continuous` 表示边界内连续执行:
|
|
133
130
|
|
|
134
|
-
-
|
|
135
|
-
不要求用户预先逐项提供。
|
|
131
|
+
- 目标、范围、验收、权限和风险由 AI 基于目标、上下文和仓库事实推断;不要求用户逐项提供。
|
|
136
132
|
- `readiness = ready_to_execute` 表示没有 Red 预检项,可以执行。
|
|
137
133
|
- `readiness = draft_for_confirmation` 表示需要人类确认后才能执行。
|
|
138
134
|
- `readiness = blocked` 表示当前任务不可执行,必须写 blocked 结果。
|
|
139
|
-
-
|
|
140
|
-
- 执行前必须把 L1
|
|
141
|
-
- 执行前必须列出 L1
|
|
135
|
+
- 本轮新建或重写 `task.md` 时必须停在确认交接;草稿不能执行。
|
|
136
|
+
- 执行前必须把 L1 清单写入 `execution_policy.task_tree`。
|
|
137
|
+
- 执行前必须列出 L1 清单;每个 L1 用待办表示,完成后打勾并划掉。
|
|
142
138
|
- L1 必须是可独立验收的垂直切片;不要把单个机械步骤拆成 L1,也不要把多个
|
|
143
139
|
可独立验收的用户可见结果合并成一个 L1。
|
|
144
|
-
-
|
|
145
|
-
- 默认最多 3
|
|
146
|
-
-
|
|
140
|
+
- 执行 L1 前规划 L2;L2 仍过大时规划 L3。
|
|
141
|
+
- 默认最多 3 层;不拆 L4 会导致 L3 过大或不可验证时,才允许 L4。
|
|
142
|
+
- 每个节点都由 AI 生成 Green / Yellow / Red 风险评级。
|
|
147
143
|
- 只有 Red 停下来让人类确认;Green 自动继续,Yellow 只允许当前 L1/L2 内的局部
|
|
148
144
|
低风险修正,不能改变公共接口、数据模型、权限、安全、架构方向或验收标准。
|
|
149
|
-
- `progress_unit`
|
|
150
|
-
- `checkpoint_budget`
|
|
145
|
+
- `progress_unit` 默认为 `vertical_slice`:每轮都应产生可检查增量。
|
|
146
|
+
- `checkpoint_budget` 是上限,不是必须用完;不要为消耗预算而汇报。
|
|
151
147
|
- 只有在风险从 Green 变 Yellow/Red、即将扩大范围或权限、完成 L1 垂直切片、
|
|
152
148
|
验证失败后准备继续、准备最终收尾时才输出 Checkpoint。
|
|
153
149
|
- 每个 Checkpoint 必须包含证据:已改文件、已运行命令、验证结果或无法验证的原因。
|
|
154
|
-
- `task_tree`
|
|
155
|
-
|
|
150
|
+
- `task_tree` 写回:执行前写 L1 清单;L1 开始/完成、Red、blocked、范围变化或收尾时写回;
|
|
151
|
+
不为微小 L3 操作写回。
|
|
156
152
|
- 完成后只做一次总复盘;只对 Yellow、Red、失败验证或高影响模块做二次抽检。
|
|
157
153
|
- 连续执行不改变模型策略;涉及判断、架构、失败复盘或验收争议时仍按 `model_policy` 升级。
|
|
158
154
|
|
|
@@ -163,9 +159,8 @@ permission:
|
|
|
163
159
|
|
|
164
160
|
## 模型策略
|
|
165
161
|
|
|
166
|
-
默认使用 `model_policy.default_tier`
|
|
167
|
-
|
|
168
|
-
并在 `ai/project/metrics.json` 中记录原因。
|
|
162
|
+
默认使用 `model_policy.default_tier`。不要用 `strong` 做常规执行;只在
|
|
163
|
+
`model_policy` 声明的角色和触发条件下使用,并在 `metrics.json` 记录原因。
|
|
169
164
|
|
|
170
165
|
## 停止条件
|
|
171
166
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
0.8.
|
|
1
|
+
0.8.20
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
# AI 执行引导
|
|
2
2
|
|
|
3
3
|
不要总结这个文件。
|
|
4
|
-
|
|
4
|
+
按下面流程整理项目上下文。
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
目标:建立后续任务依赖的稳定项目理解。这是发现与确认,不是实现。
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
你的任务是检查项目,创建或更新 `ai/project/project.md`
|
|
12
|
-
以及相关的 `ai/project/refs/*`,然后在“引导后交接”处停止。
|
|
8
|
+
检查项目,创建或更新 `ai/project/project.md` 和相关 `ai/project/refs/*`,
|
|
9
|
+
然后在“引导后交接”处停止。
|
|
13
10
|
|
|
14
11
|
## 先读
|
|
15
12
|
|
|
@@ -31,11 +28,9 @@
|
|
|
31
28
|
- 能推断约束时,更新 `ai/project/refs/constraints.md`
|
|
32
29
|
- 只有存在持久决策证据时,更新 `ai/project/refs/decisions.md`
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
如果创建了 `ai/project/task.md`,只起草任务契约,不进入执行。
|
|
31
|
+
只有人类同时提供当前任务时,才创建 `ai/project/task.md`。只起草任务契约,不执行。
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
运行时文件、结果文件或指标文件。
|
|
33
|
+
引导期间不要编辑源码、测试、配置、依赖、生成文件、运行时、结果或指标文件。
|
|
39
34
|
|
|
40
35
|
## 阅读顺序
|
|
41
36
|
|
|
@@ -48,12 +43,12 @@
|
|
|
48
43
|
4. 现有 AI 引用:`ai/project/refs/*.md`
|
|
49
44
|
5. 源码、测试、配置和文档目录的浅层仓库结构
|
|
50
45
|
|
|
51
|
-
|
|
46
|
+
文档和清单不足时,可有限读取代码推断:
|
|
52
47
|
|
|
53
48
|
- 先检查顶层目录和文件名;
|
|
54
49
|
- 检查可能的入口目录,例如 `src/`、`app/`、`lib/`、`packages/`、
|
|
55
50
|
`services/`、`cmd/`、`internal/`、`server/`、`client/`、`test/`、`tests/`;
|
|
56
|
-
-
|
|
51
|
+
- 只读取足够识别目的、模块边界、命令和约束的路由、模块、配置和测试文件;
|
|
57
52
|
- 除非人类明确授权,不要读取整个代码库。
|
|
58
53
|
|
|
59
54
|
除非人类明确引用或授权,不要读取依赖目录、构建产物、覆盖率输出、锁文件
|
|
@@ -61,7 +56,7 @@
|
|
|
61
56
|
|
|
62
57
|
## 确认维度
|
|
63
58
|
|
|
64
|
-
|
|
59
|
+
读取后,请人类确认或修正:
|
|
65
60
|
|
|
66
61
|
- 项目名称、目的和主要用户;
|
|
67
62
|
- 一句话定位、最终形态和任务是否值得做的判断标准;
|
|
@@ -74,19 +69,18 @@
|
|
|
74
69
|
- 持久约束、安全边界、兼容性要求和高风险区域;
|
|
75
70
|
- 会影响后续任务精度的未知项。
|
|
76
71
|
|
|
77
|
-
|
|
78
|
-
权限或验收的问题。
|
|
72
|
+
最多问 3 个问题。只问会改变身份、命令、边界、约束、风险、权限或验收的问题。
|
|
79
73
|
|
|
80
74
|
## 输出规则
|
|
81
75
|
|
|
82
76
|
- 未知事实标记为 `Unknown`;不要把猜测当成事实。
|
|
83
|
-
-
|
|
84
|
-
|
|
85
|
-
`ai/project/inbox/
|
|
86
|
-
|
|
77
|
+
- 若本次吸收 `ai/project/inbox/*.md` 或 `ai/project/inbox/raw/*.md`,写入上下文后移到
|
|
78
|
+
`ai/project/inbox/processed/`,保留相对路径:`ai/project/inbox/raw/file.md` ->
|
|
79
|
+
`ai/project/inbox/processed/raw/file.md`。文件名冲突时加日期或序号。不要移动
|
|
80
|
+
`ai/project/inbox/ideas/**`。
|
|
87
81
|
- 未吸收资料必须留在原位置,并在最终回复中说明原因。
|
|
88
|
-
-
|
|
89
|
-
|
|
82
|
+
- `final-shape.md`、`module-map.md`、`roadmap.md` 的初始化内容必须标明证据来源;
|
|
83
|
+
证据不足时保持占位或写 `Unknown`,不要编造愿景。
|
|
90
84
|
- 有帮助时,在相关文件中记录证据来源。
|
|
91
85
|
- 保持 `ai/project/project.md` 稳定、长期有效。
|
|
92
86
|
- 保持 `ai/project/refs/*.md` 聚焦;不要把引用文件写成项目流水账。
|
|
@@ -95,11 +89,11 @@
|
|
|
95
89
|
|
|
96
90
|
## 引导后交接
|
|
97
91
|
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
写完上下文草稿后,不要只要求人类打开文件检查。最终回复必须给出可确认摘要,
|
|
93
|
+
让人类能直接在聊天里确认或修正。
|
|
100
94
|
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
如果引导请求已包含当前任务目标,必须同时起草 `ai/project/task.md`,
|
|
96
|
+
并交付项目理解摘要和任务草稿摘要。
|
|
103
97
|
|
|
104
98
|
如果人类没有给出当前任务目标,你必须根据项目现状推荐下一步最值得做的任务。
|
|
105
99
|
|
|
@@ -199,5 +193,5 @@
|
|
|
199
193
|
- 修正:<你要改的地方>
|
|
200
194
|
```
|
|
201
195
|
|
|
202
|
-
|
|
196
|
+
重要未知项只在“仍不确定”中列最多 3 条。
|
|
203
197
|
不要让人类主动去文件管理器里寻找问题;文件路径只作为可追溯记录。
|
|
@@ -104,6 +104,9 @@ Checkpoint 只在以下情况输出:风险从 Green 变 Yellow/Red、即将扩
|
|
|
104
104
|
|
|
105
105
|
## 用户可见输出
|
|
106
106
|
|
|
107
|
+
- 默认使用当前安装模板语言输出。`ai/template/LANG` 为 `zh` 时,用户可见的计划、
|
|
108
|
+
L1 清单、Checkpoint、任务草稿交接、阻塞说明和最终结果默认使用中文;只有用户
|
|
109
|
+
明确要求其他语言,或需要保留代码、命令、文件路径、协议字段原文时才使用其他语言。
|
|
107
110
|
- 默认展示 L1 清单;不要默认展示完整 L2/L3/L4。
|
|
108
111
|
- 展示风险结论和必要原因;不要输出长篇内部推理。
|
|
109
112
|
- 展示证据;不要展示内部协议字段、完整 YAML、`checkpoint_budget` 或 `model_policy`。
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
# AI 执行提示
|
|
2
2
|
|
|
3
3
|
不要总结这个文件。
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
你正在 Agent Execution Template 工作区内操作。
|
|
4
|
+
按下面流程执行。你正在 Agent Execution Template 工作区内操作。
|
|
7
5
|
|
|
8
6
|
先读取:
|
|
9
7
|
|
|
@@ -11,54 +9,45 @@
|
|
|
11
9
|
2. `ai/template/rules/core.md`
|
|
12
10
|
3. `ai/template/execution-policy.md`
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
选择模式:
|
|
15
13
|
|
|
16
|
-
-
|
|
17
|
-
或 `ai/project/inbox/ideas/`
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
`ai/project/proposals/final-shape-updates/*.md` 可以合并,按
|
|
21
|
-
`apply_strategy_update` 起草或执行应用任务;如果 proposal 仍为
|
|
22
|
-
`proposed`,先根据这次明确确认更新为 `accepted`。
|
|
14
|
+
- 用户要求更新北极星、最终形态、产品宪法、模块地图、路线图或项目方向,
|
|
15
|
+
或 `ai/project/inbox/ideas/` 有待评估灵感:走 `strategy_update`,生成提案后停下确认。
|
|
16
|
+
- 用户明确确认某个 `ai/project/proposals/final-shape-updates/*.md` 可合并:
|
|
17
|
+
走 `apply_strategy_update`。若 proposal 仍为 `proposed`,先改为 `accepted`。
|
|
23
18
|
- 如果用户说“开始初始化这个项目,并吸收 ai/project/inbox/ 里的资料”,
|
|
24
|
-
|
|
25
|
-
`ai/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
并按它的两阶段流程停止或更新;但 `ai/project/inbox/processed/` 是已处理资料,
|
|
33
|
-
不应触发整合,`ai/project/inbox/ideas/` 应优先走 `strategy_update`。即使用户说
|
|
34
|
-
“整合整个 inbox”,默认也只处理 `ai/project/inbox/*.md` 和
|
|
35
|
-
`ai/project/inbox/raw/*.md`。
|
|
19
|
+
或要求初始化时吸收 inbox:先检查 `ai/project/project.md`。若已存在且有效,
|
|
20
|
+
执行 `ai/template/reconcile.md`,不要重新 bootstrap;若为空、占位或不完整,执行
|
|
21
|
+
`ai/template/bootstrap.md`,并把 `ai/project/inbox/*.md` 与
|
|
22
|
+
`ai/project/inbox/raw/*.md` 纳入引导输入;上下文确认后停止。
|
|
23
|
+
- 用户说“整合 ai/project/inbox/ 里的新资料”,要求整合/合并/吸收/更新上下文/处理新资料,提到 `reconcile` 或
|
|
24
|
+
`ai/project/inbox/`,或 inbox 有待吸收资料:执行 `ai/template/reconcile.md`。
|
|
25
|
+
`processed/` 不触发整合,`ideas/` 优先走 `strategy_update`。即使用户说
|
|
26
|
+
“整合整个 inbox”,也默认只处理 `ai/project/inbox/*.md` 和 `ai/project/inbox/raw/*.md`。
|
|
36
27
|
- 如果用户说“开始初始化这个项目”、要求初始化/整理/生成项目上下文,
|
|
37
|
-
或 `ai/project/project.md`
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
- 只有当 `
|
|
45
|
-
|
|
28
|
+
或 `ai/project/project.md` 为空、占位或不完整:执行 `ai/template/bootstrap.md`,
|
|
29
|
+
上下文确认后停止。
|
|
30
|
+
- `ai/project/task.md` 为空、占位或不完整:按当前目标和已确认上下文起草任务,
|
|
31
|
+
然后停下确认。
|
|
32
|
+
- 用户说“继续推进这个项目”且无更具体目标:先判断最值得做的下一步,优先处理
|
|
33
|
+
待确认上下文、待确认任务、失败结果、未完成任务或明显风险;给出建议或起草
|
|
34
|
+
`ai/project/task.md`,不要让人类自己找问题。
|
|
35
|
+
- 只有当 `project.md` 和 `task.md` 足以定义身份、目标、范围、权限和验收时,
|
|
36
|
+
才进入执行模式。
|
|
46
37
|
|
|
47
38
|
## 任务草稿交接
|
|
48
39
|
|
|
49
40
|
在任务草稿模式中:
|
|
50
41
|
|
|
51
42
|
1. 读取已确认的 `ai/project/project.md` 和相关 `ai/project/refs/*.md`。
|
|
52
|
-
2.
|
|
53
|
-
|
|
43
|
+
2. 根据用户目标、项目上下文和仓库事实推断目标、范围、验收、权限、验证方式和初始风险;
|
|
44
|
+
不要求用户逐项提供。
|
|
54
45
|
3. 起草 `ai/project/task.md`,并将 `execution_policy.mode` 设为 `auto`。
|
|
55
|
-
4. 执行前列出 L1
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
6. 只有已有任务明确处于 `ready_to_execute`,且没有 Red 预检项时,才能进入执行模式;
|
|
61
|
-
如果不可执行,设为 `blocked`。
|
|
46
|
+
4. 执行前列出 L1 清单并标注 Green / Yellow / Red,写入 `execution_policy.task_tree`。
|
|
47
|
+
L1 < 2 用 `normal`;L1 >= 2 自动用 `bounded_continuous`。
|
|
48
|
+
5. 本轮新建或重写 `task.md` 时,将 `readiness` 设为 `draft_for_confirmation` 并停止;
|
|
49
|
+
草稿不能直接执行。
|
|
50
|
+
6. 只有既有任务为 `ready_to_execute` 且无 Red 预检项,才进入执行;否则设为 `blocked`。
|
|
62
51
|
7. 不要在任务草稿模式中修改源码或业务文件。
|
|
63
52
|
|
|
64
53
|
任务草稿模式必须以下面结构结束:
|
|
@@ -108,15 +97,14 @@
|
|
|
108
97
|
2. `ai/project/runtime.md`
|
|
109
98
|
3. `ai/project/task.md`
|
|
110
99
|
|
|
111
|
-
然后按 `ai/template/execution-policy.md`
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
`ai/template/execution-policy.md` 的“用户可见输出”规则。最后把结果写入:
|
|
100
|
+
然后按 `ai/template/execution-policy.md` 规划:列 L1,标注 Green / Yellow / Red,
|
|
101
|
+
写入 `execution_policy.task_tree`,并按 L1 数量选择 `normal` 或 `bounded_continuous`。
|
|
102
|
+
只有 `readiness = ready_to_execute` 才能执行;本轮新建或重写任务契约时先停下确认。
|
|
103
|
+
L1 必须是可独立验收的垂直切片。执行 L1 前规划 L2,执行 L2 前按需规划 L3;
|
|
104
|
+
默认最多 3 层,必要时允许 L4。每完成一个 L1,在清单中打勾并划掉;仅在 L1
|
|
105
|
+
开始/完成、Red/blocked、范围变化或最终收尾时写回 `task_tree`。Red 停止确认;
|
|
106
|
+
Green 自动继续;Yellow 只做当前 L1/L2 内的局部低风险修正。用户可见输出遵守
|
|
107
|
+
“用户可见输出”规则。最后写入:
|
|
120
108
|
|
|
121
109
|
- `ai/project/result.json`
|
|
122
110
|
- `ai/project/result.md`
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# 协议
|
|
2
2
|
|
|
3
|
-
Agent Execution Template v0.8
|
|
3
|
+
Agent Execution Template v0.8 分离可复用协议和项目现场。
|
|
4
4
|
|
|
5
5
|
```text
|
|
6
6
|
ai/template/ = 可复用执行协议
|
|
7
7
|
ai/project/ = 当前项目执行工作区
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
`template` 是协议,`project`
|
|
10
|
+
`template` 是协议,`project` 是现场。
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
项目现场同时保存任务和方向层。方向层回答“为什么做、往哪里长”,执行层回答
|
|
13
|
+
“这次做什么、如何验收”。
|
|
14
14
|
|
|
15
15
|
```text
|
|
16
16
|
ai/project/refs/final-shape.md = 项目北极星说明书
|
|
@@ -26,15 +26,14 @@ ai/project/task.md = 当前执行契约
|
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
1. 项目发现时,执行 `ai/template/bootstrap.md`;不要总结它。
|
|
29
|
-
2.
|
|
30
|
-
不要只要求人类打开文件检查。
|
|
29
|
+
2. 引导结束用“引导后交接”,在聊天里给可确认摘要和推荐下一步,不只要求人类打开文件。
|
|
31
30
|
3. 任务执行时,执行 `ai/template/prompt.md`;不要总结它。
|
|
32
|
-
4.
|
|
33
|
-
|
|
34
|
-
5.
|
|
35
|
-
|
|
36
|
-
6.
|
|
37
|
-
`
|
|
31
|
+
4. 新权威资料放入 `ai/project/inbox/`,执行 `ai/template/reconcile.md`;不要总结它。
|
|
32
|
+
整合先出计划,确认后更新上下文。
|
|
33
|
+
5. 会改变最终形态、模块边界或路线图的灵感先放入 `ai/project/inbox/ideas/`,
|
|
34
|
+
再用 `strategy_update` 生成提案。
|
|
35
|
+
6. 人类确认提案后,才可用 `apply_strategy_update` 修改 `final-shape.md`、
|
|
36
|
+
`module-map.md` 或 `roadmap.md`。
|
|
38
37
|
7. 如果 `ai/project/task.md` 缺失或不完整,根据当前目标和已确认的项目上下文起草它,
|
|
39
38
|
然后用“任务草稿交接”停止。
|
|
40
39
|
8. 任务确认后,检查就绪度、风险、模型策略、引用、权限和验收。
|
|
@@ -45,12 +44,10 @@ ai/project/task.md = 当前执行契约
|
|
|
45
44
|
|
|
46
45
|
任务执行前必须读取 `ai/template/execution-policy.md`。
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
`
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
停在确认交接。只有 Red 停止等待人类确认,Yellow 只允许当前 L1/L2 内的局部
|
|
53
|
-
低风险修正。
|
|
47
|
+
默认 `auto`:AI 先拆 L1 并判断 Green / Yellow / Red,再选择 `normal` 或
|
|
48
|
+
`bounded_continuous`。L1 < 2 用 `normal`;L1 >= 2 自动启用 `bounded_continuous`。
|
|
49
|
+
L1 必须是可独立验收的垂直切片。只有既有任务 `readiness = ready_to_execute` 才能执行;
|
|
50
|
+
本轮新建或重写任务契约时先停下确认。Red 停止确认,Yellow 只允许当前 L1/L2 内的局部低风险修正。
|
|
54
51
|
|
|
55
52
|
任务树、风险分级、Checkpoint 证据和 `task_tree` 写回规则由
|
|
56
53
|
`ai/template/execution-policy.md` 定义。
|
|
@@ -62,17 +59,16 @@ ai/project/task.md = 当前执行契约
|
|
|
62
59
|
- `ai/project/project.md`
|
|
63
60
|
- `ai/project/refs/*.md`
|
|
64
61
|
|
|
65
|
-
当 `
|
|
66
|
-
使用引导模式。
|
|
62
|
+
当 `project.md` 为空、占位、过期、不完整,或用户要求整理上下文时,使用引导模式。
|
|
67
63
|
|
|
68
64
|
引导模式必须:
|
|
69
65
|
|
|
70
66
|
- 先只读取批准的引导来源;
|
|
71
67
|
- 将稳定项目事实总结到 `ai/project/project.md`;
|
|
72
|
-
-
|
|
68
|
+
- 能推断持久架构、命令、约束或决策事实时,更新聚焦引用文件;
|
|
73
69
|
- 只有在人类同时提供当前任务时,才创建 `ai/project/task.md`,且只起草任务契约;
|
|
74
70
|
- 将未知事实标记为 `Unknown`,不要猜测;
|
|
75
|
-
-
|
|
71
|
+
- 只有答案会改变范围、风险、权限或验收时,才问问题,最多 3 个;
|
|
76
72
|
- 写完项目上下文草稿后停止;如果已提供当前任务,也可以同时写任务草稿后停止;
|
|
77
73
|
- 永远不要编辑源码、业务、配置、依赖或生成文件。
|
|
78
74
|
|
|
@@ -102,12 +98,12 @@ ai/project/task.md = 当前执行契约
|
|
|
102
98
|
5. 浅层仓库结构:
|
|
103
99
|
- 只查看源码、测试、配置和文档目录。
|
|
104
100
|
|
|
105
|
-
|
|
101
|
+
文档和清单不足时,可有限读取代码推断:
|
|
106
102
|
|
|
107
103
|
- 先检查顶层目录和文件名;
|
|
108
104
|
- 检查可能的入口目录,例如 `src/`、`app/`、`lib/`、`packages/`、
|
|
109
105
|
`services/`、`cmd/`、`internal/`、`server/`、`client/`、`test/`、`tests/`;
|
|
110
|
-
-
|
|
106
|
+
- 只读取足够识别目的、模块边界、命令和约束的路由、模块、配置和测试文件;
|
|
111
107
|
- 除非人类明确授权,不要读取整个代码库。
|
|
112
108
|
|
|
113
109
|
默认不要读取:
|
|
@@ -118,7 +114,7 @@ ai/project/task.md = 当前执行契约
|
|
|
118
114
|
- `.env*` 等密钥或环境文件;
|
|
119
115
|
- 归档或历史目录,除非用户明确引用。
|
|
120
116
|
|
|
121
|
-
|
|
117
|
+
仓库很大时,先读根文档和清单,再询问是否扩展读取范围。
|
|
122
118
|
|
|
123
119
|
### 引导输出
|
|
124
120
|
|
|
@@ -160,8 +156,8 @@ ai/project/task.md = 当前执行契约
|
|
|
160
156
|
|
|
161
157
|
- `ai/project/task.md`
|
|
162
158
|
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
项目上下文已确认但 `task.md` 为空、占位、不完整,或人类提供新任务且引导尚未起草时,
|
|
160
|
+
使用任务草稿模式。
|
|
165
161
|
|
|
166
162
|
任务草稿模式应该:
|
|
167
163
|
|
|
@@ -175,7 +171,7 @@ ai/project/task.md = 当前执行契约
|
|
|
175
171
|
|
|
176
172
|
## 上下文整合模式
|
|
177
173
|
|
|
178
|
-
|
|
174
|
+
上下文整合模式吸收新权威资料,修正长期上下文。
|
|
179
175
|
|
|
180
176
|
新资料优先放入:
|
|
181
177
|
|
|
@@ -184,21 +180,20 @@ ai/project/task.md = 当前执行契约
|
|
|
184
180
|
|
|
185
181
|
已整合资料统一移动到 `ai/project/inbox/processed/`,默认不再作为待吸收资料读取。
|
|
186
182
|
|
|
187
|
-
|
|
188
|
-
执行 `ai/template/reconcile.md`。
|
|
183
|
+
用户可直接说“整合 ai/project/inbox/ 里的新资料”。整合时执行 `ai/template/reconcile.md`。
|
|
189
184
|
|
|
190
185
|
上下文整合模式必须:
|
|
191
186
|
|
|
192
187
|
- 读取现有 `ai/project/project.md`、`ai/project/runtime.md` 和 `ai/project/refs/*.md`;
|
|
193
188
|
- 读取人类指定的新资料;未指定时读取 `ai/project/inbox/*.md`;
|
|
194
189
|
- 先输出整合计划,不修改文件;
|
|
195
|
-
-
|
|
190
|
+
- 人类确认后,才更新 `ai/project/project.md`、`ai/project/runtime.md` 和 `ai/project/refs/*.md`;
|
|
196
191
|
- 应用整合后,把本次已处理的 `ai/project/inbox/*.md` 移动到 `ai/project/inbox/processed/`;
|
|
197
192
|
- 不要默认修改 `task.md`、`result.*`、`metrics.json`、源码、测试、配置或依赖文件;
|
|
198
193
|
- 不要把新资料整段塞进 refs,而是吸收长期有效、结构化、可复用的事实。
|
|
199
194
|
|
|
200
|
-
|
|
201
|
-
|
|
195
|
+
新资料若改变 `final-shape.md`、`module-map.md` 或 `roadmap.md` 的方向性内容,
|
|
196
|
+
整合只能建议 `strategy_update`,不能直接修改。
|
|
202
197
|
|
|
203
198
|
## 策略修订模式
|
|
204
199
|
|
|
@@ -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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
不要默认读取 `
|
|
37
|
-
|
|
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
|
-
-
|
|
54
|
-
-
|
|
55
|
-
|
|
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
|
-
|
|
101
|
-
`ai/project/inbox/
|
|
102
|
-
`ai/project/inbox/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
|
-
|
|
5
|
+
编辑前,确认 `ai/project/task.md` 已清楚定义:
|
|
6
6
|
|
|
7
7
|
- 目标
|
|
8
8
|
- 范围
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
|
|
19
19
|
## 引导门
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
36
|
-
此时只能起草任务契约,不能进入实现。
|
|
35
|
+
只有人类同时提供当前任务目标时,引导模式才可写 `ai/project/task.md`;只能起草,不实现。
|
|
37
36
|
|
|
38
|
-
|
|
37
|
+
引导模式不得编辑源码、测试、配置、依赖、生成文件、运行时、结果或指标文件。
|
|
39
38
|
|
|
40
39
|
写完引导草稿后,使用 `ai/template/bootstrap.md` 中的“引导后交接”停止。
|
|
41
40
|
交接必须在聊天里给出可确认摘要和推荐下一步,不要只让人类打开文件检查。
|
|
42
|
-
|
|
41
|
+
若人类已提供任务目标,可同轮起草 `task.md`,但仍必须停止确认,不能实现。
|
|
43
42
|
|
|
44
43
|
## 引导读取范围
|
|
45
44
|
|
|
@@ -60,9 +59,8 @@
|
|
|
60
59
|
|
|
61
60
|
## 任务草稿门
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
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,13 +100,12 @@
|
|
|
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
|
|
|
111
|
-
- 只有 `
|
|
112
|
-
`task.md` 时必须停在确认交接。
|
|
108
|
+
- 只有 `task.md.readiness = ready_to_execute` 才能执行;本轮新建或重写 `task.md` 时必须停下确认。
|
|
113
109
|
- L1 必须是可独立验收的垂直切片,不是机械步骤清单。
|
|
114
110
|
- `execution_policy.task_tree` 必须记录 L1 清单和执行状态。
|
|
115
111
|
- 每个任务节点必须有 Green / Yellow / Red 风险评级。
|
|
@@ -117,8 +113,8 @@
|
|
|
117
113
|
权限、安全、架构方向或验收标准。
|
|
118
114
|
- 每个 Checkpoint 必须包含证据;不接受只有主观判断的 Green。
|
|
119
115
|
- Red 必须停止等待人类确认。
|
|
120
|
-
-
|
|
121
|
-
|
|
116
|
+
- 涉及方向、核心架构、公共 API、持久化数据、安全、支付、账号、权限、大量删除、
|
|
117
|
+
核心重写或高成本取舍时,必须停止。
|
|
122
118
|
- 需要扩大范围、权限、命令、网络或验收时,必须停止。
|
|
123
119
|
- `task_tree` 写回应集中在 L1 开始/完成、Red、blocked、范围变化和最终收尾,
|
|
124
120
|
不要为每个微小 L3 操作写回。
|
|
@@ -128,9 +124,8 @@
|
|
|
128
124
|
|
|
129
125
|
## 策略修订门
|
|
130
126
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
`strategy_update`。
|
|
127
|
+
用户要求更新北极星、最终形态、产品宪法、模块地图、路线图或项目方向,或
|
|
128
|
+
`ai/project/inbox/ideas/` 有新灵感时,执行 `strategy_update`。
|
|
134
129
|
|
|
135
130
|
`strategy_update` 只能:
|
|
136
131
|
|
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,7 +83,7 @@ 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("
|
|
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");
|
|
87
89
|
assert(read(cwd, "ai/template/execution-policy.md").includes("可独立验收的垂直切片"), "execution policy should define L1 granularity");
|
|
@@ -89,6 +91,8 @@ function testInitUpdateDoctor() {
|
|
|
89
91
|
assert(read(cwd, "ai/template/execution-policy.md").includes("不要为每个微小 L3 操作写回"), "execution policy should limit task tree write-back churn");
|
|
90
92
|
assert(read(cwd, "ai/template/execution-policy.md").includes("公共接口、数据模型、权限、安全"), "execution policy should constrain Yellow corrections");
|
|
91
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");
|
|
92
96
|
assert(read(cwd, "ai/template/execution-policy.md").includes("不要默认展示完整 L2/L3/L4"), "execution policy should avoid exposing full subtask trees by default");
|
|
93
97
|
assert(read(cwd, "ai/template/execution-policy.md").includes("不要展示内部协议字段"), "execution policy should hide internal protocol details by default");
|
|
94
98
|
assert(read(cwd, "ai/template/execution-policy.md").includes("L1 为 2 个或更多,自动启用"), "protocol should auto-enable continuous execution from L1 count");
|
|
@@ -110,12 +114,12 @@ function testInitUpdateDoctor() {
|
|
|
110
114
|
assert(read(cwd, "ai/template/prompt.md").includes("不要重新 bootstrap"), "execution prompt should reconcile inbox material when project context already exists");
|
|
111
115
|
assert(read(cwd, "ai/template/prompt.md").includes("整合 ai/project/inbox/ 里的新资料"), "execution prompt should route natural reconcile entry");
|
|
112
116
|
assert(read(cwd, "ai/template/prompt.md").includes("继续推进这个项目"), "execution prompt should route natural continue entry");
|
|
113
|
-
assert(read(cwd, "ai/template/prompt.md").includes("
|
|
117
|
+
assert(read(cwd, "ai/template/prompt.md").includes("草稿不能直接执行"), "execution prompt should stop after drafting a task");
|
|
114
118
|
assert(read(cwd, "ai/template/prompt.md").includes("用户可见输出"), "execution prompt should reference user-visible output rules");
|
|
115
119
|
assert(read(cwd, "ai/template/prompt.md").includes("strategy_update"), "execution prompt should route strategy updates");
|
|
116
120
|
assert(read(cwd, "ai/template/reconcile.md").includes("上下文整合"), "init should install reconcile prompt");
|
|
117
121
|
assert(read(cwd, "ai/template/reconcile.md").includes("整合计划"), "reconcile prompt should require a plan first");
|
|
118
|
-
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");
|
|
119
123
|
assert(read(cwd, "ai/template/reconcile.md").includes("ai/project/inbox/processed/raw/file.md"), "reconcile prompt should archive absorbed raw inbox material");
|
|
120
124
|
assert(read(cwd, "ai/template/reconcile.md").includes("未吸收资料"), "reconcile handoff should audit unabsorbed material");
|
|
121
125
|
assert(read(cwd, "ai/template/reconcile.md").includes("冲突处理"), "reconcile handoff should audit conflict handling");
|
|
@@ -153,7 +157,9 @@ function testInitUpdateDoctor() {
|
|
|
153
157
|
|
|
154
158
|
const doctorOutput = run(["doctor"], cwd);
|
|
155
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");
|
|
156
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");
|
|
157
163
|
assert(doctorOutput.includes("ai/project/task.md front matter"), "doctor should validate task front matter");
|
|
158
164
|
}
|
|
159
165
|
|
|
@@ -163,6 +169,8 @@ function testEnglishInitUpdateDoctor() {
|
|
|
163
169
|
const initOutput = run(["init", "--lang", "en"], cwd);
|
|
164
170
|
assert(read(cwd, "ai/template/LANG") === "en\n", "init --lang en should install English template");
|
|
165
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");
|
|
166
174
|
assert(read(cwd, "ai/template/bootstrap.md").includes("Confirmation Dimensions"), "English init should install English bootstrap prompt");
|
|
167
175
|
assert(read(cwd, "ai/template/bootstrap.md").includes("Do not summarize this file"), "English bootstrap prompt should prevent summary-only behavior");
|
|
168
176
|
assert(read(cwd, "ai/template/bootstrap.md").includes("ai/project/refs/final-shape.md"), "English bootstrap prompt should initialize the North Star");
|
|
@@ -186,6 +194,8 @@ function testEnglishInitUpdateDoctor() {
|
|
|
186
194
|
assert(read(cwd, "ai/template/execution-policy.md").includes("every tiny L3 operation"), "English execution policy should limit task tree write-back churn");
|
|
187
195
|
assert(read(cwd, "ai/template/execution-policy.md").includes("public interfaces, data models, permissions"), "English execution policy should constrain Yellow corrections");
|
|
188
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");
|
|
189
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");
|
|
190
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");
|
|
191
201
|
assert(read(cwd, "ai/template/execution-policy.md").includes("Automatically use `bounded_continuous`"), "English protocol should auto-enable continuous execution from L1 count");
|
|
@@ -241,6 +251,7 @@ function testEnglishInitUpdateDoctor() {
|
|
|
241
251
|
const doctorOutput = run(["doctor"], cwd);
|
|
242
252
|
assert(doctorOutput.includes("Template language: en"), "doctor should show installed English language");
|
|
243
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");
|
|
244
255
|
assert(doctorOutput.includes("ai/project/task.md front matter"), "English doctor should validate task front matter");
|
|
245
256
|
assert(doctorOutput.includes("[OK] Ready to run"), "doctor should use installed English language");
|
|
246
257
|
const reconcileOutput = run(["reconcile"], cwd);
|
|
@@ -271,6 +282,60 @@ function testDoctorFailureAndWarning() {
|
|
|
271
282
|
const invalidJsonOutput = run(["doctor"], invalidJsonCwd, 1);
|
|
272
283
|
assert(invalidJsonOutput.includes("JSON 无效"), "doctor should fail invalid result JSON");
|
|
273
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
|
+
|
|
274
339
|
const taskWarnCwd = createTempProject("agent-execution-template-task-frontmatter");
|
|
275
340
|
run(["init"], taskWarnCwd);
|
|
276
341
|
write(taskWarnCwd, "ai/project/task.md", "# Task only\n");
|