@tea-agent/loop-agent 0.19.0 → 0.20.1-beta.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 (31) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/application/dag/generate-task-dag.js +12 -1
  3. package/dist/executors/shell-executor.js +189 -2
  4. package/dist/worker/observe/spec-evidence.js +33 -0
  5. package/dist/worker/observe/static/views/dag-inspector.js +67 -4
  6. package/dist/workflows/dag/backend-test-markdown-workflow.js +163 -41
  7. package/dist/workflows/dag/backend-test-result-contract.js +30 -7
  8. package/dist/workflows/dag/frontend-prewrite-gate.js +172 -0
  9. package/dist/workflows/dag/frontend-project-capability.js +6 -2
  10. package/dist/workflows/dag/frontend-repair.js +7 -1
  11. package/dist/workflows/dag/frontend-review-context.js +43 -0
  12. package/dist/workflows/dag/frontend-verification-trace.js +34 -15
  13. package/dist/workflows/dag/governance-profile.js +14 -6
  14. package/dist/workflows/dag/init-hybrid.js +144 -399
  15. package/dist/workflows/dag/types.js +33 -0
  16. package/dist/workflows/dag/validate.js +22 -1
  17. package/docs/README.md +1 -0
  18. package/docs/templates/agent-dag.schema.json +40 -0
  19. package/docs/templates/backend-test-dag.generate-pytest.prompt.md +23 -192
  20. package/docs/templates/backend-test-dag.json +8 -8
  21. package/docs/templates/backend-test-dag.review-cases.prompt.md +22 -75
  22. package/package.json +1 -1
  23. package/skills/frontend-design-review/SKILL.md +5 -3
  24. package/skills/frontend-design-review/references/review-checklist.md +3 -2
  25. package/skills/frontend-implementation/references/design-spec.md +16 -8
  26. package/skills/frontend-implementation/references/node-contracts.md +6 -8
  27. package/skills/frontend-review/SKILL.md +12 -9
  28. package/skills/frontend-review/references/review-findings.md +5 -1
  29. package/skills/frontend-verification/SKILL.md +5 -3
  30. package/skills/frontend-verification/references/verification-checklist.md +3 -2
  31. package/skills/loop-agent/references/hybrid-dag.md +2 -2
@@ -2,14 +2,22 @@
2
2
 
3
3
  ## Required Source Sequence
4
4
 
5
- 1. Attempt the configured component/design knowledge-base query first.
6
- 2. If unavailable, failed, timed out, or unmatched, recursively search the project root's exact `openspec/` directory.
7
- 3. Treat relevant matches as the current project's specification for this run.
8
- 4. Only then use component source, tokens, stories, tests, and pages as non-normative repository fallback.
9
-
10
- Never skip `openspec/` directly to neighboring-code conventions. Report source
11
- conflicts instead of combining them. Explicit task requirements remain the contract;
12
- flag conflicts with knowledge-base or `openspec/` rules.
5
+ Knowledge base and `openspec/` are parallel specification sources:
6
+
7
+ 1. Attempt the configured component/design knowledge-base query first when a
8
+ connector is available in the execution environment.
9
+ 2. Regardless of knowledge-base success, failure, timeout, no match, or no
10
+ configuration, also recursively search the project root's exact `openspec/`
11
+ directory for index files and task-relevant specification content.
12
+ 3. Treat relevant matches from both sources as the current project's
13
+ specification for this run.
14
+ 4. Only then use component source, tokens, stories, tests, and pages as
15
+ non-normative repository fallback.
16
+
17
+ Never skip `openspec/` directly to neighboring-code conventions, even when a
18
+ knowledge-base query returned results. Report source conflicts instead of
19
+ combining them. Explicit task requirements remain the contract; flag conflicts
20
+ with knowledge-base or `openspec/` rules.
13
21
 
14
22
  ## Knowledge Base Connection — TODO
15
23
 
@@ -6,22 +6,20 @@ Pre-write nodes are read-only. Preserve IDs, labels, commands, language, require
6
6
 
7
7
  - **`frontend-contract-pi`**: `Scope`, `Non-goals`, `Acceptance Criteria`, `UI States`, `Target Runtime Environment`, `Risks`, `Verification Expectations`. No guessed requirements.
8
8
  - **`frontend-scout-pi`**: routes, components, tokens, data/API/Mock, scripts, tests, assets. Fact vs inference vs gap. Knowledge base first; else search+read `<repoRoot>/openspec/**` before repo fallback. Output stack, routes, components, styling, conventions, state/data, test entry points, reuse, risks.
