@tea-agent/loop-agent 0.2.1 → 0.3.0

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.
Files changed (33) hide show
  1. package/AGENTS.md +56 -54
  2. package/CHANGELOG.md +22 -10
  3. package/README.md +24 -12
  4. package/dist/application/dag/args.js +6 -0
  5. package/dist/application/dag/generate-task-dag.js +2 -0
  6. package/dist/application/dag/run-dag.js +3 -0
  7. package/dist/application/dag/validate-dag.js +40 -0
  8. package/dist/cli/command-definitions.js +2 -2
  9. package/dist/cli/program.js +24 -4
  10. package/dist/commands/init.js +554 -2
  11. package/dist/workflows/dag/dynamic-runtime/loop-until.js +2 -1
  12. package/dist/workflows/dag/dynamic-runtime/map.js +1 -0
  13. package/dist/workflows/dag/init-hybrid.js +3 -3
  14. package/dist/workflows/dag/skills.js +3 -3
  15. package/dist/workflows/dag/types.js +2 -0
  16. package/dist/workflows/dynamic/compile.js +11 -0
  17. package/dist/workflows/dynamic/spec.js +1 -0
  18. package/docs/README.md +7 -4
  19. package/docs/agent-dag-runner.md +2 -0
  20. package/docs/exec-plans/active/README.md +1 -4
  21. package/docs/exec-plans/completed/README.md +2 -0
  22. package/docs/init-surface.manifest.json +175 -0
  23. package/docs/skills/README.md +6 -0
  24. package/docs/skills/vetted-skill-registry.md +26 -0
  25. package/docs/templates/init-evolution-review.md +33 -0
  26. package/harness.json +5 -3
  27. package/package.json +7 -5
  28. package/skills/code-review-core/SKILL.md +20 -0
  29. package/skills/codebase-scout/SKILL.md +19 -0
  30. package/skills/init-capability-evolution/SKILL.md +69 -0
  31. package/skills/loop-agent/references/command-reference.md +37 -19
  32. package/skills/test-driven-development/SKILL.md +20 -0
  33. package/skills/webapp-testing/SKILL.md +19 -0
package/AGENTS.md CHANGED
@@ -1,7 +1,7 @@
1
- <!-- CODEGRAPH_START -->
2
- ## CodeGraph
3
-
4
- 如果仓库根目录存在 `.codegraph/`,在理解或定位代码前优先使用 CodeGraph,再考虑 rg/fd 或手动读文件。
1
+ <!-- CODEGRAPH_START -->
2
+ ## CodeGraph
3
+
4
+ 如果仓库根目录存在 `.codegraph/`,在理解或定位代码前优先使用 CodeGraph,再考虑 rg/fd 或手动读文件。
5
5
  <!-- CODEGRAPH_END -->
6
6
 
7
7
  # AGENTS.md
@@ -16,14 +16,14 @@
16
16
  - 一次只推进一个清晰工作块;主会话按 Orient → Select → Contract → Implement → Verify → Handoff 治理,runtime 真实流程以 `src/workflows/` 为准。
17
17
  - 先验证基线,再叠加改动;如果当前基线已坏,优先定位基线问题。
18
18
  - 完成定义必须可验证;不能靠删测试、降标准或模糊描述制造“完成”。
