@tea-agent/loop-agent 0.12.0 → 0.13.0-alpha.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 (79) hide show
  1. package/CHANGELOG.md +50 -2
  2. package/README.md +30 -2
  3. package/dist/application/dag/generate-task-dag.js +30 -0
  4. package/dist/cli/command-definitions.js +10 -3
  5. package/dist/commands/knowledge.js +129 -31
  6. package/dist/governance/manifest-types.js +3 -0
  7. package/dist/task/config-types.js +5 -1
  8. package/dist/worker/cli.js +96 -1
  9. package/dist/worker/delivery/package.js +3 -3
  10. package/dist/worker/feature/decision-loader.js +37 -6
  11. package/dist/worker/feature/next-action.js +10 -2
  12. package/dist/worker/feature/ready-plan-projection.js +81 -0
  13. package/dist/worker/feature/reducer.js +2 -1
  14. package/dist/worker/feature/review.js +19 -2
  15. package/dist/worker/feature/run.js +27 -2
  16. package/dist/worker/follow-up/approve.js +5 -2
  17. package/dist/worker/follow-up/factory.js +1 -1
  18. package/dist/worker/observability/read-model.js +246 -41
  19. package/dist/worker/observe/routes.js +158 -15
  20. package/dist/worker/observe/spec-evidence.js +281 -0
  21. package/dist/worker/observe/static/api.js +19 -0
  22. package/dist/worker/observe/static/app.js +2 -2
  23. package/dist/worker/observe/static/relations.js +17 -12
  24. package/dist/worker/observe/static/router.js +8 -0
  25. package/dist/worker/observe/static/styles.css +12 -0
  26. package/dist/worker/observe/static/views/batch.js +3 -2
  27. package/dist/worker/observe/static/views/dag-inspector.js +123 -4
  28. package/dist/worker/observe/static/views/dashboard.js +8 -5
  29. package/dist/worker/observe/static/views/feature.js +43 -4
  30. package/dist/worker/observe/static/views/pool.js +5 -2
  31. package/dist/worker/observe/static/views/run.js +1 -1
  32. package/dist/worker/observe/static/views/task.js +69 -15
  33. package/dist/worker/pool/doctor.js +165 -0
  34. package/dist/worker/pool/migrate-state.js +303 -0
  35. package/dist/worker/pool/run-store.js +205 -17
  36. package/dist/worker/pool/types.js +17 -1
  37. package/dist/worker/pool/validation.js +100 -15
  38. package/dist/worker/report/morning-report.js +12 -2
  39. package/dist/worker/runner/run-ready.js +41 -26
  40. package/dist/worker/task-graph/ready-planner.js +136 -0
  41. package/dist/workflows/dag/convergence/controller.js +16 -8
  42. package/dist/workflows/dag/failure-routing.js +12 -1
  43. package/dist/workflows/dag/init-hybrid.js +837 -8
  44. package/dist/workflows/dag/types.js +1 -0
  45. package/docs/README.md +1 -1
  46. package/docs/agent-dag-recovery-playbook.md +9 -0
  47. package/docs/architecture/evolution.md +4 -3
  48. package/docs/architecture/facts-and-state.md +14 -1
  49. package/docs/architecture/worker-and-feature.md +6 -2
  50. package/docs/decisions/README.md +3 -0
  51. package/docs/design/README.md +8 -0
  52. package/docs/exec-plans/active/README.md +2 -0
  53. package/docs/exec-plans/completed/README.md +3 -2
  54. package/docs/feature-workflow.md +80 -2
  55. package/docs/loop-agent-harness.md +15 -4
  56. package/docs/progress/README.md +4 -0
  57. package/docs/reports/README.md +6 -0
  58. package/docs/templates/backend-test-dag.json +12 -0
  59. package/docs/templates/knowledge-graph-bootstrap-dag.json +118 -0
  60. package/docs/templates/knowledge-sync-dag.json +177 -0
  61. package/docs/templates/knowledge-sync-draft.schema.json +71 -0
  62. package/docs/verification-matrix.md +2 -1
  63. package/package.json +8 -2
  64. package/scripts/kb-bootstrap-init-skeleton.sh +239 -0
  65. package/scripts/kb-graph-incremental-prepare.mjs +372 -0
  66. package/scripts/kb-graph-incremental-prepare.sh +5 -0
  67. package/scripts/kb-graph-materialize.mjs +105 -0
  68. package/scripts/kb-graph-materialize.sh +4 -0
  69. package/scripts/kb-graph-promote.mjs +153 -0
  70. package/scripts/kb-graph-promote.sh +4 -0
  71. package/scripts/kb-query.mjs +554 -0
  72. package/scripts/kb-query.sh +5 -0
  73. package/skills/agent-worker/SKILL.md +3 -1
  74. package/skills/agent-worker/references/agent-worker-operator.md +18 -1
  75. package/skills/frontend-design-review/SKILL.md +26 -24
  76. package/skills/frontend-implementation/SKILL.md +29 -26
  77. package/skills/frontend-implementation/references/node-contracts.md +50 -19
  78. package/skills/frontend-review/SKILL.md +1 -1
  79. package/skills/loop-agent/references/command-reference.md +1 -0