9
- - **`frontend-mock-assess-pi` + gate**: declares `firstProtocolLine: "MOCK_STRATEGY:"`; canonical output first line
10
- `MOCK_STRATEGY: native|browser-intercept|request-adapter|not-needed|blocked`
11
- Pi output mapping promotes the first explicitly labeled Mock strategy line ahead of any preamble, including common bullet, quote, inline-code, fullwidth-colon, `Mock strategy`, and split label/value drift, without inventing or replacing its value; missing, unlabeled, malformed, or blocked strategies still fail closed. Prefer native Mock; browser intercept only with existing e2e; request-adapter only for reversible local preview. Default `auto` may select `not-needed` when contract/scout evidence confirms no project Mock capability, without adding Mock files/deps, while keeping real requests default and recording the Real Integration Gap. Other `not-needed` cases need positive no-remote/stable-backend evidence; invalid when `frontendMock.policy=required`. `blocked` for missing/conflicting contracts, unsafe paths/deps, unread specs, production-default-on, unverifiable entrypoints. Output Mock Decision, API/spec/service evidence, backend readiness, selection evidence, endpoint/fixture matrix, activation, targets, production safety, verification plan, real-integration gap, blocking issues. Never invent fields, store secrets, comment real requests, import test mocks into production, or treat Mock as real integration. Gate uses `first-non-empty` only; never authorizes writes. Unsafe required contracts → no writer.
12
- - **`frontend-plan-pi` + conditional design loop**: AC → steps, in-bound files, UI states, reuse, deps, activation/rollback, frozen verify entrypoints, real-integration gap. Initial `VERDICT: pass` uses the original plan directly. Only exact `VERDICT: request-revision` runs read-only plan revision plus final review; there is no `frontend-first-design-gate-shell` or pass-path `PASS_NO_REVISION_NEEDED` node. The effective final gate prefers final review when present, otherwise initial review, and only exact pass authorizes writes; malformed/missing/request-revision fails closed → replan/rerun (not dev-fix). The plan-pi prompt includes the complete `frontend-implementation-contract-v1` JSON Schema loaded from the loop-agent package `docs/templates/` path, plus deterministic source binding, risk level, and allowed implementation targets. The model does not need to search or guess contract fields; `schemaId`, `targetFiles`, `requirementCoverage` are explicitly forbidden.
9
+ - **`frontend-plan-pi` + conditional design loop**: AC → steps, in-bound files, UI states, reuse, deps, Mock/API strategy, activation/rollback, frozen verify entrypoints, real-integration gap, and exactly one `frontend-implementation-contract-v1` JSON object. Prefer native Mock; browser intercept only with existing e2e; request-adapter only for a reversible seam. `auto` may select `not-needed` when no project Mock capability exists, while keeping real requests default and recording the gap; `required` cannot. Initial design pass uses the original plan; only exact `request-revision` runs read-only revision plus final review. Small-risk runs one design review only.
10
+ - **`frontend-prewrite-gate-shell`**: the sole write authorization. Resolve effective plan/review, require exact pass, retain every REQ/BR/AC id, enforce Mock policy, validate schema/source binding, and materialize `contracts/frontend-implementation-contract.json`. Fallback is allowed only when a conditional primary is absent; an existing malformed primary fails closed. Generation-time blocked Mock produces one deterministic blocking shell node and no writer.
13
11
  - **`frontend-implement-pi`**: sole exclusive writer. Stay in `writeSet`; real requests default-on; Mock reversible, dev/test-only, production-off. Atomic handler/intercept/adapter with consumer+tests. Stop on forbidden paths or guesses. Output changed files, behavior, UI states, styling notes, verification attempted, residual risks. Optional mock-verify when frozen; static+behavior always; behavior must prove page consumption. Skipped-Mock `not-needed` keeps real integration pending unless the real backend path has fresh evidence.
14
12
 
15
13
  ## Contract / trace / stages (M1–M2)
16
14
 
17
- - Contract shell: `jsonArtifactGate` → `contracts/frontend-implementation-contract.json` from the effective plan (one fenced JSON or pure JSON); schemaId `frontend-implementation-contract-v1`. Revision is primary and original plan is fallback only when the conditional revision output is absent. Requirement coverage uses the same primary/fallback rule. An existing malformed/schema-invalid/incomplete primary fails closed; fallback never masks it. Final design + implement depend on the artifact; `MOCK_STRATEGY: blocked` not implementable.
18
- - Trace shell: `frontend-verification-trace-gate` binds contract `verificationTargets` to static/behavior records (`commandLabels`, file exists, optional symbol). Assess `MOCK_STRATEGY:` must match `mockApi.strategy` when present. Writes `contracts/frontend-verification-trace.json`. Browser/visual always `not-run`.
15
+ - `frontend-verify-assess-shell` runs Mock/static/behavior command groups, binds contract `verificationTargets` to command labels and file/symbol evidence, then writes `frontend-verification-trace.json` and `frontend-repair-assessment.json`. Browser/visual remain `not-run`.
16
+ - `frontend-review-context-shell` captures the real diff and combines contract, effective trace, repair assessment, and diff into `contracts/frontend-review-context.json`.
19
17
  - Implement stages: (1) contract confirm (2) tests sync (3) component/UI (4) API/Mock (5) frozen checks (6) diff cleanup. Summary: Contract Ref, Changed Files, Requirements, UI States, Tests, Verification Attempts, Deviations, Residual Risks.
