opencode-plugin-flow 4.3.9 → 4.4.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.
package/dist/index.js CHANGED
@@ -2,14 +2,18 @@
2
2
  var handoff_format_default = `# Flow worker handoff contract
3
3
 
4
4
  Flow managers merge only the worker's final response. Treat that response as the
5
- worker report of record: it must include the assigned scope, what was actually
6
- covered, the evidence for each useful claim, and the remaining gaps. End worker
7
- prompts with "Return only this Flow handoff."
8
-
9
- Empty or unstructured worker output is a failed handoff. If the worker cannot
10
- cover the assigned scope, verify the evidence, or satisfy the handoff shape, it
11
- must return \`Status: blocked\` with the missing elements, and the manager must
12
- not treat the slice as complete.
5
+ worker report of record. End worker prompts with "Return only this Flow
6
+ handoff."
7
+
8
+ <!-- flow-prompt:worker-integrity:start -->
9
+ Cite or drop every claim. Label single-source, inferred, and unsettled claims.
10
+ When usable evidence exists but named expected coverage could not be checked,
11
+ return the required handoff with \`## Status\` set to \`partial\` and enumerate the
12
+ unchecked items and reasons. If the assignment or required shape is missing,
13
+ or no usable coverage can be produced, return the required handoff with
14
+ \`## Status\` set to \`blocked\` and name the missing elements. Empty or
15
+ unstructured output is a failed handoff.
16
+ <!-- flow-prompt:worker-integrity:end -->
13
17
 
14
18
  Sections: evidence/review/validation/audit worker report, verifier worker report,
15
19
  and candidate implementation worker report.
@@ -25,154 +29,143 @@ Status meanings:
25
29
 
26
30
  ## Evidence, review, validation, or audit worker report
27
31
 
28
- Use this for \`flow-evidence-worker\`, \`flow-reviewer\`,
29
- \`flow-validation-worker\`, and \`flow-audit-worker\`.
32
+ Use the one role-specific block that matches the assigned worker.
30
33
 
31
- \`\`\`markdown
34
+ <!-- flow-prompt:handoff-evidence:start -->
35
+ Return only this Flow handoff:
32
36
  ## Status
33
37
  success | partial | blocked
34
-
35
38
  ## Scope
36
- <owned slice: path set, module, command, risk lens, route, data range, or question set>
37
-
39
+ assigned slice
38
40
  ## Pass metadata
39
- - Pass id: <stable pass id from the manifest>
40
- - Manifest row id: <row id from the manifest>
41
- - Depends on: <upstream row ids or "none">
42
- - Write scope: <none | manager-serial | exact-path | isolated-worktree | mixed>
43
-
41
+ pass id, manifest row id, dependencies, write scope
44
42
  ## Coverage
45
- - Expected: <files, ranges, questions, commands, or findings assigned>
46
- - Checked: <actual coverage, for example "12/12 files" or "command not run">
47
- - Not checked: <items skipped with reason, or "none">
48
-
43
+ expected, checked, not checked with reasons
49
44
  ## Findings or facts
50
- - [high|med|low] <claim>; evidence: <file:line | command summary | screenshot path | URL | metric>; corroboration: <N sources or "single source">
51
- - [high|med|low] <claim>; evidence: <...>; corroboration: <...>
52
-
45
+ confidence, atomic claim, citation, corroboration
53
46
  ## Sources
54
- - <paths read, commands run, docs fetched, data ranges covered, screenshots inspected>
55
-
47
+ paths, commands, documents, screenshots, or data ranges inspected
56
48
  ## Confidence and verification
57
- - Verified: <claims directly re-run, recounted, traced, or cross-checked>
58
- - Single-source: <claims with exactly one supporting source>
59
- - Inferred: <claims derived from surrounding evidence rather than directly observed>
60
- - Unsettled: <claims, sources, or citations that could not be resolved>
61
- - Falsifier or missing input: <what would overturn or materially change the result>
62
-
49
+ verified, single-source, inferred, unsettled, falsifier
63
50
  ## Open questions / gaps
64
- - <ambiguity, missing source, contradiction, skipped item, or out-of-scope dependency>
65
-
66
51
  ## Manager follow-ups
67
- - <concrete next tasks, verifier claims, validation commands, or Flow plan targets>
68
- \`\`\`
52
+ <!-- flow-prompt:handoff-evidence:end -->
69
53
 
70
- Validation workers must include exact command names and raw outcome summaries
71
- for commands they actually ran. Audit workers must include guards checked for
72
- any blocking-severity candidate. Review workers must separate blocking findings
73
- from advisory notes. In the shared \`Findings or facts\` section, review workers
74
- should prefix review items with \`blocking:\` or \`advisory:\` before the claim.
54
+ <!-- flow-prompt:handoff-validation:start -->
55
+ Return only this Flow handoff:
56
+ ## Status
57
+ success | partial | blocked
58
+ ## Scope
59
+ assigned checks or validation question
60
+ ## Pass metadata
61
+ pass id, manifest row id, dependencies, write scope
62
+ ## Coverage
63
+ expected, checked, not checked with reasons
64
+ ## Commands and outcomes
65
+ exact command, status, raw outcome summary, behavior covered
66
+ ## Confidence and verification
67
+ verified, single-source, inferred, unsettled, falsifier
68
+ ## Open questions / gaps
69
+ ## Manager follow-ups
70
+ <!-- flow-prompt:handoff-validation:end -->
75
71
 
76
- Example evidence quality:
72
+ <!-- flow-prompt:handoff-audit:start -->
73
+ Return only this Flow handoff:
74
+ ## Status
75
+ success | partial | blocked
76
+ ## Scope
77
+ assigned paths, risks, or candidate findings
78
+ ## Pass metadata
79
+ pass id, manifest row id, dependencies, write scope
80
+ ## Coverage
81
+ expected, checked, not checked with reasons
82
+ ## Findings
83
+ severity, atomic claim, citation, corroboration, guards checked, refutation result
84
+ ## Sources
85
+ ## Confidence and verification
86
+ verified, single-source, inferred, unsettled, falsifier
87
+ ## Open questions / gaps
88
+ ## Manager follow-ups
89
+ <!-- flow-prompt:handoff-audit:end -->
77
90
 
78
- - Good fact: \`[high] public Flow command prompts include bundled instructions;
79
- evidence: src/config-shared.ts:135; corroboration: single source\`.
80
- - Weak fact: \`[high] prompts look self-contained; evidence: read the config\`.
81
- - Good validation: \`bun test tests/distribution-and-surface.test.ts\`, status
82
- passed, summary \`surface tests passed and covered bundled command prompts\`.
83
- - Weak validation: \`tests pass\`, with no command, status, or raw outcome.
91
+ <!-- flow-prompt:handoff-review-slice:start -->
92
+ For an assigned review slice, return only this Flow handoff:
93
+ ## Status
94
+ success | partial | blocked
95
+ ## Scope
96
+ assigned files, risk lens, or validation surface
97
+ ## Pass metadata
98
+ pass id, manifest row id, dependencies, write scope
99
+ ## Coverage
100
+ expected, checked, not checked with reasons
101
+ ## Findings
102
+ prefix each \`blocking:\` or \`advisory:\`, then severity, claim, citation, and corroboration
103
+ ## Sources
104
+ ## Confidence and verification
105
+ verified, single-source, inferred, unsettled, falsifier
106
+ ## Open questions / gaps
107
+ ## Manager follow-ups
108
+ <!-- flow-prompt:handoff-review-slice:end -->
84
109
 
85
110
  ## Verifier worker report
86
111
 
87
- Use this for \`flow-verifier-worker\`. Give it atomic claims and the cited sources
88
- or commands. Do not include the generator's reasoning unless that reasoning is
89
- the thing being verified, and do not say which worker produced the claim.
112
+ Use this for \`flow-verifier-worker\`.
90
113
 
91
- \`\`\`markdown
114
+ <!-- flow-prompt:handoff-verifier:start -->
115
+ Return only this Flow handoff:
92
116
  ## Status
93
117
  success | partial | blocked
94
-
95
118
  ## Scope
96
- <claim ids, sources or commands checked, and the acceptance question>
97
-
119
+ atomic claim ids, sources or commands checked, acceptance question
98
120
  ## Pass metadata
99
- - Pass id: <stable pass id from the manifest>
100
- - Manifest row id: <row id from the manifest>
101
- - Depends on: <upstream row ids or "none">
102
-
121
+ pass id, manifest row id, dependencies
103
122
  ## Verdict per claim
104
- - <claim id>: verdict=<supported | partly-supported | unsupported | source-not-found>
105
- - claim: <claim text>
106
- - evidence: <supporting snippet, path plus line, measured value, command result, or "none">
107
- - source resolution: <URL, path, or command plus whether it resolved>
108
- - confidence level: high | med | low
109
- - recommended action: <keep, narrow, rewrite, or remove>
110
-
123
+ supported | partly-supported | unsupported | source-not-found; include claim, resolved evidence, confidence, recommended action
111
124
  ## Overall
112
- <accept | revise | reject> because <brief reason>
113
-
125
+ accept | revise | reject with reason
114
126
  ## Gaps
115
- - <unavailable source, ambiguous claim wording, missing oracle, or check not run>
116
-
117
127
  ## Manager follow-ups
118
- - <narrow recheck, plan adjustment, review finding, or none>
119
- \`\`\`
128
+ <!-- flow-prompt:handoff-verifier:end -->
120
129
 
121
130
  ## Candidate implementation worker report
122
131
 
123
- Use this only with explicit user authorization, in an isolated worktree or an
124
- exact non-overlapping path-owned slice assigned by the manager.
132
+ Use this only with explicit user authorization and isolated or exact-path
133
+ ownership.
125
134
 
126
- \`\`\`markdown
135
+ <!-- flow-prompt:handoff-candidate:start -->
136
+ Return only this Flow handoff:
127
137
  ## Status
128
138
  success | partial | blocked
129
-
130
139
  ## Scope
131
- <isolated worktree or exact path-owned slice>
132
-
140
+ isolated worktree or exact path-owned slice
133
141
  ## Pass metadata
134
- - Pass id: <stable pass id from the manifest>
135
- - Manifest row id: <row id from the manifest>
136
- - Depends on: <upstream row ids or "none">
137
- - Write scope: <exact-path | isolated-worktree>
138
-
142
+ pass id, manifest row id, dependencies, exact-path | isolated-worktree
139
143
  ## Changed or proposed patch
140
- - <path>: <what changed and why>
141
-
144
+ paths, change, reason
142
145
  ## Coverage
143
- - Assigned: <owned files/modules>
144
- - Touched: <files changed or proposed>
145
- - Skipped: <anything assigned but not changed and why, or "none">
146
-
146
+ assigned, touched, skipped with reasons
147
147
  ## Verification
148
- live-verified | test-verified | type-check-only | not-verified
149
- - <command, observed outcome, pass/fail counts, or manual check>
150
-
148
+ level, exact command or check, observed outcome
151
149
  ## Confidence and risk
152
- - Checked directly: <behavior, files, or commands verified by the worker>
153
- - Still open: <tests, review paths, or integration points the manager must cover>
154
- - Risk: low | medium | high -- <why>
155
-
150
+ directly checked, still open, risk with reason
156
151
  ## Merge notes
157
- - <conflicts, nearby user changes, assumptions, or deviations>
158
-
152
+ conflicts, user changes, assumptions, deviations
159
153
  ## Manager follow-ups
160
- - <merge, reject, rerun check, verifier pass, or replan task>
161
- \`\`\`
154
+ <!-- flow-prompt:handoff-candidate:end -->
162
155
 
163
156
  The manager must inspect and validate any candidate patch before recording Flow
164
157
  completion.
165
158
 
166
159
  ## Manager pass accounting record
167
160
 
168
- The manager, not the worker, may carry compact records into
161
+ The manager, not the worker, may carry bounded records into
169
162
  \`flow_feature_complete.orchestrationPasses\`. Use one record per material pass or
170
163
  implementation decision; keep handoffs and long artifacts outside \`.flow/**\`.
171
164
  The candidate accounting rules — which \`candidateEligibility\`,
172
165
  \`candidateDecision\`, and \`decision\` combinations validate, and what counts as
173
166
  candidate execution evidence — live in
174
- [parallel-orchestration.md](parallel-orchestration.md) under "Implementation
175
- pass decision"; note \`decision: "parallel"\` is not valid on
167
+ [parallel-decision.md](parallel-decision.md) under "Implementation pass
168
+ decision"; note \`decision: "parallel"\` is not valid on
176
169
  \`implementation-decision\` records.
177
170
 
178
171
  \`\`\`json
@@ -206,557 +199,252 @@ pass decision"; note \`decision: "parallel"\` is not valid on
206
199
  \`\`\`
207
200
  `;
208
201
 
209
- // skills/flow/references/parallel-orchestration.md
210
- var parallel_orchestration_default = `# Parallel orchestration
211
-
212
- Use fan-out when Flow work is broad enough that independent workers can gather
213
- evidence faster than one linear pass. The manager still owns the Flow session:
214
- only the manager calls state-changing Flow tools, approves plans, completes
215
- features, records reviews, or closes sessions.
202
+ // skills/flow/references/parallel-decision.md
203
+ var parallel_decision_default = `# Parallel pass decisions
216
204
 
217
- Every parallel pass runs the same loop:
205
+ Read this reference after serial orientation and before creating a pass
206
+ manifest. It decides whether fan-out is worth its coordination cost and records
207
+ why implementation stays serial or uses candidate workers.
218
208
 
219
- **orient slice → manifest → fan out → account → verify → synthesize →
220
- extend or stop.**
209
+ <!-- flow-prompt:manager-parallel-core:start -->
210
+ ## Conditional parallel pass
221
211
 
222
- This file is the whole playbook; read it once and run the pass. Two companions
223
- stay separate:
212
+ Use a parallel pass only when independent coverage is worth its coordination
213
+ cost. Orient serially first. Before fan-out record a stable pass id, purpose,
214
+ bounded worker count, exact non-overlapping slices, expected coverage, named
215
+ Flow worker roles, dependencies, write scope, handoff kind, verification plan,
216
+ and stop condition.
224
217
 