19
- - 搜索先于实现;先查现有代码、文档、脚本、测试,避免重复造轮子或误判系统能力。
20
- - 在 DAG runtime 中,搜索/侦察是显式节点:标准路径是 Contract → Scout → Plan → Implement → Verify → Closeout/Handoff。
21
- - runtime 边界、command registry、skill entry 和架构 import 方向是可机器校验的治理契约;相关细节以 `docs/architecture/runtime-boundaries.md`、`src/cli/command-definitions.ts`、`skills/loop-agent/` 和 `scripts/check-*.sh` 为准,顶层 `AGENTS.md` 只指路,不重复维护事实源。
22
- - 本仓库既是 loop-agent 源项目,也是目标项目初始化体验的默认模板;任何新增命令、脚本、文档、skill、模板或发布包内容,都要判断它应由 npm 包内置提供,还是由 `loop-agent init` 投影到目标项目,避免出现“本项目能用、初始化项目缺能力”。
23
- - 委托模型写入前,必须把写入边界写成结构化 `task.json.allowedPaths` / `task.json.forbiddenPaths`,再审查生成 DAG 的 writer `writeSet`;不要只依赖 `source/执行约束.md` 的自然语言约束。
24
- - Shell 搜索优先 `rg`,按名找文件优先 `fd`;脚本确为 Bash 脚本时使用 Git Bash 或已配置的兼容 Bash,不要求 Windows 环境适配 POSIX 路径。
25
- - 用 loop-agent 迭代本仓库时,控制器必须来自已发布的 npm 安装包;首次安装或有意升级可用 `@tea-agent/loop-agent@latest`,但一次自举任务启动后不要中途升级控制器,并记录 `npm list -g @tea-agent/loop-agent --depth=0` 显示的实际版本。不要用当前工作区的 `npm link` 或 `npm run dev` 控制可能改动 CLI、DAG runtime、executor、package metadata 或 build output 的任务。
26
- - 反复出现的约束要固化为文档、脚本、检查项、测试或模板。
19
+ - 搜索先于实现;先查现有代码、文档、脚本、测试,避免重复造轮子或误判系统能力。
20
+ - 在 DAG runtime 中,搜索/侦察是显式节点:标准路径是 Contract → Scout → Plan → Implement → Verify → Closeout/Handoff。
21
+ - init surface、runtime 边界、command registry、skill entry 和架构 import 方向是可机器校验的治理契约;相关细节以 `docs/init-surface.manifest.json`、`docs/architecture/runtime-boundaries.md`、`src/cli/command-definitions.ts`、`skills/loop-agent/` 和 `scripts/check-*.sh` 为准,顶层 `AGENTS.md` 只指路,不重复维护事实源。
22
+ - 本仓库既是 loop-agent 源项目,也是目标项目初始化体验的默认模板;任何新增命令、脚本、文档、skill、模板或发布包内容,都要判断它应由 npm 包内置提供,还是由 `loop-agent init` 投影到目标项目,避免出现“本项目能用、初始化项目缺能力”。
23
+ - 委托模型写入前,必须把写入边界写成结构化 `task.json.allowedPaths` / `task.json.forbiddenPaths`,再审查生成 DAG 的 writer `writeSet`;不要只依赖 `source/执行约束.md` 的自然语言约束。
24
+ - Shell 搜索优先 `rg`,按名找文件优先 `fd`;脚本确为 Bash 脚本时使用 Git Bash 或已配置的兼容 Bash,不要求 Windows 环境适配 POSIX 路径。
25
+ - 用 loop-agent 迭代本仓库时,控制器必须来自已发布的 npm 安装包;首次安装或有意升级可用 `@tea-agent/loop-agent@latest`,但一次自举任务启动后不要中途升级控制器,并记录 `npm list -g @tea-agent/loop-agent --depth=0` 显示的实际版本。不要用当前工作区的 `npm link` 或 `npm run dev` 控制可能改动 CLI、DAG runtime、executor、package metadata 或 build output 的任务。
26
+ - 反复出现的约束要固化为文档、脚本、检查项、测试或模板。
27
27
  - 禁止占位实现;除非 contract 明确约定为脚手架且标出后续闭环。
28
28
 
29
29
  ## 开始顺序
@@ -34,32 +34,32 @@
34
34
  2. 阅读 `README.md`。
35
35
  3. 阅读 `harness.json`。
36
36
  4. 阅读 `docs/README.md`。
37
- 5. 如果是实现类工作,继续阅读:
38
- - `docs/development-principles.md`
39
- - `docs/feature-workflow.md`
40
- - `docs/verification-matrix.md`
41
- 6. 如果任务涉及命令入口、执行流程、executor、初始化投影、skills、脚本矩阵、发布包范围或治理检查,继续阅读:
42
- - `docs/architecture/runtime-boundaries.md`
43
- - `docs/loop-agent-harness.md`
44
- 7. 如果任务涉及测试纪律、验证声明或调试,继续阅读:
45
- - `docs/harness-methodology-tdd.md`
46
- - `docs/harness-methodology-verification.md`
47
- - `docs/harness-methodology-debugging.md`
48
- 8. 查看最近提交、相关执行计划、progress/report,确认当前上下文。
49
- 9. 检查 `git status --short --branch`。
50
- 10. 运行本次任务相关的最小基线验证。
37
+ 5. 如果是实现类工作,继续阅读:
38
+ - `docs/development-principles.md`
39
+ - `docs/feature-workflow.md`
40
+ - `docs/verification-matrix.md`
41
+ 6. 如果任务涉及命令入口、执行流程、executor、初始化投影、skills、脚本矩阵、发布包范围或治理检查,继续阅读:
42
+ - `docs/architecture/runtime-boundaries.md`
43
+ - `docs/loop-agent-harness.md`
44
+ 7. 如果任务涉及测试纪律、验证声明或调试,继续阅读:
45
+ - `docs/harness-methodology-tdd.md`
46
+ - `docs/harness-methodology-verification.md`
47
+ - `docs/harness-methodology-debugging.md`
48
+ 8. 查看最近提交、相关执行计划、progress/report,确认当前上下文。
49
+ 9. 检查 `git status --short --branch`。
50
+ 10. 运行本次任务相关的最小基线验证。
51
51
 
52
52
  ## 会话协议
53
53
 
54
54
  1. Orient:读入口文档、相关专题、最近变更和现有实现。
55
55
  2. Select:只选一个清晰工作块;避免把重构、新功能、文档迁移混在一轮里。
56
- 3. Contract:写清本轮交付物、非目标、完成标准、验证方法和失败条件。
57
- 4. Implement:做最小增量实现,同步维护必要文档、脚本和测试。
58
- 5. Verify:优先跑快速反馈,再跑必要的真实路径验证。
59
- 6. Converge Docs:检查 README、AGENTS.md、CHANGELOG.md、docs/README.md、相关治理文档、skills references、website docs、初始化模板和脚本说明是否仍与实际行为一致;只更新与本次变更相关的内容,不做顺手文档迁移。
60
- 7. Handoff:更新 progress/report/plan 中有长期价值的信息,写清风险、剩余项和下一步。
56
+ 3. Contract:写清本轮交付物、非目标、完成标准、验证方法和失败条件。
57
+ 4. Implement:做最小增量实现,同步维护必要文档、脚本和测试。
58
+ 5. Verify:优先跑快速反馈,再跑必要的真实路径验证。
59
+ 6. Converge Docs:检查 README、AGENTS.md、CHANGELOG.md、docs/README.md、相关治理文档、skills references、website docs、初始化模板和脚本说明是否仍与实际行为一致;只更新与本次变更相关的内容,不做顺手文档迁移。
60
+ 7. Handoff:更新 progress/report/plan 中有长期价值的信息,写清风险、剩余项和下一步。
61
61
 
