@tea-agent/loop-agent 0.2.1 → 0.4.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 (135) hide show
  1. package/AGENTS.md +91 -87
  2. package/CHANGELOG.md +89 -52
  3. package/README.md +195 -180
  4. package/bin/agent-worker.js +22 -0
  5. package/bin/loop-agent.js +21 -21
  6. package/dist/application/dag/args.js +6 -0
  7. package/dist/application/dag/generate-task-dag.js +2 -0
  8. package/dist/application/dag/run-dag.js +3 -0
  9. package/dist/application/dag/validate-dag.js +40 -0
  10. package/dist/cli/command-definitions.js +2 -2
  11. package/dist/cli/program.js +24 -4
  12. package/dist/commands/init.js +1011 -459
  13. package/dist/commands/loop-benchmark.js +11 -11
  14. package/dist/commands/pi-reuse-benchmark.js +16 -16
  15. package/dist/executors/cursor-executor.js +1 -1
  16. package/dist/executors/dag-pi-executor.js +8 -1
  17. package/dist/task/runtime.js +27 -27
  18. package/dist/worker/cli.js +119 -0
  19. package/dist/worker/loop-agent/command-result.js +1 -0
  20. package/dist/worker/loop-agent/loop-agent-client.js +105 -0
  21. package/dist/worker/loop-agent/parse-json.js +14 -0
  22. package/dist/worker/materialize/harness-task-materializer.js +157 -0
  23. package/dist/worker/pool/failure-routing.js +98 -0
  24. package/dist/worker/pool/run-store.js +117 -0
  25. package/dist/worker/pool/types.js +1 -0
  26. package/dist/worker/preflight.js +108 -0
  27. package/dist/worker/profile-mapping.js +76 -0
  28. package/dist/worker/progress-reporter.js +81 -0
  29. package/dist/worker/report/morning-report.js +69 -0
  30. package/dist/worker/repos/repo-resolver.js +23 -0
  31. package/dist/worker/run-task/run-task.js +359 -0
  32. package/dist/worker/runner/run-ready.js +216 -0
  33. package/dist/worker/task-graph/acceptance-schema.js +25 -0
  34. package/dist/worker/task-graph/ready-queue.js +23 -0
  35. package/dist/worker/task-graph/task-graph-schema.js +28 -0
  36. package/dist/worker/task-graph/types.js +1 -0
  37. package/dist/worker/task-graph/validate.js +188 -0
  38. package/dist/worker/task-spec/complexity-mapping.js +8 -0
  39. package/dist/worker/task-spec/schema.js +116 -0
  40. package/dist/worker/task-spec/types.js +1 -0
  41. package/dist/worker/task-spec/validate.js +352 -0
  42. package/dist/workflows/dag/canvas-observer.js +275 -275
  43. package/dist/workflows/dag/dynamic-runtime/loop-until.js +2 -1
  44. package/dist/workflows/dag/dynamic-runtime/map.js +1 -0
  45. package/dist/workflows/dag/init-hybrid.js +3 -3
  46. package/dist/workflows/dag/skills.js +3 -3
  47. package/dist/workflows/dag/types.js +2 -0
  48. package/dist/workflows/dynamic/compile.js +11 -0
  49. package/dist/workflows/dynamic/spec.js +1 -0
  50. package/docs/README.md +72 -65
  51. package/docs/agent-dag-recovery-playbook.md +184 -184
  52. package/docs/agent-dag-runner.md +42 -40
  53. package/docs/architecture/runtime-boundaries.md +147 -147
  54. package/docs/cursor-executor-usage.md +25 -25
  55. package/docs/decisions/README.md +3 -3
  56. package/docs/design/README.md +36 -36
  57. package/docs/development-principles.md +73 -71
  58. package/docs/dynamic-workflow-dag-engine-roadmap.md +1749 -1749
  59. package/docs/exec-plans/README.md +6 -6
  60. package/docs/exec-plans/active/README.md +7 -10
  61. package/docs/exec-plans/completed/README.md +19 -9
  62. package/docs/feature-workflow.md +186 -186
  63. package/docs/harness-methodology-debugging.md +153 -153
  64. package/docs/harness-methodology-tdd.md +130 -130
  65. package/docs/harness-methodology-verification.md +27 -27
  66. package/docs/init-surface.manifest.json +175 -0
  67. package/docs/loop-agent-harness.md +42 -42
  68. package/docs/production-readiness.md +96 -96
  69. package/docs/progress/README.md +3 -3
  70. package/docs/reports/README.md +5 -5
  71. package/docs/skills/README.md +6 -0
  72. package/docs/skills/vetted-skill-registry.md +26 -0
  73. package/docs/templates/adr.md +60 -60
  74. package/docs/templates/agent-dag-authority-surface-audit.prompt.md +94 -94
  75. package/docs/templates/agent-dag-decision-envelope.schema.json +213 -213
  76. package/docs/templates/agent-dag-decision-gate-dogfood-report.md +117 -117
  77. package/docs/templates/agent-dag-decision-gate.prompt.md +246 -246
  78. package/docs/templates/agent-dag-process-supervisor.prompt.md +98 -98
  79. package/docs/templates/agent-dag-report.schema.json +454 -454
  80. package/docs/templates/agent-dag-review-verdict.prompt.md +68 -68
  81. package/docs/templates/agent-dag.base.json +195 -195
  82. package/docs/templates/agent-dag.final-verification.json +190 -190
  83. package/docs/templates/agent-dag.schema.json +316 -316
  84. package/docs/templates/agent-dag.supervised-implementation.json +500 -500
  85. package/docs/templates/exec-plan.md +64 -64
  86. package/docs/templates/feature-spec.md +53 -53
  87. package/docs/templates/hybrid-dag.json +193 -193
  88. package/docs/templates/init-evolution-review.md +33 -0
  89. package/docs/templates/production-readiness-checklist.md +57 -57
  90. package/docs/templates/progress-log.md +17 -17
  91. package/docs/templates/project-start-checklist.md +9 -9
  92. package/docs/templates/qa-report.md +48 -48
  93. package/docs/templates/sprint-contract.md +29 -29
  94. package/docs/verification-matrix.md +41 -41
  95. package/examples/decision-gate-agent-dag.json +123 -123
  96. package/examples/example-dag.json +51 -51
  97. package/examples/hybrid-loop-agent-dag.json +194 -194
  98. package/harness.json +94 -92
  99. package/package.json +66 -62
  100. package/skills/ai-engineering-context/SKILL.md +48 -48
  101. package/skills/code-review-core/SKILL.md +20 -0
  102. package/skills/codebase-scout/SKILL.md +19 -0
  103. package/skills/init-capability-evolution/SKILL.md +69 -0
  104. package/skills/loop-agent/SKILL.md +147 -145
  105. package/skills/loop-agent/references/README.md +67 -67
  106. package/skills/loop-agent/references/command-reference.md +403 -357
  107. package/skills/loop-agent/references/harness-policy.md +259 -258
  108. package/skills/loop-agent/references/hybrid-dag.md +216 -216
  109. package/skills/loop-agent/references/learned/README.md +21 -21
  110. package/skills/loop-agent/references/long-running-loop.md +59 -59
  111. package/skills/loop-agent/references/model-routing.md +36 -36
  112. package/skills/loop-agent/references/multi-worktree.md +54 -54
  113. package/skills/loop-agent/references/one-shot-runs.md +85 -85
  114. package/skills/loop-agent/references/orchestrator-and-interventions.md +169 -169
  115. package/skills/loop-agent/references/pi-prompt.md +23 -23
  116. package/skills/loop-agent/references/pi-subagent-assisted-mode.md +81 -81
  117. package/skills/loop-agent/references/post-implementation-and-patterns.md +44 -44
  118. package/skills/loop-agent/references/task-workflow.md +84 -84
  119. package/skills/loop-agent/references/verification-and-failure-handling.md +128 -128
  120. package/skills/requesting-code-review/SKILL.md +101 -101
  121. package/skills/requesting-code-review/code-reviewer.md +168 -168
  122. package/skills/systematic-debugging/CREATION-LOG.md +119 -119
  123. package/skills/systematic-debugging/SKILL.md +296 -296
  124. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -158
  125. package/skills/systematic-debugging/condition-based-waiting.md +115 -115
  126. package/skills/systematic-debugging/defense-in-depth.md +122 -122
  127. package/skills/systematic-debugging/find-polluter.sh +63 -63
  128. package/skills/systematic-debugging/root-cause-tracing.md +169 -169
  129. package/skills/systematic-debugging/test-academic.md +14 -14
  130. package/skills/systematic-debugging/test-pressure-1.md +58 -58
  131. package/skills/systematic-debugging/test-pressure-2.md +68 -68
  132. package/skills/systematic-debugging/test-pressure-3.md +69 -69
  133. package/skills/test-driven-development/SKILL.md +20 -0
  134. package/skills/verification-before-completion/SKILL.md +154 -154
  135. package/skills/webapp-testing/SKILL.md +19 -0