@@ -3,9 +3,9 @@ name: frontend-implementation
3
3
  description: >-
4
4
  Use for frontend contract, scout, plan, and implementation DAG nodes.
5
5
  references:
6
- - path: references/node-contracts.md
7
- required: true
8
- maxChars: 3000
6
+ - path: references/node-contracts.md
7
+ required: true
8
+ maxChars: 3200
9
9
  - path: references/design-spec.md
10
10
  required: true
11
11
  maxChars: 3000
@@ -16,36 +16,39 @@ references:
16
16
 
17
17
  # Frontend Implementation
18
18
 
19
- Use for `frontend-contract-pi`, `frontend-scout-pi`, `frontend-plan-pi`, and
20
- `frontend-implement-pi`. Read every required reference before acting.
19
+ For `frontend-contract-pi`, `frontend-scout-pi`, `frontend-plan-pi`, and
20
+ `frontend-implement-pi`. Read all required references first.
21
21
 
22
22
  ## Source And Evidence Rules
23
23
 
24
- Use task source and references first, then constraints and `task.json`. Resolve
25
- component/design rules by the required sequence in `design-spec.md`: connect/query
26
- the knowledge base first; when it is not configured, connection/query fails, or no
27
- relevant result exists, search `<repoRoot>/openSpec/**` and treat matching rules as
28
- the current project's specification. Use other repository evidence only afterward.
24
+ Use task sources/references, constraints, then `task.json`. Resolve design rules in
25
+ `design-spec.md` order: query the knowledge base; if unavailable, failed, or empty,
26
+ search `<repoRoot>/openSpec/**`; only then use other repository evidence.
27
+
28
+ - Cite paths/symbols or tight lines; label assumptions, questions, and missing evidence.
29
+ - Never invent conventions, APIs, tokens, commands, or knowledge-base results.
30
+ - Record `knowledge-base`, `openSpec fallback`, `repository fallback`, or `unavailable`, plus evidence/conflicts.
31
+
32
+ ### Observable Spec Retrieval
29
33
 
30
- - Cite repository findings with paths and symbols or tight line ranges.
31
- - Label assumptions, unresolved questions, and unavailable evidence.
32
- - Never invent conventions, component APIs, tokens, commands, or knowledge-base results.
33
- - Record the selected source as `knowledge-base`, `openSpec fallback`, `repository fallback`, or `unavailable`, with evidence and conflicts.
34
+ Scout/planner nodes must `grep`/`find` relevant `openSpec/**` and skill references,
35
+ then explicitly `read` every consulted spec (`SKILL.md`, `design-spec.md`,
36
+ `code-standards.md`, etc.). Observe derives evidence from session tool events: only
37
+ successful paired `read` calls count as “已读取规范文件”; summaries do not. If the
38
+ knowledge base is unavailable, record `openSpec/**` search hits before repo fallback.
34
39
 
35
40
  ## Implementation Discipline
36
41
 
37
- - Treat explicit project specs and repo-local skills as authoritative within their stated scope.
38
- - Reuse confirmed components, tokens, helpers, APIs, mocks, schemas, and test patterns.
39
- - Do not add dependencies unless the task allows them and the approved plan justifies them.
40
- - Cover applicable success, error, loading, empty, disabled, permission, and boundary states; mark non-applicable states with reasons.
41
- - Keep state and validation logic testable where project conventions support it.
42
- - Writer nodes stay inside `writeSet`, preserve unrelated behavior, and update tests with behavior.
43
- - Never relax lint/type/test/build configuration or write unauthorized generated output.
42
+ - Project specs and repo-local skills are authoritative within scope.
43
+ - Reuse confirmed components, tokens, helpers, APIs, mocks, schemas, and tests.
44
+ - Add dependencies only when task and approved plan allow them.
45
+ - Cover success/error/loading/empty/disabled/permission/boundary states; justify N/A.
46
+ - Keep state/validation testable. Writers stay in `writeSet`, preserve unrelated behavior, and update tests.
47
+ - Never relax lint/type/test/build config or write unauthorized generated output.
44
48
 