62
- 这套会话协议不是 DAG runtime 的节点序列。复杂实现默认采用 Agent DAG;具体节点拓扑、profile routing、writer 选择和 runner 行为以 `docs/feature-workflow.md` 与 `src/workflows/` 为准。主 agent 负责拆任务、写 contract、把允许/禁止路径写入结构化 task config、审查 DAG/writeSet/profile/shell verification、盯验证与 handoff。微小任务或 DAG runtime 自身修复也应优先使用 DAG,或使用 one-shot `pi-prompt` / `cursor-prompt` escape hatch 并记录边界与验证证据。
62
+ 这套会话协议不是 DAG runtime 的节点序列。复杂实现默认采用 Agent DAG;具体节点拓扑、profile routing、writer 选择和 runner 行为以 `docs/feature-workflow.md` 与 `src/workflows/` 为准。主 agent 负责拆任务、写 contract、把允许/禁止路径写入结构化 task config、审查 DAG/writeSet/profile/shell verification、盯验证与 handoff。微小任务或 DAG runtime 自身修复也应优先使用 DAG,或使用 one-shot `pi-prompt` / `cursor-prompt` escape hatch 并记录边界与验证证据。
63
63
 
64
64
  ## 项目地图
65
65
 
@@ -77,15 +77,16 @@
77
77
  - 每次任务只推进一个清晰、有边界的工作块。
78
78
  - 保留无关的用户改动,不要回退自己没有做的修改。
79
79
  - 优先沿用现有 helper、目录边界和局部模式,再考虑新增抽象。
80
- - 长期决策写入 `docs/`,不要只留在聊天里。
81
- - 面向使用者的新增、修改、删除或修复,应同步更新根目录 `CHANGELOG.md`;保持版本级摘要即可,不写过细技术细节。
80
+ - 长期决策写入 `docs/`,不要只留在聊天里。
81
+ - 面向使用者的新增、修改、删除或修复,应同步更新根目录 `CHANGELOG.md`;保持版本级摘要即可,不写过细技术细节。
82
82
  - 涉及 `loop-agent init` 或目标项目投影的改动,必须同步考虑目标项目生成物:`AGENTS.md`、`README.md`、`harness.json`、`docs/`、`scripts/`、`skills/`、`.harness/prompts` 和 npm 包内置 assets。
83
+ - 涉及初始化能力演化时,按 `docs/init-surface.manifest.json` 与 `scripts/check-init-evolution-needed.sh` 分级处理:小改 advisory,中等 surface-check,高影响才需要模型审查;不要把所有小改动升级成重流程。
83
84
  - 通用脚本、skill 和模板可以复制或投影;项目相关 README、验证命令、发布/维护脚本必须基于模板和目标项目真实文件生成,不假定目标项目是 TypeScript、Node、前端、后端或工具项目。
84
- - 涉及 CLI command、skill entry、runtime boundary、import 方向或发布包范围时,同步更新对应文档、catalog/definition、治理脚本和测试,避免 README、skill reference、CLI help、npm 包内容互相漂移。
85
- - 完成相关更新后必须做文档收敛:如果 README、AGENTS.md、CHANGELOG.md、docs、skills、website、初始化生成模板或脚本说明不需要更新,应在交接里写明理由。
86
- - 不提交占位实现。
87
- - 没有新鲜验证证据时,不声明工作完成。
88
- - 发现新 bug、技术债或契约漂移时,写回当前 plan、progress 或 report,而不是只在对话里提一句。
85
+ - 涉及 CLI command、skill entry、runtime boundary、import 方向或发布包范围时,同步更新对应文档、catalog/definition、治理脚本和测试,避免 README、skill reference、CLI help、npm 包内容互相漂移。
86
+ - 完成相关更新后必须做文档收敛:如果 README、AGENTS.md、CHANGELOG.md、docs、skills、website、初始化生成模板或脚本说明不需要更新,应在交接里写明理由。
87
+ - 不提交占位实现。
88
+ - 没有新鲜验证证据时,不声明工作完成。
89
+ - 发现新 bug、技术债或契约漂移时,写回当前 plan、progress 或 report,而不是只在对话里提一句。
89
90
  - 涉及 harness 流程变化时,优先把变化落到 `harness.json`、模板、脚本或治理文档,而不是只改提示词。
90
91
 
91
92
  ## 验证
@@ -103,17 +104,18 @@ bash scripts/ci.sh
103
104
 
