@wnlen/agent-execution-template 0.8.19 → 0.8.21

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
@@ -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 workspace stays protected.
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
 
@@ -228,7 +239,7 @@ ai/
228
239
  The split is the core design:
229
240
 
230
241
  - `ai/template/**` is reusable protocol. It can be safely updated from this package.
231
- - `ai/project/**` is your project workspace. It stores local context, tasks, references, results, and metrics.
242
+ - `ai/project/**` is your repo-local project context. It stores local context, tasks, references, results, and metrics.
232
243
 
233
244
  ## Commands
234
245
 
@@ -243,6 +254,8 @@ Creates `ai/` in the current project.
243
254
  - Updates or creates `ai/template/**`.
244
255
  - Creates missing `ai/project/**` files.
245
256
  - Keeps existing `ai/project/**` files intact.
257
+ - Creates or updates the same compatibility managed block in root `AGENTS.md` /
258
+ `CLAUDE.md` so different AI tools can discover the protocol entrypoint.
246
259
  - Use `--lang zh` or omit `--lang` for the Chinese template.
247
260
 
248
261
  ### `next`
@@ -425,12 +438,16 @@ Agent Execution Template is not:
425
438
  - an IDE,
426
439
  - an agent platform,
427
440
  - a multi-agent scheduler,
441
+ - a workspace / sandbox / session runtime,
442
+ - a multi-repository context manager,
428
443
  - a cloud service,
429
444
  - a prompt collection,
430
445
  - a replacement for Codex, Claude Code, Cursor, or Aider.
431
446
 
432
447
  It is a small file protocol for making those tools behave more consistently inside real software projects.
433
448
 
449
+ 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.
450
+
434
451
  ## Specification
435
452
 
