@tea-agent/loop-agent 0.26.0 → 0.26.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/CHANGELOG.md +1032 -1020
- package/README.md +8 -3
- package/bin/loop-agent.js +21 -21
- package/dist/cli/command-definitions.js +25 -10
- package/dist/cli/help.js +4 -3
- package/dist/cli/program.js +43 -17
- package/dist/commands/cursor-prompt.js +6 -6
- package/dist/commands/import-prd.js +7 -2
- package/dist/commands/init.js +7 -5
- package/dist/commands/loop-benchmark.js +11 -11
- package/dist/commands/pi-reuse-benchmark.js +16 -16
- package/dist/commands/task-source-prepare.js +468 -0
- package/dist/executors/dag-pi-executor.js +40 -5
- package/dist/executors/shell-write-guard.js +161 -25
- package/dist/sidecars/cursor-prompt/executor.js +1 -1
- package/dist/task/source-prepare/build-draft.js +215 -0
- package/dist/task/source-prepare/completeness.js +195 -0
- package/dist/task/source-prepare/index.js +7 -0
- package/dist/task/source-prepare/parse-intent.js +373 -0
- package/dist/task/source-prepare/path-policy.js +197 -0
- package/dist/task/source-prepare/prepare.js +506 -0
- package/dist/task/source-prepare/reference-integrity.js +274 -0
- package/dist/task/source-prepare/types.js +7 -0
- package/dist/worker/observe/static/copy.js +67 -67
- package/dist/worker/observe/static/dag-layout.d.ts +31 -31
- package/dist/worker/observe/static/dag-layout.js +83 -83
- package/dist/worker/observe/static/dom.js +220 -220
- package/dist/worker/observe/static/relations.js +133 -133
- package/dist/worker/observe/static/router.js +93 -93
- package/dist/worker/observe/static/run-processing.js +148 -148
- package/dist/worker/observe/static/views/batch.js +227 -227
- package/dist/worker/observe/static/views/dag-graph.js +172 -172
- package/dist/worker/observe/static/views/failures.js +143 -143
- package/dist/worker/observe/static/views/feature.js +492 -492
- package/dist/worker/observe/static/views/run.js +453 -453
- package/dist/worker/observe/static/views/shell.js +7 -7
- package/dist/worker/observe/static/views/timeline.js +163 -163
- package/dist/workflows/dag/canvas-observer.js +275 -275
- package/docs/skills/README.md +7 -7
- package/docs/templates/adr.md +60 -60
- package/docs/templates/agent-dag-authority-surface-audit.prompt.md +94 -94
- package/docs/templates/agent-dag-decision-envelope.schema.json +213 -213
- package/docs/templates/agent-dag-decision-gate.prompt.md +246 -246
- package/docs/templates/agent-dag-process-supervisor.prompt.md +98 -98
- package/docs/templates/agent-dag-report.schema.json +473 -473
- package/docs/templates/agent-dag-review-verdict.prompt.md +68 -68
- package/docs/templates/backend-test-result.schema.json +99 -99
- package/docs/templates/feature-spec.md +53 -53
- package/docs/templates/frontend-design-contract.md +42 -42
- package/docs/templates/frontend-eval/fixtures/failures/01-type-build-error.md +17 -17
- package/docs/templates/frontend-eval/fixtures/failures/02-unit-component-test-fail.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/03-fixture-schema-drift.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/04-missing-loading-empty-error-state.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/05-forbidden-write-writeset-expansion.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/06-unapproved-dependency-add.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/07-mock-production-on.md +21 -21
- package/docs/templates/frontend-eval/fixtures/functional/01-simple-component-style.md +29 -29
- package/docs/templates/frontend-eval/fixtures/functional/02-form-validation.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/03-list-detail-page.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/04-api-mock.md +29 -29
- package/docs/templates/frontend-eval/fixtures/functional/05-permission-auth-gated-ui.md +27 -27
- package/docs/templates/frontend-eval/fixtures/functional/06-ssr-server-client-boundary.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/07-shared-public-component-api.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/08-pure-local-no-remote.md +27 -27
- package/docs/templates/frontend-eval/metrics.md +138 -138
- package/docs/templates/frontend-eval/smoke-targets.md +53 -53
- package/docs/templates/frontend-task-constraints.md +35 -35
- package/docs/templates/frontend-task-requirement.md +70 -70
- package/docs/templates/init-evolution-review.md +35 -35
- package/docs/templates/init-managed-agents.md +10 -5
- package/docs/templates/interactive-ui-round2-experiment.md +66 -66
- package/docs/templates/knowledge-graph-bootstrap-dag.json +118 -118
- package/docs/templates/knowledge-sync-dag.json +178 -178
- package/docs/templates/knowledge-sync-draft.schema.json +71 -71
- package/docs/templates/product-line/closeout.yaml +9 -9
- package/docs/templates/product-line/design.md +13 -13
- package/docs/templates/product-line/links.md +10 -10
- package/docs/templates/product-line/requirement.md +17 -17
- package/docs/templates/product-line/test-plan.md +7 -7
- package/docs/templates/production-readiness-checklist.md +57 -57
- package/docs/templates/project-start-checklist.md +9 -9
- package/docs/templates/qa-report.md +48 -48
- package/docs/templates/sprint-contract.md +29 -29
- package/docs/templates/worker-dogfood-evidence.md +80 -80
- package/docs/templates/worker-dogfood-setup.md +68 -68
- package/package.json +1 -1
- package/scripts/kb-bootstrap-init-skeleton.sh +0 -0
- package/scripts/kb-graph-incremental-prepare.mjs +386 -386
- package/scripts/kb-graph-materialize.mjs +105 -105
- package/scripts/kb-graph-promote.mjs +164 -164
- package/scripts/kb-query.mjs +554 -554
- package/skills/ai-engineering-context/SKILL.md +48 -48
- package/skills/analyze-product-dependencies/SKILL.md +67 -67
- package/skills/analyze-product-dependencies/agents/openai.yaml +4 -4
- package/skills/analyze-product-dependencies/references/api-documentation-schema.md +30 -30
- package/skills/analyze-product-dependencies/references/dependency-analysis-schema.md +28 -28
- package/skills/analyze-product-dependencies/references/example.md +76 -76
- package/skills/analyze-product-dependencies/references/forward-test-cases.md +35 -35
- package/skills/analyze-product-dependencies/references/input-contract.md +11 -11
- package/skills/analyze-product-dependencies/references/scouting-rules.md +61 -61
- package/skills/analyze-product-dependencies/scripts/test-validators.mjs +267 -267
- package/skills/analyze-product-dependencies/scripts/validate-api-documentation.mjs +101 -101
- package/skills/analyze-product-dependencies/scripts/validate-dependency-analysis.mjs +142 -142
- package/skills/analyze-product-dependencies/scripts/validate-product-requirement-input.mjs +76 -76
- package/skills/analyze-product-dependencies/scripts/validation-helpers.mjs +146 -146
- package/skills/analyze-product-requirements/SKILL.md +90 -90
- package/skills/analyze-product-requirements/agents/openai.yaml +4 -4
- package/skills/analyze-product-requirements/references/acceptance-criteria.md +91 -91
- package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +56 -56
- package/skills/analyze-product-requirements/references/example.md +86 -86
- package/skills/analyze-product-requirements/references/forward-test-cases.md +66 -66
- package/skills/analyze-product-requirements/references/product-analysis-schema.md +32 -32
- package/skills/analyze-product-requirements/references/product-requirement-schema.md +33 -33
- package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +35 -35
- package/skills/analyze-product-requirements/scripts/test-validators.mjs +193 -193
- package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +69 -69
- package/skills/analyze-product-requirements/scripts/validate-product-requirement.mjs +97 -97
- package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +98 -98
- package/skills/analyze-product-requirements/scripts/validation-helpers.mjs +156 -156
- package/skills/browser-tools/browser-content.js +103 -103
- package/skills/browser-tools/browser-cookies.js +35 -35
- package/skills/browser-tools/browser-eval.js +53 -53
- package/skills/browser-tools/browser-hn-scraper.js +108 -108
- package/skills/browser-tools/browser-nav.js +44 -44
- package/skills/browser-tools/browser-pick.js +162 -162
- package/skills/browser-tools/browser-screenshot.js +34 -34
- package/skills/browser-tools/browser-start.js +86 -86
- package/skills/browser-tools/package-lock.json +2556 -2556
- package/skills/browser-tools/package.json +19 -19
- package/skills/code-review-core/SKILL.md +20 -20
- package/skills/codebase-scout/SKILL.md +19 -19
- package/skills/grill-me/SKILL.md +10 -10
- package/skills/loop-agent/SKILL.md +5 -2
- package/skills/loop-agent/references/README.md +67 -67
- package/skills/loop-agent/references/command-reference.md +17 -15
- package/skills/loop-agent/references/docs-converge.md +126 -126
- package/skills/loop-agent/references/harness-policy.md +3 -4
- package/skills/loop-agent/references/learned/README.md +21 -21
- package/skills/loop-agent/references/long-running-loop.md +57 -57
- package/skills/loop-agent/references/one-shot-runs.md +85 -85
- package/skills/loop-agent/references/pi-prompt.md +23 -23
- package/skills/loop-agent/references/pi-subagent-assisted-mode.md +84 -84
- package/skills/loop-agent/references/post-implementation-and-patterns.md +1 -1
- package/skills/loop-agent/references/source-and-plan-practice.md +3 -2
- package/skills/loop-agent/references/task-workflow.md +7 -5
- package/skills/playwright-cli/SKILL.md +420 -420
- package/skills/playwright-cli/references/element-attributes.md +23 -23
- package/skills/playwright-cli/references/playwright-tests.md +39 -39
- package/skills/playwright-cli/references/request-mocking.md +87 -87
- package/skills/playwright-cli/references/running-code.md +241 -241
- package/skills/playwright-cli/references/session-management.md +225 -225
- package/skills/playwright-cli/references/storage-state.md +275 -275
- package/skills/playwright-cli/references/test-generation.md +433 -433
- package/skills/playwright-cli/references/tracing.md +139 -139
- package/skills/playwright-cli/references/video-recording.md +143 -143
- package/skills/requesting-code-review/SKILL.md +101 -101
- package/skills/requesting-code-review/code-reviewer.md +168 -168
- package/skills/systematic-debugging/CREATION-LOG.md +119 -119
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -158
- package/skills/systematic-debugging/condition-based-waiting.md +115 -115
- package/skills/systematic-debugging/defense-in-depth.md +122 -122
- package/skills/systematic-debugging/find-polluter.sh +63 -63
- package/skills/systematic-debugging/root-cause-tracing.md +169 -169
- package/skills/systematic-debugging/test-academic.md +14 -14
- package/skills/systematic-debugging/test-pressure-1.md +58 -58
- package/skills/systematic-debugging/test-pressure-2.md +68 -68
- package/skills/systematic-debugging/test-pressure-3.md +69 -69
- package/skills/using-git-worktrees/SKILL.md +215 -215
- package/skills/verification-before-completion/SKILL.md +154 -154
- package/skills/webapp-testing/SKILL.md +19 -19
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
# Learned loop-agent Patterns
|
|
2
|
-
|
|
3
|
-
本目录是 SePO-lite prompt evolution 的 human-gated target。
|
|
4
|
-
|
|
5
|
-
Rules:
|
|
6
|
-
|
|
7
|
-
- Files 仅为 Markdown guidance。
|
|
8
|
-
- `retrospective` 可 propose `.harness/tasks/<task-id>/source/prompt-delta.md`;不得自动 merge 到此。
|
|
9
|
-
- 不要添加 shell commands、credential handling、tool permission expansion 或 completion-authority bypass rules。
|
|
10
|
-
- DAG implementer prompts 在 node 已 request `loop-agent` skill 时,可将 repo-specific 文件 `<repo>.md` 或 `default.md` 作为 bounded inline guidance 加载。
|
|
11
|
-
- 保持条目 short 且 pattern-oriented:failure class、fix scope shape、invariant、verification evidence。
|
|
12
|
-
|
|
13
|
-
Acceptance checklist before merging a prompt delta:
|
|
14
|
-
|
|
15
|
-
- Proposal 仅为 Markdown-only process guidance。
|
|
16
|
-
- 不含 shell/runtime command lines 或 fenced command blocks。
|
|
17
|
-
- Credential material、tokens、passwords、secrets 与 API keys 保持不可触达。
|
|
18
|
-
- Tool permissions、path allowlists、`allowedPaths`、`forbiddenPaths` 与 `writeSet` 保持既有边界。
|
|
19
|
-
- Shell verification、tests、write guards、decision gates、human gates 与 completion evidence 均为保留门禁。
|
|
20
|
-
- Completed DAG 与 one-shot run facts 保持只读。
|
|
21
|
-
- Learned file 编辑后 `loop-agent docs audit` 须 pass。
|
|
1
|
+
# Learned loop-agent Patterns
|
|
2
|
+
|
|
3
|
+
本目录是 SePO-lite prompt evolution 的 human-gated target。
|
|
4
|
+
|
|
5
|
+
Rules:
|
|
6
|
+
|
|
7
|
+
- Files 仅为 Markdown guidance。
|
|
8
|
+
- `retrospective` 可 propose `.harness/tasks/<task-id>/source/prompt-delta.md`;不得自动 merge 到此。
|
|
9
|
+
- 不要添加 shell commands、credential handling、tool permission expansion 或 completion-authority bypass rules。
|
|
10
|
+
- DAG implementer prompts 在 node 已 request `loop-agent` skill 时,可将 repo-specific 文件 `<repo>.md` 或 `default.md` 作为 bounded inline guidance 加载。
|
|
11
|
+
- 保持条目 short 且 pattern-oriented:failure class、fix scope shape、invariant、verification evidence。
|
|
12
|
+
|
|
13
|
+
Acceptance checklist before merging a prompt delta:
|
|
14
|
+
|
|
15
|
+
- Proposal 仅为 Markdown-only process guidance。
|
|
16
|
+
- 不含 shell/runtime command lines 或 fenced command blocks。
|
|
17
|
+
- Credential material、tokens、passwords、secrets 与 API keys 保持不可触达。
|
|
18
|
+
- Tool permissions、path allowlists、`allowedPaths`、`forbiddenPaths` 与 `writeSet` 保持既有边界。
|
|
19
|
+
- Shell verification、tests、write guards、decision gates、human gates 与 completion evidence 均为保留门禁。
|
|
20
|
+
- Completed DAG 与 one-shot run facts 保持只读。
|
|
21
|
+
- Learned file 编辑后 `loop-agent docs audit` 须 pass。
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
# Long-Running Loop 详细规则
|
|
2
|
-
|
|
3
|
-
需要跨多轮记录目标、压缩记忆、round facts 引用,或使用 `loop init|status|run|record-round|add-signal|closeout` 时使用本文。`loop` 是 experimental outer workflow state:它不替代 Agent DAG,也不等同于已移除的顺序式 `run loop`。共享 policy 摘要见 `harness-policy.md` 的 "Long-running loop policy" 一节。
|
|
4
|
-
|
|
5
|
-
## 最小入口
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
loop-agent loop init <task-id>
|
|
9
|
-
loop-agent loop status <task-id>
|
|
10
|
-
loop-agent loop run <task-id> --action shell-verify --command "bash scripts/check-repo.sh"
|
|
11
|
-
loop-agent loop run <task-id> --action pi-review
|
|
12
|
-
loop-agent loop run <task-id> --action dag
|
|
13
|
-
loop-agent loop run <task-id> --action dag --execute
|
|
14
|
-
loop-agent loop run <task-id> --auto --max-rounds 3
|
|
15
|
-
loop-agent loop run <task-id> --auto --max-rounds 3
|
|
16
|
-
loop-agent loop add-signal <task-id> --type human_followup --message "review this boundary before closeout"
|
|
17
|
-
loop-agent loop closeout <task-id>
|
|
18
|
-
loop-agent loop record-round <task-id> \
|
|
19
|
-
--action manual \
|
|
20
|
-
--result "summary" \
|
|
21
|
-
--lesson "what to carry forward" \
|
|
22
|
-
--next "next bounded action" \
|
|
23
|
-
--decision continue \
|
|
24
|
-
--ref ".harness/runs/completed/<run-id>/result.json"
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## 状态源与记忆规则
|
|
28
|
-
|
|
29
|
-
- `loop/objective.md` 与 `loop/context.md` 是运行态投影;exec plan / task source 仍是需求状态源。
|
|
30
|
-
- `rounds.jsonl` 只引用 canonical facts,不复制完整 executor 日志。
|
|
31
|
-
- `context.md` 每轮重写为压缩记忆,不无限 append。
|
|
32
|
-
- `events.jsonl` 只用于 observability,覆盖 loop_start、round_start、action_start、action_finish、context_rewrite、decision、loop_finish;不要把 events 当状态源。
|
|
33
|
-
|
|
34
|
-
## Action 规则
|
|
35
|
-
|
|
36
|
-
- `loop run --action shell-verify` 是 deterministic action;命令 exit code 决定 verification result,输出摘要写入 `loop/verification/round-N.json`。
|
|
37
|
-
- `loop run --action pi-review` 必须保持 read-only;工具 allowlist 固定为 `read,grep,find,ls`,输出必须包含 `findingSummary`、`failureCategory`、`nextHypothesis`、`recommendedAction`、`fixScope`、`rootCause`,其中 `recommendedAction` 只能是 `implement_fix|replan|pause|done`。
|
|
38
|
-
- 自动写入只能通过 `loop run --action dag --execute` / auto DAG execute;须读取 task `allowedPaths` / `forbiddenPaths` 并审查 writer writeSet。
|
|
39
|
-
- `loop run --action dag` 默认是 review mode:调用 `dag run-task <task-id> --profile auto --strict-models` 生成 DAG,再用 `dag validate --strict-models --strict-governance` 校验,并记录 review packet。
|
|
40
|
-
- `loop run --action dag --execute` 才会调用 `run-dag`,随后读取 `dag report --json` 作为 round result;paused DAG 会让 loop 进入 `paused`。
|
|
41
|
-
|
|
42
|
-
## Auto mode 与写入边界
|
|
43
|
-
|
|
44
|
-
- `loop run --auto --max-rounds N` 使用 deterministic policy 选择下一轮 action;默认只会自动选择 shell-verify、pi-review、dag review 或 policy pause/block。
|
|
45
|
-
- 自动 DAG execute 必须显式 opt-in:`task.json.loopAutoExecutionPolicy="enabled"`,或 `approval-required` 加 pending approval;旧 `loopAutoWritePolicy` fail-fast。
|
|
46
|
-
- auto mode 遇到同类 failure streak 达阈值会 blocked,避免无限重试。
|
|
47
|
-
|
|
48
|
-
## Signals
|
|
49
|
-
|
|
50
|
-
- `loop add-signal` 写入 durable `signals.jsonl`,支持 `human_followup|approval|scope_changed|review_feedback`;urgent/scope_changed 会 pause,review feedback / human follow-up 先走 read-only Pi review,approval 触发下一轮 DAG review packet。
|
|
51
|
-
- Signals 不直接覆盖 `objective.md`;DAG decision envelope / approve / reject / resume 仍由 DAG action 机制管理,loop 只记录 refs。
|
|
52
|
-
|
|
53
|
-
## Closeout
|
|
54
|
-
|
|
55
|
-
- `loop closeout` 从 loop state、objective/context、rounds 和 signals 派生 `loop/closeout.md` draft;draft 会标出 workflow path(`dag` / `explicit-fallback` / `missing-dag-evidence` / `micro-or-small`)与 fallback reason。
|
|
56
|
-
- 非 complete 状态必须标 partial/paused/blocked,不能修改 completed facts;medium/large loop 若缺少 DAG round 且没有 `dagFallbackReason`,必须把缺失 DAG 证据列为 remaining risk。
|
|
57
|
-
- 完成声明仍必须由 shell verification、review verdict 和 success criteria coverage 证明。
|
|
1
|
+
# Long-Running Loop 详细规则
|
|
2
|
+
|
|
3
|
+
需要跨多轮记录目标、压缩记忆、round facts 引用,或使用 `loop init|status|run|record-round|add-signal|closeout` 时使用本文。`loop` 是 experimental outer workflow state:它不替代 Agent DAG,也不等同于已移除的顺序式 `run loop`。共享 policy 摘要见 `harness-policy.md` 的 "Long-running loop policy" 一节。
|
|
4
|
+
|
|
5
|
+
## 最小入口
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
loop-agent loop init <task-id>
|
|
9
|
+
loop-agent loop status <task-id>
|
|
10
|
+
loop-agent loop run <task-id> --action shell-verify --command "bash scripts/check-repo.sh"
|
|
11
|
+
loop-agent loop run <task-id> --action pi-review
|
|
12
|
+
loop-agent loop run <task-id> --action dag
|
|
13
|
+
loop-agent loop run <task-id> --action dag --execute
|
|
14
|
+
loop-agent loop run <task-id> --auto --max-rounds 3
|
|
15
|
+
loop-agent loop run <task-id> --auto --max-rounds 3
|
|
16
|
+
loop-agent loop add-signal <task-id> --type human_followup --message "review this boundary before closeout"
|
|
17
|
+
loop-agent loop closeout <task-id>
|
|
18
|
+
loop-agent loop record-round <task-id> \
|
|
19
|
+
--action manual \
|
|
20
|
+
--result "summary" \
|
|
21
|
+
--lesson "what to carry forward" \
|
|
22
|
+
--next "next bounded action" \
|
|
23
|
+
--decision continue \
|
|
24
|
+
--ref ".harness/runs/completed/<run-id>/result.json"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 状态源与记忆规则
|
|
28
|
+
|
|
29
|
+
- `loop/objective.md` 与 `loop/context.md` 是运行态投影;exec plan / task source 仍是需求状态源。
|
|
30
|
+
- `rounds.jsonl` 只引用 canonical facts,不复制完整 executor 日志。
|
|
31
|
+
- `context.md` 每轮重写为压缩记忆,不无限 append。
|
|
32
|
+
- `events.jsonl` 只用于 observability,覆盖 loop_start、round_start、action_start、action_finish、context_rewrite、decision、loop_finish;不要把 events 当状态源。
|
|
33
|
+
|
|
34
|
+
## Action 规则
|
|
35
|
+
|
|
36
|
+
- `loop run --action shell-verify` 是 deterministic action;命令 exit code 决定 verification result,输出摘要写入 `loop/verification/round-N.json`。
|
|
37
|
+
- `loop run --action pi-review` 必须保持 read-only;工具 allowlist 固定为 `read,grep,find,ls`,输出必须包含 `findingSummary`、`failureCategory`、`nextHypothesis`、`recommendedAction`、`fixScope`、`rootCause`,其中 `recommendedAction` 只能是 `implement_fix|replan|pause|done`。
|
|
38
|
+
- 自动写入只能通过 `loop run --action dag --execute` / auto DAG execute;须读取 task `allowedPaths` / `forbiddenPaths` 并审查 writer writeSet。
|
|
39
|
+
- `loop run --action dag` 默认是 review mode:调用 `dag run-task <task-id> --profile auto --strict-models` 生成 DAG,再用 `dag validate --strict-models --strict-governance` 校验,并记录 review packet。
|
|
40
|
+
- `loop run --action dag --execute` 才会调用 `run-dag`,随后读取 `dag report --json` 作为 round result;paused DAG 会让 loop 进入 `paused`。
|
|
41
|
+
|
|
42
|
+
## Auto mode 与写入边界
|
|
43
|
+
|
|
44
|
+
- `loop run --auto --max-rounds N` 使用 deterministic policy 选择下一轮 action;默认只会自动选择 shell-verify、pi-review、dag review 或 policy pause/block。
|
|
45
|
+
- 自动 DAG execute 必须显式 opt-in:`task.json.loopAutoExecutionPolicy="enabled"`,或 `approval-required` 加 pending approval;旧 `loopAutoWritePolicy` fail-fast。
|
|
46
|
+
- auto mode 遇到同类 failure streak 达阈值会 blocked,避免无限重试。
|
|
47
|
+
|
|
48
|
+
## Signals
|
|
49
|
+
|
|
50
|
+
- `loop add-signal` 写入 durable `signals.jsonl`,支持 `human_followup|approval|scope_changed|review_feedback`;urgent/scope_changed 会 pause,review feedback / human follow-up 先走 read-only Pi review,approval 触发下一轮 DAG review packet。
|
|
51
|
+
- Signals 不直接覆盖 `objective.md`;DAG decision envelope / approve / reject / resume 仍由 DAG action 机制管理,loop 只记录 refs。
|
|
52
|
+
|
|
53
|
+
## Closeout
|
|
54
|
+
|
|
55
|
+
- `loop closeout` 从 loop state、objective/context、rounds 和 signals 派生 `loop/closeout.md` draft;draft 会标出 workflow path(`dag` / `explicit-fallback` / `missing-dag-evidence` / `micro-or-small`)与 fallback reason。
|
|
56
|
+
- 非 complete 状态必须标 partial/paused/blocked,不能修改 completed facts;medium/large loop 若缺少 DAG round 且没有 `dagFallbackReason`,必须把缺失 DAG 证据列为 remaining risk。
|
|
57
|
+
- 完成声明仍必须由 shell verification、review verdict 和 success criteria coverage 证明。
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
# One-shot Run Evidence(`.harness/runs/`)
|
|
2
|
-
|
|
3
|
-
当你使用 `cursor-prompt`、Pi `cursor` tool、`promote-run`,或在治理检查中看到 `.harness/runs/active` warning 时,读本文。
|
|
4
|
-
|
|
5
|
-
## 目录职责
|
|
6
|
-
|
|
7
|
-
`.harness/runs/` 保存一次性工具调用的运行证据。它不是 task 状态源,也不是 Agent DAG run 目录。
|
|
8
|
-
|
|
9
|
-
```text
|
|
10
|
-
.harness/runs/active/<run-id>/ # 正在执行或异常残留的 one-shot tool run
|
|
11
|
-
.harness/runs/completed/<run-id>/ # 成功完成的 one-shot run evidence
|
|
12
|
-
.harness/runs/failed/<run-id>/ # 失败的 one-shot run evidence
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
每个 run directory 通常包含:
|
|
16
|
-
|
|
17
|
-
```text
|
|
18
|
-
run.md
|
|
19
|
-
meta.json
|
|
20
|
-
artifacts/
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
`run.md` 是人类可读摘要;`meta.json` 是机器可读 run metadata;`artifacts/` 是该次 one-shot 的交付物目录。
|
|
24
|
-
|
|
25
|
-
## 什么时候创建
|
|
26
|
-
|
|
27
|
-
会创建 `.harness/runs/` 的常见入口:
|
|
28
|
-
|
|
29
|
-
- `loop-agent cursor-prompt ...`
|
|
30
|
-
- Pi `cursor` tool / loop-agent cursor tool 的 one-shot Cursor 调用
|
|
31
|
-
- 内部 two-phase one-shot logging:先 `createActiveCursorRun()`,再 `finalizeCursorRunLog()`
|
|
32
|
-
|
|
33
|
-
创建条件:
|
|
34
|
-
|
|
35
|
-
- 调用的 `cwd` 必须是含 `.harness/` 的 harness repo。
|
|
36
|
-
- `cursor-prompt` 会先创建 `.harness/runs/active/<run-id>/`,再把结果归档。
|
|
37
|
-
- 成功时整个目录移动到 `.harness/runs/completed/<run-id>/`。
|
|
38
|
-
- 失败、timeout 或 cancel 时整个目录移动到 `.harness/runs/failed/<run-id>/`。
|
|
39
|
-
|
|
40
|
-
当前 `pi-prompt` 不创建 `.harness/runs/`。它是 one-shot helper,但不维护 run evidence、task state、verification 或 handoff artifact。
|
|
41
|
-
|
|
42
|
-
## 与 task / DAG 的关系
|
|
43
|
-
|
|
44
|
-
| 目录 | 含义 | 是否代表 task 完成 |
|
|
45
|
-
|---|---|---|
|
|
46
|
-
| `.harness/tasks/<task-id>/` | task 运行态状态源 | 是 task 状态源 |
|
|
47
|
-
| `.harness/runs/<state>/<run-id>/` | one-shot tool run evidence | 否,只是一次执行证据 |
|
|
48
|
-
| `.harness/dag-runs/<state>/<run-id>/` | Agent DAG run facts | 否,只是 DAG run facts |
|
|
49
|
-
|
|
50
|
-
completed one-shot evidence 若要进入 task artifacts,使用:
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
loop-agent promote-run <task-id> --run-id <run-id>
|
|
54
|
-
loop-agent closeout task <task-id>
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
`promote-run` 只读 `.harness/runs/completed/**`,生成或更新 task `artifacts/修改记录.md` / `artifacts/验证结果.md`,不修改 completed run facts。
|
|
58
|
-
|
|
59
|
-
## Active 目录清理
|
|
60
|
-
|
|
61
|
-
`.harness/runs/active/` 只应存在 live one-shot run。治理检查发现 active 内容时会 warning:
|
|
62
|
-
|
|
63
|
-
```text
|
|
64
|
-
[HARNESS RUNTIME WARNING] .harness/runs/active contains runtime entries
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
处理规则:
|
|
68
|
-
|
|
69
|
-
- 如果确有 one-shot 正在执行,可以保留;必要时用 `HARNESS_ALLOW_ACTIVE_TOOL_RUNS=1` 跑治理检查。
|
|
70
|
-
- 如果是已完成、失败或中断残留,应移动到 `completed/` / `failed/`,或在确认无价值后删除。
|
|
71
|
-
- 如果是 `.DS_Store` 等系统垃圾文件,直接删除;它不是合法 run evidence。
|
|
72
|
-
- 不要把 active 残留当作 task 完成证据。
|
|
73
|
-
|
|
74
|
-
严格检查可用:
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
HARNESS_STRICT_ACTIVE_TOOL_RUNS=1 bash scripts/check-harness-runtime-clean.sh
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## 不要做什么
|
|
81
|
-
|
|
82
|
-
- 不要提交 `.harness/runs/**` 运行态内容。
|
|
83
|
-
- 不要手动改写 `.harness/runs/completed/**` 或 `.harness/runs/failed/**` 事实。
|
|
84
|
-
- 不要把 `.harness/runs/active/**` 当作长期记录。
|
|
85
|
-
- 不要把 one-shot evidence 直接等同于 task artifacts;需要汇总时用 `promote-run`。
|
|
1
|
+
# One-shot Run Evidence(`.harness/runs/`)
|
|
2
|
+
|
|
3
|
+
当你使用 `cursor-prompt`、Pi `cursor` tool、`promote-run`,或在治理检查中看到 `.harness/runs/active` warning 时,读本文。
|
|
4
|
+
|
|
5
|
+
## 目录职责
|
|
6
|
+
|
|
7
|
+
`.harness/runs/` 保存一次性工具调用的运行证据。它不是 task 状态源,也不是 Agent DAG run 目录。
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
.harness/runs/active/<run-id>/ # 正在执行或异常残留的 one-shot tool run
|
|
11
|
+
.harness/runs/completed/<run-id>/ # 成功完成的 one-shot run evidence
|
|
12
|
+
.harness/runs/failed/<run-id>/ # 失败的 one-shot run evidence
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
每个 run directory 通常包含:
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
run.md
|
|
19
|
+
meta.json
|
|
20
|
+
artifacts/
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`run.md` 是人类可读摘要;`meta.json` 是机器可读 run metadata;`artifacts/` 是该次 one-shot 的交付物目录。
|
|
24
|
+
|
|
25
|
+
## 什么时候创建
|
|
26
|
+
|
|
27
|
+
会创建 `.harness/runs/` 的常见入口:
|
|
28
|
+
|
|
29
|
+
- `loop-agent cursor-prompt ...`
|
|
30
|
+
- Pi `cursor` tool / loop-agent cursor tool 的 one-shot Cursor 调用
|
|
31
|
+
- 内部 two-phase one-shot logging:先 `createActiveCursorRun()`,再 `finalizeCursorRunLog()`
|
|
32
|
+
|
|
33
|
+
创建条件:
|
|
34
|
+
|
|
35
|
+
- 调用的 `cwd` 必须是含 `.harness/` 的 harness repo。
|
|
36
|
+
- `cursor-prompt` 会先创建 `.harness/runs/active/<run-id>/`,再把结果归档。
|
|
37
|
+
- 成功时整个目录移动到 `.harness/runs/completed/<run-id>/`。
|
|
38
|
+
- 失败、timeout 或 cancel 时整个目录移动到 `.harness/runs/failed/<run-id>/`。
|
|
39
|
+
|
|
40
|
+
当前 `pi-prompt` 不创建 `.harness/runs/`。它是 one-shot helper,但不维护 run evidence、task state、verification 或 handoff artifact。
|
|
41
|
+
|
|
42
|
+
## 与 task / DAG 的关系
|
|
43
|
+
|
|
44
|
+
| 目录 | 含义 | 是否代表 task 完成 |
|
|
45
|
+
|---|---|---|
|
|
46
|
+
| `.harness/tasks/<task-id>/` | task 运行态状态源 | 是 task 状态源 |
|
|
47
|
+
| `.harness/runs/<state>/<run-id>/` | one-shot tool run evidence | 否,只是一次执行证据 |
|
|
48
|
+
| `.harness/dag-runs/<state>/<run-id>/` | Agent DAG run facts | 否,只是 DAG run facts |
|
|
49
|
+
|
|
50
|
+
completed one-shot evidence 若要进入 task artifacts,使用:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
loop-agent promote-run <task-id> --run-id <run-id>
|
|
54
|
+
loop-agent closeout task <task-id>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`promote-run` 只读 `.harness/runs/completed/**`,生成或更新 task `artifacts/修改记录.md` / `artifacts/验证结果.md`,不修改 completed run facts。
|
|
58
|
+
|
|
59
|
+
## Active 目录清理
|
|
60
|
+
|
|
61
|
+
`.harness/runs/active/` 只应存在 live one-shot run。治理检查发现 active 内容时会 warning:
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
[HARNESS RUNTIME WARNING] .harness/runs/active contains runtime entries
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
处理规则:
|
|
68
|
+
|
|
69
|
+
- 如果确有 one-shot 正在执行,可以保留;必要时用 `HARNESS_ALLOW_ACTIVE_TOOL_RUNS=1` 跑治理检查。
|
|
70
|
+
- 如果是已完成、失败或中断残留,应移动到 `completed/` / `failed/`,或在确认无价值后删除。
|
|
71
|
+
- 如果是 `.DS_Store` 等系统垃圾文件,直接删除;它不是合法 run evidence。
|
|
72
|
+
- 不要把 active 残留当作 task 完成证据。
|
|
73
|
+
|
|
74
|
+
严格检查可用:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
HARNESS_STRICT_ACTIVE_TOOL_RUNS=1 bash scripts/check-harness-runtime-clean.sh
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## 不要做什么
|
|
81
|
+
|
|
82
|
+
- 不要提交 `.harness/runs/**` 运行态内容。
|
|
83
|
+
- 不要手动改写 `.harness/runs/completed/**` 或 `.harness/runs/failed/**` 事实。
|
|
84
|
+
- 不要把 `.harness/runs/active/**` 当作长期记录。
|
|
85
|
+
- 不要把 one-shot evidence 直接等同于 task artifacts;需要汇总时用 `promote-run`。
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
# One-shot Pi SDK Prompt Helper(`pi-prompt`)
|
|
2
|
-
|
|
3
|
-
短时 Pi SDK task、不需要完整 `.harness/tasks/<id>` workflow 时使用本文。替代 ad-hoc 临时代码脚本导入 `executeSingleSdkAttempt` 的做法。
|
|
4
|
-
|
|
5
|
-
### One-shot Pi SDK prompt helper
|
|
6
|
-
|
|
7
|
-
短时 Pi SDK task、不需要完整 `.harness/tasks/<id>` workflow 时,用 `loop-agent pi-prompt`,勿创建 ad-hoc 临时代码脚本导入 `executeSingleSdkAttempt`。`pi-prompt` 是一次性 full-capability helper;是否只读由本次调用的 prompt 与 `--tools` 决定。
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
loop-agent pi-prompt "Reply with exactly OK."
|
|
11
|
-
loop-agent pi-prompt --stdin < <temp-dir>/task.md
|
|
12
|
-
loop-agent pi-prompt --file <temp-dir>/task.md
|
|
13
|
-
loop-agent pi-prompt --cwd ~/go/src/loop-agent --tools read,grep,find,ls "Review the current diff. Do not edit files."
|
|
14
|
-
loop-agent pi-prompt --cwd ~/go/src/loop-agent --tools subagent,read --timeout 2400000 "Use subagent exactly once ..."
|
|
15
|
-
loop-agent pi-prompt --model gpt-5.5 --cwd ~/go/src/loop-agent "Deeply diagnose this failure."
|
|
16
|
-
loop-agent pi-prompt "Reply with exactly OK."
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
`<temp-dir>` 表示平台原生临时目录;实际命令中使用本机路径。
|
|
20
|
-
|
|
21
|
-
默认:`--provider wizard-local --model glm-5.2`;高复杂度 one-shot 可显式 `--model gpt-5.5`。按需用 `--provider`、`--model`、`--thinking`、`--tools`、`--timeout` 覆盖。
|
|
22
|
-
|
|
23
|
-
`pi-prompt` 仅用于 quick one-shot SDK call。**不**创建 `.harness/tasks/`、不跑 verification、不写 handoff artifact、不保留 workflow state。须可恢复、可验证的 implementation work 用 DAG 路径;需要隔离写入时使用 bounded Cursor 或 `delegate`。
|
|
1
|
+
# One-shot Pi SDK Prompt Helper(`pi-prompt`)
|
|
2
|
+
|
|
3
|
+
短时 Pi SDK task、不需要完整 `.harness/tasks/<id>` workflow 时使用本文。替代 ad-hoc 临时代码脚本导入 `executeSingleSdkAttempt` 的做法。
|
|
4
|
+
|
|
5
|
+
### One-shot Pi SDK prompt helper
|
|
6
|
+
|
|
7
|
+
短时 Pi SDK task、不需要完整 `.harness/tasks/<id>` workflow 时,用 `loop-agent pi-prompt`,勿创建 ad-hoc 临时代码脚本导入 `executeSingleSdkAttempt`。`pi-prompt` 是一次性 full-capability helper;是否只读由本次调用的 prompt 与 `--tools` 决定。
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
loop-agent pi-prompt "Reply with exactly OK."
|
|
11
|
+
loop-agent pi-prompt --stdin < <temp-dir>/task.md
|
|
12
|
+
loop-agent pi-prompt --file <temp-dir>/task.md
|
|
13
|
+
loop-agent pi-prompt --cwd ~/go/src/loop-agent --tools read,grep,find,ls "Review the current diff. Do not edit files."
|
|
14
|
+
loop-agent pi-prompt --cwd ~/go/src/loop-agent --tools subagent,read --timeout 2400000 "Use subagent exactly once ..."
|
|
15
|
+
loop-agent pi-prompt --model gpt-5.5 --cwd ~/go/src/loop-agent "Deeply diagnose this failure."
|
|
16
|
+
loop-agent pi-prompt "Reply with exactly OK."
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`<temp-dir>` 表示平台原生临时目录;实际命令中使用本机路径。
|
|
20
|
+
|
|
21
|
+
默认:`--provider wizard-local --model glm-5.2`;高复杂度 one-shot 可显式 `--model gpt-5.5`。按需用 `--provider`、`--model`、`--thinking`、`--tools`、`--timeout` 覆盖。
|
|
22
|
+
|
|
23
|
+
`pi-prompt` 仅用于 quick one-shot SDK call。**不**创建 `.harness/tasks/`、不跑 verification、不写 handoff artifact、不保留 workflow state。须可恢复、可验证的 implementation work 用 DAG 路径;需要隔离写入时使用 bounded Cursor 或 `delegate`。
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
# Pi Subagent Assisted Mode
|
|
2
|
-
|
|
3
|
-
loop-agent task 启用 `piSubagentMode`、在 analyze/plan/spec/retrospective 内需要 read-only scout/planner/reviewer subagents,或配置 project-local agents/prompts 时使用本文。
|
|
4
|
-
|
|
5
|
-
`task.json` 支持可选字段 `piSubagentMode`,用于 step 级 `subagent` tool delegation:
|
|
6
|
-
|
|
7
|
-
| Mode | analyze | plan | spec | implement | retrospective | verify |
|
|
8
|
-
|------|---------|------|------|-----------|----------------|--------|
|
|
9
|
-
| `off`(默认) | read only | read only | read only | +write/edit/bash | read only | read only |
|
|
10
|
-
| `analyze-plan` | **+subagent** | **+subagent** | **+subagent** | 同 off | 同 off | 同 off |
|
|
11
|
-
| `full` | **+subagent** | **+subagent** | **+subagent** | 同 off | **+subagent** | 同 off |
|
|
12
|
-
|
|
13
|
-
### 何时启用
|
|
14
|
-
|
|
15
|
-
在 `task.json` 设 `piSubagentMode: "analyze-plan"` 或 `piSubagentMode: "full"` 当:
|
|
16
|
-
- task 涉及大规模 codebase 阅读,适合 parallel scout agents
|
|
17
|
-
- analysis 或 planning 需多角度调查(如跨模块比较实现)
|
|
18
|
-
- retrospective review 适合独立 reviewer subagent(`full` mode)
|
|
19
|
-
|
|
20
|
-
### step 内使用 `subagent` 的指引
|
|
21
|
-
|
|
22
|
-
subagent 可用时,**仅用于 read-only task**:
|
|
23
|
-
- **Parallel scout**:dispatch 多个 subagent 同时搜索/阅读不同区域
|
|
24
|
-
- **Chain**:一个 subagent scout,另一个基于发现 planning
|
|
25
|
-
- **Reviewer**:用 subagent 在定稿前 review analysis/plan
|
|
26
|
-
|
|
27
|
-
**不要**用 subagent 做 writing、editing 或执行命令。subagent 输出仅 advisory;务必 verify 并将发现并入自己的输出。**不要**把 subagent 结果当作权威 state 或 artifact source。
|
|
28
|
-
|
|
29
|
-
### 前置条件
|
|
30
|
-
|
|
31
|
-
- Pi runtime 环境须有 `subagent` tool(经 Pi subagent extension 加载)
|
|
32
|
-
- 推荐用 Pi 自带 example 文件安装:
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
mkdir -p ~/.pi/agent/extensions/subagent ~/.pi/agent/agents ~/.pi/agent/prompts
|
|
36
|
-
|
|
37
|
-
ln -sf /usr/local/lib/node_modules/@earendil-works/pi-coding-agent/examples/extensions/subagent/index.ts ~/.pi/agent/extensions/subagent/index.ts
|
|
38
|
-
ln -sf /usr/local/lib/node_modules/@earendil-works/pi-coding-agent/examples/extensions/subagent/agents.ts ~/.pi/agent/extensions/subagent/agents.ts
|
|
39
|
-
|
|
40
|
-
for f in /usr/local/lib/node_modules/@earendil-works/pi-coding-agent/examples/extensions/subagent/agents/*.md; do
|
|
41
|
-
ln -sf "$f" ~/.pi/agent/agents/$(basename "$f")
|
|
42
|
-
done
|
|
43
|
-
|
|
44
|
-
for f in /usr/local/lib/node_modules/@earendil-works/pi-coding-agent/examples/extensions/subagent/prompts/*.md; do
|
|
45
|
-
ln -sf "$f" ~/.pi/agent/prompts/$(basename "$f")
|
|
46
|
-
done
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
- 最小 smoke check:
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
pi -p --no-session --no-context-files --no-skills --tools subagent "Reply with exactly OK."
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
预期输出:`OK`
|
|
56
|
-
- mode 按 task opt-in;默认 `off` 保持向后兼容
|
|
57
|
-
- 任何 mode 下 `implement` 都不给 `subagent`(防止 nested multi-writer)
|
|
58
|
-
|
|
59
|
-
### 内置 Project-Local Agents 与 Prompts
|
|
60
|
-
|
|
61
|
-
本 repo 提供 `.pi/agents/` 与 `.pi/prompts/` 模板,供 `piSubagentMode` 使用:
|
|
62
|
-
|
|
63
|
-
**Agents**(`.pi/agents/`)
|
|
64
|
-
|
|
65
|
-
| Agent | Role | 对应阶段 |
|
|
66
|
-
|-------|------|----------|
|
|
67
|
-
| `loop-agent-scout` | 只读侦察:code、tests、docs、governance | Scout |
|
|
68
|
-
| `loop-agent-planner` | 最小可执行计划;强调验证与回退 | Plan |
|
|
69
|
-
| `loop-agent-reviewer` | 严格审查:范围漂移、验证缺口、契约破坏 | Verify / Review |
|
|
70
|
-
| `loop-agent-worker` | 有界实现与修补 | Implement |
|
|
71
|
-
|
|
72
|
-
另有通用 agents:`scout` / `planner` / `worker` / `reviewer`(中文提示,可被通用 prompt 模板调用)。模型以各 agent frontmatter 为准(当前仓库默认对齐 `harness.json` 的 Pi executor)。
|
|
73
|
-
|
|
74
|
-
**Prompt Templates**(`.pi/prompts/`):输入 `/loop-agent-*` 或通用模板名调用
|
|
75
|
-
|
|
76
|
-
| Template | Flow |
|
|
77
|
-
|----------|------|
|
|
78
|
-
| `loop-agent-scout-and-plan` | parallel scout → planner |
|
|
79
|
-
| `loop-agent-analyze-wide` | 3 parallel scouts → 结构化分析 |
|
|
80
|
-
| `loop-agent-review-only` | 独立审查计划/实现/验证 |
|
|
81
|
-
| `loop-agent-implement-and-review` | worker → reviewer → worker |
|
|
82
|
-
| `scout-and-plan` / `implement` / `implement-and-review` | 通用 chain(调用 `scout`/`planner`/`worker`/`reviewer`) |
|
|
83
|
-
|
|
84
|
-
传 `agentScope: "both"` + `confirmProjectAgents: false` 以访问 repo-local agents。
|
|
1
|
+
# Pi Subagent Assisted Mode
|
|
2
|
+
|
|
3
|
+
loop-agent task 启用 `piSubagentMode`、在 analyze/plan/spec/retrospective 内需要 read-only scout/planner/reviewer subagents,或配置 project-local agents/prompts 时使用本文。
|
|
4
|
+
|
|
5
|
+
`task.json` 支持可选字段 `piSubagentMode`,用于 step 级 `subagent` tool delegation:
|
|
6
|
+
|
|
7
|
+
| Mode | analyze | plan | spec | implement | retrospective | verify |
|
|
8
|
+
|------|---------|------|------|-----------|----------------|--------|
|
|
9
|
+
| `off`(默认) | read only | read only | read only | +write/edit/bash | read only | read only |
|
|
10
|
+
| `analyze-plan` | **+subagent** | **+subagent** | **+subagent** | 同 off | 同 off | 同 off |
|
|
11
|
+
| `full` | **+subagent** | **+subagent** | **+subagent** | 同 off | **+subagent** | 同 off |
|
|
12
|
+
|
|
13
|
+
### 何时启用
|
|
14
|
+
|
|
15
|
+
在 `task.json` 设 `piSubagentMode: "analyze-plan"` 或 `piSubagentMode: "full"` 当:
|
|
16
|
+
- task 涉及大规模 codebase 阅读,适合 parallel scout agents
|
|
17
|
+
- analysis 或 planning 需多角度调查(如跨模块比较实现)
|
|
18
|
+
- retrospective review 适合独立 reviewer subagent(`full` mode)
|
|
19
|
+
|
|
20
|
+
### step 内使用 `subagent` 的指引
|
|
21
|
+
|
|
22
|
+
subagent 可用时,**仅用于 read-only task**:
|
|
23
|
+
- **Parallel scout**:dispatch 多个 subagent 同时搜索/阅读不同区域
|
|
24
|
+
- **Chain**:一个 subagent scout,另一个基于发现 planning
|
|
25
|
+
- **Reviewer**:用 subagent 在定稿前 review analysis/plan
|
|
26
|
+
|
|
27
|
+
**不要**用 subagent 做 writing、editing 或执行命令。subagent 输出仅 advisory;务必 verify 并将发现并入自己的输出。**不要**把 subagent 结果当作权威 state 或 artifact source。
|
|
28
|
+
|
|
29
|
+
### 前置条件
|
|
30
|
+
|
|
31
|
+
- Pi runtime 环境须有 `subagent` tool(经 Pi subagent extension 加载)
|
|
32
|
+
- 推荐用 Pi 自带 example 文件安装:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
mkdir -p ~/.pi/agent/extensions/subagent ~/.pi/agent/agents ~/.pi/agent/prompts
|
|
36
|
+
|
|
37
|
+
ln -sf /usr/local/lib/node_modules/@earendil-works/pi-coding-agent/examples/extensions/subagent/index.ts ~/.pi/agent/extensions/subagent/index.ts
|
|
38
|
+
ln -sf /usr/local/lib/node_modules/@earendil-works/pi-coding-agent/examples/extensions/subagent/agents.ts ~/.pi/agent/extensions/subagent/agents.ts
|
|
39
|
+
|
|
40
|
+
for f in /usr/local/lib/node_modules/@earendil-works/pi-coding-agent/examples/extensions/subagent/agents/*.md; do
|
|
41
|
+
ln -sf "$f" ~/.pi/agent/agents/$(basename "$f")
|
|
42
|
+
done
|
|
43
|
+
|
|
44
|
+
for f in /usr/local/lib/node_modules/@earendil-works/pi-coding-agent/examples/extensions/subagent/prompts/*.md; do
|
|
45
|
+
ln -sf "$f" ~/.pi/agent/prompts/$(basename "$f")
|
|
46
|
+
done
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- 最小 smoke check:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pi -p --no-session --no-context-files --no-skills --tools subagent "Reply with exactly OK."
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
预期输出:`OK`
|
|
56
|
+
- mode 按 task opt-in;默认 `off` 保持向后兼容
|
|
57
|
+
- 任何 mode 下 `implement` 都不给 `subagent`(防止 nested multi-writer)
|
|
58
|
+
|
|
59
|
+
### 内置 Project-Local Agents 与 Prompts
|
|
60
|
+
|
|
61
|
+
本 repo 提供 `.pi/agents/` 与 `.pi/prompts/` 模板,供 `piSubagentMode` 使用:
|
|
62
|
+
|
|
63
|
+
**Agents**(`.pi/agents/`)
|
|
64
|
+
|
|
65
|
+
| Agent | Role | 对应阶段 |
|
|
66
|
+
|-------|------|----------|
|
|
67
|
+
| `loop-agent-scout` | 只读侦察:code、tests、docs、governance | Scout |
|
|
68
|
+
| `loop-agent-planner` | 最小可执行计划;强调验证与回退 | Plan |
|
|
69
|
+
| `loop-agent-reviewer` | 严格审查:范围漂移、验证缺口、契约破坏 | Verify / Review |
|
|
70
|
+
| `loop-agent-worker` | 有界实现与修补 | Implement |
|
|
71
|
+
|
|
72
|
+
另有通用 agents:`scout` / `planner` / `worker` / `reviewer`(中文提示,可被通用 prompt 模板调用)。模型以各 agent frontmatter 为准(当前仓库默认对齐 `harness.json` 的 Pi executor)。
|
|
73
|
+
|
|
74
|
+
**Prompt Templates**(`.pi/prompts/`):输入 `/loop-agent-*` 或通用模板名调用
|
|
75
|
+
|
|
76
|
+
| Template | Flow |
|
|
77
|
+
|----------|------|
|
|
78
|
+
| `loop-agent-scout-and-plan` | parallel scout → planner |
|
|
79
|
+
| `loop-agent-analyze-wide` | 3 parallel scouts → 结构化分析 |
|
|
80
|
+
| `loop-agent-review-only` | 独立审查计划/实现/验证 |
|
|
81
|
+
| `loop-agent-implement-and-review` | worker → reviewer → worker |
|
|
82
|
+
| `scout-and-plan` / `implement` / `implement-and-review` | 通用 chain(调用 `scout`/`planner`/`worker`/`reviewer`) |
|
|
83
|
+
|
|
84
|
+
传 `agentScope: "both"` + `confirmProjectAgents: false` 以访问 repo-local agents。
|
|
@@ -27,7 +27,7 @@ DAG run、promotion、closeout 和最终验证完成后:
|
|
|
27
27
|
|
|
28
28
|
```
|
|
29
29
|
1. new-task <id>
|
|
30
|
-
2. 有 PRD 文件:import-prd
|
|
30
|
+
2. 有 PRD 文件:import-prd → task source prepare --use-imported-prd --apply(默认不手写两 source)
|
|
31
31
|
3. 非微小:plan create(或挂到已有 active plan)
|
|
32
32
|
4. dag run-task <id> --profile auto --strict-models
|
|
33
33
|
5. dag validate --dag .harness/tasks/<id>/dag.json --strict-models --strict-governance
|
|
@@ -11,7 +11,7 @@ Task 目录布局:`task-workflow.md`。
|
|
|
11
11
|
| 层 | 命令 / 路径 | 作用 | 主路径 DAG 是否强制 |
|
|
12
12
|
| --- | --- | --- | --- |
|
|
13
13
|
| Source 事实 | `import-prd` → `source/references/*` + `source-manifest.json` | 原始 PRD **不可变**归档 | 否(有 PRD 文件时**强烈推荐**) |
|
|
14
|
-
| Source 契约 |
|
|
14
|
+
| Source 契约 | `task source prepare --apply` 投影 `source/需求.md`、`执行约束.md` + managed paths | DAG 生成与验收真源 | **是**(至少 `需求.md`;默认不手写) |
|
|
15
15
|
| Exec-plan | `plan create` / `plan complete` / `plan check` | 仓库级计划索引与交接 | 否(**非微小**推荐) |
|
|
16
16
|
| DAG 运行时 | `dag run-task` → `dag validate` → `run-dag` | 可执行编排 | **是**(常规实现) |
|
|
17
17
|
|
|
@@ -47,7 +47,8 @@ Task 目录布局:`task-workflow.md`。
|
|
|
47
47
|
```bash
|
|
48
48
|
loop-agent new-task <task-id> "简短标题"
|
|
49
49
|
loop-agent import-prd <task-id> --file <path-to-original-prd.md> [--json]
|
|
50
|
-
|
|
50
|
+
loop-agent task source prepare <task-id> --use-imported-prd --allowed-path "<glob>" --apply --json
|
|
51
|
+
# 默认无 LLM 写 source;工程边界用 flags 显式给出
|
|
51
52
|
# .harness/tasks/<task-id>/source/需求.md
|
|
52
53
|
# .harness/tasks/<task-id>/source/执行约束.md
|
|
53
54
|
# 同步 task.json.allowedPaths / forbiddenPaths
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
loop-agent new-task <task-id> "Task Title"
|
|
11
|
-
#
|
|
11
|
+
# 推荐:详细 PRD → import → prepare(无需手写两 source)
|
|
12
|
+
loop-agent import-prd <task-id> --file <prd>
|
|
13
|
+
loop-agent task source prepare <task-id> --use-imported-prd --allowed-path "<glob>" --apply --json
|
|
12
14
|
# 非微小:loop-agent plan create <plan-id> "<title>"(可与 task 解耦,见 source-and-plan-practice.md)
|
|
13
15
|
loop-agent dag run-task <task-id> --profile auto --strict-models
|
|
14
16
|
loop-agent dag validate --dag .harness/tasks/<task-id>/dag.json --strict-models --strict-governance
|
|
@@ -35,10 +37,10 @@ loop-agent run-dag --dag .harness/tasks/<task-id>/dag.json --cwd <repo-root>
|
|
|
35
37
|
task.json
|
|
36
38
|
```
|
|
37
39
|
|
|
38
|
-
- 用户原始 PRD 用 `loop-agent import-prd <task-id> --file <prd>` 归档到 `source/references/`,禁止 AI 改写。**有文件就 import
|
|
39
|
-
- `需求.md`
|
|
40
|
-
-
|
|
41
|
-
- 若 `ai_workspace/loop-agent/` 已有权威 plan/spec/PRD,优先 `import-prd`
|
|
40
|
+
- 用户原始 PRD 用 `loop-agent import-prd <task-id> --file <prd>` 归档到 `source/references/`,禁止 AI 改写。**有文件就 import**。
|
|
41
|
+
- 默认用 `task source prepare --use-imported-prd --apply` 投影 `需求.md` / `执行约束.md` 与 managed paths;**不要**默认让 LLM/主会话手写两 source。
|
|
42
|
+
- 无独立 PRD 的微小任务可用 `task source prepare --from-text ... --apply` escape hatch(见 `source-and-plan-practice.md`)。
|
|
43
|
+
- 若 `ai_workspace/loop-agent/` 已有权威 plan/spec/PRD,优先 `import-prd` 复制,再 prepare 派生薄契约;避免把长 PRD 直接改写成唯一 source。
|
|
42
44
|
- 仓库级 exec-plan(`plan create`)与 harness task **解耦**:非微小实现应有 plan 或复用 active plan;微小任务可不建 plan。
|
|
43
45
|
- Worker / TaskSpec materialize 路径会把 `source_docs` 复制到 `source/references/`,并在派生 `需求.md` 顶部声明“冲突以 references 为准”;`acceptance_refs` 应展开为短摘要而不只写 ID。
|
|
44
46
|
- review 节点必须三方对照:`source/references/*`(尤其 requirement/acceptance)、派生 `需求.md`、以及实现/验证证据。
|