225
- - \`handoff-format.md\` holds the worker response templates. The manager pastes
226
- the matching template verbatim into every worker prompt.
227
- - \`parallel-pass-example.md\` walks one concrete end-to-end pass (synced with
228
- the \`flow\` skill; not bundled into commands).
218
+ Use \`flow-evidence-worker\` for discovery, \`flow-validation-worker\` for commands,
219
+ \`flow-audit-worker\` for adversarial findings, \`flow-verifier-worker\` for
220
+ high-impact claim checks, and \`flow-reviewer\` for independent review. Account
221
+ for every manifest row. A missing, empty, malformed, partial, or blocked
222
+ handoff is a coverage gap, not success. Verify high-impact or single-source
223
+ claims, then let only the manager synthesize the result and mutate Flow state.
224
+ <!-- flow-prompt:manager-parallel-core:end -->
229
225
 
230
226
  ## Choose a pass
231
227
 
232
- | Situation | Flow pass | Output the manager may synthesize |
228
+ | Situation | Flow pass | Manager-owned result |
233
229
  | --- | --- | --- |
234
- | Repo shape is unclear before planning | Discovery pass | Requirements, decisions, targets, validation entries, or a review-first feature |
235
- | A broad finding set needs refutation | Audit pass | Surviving findings with guards checked and gaps named |
236
- | Changed files or risk lenses are too broad for one review pass | Review pass | One feature review packet or \`finalReview\` payload owned by the manager |
237
- | Test strategy or route coverage is unclear | Validation pass | Candidate commands or authorized raw command evidence |
238
- | A claim is single-source, surprising, high-stakes, or payload-bound | Verification pass | Per-claim keep, narrow, rewrite, or remove decisions |
239
- | Multiple implementation paths are plausible | Candidate pass | Candidate patches inspected and validated by the manager before use |
240
-
241
- Pass notes:
242
-
243
- - **Discovery**: workers read specific modules, routes, docs, commands, or risk
244
- lenses; only evidenced claims become plan fields.
245
- - **Audit**: workers actively look for guards, lifecycle resets, deployment
246
- constraints, and counterexamples before reporting a finding. A finding
247
- without refutation work stays advisory or becomes a follow-up question.
248
- - **Review**: workers separate blocking findings from advisory notes; the
249
- manager resolves conflicts and returns one review payload.
250
- - **Validation**: workers run only manager-authorized commands and report the
251
- exact command, status, and raw outcome summary.
252
- - **Verification**: verifiers judge atomic claims against cited sources or
253
- commands; do not ask a verifier to redesign the work or review the whole
254
- feature.
255
- - **Candidate**: only with explicit user authorization plus isolated worktrees
256
- or exact non-overlapping path ownership. Patches stay proposals until the
257
- manager inspects, merges or rejects, and validates.
230
+ | Repo shape is unclear before planning | Discovery | Evidenced requirements, decisions, targets, validation, or a review-first feature |
231
+ | A broad finding set needs refutation | Audit | Findings that survive guard and counterexample checks |
232
+ | Changed files or risk lenses exceed one review pass | Review | One feature review or final review payload |
233
+ | Test strategy or route coverage is unclear | Validation | Candidate commands or authorized raw command evidence |
234
+ | A claim is surprising, high-stakes, single-source, or payload-bound | Verification | Per-claim keep, narrow, rewrite, or remove decisions |
235
+ | Multiple independent implementation paths are plausible | Candidate | Inspected candidate patches, never direct Flow completion |
236
+
237
+ Discovery, audit, review, validation, and verification passes are read-only.
238
+ Validation workers run only manager-authorized commands. Verification workers
239
+ judge atomic claims rather than redesigning the work. Candidate passes require
240
+ explicit user authorization plus an isolated worktree or exact non-overlapping
241
+ path ownership; patches remain proposals until manager inspection and
242
+ validation.
258
243
 
259
244
  ## Implementation pass decision
260
245
 
261
- Before implementing a broad, risky, or multi-target feature, record one manager
262
- decision. This is required even when the answer is "stay serial"; the point is
263
- to make the skipped parallelism visible instead of relying on memory.
264
-
265
- First classify candidate eligibility:
266
-
267
- - \`eligible\`: at least one slice is independent enough for a candidate worker.
268
- - \`not_eligible\`: worker isolation would not make the implementation safer or
269
- cheaper because the slice shares state, files, tests, or one mental model.
270
- - \`unknown\`: orientation did not produce enough evidence to classify; use this
271
- only for non-decision pass rows or legacy low-signal records, not for
272
- \`implementation-decision\` records and not as a substitute for judgment.
273
-
274
- Then record the candidate decision:
275
-
276
- - \`used\`: candidate workers were used or a candidate pass carried the work.
277
- - \`skipped\`: candidates were eligible, but the manager chose serial anyway.
278
- This is the underused-parallelism signal counted by Flow status; use it only
279
- on \`kind: "implementation-decision"\` records.
280
- - \`serial_required\`: candidates were not eligible, so serial work was the
281
- correct implementation shape. Use it only on \`kind: "implementation-decision"\`
282
- records.
283
-
284
- Use one of these decisions:
285
-
286
- - \`serial\`: the manager implements directly because slices overlap, the next
287
- edit depends on one shared contract, or prompt/merge overhead would exceed the
288
- value. Pair unsafe or not-useful worker cases with
289
- \`candidateEligibility: "not_eligible"\` and
290
- \`candidateDecision: "serial_required"\`.
291
- - \`candidate-exact-path\`: one or more candidate workers may edit exact
292
- non-overlapping paths or modules named by the manager.
293
- - \`candidate-worktree\`: one or more candidate workers may edit in isolated
294
- worktrees, then the manager inspects and merges or rejects.
295
- - \`tournament\`: several isolated candidate implementations compete for the same
296
- outcome; the manager filters by tests, review, and source inspection before
297
- accepting one.
298
- - Candidate-shaped decisions (\`candidate-exact-path\`, \`candidate-worktree\`,
299
- \`tournament\`) require candidate execution evidence on the same record:
300
- \`kind: "candidate"\`, \`modes\` includes \`candidate-implementation\`, or
301
- \`candidateWorkerCount > 0\`. The same evidence rule applies to
302
- \`candidateDecision: "used"\`. Non-decision candidate rows (for example
303
- \`kind: "candidate"\`) may omit \`decision\`; \`implementation-decision\` rows must
304
- always set one, and when \`candidateDecision\` is \`"used"\` that decision must
305
- be candidate-shaped — never \`serial\`, \`parallel\`, or \`skipped\`.
306
- - \`parallel\` describes multi-worker read or audit passes (discovery, audit,
307
- review); it is not a valid \`implementation-decision\` value. Implementation
308
- decisions use \`serial\`, \`skipped\`, or a candidate-shaped decision.
309
- - \`skipped\`: candidate workers were eligible but the manager chose serial
310
- anyway; pair this with \`candidateEligibility: "eligible"\` and
311
- \`candidateDecision: "skipped"\`. Do not use \`skipped\` for shared fixtures,
312
- shared API contracts, unclear ownership, or other unsafe worker cases; use
313
- \`serial\` plus \`serial_required\` for those.
314
-
315
- Use structured \`decisionFactors\` alongside prose \`decisionReason\`:
246
+ Before editing a broad, risky, or multi-target feature, record one manager
247
+ decision even when implementation stays serial. Keep \`candidateEligibility\`,
248
+ \`candidateDecision\`, and \`decision\` as distinct fields.
249
+
250
+ Classify candidate eligibility separately from the decision:
251
+
252
+ | Eligibility | Meaning |
253
+ | --- | --- |
254
+ | \`eligible\` | At least one slice has independent ownership and practical validation. |
255
+ | \`not_eligible\` | Shared state, files, tests, or judgment make isolation unsafe or wasteful. |
256
+ | \`unknown\` | Orientation is incomplete; never use this on an \`implementation-decision\` record. |
257
+
258
+ Use only these pairings on \`implementation-decision\` records:
259
+
260
+ | Eligibility | Candidate decision | Implementation decision |
261
+ | --- | --- | --- |
262
+ | \`eligible\` | \`used\` | \`candidate-exact-path\`, \`candidate-worktree\`, or \`tournament\` |
263
+ | \`eligible\` | \`skipped\` | \`skipped\` |
264
+ | \`not_eligible\` | \`serial_required\` | \`serial\` |
265
+
266
+ Candidate-shaped decisions and \`candidateDecision: "used"\` require execution
267
+ evidence on the same record: \`kind: "candidate"\`, \`modes\` containing
268
+ \`candidate-implementation\`, or \`candidateWorkerCount > 0\`. Keep
269
+ \`candidateWorkerCount <= workerCount\` and
270
+ \`verifierWorkerCount <= workerCount\`; one worker may fill both subtype counts.
271
+ Never use \`parallel\` as an implementation decision. Reserve \`parallel\` for
272
+ multi-worker read, audit, review, validation, or verification passes.
273
+
274
+ Implementation decision meanings:
275
+
276
+ - \`serial\`: the manager implements directly because work overlaps or depends on
277
+ one shared contract or mental model.
278
+ - \`candidate-exact-path\`: workers own exact, disjoint path sets in one checkout.
279
+ - \`candidate-worktree\`: isolated workers propose patches for manager integration.
280
+ - \`tournament\`: isolated candidates compete; the manager selects using source
281
+ inspection, validation, and review.
282
+ - \`skipped\`: candidate work was eligible, but coordination cost outweighed its
283
+ value. Do not use it for unsafe ownership; those cases are \`serial\`.
284
+
285
+ Record \`decisionReason\` plus the applicable structured \`decisionFactors\`:
316
286
  \`shared_state\`, \`overlapping_files\`, \`small_slice\`,
317
287
  \`needs_manager_judgment\`, \`independent_surface\`, and
318
- \`validation_available\`. Serial-required records usually cite
319
- \`shared_state\`, \`overlapping_files\`, or \`needs_manager_judgment\`; eligible
320
- records usually cite \`independent_surface\` and \`validation_available\`, with
321
- \`small_slice\` explaining an eligible-but-skipped choice.
322
-
323
- ### Worker decision rubric
324
-
325
- Default to considering candidate workers when:
326
-
327
- - the plan has three or more features.
328
- - features touch separate surfaces such as frontend, core, docs, release
329
- scripts, tests, or bindings.
330
- - validation can run per slice.
331
- - the work is mostly additive or localized.
332
- - the final manager can review, apply, adapt, or reject the result safely.
333
-
334
- Prefer serial when:
335
-
336
- - one tight invariant crosses shared files.
337
- - migrations, persistence, storage, or lifecycle semantics require one mental
338
- model.
339
- - tests require iterative local debugging in one checkout.
340
- - multiple slices would edit the same files or fixtures.
341
- - the slice is so small that prompt, handoff, merge, and verification overhead
342
- costs more than direct work.
343
-
344
- Record the decision in the pass manifest with a stable pass id,
345
- \`candidateEligibility\`, \`candidateDecision\`, \`decisionFactors\`,
346
- \`decisionReason\`, \`writeScope\`, expected verification, and where any handoff or
347
- synthesis artifact will live. If the feature completes, include the compact
348
- record in the \`orchestrationPasses\` array of the \`flow_feature_complete\`
349
- payload. The runtime stores only compact accounting; full worker handoffs stay
350
- in manager-owned scratch files or the conversation.
351
-
352
- ## When to stay serial
353
-
354
- - One file, command, or design question determines the next step.
355
- - Slices would share the same contracts, fixtures, or edit targets.
356
- - The manager can inspect the full scope faster than writing and checking
357
- worker prompts.
358
- - The result would still need the same manual synthesis with no time saved.
359
-
360
- Do not fan out to keep agents busy. Every worker should reduce a named
361
- planning, validation, review, audit, or implementation uncertainty. A normal
362
- first pass is two to five workers with independent slices; use more only when
363
- the manifest stays countable and non-overlapping.
364
-
365
- ## Modes
366
-
367
- When fanning out Flow work, select the matching hidden Flow agent by name. These
368
- workers are injected by the plugin config; invoke the named worker when it is
369
- available. Do not use generic subagents for Flow slices because Flow workers
370
- carry the permission boundaries for each mode.
371
-
372
- | Mode | Use agent | Worker output | Write access | Flow tools |
373
- | --- | --- | --- | --- | --- |
374
- | \`evidence\` | \`flow-evidence-worker\` | Coverage, facts, files inspected, confidence, gaps, suggested plan targets | No | \`flow_status\` only if needed |
375
- | \`review\` | \`flow-reviewer\` | Coverage, candidate findings or review slice summary, confidence, gaps | No | \`flow_status\` only if needed |
376
- | \`validation\` | \`flow-validation-worker\` | Command options or manager-authorized raw output, coverage, confidence, gaps | No code edits; commands only when explicitly allowed | \`flow_status\` only if needed |
377
- | \`audit\` | \`flow-audit-worker\` | Refuted or surviving finding candidates, guards checked, confidence, gaps | No | \`flow_status\` only if needed |
378
- | \`verifier\` | \`flow-verifier-worker\` | Per-claim verdicts against cited evidence or commands | No | \`flow_status\` only if needed |
379
- | \`candidate-implementation\` | \`flow-candidate-worker\` | Candidate patch summary from an isolated worktree or exact path-owned slice | Only with explicit user authorization plus isolation or exact non-overlapping path ownership | No state-changing Flow tools |
380
-
381
- Use worker-specific model routing where the installation can support it:
382
- \`OPENCODE_FLOW_READONLY_WORKER_MODEL\` for evidence, validation, and audit
383
- workers; \`OPENCODE_FLOW_REVIEW_WORKER_MODEL\` for reviewer and verifier workers;
384
- \`OPENCODE_FLOW_CANDIDATE_WORKER_MODEL\` for candidate implementation workers; and
385
- \`OPENCODE_FLOW_WORKER_MODEL\` as a fallback for all hidden Flow workers. Model IDs
386
- are OpenCode installation-specific (\`provider/model\`), so leave these unset when
387
- the configured provider is unknown. Spend stronger models where being wrong is
388
- expensive; read-heavy discovery slices tolerate the cheapest configured option,
389
- while verifier and review slices deserve the strongest.
390
-
391
- ## Permission contract
392
-
393
- The plugin injects these hidden workers with the following permission values.
394
- \`Flow state tools\` means the \`flow_*\` rule, while \`Flow status\` documents the
395
- explicit \`flow_status\` exception.
396
-
397
- | Worker | Edit | Bash | Task | Skill | Flow state tools | Flow status |
398
- | --- | --- | --- | --- | --- | --- | --- |
399
- | \`flow-reviewer\` | deny | deny | deny | deny | deny | allow |
400
- | \`flow-evidence-worker\` | deny | deny | deny | deny | deny | allow |
401
- | \`flow-validation-worker\` | deny | ask | deny | deny | deny | allow |
402
- | \`flow-audit-worker\` | deny | ask | deny | deny | deny | allow |
403
- | \`flow-candidate-worker\` | ask | ask | deny | deny | deny | allow |
404
- | \`flow-verifier-worker\` | deny | ask | deny | deny | deny | allow |
405
-
406
- Do not fan out parallel \`flow_plan_save\`, \`flow_plan_approve\`,
407
- \`flow_run_start\`, \`flow_feature_complete\`, \`flow_feature_reset\`, or
408
- \`flow_session_close\` calls. Runtime locking protects files, but Flow accepts only
409
- one active feature result at a time.
410
-
411
- Workers may read files, inspect docs, run authorized read-only commands, and
412
- summarize evidence. Candidate implementation workers may edit only when the
413
- manager assigned an isolated worktree or exact path ownership that does not
414
- overlap sibling workers or manager edits. Workers must not edit \`.flow/**\`,
415
- must not call state-changing Flow tools, and must not approve work, close
416
- sessions, record Flow validation, or claim validation they did not run. A
417
- worker may report raw validation output it actually ran; the manager decides
418
- whether it is strong enough to record.
419
-
420
- ## Stage 1 — Orient (serial)
421
-
422
- Call \`flow_status\` if a Flow session may already exist. Read enough files,
423
- schemas, docs, tests, commands, or artifacts to identify real slices. Keep the
424
- immediate blocker local: do not delegate the question that determines whether
425
- fan-out is even valid.
426
-
427
- Treat orientation as uncertainty reduction. Resolve environment uncertainty by
428
- inspecting the repo, running cheap commands, or assigning evidence workers; ask
429
- the user only when the remaining specification uncertainty would make a wrong
430
- slice expensive to undo. Do not split a vague goal into workers until the
431
- candidate slices have concrete targets, dependencies, and verification signals.
432
-
433
- ## Stage 2 — Slice
434
-
435
- Split along whichever axis keeps slices independent: modules or path sets,
436
- route or endpoint groups, risk lenses, command surfaces, data ranges, or claim
437
- sets. Each slice needs a one-line scope, expected coverage, and a defined
438
- output the manager can check.
439
-
440
- For implementation slices, also name dependencies and write ownership before
441
- spawning. A real dependency edge means the later slice waits for a verified
442
- handoff or manager synthesis from the earlier slice; a shared file, fixture,
443
- schema, or public contract usually means the work should stay serial unless an
444
- isolated worktree is used. The manifest owns those edges through \`dependsOn\`
445
- and \`writeScope\`.
446
-
447
- ## Stage 3 — Manifest (the pre-fan-out coverage gate)
448
-
449
- Before spawning, write a pass manifest: one row per slice, plus a totals check.
450
- Give the pass a stable id so later handoffs, verifier claims, and completion
451
- payloads can refer to the same work without replaying chat.
288
+ \`validation_available\`. Also record a stable pass id, write scope, expected
289
+ verification, and the handoff or synthesis location. Carry the bounded record
290
+ into \`flow_feature_complete.orchestrationPasses\` when it materially shaped the
291
+ feature; keep full handoffs and logs outside Flow state.
452
292
 
453
- | Row id | Slice scope | Expected coverage | Mode | Depends on | Write scope | Verification tier | Handoff ref | Verification status | Synthesis ref |
454
- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
455
- | \`runtime-read\` | \`src/core/**\` plus its tests | 14 files | \`evidence\` | none | none | accept locally | pending | pending | pending |
456
- | \`release-read\` | release contract: CI workflows, \`package.json\`, changelog | 6 files | \`evidence\` | none | none | verify once | pending | pending | pending |
457
-
458
- \`writeScope\` values in runtime accounting are \`none\`, \`manager-serial\`,
459
- \`exact-path\`, \`isolated-worktree\`, or \`mixed\`. Use \`manager-serial\` for a
460
- recorded serial implementation decision, \`exact-path\` for disjoint candidate
461
- edits in one checkout, and \`isolated-worktree\` for candidate work that must be
462
- merged back by the manager.
463
-
464
- - Count the total work items when countable: files, modules, routes, commands,
465
- rows, findings, screenshots, or claims. Confirm slice counts add back to the
466
- total, with no overlaps, gaps, empty slices, or ambiguous shared contracts.
467
- - If the scope cannot be counted, state the completeness rule instead, such as
468
- "all changed files plus callers" or "all public commands plus release docs."
469
- - Assign each slice's verification tier now (see Stage 6). Deciding where a
470
- wrong claim is expensive belongs before handoffs arrive, not after.
471
- - Record dependency edges now. A row may be spawned only after every \`depends on\`
472
- row it names has returned a verified handoff or a manager synthesis that
473
- explicitly settles the dependency.
474
- - Fix the slice map centrally before spawning if the gate does not reconcile.
475
-
476
- The manifest is also the accounting contract for the pass: N rows spawned means
477
- N handoffs collected and checked in Stage 5 before anything is synthesized.
478
-
479
- For implementation decisions, add a manifest row even when no worker is spawned:
480
- \`kind=implementation-decision\`, \`decision=serial\` or \`decision=skipped\`,
481
- \`candidateEligibility\`, \`candidateDecision\`, \`decisionFactors\`,
482
- \`workerCount=0\`, \`writeScope=manager-serial\`, and a concrete \`decisionReason\`.
483
- Use \`decision=serial\` with \`candidateDecision=serial_required\` for ineligible
484
- worker cases; reserve \`decision=skipped\` for eligible candidate work that the
485
- manager chose not to delegate. When an implementation-decision row uses
486
- \`candidateDecision=used\`, it must also record actual candidate execution
487
- evidence: either \`modes=candidate-implementation\`, or \`candidateWorkerCount > 0\`
488
- with \`workerCount\` raised to cover it — a \`workerCount=0\` row cannot carry a
489
- positive \`candidateWorkerCount\`. Neither subtype count may exceed the total:
490
- \`candidateWorkerCount <= workerCount\` and \`verifierWorkerCount <= workerCount\`
491
- (a single worker may fill both roles).
492
- This is how Flow distinguishes deliberate serial work from forgotten candidate
493
- or verifier passes.
494
-
495
- Write the manifest where it survives the pass: the conversation is enough for a
496
- single bounded pass, but when a follow-up pass or a session resume is
497
- plausible, persist it with the synthesis (Stage 7) so the accounting can be
498
- reconstructed.
499
-
500
- ## Stage 4 — Fan out
501
-
502
- Every worker prompt includes:
293
+ ## Candidate judgment
503
294
 
504
- \`\`\`text
505
- Overall goal, context only: <goal>
506
- Mode: evidence | review | validation | audit | verifier | candidate-implementation
507
- Pass id and manifest row id: <stable ids from the manifest>
508
- Your exact slice: <paths, modules, command, claim ids, risk lens, or worktree>
509
- Expected coverage: <count, paths, range, or complete question set>
510
- Dependencies and write scope: <verified dependencies, if any; none | manager-serial | exact-path | isolated-worktree>
511
- Do: <bounded actions>
512
- Do not: call state-changing Flow tools, edit .flow/**, own sibling slices, or make the final Flow verdict.
513
- Return only the Flow handoff in this exact shape:
514
- <matching handoff template copied verbatim from handoff-format.md>
515
- \`\`\`
295
+ Consider candidate workers when ownership is additive or localized, validation
296
+ can run per slice, and the manager can safely inspect or reject the result.
297
+ Separate frontend, core, docs, release, test, or binding surfaces are useful
298
+ signals, but the actual path and contract boundaries decide eligibility.
516
299
 
517
- Hidden workers cannot load skills or read \`handoff-format.md\` themselves. The
518
- manager copies the matching handoff template into every worker prompt; a bare
519
- filename reference is not enough. Workers also cannot read the conversation, so
520
- prompts cite file paths — including any synthesis file from an earlier pass —
521
- instead of restating chat history.
522
-
523
- For research or current-doc slices, require source checks for versioned or
524
- time-sensitive facts. For implementation candidates, remind workers that other
525
- work may be active and that they must not revert unrelated changes.
526
-
527
- Continue non-overlapping manager work while workers run.
528
-
529
- ## Stage 5 — Account
530
-
531
- Check every manifest row off against a returned handoff before synthesis. A
532
- worker that never returns, errors out, returns empty or unstructured output, or
533
- reports \`partial\` or \`blocked\` is a hole in the pass, and synthesizing around it
534
- silently drops a slice.
535
-
536
- For each row, fill in:
537
-
538
- - \`handoffRefs\`: worker ids, handoff file paths, command output artifacts, or
539
- review packet location that the manager can re-open.
540
- - \`verificationStatus\`: \`not-needed\`, \`pending\`, \`passed\`, \`failed\`, \`mixed\`,
541
- or \`downgraded\`.
542
- - \`outcome\`: \`accepted\`, \`modified\`, \`rejected\`, \`partial\`, \`not-covered\`, or
543
- \`superseded\`.
544
- - \`synthesisRef\`: the manager-owned synthesis file or plan field that carries
545
- the accepted result forward.
546
-
547
- Rows with no worker, such as serial or skipped implementation decisions, still
548
- need a row id, decision, reason, and outcome. They are not handoffs, but they
549
- are accounting.
550
-
551
- Worker failure ladder:
552
-
553
- 1. Re-spawn once with a narrower slice and a note about what the first attempt
554
- returned.
555
- 2. If it fails again, cover the slice directly in the manager session.
556
- 3. If it stays blocked, carry the slice into the synthesis explicitly as
557
- not-covered. Never present results as if coverage were complete.
558
-
559
- ## Stage 6 — Verify
560
-
561
- \`Status: success\` only says the worker believes its slice is done. Accept a
562
- handoff only after a cheap manager-side pass:
563
-
564
- - \`Status\` is present and terminal: \`success\`, \`partial\`, or \`blocked\`; empty or
565
- unstructured output fails this check.
566
- - Coverage matches the assigned slice, or skips are explicit.
567
- - Important claims have concrete evidence and confidence tags.
568
- - Cited paths, commands, screenshots, URLs, or metrics resolve.
569
- - The evidence supports the claim, not just the topic.
570
- - Findings stay inside the worker's slice.
571
- - Headline counts can be recounted or traced.
572
- - Dependency claims cite the verified upstream handoff, synthesis, or source
573
- artifact they depend on.
574
- - Candidate implementation claims identify whether they came from exact path
575
- ownership or an isolated worktree, and whether the manager inspected the
576
- resulting patch. Record the manager result as \`accepted\`, \`modified\`, or
577
- \`rejected\` where that is the most precise candidate outcome.
578
- - Contradictions between workers are either resolved or explicitly marked as
579
- contested.
580
-
581
- Demote, drop, re-task, or verify claims that fail this pass.
582
-
583
- ### Verification tiers
584
-
585
- One taxonomy decides how much verification a claim gets: the manifest assigns
586
- a default tier per slice, and this stage applies it per claim. Use the cheapest
587
- check that matches the risk:
588
-
589
- - **Accept locally**: low-risk claims with direct evidence that the manager can
590
- cheaply inspect or recount.
591
- - **Verify once** with \`flow-verifier-worker\`: single-source, surprising,
592
- inferred, low-confidence, citation-heavy, contested, or Flow-payload-bound
593
- claims, including any count, benchmark, command result, or pass/fail claim a
594
- Flow payload will rely on.
595
- - **Verify strongly**: blocking or release-sensitive claims and claims that
596
- affect user data, security, persistence, permissions, public API behavior,
597
- release behavior, or data loss. Use independent verifier checks, manager-run
598
- commands, or direct artifact inspection strong enough to settle the claim.
599
- - **Do not accept**: claims without concrete evidence, claims outside the
600
- assigned slice, claims contradicted by inspected artifacts, or claims where
601
- the cited evidence supports only the topic rather than the assertion.
602
-
603
- Verifier prompts use stable claim ids, one atomic assertion per id, the cited
604
- source or command for each id, and the exact acceptance question. Do not
605
- include the generator's reasoning unless that reasoning is the thing being
606
- verified, do not say which worker produced the claim, and do not ask a
607
- verifier to redesign the work or review the whole feature.
608
-
609
- ## Stage 7 — Synthesize
610
-
611
- Apply the manager synthesis barrier before presenting or recording anything:
612
-
613
- - Preserve confidence: verified, single-sourced, inferred, and unresolved claims
614
- stay distinct when it matters.
615
- - When workers disagree, inspect the cited artifact or rerun the cited command
616
- instead of arbitrating from summaries. Do not average conflicting claims.
617
- - Run the strongest practical local check for the deliverable.
618
- - For broad implementation sessions, use one verifier worker after manager
619
- synthesis when the risk is medium or high. Ask it whether every planned
620
- feature landed, worker validation claims are supported, final code matches
621
- the audit finding, generated bindings/docs/version metadata stayed
622
- consistent, and changed files have plausible test coverage.
623
- - Re-read critical files or docs that will be cited in the final decision.
624
- - Move only distilled, evidence-backed claims forward; raw handoffs remain
625
- candidate evidence, not a plan, review, completion payload, or final answer.
626
- - Record gaps honestly instead of converting missing evidence into success
627
- language.
628
-
629
- Where accepted evidence goes:
630
-
631
- - Planning evidence becomes \`requirements\`, \`decisions\`, feature \`targets\`,
632
- feature \`validation\`, or plan notes — only when the source and scope are
633
- clear. Unverified broad findings become a review-first feature, not a fix
634
- plan.
635
- - Validation evidence may become \`validationRun\` only when the worker was
636
- explicitly authorized to run the command and reported the exact command,
637
- status, and raw outcome summary.
638
- - Review evidence informs \`featureReviewDepth\` plus \`featureReview\`, or \`finalReview\`, but the manager
639
- owns the pass/fail verdict and must resolve blockers, contradictions, and
640
- coverage gaps before returning the payload.
641
- - Audit evidence becomes findings only after refutation; blocking findings need
642
- guards checked, deployment context, and evidence that the current code
643
- exhibits the behavior.
644
- - Candidate patches are not Flow evidence until the manager inspects, merges or
645
- rejects them, and validates the main Flow-managed workspace.
646
-
647
- When completing a feature, include compact pass accounting in
648
- \`flow_feature_complete.orchestrationPasses\` for any pass or implementation
649
- decision that materially affected the feature:
300
+ Stay serial when any of these apply:
650
301
 
651
- \`\`\`json
652
- {
653
- "id": "feature-id-implementation-decision",
654
- "kind": "implementation-decision",
655
- "decision": "serial",
656
- "decisionReason": "Shared schema and tests made exact path ownership unsafe.",
657
- "candidateEligibility": "not_eligible",
658
- "candidateDecision": "serial_required",
659
- "decisionFactors": ["shared_state", "overlapping_files"],
660
- "modes": [],
661
- "workerCount": 0,
662
- "candidateWorkerCount": 0,
663
- "verifierWorkerCount": 0,
664
- "sliceIds": ["manager-implementation"],
665
- "dependsOn": [],
666
- "writeScope": "manager-serial",
667
- "handoffRefs": [],
668
- "verificationStatus": "not-needed",
669
- "outcome": "accepted",
670
- "synthesisRef": "/tmp/flow-pass-synthesis.md"
671
- }
672
- \`\`\`
302
+ - One file, command, contract, migration, or design question determines the
303
+ next step.
304
+ - Slices share state, callers, fixtures, generated output, lockfiles, tests, or
305
+ edit targets.
306
+ - Persistence or lifecycle behavior requires one mental model.
307
+ - Iterative debugging must happen in one checkout.
308
+ - Prompt, handoff, merge, and verification cost exceeds direct work.
309
+ - The manager would still need the same full synthesis with no coverage gain.
673
310
 
674
- For candidate and verifier passes, use \`kind: "candidate"\` or
675
- \`kind: "verification"\`, list the worker modes used, worker counts, slice ids,
676
- handoff refs, dependency ids, verification status, and whether the manager
677
- accepted, rejected, downgraded, or superseded the pass. The runtime aggregates
678
- these compact records into \`session.budget.orchestration\` and stores them on
679
- the feature history entry. Do not store full handoffs, long logs, or scratch
680
- tables in \`.flow/session.json\`.
681
-
682
- Status accounting distinguishes three cases: \`candidateDecision: "used"\` means
683
- candidate execution evidence was recorded, \`candidateDecision:
684
- "serial_required"\` means workers were not safe or useful, and
685
- \`candidateEligibility: "eligible"\` plus \`candidateDecision: "skipped"\`
686
- increments \`skippedCandidateDecisionCount\`. These candidate decision counters
687
- come from \`kind: "implementation-decision"\` records; \`skipped\` and
688
- \`serial_required\` are not valid on discovery, audit, review, validation,
689
- verification, or candidate pass rows. \`candidatePassCount\`
690
- counts actual candidate pass or worker evidence (\`kind: "candidate"\`,
691
- \`modes\` includes \`candidate-implementation\`, or \`candidateWorkerCount > 0\`) —
692
- a candidate-shaped decision label without that evidence is rejected, so decision
693
- labels alone never count. \`verifierPassCount\` similarly counts
694
- actual verifier pass or worker evidence (\`kind: "verification"\`, \`modes\`
695
- includes \`verifier\`, or \`verifierWorkerCount > 0\`).
696
-
697
- Persist the manifest and the synthesis when another pass may follow or the
698
- session is long enough to be compacted or resumed: write the distilled result —
699
- the accounted manifest, accepted claims with evidence and confidence, dropped
700
- claims with one-line reasons, and open gaps — into plan prose fields or a
701
- manager-owned scratch file outside both \`.flow/**\` and the repository worktree,
702
- such as a file in the OS temporary directory. The runtime owns the \`.flow/**\`
703
- layout, and scratch files left in the worktree end up staged or reviewed as if
704
- they were project changes. Follow-up worker prompts cite that path; files are
705
- the only shared memory between passes.
706
-
707
- ## Stage 8 — Extend or stop
708
-
709
- Stop after a pass when:
710
-
711
- - the manifest's coverage rule is satisfied and every row is accounted for.
712
- - accepted claims are evidenced, scoped, and confidence-labeled.
713
- - material single-source, contested, high-stakes, or payload-bound claims have
714
- been verified or downgraded.
715
- - every dependency edge named in the manifest has either a verified upstream
716
- result or an explicit not-covered outcome.
717
- - implementation pass decisions are recorded, including skipped candidate
718
- workers, candidate eligibility, candidate decision, structured factors, and
719
- the reason eligible workers were skipped.
720
- - remaining gaps are explicit and do not block the Flow artifact being produced.
721
-
722
- Start a bounded follow-up pass only when:
723
-
724
- - the original slice map missed material scope.
725
- - workers disagree on a claim that affects the Flow decision.
726
- - a high-stakes or payload-bound claim needs verification.
727
- - a dependency has just become verified and now unlocks a dependent slice.
728
- - a candidate patch was rejected and an isolated alternative is still cheaper
729
- than serial repair.
730
- - a first pass exposes a narrower implementation or validation slice worth
731
- isolating.
732
-
733
- Run at most one routine follow-up pass. Extra passes need an explicit manager
734
- reason, such as a high-stakes verifier check or a newly discovered bounded
735
- slice. Do not recurse by default: if a worker says it needs another worker, the
736
- manager decides whether that is a follow-up pass and writes the next bounded
737
- prompt, starting again from the manifest.
311
+ Do not fan out to keep workers busy. Every worker must reduce a named
312
+ uncertainty.
738
313
 
739
314
  ## Worker count defaults
740
315
 
741
- Use caps, not a fixed feature limit:
316
+ Use bounded caps rather than worker-count targets:
742
317
 
743
- - small implementation: zero or one worker.
744
- - medium independent implementation: two workers.
745
- - broad audit: three to five workers.
746
- - broad implementation: two to four candidate workers, only for
747
- non-overlapping slices.
748
- - final verifier: one worker when risk is medium or high.
318
+ - Small implementation: zero or one worker.
319
+ - Medium independent implementation: at most two workers.
320
+ - Broad audit: three to five workers.
321
+ - Broad implementation: two to four candidate workers with non-overlapping
322
+ ownership.
323
+ - Medium- or high-risk final verification: one verifier.
749
324
 
750
- The target is not "more workers." The target is explicit accounting: Flow must
751
- justify not using workers when the work was eligible.
325
+ Use more only when the manifest remains countable and non-overlapping.
326
+ `;
327
+
328
+ // skills/flow/references/parallel-execution.md
329
+ var parallel_execution_default = "# Parallel pass execution\n\nRead this after a pass decision and complete manifest. It defines Flow-native\nworker routing, permissions, and launch prompts. Do not use generic workers for\nFlow slices when the named hidden Flow worker is available.\n\n## Modes\n\n| Mode | Use worker | Output | Write access |\n| --- | --- | --- | --- |\n| `evidence` | `flow-evidence-worker` | Facts, coverage, confidence, gaps | None |\n| `review` | `flow-reviewer` | Review slice findings and coverage | None |\n| `validation` | `flow-validation-worker` | Proposed checks or authorized raw command evidence | Commands only when explicitly allowed |\n| `audit` | `flow-audit-worker` | Refuted or surviving findings and guards checked | None |\n| `verifier` | `flow-verifier-worker` | Per-claim verdicts against cited evidence | None |\n| `candidate-implementation` | `flow-candidate-worker` | Candidate patch from isolated or exact-path ownership | Explicitly authorized owned paths only |\n\n## Worker role contracts\n\nThese marked blocks are the canonical role instructions compiled into hidden\nworker prompts.\n\n<!-- flow-prompt:worker-role-evidence:start -->\n### Flow evidence worker\n\nInspect only the assigned read-only slice. Report observed facts and coverage;\ndo not edit files, expand scope, or synthesize the whole pass. Only the root\nmanager may mutate Flow state.\n<!-- flow-prompt:worker-role-evidence:end -->\n\n<!-- flow-prompt:worker-role-validation:start -->\n### Flow validation worker\n\nRun only manager-specified commands or propose focused checks. Do not edit\nfiles, expand scope, or synthesize completion. Only the root manager may mutate\nFlow state. Distinguish commands actually run from checks merely proposed.\n<!-- flow-prompt:worker-role-validation:end -->\n\n<!-- flow-prompt:worker-role-audit:start -->\n### Flow audit worker\n\nInspect only the assigned read-only slice and actively try to refute candidate\nfindings. Do not edit files, expand scope, or synthesize the whole audit. Only\nthe root manager may mutate Flow state. A blocking candidate must name the\nguards and mitigating paths checked.\n<!-- flow-prompt:worker-role-audit:end -->\n\n<!-- flow-prompt:worker-role-candidate:start -->\n### Flow candidate implementation worker\n\nWork only in the manager-assigned isolated worktree or exact non-overlapping\npath set. Preserve unrelated user changes. Never edit `.flow/**`, expand\nownership, claim completion, integrate other slices, commit, push, or publish.\nOnly the root manager may mutate Flow state. Your patch is a candidate for\nmanager inspection.\n<!-- flow-prompt:worker-role-candidate:end -->\n\n<!-- flow-prompt:worker-role-verifier:start -->\n### Flow verifier worker\n\nVerify only the assigned atomic claims against provided sources, commands,\ncounts, or current documentation. Resolve each source independently. Do not\ngenerate new scope, edit files, identify the originating worker, or synthesize\nthe whole pass. Only the root manager may mutate Flow state.\n<!-- flow-prompt:worker-role-verifier:end -->\n\n## Permission contract\n\nThe plugin injects these hidden workers. `Flow state tools` means every\nstate-changing `flow_*` call; `flow_status` is the explicit read-only exception.\n\n| Worker | Edit | Bash | Task | Skill | Flow state tools | `flow_status` |\n| --- | --- | --- | --- | --- | --- | --- |\n| `flow-reviewer` | deny | deny | deny | deny | deny | allow |\n| `flow-evidence-worker` | deny | deny | deny | deny | deny | allow |\n| `flow-validation-worker` | deny | ask | deny | deny | deny | allow |\n| `flow-audit-worker` | deny | ask | deny | deny | deny | allow |\n| `flow-candidate-worker` | ask | ask | deny | deny | deny | allow |\n| `flow-verifier-worker` | deny | ask | deny | deny | deny | allow |\n\nNever fan out `flow_plan_save`, `flow_plan_approve`, `flow_run_start`,\n`flow_feature_complete`, `flow_feature_reset`, or `flow_session_close`. Workers\nmust not edit `.flow/**`, approve work, record Flow evidence, or claim commands\nthey did not run. Candidate workers may edit only their authorized isolation or\nexact path scope.\n\n## Launch\n\nEvery worker prompt contains:\n\n```text\nOverall goal, context only: <goal>\nMode: evidence | review | validation | audit | verifier | candidate-implementation\nPass id and manifest row id: <stable ids>\nYour exact slice: <paths, modules, commands, claims, risk lens, or worktree>\nExpected coverage: <count, paths, range, or completeness rule>\nDependencies and write scope: <verified dependencies; approved write scope>\nDo: <bounded actions>\nDo not: call state-changing Flow tools, edit .flow/**, own sibling slices, or make the final Flow verdict.\nReturn only the Flow handoff in this exact shape:\n<matching handoff template copied verbatim from handoff-format.md>\n```\n\nHidden workers cannot load skills, references, or conversation history. Copy the\nmatching block from `handoff-format.md`; a filename alone is insufficient. Cite\npaths to any prerequisite synthesis artifact instead of restating accumulated\nchat. For current-doc research, require checks for versioned or time-sensitive\nfacts. Remind candidate workers not to revert unrelated changes.\n\nContinue only non-overlapping manager work while workers run.\n\n## Model routing\n\nWhen the installation supports worker-specific models, use\n`OPENCODE_FLOW_READONLY_WORKER_MODEL` for evidence, validation, and audit;\n`OPENCODE_FLOW_REVIEW_WORKER_MODEL` for review and verification;\n`OPENCODE_FLOW_CANDIDATE_WORKER_MODEL` for candidate implementation; and\n`OPENCODE_FLOW_WORKER_MODEL` as fallback. Model ids are installation-specific\n`provider/model` values. Leave overrides unset when the provider is unknown and\nprefer stronger models where incorrect findings or patches are expensive.\n";
330
+
331
+ // skills/flow/references/parallel-manifest.md
332
+ var parallel_manifest_default = `# Parallel pass manifest
333
+
334
+ Read this only after \`parallel-decision.md\` selects a parallel or candidate
335
+ pass. The manifest is the pre-fan-out coverage gate and the accounting contract
336
+ for every worker result.
337
+
338
+ ## Orient and slice
339
+
340
+ Call \`flow_status\` when a Flow session may exist. Read enough code, schemas,
341
+ docs, tests, commands, or artifacts to identify real slices. Keep the question
342
+ that determines whether fan-out is valid in manager context.
343
+
344
+ Split by an axis that keeps work independent: modules or paths, routes or
345
+ endpoints, risk lenses, commands, data ranges, or atomic claims. Give each slice
346
+ a one-line scope, expected coverage, checkable output, dependencies, write
347
+ scope, and verification tier. Shared files, fixtures, schemas, and public
348
+ contracts normally stay serial unless candidate work uses isolated worktrees.
349
+
350
+ ## Write the manifest
351
+
352
+ Before spawning, write one row per slice plus a totals or completeness check.
353
+ Use stable pass and row ids so later handoffs, verification, synthesis, and
354
+ completion accounting refer to the same work without replaying conversation
355
+ history.
356
+
357
+ | Row id | Slice | Expected coverage | Mode | Depends on | Write scope | Verification tier | Handoff ref | Verification status | Synthesis ref |
358
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
359
+ | \`runtime-read\` | \`src/core/**\` plus tests | 14 files | \`evidence\` | none | none | accept locally | pending | pending | pending |
360
+ | \`release-read\` | CI, package metadata, changelog | 6 files | \`audit\` | none | none | verify once | pending | pending | pending |
361
+
362
+ Use runtime \`writeScope\` values exactly: \`none\`, \`manager-serial\`, \`exact-path\`,
363
+ \`isolated-worktree\`, or \`mixed\`.
364
+
365
+ Before launch:
366
+
367
+ - Reconcile countable work such as files, routes, commands, rows, findings,
368
+ screenshots, or claims. Slice totals must have no overlaps, gaps, or empty
369
+ rows.
370
+ - When scope is not countable, state a completeness rule such as "all changed
371
+ files plus callers" or "all public commands plus release docs."
372
+ - Assign a verification tier before handoffs arrive.
373
+ - Record dependency edges. Spawn a dependent row only after its prerequisite
374
+ has a verified handoff or manager synthesis that settles the dependency.
375
+ - Fix an unreconciled slice map centrally before fan-out.
376
+
377
+ N spawned rows require N collected and checked handoffs before synthesis.
378
+
379
+ ## Implementation decision rows
380
+
381
+ Add an implementation decision row even when no worker is spawned. Record:
382
+
383
+ - \`kind: "implementation-decision"\`
384
+ - the valid decision, eligibility, and candidate-decision pairing from
385
+ \`parallel-decision.md\`
386
+ - \`decisionFactors\`, \`decisionReason\`, and \`writeScope: "manager-serial"\`
387
+ - \`workerCount: 0\`, a stable row id, verification status, and outcome
388
+
389
+ When \`candidateDecision\` is \`used\`, record actual candidate execution evidence
390
+ and raise worker counts accordingly. A zero-worker record cannot claim candidate
391
+ use. Subtype counts may not exceed total worker count.
392
+
393
+ ## Persistence
394
+
395
+ The conversation is sufficient for one bounded pass. When a follow-up pass or
396
+ session resume is plausible, persist the accounted manifest with the synthesis
397
+ in a manager-owned temporary artifact outside \`.flow/**\` and outside the repo
398
+ worktree. The runtime stores bounded accounting, not complete worker handoffs.
399
+ `;
400
+
401
+ // skills/flow/references/parallel-orchestration.md
402
+ var parallel_orchestration_default = `# Parallel orchestration
403
+
404
+ Use this index after a serial orientation pass shows that independent slices
405
+ may reduce a named discovery, validation, review, audit, verification, or
406
+ implementation uncertainty. The root manager owns the Flow session and every
407
+ state-changing \`flow_*\` call throughout the pass.
408
+
409
+ ## Load only the selected branch
410
+
411
+ 1. Read \`parallel-decision.md\` whenever deciding whether work should fan out.
412
+ 2. Stop loading parallel references when the decision is serial. Record the
413
+ implementation decision when the active feature requires one.
414
+ 3. After selecting a parallel or candidate pass, read
415
+ \`parallel-manifest.md\`, then \`parallel-execution.md\`.
416
+ 4. When handoffs return, read \`parallel-synthesis.md\` before accepting claims,
417
+ recording evidence, or presenting a result.
418
+ 5. Copy exactly one matching worker response template from \`handoff-format.md\`
419
+ into each worker prompt. Hidden workers cannot load skills or references.
420
+ 6. Read \`parallel-pass-example.md\` only when a concrete end-to-end example is
421
+ needed.
422
+
423
+ Do not preload the manifest, worker, and synthesis runbooks merely because a
424
+ task could be parallel. The decision reference is enough to keep serial work
425
+ serial.
426
+
427
+ ## Pass routing
428
+
429
+ | Situation | Pass | Typical worker |
430
+ | --- | --- | --- |
431
+ | Repo shape is unclear before planning | Discovery | \`flow-evidence-worker\` |
432
+ | A broad finding set needs refutation | Audit | \`flow-audit-worker\` |
433
+ | Changed files or risk lenses exceed one review pass | Review | \`flow-reviewer\` |
434
+ | Test strategy or route coverage is unclear | Validation | \`flow-validation-worker\` |
435
+ | A claim is surprising, high-stakes, single-source, or payload-bound | Verification | \`flow-verifier-worker\` |
436
+ | An authorized independent implementation slice exists | Candidate | \`flow-candidate-worker\` |
437
+
438
+ Only the manager synthesizes the pass, decides whether evidence is sufficient,
439
+ integrates candidate patches, records Flow state, or returns the final verdict.
752
440
  `;
