@tea-agent/loop-agent 0.22.0 → 0.23.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 (73) hide show
  1. package/AGENTS.md +42 -108
  2. package/CHANGELOG.md +68 -0
  3. package/README.md +7 -4
  4. package/dist/application/context-usage/skill-resolution-stats.js +263 -0
  5. package/dist/application/dag/generate-task-dag.js +17 -3
  6. package/dist/cli/command-definitions.js +8 -7
  7. package/dist/cli/program.js +17 -15
  8. package/dist/commands/doctor.js +269 -18
  9. package/dist/commands/init.js +101 -86
  10. package/dist/commands/stats.js +40 -11
  11. package/dist/shared/operator/capabilities.js +11 -1
  12. package/dist/worker/console/app-data.js +4 -0
  13. package/dist/worker/console/chat/instruction-skills.js +217 -0
  14. package/dist/worker/console/chat/model-resolver.js +106 -0
  15. package/dist/worker/console/chat/pi-runtime.js +605 -0
  16. package/dist/worker/console/chat/resource-loader.js +66 -0
  17. package/dist/worker/console/chat/routes.js +357 -0
  18. package/dist/worker/console/chat/session-store.js +238 -0
  19. package/dist/worker/console/chat/tool-adapter.js +238 -0
  20. package/dist/worker/console/chat/tools.js +171 -0
  21. package/dist/worker/console/server.js +55 -0
  22. package/dist/worker/console/static/assets/index-DVl7Jxt5.js +25 -0
  23. package/dist/worker/console/static/assets/index-lVcIr9Ju.css +1 -0
  24. package/dist/worker/console/static/index.html +2 -2
  25. package/dist/worker/feature/profile-schema.js +1 -1
  26. package/dist/workflows/dag/init-hybrid.js +69 -21
  27. package/dist/workflows/dag/node-execution.js +38 -1
  28. package/dist/workflows/dag/output-protocol.js +89 -0
  29. package/dist/workflows/dag/prompt.js +35 -1
  30. package/dist/workflows/dag/recovery-recommendation.js +45 -0
  31. package/dist/workflows/dag/report.js +28 -1
  32. package/dist/workflows/dag/rerun-task.js +1 -1
  33. package/dist/workflows/dag/scheduler.js +9 -0
  34. package/dist/workflows/dag/types.js +12 -0
  35. package/dist/workflows/dag/validate.js +55 -0
  36. package/docs/README.md +73 -156
  37. package/docs/architecture/README.md +3 -2
  38. package/docs/architecture/dag-execution.md +2 -2
  39. package/docs/architecture/evolution.md +14 -12
  40. package/docs/architecture/system-overview.md +1 -1
  41. package/docs/architecture/worker-and-feature.md +3 -3
  42. package/docs/governance/README.md +15 -0
  43. package/docs/{harness-methodology-debugging.md → governance/harness-methodology-debugging.md} +27 -3
  44. package/docs/init-surface.manifest.json +22 -4
  45. package/docs/operations/README.md +12 -0
  46. package/docs/{local-development-environment.md → operations/local-development-environment.md} +1 -1
  47. package/docs/skills/vetted-skill-registry.md +23 -3
  48. package/docs/templates/README.md +55 -0
  49. package/docs/templates/evaluation/agents-map-slim-v1.candidate.json +9 -0
  50. package/docs/templates/evaluation/agents-map-slim-v1.md +87 -0
  51. package/docs/templates/evaluation/agents-map-verbose-v0.candidate.json +9 -0
  52. package/docs/templates/evaluation/agents-map-verbose-v0.md +153 -0
  53. package/docs/templates/hybrid-dag.json +1 -1
  54. package/docs/templates/progress-log.md +9 -2
  55. package/harness.json +5 -5
  56. package/package.json +5 -5
  57. package/scripts/kb-bootstrap-init-skeleton.sh +2 -2
  58. package/skills/agent-worker/SKILL.md +1 -1
  59. package/skills/grill-with-docs/SKILL.md +44 -52
  60. package/skills/grill-with-docs/adr-format.md +37 -26
  61. package/skills/grill-with-docs/context-format.md +18 -26
  62. package/skills/loop-agent/SKILL.md +28 -112
  63. package/skills/loop-agent/references/command-reference.md +9 -3
  64. package/skills/loop-agent/references/harness-policy.md +3 -3
  65. package/skills/loop-agent/references/hybrid-dag.md +1 -1
  66. package/skills/loop-agent/references/orchestrator-and-interventions.md +1 -1
  67. package/skills/loop-agent/references/task-workflow.md +2 -0
  68. package/skills/systematic-debugging/SKILL.md +20 -4
  69. package/skills/test-driven-development/SKILL.md +10 -3
  70. package/dist/worker/console/static/assets/index-CUDke82y.js +0 -18
  71. package/dist/worker/console/static/assets/index-wSEksVSO.css +0 -1
  72. /package/docs/{harness-methodology-tdd.md → governance/harness-methodology-tdd.md} +0 -0
  73. /package/docs/{harness-methodology-verification.md → governance/harness-methodology-verification.md} +0 -0
