@kontourai/flow-agents 3.6.0 → 3.7.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 (86) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/build/src/builder-flow-run-adapter.d.ts +22 -2
  3. package/build/src/builder-flow-run-adapter.js +93 -28
  4. package/build/src/builder-flow-runtime.d.ts +8 -3
  5. package/build/src/builder-flow-runtime.js +308 -47
  6. package/build/src/cli/assignment-provider.d.ts +4 -7
  7. package/build/src/cli/assignment-provider.js +67 -13
  8. package/build/src/cli/builder-run.js +14 -18
  9. package/build/src/cli/workflow-sidecar.d.ts +28 -4
  10. package/build/src/cli/workflow-sidecar.js +801 -97
  11. package/build/src/cli/workflow.js +290 -42
  12. package/build/src/flow-kit/validate.d.ts +17 -0
  13. package/build/src/flow-kit/validate.js +340 -2
  14. package/build/src/index.js +5 -5
  15. package/build/src/lib/observed-command.d.ts +7 -0
  16. package/build/src/lib/observed-command.js +100 -0
  17. package/build/src/tools/generate-context-map.js +5 -3
  18. package/context/scripts/hooks/lib/kit-catalog.js +1 -1
  19. package/context/scripts/hooks/stop-goal-fit.js +78 -9
  20. package/docs/context-map.md +22 -20
  21. package/docs/developer-architecture.md +1 -1
  22. package/docs/public-workflow-cli.md +76 -7
  23. package/docs/skills-map.md +51 -27
  24. package/docs/spec/builder-flow-runtime.md +41 -40
  25. package/docs/workflow-usage-guide.md +109 -42
  26. package/evals/fixtures/hook-influence/cases.json +2 -2
  27. package/evals/integration/test_builder_entry_enforcement.sh +52 -41
  28. package/evals/integration/test_builder_step_producers.sh +297 -6
  29. package/evals/integration/test_bundle_install.sh +212 -63
  30. package/evals/integration/test_critique_supersession_roundtrip.sh +21 -8
  31. package/evals/integration/test_current_json_per_actor.sh +12 -0
  32. package/evals/integration/test_dual_emit_flow_step.sh +62 -43
  33. package/evals/integration/test_flowdef_session_activation.sh +145 -25
  34. package/evals/integration/test_flowdef_session_history_preservation.sh +23 -21
  35. package/evals/integration/test_gate_lockdown.sh +3 -5
  36. package/evals/integration/test_goal_fit_hook.sh +60 -2
  37. package/evals/integration/test_liveness_verdict.sh +14 -17
  38. package/evals/integration/test_phase_map_and_gate_claim.sh +63 -38
  39. package/evals/integration/test_public_workflow_cli.sh +325 -11
  40. package/evals/integration/test_pull_work_liveness_preflight.sh +22 -66
  41. package/evals/integration/test_sidecar_field_preservation.sh +36 -11
  42. package/evals/integration/test_workflow_sidecar_writer.sh +277 -44
  43. package/evals/integration/test_workflow_steering_hook.sh +15 -38
  44. package/evals/run.sh +2 -0
  45. package/evals/static/test_builder_skill_coherence.sh +247 -0
  46. package/evals/static/test_library_exports.sh +5 -2
  47. package/evals/static/test_workflow_skills.sh +13 -325
  48. package/kits/builder/flows/build.flow.json +22 -0
  49. package/kits/builder/flows/shape.flow.json +9 -9
  50. package/kits/builder/kit.json +70 -16
  51. package/kits/builder/skills/builder-shape/SKILL.md +75 -75
  52. package/kits/builder/skills/continue-work/SKILL.md +45 -106
  53. package/kits/builder/skills/deliver/SKILL.md +96 -442
  54. package/kits/builder/skills/design-probe/SKILL.md +40 -139
  55. package/kits/builder/skills/evidence-gate/SKILL.md +59 -201
  56. package/kits/builder/skills/execute-plan/SKILL.md +54 -125
  57. package/kits/builder/skills/fix-bug/SKILL.md +42 -132
  58. package/kits/builder/skills/gate-review/SKILL.md +60 -211
  59. package/kits/builder/skills/idea-to-backlog/SKILL.md +63 -244
  60. package/kits/builder/skills/learning-review/SKILL.md +63 -170
  61. package/kits/builder/skills/pickup-probe/SKILL.md +54 -111
  62. package/kits/builder/skills/plan-work/SKILL.md +51 -185
  63. package/kits/builder/skills/pull-work/SKILL.md +136 -485
  64. package/kits/builder/skills/release-readiness/SKILL.md +66 -107
  65. package/kits/builder/skills/review-work/SKILL.md +89 -176
  66. package/kits/builder/skills/tdd-workflow/SKILL.md +53 -147
  67. package/kits/builder/skills/verify-work/SKILL.md +101 -113
  68. package/package.json +2 -2
  69. package/scripts/hooks/lib/kit-catalog.js +1 -1
  70. package/scripts/hooks/stop-goal-fit.js +78 -9
  71. package/src/builder-flow-run-adapter.ts +118 -32
  72. package/src/builder-flow-runtime.ts +331 -61
  73. package/src/cli/assignment-provider-lock.test.mjs +83 -0
  74. package/src/cli/assignment-provider.ts +62 -13
  75. package/src/cli/builder-flow-run-adapter.test.mjs +4 -2
  76. package/src/cli/builder-flow-runtime.test.mjs +194 -8
  77. package/src/cli/builder-run.ts +3 -9
  78. package/src/cli/kit-metadata-security.test.mjs +232 -6
  79. package/src/cli/public-api.test.mjs +15 -0
  80. package/src/cli/workflow-sidecar-execution-proof.test.mjs +90 -0
  81. package/src/cli/workflow-sidecar.ts +724 -97
  82. package/src/cli/workflow.ts +277 -40
  83. package/src/flow-kit/validate.ts +320 -2
  84. package/src/index.ts +6 -5
  85. package/src/lib/observed-command.ts +96 -0
  86. package/src/tools/generate-context-map.ts +5 -3