753
441
 
754
442
  // skills/flow/references/parallel-pass-example.md
755
443
  var parallel_pass_example_default = `# Parallel pass example
756
444
 
757
- Use this example after \`parallel-orchestration.md\` when a broad Flow task needs a
758
- concrete pass shape. The project below is illustrative; derive your own slices
759
- from the actual repo during serial orientation.
445
+ Use this example only after \`parallel-orchestration.md\` routes a broad Flow task
446
+ to fan-out. It illustrates the manifest, execution, and synthesis references;
447
+ derive real slices from the actual repo during serial orientation.
760
448
 
761
449
  Goal: review whether a web app's API error handling is consistent before
762
450
  planning a refactor.
@@ -842,18 +530,21 @@ keeps only verified or clearly labeled claims, and records one artifact such as
842
530
  a plan decision, review payload, or docs patch. Raw handoffs and unverified
843
531
  suggestions do not move into the next pass or user-facing answer.
844
532
 
845
- If the pass shaped feature execution, the manager records compact accounting in
533
+ If the pass shaped feature execution, the manager records bounded accounting in
846
534
  \`flow_feature_complete.orchestrationPasses\`, such as pass id
847
535
  \`api-error-handling-read\`, kind \`review\`, worker count \`3\`, slice ids
848
536
  \`routes-auth\`, \`routes-billing\`, and \`routes-admin\`, verification status
849
537
  \`mixed\` or \`passed\`, and a synthesis ref pointing to the manager-owned summary.
850
538
  `;