20
18
 
21
19
  ## Repair (M3)
22
20
 
23
- static/behavior/trace may `nonZeroExitPolicy: record`. Assess emits pure JSON and writes `contracts/frontend-repair-assessment.json`. Only `eligible=true` runs `frontend-repair-pi` (same writeSet as implement; no re-spec; max 1 attempt), reverify, and retrace. No-failure condition-skips that branch, while diff/review/read-only `frontend-closeout-pi` continue on initial evidence. Repair-contract fails closed on non-repairable (contract/path/dependency/credential/deploy/spec-unclear), writeSet expansion, ERROR, or hard skip; `all-or-condition-skip` never softens those failures.
21
+ Only `eligible=true` runs `frontend-repair-pi` (same writeSet as implement; no re-spec; max 1 attempt) and `frontend-reverify-shell`. No failure condition-skips both. Non-repairable contract/path/dependency/credential/deploy/spec-unclear failures fail closed.
24
22
 
25
23
  ## Risk & capability (M4–M6)
26
24
 
27
- Deterministic risk (no model); high-risk beats small; supervised never small. Small may drop the initial design review + conditional revision branch; its retained final review audits `frontend-plan-pi`, and contract shell retargets to that plan without fallback. Capability seed injects adapters; openspec/task sources outrank. A11y: static/component tools only when present; Browser a11y always not-run.
25
+ Deterministic risk (no model); high-risk beats small; supervised never small. Standard/high-risk contain 15 top-level nodes; small contains 13 by omitting revision and final review. Capability seed injects adapters; openspec/task sources outrank. A11y: static/component tools only when present; Browser a11y always not-run.
@@ -10,14 +10,11 @@ references:
10
10
  # Frontend Review
11
11
 
12
12
  Use for `frontend-review-pi`; read the findings guide first. Required inputs are
13
- original task/reference material, contract/constraints, Mock assessment, original and
14
- revised/confirmed plan, final design verdict, implementation summary, actual diff,
15
- and static/behavior/optional Mock shell evidence. The actual diff is the run-owned
16
- `frontend-worktree-diff-shell` artifacts: `contracts/frontend-worktree-diff.json` and
17
- `artifacts/diff_patch.patch` under the current DAG run directory. When those artifacts
18
- exist, treat them as the authoritative actual diff—do not request revision solely for
19
- "missing diff". Only force revision for a missing actual diff when both artifacts are
20
- absent; never invent a diff from an implementation summary alone.
13
+ original task/reference material, effective plan/design branch, implementation summary,
14
+ and `contracts/frontend-review-context.json`. That canonical context binds the validated
15
+ implementation contract, effective initial-or-post-repair verification trace, repair
16
+ assessment, and run-owned actual diff. Treat its diff as authoritative; never invent a
17
+ diff from an implementation summary alone.
21
18
 
22
19
  ## Verdict Contract
23
20
 
@@ -37,7 +34,13 @@ required check, forbidden write, or unmet acceptance criterion forces revision.
37
34
  and no false real-integration claim. `not-needed` needs applicable real/no-remote
38
35
  evidence, or an explicit default-auto skipped-Mock rationale with the Real
39
36
  Integration Gap preserved when no project Mock capability is confirmed.
40
- - Component/design claims require traceable knowledge-base evidence or, after connection/query failure or no match, relevant `<repoRoot>/openspec/**` evidence. The connector format is TODO; never claim a query or fallback search without evidence. Execute explicit `grep`/`find` to locate spec files and `read` to load them before referencing their rules. Only successful `read` tool calls are observable as "已读取规范文件" in the spec-evidence inspector.
37
+ - Component/design claims require traceable evidence from two parallel sources:
38
+ knowledge base and `<repoRoot>/openspec/**`. Query the knowledge-base connector
39
+ when available; regardless of result, also read `<repoRoot>/openspec/**`.
40
+ The connector format is TODO; never claim a query or fallback search without
41
+ evidence. Execute explicit `grep`/`find` to locate spec files and `read` to
42
+ load them before referencing their rules. Only successful `read` tool calls are
43
+ observable as "已读取规范文件" in the spec-evidence inspector.
41
44
  - Treat shell exit status as authoritative. Do not edit files.