@@ -77,9 +77,9 @@ loop-agent run-dag \
77
77
 
78
78
  `loop-agent` is the preferred global CLI. For self-hosting loop-agent development, the controller must be an installed npm-published package. Use `npm install -g @tea-agent/loop-agent@latest` for first install or intentional upgrades, then treat the installed version as frozen for the current task and record `npm list -g @tea-agent/loop-agent --depth=0`. Do not repeatedly fetch `npx @latest` inside DAG nodes, and do not use the current working tree's `npm link` or `npm run dev` to control tasks that may edit CLI, DAG runtime, executors, package metadata, or build output. Use `npm run dev -- <args>` only for source debugging and focused CLI development.
79
79
 
80
- The npm package carries static capability assets: `.agents/skills/`, top-level governance docs, `ai_workspace/loop-agent/templates/`, `examples/`, `harness.json`, `AGENTS.md`, `README.md`, and `CHANGELOG.md`. Generated or historical task facts under `ai_workspace/loop-agent/progress/`, `ai_workspace/loop-agent/reports/`, `ai_workspace/loop-agent/exec-plans/`, and `ai_workspace/loop-agent/decisions/` belong to the target repository; package only their directory README files, not prior run content.
80
+ The npm package carries static capability assets: `skills/` (bundled in-package, containing `loop-agent` and `agent-worker`; `loop-agent init` mirrors them into the target project's `.agents/skills/`), `docs/templates/`, `docs/architecture/`, `docs/skills/`, `examples/`, `harness.json`, `AGENTS.md`, `README.md`, and `CHANGELOG.md`. `loop-agent init` creates `ai_workspace/loop-agent/` (the default governanceRoot) in the target project with `progress/`, `reports/`, `exec-plans/`, and `decisions/` directories plus their README files; the actual files under those directories belong to the target repository and are not shipped by the npm package.
81
81
 
82
- For arbitrary target repositories, DAG skill instructions must not depend on loop-agent source history being copied into the target repo. Resolve configured, user, or target-local skills when present, then fall back to package-bundled `.agents/skills/` as the stable default capability set.
82
+ For arbitrary target repositories, DAG skill instructions must not depend on loop-agent source history being copied into the target repo. Resolve configured, user, or target-local skills when present, then fall back to the package-bundled `skills/` (mirrored as `.agents/skills/` in the target project) as the stable default capability set.
83
83
 
84
84
  `<temp-dir>` means the platform-native temp directory. Use native paths for actual `--output`, `--dag`, and `--cwd` values on macOS and Windows; use `/` only for stable repo refs, JSON/Markdown evidence refs, and glob conventions.
85
85
 
@@ -190,7 +190,7 @@ Rules:
190
190
 
191
191
  - Learned prompt deltas 是 human-gated proposals;成为 reusable guidance 前须 review。
192
192
  - Prompt deltas 为 Markdown-only process guidance;不得含 shell commands、credential handling、tool permission expansion 或 completion-authority bypass。
193
- - Accepted learned guidance 位于 `./skill/references/learned/<repo>.md` 或 `default.md`。
193
+ - Accepted learned guidance 位于 `skills/loop-agent/references/learned/<repo>.md` 或 `default.md`。
194
194
  - 已 request `loop-agent` 的 DAG implementer prompts 可 inline 最多三个 human-gated learned Markdown sections。
195
195
  - Learned guidance 为 advisory,永不替代 writeSet governance、Decision Gate policy 或 shell verification。
196
196
 
@@ -238,7 +238,7 @@ review-heavy DAG 中长 shell stdout 可能掩盖 proof 时,用 **evidence-sum
238
238
  | 7 | Completed facts | `.harness/dag-runs/completed/**` 仅可读 evidence — 归档后永不 mutate 历史 run 目录、`run.json`、`state.json` 或 `artifacts/**` |
239
239
  | 8 | Verdict gate | review/supervisor 应以 `VERDICT: pass` 或 `VERDICT: request-revision` 开头以利阅读;用 current-run `<fromNodeId>.json`(`$HARNESS_DAG_RUN_DIR`)上 `shell.verdictGate` block,exact-match `accept[]`;默认 `lineMode=first-non-empty`,supervised template 用 `first-verdict-line` 容忍 preamble 或第一条 normalized `VERDICT:` 前的常见整行 Markdown emphasis |
240
240
  | 9 | Decision Gate | 恰好 emit 一个 `DECISION_ENVELOPE_JSON` block;`audit.runId` 须绑定 **当前** run id;禁止 `decision: accept`、发明 schema、extra root key;填 `audit.nodeId` / `audit.model` |
241
- | 10 | writeSet planning | scout 应列出链接的 `./skill/references/**` 为 **writeSet expansion candidates**(P2:遗漏链接 skill ref 会导致无法在 DAG 内收敛,禁止事后主会话大段补写) |
241
+ | 10 | writeSet planning | scout 应列出链接的 `skills/loop-agent/references/**` 为 **writeSet expansion candidates**(P2:遗漏链接 skill ref 会导致无法在 DAG 内收敛,禁止事后主会话大段补写) |
242
242
  | 11 | Evidence summary | `evidence-summary-shell` / leading `EVIDENCE:` 行是 **practice convention**,非 runtime executor、schema field 或 parser |
243
243
  | 12 | Featureization | 除非 repeated real-run failure 证明 checklist guidance 不够,勿加 runtime/schema/validator/CLI/executor feature |
244
244
  | 13 | writeSet / writer backend | `exclusive` node 用 narrow、disjoint path;无 `**`;固定用 Pi write profile |
@@ -72,7 +72,7 @@ Agent DAG read-only node **不得**写 root `artifacts/`。
72
72
  - `./artifacts/**` 不是 DAG artifact 位置;出现该目录通常表示 Cursor prompt 没有收到 DAG-owned artifact dir。
73
73
  - 若必须更新 root `artifacts/`,用显式 write-capable DAG node;不要用主会话「顺手写 root artifacts」代替节点。
74
74
 
75
- **Linked skill-reference writeSet candidates**:DAG task 变更 workflow 语义时,scout 应提议 `./skill/references/**` 为 **writeSet expansion candidates**,并在下一轮 DAG 中写入,而不是 post-DAG 由主会话大段补写 skill。
75
+ **Linked skill-reference writeSet candidates**:DAG task 变更 workflow 语义时,scout 应提议 `skills/loop-agent/references/**` 为 **writeSet expansion candidates**,并在下一轮 DAG 中写入,而不是 post-DAG 由主会话大段补写 skill。
76
76
 
77
77
  **允许的 operator 写入必须记录**:若发生下文极窄 operator 文件维护,须在 `ai_workspace/loop-agent/reports/`、`progress/` 或 exec plan 留下 scope + verification — 不可静默、不可当作实现完成。
78
78
 
@@ -75,6 +75,8 @@ loop-agent --repo-root /path/to/target-repo <command>
75
75
  - `verifyCommands` / adapter verification settings
76
76
  - `dagFallbackReason`,仅用于记录为何某个长期 loop 缺少 DAG round evidence
77
77
 
78
+ 切片形状:每个 task 应是可独立验证的垂直 tracer bullet,而不是某一层的水平批处理。Autonomy(AFK/HITL)与 governance profile(`minimal`/`standard`/`reviewed`/`supervised`)分开声明;默认 `--profile auto`。
79
+
78
80
  ## Verification
79
81
 
80
82
  完成声明必须来自新鲜验证证据。按目标 repo 的 `harness.json.governanceRoot` 下 `verification-matrix.md` 选择最小证明命令;loop-agent 自身常用:
@@ -21,6 +21,19 @@ NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
21
21
 
22
22
  若尚未完成 Phase 1,不得提出 fixes。
23
23
 
24
+ ## Feedback Loop Gate(Phase 1 之前)
25
+
26
+ 在列假设、读大段代码或改文件之前,先建立一条**快速、确定性、Agent 可运行**的 pass/fail 信号。完整优先级与手段见 governance 下的 `harness-methodology-debugging.md`。
27
+
28
+ 可执行清单:
29
+
30
+ 1. 选最小回路:失败测试 → HTTP/CLI/浏览器脚本 → fixture/snapshot → 一次性 harness → bisect/differential → 结构化 HITL。
31
+ 2. 跑一次,确认有可重复的 exit code / 断言结果。
32
+ 3. 间歇性问题:先提高复现率,再进入根因调查。
33
+ 4. **无回路 → STOP**:请求环境、artifact 或临时插桩许可;不要猜。
34
+
35
+ Verifier 角色只提供诊断与证据,不得越过 writer `writeSet` / `allowedPaths` 直接修复。
36
+
24
37
  ## When to Use
25
38
 
26
39
  用于 ANY technical issue:
@@ -45,11 +58,11 @@ NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
45
58
 
46
59
  ## The Four Phases
47
60
 
48
- 进入下一阶段前 MUST 完成每一 phase。
61
+ 进入下一阶段前 MUST 完成每一 phase。反馈回路是地基,不是第五 phase
49
62
 
50
63
  ### Phase 1: Root Cause Investigation
51
64
 
52
- **在尝试 ANY fix 之前:**
65
+ **在尝试 ANY fix 之前(且已有反馈回路):**
53
66
 
54
67
  1. **Read Error Messages Carefully**
55
68
  - 不要跳过 errors 或 warnings
@@ -215,6 +228,7 @@ NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
215
228
  ## Red Flags - STOP and Follow Process
216
229
 
217
230
  若发现自己想:
231
+ - "No pass/fail loop yet — just read code and guess"
218
232
  - "Quick fix for now, investigate later"
219
233
  - "Just try changing X and see if it works"
220
234
  - "Add multiple changes, run tests"
@@ -227,7 +241,7 @@ NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
227
241
  - **"One more fix attempt" (when already tried 2+)**
228
242
  - **Each fix reveals new problem in different place**
229
243
 
230
- **ALL of these mean: STOP. Return to Phase 1.**
244
+ **ALL of these mean: STOP. Return to feedback loop / Phase 1.**
231
245
 
232
246
  **If 3+ fixes failed:** Question the architecture (see Phase 4.5)
233
247
 
@@ -259,6 +273,7 @@ NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
259
273
 
260
274
  | Phase | Key Activities | Success Criteria |
261
275
  |-------|---------------|------------------|
276
+ | **0. Feedback Loop** | Build fast deterministic pass/fail signal | Repeatable command + exit code |
262
277
  | **1. Root Cause** | Read errors, reproduce, check changes, gather evidence | Understand WHAT and WHY |
263
278
  | **2. Pattern** | Find working examples, compare | Identify differences |
264
279
  | **3. Hypothesis** | Form theory, test minimally | Confirmed or new hypothesis |
@@ -284,8 +299,9 @@ NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
284
299
  - **`condition-based-waiting.md`** — 用 condition polling 替代 arbitrary timeouts
285
300
 
286
301
  **Related principles:**
287
- - **RED-GREEN-REFACTOR**(见 `ai_workspace/loop-agent/harness-methodology-tdd.md`)— 用于 creating failing test case(Phase 4, Step 1)
302
+ - **RED-GREEN-REFACTOR**(见 `harness.json.governanceRoot` 下 `harness-methodology-tdd.md`)— 用于 creating failing test case(Phase 4, Step 1)
288
303
  - **Verification discipline** — 宣称 success 前 verify fix worked。Run verification command,读 output,THEN claim result。
304
+ - **Feedback loop**(见同目录 `harness-methodology-debugging.md`)— Phase 1 前的 pass/fail 地基。
289
305
 
290
306
  ## Real-World Impact
291
307
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: test-driven-development
3
- description: 用于需要回归覆盖的行为变更与 bug 修复。保持小循环:写失败测试 → 变绿 → 仅在 green 后 refactor
3
+ description: 用于需要回归覆盖的行为变更与 bug 修复。保持小循环:写失败测试 → 变绿 → 仅在 green 后 refactor。禁止水平批处理。
4
4
  ---
5
5
 
6
6
  # Test-Driven Development
@@ -10,11 +10,18 @@ description: 用于需要回归覆盖的行为变更与 bug 修复。保持小
10
10
  ## 规则
11
11
 
12
12
  - 行为是新增或已损坏时,在 production code 之前写或更新聚焦测试。
13
- - 运行聚焦测试,确认因预期原因失败。
14
- - 做最小实现变更使测试变绿。
13
+ - 运行聚焦测试,确认因预期原因失败(RED)。
14
+ - 做最小实现变更使测试变绿(GREEN)。
15
15
  - refactor 仅在 green 之后,且仍在同一 bounded write set 内。
16
16
  - 能测真实本地 module 时,不要用 broad mock。
17
17
 
18
+ ## 垂直切片:一测试一实现
19
+
20
+ - 循环是:**一个行为测试 → 最小实现 → 验证通过 → 下一个行为**。
21
+ - **禁止**「先批量写完所有测试(全部 RED),再批量实现(全部 GREEN)」的水平切片。
22
+ - 每个行为切片必须有独立验收标准与可运行的验证命令。
23
+ - 纯文档 / 机械迁移工作不强制新增测试;行为变更与 bug 修复必须走上述循环。
24
+
18
25
  ## Output
19
26
 
20
27
  报告 red 命令、green 命令,以及仍需要的 broader verification。