@tea-agent/loop-agent 0.20.1 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/bin/agent-worker.js +0 -0
  3. package/dist/adapters/loop-agent.js +52 -0
  4. package/dist/commands/init.js +104 -0
  5. package/dist/executors/dag-pi-executor.js +26 -0
  6. package/dist/executors/pi-executor.js +111 -36
  7. package/dist/executors/pi-sdk-executor.js +105 -29
  8. package/dist/executors/shell-executor.js +215 -29
  9. package/dist/shared/openspec-spec.js +49 -0
  10. package/dist/worker/loop-agent/loop-agent-client.js +43 -9
  11. package/dist/worker/observability/read-model.js +28 -2
  12. package/dist/worker/observe/spec-evidence.js +12 -15
  13. package/dist/worker/observe/static/constants.js +5 -0
  14. package/dist/worker/observe/static/dag-helpers.js +22 -0
  15. package/dist/worker/observe/static/format-pool.js +22 -3
  16. package/dist/worker/observe/static/styles.css +32 -3
  17. package/dist/worker/observe/static/views/dag-inspector.js +2 -2
  18. package/dist/worker/observe/static/views/dag.js +5 -0
  19. package/dist/worker/run-task/run-task.js +16 -6
  20. package/dist/workflows/dag/backend-test-markdown-workflow.js +328 -97
  21. package/dist/workflows/dag/backend-test-result-contract.js +10 -4
  22. package/dist/workflows/dag/frontend-implementation-contract.js +141 -32
  23. package/dist/workflows/dag/frontend-lint-baseline.js +471 -0
  24. package/dist/workflows/dag/frontend-prewrite-gate.js +79 -16
  25. package/dist/workflows/dag/frontend-project-capability.js +11 -8
  26. package/dist/workflows/dag/frontend-repair.js +6 -4
  27. package/dist/workflows/dag/frontend-review-context.js +67 -0
  28. package/dist/workflows/dag/frontend-test-case-quality.js +105 -0
  29. package/dist/workflows/dag/frontend-test-result-contract.js +71 -66
  30. package/dist/workflows/dag/frontend-verification-trace.js +31 -1
  31. package/dist/workflows/dag/frontend-worktree-diff.js +81 -6
  32. package/dist/workflows/dag/init-hybrid.js +370 -79
  33. package/dist/workflows/dag/lifecycle.js +60 -4
  34. package/dist/workflows/dag/liveness-policy.js +250 -0
  35. package/dist/workflows/dag/node-execution.js +49 -0
  36. package/dist/workflows/dag/runner.js +21 -1
  37. package/dist/workflows/dag/types.js +67 -1
  38. package/docs/README.md +5 -6
  39. package/docs/architecture/dag-execution.md +11 -0
  40. package/docs/architecture/facts-and-state.md +1 -0
  41. package/docs/architecture/worker-and-feature.md +10 -0
  42. package/docs/templates/agent-dag.schema.json +15 -5
  43. package/docs/templates/backend-test-dag.generate-pytest.prompt.md +5 -2
  44. package/docs/templates/backend-test-dag.json +15 -15
  45. package/docs/templates/frontend-implementation-contract.schema.json +4 -3
  46. package/docs/templates/frontend-test-case-checklist.md +6 -2
  47. package/docs/templates/frontend-test-dag.json +2 -2
  48. package/harness.json +1 -1
  49. package/package.json +1 -1
  50. package/skills/frontend-design-review/SKILL.md +12 -10
  51. package/skills/frontend-design-review/references/review-checklist.md +4 -4
  52. package/skills/frontend-implementation/SKILL.md +2 -2
  53. package/skills/frontend-implementation/references/code-standards.md +4 -3
  54. package/skills/frontend-implementation/references/design-spec.md +19 -14
  55. package/skills/frontend-implementation/references/node-contracts.md +2 -2
  56. package/skills/frontend-review/SKILL.md +15 -28
  57. package/skills/frontend-review/references/review-findings.md +16 -18
  58. package/skills/frontend-verification/SKILL.md +16 -13
  59. package/skills/frontend-verification/references/verification-checklist.md +18 -30
  60. package/skills/loop-agent/references/command-reference.md +2 -0
  61. package/skills/loop-agent/references/hybrid-dag.md +2 -2
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Severity
4
4
 
