@tea-agent/loop-agent 0.21.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.
- package/AGENTS.md +42 -108
- package/CHANGELOG.md +114 -0
- package/README.md +7 -4
- package/bin/agent-worker.js +0 -0
- package/dist/adapters/loop-agent.js +52 -0
- package/dist/application/context-usage/skill-resolution-stats.js +263 -0
- package/dist/application/dag/generate-task-dag.js +17 -3
- package/dist/cli/command-definitions.js +8 -7
- package/dist/cli/program.js +17 -15
- package/dist/commands/doctor.js +269 -18
- package/dist/commands/init.js +198 -86
- package/dist/commands/stats.js +40 -11
- package/dist/executors/dag-pi-executor.js +2 -0
- package/dist/executors/shell-executor.js +162 -19
- package/dist/shared/openspec-spec.js +49 -0
- package/dist/shared/operator/capabilities.js +11 -1
- package/dist/worker/console/app-data.js +4 -0
- package/dist/worker/console/chat/instruction-skills.js +217 -0
- package/dist/worker/console/chat/model-resolver.js +106 -0
- package/dist/worker/console/chat/pi-runtime.js +605 -0
- package/dist/worker/console/chat/resource-loader.js +66 -0
- package/dist/worker/console/chat/routes.js +357 -0
- package/dist/worker/console/chat/session-store.js +238 -0
- package/dist/worker/console/chat/tool-adapter.js +238 -0
- package/dist/worker/console/chat/tools.js +171 -0
- package/dist/worker/console/server.js +55 -0
- package/dist/worker/console/static/assets/index-DVl7Jxt5.js +25 -0
- package/dist/worker/console/static/assets/index-lVcIr9Ju.css +1 -0
- package/dist/worker/console/static/index.html +2 -2
- package/dist/worker/feature/profile-schema.js +1 -1
- package/dist/worker/observability/read-model.js +21 -1
- package/dist/worker/observe/spec-evidence.js +12 -15
- package/dist/worker/observe/static/dag-helpers.js +22 -0
- package/dist/worker/observe/static/views/dag.js +5 -0
- package/dist/workflows/dag/backend-test-markdown-workflow.js +37 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +141 -32
- package/dist/workflows/dag/frontend-lint-baseline.js +471 -0
- package/dist/workflows/dag/frontend-prewrite-gate.js +79 -16
- package/dist/workflows/dag/frontend-project-capability.js +11 -8
- package/dist/workflows/dag/frontend-repair.js +6 -4
- package/dist/workflows/dag/frontend-review-context.js +67 -0
- package/dist/workflows/dag/frontend-test-case-quality.js +105 -0
- package/dist/workflows/dag/frontend-test-result-contract.js +71 -66
- package/dist/workflows/dag/frontend-verification-trace.js +31 -1
- package/dist/workflows/dag/frontend-worktree-diff.js +81 -6
- package/dist/workflows/dag/init-hybrid.js +412 -84
- package/dist/workflows/dag/node-execution.js +38 -1
- package/dist/workflows/dag/output-protocol.js +89 -0
- package/dist/workflows/dag/prompt.js +35 -1
- package/dist/workflows/dag/recovery-recommendation.js +45 -0
- package/dist/workflows/dag/report.js +28 -1
- package/dist/workflows/dag/rerun-task.js +1 -1
- package/dist/workflows/dag/scheduler.js +9 -0
- package/dist/workflows/dag/types.js +74 -1
- package/dist/workflows/dag/validate.js +55 -0
- package/docs/README.md +73 -156
- package/docs/architecture/README.md +3 -2
- package/docs/architecture/dag-execution.md +2 -2
- package/docs/architecture/evolution.md +14 -12
- package/docs/architecture/system-overview.md +1 -1
- package/docs/architecture/worker-and-feature.md +3 -3
- package/docs/governance/README.md +15 -0
- package/docs/{harness-methodology-debugging.md → governance/harness-methodology-debugging.md} +27 -3
- package/docs/init-surface.manifest.json +22 -4
- package/docs/operations/README.md +12 -0
- package/docs/{local-development-environment.md → operations/local-development-environment.md} +1 -1
- package/docs/skills/vetted-skill-registry.md +23 -3
- package/docs/templates/README.md +55 -0
- package/docs/templates/agent-dag.schema.json +15 -5
- package/docs/templates/backend-test-dag.json +1 -1
- package/docs/templates/evaluation/agents-map-slim-v1.candidate.json +9 -0
- package/docs/templates/evaluation/agents-map-slim-v1.md +87 -0
- package/docs/templates/evaluation/agents-map-verbose-v0.candidate.json +9 -0
- package/docs/templates/evaluation/agents-map-verbose-v0.md +153 -0
- package/docs/templates/frontend-implementation-contract.schema.json +4 -3
- package/docs/templates/frontend-test-case-checklist.md +6 -2
- package/docs/templates/frontend-test-dag.json +2 -2
- package/docs/templates/hybrid-dag.json +1 -1
- package/docs/templates/progress-log.md +9 -2
- package/harness.json +5 -5
- package/package.json +5 -5
- package/scripts/kb-bootstrap-init-skeleton.sh +2 -2
- package/skills/agent-worker/SKILL.md +1 -1
- package/skills/frontend-design-review/SKILL.md +12 -10
- package/skills/frontend-design-review/references/review-checklist.md +4 -4
- package/skills/frontend-implementation/SKILL.md +2 -2
- package/skills/frontend-implementation/references/code-standards.md +4 -3
- package/skills/frontend-implementation/references/design-spec.md +19 -14
- package/skills/frontend-implementation/references/node-contracts.md +2 -2
- package/skills/frontend-review/SKILL.md +15 -28
- package/skills/frontend-review/references/review-findings.md +16 -18
- package/skills/frontend-verification/SKILL.md +16 -13
- package/skills/frontend-verification/references/verification-checklist.md +18 -30
- package/skills/grill-with-docs/SKILL.md +44 -52
- package/skills/grill-with-docs/adr-format.md +37 -26
- package/skills/grill-with-docs/context-format.md +18 -26
- package/skills/loop-agent/SKILL.md +28 -112
- package/skills/loop-agent/references/command-reference.md +9 -3
- package/skills/loop-agent/references/harness-policy.md +3 -3
- package/skills/loop-agent/references/hybrid-dag.md +1 -1
- package/skills/loop-agent/references/orchestrator-and-interventions.md +1 -1
- package/skills/loop-agent/references/task-workflow.md +2 -0
- package/skills/systematic-debugging/SKILL.md +20 -4
- package/skills/test-driven-development/SKILL.md +10 -3
- package/dist/worker/console/static/assets/index-CUDke82y.js +0 -18
- package/dist/worker/console/static/assets/index-wSEksVSO.css +0 -1
- /package/docs/{harness-methodology-tdd.md → governance/harness-methodology-tdd.md} +0 -0
- /package/docs/{harness-methodology-verification.md → governance/harness-methodology-verification.md} +0 -0
|
@@ -1,47 +1,58 @@
|
|
|
1
1
|
# ADR Format
|
|
2
2
|
|
|
3
|
-
ADRs live
|
|
3
|
+
ADRs live under `${harness.json.governanceRoot}/decisions/`(源码仓库通常为 `docs/decisions/`;普通初始化目标项目通常为 `ai_workspace/loop-agent/decisions/`)。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Do **not** create a parallel `adr/` tree. Use `decisions/` under the governance root only.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```md
|
|
10
|
-
# {Short title of the decision}
|
|
7
|
+
Create the decisions directory lazily — only when the first ADR is needed and write permission exists.
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
```
|
|
9
|
+
## Template
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
Follow the **target repository's existing ADR template**. In the loop-agent source repo that is `docs/templates/adr.md` with full sections:
|
|
16
12
|
|
|
17
|
-
|
|
13
|
+
- 标题 / 状态
|
|
14
|
+
- 背景
|
|
15
|
+
- 决策
|
|
16
|
+
- 备选方案
|
|
17
|
+
- 取舍理由
|
|
18
|
+
- 影响范围
|
|
19
|
+
- 后果(正面 / 负面)
|
|
20
|
+
- 验证与落地
|
|
21
|
+
- 复审条件
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
Do not replace a full local template with a one-paragraph mini-ADR.
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
- **Considered Options** — only when the rejected alternatives are worth remembering
|
|
23
|
-
- **Consequences** — only when non-obvious downstream effects need to be called out
|
|
25
|
+
Target projects may ship a copy of the template under their governance `templates/` directory; use that when present.
|
|
24
26
|
|
|
25
27
|
## Numbering
|
|
26
28
|
|
|
27
|
-
Scan
|
|
29
|
+
Scan the decisions directory for the highest existing `NNNN-*.md` number and increment by one. Update the decisions README index when one exists.
|
|
28
30
|
|
|
29
31
|
## When to offer an ADR
|
|
30
32
|
|
|
31
|
-
All three
|
|
33
|
+
All three must be true:
|
|
32
34
|
|
|
33
35
|
1. **Hard to reverse** — the cost of changing your mind later is meaningful
|
|
34
|
-
2. **Surprising without context** — a future reader will
|
|
35
|
-
3. **The result of a real trade-off** —
|
|
36
|
+
2. **Surprising without context** — a future reader will wonder why this path was chosen
|
|
37
|
+
3. **The result of a real trade-off** — genuine alternatives existed and one was chosen for specific reasons
|
|
36
38
|
|
|
37
|
-
If
|
|
39
|
+
If any is missing, skip the ADR.
|
|
38
40
|
|
|
39
41
|
### What qualifies
|
|
40
42
|
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
|
|
43
|
+
- Architectural shape and integration patterns between contexts
|
|
44
|
+
- Technology choices that carry lock-in
|
|
45
|
+
- Boundary and scope decisions (explicit no-es included)
|
|
46
|
+
- Deliberate deviations from the obvious path
|
|
47
|
+
- Constraints not visible in the code
|
|
48
|
+
- Rejected alternatives when the rejection is non-obvious
|
|
49
|
+
|
|
50
|
+
### What does not
|
|
51
|
+
|
|
52
|
+
- Temporary scheduling
|
|
53
|
+
- Obvious implementation choices with no alternatives
|
|
54
|
+
- Facts that belong in code, tests, or progress/report artifacts
|
|
55
|
+
|
|
56
|
+
## Write boundary
|
|
57
|
+
|
|
58
|
+
Only create or edit ADR files when the current task `allowedPaths` / DAG `writeSet` allow it. Otherwise return a suggested patch for human or writer follow-up.
|
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
{One or two sentence description of what this context is and why it exists.}
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## 使用说明(optional but recommended)
|
|
11
|
+
|
|
12
|
+
- CONTEXT.md is a glossary and nothing else.
|
|
13
|
+
- Do not store implementation details, draft specs, plan status, or architecture decisions.
|
|
14
|
+
|
|
15
|
+
## 术语 / Language
|
|
11
16
|
|
|
12
17
|
**Order**:
|
|
13
18
|
{A one or two sentence description of the term}
|
|
@@ -16,45 +21,32 @@ _Avoid_: Purchase, transaction
|
|
|
16
21
|
**Invoice**:
|
|
17
22
|
A request for payment sent to a customer after delivery.
|
|
18
23
|
_Avoid_: Bill, payment request
|
|
19
|
-
|
|
20
|
-
**Customer**:
|
|
21
|
-
A person or organization that places orders.
|
|
22
|
-
_Avoid_: Client, buyer, account
|
|
23
24
|
```
|
|
24
25
|
|
|
26
|
+
Prefer the target repository's existing heading style(本仓库使用「术语」与 `_避免_`)。
|
|
27
|
+
|
|
25
28
|
## Rules
|
|
26
29
|
|
|
27
|
-
- **Be opinionated.** When multiple words exist for the same concept, pick the best one and list the others under `_Avoid_`.
|
|
30
|
+
- **Be opinionated.** When multiple words exist for the same concept, pick the best one and list the others under `_Avoid_` / `_避免_`.
|
|
28
31
|
- **Keep definitions tight.** One or two sentences max. Define what it IS, not what it does.
|
|
29
|
-
- **
|
|
30
|
-
- **
|
|
32
|
+
- **Glossary only.** No implementation details, specs, plan status, or ADRs.
|
|
33
|
+
- **Only include terms specific to this project's context.** General programming concepts do not belong.
|
|
34
|
+
- **Group terms under subheadings** when natural clusters emerge.
|
|
31
35
|
|
|
32
36
|
## Single vs multi-context repos
|
|
33
37
|
|
|
34
38
|
**Single context (most repos):** One `CONTEXT.md` at the repo root.
|
|
35
39
|
|
|
36
|
-
**Multiple contexts:** A `CONTEXT-MAP.md` at the repo root lists the contexts, where they live, and how they relate
|
|
37
|
-
|
|
38
|
-
```md
|
|
39
|
-
# Context Map
|
|
40
|
-
|
|
41
|
-
## Contexts
|
|
42
|
-
|
|
43
|
-
- `src/ordering/CONTEXT.md` — receives and tracks customer orders
|
|
44
|
-
- `src/billing/CONTEXT.md` — generates invoices and processes payments
|
|
45
|
-
- `src/fulfillment/CONTEXT.md` — manages warehouse picking and shipping
|
|
46
|
-
|
|
47
|
-
## Relationships
|
|
48
|
-
|
|
49
|
-
- **Ordering → Fulfillment**: Ordering emits `OrderPlaced` events; Fulfillment consumes them to start picking
|
|
50
|
-
- **Fulfillment → Billing**: Fulfillment emits `ShipmentDispatched` events; Billing consumes them to generate invoices
|
|
51
|
-
- **Ordering ↔ Billing**: Shared types for `CustomerId` and `Money`
|
|
52
|
-
```
|
|
40
|
+
**Multiple contexts:** A `CONTEXT-MAP.md` at the repo root lists the contexts, where they live, and how they relate.
|
|
53
41
|
|
|
54
42
|
The skill infers which structure applies:
|
|
55
43
|
|
|
56
44
|
- If `CONTEXT-MAP.md` exists, read it to find contexts
|
|
57
45
|
- If only a root `CONTEXT.md` exists, single context
|
|
58
|
-
- If neither exists,
|
|
46
|
+
- If neither exists, propose a root `CONTEXT.md` lazily when the first term is resolved — create only when write permission exists
|
|
59
47
|
|
|
60
48
|
When multiple contexts exist, infer which one the current topic relates to. If unclear, ask.
|
|
49
|
+
|
|
50
|
+
## Write boundary
|
|
51
|
+
|
|
52
|
+
Only edit `CONTEXT.md` when current task `allowedPaths` / DAG `writeSet` allow it. Otherwise return a suggested patch.
|
|
@@ -9,142 +9,58 @@ references:
|
|
|
9
9
|
required: true
|
|
10
10
|
- path: references/verification-and-failure-handling.md
|
|
11
11
|
required: true
|
|
12
|
-
- path: references/command-reference.md
|
|
13
|
-
required: true
|
|
14
12
|
---
|
|
15
13
|
|
|
16
14
|
# loop-agent Workflow
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
## Canonical Harness Policy
|
|
21
|
-
|
|
22
|
-
Shared loop-agent harness workflow 规则见 `references/harness-policy.md`。Repo-local `ai_workspace/loop-agent/loop-agent-harness.md` / `specs/loop-agent-harness.md` 应保持为 local runtime path、governance root、verification commands 的 thin adapters。
|
|
16
|
+
Entry for `loop-agent`: trigger, routing, hard rules. Details live in `references/` on demand. `references/command-reference.md` is discoverable via the routing table, **not** a required reference.
|
|
23
17
|
|
|
24
18
|
## 默认立场
|
|
25
19
|
|
|
26
|
-
- 主入口是 **Agent DAG
|
|
27
|
-
- 本 skill
|
|
28
|
-
- **主会话 = operator-only**:编排 CLI、审 writeSet、只读 status/doctor/report
|
|
29
|
-
- **严禁**主会话绕过
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
- **失败时只允许**:`dag doctor` / `dag report` / `dag reconcile-run`(及 worker 侧 reconcile)、记 human gate、按边界重跑或 replan;不得改走主会话直接写实现。
|
|
33
|
-
- DAG `pi` executor 是唯一受治理 Agent runtime:默认 read-only planning / review / diagnosis;`toolProfile: "write"` 时为 bounded implementation / repair。Pi 模型矩阵 LOW=`gpt-5.3-codex-spark`、MED=`glm-5.2`、HIGH=`gpt-5.5`。
|
|
34
|
-
- `pi-prompt` 与 `cursor-prompt` 是一次性 helper;sidecar 须在 prompt/tool 参数中收窄。Cursor 仅显式手工 `cursor-prompt`,不是 DAG/Loop writer。
|
|
35
|
-
- Shell verification 是事实源;完成声明必须有本轮命令输出。
|
|
36
|
-
- 长期结论写回 `ai_workspace/loop-agent/exec-plans/`、`ai_workspace/loop-agent/reports/`、`ai_workspace/loop-agent/progress/` 或 `./skill/`。
|
|
20
|
+
- 主入口是 **Agent DAG**(经 `loop-agent` / 可选 `agent-worker` CLI)。
|
|
21
|
+
- 本 skill 对宿主定位是 **Compatibility / Operator Assist**,不写业务代码。
|
|
22
|
+
- **主会话 = operator-only**:编排 CLI、审 writeSet、只读 status/doctor/report、记 human gate、跑 Shell verification 与 handoff。
|
|
23
|
+
- **严禁**主会话绕过 CLI 用宿主 Edit/Write 改业务实现,或 CLI 失败后「救火改文件」。
|
|
24
|
+
- DAG `pi` executor 默认 read-only;`toolProfile: "write"` 时为 bounded writer;sidecar 须 per call 收窄。
|
|
25
|
+
- Shell verification 是事实源;长期结论写回 `ai_workspace/loop-agent/`、`docs/decisions/` 或 `skills/`。
|
|
37
26
|
|
|
38
27
|
## 唯一推荐执行路径
|
|
39
28
|
|
|
40
29
|
```bash
|
|
41
|
-
loop-agent new-task <task-id> "
|
|
42
|
-
# Prefer immutable
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
loop-agent dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
|
|
48
|
-
loop-agent dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
|
|
49
|
-
loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <repo-root>
|
|
30
|
+
loop-agent new-task <task-id> "Title"
|
|
31
|
+
# Prefer immutable PRD: loop-agent import-prd <task-id> --file <path>
|
|
32
|
+
loop-agent dag run-task <task-id> --profile auto --strict-models --output <dag.json>
|
|
33
|
+
loop-agent dag validate --dag <dag.json> --strict-models --strict-governance
|
|
34
|
+
loop-agent run-dag --dag <dag.json> --cwd <repo-root>
|
|
50
35
|
```
|
|
51
36
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
`<temp-dir>` 表示平台原生临时目录。macOS 和 Windows 都应使用实际平台路径;`/` 只用于 repo refs、JSON/Markdown 证据 refs 和 glob 约定。
|
|
55
|
-
|
|
56
|
-
执行前必须审阅:
|
|
57
|
-
|
|
58
|
-
- `profileRouting`
|
|
59
|
-
- `governanceProfile`
|
|
60
|
-
- writer `writeSet`
|
|
61
|
-
- writer `forbiddenPaths`
|
|
62
|
-
- shell verification commands
|
|
63
|
-
- decision gate mode
|
|
64
|
-
|
|
65
|
-
## Pi Sidecar 入口规则
|
|
66
|
-
|
|
67
|
-
短时规划、审查、失败归因可使用 full-capability `pi-prompt`,默认模型是 `glm-5.2`:
|
|
68
|
-
|
|
69
|
-
- 只读 sidecar 必须显式传 `--tools read,grep,find,ls`,并在 prompt 中写明不编辑文件。
|
|
70
|
-
- 高复杂度 one-shot 诊断可显式加 `--model gpt-5.5`。
|
|
71
|
-
- 输出是 advisory,不能替代 deterministic verification;发现必须写回 task source、report、progress 或 exec plan。
|
|
72
|
-
|
|
73
|
-
## Bounded Write Execution
|
|
74
|
-
|
|
75
|
-
需要写业务代码时,**只**通过 DAG `pi` writer(`implement-pi` / `repair-pi`)经 `loop-agent run-dag` / `dag run-task --execute` 等 CLI 路径执行。主会话不得自行 Edit 实现文件「代替」writer。
|
|
76
|
-
|
|
77
|
-
Pi writer 节点必须包含 task id、目标、allowed paths、forbidden paths、writeSet、硬约束和预期验证;执行后由主会话**独立跑 shell 验证**(仍经终端/CLI,不手改代码冒充通过)。
|
|
78
|
-
|
|
79
|
-
`cursor-prompt` 仅作人工 one-shot sidecar intervention,不进入 Loop auto-execute / Delegate auto-run / DAG writer 选择。细节见 `ai_workspace/loop-agent/cursor-prompt-sidecar.md`、`references/harness-policy.md` 和 `references/verification-and-failure-handling.md`。
|
|
80
|
-
|
|
81
|
-
Pi writer / 可选 sidecar prompt 都必须包含:task id、exact objective、allowed/forbidden paths、hard constraints、expected verification、preserve unrelated files。
|
|
82
|
-
|
|
83
|
-
bounded writer 完成后,主会话只做独立复核;命令清单见 `references/verification-and-failure-handling.md`。
|
|
37
|
+
执行前审阅 `profileRouting`、`governanceProfile`、writer `writeSet`、`forbiddenPaths`、decision gate mode。
|
|
84
38
|
|
|
85
39
|
## 进阶主题路由
|
|
86
40
|
|
|
87
|
-
以下主题只在 references 中维护细节,不在本文展开:
|
|
88
|
-
|
|
89
41
|
| 主题 | Reference |
|
|
90
42
|
|---|---|
|
|
91
|
-
|
|
|
92
|
-
|
|
|
93
|
-
| Operator commands
|
|
94
|
-
|
|
|
95
|
-
| Post-writer 独立验证、verify knobs、failure handling、closeout | `references/verification-and-failure-handling.md` |
|
|
96
|
-
| Docs Converge(用户可见变更后的站上/治理文档同步检查表) | `references/docs-converge.md` |
|
|
43
|
+
| Harness policy、Loop、SePO-lite | `references/harness-policy.md` |
|
|
44
|
+
| Agent DAG topology、writeSet、recovery | `references/hybrid-dag.md` |
|
|
45
|
+
| Operator commands、`agent-worker` | `references/command-reference.md` |
|
|
46
|
+
| 独立验证、failure handling、closeout | `references/verification-and-failure-handling.md` |
|
|
97
47
|
|
|
98
48
|
## Source Layout
|
|
99
49
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
| Area | Entry |
|
|
103
|
-
|---|---|
|
|
104
|
-
| CLI command tree / help / commander program | `src/cli/` |
|
|
105
|
-
| DAG workflow | `src/workflows/dag/` |
|
|
106
|
-
| Long-running loop workflow | `src/workflows/loop/` |
|
|
107
|
-
| Task runtime | `src/task/` |
|
|
108
|
-
| Executors | `src/executors/` |
|
|
109
|
-
| Worker TaskSpec pipeline(伴生 CLI `agent-worker`) | `src/worker/` |
|
|
110
|
-
| Run records / promotion / closeout | `src/records/` |
|
|
111
|
-
| Governance | `src/governance/` |
|
|
112
|
-
| Shared helpers | `src/shared/` |
|
|
113
|
-
| Repo adapters | `src/adapters/` |
|
|
114
|
-
|
|
115
|
-
不要新增平行兼容入口。CLI public export 的唯一入口是 `src/cli/index.ts`;commander command tree 和 help 实现在 `src/cli/program.ts`。
|
|
50
|
+
CLI `src/cli/`;DAG `src/workflows/dag/`;loop `src/workflows/loop/`;executors `src/executors/`;worker `src/worker/`;governance `src/governance/`。不新增平行兼容入口。
|
|
116
51
|
|
|
117
52
|
## Hard Rules
|
|
118
53
|
|
|
119
|
-
1.
|
|
120
|
-
2.
|
|
121
|
-
3.
|
|
122
|
-
4.
|
|
123
|
-
5.
|
|
124
|
-
6.
|
|
125
|
-
7.
|
|
126
|
-
8. Do not write root `artifacts/` from read-only DAG or sidecar steps.
|
|
127
|
-
9. Do not keep hidden workflow state in chat only; write durable conclusions to repo artifacts.
|
|
128
|
-
10. Verify before completion.
|
|
54
|
+
1. Prefer vertical tracer bullets: each slice crosses the real integration layers with independent acceptance/verification. Do not horizontal-slice.
|
|
55
|
+
2. Autonomy ≠ governance profile: declare AFK/HITL in human gate; choose `--profile` by risk.
|
|
56
|
+
3. Source materials mandatory: `source/需求.md`、`source/执行约束.md`、优先 `source/references/*` originals。
|
|
57
|
+
4. Agent DAG is the implementation workflow;review three-way checks references + derived source + implementation。
|
|
58
|
+
5. 主会话不绕过 CLI 直接写业务代码;失败只走 doctor/reconcile/human gate/重跑。
|
|
59
|
+
6. DAG `pi` executor read-only unless `toolProfile: "write"`;completed run facts read-only;不得从 read-only DAG/sidecar 写 root `artifacts/`。
|
|
60
|
+
7. No hidden state in chat only;verify before completion.
|
|
129
61
|
|
|
130
62
|
## References
|
|
131
63
|
|
|
132
|
-
Required
|
|
133
|
-
|
|
134
|
-
-
|
|
135
|
-
- `references/hybrid-dag.md`
|
|
136
|
-
- `references/verification-and-failure-handling.md`
|
|
137
|
-
- `references/command-reference.md`
|
|
138
|
-
|
|
139
|
-
Optional(按需加载):
|
|
140
|
-
|
|
141
|
-
- `references/orchestrator-and-interventions.md`
|
|
142
|
-
- `references/long-running-loop.md`
|
|
143
|
-
- `references/task-workflow.md`
|
|
144
|
-
- `references/pi-prompt.md`
|
|
145
|
-
- `references/one-shot-runs.md`
|
|
146
|
-
- `references/pi-subagent-assisted-mode.md`
|
|
147
|
-
- `references/model-routing.md`
|
|
148
|
-
- `references/multi-worktree.md`
|
|
149
|
-
- `references/post-implementation-and-patterns.md`
|
|
150
|
-
- `references/docs-converge.md` — 用户可见变更后的文档收敛检查表;禁止每次重新规划整站大纲
|
|
64
|
+
Required(按需 inline):`references/harness-policy.md`、`references/hybrid-dag.md`、`references/verification-and-failure-handling.md`
|
|
65
|
+
|
|
66
|
+
Optional:`references/command-reference.md`(operator commands、`agent-worker`)、`references/long-running-loop.md`、`references/orchestrator-and-interventions.md`、`references/task-workflow.md`、`references/pi-prompt.md`、`references/one-shot-runs.md`、`references/pi-subagent-assisted-mode.md`、`references/model-routing.md`、`references/multi-worktree.md`、`references/post-implementation-and-patterns.md`、`references/docs-converge.md`
|
|
@@ -25,7 +25,7 @@ loop-agent doctor
|
|
|
25
25
|
|
|
26
26
|
发布包入口加载 `dist/cli.js`;开发入口加载 `src/cli.ts`。
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
发布包携带静态能力资料:`skills/`(包内内置,含 `loop-agent` 与 `agent-worker`;`loop-agent init` 投影时镜像为目标项目 `.agents/skills/`)、`docs/templates/`、`docs/architecture/`、`docs/skills/` 和 `examples/`。`ai_workspace/loop-agent/`(默认 governanceRoot)下的 `progress/`、`reports/`、`exec-plans/`、`decisions/` 由 `loop-agent init` 在目标项目创建目录并投放 README,其中的任务正文属于目标仓库运行中生成的事实,不从 npm 包复制。
|
|
29
29
|
|
|
30
30
|
## 命令参考
|
|
31
31
|
|
|
@@ -285,6 +285,7 @@ cp ai_workspace/loop-agent/templates/agent-dag.supervised-implementation.json <t
|
|
|
285
285
|
(npx vitest run test/dag-supervised-template.test.ts test/dag-validate.test.ts test/dag-shell-executor.test.ts --reporter=dot) # supervised template + shell.verdictGate runtime
|
|
286
286
|
loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --cwd <repo-root> # 执行 Agent DAG
|
|
287
287
|
loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --init-only --canvas-path <temp-dir>/hybrid-dag.canvas.tsx # 可选 derived Canvas view
|
|
288
|
+
bash scripts/run-dag-safe.sh --dag <temp-dir>/hybrid-dag.json --cwd <repo-root> [--timeout-secs 7200] # 后台运行 + 轮询,避免外层 bash timeout 杀进程(见 agent-dag-runner.md §Adaptive liveness)
|
|
288
289
|
loop-agent dag init-hybrid <task-id> # 生成可审阅的 DAG draft
|
|
289
290
|
loop-agent dag run-task <task-id> # generate + validate(安全默认;无 dag-runs;standard-compatible)
|
|
290
291
|
loop-agent dag workflow-plan <task-id> --profile pr-review --output <temp-dir>/<task-id>.workflow.json
|
|
@@ -488,7 +489,7 @@ loop-agent knowledge curate --markdown
|
|
|
488
489
|
loop-agent knowledge curate --markdown --output ai_workspace/loop-agent/reports/<task-id>-learned-proposal.md
|
|
489
490
|
```
|
|
490
491
|
|
|
491
|
-
读取 `.harness/knowledge/patterns.jsonl` 中 completed convergence repair pattern,按 `failureClass + fixScope shape + invariant` 去重,生成 human-gated learned guidance proposal。命令只生成 proposal,不直接修改
|
|
492
|
+
读取 `.harness/knowledge/patterns.jsonl` 中 completed convergence repair pattern,按 `failureClass + fixScope shape + invariant` 去重,生成 human-gated learned guidance proposal。命令只生成 proposal,不直接修改 `skills/loop-agent/references/learned/*.md`;输出会先通过 skill safety audit。
|
|
492
493
|
|
|
493
494
|
### Knowledge graph / query CLI
|
|
494
495
|
|
|
@@ -562,12 +563,17 @@ agent-worker observe snapshot --repo <repo-root> # 输出 GlobalSnapshot JSON
|
|
|
562
563
|
- **推荐** `console serve`(默认 `127.0.0.1:8790`)提供 Operate + Inspect;Inspect 路径为 `/inspect/#/...`,API 仍为根 `/api/**`。`observe serve` 为兼容入口(默认 `8787`,启动时 stderr 输出 `OBSERVE_SERVE_DEPRECATED`);`observe snapshot` 保留。两者都不会启动、暂停或重试 Task / Worker / DAG。
|
|
563
564
|
- 当前 Worker 仍是 v0(库 + CLI + dogfood),未接入定时/CI 驱动;`report morning` 只能从已有 Task Pool runs 汇总。
|
|
564
565
|
|
|
565
|
-
### 查看 duration statistics
|
|
566
|
+
### 查看 duration statistics / context usage
|
|
566
567
|
|
|
567
568
|
```bash
|
|
568
569
|
loop-agent stats
|
|
570
|
+
loop-agent stats context --last 50
|
|
571
|
+
loop-agent stats context --last 50 --json
|
|
569
572
|
```
|
|
570
573
|
|
|
574
|
+
- `stats`:legacy step-duration 直方图(`.harness/tasks/*/logs/executor.jsonl`)。
|
|
575
|
+
- `stats context`:最近 N 个 DAG runs 的 **skill-resolution** 与节点 outcome 只读聚合(declared/resolved/missing/error、truncation、`unresolvedReferences.reason`、FINISHED/ERROR/SKIPPED + failureCategory)。**不**宣称模型遵循率或 skill execution rate;corrupted snapshot 记为 finding 且 `ok=false`。
|
|
576
|
+
|
|
571
577
|
### Worktree delegate / harvest(escape hatch)
|
|
572
578
|
|
|
573
579
|
```bash
|
|
@@ -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:
|
|
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 位于
|
|
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 应列出链接的
|
|
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 应提议
|
|
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**(见 `
|
|
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。
|