851
539
 
540
+ // skills/flow/references/parallel-synthesis.md
541
+ var parallel_synthesis_default = "# Parallel pass synthesis\n\nRead this when worker handoffs return. Account for every manifest row, verify\nmaterial claims, and let only the root manager synthesize or mutate Flow state.\n\n## Account for handoffs\n\nCheck each manifest row before synthesis. A missing, errored, empty,\nunstructured, malformed, `partial`, or `blocked` response is a coverage gap.\nFor each row record:\n\n- `handoffRefs`: worker ids or reopenable artifact locations.\n- `verificationStatus`: `not-needed`, `pending`, `passed`, `failed`, `mixed`,\n or `downgraded`.\n- `outcome`: `accepted`, `modified`, `rejected`, `partial`, `not-covered`, or\n `superseded`.\n- `synthesisRef`: the manager-owned result that carries accepted work forward.\n\nSerial and skipped decision rows have no handoff, but still require an id,\ndecision, reason, verification status, and outcome.\n\nWorker failure ladder:\n\n1. Retry once with a narrower slice and the first attempt's concrete gap.\n2. Cover the slice directly in manager context if the retry fails.\n3. Carry a persistent blocker into synthesis as `not-covered`.\n\nNever present incomplete coverage as a complete pass.\n\n## Accept and verify\n\nTreat worker `Status: success` as a claim, not proof. Accept a handoff only when:\n\n- status is exactly `success`, `partial`, or `blocked` and every required\n section is non-empty;\n- coverage matches the assigned slice or names every omission;\n- important claims have concrete evidence and confidence;\n- paths, commands, screenshots, URLs, counts, and metrics resolve;\n- evidence supports the assertion rather than merely its topic;\n- findings stay inside the assigned slice;\n- dependency claims cite a verified upstream handoff or synthesis;\n- candidate work identifies exact-path or isolated-worktree ownership and the\n manager's patch inspection result;\n- contradictions are settled from source evidence or marked contested.\n\nDemote, drop, retry, or independently verify claims that fail these checks.\n\n### Verification tiers\n\nAssign the cheapest tier that matches the consequence of error:\n\n- **Accept locally**: direct, low-risk evidence the manager can cheaply inspect\n or recount.\n- **Verify once**: use `flow-verifier-worker` for surprising, inferred,\n low-confidence, citation-heavy, contested, single-source, or\n Flow-payload-bound claims, including counts and command results.\n- **Verify strongly**: independently inspect or rerun evidence for blocking,\n release-sensitive, data-loss, security, persistence, permissions, or public\n API claims.\n- **Do not accept**: unsupported, out-of-scope, contradicted, or topic-only\n evidence.\n\nVerifier prompts use stable ids, one atomic assertion and cited source or\ncommand per id, and one exact acceptance question. Do not reveal the generating\nworker or ask the verifier to redesign the work.\n\n## Synthesize\n\nBefore presenting or recording a result:\n\n- Preserve meaningful distinctions between verified, single-source, inferred,\n and unresolved claims.\n- Resolve worker conflicts from the cited artifact or command; never average\n contradictory summaries.\n- Run the strongest practical local check for the deliverable.\n- For medium- or high-risk broad implementation, use one verifier after manager\n synthesis to check planned coverage, worker validation claims, changed code,\n generated artifacts, and plausible test coverage.\n- Re-read critical sources that support the final decision.\n- Move only distilled evidence forward and name remaining gaps honestly.\n\nPlanning evidence may become requirements, decisions, targets, validation, or a\nreview-first feature. Authorized command evidence may become `validationRun`\nonly with exact command, status, and observed result. Review workers inform but\ndo not own the final review payload. Audit findings must survive refutation.\nCandidate patches become usable only after manager inspection, integration, and\nvalidation in the Flow-managed workspace.\n\n## Record bounded accounting\n\nUse the canonical manager record in `handoff-format.md` for every material pass\nor implementation decision. Runtime semantics are:\n\n- `candidateDecision: \"used\"` requires actual candidate execution evidence.\n- `candidateDecision: \"serial_required\"` means candidate work was ineligible.\n- `candidateEligibility: \"eligible\"` plus `candidateDecision: \"skipped\"`\n increments skipped-candidate accounting.\n- Candidate and verifier pass counts come from actual pass kind, mode, or worker\n count evidence, never a decision label alone.\n\nKeep full handoffs, scratch tables, and long logs out of `.flow/session.json`.\nWhen another pass or resume is likely, persist the accounted manifest, accepted\nclaims with evidence and confidence, dropped claims with short reasons, and\nopen gaps in a manager-owned temporary file outside `.flow/**` and the repo\nworktree. Follow-up prompts cite that artifact; do not replay the transcript.\n\n## Extend or stop\n\nStop when every manifest row and dependency is accounted for, accepted claims\nare evidenced and scoped, material claims have the required verification, and\nremaining gaps are explicit but non-blocking.\n\nStart at most one routine follow-up pass when material scope was missed,\nworkers disagree on a decision-changing claim, a high-impact claim needs more\nverification, a newly verified dependency unlocks a slice, or a rejected\ncandidate still has a cheaper isolated alternative. Extra passes require a\nspecific high-impact reason. Workers never recursively launch workers; the\nmanager creates any follow-up manifest and prompt.\n";
542
+
852
543
  // skills/flow/references/recovery-playbook.md
853
544
  var recovery_playbook_default = '# Recovery playbook\n\nUse this when a Flow tool returns `status: "error"`, a blocker, or a `nextAction` that conflicts with memory.\n\n## First response\n\n1. Re-anchor with `flow_status`.\n2. Read the returned `summary`, `recovery`, `lastError`, and active feature.\n3. Fix the cause, then retry the smallest valid Flow action.\n\n## Common cases\n\n- `missing_session`: start with `flow_plan_save` using the user\'s goal.\n- `missing_goal`: ask for a concrete goal before planning.\n- `Approved plans cannot be changed`: use `flow_feature_reset` when only affected features need another pass; otherwise close and start a new goal.\n- `No feature is currently running`: call `flow_run_start` before completing.\n- `already in progress`: finish, reset, or block the active feature before starting another.\n- `Completion requires recorded validation evidence`: run real validation and include at least one passing `validationRun`.\n- `Completion requires all recorded validation to pass`: fix failures and rerun. Do not relabel failed checks as passed.\n- `Non-final feature completion requires targeted validation`: use `validationScope: "targeted"` for ordinary features.\n- `Final feature completion requires broad validation`: run the project-level gate and use `validationScope: "broad"`.\n- `Feature review depth ... does not meet the plan requirement`: rerun review\n at the feature\'s planned depth or reset/replan if the depth was chosen\n incorrectly.\n- `Completion requires a passing featureReview`: run or request a real review and include a passing `featureReview` only when there are no blocking findings.\n- `Review retry budget exhausted`: stop and report the remaining blocker. Do\n not keep patching; reset or replan only after explicit user direction.\n- `Final feature completion requires a finalReview`: perform final review and include `finalReview`.\n- `Final review depth must match the plan policy`: use `reviewDepth` equal to the approved plan\'s `finalReviewPolicy`; valid final-review values are `broad` and `detailed`.\n- `Cannot close ... unfinished features`: complete, reset, defer, or abandon honestly. Do not mark completed while work remains.\n\n## Reset guidance\n\nUse `flow_feature_reset` when the active or completed work was built on the wrong assumption, validation revealed a design issue, dependencies need to be rerun, or dependent features must be invalidated. Resetting a feature also resets its dependents.\n\n## Closure guidance\n\nUse `flow_session_close`:\n\n- `completed`: only after all planned features are complete.\n- `deferred`: the user intentionally postpones unfinished work.\n- `abandoned`: the session should be archived without claiming delivery.\n\nAfter closure, the active `.flow/session.json` is removed and the archived JSON is stored under `.flow/history/`.\n';
854
545
 
855
546
  // skills/flow/SKILL.md
856
- var SKILL_default = "---\nname: flow\ndescription: Manage the end-to-end Flow loop for skills-first OpenCode work. Use when a user asks for Flow-guided delivery from goal to completion, resumable autonomous delivery, or resuming or closing a Flow session. For plan-only work use flow-plan; for executing one approved feature use flow-run.\n---\n\n# Flow\n\nUse Flow as a minimal state ledger, not as a framework. Skills provide judgment; the runtime only records the approved plan, active feature, validation evidence, review evidence, and closure.\n\nRouting: this manager skill owns the whole loop and every state-changing `flow_*` call. Load `flow-plan` alone for plan-only requests and `flow-run` alone when an approved plan needs one feature executed. Answer status-only questions with `flow_status`; no skill load is needed. `flow-test`, `flow-deslop`, and `flow-ui-quality` are optional helpers loaded from inside the loop; `flow-commit` is user-triggered only and never part of the autonomous loop.\n\n## Loop\n\n1. Call `flow_status` first. Trust its active session and next action over conversation memory.\n If the result includes `setup.skills`, follow the Skill Availability rules\n below before loading any Flow skill.\n If it includes `session.resumePacket` or `session.budget.phaseBoundary`, stop\n and report the resume instructions unless this is a fresh user invocation\n explicitly resuming the session. Only then may the next `flow_run_start` use\n `phaseBoundaryAck: true`.\n2. If there is no active session and the user gave a goal, load `flow-plan`, save a plan with `flow_plan_save`, then approve it with `flow_plan_approve` only after explicit user approval or prior authorization for autonomous implementation. If there is no goal, ask for one.\n3. Load `flow-run`, call `flow_run_start`, implement exactly one feature, validate it, and prepare a `flow_feature_complete` payload. For validation-heavy, regression-sensitive, browser QA, route QA, or failure-prone work, use `flow-test` to choose and summarize evidence before completion.\n4. Load `flow-review` for the required feature review. Send a compact review\n packet, not the accumulated root transcript. The reviewer reports\n `featureReviewDepth` and `featureReview`; the manager records both inside\n `flow_feature_complete`.\n5. On the final feature, run broad validation and include `finalReview` in the same `flow_feature_complete` call. Its `reviewDepth` must match the plan's `finalReviewPolicy`.\n6. After all features are complete, archive the session with `flow_session_close` using `kind: \"completed\"`.\n\nUse `references/parallel-orchestration.md` for broad read-only discovery, audit, validation, review, verification, or candidate implementation passes. It is the whole pass playbook orient, slice, manifest, fan out, account, verify, synthesize, extend or stop and its `references/handoff-format.md` companion holds the worker report templates the manager pastes into prompts. Hidden Flow workers are injected by plugin config; invoke the named worker when it is available. The manager owns every `flow_*` state change.\n\nDo not commit, push, amend, rebase, publish, or mutate releases during the\nautonomous Flow loop. Load `flow-commit` only when the user explicitly asks for\ncommit preparation or commit creation.\n\n## Skill Availability\n\nIf `flow_status` returns `setup.skills`, report that setup status and stop\nnative-loading Flow skills in the current OpenCode startup. Missing, incomplete,\nor outdated managed skills require a sync/restart cycle before their native skill\ninstructions can be trusted by the running process. Public command bundles are\nself-contained and may continue when the command prompt already embeds the\nrequired Flow instructions.\n\nIf optional helper skills such as `flow-test`, `flow-deslop`, or\n`flow-ui-quality` are unavailable, continue only with explicit coverage gaps. Do\nnot copy their rubrics into another skill and do not claim their quality checks\nwere completed.\n\n## Runtime Surface\n\n- `flow_status`: read the active session.\n- `flow_plan_save`: create a session and/or save a draft plan.\n- `flow_plan_approve`: lock the draft plan.\n- `flow_run_start`: start one runnable feature.\n- `flow_feature_complete`: record completion or a real blocker with validation and review evidence.\n- `flow_feature_reset`: reset one feature and its dependents.\n- `flow_session_close`: archive the active session as `completed`, `deferred`, or `abandoned`.\n\nThere is no `flow_context`, no separate review-record tool, and no multi-session activation surface. The single active source of truth is `.flow/session.json`; closed sessions are archived under `.flow/history/`.\n\nPlanning and running require loaded Flow tools; do not simulate plan approval or feature completion when the runtime is unavailable. Review may still return advisory output when tools, skills, or references are stale or unavailable, but the manager must not record it as Flow-gated evidence.\n\n## Hard Gates\n\n- Approved plans are immutable. To change direction, reset affected features or close the session and start a new goal.\n- Only one feature can be active at a time.\n- Each feature's planned `reviewDepth` is the minimum accepted\n `featureReviewDepth` for completion.\n- Completion requires at least one passing `validationRun` entry.\n- Non-final completion requires `validationScope: \"targeted\"`.\n- Final completion requires `validationScope: \"broad\"` and a passing `finalReview`.\n- Every completed feature requires a passing `featureReview` with no blocking findings.\n- Failed reviews pause the loop by default. Autonomous repair may make at most\n one repair plus one retry review before stopping.\n- Phase boundaries stop the current root session; resume from\n `.flow/session.json` in a fresh OpenCode session.\n- `flow_session_close` accepts `kind: \"completed\"` only after an approved plan has passed final completion.\n\n## Budget And Retry Boundaries\n\nFlow enforces review retry counts in the runtime ledger and tracks completed\nfeature counts as telemetry only. The current OpenCode plugin surface does not\nexpose per-turn token usage to Flow; when usage is visible in the host UI or\nlogs, stop the current autonomous loop once the root session is large enough to\nthreaten latency or cost and report a compact handoff instead of continuing.\nTreat high visible tokens, high non-cache tokens, or repeated reviewer fan-out\nas a reason to finish the current feature, emit the resume packet, and continue\nin a fresh session.\n\n## Recovery\n\n- Confused state: call `flow_status` and follow `nextAction`.\n- Wrong assumption or failed implementation path: use `flow_feature_reset` for the feature and dependents, then rerun from the corrected plan.\n- Missing validation or review evidence: gather real evidence, then call `flow_feature_complete`.\n- Approved plan is materially wrong: reset the affected features, save a revised plan if the session is back in planning; otherwise close and start a new goal.\n- Unknown runtime error: read `summary` and `recovery`; see `references/recovery-playbook.md` for common cases.\n\nNever fabricate validation output, backfill review approval you did not perform, or close as `deferred`/`abandoned` merely to avoid an unfinished-work blocker.\n";
547
+ var SKILL_default = "---\nname: flow\ndescription: Manage the end-to-end Flow loop for skills-first OpenCode work. Use when a user asks for Flow-guided delivery from goal to completion, resumable autonomous delivery, or resuming or closing a Flow session. For plan-only work use flow-plan; for executing one approved feature use flow-run.\n---\n\n# Flow\n\nUse Flow as a minimal state ledger, not as a framework. Skills provide judgment; the runtime only records the approved plan, active feature, validation evidence, review evidence, and closure.\n\nRouting: this manager skill owns the whole loop and every state-changing `flow_*` call. Load `flow-plan` alone for plan-only requests and `flow-run` alone when an approved plan needs one feature executed. Answer status-only questions with `flow_status`; no skill load is needed. `flow-test`, `flow-deslop`, and `flow-ui-quality` are optional helpers loaded from inside the loop; `flow-commit` is user-triggered only and never part of the autonomous loop.\n\n## Loop\n\n1. Call `flow_status` first. Trust its active session and next action over conversation memory.\n If the result includes `setup.skills`, follow the Skill Availability rules\n below before loading any Flow skill.\n If it includes `session.resumePacket` or `session.budget.phaseBoundary`, stop\n and report the resume instructions unless this is a fresh user invocation\n explicitly resuming the session. Only then may the next `flow_run_start` use\n `phaseBoundaryAck: true`.\n2. If there is no active session and the user gave a goal, load `flow-plan`, save a plan with `flow_plan_save`, then approve it with `flow_plan_approve` only after explicit user approval or prior authorization for autonomous implementation. If there is no goal, ask for one.\n3. Load `flow-run`, call `flow_run_start`, implement exactly one feature, validate it, and prepare a `flow_feature_complete` payload. For validation-heavy, regression-sensitive, browser QA, route QA, or failure-prone work, use `flow-test` to choose and summarize evidence before completion.\n4. Load `flow-review` for the required feature review. Send a bounded review\n packet, not the accumulated root transcript. The reviewer reports\n `featureReviewDepth` and `featureReview`; the manager records both inside\n `flow_feature_complete`.\n5. On the final feature, run broad validation and include `finalReview` in the same `flow_feature_complete` call. Its `reviewDepth` must match the plan's `finalReviewPolicy`.\n6. After all features are complete, archive the session with `flow_session_close` using `kind: \"completed\"`.\n\nFor broad discovery, audit, validation, review, verification, or candidate work,\nuse `references/parallel-orchestration.md` as the routing index. Read\n`references/parallel-decision.md` first. Load\n`references/parallel-manifest.md` and `references/parallel-execution.md` only\nafter selecting fan-out, then read `references/parallel-synthesis.md` when\nhandoffs return. Paste one matching template from\n`references/handoff-format.md` into each worker prompt. Hidden Flow workers are\ninjected by plugin config; invoke the named worker when available. The manager\nowns every `flow_*` state change.\n\nDo not commit, push, amend, rebase, publish, or mutate releases during the\nautonomous Flow loop. Load `flow-commit` only when the user explicitly asks for\ncommit preparation or commit creation.\n\n## Skill Availability\n\nIf `flow_status` returns `setup.skills`, report that setup status and stop\nnative-loading Flow skills in the current OpenCode startup. Missing, incomplete,\nor outdated managed skills require a sync/restart cycle before their native skill\ninstructions can be trusted by the running process. Public command bundles are\nself-contained and may continue when the command prompt already embeds the\nrequired Flow instructions.\n\nIf optional helper skills such as `flow-test`, `flow-deslop`, or\n`flow-ui-quality` are unavailable, continue only with explicit coverage gaps. Do\nnot copy their rubrics into another skill and do not claim their quality checks\nwere completed.\n\n## Runtime Surface\n\n- `flow_status`: read the active session.\n- `flow_plan_save`: create a session and/or save a draft plan.\n- `flow_plan_approve`: lock the draft plan.\n- `flow_run_start`: start one runnable feature.\n- `flow_feature_complete`: record completion or a real blocker with validation and review evidence.\n- `flow_feature_reset`: reset one feature and its dependents.\n- `flow_session_close`: archive the active session as `completed`, `deferred`, or `abandoned`.\n\nThere is no `flow_context`, no separate review-record tool, and no multi-session activation surface. The single active source of truth is `.flow/session.json`; closed sessions are archived under `.flow/history/`.\n\nPlanning and running require loaded Flow tools; do not simulate plan approval or feature completion when the runtime is unavailable. Review may still return advisory output when tools, skills, or references are stale or unavailable, but the manager must not record it as Flow-gated evidence.\n\n## Hard Gates\n\n- Approved plans are immutable. To change direction, reset affected features or close the session and start a new goal.\n- Only one feature can be active at a time.\n- Each feature's planned `reviewDepth` is the minimum accepted\n `featureReviewDepth` for completion.\n- Completion requires at least one passing `validationRun` entry.\n- Non-final completion requires `validationScope: \"targeted\"`.\n- Final completion requires `validationScope: \"broad\"` and a passing `finalReview`.\n- Every completed feature requires a passing `featureReview` with no blocking findings.\n- Failed reviews pause the loop by default. Autonomous repair may make at most\n one repair plus one retry review before stopping.\n- Phase boundaries stop the current root session; resume from\n `.flow/session.json` in a fresh OpenCode session.\n- `flow_session_close` accepts `kind: \"completed\"` only after an approved plan has passed final completion.\n\n## Recovery\n\n- Confused state: call `flow_status` and follow `nextAction`.\n- Wrong assumption or failed implementation path: use `flow_feature_reset` for the feature and dependents, then rerun from the corrected plan.\n- Missing validation or review evidence: gather real evidence, then call `flow_feature_complete`.\n- Approved plan is materially wrong: reset the affected features, save a revised plan if the session is back in planning; otherwise close and start a new goal.\n- Unknown runtime error: read `summary` and `recovery`; see `references/recovery-playbook.md` for common cases.\n\nNever fabricate validation output, backfill review approval you did not perform, or close as `deferred`/`abandoned` merely to avoid an unfinished-work blocker.\n";
857
548
 