@@ -1,140 +1,69 @@
1
1
  ---
2
2
  name: "execute-plan"
3
- description: "Parallel execution primitive plan artifact path to implemented code via tool-worker (x4). Reads plan directly. Updates session file between waves."
3
+ description: "Execution primitive that turns a structured plan into implemented scope through tool-worker delegation."
4
4
  ---
5
5
 
6
- # Execute
6
+ # Execute Plan
7
7
 
8
- Plan artifact in, implemented code out. Fans out to tool-worker subagents in parallel waves.
8
+ Implement an approved plan while preserving scope, traceability, and recovery context.
9
9
 
10
- ## Agents
10
+ ## Role And Binding
11
11
 
12
- | Agent | Role |
13
- |---|---|
14
- | tool-worker | Implementation per task spec (up to 4 parallel) |
12
+ - **Role:** canonical Builder build-step producer and standalone execution primitive.
13
+ - **Binding:** `builder.build` step `execute`.
14
+ - **Produces:** the active session execution report (`<slug>--deliver.md`), `state.json`, and `implementation-scope` for an active matching run.
15
+ - **Standalone no-run behavior:** execute the supplied plan and return execution evidence. Do not start a Builder run, record Builder evidence, or imply that an inactive Builder flow advanced.
15
16
 
16
17
  ## Model Routing
17
18
 
