@wnlen/agent-execution-template 0.8.20 → 0.8.22
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 +25 -2
- package/README.zh-CN.md +18 -0
- package/bin/agent-execution-template.js +129 -63
- package/docs/SPEC.md +65 -12
- package/package.json +1 -1
- package/template/en/ai/README.md +4 -1
- package/template/en/ai/project/task.md +13 -53
- package/template/en/ai/template/VERSION +1 -1
- package/template/en/ai/template/bootstrap.md +4 -1
- package/template/en/ai/template/execution-policy.md +28 -1
- package/template/en/ai/template/prompt.md +20 -11
- package/template/en/ai/template/protocol.md +16 -3
- package/template/zh/ai/README.md +2 -0
- package/template/zh/ai/project/task.md +8 -52
- package/template/zh/ai/template/VERSION +1 -1
- package/template/zh/ai/template/bootstrap.md +3 -1
- package/template/zh/ai/template/execution-policy.md +25 -2
- package/template/zh/ai/template/prompt.md +16 -9
- package/template/zh/ai/template/protocol.md +9 -0
- package/test/selftest.js +94 -22
package/README.md
CHANGED
|
@@ -21,6 +21,9 @@ Start initializing this project
|
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
Agent Execution Template is not another agent framework. It is the missing execution layer between your repository and tools like Codex, Claude Code, Cursor, Aider, or any other AI coding agent.
|
|
24
|
+
More precisely, it is an **AI Repo Execution Protocol**: it governs how an AI reads context, confirms a task, respects file modification boundaries, verifies acceptance, and records results inside a specific repository.
|
|
25
|
+
|
|
26
|
+
It does not manage workspace switching, session isolation, sandbox lifecycle, or worker scheduling. Those belong to an external workspace/session runtime.
|
|
24
27
|
|
|
25
28
|
It turns AI coding from:
|
|
26
29
|
|
|
@@ -56,7 +59,7 @@ ai/template/ reusable execution protocol
|
|
|
56
59
|
ai/project/ project-specific working context and direction layer
|
|
57
60
|
```
|
|
58
61
|
|
|
59
|
-
`update` can refresh the protocol, while your project
|
|
62
|
+
`update` can refresh the protocol, while your repo-local project context stays protected.
|
|
60
63
|
|
|
61
64
|
## Quick Start
|
|
62
65
|
|
|
@@ -72,6 +75,14 @@ Ask your agent to bootstrap project context from existing docs and manifests:
|
|
|
72
75
|
Start initializing this project
|
|
73
76
|
```
|
|
74
77
|
|
|
78
|
+
`init` installs compatibility managed blocks in root `AGENTS.md` and `CLAUDE.md`.
|
|
79
|
+
They have the same content and are not separate protocols; they adapt to generic
|
|
80
|
+
Agent / Codex and Claude Code discovery conventions. Compatible AI tools read
|
|
81
|
+
`ai/template/prompt.md` first, then route bootstrap to `ai/template/bootstrap.md`.
|
|
82
|
+
If your AI tool does not auto-read those root
|
|
83
|
+
entrypoints, ask it to read `AGENTS.md` or `CLAUDE.md` before sending the
|
|
84
|
+
initialization instruction above.
|
|
85
|
+
|
|
75
86
|
The agent will generate project context and summarize what needs confirmation,
|
|
76
87
|
risks, and the recommended next step in chat:
|
|
77
88
|
|
|
@@ -170,6 +181,12 @@ acceptable vertical slice, not a mechanical step checklist:
|
|
|
170
181
|
- [ ] L1-3 Export entrypoint Yellow
|
|
171
182
|
```
|
|
172
183
|
|
|
184
|
+
Simple tasks are not buried under a full process form. A single-L1, Green,
|
|
185
|
+
low-risk task uses a compact task contract with only the goal, scope,
|
|
186
|
+
acceptance, permissions, verification commands, and minimal `task_tree`.
|
|
187
|
+
Multi-L1, Yellow/Red, cross-module, continuously executed, or highly uncertain
|
|
188
|
+
tasks use an expanded task contract.
|
|
189
|
+
|
|
173
190
|
Because there are two or more L1 tasks, the protocol automatically uses bounded
|
|
174
191
|
continuous execution. Before each L1, the AI plans naturally derived L2/L3 work.
|
|
175
192
|
After completing an L1, it checks and strikes the item. `task_tree` is written
|
|
@@ -228,7 +245,7 @@ ai/
|
|
|
228
245
|
The split is the core design:
|
|
229
246
|
|
|
230
247
|
- `ai/template/**` is reusable protocol. It can be safely updated from this package.
|
|
231
|
-
- `ai/project/**` is your project
|
|
248
|
+
- `ai/project/**` is your repo-local project context. It stores local context, tasks, references, results, and metrics.
|
|
232
249
|
|
|
233
250
|
## Commands
|
|
234
251
|
|
|
@@ -243,6 +260,8 @@ Creates `ai/` in the current project.
|
|
|
243
260
|
- Updates or creates `ai/template/**`.
|
|
244
261
|
- Creates missing `ai/project/**` files.
|
|
245
262
|
- Keeps existing `ai/project/**` files intact.
|
|
263
|
+
- Creates or updates the same compatibility managed block in root `AGENTS.md` /
|
|
264
|
+
`CLAUDE.md` so different AI tools can discover the protocol entrypoint.
|
|
246
265
|
- Use `--lang zh` or omit `--lang` for the Chinese template.
|
|
247
266
|
|
|
248
267
|
### `next`
|
|
@@ -425,12 +444,16 @@ Agent Execution Template is not:
|
|
|
425
444
|
- an IDE,
|
|
426
445
|
- an agent platform,
|
|
427
446
|
- a multi-agent scheduler,
|
|
447
|
+
- a workspace / sandbox / session runtime,
|
|
448
|
+
- a multi-repository context manager,
|
|
428
449
|
- a cloud service,
|
|
429
450
|
- a prompt collection,
|
|
430
451
|
- a replacement for Codex, Claude Code, Cursor, or Aider.
|
|
431
452
|
|
|
432
453
|
It is a small file protocol for making those tools behave more consistently inside real software projects.
|
|
433
454
|
|
|
455
|
+
It does not handle workspace switching, sandbox lifecycle, session fork / rollback, or worker scheduling. Conversely, an external runtime should not replace in-repository task definitions, file modification rules, acceptance criteria, or concrete coding context.
|
|
456
|
+
|
|
434
457
|
## Specification
|
|
435
458
|
|
|
436
459
|
- [Full specification](docs/SPEC.md)
|
package/README.zh-CN.md
CHANGED
|
@@ -27,6 +27,9 @@ npx -y @wnlen/agent-execution-template init --lang zh
|
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
Agent Execution Template 不是新的 Agent 框架。它是代码仓库和 Codex、Claude Code、Cursor、Aider 等 AI Coding Agent 之间缺失的执行层。
|
|
30
|
+
更准确地说,它是 **AI Repo Execution Protocol**:只约束 AI 在某个仓库内如何读取上下文、确认任务、遵守文件修改边界、验收并记录结果。
|
|
31
|
+
|
|
32
|
+
它不管理 workspace 切换、Session 隔离、sandbox 生命周期或 worker 调度。这些属于外部 workspace/session runtime。
|
|
30
33
|
|
|
31
34
|
它把 AI 编程从:
|
|
32
35
|
|
|
@@ -83,6 +86,12 @@ npx -y @wnlen/agent-execution-template init --lang en
|
|
|
83
86
|
开始初始化这个项目
|
|
84
87
|
```
|
|
85
88
|
|
|
89
|
+
`init` 会在仓库根目录安装 `AGENTS.md` 和 `CLAUDE.md` 兼容入口托管块。两者内容相同,
|
|
90
|
+
不是两套协议;它们分别适配通用 Agent / Codex 和 Claude Code 的自动发现约定。
|
|
91
|
+
支持这些入口的 AI 工具会先读取 `ai/template/prompt.md`,再路由到 `ai/template/bootstrap.md`。
|
|
92
|
+
如果你的 AI 工具没有自动读取根目录入口文件,请先让它读取 `AGENTS.md` 或
|
|
93
|
+
`CLAUDE.md`,再发送上面的初始化指令。
|
|
94
|
+
|
|
86
95
|
Agent 会生成项目上下文,并在聊天里给出需要确认的摘要、风险和建议下一步:
|
|
87
96
|
|
|
88
97
|
```text
|
|
@@ -179,6 +188,10 @@ AI 会在执行前先拆 L1 任务。L1 必须是可独立验收的垂直切片
|
|
|
179
188
|
- [ ] L1-3 导出入口 Yellow
|
|
180
189
|
```
|
|
181
190
|
|
|
191
|
+
简单任务不会被完整流程表单淹没。单 L1、Green、低风险任务使用 compact task
|
|
192
|
+
contract,只保留目标、范围、验收、权限、验证命令和最小 `task_tree`。多 L1、
|
|
193
|
+
Yellow/Red、跨模块、连续执行或高不确定任务才使用 expanded task contract。
|
|
194
|
+
|
|
182
195
|
因为 L1 有两个以上,协议会自动使用边界内连续执行。执行每个 L1 前,AI 再规划
|
|
183
196
|
自然衍生的 L2/L3;完成一个 L1 后,在清单中打勾并划掉。`task_tree` 只在
|
|
184
197
|
L1 开始/完成、Red/blocked、范围变化或最终收尾时写回,避免为微小步骤反复改文件。
|
|
@@ -247,6 +260,7 @@ npx -y @wnlen/agent-execution-template init
|
|
|
247
260
|
- 更新或创建 `ai/template/**`。
|
|
248
261
|
- 创建缺失的 `ai/project/**` 文件。
|
|
249
262
|
- 保留已有的 `ai/project/**` 文件。
|
|
263
|
+
- 创建或更新根目录 `AGENTS.md` / `CLAUDE.md` 中的同内容兼容托管块,让不同 AI 工具能发现协议入口。
|
|
250
264
|
- 默认安装中文模板;英文模板使用 `--lang en`。
|
|
251
265
|
|
|
252
266
|
### `next`
|
|
@@ -426,12 +440,16 @@ Agent Execution Template 不是:
|
|
|
426
440
|
- IDE;
|
|
427
441
|
- Agent 平台;
|
|
428
442
|
- 多 Agent 调度器;
|
|
443
|
+
- workspace / sandbox / session 运行时;
|
|
444
|
+
- 多仓库上下文管理器;
|
|
429
445
|
- 云服务;
|
|
430
446
|
- 提示词合集;
|
|
431
447
|
- Codex、Claude Code、Cursor 或 Aider 的替代品。
|
|
432
448
|
|
|
433
449
|
它是一个小型文件协议,用来让这些工具在真实软件项目中表现得更稳定。
|
|
434
450
|
|
|
451
|
+
它不负责 workspace 切换、sandbox 生命周期、session fork / rollback 或 worker 调度。反过来,外部运行时不应该替代仓库内的任务定义、文件修改规则、acceptance criteria 或具体编码上下文。
|
|
452
|
+
|
|
435
453
|
## 规格
|
|
436
454
|
|
|
437
455
|
- [完整规格](docs/SPEC.md)
|
|
@@ -8,6 +8,9 @@ const TEMPLATE_ROOT = path.join(PACKAGE_ROOT, "template");
|
|
|
8
8
|
const TARGET_AI = path.join(process.cwd(), "ai");
|
|
9
9
|
const DEFAULT_LANG = "zh";
|
|
10
10
|
const SUPPORTED_LANGS = new Set(["zh", "en"]);
|
|
11
|
+
const ROOT_ENTRYPOINT_FILES = ["AGENTS.md", "CLAUDE.md"];
|
|
12
|
+
const ENTRYPOINT_BLOCK_START = "<!-- agent-execution-template:start -->";
|
|
13
|
+
const ENTRYPOINT_BLOCK_END = "<!-- agent-execution-template:end -->";
|
|
11
14
|
|
|
12
15
|
const REQUIRED_FILES = [
|
|
13
16
|
"ai/template/LANG",
|
|
@@ -49,11 +52,7 @@ const TASK_HEALTH_PATTERNS = [
|
|
|
49
52
|
/^readiness:\s*/m,
|
|
50
53
|
/^execution_policy:/m,
|
|
51
54
|
/^\s+mode:\s*/m,
|
|
52
|
-
/^\s+activation_rule:\s*/m,
|
|
53
55
|
/^\s+task_tree:/m,
|
|
54
|
-
/^\s+risk_gate:/m,
|
|
55
|
-
/^\s+evidence_required:\s*/m,
|
|
56
|
-
/^model_policy:/m,
|
|
57
56
|
/^refs:/m,
|
|
58
57
|
/^permission:/m
|
|
59
58
|
];
|
|
@@ -74,31 +73,24 @@ const TEXT = {
|
|
|
74
73
|
`,
|
|
75
74
|
unknown: "未知",
|
|
76
75
|
sourceMissing: "找不到模板来源",
|
|
77
|
-
ready: "Agent Execution Template
|
|
78
|
-
initGuide:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
对 AI 说: 把 ai/project/inbox/ideas/ 里的新灵感生成方向修订提案
|
|
96
|
-
5. 查看下一步
|
|
97
|
-
运行命令: npx -y @wnlen/agent-execution-template next
|
|
98
|
-
|
|
99
|
-
[区分标准]
|
|
100
|
-
资料 = 已确定的事实、文档、流程、接口、业务规则
|
|
101
|
-
方向 = 还没决定的新想法、产品策略、架构调整、路线变化`,
|
|
76
|
+
ready: "Agent Execution Template 协议已安装。项目上下文尚未初始化。",
|
|
77
|
+
initGuide: `下一步,把这句话发给你的 AI coding 工具:
|
|
78
|
+
|
|
79
|
+
开始初始化这个项目
|
|
80
|
+
|
|
81
|
+
如果你已经有确定资料:
|
|
82
|
+
1. 放到 ai/project/inbox/
|
|
83
|
+
2. 对 AI 说: 开始初始化这个项目,并吸收 ai/project/inbox/ 里的资料
|
|
84
|
+
|
|
85
|
+
资料路径:
|
|
86
|
+
- 已确定资料: ai/project/inbox/
|
|
87
|
+
- 未决定的新想法: ai/project/inbox/ideas/
|
|
88
|
+
|
|
89
|
+
忘了下一步时运行:
|
|
90
|
+
npx -y @wnlen/agent-execution-template next
|
|
91
|
+
|
|
92
|
+
已完成:
|
|
93
|
+
- 根目录 AI 入口: AGENTS.md / CLAUDE.md`,
|
|
102
94
|
start: "开始:",
|
|
103
95
|
startPrompt: "开始初始化这个项目",
|
|
104
96
|
then: "然后:",
|
|
@@ -107,8 +99,8 @@ const TEXT = {
|
|
|
107
99
|
confirmTask: "需要吸收新资料时,先放入 ai/project/inbox/,然后说:",
|
|
108
100
|
executePrompt: "整合 ai/project/inbox/ 里的新资料",
|
|
109
101
|
strategyHint: "需要修订方向时,先放入 ai/project/inbox/ideas/,然后生成 strategy_update 提案。",
|
|
110
|
-
files: "
|
|
111
|
-
check: "
|
|
102
|
+
files: "文件已就绪",
|
|
103
|
+
check: "检查安装",
|
|
112
104
|
details: "详情:",
|
|
113
105
|
refreshTitle: "Agent Execution Template 项目上下文重整",
|
|
114
106
|
improveContextTitle: "Agent Execution Template 上下文总结优化",
|
|
@@ -131,6 +123,8 @@ const TEXT = {
|
|
|
131
123
|
invalidJson: "JSON 无效",
|
|
132
124
|
invalidSchema: "不符合协议 schema",
|
|
133
125
|
taskFrontMatterIncomplete: "任务 front matter 缺少关键字段",
|
|
126
|
+
entrypointReady: "根目录 AI 兼容入口已安装: AGENTS.md / CLAUDE.md",
|
|
127
|
+
entrypointMissing: "缺少根目录 AI 兼容入口托管块;AI 可能不会自动读取 ai/template/prompt.md",
|
|
134
128
|
versionMismatch: "模板版本与包版本不一致",
|
|
135
129
|
runInit: "请运行 npx -y @wnlen/agent-execution-template init",
|
|
136
130
|
readyWithWarnings: "已就绪,但存在警告",
|
|
@@ -184,31 +178,24 @@ Usage:
|
|
|
184
178
|
`,
|
|
185
179
|
unknown: "unknown",
|
|
186
180
|
sourceMissing: "Template source not found",
|
|
187
|
-
ready: "Agent Execution Template
|
|
188
|
-
initGuide: `
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
Tell the AI: Generate a direction amendment proposal from ai/project/inbox/ideas/
|
|
206
|
-
5. Show next step
|
|
207
|
-
Run: npx -y @wnlen/agent-execution-template next
|
|
208
|
-
|
|
209
|
-
[Rule of thumb]
|
|
210
|
-
Material = confirmed facts, docs, workflows, APIs, or business rules
|
|
211
|
-
Direction = undecided ideas, product strategy, architecture changes, or roadmap changes`,
|
|
181
|
+
ready: "Agent Execution Template protocol installed. Project context is not initialized yet.",
|
|
182
|
+
initGuide: `Next, send this to your AI coding tool:
|
|
183
|
+
|
|
184
|
+
Start initializing this project
|
|
185
|
+
|
|
186
|
+
If you already have confirmed material:
|
|
187
|
+
1. Put it in ai/project/inbox/
|
|
188
|
+
2. Tell the AI: Start initializing this project and absorb the material in ai/project/inbox/
|
|
189
|
+
|
|
190
|
+
Material paths:
|
|
191
|
+
- Confirmed material: ai/project/inbox/
|
|
192
|
+
- Undecided ideas: ai/project/inbox/ideas/
|
|
193
|
+
|
|
194
|
+
If you forget the next step, run:
|
|
195
|
+
npx -y @wnlen/agent-execution-template next
|
|
196
|
+
|
|
197
|
+
Completed:
|
|
198
|
+
- Root AI entrypoints: AGENTS.md / CLAUDE.md`,
|
|
212
199
|
start: "Start:",
|
|
213
200
|
startPrompt: "Start initializing this project",
|
|
214
201
|
then: "Then:",
|
|
@@ -217,8 +204,8 @@ Usage:
|
|
|
217
204
|
confirmTask: "When you need to absorb new material, put it in ai/project/inbox/, then say:",
|
|
218
205
|
executePrompt: "Reconcile the new material in ai/project/inbox/",
|
|
219
206
|
strategyHint: "When direction changes, put ideas in ai/project/inbox/ideas/ and produce a strategy_update proposal.",
|
|
220
|
-
files: "Files",
|
|
221
|
-
check: "Check",
|
|
207
|
+
files: "Files ready",
|
|
208
|
+
check: "Check install",
|
|
222
209
|
details: "Details:",
|
|
223
210
|
refreshTitle: "Agent Execution Template project context refresh",
|
|
224
211
|
improveContextTitle: "Agent Execution Template project context improvement",
|
|
@@ -241,6 +228,8 @@ Usage:
|
|
|
241
228
|
invalidJson: "contains invalid JSON",
|
|
242
229
|
invalidSchema: "does not match protocol schema",
|
|
243
230
|
taskFrontMatterIncomplete: "task front matter is missing required fields",
|
|
231
|
+
entrypointReady: "root AI compatibility entrypoints installed: AGENTS.md / CLAUDE.md",
|
|
232
|
+
entrypointMissing: "missing root AI compatibility entrypoint managed block; the AI may not auto-read ai/template/prompt.md",
|
|
244
233
|
versionMismatch: "template version does not match package version",
|
|
245
234
|
runInit: "Run npx -y @wnlen/agent-execution-template init",
|
|
246
235
|
readyWithWarnings: "Ready to run with warnings",
|
|
@@ -397,6 +386,72 @@ function copyTree(sourceRoot, targetRoot, overwrite) {
|
|
|
397
386
|
);
|
|
398
387
|
}
|
|
399
388
|
|
|
389
|
+
function rootEntrypointBlock(lang) {
|
|
390
|
+
if (lang === "en") {
|
|
391
|
+
return `${ENTRYPOINT_BLOCK_START}
|
|
392
|
+
## Agent Execution Template
|
|
393
|
+
|
|
394
|
+
This repository has Agent Execution Template installed in \`ai/\`.
|
|
395
|
+
This managed block is intentionally duplicated in \`AGENTS.md\` and \`CLAUDE.md\` for different AI tool discovery conventions.
|
|
396
|
+
|
|
397
|
+
Mandatory routing:
|
|
398
|
+
- Before acting on any project request, first read and follow \`ai/template/prompt.md\`.
|
|
399
|
+
- If the user says "Start initializing this project" or asks to initialize/bootstrap project context, do not run installs, create lockfiles, or edit app files before \`ai/template/prompt.md\` routes the workflow.
|
|
400
|
+
${ENTRYPOINT_BLOCK_END}`;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return `${ENTRYPOINT_BLOCK_START}
|
|
404
|
+
## Agent Execution Template
|
|
405
|
+
|
|
406
|
+
本仓库已安装 Agent Execution Template,协议位于 \`ai/\`。
|
|
407
|
+
此托管块会有意同时写入 \`AGENTS.md\` 和 \`CLAUDE.md\`,用于适配不同 AI 工具的自动发现约定。
|
|
408
|
+
|
|
409
|
+
强制路由:
|
|
410
|
+
- 处理任何项目请求前,必须先读取并遵守 \`ai/template/prompt.md\`。
|
|
411
|
+
- 如果用户说“开始初始化这个项目”或要求初始化/整理项目上下文,在 \`ai/template/prompt.md\` 完成路由前,不要运行安装命令、不要创建 lockfile、不要编辑业务文件。
|
|
412
|
+
${ENTRYPOINT_BLOCK_END}`;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function hasManagedEntrypointBlock(content) {
|
|
416
|
+
return content.includes(ENTRYPOINT_BLOCK_START) && content.includes(ENTRYPOINT_BLOCK_END);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function upsertManagedBlock(content, block) {
|
|
420
|
+
if (!hasManagedEntrypointBlock(content)) {
|
|
421
|
+
const separator = content.trim().length > 0 ? "\n\n" : "";
|
|
422
|
+
return `${content.replace(/\s*$/, "")}${separator}${block}\n`;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
const start = content.indexOf(ENTRYPOINT_BLOCK_START);
|
|
426
|
+
const end = content.indexOf(ENTRYPOINT_BLOCK_END, start) + ENTRYPOINT_BLOCK_END.length;
|
|
427
|
+
return `${content.slice(0, start)}${block}${content.slice(end)}`;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function ensureRootEntrypoints(lang) {
|
|
431
|
+
const block = rootEntrypointBlock(lang);
|
|
432
|
+
const changes = [];
|
|
433
|
+
for (const file of ROOT_ENTRYPOINT_FILES) {
|
|
434
|
+
const fullPath = path.join(process.cwd(), file);
|
|
435
|
+
const existed = fs.existsSync(fullPath);
|
|
436
|
+
const current = existed ? fs.readFileSync(fullPath, "utf8") : "";
|
|
437
|
+
const next = upsertManagedBlock(current, block);
|
|
438
|
+
if (existed && current === next) {
|
|
439
|
+
changes.push({ action: "kept", path: file });
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
fs.writeFileSync(fullPath, next);
|
|
443
|
+
changes.push({ action: existed ? "updated" : "created", path: file });
|
|
444
|
+
}
|
|
445
|
+
return changes;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function hasAllRootEntrypoints() {
|
|
449
|
+
return ROOT_ENTRYPOINT_FILES.every((file) => {
|
|
450
|
+
const fullPath = path.join(process.cwd(), file);
|
|
451
|
+
return fs.existsSync(fullPath) && hasManagedEntrypointBlock(fs.readFileSync(fullPath, "utf8"));
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
|
|
400
455
|
function formatTimestamp(date = new Date()) {
|
|
401
456
|
const pad = (value) => String(value).padStart(2, "0");
|
|
402
457
|
return [
|
|
@@ -495,7 +550,7 @@ function proposalState() {
|
|
|
495
550
|
return hasProposed ? "proposed" : null;
|
|
496
551
|
}
|
|
497
552
|
|
|
498
|
-
function init({ lang = DEFAULT_LANG, verbose = false, quiet = false } = {}) {
|
|
553
|
+
function init({ lang = DEFAULT_LANG, verbose = false, quiet = false, manageEntrypoints = true } = {}) {
|
|
499
554
|
const text = getText(lang);
|
|
500
555
|
if (!SUPPORTED_LANGS.has(lang)) {
|
|
501
556
|
console.error(`[${text.fail}] ${text.invalidLang}: ${lang}`);
|
|
@@ -522,13 +577,16 @@ function init({ lang = DEFAULT_LANG, verbose = false, quiet = false } = {}) {
|
|
|
522
577
|
changes.push(...copyTree(path.join(sourceAi, "project"), path.join(TARGET_AI, "project"), false)
|
|
523
578
|
.map((change) => ({ ...change, path: path.join("ai/project", change.path) })));
|
|
524
579
|
|
|
580
|
+
if (manageEntrypoints) {
|
|
581
|
+
changes.push(...ensureRootEntrypoints(lang));
|
|
582
|
+
}
|
|
583
|
+
|
|
525
584
|
if (!quiet) {
|
|
526
|
-
const sourceNotice = isSourceCheckout() ?
|
|
585
|
+
const sourceNotice = isSourceCheckout() ? `\n${text.sourceCheckoutNotice}` : "";
|
|
527
586
|
console.log(`${text.ready}
|
|
528
587
|
|
|
529
|
-
${text.initGuide}
|
|
588
|
+
${text.initGuide}${sourceNotice}
|
|
530
589
|
|
|
531
|
-
${sourceNotice}
|
|
532
590
|
${text.files}: ${summarizeChanges(changes, lang)}
|
|
533
591
|
${text.check}: ${commandHint("doctor")}
|
|
534
592
|
`);
|
|
@@ -559,7 +617,7 @@ function refresh({ lang = DEFAULT_LANG, title } = {}) {
|
|
|
559
617
|
const backupPath = uniqueBackupPath(path.join(TARGET_AI, `project.backup.${formatTimestamp()}`));
|
|
560
618
|
fs.renameSync(projectPath, backupPath);
|
|
561
619
|
|
|
562
|
-
init({ lang, verbose: false, quiet: true });
|
|
620
|
+
init({ lang, verbose: false, quiet: true, manageEntrypoints: false });
|
|
563
621
|
|
|
564
622
|
const importPath = path.join(TARGET_AI, "project", "inbox", "raw", "old-project");
|
|
565
623
|
ensureDir(importPath);
|
|
@@ -653,6 +711,7 @@ function update({ lang = readInstalledLang() } = {}) {
|
|
|
653
711
|
ensureDir(targetTemplate);
|
|
654
712
|
const changes = copyTree(sourceTemplate, targetTemplate, true)
|
|
655
713
|
.map((change) => ({ ...change, path: path.join("ai/template", change.path) }));
|
|
714
|
+
changes.push(...ensureRootEntrypoints(lang));
|
|
656
715
|
printChanges(text.updateTitle, changes, lang);
|
|
657
716
|
console.log(`[${text.pass}] ${text.updated} ${readVersion(sourceTemplate) || text.unknown}. ${text.projectNotModified}`);
|
|
658
717
|
}
|
|
@@ -866,6 +925,13 @@ function doctor() {
|
|
|
866
925
|
console.log(`[${text.pass}] ${file}`);
|
|
867
926
|
}
|
|
868
927
|
|
|
928
|
+
if (hasAllRootEntrypoints()) {
|
|
929
|
+
console.log(`[${text.pass}] ${text.entrypointReady}`);
|
|
930
|
+
} else {
|
|
931
|
+
console.log(`[${text.warn}] ${text.entrypointMissing}`);
|
|
932
|
+
warnings += 1;
|
|
933
|
+
}
|
|
934
|
+
|
|
869
935
|
const schemaChecks = [
|
|
870
936
|
["ai/project/result.json", "ai/template/schemas/result.schema.json"],
|
|
871
937
|
["ai/project/metrics.json", "ai/template/schemas/metrics.schema.json"]
|
package/docs/SPEC.md
CHANGED
|
@@ -8,7 +8,7 @@ Current protocol: v0.8
|
|
|
8
8
|
|
|
9
9
|
## 2. 一句话定位
|
|
10
10
|
|
|
11
|
-
**Agent Execution Template 是一个 30 秒可安装、可升级、保护用户项目现场的 AI
|
|
11
|
+
**Agent Execution Template 是一个 30 秒可安装、可升级、保护用户项目现场的 AI Repo Execution Protocol。**
|
|
12
12
|
|
|
13
13
|
它把 AI 编程从“聊天式执行”变成:
|
|
14
14
|
|
|
@@ -18,11 +18,13 @@ npx 安装协议 -> AI 整理项目上下文 -> 人类确认 -> AI 生成任务
|
|
|
18
18
|
|
|
19
19
|
当前版本的核心不是做一个新的 Agent,也不是做复杂调度系统,而是给 Codex、Claude Code、Cursor、Aider 等 AI Coding Agent 提供同一套项目内执行协议。
|
|
20
20
|
|
|
21
|
+
它只管 AI 在某个仓库内怎么干活:当前任务是什么、哪些文件能改、需要读哪些上下文、执行结果怎么记录、如何审计本次任务,以及 Agent 进入项目后先读什么。
|
|
22
|
+
|
|
21
23
|
## 3. 当前版本
|
|
22
24
|
|
|
23
25
|
```text
|
|
24
26
|
Protocol: v0.8
|
|
25
|
-
Package: @wnlen/agent-execution-template@0.8.
|
|
27
|
+
Package: @wnlen/agent-execution-template@0.8.22
|
|
26
28
|
中文安装: npx -y @wnlen/agent-execution-template init
|
|
27
29
|
英文安装: npx -y @wnlen/agent-execution-template init --lang en
|
|
28
30
|
```
|
|
@@ -33,6 +35,7 @@ Package: @wnlen/agent-execution-template@0.8.19
|
|
|
33
35
|
- `init` / `next` / `refresh` / `improve-context` / `update` / `reconcile` / `strategy` / `doctor` 命令;
|
|
34
36
|
- `init --lang zh|en` 双语安装入口,默认中文;
|
|
35
37
|
- `template/project` 双区结构;
|
|
38
|
+
- 根目录 AI 兼容入口托管块:`AGENTS.md` / `CLAUDE.md`;
|
|
36
39
|
- 保护 `ai/project/**` 不被升级覆盖;
|
|
37
40
|
- 模板版本文件 `ai/template/VERSION`;
|
|
38
41
|
- 引导模式:通过 `ai/template/bootstrap.md` 从受控范围内的项目文档、manifest 和必要代码生成 `project.md` / refs 草稿;
|
|
@@ -70,6 +73,8 @@ Agent Execution Template 不是:
|
|
|
70
73
|
- AI IDE;
|
|
71
74
|
- Agent 平台;
|
|
72
75
|
- 多 Agent 调度器;
|
|
76
|
+
- workspace / sandbox / session 运行时;
|
|
77
|
+
- 多仓库上下文管理器;
|
|
73
78
|
- 任务队列系统;
|
|
74
79
|
- 云服务;
|
|
75
80
|
- Prompt Collection;
|
|
@@ -81,6 +86,20 @@ Agent Execution Template 不是:
|
|
|
81
86
|
AI Coding Agent 在项目里工作的文件协议和安全边界。
|
|
82
87
|
```
|
|
83
88
|
|
|
89
|
+
明确禁止混淆:
|
|
90
|
+
|
|
91
|
+
- Agent Execution Template 不做 workspace 切换、多仓库管理、sandbox 生命周期、session fork / rollback 或 worker 调度。
|
|
92
|
+
- 与外部运行时集成时,不应把业务任务定义、项目最终形态说明、仓库内文件修改规则、acceptance criteria 或具体编码上下文移出本协议。
|
|
93
|
+
|
|
94
|
+
与 `openclaw-workspaces` 这类外部运行时一起使用时,推荐分工是:
|
|
95
|
+
|
|
96
|
+
```text
|
|
97
|
+
openclaw-workspaces = AI Workspace & Session Runtime
|
|
98
|
+
agent-execution-template = AI Repo Execution Protocol
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
外部运行时负责仓库外能力,例如创建独立 workspace、切换项目上下文、保存/恢复/打包 session、管理 worker/agent 运行环境、隔离污染,以及未来承载多 Agent Task Graph。
|
|
102
|
+
|
|
84
103
|
## 6. 安装与日常使用
|
|
85
104
|
|
|
86
105
|
在任意项目根目录执行:
|
|
@@ -225,6 +244,8 @@ template 是协议。
|
|
|
225
244
|
project 是现场。
|
|
226
245
|
```
|
|
227
246
|
|
|
247
|
+
这里的“项目现场”只指某个仓库内的 `ai/project/**` 执行上下文,不是跨项目 workspace/runtime。外部 workspace、session 和 sandbox 生命周期应由外部运行时管理。
|
|
248
|
+
|
|
228
249
|
## 8. template 区与 project 区
|
|
229
250
|
|
|
230
251
|
### 8.1 `ai/template/`
|
|
@@ -301,6 +322,7 @@ npx -y @wnlen/agent-execution-template init
|
|
|
301
322
|
- 创建缺失的 `ai/project/**` 文件;
|
|
302
323
|
- 不覆盖已有 `ai/project/**`;
|
|
303
324
|
- 安装或覆盖 `ai/template/**`;
|
|
325
|
+
- 创建或更新根目录 `AGENTS.md` / `CLAUDE.md` 中的同内容兼容托管块;
|
|
304
326
|
- 支持 `--lang zh|en`,默认中文;
|
|
305
327
|
- 输出下一步使用说明。
|
|
306
328
|
|
|
@@ -310,6 +332,11 @@ npx -y @wnlen/agent-execution-template init
|
|
|
310
332
|
init 可以安装模板协议,但不能覆盖用户现场。
|
|
311
333
|
```
|
|
312
334
|
|
|
335
|
+
根目录 AI 兼容入口文件只管理 `agent-execution-template` 标记块,不能覆盖用户已有
|
|
336
|
+
`AGENTS.md` 或 `CLAUDE.md` 内容。两个文件中的托管块内容必须一致;这不是两套协议,
|
|
337
|
+
而是分别适配通用 Agent / Codex 和 Claude Code 的自动发现约定。托管块必须要求 AI 在“开始初始化这个项目”时先读
|
|
338
|
+
`ai/template/prompt.md`,再由它路由到 `ai/template/bootstrap.md`。
|
|
339
|
+
|
|
313
340
|
### 9.2 `update`
|
|
314
341
|
|
|
315
342
|
```bash
|
|
@@ -319,6 +346,7 @@ npx -y @wnlen/agent-execution-template update
|
|
|
319
346
|
作用:
|
|
320
347
|
|
|
321
348
|
- 只更新 `ai/template/**`;
|
|
349
|
+
- 刷新根目录 AI 兼容入口文件中的托管块;
|
|
322
350
|
- 绝不修改 `ai/project/**`;
|
|
323
351
|
- 默认沿用 `ai/template/LANG` 中记录的已安装语言;
|
|
324
352
|
- 输出更新文件列表和模板版本。
|
|
@@ -392,7 +420,7 @@ npx -y @wnlen/agent-execution-template doctor
|
|
|
392
420
|
```text
|
|
393
421
|
Agent Execution Template 检查
|
|
394
422
|
|
|
395
|
-
模板版本: 0.8.
|
|
423
|
+
模板版本: 0.8.22
|
|
396
424
|
模板语言: zh
|
|
397
425
|
|
|
398
426
|
[通过] ai/template/LANG
|
|
@@ -448,6 +476,13 @@ npx -y @wnlen/agent-execution-template reconcile
|
|
|
448
476
|
开始初始化这个项目
|
|
449
477
|
```
|
|
450
478
|
|
|
479
|
+
为了让 AI 工具能发现这个入口,`init` 会在仓库根目录安装 `AGENTS.md` 和
|
|
480
|
+
`CLAUDE.md` 兼容入口托管块。两个托管块内容相同,不代表两套协议;它们分别适配不同
|
|
481
|
+
AI 工具的自动发现约定。兼容这些入口的 AI 工具必须先读取托管块,再读取
|
|
482
|
+
`ai/template/prompt.md`,最后由 `prompt.md` 路由到 `ai/template/bootstrap.md`。
|
|
483
|
+
如果宿主工具没有自动读取根目录入口,人类应先要求它读取 `AGENTS.md` 或
|
|
484
|
+
`CLAUDE.md`。
|
|
485
|
+
|
|
451
486
|
面向用户的任务执行入口是:
|
|
452
487
|
|
|
453
488
|
```text
|
|
@@ -469,17 +504,18 @@ npx -y @wnlen/agent-execution-template reconcile
|
|
|
469
504
|
内部协议入口分别由 `ai/template/bootstrap.md`、`ai/template/prompt.md` 和
|
|
470
505
|
`ai/template/reconcile.md` 承载,用户不需要记忆这些文件名。
|
|
471
506
|
|
|
472
|
-
|
|
507
|
+
执行入口采用懒加载。AI Agent 先读:
|
|
473
508
|
|
|
474
509
|
```text
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
3. ai/project/project.md
|
|
478
|
-
4. ai/project/runtime.md
|
|
479
|
-
5. ai/project/task.md
|
|
510
|
+
0. AGENTS.md 或 CLAUDE.md 中的同内容 agent-execution-template 兼容托管块
|
|
511
|
+
1. ai/template/prompt.md
|
|
480
512
|
```
|
|
481
513
|
|
|
482
|
-
|
|
514
|
+
`prompt.md` 只做模式路由:初始化时再读 `bootstrap.md`;整合时再读
|
|
515
|
+
`reconcile.md`;执行任务时才读 `protocol.md`、`rules/core.md`、
|
|
516
|
+
`execution-policy.md`、`project.md`、`runtime.md` 和 `task.md`。
|
|
517
|
+
|
|
518
|
+
执行完成后写入:
|
|
483
519
|
|
|
484
520
|
```text
|
|
485
521
|
ai/project/result.json
|
|
@@ -540,12 +576,15 @@ ai/project/task.md
|
|
|
540
576
|
|
|
541
577
|
AI 在引导模式中负责先生成项目上下文草稿。默认读取范围包括:
|
|
542
578
|
|
|
543
|
-
- 根目录文档:`README*`、`
|
|
579
|
+
- 根目录文档:`README*`、`CONTRIBUTING*`、`CHANGELOG*`;
|
|
544
580
|
- package/build manifest:`package.json`、`pyproject.toml`、`Cargo.toml`、`go.mod`、`pom.xml`、`build.gradle*`、`Makefile`;
|
|
545
581
|
- 项目文档:`docs/**`,优先 overview、architecture、setup、testing、deployment、API、ADR、decision;
|
|
546
582
|
- 已有 AI refs:`ai/project/refs/*.md`;
|
|
547
583
|
- source / test / config / docs 的浅层目录结构。
|
|
548
584
|
|
|
585
|
+
`AGENTS.md` 和 `CLAUDE.md` 是同内容 AI 入口路由文件,只用于宿主工具自动发现,
|
|
586
|
+
不作为项目业务证据读取。
|
|
587
|
+
|
|
549
588
|
如果文档和 manifest 不足,允许从业务代码做有边界推断:
|
|
550
589
|
|
|
551
590
|
- 先看顶层目录和文件名;
|
|
@@ -658,6 +697,16 @@ ai/project/task.md.execution_policy
|
|
|
658
697
|
ai/template/execution-policy.md
|
|
659
698
|
```
|
|
660
699
|
|
|
700
|
+
`ai/project/task.md` 支持两种契约形态:
|
|
701
|
+
|
|
702
|
+
- compact task contract:用于单 L1、Green、低风险任务,只写目标、范围、验收、权限、
|
|
703
|
+
验证命令和最小 `execution_policy.task_tree`。
|
|
704
|
+
- expanded task contract:用于多 L1、Yellow/Red、跨模块、连续执行、高不确定或高风险任务,
|
|
705
|
+
可按需展开 checkpoint、模型策略、风险门和更完整的任务树字段。
|
|
706
|
+
|
|
707
|
+
默认优先 compact。完整默认策略保存在 `ai/template/execution-policy.md`,简单任务不应把
|
|
708
|
+
`checkpoint_budget`、`model_policy` 等内部控制字段机械复制进 `task.md`。
|
|
709
|
+
|
|
661
710
|
默认模式是 `auto`。AI 每次执行前先做任务分解和风险判断,再决定使用
|
|
662
711
|
`normal` 还是 `bounded_continuous`,不依赖用户口令。
|
|
663
712
|
|
|
@@ -1066,6 +1115,10 @@ git diff --check
|
|
|
1066
1115
|
- 自动运行 Agent;
|
|
1067
1116
|
- 自动切换模型;
|
|
1068
1117
|
- 多 Agent 编排;
|
|
1118
|
+
- workspace 切换;
|
|
1119
|
+
- sandbox 生命周期;
|
|
1120
|
+
- session fork / rollback;
|
|
1121
|
+
- worker 调度;
|
|
1069
1122
|
- 云同步;
|
|
1070
1123
|
- IDE 插件;
|
|
1071
1124
|
- 发布流水线。
|
|
@@ -1075,7 +1128,7 @@ git diff --check
|
|
|
1075
1128
|
Agent Execution Template v0.8 已经从一个 prompt/template 原型,升级为:
|
|
1076
1129
|
|
|
1077
1130
|
```text
|
|
1078
|
-
低摩擦、可安装、可升级、保护用户现场的 AI
|
|
1131
|
+
低摩擦、可安装、可升级、保护用户现场的 AI Repo Execution Protocol npm 包雏形。
|
|
1079
1132
|
```
|
|
1080
1133
|
|
|
1081
1134
|
它的长期价值不在于替代任何模型或 Agent,而在于提供一套稳定协议:
|
package/package.json
CHANGED
package/template/en/ai/README.md
CHANGED
|
@@ -4,9 +4,12 @@ Copy this folder into a target software project.
|
|
|
4
4
|
|
|
5
5
|
```text
|
|
6
6
|
template is protocol
|
|
7
|
-
project is
|
|
7
|
+
project is repo-local context
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
+
Here, `project` means the repo-local `ai/project/**` context. It is not an
|
|
11
|
+
external workspace, session, or sandbox runtime.
|
|
12
|
+
|
|
10
13
|
## Files
|
|
11
14
|
|
|
12
15
|
- `template/prompt.md`: AI startup prompt.
|