104
105
  Windows 上运行 `scripts/*.sh` 时使用 Git Bash 或已配置的兼容 Bash。CLI、Node 代码、模板和提示词里的实际文件路径必须兼容 macOS 与 Windows:优先使用平台原生临时目录和 `path`/`os.tmpdir()`;仅在 repo 引用、JSON/Markdown 证据引用和 glob 约定中使用 `/` 作为稳定分隔符。
105
106
 
106
- 文档站相关变更还需要按范围运行:
107
-
108
- ```bash
109
- npm run docs:build
110
- ```
111
-
112
- 按变更类型补充定向验证:
113
-
107
+ 文档站相关变更还需要按范围运行:
108
+
109
+ ```bash
110
+ npm run docs:build
111
+ ```
112
+
113
+ 按变更类型补充定向验证:
114
+
114
115
  - 初始化能力或目标项目投影:运行 `test/init-command.test.ts`,并在临时目标项目执行 `loop-agent init --profile full --merge`、`loop-agent init doctor`、`loop-agent inspect`、`loop-agent docs audit` 和目标项目 `bash scripts/check-repo.sh`。
116
+ - init surface 或初始化能力演化:运行 `bash scripts/check-init-evolution-needed.sh` 和 `bash scripts/check-init-surface.sh`;高影响或发布前按需使用 `--strict` 并参考 `skills/init-capability-evolution/` 与 `docs/templates/init-evolution-review.md`。
115
117
  - runtime boundary / command registry / skill entry:运行 `bash scripts/check-architecture-boundaries.sh`、`bash scripts/check-command-registry-drift.sh`、`bash scripts/check-skill-entry.sh`,并确保 `bash scripts/check-repo.sh` 覆盖这些检查。
116
- - 发布包范围:运行 `npm run build`、`node bin/loop-agent.js --help` 和 `npm pack --dry-run`,确认初始化所需静态资料在 package files 中。
118
+ - 发布包范围:运行 `npm run build`、`node bin/loop-agent.js --help` 和 `npm pack --dry-run`,确认初始化所需静态资料在 package files 中。
117
119
 
118
120
  ## 交接
119
121
 
@@ -130,9 +132,9 @@ npm run docs:build
130
132
 
131
133
  - 不要在未读相关文档的前提下直接大改。
132
134
  - 不要一次混合重构、新功能和文档大迁移而没有清晰边界。
133
- - 不要把仅存在于对话里的约束当作长期知识。
134
- - 不要在缺少验证的情况下宣称完成。
135
- - 不要假设系统没有某个能力;先搜索再判断。
136
- - 不要用 stub、假数据通路或注释承诺替代真正交付。
137
- - 不要把个人机器的绝对路径写入仓库级 `AGENTS.md`、README、模板或发布包资料;个人工具配置应留在用户级配置或本机会话上下文。
138
- - 不要只更新 loop-agent 本仓库体验而遗漏目标项目初始化体验;新增能力如果不能通过 npm 内置资料或 `loop-agent init` 到达目标项目,必须写清原因和替代入口。
135
+ - 不要把仅存在于对话里的约束当作长期知识。
136
+ - 不要在缺少验证的情况下宣称完成。
137
+ - 不要假设系统没有某个能力;先搜索再判断。
138
+ - 不要用 stub、假数据通路或注释承诺替代真正交付。
139
+ - 不要把个人机器的绝对路径写入仓库级 `AGENTS.md`、README、模板或发布包资料;个人工具配置应留在用户级配置或本机会话上下文。
140
+ - 不要只更新 loop-agent 本仓库体验而遗漏目标项目初始化体验;新增能力如果不能通过 npm 内置资料或 `loop-agent init` 到达目标项目,必须写清原因和替代入口。
package/CHANGELOG.md CHANGED
@@ -2,23 +2,35 @@
2
2
 
3
3
  这里记录每个版本面向使用者的主要变化。保持简短即可:新增、修改、修复或删除了什么,不需要展开实现细节。
4
4
 
5
- ## [0.2.1] - 2026-07-06
5
+ ## [0.3.0] - 2026-07-06
6
6
 
7
7
  ### 新增
8
8
 
9
- - 新增 Production Readiness v0.1 治理标准、生产可用 checklist 模板,以及 2026-07-06 2026-07-12 的生产可用硬化 sprint 执行计划,明确低/中风险单 repo DAG 任务的支持范围、非目标、证据要求、失败分类和最终验证门禁。
10
- - 新增 DAG production-readiness hardening:`dag validate` / `run-dag` 输出下一步指引,`dag report` 暴露 product-line failure routing 和 Operator Next Steps,`dag doctor --run-id --markdown` 输出失败诊断,failed `dag closeout-draft` 生成 Failure Handoff。
11
-
12
- ### 修改
9
+ - 新增 init surface manifest `scripts/check-init-surface.sh`,自动校验 npm 发布包范围和 `loop-agent init --profile full` 对目标项目的关键文件投影。
10
+ - 新增 `init-capability-evolution` skill、init evolution review 模板与 `scripts/check-init-evolution-needed.sh`,按 advisory / surface-check / model-review 三档提示初始化能力是否需要模型审查;默认不阻塞小改动。
11
+ - CLI 新增 `-V, --version` / `--version`,输出当前 package 版本且不要求 repo adapter。
12
+ - 新增 `loop-agent init check-update` 与 `loop-agent init update`,为旧版初始化过的目标项目生成 deterministic actions、model merge tasks、human decisions,并支持 `.harness/init-surface.json` baseline bootstrap 与安全补齐。
13
13
 