18
- Worker slices (`tool-worker`) route by task shape: `delegate-implementation` for
19
- precisely-planned implementation (the default), `delegate-mechanical` for
20
- fully-specified mechanical slices (issue sync, doc/scan bookkeeping),
21
- `delegate-design` when a slice genuinely needs design latitude. Resolve the role
22
- from `.datum/config.json` (`npx @kontourai/datum resolve <role> --json`) and pass
23
- the model explicitly. On a review/verify gate failure of a slice, re-dispatch its
24
- fix one tier higher and record the escalation. See
25
- `context/contracts/execution-contract.md` § Delegation: Model Routing (and
26
- § Escalation on gate failure). Fallback: inherit the session model when
27
- datum/config is absent, noted in the artifact.
28
-
29
- ## Orchestrator Rule
30
-
31
- You do not write source files. You read the plan artifact, fan out tasks to tool-worker, and update the session file between waves.
32
-
33
- ## Shared Contracts
34
-
35
- Follow:
36
- - `context/contracts/artifact-contract.md`
37
- - `context/contracts/execution-contract.md`
38
- - `context/contracts/planning-contract.md` for the plan artifact and Definition Of Done
39
- - `context/contracts/sandbox-policy.md`
40
-
41
- This skill owns orchestration between waves. The contracts own artifact continuity, worker task expectations, conflict handling, validation expectations, and completion rules.
42
-
43
- ## Input
44
-
45
- - **Plan artifact path**: path to the `-plan.md` file in `.kontourai/flow-agents/<slug>/`
46
- - **Session file path**: the session file to update with progress
47
-
48
- ## Workflow
49
-
50
- 1. Read the plan artifact directly
51
- 2. Confirm the plan follows `context/contracts/planning-contract.md`, including `## Definition Of Done`. If missing, return to `plan-work` before implementation.
52
- 3. Confirm the plan records an appropriate `sandbox_mode` using `context/contracts/sandbox-policy.md`. If missing, infer the smallest safe mode and record it before delegation.
53
- 4. Confirm execution traceability before any worker starts:
54
- - acceptance criteria have stable ids, preferably matching `acceptance.json`
55
- - every wave/task lists the acceptance ids it supports
56
- - the session/deliver file copies or links the criteria and includes a `Requirements Trace` or equivalent mapping
57
- - each worker prompt includes the relevant acceptance ids and required evidence, not only a loose task title
58
- - if traceability is missing, update the session file and/or send the plan back for refinement before delegation
59
- 5. Set session file `status: executing` and use `npm run workflow:sidecar -- advance-state <artifact-dir> --status in_progress --phase execution --summary ... --next-action ...` when the repository provides it
60
- 6. **Frontend design check:** If any tasks involve UI, CSS, layouts, components, or visual design, read the `frontend-design` skill and include its aesthetics guidelines in the tool-worker prompts for those tasks
61
- 7. **Before fan-out, run the [Pre-Fan-Out Freshness Re-Check](#pre-fan-out-freshness-re-check) and re-ground if the plan is stale.** Then fan out each wave to tool-worker subagents (up to 4 parallel):
62
- - Delegate to the exact `tool-worker` role for every implementation worker. Do not spawn unnamed/default implementation agents.
63
- ```
64
- Each tool-worker gets:
65
- - Task description from plan
66
- - Files to create/modify
67
- - Acceptance criteria
68
- - Acceptance criterion ids and requirement ids this task supports
69
- - Required evidence for those criteria
70
- - Definition Of Done items that this task supports
71
- - Sandbox mode, approval assumptions, rollback expectations, and escalation stop conditions
72
- - Context from plan + prior wave results
73
- - Plan artifact path (so it can read full context directly)
74
- ```
75
- 8. Between waves:
76
- - Collect results from all tool-worker subagents
77
- - Check for conflicts before next wave
78
- - Feed completed wave context forward
79
- - **Checkpoint**: update session file with completed tasks and next wave
80
- - Record worker progress with `npm run workflow:sidecar -- record-agent-event --artifact-dir <artifact-dir> --agent-id <worker-id> --kind evidence --status active|done --summary ...`
81
- 9. After all waves: set session file `status: executed` and update `state.json` / `handoff.json` with `advance-state`
82
- 10. For an active Builder Flow run, record the `implementation-scope` gate claim only after the changed-file scope and acceptance mapping are complete:
83
- ```bash
84
- npm run workflow:sidecar -- record-gate-claim .kontourai/flow-agents/<slug> \
85
- --expectation implementation-scope \
86
- --status pass \
87
- --summary "Implementation completed within the planned scope; changed files and supported acceptance criteria are recorded." \
88
- --evidence-ref-json '{"kind":"artifact","file":".kontourai/flow-agents/<slug>/<slug>--execute-plan.md","summary":"Execution record with changed files, acceptance mapping, and worker evidence."}'
89
- ```
90
- Use `fail` or `not_verified` when scope integrity is unresolved. The sidecar writer synchronizes Flow; it does not declare the execute gate passed itself.
91
-
92
- The orchestrator is responsible for keeping root `state.json` current, and performs that update **exclusively** through `npm run workflow:sidecar -- advance-state` — never through a direct Write/Edit tool call against the sidecar path. `config-protection.js` blocks direct tool-mediated writes to `state.json` by design; that block is expected and correct, not a bug to route around. Workers should receive the workflow artifact root explicitly and append agent events under that root instead of inferring the slug or rewriting shared sidecars.
93
-
94
- ## Pre-Fan-Out Freshness Re-Check
95
-
96
- A plan can go stale between planning and execution — upstream may have advanced, or the plan may simply be old. `plan-work` and `pull-work` stamp and check `planned_base_sha` / `revision_freshness` at planning and pickup; this is the same check at the **execution boundary**, where stale plans actually cause wasted work (parallel workers building what already landed upstream). Run it before any worker starts.
97
-
98
- - **Always — cheap SHA tripwire.** Re-fetch the target ref and compare the current target SHA to the plan's `planned_base_sha` (per `context/contracts/planning-contract.md`). If the base moved **and** the newer commits/files intersect `planning_scope_refs`, the plan is stale: do not fan out. Route back to `plan-work` (or `pickup-probe` for provider-backed work) to re-ground against the current base — the same `revision_freshness: stale` rule plan-work and pull-work already enforce. Missing `planned_base_sha` is not fresh; record a `NOT_VERIFIED` gap and confirm the base before fan-out.
99
- - **On plan age — deeper re-survey.** If the plan is older than the staleness window (default ~1h; shorter for fast-moving scope), do the costlier relook the SHA diff cannot: re-survey what now exists in the target area (recently merged PRs, new modules, sibling work) for anything that already does what this plan proposes. If it already shipped upstream, stop and route back to `plan-work` rather than building a duplicate. The SHA tripwire is the precise signal; plan age is the backstop for landscape drift the diff can't see.
100
- - Record the re-check result (`fresh`, or re-grounded with the compared SHAs and route-back) in the session file before continuing. Worktree/isolation needs stay owned by `pull-work`'s file-overlap decision — don't re-derive them here.
101
-
102
- ## Session File Updates
103
-
104
- Between each wave, append to the session file:
105
-
106
- ```markdown
107
- ## Execution Progress
108
-
109
- ### Wave 1 (completed)
110
- - [x] Task A — done. Supports: AC1, AC2. Evidence: <test/check/artifact>. Modified files: `<path>`.
111
- - [x] Task B — done. Supports: AC3. Evidence: <test/check/artifact>. Modified files: `<path>`.
112
-
113
- ### Wave 2 (in progress)
114
- - [ ] Task C. Supports: AC4, AC5. Required evidence: <test/check/artifact>.
115
- - [ ] Task D. Supports: AC6. Required evidence: <test/check/artifact>.
116
-
117
- ## Requirements Trace
118
-
119
- - R1 <requirement>. Acceptance: AC1, AC2.
120
- - R2 <requirement>. Acceptance: AC3.
121
-
122
- ## Modified Files / Scope
123
-
124
- - Record changed paths in the session/deliver artifact and worker event summaries after each wave.
125
- - Do not add ad hoc `modified_files` keys to `state.json` unless the sidecar schema explicitly supports them.
126
- - Verification and optional governance providers such as Veritas should consume this scope from the session/evidence artifacts or a dedicated evidence sidecar, not from invalid state fields.
127
- ```
19
+ Delegate implementation tasks to `tool-worker`. Select `delegate-mechanical`, `delegate-implementation`, or `delegate-design` according to the planned task, resolving the role from `.datum/config.json` when available. Use parallel workers only when the plan's file ownership and dependencies make concurrent work safe; no fixed worker count is part of this contract.
20
+ Apply the routing and escalation contract in `context/contracts/execution-contract.md`.
21
+
22
+ ## Provider Boundaries
23
+
24
+ Use `RepositoryAdapter` for repository, target revision, worktree, and changed-file context. Carry provider-backed work-item, board, and ownership context from `WorkItemProvider`, `BoardProvider`, and `AssignmentProvider` when present. GitHub is an optional adapter, never a required execution contract.
25
+
26
+ ## Inputs
27
+
28
+ - structured implementation plan and optional host session/artifact location
29
+ - Definition Of Done, stable acceptance criteria, task-to-criterion mapping, and required evidence
30
+ - sandbox/worktree mode, expected modified files, source revision, and conflict risks
128
31
 
129
- This is the recovery point. If context is lost, a new session reads this and knows which waves are done.
32
+ ## Procedure
130
33
 
131
- ## Output
34
+ 1. Read the plan. Return it to `plan-work` when it lacks a Definition Of Done, stable acceptance criteria, task mapping, sandbox boundary, or usable execution scope.
35
+ 2. Before delegation, compare the current target revision with the plan's base through `RepositoryAdapter`. Re-ground the plan when changed scope intersects its assumptions; record missing confirmation as `NOT_VERIFIED` rather than treating it as fresh.
36
+ 3. Give each worker its bounded task, owned files, relevant acceptance IDs, required evidence, sandbox/worktree constraints, rollback conditions, and plan reference.
37
+ 4. Run safe independent tasks concurrently and dependent tasks in order. Between waves, collect results, resolve conflicts, and update the execution record with completed work, remaining work, changed files, and supported acceptance criteria.
38
+ 5. For UI tasks, include the applicable frontend design guidance in the worker instruction.
39
+ 6. When implementation completes, record scope integrity: changed files, accepted deviations, task-to-criterion traceability, evidence, and outstanding gaps. Hand off to report-only review and verification; do not treat implementation as verification.
40
+ 7. Reconcile the execution report and `state.json` with the active session artifact directory.
41
+ Any missing, stale, or unwritable durable record is a blocker or
42
+ `NOT_VERIFIED` gap, not a reason to substitute chat prose. Publish only
43
+ structured, resolving evidence references through the public CLI.
132
44
 
133
- - Implemented code in the working directory
134
- - Session file updated with execution progress and `status: executed`
135
- - Execution progress follows `context/contracts/execution-contract.md`
136
- - Structured state/handoff sidecars advanced when `npm run workflow:sidecar --` is available
45
+ ## Execution Record
137
46
 
138
- If `advance-state` or artifact validation is unavailable or blocked, record that exact blocker in the session file and do not mark execution as cleanly complete.
47
+ The execution record must identify:
48
+
49
+ - each completed task and its supported `AC*` identifiers
50
+ - changed files and any scope deviation with approval or route-back reason
51
+ - worker evidence, conflicts, rollback notes, remaining work, and next action
52
+ - current revision comparison and re-grounding decision
53
+
54
+ ## Active Builder Evidence
55
+
56
+ For an active `builder.build` `execute` step, record `implementation-scope` only after the changed-file scope and acceptance mapping are complete:
57
+
58
+ ```bash
59
+ flow-agents workflow status --session-dir <session-dir>
60
+ flow-agents workflow evidence --session-dir <session-dir> \
61
+ --expectation implementation-scope --status pass \
62
+ --summary "Implementation stayed within recorded scope; changed files and supported acceptance criteria are documented." \
63
+ --evidence-ref-json '{"kind":"artifact","file":"<session-dir>/<slug>--deliver.md","summary":"Execution report with changed scope and acceptance mapping."}' \
64
+ --evidence-ref-json '{"kind":"artifact","file":"<session-dir>/state.json","summary":"Current execution state and canonical next action."}'
65
+ ```
139
66
 
140
- {context?}
67
+ Use `fail` or `not_verified` when scope integrity is unresolved. A successful
68
+ worker report does not override missing changed-file or acceptance mappings. Do
69
+ not create a Builder run here or use private writer commands.
@@ -1,152 +1,62 @@
1
1
  ---
2
2
  name: "fix-bug"
3
- description: "Bug fix orchestrator diagnose plan-work execute-plan → review-work verify-work loop. Diagnosis phase is unique to bugs, then chains the same primitives."
3
+ description: "Bug-fix profile for builder.build. Adds disciplined diagnosis and regression-focused verification without replacing the build primitives."
4
4
  ---
5
5
 
6
- # Bug Fix
6
+ # Fix Bug
7
7
 
8
- Diagnose a bug, then chain the same plan → execute → verify loop. The diagnosis phase is what makes this different from deliver.
8
+ ## Role and Boundary
9
9
 
10
- ## Agents
10
+ **Role:** `builder.build` profile for a reported defect.
11
11
 
12
- Inherited from primitives + diagnosis:
12
+ Select this profile when a Work Item is a bug report, regression, error, or
13
+ observable incorrect behavior. It supplies diagnosis context to the standard
14
+ build primitives; it is not a separate flow or a generic delivery entrypoint.
13
15
 
14
- | Agent | Used by |
15
- |---|---|
16
- | tool-planner | diagnosis + plan-work |
17
- | tool-worker (x4) | execute-plan |
18
- | tool-code-reviewer | review-work |
19
- | tool-security-reviewer | review-work (conditional — security-sensitive changes) |
20
- | tool-verifier | verify-work |
21
- | tool-playwright | diagnosis (reproduce) + verify-work |
16
+ The profile owns **no step-gate evidence**. `pull-work`, `design-probe`,
17
+ `plan-work`, `execute-plan`, `review-work`, and `verify-work` retain ownership
18
+ of their artifacts and evidence.
22
19
 
23
20
  ## Model Routing
24
21
 
25
- Delegates are spawned with an explicit model override resolved from
26
- `.datum/config.json` via `npx @kontourai/datum resolve <role> --json` see
27
- `context/contracts/execution-contract.md` § Delegation: Model Routing:
22
+ Use `delegate-mechanical` for reproduction bookkeeping, `delegate-design` for
23
+ hypothesis and fix planning, and `delegate-implementation` for implementation,
24
+ review, and verification. Resolve roles from `.datum/config.json` under
25
+ `context/contracts/execution-contract.md` and record fallbacks or escalations.
28
26
 
29
- | Delegate | Role |
30
- |---|---|
31
- | tool-worker | `delegate-mechanical` for fully-specified mechanical slices, `delegate-implementation` for precisely-planned implementation, `delegate-design` when a slice needs design latitude |
32
- | tool-planner | `delegate-design` |
33
- | tool-code-reviewer / tool-security-reviewer | `delegate-implementation` by default, raised to the worker's tier when higher — never below the tier of the checked work (Goodhart guard) |
34
- | tool-verifier / tool-playwright | `delegate-implementation` by default, raised to the worker's tier when higher — never below the tier of the checked work (Goodhart guard) |
27
+ ## Inputs and Provider Adapters
35
28
 
36
- On a review/verify gate failure, re-dispatch the fix one tier higher and record
37
- the escalation (contract § Escalation on gate failure). Fallback: inherit the
38
- session model when datum/config is absent, noted in the artifact.
29
+ Capture the original report, reproduction steps, logs, screenshots, affected
30
+ Repository adapter, and relevant Change-adapter history. The Work Item adapter
31
+ holds the defect scope and acceptance criteria. A GitHub issue is an optional
32
+ Work Item example, not a prerequisite.
39
33
 
40
- ## Orchestrator Rule
34
+ ## Profile Behavior
41
35
 
42
- You never use `read`, `glob`, `grep`, or `code` on source files. All codebase analysis goes through tool-planner. All review goes through review-work. All verification goes through tool-verifier or tool-playwright.
36
+ 1. Select `builder.build` through the `deliver` entrypoint, with this profile
37
+ recorded as `fix-bug` in the planning context.
38
+ 2. Reproduce the behavior when feasible and distinguish confirmed observations
39
+ from unverified reports.
40
+ 3. Ask the planning primitive to identify a root-cause hypothesis, minimal fix
41
+ scope, affected tests, and regression risks before implementation.
42
+ 4. Require the execution and verification primitives to prove both that the
43
+ reported behavior is corrected and that relevant existing behavior still
44
+ works.
45
+ 5. Route a failed or inconclusive result back to the primitive best able to
46
+ resolve it; do not silently convert an unverified diagnosis into a fix.
43
47
 
44
- ## Input
48
+ Keep investigation proportionate to the report. A missing reproduction is a
49
+ recorded uncertainty, not a reason to fabricate certainty.
45
50
 
46
- - **Bug report**: screenshot, error log, user description, or all three
47
- - **Directory**: working directory
51
+ ## Output Responsibility
48
52
 
49
- ## Session File
53
+ This profile creates no independent artifact or evidence. Its output is
54
+ diagnostic and regression context carried into the standard primitive artifacts
55
+ and final delivery report.
50
56
 
51
- Filename: `<branch>--fix-bug-<slug>.md`
57
+ ## Standalone and No-Active-Run Behavior
52
58
 
53
- ```markdown
54
- # BUG: <one-liner>
55
-
56
- branch: <branch>
57
- worktree: <worktree>
58
- created: <date>
59
- status: diagnosing | planning | fixing | verifying | resolved
60
- type: fix-bug
61
- iteration: 0
62
-
63
- ## Bug Report
64
-
65
- Source: screenshot | error log | user description
66
- <original report, pasted verbatim>
67
-
68
- ## Diagnosis
69
-
70
- Root cause from tool-planner.
71
-
72
- ## Plan
73
-
74
- (populated by plan-work)
75
-
76
- ## Execution Progress
77
-
78
- (populated by execute-plan)
79
-
80
- ## Verification Report
81
-
82
- (populated by verify-work)
83
-
84
- ## History
85
-
86
- - iteration 1: partial — fix applied but regression in sidebar
87
- - iteration 2: pass — bug fixed, no regressions
88
- ```
89
-
90
- `<branch>` is the branch recorded in `state.json`'s `branch` field (`ensure-session` derives `agent/<actor>/<slug>`; an explicit `--branch` flag overrides on a new session). `ensure-session` only records the name — creating and checking out the actual git branch/worktree remains this skill's responsibility.
91
-
92
- ## Workflow
93
-
94
- ### 1. Create session file
95
-
96
- Paste the bug report verbatim. Set `status: diagnosing`.
97
-
98
- ### 2. Diagnose (unique to bugs)
99
-
100
- 1. **Reproduce** (if visual) — delegate to tool-playwright to confirm the bug is visible. Screenshot the broken state.
101
- 2. **Find root cause** — delegate to tool-planner:
102
- ```
103
- Bug: <description>
104
- Reproduction: <steps or screenshot evidence>
105
- Directory: <working directory>
106
- todo_file: <session file path>
107
- Find the root cause and propose a fix plan.
108
- ```
109
- 3. Read the diagnosis from tool-planner's output
110
- 4. Paste into session file `## Diagnosis`
111
- 5. Present to user: "Here's what's broken and how I'd fix it. Agree?"
112
- 6. On approval → proceed to plan
113
-
114
- ### 3. Plan (plan-work)
115
-
116
- Invoke plan-work with: diagnosis + fix goal, directory, session file path.
117
-
118
- ### 4. Execute (execute-plan)
119
-
120
- Invoke execute-plan with the plan artifact path and session file path.
121
-
122
- ### 5. Review (review-work)
123
-
124
- Invoke `review-work` with the session file path. It must delegate to `tool-code-reviewer`, and to `tool-security-reviewer` when security triggers are present. CRITICAL/HIGH findings block and loop back to Execute unless explicitly accepted.
125
-
126
- ### 6. Verify (verify-work)
127
-
128
- Invoke verify-work with the session file path. tool-verifier must verify:
129
- 1. **Bug is fixed** — the specific issue from the report
130
- 2. **No regressions** — build passes, existing tests pass, related functionality works
131
-
132
- ### 7. Route on verdict
133
-
134
- - **All PASS** → resolve
135
- - **Any FAIL** → loop
136
- - **Any NOT_VERIFIED** → surface to user
137
-
138
- ### 8. Loop (on failure)
139
-
140
- 1. Summarize what failed
141
- 2. Increment `iteration`
142
- 3. Re-invoke plan-work with: original diagnosis + failure summary → updated fix plan
143
- 4. Back to step 4
144
-
145
- ### 9. Resolve
146
-
147
- 1. Include verification report verbatim
148
- 2. Show before/after evidence (screenshots if visual)
149
- 3. `git diff --stat`
150
- 4. Set `status: resolved`
151
-
152
- {context?}
59
+ `fix-bug` does not start or resume a run itself. With no active run, return the
60
+ captured bug context and route to `deliver` to select and start `builder.build`.
61
+ With an active run, apply the profile only when its Work Item matches the
62
+ reported defect; otherwise stop and ask for the intended Work Item.