opencode-plugin-flow 4.4.0 → 5.0.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/CHANGELOG.md +57 -0
- package/README.md +44 -40
- package/dist/application/errors.d.ts +5 -0
- package/dist/{runtime/api.d.ts → application/flow-service.d.ts} +89 -57
- package/dist/application/ports/session-repository.d.ts +11 -0
- package/dist/{runtime → application}/schema.d.ts +291 -371
- package/dist/cli.js +283 -2720
- package/dist/cli.js.map +7 -6
- package/dist/config-shared.d.ts +28 -14
- package/dist/config.d.ts +1 -1
- package/dist/distribution/legacy-cleanup.d.ts +25 -0
- package/dist/domain/feature-id.d.ts +3 -0
- package/dist/domain/limits.d.ts +1 -0
- package/dist/domain/orchestration-policy.d.ts +27 -0
- package/dist/domain/session.d.ts +181 -0
- package/dist/domain/transitions.d.ts +80 -0
- package/dist/guidance/catalog.d.ts +18 -0
- package/dist/guidance/ids.d.ts +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1279 -1102
- package/dist/index.js.map +24 -18
- package/dist/infrastructure/fs/session-repository.d.ts +2 -0
- package/dist/infrastructure/fs/workspace-flow-service.d.ts +9 -0
- package/dist/{runtime → infrastructure/fs}/workspace.d.ts +10 -15
- package/dist/infrastructure/system/transition-environment.d.ts +2 -0
- package/dist/platform/opencode/config.d.ts +2 -0
- package/dist/{adapters → platform}/opencode/plugin.d.ts +1 -1
- package/dist/{adapters → platform}/opencode/sdk.d.ts +0 -1
- package/dist/platform/opencode/tools.d.ts +6 -0
- package/dist/prompt-model-evaluation.d.ts +19 -30
- package/dist/prompt-quality.d.ts +1 -1
- package/dist/version.d.ts +1 -0
- package/package.json +16 -11
- package/dist/adapters/opencode/config.d.ts +0 -3
- package/dist/adapters/opencode/tools.d.ts +0 -322
- package/dist/distribution/flow-skill-definitions.d.ts +0 -9
- package/dist/distribution/sync.d.ts +0 -69
- package/dist/runtime/time.d.ts +0 -2
- package/dist/runtime/transitions.d.ts +0 -230
- /package/dist/{runtime/json/strict-object.d.ts → infrastructure/fs/strict-json-object.d.ts} +0 -0
- /package/dist/{adapters → platform}/opencode/logging.d.ts +0 -0
package/dist/cli.js
CHANGED
|
@@ -1,2719 +1,347 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// src/distribution/
|
|
3
|
+
// src/distribution/legacy-cleanup.ts
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Sections: evidence/review/validation/audit worker report, verifier worker report,
|
|
28
|
-
and candidate implementation worker report.
|
|
29
|
-
|
|
30
|
-
Status meanings:
|
|
31
|
-
|
|
32
|
-
- \`success\`: the assigned scope was covered, or any skipped items are explicitly
|
|
33
|
-
immaterial to the assigned question.
|
|
34
|
-
- \`partial\`: useful evidence was gathered, but material assigned scope remains
|
|
35
|
-
unchecked or unresolved.
|
|
36
|
-
- \`blocked\`: the worker cannot answer the assigned question without missing
|
|
37
|
-
access, input, dependencies, or manager clarification.
|
|
38
|
-
|
|
39
|
-
## Evidence, review, validation, or audit worker report
|
|
40
|
-
|
|
41
|
-
Use the one role-specific block that matches the assigned worker.
|
|
42
|
-
|
|
43
|
-
<!-- flow-prompt:handoff-evidence:start -->
|
|
44
|
-
Return only this Flow handoff:
|
|
45
|
-
## Status
|
|
46
|
-
success | partial | blocked
|
|
47
|
-
## Scope
|
|
48
|
-
assigned slice
|
|
49
|
-
## Pass metadata
|
|
50
|
-
pass id, manifest row id, dependencies, write scope
|
|
51
|
-
## Coverage
|
|
52
|
-
expected, checked, not checked with reasons
|
|
53
|
-
## Findings or facts
|
|
54
|
-
confidence, atomic claim, citation, corroboration
|
|
55
|
-
## Sources
|
|
56
|
-
paths, commands, documents, screenshots, or data ranges inspected
|
|
57
|
-
## Confidence and verification
|
|
58
|
-
verified, single-source, inferred, unsettled, falsifier
|
|
59
|
-
## Open questions / gaps
|
|
60
|
-
## Manager follow-ups
|
|
61
|
-
<!-- flow-prompt:handoff-evidence:end -->
|
|
62
|
-
|
|
63
|
-
<!-- flow-prompt:handoff-validation:start -->
|
|
64
|
-
Return only this Flow handoff:
|
|
65
|
-
## Status
|
|
66
|
-
success | partial | blocked
|
|
67
|
-
## Scope
|
|
68
|
-
assigned checks or validation question
|
|
69
|
-
## Pass metadata
|
|
70
|
-
pass id, manifest row id, dependencies, write scope
|
|
71
|
-
## Coverage
|
|
72
|
-
expected, checked, not checked with reasons
|
|
73
|
-
## Commands and outcomes
|
|
74
|
-
exact command, status, raw outcome summary, behavior covered
|
|
75
|
-
## Confidence and verification
|
|
76
|
-
verified, single-source, inferred, unsettled, falsifier
|
|
77
|
-
## Open questions / gaps
|
|
78
|
-
## Manager follow-ups
|
|
79
|
-
<!-- flow-prompt:handoff-validation:end -->
|
|
80
|
-
|
|
81
|
-
<!-- flow-prompt:handoff-audit:start -->
|
|
82
|
-
Return only this Flow handoff:
|
|
83
|
-
## Status
|
|
84
|
-
success | partial | blocked
|
|
85
|
-
## Scope
|
|
86
|
-
assigned paths, risks, or candidate findings
|
|
87
|
-
## Pass metadata
|
|
88
|
-
pass id, manifest row id, dependencies, write scope
|
|
89
|
-
## Coverage
|
|
90
|
-
expected, checked, not checked with reasons
|
|
91
|
-
## Findings
|
|
92
|
-
severity, atomic claim, citation, corroboration, guards checked, refutation result
|
|
93
|
-
## Sources
|
|
94
|
-
## Confidence and verification
|
|
95
|
-
verified, single-source, inferred, unsettled, falsifier
|
|
96
|
-
## Open questions / gaps
|
|
97
|
-
## Manager follow-ups
|
|
98
|
-
<!-- flow-prompt:handoff-audit:end -->
|
|
99
|
-
|
|
100
|
-
<!-- flow-prompt:handoff-review-slice:start -->
|
|
101
|
-
For an assigned review slice, return only this Flow handoff:
|
|
102
|
-
## Status
|
|
103
|
-
success | partial | blocked
|
|
104
|
-
## Scope
|
|
105
|
-
assigned files, risk lens, or validation surface
|
|
106
|
-
## Pass metadata
|
|
107
|
-
pass id, manifest row id, dependencies, write scope
|
|
108
|
-
## Coverage
|
|
109
|
-
expected, checked, not checked with reasons
|
|
110
|
-
## Findings
|
|
111
|
-
prefix each \`blocking:\` or \`advisory:\`, then severity, claim, citation, and corroboration
|
|
112
|
-
## Sources
|
|
113
|
-
## Confidence and verification
|
|
114
|
-
verified, single-source, inferred, unsettled, falsifier
|
|
115
|
-
## Open questions / gaps
|
|
116
|
-
## Manager follow-ups
|
|
117
|
-
<!-- flow-prompt:handoff-review-slice:end -->
|
|
118
|
-
|
|
119
|
-
## Verifier worker report
|
|
120
|
-
|
|
121
|
-
Use this for \`flow-verifier-worker\`.
|
|
122
|
-
|
|
123
|
-
<!-- flow-prompt:handoff-verifier:start -->
|
|
124
|
-
Return only this Flow handoff:
|
|
125
|
-
## Status
|
|
126
|
-
success | partial | blocked
|
|
127
|
-
## Scope
|
|
128
|
-
atomic claim ids, sources or commands checked, acceptance question
|
|
129
|
-
## Pass metadata
|
|
130
|
-
pass id, manifest row id, dependencies
|
|
131
|
-
## Verdict per claim
|
|
132
|
-
supported | partly-supported | unsupported | source-not-found; include claim, resolved evidence, confidence, recommended action
|
|
133
|
-
## Overall
|
|
134
|
-
accept | revise | reject with reason
|
|
135
|
-
## Gaps
|
|
136
|
-
## Manager follow-ups
|
|
137
|
-
<!-- flow-prompt:handoff-verifier:end -->
|
|
138
|
-
|
|
139
|
-
## Candidate implementation worker report
|
|
140
|
-
|
|
141
|
-
Use this only with explicit user authorization and isolated or exact-path
|
|
142
|
-
ownership.
|
|
143
|
-
|
|
144
|
-
<!-- flow-prompt:handoff-candidate:start -->
|
|
145
|
-
Return only this Flow handoff:
|
|
146
|
-
## Status
|
|
147
|
-
success | partial | blocked
|
|
148
|
-
## Scope
|
|
149
|
-
isolated worktree or exact path-owned slice
|
|
150
|
-
## Pass metadata
|
|
151
|
-
pass id, manifest row id, dependencies, exact-path | isolated-worktree
|
|
152
|
-
## Changed or proposed patch
|
|
153
|
-
paths, change, reason
|
|
154
|
-
## Coverage
|
|
155
|
-
assigned, touched, skipped with reasons
|
|
156
|
-
## Verification
|
|
157
|
-
level, exact command or check, observed outcome
|
|
158
|
-
## Confidence and risk
|
|
159
|
-
directly checked, still open, risk with reason
|
|
160
|
-
## Merge notes
|
|
161
|
-
conflicts, user changes, assumptions, deviations
|
|
162
|
-
## Manager follow-ups
|
|
163
|
-
<!-- flow-prompt:handoff-candidate:end -->
|
|
164
|
-
|
|
165
|
-
The manager must inspect and validate any candidate patch before recording Flow
|
|
166
|
-
completion.
|
|
167
|
-
|
|
168
|
-
## Manager pass accounting record
|
|
169
|
-
|
|
170
|
-
The manager, not the worker, may carry bounded records into
|
|
171
|
-
\`flow_feature_complete.orchestrationPasses\`. Use one record per material pass or
|
|
172
|
-
implementation decision; keep handoffs and long artifacts outside \`.flow/**\`.
|
|
173
|
-
The candidate accounting rules — which \`candidateEligibility\`,
|
|
174
|
-
\`candidateDecision\`, and \`decision\` combinations validate, and what counts as
|
|
175
|
-
candidate execution evidence — live in
|
|
176
|
-
[parallel-decision.md](parallel-decision.md) under "Implementation pass
|
|
177
|
-
decision"; note \`decision: "parallel"\` is not valid on
|
|
178
|
-
\`implementation-decision\` records.
|
|
179
|
-
|
|
180
|
-
\`\`\`json
|
|
181
|
-
{
|
|
182
|
-
"id": "stable-pass-id",
|
|
183
|
-
"kind": "discovery | audit | review | validation | verification | candidate | implementation-decision",
|
|
184
|
-
"decision": "serial | parallel | candidate-exact-path | candidate-worktree | tournament | skipped",
|
|
185
|
-
"decisionReason": "why this pass shape was chosen",
|
|
186
|
-
"candidateEligibility": "eligible | not_eligible | unknown",
|
|
187
|
-
"candidateDecision": "used | skipped | serial_required",
|
|
188
|
-
"decisionFactors": [
|
|
189
|
-
"shared_state",
|
|
190
|
-
"overlapping_files",
|
|
191
|
-
"small_slice",
|
|
192
|
-
"needs_manager_judgment",
|
|
193
|
-
"independent_surface",
|
|
194
|
-
"validation_available"
|
|
195
|
-
],
|
|
196
|
-
"modes": ["evidence"],
|
|
197
|
-
"workerCount": 1,
|
|
198
|
-
"candidateWorkerCount": 0,
|
|
199
|
-
"verifierWorkerCount": 0,
|
|
200
|
-
"sliceIds": ["manifest-row-id"],
|
|
201
|
-
"dependsOn": [],
|
|
202
|
-
"writeScope": "none | manager-serial | exact-path | isolated-worktree | mixed",
|
|
203
|
-
"handoffRefs": ["/tmp/flow-handoff.md"],
|
|
204
|
-
"verificationStatus": "not-needed | pending | passed | failed | mixed | downgraded",
|
|
205
|
-
"outcome": "accepted | modified | rejected | partial | not-covered | superseded",
|
|
206
|
-
"synthesisRef": "/tmp/flow-synthesis.md"
|
|
207
|
-
}
|
|
208
|
-
\`\`\`
|
|
209
|
-
`;
|
|
210
|
-
|
|
211
|
-
// skills/flow/references/parallel-decision.md
|
|
212
|
-
var parallel_decision_default = `# Parallel pass decisions
|
|
213
|
-
|
|
214
|
-
Read this reference after serial orientation and before creating a pass
|
|
215
|
-
manifest. It decides whether fan-out is worth its coordination cost and records
|
|
216
|
-
why implementation stays serial or uses candidate workers.
|
|
217
|
-
|
|
218
|
-
<!-- flow-prompt:manager-parallel-core:start -->
|
|
219
|
-
## Conditional parallel pass
|
|
220
|
-
|
|
221
|
-
Use a parallel pass only when independent coverage is worth its coordination
|
|
222
|
-
cost. Orient serially first. Before fan-out record a stable pass id, purpose,
|
|
223
|
-
bounded worker count, exact non-overlapping slices, expected coverage, named
|
|
224
|
-
Flow worker roles, dependencies, write scope, handoff kind, verification plan,
|
|
225
|
-
and stop condition.
|
|
226
|
-
|
|
227
|
-
Use \`flow-evidence-worker\` for discovery, \`flow-validation-worker\` for commands,
|
|
228
|
-
\`flow-audit-worker\` for adversarial findings, \`flow-verifier-worker\` for
|
|
229
|
-
high-impact claim checks, and \`flow-reviewer\` for independent review. Account
|
|
230
|
-
for every manifest row. A missing, empty, malformed, partial, or blocked
|
|
231
|
-
handoff is a coverage gap, not success. Verify high-impact or single-source
|
|
232
|
-
claims, then let only the manager synthesize the result and mutate Flow state.
|
|
233
|
-
<!-- flow-prompt:manager-parallel-core:end -->
|
|
234
|
-
|
|
235
|
-
## Choose a pass
|
|
236
|
-
|
|
237
|
-
| Situation | Flow pass | Manager-owned result |
|
|
238
|
-
| --- | --- | --- |
|
|
239
|
-
| Repo shape is unclear before planning | Discovery | Evidenced requirements, decisions, targets, validation, or a review-first feature |
|
|
240
|
-
| A broad finding set needs refutation | Audit | Findings that survive guard and counterexample checks |
|
|
241
|
-
| Changed files or risk lenses exceed one review pass | Review | One feature review or final review payload |
|
|
242
|
-
| Test strategy or route coverage is unclear | Validation | Candidate commands or authorized raw command evidence |
|
|
243
|
-
| A claim is surprising, high-stakes, single-source, or payload-bound | Verification | Per-claim keep, narrow, rewrite, or remove decisions |
|
|
244
|
-
| Multiple independent implementation paths are plausible | Candidate | Inspected candidate patches, never direct Flow completion |
|
|
245
|
-
|
|
246
|
-
Discovery, audit, review, validation, and verification passes are read-only.
|
|
247
|
-
Validation workers run only manager-authorized commands. Verification workers
|
|
248
|
-
judge atomic claims rather than redesigning the work. Candidate passes require
|
|
249
|
-
explicit user authorization plus an isolated worktree or exact non-overlapping
|
|
250
|
-
path ownership; patches remain proposals until manager inspection and
|
|
251
|
-
validation.
|
|
252
|
-
|
|
253
|
-
## Implementation pass decision
|
|
254
|
-
|
|
255
|
-
Before editing a broad, risky, or multi-target feature, record one manager
|
|
256
|
-
decision even when implementation stays serial. Keep \`candidateEligibility\`,
|
|
257
|
-
\`candidateDecision\`, and \`decision\` as distinct fields.
|
|
258
|
-
|
|
259
|
-
Classify candidate eligibility separately from the decision:
|
|
260
|
-
|
|
261
|
-
| Eligibility | Meaning |
|
|
262
|
-
| --- | --- |
|
|
263
|
-
| \`eligible\` | At least one slice has independent ownership and practical validation. |
|
|
264
|
-
| \`not_eligible\` | Shared state, files, tests, or judgment make isolation unsafe or wasteful. |
|
|
265
|
-
| \`unknown\` | Orientation is incomplete; never use this on an \`implementation-decision\` record. |
|
|
266
|
-
|
|
267
|
-
Use only these pairings on \`implementation-decision\` records:
|
|
268
|
-
|
|
269
|
-
| Eligibility | Candidate decision | Implementation decision |
|
|
270
|
-
| --- | --- | --- |
|
|
271
|
-
| \`eligible\` | \`used\` | \`candidate-exact-path\`, \`candidate-worktree\`, or \`tournament\` |
|
|
272
|
-
| \`eligible\` | \`skipped\` | \`skipped\` |
|
|
273
|
-
| \`not_eligible\` | \`serial_required\` | \`serial\` |
|
|
274
|
-
|
|
275
|
-
Candidate-shaped decisions and \`candidateDecision: "used"\` require execution
|
|
276
|
-
evidence on the same record: \`kind: "candidate"\`, \`modes\` containing
|
|
277
|
-
\`candidate-implementation\`, or \`candidateWorkerCount > 0\`. Keep
|
|
278
|
-
\`candidateWorkerCount <= workerCount\` and
|
|
279
|
-
\`verifierWorkerCount <= workerCount\`; one worker may fill both subtype counts.
|
|
280
|
-
Never use \`parallel\` as an implementation decision. Reserve \`parallel\` for
|
|
281
|
-
multi-worker read, audit, review, validation, or verification passes.
|
|
282
|
-
|
|
283
|
-
Implementation decision meanings:
|
|
284
|
-
|
|
285
|
-
- \`serial\`: the manager implements directly because work overlaps or depends on
|
|
286
|
-
one shared contract or mental model.
|
|
287
|
-
- \`candidate-exact-path\`: workers own exact, disjoint path sets in one checkout.
|
|
288
|
-
- \`candidate-worktree\`: isolated workers propose patches for manager integration.
|
|
289
|
-
- \`tournament\`: isolated candidates compete; the manager selects using source
|
|
290
|
-
inspection, validation, and review.
|
|
291
|
-
- \`skipped\`: candidate work was eligible, but coordination cost outweighed its
|
|
292
|
-
value. Do not use it for unsafe ownership; those cases are \`serial\`.
|
|
293
|
-
|
|
294
|
-
Record \`decisionReason\` plus the applicable structured \`decisionFactors\`:
|
|
295
|
-
\`shared_state\`, \`overlapping_files\`, \`small_slice\`,
|
|
296
|
-
\`needs_manager_judgment\`, \`independent_surface\`, and
|
|
297
|
-
\`validation_available\`. Also record a stable pass id, write scope, expected
|
|
298
|
-
verification, and the handoff or synthesis location. Carry the bounded record
|
|
299
|
-
into \`flow_feature_complete.orchestrationPasses\` when it materially shaped the
|
|
300
|
-
feature; keep full handoffs and logs outside Flow state.
|
|
301
|
-
|
|
302
|
-
## Candidate judgment
|
|
303
|
-
|
|
304
|
-
Consider candidate workers when ownership is additive or localized, validation
|
|
305
|
-
can run per slice, and the manager can safely inspect or reject the result.
|
|
306
|
-
Separate frontend, core, docs, release, test, or binding surfaces are useful
|
|
307
|
-
signals, but the actual path and contract boundaries decide eligibility.
|
|
308
|
-
|
|
309
|
-
Stay serial when any of these apply:
|
|
310
|
-
|
|
311
|
-
- One file, command, contract, migration, or design question determines the
|
|
312
|
-
next step.
|
|
313
|
-
- Slices share state, callers, fixtures, generated output, lockfiles, tests, or
|
|
314
|
-
edit targets.
|
|
315
|
-
- Persistence or lifecycle behavior requires one mental model.
|
|
316
|
-
- Iterative debugging must happen in one checkout.
|
|
317
|
-
- Prompt, handoff, merge, and verification cost exceeds direct work.
|
|
318
|
-
- The manager would still need the same full synthesis with no coverage gain.
|
|
319
|
-
|
|
320
|
-
Do not fan out to keep workers busy. Every worker must reduce a named
|
|
321
|
-
uncertainty.
|
|
322
|
-
|
|
323
|
-
## Worker count defaults
|
|
324
|
-
|
|
325
|
-
Use bounded caps rather than worker-count targets:
|
|
326
|
-
|
|
327
|
-
- Small implementation: zero or one worker.
|
|
328
|
-
- Medium independent implementation: at most two workers.
|
|
329
|
-
- Broad audit: three to five workers.
|
|
330
|
-
- Broad implementation: two to four candidate workers with non-overlapping
|
|
331
|
-
ownership.
|
|
332
|
-
- Medium- or high-risk final verification: one verifier.
|
|
333
|
-
|
|
334
|
-
Use more only when the manifest remains countable and non-overlapping.
|
|
335
|
-
`;
|
|
336
|
-
|
|
337
|
-
// skills/flow/references/parallel-execution.md
|
|
338
|
-
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";
|
|
339
|
-
|
|
340
|
-
// skills/flow/references/parallel-manifest.md
|
|
341
|
-
var parallel_manifest_default = `# Parallel pass manifest
|
|
342
|
-
|
|
343
|
-
Read this only after \`parallel-decision.md\` selects a parallel or candidate
|
|
344
|
-
pass. The manifest is the pre-fan-out coverage gate and the accounting contract
|
|
345
|
-
for every worker result.
|
|
346
|
-
|
|
347
|
-
## Orient and slice
|
|
348
|
-
|
|
349
|
-
Call \`flow_status\` when a Flow session may exist. Read enough code, schemas,
|
|
350
|
-
docs, tests, commands, or artifacts to identify real slices. Keep the question
|
|
351
|
-
that determines whether fan-out is valid in manager context.
|
|
352
|
-
|
|
353
|
-
Split by an axis that keeps work independent: modules or paths, routes or
|
|
354
|
-
endpoints, risk lenses, commands, data ranges, or atomic claims. Give each slice
|
|
355
|
-
a one-line scope, expected coverage, checkable output, dependencies, write
|
|
356
|
-
scope, and verification tier. Shared files, fixtures, schemas, and public
|
|
357
|
-
contracts normally stay serial unless candidate work uses isolated worktrees.
|
|
358
|
-
|
|
359
|
-
## Write the manifest
|
|
360
|
-
|
|
361
|
-
Before spawning, write one row per slice plus a totals or completeness check.
|
|
362
|
-
Use stable pass and row ids so later handoffs, verification, synthesis, and
|
|
363
|
-
completion accounting refer to the same work without replaying conversation
|
|
364
|
-
history.
|
|
365
|
-
|
|
366
|
-
| Row id | Slice | Expected coverage | Mode | Depends on | Write scope | Verification tier | Handoff ref | Verification status | Synthesis ref |
|
|
367
|
-
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
368
|
-
| \`runtime-read\` | \`src/core/**\` plus tests | 14 files | \`evidence\` | none | none | accept locally | pending | pending | pending |
|
|
369
|
-
| \`release-read\` | CI, package metadata, changelog | 6 files | \`audit\` | none | none | verify once | pending | pending | pending |
|
|
370
|
-
|
|
371
|
-
Use runtime \`writeScope\` values exactly: \`none\`, \`manager-serial\`, \`exact-path\`,
|
|
372
|
-
\`isolated-worktree\`, or \`mixed\`.
|
|
373
|
-
|
|
374
|
-
Before launch:
|
|
375
|
-
|
|
376
|
-
- Reconcile countable work such as files, routes, commands, rows, findings,
|
|
377
|
-
screenshots, or claims. Slice totals must have no overlaps, gaps, or empty
|
|
378
|
-
rows.
|
|
379
|
-
- When scope is not countable, state a completeness rule such as "all changed
|
|
380
|
-
files plus callers" or "all public commands plus release docs."
|
|
381
|
-
- Assign a verification tier before handoffs arrive.
|
|
382
|
-
- Record dependency edges. Spawn a dependent row only after its prerequisite
|
|
383
|
-
has a verified handoff or manager synthesis that settles the dependency.
|
|
384
|
-
- Fix an unreconciled slice map centrally before fan-out.
|
|
385
|
-
|
|
386
|
-
N spawned rows require N collected and checked handoffs before synthesis.
|
|
387
|
-
|
|
388
|
-
## Implementation decision rows
|
|
389
|
-
|
|
390
|
-
Add an implementation decision row even when no worker is spawned. Record:
|
|
391
|
-
|
|
392
|
-
- \`kind: "implementation-decision"\`
|
|
393
|
-
- the valid decision, eligibility, and candidate-decision pairing from
|
|
394
|
-
\`parallel-decision.md\`
|
|
395
|
-
- \`decisionFactors\`, \`decisionReason\`, and \`writeScope: "manager-serial"\`
|
|
396
|
-
- \`workerCount: 0\`, a stable row id, verification status, and outcome
|
|
397
|
-
|
|
398
|
-
When \`candidateDecision\` is \`used\`, record actual candidate execution evidence
|
|
399
|
-
and raise worker counts accordingly. A zero-worker record cannot claim candidate
|
|
400
|
-
use. Subtype counts may not exceed total worker count.
|
|
401
|
-
|
|
402
|
-
## Persistence
|
|
403
|
-
|
|
404
|
-
The conversation is sufficient for one bounded pass. When a follow-up pass or
|
|
405
|
-
session resume is plausible, persist the accounted manifest with the synthesis
|
|
406
|
-
in a manager-owned temporary artifact outside \`.flow/**\` and outside the repo
|
|
407
|
-
worktree. The runtime stores bounded accounting, not complete worker handoffs.
|
|
408
|
-
`;
|
|
409
|
-
|
|
410
|
-
// skills/flow/references/parallel-orchestration.md
|
|
411
|
-
var parallel_orchestration_default = `# Parallel orchestration
|
|
412
|
-
|
|
413
|
-
Use this index after a serial orientation pass shows that independent slices
|
|
414
|
-
may reduce a named discovery, validation, review, audit, verification, or
|
|
415
|
-
implementation uncertainty. The root manager owns the Flow session and every
|
|
416
|
-
state-changing \`flow_*\` call throughout the pass.
|
|
417
|
-
|
|
418
|
-
## Load only the selected branch
|
|
419
|
-
|
|
420
|
-
1. Read \`parallel-decision.md\` whenever deciding whether work should fan out.
|
|
421
|
-
2. Stop loading parallel references when the decision is serial. Record the
|
|
422
|
-
implementation decision when the active feature requires one.
|
|
423
|
-
3. After selecting a parallel or candidate pass, read
|
|
424
|
-
\`parallel-manifest.md\`, then \`parallel-execution.md\`.
|
|
425
|
-
4. When handoffs return, read \`parallel-synthesis.md\` before accepting claims,
|
|
426
|
-
recording evidence, or presenting a result.
|
|
427
|
-
5. Copy exactly one matching worker response template from \`handoff-format.md\`
|
|
428
|
-
into each worker prompt. Hidden workers cannot load skills or references.
|
|
429
|
-
6. Read \`parallel-pass-example.md\` only when a concrete end-to-end example is
|
|
430
|
-
needed.
|
|
431
|
-
|
|
432
|
-
Do not preload the manifest, worker, and synthesis runbooks merely because a
|
|
433
|
-
task could be parallel. The decision reference is enough to keep serial work
|
|
434
|
-
serial.
|
|
435
|
-
|
|
436
|
-
## Pass routing
|
|
437
|
-
|
|
438
|
-
| Situation | Pass | Typical worker |
|
|
439
|
-
| --- | --- | --- |
|
|
440
|
-
| Repo shape is unclear before planning | Discovery | \`flow-evidence-worker\` |
|
|
441
|
-
| A broad finding set needs refutation | Audit | \`flow-audit-worker\` |
|
|
442
|
-
| Changed files or risk lenses exceed one review pass | Review | \`flow-reviewer\` |
|
|
443
|
-
| Test strategy or route coverage is unclear | Validation | \`flow-validation-worker\` |
|
|
444
|
-
| A claim is surprising, high-stakes, single-source, or payload-bound | Verification | \`flow-verifier-worker\` |
|
|
445
|
-
| An authorized independent implementation slice exists | Candidate | \`flow-candidate-worker\` |
|
|
446
|
-
|
|
447
|
-
Only the manager synthesizes the pass, decides whether evidence is sufficient,
|
|
448
|
-
integrates candidate patches, records Flow state, or returns the final verdict.
|
|
449
|
-
`;
|
|
450
|
-
|
|
451
|
-
// skills/flow/references/parallel-pass-example.md
|
|
452
|
-
var parallel_pass_example_default = `# Parallel pass example
|
|
453
|
-
|
|
454
|
-
Use this example only after \`parallel-orchestration.md\` routes a broad Flow task
|
|
455
|
-
to fan-out. It illustrates the manifest, execution, and synthesis references;
|
|
456
|
-
derive real slices from the actual repo during serial orientation.
|
|
457
|
-
|
|
458
|
-
Goal: review whether a web app's API error handling is consistent before
|
|
459
|
-
planning a refactor.
|
|
460
|
-
|
|
461
|
-
Serial orientation: the manager reads the router entry point enough to identify
|
|
462
|
-
twelve API route modules, one shared error middleware, and an integration test
|
|
463
|
-
directory. The manager keeps the middleware local because it is one file and
|
|
464
|
-
anchors every other judgment.
|
|
465
|
-
|
|
466
|
-
Pass manifest: twelve countable route modules remain after the local check, and
|
|
467
|
-
4 + 3 + 5 adds back to 12 with no overlaps or gaps. The pass id is
|
|
468
|
-
\`api-error-handling-read\`.
|
|
469
|
-
|
|
470
|
-
| Row id | Slice scope | Expected coverage | Mode | Depends on | Write scope | Verification tier | Handoff ref | Verification status | Synthesis ref |
|
|
471
|
-
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
472
|
-
| \`routes-auth\` | auth and account routes | 4/12 modules | \`evidence\` | none | none | accept locally | pending | pending | pending |
|
|
473
|
-
| \`routes-billing\` | billing and subscription routes | 3/12 modules | \`review\` | none | none | verify once | pending | pending | pending |
|
|
474
|
-
| \`routes-admin\` | remaining content and admin routes | 5/12 modules | \`audit\` | none | none | verify once | pending | pending | pending |
|
|
475
|
-
|
|
476
|
-
Worker prompts:
|
|
477
|
-
|
|
478
|
-
\`\`\`text
|
|
479
|
-
Overall goal, context only: confirm API error handling is consistent.
|
|
480
|
-
Mode: evidence
|
|
481
|
-
Pass id and manifest row id: api-error-handling-read / routes-auth
|
|
482
|
-
Your exact slice: the four auth and account route modules under src/routes/.
|
|
483
|
-
Expected coverage: 4/4 modules.
|
|
484
|
-
Dependencies and write scope: none; none.
|
|
485
|
-
Do: report each route's error paths, status codes, and middleware usage with file:line evidence.
|
|
486
|
-
Do not: call state-changing Flow tools, edit .flow/**, own sibling slices, or make the final Flow verdict.
|
|
487
|
-
Return only the Flow handoff in this exact shape:
|
|
488
|
-
<matching handoff template copied verbatim from handoff-format.md>
|
|
489
|
-
\`\`\`
|
|
490
|
-
|
|
491
|
-
\`\`\`text
|
|
492
|
-
Overall goal, context only: confirm API error handling is consistent.
|
|
493
|
-
Mode: review
|
|
494
|
-
Pass id and manifest row id: api-error-handling-read / routes-billing
|
|
495
|
-
Your exact slice: the three billing and subscription route modules under src/routes/.
|
|
496
|
-
Expected coverage: 3/3 modules.
|
|
497
|
-
Dependencies and write scope: none; none.
|
|
498
|
-
Do: separate blocking findings from advisory notes and cite file:line evidence.
|
|
499
|
-
Do not: call state-changing Flow tools, edit .flow/**, own sibling slices, or make the final Flow verdict.
|
|
500
|
-
Return only the Flow handoff in this exact shape:
|
|
501
|
-
<matching handoff template copied verbatim from handoff-format.md>
|
|
502
|
-
\`\`\`
|
|
503
|
-
|
|
504
|
-
\`\`\`text
|
|
505
|
-
Overall goal, context only: confirm API error handling is consistent.
|
|
506
|
-
Mode: audit
|
|
507
|
-
Pass id and manifest row id: api-error-handling-read / routes-admin
|
|
508
|
-
Your exact slice: the five content and admin route modules under src/routes/.
|
|
509
|
-
Expected coverage: 5/5 modules.
|
|
510
|
-
Dependencies and write scope: none; none.
|
|
511
|
-
Do: check each claimed error path against the shared middleware contract and report divergences with evidence.
|
|
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
|
-
\`\`\`
|
|
516
|
-
|
|
517
|
-
Accounting: three manifest rows spawned means three handoffs collected before
|
|
518
|
-
synthesis. If slice B returned \`partial\`, the manager would re-spawn it once
|
|
519
|
-
with a narrower scope, then cover it directly, and as a last resort carry it
|
|
520
|
-
into the synthesis explicitly as not-covered.
|
|
521
|
-
The manager fills \`handoffRefs\`, \`verificationStatus\`, \`outcome\`, and
|
|
522
|
-
\`synthesisRef\` for each row before any claim becomes a plan decision or review
|
|
523
|
-
payload.
|
|
524
|
-
|
|
525
|
-
Handoff checks: the manager accepts only reports with terminal status, matching
|
|
526
|
-
coverage counts, concrete file:line evidence, confidence tags, and claims inside
|
|
527
|
-
the assigned slice. A claim such as \`[high] billing routes bypass the error
|
|
528
|
-
middleware; evidence: src/routes/billing.ts:88-104; corroboration: single
|
|
529
|
-
source\` is usable. A claim such as \`[high] error handling looks fine; evidence:
|
|
530
|
-
routes reviewed\` is dropped or retasked.
|
|
531
|
-
|
|
532
|
-
Verifier pass: the manager sends any single-source claim that will enter the
|
|
533
|
-
Flow payload to \`flow-verifier-worker\`, for example: \`C1: billing and
|
|
534
|
-
subscription routes return raw exceptions while all other routes use the shared
|
|
535
|
-
error envelope; sources: src/routes/billing.ts, src/routes/subscription.ts\`.
|
|
536
|
-
|
|
537
|
-
Final synthesis: the manager re-reads the relevant route and middleware lines,
|
|
538
|
-
keeps only verified or clearly labeled claims, and records one artifact such as
|
|
539
|
-
a plan decision, review payload, or docs patch. Raw handoffs and unverified
|
|
540
|
-
suggestions do not move into the next pass or user-facing answer.
|
|
541
|
-
|
|
542
|
-
If the pass shaped feature execution, the manager records bounded accounting in
|
|
543
|
-
\`flow_feature_complete.orchestrationPasses\`, such as pass id
|
|
544
|
-
\`api-error-handling-read\`, kind \`review\`, worker count \`3\`, slice ids
|
|
545
|
-
\`routes-auth\`, \`routes-billing\`, and \`routes-admin\`, verification status
|
|
546
|
-
\`mixed\` or \`passed\`, and a synthesis ref pointing to the manager-owned summary.
|
|
547
|
-
`;
|
|
548
|
-
|
|
549
|
-
// skills/flow/references/parallel-synthesis.md
|
|
550
|
-
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";
|
|
551
|
-
|
|
552
|
-
// skills/flow/references/recovery-playbook.md
|
|
553
|
-
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';
|
|
554
|
-
|
|
555
|
-
// skills/flow/SKILL.md
|
|
556
|
-
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";
|
|
557
|
-
|
|
558
|
-
// skills/flow-commit/SKILL.md
|
|
559
|
-
var SKILL_default2 = `---
|
|
560
|
-
name: flow-commit
|
|
561
|
-
description: Prepare safe Git commits and commit messages. Use only when the user asks to inspect, stage, validate, write a commit message, or create a commit; preserves unrelated work and never pushes, amends, rebases, or publishes without explicit authorization.
|
|
562
|
-
---
|
|
563
|
-
|
|
564
|
-
# Flow Commit
|
|
565
|
-
|
|
566
|
-
Use this skill only when the user asks to prepare or create a commit, write a
|
|
567
|
-
commit message, stage intended work, or validate staged changes before
|
|
568
|
-
committing. It is not part of the autonomous Flow loop and must not be loaded
|
|
569
|
-
automatically by \`flow\`, \`flow-run\`, or \`flow_feature_complete\`.
|
|
570
|
-
|
|
571
|
-
When a Flow session exists, a commit never substitutes for Flow completion. The
|
|
572
|
-
manager still records validation and review evidence through
|
|
573
|
-
\`flow_feature_complete\` before claiming a Flow feature is done. Default to commit
|
|
574
|
-
preparation only after \`flow_feature_complete\` has recorded the relevant
|
|
575
|
-
completion evidence. If the user explicitly asks for a WIP commit, preserve
|
|
576
|
-
failing or incomplete validation context in the message.
|
|
577
|
-
|
|
578
|
-
## Boundaries
|
|
579
|
-
|
|
580
|
-
- Preserve unrelated user work.
|
|
581
|
-
- Stage explicit paths or hunks only. Do not default to \`git add .\` or
|
|
582
|
-
\`git add -A\`.
|
|
583
|
-
- Do not commit \`.flow/**\` state unless the maintainer explicitly asks to
|
|
584
|
-
archive those exact files.
|
|
585
|
-
- Do not push, amend, rebase, squash, reset, force-push, tag, release, publish,
|
|
586
|
-
or mutate remote state unless the user explicitly authorizes that exact
|
|
587
|
-
operation.
|
|
588
|
-
- Stop before committing secrets, local config, credentials, private keys,
|
|
589
|
-
generated release artifacts, or suspicious environment files.
|
|
590
|
-
- Stop when validation fails unless the user explicitly wants an unfinished WIP
|
|
591
|
-
commit and the commit message says so.
|
|
592
|
-
|
|
593
|
-
## Inspect
|
|
594
|
-
|
|
595
|
-
Start with the worktree and intent:
|
|
596
|
-
|
|
597
|
-
1. Run \`git status --short\`.
|
|
598
|
-
2. Inspect unstaged and staged changes separately with \`git diff\` and
|
|
599
|
-
\`git diff --cached\`.
|
|
600
|
-
3. Inspect untracked files before deciding whether they belong.
|
|
601
|
-
4. Group changes by intent, feature, and risk. Prefer one coherent commit over
|
|
602
|
-
one large mixed commit.
|
|
603
|
-
5. Identify exclusions: unrelated files, local notes, \`.flow/**\`, generated
|
|
604
|
-
artifacts, logs, caches, credentials, and temporary outputs.
|
|
605
|
-
|
|
606
|
-
If the commit boundary is unclear, propose the boundary and ask before staging.
|
|
607
|
-
|
|
608
|
-
## Stage
|
|
609
|
-
|
|
610
|
-
Stage only the intended boundary:
|
|
611
|
-
|
|
612
|
-
- Use explicit file paths for whole-file staging.
|
|
613
|
-
- Use patch staging for mixed-intent files.
|
|
614
|
-
- Re-run \`git status --short\` and \`git diff --cached --stat\` after staging.
|
|
615
|
-
- Review the full staged diff before validation and commit.
|
|
616
|
-
|
|
617
|
-
Never undo or rewrite user changes to make staging easier. If a file contains
|
|
618
|
-
mixed user and agent work, either stage selected hunks or ask for direction.
|
|
619
|
-
|
|
620
|
-
## Screen and Validate
|
|
621
|
-
|
|
622
|
-
Before commit creation, check the staged diff for:
|
|
623
|
-
|
|
624
|
-
- Secrets, tokens, private keys, credentials, cookies, and unredacted personal
|
|
625
|
-
data.
|
|
626
|
-
- \`.env\`, local config, machine-specific paths, and editor files.
|
|
627
|
-
- \`.flow/**\` state.
|
|
628
|
-
- Generated artifacts that are not normally versioned.
|
|
629
|
-
- Package or version metadata drift unrelated to the requested change.
|
|
630
|
-
|
|
631
|
-
If the repository documents its own commit preflight (a package script, a
|
|
632
|
-
repo-local preflight script, or guidance in AGENTS/docs or CI config), defer to
|
|
633
|
-
it for staged validation instead of duplicating its checks. Run it after
|
|
634
|
-
staging and rerun it after any staging change. A staged-boundary preflight
|
|
635
|
-
validates diff hygiene and staged secret screening; it does not run a
|
|
636
|
-
whole-worktree gate, choose commit boundaries, or write commit messages.
|
|
637
|
-
|
|
638
|
-
Use the repository's documented broad validation gate when a full local check is
|
|
639
|
-
appropriate, such as package scripts, AGENTS/docs, or CI guidance. Treat broad
|
|
640
|
-
checks as whole-worktree evidence unless the repository explicitly provides a
|
|
641
|
-
staged-content runner. Use narrower tests only when the user has asked for a
|
|
642
|
-
lighter pass or when the change is intentionally not ready for the broad gate.
|
|
643
|
-
|
|
644
|
-
## Message
|
|
645
|
-
|
|
646
|
-
Propose a commit message that reflects the staged diff:
|
|
647
|
-
|
|
648
|
-
- Subject: imperative, specific, and scoped.
|
|
649
|
-
- Body when useful: context, changed areas, validation run, and remaining risk.
|
|
650
|
-
- Do not mention unstaged or excluded work as if it were included.
|
|
651
|
-
- Include WIP or failing-validation context only when the user explicitly chose
|
|
652
|
-
that path.
|
|
653
|
-
|
|
654
|
-
## Create Commit
|
|
655
|
-
|
|
656
|
-
Create the commit only after the user explicitly asks for commit creation or has
|
|
657
|
-
already authorized it in the current request.
|
|
658
|
-
|
|
659
|
-
Before running \`git commit\`, report:
|
|
660
|
-
|
|
661
|
-
- Staged paths.
|
|
662
|
-
- Excluded dirty or untracked paths.
|
|
663
|
-
- Validation command and result.
|
|
664
|
-
- Proposed message.
|
|
665
|
-
- Any risks or gaps.
|
|
666
|
-
|
|
667
|
-
After a successful commit, report the commit hash and leave push or release
|
|
668
|
-
actions for a separate explicit request.
|
|
669
|
-
`;
|
|
670
|
-
|
|
671
|
-
// skills/flow-deslop/references/refactor-workflow.md
|
|
672
|
-
var refactor_workflow_default = `# Safe refactor workflow
|
|
673
|
-
|
|
674
|
-
Refactoring is a behavior-preserving sequence of small changes. This workflow keeps cleanup from becoming an unreviewable rewrite.
|
|
675
|
-
|
|
676
|
-
## Before editing
|
|
677
|
-
|
|
678
|
-
- Define the invariant: what behavior, API, schema, command, state path, or visual output must remain unchanged.
|
|
679
|
-
- Locate callers and tests before changing the target. If there is no test coverage, add or run the narrowest check that proves current behavior.
|
|
680
|
-
- Identify the smallest reversible move: remove dead code, rename, extract, inline, move, consolidate, or split phase.
|
|
681
|
-
- Choose a validation command that can fail for the behavior you might break.
|
|
682
|
-
|
|
683
|
-
## During editing
|
|
684
|
-
|
|
685
|
-
- Make one structural move at a time, then re-run the relevant check when risk is non-trivial.
|
|
686
|
-
- Prefer deleting or inlining a useless layer before introducing a new one.
|
|
687
|
-
- Keep names domain-specific. Generic names like \`manager\`, \`processor\`, \`utils\`, and \`helper\` are suspect unless the repo already owns that vocabulary.
|
|
688
|
-
- Avoid mixed commits inside a feature: no unrelated formatting, package churn, comment rewrites, or style sweeps.
|
|
689
|
-
- If the refactor uncovers a behavior bug, stop and replan unless the approved feature already includes fixing that bug.
|
|
690
|
-
|
|
691
|
-
## Validation evidence
|
|
692
|
-
|
|
693
|
-
Good cleanup evidence includes:
|
|
694
|
-
|
|
695
|
-
- focused tests for behavior touched by the refactor.
|
|
696
|
-
- typecheck/lint/build output for mechanical structure changes.
|
|
697
|
-
- before/after references for deleted exports, commands, generated files, and docs when static search is not enough.
|
|
698
|
-
- broad validation when shared abstractions, public APIs, persistence, or cross-feature integration changed.
|
|
699
|
-
|
|
700
|
-
Weak evidence includes:
|
|
701
|
-
|
|
702
|
-
- "No tests needed" for behavior-adjacent refactors.
|
|
703
|
-
- tests that were edited to match the new shape but do not prove the old behavior.
|
|
704
|
-
- scanner metrics without human inspection.
|
|
705
|
-
- green tests after changing unrelated surfaces not covered by those tests.
|
|
706
|
-
|
|
707
|
-
## Review checklist
|
|
708
|
-
|
|
709
|
-
- Every changed artifact maps to the approved cleanup scope.
|
|
710
|
-
- The new structure has fewer reasons to change, not just fewer lines.
|
|
711
|
-
- Public contracts and compatibility shims remain intact or were explicitly planned.
|
|
712
|
-
- Deleted code is actually unreachable or obsolete.
|
|
713
|
-
- Validation can catch a realistic mistake in the refactor.
|
|
714
|
-
`;
|
|
715
|
-
|
|
716
|
-
// skills/flow-deslop/references/smell-rubric.md
|
|
717
|
-
var smell_rubric_default = `# Deslop smell rubric
|
|
718
|
-
|
|
719
|
-
Use this rubric to turn vague cleanup instincts into reviewable findings.
|
|
720
|
-
|
|
721
|
-
## Actionable smell classes
|
|
722
|
-
|
|
723
|
-
- **duplication** — repeated logic or conditionals that must change together. Confirm whether small repetition is clearer than abstraction.
|
|
724
|
-
- **bloat** — long function, large class/module, or oversized component whose responsibilities are mixed enough to hide behavior.
|
|
725
|
-
- **speculative generality** — unused extension points, factories, options, interfaces, or configuration added for imagined futures.
|
|
726
|
-
- **dead code** — unreachable branches, unused exports, stale flags, abandoned helpers, obsolete tests, or comments describing code that no longer exists.
|
|
727
|
-
- **primitive obsession** — stringly typed modes, loosely shaped objects, or magic literals that obscure a domain constraint already present elsewhere.
|
|
728
|
-
- **shotgun surgery** — one conceptual change requires scattered edits across unrelated modules.
|
|
729
|
-
- **feature envy / misplaced responsibility** — code repeatedly reaches into another module's internals instead of using the owning boundary.
|
|
730
|
-
- **message chains / excessive delegation** — call chains or wrappers that add no policy and make behavior harder to locate.
|
|
731
|
-
- **agent slop** — verbose scaffolding, duplicate defensive branches, generic helper layers, temporary flags, commented-out code, debug output, or invented patterns that do not match the repo.
|
|
732
|
-
- **test-oracle slop** — tests that assert implementation trivia, snapshots of noisy markup, or mocks that make broken behavior pass.
|
|
733
|
-
|
|
734
|
-
## Non-smells until proven
|
|
735
|
-
|
|
736
|
-
- Repetition that makes two workflows intentionally independent.
|
|
737
|
-
- Framework-required shape, generated code, migration history, compatibility shims, or public API affordances.
|
|
738
|
-
- Verbose guards protecting data loss, security, lifecycle ordering, or error observability.
|
|
739
|
-
- Logging/metrics that operators or tests rely on.
|
|
740
|
-
- Local style differences already accepted by the repo and not hurting changeability.
|
|
741
|
-
|
|
742
|
-
## Finding shape
|
|
743
|
-
|
|
744
|
-
Each blocking cleanup finding should carry:
|
|
745
|
-
|
|
746
|
-
\`\`\`text
|
|
747
|
-
class; severity; location; evidence read; refutation checked; why it matters; safe fix shape; validation command
|
|
748
|
-
\`\`\`
|
|
749
|
-
|
|
750
|
-
Rate as blocking only when the smell materially raises defect risk, blocks planned work, hides behavior, or makes the success claim unverifiable. Style-only cleanup is advisory.
|
|
751
|
-
`;
|
|
752
|
-
|
|
753
|
-
// skills/flow-deslop/SKILL.md
|
|
754
|
-
var SKILL_default3 = `---
|
|
755
|
-
name: flow-deslop
|
|
756
|
-
description: Clean up and refactor code with evidence-backed code-smell analysis. Use for AI-slop removal, overengineering reduction, maintainability refactors, behavior-preserving cleanup, duplicated or bloated code, speculative abstractions, and dead code. Review verdicts on cleanup work stay in flow-review, which loads this skill to judge cleanup claims.
|
|
757
|
-
---
|
|
758
|
-
|
|
759
|
-
# Flow deslop
|
|
760
|
-
|
|
761
|
-
Use this skill when the Flow work is about improving code quality rather than adding a new user-visible feature. The job is to make the code easier to change without changing behavior unless the approved plan explicitly says behavior changes.
|
|
762
|
-
|
|
763
|
-
This is a helper skill: it produces cleanup findings and evidence only. The manager owns every state-changing \`flow_*\` call, and cleanup review verdicts are returned through \`flow-review\`.
|
|
764
|
-
|
|
765
|
-
## Ground the cleanup
|
|
766
|
-
|
|
767
|
-
- Start from concrete evidence: duplicated code, unnecessary abstraction, long or tangled functions, dead branches, confusing ownership, repeated conditionals, excessive coupling, or validation gaps that hide maintainability risk.
|
|
768
|
-
- Load \`references/smell-rubric.md\` when classifying findings or deciding what is worth fixing.
|
|
769
|
-
- Load \`references/refactor-workflow.md\` before implementing or reviewing non-trivial cleanup.
|
|
770
|
-
- Treat scanner output, metrics, and model impressions as candidates only. A smell becomes actionable after reading the surrounding code, callers, tests, and relevant contracts.
|
|
771
|
-
- Record cleanup context in existing Flow plan fields: \`requirements\`, \`decisions\`, feature \`targets\`, and feature \`validation\`. Do not invent new Flow payload fields.
|
|
772
|
-
|
|
773
|
-
## Plan cleanup work
|
|
774
|
-
|
|
775
|
-
- Prefer one feature per validated cleanup theme with a clear validation story. "Clean the whole repo" starts with a review-first feature that produces evidence-backed findings, then fix features for confirmed clusters.
|
|
776
|
-
- Keep refactors small and behavior-preserving. If a cleanup requires behavior change, surface it as product scope and replan.
|
|
777
|
-
- State what will not be cleaned. Broad cleanup without boundaries invites churn and makes review impossible.
|
|
778
|
-
- Choose validation before editing: focused tests for affected behavior, typecheck/lint for mechanical changes, and a broad gate when cleanup spans shared abstractions.
|
|
779
|
-
|
|
780
|
-
## Execute cleanup safely
|
|
781
|
-
|
|
782
|
-
- Preserve public APIs, persisted data, command names, tool names, and observable behavior unless the approved plan explicitly changes them.
|
|
783
|
-
- Prefer removal, consolidation, naming, and local extraction before new abstractions. New abstractions must reduce real duplication or clarify an existing boundary.
|
|
784
|
-
- Delete dead code only after checking references, exports, generated entrypoints, docs, tests, and runtime/distribution paths that static search may miss.
|
|
785
|
-
- Keep every change tied to a finding or plan target. Opportunistic style edits are out of scope.
|
|
786
|
-
|
|
787
|
-
## Review cleanup claims
|
|
788
|
-
|
|
789
|
-
For each claimed smell removal, verify:
|
|
790
|
-
|
|
791
|
-
- **location** — the changed code and the original smell were actually read.
|
|
792
|
-
- **impact** — the change reduces duplication, coupling, complexity, or future-change risk in a concrete way.
|
|
793
|
-
- **refutation checked** — apparent smell was not intentional compatibility, performance, generated code, framework convention, or a safety guard.
|
|
794
|
-
- **behavior preserved** — tests or other evidence cover the behavior touched.
|
|
795
|
-
- **blast radius** — public contracts and downstream callers still work.
|
|
796
|
-
|
|
797
|
-
Never approve cleanup because it "looks cleaner" without evidence. Tests passing is necessary but not sufficient when the refactor changes structure across files.
|
|
798
|
-
`;
|
|
799
|
-
|
|
800
|
-
// skills/flow-plan/references/parallel-discovery.md
|
|
801
|
-
var parallel_discovery_default = `# Parallel discovery
|
|
802
|
-
|
|
803
|
-
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.
|
|
804
|
-
|
|
805
|
-
For broad parallel passes, start with
|
|
806
|
-
\`../../flow/references/parallel-orchestration.md\`. If it selects fan-out, use
|
|
807
|
-
\`../../flow/references/parallel-manifest.md\` as the coverage gate,
|
|
808
|
-
\`../../flow/references/parallel-execution.md\` for worker prompts, and
|
|
809
|
-
\`../../flow/references/parallel-synthesis.md\` when handoffs return. Copy the
|
|
810
|
-
matching \`../../flow/references/handoff-format.md\` response shape into each
|
|
811
|
-
prompt.
|
|
812
|
-
|
|
813
|
-
## Good slices
|
|
814
|
-
|
|
815
|
-
- Independent modules or packages.
|
|
816
|
-
- Frontend route and backend endpoint pairs.
|
|
817
|
-
- Test, CI, and release surfaces.
|
|
818
|
-
- Risk lenses such as security, persistence, accessibility, migration, or performance.
|
|
819
|
-
- Documentation and operator-contract checks.
|
|
820
|
-
|
|
821
|
-
## Deriving first-pass slices
|
|
822
|
-
|
|
823
|
-
Derive slices from the repo shape found during the serial orientation pass:
|
|
824
|
-
top-level packages or source directories, the test tree, CI and release
|
|
825
|
-
config, and docs. Name each slice by the paths it owns, for example "runtime:
|
|
826
|
-
\`src/core/**\` plus its tests" or "release contract: CI workflows,
|
|
827
|
-
\`package.json\`, and the changelog".
|
|
828
|
-
|
|
829
|
-
Treat derived slices as starting points, not a simultaneous coverage map.
|
|
830
|
-
Before fan-out, choose the relevant entries and de-overlap shared docs,
|
|
831
|
-
config, or release surfaces in the pass manifest.
|
|
832
|
-
|
|
833
|
-
## Manifest and prompts
|
|
834
|
-
|
|
835
|
-
Write the pass manifest and worker prompts as \`parallel-manifest.md\` and
|
|
836
|
-
\`parallel-execution.md\` define them: one manifest row
|
|
837
|
-
per slice with expected coverage, dependencies, write scope, and a verification
|
|
838
|
-
tier, and a self-contained prompt per worker naming the mode (usually
|
|
839
|
-
\`evidence\`), the exact slice, and the expected coverage. Discovery-specific
|
|
840
|
-
rules:
|
|
841
|
-
|
|
842
|
-
- Workers are read-only. For validation-oriented discovery, workers may report
|
|
843
|
-
commands that should be run, and include raw output only for commands they
|
|
844
|
-
actually ran.
|
|
845
|
-
- Workers cannot read reference files themselves; paste the matching handoff
|
|
846
|
-
template from \`../../flow/references/handoff-format.md\` into the prompt.
|
|
847
|
-
- If discovery finds later features with disjoint path ownership, preserve that
|
|
848
|
-
fact in feature \`targets\` and \`dependsOn\` so execution can make an explicit
|
|
849
|
-
serial or candidate-pass decision instead of rediscovering ownership.
|
|
850
|
-
|
|
851
|
-
## Synthesis
|
|
852
|
-
|
|
853
|
-
Convert only evidence-backed work into plan fields:
|
|
854
|
-
|
|
855
|
-
- \`requirements\`: user promises and externally visible acceptance criteria.
|
|
856
|
-
- \`decisions\`: architecture boundaries, rejected approaches, and scope cuts.
|
|
857
|
-
- feature \`targets\`: files, modules, routes, commands, docs, or workflows the feature owns.
|
|
858
|
-
- feature \`validation\`: checks expected to prove the feature.
|
|
859
|
-
|
|
860
|
-
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.
|
|
861
|
-
|
|
862
|
-
Apply the manager synthesis barrier from
|
|
863
|
-
\`../../flow/references/parallel-synthesis.md\`: only distilled,
|
|
864
|
-
evidence-backed claims become plan fields.
|
|
865
|
-
`;
|
|
866
|
-
|
|
867
|
-
// skills/flow-plan/references/plan-quality-checklist.md
|
|
868
|
-
var plan_quality_checklist_default = `# Plan quality checklist
|
|
869
|
-
|
|
870
|
-
Use this checklist before \`flow_plan_save\` and again before approval if the plan
|
|
871
|
-
changed during discussion. The goal is not a long planning artifact; it is a
|
|
872
|
-
concise plan another agent can execute without rediscovering the work.
|
|
873
|
-
|
|
874
|
-
## Must pass
|
|
875
|
-
|
|
876
|
-
- Outcome: \`summary\` names the user-visible result, not an internal activity.
|
|
877
|
-
- Requirements: acceptance criteria, constraints, and non-goals that affect
|
|
878
|
-
implementation are captured in \`requirements\`.
|
|
879
|
-
- Decisions: assumptions, scope choices, and architecture choices already made
|
|
880
|
-
are captured in \`decisions\`.
|
|
881
|
-
- Uncertainty: specification uncertainty is resolved by a decision or a user
|
|
882
|
-
question; environment uncertainty is resolved by inspection, discovery, or a
|
|
883
|
-
first evidence-producing feature.
|
|
884
|
-
- Feature shape: each feature has one coherent outcome and can be reviewed on
|
|
885
|
-
its own.
|
|
886
|
-
- Targets: each feature names bounded files, modules, routes, commands, docs, or
|
|
887
|
-
generated surfaces. Whole-repo targets are allowed only for explicit broad
|
|
888
|
-
audits or final validation.
|
|
889
|
-
- Validation: each feature names expected check levels, such as targeted unit,
|
|
890
|
-
integration, browser/e2e, package/build, docs/static, cleanup preservation, or
|
|
891
|
-
broad project gate.
|
|
892
|
-
- Dependencies: \`dependsOn\` captures true ordering and avoids hidden dependency
|
|
893
|
-
chains.
|
|
894
|
-
- Review policy: \`finalReviewPolicy\` is \`detailed\` when the work changes
|
|
895
|
-
behavior, persistence, public contracts, security posture, release surfaces,
|
|
896
|
-
or multiple modules.
|
|
897
|
-
|
|
898
|
-
## Revise when you see this
|
|
899
|
-
|
|
900
|
-
- A feature title describes a step like "update files" instead of a result.
|
|
901
|
-
- A validation entry says only "manual testing" or "run tests".
|
|
902
|
-
- A feature has targets but no behavior or artifact that can be judged.
|
|
903
|
-
- A feature claims cleanup or simplification without an evidence-producing
|
|
904
|
-
audit or cited smell.
|
|
905
|
-
- A docs feature depends on behavior that is not yet implemented but lacks
|
|
906
|
-
\`dependsOn\`.
|
|
907
|
-
- A low-risk \`finalReviewPolicy: "broad"\` is used while the plan crosses runtime,
|
|
908
|
-
schema, persistence, security, or release boundaries.
|
|
909
|
-
|
|
910
|
-
## Approval summary
|
|
911
|
-
|
|
912
|
-
When presenting the plan for approval, include:
|
|
913
|
-
|
|
914
|
-
- The promised outcome.
|
|
915
|
-
- The feature order and any dependencies that matter.
|
|
916
|
-
- The main validation levels.
|
|
917
|
-
- Material assumptions in \`decisions\`.
|
|
918
|
-
- Any known gaps that remain intentional.
|
|
919
|
-
`;
|
|
920
|
-
|
|
921
|
-
// skills/flow-plan/references/planning-examples.md
|
|
922
|
-
var planning_examples_default = `# Planning examples
|
|
923
|
-
|
|
924
|
-
## Rate limiting feature set
|
|
925
|
-
|
|
926
|
-
Human summary:
|
|
927
|
-
|
|
928
|
-
1. **In-memory rate limit middleware** - add request counting and response headers for one-process deployments.
|
|
929
|
-
2. **Redis-backed limiter** - add shared store adapter for multi-instance deployments.
|
|
930
|
-
3. **Operator docs** - document configuration and rollout notes.
|
|
931
|
-
|
|
932
|
-
Payload:
|
|
933
|
-
|
|
934
|
-
\`\`\`json
|
|
935
|
-
{
|
|
936
|
-
"goal": "Add API rate limiting with local and Redis-backed stores",
|
|
937
|
-
"plan": {
|
|
938
|
-
"summary": "Add configurable rate limiting for API routes.",
|
|
939
|
-
"overview": "Implement middleware first, then a Redis store, then document rollout.",
|
|
940
|
-
"requirements": [
|
|
941
|
-
"Preserve existing route behavior except rate-limit responses.",
|
|
942
|
-
"Expose deterministic headers for limit, remaining, and reset time."
|
|
943
|
-
],
|
|
944
|
-
"decisions": [
|
|
945
|
-
"Start with an in-memory store for single-process deployments.",
|
|
946
|
-
"Keep Redis behind a store interface so tests can use a mock."
|
|
947
|
-
],
|
|
948
|
-
"finalReviewPolicy": "detailed",
|
|
949
|
-
"features": [
|
|
950
|
-
{
|
|
951
|
-
"id": "rate-limit-middleware",
|
|
952
|
-
"title": "In-memory limiter",
|
|
953
|
-
"summary": "Add middleware, config, and tests for single-process rate limiting.",
|
|
954
|
-
"targets": ["src/middleware/rate-limit.ts", "src/app.ts", "src/config.ts"],
|
|
955
|
-
"validation": ["route tests for limit/reset/header behavior", "typecheck"],
|
|
956
|
-
"dependsOn": []
|
|
957
|
-
},
|
|
958
|
-
{
|
|
959
|
-
"id": "redis-store",
|
|
960
|
-
"title": "Redis store",
|
|
961
|
-
"summary": "Add a Redis-backed rate limit store without changing middleware behavior.",
|
|
962
|
-
"targets": ["src/middleware/stores/redis.ts", "src/middleware/rate-limit.ts"],
|
|
963
|
-
"validation": ["store tests with Redis mock", "manual two-process recipe if practical"],
|
|
964
|
-
"dependsOn": ["rate-limit-middleware"]
|
|
965
|
-
},
|
|
966
|
-
{
|
|
967
|
-
"id": "operator-docs",
|
|
968
|
-
"title": "Operator docs",
|
|
969
|
-
"summary": "Document configuration, headers, and rollout guidance.",
|
|
970
|
-
"targets": ["README.md", "docs/operations.md"],
|
|
971
|
-
"validation": ["lint docs if available", "review examples against implemented config"],
|
|
972
|
-
"dependsOn": ["redis-store"]
|
|
973
|
-
}
|
|
974
|
-
]
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
\`\`\`
|
|
978
|
-
|
|
979
|
-
## Review-first cleanup
|
|
980
|
-
|
|
981
|
-
Bad plan:
|
|
982
|
-
|
|
983
|
-
\`\`\`text
|
|
984
|
-
1. Simplify services
|
|
985
|
-
2. Remove duplication
|
|
986
|
-
3. Improve tests
|
|
987
|
-
\`\`\`
|
|
988
|
-
|
|
989
|
-
Why it is bad: no evidence names which services are actually tangled, what duplication exists, or which behavior needs test coverage.
|
|
990
|
-
|
|
991
|
-
Better plan:
|
|
992
|
-
|
|
993
|
-
\`\`\`text
|
|
994
|
-
1. Audit service layer - produce evidence-backed findings with file:line citations, guards checked, and follow-up order.
|
|
995
|
-
2. Consolidate confirmed config parsing duplication - only if the audit proves the duplication exists and is safe to merge.
|
|
996
|
-
3. Add behavior-preservation tests for the changed service paths.
|
|
997
|
-
\`\`\`
|
|
998
|
-
|
|
999
|
-
## Bugfix plan
|
|
1000
|
-
|
|
1001
|
-
Human summary:
|
|
1002
|
-
|
|
1003
|
-
1. Reproduce and localize the failed password reset redirect.
|
|
1004
|
-
2. Fix the redirect state handling and cover the regression.
|
|
1005
|
-
3. Update release notes only if user-facing behavior changed.
|
|
1006
|
-
|
|
1007
|
-
Payload:
|
|
1008
|
-
|
|
1009
|
-
\`\`\`json
|
|
1010
|
-
{
|
|
1011
|
-
"goal": "Fix password reset links landing users on the wrong page",
|
|
1012
|
-
"plan": {
|
|
1013
|
-
"summary": "Password reset links land users on the intended reset confirmation flow.",
|
|
1014
|
-
"overview": "Start with a focused reproduction, then fix the redirect state and update user-facing notes only if the behavior change needs documentation.",
|
|
1015
|
-
"requirements": [
|
|
1016
|
-
"Preserve existing token validation and expiry behavior.",
|
|
1017
|
-
"Users with valid reset links should not be sent to the generic sign-in page before completing the reset."
|
|
1018
|
-
],
|
|
1019
|
-
"decisions": [
|
|
1020
|
-
"Treat the current redirect mismatch as a regression until reproduction proves otherwise."
|
|
1021
|
-
],
|
|
1022
|
-
"finalReviewPolicy": "detailed",
|
|
1023
|
-
"features": [
|
|
1024
|
-
{
|
|
1025
|
-
"id": "reset-redirect-repro",
|
|
1026
|
-
"title": "Redirect reproduction",
|
|
1027
|
-
"summary": "Produce a failing focused check or trace that identifies where the reset redirect is lost.",
|
|
1028
|
-
"targets": ["src/auth/reset", "tests/auth"],
|
|
1029
|
-
"validation": ["targeted unit or integration reproduction for reset redirect behavior"],
|
|
1030
|
-
"dependsOn": []
|
|
1031
|
-
},
|
|
1032
|
-
{
|
|
1033
|
-
"id": "reset-redirect-fix",
|
|
1034
|
-
"title": "Redirect fix",
|
|
1035
|
-
"summary": "Preserve reset redirect state through token validation and completion.",
|
|
1036
|
-
"targets": ["src/auth/reset", "tests/auth"],
|
|
1037
|
-
"validation": ["targeted regression test passes", "auth package/build check if available"],
|
|
1038
|
-
"dependsOn": ["reset-redirect-repro"]
|
|
1039
|
-
},
|
|
1040
|
-
{
|
|
1041
|
-
"id": "reset-redirect-notes",
|
|
1042
|
-
"title": "User-facing notes",
|
|
1043
|
-
"summary": "Document the corrected reset-link behavior if release notes or help text mention the flow.",
|
|
1044
|
-
"targets": ["CHANGELOG.md", "docs/auth.md"],
|
|
1045
|
-
"validation": ["docs/static check if available", "review docs against implemented behavior"],
|
|
1046
|
-
"dependsOn": ["reset-redirect-fix"]
|
|
1047
|
-
}
|
|
1048
|
-
]
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
\`\`\`
|
|
1052
|
-
|
|
1053
|
-
## UI/frontend plan
|
|
1054
|
-
|
|
1055
|
-
Human summary:
|
|
1056
|
-
|
|
1057
|
-
1. Map the current checkout empty state and responsive constraints.
|
|
1058
|
-
2. Implement the empty state with accessible controls and mobile layout.
|
|
1059
|
-
3. Verify the visual states with screenshots or browser evidence.
|
|
1060
|
-
|
|
1061
|
-
Good feature outline:
|
|
1062
|
-
|
|
1063
|
-
\`\`\`text
|
|
1064
|
-
1. Empty-state discovery - inspect the route, component boundaries, design tokens, existing empty states, and likely responsive breakpoints.
|
|
1065
|
-
2. Empty-state implementation - add the checkout empty state, action wiring, focus order, and loading/error boundaries in the existing component style.
|
|
1066
|
-
3. Visual and interaction verification - capture desktop and mobile evidence, run available route/component checks, and fix overlap or accessibility regressions.
|
|
1067
|
-
\`\`\`
|
|
1068
|
-
|
|
1069
|
-
Why this is better than one "build UI" feature: the plan names the uncertain
|
|
1070
|
-
surface first, keeps implementation scoped to the route/components, and makes
|
|
1071
|
-
visual evidence part of completion rather than an afterthought.
|
|
1072
|
-
|
|
1073
|
-
## Runtime or schema plan
|
|
1074
|
-
|
|
1075
|
-
Human summary:
|
|
1076
|
-
|
|
1077
|
-
1. Introduce the schema change behind a backward-compatible parser.
|
|
1078
|
-
2. Migrate callers and persistence writes.
|
|
1079
|
-
3. Add compatibility validation and docs.
|
|
1080
|
-
|
|
1081
|
-
Good feature outline:
|
|
1082
|
-
|
|
1083
|
-
\`\`\`text
|
|
1084
|
-
1. Compatible schema reader - accept old and new session payloads, with targeted parser tests for both.
|
|
1085
|
-
2. New writer path - emit the new field from runtime transitions and update affected callers.
|
|
1086
|
-
3. Compatibility sweep - run persistence/workspace tests, update docs, and verify old sessions still recover.
|
|
1087
|
-
\`\`\`
|
|
1088
|
-
|
|
1089
|
-
Use \`finalReviewPolicy: "detailed"\` for this shape. Persistence and schema work
|
|
1090
|
-
usually has hidden downstream contracts, so feature validation should name both
|
|
1091
|
-
targeted parser checks and broader workspace/runtime gates.
|
|
1092
|
-
|
|
1093
|
-
## Docs-only plan
|
|
1094
|
-
|
|
1095
|
-
Docs-only work can use \`finalReviewPolicy: "broad"\` when it does not change
|
|
1096
|
-
commands, configuration, generated files, or release metadata.
|
|
1097
|
-
|
|
1098
|
-
Good feature outline:
|
|
1099
|
-
|
|
1100
|
-
\`\`\`text
|
|
1101
|
-
1. Align installation docs - update README and troubleshooting steps for the current setup flow.
|
|
1102
|
-
2. Verify commands and links - check documented commands against package scripts and make sure links/paths resolve.
|
|
1103
|
-
\`\`\`
|
|
1104
|
-
|
|
1105
|
-
Bad validation:
|
|
1106
|
-
|
|
1107
|
-
\`\`\`text
|
|
1108
|
-
validation: ["manual review"]
|
|
1109
|
-
\`\`\`
|
|
1110
|
-
|
|
1111
|
-
Better validation:
|
|
1112
|
-
|
|
1113
|
-
\`\`\`text
|
|
1114
|
-
validation: ["docs/static link and path review", "command examples checked against package scripts"]
|
|
1115
|
-
\`\`\`
|
|
1116
|
-
|
|
1117
|
-
## Audit-first and review-first plans
|
|
1118
|
-
|
|
1119
|
-
Use an evidence-producing first feature when the request asks to "review",
|
|
1120
|
-
"audit", "clean up", "modernize", or "improve" a broad area.
|
|
1121
|
-
|
|
1122
|
-
Good feature outline:
|
|
1123
|
-
|
|
1124
|
-
\`\`\`text
|
|
1125
|
-
1. Audit checkout state management - cite concrete findings with file:line evidence, refutation checks, severity, and recommended fix order.
|
|
1126
|
-
2. Fix confirmed high-impact state leak - only for findings that survived the audit.
|
|
1127
|
-
3. Regression validation - add or run checks covering the changed state paths.
|
|
1128
|
-
\`\`\`
|
|
1129
|
-
|
|
1130
|
-
Do not plan fixes for guessed findings. If the audit might find no actionable
|
|
1131
|
-
issue, say that in the first feature summary and make later features conditional
|
|
1132
|
-
on evidence.
|
|
1133
|
-
|
|
1134
|
-
## Validation examples
|
|
1135
|
-
|
|
1136
|
-
Weak:
|
|
1137
|
-
|
|
1138
|
-
\`\`\`text
|
|
1139
|
-
validation: ["run tests", "manual testing"]
|
|
1140
|
-
\`\`\`
|
|
1141
|
-
|
|
1142
|
-
Stronger:
|
|
1143
|
-
|
|
1144
|
-
\`\`\`text
|
|
1145
|
-
validation: [
|
|
1146
|
-
"targeted unit tests for empty and invalid input",
|
|
1147
|
-
"integration test for persisted session recovery",
|
|
1148
|
-
"package/build gate for changed TypeScript exports",
|
|
1149
|
-
"browser screenshot at desktop and mobile widths for layout-sensitive UI",
|
|
1150
|
-
"docs/static review for changed command examples"
|
|
1151
|
-
]
|
|
1152
|
-
\`\`\`
|
|
1153
|
-
|
|
1154
|
-
The stronger version says what level of evidence is expected and which behavior
|
|
1155
|
-
or surface it covers.
|
|
1156
|
-
|
|
1157
|
-
## Decomposition anti-patterns
|
|
1158
|
-
|
|
1159
|
-
- Feature per file when behavior crosses files.
|
|
1160
|
-
- Feature per implementation step with no user-visible or reviewable outcome.
|
|
1161
|
-
- Plan fixes for findings not yet verified.
|
|
1162
|
-
- Validation that only says "manual testing".
|
|
1163
|
-
- Targets that name the entire repo.
|
|
1164
|
-
- Features with hidden dependencies instead of \`dependsOn\`.
|
|
1165
|
-
`;
|
|
1166
|
-
|
|
1167
|
-
// skills/flow-plan/SKILL.md
|
|
1168
|
-
var SKILL_default4 = `---
|
|
1169
|
-
name: flow-plan
|
|
1170
|
-
description: "Use when Flow work needs planning before implementation: a new goal to turn into an approved Flow feature plan, a draft plan to revise, or a decomposition or plan-approval decision in the v4 skills-first runtime. For executing an approved feature use flow-run; for the full goal-to-completion loop use flow."
|
|
1171
|
-
---
|
|
1172
|
-
|
|
1173
|
-
# Flow Plan
|
|
1174
|
-
|
|
1175
|
-
Use this skill before implementation. The output is a concise plan the runtime can enforce and future agents can execute without rediscovering the goal.
|
|
1176
|
-
|
|
1177
|
-
## Planning runtime availability
|
|
1178
|
-
|
|
1179
|
-
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.
|
|
1180
|
-
|
|
1181
|
-
## Inspect first
|
|
1182
|
-
|
|
1183
|
-
- Read the files, docs, tests, package scripts, and local conventions that determine the work.
|
|
1184
|
-
- For broad discovery, read \`references/parallel-discovery.md\` after a serial
|
|
1185
|
-
orientation pass. When multiple workers may help, start with
|
|
1186
|
-
\`../flow/references/parallel-orchestration.md\` and load only the branch it
|
|
1187
|
-
selects.
|
|
1188
|
-
- Helper rule: when a named helper skill is unavailable, record a planning gap
|
|
1189
|
-
and keep the corresponding claims conservative instead of simulating its
|
|
1190
|
-
checks.
|
|
1191
|
-
- For complex validation, regression-sensitive changes, browser QA, route QA,
|
|
1192
|
-
failure-prone checks, or uncertain test strategy, load \`flow-test\`.
|
|
1193
|
-
- For cleanup/refactor goals, load \`flow-deslop\`.
|
|
1194
|
-
- For UI/frontend goals, load \`flow-ui-quality\`.
|
|
1195
|
-
- Do not invent findings. Broad "review and fix" goals start with a review-first feature whose deliverable is evidence-backed findings.
|
|
1196
|
-
|
|
1197
|
-
## Reduce uncertainty before decomposing
|
|
1198
|
-
|
|
1199
|
-
A vague goal does not slice into reliable features yet. Name what is uncertain,
|
|
1200
|
-
because the two kinds resolve differently:
|
|
1201
|
-
|
|
1202
|
-
- **Specification uncertainty** — what the user wants: ambiguous goal, missing
|
|
1203
|
-
acceptance criteria, unstated constraints. Resolve by stating an explicit
|
|
1204
|
-
assumption in \`decisions\` and proceeding, or by asking only when a wrong
|
|
1205
|
-
guess would be expensive to undo.
|
|
1206
|
-
- **Environment uncertainty** — facts the repo, docs, commands, or data can
|
|
1207
|
-
answer: code shape, schema, API behavior, current conventions. Resolve by
|
|
1208
|
-
inspecting or by a discovery pass, never by asking the user.
|
|
1209
|
-
|
|
1210
|
-
Spend the cheapest probe that removes the most uncertainty first: local reads
|
|
1211
|
-
before worker fan-out, fan-out before user questions. Decompose into features
|
|
1212
|
-
only once the remaining uncertainty is low enough that \`targets\` and
|
|
1213
|
-
\`validation\` can be stated concretely; otherwise the first feature is a
|
|
1214
|
-
review-first or discovery deliverable that produces the missing evidence.
|
|
1215
|
-
|
|
1216
|
-
## Plan shape
|
|
1217
|
-
|
|
1218
|
-
Call \`flow_plan_save\` with:
|
|
1219
|
-
|
|
1220
|
-
\`\`\`json
|
|
1221
|
-
{
|
|
1222
|
-
"goal": "user-visible goal",
|
|
1223
|
-
"plan": {
|
|
1224
|
-
"summary": "one-sentence outcome",
|
|
1225
|
-
"overview": "implementation strategy and boundaries",
|
|
1226
|
-
"requirements": ["constraints, acceptance criteria, user promises"],
|
|
1227
|
-
"decisions": ["architecture or scope decisions already made"],
|
|
1228
|
-
"finalReviewPolicy": "detailed",
|
|
1229
|
-
"features": [
|
|
1230
|
-
{
|
|
1231
|
-
"id": "lowercase-kebab-case",
|
|
1232
|
-
"title": "Short title",
|
|
1233
|
-
"summary": "Outcome this feature delivers",
|
|
1234
|
-
"reviewDepth": "standard",
|
|
1235
|
-
"targets": ["files, modules, routes, commands, or docs in scope"],
|
|
1236
|
-
"validation": ["focused checks expected before completion"],
|
|
1237
|
-
"dependsOn": []
|
|
1238
|
-
}
|
|
1239
|
-
]
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
\`\`\`
|
|
1243
|
-
|
|
1244
|
-
Use only \`finalReviewPolicy: "broad"\` or \`"detailed"\`. These are the canonical final-review policy and \`reviewDepth\` enum values. Use \`"broad"\` only for low-risk, narrow work. Use \`"detailed"\` for behavioral changes, cross-module edits, migrations, releases, security-sensitive code, or large refactors.
|
|
1245
|
-
|
|
1246
|
-
Set each feature's \`reviewDepth\` to one of:
|
|
1247
|
-
|
|
1248
|
-
- \`quick\`: docs, comments, config-only changes, generated output, or mechanical changes fully covered by tooling.
|
|
1249
|
-
- \`standard\`: the default for ordinary implementation slices. The review reads every changed file and relevant tests.
|
|
1250
|
-
- \`detailed\`: persistence, migrations, concurrency, security, cross-module behavior, release/package surfaces, large refactors, weak validation, or any work where a missed edge case would be expensive.
|
|
1251
|
-
|
|
1252
|
-
Do not make reviews shallower to save tokens. Reduce token use by splitting features, keeping \`targets\` precise, and using scoped review packets during execution.
|
|
1253
|
-
|
|
1254
|
-
## Plan quality gate
|
|
1255
|
-
|
|
1256
|
-
Before saving or asking for approval, load
|
|
1257
|
-
\`references/plan-quality-checklist.md\` and check the draft against it. Revise the
|
|
1258
|
-
plan until it passes, or record the remaining gap in \`decisions\` when the gap is
|
|
1259
|
-
an intentional assumption. Do not approve a plan whose outcome, requirements,
|
|
1260
|
-
targets, validation, or dependency order are still too vague for another agent
|
|
1261
|
-
to execute.
|
|
1262
|
-
|
|
1263
|
-
## Feature sizing
|
|
1264
|
-
|
|
1265
|
-
- Each feature should have one owner, one coherent outcome, and a validation story.
|
|
1266
|
-
- Split by dependency order: foundations before callers, schema before consumers, implementation before docs when docs depend on behavior.
|
|
1267
|
-
- Avoid "misc cleanup" features. Tie cleanup to evidence and targets.
|
|
1268
|
-
- Keep feature ids stable once the plan is approved.
|
|
1269
|
-
- Put scope boundaries in \`targets\` and expected checks in \`validation\`. Each
|
|
1270
|
-
validation entry should name the expected test level, such as targeted unit,
|
|
1271
|
-
integration, browser/e2e, package/build, docs/static, cleanup preservation, or
|
|
1272
|
-
broad project gate.
|
|
1273
|
-
- When a feature may benefit from parallel implementation, make \`targets\`
|
|
1274
|
-
precise enough for later ownership decisions: name exact modules, docs,
|
|
1275
|
-
commands, or route groups, and use \`dependsOn\` to preserve prerequisite order.
|
|
1276
|
-
Broad shared-contract work should stay in one feature or an earlier foundation
|
|
1277
|
-
feature so later candidate passes can own disjoint paths safely.
|
|
1278
|
-
- Assign \`reviewDepth\` from risk. Use \`detailed\` for persistence, migration,
|
|
1279
|
-
concurrency, security, final-delivery-adjacent, or cross-module slices; use
|
|
1280
|
-
\`standard\` for normal code changes; reserve \`quick\` for low-risk non-behavioral
|
|
1281
|
-
work.
|
|
1282
|
-
|
|
1283
|
-
## Approval
|
|
1284
|
-
|
|
1285
|
-
After saving, summarize the plan to the user. Call \`flow_plan_approve\` only after explicit user approval, unless the user already authorized autonomous implementation. Approved plans are immutable; changing them later requires reset/closure rather than silent edits.
|
|
1286
|
-
|
|
1287
|
-
See \`references/planning-examples.md\` for payload examples and decomposition
|
|
1288
|
-
anti-patterns.
|
|
1289
|
-
`;
|
|
1290
|
-
|
|
1291
|
-
// skills/flow-review/references/hidden-reviewer-contract.md
|
|
1292
|
-
var hidden_reviewer_contract_default = `# Hidden Flow reviewer contract
|
|
1293
|
-
|
|
1294
|
-
This is the canonical role-safe contract bundled into \`flow-reviewer\`. It does
|
|
1295
|
-
not grant manager capabilities and does not tell the hidden reviewer to load
|
|
1296
|
-
skills, run commands, edit files, or launch workers.
|
|
1297
|
-
|
|
1298
|
-
## Role and availability
|
|
1299
|
-
|
|
1300
|
-
You are an independent read-only reviewer. Call \`flow_status\` when available,
|
|
1301
|
-
prefer the manager's bounded review packet, and inspect the actual changed
|
|
1302
|
-
artifacts and supplied validation evidence. Only the root manager may mutate
|
|
1303
|
-
Flow state; return findings without fixing them. Your permissions intentionally
|
|
1304
|
-
exclude edits, shell commands, skill loading, and nested workers. Record missing
|
|
1305
|
-
evidence as a gap or blocker instead of claiming coverage.
|
|
1306
|
-
|
|
1307
|
-
If Flow setup or required evidence is stale or unavailable, label the result
|
|
1308
|
-
advisory and do not present it as Flow-gated evidence.
|
|
1309
|
-
|
|
1310
|
-
## Feature review depths
|
|
1311
|
-
|
|
1312
|
-
- \`quick\`: docs, comments, config-only changes, generated output, or mechanical
|
|
1313
|
-
changes fully covered by tooling.
|
|
1314
|
-
- \`standard\`: read every changed file and relevant test; this is the default for
|
|
1315
|
-
ordinary implementation work.
|
|
1316
|
-
- \`detailed\`: inspect risky behavior, persistence, security, cross-module
|
|
1317
|
-
refactors, migrations, releases, weak validation, and expensive edge cases.
|
|
1318
|
-
|
|
1319
|
-
The actual feature-review depth must meet or exceed the approved feature's
|
|
1320
|
-
\`reviewDepth\`. Final reviews use \`reviewDepth: "broad"\` or \`"detailed"\` and must
|
|
1321
|
-
match the plan's \`finalReviewPolicy\`. Claim only the depth actually performed.
|
|
1322
|
-
|
|
1323
|
-
## Direct review outputs
|
|
1324
|
-
|
|
1325
|
-
For a direct feature review, return only \`featureReviewDepth\` plus
|
|
1326
|
-
\`featureReview\`. For a direct final review, return only \`status\`, \`summary\`,
|
|
1327
|
-
\`blockingFindings\`, and \`reviewDepth\`. Use \`status: "failed"\` whenever a
|
|
1328
|
-
blocking finding remains. Advisory notes belong in the summary, while
|
|
1329
|
-
\`blockingFindings\` contains only blockers.
|
|
1330
|
-
|
|
1331
|
-
## Special-case evidence
|
|
1332
|
-
|
|
1333
|
-
- Cleanup/refactor: verify that the smell was real, refutation paths were
|
|
1334
|
-
checked, and behavior was preserved. If helper evidence is unavailable,
|
|
1335
|
-
record a coverage gap instead of approving the cleanup claim.
|
|
1336
|
-
- UI/frontend: verify relevant states and supplied visual evidence. When visual
|
|
1337
|
-
evidence is missing, record a coverage gap and do not claim visual polish was
|
|
1338
|
-
verified.
|
|
1339
|
-
- Audit reports: findings must survive refutation against cited code, guards,
|
|
1340
|
-
and mitigating paths before they can drive fixes.
|
|
1341
|
-
|
|
1342
|
-
## Completion checkpoint
|
|
1343
|
-
|
|
1344
|
-
Before returning, confirm that the stated depth matches work actually
|
|
1345
|
-
inspected, every blocker has concrete evidence, missing coverage is explicit,
|
|
1346
|
-
and the response uses exactly the direct-review payload or assigned-slice
|
|
1347
|
-
handoff requested.
|
|
1348
|
-
`;
|
|
1349
|
-
|
|
1350
|
-
// skills/flow-review/references/review-rubric.md
|
|
1351
|
-
var review_rubric_default = `# Review rubric
|
|
1352
|
-
|
|
1353
|
-
Use this to decide whether a \`featureReview\` or \`finalReview\` payload may pass.
|
|
1354
|
-
|
|
1355
|
-
## Finding classes
|
|
1356
|
-
|
|
1357
|
-
- **correctness**: wrong result, broken state transition, bad edge case, race, data loss, or crash.
|
|
1358
|
-
- **contract**: public API, CLI, config, persisted data, or documented behavior changed without plan approval.
|
|
1359
|
-
- **security/privacy**: unsafe input handling, secret exposure, permission bypass, or insecure default.
|
|
1360
|
-
- **test-coverage**: behavioral change lacks a check strong enough for the risk.
|
|
1361
|
-
- **maintainability**: complexity or coupling creates concrete future-change risk.
|
|
1362
|
-
- **ui/accessibility**: user cannot complete the workflow, layout breaks, accessibility basics fail, or visual claims lack evidence.
|
|
1363
|
-
|
|
1364
|
-
## Severity
|
|
1365
|
-
|
|
1366
|
-
- **blocking**: must fail the review. Includes incorrect behavior, data loss, security risk, unverifiable completion claims, missing validation for behavioral work, or unresolved scope drift.
|
|
1367
|
-
- **advisory**: worth noting but does not block the current goal.
|
|
1368
|
-
|
|
1369
|
-
If unsure whether a finding is real, read more or downgrade it. Do not promote guesses to blockers.
|
|
1370
|
-
|
|
1371
|
-
## Feature review checklist
|
|
1372
|
-
|
|
1373
|
-
- The work matches the active feature's \`summary\`, \`targets\`, and dependencies.
|
|
1374
|
-
- Plan \`requirements\` and \`decisions\` are still honored.
|
|
1375
|
-
- Changed files were read, not just summarized.
|
|
1376
|
-
- Validation evidence covers the behavior touched.
|
|
1377
|
-
- New tests or manual checks would fail or visibly differ without the change where practical.
|
|
1378
|
-
- No unrelated scope slipped in.
|
|
1379
|
-
- Public contracts and downstream callers still work.
|
|
1380
|
-
|
|
1381
|
-
## Final review checklist
|
|
1382
|
-
|
|
1383
|
-
- The original goal is satisfied by the delivered behavior or artifacts.
|
|
1384
|
-
- Every approved requirement is either met or explicitly accounted for by an
|
|
1385
|
-
accepted gap.
|
|
1386
|
-
- Plan decisions and scope boundaries still match the implementation.
|
|
1387
|
-
- Every planned feature is complete, has recorded validation evidence, and
|
|
1388
|
-
contributes to the final outcome.
|
|
1389
|
-
- Feature dependencies were completed in an order that makes the evidence
|
|
1390
|
-
trustworthy.
|
|
1391
|
-
- Changed artifacts match the plan's \`targets\`; extra changed surfaces are
|
|
1392
|
-
explained and reviewed.
|
|
1393
|
-
- Broad validation ran and passed, or any skipped broad check is justified as a
|
|
1394
|
-
non-blocking gap.
|
|
1395
|
-
- The final \`reviewDepth\` equals the approved \`finalReviewPolicy\`; the only final-review enum values are \`broad\` and \`detailed\`.
|
|
1396
|
-
- Feature-level reviews have no unresolved blocking findings.
|
|
1397
|
-
- Docs, commands, package metadata, and release surfaces match the delivered behavior.
|
|
1398
|
-
- Remaining gaps are explicit and do not contradict \`kind: "completed"\`.
|
|
1399
|
-
|
|
1400
|
-
## Final convergence scan
|
|
1401
|
-
|
|
1402
|
-
Run this scan before returning a passing \`finalReview\`:
|
|
1403
|
-
|
|
1404
|
-
1. Restate the original goal and the approved plan summary in your own words.
|
|
1405
|
-
2. Map each requirement to delivered evidence, validation output, or an explicit
|
|
1406
|
-
accepted gap.
|
|
1407
|
-
3. Walk every planned feature and confirm its completion evidence, review
|
|
1408
|
-
result, and validation level.
|
|
1409
|
-
4. Compare the changed files, docs, commands, generated surfaces, and package
|
|
1410
|
-
metadata to the planned targets and requirements.
|
|
1411
|
-
5. Check whether the validation evidence would have caught the main failure
|
|
1412
|
-
modes introduced by the work.
|
|
1413
|
-
6. Decide whether remaining gaps are advisory or blocking before setting
|
|
1414
|
-
\`status\`.
|
|
1415
|
-
|
|
1416
|
-
Fail the final review when the delivered work cannot be traced back to the
|
|
1417
|
-
approved goal and requirements, even if each individual feature review passed.
|
|
1418
|
-
|
|
1419
|
-
## Payloads
|
|
1420
|
-
|
|
1421
|
-
Feature review:
|
|
1422
|
-
|
|
1423
|
-
\`\`\`json
|
|
1424
|
-
{
|
|
1425
|
-
"featureReviewDepth": "standard",
|
|
1426
|
-
"featureReview": {
|
|
1427
|
-
"status": "passed",
|
|
1428
|
-
"summary": "Reviewed changed runtime files and focused tests; validation covers the new gate.",
|
|
1429
|
-
"blockingFindings": []
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
\`\`\`
|
|
1433
|
-
|
|
1434
|
-
Failed feature review:
|
|
1435
|
-
|
|
1436
|
-
\`\`\`json
|
|
1437
|
-
{
|
|
1438
|
-
"featureReviewDepth": "detailed",
|
|
1439
|
-
"featureReview": {
|
|
1440
|
-
"status": "failed",
|
|
1441
|
-
"summary": "Validation does not exercise the changed persistence path.",
|
|
1442
|
-
"blockingFindings": [
|
|
1443
|
-
{
|
|
1444
|
-
"summary": "No test covers archive removal of .flow/session.json after close.",
|
|
1445
|
-
"severity": "blocking"
|
|
1446
|
-
}
|
|
1447
|
-
]
|
|
1448
|
-
}
|
|
1449
|
-
}
|
|
1450
|
-
\`\`\`
|
|
1451
|
-
|
|
1452
|
-
Final review:
|
|
1453
|
-
|
|
1454
|
-
\`\`\`json
|
|
1455
|
-
{
|
|
1456
|
-
"status": "passed",
|
|
1457
|
-
"summary": "Reviewed plan scope, all changed files, broad validation, and release metadata.",
|
|
1458
|
-
"blockingFindings": [],
|
|
1459
|
-
"reviewDepth": "detailed"
|
|
1460
|
-
}
|
|
1461
|
-
\`\`\`
|
|
1462
|
-
|
|
1463
|
-
## Audit report reviews
|
|
1464
|
-
|
|
1465
|
-
When reviewing a findings report, verify findings adversarially:
|
|
1466
|
-
|
|
1467
|
-
- Check the cited file and surrounding code.
|
|
1468
|
-
- Trace mitigating paths before accepting blocking severity.
|
|
1469
|
-
- Confirm the deployment model used for severity.
|
|
1470
|
-
- Dedupe overlapping findings.
|
|
1471
|
-
- Downgrade or reject findings that do not survive refutation.
|
|
1472
|
-
|
|
1473
|
-
Approve only on evidence actually inspected. A review is a claim of coverage, not a courtesy stamp.
|
|
1474
|
-
`;
|
|
1475
|
-
|
|
1476
|
-
// skills/flow-review/SKILL.md
|
|
1477
|
-
var SKILL_default5 = `---
|
|
1478
|
-
name: flow-review
|
|
1479
|
-
description: "Use when Flow work needs a review verdict in the v4 runtime: a completed feature awaiting its featureReview, a final session review, or an assigned review slice. Validation evidence gathering stays in flow-test; cleanup judgment stays in flow-deslop."
|
|
1480
|
-
---
|
|
1481
|
-
|
|
1482
|
-
# Flow Review
|
|
1483
|
-
|
|
1484
|
-
Use this skill for review. The reviewer is usually read-only and does not mutate Flow state. The manager records the returned review payload inside \`flow_feature_complete\`.
|
|
1485
|
-
|
|
1486
|
-
If Flow tools, required Flow skills, or required references are unavailable or
|
|
1487
|
-
stale, perform an advisory review and say that no Flow-gated review payload was
|
|
1488
|
-
recorded.
|
|
1489
|
-
|
|
1490
|
-
## Execution contexts
|
|
1491
|
-
|
|
1492
|
-
These instructions run in two contexts, and only one of them can load helpers:
|
|
1493
|
-
|
|
1494
|
-
- **Manager context**: the manager reviews inside the Flow loop (the \`flow\` or
|
|
1495
|
-
\`flow-run\` skills, or a bundled public Flow command) before recording
|
|
1496
|
-
evidence. The manager may load helper skills and fan out read-only workers.
|
|
1497
|
-
- **Hidden reviewer context**: \`/flow-review\` runs as the \`flow-reviewer\`
|
|
1498
|
-
subagent, whose permissions deny skill loading, shell commands, and
|
|
1499
|
-
subagents. In this context, skip every "load" and "fan out" instruction
|
|
1500
|
-
below: judge from the diff, the plan fields, and the recorded validation
|
|
1501
|
-
evidence, and record a coverage gap for any judgment that would have needed
|
|
1502
|
-
a helper skill or a command run. The bundled hidden reviewer prompt uses the
|
|
1503
|
-
canonical role-safe contract in
|
|
1504
|
-
\`references/hidden-reviewer-contract.md\`.
|
|
1505
|
-
|
|
1506
|
-
## Start
|
|
1507
|
-
|
|
1508
|
-
- Call \`flow_status\` when available.
|
|
1509
|
-
- Identify whether this is a feature review or final review.
|
|
1510
|
-
- Prefer the manager's bounded review packet over parent-session memory. The
|
|
1511
|
-
packet should name the active feature, minimum \`reviewDepth\`, changed files,
|
|
1512
|
-
diff summary, validation evidence, and targeted paths or risk lenses. If the
|
|
1513
|
-
packet is missing important scope or evidence, record that as a coverage gap
|
|
1514
|
-
or blocker instead of searching the full conversation transcript.
|
|
1515
|
-
- Read the approved plan fields relevant to the work: \`requirements\`, \`decisions\`, feature \`targets\`, feature \`validation\`, and dependencies.
|
|
1516
|
-
- For final review, also compare the original goal, full feature list, completed
|
|
1517
|
-
feature evidence, changed artifacts, and final validation against the
|
|
1518
|
-
convergence checklist in \`references/review-rubric.md\`.
|
|
1519
|
-
- Inspect the actual diff, changed files, tests, and validation output. Do not review only the completion summary.
|
|
1520
|
-
- In manager context, load \`flow-test\` for validation-heavy,
|
|
1521
|
-
regression-sensitive, browser QA, or unclear coverage reviews. If it is
|
|
1522
|
-
unavailable or you are the hidden reviewer, record a coverage gap and treat
|
|
1523
|
-
missing validation evidence as a gap or blocker based on user impact.
|
|
1524
|
-
- Load \`references/review-rubric.md\` for severity, depth, and payload shape.
|
|
1525
|
-
|
|
1526
|
-
## Feature Review Depth
|
|
1527
|
-
|
|
1528
|
-
- **quick**: docs, comments, config-only changes, or mechanical changes fully covered by tooling.
|
|
1529
|
-
- **standard**: default feature review. Read every changed file and relevant tests.
|
|
1530
|
-
- **detailed**: risky behavior, persistence, security, cross-module refactors, migrations, releases, or weak validation.
|
|
1531
|
-
|
|
1532
|
-
\`quick\` and \`standard\` are feature-review depth descriptions only. Final reviews use \`reviewDepth: "broad"\` or \`"detailed"\` to match the plan's \`finalReviewPolicy\`; these runtime enum values are the canonical final-review terms. Claim only the depth actually performed. Missing evidence is a finding, not a nuisance.
|
|
1533
|
-
|
|
1534
|
-
## Output
|
|
1535
|
-
|
|
1536
|
-
For a feature review, return a packet the manager can copy into
|
|
1537
|
-
\`flow_feature_complete\`:
|
|
1538
|
-
|
|
1539
|
-
\`\`\`json
|
|
1540
|
-
{
|
|
1541
|
-
"featureReviewDepth": "standard",
|
|
1542
|
-
"featureReview": {
|
|
1543
|
-
"status": "passed",
|
|
1544
|
-
"summary": "what was reviewed and why it is acceptable",
|
|
1545
|
-
"blockingFindings": []
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
\`\`\`
|
|
1549
|
-
|
|
1550
|
-
\`featureReviewDepth\` must be at least the feature's planned \`reviewDepth\`.
|
|
1551
|
-
Use the actual depth performed: \`quick\`, \`standard\`, or \`detailed\`.
|
|
1552
|
-
|
|
1553
|
-
For a final review, return:
|
|
1554
|
-
|
|
1555
|
-
\`\`\`json
|
|
1556
|
-
{
|
|
1557
|
-
"status": "passed",
|
|
1558
|
-
"summary": "session-level review summary",
|
|
1559
|
-
"blockingFindings": [],
|
|
1560
|
-
"reviewDepth": "detailed"
|
|
1561
|
-
}
|
|
1562
|
-
\`\`\`
|
|
1563
|
-
|
|
1564
|
-
Use \`status: "failed"\` when any blocking finding remains. Advisory findings may be included in the prose summary, but \`blockingFindings\` contains only blockers.
|
|
1565
|
-
|
|
1566
|
-
## Special cases
|
|
1567
|
-
|
|
1568
|
-
- 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.
|
|
1569
|
-
- 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.
|
|
1570
|
-
- Audit reports: use \`../flow-run/references/audit-rubric.md\`; findings must survive refutation before they can drive fix features.
|
|
1571
|
-
- Large reviews (manager context only): start with
|
|
1572
|
-
\`../flow/references/parallel-orchestration.md\` for read-only slices by
|
|
1573
|
-
changed-file group, risk lens, or validation surface. If fan-out is selected,
|
|
1574
|
-
use \`../flow/references/parallel-manifest.md\`,
|
|
1575
|
-
\`../flow/references/parallel-execution.md\`, and
|
|
1576
|
-
\`../flow/references/parallel-synthesis.md\` with the named review, audit,
|
|
1577
|
-
evidence, or validation workers; only the manager returns the final
|
|
1578
|
-
\`featureReview\` or \`finalReview\` payload. If those references are unavailable
|
|
1579
|
-
in the current context (for example in a bundled public Flow
|
|
1580
|
-
command that does not include it), review serially and record the skipped
|
|
1581
|
-
fan-out as a coverage gap instead of improvising worker contracts. The hidden
|
|
1582
|
-
reviewer cannot spawn workers; it reviews its assigned scope directly and
|
|
1583
|
-
reports coverage gaps for the rest.
|
|
1584
|
-
|
|
1585
|
-
Never approve to unblock completion, fix findings in the review pass, or vouch for validation you did not inspect.
|
|
1586
|
-
`;
|
|
1587
|
-
|
|
1588
|
-
// skills/flow-run/references/audit-rubric.md
|
|
1589
|
-
var audit_rubric_default = `# Audit findings rubric
|
|
1590
|
-
|
|
1591
|
-
What counts as a valid finding when the feature's deliverable is a findings report: a codebase audit, a review-first feature, or any report whose findings a later feature will fix. The commands you run are still governed by \`validation-rubric.md\`; this rubric governs the findings themselves.
|
|
1592
|
-
|
|
1593
|
-
A findings report is a set of claims about code you did not write. Its failure mode is not "missed something" — it is the confident, accurately-cited finding that is wrong because the mitigating code path was never read. Accurate citations are necessary, never sufficient: a citation proves you found the suspicious site, not that the suspicion survives contact with the rest of the codebase.
|
|
1594
|
-
|
|
1595
|
-
## Refute before you report
|
|
1596
|
-
|
|
1597
|
-
Before any finding earns blocking severity (P1/P2 or equivalent), actively try to kill it:
|
|
1598
|
-
|
|
1599
|
-
- **Trace the mitigating paths.** Read the callers of the suspicious site and the code it delegates to. The question is never "could this line misbehave?" but "does anything between input and this line already prevent that?"
|
|
1600
|
-
- **Cross the layer boundary.** In a multi-layer repo, a finding in one layer is unverified until you have read its counterpart in the other. A frontend finding requires reading the backend handler it calls (it may already validate or dedupe); a library-internals finding requires checking what validation real callers pass through; an API finding requires checking what the client can actually send.
|
|
1601
|
-
- **Check the surrounding lifecycle.** State that "leaks" or "goes stale" may already be reset by an effect, a guard clause, or an invalidation a few lines away from where you stopped reading.
|
|
1602
|
-
|
|
1603
|
-
A finding that survives this pass is worth reporting. A finding you did not try to refute is a guess with a citation.
|
|
1604
|
-
|
|
1605
|
-
## Parallel audit slices
|
|
1606
|
-
|
|
1607
|
-
For broad audits, start with \`../../flow/references/parallel-orchestration.md\` to split
|
|
1608
|
-
read-only slices by module, data flow, or risk lens. Workers surface candidates;
|
|
1609
|
-
the audit author owns the report. Apply its handoff format and verification
|
|
1610
|
-
gates. Before blocking severity, dedupe, trace guards, fill cross-layer checks,
|
|
1611
|
-
verify contested or high-stakes claims, and downgrade missing context.
|
|
1612
|
-
|
|
1613
|
-
## Every blocking finding records "guards checked"
|
|
1614
|
-
|
|
1615
|
-
In addition to evidence, why-it-matters, and fix shape, every blocking finding names the mitigating paths you traced and why they do not cover this case ("\`suggest_mappings()\` enforces one-to-one via \`used_a\`/\`used_b\` — but nothing dedupes after the frontend re-sorts" reads very differently from silence). No guards-checked line means the finding is unverified: downgrade it to advisory and say what you did not trace.
|
|
1616
|
-
|
|
1617
|
-
## Observed, not hypothesized
|
|
1618
|
-
|
|
1619
|
-
- A blocking finding describes behavior the current code exhibits, with the input that triggers it. "If the backend ever returns X" is a hypothesis about code you chose not to read — either read it and confirm, or record the item as a defense-in-depth note (advisory at most).
|
|
1620
|
-
- Uncertainty after tracing is honest — state it and rate by the realistic worst case. Uncertainty instead of tracing is padding.
|
|
1621
|
-
|
|
1622
|
-
## Severity is rated in deployment context
|
|
1623
|
-
|
|
1624
|
-
- The report header states the deployment model the product actually has: desktop app, shared server, library consumed by others, CLI, and so on.
|
|
1625
|
-
- Rate impact within that model. Unbounded memory in a single-user desktop process whose lifetime is one window is not the severity it would be in a long-running shared service. When a finding only matters under a deployment the product does not have, say so explicitly ("becomes blocking if this ships as a shared service") instead of rating for the imagined deployment.
|
|
1626
|
-
|
|
1627
|
-
## Report shape
|
|
1628
|
-
|
|
1629
|
-
\`\`\`
|
|
1630
|
-
header: scope audited; deployment context; validation commands actually run
|
|
1631
|
-
findings, strongest first, each with:
|
|
1632
|
-
- class and severity
|
|
1633
|
-
- evidence — file:line actually read
|
|
1634
|
-
- guards checked — mitigating paths traced and why they fall short (blocking findings)
|
|
1635
|
-
- why it matters — the concrete failure, with triggering input
|
|
1636
|
-
- fix shape — one sentence, not an implementation
|
|
1637
|
-
positive findings — what is genuinely solid, so fixes do not regress it
|
|
1638
|
-
follow-up order — correctness and persisted/user-input surfaces first
|
|
1639
|
-
\`\`\`
|
|
1640
|
-
|
|
1641
|
-
Never: promote a hypothesis to blocking severity; cite a line you did not read in context; rate severity against a deployment model the product does not have; pad the report to look thorough — six verified findings outrank nine where three die on first contact.
|
|
1642
|
-
`;
|
|
1643
|
-
|
|
1644
|
-
// skills/flow-run/references/validation-rubric.md
|
|
1645
|
-
var validation_rubric_default = `# Validation evidence rubric
|
|
1646
|
-
|
|
1647
|
-
Use this before recording \`flow_feature_complete\`.
|
|
1648
|
-
|
|
1649
|
-
## Evidence tiers
|
|
1650
|
-
|
|
1651
|
-
1. **Behavioral automated test**: a targeted unit/integration/e2e test exercises the changed behavior and fails without the change.
|
|
1652
|
-
2. **Manual reproducible check**: you ran the app, CLI, endpoint, or workflow and recorded exact steps plus observed result.
|
|
1653
|
-
3. **Indirect automated check**: typecheck, lint, build, or compile proves shape but not behavior. Acceptable alone only for docs, comments, renames fully covered by tooling, or purely mechanical changes.
|
|
1654
|
-
4. **Static inspection**: reading code without running anything. This is a gap, not completion evidence for behavioral work.
|
|
1655
|
-
|
|
1656
|
-
Use the strongest practical tier. For risky work, combine tiers.
|
|
1657
|
-
|
|
1658
|
-
## Recording rules
|
|
1659
|
-
|
|
1660
|
-
- Each \`validationRun\` entry has \`command\`, \`status\`, and \`summary\`.
|
|
1661
|
-
- Completion accepts only passing entries. Failed or skipped checks belong in the summary/notes and must be resolved or explained as blockers.
|
|
1662
|
-
- Do not claim a command was run unless it was run in this session or directly reported by a trusted worker with raw output.
|
|
1663
|
-
- Worker-reported command output must satisfy the acceptance and verification
|
|
1664
|
-
rules in \`../../flow/references/parallel-synthesis.md\`: exact command, status,
|
|
1665
|
-
raw outcome summary, coverage, and manager acceptance.
|
|
1666
|
-
- Include scope in the summary: what behavior, files, routes, or states the check covered.
|
|
1667
|
-
- UI work should include browser or screenshot evidence when the app can run locally.
|
|
1668
|
-
- Cleanup/refactor work should show behavior preservation, not only formatting success.
|
|
1669
|
-
|
|
1670
|
-
## Scope
|
|
1671
|
-
|
|
1672
|
-
- Use \`validationScope: "targeted"\` for ordinary feature completion.
|
|
1673
|
-
- Use \`validationScope: "broad"\` only when the session is on its final feature and the project-level gate was run.
|
|
1674
|
-
|
|
1675
|
-
Broad validation usually means the repo's full check command, full relevant test suite, build, or equivalent release gate. If the broad gate cannot run, do not mark the final feature complete; report \`needs_input\` or fix the blocker.
|
|
1676
|
-
|
|
1677
|
-
## Good payload fragment
|
|
1678
|
-
|
|
1679
|
-
\`\`\`json
|
|
1680
|
-
{
|
|
1681
|
-
"validationRun": [
|
|
1682
|
-
{
|
|
1683
|
-
"command": "bun test tests/runtime-gates.test.ts",
|
|
1684
|
-
"status": "passed",
|
|
1685
|
-
"summary": "12 pass; covered approval immutability, active feature, and completion gates"
|
|
1686
|
-
},
|
|
1687
|
-
{
|
|
1688
|
-
"command": "bun run typecheck",
|
|
1689
|
-
"status": "passed",
|
|
1690
|
-
"summary": "TypeScript accepted runtime and adapter changes"
|
|
1691
|
-
}
|
|
1692
|
-
],
|
|
1693
|
-
"validationScope": "broad"
|
|
1694
|
-
}
|
|
1695
|
-
\`\`\`
|
|
1696
|
-
|
|
1697
|
-
## Blockers and resets
|
|
1698
|
-
|
|
1699
|
-
- If validation fails due to a code bug, fix it and rerun.
|
|
1700
|
-
- If validation reveals a wrong design or interface assumption, call \`flow_feature_reset\` and rerun from the corrected approach.
|
|
1701
|
-
- If validation needs external access, missing credentials, or ambiguous user input, record \`status: "needs_input"\` with an honest \`outcome\`.
|
|
1702
|
-
|
|
1703
|
-
Never trim failing output, relabel a failed command as passed, or use "not run" as completion evidence.
|
|
1704
|
-
`;
|
|
1705
|
-
|
|
1706
|
-
// skills/flow-run/SKILL.md
|
|
1707
|
-
var SKILL_default6 = `---
|
|
1708
|
-
name: flow-run
|
|
1709
|
-
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."
|
|
1710
|
-
---
|
|
1711
|
-
|
|
1712
|
-
# Flow Run
|
|
1713
|
-
|
|
1714
|
-
Use this skill for implementation after a Flow plan is approved. Work one feature at a time.
|
|
1715
|
-
|
|
1716
|
-
## Execution runtime availability
|
|
1717
|
-
|
|
1718
|
-
If \`flow_run_start\` is unavailable, stop and tell the user to check that \`opencode-plugin-flow\` is loaded in OpenCode.
|
|
1719
|
-
|
|
1720
|
-
## Start
|
|
1721
|
-
|
|
1722
|
-
- Call \`flow_status\`.
|
|
1723
|
-
- If \`flow_status\` returns a \`session.resumePacket\` or
|
|
1724
|
-
\`session.budget.phaseBoundary\`, stop the current autonomous loop and report
|
|
1725
|
-
the resume instructions. Only call \`flow_run_start\` with
|
|
1726
|
-
\`phaseBoundaryAck: true\` at the start of a fresh user invocation that is
|
|
1727
|
-
explicitly resuming the Flow session; do not acknowledge a boundary inside
|
|
1728
|
-
the same uninterrupted loop that created it.
|
|
1729
|
-
- Call \`flow_run_start\` with no \`featureId\` unless the user or plan requires a specific runnable feature.
|
|
1730
|
-
- Treat the returned feature as the sole scope until it is completed, blocked, or reset.
|
|
1731
|
-
- Helper rule: when a named helper skill is unavailable, record the gap and
|
|
1732
|
-
keep the corresponding claims conservative instead of simulating its checks.
|
|
1733
|
-
- Load \`flow-deslop\` for cleanup/refactor features.
|
|
1734
|
-
- Load \`flow-ui-quality\` for frontend, UX, responsive, accessibility, or visual work.
|
|
1735
|
-
|
|
1736
|
-
## Implement
|
|
1737
|
-
|
|
1738
|
-
- Read the feature \`targets\`, \`summary\`, \`validation\`, dependencies, and plan \`requirements\`/\`decisions\`.
|
|
1739
|
-
- Treat the feature's \`reviewDepth\` as the minimum feature-review depth that
|
|
1740
|
-
must be recorded in \`flow_feature_complete\`.
|
|
1741
|
-
- Keep edits scoped to the active feature. If new scope appears, stop and replan or defer it to another feature.
|
|
1742
|
-
- Preserve unrelated user changes in the worktree.
|
|
1743
|
-
- When a wrong assumption invalidates the feature, use \`flow_feature_reset\`; do not pile patches onto a bad path.
|
|
1744
|
-
- Do not stage, commit, push, amend, rebase, publish, or mutate releases as part
|
|
1745
|
-
of feature execution. If the user explicitly asks for commit preparation, load
|
|
1746
|
-
\`flow-commit\` only after \`flow_feature_complete\` has been recorded, unless the
|
|
1747
|
-
user explicitly asks for a WIP commit path. Keep Git boundaries separate from
|
|
1748
|
-
Flow state recording.
|
|
1749
|
-
|
|
1750
|
-
## Candidate implementation
|
|
1751
|
-
|
|
1752
|
-
\`flow-run\` remains the candidate-implementation manager entry route. Invoke the
|
|
1753
|
-
hidden \`flow-candidate-worker\` only after feature start and a complete pass
|
|
1754
|
-
manifest; never route the user's feature request directly to it.
|
|
1755
|
-
|
|
1756
|
-
For broad, risky, or multi-target work, record an implementation pass decision
|
|
1757
|
-
before editing: \`serial\`, \`candidate-exact-path\`, \`candidate-worktree\`,
|
|
1758
|
-
\`tournament\`, or \`skipped\`. Candidate implementation requires explicit user
|
|
1759
|
-
authorization and either an isolated worktree or exact non-overlapping path
|
|
1760
|
-
ownership. It is eligible only when the slice has an independent surface and
|
|
1761
|
-
practical validation, with no shared state, overlapping files, or unresolved
|
|
1762
|
-
manager judgment. Shared contracts, migrations, lockfiles, generated outputs,
|
|
1763
|
-
tightly coupled callers, unclear ownership, and small slices remain serial.
|
|
1764
|
-
|
|
1765
|
-
Classify \`candidateEligibility\` (\`eligible\`, \`not_eligible\`, or \`unknown\`) and
|
|
1766
|
-
\`candidateDecision\` (\`used\`, \`skipped\`, or \`serial_required\`) separately. Read
|
|
1767
|
-
\`../flow/references/parallel-decision.md\` for valid pairings and factors. After
|
|
1768
|
-
selecting fan-out, read \`../flow/references/parallel-manifest.md\` and
|
|
1769
|
-
\`../flow/references/parallel-execution.md\`, then
|
|
1770
|
-
\`../flow/references/parallel-synthesis.md\` when handoffs return.
|
|
1771
|
-
Set \`decision\`, \`decisionReason\`, \`decisionFactors\`, and \`writeScope\`.
|
|
1772
|
-
|
|
1773
|
-
Candidate workers return patches for manager inspection. The manager accepts,
|
|
1774
|
-
modifies, or rejects them, integrates accepted work, validates, reviews, and
|
|
1775
|
-
records Flow state serially. Record the candidate outcome as \`accepted\`,
|
|
1776
|
-
\`modified\`, or \`rejected\`. When a candidate pass or serial/skipped decision
|
|
1777
|
-
materially shaped the feature, include its bounded record in
|
|
1778
|
-
\`flow_feature_complete.orchestrationPasses\`; keep full handoffs and long logs
|
|
1779
|
-
outside the runtime payload.
|
|
1780
|
-
|
|
1781
|
-
## Validate
|
|
1782
|
-
|
|
1783
|
-
- For complex validation, regression-sensitive changes, browser QA, route QA,
|
|
1784
|
-
failure-prone checks, unclear coverage, exploratory QA, or
|
|
1785
|
-
\`validationRun\` summarization, load \`flow-test\` (helper rule applies).
|
|
1786
|
-
- Read \`references/validation-rubric.md\` before completing.
|
|
1787
|
-
- Run the strongest practical checks for the changed behavior.
|
|
1788
|
-
- Record concrete command names, status, and observed results. "Tests pass" is not evidence.
|
|
1789
|
-
- Non-final features complete with \`validationScope: "targeted"\`.
|
|
1790
|
-
- The final feature must run a broad project-level gate and use \`validationScope: "broad"\`.
|
|
1791
|
-
|
|
1792
|
-
For broad validation research, risky changes, or unclear coverage, start with
|
|
1793
|
-
\`../flow/references/parallel-orchestration.md\`. If it routes to fan-out, write
|
|
1794
|
-
the manifest from \`../flow/references/parallel-manifest.md\`, use the named Flow
|
|
1795
|
-
workers and prompt contract in \`../flow/references/parallel-execution.md\`, paste
|
|
1796
|
-
the matching handoff template from \`../flow/references/handoff-format.md\`, and
|
|
1797
|
-
apply \`../flow/references/parallel-synthesis.md\` when the handoffs return.
|
|
1798
|
-
They may report command output they actually ran or propose focused checks; the
|
|
1799
|
-
manager decides what is strong enough to record.
|
|
1800
|
-
|
|
1801
|
-
## Review and complete
|
|
1802
|
-
|
|
1803
|
-
Before \`flow_feature_complete\`, obtain a \`featureReview\` payload. Load
|
|
1804
|
-
\`flow-review\`; for read-only subagent reviews, the manager receives the review
|
|
1805
|
-
packet and records both \`featureReviewDepth\` and \`featureReview\`.
|
|
1806
|
-
|
|
1807
|
-
Send reviewers a bounded review packet. Do not rely on the accumulated parent
|
|
1808
|
-
conversation. Include only:
|
|
1809
|
-
|
|
1810
|
-
- active feature id, title, summary, \`reviewDepth\`, targets, validation, and dependencies
|
|
1811
|
-
- relevant plan requirements, decisions, and final review policy
|
|
1812
|
-
- changed files and a short diff summary
|
|
1813
|
-
- validation evidence with exact commands, status, and observed result
|
|
1814
|
-
- targeted paths or risk lenses the reviewer must inspect
|
|
1815
|
-
|
|
1816
|
-
If the review returns \`status: "failed"\`, do not fix inside the review pass.
|
|
1817
|
-
Record the failed attempt by calling \`flow_feature_complete\` with the otherwise
|
|
1818
|
-
prepared completion payload, the failed \`featureReview\`, and the attempted
|
|
1819
|
-
\`featureReviewDepth\`; the runtime will reject completion and update the retry
|
|
1820
|
-
budget. Default to stopping and reporting the blocker. When the user already
|
|
1821
|
-
authorized autonomous implementation, make at most one repair and run one retry
|
|
1822
|
-
review. If the retry fails or the runtime reports review retry budget
|
|
1823
|
-
exhausted, stop with the blocker.
|
|
1824
|
-
|
|
1825
|
-
If \`flow_status\` reports \`setup.skills\` or \`flow-review\` cannot be loaded, do
|
|
1826
|
-
not record a Flow-gated \`featureReview\` or \`finalReview\`. You may perform an
|
|
1827
|
-
advisory review using available context or the bundled review fallback provided
|
|
1828
|
-
by plugin config, then complete with \`status: "needs_input"\` if review evidence
|
|
1829
|
-
is required to proceed.
|
|
1830
|
-
|
|
1831
|
-
For the final feature, also obtain a \`finalReview\` payload whose \`reviewDepth\` equals the approved plan's \`finalReviewPolicy\`.
|
|
1832
|
-
|
|
1833
|
-
Complete with:
|
|
1834
|
-
|
|
1835
|
-
\`\`\`json
|
|
1836
|
-
{
|
|
1837
|
-
"status": "ok",
|
|
1838
|
-
"featureId": "active-feature-id",
|
|
1839
|
-
"summary": "what changed",
|
|
1840
|
-
"artifactsChanged": [{ "path": "src/file.ts" }],
|
|
1841
|
-
"validationRun": [
|
|
1842
|
-
{ "command": "bun test tests/foo.test.ts", "status": "passed", "summary": "3 pass, exercised foo behavior" }
|
|
1843
|
-
],
|
|
1844
|
-
"validationScope": "targeted",
|
|
1845
|
-
"featureReviewDepth": "standard",
|
|
1846
|
-
"featureReview": { "status": "passed", "summary": "review summary", "blockingFindings": [] },
|
|
1847
|
-
"orchestrationPasses": [
|
|
1848
|
-
{
|
|
1849
|
-
"id": "active-feature-id-implementation-decision",
|
|
1850
|
-
"kind": "implementation-decision",
|
|
1851
|
-
"decision": "serial",
|
|
1852
|
-
"decisionReason": "Shared contract edits made worker ownership unsafe.",
|
|
1853
|
-
"candidateEligibility": "not_eligible",
|
|
1854
|
-
"candidateDecision": "serial_required",
|
|
1855
|
-
"decisionFactors": ["shared_state", "overlapping_files"],
|
|
1856
|
-
"writeScope": "manager-serial",
|
|
1857
|
-
"verificationStatus": "not-needed",
|
|
1858
|
-
"outcome": "accepted"
|
|
1859
|
-
}
|
|
1860
|
-
]
|
|
1861
|
-
}
|
|
1862
|
-
\`\`\`
|
|
1863
|
-
|
|
1864
|
-
If \`flow_feature_complete\` returns a \`session.resumePacket\` or
|
|
1865
|
-
\`session.budget.phaseBoundary\`, stop after reporting the runtime-provided resume
|
|
1866
|
-
packet. If
|
|
1867
|
-
genuinely blocked, call \`flow_feature_complete\` with \`status: "needs_input"\` and
|
|
1868
|
-
an \`outcome\` that explains the blocker and next step. Never fabricate validation
|
|
1869
|
-
or review evidence to force progress.
|
|
1870
|
-
`;
|
|
1871
|
-
|
|
1872
|
-
// skills/flow-test/SKILL.md
|
|
1873
|
-
var SKILL_default7 = `---
|
|
1874
|
-
name: flow-test
|
|
1875
|
-
description: Choose, run, and summarize validation checks for Flow features. Use when selecting validation coverage, running tests or browser/e2e QA, classifying test failures, or preparing validationRun evidence for flow_feature_complete. Visual design judgment stays in flow-ui-quality and review verdicts stay in flow-review.
|
|
1876
|
-
---
|
|
1877
|
-
|
|
1878
|
-
# Flow Test
|
|
1879
|
-
|
|
1880
|
-
Use this skill to decide and gather validation evidence. It produces validation
|
|
1881
|
-
evidence only: the manager still owns \`flow_feature_complete\`, review payloads,
|
|
1882
|
-
plan approval, session closure, and every other Flow state change.
|
|
1883
|
-
|
|
1884
|
-
Do not mutate \`.flow/**\`, approve plans, complete features, close sessions, or
|
|
1885
|
-
substitute for \`flow-review\`. If Flow tools are unavailable, this skill can still
|
|
1886
|
-
produce an advisory validation plan or test summary, but it cannot record Flow
|
|
1887
|
-
state.
|
|
1888
|
-
|
|
1889
|
-
## Inputs
|
|
1890
|
-
|
|
1891
|
-
Start from the smallest concrete surface:
|
|
1892
|
-
|
|
1893
|
-
- The approved feature \`summary\`, \`targets\`, and \`validation\` entries when a
|
|
1894
|
-
Flow session exists.
|
|
1895
|
-
- The actual diff, changed files, package scripts, docs, and test conventions.
|
|
1896
|
-
- Recent command output from this session or from a trusted worker handoff.
|
|
1897
|
-
- Any user-stated acceptance criteria, browser target, fixture, or environment
|
|
1898
|
-
constraint.
|
|
1899
|
-
|
|
1900
|
-
Prefer repository scripts and local conventions over invented commands. If a
|
|
1901
|
-
command has not been run in this session or directly reported by a trusted
|
|
1902
|
-
worker with raw outcome, recommend it instead of claiming it passed.
|
|
1903
|
-
|
|
1904
|
-
## Select Coverage
|
|
1905
|
-
|
|
1906
|
-
Choose checks from changed-surface risk, not from habit:
|
|
1907
|
-
|
|
1908
|
-
- **Targeted behavior**: unit, integration, CLI, route, or component tests that
|
|
1909
|
-
exercise the changed behavior and would fail without the fix.
|
|
1910
|
-
- **Integration and persistence**: database, filesystem, API, adapter, lock, or
|
|
1911
|
-
serialization paths touched by the feature.
|
|
1912
|
-
- **Browser or e2e**: user-visible workflows, responsive states, accessibility
|
|
1913
|
-
basics, form flows, and screenshots when a local target and browser tooling
|
|
1914
|
-
are available.
|
|
1915
|
-
- **Package and build shape**: typecheck, lint, build, generated distribution,
|
|
1916
|
-
or schema checks when public contracts, bundling, or package exports changed.
|
|
1917
|
-
- **Docs and mechanical edits**: markdown rendering, link/path sanity, spelling
|
|
1918
|
-
of commands, or the narrowest project check when behavior is unchanged.
|
|
1919
|
-
- **Cleanup/refactor**: behavior-preservation tests plus the relevant broad
|
|
1920
|
-
check; formatting alone is not evidence of preserved behavior.
|
|
1921
|
-
- **Final feature**: the repository's broad gate, full relevant suite, build, or
|
|
1922
|
-
equivalent release gate before \`validationScope: "broad"\` is recorded.
|
|
1923
|
-
|
|
1924
|
-
If the planned coverage is weaker than the risk, say so explicitly and list the
|
|
1925
|
-
missing evidence.
|
|
1926
|
-
|
|
1927
|
-
## Run Discipline
|
|
1928
|
-
|
|
1929
|
-
For each check:
|
|
1930
|
-
|
|
1931
|
-
1. State the hypothesis: what behavior or contract the check is expected to
|
|
1932
|
-
prove.
|
|
1933
|
-
2. Run the command or manual workflow when the environment allows it.
|
|
1934
|
-
3. Record exact command, status, and observed result.
|
|
1935
|
-
4. If it fails, classify the failure before editing:
|
|
1936
|
-
- product failure
|
|
1937
|
-
- test failure
|
|
1938
|
-
- environment failure
|
|
1939
|
-
- pre-existing failure
|
|
1940
|
-
- flake
|
|
1941
|
-
- unrelated failure
|
|
1942
|
-
5. Before a fix attempt, write a short failure hypothesis that names the likely
|
|
1943
|
-
cause and the file or behavior to inspect.
|
|
1944
|
-
6. After a fix, rerun the failing check and one appropriate regression check.
|
|
1945
|
-
|
|
1946
|
-
Do not trim failure output so far that the manager cannot understand the
|
|
1947
|
-
failure. Do redact secrets and credentials.
|
|
1948
|
-
|
|
1949
|
-
## Browser and Exploratory QA
|
|
1950
|
-
|
|
1951
|
-
For meaningful UI or browser workflow changes, browser evidence is expected when
|
|
1952
|
-
a local target can run:
|
|
1953
|
-
|
|
1954
|
-
- Open the relevant route or story with the available browser tooling.
|
|
1955
|
-
- Exercise the main changed workflow, not only page load.
|
|
1956
|
-
- Check desktop and mobile breakpoints when responsive behavior is in scope.
|
|
1957
|
-
- Capture screenshots or describe the viewport, route, steps, and observed
|
|
1958
|
-
result.
|
|
1959
|
-
- Inspect visible error states, empty states, long labels, focus behavior, and
|
|
1960
|
-
console or network failures when the tooling exposes them.
|
|
1961
|
-
|
|
1962
|
-
Browser claims are evidence requirements, not guaranteed coverage. If browser
|
|
1963
|
-
tooling, credentials, seed data, or a local server is unavailable, record the
|
|
1964
|
-
gap and provide the next-best evidence such as component tests, build output, or
|
|
1965
|
-
static inspection.
|
|
1966
|
-
|
|
1967
|
-
Exploratory QA should be scenario-based. Name the user path, the state varied,
|
|
1968
|
-
and the expected outcome. Do not replace automated evidence with exploratory QA
|
|
1969
|
-
when a practical automated check exists.
|
|
1970
|
-
|
|
1971
|
-
## Output
|
|
1972
|
-
|
|
1973
|
-
Return a concise validation summary and a \`validationRun\` array that the manager
|
|
1974
|
-
can record through \`flow_feature_complete\` if it accepts the evidence:
|
|
1975
|
-
|
|
1976
|
-
\`\`\`json
|
|
1977
|
-
{
|
|
1978
|
-
"validationRun": [
|
|
1979
|
-
{
|
|
1980
|
-
"command": "bun test tests/foo.test.ts",
|
|
1981
|
-
"status": "passed",
|
|
1982
|
-
"summary": "3 pass; covered foo creation, duplicate rejection, and reset behavior"
|
|
1983
|
-
}
|
|
1984
|
-
],
|
|
1985
|
-
"testSummary": "Targeted behavior and package shape passed. Browser evidence was not applicable.",
|
|
1986
|
-
"gaps": []
|
|
1987
|
-
}
|
|
1988
|
-
\`\`\`
|
|
1989
|
-
|
|
1990
|
-
Only passing checks belong in \`validationRun\` for completion. Failed, skipped,
|
|
1991
|
-
or unavailable checks belong in \`testSummary\`, \`gaps\`, or a blocker outcome.
|
|
1992
|
-
Each summary must state what behavior, file set, route, command, or state was
|
|
1993
|
-
covered. Static inspection alone is a gap for behavioral changes.
|
|
1994
|
-
|
|
1995
|
-
Never relabel a failed command as passed, invent output, or use "not run" as
|
|
1996
|
-
completion evidence.
|
|
1997
|
-
`;
|
|
1998
|
-
|
|
1999
|
-
// skills/flow-ui-quality/references/ui-rubric.md
|
|
2000
|
-
var ui_rubric_default = `# UI quality rubric
|
|
2001
|
-
|
|
2002
|
-
Use this rubric for frontend planning, implementation, and review.
|
|
2003
|
-
|
|
2004
|
-
## Product fit
|
|
2005
|
-
|
|
2006
|
-
- The screen solves the user's actual task, not a generic demo of components.
|
|
2007
|
-
- The first viewport shows the product, data, object, or workflow the user came for.
|
|
2008
|
-
- The information density matches use: operational tools favor scannable, compact structure; expressive pages need stronger visual identity and media.
|
|
2009
|
-
- Navigation and primary actions are obvious without explanatory helper text.
|
|
2010
|
-
|
|
2011
|
-
## Visual design
|
|
2012
|
-
|
|
2013
|
-
- **Typography**: hierarchy is clear; font choices fit the product; body text remains readable; compact surfaces do not use hero-scale type.
|
|
2014
|
-
- **Color**: palette has a coherent role system; contrast is sufficient; accent colors guide attention; avoid one-note palettes and generic purple-blue gradients unless the brand requires them.
|
|
2015
|
-
- **Composition**: alignment, spacing, and grouping make comparison easy; repeated items are consistent; page sections are not nested decorative cards.
|
|
2016
|
-
- **Controls**: use familiar controls for the job: icons for common tools, toggles for binary settings, segmented controls for modes, sliders/inputs for numbers, menus for option sets.
|
|
2017
|
-
- **Motion**: animation clarifies state or creates a focused moment; it does not hide latency, distract from work, or ignore reduced-motion needs.
|
|
2018
|
-
- **Imagery/media**: when the subject matters, show the actual product/place/object/state rather than atmospheric filler.
|
|
2019
|
-
|
|
2020
|
-
## Interaction and states
|
|
2021
|
-
|
|
2022
|
-
- Loading, empty, error, disabled, hover, focus, selected, and validation states exist for the changed workflow.
|
|
2023
|
-
- Long strings, missing data, large numbers, and small screens do not break layout.
|
|
2024
|
-
- Destructive actions have appropriate confirmation or undo patterns.
|
|
2025
|
-
- Form errors are close to the field and clear enough to fix.
|
|
2026
|
-
- Async state cannot double-submit, lose edits, or leave stale UI behind.
|
|
2027
|
-
|
|
2028
|
-
## Accessibility baseline
|
|
2029
|
-
|
|
2030
|
-
- Interactive elements are semantic or have correct roles and labels.
|
|
2031
|
-
- Keyboard users can reach and operate controls in a logical order.
|
|
2032
|
-
- Focus indicators are visible.
|
|
2033
|
-
- Text and essential UI meet contrast expectations.
|
|
2034
|
-
- Status, error, and progress messages are not conveyed by color alone.
|
|
2035
|
-
- Motion respects reduced-motion preferences when substantial.
|
|
2036
|
-
|
|
2037
|
-
## Review finding shape
|
|
2038
|
-
|
|
2039
|
-
\`\`\`text
|
|
2040
|
-
class; severity; location or screenshot area; evidence inspected; user impact; fix shape; visual/validation evidence needed
|
|
2041
|
-
\`\`\`
|
|
2042
|
-
|
|
2043
|
-
Blocking UI findings are issues that prevent task completion, hide required information, break accessibility basics, create incoherent layout at supported sizes, or make the visual success claim unverifiable.
|
|
2044
|
-
`;
|
|
2045
|
-
|
|
2046
|
-
// skills/flow-ui-quality/references/visual-verification.md
|
|
2047
|
-
var visual_verification_default = `# Visual verification workflow
|
|
2048
|
-
|
|
2049
|
-
Use this workflow when UI changes can be run locally. Flow execution may create visual evidence; Flow review usually assesses recorded evidence because the reviewer is read-only.
|
|
2050
|
-
|
|
2051
|
-
## Execution lane
|
|
2052
|
-
|
|
2053
|
-
- Identify the target route, state, viewport sizes, and any required seed data.
|
|
2054
|
-
- Start the repo's normal dev server or storybook command from the recorded repo profile.
|
|
2055
|
-
- Prefer existing browser or Playwright tooling when available. Do not add heavy visual tooling just to inspect a small change.
|
|
2056
|
-
- Capture at least one desktop viewport and one mobile viewport for user-facing layout changes.
|
|
2057
|
-
- Exercise the primary interaction changed by the feature.
|
|
2058
|
-
- Inspect loading, empty, and error states when they are part of the changed workflow or easy to reach.
|
|
2059
|
-
- Check browser console output when the tooling exposes it.
|
|
2060
|
-
- For canvas/3D/media-heavy UI, verify rendered pixels are nonblank and the subject is framed.
|
|
2061
|
-
|
|
2062
|
-
## Review lane
|
|
2063
|
-
|
|
2064
|
-
- Inspect the screenshots, browser notes, console output, or visual artifacts recorded by execution.
|
|
2065
|
-
- Compare recorded evidence against the plan's design intent, supported viewports, state coverage, and the UI rubric.
|
|
2066
|
-
- If the current reviewer has browser/shell tools and permissions, it may perform additional read-only visual checks.
|
|
2067
|
-
- If the reviewer is read-only without browser or shell access, do not try to recreate evidence. Treat missing or insufficient visual evidence as a finding or coverage gap.
|
|
2068
|
-
|
|
2069
|
-
## What to look for
|
|
2070
|
-
|
|
2071
|
-
- Text overlap, clipped labels, unintended wrapping, and controls resizing on hover.
|
|
2072
|
-
- Incoherent spacing, nested cards, generic placeholder visuals, and decorative elements that compete with the task.
|
|
2073
|
-
- Missing focus states, low contrast, unreachable controls, and color-only status.
|
|
2074
|
-
- Broken responsive behavior: horizontal scroll, collapsed controls, hidden primary actions, or unreadable tables.
|
|
2075
|
-
- State bugs: stale loading indicators, duplicate submissions, lost input, or errors that cannot be recovered.
|
|
2076
|
-
|
|
2077
|
-
## If visual verification is unavailable
|
|
2078
|
-
|
|
2079
|
-
Record the reason and use the strongest available substitute:
|
|
2080
|
-
|
|
2081
|
-
- build/typecheck/lint for changed frontend code.
|
|
2082
|
-
- component or interaction tests.
|
|
2083
|
-
- Storybook/static render output.
|
|
2084
|
-
- code inspection against existing component patterns.
|
|
2085
|
-
|
|
2086
|
-
Do not claim visual polish was verified if no visual artifact was inspected.
|
|
2087
|
-
`;
|
|
2088
|
-
|
|
2089
|
-
// skills/flow-ui-quality/SKILL.md
|
|
2090
|
-
var SKILL_default8 = `---
|
|
2091
|
-
name: flow-ui-quality
|
|
2092
|
-
description: Review and improve frontend UI quality for Flow work. Use for UX/UI design, frontend polish, visual quality review, responsive and accessible interfaces, interaction states, screenshot assessment, and avoiding generic AI-generated UI. Browser-run mechanics and validationRun summaries stay in flow-test.
|
|
2093
|
-
---
|
|
2094
|
-
|
|
2095
|
-
# Flow UI quality
|
|
2096
|
-
|
|
2097
|
-
Use this skill when Flow work changes what a user sees or how they interact with an interface. The goal is production UI quality: useful, coherent, accessible, responsive, and visually intentional.
|
|
2098
|
-
|
|
2099
|
-
This is a helper skill: it contributes UI judgment and visual evidence only. The manager owns every state-changing \`flow_*\` call.
|
|
2100
|
-
|
|
2101
|
-
## Establish the interface intent
|
|
2102
|
-
|
|
2103
|
-
- Identify the user, job-to-be-done, primary workflow, density needs, device constraints, and brand/product tone before choosing visuals.
|
|
2104
|
-
- Choose a clear design direction that fits the product context. Distinctive does not mean decorative; utilitarian tools can be excellent through restraint, hierarchy, and speed.
|
|
2105
|
-
- Load \`references/ui-rubric.md\` for design and UX review criteria.
|
|
2106
|
-
- Load \`references/visual-verification.md\` before completing meaningful UI changes to capture visual evidence. During review, use it to assess recorded evidence; only run browser checks yourself if the current agent and tools permit it.
|
|
2107
|
-
- Record design constraints and verification expectations in Flow plan fields: \`requirements\`, \`decisions\`, feature \`targets\`, and feature \`validation\`. Do not add new Flow payload fields.
|
|
2108
|
-
|
|
2109
|
-
## Build with visual intent
|
|
2110
|
-
|
|
2111
|
-
- Use existing design systems, component libraries, tokens, icons, and layout conventions before inventing new primitives.
|
|
2112
|
-
- Make typography, spacing, color, motion, and hierarchy deliberate. Avoid default-looking AI output: centered everything, purple gradients, generic cards, uniform oversized radii, stock SaaS layouts, and unexamined Inter/system-font sameness.
|
|
2113
|
-
- Match composition to domain: operational apps need scanability, alignment, predictable controls, efficient density, and clear states; marketing or editorial surfaces can carry more expressive imagery and motion.
|
|
2114
|
-
- Include states a real user will hit: loading, empty, error, disabled, hover, focus, selected, validation, and long content.
|
|
2115
|
-
- Protect accessibility: semantic controls, labels, focus order, keyboard reachability, contrast, reduced-motion behavior, and non-color-only status.
|
|
2116
|
-
|
|
2117
|
-
## Verify visually
|
|
2118
|
-
|
|
2119
|
-
- For meaningful UI changes, run the app and capture screenshots when a local browser target is available.
|
|
2120
|
-
- For browser-driven QA, route selection, failure classification, and
|
|
2121
|
-
\`validationRun\` summaries, load \`flow-test\`. Keep visual judgment, design
|
|
2122
|
-
quality, and screenshot assessment in \`flow-ui-quality\`.
|
|
2123
|
-
- Check desktop and mobile breakpoints, not only the viewport you developed in.
|
|
2124
|
-
- Verify text does not overlap, truncate unintentionally, or escape controls; long labels and empty/error states must fit.
|
|
2125
|
-
- Compare against provided screenshots, design references, or the stated product intent. List meaningful differences and fix the ones that violate the goal.
|
|
2126
|
-
- If browser verification cannot run, record the gap and the next-best evidence such as component tests, Storybook snapshots, build output, or static inspection.
|
|
2127
|
-
|
|
2128
|
-
## Review UI work
|
|
2129
|
-
|
|
2130
|
-
Approve only when the interface is both useful and inspectable:
|
|
2131
|
-
|
|
2132
|
-
- The main workflow is visible and efficient.
|
|
2133
|
-
- Visual hierarchy makes the next action obvious.
|
|
2134
|
-
- Responsive behavior is deliberate.
|
|
2135
|
-
- Accessibility basics are covered.
|
|
2136
|
-
- State coverage is present or the gaps are explicit.
|
|
2137
|
-
- Screenshot/browser evidence supports the claim whenever feasible.
|
|
2138
|
-
|
|
2139
|
-
Never approve a UI change based only on code shape. If users will judge it visually, Flow evidence should include visual inspection.
|
|
2140
|
-
`;
|
|
2141
|
-
|
|
2142
|
-
// src/distribution/flow-skill-definitions.ts
|
|
2143
|
-
var FLOW_SKILL_DEFINITIONS = [
|
|
2144
|
-
{
|
|
2145
|
-
name: "flow",
|
|
2146
|
-
files: [
|
|
2147
|
-
{ relativePath: "SKILL.md", content: SKILL_default },
|
|
2148
|
-
{
|
|
2149
|
-
relativePath: "references/recovery-playbook.md",
|
|
2150
|
-
content: recovery_playbook_default
|
|
2151
|
-
},
|
|
2152
|
-
{
|
|
2153
|
-
relativePath: "references/parallel-orchestration.md",
|
|
2154
|
-
content: parallel_orchestration_default
|
|
2155
|
-
},
|
|
2156
|
-
{
|
|
2157
|
-
relativePath: "references/parallel-decision.md",
|
|
2158
|
-
content: parallel_decision_default
|
|
2159
|
-
},
|
|
2160
|
-
{
|
|
2161
|
-
relativePath: "references/parallel-manifest.md",
|
|
2162
|
-
content: parallel_manifest_default
|
|
2163
|
-
},
|
|
2164
|
-
{
|
|
2165
|
-
relativePath: "references/parallel-execution.md",
|
|
2166
|
-
content: parallel_execution_default
|
|
2167
|
-
},
|
|
2168
|
-
{
|
|
2169
|
-
relativePath: "references/parallel-synthesis.md",
|
|
2170
|
-
content: parallel_synthesis_default
|
|
2171
|
-
},
|
|
2172
|
-
{
|
|
2173
|
-
relativePath: "references/parallel-pass-example.md",
|
|
2174
|
-
content: parallel_pass_example_default
|
|
2175
|
-
},
|
|
2176
|
-
{
|
|
2177
|
-
relativePath: "references/handoff-format.md",
|
|
2178
|
-
content: handoff_format_default
|
|
2179
|
-
}
|
|
2180
|
-
]
|
|
2181
|
-
},
|
|
2182
|
-
{
|
|
2183
|
-
name: "flow-plan",
|
|
2184
|
-
files: [
|
|
2185
|
-
{ relativePath: "SKILL.md", content: SKILL_default4 },
|
|
2186
|
-
{
|
|
2187
|
-
relativePath: "references/planning-examples.md",
|
|
2188
|
-
content: planning_examples_default
|
|
2189
|
-
},
|
|
2190
|
-
{
|
|
2191
|
-
relativePath: "references/plan-quality-checklist.md",
|
|
2192
|
-
content: plan_quality_checklist_default
|
|
2193
|
-
},
|
|
2194
|
-
{
|
|
2195
|
-
relativePath: "references/parallel-discovery.md",
|
|
2196
|
-
content: parallel_discovery_default
|
|
2197
|
-
}
|
|
2198
|
-
]
|
|
2199
|
-
},
|
|
2200
|
-
{
|
|
2201
|
-
name: "flow-run",
|
|
2202
|
-
files: [
|
|
2203
|
-
{ relativePath: "SKILL.md", content: SKILL_default6 },
|
|
2204
|
-
{
|
|
2205
|
-
relativePath: "references/validation-rubric.md",
|
|
2206
|
-
content: validation_rubric_default
|
|
2207
|
-
},
|
|
2208
|
-
{
|
|
2209
|
-
relativePath: "references/audit-rubric.md",
|
|
2210
|
-
content: audit_rubric_default
|
|
2211
|
-
}
|
|
2212
|
-
]
|
|
2213
|
-
},
|
|
2214
|
-
{
|
|
2215
|
-
name: "flow-test",
|
|
2216
|
-
files: [{ relativePath: "SKILL.md", content: SKILL_default7 }]
|
|
2217
|
-
},
|
|
2218
|
-
{
|
|
2219
|
-
name: "flow-review",
|
|
2220
|
-
files: [
|
|
2221
|
-
{ relativePath: "SKILL.md", content: SKILL_default5 },
|
|
2222
|
-
{
|
|
2223
|
-
relativePath: "references/hidden-reviewer-contract.md",
|
|
2224
|
-
content: hidden_reviewer_contract_default
|
|
2225
|
-
},
|
|
2226
|
-
{
|
|
2227
|
-
relativePath: "references/review-rubric.md",
|
|
2228
|
-
content: review_rubric_default
|
|
2229
|
-
}
|
|
2230
|
-
]
|
|
2231
|
-
},
|
|
2232
|
-
{
|
|
2233
|
-
name: "flow-deslop",
|
|
2234
|
-
files: [
|
|
2235
|
-
{ relativePath: "SKILL.md", content: SKILL_default3 },
|
|
2236
|
-
{
|
|
2237
|
-
relativePath: "references/smell-rubric.md",
|
|
2238
|
-
content: smell_rubric_default
|
|
2239
|
-
},
|
|
2240
|
-
{
|
|
2241
|
-
relativePath: "references/refactor-workflow.md",
|
|
2242
|
-
content: refactor_workflow_default
|
|
2243
|
-
}
|
|
2244
|
-
]
|
|
2245
|
-
},
|
|
2246
|
-
{
|
|
2247
|
-
name: "flow-ui-quality",
|
|
2248
|
-
files: [
|
|
2249
|
-
{ relativePath: "SKILL.md", content: SKILL_default8 },
|
|
2250
|
-
{
|
|
2251
|
-
relativePath: "references/ui-rubric.md",
|
|
2252
|
-
content: ui_rubric_default
|
|
2253
|
-
},
|
|
2254
|
-
{
|
|
2255
|
-
relativePath: "references/visual-verification.md",
|
|
2256
|
-
content: visual_verification_default
|
|
2257
|
-
}
|
|
2258
|
-
]
|
|
2259
|
-
},
|
|
2260
|
-
{
|
|
2261
|
-
name: "flow-commit",
|
|
2262
|
-
files: [{ relativePath: "SKILL.md", content: SKILL_default2 }]
|
|
2263
|
-
}
|
|
5
|
+
import { constants } from "node:fs";
|
|
6
|
+
import {
|
|
7
|
+
lstat,
|
|
8
|
+
mkdir,
|
|
9
|
+
open,
|
|
10
|
+
readdir,
|
|
11
|
+
rename
|
|
12
|
+
} from "node:fs/promises";
|
|
13
|
+
import { homedir } from "node:os";
|
|
14
|
+
import { isAbsolute, join, normalize, sep } from "node:path";
|
|
15
|
+
|
|
16
|
+
// src/guidance/ids.ts
|
|
17
|
+
var FLOW_GUIDANCE_TOPICS = [
|
|
18
|
+
"flow",
|
|
19
|
+
"flow-plan",
|
|
20
|
+
"flow-run",
|
|
21
|
+
"flow-test",
|
|
22
|
+
"flow-review",
|
|
23
|
+
"flow-deslop",
|
|
24
|
+
"flow-ui-quality",
|
|
25
|
+
"flow-commit"
|
|
2264
26
|
];
|
|
2265
27
|
|
|
2266
|
-
// src/distribution/
|
|
2267
|
-
var
|
|
2268
|
-
var
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
const namedHash = backupHashFromName(relativePath);
|
|
2274
|
-
if (!namedHash)
|
|
2275
|
-
return false;
|
|
2276
|
-
const content = await optionalRead(resolveSkillFile(folder, relativePath));
|
|
2277
|
-
if (content === null)
|
|
2278
|
-
return false;
|
|
2279
|
-
return sha256(content).slice(0, 12) === namedHash;
|
|
2280
|
-
}
|
|
2281
|
-
function normalizeNewlines(value) {
|
|
2282
|
-
return value.replace(/\r\n/g, `
|
|
2283
|
-
`);
|
|
2284
|
-
}
|
|
2285
|
-
var CHANGED_SYNC_ACTIONS = [
|
|
2286
|
-
"installed",
|
|
2287
|
-
"updated",
|
|
2288
|
-
"updated_with_backup"
|
|
2289
|
-
];
|
|
2290
|
-
function isChangedSyncAction(action) {
|
|
2291
|
-
return CHANGED_SYNC_ACTIONS.includes(action);
|
|
28
|
+
// src/distribution/legacy-cleanup.ts
|
|
29
|
+
var LEGACY_MARKER = ".flow-skill-version";
|
|
30
|
+
var NO_FOLLOW = constants.O_NOFOLLOW ?? 0;
|
|
31
|
+
var SUPPORTED_LEGACY_MAJOR = "4";
|
|
32
|
+
var SEMVER_PATTERN = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
33
|
+
function configuredHome() {
|
|
34
|
+
return process.env.HOME?.trim() || process.env.USERPROFILE?.trim() || homedir();
|
|
2292
35
|
}
|
|
2293
|
-
function
|
|
2294
|
-
const configured = process.env.HOME?.trim() || process.env.USERPROFILE?.trim();
|
|
2295
|
-
return configured || homedir();
|
|
2296
|
-
}
|
|
2297
|
-
function resolveFlowSkillsRoot(home = homeDir()) {
|
|
36
|
+
function resolveLegacySkillsRoot(home = configuredHome()) {
|
|
2298
37
|
return join(home, ".config", "opencode", "skills");
|
|
2299
38
|
}
|
|
2300
|
-
function
|
|
2301
|
-
return
|
|
39
|
+
function resolveLegacyArchiveRoot(home = configuredHome()) {
|
|
40
|
+
return join(home, ".config", "opencode", "flow-legacy-skills");
|
|
2302
41
|
}
|
|
2303
|
-
function
|
|
2304
|
-
return
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
42
|
+
function sha256(content) {
|
|
43
|
+
return createHash("sha256").update(content).digest("hex");
|
|
44
|
+
}
|
|
45
|
+
function safeLegacyPath(folder, relativePath) {
|
|
46
|
+
if (!relativePath || isAbsolute(relativePath) || relativePath.includes("\\") || relativePath.split("/").some((part) => !part || part === "." || part === "..")) {
|
|
47
|
+
throw new Error(`unsafe marker path '${relativePath}'`);
|
|
48
|
+
}
|
|
49
|
+
const resolved = normalize(join(folder, ...relativePath.split("/")));
|
|
50
|
+
if (!resolved.startsWith(`${folder}${sep}`)) {
|
|
51
|
+
throw new Error(`unsafe marker path '${relativePath}'`);
|
|
52
|
+
}
|
|
53
|
+
return resolved;
|
|
2310
54
|
}
|
|
2311
|
-
async function
|
|
55
|
+
async function optionalStat(path) {
|
|
2312
56
|
try {
|
|
2313
|
-
return await
|
|
57
|
+
return await lstat(path, { bigint: false });
|
|
2314
58
|
} catch (error) {
|
|
2315
|
-
|
|
2316
|
-
if (code === "ENOENT" || code === "ENOTDIR")
|
|
59
|
+
if (error.code === "ENOENT")
|
|
2317
60
|
return null;
|
|
2318
61
|
throw error;
|
|
2319
62
|
}
|
|
2320
63
|
}
|
|
2321
|
-
function
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
64
|
+
async function readRegularFileWithoutFollowing(path) {
|
|
65
|
+
let handle;
|
|
66
|
+
try {
|
|
67
|
+
const pathMetadata = await lstat(path);
|
|
68
|
+
if (pathMetadata.isSymbolicLink()) {
|
|
69
|
+
throw new Error(`symbolic link refused: ${path}`);
|
|
70
|
+
}
|
|
71
|
+
if (!pathMetadata.isFile())
|
|
72
|
+
throw new Error(`not a regular file: ${path}`);
|
|
73
|
+
handle = await open(path, constants.O_RDONLY | NO_FOLLOW);
|
|
74
|
+
const metadata = await handle.stat();
|
|
75
|
+
if (!metadata.isFile())
|
|
76
|
+
throw new Error(`not a regular file: ${path}`);
|
|
77
|
+
if (metadata.dev !== pathMetadata.dev || metadata.ino !== pathMetadata.ino) {
|
|
78
|
+
throw new Error(`file changed while cleanup was running: ${path}`);
|
|
2332
79
|
}
|
|
80
|
+
return await handle.readFile({ encoding: "utf8" });
|
|
81
|
+
} catch (error) {
|
|
82
|
+
if (error.code === "ELOOP") {
|
|
83
|
+
throw new Error(`symbolic link refused: ${path}`);
|
|
84
|
+
}
|
|
85
|
+
throw error;
|
|
86
|
+
} finally {
|
|
87
|
+
await handle?.close();
|
|
2333
88
|
}
|
|
2334
|
-
return files;
|
|
2335
89
|
}
|
|
2336
|
-
function
|
|
2337
|
-
|
|
2338
|
-
|
|
90
|
+
function parseMarker(content) {
|
|
91
|
+
let version;
|
|
92
|
+
const files = new Map;
|
|
2339
93
|
for (const line of content.split(/\r?\n/)) {
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
if (resolved !== folder && resolved.startsWith(`${folder}${sep}`)) {
|
|
2349
|
-
return resolved;
|
|
2350
|
-
}
|
|
2351
|
-
throw new Error(`Unsafe skill file path '${relativePath}'.`);
|
|
2352
|
-
}
|
|
2353
|
-
async function writeBackup(path, content) {
|
|
2354
|
-
const basePath = `${path}.backup.${sha256(content).slice(0, 12)}`;
|
|
2355
|
-
for (let index = 0;; index += 1) {
|
|
2356
|
-
const backupPath = index === 0 ? basePath : `${basePath}.${index}`;
|
|
2357
|
-
try {
|
|
2358
|
-
await writeFile(backupPath, content, { encoding: "utf8", flag: "wx" });
|
|
2359
|
-
return backupPath;
|
|
2360
|
-
} catch (error) {
|
|
2361
|
-
if (error.code === "EEXIST")
|
|
2362
|
-
continue;
|
|
2363
|
-
throw error;
|
|
94
|
+
if (!line)
|
|
95
|
+
continue;
|
|
96
|
+
const versionMatch = /^version=(.+)$/.exec(line);
|
|
97
|
+
if (versionMatch?.[1]) {
|
|
98
|
+
if (version)
|
|
99
|
+
throw new Error("marker contains duplicate versions");
|
|
100
|
+
version = versionMatch[1];
|
|
101
|
+
continue;
|
|
2364
102
|
}
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
const markerPath = join(folder, MARKER_FILENAME);
|
|
2370
|
-
const markerContent = await optionalRead(markerPath);
|
|
2371
|
-
const existingMarkerHashes = parseMarkerFiles(markerContent);
|
|
2372
|
-
if (markerContent === null) {
|
|
2373
|
-
for (const file of definition.files) {
|
|
2374
|
-
const existing = await optionalRead(resolveSkillFile(folder, file.relativePath));
|
|
2375
|
-
if (existing !== null) {
|
|
2376
|
-
return { name: definition.name, action: "skipped_foreign" };
|
|
103
|
+
const fileMatch = /^file=(.+) sha256=([a-f0-9]{64})$/.exec(line) ?? /^file=(.+)=sha256:([a-f0-9]{64})$/.exec(line);
|
|
104
|
+
if (fileMatch?.[1] && fileMatch[2]) {
|
|
105
|
+
if (files.has(fileMatch[1])) {
|
|
106
|
+
throw new Error(`marker contains duplicate file '${fileMatch[1]}'`);
|
|
2377
107
|
}
|
|
2378
|
-
|
|
2379
|
-
}
|
|
2380
|
-
let changed = false;
|
|
2381
|
-
const backupPaths = [];
|
|
2382
|
-
const currentRelativePaths = new Set(definition.files.map((file) => file.relativePath));
|
|
2383
|
-
for (const file of definition.files) {
|
|
2384
|
-
const path = resolveSkillFile(folder, file.relativePath);
|
|
2385
|
-
const existing = await optionalRead(path);
|
|
2386
|
-
if (existing === file.content)
|
|
108
|
+
files.set(fileMatch[1], fileMatch[2]);
|
|
2387
109
|
continue;
|
|
2388
|
-
changed = true;
|
|
2389
|
-
const recordedHash = existingMarkerHashes.get(file.relativePath);
|
|
2390
|
-
const userEdited = existing !== null && (recordedHash ? sha256(existing) !== recordedHash : markerContent !== null);
|
|
2391
|
-
if (userEdited) {
|
|
2392
|
-
backupPaths.push(await writeBackup(path, existing));
|
|
2393
110
|
}
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
continue;
|
|
2398
|
-
const path = resolveSkillFile(folder, relativePath);
|
|
2399
|
-
const existing = await optionalRead(path);
|
|
2400
|
-
if (existing === null)
|
|
111
|
+
const topLevelHash = /^hash=sha256:([a-f0-9]{64})$/.exec(line);
|
|
112
|
+
if (topLevelHash?.[1] && !files.has("SKILL.md")) {
|
|
113
|
+
files.set("SKILL.md", topLevelHash[1]);
|
|
2401
114
|
continue;
|
|
2402
|
-
changed = true;
|
|
2403
|
-
if (sha256(existing) !== recordedHash) {
|
|
2404
|
-
backupPaths.push(await writeBackup(path, existing));
|
|
2405
115
|
}
|
|
2406
|
-
|
|
2407
|
-
}
|
|
2408
|
-
if (!
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
const
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
116
|
+
throw new Error(`marker contains an invalid line: '${line}'`);
|
|
117
|
+
}
|
|
118
|
+
if (!version)
|
|
119
|
+
throw new Error("marker has no version");
|
|
120
|
+
if (!files.has("SKILL.md"))
|
|
121
|
+
throw new Error("marker does not own SKILL.md");
|
|
122
|
+
return { version, files };
|
|
123
|
+
}
|
|
124
|
+
function assertSupportedLegacyVersion(version) {
|
|
125
|
+
const match = SEMVER_PATTERN.exec(version);
|
|
126
|
+
if (!match) {
|
|
127
|
+
throw new Error(`marker version '${version}' is not a valid semantic version`);
|
|
128
|
+
}
|
|
129
|
+
if (match[1] !== SUPPORTED_LEGACY_MAJOR) {
|
|
130
|
+
throw new Error(`marker version '${version}' is outside the supported legacy range >=4.0.0 <5.0.0`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function expectedDirectoryEntries(marker) {
|
|
134
|
+
const entries = new Map([
|
|
135
|
+
["", new Set([LEGACY_MARKER])]
|
|
136
|
+
]);
|
|
137
|
+
for (const relativePath of marker.files.keys()) {
|
|
138
|
+
const parts = relativePath.split("/");
|
|
139
|
+
let parent = "";
|
|
140
|
+
for (let index = 0;index < parts.length; index += 1) {
|
|
141
|
+
const part = parts[index];
|
|
142
|
+
if (!part)
|
|
143
|
+
throw new Error(`unsafe marker path '${relativePath}'`);
|
|
144
|
+
const children = entries.get(parent) ?? new Set;
|
|
145
|
+
children.add(part);
|
|
146
|
+
entries.set(parent, children);
|
|
147
|
+
if (index < parts.length - 1) {
|
|
148
|
+
parent = parent ? `${parent}/${part}` : part;
|
|
149
|
+
if (!entries.has(parent))
|
|
150
|
+
entries.set(parent, new Set);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
2420
153
|
}
|
|
2421
|
-
|
|
2422
|
-
return {
|
|
2423
|
-
name: definition.name,
|
|
2424
|
-
action: backupPaths.length > 0 ? "updated_with_backup" : managedSkillExists ? "updated" : "installed",
|
|
2425
|
-
...backupPaths.length > 0 ? { backupPaths } : {}
|
|
2426
|
-
};
|
|
2427
|
-
}
|
|
2428
|
-
function expectedSkillNames() {
|
|
2429
|
-
return FLOW_SKILL_DEFINITIONS.map((definition) => definition.name);
|
|
2430
|
-
}
|
|
2431
|
-
function formatFlowDoctorCommand(version) {
|
|
2432
|
-
const pin = version === "0.0.0" ? "latest" : version;
|
|
2433
|
-
return `npx -y opencode-plugin-flow@${pin} doctor`;
|
|
154
|
+
return entries;
|
|
2434
155
|
}
|
|
2435
|
-
function
|
|
2436
|
-
|
|
2437
|
-
|
|
156
|
+
async function inspectLegacyFolder(name, folder) {
|
|
157
|
+
const metadata = await optionalStat(folder);
|
|
158
|
+
if (!metadata)
|
|
159
|
+
return { name, path: folder, status: "absent" };
|
|
160
|
+
if (!metadata.isDirectory()) {
|
|
161
|
+
return {
|
|
162
|
+
name,
|
|
163
|
+
path: folder,
|
|
164
|
+
status: "refused",
|
|
165
|
+
reason: "path is not a real directory"
|
|
166
|
+
};
|
|
167
|
+
}
|
|
2438
168
|
try {
|
|
2439
|
-
const
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
const skills = await Promise.all(FLOW_SKILL_DEFINITIONS.map(async (definition) => {
|
|
2458
|
-
const folder = join(root, definition.name);
|
|
2459
|
-
const markerContent = await optionalRead(join(folder, MARKER_FILENAME));
|
|
2460
|
-
const markerVersion = parseMarkerVersion(markerContent);
|
|
2461
|
-
const markerHashes = parseMarkerFiles(markerContent);
|
|
2462
|
-
const existingSkill = await optionalRead(join(folder, "SKILL.md"));
|
|
2463
|
-
const backupFiles = markerContent === null ? [] : await listFlowBackupFiles(folder);
|
|
2464
|
-
if (existingSkill === null) {
|
|
2465
|
-
return {
|
|
2466
|
-
name: definition.name,
|
|
2467
|
-
path: folder,
|
|
2468
|
-
status: "missing",
|
|
2469
|
-
markerVersion,
|
|
2470
|
-
missingFiles: definition.files.map((file) => file.relativePath),
|
|
2471
|
-
editedFiles: [],
|
|
2472
|
-
outdatedFiles: [],
|
|
2473
|
-
backupFiles
|
|
2474
|
-
};
|
|
2475
|
-
}
|
|
2476
|
-
if (markerContent === null) {
|
|
2477
|
-
return {
|
|
2478
|
-
name: definition.name,
|
|
2479
|
-
path: folder,
|
|
2480
|
-
status: "foreign",
|
|
2481
|
-
markerVersion,
|
|
2482
|
-
missingFiles: [],
|
|
2483
|
-
editedFiles: [],
|
|
2484
|
-
outdatedFiles: [],
|
|
2485
|
-
backupFiles
|
|
2486
|
-
};
|
|
2487
|
-
}
|
|
2488
|
-
const missingFiles = [];
|
|
2489
|
-
const editedFiles = [];
|
|
2490
|
-
const outdatedFiles = [];
|
|
2491
|
-
for (const file of definition.files) {
|
|
2492
|
-
const existing = await optionalRead(resolveSkillFile(folder, file.relativePath));
|
|
2493
|
-
if (existing === null) {
|
|
2494
|
-
missingFiles.push(file.relativePath);
|
|
2495
|
-
continue;
|
|
169
|
+
const markerPath = join(folder, LEGACY_MARKER);
|
|
170
|
+
const marker = parseMarker(await readRegularFileWithoutFollowing(markerPath));
|
|
171
|
+
assertSupportedLegacyVersion(marker.version);
|
|
172
|
+
const directories = expectedDirectoryEntries(marker);
|
|
173
|
+
for (const [relativeDirectory, expectedEntries] of directories) {
|
|
174
|
+
const directory = relativeDirectory ? safeLegacyPath(folder, relativeDirectory) : folder;
|
|
175
|
+
const directoryMetadata = await optionalStat(directory);
|
|
176
|
+
if (!directoryMetadata?.isDirectory()) {
|
|
177
|
+
throw new Error(`expected real directory: ${relativeDirectory || "."}`);
|
|
178
|
+
}
|
|
179
|
+
const actualEntries = await readdir(directory);
|
|
180
|
+
const unexpected = actualEntries.filter((entry) => !expectedEntries.has(entry));
|
|
181
|
+
const missing = [...expectedEntries].filter((entry) => !actualEntries.includes(entry));
|
|
182
|
+
if (unexpected.length > 0 || missing.length > 0) {
|
|
183
|
+
throw new Error([
|
|
184
|
+
unexpected.length > 0 ? `unexpected entries: ${unexpected.join(", ")}` : "",
|
|
185
|
+
missing.length > 0 ? `missing entries: ${missing.join(", ")}` : ""
|
|
186
|
+
].filter(Boolean).join("; "));
|
|
2496
187
|
}
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
const
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
188
|
+
}
|
|
189
|
+
for (const [relativePath, expectedHash] of marker.files) {
|
|
190
|
+
const path = safeLegacyPath(folder, relativePath);
|
|
191
|
+
const content = await readRegularFileWithoutFollowing(path);
|
|
192
|
+
if (sha256(content) !== expectedHash) {
|
|
193
|
+
throw new Error(`edited file refused: ${relativePath}`);
|
|
2503
194
|
}
|
|
2504
|
-
outdatedFiles.push(file.relativePath);
|
|
2505
195
|
}
|
|
2506
|
-
const markerDrift = normalizeNewlines(markerContent) !== markerFor(definition, version);
|
|
2507
|
-
const status = missingFiles.length > 0 ? "incomplete" : editedFiles.length > 0 ? "edited" : markerDrift || outdatedFiles.length > 0 ? "outdated" : "ok";
|
|
2508
196
|
return {
|
|
2509
|
-
name
|
|
197
|
+
name,
|
|
2510
198
|
path: folder,
|
|
2511
|
-
status
|
|
2512
|
-
markerVersion,
|
|
2513
|
-
missingFiles,
|
|
2514
|
-
editedFiles,
|
|
2515
|
-
outdatedFiles,
|
|
2516
|
-
backupFiles
|
|
199
|
+
status: "eligible"
|
|
2517
200
|
};
|
|
2518
|
-
}));
|
|
2519
|
-
let entries = [];
|
|
2520
|
-
try {
|
|
2521
|
-
entries = await readdir(root);
|
|
2522
201
|
} catch (error) {
|
|
2523
|
-
|
|
2524
|
-
|
|
202
|
+
return {
|
|
203
|
+
name,
|
|
204
|
+
path: folder,
|
|
205
|
+
status: "refused",
|
|
206
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
207
|
+
};
|
|
2525
208
|
}
|
|
2526
|
-
const unmanagedFlowSkills = entries.filter((name) => (name === "flow" || name.startsWith("flow-")) && !expected.has(name)).map((name) => join(root, name));
|
|
2527
|
-
const syncRequiredSkills = skills.filter((skill) => ["missing", "incomplete", "outdated"].includes(skill.status)).map((skill) => skill.name);
|
|
2528
|
-
const actionRequiredSkills = skills.filter((skill) => ["foreign", "edited"].includes(skill.status) || skill.backupFiles.length > 0).map((skill) => skill.name);
|
|
2529
|
-
const actionRequired = actionRequiredSkills.length > 0;
|
|
2530
|
-
const syncRequired = syncRequiredSkills.length > 0;
|
|
2531
|
-
return {
|
|
2532
|
-
status: actionRequired ? "action_required" : syncRequired ? "sync_required" : "ok",
|
|
2533
|
-
version,
|
|
2534
|
-
root,
|
|
2535
|
-
expectedSkills: [...expected],
|
|
2536
|
-
skills,
|
|
2537
|
-
syncRequiredSkills,
|
|
2538
|
-
actionRequiredSkills,
|
|
2539
|
-
unmanagedFlowSkills
|
|
2540
|
-
};
|
|
2541
|
-
}
|
|
2542
|
-
function appendSkillList(lines, label, skills) {
|
|
2543
|
-
if (skills.length === 0)
|
|
2544
|
-
return;
|
|
2545
|
-
lines.push(`- ${label}: ${skills.join(", ")}`);
|
|
2546
209
|
}
|
|
2547
|
-
function
|
|
2548
|
-
const
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
`- skills root: ${report.root}`,
|
|
2553
|
-
`- expected skills: ${report.expectedSkills.join(", ")}`
|
|
2554
|
-
];
|
|
2555
|
-
appendSkillList(lines, "startup sync can install/update", report.syncRequiredSkills);
|
|
2556
|
-
appendSkillList(lines, "needs user decision", report.actionRequiredSkills);
|
|
2557
|
-
lines.push("", "Skills:");
|
|
2558
|
-
for (const skill of report.skills) {
|
|
2559
|
-
lines.push(`- ${skill.name}: ${skill.status} (${skill.path})${skill.markerVersion ? ` marker=${skill.markerVersion}` : ""}`);
|
|
2560
|
-
if (skill.missingFiles.length > 0) {
|
|
2561
|
-
lines.push(` missing: ${skill.missingFiles.join(", ")}`);
|
|
2562
|
-
}
|
|
2563
|
-
if (skill.editedFiles.length > 0) {
|
|
2564
|
-
lines.push(` edited: ${skill.editedFiles.join(", ")}`);
|
|
2565
|
-
}
|
|
2566
|
-
if (skill.outdatedFiles.length > 0) {
|
|
2567
|
-
lines.push(` outdated: ${skill.outdatedFiles.join(", ")}`);
|
|
2568
|
-
}
|
|
2569
|
-
if (skill.backupFiles.length > 0) {
|
|
2570
|
-
lines.push(` backups: ${skill.backupFiles.join(", ")}`);
|
|
2571
|
-
}
|
|
2572
|
-
}
|
|
2573
|
-
if (report.unmanagedFlowSkills.length > 0) {
|
|
2574
|
-
lines.push("", "Unmanaged Flow-like skill folders:");
|
|
2575
|
-
for (const path of report.unmanagedFlowSkills)
|
|
2576
|
-
lines.push(`- ${path}`);
|
|
2577
|
-
}
|
|
2578
|
-
lines.push("", "Recommendation:");
|
|
2579
|
-
if (report.status === "ok") {
|
|
2580
|
-
lines.push("- Flow skills are present and current.");
|
|
2581
|
-
} else if (report.status === "sync_required") {
|
|
2582
|
-
lines.push("- Start or restart OpenCode with opencode-plugin-flow enabled so startup sync can install or update the listed skills. If Flow then reports restart_required, restart OpenCode once more so the refreshed skill registry is used.");
|
|
2583
|
-
} else {
|
|
2584
|
-
lines.push("- Resolve user-owned or edited managed skill folders, then restart OpenCode. Move a folder aside to let Flow recreate it, or keep it intentionally as a local override.");
|
|
2585
|
-
if (report.skills.some((skill) => skill.backupFiles.length > 0)) {
|
|
2586
|
-
lines.push("- Flow saved earlier local edits as .backup files; review each one and delete it once the saved copy is no longer needed. Sync ignores them, and uninstall removes them (naming each) along with the folder.");
|
|
210
|
+
async function ensureRealArchiveRoot(path) {
|
|
211
|
+
const existing = await optionalStat(path);
|
|
212
|
+
if (existing) {
|
|
213
|
+
if (!existing.isDirectory()) {
|
|
214
|
+
throw new Error(`Legacy archive path is not a real directory: ${path}`);
|
|
2587
215
|
}
|
|
216
|
+
return;
|
|
2588
217
|
}
|
|
2589
|
-
lines.push(`- Details command: ${formatFlowDoctorCommand(report.version)}`);
|
|
2590
|
-
return `${lines.join(`
|
|
2591
|
-
`)}
|
|
2592
|
-
`;
|
|
2593
|
-
}
|
|
2594
|
-
async function listSkillFolderFiles(folder) {
|
|
2595
|
-
const entries = await readdir(folder, {
|
|
2596
|
-
recursive: true,
|
|
2597
|
-
withFileTypes: true
|
|
2598
|
-
});
|
|
2599
|
-
return entries.filter((entry) => entry.isFile()).map((entry) => join(entry.parentPath, entry.name).slice(folder.length + 1).split(sep).join("/"));
|
|
2600
|
-
}
|
|
2601
|
-
async function listFlowBackupFiles(folder) {
|
|
2602
|
-
let names;
|
|
2603
218
|
try {
|
|
2604
|
-
|
|
219
|
+
await mkdir(path, { mode: 448 });
|
|
2605
220
|
} catch (error) {
|
|
2606
|
-
if (error.code
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
if (await isFlowCreatedBackup(folder, name))
|
|
2613
|
-
backups.push(name);
|
|
221
|
+
if (error.code !== "EEXIST")
|
|
222
|
+
throw error;
|
|
223
|
+
const raced = await optionalStat(path);
|
|
224
|
+
if (!raced?.isDirectory()) {
|
|
225
|
+
throw new Error(`Legacy archive path is not a real directory: ${path}`);
|
|
226
|
+
}
|
|
2614
227
|
}
|
|
2615
|
-
return backups;
|
|
2616
228
|
}
|
|
2617
|
-
async function
|
|
2618
|
-
const
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
const
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
const
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
return { pristine: false, backups };
|
|
2630
|
-
}
|
|
2631
|
-
continue;
|
|
2632
|
-
}
|
|
2633
|
-
if (await isFlowCreatedBackup(folder, relativePath)) {
|
|
2634
|
-
backups.push(relativePath);
|
|
229
|
+
async function cleanupLegacySkills(options) {
|
|
230
|
+
const home = options?.home ?? configuredHome();
|
|
231
|
+
const root = resolveLegacySkillsRoot(home);
|
|
232
|
+
const archiveRoot = resolveLegacyArchiveRoot(home);
|
|
233
|
+
const apply = options?.apply === true;
|
|
234
|
+
const results = [];
|
|
235
|
+
let archiveReady = false;
|
|
236
|
+
for (const name of FLOW_GUIDANCE_TOPICS) {
|
|
237
|
+
const path = join(root, name);
|
|
238
|
+
const inspected = await inspectLegacyFolder(name, path);
|
|
239
|
+
if (!apply || inspected.status !== "eligible") {
|
|
240
|
+
results.push(inspected);
|
|
2635
241
|
continue;
|
|
2636
242
|
}
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
}
|
|
2641
|
-
async function uninstallFlowSkills(home = homeDir(), options = {}) {
|
|
2642
|
-
const root = resolveFlowSkillsRoot(home);
|
|
2643
|
-
const removed = [];
|
|
2644
|
-
const kept = [];
|
|
2645
|
-
const removedBackups = [];
|
|
2646
|
-
let entries;
|
|
2647
|
-
try {
|
|
2648
|
-
entries = await readdir(root);
|
|
2649
|
-
} catch (error) {
|
|
2650
|
-
if (error.code === "ENOENT") {
|
|
2651
|
-
return { removed, kept, removedBackups };
|
|
243
|
+
if (!archiveReady) {
|
|
244
|
+
await ensureRealArchiveRoot(archiveRoot);
|
|
245
|
+
archiveReady = true;
|
|
2652
246
|
}
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
247
|
+
const archivePath = join(archiveRoot, `${name}-${new Date().toISOString().replaceAll(":", "-")}-${crypto.randomUUID()}`);
|
|
248
|
+
try {
|
|
249
|
+
await rename(path, archivePath);
|
|
250
|
+
} catch (error) {
|
|
251
|
+
if (error.code !== "ENOENT")
|
|
252
|
+
throw error;
|
|
253
|
+
results.push({
|
|
254
|
+
name,
|
|
255
|
+
path,
|
|
256
|
+
status: "refused",
|
|
257
|
+
reason: "folder changed while cleanup was running"
|
|
258
|
+
});
|
|
2662
259
|
continue;
|
|
2663
260
|
}
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
261
|
+
await options?.afterQuarantine?.({ name, path, archivePath });
|
|
262
|
+
const verified = await inspectLegacyFolder(name, archivePath);
|
|
263
|
+
if (verified.status !== "eligible") {
|
|
264
|
+
results.push({
|
|
265
|
+
name,
|
|
266
|
+
path,
|
|
267
|
+
status: "quarantined",
|
|
268
|
+
reason: "folder changed while cleanup was running; preserved for manual recovery",
|
|
269
|
+
archivePath
|
|
270
|
+
});
|
|
2667
271
|
continue;
|
|
2668
272
|
}
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
}
|
|
2675
|
-
removed.push(folder);
|
|
273
|
+
results.push({
|
|
274
|
+
name,
|
|
275
|
+
path,
|
|
276
|
+
status: "archived",
|
|
277
|
+
archivePath
|
|
278
|
+
});
|
|
2676
279
|
}
|
|
2677
|
-
return {
|
|
280
|
+
return {
|
|
281
|
+
mode: apply ? "apply" : "dry-run",
|
|
282
|
+
root,
|
|
283
|
+
archiveRoot,
|
|
284
|
+
results
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// src/version.ts
|
|
289
|
+
import { createRequire } from "node:module";
|
|
290
|
+
function resolveFlowPluginVersion() {
|
|
291
|
+
try {
|
|
292
|
+
const require2 = createRequire(import.meta.url);
|
|
293
|
+
const manifest = require2("../package.json");
|
|
294
|
+
if (manifest.version)
|
|
295
|
+
return manifest.version;
|
|
296
|
+
} catch {}
|
|
297
|
+
return "0.0.0";
|
|
2678
298
|
}
|
|
2679
299
|
|
|
2680
300
|
// src/cli.ts
|
|
2681
301
|
function usage() {
|
|
2682
302
|
return [
|
|
2683
|
-
"usage: opencode-plugin-flow
|
|
303
|
+
"usage: opencode-plugin-flow legacy-cleanup <--dry-run|--apply> [--json]",
|
|
2684
304
|
"",
|
|
2685
305
|
"commands:",
|
|
2686
|
-
"
|
|
2687
|
-
" sync Install or refresh managed Flow skills",
|
|
2688
|
-
" uninstall Remove pristine Flow-owned managed skills",
|
|
2689
|
-
"",
|
|
2690
|
-
"doctor options:",
|
|
2691
|
-
" --json Write the doctor report as JSON",
|
|
2692
|
-
" --check, --strict Exit nonzero when doctor status is not ok",
|
|
306
|
+
" legacy-cleanup Inspect or archive marker-proven legacy global Flow skills",
|
|
2693
307
|
"",
|
|
2694
|
-
"
|
|
2695
|
-
" --dry-run
|
|
2696
|
-
"",
|
|
2697
|
-
"
|
|
308
|
+
"options:",
|
|
309
|
+
" --dry-run Report eligible folders without changing the filesystem",
|
|
310
|
+
" --apply Move eligible folders to a recoverable archive outside skill discovery",
|
|
311
|
+
" Cleanup never deletes legacy folders",
|
|
312
|
+
" --json Write the report as JSON",
|
|
2698
313
|
" --help Show this help",
|
|
2699
314
|
" --version Print the plugin version"
|
|
2700
315
|
].join(`
|
|
2701
316
|
`);
|
|
2702
317
|
}
|
|
2703
|
-
function
|
|
2704
|
-
|
|
2705
|
-
}
|
|
2706
|
-
function writeDoctorReport(report, options) {
|
|
2707
|
-
if (options.json) {
|
|
318
|
+
function writeReport(report, json) {
|
|
319
|
+
if (json) {
|
|
2708
320
|
process.stdout.write(`${JSON.stringify(report, null, 2)}
|
|
2709
321
|
`);
|
|
2710
322
|
return;
|
|
2711
323
|
}
|
|
2712
|
-
process.stdout.write(
|
|
324
|
+
process.stdout.write(`Flow legacy skill cleanup (${report.mode})
|
|
325
|
+
`);
|
|
326
|
+
process.stdout.write(`- legacy root: ${report.root}
|
|
327
|
+
`);
|
|
328
|
+
process.stdout.write(`- archive root: ${report.archiveRoot}
|
|
329
|
+
`);
|
|
330
|
+
for (const result of report.results) {
|
|
331
|
+
process.stdout.write(`- ${result.name}: ${result.status}
|
|
332
|
+
`);
|
|
333
|
+
if (result.reason)
|
|
334
|
+
process.stdout.write(` reason: ${result.reason}
|
|
335
|
+
`);
|
|
336
|
+
if (result.archivePath) {
|
|
337
|
+
const label = result.status === "archived" ? "archived" : "preserved";
|
|
338
|
+
process.stdout.write(` ${label} at: ${result.archivePath}
|
|
339
|
+
`);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
2713
342
|
}
|
|
2714
343
|
async function main(argv) {
|
|
2715
|
-
const command = argv
|
|
2716
|
-
const flags = argv.slice(3);
|
|
344
|
+
const [command, ...flags] = argv.slice(2);
|
|
2717
345
|
if (command === "--help" || command === "-h") {
|
|
2718
346
|
process.stdout.write(`${usage()}
|
|
2719
347
|
`);
|
|
@@ -2724,86 +352,21 @@ async function main(argv) {
|
|
|
2724
352
|
`);
|
|
2725
353
|
return;
|
|
2726
354
|
}
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
}
|
|
2733
|
-
if (command === "doctor") {
|
|
2734
|
-
const knownDoctorFlags = new Set(["--json", "--check", "--strict"]);
|
|
2735
|
-
if (!hasOnlyKnownFlags(flags, knownDoctorFlags)) {
|
|
2736
|
-
process.stderr.write(`${usage()}
|
|
2737
|
-
`);
|
|
2738
|
-
process.exitCode = 2;
|
|
2739
|
-
return;
|
|
2740
|
-
}
|
|
2741
|
-
const report = await inspectFlowSkillInstall();
|
|
2742
|
-
writeDoctorReport(report, { json: flags.includes("--json") });
|
|
2743
|
-
if ((report.status === "sync_required" || report.status === "action_required") && (flags.includes("--check") || flags.includes("--strict"))) {
|
|
2744
|
-
process.exitCode = 1;
|
|
2745
|
-
}
|
|
2746
|
-
return;
|
|
2747
|
-
}
|
|
2748
|
-
const knownUninstallFlags = new Set(["--dry-run"]);
|
|
2749
|
-
if (command === "uninstall" && !hasOnlyKnownFlags(flags, knownUninstallFlags)) {
|
|
2750
|
-
process.stderr.write(`${usage()}
|
|
2751
|
-
`);
|
|
2752
|
-
process.exitCode = 2;
|
|
2753
|
-
return;
|
|
2754
|
-
}
|
|
2755
|
-
if (command === "sync" && flags.length > 0) {
|
|
355
|
+
const knownFlags = new Set(["--dry-run", "--apply", "--json"]);
|
|
356
|
+
const validFlags = flags.every((flag) => knownFlags.has(flag));
|
|
357
|
+
const dryRun = flags.includes("--dry-run");
|
|
358
|
+
const apply = flags.includes("--apply");
|
|
359
|
+
if (command !== "legacy-cleanup" || !validFlags || dryRun === apply) {
|
|
2756
360
|
process.stderr.write(`${usage()}
|
|
2757
361
|
`);
|
|
2758
362
|
process.exitCode = 2;
|
|
2759
363
|
return;
|
|
2760
364
|
}
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
const actionRequired = results.filter((result2) => result2.action === "skipped_foreign");
|
|
2766
|
-
process.stdout.write(`Flow skill sync (${version})
|
|
2767
|
-
`);
|
|
2768
|
-
for (const result2 of results) {
|
|
2769
|
-
process.stdout.write(`- ${result2.name}: ${result2.action}
|
|
2770
|
-
`);
|
|
2771
|
-
for (const backupPath of result2.backupPaths ?? []) {
|
|
2772
|
-
process.stdout.write(` backup: ${backupPath}
|
|
2773
|
-
`);
|
|
2774
|
-
}
|
|
2775
|
-
}
|
|
2776
|
-
if (changed.length > 0) {
|
|
2777
|
-
process.stdout.write(`Restart OpenCode so the refreshed skill registry is used.
|
|
2778
|
-
`);
|
|
2779
|
-
}
|
|
2780
|
-
if (actionRequired.length > 0) {
|
|
2781
|
-
process.stdout.write(`Some managed skill folders are user-owned or edited; run doctor for repair guidance.
|
|
2782
|
-
`);
|
|
2783
|
-
}
|
|
2784
|
-
return;
|
|
2785
|
-
}
|
|
2786
|
-
const dryRun = flags.includes("--dry-run");
|
|
2787
|
-
const result = await uninstallFlowSkills(undefined, { dryRun });
|
|
2788
|
-
for (const path of result.removed) {
|
|
2789
|
-
process.stdout.write(`${dryRun ? "Would remove" : "Removed"} Flow skill: ${path}
|
|
2790
|
-
`);
|
|
2791
|
-
}
|
|
2792
|
-
for (const path of result.kept) {
|
|
2793
|
-
process.stdout.write(`Kept non-Flow or user-edited skill: ${path}
|
|
2794
|
-
`);
|
|
2795
|
-
}
|
|
2796
|
-
if (result.removedBackups.length > 0) {
|
|
2797
|
-
process.stdout.write(`${dryRun ? "Would remove" : "Removed"} Flow-created backup files holding your earlier edits:
|
|
2798
|
-
`);
|
|
2799
|
-
for (const path of result.removedBackups) {
|
|
2800
|
-
process.stdout.write(` ${path}
|
|
2801
|
-
`);
|
|
2802
|
-
}
|
|
365
|
+
const report = await cleanupLegacySkills({ apply });
|
|
366
|
+
writeReport(report, flags.includes("--json"));
|
|
367
|
+
if (apply && report.results.some((result) => ["refused", "quarantined"].includes(result.status))) {
|
|
368
|
+
process.exitCode = 1;
|
|
2803
369
|
}
|
|
2804
|
-
process.stdout.write(dryRun ? `Dry run: no files were removed.
|
|
2805
|
-
` : `Remove opencode-plugin-flow from your OpenCode plugin config and restart OpenCode.
|
|
2806
|
-
`);
|
|
2807
370
|
}
|
|
2808
371
|
main(process.argv).catch((error) => {
|
|
2809
372
|
process.stderr.write(`${error instanceof Error ? error.message : String(error)}
|
|
@@ -2811,4 +374,4 @@ main(process.argv).catch((error) => {
|
|
|
2811
374
|
process.exitCode = 1;
|
|
2812
375
|
});
|
|
2813
376
|
|
|
2814
|
-
//# debugId=
|
|
377
|
+
//# debugId=690F8C77CD4F802F64756E2164756E21
|