14
- - 更新本仓库与目标项目初始化后的 `AGENTS.md` 工作协议,新增文档收敛步骤、结构化 DAG 写入边界要求,以及 runtime boundary / command registry / skill entry / 发布包范围的定向验证指引。
15
- - `loop-agent init` 生成的目标项目 `AGENTS.md` 同步包含文档收敛、`task.json.allowedPaths` / `task.json.forbiddenPaths`、DAG 失败诊断与 failure handoff 规则,目标项目文档也会显式导航 production readiness checklist、`dag report`、`dag doctor --run-id --markdown` 和失败 run 的 `dag closeout-draft`。
14
+ ## [0.2.1] - 2026-07-06
16
15
 
17
- ### 修复
16
+ ### 新增
18
17
 
19
- - 修复 `check-harness-runtime-clean.sh` CLI contract 集成测试在 full-suite 负载下可能因默认 5s Vitest timeout 超时的问题,保留真实 shell/CLI 检查和断言。
18
+ - 新增 Production Readiness v0.1 治理标准、生产可用 checklist 模板,以及 2026-07-06 到 2026-07-12 的生产可用硬化 sprint 执行计划,明确低/中风险单 repo DAG 任务的支持范围、非目标、证据要求、失败分类和最终验证门禁。
19
+ - 新增 DAG production-readiness hardening:`dag validate` / `run-dag` 输出下一步指引,`dag report` 暴露 product-line failure routing 和 Operator Next Steps,`dag doctor --run-id --markdown` 输出失败诊断,failed `dag closeout-draft` 生成 Failure Handoff。
20
+ - `dag run-task`、`dag validate`、`run-dag` 的 JSON 输出新增稳定 `message` summary;`dag validate` 额外输出 write set 与 decision gate check 摘要。
21
+ - Dynamic Workflow node 现在可声明 `skills`,编译到 DAG 时会保留到对应 task、动态展开 child task 和 loop body task。
22
+ - 新增 repo-local vetted skill registry、首批 role skill wrappers,以及 opt-in `dag validate --strict-skills` audit gate。
20
23
 
21
- ## [0.2.0] - 2026-07-05
24
+ ### 修改
25
+
26
+ - 更新本仓库与目标项目初始化后的 `AGENTS.md` 工作协议,新增文档收敛步骤、结构化 DAG 写入边界要求,以及 runtime boundary / command registry / skill entry / 发布包范围的定向验证指引。
27
+ - `loop-agent init` 生成的目标项目 `AGENTS.md` 同步包含文档收敛、`task.json.allowedPaths` / `task.json.forbiddenPaths`、DAG 失败诊断与 failure handoff 规则,目标项目文档也会显式导航 production readiness checklist、`dag report`、`dag doctor --run-id --markdown` 和失败 run 的 `dag closeout-draft`。
28
+
29
+ ### 修复
30
+
31
+ - 修复 `check-harness-runtime-clean.sh` 与 CLI contract 集成测试在 full-suite 负载下可能因默认 5s Vitest timeout 超时的问题,保留真实 shell/CLI 检查和断言。
32
+
33
+ ## [0.2.0] - 2026-07-05
22
34
 
23
35
  ### 新增
24
36
 
package/README.md CHANGED
@@ -15,9 +15,10 @@
15
15
  作为 CLI 使用时,安装已发布包:
16
16
 
17
17
  ```bash
18
- npm install -g @tea-agent/loop-agent@latest
19
- loop-agent --help
20
- ```
18
+ npm install -g @tea-agent/loop-agent@latest
19
+ loop-agent --version
20
+ loop-agent --help
21
+ ```
21
22
 
22
23
  检查当前项目的 loop-agent 配置:
23
24
 
@@ -45,14 +46,25 @@ loop-agent inspect
45
46
  如果手动运行 CLI,可以使用:
46
47
 
47
48
  ```bash