858
549
  // skills/flow-commit/SKILL.md
859
550
  var SKILL_default2 = `---
@@ -1102,9 +793,13 @@ var parallel_discovery_default = `# Parallel discovery
1102
793
 
1103
794
  Use this only after a serial orientation pass has identified the repo shape and the likely slices. Workers are read-only evidence gatherers; the planner owns the plan.
1104
795
 
1105
- For broad parallel passes, also load \`../../flow/references/parallel-orchestration.md\`.
1106
- Use its pass manifest as the pre-fan-out coverage gate and
1107
- \`../../flow/references/handoff-format.md\` response shapes.
796
+ For broad parallel passes, start with
797
+ \`../../flow/references/parallel-orchestration.md\`. If it selects fan-out, use
798
+ \`../../flow/references/parallel-manifest.md\` as the coverage gate,
799
+ \`../../flow/references/parallel-execution.md\` for worker prompts, and
800
+ \`../../flow/references/parallel-synthesis.md\` when handoffs return. Copy the
801
+ matching \`../../flow/references/handoff-format.md\` response shape into each
802
+ prompt.
1108
803
 
1109
804
  ## Good slices
1110
805
 
@@ -1128,8 +823,8 @@ config, or release surfaces in the pass manifest.
1128
823
 
1129
824
  ## Manifest and prompts
1130
825
 
1131
- Write the pass manifest and the worker prompts exactly as Stages 3 and 4 of
1132
- \`../../flow/references/parallel-orchestration.md\` define them: one manifest row
826
+ Write the pass manifest and worker prompts as \`parallel-manifest.md\` and
827
+ \`parallel-execution.md\` define them: one manifest row
1133
828
  per slice with expected coverage, dependencies, write scope, and a verification
1134
829
  tier, and a self-contained prompt per worker naming the mode (usually
1135
830
  \`evidence\`), the exact slice, and the expected coverage. Discovery-specific
@@ -1156,7 +851,7 @@ Convert only evidence-backed work into plan fields:
1156
851
  If workers disagree, inspect the source artifact yourself. If a candidate finding lacks a concrete citation or refutation pass, make it a review-first deliverable rather than a fix feature.
1157
852
 
1158
853
  Apply the manager synthesis barrier from
1159
- \`../../flow/references/parallel-orchestration.md\`: only distilled,
854
+ \`../../flow/references/parallel-synthesis.md\`: only distilled,
1160
855
  evidence-backed claims become plan fields.
1161
856
  `;
1162
857
 
@@ -1165,7 +860,7 @@ var plan_quality_checklist_default = `# Plan quality checklist
1165
860
 
1166
861
  Use this checklist before \`flow_plan_save\` and again before approval if the plan
1167
862
  changed during discussion. The goal is not a long planning artifact; it is a
1168
- compact plan another agent can execute without rediscovering the work.
863
+ concise plan another agent can execute without rediscovering the work.
1169
864
 
1170
865
  ## Must pass
1171
866
 
@@ -1468,14 +1163,19 @@ description: "Use when Flow work needs planning before implementation: a new goa
1468
1163
 
1469
1164
  # Flow Plan
1470
1165
 
1471
- Use this skill before implementation. The output is a compact plan the runtime can enforce and future agents can execute without rediscovering the goal.
1166
+ Use this skill before implementation. The output is a concise plan the runtime can enforce and future agents can execute without rediscovering the goal.
1167
+
1168
+ ## Planning runtime availability
1472
1169
 
1473
1170
  If \`flow_plan_save\` or \`flow_plan_approve\` is unavailable, stop and tell the user to check that \`opencode-plugin-flow\` is loaded in OpenCode. Planning requires the loaded Flow runtime.
1474
1171
 
1475
1172
  ## Inspect first
1476
1173
 
1477
1174
  - Read the files, docs, tests, package scripts, and local conventions that determine the work.
1478
- - For broad discovery, read \`references/parallel-discovery.md\` after a serial orientation pass. Use \`../flow/references/parallel-orchestration.md\` when discovery needs multiple workers, and write its pass manifest before fan-out.
1175
+ - For broad discovery, read \`references/parallel-discovery.md\` after a serial
1176
+ orientation pass. When multiple workers may help, start with
1177
+ \`../flow/references/parallel-orchestration.md\` and load only the branch it
1178
+ selects.
1479
1179
  - Helper rule: when a named helper skill is unavailable, record a planning gap
1480
1180
  and keep the corresponding claims conservative instead of simulating its
1481
1181
  checks.
@@ -1579,6 +1279,65 @@ See \`references/planning-examples.md\` for payload examples and decomposition
1579
1279
  anti-patterns.
1580
1280
  `;
1581
1281
 
1282
+ // skills/flow-review/references/hidden-reviewer-contract.md
1283
+ var hidden_reviewer_contract_default = `# Hidden Flow reviewer contract
1284
+
1285
+ This is the canonical role-safe contract bundled into \`flow-reviewer\`. It does
1286
+ not grant manager capabilities and does not tell the hidden reviewer to load
1287
+ skills, run commands, edit files, or launch workers.
1288
+
1289
+ ## Role and availability
1290
+
1291
+ You are an independent read-only reviewer. Call \`flow_status\` when available,
1292
+ prefer the manager's bounded review packet, and inspect the actual changed
1293
+ artifacts and supplied validation evidence. Only the root manager may mutate
1294
+ Flow state; return findings without fixing them. Your permissions intentionally
1295
+ exclude edits, shell commands, skill loading, and nested workers. Record missing
1296
+ evidence as a gap or blocker instead of claiming coverage.
1297
+
1298
+ If Flow setup or required evidence is stale or unavailable, label the result
1299
+ advisory and do not present it as Flow-gated evidence.
1300
+
1301
+ ## Feature review depths
1302
+
1303
+ - \`quick\`: docs, comments, config-only changes, generated output, or mechanical
1304
+ changes fully covered by tooling.
1305
+ - \`standard\`: read every changed file and relevant test; this is the default for
1306
+ ordinary implementation work.
1307
+ - \`detailed\`: inspect risky behavior, persistence, security, cross-module
1308
+ refactors, migrations, releases, weak validation, and expensive edge cases.
1309
+
1310
+ The actual feature-review depth must meet or exceed the approved feature's
1311
+ \`reviewDepth\`. Final reviews use \`reviewDepth: "broad"\` or \`"detailed"\` and must
1312
+ match the plan's \`finalReviewPolicy\`. Claim only the depth actually performed.
1313
+
1314
+ ## Direct review outputs
1315
+
1316
+ For a direct feature review, return only \`featureReviewDepth\` plus
1317
+ \`featureReview\`. For a direct final review, return only \`status\`, \`summary\`,
1318
+ \`blockingFindings\`, and \`reviewDepth\`. Use \`status: "failed"\` whenever a
1319
+ blocking finding remains. Advisory notes belong in the summary, while
1320
+ \`blockingFindings\` contains only blockers.
1321
+
1322
+ ## Special-case evidence
1323
+
1324
+ - Cleanup/refactor: verify that the smell was real, refutation paths were
1325
+ checked, and behavior was preserved. If helper evidence is unavailable,
1326
+ record a coverage gap instead of approving the cleanup claim.
1327
+ - UI/frontend: verify relevant states and supplied visual evidence. When visual
1328
+ evidence is missing, record a coverage gap and do not claim visual polish was
1329
+ verified.
1330
+ - Audit reports: findings must survive refutation against cited code, guards,
1331
+ and mitigating paths before they can drive fixes.
1332
+
1333
+ ## Completion checkpoint
1334
+
1335
+ Before returning, confirm that the stated depth matches work actually
1336
+ inspected, every blocker has concrete evidence, missing coverage is explicit,
1337
+ and the response uses exactly the direct-review payload or assigned-slice
1338
+ handoff requested.
1339
+ `;
1340
+
1582
1341
  // skills/flow-review/references/review-rubric.md
1583
1342
  var review_rubric_default = `# Review rubric
1584
1343
 
@@ -1731,13 +1490,15 @@ These instructions run in two contexts, and only one of them can load helpers:
1731
1490
  subagents. In this context, skip every "load" and "fan out" instruction
1732
1491
  below: judge from the diff, the plan fields, and the recorded validation
1733
1492
  evidence, and record a coverage gap for any judgment that would have needed
1734
- a helper skill or a command run.
1493
+ a helper skill or a command run. The bundled hidden reviewer prompt uses the
1494
+ canonical role-safe contract in
1495
+ \`references/hidden-reviewer-contract.md\`.
1735
1496
 
1736
1497
  ## Start
1737
1498
 
1738
1499
  - Call \`flow_status\` when available.
1739
1500
  - Identify whether this is a feature review or final review.
1740
- - Prefer the manager's compact review packet over parent-session memory. The
1501
+ - Prefer the manager's bounded review packet over parent-session memory. The
1741
1502
  packet should name the active feature, minimum \`reviewDepth\`, changed files,
1742
1503
  diff summary, validation evidence, and targeted paths or risk lenses. If the
1743
1504
  packet is missing important scope or evidence, record that as a coverage gap
@@ -1798,14 +1559,15 @@ Use \`status: "failed"\` when any blocking finding remains. Advisory findings ma
1798
1559
  - Cleanup/refactor: in manager context, load \`flow-deslop\`; verify the smell was real, refutation paths were checked, and behavior was preserved. If it is unavailable or you are the hidden reviewer, record a coverage gap instead of approving cleanup claims.
1799
1560
  - UI/frontend: in manager context, load \`flow-ui-quality\`; verify state coverage and visual evidence when a local target was available. If it is unavailable or you are the hidden reviewer, record a coverage gap and do not claim visual polish was verified.
1800
1561
  - Audit reports: use \`../flow-run/references/audit-rubric.md\`; findings must survive refutation before they can drive fix features.
1801
- - Large reviews (manager context only): use
1562
+ - Large reviews (manager context only): start with
1802
1563
  \`../flow/references/parallel-orchestration.md\` for read-only slices by
1803
- changed-file group, risk lens, or validation surface. Use the named review,
1804
- audit, evidence, or validation agents from that reference instead of generic
1805
- subagents. Write its pass manifest before fan-out and apply its Stage 6
1806
- handoff acceptance and verification tiers; only the manager
1807
- returns the final \`featureReview\` or \`finalReview\` payload. If that reference
1808
- is unavailable in the current context (for example in a bundled public Flow
1564
+ changed-file group, risk lens, or validation surface. If fan-out is selected,
1565
+ use \`../flow/references/parallel-manifest.md\`,
1566
+ \`../flow/references/parallel-execution.md\`, and
1567
+ \`../flow/references/parallel-synthesis.md\` with the named review, audit,
1568
+ evidence, or validation workers; only the manager returns the final
1569
+ \`featureReview\` or \`finalReview\` payload. If those references are unavailable
1570
+ in the current context (for example in a bundled public Flow
1809
1571
  command that does not include it), review serially and record the skipped
1810
1572
  fan-out as a coverage gap instead of improvising worker contracts. The hidden
1811
1573
  reviewer cannot spawn workers; it reviews its assigned scope directly and
@@ -1833,7 +1595,7 @@ A finding that survives this pass is worth reporting. A finding you did not try
1833
1595
 
1834
1596
  ## Parallel audit slices
1835
1597
 
1836
- For broad audits, use \`../../flow/references/parallel-orchestration.md\` to split
1598
+ For broad audits, start with \`../../flow/references/parallel-orchestration.md\` to split
1837
1599
  read-only slices by module, data flow, or risk lens. Workers surface candidates;
1838
1600
  the audit author owns the report. Apply its handoff format and verification
1839
1601
  gates. Before blocking severity, dedupe, trace guards, fill cross-layer checks,
@@ -1889,7 +1651,9 @@ Use the strongest practical tier. For risky work, combine tiers.
1889
1651
  - Each \`validationRun\` entry has \`command\`, \`status\`, and \`summary\`.
1890
1652
  - Completion accepts only passing entries. Failed or skipped checks belong in the summary/notes and must be resolved or explained as blockers.
1891
1653
  - Do not claim a command was run unless it was run in this session or directly reported by a trusted worker with raw output.
1892
- - Worker-reported command output must satisfy the verification stage of \`../../flow/references/parallel-orchestration.md\`: exact command, status, raw outcome summary, coverage, and manager acceptance.
1654
+ - Worker-reported command output must satisfy the acceptance and verification
1655
+ rules in \`../../flow/references/parallel-synthesis.md\`: exact command, status,
1656
+ raw outcome summary, coverage, and manager acceptance.
1893
1657
  - Include scope in the summary: what behavior, files, routes, or states the check covered.
1894
1658
  - UI work should include browser or screenshot evidence when the app can run locally.
1895
1659
  - Cleanup/refactor work should show behavior preservation, not only formatting success.
@@ -1931,7 +1695,170 @@ Never trim failing output, relabel a failed command as passed, or use "not run"
1931
1695
  `;
1932
1696
 
1933
1697
  // skills/flow-run/SKILL.md
