@tea-agent/loop-agent 0.2.0 → 0.2.1

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 (58) hide show
  1. package/AGENTS.md +62 -45
  2. package/CHANGELOG.md +59 -43
  3. package/README.md +180 -179
  4. package/bin/loop-agent.js +21 -21
  5. package/dist/application/dag/generate-task-dag.js +3 -3
  6. package/dist/application/dag/run-dag.js +14 -1
  7. package/dist/application/dag/validate-dag.js +1 -0
  8. package/dist/commands/init.js +482 -459
  9. package/dist/workflows/dag/failure-routing.js +82 -0
  10. package/dist/workflows/dag/lifecycle.js +95 -3
  11. package/dist/workflows/dag/report.js +73 -1
  12. package/docs/README.md +47 -45
  13. package/docs/agent-dag-recovery-playbook.md +32 -6
  14. package/docs/agent-dag-runner.md +17 -17
  15. package/docs/architecture/runtime-boundaries.md +1 -1
  16. package/docs/cursor-executor-usage.md +5 -5
  17. package/docs/decisions/README.md +2 -2
  18. package/docs/design/README.md +24 -24
  19. package/docs/development-principles.md +50 -50
  20. package/docs/dynamic-workflow-dag-engine-roadmap.md +6 -6
  21. package/docs/exec-plans/README.md +4 -4
  22. package/docs/exec-plans/active/README.md +10 -9
  23. package/docs/exec-plans/completed/README.md +8 -8
  24. package/docs/feature-workflow.md +111 -109
  25. package/docs/harness-methodology-verification.md +18 -18
  26. package/docs/loop-agent-harness.md +36 -36
  27. package/docs/production-readiness.md +96 -0
  28. package/docs/progress/README.md +2 -2
  29. package/docs/reports/README.md +4 -2
  30. package/docs/templates/agent-dag-decision-gate-dogfood-report.md +1 -1
  31. package/docs/templates/agent-dag-process-supervisor.prompt.md +2 -2
  32. package/docs/templates/agent-dag-report.schema.json +33 -2
  33. package/docs/templates/agent-dag-review-verdict.prompt.md +1 -1
  34. package/docs/templates/agent-dag.base.json +195 -195
  35. package/docs/templates/agent-dag.final-verification.json +190 -190
  36. package/docs/templates/agent-dag.schema.json +17 -17
  37. package/docs/templates/agent-dag.supervised-implementation.json +500 -500
  38. package/docs/templates/hybrid-dag.json +193 -193
  39. package/docs/templates/production-readiness-checklist.md +57 -0
  40. package/docs/templates/progress-log.md +7 -7
  41. package/docs/templates/project-start-checklist.md +8 -8
  42. package/docs/templates/qa-report.md +17 -11
  43. package/docs/templates/sprint-contract.md +19 -19
  44. package/docs/verification-matrix.md +37 -26
  45. package/examples/example-dag.json +51 -51
  46. package/examples/hybrid-loop-agent-dag.json +194 -194
  47. package/harness.json +5 -5
  48. package/package.json +62 -62
  49. package/skills/loop-agent/SKILL.md +35 -35
  50. package/skills/loop-agent/references/command-reference.md +107 -65
  51. package/skills/loop-agent/references/harness-policy.md +30 -30
  52. package/skills/loop-agent/references/hybrid-dag.md +30 -30
  53. package/skills/loop-agent/references/model-routing.md +1 -1
  54. package/skills/loop-agent/references/orchestrator-and-interventions.md +1 -1
  55. package/skills/loop-agent/references/pi-prompt.md +9 -9
  56. package/skills/loop-agent/references/post-implementation-and-patterns.md +7 -7
  57. package/skills/loop-agent/references/task-workflow.md +19 -19
  58. package/skills/loop-agent/references/verification-and-failure-handling.md +36 -0
@@ -1,27 +1,27 @@
1
- # Verification Methodology
1
+ # 验证方法论
2
2
 
3
- Completion claims require current evidence.
3
+ 完成声明需要当前证据。
4
4
 
5
- ## Gate Function
5
+ ## 门禁函数
6
6
 