48
- loop-agent init instructions --repo-root <target-repo>
49
- loop-agent init --repo-root <target-repo> --profile full --merge
50
- loop-agent init doctor --repo-root <target-repo>
51
- ```
52
-
53
- `init instructions` 会输出给模型/Agent 执行完整初始化的指引包,不要求目标项目已有 `harness.json`。默认初始化会 merge 已有 `AGENTS.md`、`harness.json` 和 `docs/`,复制 repo-local `skills/`,生成语言无关的治理脚本矩阵、中文根 README 入口、目标项目版治理文档和 `.harness/` 骨架;已有 README 会保留用户正文并插入/更新 loop-agent managed block。
54
-
55
- 当初始化由模型/Agent 执行时,它应把初始化当成一个自动化闭环:确认真正不能安全默认的 provider/model、治理根目录或凭据/成本问题后,运行 deterministic init,随后立刻读取目标项目真实文件,补全根 README 的项目概览、技术栈/目录结构、开发与验证命令,并同步适配 `docs/verification-matrix.md` 和必要的 `scripts/ci-tests.sh`。
49
+ loop-agent init instructions --repo-root <target-repo>
50
+ loop-agent init --repo-root <target-repo> --profile full --merge
51
+ loop-agent init doctor --repo-root <target-repo>
52
+ ```
53
+
54
+ `init instructions` 会输出给模型/Agent 执行完整初始化的指引包,不要求目标项目已有 `harness.json`。默认初始化会 merge 已有 `AGENTS.md`、`harness.json` 和 `docs/`,复制 repo-local `skills/`,生成语言无关的治理脚本矩阵、中文根 README 入口、目标项目版治理文档和 `.harness/` 骨架;已有 README 会保留用户正文并插入/更新 loop-agent managed block。
55
+
56
+ 新初始化会写入 `.harness/init-surface.json`,记录当前 controller 版本、初始化投影文件 hash manifest hash。已用旧版本初始化的目标项目,可以用下面的维护入口对齐新版本初始化能力:
57
+
58
+ ```bash
59
+ loop-agent init check-update --repo-root <target-repo> --json
60
+ loop-agent init check-update --repo-root <target-repo> --markdown
61
+ loop-agent init update --repo-root <target-repo> --bootstrap-surface
62
+ loop-agent init update --repo-root <target-repo> --apply-safe
63
+ ```
64
+
65
+ `check-update` 只读报告 deterministic actions、model merge tasks、human decisions 和 recommended next。`update --bootstrap-surface` 为旧项目补 inferred baseline;`update --apply-safe` 只补缺失文件、目录和 managed block,不覆盖已有但无法确认来源的本地文件。
66
+
67
+ 当初始化由模型/Agent 执行时,它应把初始化当成一个自动化闭环:确认真正不能安全默认的 provider/model、治理根目录或凭据/成本问题后,运行 deterministic init,随后立刻读取目标项目真实文件,补全根 README 的项目概览、技术栈/目录结构、开发与验证命令,并同步适配 `docs/verification-matrix.md` 和必要的 `scripts/ci-tests.sh`。
56
68
 
57
69
  初始化生成的 `scripts/ci-tests.sh` 不假定目标项目是 TypeScript、Node、前端或后端项目。它会保守探测 `package.json`、`Makefile`、`go.mod`、`Cargo.toml`、Python 测试配置、Maven、Gradle、.NET 等常见入口,只运行实际存在且工具可用的命令;探测不到时会清楚提示需要由初始化模型或用户按目标项目实际技术栈补充。
58
70
 
@@ -159,7 +171,7 @@ Windows 上运行 `scripts/*.sh` 时使用 Git Bash 或已配置的兼容 Bash
159
171
 
160
172
  ## 发布包内容
161
173
 
162
- 发布包包含静态运行和指导资料:`bin/`、`dist/`、`skills/`、`docs/*.md`、`docs/architecture/runtime-boundaries.md`、`docs/templates/`、`examples/`、`harness.json`、`AGENTS.md`、`README.md` 和 `CHANGELOG.md`。
174
+ 发布包包含静态运行和指导资料:`bin/`、`dist/`、`skills/`、`docs/*.md`、`docs/architecture/runtime-boundaries.md`、`docs/skills/`、`docs/templates/`、`docs/init-surface.manifest.json`、`examples/`、`harness.json`、`AGENTS.md`、`README.md` 和 `CHANGELOG.md`。
163
175
 
164
176
  `docs/progress/`、`docs/reports/`、`docs/exec-plans/`、`docs/decisions/` 等目录下的任务正文是目标仓库实时生成或历史事实;npm 包只携带这些目录的 README,不携带本仓库已有历史记录。
165
177
 