5
- - **Critical**: blocks primary flow, corrupts data, violates security/privacy, writes forbidden paths, or bypasses required verification.
5
+ - **Critical**: blocks primary flow, corrupts data, violates security/privacy, writes forbidden paths, bypasses required verification.
6
6
  - **Important**: acceptance/state/validation gap, material convention drift, missing behavior tests, unauthorized dependency, unsafe mock activation/import, mock-contract drift, misleading real-integration claim, or failed/missing required verification.
7
7
  - **Minor**: non-blocking maintainability, copy, layout, or cleanup issue.
8
8
 
@@ -10,43 +10,41 @@
10
10
 
11
11
  - Cite tight file locations, exact commands/results, or named DAG artifacts.
12
12
  - Never invent evidence; name the missing check. An implementation summary is not the actual diff.
13
- - Failed required static/behavior verification is at least Important unless proven unrelated.
14
- - Treat the knowledge base and `openspec/` as parallel sources. Record
15
- connector/query, source ID/version, and retrieval time for knowledge-base
16
- claims. Regardless of that result, evidence must show
17
- `<repoRoot>/openspec/**` search terms and matched paths/headings; label
18
- `openspec`, `repository fallback`, or `unavailable` accurately.
13
+ - Failed required static/behavior verification is at least Important. Lint may be
14
+ `baseline-debt` only with a valid `frontend-lint-assessment-v1`; this is not a
15
+ passed lint result. A changed-file lint diagnostic, new unmatched diagnostic,
16
+ command drift, missing baseline, timeout, or unparseable output is Important.
17
+ - Treat knowledge base, `openspec/schemas/`, `openspec/project-specs/`, and `ai_workspace/` as
18
+ parallel sources. Record connector/query/source/time plus openspec search terms and
19
+ matched paths/headings; label fallback or unavailable accurately.
19
20
 
20
21
  ## Review Sequence
21
22
 
22
23
  1. Establish changed-file inventory and write boundaries.
23
24
  2. Compare original requirement with derived contract/constraints.
24
25
  3. Map each criterion to code, states, tests, and evidence.
25
- 4. Inspect interactions, state/data/API behavior, failure paths, and regression risk.
26
+ 4. Inspect interactions, state/data/API behavior, failure paths, and regressions.
26
27
  5. Check mock selection, contract-to-fixture mapping, activation/default path,
27
- handler/fixture/adapter and consumer diff, optional Mock-specific verification,
28
- production imports, evidence scope, and the documented real-integration gap.
29
- 6. Check component/design evidence, responsive/accessibility behavior, dependencies, and maintenance fit when applicable.
28
+ handler/fixture/adapter and consumer diff, verification, production imports, and
29
+ the real-integration gap.
30
+ 6. Check design evidence, responsive/a11y behavior, dependencies, and maintenance.
30
31
  7. Classify findings and derive the verdict mechanically.
31
32
 
32
- Skipping the required `openspec/` search after knowledge-base failure is Important
33
- when component/design compliance affects acceptance or implementation choices.
34
-
35
- Use one issue per finding:
33
+ Skipping either directory is Important when design compliance affects acceptance.
36
34
 
37
35
  ```text
38
36
  - [Critical|Important|Minor] path:line — Problem; impact; required correction; evidence.
39
37
  ```
40
38
 
41
- Avoid vague advice. When no source location exists, cite the command or artifact.
42
-
43
39
  ## Pass Rules
44
40
 
45
41
  - No Critical or Important findings remain.
46
42
  - Required static and behavior nodes ran and passed.
