opencode-plugin-flow 4.1.18 → 4.2.1
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 +103 -23
- package/README.md +105 -162
- package/dist/cli.js +799 -233
- package/dist/cli.js.map +12 -0
- package/dist/config-shared.d.ts +1 -0
- package/dist/distribution/sync.d.ts +3 -1
- package/dist/index.js +2467 -451
- package/dist/index.js.map +11 -11
- package/dist/runtime/workspace.d.ts +11 -1
- package/package.json +8 -4
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// src/distribution/sync.ts
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
|
+
import { homedir } from "node:os";
|
|
8
|
+
import { dirname, join, normalize, sep } from "node:path";
|
|
9
|
+
|
|
10
|
+
// skills/flow/references/handoff-format.md
|
|
11
|
+
var handoff_format_default = `# Flow worker handoff contract
|
|
3
12
|
|
|
4
13
|
Flow managers merge only the worker's final response. Treat that response as the
|
|
5
14
|
worker report of record: it must include the assigned scope, what was actually
|
|
@@ -140,7 +149,10 @@ live-verified | test-verified | type-check-only | not-verified
|
|
|
140
149
|
|
|
141
150
|
The manager must inspect and validate any candidate patch before recording Flow
|
|
142
151
|
completion.
|
|
143
|
-
`;
|
|
152
|
+
`;
|
|
153
|
+
|
|
154
|
+
// skills/flow/references/parallel-orchestration.md
|
|
155
|
+
var parallel_orchestration_default = `# Parallel orchestration
|
|
144
156
|
|
|
145
157
|
Use fan-out when Flow work is broad enough that independent workers can gather
|
|
146
158
|
evidence faster than one linear pass. The manager still owns the Flow session:
|
|
@@ -155,10 +167,11 @@ Read these companion references before a broad parallel pass:
|
|
|
155
167
|
- \`parallel-pass-patterns.md\` for pass selection, effort defaults, and stop or
|
|
156
168
|
follow-up rules.
|
|
157
169
|
- \`handoff-format.md\` for the exact worker response shapes.
|
|
158
|
-
- \`verification-gates.md\` for coverage
|
|
159
|
-
triggers, and synthesis
|
|
170
|
+
- \`verification-gates.md\` for the pre-fan-out coverage gate, handoff
|
|
171
|
+
acceptance, verifier triggers, and the manager synthesis barrier. Those
|
|
172
|
+
definitions are canonical; this file only points at them.
|
|
160
173
|
- \`parallel-pass-example.md\` for a concrete end-to-end pass after the rules
|
|
161
|
-
below are clear.
|
|
174
|
+
below are clear (synced with the \`flow\` skill; not bundled into commands).
|
|
162
175
|
|
|
163
176
|
## Quick path
|
|
164
177
|
|
|
@@ -201,13 +214,9 @@ Skip fan-out when:
|
|
|
201
214
|
commands, or artifacts to identify real slices.
|
|
202
215
|
3. Define the local manager task. Do not delegate the immediate blocker that
|
|
203
216
|
determines whether fan-out is even valid.
|
|
204
|
-
4. Build
|
|
205
|
-
- total
|
|
206
|
-
|
|
207
|
-
- partition check showing slices add back to the total when the work is
|
|
208
|
-
countable.
|
|
209
|
-
- overlap/gap check showing no duplicate ownership, empty slices, or missing
|
|
210
|
-
target areas.
|
|
217
|
+
4. Build the pre-fan-out coverage gate defined in \`verification-gates.md\`
|
|
218
|
+
("Before fan-out"): total scope, one line per slice with expected count,
|
|
219
|
+
partition check, and overlap/gap check.
|
|
211
220
|
5. Spawn only named Flow workers. Use exact slices and the required handoff
|
|
212
221
|
shape. Keep each prompt self-contained.
|
|
213
222
|
6. Continue non-overlapping manager work while workers run.
|
|
@@ -217,10 +226,9 @@ Skip fan-out when:
|
|
|
217
226
|
claims to \`flow-verifier-worker\`.
|
|
218
227
|
9. Run follow-up passes only for material gaps, conflicts, narrowed scope, or
|
|
219
228
|
verification needs.
|
|
220
|
-
10. Apply the manager synthesis barrier
|
|
221
|
-
claims and synthesize one Flow artifact
|
|
222
|
-
|
|
223
|
-
paste worker handoffs as the user-facing result.
|
|
229
|
+
10. Apply the manager synthesis barrier from \`verification-gates.md\`: keep
|
|
230
|
+
only distilled, evidence-backed claims and synthesize one Flow artifact.
|
|
231
|
+
Do not paste worker handoffs as the user-facing result.
|
|
224
232
|
|
|
225
233
|
## Modes
|
|
226
234
|
|
|
@@ -304,9 +312,14 @@ Your exact slice: <paths, modules, command, claim ids, risk lens, or worktree>
|
|
|
304
312
|
Expected coverage: <count, paths, range, or complete question set>
|
|
305
313
|
Do: <bounded actions>
|
|
306
314
|
Do not: call state-changing Flow tools, edit .flow/**, own sibling slices, or make the final Flow verdict.
|
|
307
|
-
Return only the
|
|
315
|
+
Return only the Flow handoff in this exact shape:
|
|
316
|
+
<matching handoff template copied verbatim from handoff-format.md>
|
|
308
317
|
\`\`\`
|
|
309
318
|
|
|
319
|
+
Hidden workers cannot load skills or read \`handoff-format.md\` themselves. The
|
|
320
|
+
manager copies the matching handoff template into every worker prompt; a bare
|
|
321
|
+
filename reference is not enough.
|
|
322
|
+
|
|
310
323
|
For research or current-doc slices, require source checks for versioned or
|
|
311
324
|
time-sensitive facts. For implementation candidates, remind workers that other
|
|
312
325
|
work may be active and that they must not revert unrelated changes.
|
|
@@ -327,11 +340,8 @@ work may be active and that they must not revert unrelated changes.
|
|
|
327
340
|
any Flow completion call.
|
|
328
341
|
|
|
329
342
|
When worker results conflict, inspect the underlying artifact directly and rerun
|
|
330
|
-
the smallest check that can settle the disagreement.
|
|
331
|
-
|
|
332
|
-
The manager synthesis barrier means raw handoffs do not move forward by default.
|
|
333
|
-
Only claims that survived coverage, evidence, confidence, and verifier checks may
|
|
334
|
-
enter the next pass, Flow payload, patch decision, or user-facing answer.
|
|
343
|
+
the smallest check that can settle the disagreement. The manager synthesis
|
|
344
|
+
barrier in \`verification-gates.md\` applies before anything moves forward.
|
|
335
345
|
|
|
336
346
|
## Follow-up passes
|
|
337
347
|
|
|
@@ -345,74 +355,84 @@ Start a follow-up pass when first-pass handoffs reveal:
|
|
|
345
355
|
|
|
346
356
|
Do not recurse by default. If a worker says it needs another worker, the manager
|
|
347
357
|
decides whether that is a follow-up pass and writes the next bounded prompt.
|
|
348
|
-
`;
|
|
358
|
+
`;
|
|
359
|
+
|
|
360
|
+
// skills/flow/references/parallel-pass-example.md
|
|
361
|
+
var parallel_pass_example_default = `# Parallel pass example
|
|
349
362
|
|
|
350
363
|
Use this example after \`parallel-orchestration.md\` when a broad Flow task needs a
|
|
351
|
-
concrete pass shape.
|
|
364
|
+
concrete pass shape. The project below is illustrative; derive your own slices
|
|
365
|
+
from the actual repo during serial orientation.
|
|
352
366
|
|
|
353
|
-
Goal: review whether
|
|
354
|
-
|
|
367
|
+
Goal: review whether a web app's API error handling is consistent before
|
|
368
|
+
planning a refactor.
|
|
355
369
|
|
|
356
|
-
Serial orientation: the manager reads
|
|
357
|
-
|
|
358
|
-
|
|
370
|
+
Serial orientation: the manager reads the router entry point enough to identify
|
|
371
|
+
twelve API route modules, one shared error middleware, and an integration test
|
|
372
|
+
directory. The manager keeps the middleware local because it is one file and
|
|
373
|
+
anchors every other judgment.
|
|
359
374
|
|
|
360
|
-
Coverage gate:
|
|
375
|
+
Coverage gate: twelve countable route modules remain after the local check.
|
|
361
376
|
|
|
362
|
-
- Slice A:
|
|
363
|
-
- Slice B:
|
|
364
|
-
- Slice C: remaining
|
|
365
|
-
excluding the reviewer already covered by Slice B.
|
|
377
|
+
- Slice A: auth and account routes, expected 4/12.
|
|
378
|
+
- Slice B: billing and subscription routes, expected 3/12.
|
|
379
|
+
- Slice C: remaining content and admin routes, expected 5/12.
|
|
366
380
|
|
|
367
381
|
Worker prompts:
|
|
368
382
|
|
|
369
383
|
\`\`\`text
|
|
370
|
-
Overall goal, context only: confirm
|
|
384
|
+
Overall goal, context only: confirm API error handling is consistent.
|
|
371
385
|
Mode: evidence
|
|
372
|
-
Your exact slice:
|
|
373
|
-
Expected coverage:
|
|
374
|
-
Do: report
|
|
386
|
+
Your exact slice: the four auth and account route modules under src/routes/.
|
|
387
|
+
Expected coverage: 4/4 modules.
|
|
388
|
+
Do: report each route's error paths, status codes, and middleware usage with file:line evidence.
|
|
375
389
|
Do not: call state-changing Flow tools, edit .flow/**, own sibling slices, or make the final Flow verdict.
|
|
376
|
-
Return only the
|
|
390
|
+
Return only the Flow handoff in this exact shape:
|
|
391
|
+
<matching handoff template copied verbatim from handoff-format.md>
|
|
377
392
|
\`\`\`
|
|
378
393
|
|
|
379
394
|
\`\`\`text
|
|
380
|
-
Overall goal, context only: confirm
|
|
395
|
+
Overall goal, context only: confirm API error handling is consistent.
|
|
381
396
|
Mode: review
|
|
382
|
-
Your exact slice:
|
|
383
|
-
Expected coverage:
|
|
397
|
+
Your exact slice: the three billing and subscription route modules under src/routes/.
|
|
398
|
+
Expected coverage: 3/3 modules.
|
|
384
399
|
Do: separate blocking findings from advisory notes and cite file:line evidence.
|
|
385
400
|
Do not: call state-changing Flow tools, edit .flow/**, own sibling slices, or make the final Flow verdict.
|
|
386
|
-
Return only the
|
|
401
|
+
Return only the Flow handoff in this exact shape:
|
|
402
|
+
<matching handoff template copied verbatim from handoff-format.md>
|
|
387
403
|
\`\`\`
|
|
388
404
|
|
|
389
405
|
\`\`\`text
|
|
390
|
-
Overall goal, context only: confirm
|
|
406
|
+
Overall goal, context only: confirm API error handling is consistent.
|
|
391
407
|
Mode: audit
|
|
392
|
-
Your exact slice:
|
|
393
|
-
Expected coverage: 5/5
|
|
394
|
-
Do:
|
|
408
|
+
Your exact slice: the five content and admin route modules under src/routes/.
|
|
409
|
+
Expected coverage: 5/5 modules.
|
|
410
|
+
Do: check each claimed error path against the shared middleware contract and report divergences with evidence.
|
|
395
411
|
Do not: call state-changing Flow tools, edit .flow/**, own sibling slices, or make the final Flow verdict.
|
|
396
|
-
Return only the
|
|
412
|
+
Return only the Flow handoff in this exact shape:
|
|
413
|
+
<matching handoff template copied verbatim from handoff-format.md>
|
|
397
414
|
\`\`\`
|
|
398
415
|
|
|
399
416
|
Handoff checks: the manager accepts only reports with terminal status, matching
|
|
400
417
|
coverage counts, concrete file:line evidence, confidence tags, and claims inside
|
|
401
|
-
the assigned slice. A claim such as \`[high]
|
|
402
|
-
evidence: src/
|
|
403
|
-
A claim such as \`[high]
|
|
404
|
-
dropped or retasked.
|
|
418
|
+
the assigned slice. A claim such as \`[high] billing routes bypass the error
|
|
419
|
+
middleware; evidence: src/routes/billing.ts:88-104; corroboration: single
|
|
420
|
+
source\` is usable. A claim such as \`[high] error handling looks fine; evidence:
|
|
421
|
+
routes reviewed\` is dropped or retasked.
|
|
405
422
|
|
|
406
423
|
Verifier pass: the manager sends any single-source claim that will enter the
|
|
407
|
-
Flow payload to \`flow-verifier-worker\`, for example: \`C1:
|
|
408
|
-
|
|
409
|
-
|
|
424
|
+
Flow payload to \`flow-verifier-worker\`, for example: \`C1: billing and
|
|
425
|
+
subscription routes return raw exceptions while all other routes use the shared
|
|
426
|
+
error envelope; sources: src/routes/billing.ts, src/routes/subscription.ts\`.
|
|
410
427
|
|
|
411
|
-
Final synthesis: the manager re-reads the relevant
|
|
412
|
-
verified or clearly labeled claims, and records one artifact such as
|
|
413
|
-
decision, review payload, or docs patch. Raw handoffs and unverified
|
|
414
|
-
do not move into the next pass or user-facing answer.
|
|
415
|
-
`;
|
|
428
|
+
Final synthesis: the manager re-reads the relevant route and middleware lines,
|
|
429
|
+
keeps only verified or clearly labeled claims, and records one artifact such as
|
|
430
|
+
a plan decision, review payload, or docs patch. Raw handoffs and unverified
|
|
431
|
+
suggestions do not move into the next pass or user-facing answer.
|
|
432
|
+
`;
|
|
433
|
+
|
|
434
|
+
// skills/flow/references/parallel-pass-patterns.md
|
|
435
|
+
var parallel_pass_patterns_default = `# Parallel pass patterns
|
|
416
436
|
|
|
417
437
|
Flow uses parallel workers to reduce uncertainty, not to delegate decisions.
|
|
418
438
|
Each pass has a bounded purpose, an explicit coverage rule, and one
|
|
@@ -501,10 +521,15 @@ Start a bounded follow-up pass only when:
|
|
|
501
521
|
- a first pass exposes a narrower implementation or validation slice worth
|
|
502
522
|
isolating.
|
|
503
523
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
524
|
+
After every pass, the manager synthesis barrier from \`verification-gates.md\`
|
|
525
|
+
applies before any handoff content moves forward.
|
|
526
|
+
`;
|
|
527
|
+
|
|
528
|
+
// skills/flow/references/recovery-playbook.md
|
|
529
|
+
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- `Completion requires a passing featureReview`: run or request a real review and include a passing `featureReview` only when there are no blocking findings.\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';
|
|
530
|
+
|
|
531
|
+
// skills/flow/references/verification-gates.md
|
|
532
|
+
var verification_gates_default = `# Verification gates
|
|
508
533
|
|
|
509
534
|
Verification is how Flow keeps parallel work from turning into parallel
|
|
510
535
|
guesswork. Worker handoffs are candidate evidence; the manager decides what can
|
|
@@ -618,82 +643,13 @@ Before presenting or recording the result:
|
|
|
618
643
|
|
|
619
644
|
\`Status: success\` only says the worker believes its slice is done. The manager
|
|
620
645
|
still checks coverage and evidence before trusting the result.
|
|
621
|
-
`;
|
|
622
|
-
name: flow
|
|
623
|
-
description: Run the end-to-end Flow loop for skills-first OpenCode work. Use when a user asks for Flow-guided planning through implementation, resumable autonomous delivery, session status, or completion with validation and review gates.
|
|
624
|
-
---
|
|
625
|
-
|
|
626
|
-
# Flow
|
|
627
|
-
|
|
628
|
-
Use 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.
|
|
629
|
-
|
|
630
|
-
## Loop
|
|
631
|
-
|
|
632
|
-
1. Call \`flow_status\` first. Trust its active session and next action over conversation memory.
|
|
633
|
-
If the result includes \`setup.skills\`, report that setup status and do not
|
|
634
|
-
native-load Flow skills in this startup. Public bundled Flow commands may
|
|
635
|
-
continue with their embedded instructions, but a just-synced native skill can
|
|
636
|
-
be on disk while unavailable to the running OpenCode process.
|
|
637
|
-
2. 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.
|
|
638
|
-
3. 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.
|
|
639
|
-
4. Load \`flow-review\` for the required feature review. The reviewer reports a \`featureReview\` payload; the manager records it inside \`flow_feature_complete\`.
|
|
640
|
-
5. 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\`.
|
|
641
|
-
6. After all features are complete, archive the session with \`flow_session_close\` using \`kind: "completed"\`.
|
|
642
|
-
|
|
643
|
-
Use \`references/parallel-orchestration.md\` for broad read-only discovery, audit, validation, review, verification, or candidate implementation passes. Hidden Flow workers are injected by plugin config; invoke the named worker when it is available. Its \`references/parallel-pass-patterns.md\`, \`references/handoff-format.md\`, and \`references/verification-gates.md\` companions define pass selection, worker contracts, and claim acceptance. The manager owns every \`flow_*\` state change.
|
|
644
|
-
|
|
645
|
-
Do not commit, push, amend, rebase, publish, or mutate releases during the
|
|
646
|
-
autonomous Flow loop. Load \`flow-commit\` only when the user explicitly asks for
|
|
647
|
-
commit preparation or commit creation.
|
|
648
|
-
|
|
649
|
-
## Skill Availability
|
|
650
|
-
|
|
651
|
-
If \`flow_status\` returns \`setup.skills\`, report that setup status and stop
|
|
652
|
-
native-loading Flow skills in the current OpenCode startup. Missing, incomplete,
|
|
653
|
-
or outdated managed skills require a sync/restart cycle before their native skill
|
|
654
|
-
instructions can be trusted by the running process. Public command bundles are
|
|
655
|
-
self-contained and may continue when the command prompt already embeds the
|
|
656
|
-
required Flow instructions.
|
|
657
|
-
|
|
658
|
-
If optional helper skills such as \`flow-test\`, \`flow-deslop\`, or
|
|
659
|
-
\`flow-ui-quality\` are unavailable, continue only with explicit coverage gaps. Do
|
|
660
|
-
not copy their rubrics into another skill and do not claim their quality checks
|
|
661
|
-
were completed.
|
|
662
|
-
|
|
663
|
-
## Runtime Surface
|
|
664
|
-
|
|
665
|
-
- \`flow_status\`: read the active session.
|
|
666
|
-
- \`flow_plan_save\`: create a session and/or save a draft plan.
|
|
667
|
-
- \`flow_plan_approve\`: lock the draft plan.
|
|
668
|
-
- \`flow_run_start\`: start one runnable feature.
|
|
669
|
-
- \`flow_feature_complete\`: record completion or a real blocker with validation and review evidence.
|
|
670
|
-
- \`flow_feature_reset\`: reset one feature and its dependents.
|
|
671
|
-
- \`flow_session_close\`: archive the active session as \`completed\`, \`deferred\`, or \`abandoned\`.
|
|
646
|
+
`;
|
|
672
647
|
|
|
673
|
-
|
|
648
|
+
// skills/flow/SKILL.md
|
|
649
|
+
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.\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. The reviewer reports a `featureReview` payload; the manager records it inside `flow_feature_complete`.\n5. On the final feature, run broad validation and include `finalReview` in the same `flow_feature_complete` call. Its `reviewDepth` must match the plan's `finalReviewPolicy`.\n6. After all features are complete, archive the session with `flow_session_close` using `kind: \"completed\"`.\n\nUse `references/parallel-orchestration.md` for broad read-only discovery, audit, validation, review, verification, or candidate implementation passes. Hidden Flow workers are injected by plugin config; invoke the named worker when it is available. Its `references/parallel-pass-patterns.md`, `references/handoff-format.md`, and `references/verification-gates.md` companions define pass selection, worker contracts, and claim acceptance. The manager owns every `flow_*` state change.\n\nDo not commit, push, amend, rebase, publish, or mutate releases during the\nautonomous Flow loop. Load `flow-commit` only when the user explicitly asks for\ncommit preparation or commit creation.\n\n## Skill Availability\n\nIf `flow_status` returns `setup.skills`, report that setup status and stop\nnative-loading Flow skills in the current OpenCode startup. Missing, incomplete,\nor outdated managed skills require a sync/restart cycle before their native skill\ninstructions can be trusted by the running process. Public command bundles are\nself-contained and may continue when the command prompt already embeds the\nrequired Flow instructions.\n\nIf optional helper skills such as `flow-test`, `flow-deslop`, or\n`flow-ui-quality` are unavailable, continue only with explicit coverage gaps. Do\nnot copy their rubrics into another skill and do not claim their quality checks\nwere completed.\n\n## Runtime Surface\n\n- `flow_status`: read the active session.\n- `flow_plan_save`: create a session and/or save a draft plan.\n- `flow_plan_approve`: lock the draft plan.\n- `flow_run_start`: start one runnable feature.\n- `flow_feature_complete`: record completion or a real blocker with validation and review evidence.\n- `flow_feature_reset`: reset one feature and its dependents.\n- `flow_session_close`: archive the active session as `completed`, `deferred`, or `abandoned`.\n\nThere is no `flow_context`, no separate review-record tool, and no multi-session activation surface. The single active source of truth is `.flow/session.json`; closed sessions are archived under `.flow/history/`.\n\nPlanning and running require loaded Flow tools; do not simulate plan approval or feature completion when the runtime is unavailable. Review may still return advisory output when tools, skills, or references are stale or unavailable, but the manager must not record it as Flow-gated evidence.\n\n## Hard Gates\n\n- Approved plans are immutable. To change direction, reset affected features or close the session and start a new goal.\n- Only one feature can be active at a time.\n- 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- `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";
|
|
674
650
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
## Hard Gates
|
|
678
|
-
|
|
679
|
-
- Approved plans are immutable. To change direction, reset affected features or close the session and start a new goal.
|
|
680
|
-
- Only one feature can be active at a time.
|
|
681
|
-
- Completion requires at least one passing \`validationRun\` entry.
|
|
682
|
-
- Non-final completion requires \`validationScope: "targeted"\`.
|
|
683
|
-
- Final completion requires \`validationScope: "broad"\` and a passing \`finalReview\`.
|
|
684
|
-
- Every completed feature requires a passing \`featureReview\` with no blocking findings.
|
|
685
|
-
- \`flow_session_close\` accepts \`kind: "completed"\` only after an approved plan has passed final completion.
|
|
686
|
-
|
|
687
|
-
## Recovery
|
|
688
|
-
|
|
689
|
-
- Confused state: call \`flow_status\` and follow \`nextAction\`.
|
|
690
|
-
- Wrong assumption or failed implementation path: use \`flow_feature_reset\` for the feature and dependents, then rerun from the corrected plan.
|
|
691
|
-
- Missing validation or review evidence: gather real evidence, then call \`flow_feature_complete\`.
|
|
692
|
-
- 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.
|
|
693
|
-
- Unknown runtime error: read \`summary\` and \`recovery\`; see \`references/recovery-playbook.md\` for common cases.
|
|
694
|
-
|
|
695
|
-
Never fabricate validation output, backfill review approval you did not perform, or close as \`deferred\`/\`abandoned\` merely to avoid an unfinished-work blocker.
|
|
696
|
-
`;var N=`---
|
|
651
|
+
// skills/flow-commit/SKILL.md
|
|
652
|
+
var SKILL_default2 = `---
|
|
697
653
|
name: flow-commit
|
|
698
654
|
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.
|
|
699
655
|
---
|
|
@@ -765,18 +721,12 @@ Before commit creation, check the staged diff for:
|
|
|
765
721
|
- Generated artifacts that are not normally versioned.
|
|
766
722
|
- Package or version metadata drift unrelated to the requested change.
|
|
767
723
|
|
|
768
|
-
|
|
769
|
-
or
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
Run it after staging and rerun it after any staging change. Commit mode validates
|
|
776
|
-
the staged boundary for diff hygiene, staged review, and staged secret screening;
|
|
777
|
-
it does not run a whole-worktree gate, choose commit boundaries, or write commit
|
|
778
|
-
messages. If the script is absent, use the repository's documented commit
|
|
779
|
-
preflight from package scripts, AGENTS/docs, or CI guidance.
|
|
724
|
+
If the repository documents its own commit preflight (a package script, a
|
|
725
|
+
repo-local preflight script, or guidance in AGENTS/docs or CI config), defer to
|
|
726
|
+
it for staged validation instead of duplicating its checks. Run it after
|
|
727
|
+
staging and rerun it after any staging change. A staged-boundary preflight
|
|
728
|
+
validates diff hygiene and staged secret screening; it does not run a
|
|
729
|
+
whole-worktree gate, choose commit boundaries, or write commit messages.
|
|
780
730
|
|
|
781
731
|
Use the repository's documented broad validation gate when a full local check is
|
|
782
732
|
appropriate, such as package scripts, AGENTS/docs, or CI guidance. Treat broad
|
|
@@ -809,7 +759,10 @@ Before running \`git commit\`, report:
|
|
|
809
759
|
|
|
810
760
|
After a successful commit, report the commit hash and leave push or release
|
|
811
761
|
actions for a separate explicit request.
|
|
812
|
-
`;
|
|
762
|
+
`;
|
|
763
|
+
|
|
764
|
+
// skills/flow-deslop/references/refactor-workflow.md
|
|
765
|
+
var refactor_workflow_default = `# Safe refactor workflow
|
|
813
766
|
|
|
814
767
|
Refactoring is a behavior-preserving sequence of small changes. This workflow keeps cleanup from becoming an unreviewable rewrite.
|
|
815
768
|
|
|
@@ -851,7 +804,10 @@ Weak evidence includes:
|
|
|
851
804
|
- Public contracts and compatibility shims remain intact or were explicitly planned.
|
|
852
805
|
- Deleted code is actually unreachable or obsolete.
|
|
853
806
|
- Validation can catch a realistic mistake in the refactor.
|
|
854
|
-
`;
|
|
807
|
+
`;
|
|
808
|
+
|
|
809
|
+
// skills/flow-deslop/references/smell-rubric.md
|
|
810
|
+
var smell_rubric_default = `# Deslop smell rubric
|
|
855
811
|
|
|
856
812
|
Use this rubric to turn vague cleanup instincts into reviewable findings.
|
|
857
813
|
|
|
@@ -885,15 +841,20 @@ class; severity; location; evidence read; refutation checked; why it matters; sa
|
|
|
885
841
|
\`\`\`
|
|
886
842
|
|
|
887
843
|
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.
|
|
888
|
-
`;
|
|
844
|
+
`;
|
|
845
|
+
|
|
846
|
+
// skills/flow-deslop/SKILL.md
|
|
847
|
+
var SKILL_default3 = `---
|
|
889
848
|
name: flow-deslop
|
|
890
|
-
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, dead code,
|
|
849
|
+
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.
|
|
891
850
|
---
|
|
892
851
|
|
|
893
852
|
# Flow deslop
|
|
894
853
|
|
|
895
854
|
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.
|
|
896
855
|
|
|
856
|
+
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\`.
|
|
857
|
+
|
|
897
858
|
## Ground the cleanup
|
|
898
859
|
|
|
899
860
|
- 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.
|
|
@@ -927,7 +888,10 @@ For each claimed smell removal, verify:
|
|
|
927
888
|
- **blast radius** — public contracts and downstream callers still work.
|
|
928
889
|
|
|
929
890
|
Never approve cleanup because it "looks cleaner" without evidence. Tests passing is necessary but not sufficient when the refactor changes structure across files.
|
|
930
|
-
`;
|
|
891
|
+
`;
|
|
892
|
+
|
|
893
|
+
// skills/flow-plan/references/parallel-discovery.md
|
|
894
|
+
var parallel_discovery_default = `# Parallel discovery
|
|
931
895
|
|
|
932
896
|
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.
|
|
933
897
|
|
|
@@ -943,26 +907,17 @@ Use its pre-fan-out coverage gate and
|
|
|
943
907
|
- Risk lenses such as security, persistence, accessibility, migration, or performance.
|
|
944
908
|
- Documentation and operator-contract checks.
|
|
945
909
|
|
|
946
|
-
##
|
|
947
|
-
|
|
948
|
-
For this repository, good first-pass slices are:
|
|
910
|
+
## Deriving first-pass slices
|
|
949
911
|
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
- OpenCode adapter surface: \`src/adapters/opencode/**\`, \`src/config-shared.ts\`,
|
|
956
|
-
\`src/config.ts\`, \`src/index.ts\`, and surface tests.
|
|
957
|
-
- Distribution and synced skills: \`src/distribution/**\`, \`src/cli.ts\`,
|
|
958
|
-
\`skills/**\`, and distribution tests.
|
|
959
|
-
- CI, package, and release contract: \`.github/workflows/**\`, \`package.json\`,
|
|
960
|
-
\`bun.lock\`, \`README.md\`, and \`CHANGELOG.md\`.
|
|
961
|
-
- Docs and operator contract: \`docs/**\`, \`README.md\`, and skill references.
|
|
912
|
+
Derive slices from the repo shape found during the serial orientation pass:
|
|
913
|
+
top-level packages or source directories, the test tree, CI and release
|
|
914
|
+
config, and docs. Name each slice by the paths it owns, for example "runtime:
|
|
915
|
+
\`src/core/**\` plus its tests" or "release contract: CI workflows,
|
|
916
|
+
\`package.json\`, and the changelog".
|
|
962
917
|
|
|
963
|
-
Treat
|
|
964
|
-
choose the relevant entries and de-overlap shared docs,
|
|
965
|
-
surfaces in the coverage gate.
|
|
918
|
+
Treat derived slices as starting points, not a simultaneous coverage map.
|
|
919
|
+
Before fan-out, choose the relevant entries and de-overlap shared docs,
|
|
920
|
+
config, or release surfaces in the coverage gate.
|
|
966
921
|
|
|
967
922
|
## Coverage gate
|
|
968
923
|
|
|
@@ -975,8 +930,8 @@ state the completeness rule, such as "all changed files plus callers."
|
|
|
975
930
|
|
|
976
931
|
\`\`\`text
|
|
977
932
|
Inspect <slice> for <goal>. Read-only. Do not edit files or call
|
|
978
|
-
state-changing Flow tools. Return the
|
|
979
|
-
|
|
933
|
+
state-changing Flow tools. Return only the Flow handoff in this exact shape:
|
|
934
|
+
<matching handoff template copied verbatim from handoff-format.md>
|
|
980
935
|
\`\`\`
|
|
981
936
|
|
|
982
937
|
For validation-oriented discovery:
|
|
@@ -984,11 +939,14 @@ For validation-oriented discovery:
|
|
|
984
939
|
\`\`\`text
|
|
985
940
|
Inspect <slice> for validation risk. Read-only. Do not edit files or call
|
|
986
941
|
state-changing Flow tools. You may report commands that should be run, and
|
|
987
|
-
include raw output only for commands you actually ran. Return the
|
|
988
|
-
|
|
989
|
-
|
|
942
|
+
include raw output only for commands you actually ran. Return only the Flow
|
|
943
|
+
handoff in this exact shape:
|
|
944
|
+
<matching handoff template copied verbatim from handoff-format.md>
|
|
990
945
|
\`\`\`
|
|
991
946
|
|
|
947
|
+
Workers cannot read reference files themselves; paste the matching handoff
|
|
948
|
+
template from \`../../flow/references/handoff-format.md\` into the prompt.
|
|
949
|
+
|
|
992
950
|
## Synthesis
|
|
993
951
|
|
|
994
952
|
Convert only evidence-backed work into plan fields:
|
|
@@ -1003,7 +961,10 @@ If workers disagree, inspect the source artifact yourself. If a candidate findin
|
|
|
1003
961
|
Apply the manager synthesis barrier from
|
|
1004
962
|
\`../../flow/references/verification-gates.md\`: only distilled, evidence-backed
|
|
1005
963
|
claims become plan fields.
|
|
1006
|
-
`;
|
|
964
|
+
`;
|
|
965
|
+
|
|
966
|
+
// skills/flow-plan/references/planning-examples.md
|
|
967
|
+
var planning_examples_default = `# Planning examples
|
|
1007
968
|
|
|
1008
969
|
## Rate limiting feature set
|
|
1009
970
|
|
|
@@ -1088,7 +1049,10 @@ Better plan:
|
|
|
1088
1049
|
- Validation that only says "manual testing".
|
|
1089
1050
|
- Targets that name the entire repo.
|
|
1090
1051
|
- Features with hidden dependencies instead of \`dependsOn\`.
|
|
1091
|
-
`;
|
|
1052
|
+
`;
|
|
1053
|
+
|
|
1054
|
+
// skills/flow-plan/SKILL.md
|
|
1055
|
+
var SKILL_default4 = `---
|
|
1092
1056
|
name: flow-plan
|
|
1093
1057
|
description: "Plan Flow work for the v4 skills-first runtime: inspect the repo, decompose a user goal into right-sized features, save a draft with flow_plan_save, and approve it with flow_plan_approve."
|
|
1094
1058
|
---
|
|
@@ -1103,14 +1067,13 @@ If \`flow_plan_save\` or \`flow_plan_approve\` is unavailable, stop and tell the
|
|
|
1103
1067
|
|
|
1104
1068
|
- Read the files, docs, tests, package scripts, and local conventions that determine the work.
|
|
1105
1069
|
- For broad discovery, read \`references/parallel-discovery.md\` after a serial orientation pass. Use \`../flow/references/parallel-orchestration.md\` when discovery needs multiple workers, and apply its coverage gate before fan-out.
|
|
1070
|
+
- Helper rule: when a named helper skill is unavailable, record a planning gap
|
|
1071
|
+
and keep the corresponding claims conservative instead of simulating its
|
|
1072
|
+
checks.
|
|
1106
1073
|
- For complex validation, regression-sensitive changes, browser QA, route QA,
|
|
1107
|
-
failure-prone checks, or uncertain test strategy, load \`flow-test\`.
|
|
1108
|
-
|
|
1109
|
-
- For
|
|
1110
|
-
a planning gap and keep cleanup claims conservative.
|
|
1111
|
-
- For UI/frontend goals, load \`flow-ui-quality\`. If it is unavailable, record a
|
|
1112
|
-
planning gap and require next-best UI evidence rather than claiming visual
|
|
1113
|
-
quality was reviewed.
|
|
1074
|
+
failure-prone checks, or uncertain test strategy, load \`flow-test\`.
|
|
1075
|
+
- For cleanup/refactor goals, load \`flow-deslop\`.
|
|
1076
|
+
- For UI/frontend goals, load \`flow-ui-quality\`.
|
|
1114
1077
|
- Do not invent findings. Broad "review and fix" goals start with a review-first feature whose deliverable is evidence-backed findings.
|
|
1115
1078
|
|
|
1116
1079
|
## Plan shape
|
|
@@ -1158,7 +1121,10 @@ Use only \`finalReviewPolicy: "broad"\` or \`"detailed"\`. These are the canonic
|
|
|
1158
1121
|
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.
|
|
1159
1122
|
|
|
1160
1123
|
See \`references/planning-examples.md\` for payload examples and decomposition anti-patterns.
|
|
1161
|
-
`;
|
|
1124
|
+
`;
|
|
1125
|
+
|
|
1126
|
+
// skills/flow-review/references/review-rubric.md
|
|
1127
|
+
var review_rubric_default = `# Review rubric
|
|
1162
1128
|
|
|
1163
1129
|
Use this to decide whether a \`featureReview\` or \`finalReview\` payload may pass.
|
|
1164
1130
|
|
|
@@ -1246,7 +1212,10 @@ When reviewing a findings report, verify findings adversarially:
|
|
|
1246
1212
|
- Downgrade or reject findings that do not survive refutation.
|
|
1247
1213
|
|
|
1248
1214
|
Approve only on evidence actually inspected. A review is a claim of coverage, not a courtesy stamp.
|
|
1249
|
-
`;
|
|
1215
|
+
`;
|
|
1216
|
+
|
|
1217
|
+
// skills/flow-review/SKILL.md
|
|
1218
|
+
var SKILL_default5 = `---
|
|
1250
1219
|
name: flow-review
|
|
1251
1220
|
description: "Review Flow work in the v4 runtime: inspect feature or final-session changes, classify findings, and return featureReview or finalReview payloads for flow_feature_complete."
|
|
1252
1221
|
---
|
|
@@ -1259,15 +1228,30 @@ If Flow tools, required Flow skills, or required references are unavailable or
|
|
|
1259
1228
|
stale, perform an advisory review and say that no Flow-gated review payload was
|
|
1260
1229
|
recorded.
|
|
1261
1230
|
|
|
1231
|
+
## Execution contexts
|
|
1232
|
+
|
|
1233
|
+
These instructions run in two contexts, and only one of them can load helpers:
|
|
1234
|
+
|
|
1235
|
+
- **Manager context**: the manager reviews inside the Flow loop (the \`flow\` or
|
|
1236
|
+
\`flow-run\` skills, or a bundled public Flow command) before recording
|
|
1237
|
+
evidence. The manager may load helper skills and fan out read-only workers.
|
|
1238
|
+
- **Hidden reviewer context**: \`/flow-review\` runs as the \`flow-reviewer\`
|
|
1239
|
+
subagent, whose permissions deny skill loading, shell commands, and
|
|
1240
|
+
subagents. In this context, skip every "load" and "fan out" instruction
|
|
1241
|
+
below: judge from the diff, the plan fields, and the recorded validation
|
|
1242
|
+
evidence, and record a coverage gap for any judgment that would have needed
|
|
1243
|
+
a helper skill or a command run.
|
|
1244
|
+
|
|
1262
1245
|
## Start
|
|
1263
1246
|
|
|
1264
1247
|
- Call \`flow_status\` when available.
|
|
1265
1248
|
- Identify whether this is a feature review or final review.
|
|
1266
1249
|
- Read the approved plan fields relevant to the work: \`requirements\`, \`decisions\`, feature \`targets\`, feature \`validation\`, and dependencies.
|
|
1267
1250
|
- Inspect the actual diff, changed files, tests, and validation output. Do not review only the completion summary.
|
|
1268
|
-
-
|
|
1269
|
-
unclear coverage reviews. If it is
|
|
1270
|
-
|
|
1251
|
+
- In manager context, load \`flow-test\` for validation-heavy,
|
|
1252
|
+
regression-sensitive, browser QA, or unclear coverage reviews. If it is
|
|
1253
|
+
unavailable or you are the hidden reviewer, record a coverage gap and treat
|
|
1254
|
+
missing validation evidence as a gap or blocker based on user impact.
|
|
1271
1255
|
- Load \`references/review-rubric.md\` for severity, depth, and payload shape.
|
|
1272
1256
|
|
|
1273
1257
|
## Feature Review Depth
|
|
@@ -1305,18 +1289,23 @@ Use \`status: "failed"\` when any blocking finding remains. Advisory findings ma
|
|
|
1305
1289
|
|
|
1306
1290
|
## Special cases
|
|
1307
1291
|
|
|
1308
|
-
- Cleanup/refactor: load \`flow-deslop\`; verify the smell was real, refutation paths were checked, and behavior was preserved. If unavailable, record a coverage gap instead of approving cleanup claims.
|
|
1309
|
-
- UI/frontend: load \`flow-ui-quality\`; verify state coverage and visual evidence when a local target was available. If unavailable, record a coverage gap and do not claim visual polish was verified.
|
|
1292
|
+
- 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.
|
|
1293
|
+
- 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.
|
|
1310
1294
|
- Audit reports: use \`../flow-run/references/audit-rubric.md\`; findings must survive refutation before they can drive fix features.
|
|
1311
|
-
- Large reviews: use
|
|
1312
|
-
read-only slices by
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
verification gates; only the manager
|
|
1316
|
-
\`finalReview\` payload.
|
|
1295
|
+
- Large reviews (manager context only): use
|
|
1296
|
+
\`../flow/references/parallel-orchestration.md\` for read-only slices by
|
|
1297
|
+
changed-file group, risk lens, or validation surface. Use the named review,
|
|
1298
|
+
audit, evidence, or validation agents from that reference instead of generic
|
|
1299
|
+
subagents. Apply its handoff format and verification gates; only the manager
|
|
1300
|
+
returns the final \`featureReview\` or \`finalReview\` payload. The hidden
|
|
1301
|
+
reviewer cannot spawn workers; it reviews its assigned scope directly and
|
|
1302
|
+
reports coverage gaps for the rest.
|
|
1317
1303
|
|
|
1318
1304
|
Never approve to unblock completion, fix findings in the review pass, or vouch for validation you did not inspect.
|
|
1319
|
-
`;
|
|
1305
|
+
`;
|
|
1306
|
+
|
|
1307
|
+
// skills/flow-run/references/audit-rubric.md
|
|
1308
|
+
var audit_rubric_default = `# Audit findings rubric
|
|
1320
1309
|
|
|
1321
1310
|
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.
|
|
1322
1311
|
|
|
@@ -1369,7 +1358,10 @@ follow-up order — correctness and persisted/user-input surfaces first
|
|
|
1369
1358
|
\`\`\`
|
|
1370
1359
|
|
|
1371
1360
|
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.
|
|
1372
|
-
`;
|
|
1361
|
+
`;
|
|
1362
|
+
|
|
1363
|
+
// skills/flow-run/references/validation-rubric.md
|
|
1364
|
+
var validation_rubric_default = `# Validation evidence rubric
|
|
1373
1365
|
|
|
1374
1366
|
Use this before recording \`flow_feature_complete\`.
|
|
1375
1367
|
|
|
@@ -1426,7 +1418,10 @@ Broad validation usually means the repo's full check command, full relevant test
|
|
|
1426
1418
|
- If validation needs external access, missing credentials, or ambiguous user input, record \`status: "needs_input"\` with an honest \`outcome\`.
|
|
1427
1419
|
|
|
1428
1420
|
Never trim failing output, relabel a failed command as passed, or use "not run" as completion evidence.
|
|
1429
|
-
`;
|
|
1421
|
+
`;
|
|
1422
|
+
|
|
1423
|
+
// skills/flow-run/SKILL.md
|
|
1424
|
+
var SKILL_default6 = `---
|
|
1430
1425
|
name: flow-run
|
|
1431
1426
|
description: "Execute one approved Flow feature in the v4 runtime: start a feature with flow_run_start, make scoped changes, gather real validation evidence, obtain review payloads, and complete with flow_feature_complete."
|
|
1432
1427
|
---
|
|
@@ -1442,9 +1437,10 @@ If \`flow_run_start\` is unavailable, stop and tell the user to check that \`ope
|
|
|
1442
1437
|
- Call \`flow_status\`.
|
|
1443
1438
|
- Call \`flow_run_start\` with no \`featureId\` unless the user or plan requires a specific runnable feature.
|
|
1444
1439
|
- Treat the returned feature as the sole scope until it is completed, blocked, or reset.
|
|
1445
|
-
-
|
|
1446
|
-
|
|
1447
|
-
- Load \`flow-
|
|
1440
|
+
- Helper rule: when a named helper skill is unavailable, record the gap and
|
|
1441
|
+
keep the corresponding claims conservative instead of simulating its checks.
|
|
1442
|
+
- Load \`flow-deslop\` for cleanup/refactor features.
|
|
1443
|
+
- Load \`flow-ui-quality\` for frontend, UX, responsive, accessibility, or visual work.
|
|
1448
1444
|
|
|
1449
1445
|
## Implement
|
|
1450
1446
|
|
|
@@ -1462,8 +1458,7 @@ If \`flow_run_start\` is unavailable, stop and tell the user to check that \`ope
|
|
|
1462
1458
|
|
|
1463
1459
|
- For complex validation, regression-sensitive changes, browser QA, route QA,
|
|
1464
1460
|
failure-prone checks, unclear coverage, exploratory QA, or
|
|
1465
|
-
\`validationRun\` summarization, load \`flow-test
|
|
1466
|
-
the coverage gap and keep validation claims conservative.
|
|
1461
|
+
\`validationRun\` summarization, load \`flow-test\` (helper rule applies).
|
|
1467
1462
|
- Read \`references/validation-rubric.md\` before completing.
|
|
1468
1463
|
- Run the strongest practical checks for the changed behavior.
|
|
1469
1464
|
- Record concrete command names, status, and observed results. "Tests pass" is not evidence.
|
|
@@ -1513,9 +1508,12 @@ Complete with:
|
|
|
1513
1508
|
\`\`\`
|
|
1514
1509
|
|
|
1515
1510
|
If genuinely blocked, call \`flow_feature_complete\` with \`status: "needs_input"\` and an \`outcome\` that explains the blocker and next step. Never fabricate validation or review evidence to force progress.
|
|
1516
|
-
`;
|
|
1511
|
+
`;
|
|
1512
|
+
|
|
1513
|
+
// skills/flow-test/SKILL.md
|
|
1514
|
+
var SKILL_default7 = `---
|
|
1517
1515
|
name: flow-test
|
|
1518
|
-
description:
|
|
1516
|
+
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.
|
|
1519
1517
|
---
|
|
1520
1518
|
|
|
1521
1519
|
# Flow Test
|
|
@@ -1637,7 +1635,10 @@ covered. Static inspection alone is a gap for behavioral changes.
|
|
|
1637
1635
|
|
|
1638
1636
|
Never relabel a failed command as passed, invent output, or use "not run" as
|
|
1639
1637
|
completion evidence.
|
|
1640
|
-
`;
|
|
1638
|
+
`;
|
|
1639
|
+
|
|
1640
|
+
// skills/flow-ui-quality/references/ui-rubric.md
|
|
1641
|
+
var ui_rubric_default = `# UI quality rubric
|
|
1641
1642
|
|
|
1642
1643
|
Use this rubric for frontend planning, implementation, and review.
|
|
1643
1644
|
|
|
@@ -1681,7 +1682,10 @@ class; severity; location or screenshot area; evidence inspected; user impact; f
|
|
|
1681
1682
|
\`\`\`
|
|
1682
1683
|
|
|
1683
1684
|
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.
|
|
1684
|
-
`;
|
|
1685
|
+
`;
|
|
1686
|
+
|
|
1687
|
+
// skills/flow-ui-quality/references/visual-verification.md
|
|
1688
|
+
var visual_verification_default = `# Visual verification workflow
|
|
1685
1689
|
|
|
1686
1690
|
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.
|
|
1687
1691
|
|
|
@@ -1721,15 +1725,20 @@ Record the reason and use the strongest available substitute:
|
|
|
1721
1725
|
- code inspection against existing component patterns.
|
|
1722
1726
|
|
|
1723
1727
|
Do not claim visual polish was verified if no visual artifact was inspected.
|
|
1724
|
-
`;
|
|
1728
|
+
`;
|
|
1729
|
+
|
|
1730
|
+
// skills/flow-ui-quality/SKILL.md
|
|
1731
|
+
var SKILL_default8 = `---
|
|
1725
1732
|
name: flow-ui-quality
|
|
1726
|
-
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,
|
|
1733
|
+
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.
|
|
1727
1734
|
---
|
|
1728
1735
|
|
|
1729
1736
|
# Flow UI quality
|
|
1730
1737
|
|
|
1731
1738
|
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.
|
|
1732
1739
|
|
|
1740
|
+
This is a helper skill: it contributes UI judgment and visual evidence only. The manager owns every state-changing \`flow_*\` call.
|
|
1741
|
+
|
|
1733
1742
|
## Establish the interface intent
|
|
1734
1743
|
|
|
1735
1744
|
- Identify the user, job-to-be-done, primary workflow, density needs, device constraints, and brand/product tone before choosing visuals.
|
|
@@ -1769,23 +1778,580 @@ Approve only when the interface is both useful and inspectable:
|
|
|
1769
1778
|
- Screenshot/browser evidence supports the claim whenever feasible.
|
|
1770
1779
|
|
|
1771
1780
|
Never approve a UI change based only on code shape. If users will judge it visually, Flow evidence should include visual inspection.
|
|
1772
|
-
`;
|
|
1773
|
-
|
|
1781
|
+
`;
|
|
1782
|
+
|
|
1783
|
+
// src/distribution/flow-skill-definitions.ts
|
|
1784
|
+
var FLOW_SKILL_DEFINITIONS = [
|
|
1785
|
+
{
|
|
1786
|
+
name: "flow",
|
|
1787
|
+
files: [
|
|
1788
|
+
{ relativePath: "SKILL.md", content: SKILL_default },
|
|
1789
|
+
{
|
|
1790
|
+
relativePath: "references/recovery-playbook.md",
|
|
1791
|
+
content: recovery_playbook_default
|
|
1792
|
+
},
|
|
1793
|
+
{
|
|
1794
|
+
relativePath: "references/parallel-orchestration.md",
|
|
1795
|
+
content: parallel_orchestration_default
|
|
1796
|
+
},
|
|
1797
|
+
{
|
|
1798
|
+
relativePath: "references/parallel-pass-patterns.md",
|
|
1799
|
+
content: parallel_pass_patterns_default
|
|
1800
|
+
},
|
|
1801
|
+
{
|
|
1802
|
+
relativePath: "references/parallel-pass-example.md",
|
|
1803
|
+
content: parallel_pass_example_default
|
|
1804
|
+
},
|
|
1805
|
+
{
|
|
1806
|
+
relativePath: "references/handoff-format.md",
|
|
1807
|
+
content: handoff_format_default
|
|
1808
|
+
},
|
|
1809
|
+
{
|
|
1810
|
+
relativePath: "references/verification-gates.md",
|
|
1811
|
+
content: verification_gates_default
|
|
1812
|
+
}
|
|
1813
|
+
]
|
|
1814
|
+
},
|
|
1815
|
+
{
|
|
1816
|
+
name: "flow-plan",
|
|
1817
|
+
files: [
|
|
1818
|
+
{ relativePath: "SKILL.md", content: SKILL_default4 },
|
|
1819
|
+
{
|
|
1820
|
+
relativePath: "references/planning-examples.md",
|
|
1821
|
+
content: planning_examples_default
|
|
1822
|
+
},
|
|
1823
|
+
{
|
|
1824
|
+
relativePath: "references/parallel-discovery.md",
|
|
1825
|
+
content: parallel_discovery_default
|
|
1826
|
+
}
|
|
1827
|
+
]
|
|
1828
|
+
},
|
|
1829
|
+
{
|
|
1830
|
+
name: "flow-run",
|
|
1831
|
+
files: [
|
|
1832
|
+
{ relativePath: "SKILL.md", content: SKILL_default6 },
|
|
1833
|
+
{
|
|
1834
|
+
relativePath: "references/validation-rubric.md",
|
|
1835
|
+
content: validation_rubric_default
|
|
1836
|
+
},
|
|
1837
|
+
{
|
|
1838
|
+
relativePath: "references/audit-rubric.md",
|
|
1839
|
+
content: audit_rubric_default
|
|
1840
|
+
}
|
|
1841
|
+
]
|
|
1842
|
+
},
|
|
1843
|
+
{
|
|
1844
|
+
name: "flow-test",
|
|
1845
|
+
files: [{ relativePath: "SKILL.md", content: SKILL_default7 }]
|
|
1846
|
+
},
|
|
1847
|
+
{
|
|
1848
|
+
name: "flow-review",
|
|
1849
|
+
files: [
|
|
1850
|
+
{ relativePath: "SKILL.md", content: SKILL_default5 },
|
|
1851
|
+
{
|
|
1852
|
+
relativePath: "references/review-rubric.md",
|
|
1853
|
+
content: review_rubric_default
|
|
1854
|
+
}
|
|
1855
|
+
]
|
|
1856
|
+
},
|
|
1857
|
+
{
|
|
1858
|
+
name: "flow-deslop",
|
|
1859
|
+
files: [
|
|
1860
|
+
{ relativePath: "SKILL.md", content: SKILL_default3 },
|
|
1861
|
+
{
|
|
1862
|
+
relativePath: "references/smell-rubric.md",
|
|
1863
|
+
content: smell_rubric_default
|
|
1864
|
+
},
|
|
1865
|
+
{
|
|
1866
|
+
relativePath: "references/refactor-workflow.md",
|
|
1867
|
+
content: refactor_workflow_default
|
|
1868
|
+
}
|
|
1869
|
+
]
|
|
1870
|
+
},
|
|
1871
|
+
{
|
|
1872
|
+
name: "flow-ui-quality",
|
|
1873
|
+
files: [
|
|
1874
|
+
{ relativePath: "SKILL.md", content: SKILL_default8 },
|
|
1875
|
+
{
|
|
1876
|
+
relativePath: "references/ui-rubric.md",
|
|
1877
|
+
content: ui_rubric_default
|
|
1878
|
+
},
|
|
1879
|
+
{
|
|
1880
|
+
relativePath: "references/visual-verification.md",
|
|
1881
|
+
content: visual_verification_default
|
|
1882
|
+
}
|
|
1883
|
+
]
|
|
1884
|
+
},
|
|
1885
|
+
{
|
|
1886
|
+
name: "flow-commit",
|
|
1887
|
+
files: [{ relativePath: "SKILL.md", content: SKILL_default2 }]
|
|
1888
|
+
}
|
|
1889
|
+
];
|
|
1890
|
+
|
|
1891
|
+
// src/distribution/sync.ts
|
|
1892
|
+
var MARKER_FILENAME = ".flow-skill-version";
|
|
1893
|
+
function homeDir() {
|
|
1894
|
+
return process.env.HOME ?? process.env.USERPROFILE ?? homedir();
|
|
1895
|
+
}
|
|
1896
|
+
function resolveFlowSkillsRoot(home = homeDir()) {
|
|
1897
|
+
return join(home, ".config", "opencode", "skills");
|
|
1898
|
+
}
|
|
1899
|
+
function sha256(value) {
|
|
1900
|
+
return createHash("sha256").update(value).digest("hex");
|
|
1901
|
+
}
|
|
1902
|
+
function markerFor(definition, version) {
|
|
1903
|
+
return [
|
|
1904
|
+
`version=${version}`,
|
|
1905
|
+
...definition.files.map((file) => `file=${file.relativePath} sha256=${sha256(file.content)}`),
|
|
1906
|
+
""
|
|
1907
|
+
].join(`
|
|
1908
|
+
`);
|
|
1909
|
+
}
|
|
1910
|
+
async function optionalRead(path) {
|
|
1911
|
+
try {
|
|
1912
|
+
return await readFile(path, "utf8");
|
|
1913
|
+
} catch (error) {
|
|
1914
|
+
if (error.code === "ENOENT")
|
|
1915
|
+
return null;
|
|
1916
|
+
throw error;
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
function parseMarkerFiles(content) {
|
|
1920
|
+
const files = new Map;
|
|
1921
|
+
if (!content)
|
|
1922
|
+
return files;
|
|
1923
|
+
for (const line of content.split(/\r?\n/)) {
|
|
1924
|
+
const match = /^file=(.+) sha256=([a-f0-9]{64})$/.exec(line) ?? /^file=(.+)=sha256:([a-f0-9]{64})$/.exec(line);
|
|
1925
|
+
if (match?.[1] && match[2])
|
|
1926
|
+
files.set(match[1], match[2]);
|
|
1927
|
+
const topLevelHash = /^hash=sha256:([a-f0-9]{64})$/.exec(line);
|
|
1928
|
+
if (topLevelHash?.[1] && !files.has("SKILL.md")) {
|
|
1929
|
+
files.set("SKILL.md", topLevelHash[1]);
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
return files;
|
|
1933
|
+
}
|
|
1934
|
+
function parseMarkerVersion(content) {
|
|
1935
|
+
if (!content)
|
|
1936
|
+
return null;
|
|
1937
|
+
for (const line of content.split(/\r?\n/)) {
|
|
1938
|
+
const match = /^version=(.+)$/.exec(line);
|
|
1939
|
+
if (match?.[1])
|
|
1940
|
+
return match[1];
|
|
1941
|
+
}
|
|
1942
|
+
return null;
|
|
1943
|
+
}
|
|
1944
|
+
function resolveSkillFile(folder, relativePath) {
|
|
1945
|
+
const resolved = normalize(join(folder, ...relativePath.split("/")));
|
|
1946
|
+
if (resolved !== folder && resolved.startsWith(`${folder}${sep}`)) {
|
|
1947
|
+
return resolved;
|
|
1948
|
+
}
|
|
1949
|
+
throw new Error(`Unsafe skill file path '${relativePath}'.`);
|
|
1950
|
+
}
|
|
1951
|
+
async function writeBackup(path, content) {
|
|
1952
|
+
const basePath = `${path}.backup.${sha256(content).slice(0, 12)}`;
|
|
1953
|
+
for (let index = 0;; index += 1) {
|
|
1954
|
+
const backupPath = index === 0 ? basePath : `${basePath}.${index}`;
|
|
1955
|
+
try {
|
|
1956
|
+
await writeFile(backupPath, content, { encoding: "utf8", flag: "wx" });
|
|
1957
|
+
return backupPath;
|
|
1958
|
+
} catch (error) {
|
|
1959
|
+
if (error.code === "EEXIST")
|
|
1960
|
+
continue;
|
|
1961
|
+
throw error;
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
async function syncSkill(definition, version, root) {
|
|
1966
|
+
const folder = join(root, definition.name);
|
|
1967
|
+
const markerPath = join(folder, MARKER_FILENAME);
|
|
1968
|
+
const markerContent = await optionalRead(markerPath);
|
|
1969
|
+
const existingMarkerHashes = parseMarkerFiles(markerContent);
|
|
1970
|
+
const existingSkill = await optionalRead(join(folder, "SKILL.md"));
|
|
1971
|
+
if (existingSkill !== null && markerContent === null) {
|
|
1972
|
+
return { name: definition.name, action: "skipped_foreign" };
|
|
1973
|
+
}
|
|
1974
|
+
let changed = false;
|
|
1975
|
+
const backupPaths = [];
|
|
1976
|
+
const currentRelativePaths = new Set(definition.files.map((file) => file.relativePath));
|
|
1977
|
+
for (const file of definition.files) {
|
|
1978
|
+
const path = resolveSkillFile(folder, file.relativePath);
|
|
1979
|
+
const existing = await optionalRead(path);
|
|
1980
|
+
if (existing === file.content)
|
|
1981
|
+
continue;
|
|
1982
|
+
changed = true;
|
|
1983
|
+
const recordedHash = existingMarkerHashes.get(file.relativePath);
|
|
1984
|
+
const userEdited = existing !== null && (recordedHash ? sha256(existing) !== recordedHash : markerContent !== null);
|
|
1985
|
+
if (userEdited) {
|
|
1986
|
+
backupPaths.push(await writeBackup(path, existing));
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
for (const [relativePath, recordedHash] of existingMarkerHashes) {
|
|
1990
|
+
if (currentRelativePaths.has(relativePath))
|
|
1991
|
+
continue;
|
|
1992
|
+
const path = resolveSkillFile(folder, relativePath);
|
|
1993
|
+
const existing = await optionalRead(path);
|
|
1994
|
+
if (existing === null)
|
|
1995
|
+
continue;
|
|
1996
|
+
changed = true;
|
|
1997
|
+
if (sha256(existing) !== recordedHash) {
|
|
1998
|
+
backupPaths.push(await writeBackup(path, existing));
|
|
1999
|
+
}
|
|
2000
|
+
await rm(path, { force: true });
|
|
2001
|
+
}
|
|
2002
|
+
if (!changed && markerContent === markerFor(definition, version)) {
|
|
2003
|
+
return { name: definition.name, action: "unchanged" };
|
|
2004
|
+
}
|
|
2005
|
+
if (!changed) {
|
|
2006
|
+
await writeFile(markerPath, markerFor(definition, version), "utf8");
|
|
2007
|
+
return { name: definition.name, action: "marker_updated" };
|
|
2008
|
+
}
|
|
2009
|
+
const managedSkillExists = markerContent !== null;
|
|
2010
|
+
for (const file of definition.files) {
|
|
2011
|
+
const path = resolveSkillFile(folder, file.relativePath);
|
|
2012
|
+
await mkdir(dirname(path), { recursive: true });
|
|
2013
|
+
await writeFile(path, file.content, "utf8");
|
|
2014
|
+
}
|
|
2015
|
+
await writeFile(markerPath, markerFor(definition, version), "utf8");
|
|
2016
|
+
return {
|
|
2017
|
+
name: definition.name,
|
|
2018
|
+
action: backupPaths.length > 0 ? "updated_with_backup" : managedSkillExists ? "updated" : "installed",
|
|
2019
|
+
...backupPaths.length > 0 ? { backupPaths } : {}
|
|
2020
|
+
};
|
|
2021
|
+
}
|
|
2022
|
+
function expectedSkillNames() {
|
|
2023
|
+
return FLOW_SKILL_DEFINITIONS.map((definition) => definition.name);
|
|
2024
|
+
}
|
|
2025
|
+
function formatFlowDoctorCommand(version) {
|
|
2026
|
+
const pin = version === "0.0.0" ? "latest" : version;
|
|
2027
|
+
return `npx -y opencode-plugin-flow@${pin} doctor`;
|
|
2028
|
+
}
|
|
2029
|
+
function resolveFlowPluginVersion() {
|
|
2030
|
+
if (process.env.npm_package_version)
|
|
2031
|
+
return process.env.npm_package_version;
|
|
2032
|
+
try {
|
|
2033
|
+
const require2 = createRequire(import.meta.url);
|
|
2034
|
+
for (const path of ["../package.json", "../../package.json"]) {
|
|
2035
|
+
try {
|
|
2036
|
+
const manifest = require2(path);
|
|
2037
|
+
if (manifest.version)
|
|
2038
|
+
return manifest.version;
|
|
2039
|
+
} catch {}
|
|
2040
|
+
}
|
|
2041
|
+
} catch {}
|
|
2042
|
+
return "0.0.0";
|
|
2043
|
+
}
|
|
2044
|
+
async function syncFlowSkills(version, home = homeDir()) {
|
|
2045
|
+
const root = resolveFlowSkillsRoot(home);
|
|
2046
|
+
return Promise.all(FLOW_SKILL_DEFINITIONS.map((definition) => syncSkill(definition, version, root)));
|
|
2047
|
+
}
|
|
2048
|
+
async function inspectFlowSkillInstall(version = resolveFlowPluginVersion(), home = homeDir()) {
|
|
2049
|
+
const root = resolveFlowSkillsRoot(home);
|
|
2050
|
+
const expected = new Set(expectedSkillNames());
|
|
2051
|
+
const skills = await Promise.all(FLOW_SKILL_DEFINITIONS.map(async (definition) => {
|
|
2052
|
+
const folder = join(root, definition.name);
|
|
2053
|
+
const markerContent = await optionalRead(join(folder, MARKER_FILENAME));
|
|
2054
|
+
const markerVersion = parseMarkerVersion(markerContent);
|
|
2055
|
+
const markerHashes = parseMarkerFiles(markerContent);
|
|
2056
|
+
const existingSkill = await optionalRead(join(folder, "SKILL.md"));
|
|
2057
|
+
if (existingSkill === null) {
|
|
2058
|
+
return {
|
|
2059
|
+
name: definition.name,
|
|
2060
|
+
path: folder,
|
|
2061
|
+
status: "missing",
|
|
2062
|
+
markerVersion,
|
|
2063
|
+
missingFiles: definition.files.map((file) => file.relativePath),
|
|
2064
|
+
editedFiles: [],
|
|
2065
|
+
outdatedFiles: []
|
|
2066
|
+
};
|
|
2067
|
+
}
|
|
2068
|
+
if (markerContent === null) {
|
|
2069
|
+
return {
|
|
2070
|
+
name: definition.name,
|
|
2071
|
+
path: folder,
|
|
2072
|
+
status: "foreign",
|
|
2073
|
+
markerVersion,
|
|
2074
|
+
missingFiles: [],
|
|
2075
|
+
editedFiles: [],
|
|
2076
|
+
outdatedFiles: []
|
|
2077
|
+
};
|
|
2078
|
+
}
|
|
2079
|
+
const missingFiles = [];
|
|
2080
|
+
const editedFiles = [];
|
|
2081
|
+
const outdatedFiles = [];
|
|
2082
|
+
for (const file of definition.files) {
|
|
2083
|
+
const existing = await optionalRead(resolveSkillFile(folder, file.relativePath));
|
|
2084
|
+
if (existing === null) {
|
|
2085
|
+
missingFiles.push(file.relativePath);
|
|
2086
|
+
continue;
|
|
2087
|
+
}
|
|
2088
|
+
if (existing === file.content)
|
|
2089
|
+
continue;
|
|
2090
|
+
const recordedHash = markerHashes.get(file.relativePath);
|
|
2091
|
+
if (recordedHash && sha256(existing) !== recordedHash) {
|
|
2092
|
+
editedFiles.push(file.relativePath);
|
|
2093
|
+
continue;
|
|
2094
|
+
}
|
|
2095
|
+
outdatedFiles.push(file.relativePath);
|
|
2096
|
+
}
|
|
2097
|
+
const markerDrift = markerContent !== markerFor(definition, version);
|
|
2098
|
+
const status = missingFiles.length > 0 ? "incomplete" : editedFiles.length > 0 ? "edited" : markerDrift || outdatedFiles.length > 0 ? "outdated" : "ok";
|
|
2099
|
+
return {
|
|
2100
|
+
name: definition.name,
|
|
2101
|
+
path: folder,
|
|
2102
|
+
status,
|
|
2103
|
+
markerVersion,
|
|
2104
|
+
missingFiles,
|
|
2105
|
+
editedFiles,
|
|
2106
|
+
outdatedFiles
|
|
2107
|
+
};
|
|
2108
|
+
}));
|
|
2109
|
+
let entries = [];
|
|
2110
|
+
try {
|
|
2111
|
+
entries = await readdir(root);
|
|
2112
|
+
} catch (error) {
|
|
2113
|
+
if (error.code !== "ENOENT")
|
|
2114
|
+
throw error;
|
|
2115
|
+
}
|
|
2116
|
+
const unmanagedFlowSkills = entries.filter((name) => (name === "flow" || name.startsWith("flow-")) && !expected.has(name)).map((name) => join(root, name));
|
|
2117
|
+
const syncRequiredSkills = skills.filter((skill) => ["missing", "incomplete", "outdated"].includes(skill.status)).map((skill) => skill.name);
|
|
2118
|
+
const actionRequiredSkills = skills.filter((skill) => ["foreign", "edited"].includes(skill.status)).map((skill) => skill.name);
|
|
2119
|
+
const actionRequired = actionRequiredSkills.length > 0;
|
|
2120
|
+
const syncRequired = syncRequiredSkills.length > 0;
|
|
2121
|
+
return {
|
|
2122
|
+
status: actionRequired ? "action_required" : syncRequired ? "sync_required" : "ok",
|
|
2123
|
+
version,
|
|
2124
|
+
root,
|
|
2125
|
+
expectedSkills: [...expected],
|
|
2126
|
+
skills,
|
|
2127
|
+
syncRequiredSkills,
|
|
2128
|
+
actionRequiredSkills,
|
|
2129
|
+
unmanagedFlowSkills
|
|
2130
|
+
};
|
|
2131
|
+
}
|
|
2132
|
+
function appendSkillList(lines, label, skills) {
|
|
2133
|
+
if (skills.length === 0)
|
|
2134
|
+
return;
|
|
2135
|
+
lines.push(`- ${label}: ${skills.join(", ")}`);
|
|
2136
|
+
}
|
|
2137
|
+
function formatFlowSkillDoctor(report) {
|
|
2138
|
+
const lines = [
|
|
2139
|
+
"Flow doctor",
|
|
2140
|
+
`- status: ${report.status}`,
|
|
2141
|
+
`- plugin version: ${report.version}`,
|
|
2142
|
+
`- skills root: ${report.root}`,
|
|
2143
|
+
`- expected skills: ${report.expectedSkills.join(", ")}`
|
|
2144
|
+
];
|
|
2145
|
+
appendSkillList(lines, "startup sync can install/update", report.syncRequiredSkills);
|
|
2146
|
+
appendSkillList(lines, "needs user decision", report.actionRequiredSkills);
|
|
2147
|
+
lines.push("", "Skills:");
|
|
2148
|
+
for (const skill of report.skills) {
|
|
2149
|
+
lines.push(`- ${skill.name}: ${skill.status} (${skill.path})${skill.markerVersion ? ` marker=${skill.markerVersion}` : ""}`);
|
|
2150
|
+
if (skill.missingFiles.length > 0) {
|
|
2151
|
+
lines.push(` missing: ${skill.missingFiles.join(", ")}`);
|
|
2152
|
+
}
|
|
2153
|
+
if (skill.editedFiles.length > 0) {
|
|
2154
|
+
lines.push(` edited: ${skill.editedFiles.join(", ")}`);
|
|
2155
|
+
}
|
|
2156
|
+
if (skill.outdatedFiles.length > 0) {
|
|
2157
|
+
lines.push(` outdated: ${skill.outdatedFiles.join(", ")}`);
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
if (report.unmanagedFlowSkills.length > 0) {
|
|
2161
|
+
lines.push("", "Unmanaged Flow-like skill folders:");
|
|
2162
|
+
for (const path of report.unmanagedFlowSkills)
|
|
2163
|
+
lines.push(`- ${path}`);
|
|
2164
|
+
}
|
|
2165
|
+
lines.push("", "Recommendation:");
|
|
2166
|
+
if (report.status === "ok") {
|
|
2167
|
+
lines.push("- Flow skills are present and current.");
|
|
2168
|
+
} else if (report.status === "sync_required") {
|
|
2169
|
+
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.");
|
|
2170
|
+
} else {
|
|
2171
|
+
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.");
|
|
2172
|
+
}
|
|
2173
|
+
lines.push(`- Details command: ${formatFlowDoctorCommand(report.version)}`);
|
|
2174
|
+
return `${lines.join(`
|
|
1774
2175
|
`)}
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
2176
|
+
`;
|
|
2177
|
+
}
|
|
2178
|
+
async function listSkillFolderFiles(folder) {
|
|
2179
|
+
const entries = await readdir(folder, {
|
|
2180
|
+
recursive: true,
|
|
2181
|
+
withFileTypes: true
|
|
2182
|
+
});
|
|
2183
|
+
return entries.filter((entry) => entry.isFile()).map((entry) => join(entry.parentPath, entry.name).slice(folder.length + 1).split(sep).join("/"));
|
|
2184
|
+
}
|
|
2185
|
+
async function isPristineManagedFolder(folder, markerContent) {
|
|
2186
|
+
const hashes = parseMarkerFiles(markerContent);
|
|
2187
|
+
if (hashes.size === 0)
|
|
2188
|
+
return false;
|
|
2189
|
+
for (const relativePath of await listSkillFolderFiles(folder)) {
|
|
2190
|
+
if (relativePath === MARKER_FILENAME)
|
|
2191
|
+
continue;
|
|
2192
|
+
const recordedHash = hashes.get(relativePath);
|
|
2193
|
+
if (recordedHash === undefined)
|
|
2194
|
+
return false;
|
|
2195
|
+
const content = await optionalRead(resolveSkillFile(folder, relativePath));
|
|
2196
|
+
if (content === null || sha256(content) !== recordedHash)
|
|
2197
|
+
return false;
|
|
2198
|
+
}
|
|
2199
|
+
return true;
|
|
2200
|
+
}
|
|
2201
|
+
async function uninstallFlowSkills(home = homeDir(), options = {}) {
|
|
2202
|
+
const root = resolveFlowSkillsRoot(home);
|
|
2203
|
+
const removed = [];
|
|
2204
|
+
const kept = [];
|
|
2205
|
+
let entries;
|
|
2206
|
+
try {
|
|
2207
|
+
entries = await readdir(root);
|
|
2208
|
+
} catch (error) {
|
|
2209
|
+
if (error.code === "ENOENT") {
|
|
2210
|
+
return { removed, kept };
|
|
2211
|
+
}
|
|
2212
|
+
throw error;
|
|
2213
|
+
}
|
|
2214
|
+
for (const name of entries) {
|
|
2215
|
+
if (name !== "flow" && !name.startsWith("flow-"))
|
|
2216
|
+
continue;
|
|
2217
|
+
const folder = join(root, name);
|
|
2218
|
+
const markerContent = await optionalRead(join(folder, MARKER_FILENAME));
|
|
2219
|
+
if (markerContent === null || !await isPristineManagedFolder(folder, markerContent)) {
|
|
2220
|
+
kept.push(folder);
|
|
2221
|
+
continue;
|
|
2222
|
+
}
|
|
2223
|
+
if (!options.dryRun) {
|
|
2224
|
+
await rm(folder, { recursive: true, force: true });
|
|
2225
|
+
}
|
|
2226
|
+
removed.push(folder);
|
|
2227
|
+
}
|
|
2228
|
+
return { removed, kept };
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
// src/cli.ts
|
|
2232
|
+
function usage() {
|
|
2233
|
+
return [
|
|
2234
|
+
"usage: opencode-plugin-flow <doctor|sync|uninstall> [options]",
|
|
2235
|
+
"",
|
|
2236
|
+
"commands:",
|
|
2237
|
+
" doctor Inspect managed Flow skills",
|
|
2238
|
+
" sync Install or refresh managed Flow skills",
|
|
2239
|
+
" uninstall Remove pristine Flow-owned managed skills",
|
|
2240
|
+
"",
|
|
2241
|
+
"doctor options:",
|
|
2242
|
+
" --json Write the doctor report as JSON",
|
|
2243
|
+
" --check, --strict Exit nonzero when doctor status is not ok",
|
|
2244
|
+
"",
|
|
2245
|
+
"uninstall options:",
|
|
2246
|
+
" --dry-run Preview removals without deleting anything",
|
|
2247
|
+
"",
|
|
2248
|
+
"global options:",
|
|
2249
|
+
" --help Show this help",
|
|
2250
|
+
" --version Print the plugin version"
|
|
2251
|
+
].join(`
|
|
2252
|
+
`);
|
|
2253
|
+
}
|
|
2254
|
+
function hasOnlyKnownFlags(flags, known) {
|
|
2255
|
+
return flags.every((flag) => known.has(flag));
|
|
2256
|
+
}
|
|
2257
|
+
function writeDoctorReport(report, options) {
|
|
2258
|
+
if (options.json) {
|
|
2259
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}
|
|
2260
|
+
`);
|
|
2261
|
+
return;
|
|
2262
|
+
}
|
|
2263
|
+
process.stdout.write(formatFlowSkillDoctor(report));
|
|
2264
|
+
}
|
|
2265
|
+
async function main(argv) {
|
|
2266
|
+
const command = argv[2];
|
|
2267
|
+
const flags = argv.slice(3);
|
|
2268
|
+
if (command === "--help" || command === "-h") {
|
|
2269
|
+
process.stdout.write(`${usage()}
|
|
2270
|
+
`);
|
|
2271
|
+
return;
|
|
2272
|
+
}
|
|
2273
|
+
if (command === "--version" || command === "-v") {
|
|
2274
|
+
process.stdout.write(`${resolveFlowPluginVersion()}
|
|
2275
|
+
`);
|
|
2276
|
+
return;
|
|
2277
|
+
}
|
|
2278
|
+
if (command !== "uninstall" && command !== "doctor" && command !== "sync") {
|
|
2279
|
+
process.stderr.write(`${usage()}
|
|
2280
|
+
`);
|
|
2281
|
+
process.exitCode = 2;
|
|
2282
|
+
return;
|
|
2283
|
+
}
|
|
2284
|
+
if (command === "doctor") {
|
|
2285
|
+
const knownDoctorFlags = new Set(["--json", "--check", "--strict"]);
|
|
2286
|
+
if (!hasOnlyKnownFlags(flags, knownDoctorFlags)) {
|
|
2287
|
+
process.stderr.write(`${usage()}
|
|
2288
|
+
`);
|
|
2289
|
+
process.exitCode = 2;
|
|
2290
|
+
return;
|
|
2291
|
+
}
|
|
2292
|
+
const report = await inspectFlowSkillInstall();
|
|
2293
|
+
writeDoctorReport(report, { json: flags.includes("--json") });
|
|
2294
|
+
if ((report.status === "sync_required" || report.status === "action_required") && (flags.includes("--check") || flags.includes("--strict"))) {
|
|
2295
|
+
process.exitCode = 1;
|
|
2296
|
+
}
|
|
2297
|
+
return;
|
|
2298
|
+
}
|
|
2299
|
+
const knownUninstallFlags = new Set(["--dry-run"]);
|
|
2300
|
+
if (command === "uninstall" && !hasOnlyKnownFlags(flags, knownUninstallFlags)) {
|
|
2301
|
+
process.stderr.write(`${usage()}
|
|
2302
|
+
`);
|
|
2303
|
+
process.exitCode = 2;
|
|
2304
|
+
return;
|
|
2305
|
+
}
|
|
2306
|
+
if (command === "sync" && flags.length > 0) {
|
|
2307
|
+
process.stderr.write(`${usage()}
|
|
2308
|
+
`);
|
|
2309
|
+
process.exitCode = 2;
|
|
2310
|
+
return;
|
|
2311
|
+
}
|
|
2312
|
+
if (command === "sync") {
|
|
2313
|
+
const version = resolveFlowPluginVersion();
|
|
2314
|
+
const results = await syncFlowSkills(version);
|
|
2315
|
+
const changed = results.filter((result2) => ["installed", "updated", "updated_with_backup"].includes(result2.action));
|
|
2316
|
+
const actionRequired = results.filter((result2) => result2.action === "skipped_foreign");
|
|
2317
|
+
process.stdout.write(`Flow skill sync (${version})
|
|
2318
|
+
`);
|
|
2319
|
+
for (const result2 of results) {
|
|
2320
|
+
process.stdout.write(`- ${result2.name}: ${result2.action}
|
|
2321
|
+
`);
|
|
2322
|
+
for (const backupPath of result2.backupPaths ?? []) {
|
|
2323
|
+
process.stdout.write(` backup: ${backupPath}
|
|
2324
|
+
`);
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
if (changed.length > 0) {
|
|
2328
|
+
process.stdout.write(`Restart OpenCode so the refreshed skill registry is used.
|
|
2329
|
+
`);
|
|
2330
|
+
}
|
|
2331
|
+
if (actionRequired.length > 0) {
|
|
2332
|
+
process.stdout.write(`Some managed skill folders are user-owned or edited; run doctor for repair guidance.
|
|
2333
|
+
`);
|
|
2334
|
+
}
|
|
2335
|
+
return;
|
|
2336
|
+
}
|
|
2337
|
+
const dryRun = flags.includes("--dry-run");
|
|
2338
|
+
const result = await uninstallFlowSkills(undefined, { dryRun });
|
|
2339
|
+
for (const path of result.removed) {
|
|
2340
|
+
process.stdout.write(`${dryRun ? "Would remove" : "Removed"} Flow skill: ${path}
|
|
2341
|
+
`);
|
|
2342
|
+
}
|
|
2343
|
+
for (const path of result.kept) {
|
|
2344
|
+
process.stdout.write(`Kept non-Flow or user-edited skill: ${path}
|
|
2345
|
+
`);
|
|
2346
|
+
}
|
|
2347
|
+
process.stdout.write(dryRun ? `Dry run: no files were removed.
|
|
2348
|
+
` : `Remove opencode-plugin-flow from your OpenCode plugin config and restart OpenCode.
|
|
2349
|
+
`);
|
|
2350
|
+
}
|
|
2351
|
+
main(process.argv).catch((error) => {
|
|
2352
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}
|
|
2353
|
+
`);
|
|
2354
|
+
process.exitCode = 1;
|
|
2355
|
+
});
|
|
2356
|
+
|
|
2357
|
+
//# debugId=009E272E1911CD7D64756E2164756E21
|