7
- 1. Identify the command that proves the claim.
8
- 2. Run the full command.
9
- 3. Read the output and exit code.
10
- 4. Fix failures or report the exact failing state.
11
- 5. Only then claim the result.
7
+ 1. 确定能证明声明的命令
8
+ 2. 完整运行该命令
9
+ 3. 读输出与 exit code
10
+ 4. 修失败或报告确切失败状态
11
+ 5. 然后再声明结果
12
12
 
13
- ## Common Gates
13
+ ## 常见门禁
14
14
 
15
- | Claim | Command |
15
+ | 声明 | 命令 |
16
16
  |---|---|
17
- | Governance is valid | `bash scripts/check-repo.sh` |
18
- | TypeScript compiles | `npm run typecheck` |
19
- | Behavior is covered | `npm test` |
20
- | Full local delivery is valid | `bash scripts/ci.sh` |
17
+ | 治理有效 | `bash scripts/check-repo.sh` |
18
+ | TypeScript 编译通过 | `npm run typecheck` |
19
+ | 行为有覆盖 | `npm test` |
20
+ | 完整本地交付有效 | `bash scripts/ci.sh` |
21
21
 
22
22
  ## Red Flags
23
23
 
24
- - claiming completion from intent
25
- - relying on stale command output
26
- - using a narrow check for a broad claim
27
- - skipping failed command details
24
+ - 凭意图声明完成
25
+ - 依赖陈旧命令输出
26
+ - 用窄检查支撑宽声明
27
+ - 跳过失败命令的细节
@@ -1,41 +1,41 @@
1
1
  # loop-agent Harness
2
2
 
3
- loop-agent provides a local harness for structured agent work.
4
-
5
- ## Runtime Areas
6
-
7
- - `.harness/tasks/` stores task source, constraints, state, and loop facts.
8
- - `.harness/dag-runs/` stores DAG run state and artifacts.
9
- - `.harness/runs/` stores one-shot tool run evidence.
10
- - `.harness/cache/` stores local runtime cache.
11
- - `.harness/live/` stores transient live-session files.
12
-
13
- ## Skill Instructions
14
-
15
- - `skills/loop-agent/` stores loop-agent's repo-owned skill instructions and references.
16
- - `skills/<skill-name>/` stores local copies of skills referenced by DAG templates, including supervised implementation roles.
17
- - Historical `skill/` is no longer a required repository path; runtime lookup keeps it only as a compatibility fallback for `loop-agent`.
18
-
19
- ## Package Assets
20
-
21
- The npm package includes static capability assets needed to run and explain the harness: `bin/`, `dist/`, `skills/`, top-level `docs/*.md`, `docs/templates/`, `examples/`, `harness.json`, `AGENTS.md`, `README.md`, and `CHANGELOG.md`.
22
-
23
- Generated or historical task facts are not package assets. Existing files under `docs/progress/`, `docs/reports/`, `docs/exec-plans/`, and `docs/decisions/` belong to the target repository's history; the package carries only the directory README files for those areas.
24
-
25
- When `loop-agent` is installed from npm and used against another project, DAG skill instructions resolve from configured, user, or target-local skill directories when present, then fall back to the package-bundled `skills/`. A target project may add local skills, but it does not need loop-agent's source history or a copied `skills/` directory to use the default DAG workflow.
26
-
27
- ## Command Surfaces
28
-
29
- - `new-task`, `status`, `inspect`, `doctor`
30
- - `dag run-task`, `dag validate`, `run-dag`, `dag report`, `dag resume`
31
- - `delegate`, `harvest`, `promote-run`, `closeout`
32
- - `loop init`, `loop run`, `loop status`, `loop closeout`
33
- - `pi-prompt`, `cursor-prompt`
34
- - `docs audit`, `handoff check`, `spine audit`, `knowledge curate`
35
-
36
- ## Verification Preset
37
-
38
- The shell preset `loop-agent-standard-verify` runs typecheck and focused DAG tests. Full delivery should still use:
3
+ loop-agent 提供结构化 agent 工作的本地 harness
4
+
5
+ ## Runtime 区域
6
+
7
+ - `.harness/tasks/` task source、约束、stateloop facts
8
+ - `.harness/dag-runs/` DAG run state artifacts
9
+ - `.harness/runs/` one-shot tool run 证据
10
+ - `.harness/cache/` 本地 runtime 缓存
11
+ - `.harness/live/` 瞬态 live-session 文件
12
+
13
+ ## Skill 指令
14
+
15
+ - `skills/loop-agent/` loop-agent 仓库自有的 skill 指令与参考资料
16
+ - `skills/<skill-name>/` DAG 模板引用的 skill 本地副本,含 supervised implementation 角色
17
+ - 历史 `skill/` 不再是必需仓库路径;runtime 查找仅为 `loop-agent` 保留兼容 fallback
18
+
19
+ ## Package 资产
20
+
21
+ npm 包包含运行与说明 harness 所需的静态能力资产:`bin/`、`dist/`、`skills/`、顶层 `docs/*.md`、`docs/templates/`、`examples/`、`harness.json`、`AGENTS.md`、`README.md`、`CHANGELOG.md`。
22
+
23
+ 生成或历史的 task facts 不是 package 资产。`docs/progress/`、`docs/reports/`、`docs/exec-plans/`、`docs/decisions/` 下现有文件属于目标仓库历史;包只携带这些目录的 README
24
+
25
+ npm 安装 `loop-agent` 并在其他项目使用时,DAG skill 指令按配置、用户或目标本地 skill 目录解析(若存在),再回退到包内 `skills/`。目标项目可添加本地 skills,但不必复制 loop-agent 源码历史或 `skills/` 目录即可使用默认 DAG 工作流。
26
+
27
+ ## Command Surface
28
+
29
+ - `new-task`、`status`、`inspect`、`doctor`
30
+ - `dag run-task`、`dag validate`、`run-dag`、`dag report`、`dag resume`
31
+ - `delegate`、`harvest`、`promote-run`、`closeout`
32
+ - `loop init`、`loop run`、`loop status`、`loop closeout`
33
+ - `pi-prompt`、`cursor-prompt`
34
+ - `docs audit`、`handoff check`、`spine audit`、`knowledge curate`
35
+
36
+ ## 验证 Preset
37
+
38
+ Shell preset `loop-agent-standard-verify` typecheck 与聚焦 DAG 测试。完整交付仍应使用:
39
39
 