43
+ - Lint is `passed` or evidence-backed `baseline-debt`; typecheck, build, and test are
44
+ passed. Any debt count and affected unchanged files remain disclosed.
47
45
  - Changed files are authorized.
48
46
  - Criteria and applicable states have implementation and evidence.
49
47
  - Required Mock-backed behavior passed; any generated Mock-specific verification also
50
48
  passed; Mock is not enabled by default in production. For default-auto skipped
51
49
  Mock, the real request remains default and the Real Integration Gap is preserved.
52
- - Optional unavailable knowledge-base, browser, visual, or manual checks remain explicit risks.
50
+ - Optional unavailable knowledge/browser/visual/manual checks remain explicit risks.
@@ -17,18 +17,22 @@ verdict/findings, and required browser, visual, manual, or knowledge evidence.
17
17
 
18
18
  ## Evidence Rules
19
19
 
20
- - Static evidence covers type/lint/build/schema; behavior evidence must exercise the flow.
20
+ - Static evidence covers type/build/schema; behavior evidence must exercise the flow.
21
+ Lint has its own assessment status: `passed`, `baseline-debt`, `failed`, or
22
+ `unavailable`.
21
23
  - Shell exit status is authoritative. Classify as `passed`, `failed`, `not-run`,
22
24
  `blocked`, or `unavailable`; only passed satisfies a required check.
23
25
  - Never use static success as behavior proof, or tests as visual/browser proof they did not exercise.
24
26
  - Mock-backed behavior proves frontend rendering and state transitions only. It never
25
27
  proves backend readiness, transport compatibility, or real API integration.
26
28
  - Unavailable commands remain gaps.
27
- - Resolve design evidence from two parallel sources: query the execution environment's
28
- knowledge base connector when available; regardless of result, also read
29
- `<repoRoot>/openspec/**` for index and task-relevant specification content.
30
- The connector format remains TODO; never invent it. Applied `openspec` rules
31
- from successful reads are available project evidence.
29
+ - `baseline-debt` is not lint passed. It requires
30
+ `frontend-lint-assessment-v1` proving only pre-writer diagnostics on unchanged
31
+ files. Report debt count, changed files, and raw evidence. Typecheck/build/test do
32
+ not support debt.
33
+ - Resolve design evidence from parallel sources: query the available knowledge
34
+ connector and always read task-relevant `<repoRoot>/openspec/schemas/`,
35
+ `<repoRoot>/openspec/project-specs/`, and `<repoRoot>/ai_workspace/`. Connector format is TODO; never invent it.
32
36
  - Separate Mock service/handler checks from page consumption and record the
33
37
  dev/test-only boundary; handler tests alone do not prove page use.
34
38
 
@@ -40,18 +44,17 @@ only proven changes.
40
44
  Return Markdown headings:
41
45
 
42
46
  - `Changes`: changed behavior and areas.
43
- - `Mock Decision`, `Mock Files`, `Mock Verification`, `Production Boundary`: status is `passed`, `failed`, `not-required`, `blocked`, or `unavailable`.
47
+ - `Mock Decision`, `Mock Files`, `Mock Verification`, `Production Boundary`.
44
48
  - `Verification Evidence`: table of check, command/source, status, and artifact/result.
49
+ Keep lint `baseline-debt` verbatim rather than converting it to `passed`.
45
50
  - `Review Result`: exact review verdict and findings.
46
51
  - `Known Risks`: missing optional checks and environment caveats.
47
52
  - `Follow-up`: concrete work or `None`.
48
53
 