45
49
  ## Output And Failure Rules
46
50
 
47
- - Follow the node-specific headings in `node-contracts.md` exactly.
48
- - Read-only nodes return Markdown and never edit repository files.
49
- - Missing input blocks a node when proceeding would guess behavior, design compliance, write boundaries, or verification.
50
- - Keep protocol tokens, commands, paths, identifiers, and configured output language unchanged.
51
- - Implementation may report attempted checks, but completion requires fresh downstream shell evidence.
51
+ - Follow `node-contracts.md` headings exactly. Read-only nodes return Markdown and never edit files.
52
+ - Missing input blocks work when proceeding would guess behavior, compliance, write bounds, or verification.
53
+ - Preserve protocol tokens, commands, paths, identifiers, and output language.
54
+ - Attempted checks may be reported; completion needs fresh downstream shell evidence.
@@ -1,32 +1,63 @@
1
1
  # Frontend Node Contracts
2
2
 
3
+ Pre-implementation nodes are read-only. Preserve IDs, protocol tokens, source
4
+ labels, language, and named output headings.
5
+
3
6
  ## `frontend-contract-pi`
4
7
 
5
- - Read task source, constraints, `task.json`, and explicit references; do not edit.
6
- - Define scope, non-goals, routes/components, runtime, user flows, acceptance criteria, states, risks, and verification expectations.
7
- - Preserve requirement IDs and language; never turn an implementation guess into a requirement.
8
- - For every standard UI state, specify behavior or mark it not applicable with a reason.
9
- - Output: `Scope`, `Non-goals`, `Acceptance Criteria`, `UI States`, `Target Runtime Environment`, `Risks`, `Verification Expectations`.
8
+ Read task sources, constraints, config, and references. Define scope, non-goals,
9
+ routes/components, runtime, flows, criteria, states, risks, and verification. Never
10
+ turn a guess into a requirement. Output: `Scope`,
11
+ `Non-goals`, `Acceptance Criteria`, `UI States`, `Target Runtime Environment`,
12
+ `Risks`, `Verification Expectations`.
10
13
 
11
14
  ## `frontend-scout-pi`
12
15
 
13
- - Inspect routes, pages, components, styles/tokens, state/data flow, API/mocks, scripts, tests, and reusable assets; do not edit.
14
- - Separate confirmed facts, inferred conventions, and missing information.
15
- - Attempt knowledge-base first. If absent, failed, or unmatched, recursively inspect `<repoRoot>/openSpec/**` before other repo conventions.
16
- - Record source as `knowledge-base`, `openSpec fallback`, `repository fallback`, or `unavailable`, with query/search terms and matched paths.
17
- - Output: `Frontend Stack`, `Routes`, `Components`, `Styling System`, `Existing Design Conventions`, `State / Data Flow`, `Test Entry Points`, `Reuse Opportunities`, `Risks`.
16
+ Inspect routes, components, styles/tokens, state/data, APIs/mocks, scripts, tests,
17
+ and assets. Separate facts, inferences, and gaps. Query knowledge-base;
18
+ if absent/failed/unmatched, search and read `<repoRoot>/openSpec/**` before repo
19
+ conventions. Record source, query/terms, and paths. Output: `Frontend Stack`,
20
+ `Routes`, `Components`, `Styling System`, `Existing Design Conventions`,
21
+ `State / Data Flow`, `Test Entry Points`, `Reuse Opportunities`, `Risks`.
18
22
 
19
23
  ## `frontend-plan-pi`
20
24
 