40
40
  ```bash
41
41
  bash scripts/ci.sh
@@ -0,0 +1,96 @@
1
+ # Production Readiness v0.1
2
+
3
+ 本文档冻结 2026-07-06 至 2026-07-12 hardening sprint 的单任务 production readiness 标准。
4
+
5
+ `loop-agent` production readiness v0.1 指:低/中风险的仓库本地 DAG 任务能以稳定、可解释、可验证、可恢复的方式运行。这不是组织级平台 readiness 声明。
6
+
7
+ ## 支持范围
8
+
9
+ - 单仓库
10
+ - 单任务或小范围有边界任务
11
+ - 低/中风险的代码与文档变更
12
+ - 显式 task source
13
+ - 显式 `allowedPaths`、`forbiddenPaths`、`writeSet`
14
+ - shell 验证命令
15
+ - 通过 `dag report`、`dag doctor`、`promote-run`、`closeout` 交接
16
+
17
+ ## 非目标
18
+
19
+ - 自动 merge
20
+ - 自动 release
21
+ - 生产 secrets
22
+ - 生产数据库访问
23
+ - 高风险 migration
24
+ - 在线 Worker Pool
25
+ - 多仓库 feature 编排
26
+ - 可写的 Dynamic Workflow sharded migration
27
+ - DAG runtime 之外的第二套 runner
28
+
29
+ ## 必需证据
30
+
31
+ 每个 production-ready v0.1 任务必须保留或产出以下证据:
32
+
33
+ | 证据 | 要求 |
34
+ |---|---|
35
+ | DAG spec path | 生成的 DAG JSON 路径记录在 CLI 输出、report 或 task artifacts 中 |
36
+ | DAG validation result | `dag validate --strict-models --strict-governance` 有新鲜输出 |
37
+ | Run id | `run-dag` 打印或记录 run id |
38
+ | Shell verification output | 完成声明引用新鲜命令输出,而非 model 自报 |
39
+ | Failure category | 失败 run 在可用时具备 raw、normalized、product-line 与 recommended follow-up 字段 |
40
+ | Closeout 或 failure handoff | 成功 run 可 promote 并 closeout;失败 run 产出 failure handoff 证据而非成功 closeout |
41
+
42
+ ## 必需命令
43
+
44
+ 标准任务路径:
45
+
46
+ ```bash
47
+ loop-agent new-task <task-id> "Task title"
48
+ loop-agent dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
49
+ loop-agent dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
50
+ loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd .
51
+ loop-agent dag report --run-id <run-id> --markdown
52
+ loop-agent dag doctor --run-id <run-id>
53
+ loop-agent promote-run <task-id> --run-id <run-id>
54
+ loop-agent closeout task <task-id>
55
+ ```
56
+
57
+ `<temp-dir>` 使用平台原生临时目录。
58
+
59
+ ## 必需标准
60
+
61
+ | ID | 标准 | 验收 |
62
+ |---|---|---|
63
+ | PRD-01 | 新任务仅推荐 DAG 路径 | README、docs、website、skills 不把已移除的 Level 1 顺序命令当作 fallback |
64
+ | PRD-02 | 写任务有显式边界 | strict DAG governance 在需要时拒绝缺失 `allowedPaths`、`forbiddenPaths` 或 `writeSet` |
65
+ | PRD-03 | 每次 DAG run 有可读 report | `loop-agent dag report --latest --markdown` 显示 status、failure summary 与 next step |
66
+ | PRD-04 | 失败 run 可诊断 | `loop-agent dag doctor` 报告 category 与 recommended follow-up |
67
+ | PRD-05 | Shell 验证是完成权威 | closeout 不接受 model 自报替代新鲜命令输出 |
68
+ | PRD-06 | Failure category 覆盖失败 fixture | validation、write guard、shell、timeout、auth、unknown fixture 均有映射 |
69
+ | PRD-07 | 已完成 DAG facts 不可变 | completed facts guard 仍由测试覆盖 |
70
+ | PRD-08 | CLI 主路径输出指引下一步 | `dag run-task`、`dag validate`、`run-dag`、`dag report` 打印 operator next commands |
71
+ | PRD-09 | 文档面一致 | doc 更新后 `bash scripts/check-repo.sh` 与 `npm run docs:build` 通过 |
72
+ | PRD-10 | sprint 完成前完整本地门禁通过 | 最终 hardening closeout 时 `bash scripts/ci.sh` 通过 |
73
+
74
+ ## Failure Routing
75
+
76
+ Failure category 是路由字段,不是主任务状态。保留 raw DAG facts,仅在 report、doctor 输出、closeout draft、task artifacts 或后续 Task Pool 记录中追加派生字段。
77
+
78
+ 四层结构:
79
+
80
+ ```text
81
+ raw_failure_category
82
+ dag_normalized_failure_category
83
+ product_line_failure_category
84
+ recommended_follow_up
85
+ ```
86
+
87
+ Product-line category 事实源:`docs/design/state-and-failure-taxonomy.md`。
88
+
89
+ ## Sprint Gate
90
+
91
+ 2026-07-06 sprint 仅在 active execution plan 记录以下内容时视为完成:
92
+
93
+ - M1–M4 最终状态
94
+ - 必需验证门禁的命令输出
95
+ - 成功、write-guard、shell-failure 场景的 dogfood 证据
96
+ - 剩余风险与后续工作
@@ -1,3 +1,3 @@
1
- # Progress Logs
1
+ # 进度日志
2
2
 
3
- Use this directory for concise handoff logs that should survive chat context.
3
+ 本目录存放应超越聊天上下文的简洁 handoff 日志。
@@ -1,3 +1,5 @@
1
- # Reports
1
+ # 报告
2
2
 
3
- Use this directory for verification, audit, benchmark, and closeout reports.
3
+ 本目录存放验证、审计、benchmark closeout 报告。
4
+
5
+ - [`2026-07-12-production-readiness-hardening.md`](2026-07-12-production-readiness-hardening.md)
@@ -8,7 +8,7 @@
8
8
  |---|---|
9
9
  | Date | YYYY-MM-DD |
10
10
  | Topic | |
11
- | DAG input | `<temp-dir>/<topic>-decision-gate-dag.json` |
11
+ | DAG input | `<temp-dir>/<topic>-decision-gate-dag.json` |
12
12
  | Run ID | |
13
13
  | Run facts | `.harness/dag-runs/completed/<run-id>/` |
14
14
  | Gate type | `acceptance-gate` |
@@ -11,7 +11,7 @@ Do **not** create `executor: supervisor`. Supervisor is a **role** on `executor:
11
11
  ```json
12
12
  {
13
13
  "id": "process-supervisor-pi",
14
- "depends_on": ["soft-verify-shell", "implement-pi"],
14
+ "depends_on": ["soft-verify-shell", "implement-pi"],
15
15
  "complexity": "HIGH",
16
16
  "executor": "pi",
17
17
  "role": "supervisor",
@@ -80,7 +80,7 @@ Rules:
80
80
 
81
81
  - `verdict` must match the first line.
82
82
  - `failureClass` must be one of `syntax`, `runtime`, `logic`, `boundary`, `environment`, `governance`, `unknown`.
83
- - For `request-revision`, `fixScope` must name the smallest repair paths/components and stay inside the downstream `repair-pi` writeSet/allowedPaths.
83
+ - For `request-revision`, `fixScope` must name the smallest repair paths/components and stay inside the downstream `repair-pi` writeSet/allowedPaths.
84
84
  - For `pass`, `fixScope` must be an empty array.
85
85
  - `invariant` must state the behavior or contract the repair must preserve.
86
86
  - `evidenceRefs` must name node ids or relative artifact paths consulted.
@@ -58,6 +58,21 @@
58
58
  "commandHint": { "type": "string" }
59
59
  }
60
60
  },
61
+ "dagProductLineFailureCategory": {
62
+ "type": "string",
63
+ "enum": [
64
+ "SpecUnclear",
65
+ "ContractMismatch",
66
+ "ProductBug",
67
+ "TestBug",
68
+ "EnvFailure",
69
+ "FlakyTest",
70
+ "RiskyChange",
71
+ "DependencyFailure",
72
+ "NeedsHuman",
73
+ "Unknown"
74
+ ]
75
+ },
61
76
  "dagReportPrimaryFailure": {
62
77
  "type": "object",
63
78
  "additionalProperties": false,
@@ -87,7 +102,11 @@
87
102
  "skipped",
88
103
  "unknown"
89
104
  ]
90
- }
105
+ },
106
+ "productLineFailureCategory": {
107
+ "$ref": "#/$defs/dagProductLineFailureCategory"
108
+ },
109
+ "recommendedFollowUp": { "type": "string" }
91
110
  }
92
111
  },
93
112
  "dagReportPrimaryRecovery": {
@@ -117,7 +136,11 @@
117
136
  "skipped",
118
137
  "unknown"
119
138
  ]
120
- }
139
+ },
140
+ "productLineFailureCategory": {
141
+ "$ref": "#/$defs/dagProductLineFailureCategory"
142
+ },
143
+ "recommendedFollowUp": { "type": "string" }
121
144
  }
122
145
  },
123
146
  "dagNodeDecisionEnvelope": {
@@ -333,6 +356,10 @@
333
356
  "unknown"
334
357
  ]
335
358
  },
359
+ "productLineFailureCategory": {
360
+ "$ref": "#/$defs/dagProductLineFailureCategory"
361
+ },
362
+ "recommendedFollowUp": { "type": "string" },
336
363
  "recoveryRecommendation": {
337
364
  "$ref": "#/$defs/dagRecoveryRecommendation"
338
365
  },
@@ -400,6 +427,10 @@
400
427
  "unknown"
401
428
  ]
402
429
  },
430
+ "productLineFailureCategory": {
431
+ "$ref": "#/$defs/dagProductLineFailureCategory"
432
+ },
433
+ "recommendedFollowUp": { "type": "string" },
403
434
  "recoveryRecommendation": {
404
435
  "$ref": "#/$defs/dagRecoveryRecommendation"
405
436
  },
@@ -9,7 +9,7 @@ Use this prompt for a read-only **review verdict** node after hard verification:
9
9
  ```json
10
10
  {
11
11
  "id": "review-pi",
12
- "depends_on": ["hard-verify-shell", "repair-pi"],
12
+ "depends_on": ["hard-verify-shell", "repair-pi"],
13
13
  "complexity": "HIGH",
14
14
  "executor": "pi",
15
15
  "role": "reviewer",