49
- When the backend remains unavailable but required mock-backed checks pass, state
50
- `Frontend status: mock-validated` and `Real integration: pending`. When default
51
- `auto` skipped Mock and no real API evidence passed, state
52
- `Frontend status: locally-validated` and `Real integration: pending`. Use a completed
53
- `<task-id>-real-api-integration-verify` task before changing the latter to complete;
54
- the follow-up is explicit, not auto-created or auto-executed.
54
+ With only Mock evidence, state `Frontend status: mock-validated`; when default `auto`
55
+ skipped Mock without real API evidence, state `Frontend status: locally-validated`.
56
+ Both require `Real integration: pending` and explicit
57
+ `<task-id>-real-api-integration-verify` follow-up; it is not auto-created/executed.
55
58
 
56
59
  Do not edit files. Do not claim complete when review is not pass or a required check
57
60
  is failed, not-run, blocked, unavailable, stale, or contradicted.
@@ -3,19 +3,26 @@
3
3
  ## Static And Behavior Evidence
4
4
 
5
5
  - Required type/compile, lint/format, build, schema/client, browser/e2e/manual checks ran.
6
+ - Lint is recorded as `passed | baseline-debt | failed | unavailable`.
7
+ `baseline-debt` cites `frontend-lint-baseline-v1` and
8
+ `frontend-lint-assessment-v1`, writer changed files, tolerated diagnostic count,
9
+ command identity, and raw output hashes; it is never labeled passed.
10
+ - Every remaining lint diagnostic is on an unchanged file and matches the
11
+ writer-preceding baseline. Changed-file diagnostics, new unmatched diagnostics,
12
+ command drift, timeout, worktree mutation, or unparseable output fail closed.
13
+ - Typecheck, build, and test are fully passed; none accepts baseline debt.
6
14
  - Generated output was authorized; tests cover changed logic, flows, and regressions.
7
- - Fixed DAG entrypoints prove selected-strategy behavior and applicable loading/empty/error/success/disabled/permission/retry/boundary states.
15
+ - Fixed entrypoints prove selected-strategy behavior and applicable UI states.
8
16
  - Mock-specific checks cover service/handler/schema/fixtures; behavior evidence separately proves page consumption.
9
17
  - Mock activation is explicit/non-production; a default-real-path build with Mock off proves the real request remains default.
10
- - `not-needed` has real/no-remote evidence, or default-auto skipped-Mock rationale with Real Integration Gap preserved when no project Mock capability exists.
18
+ - `not-needed` has real/no-remote evidence or a default-auto skipped-Mock rationale.
11
19
  - Mock-backed evidence is frontend-only and never satisfies real API integration.
12
20
 
13
21
  ## Design And Component Evidence
14
22
 
15
- - Claims cite two parallel sources: knowledge-base retrieval and
16
- `<repoRoot>/openspec/**`.
17
- - Evidence records query/source/time for knowledge base plus openspec search terms, paths, headings, and applied rules for both.
18
- - Relevant `openspec/` matches satisfy source availability; missing both sources blocks explicit compliance or required design decisions.
23
+ - Claims cite knowledge-base, OpenSpec, and `<repoRoot>/ai_workspace/` sources.
24
+ - Evidence records query/source/time, local-spec terms, paths, headings, and rules.
25
+ - OpenSpec or `ai_workspace/` matches satisfy source availability; none blocks required design decisions.
19
26
 
20
27
  ## Status
21
28
 
@@ -25,7 +32,8 @@
25
32
  - `blocked`: a prerequisite prevented execution.
26
33
  - `unavailable`: tool, environment, connector, or source was absent.
27
34
 
28
- Only passed satisfies a required check. Other optional statuses remain disclosed risks.
35
+ Only passed satisfies a required check. For lint alone, evidence-backed
36
+ `baseline-debt` may continue as explicit debt; it replaces no other check.
29
37
 
30
38
  ## Closeout Checks
31
39
 
@@ -35,26 +43,6 @@ Only passed satisfies a required check. Other optional statuses remain disclosed
35
43
  - If only Mock evidence exists, report `Frontend status: mock-validated` and `Real integration: pending`, with actual API verification follow-up.
36
44
  - If default `auto` skipped Mock and no real API evidence exists, report `Frontend status: locally-validated` and `Real integration: pending`.