@@ -1,40 +1,42 @@
1
- # Agent DAG Runner
2
-
3
- Agent DAG 是 loop-agent 的声明式编排 runtime。DAG 将工作拆为节点、按序执行 eligible ranks、记录 artifacts,并用 gate 做 review 与验证。
4
-
5
- ## 基本用法
6
-
7
- ```bash
8
- loop-agent dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
9
- loop-agent dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
10
- loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd .
11
- ```
12
-
13
- `<temp-dir>` 为平台原生临时目录。Windows 上 `--output`、`--dag`、`--cwd` 的实际值用原生路径。
14
-
15
- ## Executors
16
-
17
- - `static`:确定性生成的 artifacts 或 notes
18
- - `shell`:验证与文件系统检查
19
- - `pi`:规划、review、诊断;节点设 `toolProfile: "write"` 时有界写入
20
- - `cursor`:显式启用时的可选有界写后端
21
-
22
- ## Skills
23
-
24
- DAG spec 可声明 `defaults.skills`、`skillsByRole` 与节点级 `skills`。Runner 从 `skills/<skill-name>/SKILL.md` 解析本地指令,并在各节点 `skills.json` artifact 中记录解析元数据。
25
-
26
- `loop-agent` skill 位于 `skills/loop-agent/SKILL.md`。遗留根路径 `skill/SKILL.md` 仅为旧 worktree 保留兼容 fallback
27
-
28
- ## Artifacts
29
-
30
- DAG artifacts 位于:
31
-
32
- ```text
33
- .harness/dag-runs/<state>/<run-id>/artifacts/<node-id>/
34
- ```
35
-
36
- 根目录 `artifacts/` 不是有效的默认 DAG artifact 位置。
37
-
38
- ## Shell Gates
39
-
40
- - `shell.verdictGate` 从注入的当前 run 目录读取 `$HARNESS_DAG_RUN_DIR/<fromNodeId>.json`;不应自行发现 active run paths。
1
+ # Agent DAG Runner
2
+
3
+ Agent DAG 是 loop-agent 的声明式编排 runtime。DAG 将工作拆为节点、按序执行 eligible ranks、记录 artifacts,并用 gate 做 review 与验证。
4
+
5
+ ## 基本用法
6
+
7
+ ```bash
8
+ loop-agent dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
9
+ loop-agent dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
10
+ loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd .
11
+ ```
12
+
13
+ `<temp-dir>` 为平台原生临时目录。Windows 上 `--output`、`--dag`、`--cwd` 的实际值用原生路径。
14
+
15
+ ## Executors
16
+
17
+ - `static`:确定性生成的 artifacts 或 notes
18
+ - `shell`:验证与文件系统检查
19
+ - `pi`:规划、review、诊断;节点设 `toolProfile: "write"` 时有界写入
20
+ - `cursor`:显式启用时的可选有界写后端
21
+
22
+ ## Skills
23
+
24
+ DAG spec 可声明 `defaults.skills`、`skillsByRole` 与节点级 `skills`。Runner 从 `skills/<skill-name>/SKILL.md` 解析本地指令,并在各节点 `skills.json` artifact 中记录解析元数据。
25
+
26
+ 执行前可用 `dag validate --strict-skills` 做 opt-in skill audit;该门禁会在 missing/error/truncated skill 或 unresolved reference 出现时失败。默认 role skill 应来自 `docs/skills/vetted-skill-registry.md` 中记录的 repo-local wrapper
27
+
28
+ `loop-agent` skill 位于 `skills/loop-agent/SKILL.md`。遗留根路径 `skill/SKILL.md` 仅为旧 worktree 保留兼容 fallback。
29
+
30
+ ## Artifacts
31
+
32
+ DAG artifacts 位于:
33
+
34
+ ```text
35
+ .harness/dag-runs/<state>/<run-id>/artifacts/<node-id>/
36
+ ```
37
+
38
+ 根目录 `artifacts/` 不是有效的默认 DAG artifact 位置。
39
+
40
+ ## Shell Gates
41
+
42
+ - `shell.verdictGate` 从注入的当前 run 目录读取 `$HARNESS_DAG_RUN_DIR/<fromNodeId>.json`;不应自行发现 active run paths。
@@ -1,147 +1,147 @@
1
- # Runtime Boundaries
2
-
3
- 本文定义 loop-agent 各 runtime 层的 module interface、允许的依赖方向,以及治理检查 hook。目标是把「命令、文档、import 架构」从多处维护收敛为可机器校验的边界契约,而不在本阶段改变 runtime 行为。
4
-
5
- ## 分层概览
6
-
7
- ```text
8
- Skill layer
9
- └─ 入口策略、reference 路由、硬规则(skills/loop-agent/SKILL.md + references/)
10
-
11
- CLI layer (src/cli/)
12
- └─ argv 解析、adapter 解析、调用 application / command handler、格式化输出
13
-
14
- Application layer (src/application/,逐步引入)
15
- └─ 一次用户意图的 typed use-case interface,供 CLI、Loop、Workflow 复用
16
-
17
- Workflow runtime (src/workflows/)
18
- └─ DAG / Dynamic / Loop 核心执行规则;不应依赖 commands
19
-
20
- Executors (src/executors/)
21
- └─ Cursor / Pi / Shell 等外部工具适配;不应依赖 commands 或 CLI formatting
22
-
23
- Infrastructure / Store (src/infrastructure/,逐步引入)
24
- └─ .harness 文件系统副作用、run lifecycle、原子写入规则
25
-
26
- Governance (scripts/check-*.sh, src/governance/)
27
- └─ 防止 command registry、skill entry、import architecture 漂移
28
- ```
29
-
30
- ## 各层职责
31
-
32
- ### Skill layer
33
-
34
- - **位置**:`skills/loop-agent/SKILL.md` 及 `skills/loop-agent/references/**`
35
- - **职责**:定义 agent 何时启用 loop-agent、默认执行路径(Agent DAG)、硬规则与 reference 路由;不承载完整操作手册。
36
- - **禁止**:在入口 skill 中重复维护 CLI command 列表或与 `src/cli/catalog.ts` 冲突的事实源。
37
-
38
- ### CLI layer
39
-
40
- - **位置**:`src/cli.ts`、`src/cli/**`
41
- - **职责**:解析全局 flag(如 `--repo-root`)、解析 top-level / subcommand、调用 command handler、输出 help / JSON / Markdown。
42
- - **允许依赖**:`src/commands/**`(handler wiring)、`src/adapters/**`、`src/shared/**`、逐步引入的 `src/application/**`。
43
- - **禁止**:在 router 中维护与 catalog 独立的 command 事实源(Phase 1 整改目标)。
44
-
45
- ### Application layer
46
-
47
- - **位置**:`src/application/**`(按计划逐步引入)
48
- - **职责**:封装一次用户意图的 typed result(如 validate DAG、run DAG、report),供 CLI 与 workflow runtime 共用。
49
- - **允许依赖**:`src/workflows/**`、`src/infrastructure/**`、`src/task/**`、`src/records/**`。
50
- - **禁止**:直接承担 CLI formatting 或 argv 解析。
51
-
52
- ### Workflow runtime
53
-
54
- - **位置**:`src/workflows/dag/**`、`src/workflows/dynamic/**`、`src/workflows/loop/**`
55
- - **职责**:DAG spec 校验与执行、dynamic workflow 编译与 expansion、Loop 状态机与 action 编排。
56
- - **允许依赖**:`src/executors/**`、`src/task/**`、`src/records/**`、`src/shared/**`、application use-case(目标态)。
57
- - **禁止**:`import` 来自 `src/commands/**`(见下方过渡例外)。
58
-
59
- ### Executors
60
-
61
- - **位置**:`src/executors/**`
62
- - **职责**:封装 Cursor SDK/CLI、Pi SDK/CLI、shell 执行与 write guard。
63
- - **允许依赖**:`src/shared/**`、外部 SDK。
64
- - **禁止**:依赖 `src/commands/**` 或 CLI 输出格式。
65
-
66
- ### Infrastructure / Store
67
-
68
- - **位置**:`src/infrastructure/harness/**`(按计划逐步引入);过渡期部分逻辑仍在 `src/workflows/dag/lifecycle.ts`、`src/records/**`。
69
- - **职责**:`.harness/tasks`、`.harness/dag-runs`、`.harness/runs`、loop state 的集中读写;completed run facts 只读约束。
70
- - **禁止**:把 raw path mutation 扩散给 runner、loop action 或 command handler。
71
-
72
- ### Governance
73
-
74
- - **位置**:`scripts/check-repo.sh` 及子脚本、`src/governance/**`、相关 Vitest。
75
- - **职责**:在 CI / in-flight DAG 中检测文档链接、exec plan 状态、架构 import、command registry 漂移、skill entry 完整性。
76
-
77
- ## 允许的依赖方向
78
-
79
- ```text
80
- Skill (docs) ──advisory──> CLI catalog / command-reference(人类可读,机器 drift check)
81
-
82
- CLI ──────────> Application (目标态)
83
- CLI ──────────> Commands (handler 薄层)
84
- Commands ──────────> Application / Workflows / Infrastructure
85
-
86
- Workflow runtime ──────────> Executors / Task / Records / Application (目标态)
87
- Workflow runtime ──X──> Commands (目标态禁止;见过渡例外)
88
-
89
- Executors ──────────> Shared / 外部 SDK
90
- Executors ──X──> Commands / CLI
91
-
92
- Application ──────────> Workflows / Infrastructure / Task / Records
93
- Application ──X──> CLI formatting
94
-
95
- Infrastructure ──────────> Shared / node:fs
96
- Runner / Loop ──(迁移中)──> 逐步改为仅经 Store / Application
97
- ```
98
-
99
- **规则摘要**
100
-
101
- | From | May import | Must not import |
102
- |------|------------|-----------------|
103
- | `src/commands/**` | application, workflows, infrastructure, task, records, executors, shared | — |
104
- | `src/workflows/**` | executors, task, records, shared, application(目标) | `src/commands/**` |
105
- | `src/executors/**` | shared, 外部 SDK | `src/commands/**`, `src/cli/**` |
106
- | `src/cli/**` | commands, adapters, shared, application(目标) | — |
107
- | `skills/**` | (Markdown 引用,非 TS import) | 运行时 TS 模块 |
108
-
109
- ## 已知过渡耦合
110
-
111
- 当前没有允许的 `src/workflows/**` 或 `src/executors/**` → `src/commands/**` TypeScript import。
112
-
113
- `scripts/check-architecture-boundaries.sh` 的 transitional allowlist 保持为空。任何新增的 `workflows/executors -> commands` import 必须导致检查 **exit 1**;如果未来确有临时例外,必须先写入 active exec plan,说明移除时间和验证门禁。
114
-
115
- ## Governance 钩子
116
-
117
- 以下脚本由 `scripts/check-repo.sh` 调用(Phase 0 起):
118
-
119
- | Script | 检查内容 | 失败条件 |
120
- |--------|----------|----------|
121
- | `scripts/check-architecture-boundaries.sh` | `workflows` / `executors` → `commands` import | 新的未 allowlist violation |
122
- | `scripts/check-command-registry-drift.sh` | `command-reference.md` 中的 top-level command vs `src/cli/catalog.ts` | 文档引用未注册 command |
123
- | `scripts/check-skill-entry.sh` | `SKILL.md` reference 文件存在、行数阈值 | reference 缺失(fail);行数 > 220(warn) |
124
-
125
- 相关 exec plan:`docs/exec-plans/active/2026-07-04-runtime-boundary-remediation.md`。
126
-
127
- ### 验证命令
128
-
129
- ```bash
130
- bash scripts/check-repo.sh
131
- bash scripts/check-architecture-boundaries.sh
132
- bash scripts/check-command-registry-drift.sh
133
- bash scripts/check-skill-entry.sh
134
- ```
135
-
136
- Runtime 变更另需 `npm run typecheck` 及对应 targeted Vitest(见 exec plan 各 Phase 验证关口)。
137
-
138
- ## 演进里程碑
139
-
140
- | Phase | 边界变化 |
141
- |-------|----------|
142
- | 0(当前) | 文档 + 机器 guard;已知 loop/actions.ts 耦合 advisory |
143
- | 1 | CLI command definition 单源 |
144
- | 2 | Skill entry 瘦身 + frontmatter references |
145
- | 3 | DAG application use-case;Loop 开始脱离 command JSON |
146
- | 6 | `workflows → commands` import check 已从 advisory 改为 **fail** |
147
- | 7 | Harness Store / Repository 集中 `.harness` 副作用 |
1
+ # Runtime Boundaries
2
+
3
+ 本文定义 loop-agent 各 runtime 层的 module interface、允许的依赖方向,以及治理检查 hook。目标是把「命令、文档、import 架构」从多处维护收敛为可机器校验的边界契约,而不在本阶段改变 runtime 行为。
4
+
5
+ ## 分层概览
6
+
7
+ ```text
8
+ Skill layer
9
+ └─ 入口策略、reference 路由、硬规则(skills/loop-agent/SKILL.md + references/)
10
+
11
+ CLI layer (src/cli/)
12
+ └─ argv 解析、adapter 解析、调用 application / command handler、格式化输出
13
+
14
+ Application layer (src/application/,逐步引入)
15
+ └─ 一次用户意图的 typed use-case interface,供 CLI、Loop、Workflow 复用
16
+
17
+ Workflow runtime (src/workflows/)
18
+ └─ DAG / Dynamic / Loop 核心执行规则;不应依赖 commands
19
+
20
+ Executors (src/executors/)
21
+ └─ Cursor / Pi / Shell 等外部工具适配;不应依赖 commands 或 CLI formatting
22
+
23
+ Infrastructure / Store (src/infrastructure/,逐步引入)
24
+ └─ .harness 文件系统副作用、run lifecycle、原子写入规则
25
+
26
+ Governance (scripts/check-*.sh, src/governance/)
27
+ └─ 防止 command registry、skill entry、import architecture 漂移
28
+ ```
29
+
30
+ ## 各层职责
31
+
32
+ ### Skill layer
33
+
34
+ - **位置**:`skills/loop-agent/SKILL.md` 及 `skills/loop-agent/references/**`
35
+ - **职责**:定义 agent 何时启用 loop-agent、默认执行路径(Agent DAG)、硬规则与 reference 路由;不承载完整操作手册。
36
+ - **禁止**:在入口 skill 中重复维护 CLI command 列表或与 `src/cli/catalog.ts` 冲突的事实源。
37
+
38
+ ### CLI layer
39
+
40
+ - **位置**:`src/cli.ts`、`src/cli/**`
41
+ - **职责**:解析全局 flag(如 `--repo-root`)、解析 top-level / subcommand、调用 command handler、输出 help / JSON / Markdown。
42
+ - **允许依赖**:`src/commands/**`(handler wiring)、`src/adapters/**`、`src/shared/**`、逐步引入的 `src/application/**`。
43
+ - **禁止**:在 router 中维护与 catalog 独立的 command 事实源(Phase 1 整改目标)。
44
+
45
+ ### Application layer
46
+
47
+ - **位置**:`src/application/**`(按计划逐步引入)
48
+ - **职责**:封装一次用户意图的 typed result(如 validate DAG、run DAG、report),供 CLI 与 workflow runtime 共用。
49
+ - **允许依赖**:`src/workflows/**`、`src/infrastructure/**`、`src/task/**`、`src/records/**`。
50
+ - **禁止**:直接承担 CLI formatting 或 argv 解析。
51
+
52
+ ### Workflow runtime
53
+
54
+ - **位置**:`src/workflows/dag/**`、`src/workflows/dynamic/**`、`src/workflows/loop/**`
55
+ - **职责**:DAG spec 校验与执行、dynamic workflow 编译与 expansion、Loop 状态机与 action 编排。
56
+ - **允许依赖**:`src/executors/**`、`src/task/**`、`src/records/**`、`src/shared/**`、application use-case(目标态)。
57
+ - **禁止**:`import` 来自 `src/commands/**`(见下方过渡例外)。
58
+
59
+ ### Executors
60
+
61
+ - **位置**:`src/executors/**`
62
+ - **职责**:封装 Cursor SDK/CLI、Pi SDK/CLI、shell 执行与 write guard。
63
+ - **允许依赖**:`src/shared/**`、外部 SDK。
64
+ - **禁止**:依赖 `src/commands/**` 或 CLI 输出格式。
65
+
66
+ ### Infrastructure / Store
67
+
68
+ - **位置**:`src/infrastructure/harness/**`(按计划逐步引入);过渡期部分逻辑仍在 `src/workflows/dag/lifecycle.ts`、`src/records/**`。
69
+ - **职责**:`.harness/tasks`、`.harness/dag-runs`、`.harness/runs`、loop state 的集中读写;completed run facts 只读约束。
70
+ - **禁止**:把 raw path mutation 扩散给 runner、loop action 或 command handler。
71
+
72
+ ### Governance
73
+
74
+ - **位置**:`scripts/check-repo.sh` 及子脚本、`src/governance/**`、相关 Vitest。
75
+ - **职责**:在 CI / in-flight DAG 中检测文档链接、exec plan 状态、架构 import、command registry 漂移、skill entry 完整性。
76
+
77
+ ## 允许的依赖方向
78
+
79
+ ```text
80
+ Skill (docs) ──advisory──> CLI catalog / command-reference(人类可读,机器 drift check)
81
+
82
+ CLI ──────────> Application (目标态)
83
+ CLI ──────────> Commands (handler 薄层)
84
+ Commands ──────────> Application / Workflows / Infrastructure
85
+
86
+ Workflow runtime ──────────> Executors / Task / Records / Application (目标态)
87
+ Workflow runtime ──X──> Commands (目标态禁止;见过渡例外)
88
+
89
+ Executors ──────────> Shared / 外部 SDK
90
+ Executors ──X──> Commands / CLI
91
+
92
+ Application ──────────> Workflows / Infrastructure / Task / Records
93
+ Application ──X──> CLI formatting
94
+
95
+ Infrastructure ──────────> Shared / node:fs
96
+ Runner / Loop ──(迁移中)──> 逐步改为仅经 Store / Application
97
+ ```
98
+
99
+ **规则摘要**
100
+
101
+ | From | May import | Must not import |
102
+ |------|------------|-----------------|
103
+ | `src/commands/**` | application, workflows, infrastructure, task, records, executors, shared | — |
104
+ | `src/workflows/**` | executors, task, records, shared, application(目标) | `src/commands/**` |
105
+ | `src/executors/**` | shared, 外部 SDK | `src/commands/**`, `src/cli/**` |
106
+ | `src/cli/**` | commands, adapters, shared, application(目标) | — |
107
+ | `skills/**` | (Markdown 引用,非 TS import) | 运行时 TS 模块 |
108
+
109
+ ## 已知过渡耦合
110
+
111
+ 当前没有允许的 `src/workflows/**` 或 `src/executors/**` → `src/commands/**` TypeScript import。
112
+
113
+ `scripts/check-architecture-boundaries.sh` 的 transitional allowlist 保持为空。任何新增的 `workflows/executors -> commands` import 必须导致检查 **exit 1**;如果未来确有临时例外,必须先写入 active exec plan,说明移除时间和验证门禁。
114
+
115
+ ## Governance 钩子
116
+
117
+ 以下脚本由 `scripts/check-repo.sh` 调用(Phase 0 起):
118
+
119
+ | Script | 检查内容 | 失败条件 |
120
+ |--------|----------|----------|
121
+ | `scripts/check-architecture-boundaries.sh` | `workflows` / `executors` → `commands` import | 新的未 allowlist violation |
122
+ | `scripts/check-command-registry-drift.sh` | `command-reference.md` 中的 top-level command vs `src/cli/catalog.ts` | 文档引用未注册 command |
123
+ | `scripts/check-skill-entry.sh` | `SKILL.md` reference 文件存在、行数阈值 | reference 缺失(fail);行数 > 220(warn) |
124
+
125
+ 相关 exec plan:`docs/exec-plans/active/2026-07-04-runtime-boundary-remediation.md`。
126
+
127
+ ### 验证命令
128
+
129
+ ```bash
130
+ bash scripts/check-repo.sh
131
+ bash scripts/check-architecture-boundaries.sh
132
+ bash scripts/check-command-registry-drift.sh
133
+ bash scripts/check-skill-entry.sh
134
+ ```
135
+
136
+ Runtime 变更另需 `npm run typecheck` 及对应 targeted Vitest(见 exec plan 各 Phase 验证关口)。
137
+
138
+ ## 演进里程碑
139
+
140
+ | Phase | 边界变化 |
141
+ |-------|----------|
142
+ | 0(当前) | 文档 + 机器 guard;已知 loop/actions.ts 耦合 advisory |
143
+ | 1 | CLI command definition 单源 |
144
+ | 2 | Skill entry 瘦身 + frontmatter references |
145
+ | 3 | DAG application use-case;Loop 开始脱离 command JSON |
146
+ | 6 | `workflows → commands` import check 已从 advisory 改为 **fail** |
147
+ | 7 | Harness Store / Repository 集中 `.harness` 副作用 |
@@ -1,25 +1,25 @@
1
- # Cursor Executor 用法
2
-
3
- Cursor 用于有界写实现。每个 Cursor 写任务必须显式定义 scope。
4
-
5
- ## Prompt 必填字段
6
-
7
- - task id
8
- - objective
9
- - allowed paths
10
- - forbidden paths
11
- - constraints
12
- - expected verification
13
- - 保留无关变更的指令
14
-
15
- ## One-Shot Helper
16
-
17
- ```bash
18
- loop-agent cursor-prompt \
19
- --cwd . \
20
- --timeout 1800000 \
21
- --model composer-2.5 \
22
- "<bounded task prompt>"
23
- ```
24
-
25
- Cursor 返回后,主会话必须检查 diff 并运行相关验证命令。
1
+ # Cursor Executor 用法
2
+
3
+ Cursor 用于有界写实现。每个 Cursor 写任务必须显式定义 scope。
4
+
5
+ ## Prompt 必填字段
6
+
7
+ - task id
8
+ - objective
9
+ - allowed paths
10
+ - forbidden paths
11
+ - constraints
12
+ - expected verification
13
+ - 保留无关变更的指令
14
+
15
+ ## One-Shot Helper
16
+
17
+ ```bash
18
+ loop-agent cursor-prompt \
19
+ --cwd . \
20
+ --timeout 1800000 \
21
+ --model composer-2.5 \
22
+ "<bounded task prompt>"
23
+ ```
24
+
25
+ Cursor 返回后,主会话必须检查 diff 并运行相关验证命令。
@@ -1,3 +1,3 @@
1
- # 决策
2
-
3
- 本目录存放架构决策记录(ADR)。
1
+ # 决策
2
+
3
+ 本目录存放架构决策记录(ADR)。
@@ -1,36 +1,36 @@
1
- # 设计笔记
2
-
3
- `docs/design/` 存放将 `loop-agent` 作为更大产品线 agent 平台内仓库本地 runtime 的规划笔记。这些是设计输入,不是 `src/` 已具备该能力的证明。
4
-
5
- ## 文档
6
-
7
- | 文档 | 用途 |
8
- |---|---|
9
- | `产品线共享知识库.md` | 产品线文档仓库作为上游事实源 |
10
- | `研发模式.md` | 10 个工作日 Feature 团队工作流 |
11
- | `1个月规划.md` | 首月落地计划 |
12
- | `1月wbs.md` | 首月 WBS 与分工 |
13
- | `六个月规划.md` | 六个月路线图与目标架构 |
14
- | `taskspec-to-loop-agent-mapping.md` | 将产品线 TaskSpec 适配为 `loop-agent` task 的契约 |
15
- | `state-and-failure-taxonomy.md` | 文档、Task Pool、DAG、Loop 共用的 canonical status 与 failure taxonomy |
16
-
17
- ## 当前实现边界
18
-
19
- `loop-agent` 当前拥有:仓库本地 harness、Agent DAG 生成/验证/执行、shell 验证、artifacts、reports、Loop state。它不是产品线 Task Pool、Orchestrator、docs-sync 服务、Git/CI 平台或 artifact store。
20
-
21
- 设计文档使用两类 profile 名称:
22
-
23
- - **Business task profiles**:`backend-feature`、`frontend-feature`、`qa-casegen`、`qa-testcode`、`reviewer-gate`
24
- - **`loop-agent dag run-task --profile` governance profiles**:`auto`、`minimal`、`standard`、`reviewed`、`supervised`
25
-
26
- 除非 CLI 显式扩展支持,否则不要把 business task profile 直接传给 `loop-agent dag run-task --profile`。用 `taskspec-to-loop-agent-mapping.md` 将 business profile 路由到当前 governance profile。
27
-
28
- ## 维护规则
29
-
30
- 设计笔记变更时:
31
-
32
- 1. 保持 TaskSpec 字段、status 名称、failure category 与命令示例与契约文档一致
33
- 2. 未来平台组件标为目标架构,除非已存在于 `src/` 或 `scripts/`
34
- 3. `src/task/config-types.ts` 或 DAG profile routing 变更时更新 `taskspec-to-loop-agent-mapping.md`
35
- 4. DAG report category、Loop failure class 或 Task Pool state 变更时更新 `state-and-failure-taxonomy.md`
36
- 5. 运行 `bash scripts/check-repo.sh`
1
+ # 设计笔记
2
+
3
+ `docs/design/` 存放将 `loop-agent` 作为更大产品线 agent 平台内仓库本地 runtime 的规划笔记。这些是设计输入,不是 `src/` 已具备该能力的证明。
4
+
5
+ ## 文档
6
+
7
+ | 文档 | 用途 |
8
+ |---|---|
9
+ | `产品线共享知识库.md` | 产品线文档仓库作为上游事实源 |
10
+ | `研发模式.md` | 10 个工作日 Feature 团队工作流 |
11
+ | `1个月规划.md` | 首月落地计划 |
12
+ | `1月wbs.md` | 首月 WBS 与分工 |
13
+ | `六个月规划.md` | 六个月路线图与目标架构 |
14
+ | `taskspec-to-loop-agent-mapping.md` | 将产品线 TaskSpec 适配为 `loop-agent` task 的契约 |
15
+ | `state-and-failure-taxonomy.md` | 文档、Task Pool、DAG、Loop 共用的 canonical status 与 failure taxonomy |
16
+
17
+ ## 当前实现边界
18
+
19
+ `loop-agent` 当前拥有:仓库本地 harness、Agent DAG 生成/验证/执行、shell 验证、artifacts、reports、Loop state。它不是产品线 Task Pool、Orchestrator、docs-sync 服务、Git/CI 平台或 artifact store。
20
+
21
+ 设计文档使用两类 profile 名称:
22
+
23
+ - **Business task profiles**:`backend-feature`、`frontend-feature`、`qa-casegen`、`qa-testcode`、`reviewer-gate`
24
+ - **`loop-agent dag run-task --profile` governance profiles**:`auto`、`minimal`、`standard`、`reviewed`、`supervised`
25
+
26
+ 除非 CLI 显式扩展支持,否则不要把 business task profile 直接传给 `loop-agent dag run-task --profile`。用 `taskspec-to-loop-agent-mapping.md` 将 business profile 路由到当前 governance profile。
27
+
28
+ ## 维护规则
29
+
30
+ 设计笔记变更时:
31
+
32
+ 1. 保持 TaskSpec 字段、status 名称、failure category 与命令示例与契约文档一致
33
+ 2. 未来平台组件标为目标架构,除非已存在于 `src/` 或 `scripts/`
34
+ 3. `src/task/config-types.ts` 或 DAG profile routing 变更时更新 `taskspec-to-loop-agent-mapping.md`
35
+ 4. DAG report category、Loop failure class 或 Task Pool state 变更时更新 `state-and-failure-taxonomy.md`
36
+ 5. 运行 `bash scripts/check-repo.sh`