@@ -159,6 +159,7 @@ export function parseDagValidateArgs(args) {
159
159
  let dagPath;
160
160
  let strictModelMatrix = false;
161
161
  let strictGovernance = false;
162
+ let strictSkills = false;
162
163
  const forbidExecutors = [];
163
164
  let spineTaskId;
164
165
  for (let i = 0; i < args.length; i += 1) {
@@ -185,6 +186,10 @@ export function parseDagValidateArgs(args) {
185
186
  strictGovernance = true;
186
187
  continue;
187
188
  }
189
+ if (arg === "--strict-skills") {
190
+ strictSkills = true;
191
+ continue;
192
+ }
188
193
  if (arg === "--forbid-executor") {
189
194
  const executor = args[++i];
190
195
  if (!executor) {
@@ -230,6 +235,7 @@ export function parseDagValidateArgs(args) {
230
235
  dagPath: path.resolve(dagPath),
231
236
  strictModelMatrix,
232
237
  strictGovernance,
238
+ strictSkills,
233
239
  forbidExecutors,
234
240
  spineTaskId,
235
241
  };
@@ -233,6 +233,7 @@ export async function generateTaskDagUseCase(input) {
233
233
  if (!shouldRunExecution(parsed)) {
234
234
  return {
235
235
  mode: "generate+validate",
236
+ message: "DAG draft created",
236
237
  ok: true,
237
238
  taskId: initResult.taskId,
238
239
  outputPath,
@@ -264,6 +265,7 @@ export async function generateTaskDagUseCase(input) {
264
265
  });
265
266
  return {
266
267
  mode: resolveExecutionMode(parsed),
268
+ message: "DAG draft created",
267
269
  ok: true,
268
270
  taskId: initResult.taskId,
269
271
  outputPath,
@@ -72,6 +72,7 @@ export async function runDagUseCase(input) {
72
72
  const canvasError = await flushCanvasSafely(canvas);
73
73
  return {
74
74
  mode: "dry-run",
75
+ message: "DAG run prepared",
75
76
  title: spec.title,
76
77
  taskCount: spec.tasks.length,
77
78
  ranks: summary.ranks,
@@ -94,6 +95,7 @@ export async function runDagUseCase(input) {
94
95
  if (resolvedCanvasPath) {
95
96
  return {
96
97
  ...summary,
98
+ message: "DAG run finished",
97
99
  next: buildRunDagNextSteps(summary.runId),
98
100
  canvasPath: resolvedCanvasPath,
99
101
  ...(canvasError ? { canvasError } : {}),
@@ -101,6 +103,7 @@ export async function runDagUseCase(input) {
101
103
  }
102
104
  return {
103
105
  ...summary,
106
+ message: "DAG run finished",
104
107
  next: buildRunDagNextSteps(summary.runId),
105
108
  };
106
109
  }
@@ -4,6 +4,8 @@ import { assertValidDagSpec, collectExecutorModelWarnings, collectForbiddenExecu
4
4
  import { inferGovernanceProfile } from "../../workflows/dag/governance-profile.js";
5
5
  import { topoSortToRanks } from "../../workflows/dag/topo.js";
6
6
  import { runSpineAudit } from "../../governance/spine-audit.js";
7
+ import { resolveDagNodeSkills } from "../../workflows/dag/skills.js";
8
+ import { resolveDagSkillInstructions } from "../../workflows/dag/skill-instructions.js";
7
9
  function formatModelMatrixWarnings(warnings) {
8
10
  return warnings.map((warning) => ({
9
11
  executor: warning.executor,
@@ -55,6 +57,36 @@ function ensureNoForbiddenExecutors(spec, forbidExecutors, rawTaskExecutors) {
55
57
  .join("; ");
56
58
  throw new Error(`forbidden executor present: ${details}`);
57
59
  }
60
+ async function ensureStrictSkillResolution(spec, repoRoot) {
61
+ const failures = [];
62
+ for (const task of spec.tasks) {
63
+ if (task.executor !== "pi" && task.executor !== "cursor")
64
+ continue;
65
+ const skills = resolveDagNodeSkills(spec, task);
66
+ if (skills.length === 0)
67
+ continue;
68
+ const resolved = await resolveDagSkillInstructions(skills, {
69
+ cwd: repoRoot,
70
+ perSkillMaxChars: 100_000,
71
+ totalMaxChars: 1_000_000,
72
+ });
73
+ for (const entry of resolved) {
74
+ if (entry.resolution !== "resolved") {
75
+ failures.push(`${task.id}:${entry.name}:${entry.resolution}${entry.error ? `:${entry.error}` : ""}`);
76
+ continue;
77
+ }
78
+ if (entry.truncated) {
79
+ failures.push(`${task.id}:${entry.name}:truncated`);
80
+ }
81
+ for (const unresolved of entry.unresolvedReferences ?? []) {
82
+ failures.push(`${task.id}:${entry.name}:unresolved-reference:${unresolved.path}:${unresolved.reason}`);
83
+ }
84
+ }
85
+ }
86
+ if (failures.length > 0) {
87
+ throw new Error(`strict skill audit failed: ${failures.join("; ")}`);
88
+ }
89
+ }
58
90
  export async function validateDagUseCase(input) {
59
91
  const spec = await loadDagSpecFromFile(input.dagPath);
60
92
  const rawTaskExecutors = await loadRawTaskExecutorMap(input.dagPath);
@@ -65,6 +97,9 @@ export async function validateDagUseCase(input) {
65
97
  if (input.strictModelMatrix) {
66
98
  ensureStrictModelMatrix(warnings);
67
99
  }
100
+ if (input.strictSkills) {
101
+ await ensureStrictSkillResolution(spec, input.repoRoot);
102
+ }
68
103
  const spineAudit = input.spineTaskId
69
104
  ? await runSpineAudit(input.repoRoot, input.spineTaskId)
70
105
  : undefined;
@@ -81,9 +116,14 @@ export async function validateDagUseCase(input) {
81
116
  const { ranks } = topoSortToRanks(spec);
82
117
  const governanceProfile = inferGovernanceProfile(spec);
83
118
  return {
119
+ message: "DAG validation passed",
84
120
  title: spec.title,
85
121
  taskCount: spec.tasks.length,
86
122
  ranks,
123
+ checks: {
124
+ writeSets: "checked",
125
+ decisionGates: "checked",
126
+ },
87
127
  governanceProfile,
88
128
  spineAudit: spineAudit
89
129
  ? {
@@ -50,7 +50,7 @@ export function formatSubcommandUsageError(name, subcommands) {
50
50
  return `usage: ${formatSubcommandUsage(name, subcommands)}`;
51
51
  }
52
52
  const DOCS_SUBCOMMANDS = ["audit", "archive"];
53
- const INIT_SUBCOMMANDS = ["instructions", "doctor"];
53
+ const INIT_SUBCOMMANDS = ["instructions", "doctor", "check-update", "update"];
54
54
  const EXAMPLES_SUBCOMMANDS = ["list", "show", "copy"];
55
55
  const CLOSEOUT_SUBCOMMANDS = ["task"];
56
56
  const PLAN_SUBCOMMANDS = ["list"];
@@ -145,7 +145,7 @@ export const COMMAND_DEFINITIONS = [
145
145
  adapter: "none",
146
146
  tier: "primary",
147
147
  intent: "Initialize a target repository with loop-agent harness capabilities.",
148
- usage: "init [instructions|doctor] [--profile full|minimal] [--merge]",
148
+ usage: "init [instructions|doctor|check-update|update] [--profile full|minimal] [--merge] [--json|--markdown] [--bootstrap-surface|--apply-safe]",
149
149
  subcommands: [...INIT_SUBCOMMANDS],
150
150
  handler: async ({ repoRoot, subcommand, rest }) => {
151
151
  await runInit(repoRoot, [subcommand, ...rest].filter(Boolean));
@@ -1,3 +1,4 @@
1
+ import { readFileSync } from "node:fs";
1
2
  import path from "node:path";
2
3
  import { Command } from "commander";
3
4
  import { resolveAdapter } from "../adapters/index.js";
@@ -50,10 +51,22 @@ import { handleStandaloneOneShotCommandError } from "../shared/one-shot-prompt-a
50
51
  import { runDagDecisionInspect, runDagDecisionValidate, } from "../workflows/dag/decision-envelope.js";
51
52
  import { runDagDoctor, runDagStatus } from "../workflows/dag/lifecycle.js";
52
53
  import { CODE_AGENT_COMMAND_MANIFEST } from "./catalog.js";
53
- function resolveRepoRootOnly(command, defaultRepoRoot) {
54
+ function readPackageVersion() {
55
+ try {
56
+ const raw = readFileSync(new URL("../../package.json", import.meta.url), "utf-8");
57
+ const parsed = JSON.parse(raw);
58
+ if (typeof parsed.version === "string")
59
+ return parsed.version;
60
+ }
61
+ catch {
62
+ // Fall back only if the package metadata is unexpectedly unavailable.
63
+ }
64
+ return "0.0.0";
65
+ }
66
+ function resolveRepoRootOnly(command, defaultRepoRoot, behavior) {
54
67
  const options = collectGlobalOptions(command);
55
68
  const repoRoot = path.resolve(options.repoRoot ?? defaultRepoRoot);
56
- if (options.repoRoot)
69
+ if (options.repoRoot && !behavior?.quiet)
57
70
  console.log(`[loop-agent] repo root: ${repoRoot}`);
58
71
  return repoRoot;
59
72
  }
@@ -341,6 +354,7 @@ function configureDagValidate(command) {
341
354
  .option("--dag <path>", "DAG spec path")
342
355
  .option("--strict-models", "fail on model routing warnings")
343
356
  .option("--strict-governance", "fail on governance warnings")
357
+ .option("--strict-skills", "fail on missing, errored, truncated, or unresolved skill instructions")
344
358
  .option("--forbid-executor <executor>", "forbid executor", (value, previous = []) => [
345
359
  ...previous,
346
360
  value,
@@ -474,7 +488,9 @@ async function runPiPromptCommand(args) {
474
488
  }
475
489
  }
476
490
  async function runInitCommand(args, command, defaultRepoRoot) {
477
- await runInit(resolveRepoRootOnly(command, defaultRepoRoot), commandArgsWithOptions(args, command));
491
+ const initArgs = commandArgsWithOptions(args, command);
492
+ const quiet = initArgs.includes("--json") || initArgs.includes("--markdown");
493
+ await runInit(resolveRepoRootOnly(command, defaultRepoRoot, { quiet }), initArgs);
478
494
  }
479
495
  async function runExamplesCommand(args, command, defaultRepoRoot) {
480
496
  await runExamples(resolveRepoRootOnly(command, defaultRepoRoot), commandArgsWithOptions(args, command));
@@ -484,6 +500,7 @@ export function buildLoopAgentProgram(options) {
484
500
  program
485
501
  .name("loop-agent")
486
502
  .description("Loop Agent task and DAG automation CLI")
503
+ .version(readPackageVersion(), "-V, --version", "display version")
487
504
  .showHelpAfterError()
488
505
  .option("--repo-root <path>", "repository root")
489
506
  .option("--adapter <name>", "harness adapter name")
@@ -526,7 +543,10 @@ export function buildLoopAgentProgram(options) {
526
543
  .option("--no-merge", "skip existing files")
527
544
  .option("--provider <provider>", "model provider")
528
545
  .option("--model <model>", "model name")
529
- .option("--json", "print JSON");
546
+ .option("--json", "print JSON")
547
+ .option("--markdown", "print Markdown")
548
+ .option("--bootstrap-surface", "write an inferred .harness/init-surface.json baseline")
549
+ .option("--apply-safe", "apply deterministic safe init updates");
530
550
  command.action(async (args, _options, actionCommand) => runInitCommand(args, actionCommand, options.defaultRepoRoot));
531
551
  addStandaloneSubcommands(command, entry.subcommands ?? [], (args, actionCommand) => runInitCommand(args, actionCommand, options.defaultRepoRoot));
532
552
  program.addCommand(command);