37
45
 
38
- ```markdown
39
- ## Changes
40
- - ...
41
-
42
- ## Verification Evidence
43
- | Check | Command or source | Status | Evidence |
44
- |---|---|---|---|
45
- | ... | ... | passed | ... |
46
-
47
- ## Mock Decision / Mock Files / Mock Verification / Production Boundary
48
- - Status: `passed | failed | not-required | blocked | unavailable`
49
-
50
- ## Review Result
51
- - Verdict: `VERDICT: pass`
52
-
53
- ## Known Risks
54
- - ...
55
-
56
- ## Follow-up
57
- - None.
58
- ```
59
-
60
- If review is not pass or a required check is not passed, describe the task as incomplete and list concrete follow-up.
46
+ Output uses Changes, Verification Evidence, Mock Decision/Files/Verification,
47
+ Production Boundary, Review Result, Known Risks, and Follow-up headings. If review is
48
+ not pass or a required check fails, describe the task as incomplete with follow-up.
@@ -326,6 +326,8 @@ loop-agent dag resume --run-id <run-id> # approve 后继续
326
326
  - operator 聚焦最新 paused run 用 `dag report --paused-latest`(等同 `--lifecycle paused --latest`;勿与显式 `--lifecycle` 并用)。
327
327
  - 需 operator 关注的 run 用 `dag report --failed-only`、`--latest`、`--action <recovery-action>` 收窄。category→action 映射见 `ai_workspace/loop-agent/agent-dag-recovery-playbook.md`。
328
328
  - 只读扫描 `.harness/dag-runs/` 下所有 run 的生命周期 health issue 与建议 action 用 `dag doctor`(`advisoryOnly: true`;不 mutate facts)。
329
+ - `dag status` / `dag doctor` 的 runner heartbeat 只表示 lease;Pi meaningful progress 由 Provider/tool/output 活动决定。节点可显示 `quiet`、`suspected-stall`、`probing` 或 `needs-attention`,不要仅凭运行时长手工结束。
330
+ - Pi 默认 4h absolute max,`agent-worker` 默认不设置外层 `run-dag` wall-clock;显式 `worker.timeout_ms` 仍是 hard timeout。`termination-unconfirmed` 表示旧 attempt 的退出无法确认,禁止自动 retry,先保留现场并完成 operator 对账。
329
331
  - approve/resume 前用 `dag status --run-id <id>` 看单次 lifecycle、`approvalFlow`、`hasHumanApproval`。
330
332
  - lifecycle、raw status 与 liveness 冲突时先用 `dag reconcile-run --run-id <id>` 只读检查。只有 runner 已证明停止且 operator 明确给出 `supersede|abandon` 与 reason 时才允许收口;它保存原始 state,不把未执行节点标成成功。
331
333
  - task status、source/artifacts、DAG outcome、verification 记录可能 drift 时用 `dag reconcile-tasks --glob '<pattern>'`。默认仅报告;`--patch` 显式且不能伪造 verification evidence。
@@ -19,9 +19,9 @@
19
19
  前端专用链保留独立 contract/scout;plan 同时选择 Mock/API 策略并输出结构化 implementation contract。design initial pass 直接使用原计划,只有 request-revision 才运行 revision/final review;small-risk 只执行一次 design review。`frontend-prewrite-gate-shell` 合并生效 verdict、REQ/BR/AC 覆盖、Mock policy 和 contract 物化,是唯一写入授权。实现后 `frontend-verify-assess-shell` 合并 Mock/static/behavior/trace/assessment;只有 `eligible=true` 才运行同 writeSet 的 repair 和 `frontend-reverify-shell`。`frontend-review-context-shell` 绑定真实 diff 与有效验证证据后再 review/closeout。standard/high-risk 为 15 个顶层节点,small-risk 为 13;绿色路径执行 11 个节点、7 次 Pi。生成期 blocked Mock 只生成一个确定性阻塞节点且没有 writer。