1934
- var SKILL_default6 = '---\nname: flow-run\ndescription: "Use when an approved Flow plan has a feature to implement, validate, or complete in the v4 runtime, and the work is scoped to one active feature. For planning a goal first use flow-plan; for the full goal-to-completion loop or resuming a session use flow."\n---\n\n# Flow Run\n\nUse this skill for implementation after a Flow plan is approved. Work one feature at a time.\n\nIf `flow_run_start` is unavailable, stop and tell the user to check that `opencode-plugin-flow` is loaded in OpenCode.\n\n## Start\n\n- Call `flow_status`.\n- If `flow_status` returns a `session.resumePacket` or\n `session.budget.phaseBoundary`, stop the current autonomous loop and report\n the resume instructions. Only call `flow_run_start` with\n `phaseBoundaryAck: true` at the start of a fresh user invocation that is\n explicitly resuming the Flow session; do not acknowledge a boundary inside\n the same uninterrupted loop that created it.\n- Call `flow_run_start` with no `featureId` unless the user or plan requires a specific runnable feature.\n- Treat the returned feature as the sole scope until it is completed, blocked, or reset.\n- Helper rule: when a named helper skill is unavailable, record the gap and\n keep the corresponding claims conservative instead of simulating its checks.\n- Load `flow-deslop` for cleanup/refactor features.\n- Load `flow-ui-quality` for frontend, UX, responsive, accessibility, or visual work.\n\n## Implement\n\n- Read the feature `targets`, `summary`, `validation`, dependencies, and plan `requirements`/`decisions`.\n- Treat the feature\'s `reviewDepth` as the minimum feature-review depth that\n must be recorded in `flow_feature_complete`.\n- For broad, risky, or multi-target work, record an implementation pass\n decision before editing: `serial`, `candidate-exact-path`,\n `candidate-worktree`, `tournament`, or `skipped`. Use\n `../flow/references/parallel-orchestration.md` for the decision rules,\n manifest fields, and compact `orchestrationPasses` record.\n- Classify `candidateEligibility` (`eligible`, `not_eligible`, or `unknown`)\n and `candidateDecision` (`used`, `skipped`, or `serial_required`) separately;\n implementation decisions must use `eligible` or `not_eligible` and always set\n an explicit `decision`. The valid pairings and the candidate execution\n evidence rules are in `../flow/references/parallel-orchestration.md` under\n "Implementation pass decision" — follow that reference when composing the\n record.\n- Record structured `decisionFactors`: `shared_state`, `overlapping_files`,\n `small_slice`, `needs_manager_judgment`, `independent_surface`, and\n `validation_available`.\n- Keep edits scoped to the active feature. If new scope appears, stop and replan or defer it to another feature.\n- Preserve unrelated user changes in the worktree.\n- When a wrong assumption invalidates the feature, use `flow_feature_reset`; do not pile patches onto a bad path.\n- Do not stage, commit, push, amend, rebase, publish, or mutate releases as part\n of feature execution. If the user explicitly asks for commit preparation, load\n `flow-commit` only after `flow_feature_complete` has been recorded, unless the\n user explicitly asks for a WIP commit path. Keep Git boundaries separate from\n Flow state recording.\n\n## Validate\n\n- For complex validation, regression-sensitive changes, browser QA, route QA,\n failure-prone checks, unclear coverage, exploratory QA, or\n `validationRun` summarization, load `flow-test` (helper rule applies).\n- Read `references/validation-rubric.md` before completing.\n- Run the strongest practical checks for the changed behavior.\n- Record concrete command names, status, and observed results. "Tests pass" is not evidence.\n- Non-final features complete with `validationScope: "targeted"`.\n- The final feature must run a broad project-level gate and use `validationScope: "broad"`.\n\nFor broad validation research, risky changes, or unclear coverage, use\n`../flow/references/parallel-orchestration.md` to fan out named Flow workers.\nUse the mode-to-agent mapping in that reference instead of generic subagents.\nWrite its pass manifest before fan-out, paste the matching handoff template\nfrom `../flow/references/handoff-format.md` into every worker prompt, and\napply its verification tiers to the handoffs that come back.\nThey may report command output they actually ran or propose focused checks; the\nmanager decides what is strong enough to record.\n\nFor independent implementation attempts, use candidate workers only with\nexplicit user authorization plus isolated worktrees or exact non-overlapping\npath ownership. Treat their output as candidate patches. The manager inspects,\nmerges or rejects, validates, and records Flow state serially. Record whether a\ncandidate was `accepted`, `modified`, or `rejected`.\nWhen a candidate pass or serial/skipped implementation decision materially\nshaped the feature, include its compact record in\n`flow_feature_complete.orchestrationPasses`. Do not paste full worker handoffs\nor long logs into the runtime payload.\n\n## Review and complete\n\nBefore `flow_feature_complete`, obtain a `featureReview` payload. Load\n`flow-review`; for read-only subagent reviews, the manager receives the review\npacket and records both `featureReviewDepth` and `featureReview`.\n\nSend reviewers a compact review packet. Do not rely on the accumulated parent\nconversation. Include only:\n\n- active feature id, title, summary, `reviewDepth`, targets, validation, and dependencies\n- relevant plan requirements, decisions, and final review policy\n- changed files and a short diff summary\n- validation evidence with exact commands, status, and observed result\n- targeted paths or risk lenses the reviewer must inspect\n\nIf the review returns `status: "failed"`, do not fix inside the review pass.\nRecord the failed attempt by calling `flow_feature_complete` with the otherwise\nprepared completion payload, the failed `featureReview`, and the attempted\n`featureReviewDepth`; the runtime will reject completion and update the retry\nbudget. Default to stopping and reporting the blocker. When the user already\nauthorized autonomous implementation, make at most one repair and run one retry\nreview. If the retry fails or the runtime reports review retry budget\nexhausted, stop with the blocker.\n\nIf `flow_status` reports `setup.skills` or `flow-review` cannot be loaded, do\nnot record a Flow-gated `featureReview` or `finalReview`. You may perform an\nadvisory review using available context or the bundled review fallback provided\nby plugin config, then complete with `status: "needs_input"` if review evidence\nis required to proceed.\n\nFor the final feature, also obtain a `finalReview` payload whose `reviewDepth` equals the approved plan\'s `finalReviewPolicy`.\n\nComplete with:\n\n```json\n{\n "status": "ok",\n "featureId": "active-feature-id",\n "summary": "what changed",\n "artifactsChanged": [{ "path": "src/file.ts" }],\n "validationRun": [\n { "command": "bun test tests/foo.test.ts", "status": "passed", "summary": "3 pass, exercised foo behavior" }\n ],\n "validationScope": "targeted",\n "featureReviewDepth": "standard",\n "featureReview": { "status": "passed", "summary": "review summary", "blockingFindings": [] },\n "orchestrationPasses": [\n {\n "id": "active-feature-id-implementation-decision",\n "kind": "implementation-decision",\n "decision": "serial",\n "decisionReason": "Shared contract edits made worker ownership unsafe.",\n "candidateEligibility": "not_eligible",\n "candidateDecision": "serial_required",\n "decisionFactors": ["shared_state", "overlapping_files"],\n "writeScope": "manager-serial",\n "verificationStatus": "not-needed",\n "outcome": "accepted"\n }\n ]\n}\n```\n\nIf `flow_feature_complete` returns a `session.resumePacket` or\n`session.budget.phaseBoundary`, stop after reporting the compact handoff. If\ngenuinely blocked, call `flow_feature_complete` with `status: "needs_input"` and\nan `outcome` that explains the blocker and next step. Never fabricate validation\nor review evidence to force progress.\n';
1698
+ var SKILL_default6 = `---
1699
+ name: flow-run
1700
+ description: "Use when an approved Flow plan has a feature to implement, validate, or complete in the v4 runtime, and the work is scoped to one active feature. For planning a goal first use flow-plan; for the full goal-to-completion loop or resuming a session use flow."
1701
+ ---
1702
+
1703
+ # Flow Run
1704
+
1705
+ Use this skill for implementation after a Flow plan is approved. Work one feature at a time.
1706
+
1707
+ ## Execution runtime availability
1708
+
1709
+ If \`flow_run_start\` is unavailable, stop and tell the user to check that \`opencode-plugin-flow\` is loaded in OpenCode.
1710
+
1711
+ ## Start
1712
+
1713
+ - Call \`flow_status\`.
1714
+ - If \`flow_status\` returns a \`session.resumePacket\` or
1715
+ \`session.budget.phaseBoundary\`, stop the current autonomous loop and report
1716
+ the resume instructions. Only call \`flow_run_start\` with
1717
+ \`phaseBoundaryAck: true\` at the start of a fresh user invocation that is
1718
+ explicitly resuming the Flow session; do not acknowledge a boundary inside
1719
+ the same uninterrupted loop that created it.
1720
+ - Call \`flow_run_start\` with no \`featureId\` unless the user or plan requires a specific runnable feature.
1721
+ - Treat the returned feature as the sole scope until it is completed, blocked, or reset.
1722
+ - Helper rule: when a named helper skill is unavailable, record the gap and
1723
+ keep the corresponding claims conservative instead of simulating its checks.
1724
+ - Load \`flow-deslop\` for cleanup/refactor features.
1725
+ - Load \`flow-ui-quality\` for frontend, UX, responsive, accessibility, or visual work.
1726
+
1727
+ ## Implement
1728
+
1729
+ - Read the feature \`targets\`, \`summary\`, \`validation\`, dependencies, and plan \`requirements\`/\`decisions\`.
1730
+ - Treat the feature's \`reviewDepth\` as the minimum feature-review depth that
1731
+ must be recorded in \`flow_feature_complete\`.
1732
+ - Keep edits scoped to the active feature. If new scope appears, stop and replan or defer it to another feature.
1733
+ - Preserve unrelated user changes in the worktree.
1734
+ - When a wrong assumption invalidates the feature, use \`flow_feature_reset\`; do not pile patches onto a bad path.
1735
+ - Do not stage, commit, push, amend, rebase, publish, or mutate releases as part
1736
+ of feature execution. If the user explicitly asks for commit preparation, load
1737
+ \`flow-commit\` only after \`flow_feature_complete\` has been recorded, unless the
1738
+ user explicitly asks for a WIP commit path. Keep Git boundaries separate from
1739
+ Flow state recording.
1740
+
1741
+ ## Candidate implementation
1742
+
1743
+ \`flow-run\` remains the candidate-implementation manager entry route. Invoke the
1744
+ hidden \`flow-candidate-worker\` only after feature start and a complete pass
1745
+ manifest; never route the user's feature request directly to it.
1746
+
1747
+ For broad, risky, or multi-target work, record an implementation pass decision
1748
+ before editing: \`serial\`, \`candidate-exact-path\`, \`candidate-worktree\`,
1749
+ \`tournament\`, or \`skipped\`. Candidate implementation requires explicit user
1750
+ authorization and either an isolated worktree or exact non-overlapping path
1751
+ ownership. It is eligible only when the slice has an independent surface and
1752
+ practical validation, with no shared state, overlapping files, or unresolved
1753
+ manager judgment. Shared contracts, migrations, lockfiles, generated outputs,
1754
+ tightly coupled callers, unclear ownership, and small slices remain serial.
1755
+
1756
+ Classify \`candidateEligibility\` (\`eligible\`, \`not_eligible\`, or \`unknown\`) and
1757
+ \`candidateDecision\` (\`used\`, \`skipped\`, or \`serial_required\`) separately. Read
1758
+ \`../flow/references/parallel-decision.md\` for valid pairings and factors. After
1759
+ selecting fan-out, read \`../flow/references/parallel-manifest.md\` and
1760
+ \`../flow/references/parallel-execution.md\`, then
1761
+ \`../flow/references/parallel-synthesis.md\` when handoffs return.
1762
+ Set \`decision\`, \`decisionReason\`, \`decisionFactors\`, and \`writeScope\`.
1763
+
1764
+ Candidate workers return patches for manager inspection. The manager accepts,
1765
+ modifies, or rejects them, integrates accepted work, validates, reviews, and
1766
+ records Flow state serially. Record the candidate outcome as \`accepted\`,
1767
+ \`modified\`, or \`rejected\`. When a candidate pass or serial/skipped decision
1768
+ materially shaped the feature, include its bounded record in
1769
+ \`flow_feature_complete.orchestrationPasses\`; keep full handoffs and long logs
1770
+ outside the runtime payload.
1771
+
1772
+ ## Validate
1773
+
1774
+ - For complex validation, regression-sensitive changes, browser QA, route QA,
1775
+ failure-prone checks, unclear coverage, exploratory QA, or
1776
+ \`validationRun\` summarization, load \`flow-test\` (helper rule applies).
1777
+ - Read \`references/validation-rubric.md\` before completing.
1778
+ - Run the strongest practical checks for the changed behavior.
1779
+ - Record concrete command names, status, and observed results. "Tests pass" is not evidence.
1780
+ - Non-final features complete with \`validationScope: "targeted"\`.
1781
+ - The final feature must run a broad project-level gate and use \`validationScope: "broad"\`.
1782
+
1783
+ For broad validation research, risky changes, or unclear coverage, start with
1784
+ \`../flow/references/parallel-orchestration.md\`. If it routes to fan-out, write
1785
+ the manifest from \`../flow/references/parallel-manifest.md\`, use the named Flow
1786
+ workers and prompt contract in \`../flow/references/parallel-execution.md\`, paste
1787
+ the matching handoff template from \`../flow/references/handoff-format.md\`, and
1788
+ apply \`../flow/references/parallel-synthesis.md\` when the handoffs return.
1789
+ They may report command output they actually ran or propose focused checks; the
1790
+ manager decides what is strong enough to record.
1791
+
1792
+ ## Review and complete
1793
+
1794
+ Before \`flow_feature_complete\`, obtain a \`featureReview\` payload. Load
1795
+ \`flow-review\`; for read-only subagent reviews, the manager receives the review
1796
+ packet and records both \`featureReviewDepth\` and \`featureReview\`.
1797
+
1798
+ Send reviewers a bounded review packet. Do not rely on the accumulated parent
1799
+ conversation. Include only:
1800
+
1801
+ - active feature id, title, summary, \`reviewDepth\`, targets, validation, and dependencies
1802
+ - relevant plan requirements, decisions, and final review policy
1803
+ - changed files and a short diff summary
1804
+ - validation evidence with exact commands, status, and observed result
1805
+ - targeted paths or risk lenses the reviewer must inspect
1806
+
1807
+ If the review returns \`status: "failed"\`, do not fix inside the review pass.
1808
+ Record the failed attempt by calling \`flow_feature_complete\` with the otherwise
1809
+ prepared completion payload, the failed \`featureReview\`, and the attempted
1810
+ \`featureReviewDepth\`; the runtime will reject completion and update the retry
1811
+ budget. Default to stopping and reporting the blocker. When the user already
1812
+ authorized autonomous implementation, make at most one repair and run one retry
1813
+ review. If the retry fails or the runtime reports review retry budget
1814
+ exhausted, stop with the blocker.
1815
+
1816
+ If \`flow_status\` reports \`setup.skills\` or \`flow-review\` cannot be loaded, do
1817
+ not record a Flow-gated \`featureReview\` or \`finalReview\`. You may perform an
1818
+ advisory review using available context or the bundled review fallback provided
1819
+ by plugin config, then complete with \`status: "needs_input"\` if review evidence
1820
+ is required to proceed.
1821
+
1822
+ For the final feature, also obtain a \`finalReview\` payload whose \`reviewDepth\` equals the approved plan's \`finalReviewPolicy\`.
1823
+
1824
+ Complete with:
1825
+
1826
+ \`\`\`json
1827
+ {
1828
+ "status": "ok",
1829
+ "featureId": "active-feature-id",
1830
+ "summary": "what changed",
1831
+ "artifactsChanged": [{ "path": "src/file.ts" }],
1832
+ "validationRun": [
1833
+ { "command": "bun test tests/foo.test.ts", "status": "passed", "summary": "3 pass, exercised foo behavior" }
1834
+ ],
1835
+ "validationScope": "targeted",
1836
+ "featureReviewDepth": "standard",
1837
+ "featureReview": { "status": "passed", "summary": "review summary", "blockingFindings": [] },
1838
+ "orchestrationPasses": [
1839
+ {
1840
+ "id": "active-feature-id-implementation-decision",
1841
+ "kind": "implementation-decision",
1842
+ "decision": "serial",
1843
+ "decisionReason": "Shared contract edits made worker ownership unsafe.",
1844
+ "candidateEligibility": "not_eligible",
1845
+ "candidateDecision": "serial_required",
1846
+ "decisionFactors": ["shared_state", "overlapping_files"],
1847
+ "writeScope": "manager-serial",
1848
+ "verificationStatus": "not-needed",
1849
+ "outcome": "accepted"
1850
+ }
1851
+ ]
1852
+ }
1853
+ \`\`\`
1854
+
1855
+ If \`flow_feature_complete\` returns a \`session.resumePacket\` or
1856
+ \`session.budget.phaseBoundary\`, stop after reporting the runtime-provided resume
1857
+ packet. If
1858
+ genuinely blocked, call \`flow_feature_complete\` with \`status: "needs_input"\` and
1859
+ an \`outcome\` that explains the blocker and next step. Never fabricate validation
1860
+ or review evidence to force progress.
1861
+ `;
1935
1862
 
1936
1863
  // skills/flow-test/SKILL.md