42
45
 
43
46
  ## Evidence And Output
@@ -11,7 +11,11 @@
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
13
  - Failed required static/behavior verification is at least Important unless proven unrelated.
14
- - A knowledge-base claim records connector/query, source ID/version, and retrieval time. If absent, failed, or unmatched, review evidence must show `<repoRoot>/openspec/**` search terms and matched paths/headings; label `openspec fallback`, `repository fallback`, or `unavailable` accurately.
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.
15
19
 
16
20
  ## Review Sequence
17
21
 
@@ -24,9 +24,11 @@ verdict/findings, and required browser, visual, manual, or knowledge evidence.
24
24
  - Mock-backed behavior proves frontend rendering and state transitions only. It never
25
25
  proves backend readiness, transport compatibility, or real API integration.
26
26
  - Unavailable commands remain gaps.
27
- - Resolve design evidence via knowledge base, then `<repoRoot>/openspec/**` after
28
- failure/no match. Its connector format remains TODO; never invent it. An applied
29
- `openspec fallback` is available project evidence.
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.
30
32
  - Separate Mock service/handler checks from page consumption and record the
31
33
  dev/test-only boundary; handler tests alone do not prove page use.
32
34
 
@@ -12,8 +12,9 @@
12
12
 
13
13
  ## Design And Component Evidence
14
14
 
15
- - Claims cite knowledge-base retrieval or `<repoRoot>/openspec/**` fallback.
16
- - Evidence records query/source/time or fallback search terms, paths, headings, and applied rules.
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.
17
18
  - Relevant `openspec/` matches satisfy source availability; missing both sources blocks explicit compliance or required design decisions.
18
19
 
19
20
  ## Status
@@ -16,10 +16,10 @@
16
16
 
17
17
  对于默认 `standard` 任务,生成器根据标题、`source/需求.md` 和结构化 `allowedPaths` 做保守、确定性的需求分类。只有高置信的前端实现需求自动选择 `frontend-implementation` DAG;后端、前后端混合、明确排除前端或证据不足的需求继续使用 governance profile 选出的模板。分类不会把普通后端实现路由到 `backend-test`,也不会替换由显式 profile、`workflowPolicy` 或 supervised quality gate 选中的 supervised 模板。
18
18
 
19
- 前端专用链在 `frontend-scout-pi` 后加入只读 `frontend-mock-assess-pi` 和确定性 contract gate,根据接口契约、后端就绪度、生成期能力 seed 与固化验证入口选择 `native|browser-intercept|request-adapter|not-needed|blocked`。策略直接传给 plan、条件 design review、唯一 writer、实现 review 和 closeout;真实请求保持默认,缺少契约、生产隔离、注释真实请求或显式 required 合同不完整时 gate 阻塞。standard/full 拓扑的 initial design pass 直接使用 original plan,只有 request-revision 才运行 plan revisionfinal review;small-risk 拓扑保留 final review 作为对 original plan 的单一审查。已删除 `frontend-first-design-gate-shell`,保留的 final gate 只接受生效 initial/final verdict pass。可选 `frontendMock` 配置声明 `auto|required|disabled`、既有服务目录与专项命令;默认 `auto` 下没有已确认 Mock 能力时跳过 Mock 继续实现并保留真实联调缺口,不安全或不完整的显式 required 合同只生成无 writer 的评估链,有可信命令时才增加 `frontend-mock-verify-shell`。Mock-backed 证据只证明前端状态;跳过 Mock 且未调用后端时 closeout 报告 `Frontend status: locally-validated` `Real integration: pending`。初始验证后的 assessment 输出 JSON,只有 `eligible=true` 才运行 repair/reverify/retrace;绿色路径跳过该分支后仍继续 diff/review/只读 `frontend-closeout-pi`,non-repairable 或 `ERROR` 仍硬阻断。
19
+ 前端专用链保留独立 contract/scout;plan 同时选择 Mock/API 策略并输出结构化 implementation contractdesign 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 生成并独立 Review `testcase/md/**`,Shell 校验 Case ID、AC/source traceability、章节、步骤、可断言预期与 secret 安全;pytest writer 仅转换最终 Markdown,不重读 `source/**`。traceability 是执行前唯一资产硬门;pytest 只运行一次,生成 JUnit,并从同一 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/**`,Shell 校验 Case ID、AC/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。
23
23
 
24
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` 推断。
25
25