20
20
 
21
21
 
22
- > Backend-test Markdown-first:先由确定性环境 Shell 检查 clean env 中 Python/pytest、常见配置、conftest/fixture、test root、server entry 和 HTML renderer,失败时不消耗模型调用。随后 Pi 生成中文 README 索引与模块用例卡片并独立 Review `testcase/md/**`,Shell 校验 Case IDAC/source traceability、中文或历史英文分节、步骤、可断言预期与 secret 安全;pytest writer 仅转换最终 Markdown,不重读 `source/**`。traceability 同时支持模块级函数和 pytest 测试类方法;pytest 只运行一次,生成 JUnit,并把 Markdown 名称/场景/脚本映射与同一 JUnit 合成为逐条中文 self-contained HTML 主报告和 Markdown facts。最终 Pi 只解释事实并生成 Markdown 报告和 L-5 结论。active 流程不要求模型生成 backend-test 业务 JSON。
22
+ > Backend-test Markdown-first:先由确定性环境 Shell 检查 clean env 中 Python/pytest、常见配置、conftest/fixture、test root、server entry 和 HTML renderer,失败时不消耗模型调用。随后 Pi 生成中文 README 索引与模块用例卡片并独立 Review `testcase/md/**`。第 4 节点只把前置条件、操作步骤、预期结果作为必选章节,并检查 Case ID、业务 AC、步骤/预期和占位措辞;不校验需求来源引用有效性或 Markdown sensitive-shaped 内容。pytest writer 为每次真实接口调用记录脱敏、有界的请求 method/URL/参数摘要和响应 status/body 摘要。第 6 节点只扫描每条 Case 明确映射的 pytest 脚本,同时支持模块级函数和 pytest class 方法,并把缺少请求/响应日志、递归脱敏或有界截断证据记录为 advisory。第 4/6 节点均写 PASS/FAIL findings 而不阻断后续;pytest 仍只运行一次,生成 JUnit,并把 Markdown 名称/场景/脚本映射与同一 JUnit 合成为按测试概览、质量校验、失败概览、用例执行明细和技术证据组织的中文 self-contained HTML Markdown facts。最终 Pi 按固定简洁结构汇总 advisory 状态、执行事实和 L-5 结论。active 流程不要求模型生成 backend-test 业务 JSON。
23
23
 
24
- 显式专用 `taskKind` 保持兼容并优先于任务源分类。`backend-test` 选择固定 **8 个真实顶层节点**的 Markdown-first DAG:环境硬门、Markdown cases、独立 Review/修订、Markdown gate、pytest 转换、确定性 traceability、单次 pytest + JUnit/HTML/facts、最终 Markdown 报告与 L-5。历史 JSON contract/materializer 可继续读取旧 DAG,但新 runtime/template 不再生成模型业务 JSON。`knowledge-sync` 与 `knowledge-graph-bootstrap` 继续通过各自显式 taskKind 选择知识回写/图谱开荒 DAG。治理等级仍由 `minimal|standard|reviewed|supervised` 推断。
24
+ 显式专用 `taskKind` 保持兼容并优先于任务源分类。`backend-test` 选择固定 **8 个真实顶层节点**的 Markdown-first DAG:环境硬门、Markdown cases、独立 Review/修订、第 4 节点 advisory Markdown 校验、pytest 转换、第 6 节点 scoped advisory traceability、单次 pytest + JUnit/HTML/facts、最终 Markdown 报告与 L-5。历史 JSON contract/materializer 可继续读取旧 DAG,但新 runtime/template 不再生成模型业务 JSON。`knowledge-sync` 与 `knowledge-graph-bootstrap` 继续通过各自显式 taskKind 选择知识回写/图谱开荒 DAG。治理等级仍由 `minimal|standard|reviewed|supervised` 推断。
25
25
 
26
26
  ### DAG workflow 层级
27
27