1937
1864
  var SKILL_default7 = `---
@@ -2217,6 +2144,22 @@ var FLOW_SKILL_DEFINITIONS = [
2217
2144
  relativePath: "references/parallel-orchestration.md",
2218
2145
  content: parallel_orchestration_default
2219
2146
  },
2147
+ {
2148
+ relativePath: "references/parallel-decision.md",
2149
+ content: parallel_decision_default
2150
+ },
2151
+ {
2152
+ relativePath: "references/parallel-manifest.md",
2153
+ content: parallel_manifest_default
2154
+ },
2155
+ {
2156
+ relativePath: "references/parallel-execution.md",
2157
+ content: parallel_execution_default
2158
+ },
2159
+ {
2160
+ relativePath: "references/parallel-synthesis.md",
2161
+ content: parallel_synthesis_default
2162
+ },
2220
2163
  {
2221
2164
  relativePath: "references/parallel-pass-example.md",
2222
2165
  content: parallel_pass_example_default
@@ -2267,6 +2210,10 @@ var FLOW_SKILL_DEFINITIONS = [
2267
2210
  name: "flow-review",
2268
2211
  files: [
2269
2212
  { relativePath: "SKILL.md", content: SKILL_default5 },
2213
+ {
2214
+ relativePath: "references/hidden-reviewer-contract.md",
2215
+ content: hidden_reviewer_contract_default
2216
+ },
2270
2217
  {
2271
2218
  relativePath: "references/review-rubric.md",
2272
2219
  content: review_rubric_default
@@ -2307,7 +2254,54 @@ var FLOW_SKILL_DEFINITIONS = [
2307
2254
  }
2308
2255
  ];
2309
2256
 
2310
- // src/config-shared.ts
2257
+ // src/prompt-baseline-fixtures.ts
2258
+ var LEGACY_WORKER_HANDOFF = "Return only the assigned Flow handoff. Cite or drop every claim, label single-source, inferred, and unsettled claims, and report blocked if the assigned scope, expected coverage, or handoff shape is missing. Empty or unstructured output is a failed handoff; return blocked with the missing elements instead.";
2259
+ var LEGACY_PROMPT_BASELINE = Object.freeze({
2260
+ publicCommandPreflight: [
2261
+ "Call `flow_status` first. If the result includes `setup.skills`, report the setup status and continue with the bundled public Flow command instructions below.",
2262
+ "If `flow_status` includes `session.resumePacket` or `session.budget.phaseBoundary`, stop the current autonomous loop and report the resume instructions unless this is a fresh user invocation explicitly resuming the session; only then may `flow_run_start` use `phaseBoundaryAck: true`.",
2263
+ "After `flow_status`, briefly state which bundled Flow command is running and for what goal, then continue.",
2264
+ "Do not call native Flow skills for `flow`, `flow-plan`, `flow-run`, or `flow-review` from public Flow commands. In bundled sections, `load` means read and use the corresponding bundled section in this command, and missing native public Flow skills are not blockers.",
2265
+ "Optional helper skills (`flow-test`, `flow-deslop`, `flow-ui-quality`, and user-triggered `flow-commit`) are not bundled fallbacks. If one is unavailable, record the coverage gap exactly as the bundled instructions require."
2266
+ ].join(" "),
2267
+ workerPrompts: Object.freeze({
2268
+ "flow-evidence-worker": `Use Flow evidence mode. Inspect only the assigned slice, do not edit files, do not call state-changing Flow tools, and return coverage, evidence inspected, confidence-tagged findings or facts, gaps, and manager follow-ups. ${LEGACY_WORKER_HANDOFF}`,
2269
+ "flow-validation-worker": `Use Flow validation mode. Run only manager-specified commands or propose focused checks, do not edit files, do not call state-changing Flow tools, and report exact command, status, raw outcome summary, coverage, confidence, gaps, and manager follow-ups. ${LEGACY_WORKER_HANDOFF}`,
2270
+ "flow-audit-worker": `Use Flow audit mode. Inspect only the assigned slice, actively refute candidate findings before reporting them, do not edit files, do not call state-changing Flow tools, and return coverage, evidence, guards checked, confidence, gaps, and manager follow-ups. ${LEGACY_WORKER_HANDOFF}`,
2271
+ "flow-candidate-worker": `Use Flow candidate-implementation mode only when the manager assigned an isolated worktree or exact non-overlapping path ownership. Do not edit .flow/**, do not call state-changing Flow tools, do not complete Flow state, and return changed or proposed patch, verification run, coverage, confidence, merge risks, and manager follow-ups. ${LEGACY_WORKER_HANDOFF}`,
2272
+ "flow-verifier-worker": `Use Flow verifier mode. Verify only the assigned claims against the provided sources, commands, counts, or current docs. Do not generate new scope, do not edit files, do not call state-changing Flow tools, and return supported, partly-supported, unsupported, or source-not-found per claim with evidence, confidence, gaps, and manager follow-ups. ${LEGACY_WORKER_HANDOFF}`
2273
+ }),
2274
+ reviewerSections: Object.freeze([
2275
+ "Use Flow review mode. Call `flow_status` first. Do not call the native skill tool for `flow-review`; the canonical Flow review instructions and rubric are already embedded below. If Flow setup reports stale/unavailable skills, continue as advisory review only and do not present advisory review as Flow-gated `featureReview` or `finalReview` evidence.",
2276
+ "Prefer the manager's bounded review packet over the accumulated root transcript. Return feature review packets with `featureReviewDepth` plus `featureReview`; final reviews still return `finalReview` with `reviewDepth`.",
2277
+ `When the manager assigns a parallel review slice instead of a direct Flow review command, ${LEGACY_WORKER_HANDOFF}`,
2278
+ "## Bundled Flow review instructions"
2279
+ ])
2280
+ });
2281
+
2282
+ // src/prompt-surfaces.ts
2283
+ var MANAGER_ROLE = ["manager"];
2284
+ var REVIEWER_ROLE = ["reviewer"];
2285
+ var SURFACE_ROLES = {
2286
+ "flow-auto": "manager",
2287
+ "flow-plan": "manager",
2288
+ "flow-run": "manager",
2289
+ "flow-review": "reviewer",
2290
+ "flow-status": "manager",
2291
+ "flow-reviewer": "reviewer",
2292
+ "flow-evidence-worker": "evidence-worker",
2293
+ "flow-validation-worker": "validation-worker",
2294
+ "flow-audit-worker": "audit-worker",
2295
+ "flow-candidate-worker": "candidate-worker",
2296
+ "flow-verifier-worker": "verifier-worker"
2297
+ };
2298
+ var COMMAND_ACTIONS = {
2299
+ "flow-auto": "Drive the Flow loop until completion or a real blocker: $ARGUMENTS",
2300
+ "flow-plan": "Create or revise the Flow plan for: $ARGUMENTS",
2301
+ "flow-run": "Execute the next approved feature. $ARGUMENTS",
2302
+ "flow-review": "Review the assigned work: $ARGUMENTS",
2303
+ "flow-status": "Call flow_status and report the session state and next action."
2304
+ };
2311
2305
  function flowSkillFileContent(skillName, relativePath) {
2312
2306
  const definition = FLOW_SKILL_DEFINITIONS.find((candidate) => candidate.name === skillName);
2313
2307
  const file = definition?.files.find((candidate) => candidate.relativePath === relativePath);
@@ -2316,91 +2310,693 @@ function flowSkillFileContent(skillName, relativePath) {
2316
2310
  }
2317
2311
  return file.content;
2318
2312
  }
2319
- function bundledFlowInstructions(sections) {
2320
- return sections.map(([skillName, relativePath]) => `## Bundled ${skillName}/${relativePath}
2313
+ function markdownSection(content, heading) {
2314
+ const lines = content.replace(/\r\n/g, `
2315
+ `).split(`
2316
+ `);
2317
+ const start = lines.indexOf(`## ${heading}`);
2318
+ if (start === -1)
2319
+ throw new Error(`Missing markdown section '${heading}'.`);
2320
+ let end = lines.length;
2321
+ for (let index = start + 1;index < lines.length; index += 1) {
2322
+ if (/^## /.test(lines[index] ?? "")) {
2323
+ end = index;
2324
+ break;
2325
+ }
2326
+ }
2327
+ return lines.slice(start, end).join(`
2328
+ `).trim();
2329
+ }
2330
+ function sourceFragment(options) {
2331
+ const content = flowSkillFileContent(options.skill, options.path);
2332
+ const source = `${options.skill}/${options.path}`;
2333
+ return {
2334
+ id: options.id,
2335
+ source: `skills/${source}#${options.headings.join(", #")}`,
2336
+ origin: "skill-source",
2337
+ kind: options.kind ?? "reference",
2338
+ roles: options.roles ?? MANAGER_ROLE,
2339
+ ...options.conditional === undefined ? {} : { conditional: options.conditional },
2340
+ text: [
2341
+ `## Bundled ${source} (selected sections)`,
2342
+ ...options.headings.map((heading) => markdownSection(content, heading))
2343
+ ].join(`
2344
+
2345
+ `)
2346
+ };
2347
+ }
2348
+ function wholeSourceFragment(options) {
2349
+ const source = `${options.skill}/${options.path}`;
2350
+ return {
2351
+ id: options.id,
2352
+ source: `skills/${source}`,
2353
+ origin: "skill-source",
2354
+ kind: "reference",
2355
+ roles: options.roles,
2356
+ ...options.conditional === undefined ? {} : { conditional: options.conditional },
2357
+ text: `## Bundled ${source}
2358
+
2359
+ ${flowSkillFileContent(options.skill, options.path)}`
2360
+ };
2361
+ }
2362
+ function markedPromptBlock(content, marker) {
2363
+ const startMarker = `<!-- flow-prompt:${marker}:start -->`;
2364
+ const endMarker = `<!-- flow-prompt:${marker}:end -->`;
2365
+ const start = content.indexOf(startMarker);
2366
+ const end = content.indexOf(endMarker);
2367
+ if (start === -1 || end === -1 || end <= start) {
2368
+ throw new Error(`Missing or invalid Flow prompt marker '${marker}'.`);
2369
+ }
2370
+ if (content.indexOf(startMarker, start + startMarker.length) !== -1 || content.indexOf(endMarker, end + endMarker.length) !== -1) {
2371
+ throw new Error(`Duplicate Flow prompt marker '${marker}'.`);
2372
+ }
2373
+ return content.slice(start + startMarker.length, end).trim();
2374
+ }
2375
+ function markedSourceFragment(options) {
2376
+ return {
2377
+ id: options.id,
2378
+ source: `skills/${options.skill}/${options.path}#flow-prompt:${options.marker}`,
2379
+ origin: "skill-source",
2380
+ kind: options.kind,
2381
+ roles: options.roles,
2382
+ ...options.conditional === undefined ? {} : { conditional: options.conditional },
2383
+ text: markedPromptBlock(flowSkillFileContent(options.skill, options.path), options.marker)
2384
+ };
2385
+ }
2386
+ function literalFragment(options) {
2387
+ return { ...options, origin: "compiler" };
2388
+ }
2389
+ var BASELINE_COMMAND_SOURCES = {
2390
+ "flow-auto": [
2391
+ ["flow", "SKILL.md"],
2392
+ ["flow", "references/recovery-playbook.md"],
2393
+ ["flow", "references/parallel-orchestration.md"],
2394
+ ["flow", "references/parallel-decision.md"],
2395
+ ["flow", "references/parallel-manifest.md"],
2396
+ ["flow", "references/parallel-execution.md"],
2397
+ ["flow", "references/parallel-synthesis.md"],
2398
+ ["flow", "references/handoff-format.md"],
2399
+ ["flow-plan", "SKILL.md"],
2400
+ ["flow-plan", "references/planning-examples.md"],
2401
+ ["flow-plan", "references/plan-quality-checklist.md"],
2402
+ ["flow-plan", "references/parallel-discovery.md"],
2403
+ ["flow-run", "SKILL.md"],
2404
+ ["flow-run", "references/validation-rubric.md"],
2405
+ ["flow-run", "references/audit-rubric.md"],
2406
+ ["flow-review", "SKILL.md"],
2407
+ ["flow-review", "references/review-rubric.md"]
2408
+ ],
2409
+ "flow-plan": [
2410
+ ["flow-plan", "SKILL.md"],
2411
+ ["flow-plan", "references/planning-examples.md"],
2412
+ ["flow-plan", "references/plan-quality-checklist.md"],
2413
+ ["flow-plan", "references/parallel-discovery.md"],
2414
+ ["flow", "references/parallel-orchestration.md"],
2415
+ ["flow", "references/parallel-decision.md"],
2416
+ ["flow", "references/parallel-manifest.md"],
2417
+ ["flow", "references/parallel-execution.md"],
2418
+ ["flow", "references/parallel-synthesis.md"],
2419
+ ["flow", "references/handoff-format.md"]
2420
+ ],
2421
+ "flow-run": [
2422
+ ["flow-run", "SKILL.md"],
2423
+ ["flow-run", "references/validation-rubric.md"],
2424
+ ["flow-run", "references/audit-rubric.md"],
2425
+ ["flow", "references/parallel-orchestration.md"],
2426
+ ["flow", "references/parallel-decision.md"],
2427
+ ["flow", "references/parallel-manifest.md"],
2428
+ ["flow", "references/parallel-execution.md"],
2429
+ ["flow", "references/parallel-synthesis.md"],
2430
+ ["flow", "references/handoff-format.md"],
2431
+ ["flow-review", "SKILL.md"],
2432
+ ["flow-review", "references/review-rubric.md"]
2433
+ ],
2434
+ "flow-review": [
2435
+ ["flow-review", "SKILL.md"],
2436
+ ["flow-review", "references/review-rubric.md"],
2437
+ ["flow-run", "references/audit-rubric.md"]
2438
+ ]
2439
+ };
2440
+ var MANAGER_OPENINGS = {
2441
+ "flow-auto": [
2442
+ "# Flow auto command contract",
2443
+ "",
2444
+ "Purpose: manage the approved Flow lifecycle from planning through validated, independently reviewed completion.",
2445
+ "",
2446
+ "Non-negotiable invariants:",
2447
+ "- Call `flow_status` first and trust its state and `nextAction` over conversation memory.",
2448
+ "- Only the root manager may call state-changing `flow_*` tools or synthesize final results.",
2449
+ "- Approved plans are immutable, only one feature may be active, and completion requires real validation plus independent review evidence.",
2450
+ "- A phase boundary ends the current root session; acknowledge it only in a fresh invocation explicitly resuming the session."
2451
+ ].join(`
2452
+ `),
2453
+ "flow-plan": [
2454
+ "# Flow plan command contract",
2455
+ "",
2456
+ "Purpose: produce an evidence-backed, executable Flow plan without beginning implementation.",
2457
+ "",
2458
+ "Non-negotiable invariants:",
2459
+ "- Call `flow_status` first and trust its state and `nextAction` over conversation memory.",
2460
+ "- Only the root manager may call state-changing `flow_*` tools.",
2461
+ "- Inspect environment facts before decomposing; do not invent findings.",
2462
+ "- Save a complete draft before approval, and approve only with explicit user approval or prior autonomous authorization."
2463
+ ].join(`
2464
+ `),
2465
+ "flow-run": [
2466
+ "# Flow run command contract",
2467
+ "",
2468
+ "Purpose: execute exactly one approved Flow feature and record honest completion or a real blocker.",
2469
+ "",
2470
+ "Non-negotiable invariants:",
2471
+ "- Call `flow_status` first and trust its state and `nextAction` over conversation memory.",
2472
+ "- Only the root manager may call state-changing `flow_*` tools or synthesize final results.",
2473
+ "- Keep edits within the active feature and preserve unrelated user changes.",
2474
+ "- Completion requires passing validation and an independent review at least as deep as the approved plan requires."
2475
+ ].join(`
2476
+ `)
2477
+ };
2478
+ var PUBLIC_COMMAND_SETUP = literalFragment({
2479
+ id: "public-command.setup-and-resume",
2480
+ source: "src/prompt-surfaces.ts#PUBLIC_COMMAND_SETUP",
2481
+ kind: "procedure",
2482
+ roles: MANAGER_ROLE,
2483
+ text: [
2484
+ "## Public command startup",
2485
+ "",
2486
+ "If `flow_status` reports `setup.skills`, report it and continue with the compiled core instructions in this command. The compiled sections are the public command's core Flow contract: references inside them to loading `flow`, `flow-plan`, `flow-run`, or `flow-review` mean use the matching compiled section, not a native skill call. A missing optional helper becomes an explicit coverage gap, never simulated coverage.",
2487
+ "",
2488
+ "If status includes `session.resumePacket` or `session.budget.phaseBoundary`, stop and report its resume instructions unless this fresh user invocation explicitly resumes that session. Only that fresh invocation may pass `phaseBoundaryAck: true` to `flow_run_start`."
2489
+ ].join(`
2490
+ `)
2491
+ });
2492
+ var MANAGER_PARALLEL_CORE = markedSourceFragment({
2493
+ id: "manager.parallel-pass-core",
2494
+ skill: "flow",
2495
+ path: "references/parallel-decision.md",
2496
+ marker: "manager-parallel-core",
2497
+ kind: "procedure",
2498
+ roles: MANAGER_ROLE,
2499
+ conditional: true
2500
+ });
2501
+ var PUBLIC_REVIEWER_ROUTE = literalFragment({
2502
+ id: "public-command.reviewer-route",
2503
+ source: "src/prompt-surfaces.ts#PUBLIC_REVIEWER_ROUTE",
2504
+ kind: "procedure",
2505
+ roles: MANAGER_ROLE,
2506
+ text: [
2507
+ "## Public reviewer routing",
2508
+ "",
2509
+ "When a compiled source section says to load `flow-review`, route the bounded review packet to the reserved `flow-reviewer`; do not invoke a native core skill or perform the independent review in manager context."
2510
+ ].join(`
2511
+ `)
2512
+ });
2513
+ var SURFACE_SPECIFIC_COMMAND_FRAGMENTS = {
2514
+ "flow-auto": [
2515
+ PUBLIC_COMMAND_SETUP,
2516
+ sourceFragment({
2517
+ id: "manager.flow-loop",
2518
+ skill: "flow",
2519
+ path: "SKILL.md",
2520
+ headings: [
2521
+ "Loop",
2522
+ "Skill Availability",
2523
+ "Runtime Surface",
2524
+ "Hard Gates",
2525
+ "Recovery"
2526
+ ]
2527
+ }),
2528
+ sourceFragment({
2529
+ id: "manager.plan-core",
2530
+ skill: "flow-plan",
2531
+ path: "SKILL.md",
2532
+ headings: [
2533
+ "Planning runtime availability",
2534
+ "Inspect first",
2535
+ "Reduce uncertainty before decomposing",
2536
+ "Plan shape",
2537
+ "Plan quality gate",
2538
+ "Feature sizing",
2539
+ "Approval"
2540
+ ]
2541
+ }),
2542
+ sourceFragment({
2543
+ id: "manager.plan-quality-checklist",
2544
+ skill: "flow-plan",
2545
+ path: "references/plan-quality-checklist.md",
2546
+ headings: ["Must pass", "Revise when you see this", "Approval summary"]
2547
+ }),
2548
+ sourceFragment({
2549
+ id: "manager.run-core",
2550
+ skill: "flow-run",
2551
+ path: "SKILL.md",
2552
+ headings: [
2553
+ "Execution runtime availability",
2554
+ "Start",
2555
+ "Implement",
2556
+ "Candidate implementation",
2557
+ "Validate",
2558
+ "Review and complete"
2559
+ ]
2560
+ }),
2561
+ sourceFragment({
2562
+ id: "manager.validation-rubric",
2563
+ skill: "flow-run",
2564
+ path: "references/validation-rubric.md",
2565
+ headings: [
2566
+ "Evidence tiers",
2567
+ "Recording rules",
2568
+ "Scope",
2569
+ "Blockers and resets"
2570
+ ]
2571
+ }),
2572
+ MANAGER_PARALLEL_CORE,
2573
+ PUBLIC_REVIEWER_ROUTE
2574
+ ],
2575
+ "flow-plan": [
2576
+ PUBLIC_COMMAND_SETUP,
2577
+ sourceFragment({
2578
+ id: "manager.plan-core",
2579
+ skill: "flow-plan",
2580
+ path: "SKILL.md",
2581
+ headings: [
2582
+ "Planning runtime availability",
2583
+ "Inspect first",
2584
+ "Reduce uncertainty before decomposing",
2585
+ "Plan shape",
2586
+ "Plan quality gate",
2587
+ "Feature sizing",
2588
+ "Approval"
2589
+ ]
2590
+ }),
2591
+ sourceFragment({
2592
+ id: "manager.plan-quality-checklist",
2593
+ skill: "flow-plan",
2594
+ path: "references/plan-quality-checklist.md",
2595
+ headings: ["Must pass", "Revise when you see this", "Approval summary"]
2596
+ }),
2597
+ MANAGER_PARALLEL_CORE
2598
+ ],
2599
+ "flow-run": [
2600
+ PUBLIC_COMMAND_SETUP,
2601
+ sourceFragment({
2602
+ id: "manager.run-core",
2603
+ skill: "flow-run",
2604
+ path: "SKILL.md",
2605
+ headings: [
2606
+ "Execution runtime availability",
2607
+ "Start",
2608
+ "Implement",
2609
+ "Candidate implementation",
2610
+ "Validate",
2611
+ "Review and complete"
2612
+ ]
2613
+ }),
2614
+ sourceFragment({
2615
+ id: "manager.validation-rubric",
2616
+ skill: "flow-run",
2617
+ path: "references/validation-rubric.md",
2618
+ headings: [
2619
+ "Evidence tiers",
2620
+ "Recording rules",
2621
+ "Scope",
2622
+ "Blockers and resets"
2623
+ ]
2624
+ }),
2625
+ MANAGER_PARALLEL_CORE,
2626
+ PUBLIC_REVIEWER_ROUTE
2627
+ ]
2628
+ };
2629
+ var MANAGER_CHECKPOINTS = {
2630
+ "flow-auto": "Before stopping: confirm the runtime state matches the report; every completed feature has real validation and independent review evidence; the final feature has broad validation and final review; otherwise report the exact blocker or resume packet.",
2631
+ "flow-plan": "Before returning: confirm the plan is evidence-backed, executable by another agent, explicit about requirements/decisions/targets/validation/dependencies/review depth, saved as a draft, and not approved without authorization.",
2632
+ "flow-run": "Before completion: confirm scope stayed within the active feature, commands and observed results are exact, review is independent and deep enough, no blocking finding remains unresolved, and the runtime—not prose—accepted the completion payload."
2633
+ };
2634
+ var REVIEW_INVOCATION_FRAGMENT = literalFragment({
2635
+ id: "reviewer.command-invocation",
2636
+ source: "src/prompt-surfaces.ts#REVIEW_INVOCATION_FRAGMENT",
2637
+ kind: "purpose",
2638
+ roles: REVIEWER_ROLE,
2639
+ text: [
2640
+ "# Flow review request",
2641
+ "",
2642
+ "Call `flow_status` first when available, then review the assigned packet and actual changed artifacts under the `flow-reviewer` contract. Prefer the bounded packet over parent-session memory. If setup or required evidence is stale or unavailable, return an advisory result and state why it cannot be used as Flow-gated review evidence."
2643
+ ].join(`
2644
+ `)
2645
+ });
2646
+ var WORKER_INTEGRITY = markedSourceFragment({
2647
+ id: "worker.handoff-integrity",
2648
+ skill: "flow",
2649
+ path: "references/handoff-format.md",
2650
+ marker: "worker-integrity",
2651
+ kind: "invariant",
2652
+ roles: [
2653
+ "reviewer",
2654
+ "evidence-worker",
2655
+ "validation-worker",
2656
+ "audit-worker",
2657
+ "candidate-worker",
2658
+ "verifier-worker"
2659
+ ]
2660
+ });
2661
+ var EVIDENCE_HANDOFF_SCHEMA = markedSourceFragment({
2662
+ id: "handoff.evidence-schema",
2663
+ skill: "flow",
2664
+ path: "references/handoff-format.md",
2665
+ marker: "handoff-evidence",
2666
+ kind: "schema",
2667
+ roles: ["evidence-worker"]
2668
+ });
2669
+ var VALIDATION_HANDOFF_SCHEMA = markedSourceFragment({
2670
+ id: "handoff.validation-schema",
2671
+ skill: "flow",
2672
+ path: "references/handoff-format.md",
2673
+ marker: "handoff-validation",
2674
+ kind: "schema",
2675
+ roles: ["validation-worker"]
2676
+ });
2677
+ var AUDIT_HANDOFF_SCHEMA = markedSourceFragment({
2678
+ id: "handoff.audit-schema",
2679
+ skill: "flow",
2680
+ path: "references/handoff-format.md",
2681
+ marker: "handoff-audit",
2682
+ kind: "schema",
2683
+ roles: ["audit-worker"]
2684
+ });
2685
+ var REVIEW_SLICE_HANDOFF_SCHEMA = markedSourceFragment({
2686
+ id: "handoff.review-slice-schema",
2687
+ skill: "flow",
2688
+ path: "references/handoff-format.md",
2689
+ marker: "handoff-review-slice",
2690
+ kind: "schema",
2691
+ roles: ["reviewer"]
2692
+ });
2693
+ var VERIFIER_HANDOFF_SCHEMA = markedSourceFragment({
2694
+ id: "handoff.verifier-schema",
2695
+ skill: "flow",
2696
+ path: "references/handoff-format.md",
2697
+ marker: "handoff-verifier",
2698
+ kind: "schema",
2699
+ roles: ["verifier-worker"]
2700
+ });
2701
+ var CANDIDATE_HANDOFF_SCHEMA = markedSourceFragment({
2702
+ id: "handoff.candidate-schema",
2703
+ skill: "flow",
2704
+ path: "references/handoff-format.md",
2705
+ marker: "handoff-candidate",
2706
+ kind: "schema",
2707
+ roles: ["candidate-worker"]
2708
+ });
2709
+ var REVIEWER_FRAGMENTS = [
2710
+ sourceFragment({
2711
+ id: "reviewer.hidden-core",
2712
+ skill: "flow-review",
2713
+ path: "references/hidden-reviewer-contract.md",
2714
+ headings: [
2715
+ "Role and availability",
2716
+ "Feature review depths",
2717
+ "Direct review outputs",
2718
+ "Special-case evidence",
2719
+ "Completion checkpoint"
2720
+ ],
2721
+ kind: "purpose",
2722
+ roles: REVIEWER_ROLE
2723
+ }),
2724
+ sourceFragment({
2725
+ id: "reviewer.review-rubric",
2726
+ skill: "flow-review",
2727
+ path: "references/review-rubric.md",
2728
+ headings: [
2729
+ "Finding classes",
2730
+ "Severity",
2731
+ "Feature review checklist",
2732
+ "Final review checklist",
2733
+ "Final convergence scan",
2734
+ "Payloads",
2735
+ "Audit report reviews"
2736
+ ],
2737
+ roles: REVIEWER_ROLE
2738
+ }),
2739
+ REVIEW_SLICE_HANDOFF_SCHEMA,
2740
+ WORKER_INTEGRITY
2741
+ ];
2742
+ function workerRoleFragment(options) {
2743
+ return markedSourceFragment({
2744
+ id: options.id,
2745
+ skill: "flow",
2746
+ path: "references/parallel-execution.md",
2747
+ marker: options.marker,
2748
+ kind: "purpose",
2749
+ roles: [options.role]
2750
+ });
2751
+ }
2752
+ var EVIDENCE_WORKER_ROLE = workerRoleFragment({
2753
+ id: "evidence-worker.role-contract",
2754
+ marker: "worker-role-evidence",
2755
+ role: "evidence-worker"
2756
+ });
2757
+ var VALIDATION_WORKER_ROLE = workerRoleFragment({
2758
+ id: "validation-worker.role-contract",
2759
+ marker: "worker-role-validation",
2760
+ role: "validation-worker"
2761
+ });
2762
+ var AUDIT_WORKER_ROLE = workerRoleFragment({
2763
+ id: "audit-worker.role-contract",
2764
+ marker: "worker-role-audit",
2765
+ role: "audit-worker"
2766
+ });
2767
+ var CANDIDATE_WORKER_ROLE = workerRoleFragment({
2768
+ id: "candidate-worker.role-contract",
2769
+ marker: "worker-role-candidate",
2770
+ role: "candidate-worker"
2771
+ });
2772
+ var VERIFIER_WORKER_ROLE = workerRoleFragment({
2773
+ id: "verifier-worker.role-contract",
2774
+ marker: "worker-role-verifier",
2775
+ role: "verifier-worker"
2776
+ });
2777
+ var WORKER_FRAGMENTS = {
2778
+ "flow-evidence-worker": [
2779
+ EVIDENCE_WORKER_ROLE,
2780
+ EVIDENCE_HANDOFF_SCHEMA,
2781
+ WORKER_INTEGRITY
2782
+ ],
2783
+ "flow-validation-worker": [
2784
+ VALIDATION_WORKER_ROLE,
2785
+ VALIDATION_HANDOFF_SCHEMA,
2786
+ WORKER_INTEGRITY
2787
+ ],
2788
+ "flow-audit-worker": [
2789
+ AUDIT_WORKER_ROLE,
2790
+ AUDIT_HANDOFF_SCHEMA,
2791
+ WORKER_INTEGRITY
2792
+ ],
2793
+ "flow-candidate-worker": [
2794
+ CANDIDATE_WORKER_ROLE,
2795
+ CANDIDATE_HANDOFF_SCHEMA,
2796
+ WORKER_INTEGRITY
2797
+ ],
2798
+ "flow-verifier-worker": [
2799
+ VERIFIER_WORKER_ROLE,
2800
+ VERIFIER_HANDOFF_SCHEMA,
2801
+ WORKER_INTEGRITY
2802
+ ]
2803
+ };
2804
+ function assertUniqueFragmentIds(surface, fragments) {
2805
+ const seen = new Set;
2806
+ for (const fragment of fragments) {
2807
+ if (seen.has(fragment.id)) {
2808
+ throw new Error(`Prompt surface '${surface}' includes duplicate canonical fragment id '${fragment.id}'.`);
2809
+ }
2810
+ seen.add(fragment.id);
2811
+ }
2812
+ }
2813
+ function renderFragments(fragments) {
2814
+ return fragments.map((fragment) => fragment.text.trim()).join(`
2321
2815
 
2322
- ${flowSkillFileContent(skillName, relativePath)}`).join(`
2816
+ `);
2817
+ }
2818
+ function deduplicateExactParagraphs(text) {
2819
+ const seen = new Set;
2820
+ return text.split(/\n{2,}/).filter((paragraph) => {
2821
+ const key = paragraph.trim().replace(/\s+/g, " ").toLowerCase();
2822
+ if (!key || seen.has(key))
2823
+ return false;
2824
+ seen.add(key);
2825
+ return true;
2826
+ }).join(`
2323
2827
 
2324
2828
  `);
2325
2829
  }
2326
- var FLOW_REVIEW_BUNDLED_INSTRUCTIONS = bundledFlowInstructions([
2327
- ["flow-review", "SKILL.md"],
2328
- ["flow-review", "references/review-rubric.md"],
2329
- ["flow-run", "references/audit-rubric.md"]
2330
- ]);
2331
- var FLOW_PLAN_BUNDLED_INSTRUCTIONS = bundledFlowInstructions([
2332
- ["flow-plan", "SKILL.md"],
2333
- ["flow-plan", "references/planning-examples.md"],
2334
- ["flow-plan", "references/plan-quality-checklist.md"],
2335
- ["flow-plan", "references/parallel-discovery.md"],
2336
- ["flow", "references/parallel-orchestration.md"],
2337
- ["flow", "references/handoff-format.md"]
2338
- ]);
2339
- var FLOW_RUN_BUNDLED_INSTRUCTIONS = bundledFlowInstructions([
2340
- ["flow-run", "SKILL.md"],
2341
- ["flow-run", "references/validation-rubric.md"],
2342
- ["flow-run", "references/audit-rubric.md"],
2343
- ["flow", "references/parallel-orchestration.md"],
2344
- ["flow", "references/handoff-format.md"],
2345
- ["flow-review", "SKILL.md"],
2346
- ["flow-review", "references/review-rubric.md"]
2347
- ]);
2348
- var FLOW_AUTO_BUNDLED_INSTRUCTIONS = bundledFlowInstructions([
2349
- ["flow", "SKILL.md"],
2350
- ["flow", "references/recovery-playbook.md"],
2351
- ["flow", "references/parallel-orchestration.md"],
2352
- ["flow", "references/handoff-format.md"],
2353
- ["flow-plan", "SKILL.md"],
2354
- ["flow-plan", "references/planning-examples.md"],
2355
- ["flow-plan", "references/plan-quality-checklist.md"],
2356
- ["flow-plan", "references/parallel-discovery.md"],
2357
- ["flow-run", "SKILL.md"],
2358
- ["flow-run", "references/validation-rubric.md"],
2359
- ["flow-run", "references/audit-rubric.md"],
2360
- ["flow-review", "SKILL.md"],
2361
- ["flow-review", "references/review-rubric.md"]
2362
- ]);
2363
- var FLOW_SELF_CONTAINED_COMMAND_PREFLIGHT = [
2364
- "Call `flow_status` first. If the result includes `setup.skills`, report the setup status and continue with the bundled public Flow command instructions below.",
2365
- "If `flow_status` includes `session.resumePacket` or `session.budget.phaseBoundary`, stop the current autonomous loop and report the resume instructions unless this is a fresh user invocation explicitly resuming the session; only then may `flow_run_start` use `phaseBoundaryAck: true`.",
2366
- "After `flow_status`, briefly state which bundled Flow command is running and for what goal, then continue.",
2367
- "Do not call native Flow skills for `flow`, `flow-plan`, `flow-run`, or `flow-review` from public Flow commands. In bundled sections, `load` means read and use the corresponding bundled section in this command, and missing native public Flow skills are not blockers.",
2368
- "Optional helper skills (`flow-test`, `flow-deslop`, `flow-ui-quality`, and user-triggered `flow-commit`) are not bundled fallbacks. If one is unavailable, record the coverage gap exactly as the bundled instructions require."
2369
- ].join(" ");
2370
- function flowBundledCommandTemplate(commandLabel, action, bundledInstructions) {
2371
- return [
2372
- FLOW_SELF_CONTAINED_COMMAND_PREFLIGHT,
2373
- `Run the bundled ${commandLabel} instructions below. ${action}`,
2830
+ function compileBaselineCommand(surface) {
2831
+ const fragments = BASELINE_COMMAND_SOURCES[surface].map(([skill, path], index) => wholeSourceFragment({
2832
+ id: `baseline.${surface}.${index}.${skill}.${path}`,
2833
+ skill,
2834
+ path,
2835
+ roles: MANAGER_ROLE,
2836
+ conditional: path.includes("parallel") || path.includes("handoff") || path.includes("example") || path.includes("recovery")
2837
+ }));
2838
+ const text = [
2839
+ LEGACY_PROMPT_BASELINE.publicCommandPreflight,
2840
+ `Run the bundled ${surface} instructions below. ${COMMAND_ACTIONS[surface]}`,
2374
2841
  "",
2375
- bundledInstructions
2842
+ renderFragments(fragments)
2376
2843
  ].join(`
2377
2844
 
2378
2845
  `);
2846
+ return {
2847
+ surface,
2848
+ variant: "baseline",
2849
+ role: surface === "flow-review" ? "reviewer" : "manager",
2850
+ text,
2851
+ fragments
2852
+ };
2379
2853
  }
2380
- var FLOW_AUTO_COMMAND_TEMPLATE = flowBundledCommandTemplate("Flow auto", "Drive the Flow loop until completion or a real blocker: $ARGUMENTS", FLOW_AUTO_BUNDLED_INSTRUCTIONS);
2381
- var FLOW_PLAN_COMMAND_TEMPLATE = flowBundledCommandTemplate("Flow plan", "Plan: $ARGUMENTS", FLOW_PLAN_BUNDLED_INSTRUCTIONS);
2382
- var FLOW_RUN_COMMAND_TEMPLATE = flowBundledCommandTemplate("Flow run", "Execute the next approved feature. $ARGUMENTS", FLOW_RUN_BUNDLED_INSTRUCTIONS);
2383
- var FLOW_REVIEW_COMMAND_TEMPLATE = flowBundledCommandTemplate("Flow review", "Review: $ARGUMENTS", FLOW_REVIEW_BUNDLED_INSTRUCTIONS);
2384
- var FLOW_REVIEW_AGENT_INSTRUCTIONS = [
2385
- "Use Flow review mode. Call `flow_status` first. Do not call the native skill tool for `flow-review`; the canonical Flow review instructions and rubric are already embedded below. If Flow setup reports stale/unavailable skills, continue as advisory review only and do not present advisory review as Flow-gated `featureReview` or `finalReview` evidence.",
2386
- "Prefer the manager's compact review packet over the accumulated root transcript. Return feature review packets with `featureReviewDepth` plus `featureReview`; final reviews still return `finalReview` with `reviewDepth`.",
2387
- "When the manager assigns a parallel review slice instead of a direct Flow review command, cite or drop every claim, label single-source, inferred, and unsettled claims, and return only the assigned Flow handoff. Report blocked if the assigned scope, expected coverage, or handoff shape is missing. Empty or unstructured output is a failed handoff; return blocked with the missing elements instead.",
2388
- "",
2389
- "## Bundled Flow review instructions",
2390
- "",
2391
- FLOW_REVIEW_BUNDLED_INSTRUCTIONS
2392
- ].join(`
2854
+ function compileBaselineWorker(surface) {
2855
+ if (surface === "flow-reviewer") {
2856
+ const reviewBundle = BASELINE_COMMAND_SOURCES["flow-review"].map(([skill, path], index) => wholeSourceFragment({
2857
+ id: `baseline.flow-reviewer.${index}.${skill}.${path}`,
2858
+ skill,
2859
+ path,
2860
+ roles: REVIEWER_ROLE
2861
+ }));
2862
+ return {
2863
+ surface,
2864
+ variant: "baseline",
2865
+ role: "reviewer",
2866
+ fragments: reviewBundle,
2867
+ text: [
2868
+ ...LEGACY_PROMPT_BASELINE.reviewerSections,
2869
+ renderFragments(reviewBundle)
2870
+ ].join(`
2393
2871
 
2394
- `);
2395
- var FLOW_STATUS_COMMAND_TEMPLATE = "Call flow_status and report the session state and next action.";
2872
+ `)
2873
+ };
2874
+ }
2875
+ const text = LEGACY_PROMPT_BASELINE.workerPrompts[surface];
2876
+ if (!text)
2877
+ throw new Error(`No baseline worker prompt for '${surface}'.`);
2878
+ return {
2879
+ surface,
2880
+ variant: "baseline",
2881
+ role: SURFACE_ROLES[surface],
2882
+ text,
2883
+ fragments: []
2884
+ };
2885
+ }
2886
+ function compileSurfaceSpecific(surface, bookended) {
2887
+ if (surface === "flow-status") {
2888
+ return {
2889
+ surface,
2890
+ variant: bookended ? "surface-specific-bookended" : "surface-specific",
2891
+ role: "manager",
2892
+ text: COMMAND_ACTIONS["flow-status"],
2893
+ fragments: []
2894
+ };
2895
+ }
2896
+ if (surface === "flow-review") {
2897
+ const fragments2 = [REVIEW_INVOCATION_FRAGMENT];
2898
+ return {
2899
+ surface,
2900
+ variant: bookended ? "surface-specific-bookended" : "surface-specific",
2901
+ role: "reviewer",
2902
+ text: `${renderFragments(fragments2)}
2903
+
2904
+ ${COMMAND_ACTIONS[surface]}`,
2905
+ fragments: fragments2
2906
+ };
2907
+ }
2908
+ if (surface === "flow-reviewer") {
2909
+ assertUniqueFragmentIds(surface, REVIEWER_FRAGMENTS);
2910
+ return {
2911
+ surface,
2912
+ variant: bookended ? "surface-specific-bookended" : "surface-specific",
2913
+ role: "reviewer",
2914
+ text: renderFragments(REVIEWER_FRAGMENTS),
2915
+ fragments: REVIEWER_FRAGMENTS
2916
+ };
2917
+ }
2918
+ if (surface in WORKER_FRAGMENTS) {
2919
+ const fragments2 = WORKER_FRAGMENTS[surface];
2920
+ assertUniqueFragmentIds(surface, fragments2);
2921
+ return {
2922
+ surface,
2923
+ variant: bookended ? "surface-specific-bookended" : "surface-specific",
2924
+ role: SURFACE_ROLES[surface],
2925
+ text: renderFragments(fragments2),
2926
+ fragments: fragments2
2927
+ };
2928
+ }
2929
+ const command = surface;
2930
+ const coreFragments = SURFACE_SPECIFIC_COMMAND_FRAGMENTS[command];
2931
+ const action = literalFragment({
2932
+ id: `${surface}.action`,
2933
+ source: "src/prompt-surfaces.ts#COMMAND_ACTIONS",
2934
+ kind: "purpose",
2935
+ roles: MANAGER_ROLE,
2936
+ text: COMMAND_ACTIONS[command]
2937
+ });
2938
+ const opening = literalFragment({
2939
+ id: `${surface}.critical-opening`,
2940
+ source: "src/prompt-surfaces.ts#MANAGER_OPENINGS",
2941
+ kind: "invariant",
2942
+ roles: MANAGER_ROLE,
2943
+ text: MANAGER_OPENINGS[command]
2944
+ });
2945
+ const checkpoint = literalFragment({
2946
+ id: `${surface}.completion-checkpoint`,
2947
+ source: "src/prompt-surfaces.ts#MANAGER_CHECKPOINTS",
2948
+ kind: "checkpoint",
2949
+ roles: MANAGER_ROLE,
2950
+ text: `## Completion checkpoint
2951
+
2952
+ ${MANAGER_CHECKPOINTS[command]}`
2953
+ });
2954
+ const fragments = bookended ? [opening, action, ...coreFragments, checkpoint] : [action, ...coreFragments];
2955
+ assertUniqueFragmentIds(surface, fragments);
2956
+ return {
2957
+ surface,
2958
+ variant: bookended ? "surface-specific-bookended" : "surface-specific",
2959
+ role: "manager",
2960
+ text: renderFragments(fragments),
2961
+ fragments
2962
+ };
2963
+ }
2964
+ function compileFlowPromptSurface(surface, variant = "surface-specific-bookended") {
2965
+ if (variant === "baseline" || variant === "lexically-deduplicated") {
2966
+ let baseline;
2967
+ if (surface === "flow-status") {
2968
+ baseline = {
2969
+ surface,
2970
+ variant: "baseline",
2971
+ role: "manager",
2972
+ text: "Call flow_status and report the session state and next action.",
2973
+ fragments: []
2974
+ };
2975
+ } else if (surface in BASELINE_COMMAND_SOURCES) {
2976
+ baseline = compileBaselineCommand(surface);
2977
+ } else {
2978
+ baseline = compileBaselineWorker(surface);
2979
+ }
2980
+ if (variant === "baseline")
2981
+ return baseline;
2982
+ return {
2983
+ ...baseline,
2984
+ variant,
2985
+ text: deduplicateExactParagraphs(baseline.text)
2986
+ };
2987
+ }
2988
+ return compileSurfaceSpecific(surface, variant === "surface-specific-bookended");
2989
+ }
2990
+
2991
+ // src/config-shared.ts
2396
2992
  var FLOW_PUBLIC_COMMAND_TEMPLATES = {
2397
- "flow-auto": FLOW_AUTO_COMMAND_TEMPLATE,
2398
- "flow-plan": FLOW_PLAN_COMMAND_TEMPLATE,
2399
- "flow-run": FLOW_RUN_COMMAND_TEMPLATE,
2400
- "flow-review": FLOW_REVIEW_COMMAND_TEMPLATE,
2401
- "flow-status": FLOW_STATUS_COMMAND_TEMPLATE
2993
+ "flow-auto": compileFlowPromptSurface("flow-auto").text,
2994
+ "flow-plan": compileFlowPromptSurface("flow-plan").text,
2995
+ "flow-run": compileFlowPromptSurface("flow-run").text,
2996
+ "flow-review": compileFlowPromptSurface("flow-review").text,
2997
+ "flow-status": compileFlowPromptSurface("flow-status").text
2402
2998
  };
2403
- var FLOW_WORKER_HANDOFF_CONTRACT = "Return only the assigned Flow handoff. Cite or drop every claim, label single-source, inferred, and unsettled claims, and report blocked if the assigned scope, expected coverage, or handoff shape is missing. Empty or unstructured output is a failed handoff; return blocked with the missing elements instead.";
2999
+ var FLOW_REVIEW_AGENT_INSTRUCTIONS = compileFlowPromptSurface("flow-reviewer").text;
2404
3000
  function envModel(name) {
2405
3001
  const value = process.env[name]?.trim();
2406
3002
  return value ? value : undefined;
@@ -2434,7 +3030,7 @@ var FLOW_CORE_AGENTS = {
2434
3030
  mode: "subagent",
2435
3031
  hidden: true,
2436
3032
  description: "Internal read-only evidence worker for Flow planning and execution support.",
2437
- prompt: `Use Flow evidence mode. Inspect only the assigned slice, do not edit files, do not call state-changing Flow tools, and return coverage, evidence inspected, confidence-tagged findings or facts, gaps, and manager follow-ups. ${FLOW_WORKER_HANDOFF_CONTRACT}`,
3033
+ prompt: compileFlowPromptSurface("flow-evidence-worker").text,
2438
3034
  permission: {
2439
3035
  edit: "deny",
2440
3036
  bash: "deny",
@@ -2448,7 +3044,7 @@ var FLOW_CORE_AGENTS = {
2448
3044
  mode: "subagent",
2449
3045
  hidden: true,
2450
3046
  description: "Internal validation worker for Flow check selection and command evidence.",
2451
- prompt: `Use Flow validation mode. Run only manager-specified commands or propose focused checks, do not edit files, do not call state-changing Flow tools, and report exact command, status, raw outcome summary, coverage, confidence, gaps, and manager follow-ups. ${FLOW_WORKER_HANDOFF_CONTRACT}`,
3047
+ prompt: compileFlowPromptSurface("flow-validation-worker").text,
2452
3048
  permission: {
2453
3049
  edit: "deny",
2454
3050
  bash: "ask",
@@ -2462,7 +3058,7 @@ var FLOW_CORE_AGENTS = {
2462
3058
  mode: "subagent",
2463
3059
  hidden: true,
2464
3060
  description: "Internal read-only audit worker for refuted or surviving finding candidates.",
2465
- prompt: `Use Flow audit mode. Inspect only the assigned slice, actively refute candidate findings before reporting them, do not edit files, do not call state-changing Flow tools, and return coverage, evidence, guards checked, confidence, gaps, and manager follow-ups. ${FLOW_WORKER_HANDOFF_CONTRACT}`,
3061
+ prompt: compileFlowPromptSurface("flow-audit-worker").text,
2466
3062
  permission: {
2467
3063
  edit: "deny",
2468
3064
  bash: "ask",
@@ -2476,7 +3072,7 @@ var FLOW_CORE_AGENTS = {
2476
3072
  mode: "subagent",
2477
3073
  hidden: true,
2478
3074
  description: "Internal candidate implementation worker for isolated Flow worktrees or exact non-overlapping path ownership.",
2479
- prompt: `Use Flow candidate-implementation mode only when the manager assigned an isolated worktree or exact non-overlapping path ownership. Do not edit .flow/**, do not call state-changing Flow tools, do not complete Flow state, and return changed or proposed patch, verification run, coverage, confidence, merge risks, and manager follow-ups. ${FLOW_WORKER_HANDOFF_CONTRACT}`,
3075
+ prompt: compileFlowPromptSurface("flow-candidate-worker").text,
2480
3076
  permission: {
2481
3077
  edit: "ask",
2482
3078
  bash: "ask",
@@ -2490,7 +3086,7 @@ var FLOW_CORE_AGENTS = {
2490
3086
  mode: "subagent",
2491
3087
  hidden: true,
2492
3088
  description: "Internal verifier worker for checking Flow worker claims against cited evidence.",
2493
- prompt: `Use Flow verifier mode. Verify only the assigned claims against the provided sources, commands, counts, or current docs. Do not generate new scope, do not edit files, do not call state-changing Flow tools, and return supported, partly-supported, unsupported, or source-not-found per claim with evidence, confidence, gaps, and manager follow-ups. ${FLOW_WORKER_HANDOFF_CONTRACT}`,
3089
+ prompt: compileFlowPromptSurface("flow-verifier-worker").text,
2494
3090
  permission: {
2495
3091
  edit: "deny",
2496
3092
  bash: "ask",
@@ -4761,28 +5357,6 @@ function createCommandPreflightHook() {
4761
5357
  replaceFlowCommandParts(output, renderFlowCommandTitleSeed(command, input.arguments), renderFlowCommandPreflight(command, input.arguments));
4762
5358
  };
4763
5359
  }
4764
- function createCompactionHook(ctx) {
4765
- return async (_input, output) => {
4766
- try {
4767
- const root = resolveWorkspaceRoot(ctx);
4768
- const session = await loadSession(root);
4769
- if (!session)
4770
- return;
4771
- const { completed: completedFeatures, total: totalFeatures } = flowSessionProgress(session);
4772
- output.context.push([
4773
- "## Flow session context",
4774
- "An active Flow session exists in this workspace (`.flow/session.json`).",
4775
- `- goal: ${JSON.stringify(session.goal)}`,
4776
- `- status: ${JSON.stringify(session.status)}`,
4777
- `- approval: ${JSON.stringify(session.approval)}`,
4778
- `- activeFeatureId: ${JSON.stringify(session.activeFeatureId)}`,
4779
- `- progress: ${completedFeatures}/${totalFeatures} features completed`,
4780
- "After compaction, call `flow_status` before any Flow action and follow its `nextAction`."
4781
- ].join(`
4782
- `));
4783
- } catch {}
4784
- };
4785
- }
4786
5360
  var FlowPlugin = async (ctx) => {
4787
5361
  const log = createFlowLog(ctx);
4788
5362
  log("info", "Flow v4 plugin initialized.");
@@ -4792,10 +5366,6 @@ var FlowPlugin = async (ctx) => {
4792
5366
  tool: createTools(ctx),
4793
5367
  "command.execute.before": createCommandPreflightHook()
4794
5368
  };
4795
- if (process.env.FLOW_EXPERIMENTAL_COMPACTION === "1") {
4796
- hooks["experimental.session.compacting"] = createCompactionHook(ctx);
4797
- log("info", "Flow experimental compaction context enabled.");
4798
- }
4799
5369
  return hooks;
4800
5370
  };
4801
5371
  var plugin_default = FlowPlugin;
@@ -4803,4 +5373,4 @@ export {
4803
5373
  plugin_default as default
4804
5374
  };
4805
5375
 
4806
- //# debugId=C77708A78E8740C664756E2164756E21
5376
+ //# debugId=9075F9EB5AD041BE64756E2164756E21