21
- - Map every acceptance criterion to ordered implementation and verification steps.
22
- - Name target files and reasons; keep them within allowed paths and expected `writeSet`.
23
- - Define states, component/styling reuse, interaction behavior, dependency policy, and exact static/behavior commands.
24
- - Knowledge-base failure is not approval: apply relevant `openSpec/` matches as current-project rules. Request clarification only when neither source resolves required compliance or they conflict materially.
25
- - Output: `Implementation Steps`, `Target Files`, `UI State Handling`, `Styling / Component Strategy`, `Interaction Notes`, `Dependency Policy`, `Verification Plan`, `Residual Risks`.
25
+ Map each criterion to implementation and verification. Name in-bound files; define
26
+ states, reuse, interactions, dependencies, and commands. Apply `openSpec/` rules
27
+ when knowledge-base fails; ask only for material conflicts. Output: `Implementation Steps`, `Target
28
+ Files`, `UI State Handling`, `Styling / Component Strategy`, `Interaction Notes`,
29
+ `Dependency Policy`, `Verification Plan`, `Residual Risks`.
30
+
31
+ ## First design protocol gate
32
+
33
+ `frontend-first-design-gate-shell` reads `frontend-design-gate-pi`'s first
34
+ non-empty line. It accepts only `VERDICT: pass` or `VERDICT: request-revision` and
35
+ blocks malformed output. It never authorizes writes; request-revision enters plan
36
+ revision. Line mode: `first-verdict-line`.
37
+
38
+ ## `frontend-plan-revision-pi`
39
+
40
+ Consume the original plan and first review findings. On first-gate pass, output
41
+ `PASS_NO_REVISION_NEEDED`; on request-revision, address every Required Plan
42
+ Correction in a complete plan with the plan headings above. Always `read-only`;
43
+ never edit code, docs, or artifacts.
44
+
45
+ ## Final design review and gate
46
+
47
+ `frontend-final-design-review-pi` rechecks the original plan for
48
+ `PASS_NO_REVISION_NEEDED`, otherwise verifies every correction and rejects any
49
+ remaining/new gap. Its first non-empty line is exactly `VERDICT: pass` or
50
+ `VERDICT: request-revision`.
51
+
52
+ `frontend-final-design-gate-shell` reads that verdict and accepts only
53
+ `VERDICT: pass`. It is the sole write authorization. Failure routes to
54
+ `ContractMismatch` / `frontend-plan-revision-and-rerun`, never `ProductBug` /
55
+ `dev-fix`. Line mode: `first-verdict-line`.
26
56
 
27
57
  ## `frontend-implement-pi`
28
58
 
29
- - Run only after design gate pass and implement only the approved plan inside `writeSet`.
30
- - Re-read current files; stop instead of crossing forbidden paths or guessing a blocking decision.
31
- - Reuse confirmed project primitives and update tests. Do not claim knowledge-base or downstream verification without evidence.
32
- - Output: `Changed Files`, `Implemented Behavior`, `UI States Covered`, `Styling / Component Notes`, `Verification Attempted`, `Residual Risks`.
59
+ Depends directly on final gate, revision plan, and final review. After pass, re-read
60
+ current files and implement only the approved plan inside `writeSet`; stop on
61
+ forbidden paths or blocking guesses. Reuse primitives and update tests. Output:
62
+ `Changed Files`, `Implemented Behavior`, `UI States Covered`, `Styling / Component
63
+ Notes`, `Verification Attempted`, `Residual Risks`.
@@ -25,7 +25,7 @@ required check, forbidden write, or unmet acceptance criterion forces revision.
25
25
  - Inspect every changed file against allowed, forbidden, and approved write scope.
26
26
  - Map criteria to behavior, applicable UI states, tests, and shell evidence.
27
27
  - Review state/data flow, validation, async/error behavior, components/design, responsive behavior, accessibility, dependencies, maintenance, and regression risk when applicable.
28
- - 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.
28
+ - 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.
29
29
  - Treat shell exit status as authoritative. Do not edit files.
30
30
 
31
31
  ## Evidence And Output
@@ -392,6 +392,7 @@ agent-worker report metrics --repo <repo-root> --month <YYYY-MM> [--json]
392
392
  agent-worker task draft-followup <task-id> --worker-run-id <id> --feature-dir <feature-dir> --repo <repo-root> [--json]
393
393
  agent-worker feature approve-followup --feature-dir <feature-dir> --followup-id <id> --repo <repo-root> --owner <owner> [--dry-run] [--json]
394
394
  agent-worker task retry <task-id> --repo <repo-root> [--reason "<已修复的原因>"]
395
+ agent-worker batch plan-ready --feature-dir <feature-dir> --repo <repo-root> [--limit <count>] [--json]
395
396
  agent-worker batch run-ready \
396
397
  --feature-dir <feature-dir> \ # 含 tasks/task-graph.yaml
397
398
  --repo <repo-root> \ # 目标 repo