436
453
  - [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
@@ -247,6 +256,7 @@ npx -y @wnlen/agent-execution-template init
247
256
  - 更新或创建 `ai/template/**`。
248
257
  - 创建缺失的 `ai/project/**` 文件。
249
258
  - 保留已有的 `ai/project/**` 文件。
259
+ - 创建或更新根目录 `AGENTS.md` / `CLAUDE.md` 中的同内容兼容托管块,让不同 AI 工具能发现协议入口。
250
260
  - 默认安装中文模板;英文模板使用 `--lang en`。
251
261
 
252
262
  ### `next`
@@ -426,12 +436,16 @@ Agent Execution Template 不是:
426
436
  - IDE;
427
437
  - Agent 平台;
428
438
  - 多 Agent 调度器;
439
+ - workspace / sandbox / session 运行时;
440
+ - 多仓库上下文管理器;
429
441
  - 云服务;
430
442
  - 提示词合集;
431
443
  - Codex、Claude Code、Cursor 或 Aider 的替代品。
432
444
 
433
445
  它是一个小型文件协议,用来让这些工具在真实软件项目中表现得更稳定。
434
446
 
447
+ 它不负责 workspace 切换、sandbox 生命周期、session fork / rollback 或 worker 调度。反过来,外部运行时不应该替代仓库内的任务定义、文件修改规则、acceptance criteria 或具体编码上下文。
448
+
435
449
  ## 规格
436
450
 
437
451
  - [完整规格](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",
@@ -19,6 +22,8 @@ const REQUIRED_FILES = [
19
22
  "ai/template/protocol.md",
20
23
  "ai/template/rules/core.md",
21
24
  "ai/template/rules/output.md",
25
+ "ai/template/schemas/result.schema.json",
26
+ "ai/template/schemas/metrics.schema.json",
22
27
  "ai/project/inbox/.gitkeep",
23
28
  "ai/project/project.md",
24
29
  "ai/project/runtime.md",
@@ -39,11 +44,6 @@ const RECOMMENDED_FILES = [
39
44
  "ai/project/refs/roadmap.md"
40
45
  ];
41
46
 
42
- const JSON_HEALTH_FILES = [
43
- "ai/project/result.json",
44
- "ai/project/metrics.json"
45
- ];
46
-
47
47
  const TASK_HEALTH_PATTERNS = [
48
48
  /^task_id:\s*/m,
49
49
  /^type:\s*/m,
@@ -77,11 +77,13 @@ const TEXT = {
77
77
  `,
78
78
  unknown: "未知",
79
79
  sourceMissing: "找不到模板来源",
80
- ready: "Agent Execution Template 已就绪。",
81
- initGuide: `[初始化]
82
- 1. 直接初始化
80
+ ready: "Agent Execution Template 协议已安装。项目上下文尚未初始化。",
81
+ initGuide: `[下一步:让 AI 初始化项目上下文]
82
+ 已安装根目录 AI 兼容入口: AGENTS.md / CLAUDE.md
83
+
84
+ 1. 无额外资料
83
85
  对 AI 说: 开始初始化这个项目
84
- 2. 带资料初始化
86
+ 2. 有已确定资料
85
87
  先放到: ai/project/inbox/
86
88
  对 AI 说: 开始初始化这个项目,并吸收 ai/project/inbox/ 里的资料
87
89
 
@@ -132,7 +134,10 @@ const TEXT = {
132
134
  fail: "失败",
133
135
  empty: "为空",
134
136
  invalidJson: "JSON 无效",
137
+ invalidSchema: "不符合协议 schema",
135
138
  taskFrontMatterIncomplete: "任务 front matter 缺少关键字段",
139
+ entrypointReady: "根目录 AI 兼容入口已安装: AGENTS.md / CLAUDE.md",
140
+ entrypointMissing: "缺少根目录 AI 兼容入口托管块;AI 可能不会自动读取 ai/template/prompt.md",
136
141
  versionMismatch: "模板版本与包版本不一致",
137
142
  runInit: "请运行 npx -y @wnlen/agent-execution-template init",
138
143
  readyWithWarnings: "已就绪,但存在警告",
@@ -186,11 +191,13 @@ Usage:
186
191
  `,
187
192
  unknown: "unknown",
188
193
  sourceMissing: "Template source not found",
189
- ready: "Agent Execution Template ready.",
190
- initGuide: `[Initialize]
191
- 1. Initialize directly
194
+ ready: "Agent Execution Template protocol installed. Project context is not initialized yet.",
195
+ initGuide: `[Next: ask the AI to initialize project context]
196
+ Installed root AI compatibility entrypoints: AGENTS.md / CLAUDE.md
197
+
198
+ 1. Without extra material
192
199
  Tell the AI: Start initializing this project
193
- 2. Initialize with material
200
+ 2. With confirmed material
194
201
  Put it in: ai/project/inbox/
195
202
  Tell the AI: Start initializing this project and absorb the material in ai/project/inbox/
196
203
 
@@ -241,7 +248,10 @@ Usage:
241
248
  fail: "FAIL",
242
249
  empty: "is empty",
243
250
  invalidJson: "contains invalid JSON",
251
+ invalidSchema: "does not match protocol schema",
244
252
  taskFrontMatterIncomplete: "task front matter is missing required fields",
253
+ entrypointReady: "root AI compatibility entrypoints installed: AGENTS.md / CLAUDE.md",
254
+ entrypointMissing: "missing root AI compatibility entrypoint managed block; the AI may not auto-read ai/template/prompt.md",
245
255
  versionMismatch: "template version does not match package version",
246
256
  runInit: "Run npx -y @wnlen/agent-execution-template init",
247
257
  readyWithWarnings: "Ready to run with warnings",
@@ -398,6 +408,72 @@ function copyTree(sourceRoot, targetRoot, overwrite) {
398
408
  );
399
409
  }
400
410
 
411
+ function rootEntrypointBlock(lang) {
412
+ if (lang === "en") {
413
+ return `${ENTRYPOINT_BLOCK_START}
414
+ ## Agent Execution Template
415
+
416
+ This repository has Agent Execution Template installed in \`ai/\`.
417
+ This managed block is intentionally duplicated in \`AGENTS.md\` and \`CLAUDE.md\` for different AI tool discovery conventions.
418
+
419
+ Mandatory routing:
420
+ - Before acting on any project request, first read and follow \`ai/template/prompt.md\`.
421
+ - 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.
422
+ ${ENTRYPOINT_BLOCK_END}`;
423
+ }
424
+
425
+ return `${ENTRYPOINT_BLOCK_START}
426
+ ## Agent Execution Template
427
+
428
+ 本仓库已安装 Agent Execution Template,协议位于 \`ai/\`。
429
+ 此托管块会有意同时写入 \`AGENTS.md\` 和 \`CLAUDE.md\`,用于适配不同 AI 工具的自动发现约定。
430
+
431
+ 强制路由:
432
+ - 处理任何项目请求前,必须先读取并遵守 \`ai/template/prompt.md\`。
433
+ - 如果用户说“开始初始化这个项目”或要求初始化/整理项目上下文,在 \`ai/template/prompt.md\` 完成路由前,不要运行安装命令、不要创建 lockfile、不要编辑业务文件。
434
+ ${ENTRYPOINT_BLOCK_END}`;
435
+ }
436
+
437
+ function hasManagedEntrypointBlock(content) {
438
+ return content.includes(ENTRYPOINT_BLOCK_START) && content.includes(ENTRYPOINT_BLOCK_END);
439
+ }
440
+
441
+ function upsertManagedBlock(content, block) {
442
+ if (!hasManagedEntrypointBlock(content)) {
443
+ const separator = content.trim().length > 0 ? "\n\n" : "";
444
+ return `${content.replace(/\s*$/, "")}${separator}${block}\n`;
445
+ }
446
+
447
+ const start = content.indexOf(ENTRYPOINT_BLOCK_START);
448
+ const end = content.indexOf(ENTRYPOINT_BLOCK_END, start) + ENTRYPOINT_BLOCK_END.length;
449
+ return `${content.slice(0, start)}${block}${content.slice(end)}`;
450
+ }
451
+
452
+ function ensureRootEntrypoints(lang) {
453
+ const block = rootEntrypointBlock(lang);
454
+ const changes = [];
455
+ for (const file of ROOT_ENTRYPOINT_FILES) {
456
+ const fullPath = path.join(process.cwd(), file);
457
+ const existed = fs.existsSync(fullPath);
458
+ const current = existed ? fs.readFileSync(fullPath, "utf8") : "";
459
+ const next = upsertManagedBlock(current, block);
460
+ if (existed && current === next) {
461
+ changes.push({ action: "kept", path: file });
462
+ continue;
463
+ }
464
+ fs.writeFileSync(fullPath, next);
465
+ changes.push({ action: existed ? "updated" : "created", path: file });
466
+ }
467
+ return changes;
468
+ }
469
+
470
+ function hasAllRootEntrypoints() {
471
+ return ROOT_ENTRYPOINT_FILES.every((file) => {
472
+ const fullPath = path.join(process.cwd(), file);
473
+ return fs.existsSync(fullPath) && hasManagedEntrypointBlock(fs.readFileSync(fullPath, "utf8"));
474
+ });
475
+ }
476
+
401
477
  function formatTimestamp(date = new Date()) {
402
478
  const pad = (value) => String(value).padStart(2, "0");
403
479
  return [
@@ -496,7 +572,7 @@ function proposalState() {
496
572
  return hasProposed ? "proposed" : null;
497
573
  }
498
574
 
499
- function init({ lang = DEFAULT_LANG, verbose = false, quiet = false } = {}) {
575
+ function init({ lang = DEFAULT_LANG, verbose = false, quiet = false, manageEntrypoints = true } = {}) {
500
576
  const text = getText(lang);
501
577
  if (!SUPPORTED_LANGS.has(lang)) {
502
578
  console.error(`[${text.fail}] ${text.invalidLang}: ${lang}`);
@@ -523,6 +599,10 @@ function init({ lang = DEFAULT_LANG, verbose = false, quiet = false } = {}) {
523
599
  changes.push(...copyTree(path.join(sourceAi, "project"), path.join(TARGET_AI, "project"), false)
524
600
  .map((change) => ({ ...change, path: path.join("ai/project", change.path) })));
525
601
 
602
+ if (manageEntrypoints) {
603
+ changes.push(...ensureRootEntrypoints(lang));
604
+ }
605
+
526
606
  if (!quiet) {
527
607
  const sourceNotice = isSourceCheckout() ? `${text.sourceCheckoutNotice}\n\n` : "";
528
608
  console.log(`${text.ready}
@@ -560,7 +640,7 @@ function refresh({ lang = DEFAULT_LANG, title } = {}) {
560
640
  const backupPath = uniqueBackupPath(path.join(TARGET_AI, `project.backup.${formatTimestamp()}`));
561
641
  fs.renameSync(projectPath, backupPath);
562
642
 
563
- init({ lang, verbose: false, quiet: true });
643
+ init({ lang, verbose: false, quiet: true, manageEntrypoints: false });
564
644
 
565
645
  const importPath = path.join(TARGET_AI, "project", "inbox", "raw", "old-project");
566
646
  ensureDir(importPath);
@@ -654,6 +734,7 @@ function update({ lang = readInstalledLang() } = {}) {
654
734
  ensureDir(targetTemplate);
655
735
  const changes = copyTree(sourceTemplate, targetTemplate, true)
656
736
  .map((change) => ({ ...change, path: path.join("ai/template", change.path) }));
737
+ changes.push(...ensureRootEntrypoints(lang));
657
738
  printChanges(text.updateTitle, changes, lang);
658
739
  console.log(`[${text.pass}] ${text.updated} ${readVersion(sourceTemplate) || text.unknown}. ${text.projectNotModified}`);
659
740
  }
@@ -701,6 +782,117 @@ function isPermissionError(error) {
701
782
  return error && (error.code === "EACCES" || error.code === "EPERM");
702
783
  }
703
784
 
785
+ function parseJsonFile(file) {
786
+ return JSON.parse(fs.readFileSync(file, "utf8"));
787
+ }
788
+
789
+ function valueMatchesType(value, type) {
790
+ if (type === "array") return Array.isArray(value);
791
+ if (type === "integer") return Number.isInteger(value);
792
+ if (type === "number") return typeof value === "number" && Number.isFinite(value);
793
+ if (type === "object") return value !== null && typeof value === "object" && !Array.isArray(value);
794
+ return typeof value === type;
795
+ }
796
+
797
+ function valuesEqual(left, right) {
798
+ return JSON.stringify(left) === JSON.stringify(right);
799
+ }
800
+
801
+ function validateJsonSchema(value, schema, location = "$") {
802
+ const errors = [];
803
+
804
+ if (schema.const !== undefined && !valuesEqual(value, schema.const)) {
805
+ errors.push(`${location} must be ${JSON.stringify(schema.const)}`);
806
+ }
807
+
808
+ if (schema.enum && !schema.enum.some((candidate) => valuesEqual(value, candidate))) {
809
+ errors.push(`${location} must be one of ${schema.enum.map((item) => JSON.stringify(item)).join(", ")}`);
810
+ }
811
+
812
+ if (schema.type && !valueMatchesType(value, schema.type)) {
813
+ errors.push(`${location} must be ${schema.type}`);
814
+ return errors;
815
+ }
816
+
817
+ if (schema.minimum !== undefined && typeof value === "number" && value < schema.minimum) {
818
+ errors.push(`${location} must be >= ${schema.minimum}`);
819
+ }
820
+
821
+ if (schema.minLength !== undefined && typeof value === "string" && value.length < schema.minLength) {
822
+ errors.push(`${location} must have length >= ${schema.minLength}`);
823
+ }
824
+
825
+ if (schema.required && valueMatchesType(value, "object")) {
826
+ for (const key of schema.required) {
827
+ if (!Object.prototype.hasOwnProperty.call(value, key)) {
828
+ errors.push(`${location}.${key} is required`);
829
+ }
830
+ }
831
+ }
832
+
833
+ if (schema.properties && valueMatchesType(value, "object")) {
834
+ for (const [key, childSchema] of Object.entries(schema.properties)) {
835
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
836
+ errors.push(...validateJsonSchema(value[key], childSchema, `${location}.${key}`));
837
+ }
838
+ }
839
+ }
840
+
841
+ if (schema.items && Array.isArray(value)) {
842
+ value.forEach((item, index) => {
843
+ errors.push(...validateJsonSchema(item, schema.items, `${location}[${index}]`));
844
+ });
845
+ }
846
+
847
+ if (schema.allOf) {
848
+ for (const childSchema of schema.allOf) {
849
+ if (childSchema.if) {
850
+ if (validateJsonSchema(value, childSchema.if, location).length === 0 && childSchema.then) {
851
+ errors.push(...validateJsonSchema(value, childSchema.then, location));
852
+ }
853
+ } else {
854
+ errors.push(...validateJsonSchema(value, childSchema, location));
855
+ }
856
+ }
857
+ }
858
+
859
+ return errors;
860
+ }
861
+
862
+ function printSchemaValidation(file, schemaFile, text) {
863
+ const fullPath = path.join(process.cwd(), file);
864
+ const schemaPath = path.join(process.cwd(), schemaFile);
865
+ if (!fs.existsSync(fullPath) || !fs.existsSync(schemaPath)) {
866
+ return 0;
867
+ }
868
+
869
+ let value;
870
+ try {
871
+ value = parseJsonFile(fullPath);
872
+ console.log(`[${text.pass}] ${file} JSON`);
873
+ } catch {
874
+ console.log(`[${text.fail}] ${file} ${text.invalidJson}`);
875
+ return 1;
876
+ }
877
+
878
+ let schema;
879
+ try {
880
+ schema = parseJsonFile(schemaPath);
881
+ } catch {
882
+ console.log(`[${text.fail}] ${schemaFile} ${text.invalidJson}`);
883
+ return 1;
884
+ }
885
+
886
+ const errors = validateJsonSchema(value, schema);
887
+ if (errors.length > 0) {
888
+ console.log(`[${text.fail}] ${file} ${text.invalidSchema}: ${errors.slice(0, 3).join("; ")}`);
889
+ return 1;
890
+ }
891
+
892
+ console.log(`[${text.pass}] ${file} schema`);
893
+ return 0;
894
+ }
895
+
704
896
  function printFatal(error, lang) {
705
897
  const text = getText(lang);
706
898
  if (isPermissionError(error)) {
@@ -756,18 +948,19 @@ function doctor() {
756
948
  console.log(`[${text.pass}] ${file}`);
757
949
  }
758
950
 
759
- for (const file of JSON_HEALTH_FILES) {
760
- const fullPath = path.join(process.cwd(), file);
761
- if (!fs.existsSync(fullPath)) {
762
- continue;
763
- }
764
- try {
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
- }
951
+ if (hasAllRootEntrypoints()) {
952
+ console.log(`[${text.pass}] ${text.entrypointReady}`);
953
+ } else {
954
+ console.log(`[${text.warn}] ${text.entrypointMissing}`);
955
+ warnings += 1;
956
+ }
957
+
958
+ const schemaChecks = [
959
+ ["ai/project/result.json", "ai/template/schemas/result.schema.json"],
960
+ ["ai/project/metrics.json", "ai/template/schemas/metrics.schema.json"]
961
+ ];
962
+ for (const [file, schemaFile] of schemaChecks) {
963
+ missing += printSchemaValidation(file, schemaFile, text);
771
964
  }
772
965
 
773
966
  const taskPath = path.join(process.cwd(), "ai/project/task.md");
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 Coding Agent 执行协议模板。**
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.19
27
+ Package: @wnlen/agent-execution-template@0.8.21
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.19
423
+ 模板版本: 0.8.21
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
- 执行入口固定要求 AI Agent 先读:
507
+ 执行入口采用懒加载。AI Agent 先读:
473
508
 
474
509
  ```text
475
- 1. ai/template/protocol.md
476
- 2. ai/template/rules/core.md
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*`、`AGENTS.md`、`CLAUDE.md`、`CONTRIBUTING*`、`CHANGELOG*`;
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
  - 先看顶层目录和文件名;
@@ -1066,6 +1105,10 @@ git diff --check
1066
1105
  - 自动运行 Agent;
1067
1106
  - 自动切换模型;
1068
1107
  - 多 Agent 编排;
1108
+ - workspace 切换;
1109
+ - sandbox 生命周期;
1110
+ - session fork / rollback;
1111
+ - worker 调度;
1069
1112
  - 云同步;
1070
1113
  - IDE 插件;
1071
1114
  - 发布流水线。
@@ -1075,7 +1118,7 @@ git diff --check
1075
1118
  Agent Execution Template v0.8 已经从一个 prompt/template 原型,升级为:
1076
1119
 
1077
1120
  ```text
1078
- 低摩擦、可安装、可升级、保护用户现场的 AI 执行协议 npm 包雏形。
1121
+ 低摩擦、可安装、可升级、保护用户现场的 AI Repo Execution Protocol npm 包雏形。
1079
1122
  ```
1080
1123
 
1081
1124
  它的长期价值不在于替代任何模型或 Agent,而在于提供一套稳定协议:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wnlen/agent-execution-template",
3
- "version": "0.8.19",
3
+ "version": "0.8.21",
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"
@@ -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 the field workspace
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.
@@ -1 +1 @@
1
- 0.8.19
1
+ 0.8.21