opencode-plugin-flow 4.1.17 → 4.2.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 +86 -22
- package/README.md +102 -163
- package/dist/cli.js +806 -162
- 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 +2477 -383
- 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,11 +1,23 @@
|
|
|
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
|
|
6
15
|
covered, the evidence for each useful claim, and the remaining gaps. End worker
|
|
7
16
|
prompts with "Return only this Flow handoff."
|
|
8
17
|
|
|
18
|
+
Sections: evidence/review/validation/audit worker report, verifier worker report,
|
|
19
|
+
and candidate implementation worker report.
|
|
20
|
+
|
|
9
21
|
Status meanings:
|
|
10
22
|
|
|
11
23
|
- \`success\`: the assigned scope was covered, or any skipped items are explicitly
|
|
@@ -137,22 +149,29 @@ live-verified | test-verified | type-check-only | not-verified
|
|
|
137
149
|
|
|
138
150
|
The manager must inspect and validate any candidate patch before recording Flow
|
|
139
151
|
completion.
|
|
140
|
-
`;
|
|
152
|
+
`;
|
|
153
|
+
|
|
154
|
+
// skills/flow/references/parallel-orchestration.md
|
|
155
|
+
var parallel_orchestration_default = `# Parallel orchestration
|
|
141
156
|
|
|
142
157
|
Use fan-out when Flow work is broad enough that independent workers can gather
|
|
143
158
|
evidence faster than one linear pass. The manager still owns the Flow session:
|
|
144
159
|
only the manager calls state-changing Flow tools, approves plans, completes
|
|
145
160
|
features, records reviews, or closes sessions.
|
|
146
161
|
|
|
162
|
+
Sections: quick path, operational defaults, manager sequence, modes, permission
|
|
163
|
+
contract, worker rules, prompt contract, handoff location, and follow-up passes.
|
|
164
|
+
|
|
147
165
|
Read these companion references before a broad parallel pass:
|
|
148
166
|
|
|
149
167
|
- \`parallel-pass-patterns.md\` for pass selection, effort defaults, and stop or
|
|
150
168
|
follow-up rules.
|
|
151
169
|
- \`handoff-format.md\` for the exact worker response shapes.
|
|
152
|
-
- \`verification-gates.md\` for coverage
|
|
153
|
-
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.
|
|
154
173
|
- \`parallel-pass-example.md\` for a concrete end-to-end pass after the rules
|
|
155
|
-
below are clear.
|
|
174
|
+
below are clear (synced with the \`flow\` skill; not bundled into commands).
|
|
156
175
|
|
|
157
176
|
## Quick path
|
|
158
177
|
|
|
@@ -195,13 +214,9 @@ Skip fan-out when:
|
|
|
195
214
|
commands, or artifacts to identify real slices.
|
|
196
215
|
3. Define the local manager task. Do not delegate the immediate blocker that
|
|
197
216
|
determines whether fan-out is even valid.
|
|
198
|
-
4. Build
|
|
199
|
-
- total
|
|
200
|
-
|
|
201
|
-
- partition check showing slices add back to the total when the work is
|
|
202
|
-
countable.
|
|
203
|
-
- overlap/gap check showing no duplicate ownership, empty slices, or missing
|
|
204
|
-
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.
|
|
205
220
|
5. Spawn only named Flow workers. Use exact slices and the required handoff
|
|
206
221
|
shape. Keep each prompt self-contained.
|
|
207
222
|
6. Continue non-overlapping manager work while workers run.
|
|
@@ -211,10 +226,9 @@ Skip fan-out when:
|
|
|
211
226
|
claims to \`flow-verifier-worker\`.
|
|
212
227
|
9. Run follow-up passes only for material gaps, conflicts, narrowed scope, or
|
|
213
228
|
verification needs.
|
|
214
|
-
10. Apply the manager synthesis barrier
|
|
215
|
-
claims and synthesize one Flow artifact
|
|
216
|
-
|
|
217
|
-
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.
|
|
218
232
|
|
|
219
233
|
## Modes
|
|
220
234
|
|
|
@@ -298,9 +312,14 @@ Your exact slice: <paths, modules, command, claim ids, risk lens, or worktree>
|
|
|
298
312
|
Expected coverage: <count, paths, range, or complete question set>
|
|
299
313
|
Do: <bounded actions>
|
|
300
314
|
Do not: call state-changing Flow tools, edit .flow/**, own sibling slices, or make the final Flow verdict.
|
|
301
|
-
Return only the
|
|
315
|
+
Return only the Flow handoff in this exact shape:
|
|
316
|
+
<matching handoff template copied verbatim from handoff-format.md>
|
|
302
317
|
\`\`\`
|
|
303
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
|
+
|
|
304
323
|
For research or current-doc slices, require source checks for versioned or
|
|
305
324
|
time-sensitive facts. For implementation candidates, remind workers that other
|
|
306
325
|
work may be active and that they must not revert unrelated changes.
|
|
@@ -321,11 +340,8 @@ work may be active and that they must not revert unrelated changes.
|
|
|
321
340
|
any Flow completion call.
|
|
322
341
|
|
|
323
342
|
When worker results conflict, inspect the underlying artifact directly and rerun
|
|
324
|
-
the smallest check that can settle the disagreement.
|
|
325
|
-
|
|
326
|
-
The manager synthesis barrier means raw handoffs do not move forward by default.
|
|
327
|
-
Only claims that survived coverage, evidence, confidence, and verifier checks may
|
|
328
|
-
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.
|
|
329
345
|
|
|
330
346
|
## Follow-up passes
|
|
331
347
|
|
|
@@ -339,74 +355,84 @@ Start a follow-up pass when first-pass handoffs reveal:
|
|
|
339
355
|
|
|
340
356
|
Do not recurse by default. If a worker says it needs another worker, the manager
|
|
341
357
|
decides whether that is a follow-up pass and writes the next bounded prompt.
|
|
342
|
-
`;
|
|
358
|
+
`;
|
|
359
|
+
|
|
360
|
+
// skills/flow/references/parallel-pass-example.md
|
|
361
|
+
var parallel_pass_example_default = `# Parallel pass example
|
|
343
362
|
|
|
344
363
|
Use this example after \`parallel-orchestration.md\` when a broad Flow task needs a
|
|
345
|
-
concrete pass shape.
|
|
364
|
+
concrete pass shape. The project below is illustrative; derive your own slices
|
|
365
|
+
from the actual repo during serial orientation.
|
|
346
366
|
|
|
347
|
-
Goal: review whether
|
|
348
|
-
|
|
367
|
+
Goal: review whether a web app's API error handling is consistent before
|
|
368
|
+
planning a refactor.
|
|
349
369
|
|
|
350
|
-
Serial orientation: the manager reads
|
|
351
|
-
|
|
352
|
-
|
|
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.
|
|
353
374
|
|
|
354
|
-
Coverage gate:
|
|
375
|
+
Coverage gate: twelve countable route modules remain after the local check.
|
|
355
376
|
|
|
356
|
-
- Slice A:
|
|
357
|
-
- Slice B:
|
|
358
|
-
- Slice C: remaining
|
|
359
|
-
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.
|
|
360
380
|
|
|
361
381
|
Worker prompts:
|
|
362
382
|
|
|
363
383
|
\`\`\`text
|
|
364
|
-
Overall goal, context only: confirm
|
|
384
|
+
Overall goal, context only: confirm API error handling is consistent.
|
|
365
385
|
Mode: evidence
|
|
366
|
-
Your exact slice:
|
|
367
|
-
Expected coverage:
|
|
368
|
-
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.
|
|
369
389
|
Do not: call state-changing Flow tools, edit .flow/**, own sibling slices, or make the final Flow verdict.
|
|
370
|
-
Return only the
|
|
390
|
+
Return only the Flow handoff in this exact shape:
|
|
391
|
+
<matching handoff template copied verbatim from handoff-format.md>
|
|
371
392
|
\`\`\`
|
|
372
393
|
|
|
373
394
|
\`\`\`text
|
|
374
|
-
Overall goal, context only: confirm
|
|
395
|
+
Overall goal, context only: confirm API error handling is consistent.
|
|
375
396
|
Mode: review
|
|
376
|
-
Your exact slice:
|
|
377
|
-
Expected coverage:
|
|
397
|
+
Your exact slice: the three billing and subscription route modules under src/routes/.
|
|
398
|
+
Expected coverage: 3/3 modules.
|
|
378
399
|
Do: separate blocking findings from advisory notes and cite file:line evidence.
|
|
379
400
|
Do not: call state-changing Flow tools, edit .flow/**, own sibling slices, or make the final Flow verdict.
|
|
380
|
-
Return only the
|
|
401
|
+
Return only the Flow handoff in this exact shape:
|
|
402
|
+
<matching handoff template copied verbatim from handoff-format.md>
|
|
381
403
|
\`\`\`
|
|
382
404
|
|
|
383
405
|
\`\`\`text
|
|
384
|
-
Overall goal, context only: confirm
|
|
406
|
+
Overall goal, context only: confirm API error handling is consistent.
|
|
385
407
|
Mode: audit
|
|
386
|
-
Your exact slice:
|
|
387
|
-
Expected coverage: 5/5
|
|
388
|
-
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.
|
|
389
411
|
Do not: call state-changing Flow tools, edit .flow/**, own sibling slices, or make the final Flow verdict.
|
|
390
|
-
Return only the
|
|
412
|
+
Return only the Flow handoff in this exact shape:
|
|
413
|
+
<matching handoff template copied verbatim from handoff-format.md>
|
|
391
414
|
\`\`\`
|
|
392
415
|
|
|
393
416
|
Handoff checks: the manager accepts only reports with terminal status, matching
|
|
394
417
|
coverage counts, concrete file:line evidence, confidence tags, and claims inside
|
|
395
|
-
the assigned slice. A claim such as \`[high]
|
|
396
|
-
evidence: src/
|
|
397
|
-
A claim such as \`[high]
|
|
398
|
-
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.
|
|
399
422
|
|
|
400
423
|
Verifier pass: the manager sends any single-source claim that will enter the
|
|
401
|
-
Flow payload to \`flow-verifier-worker\`, for example: \`C1:
|
|
402
|
-
|
|
403
|
-
|
|
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\`.
|
|
404
427
|
|
|
405
|
-
Final synthesis: the manager re-reads the relevant
|
|
406
|
-
verified or clearly labeled claims, and records one artifact such as
|
|
407
|
-
decision, review payload, or docs patch. Raw handoffs and unverified
|
|
408
|
-
do not move into the next pass or user-facing answer.
|
|
409
|
-
`;
|
|
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
|
|
410
436
|
|
|
411
437
|
Flow uses parallel workers to reduce uncertainty, not to delegate decisions.
|
|
412
438
|
Each pass has a bounded purpose, an explicit coverage rule, and one
|
|
@@ -495,16 +521,24 @@ Start a bounded follow-up pass only when:
|
|
|
495
521
|
- a first pass exposes a narrower implementation or validation slice worth
|
|
496
522
|
isolating.
|
|
497
523
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
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
|
|
502
533
|
|
|
503
534
|
Verification is how Flow keeps parallel work from turning into parallel
|
|
504
535
|
guesswork. Worker handoffs are candidate evidence; the manager decides what can
|
|
505
536
|
enter the plan, validation record, review payload, audit report, or final
|
|
506
537
|
answer.
|
|
507
538
|
|
|
539
|
+
Sections: before fan-out, every handoff, verifier triggers, verification tiers,
|
|
540
|
+
Flow payload acceptance, and manager synthesis barrier.
|
|
541
|
+
|
|
508
542
|
## Before fan-out
|
|
509
543
|
|
|
510
544
|
Run a pre-fan-out gate after serial orientation and before spawning workers:
|
|
@@ -609,7 +643,10 @@ Before presenting or recording the result:
|
|
|
609
643
|
|
|
610
644
|
\`Status: success\` only says the worker believes its slice is done. The manager
|
|
611
645
|
still checks coverage and evidence before trusting the result.
|
|
612
|
-
`;
|
|
646
|
+
`;
|
|
647
|
+
|
|
648
|
+
// skills/flow/SKILL.md
|
|
649
|
+
var SKILL_default = `---
|
|
613
650
|
name: flow
|
|
614
651
|
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.
|
|
615
652
|
---
|
|
@@ -621,10 +658,8 @@ Use Flow as a minimal state ledger, not as a framework. Skills provide judgment;
|
|
|
621
658
|
## Loop
|
|
622
659
|
|
|
623
660
|
1. Call \`flow_status\` first. Trust its active session and next action over conversation memory.
|
|
624
|
-
If the result includes \`setup.skills\`,
|
|
625
|
-
|
|
626
|
-
continue with their embedded instructions, but a just-synced native skill can
|
|
627
|
-
be on disk while unavailable to the running OpenCode process.
|
|
661
|
+
If the result includes \`setup.skills\`, follow the Skill Availability rules
|
|
662
|
+
below before loading any Flow skill.
|
|
628
663
|
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.
|
|
629
664
|
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.
|
|
630
665
|
4. Load \`flow-review\` for the required feature review. The reviewer reports a \`featureReview\` payload; the manager records it inside \`flow_feature_complete\`.
|
|
@@ -684,7 +719,10 @@ Planning and running require loaded Flow tools; do not simulate plan approval or
|
|
|
684
719
|
- Unknown runtime error: read \`summary\` and \`recovery\`; see \`references/recovery-playbook.md\` for common cases.
|
|
685
720
|
|
|
686
721
|
Never fabricate validation output, backfill review approval you did not perform, or close as \`deferred\`/\`abandoned\` merely to avoid an unfinished-work blocker.
|
|
687
|
-
`;
|
|
722
|
+
`;
|
|
723
|
+
|
|
724
|
+
// skills/flow-commit/SKILL.md
|
|
725
|
+
var SKILL_default2 = `---
|
|
688
726
|
name: flow-commit
|
|
689
727
|
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.
|
|
690
728
|
---
|
|
@@ -756,18 +794,12 @@ Before commit creation, check the staged diff for:
|
|
|
756
794
|
- Generated artifacts that are not normally versioned.
|
|
757
795
|
- Package or version metadata drift unrelated to the requested change.
|
|
758
796
|
|
|
759
|
-
|
|
760
|
-
or
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
Run it after staging and rerun it after any staging change. Commit mode validates
|
|
767
|
-
the staged boundary for diff hygiene, staged review, and staged secret screening;
|
|
768
|
-
it does not run a whole-worktree gate, choose commit boundaries, or write commit
|
|
769
|
-
messages. If the script is absent, use the repository's documented commit
|
|
770
|
-
preflight from package scripts, AGENTS/docs, or CI guidance.
|
|
797
|
+
If the repository documents its own commit preflight (a package script, a
|
|
798
|
+
repo-local preflight script, or guidance in AGENTS/docs or CI config), defer to
|
|
799
|
+
it for staged validation instead of duplicating its checks. Run it after
|
|
800
|
+
staging and rerun it after any staging change. A staged-boundary preflight
|
|
801
|
+
validates diff hygiene and staged secret screening; it does not run a
|
|
802
|
+
whole-worktree gate, choose commit boundaries, or write commit messages.
|
|
771
803
|
|
|
772
804
|
Use the repository's documented broad validation gate when a full local check is
|
|
773
805
|
appropriate, such as package scripts, AGENTS/docs, or CI guidance. Treat broad
|
|
@@ -800,7 +832,10 @@ Before running \`git commit\`, report:
|
|
|
800
832
|
|
|
801
833
|
After a successful commit, report the commit hash and leave push or release
|
|
802
834
|
actions for a separate explicit request.
|
|
803
|
-
`;
|
|
835
|
+
`;
|
|
836
|
+
|
|
837
|
+
// skills/flow-deslop/references/refactor-workflow.md
|
|
838
|
+
var refactor_workflow_default = `# Safe refactor workflow
|
|
804
839
|
|
|
805
840
|
Refactoring is a behavior-preserving sequence of small changes. This workflow keeps cleanup from becoming an unreviewable rewrite.
|
|
806
841
|
|
|
@@ -842,7 +877,10 @@ Weak evidence includes:
|
|
|
842
877
|
- Public contracts and compatibility shims remain intact or were explicitly planned.
|
|
843
878
|
- Deleted code is actually unreachable or obsolete.
|
|
844
879
|
- Validation can catch a realistic mistake in the refactor.
|
|
845
|
-
`;
|
|
880
|
+
`;
|
|
881
|
+
|
|
882
|
+
// skills/flow-deslop/references/smell-rubric.md
|
|
883
|
+
var smell_rubric_default = `# Deslop smell rubric
|
|
846
884
|
|
|
847
885
|
Use this rubric to turn vague cleanup instincts into reviewable findings.
|
|
848
886
|
|
|
@@ -876,7 +914,10 @@ class; severity; location; evidence read; refutation checked; why it matters; sa
|
|
|
876
914
|
\`\`\`
|
|
877
915
|
|
|
878
916
|
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.
|
|
879
|
-
`;
|
|
917
|
+
`;
|
|
918
|
+
|
|
919
|
+
// skills/flow-deslop/SKILL.md
|
|
920
|
+
var SKILL_default3 = `---
|
|
880
921
|
name: flow-deslop
|
|
881
922
|
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, or broad cleanup/refactor review.
|
|
882
923
|
---
|
|
@@ -918,7 +959,10 @@ For each claimed smell removal, verify:
|
|
|
918
959
|
- **blast radius** — public contracts and downstream callers still work.
|
|
919
960
|
|
|
920
961
|
Never approve cleanup because it "looks cleaner" without evidence. Tests passing is necessary but not sufficient when the refactor changes structure across files.
|
|
921
|
-
`;
|
|
962
|
+
`;
|
|
963
|
+
|
|
964
|
+
// skills/flow-plan/references/parallel-discovery.md
|
|
965
|
+
var parallel_discovery_default = `# Parallel discovery
|
|
922
966
|
|
|
923
967
|
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.
|
|
924
968
|
|
|
@@ -934,26 +978,17 @@ Use its pre-fan-out coverage gate and
|
|
|
934
978
|
- Risk lenses such as security, persistence, accessibility, migration, or performance.
|
|
935
979
|
- Documentation and operator-contract checks.
|
|
936
980
|
|
|
937
|
-
##
|
|
938
|
-
|
|
939
|
-
For this repository, good first-pass slices are:
|
|
981
|
+
## Deriving first-pass slices
|
|
940
982
|
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
- OpenCode adapter surface: \`src/adapters/opencode/**\`, \`src/config-shared.ts\`,
|
|
947
|
-
\`src/config.ts\`, \`src/index.ts\`, and surface tests.
|
|
948
|
-
- Distribution and synced skills: \`src/distribution/**\`, \`src/cli.ts\`,
|
|
949
|
-
\`skills/**\`, and distribution tests.
|
|
950
|
-
- CI, package, and release contract: \`.github/workflows/**\`, \`package.json\`,
|
|
951
|
-
\`bun.lock\`, \`README.md\`, and \`CHANGELOG.md\`.
|
|
952
|
-
- Docs and operator contract: \`docs/**\`, \`README.md\`, and skill references.
|
|
983
|
+
Derive slices from the repo shape found during the serial orientation pass:
|
|
984
|
+
top-level packages or source directories, the test tree, CI and release
|
|
985
|
+
config, and docs. Name each slice by the paths it owns, for example "runtime:
|
|
986
|
+
\`src/core/**\` plus its tests" or "release contract: CI workflows,
|
|
987
|
+
\`package.json\`, and the changelog".
|
|
953
988
|
|
|
954
|
-
Treat
|
|
955
|
-
choose the relevant entries and de-overlap shared docs,
|
|
956
|
-
surfaces in the coverage gate.
|
|
989
|
+
Treat derived slices as starting points, not a simultaneous coverage map.
|
|
990
|
+
Before fan-out, choose the relevant entries and de-overlap shared docs,
|
|
991
|
+
config, or release surfaces in the coverage gate.
|
|
957
992
|
|
|
958
993
|
## Coverage gate
|
|
959
994
|
|
|
@@ -966,8 +1001,8 @@ state the completeness rule, such as "all changed files plus callers."
|
|
|
966
1001
|
|
|
967
1002
|
\`\`\`text
|
|
968
1003
|
Inspect <slice> for <goal>. Read-only. Do not edit files or call
|
|
969
|
-
state-changing Flow tools. Return the
|
|
970
|
-
|
|
1004
|
+
state-changing Flow tools. Return only the Flow handoff in this exact shape:
|
|
1005
|
+
<matching handoff template copied verbatim from handoff-format.md>
|
|
971
1006
|
\`\`\`
|
|
972
1007
|
|
|
973
1008
|
For validation-oriented discovery:
|
|
@@ -975,11 +1010,14 @@ For validation-oriented discovery:
|
|
|
975
1010
|
\`\`\`text
|
|
976
1011
|
Inspect <slice> for validation risk. Read-only. Do not edit files or call
|
|
977
1012
|
state-changing Flow tools. You may report commands that should be run, and
|
|
978
|
-
include raw output only for commands you actually ran. Return the
|
|
979
|
-
|
|
980
|
-
|
|
1013
|
+
include raw output only for commands you actually ran. Return only the Flow
|
|
1014
|
+
handoff in this exact shape:
|
|
1015
|
+
<matching handoff template copied verbatim from handoff-format.md>
|
|
981
1016
|
\`\`\`
|
|
982
1017
|
|
|
1018
|
+
Workers cannot read reference files themselves; paste the matching handoff
|
|
1019
|
+
template from \`../../flow/references/handoff-format.md\` into the prompt.
|
|
1020
|
+
|
|
983
1021
|
## Synthesis
|
|
984
1022
|
|
|
985
1023
|
Convert only evidence-backed work into plan fields:
|
|
@@ -994,7 +1032,10 @@ If workers disagree, inspect the source artifact yourself. If a candidate findin
|
|
|
994
1032
|
Apply the manager synthesis barrier from
|
|
995
1033
|
\`../../flow/references/verification-gates.md\`: only distilled, evidence-backed
|
|
996
1034
|
claims become plan fields.
|
|
997
|
-
`;
|
|
1035
|
+
`;
|
|
1036
|
+
|
|
1037
|
+
// skills/flow-plan/references/planning-examples.md
|
|
1038
|
+
var planning_examples_default = `# Planning examples
|
|
998
1039
|
|
|
999
1040
|
## Rate limiting feature set
|
|
1000
1041
|
|
|
@@ -1079,7 +1120,10 @@ Better plan:
|
|
|
1079
1120
|
- Validation that only says "manual testing".
|
|
1080
1121
|
- Targets that name the entire repo.
|
|
1081
1122
|
- Features with hidden dependencies instead of \`dependsOn\`.
|
|
1082
|
-
`;
|
|
1123
|
+
`;
|
|
1124
|
+
|
|
1125
|
+
// skills/flow-plan/SKILL.md
|
|
1126
|
+
var SKILL_default4 = `---
|
|
1083
1127
|
name: flow-plan
|
|
1084
1128
|
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."
|
|
1085
1129
|
---
|
|
@@ -1094,14 +1138,13 @@ If \`flow_plan_save\` or \`flow_plan_approve\` is unavailable, stop and tell the
|
|
|
1094
1138
|
|
|
1095
1139
|
- Read the files, docs, tests, package scripts, and local conventions that determine the work.
|
|
1096
1140
|
- 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.
|
|
1141
|
+
- Helper rule: when a named helper skill is unavailable, record a planning gap
|
|
1142
|
+
and keep the corresponding claims conservative instead of simulating its
|
|
1143
|
+
checks.
|
|
1097
1144
|
- For complex validation, regression-sensitive changes, browser QA, route QA,
|
|
1098
|
-
failure-prone checks, or uncertain test strategy, load \`flow-test\`.
|
|
1099
|
-
|
|
1100
|
-
- For
|
|
1101
|
-
a planning gap and keep cleanup claims conservative.
|
|
1102
|
-
- For UI/frontend goals, load \`flow-ui-quality\`. If it is unavailable, record a
|
|
1103
|
-
planning gap and require next-best UI evidence rather than claiming visual
|
|
1104
|
-
quality was reviewed.
|
|
1145
|
+
failure-prone checks, or uncertain test strategy, load \`flow-test\`.
|
|
1146
|
+
- For cleanup/refactor goals, load \`flow-deslop\`.
|
|
1147
|
+
- For UI/frontend goals, load \`flow-ui-quality\`.
|
|
1105
1148
|
- Do not invent findings. Broad "review and fix" goals start with a review-first feature whose deliverable is evidence-backed findings.
|
|
1106
1149
|
|
|
1107
1150
|
## Plan shape
|
|
@@ -1149,7 +1192,10 @@ Use only \`finalReviewPolicy: "broad"\` or \`"detailed"\`. These are the canonic
|
|
|
1149
1192
|
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.
|
|
1150
1193
|
|
|
1151
1194
|
See \`references/planning-examples.md\` for payload examples and decomposition anti-patterns.
|
|
1152
|
-
`;
|
|
1195
|
+
`;
|
|
1196
|
+
|
|
1197
|
+
// skills/flow-review/references/review-rubric.md
|
|
1198
|
+
var review_rubric_default = `# Review rubric
|
|
1153
1199
|
|
|
1154
1200
|
Use this to decide whether a \`featureReview\` or \`finalReview\` payload may pass.
|
|
1155
1201
|
|
|
@@ -1237,7 +1283,10 @@ When reviewing a findings report, verify findings adversarially:
|
|
|
1237
1283
|
- Downgrade or reject findings that do not survive refutation.
|
|
1238
1284
|
|
|
1239
1285
|
Approve only on evidence actually inspected. A review is a claim of coverage, not a courtesy stamp.
|
|
1240
|
-
`;
|
|
1286
|
+
`;
|
|
1287
|
+
|
|
1288
|
+
// skills/flow-review/SKILL.md
|
|
1289
|
+
var SKILL_default5 = `---
|
|
1241
1290
|
name: flow-review
|
|
1242
1291
|
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."
|
|
1243
1292
|
---
|
|
@@ -1250,15 +1299,30 @@ If Flow tools, required Flow skills, or required references are unavailable or
|
|
|
1250
1299
|
stale, perform an advisory review and say that no Flow-gated review payload was
|
|
1251
1300
|
recorded.
|
|
1252
1301
|
|
|
1302
|
+
## Execution contexts
|
|
1303
|
+
|
|
1304
|
+
These instructions run in two contexts, and only one of them can load helpers:
|
|
1305
|
+
|
|
1306
|
+
- **Manager context**: the manager reviews inside \`flow-run\` or \`flow-auto\`
|
|
1307
|
+
before recording evidence. The manager may load helper skills and fan out
|
|
1308
|
+
read-only workers.
|
|
1309
|
+
- **Hidden reviewer context**: \`/flow-review\` runs as the \`flow-reviewer\`
|
|
1310
|
+
subagent, whose permissions deny skill loading, shell commands, and
|
|
1311
|
+
subagents. In this context, skip every "load" and "fan out" instruction
|
|
1312
|
+
below: judge from the diff, the plan fields, and the recorded validation
|
|
1313
|
+
evidence, and record a coverage gap for any judgment that would have needed
|
|
1314
|
+
a helper skill or a command run.
|
|
1315
|
+
|
|
1253
1316
|
## Start
|
|
1254
1317
|
|
|
1255
1318
|
- Call \`flow_status\` when available.
|
|
1256
1319
|
- Identify whether this is a feature review or final review.
|
|
1257
1320
|
- Read the approved plan fields relevant to the work: \`requirements\`, \`decisions\`, feature \`targets\`, feature \`validation\`, and dependencies.
|
|
1258
1321
|
- Inspect the actual diff, changed files, tests, and validation output. Do not review only the completion summary.
|
|
1259
|
-
-
|
|
1260
|
-
unclear coverage reviews. If it is
|
|
1261
|
-
|
|
1322
|
+
- In manager context, load \`flow-test\` for validation-heavy,
|
|
1323
|
+
regression-sensitive, browser QA, or unclear coverage reviews. If it is
|
|
1324
|
+
unavailable or you are the hidden reviewer, record a coverage gap and treat
|
|
1325
|
+
missing validation evidence as a gap or blocker based on user impact.
|
|
1262
1326
|
- Load \`references/review-rubric.md\` for severity, depth, and payload shape.
|
|
1263
1327
|
|
|
1264
1328
|
## Feature Review Depth
|
|
@@ -1296,18 +1360,23 @@ Use \`status: "failed"\` when any blocking finding remains. Advisory findings ma
|
|
|
1296
1360
|
|
|
1297
1361
|
## Special cases
|
|
1298
1362
|
|
|
1299
|
-
- 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.
|
|
1300
|
-
- 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.
|
|
1363
|
+
- 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.
|
|
1364
|
+
- 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.
|
|
1301
1365
|
- Audit reports: use \`../flow-run/references/audit-rubric.md\`; findings must survive refutation before they can drive fix features.
|
|
1302
|
-
- Large reviews: use
|
|
1303
|
-
read-only slices by
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
verification gates; only the manager
|
|
1307
|
-
\`finalReview\` payload.
|
|
1366
|
+
- Large reviews (manager context only): use
|
|
1367
|
+
\`../flow/references/parallel-orchestration.md\` for read-only slices by
|
|
1368
|
+
changed-file group, risk lens, or validation surface. Use the named review,
|
|
1369
|
+
audit, evidence, or validation agents from that reference instead of generic
|
|
1370
|
+
subagents. Apply its handoff format and verification gates; only the manager
|
|
1371
|
+
returns the final \`featureReview\` or \`finalReview\` payload. The hidden
|
|
1372
|
+
reviewer cannot spawn workers; it reviews its assigned scope directly and
|
|
1373
|
+
reports coverage gaps for the rest.
|
|
1308
1374
|
|
|
1309
1375
|
Never approve to unblock completion, fix findings in the review pass, or vouch for validation you did not inspect.
|
|
1310
|
-
`;
|
|
1376
|
+
`;
|
|
1377
|
+
|
|
1378
|
+
// skills/flow-run/references/audit-rubric.md
|
|
1379
|
+
var audit_rubric_default = `# Audit findings rubric
|
|
1311
1380
|
|
|
1312
1381
|
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.
|
|
1313
1382
|
|
|
@@ -1360,7 +1429,10 @@ follow-up order — correctness and persisted/user-input surfaces first
|
|
|
1360
1429
|
\`\`\`
|
|
1361
1430
|
|
|
1362
1431
|
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.
|
|
1363
|
-
`;
|
|
1432
|
+
`;
|
|
1433
|
+
|
|
1434
|
+
// skills/flow-run/references/validation-rubric.md
|
|
1435
|
+
var validation_rubric_default = `# Validation evidence rubric
|
|
1364
1436
|
|
|
1365
1437
|
Use this before recording \`flow_feature_complete\`.
|
|
1366
1438
|
|
|
@@ -1417,7 +1489,10 @@ Broad validation usually means the repo's full check command, full relevant test
|
|
|
1417
1489
|
- If validation needs external access, missing credentials, or ambiguous user input, record \`status: "needs_input"\` with an honest \`outcome\`.
|
|
1418
1490
|
|
|
1419
1491
|
Never trim failing output, relabel a failed command as passed, or use "not run" as completion evidence.
|
|
1420
|
-
`;
|
|
1492
|
+
`;
|
|
1493
|
+
|
|
1494
|
+
// skills/flow-run/SKILL.md
|
|
1495
|
+
var SKILL_default6 = `---
|
|
1421
1496
|
name: flow-run
|
|
1422
1497
|
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."
|
|
1423
1498
|
---
|
|
@@ -1433,9 +1508,10 @@ If \`flow_run_start\` is unavailable, stop and tell the user to check that \`ope
|
|
|
1433
1508
|
- Call \`flow_status\`.
|
|
1434
1509
|
- Call \`flow_run_start\` with no \`featureId\` unless the user or plan requires a specific runnable feature.
|
|
1435
1510
|
- Treat the returned feature as the sole scope until it is completed, blocked, or reset.
|
|
1436
|
-
-
|
|
1437
|
-
|
|
1438
|
-
- Load \`flow-
|
|
1511
|
+
- Helper rule: when a named helper skill is unavailable, record the gap and
|
|
1512
|
+
keep the corresponding claims conservative instead of simulating its checks.
|
|
1513
|
+
- Load \`flow-deslop\` for cleanup/refactor features.
|
|
1514
|
+
- Load \`flow-ui-quality\` for frontend, UX, responsive, accessibility, or visual work.
|
|
1439
1515
|
|
|
1440
1516
|
## Implement
|
|
1441
1517
|
|
|
@@ -1453,8 +1529,7 @@ If \`flow_run_start\` is unavailable, stop and tell the user to check that \`ope
|
|
|
1453
1529
|
|
|
1454
1530
|
- For complex validation, regression-sensitive changes, browser QA, route QA,
|
|
1455
1531
|
failure-prone checks, unclear coverage, exploratory QA, or
|
|
1456
|
-
\`validationRun\` summarization, load \`flow-test
|
|
1457
|
-
the coverage gap and keep validation claims conservative.
|
|
1532
|
+
\`validationRun\` summarization, load \`flow-test\` (helper rule applies).
|
|
1458
1533
|
- Read \`references/validation-rubric.md\` before completing.
|
|
1459
1534
|
- Run the strongest practical checks for the changed behavior.
|
|
1460
1535
|
- Record concrete command names, status, and observed results. "Tests pass" is not evidence.
|
|
@@ -1504,7 +1579,10 @@ Complete with:
|
|
|
1504
1579
|
\`\`\`
|
|
1505
1580
|
|
|
1506
1581
|
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.
|
|
1507
|
-
`;
|
|
1582
|
+
`;
|
|
1583
|
+
|
|
1584
|
+
// skills/flow-test/SKILL.md
|
|
1585
|
+
var SKILL_default7 = `---
|
|
1508
1586
|
name: flow-test
|
|
1509
1587
|
description: Test, validate, make test plans, triage failures, and gather Flow validation evidence. Use when selecting checks, running tests, running browser QA for UI changes, classifying failures, or preparing validationRun evidence for flow_feature_complete.
|
|
1510
1588
|
---
|
|
@@ -1628,7 +1706,10 @@ covered. Static inspection alone is a gap for behavioral changes.
|
|
|
1628
1706
|
|
|
1629
1707
|
Never relabel a failed command as passed, invent output, or use "not run" as
|
|
1630
1708
|
completion evidence.
|
|
1631
|
-
`;
|
|
1709
|
+
`;
|
|
1710
|
+
|
|
1711
|
+
// skills/flow-ui-quality/references/ui-rubric.md
|
|
1712
|
+
var ui_rubric_default = `# UI quality rubric
|
|
1632
1713
|
|
|
1633
1714
|
Use this rubric for frontend planning, implementation, and review.
|
|
1634
1715
|
|
|
@@ -1672,7 +1753,10 @@ class; severity; location or screenshot area; evidence inspected; user impact; f
|
|
|
1672
1753
|
\`\`\`
|
|
1673
1754
|
|
|
1674
1755
|
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.
|
|
1675
|
-
`;
|
|
1756
|
+
`;
|
|
1757
|
+
|
|
1758
|
+
// skills/flow-ui-quality/references/visual-verification.md
|
|
1759
|
+
var visual_verification_default = `# Visual verification workflow
|
|
1676
1760
|
|
|
1677
1761
|
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.
|
|
1678
1762
|
|
|
@@ -1712,7 +1796,10 @@ Record the reason and use the strongest available substitute:
|
|
|
1712
1796
|
- code inspection against existing component patterns.
|
|
1713
1797
|
|
|
1714
1798
|
Do not claim visual polish was verified if no visual artifact was inspected.
|
|
1715
|
-
`;
|
|
1799
|
+
`;
|
|
1800
|
+
|
|
1801
|
+
// skills/flow-ui-quality/SKILL.md
|
|
1802
|
+
var SKILL_default8 = `---
|
|
1716
1803
|
name: flow-ui-quality
|
|
1717
1804
|
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, screenshots, browser-verified UI work, and avoiding generic AI-generated UI.
|
|
1718
1805
|
---
|
|
@@ -1760,23 +1847,580 @@ Approve only when the interface is both useful and inspectable:
|
|
|
1760
1847
|
- Screenshot/browser evidence supports the claim whenever feasible.
|
|
1761
1848
|
|
|
1762
1849
|
Never approve a UI change based only on code shape. If users will judge it visually, Flow evidence should include visual inspection.
|
|
1763
|
-
`;
|
|
1764
|
-
|
|
1850
|
+
`;
|
|
1851
|
+
|
|
1852
|
+
// src/distribution/flow-skill-definitions.ts
|
|
1853
|
+
var FLOW_SKILL_DEFINITIONS = [
|
|
1854
|
+
{
|
|
1855
|
+
name: "flow",
|
|
1856
|
+
files: [
|
|
1857
|
+
{ relativePath: "SKILL.md", content: SKILL_default },
|
|
1858
|
+
{
|
|
1859
|
+
relativePath: "references/recovery-playbook.md",
|
|
1860
|
+
content: recovery_playbook_default
|
|
1861
|
+
},
|
|
1862
|
+
{
|
|
1863
|
+
relativePath: "references/parallel-orchestration.md",
|
|
1864
|
+
content: parallel_orchestration_default
|
|
1865
|
+
},
|
|
1866
|
+
{
|
|
1867
|
+
relativePath: "references/parallel-pass-patterns.md",
|
|
1868
|
+
content: parallel_pass_patterns_default
|
|
1869
|
+
},
|
|
1870
|
+
{
|
|
1871
|
+
relativePath: "references/parallel-pass-example.md",
|
|
1872
|
+
content: parallel_pass_example_default
|
|
1873
|
+
},
|
|
1874
|
+
{
|
|
1875
|
+
relativePath: "references/handoff-format.md",
|
|
1876
|
+
content: handoff_format_default
|
|
1877
|
+
},
|
|
1878
|
+
{
|
|
1879
|
+
relativePath: "references/verification-gates.md",
|
|
1880
|
+
content: verification_gates_default
|
|
1881
|
+
}
|
|
1882
|
+
]
|
|
1883
|
+
},
|
|
1884
|
+
{
|
|
1885
|
+
name: "flow-plan",
|
|
1886
|
+
files: [
|
|
1887
|
+
{ relativePath: "SKILL.md", content: SKILL_default4 },
|
|
1888
|
+
{
|
|
1889
|
+
relativePath: "references/planning-examples.md",
|
|
1890
|
+
content: planning_examples_default
|
|
1891
|
+
},
|
|
1892
|
+
{
|
|
1893
|
+
relativePath: "references/parallel-discovery.md",
|
|
1894
|
+
content: parallel_discovery_default
|
|
1895
|
+
}
|
|
1896
|
+
]
|
|
1897
|
+
},
|
|
1898
|
+
{
|
|
1899
|
+
name: "flow-run",
|
|
1900
|
+
files: [
|
|
1901
|
+
{ relativePath: "SKILL.md", content: SKILL_default6 },
|
|
1902
|
+
{
|
|
1903
|
+
relativePath: "references/validation-rubric.md",
|
|
1904
|
+
content: validation_rubric_default
|
|
1905
|
+
},
|
|
1906
|
+
{
|
|
1907
|
+
relativePath: "references/audit-rubric.md",
|
|
1908
|
+
content: audit_rubric_default
|
|
1909
|
+
}
|
|
1910
|
+
]
|
|
1911
|
+
},
|
|
1912
|
+
{
|
|
1913
|
+
name: "flow-test",
|
|
1914
|
+
files: [{ relativePath: "SKILL.md", content: SKILL_default7 }]
|
|
1915
|
+
},
|
|
1916
|
+
{
|
|
1917
|
+
name: "flow-review",
|
|
1918
|
+
files: [
|
|
1919
|
+
{ relativePath: "SKILL.md", content: SKILL_default5 },
|
|
1920
|
+
{
|
|
1921
|
+
relativePath: "references/review-rubric.md",
|
|
1922
|
+
content: review_rubric_default
|
|
1923
|
+
}
|
|
1924
|
+
]
|
|
1925
|
+
},
|
|
1926
|
+
{
|
|
1927
|
+
name: "flow-deslop",
|
|
1928
|
+
files: [
|
|
1929
|
+
{ relativePath: "SKILL.md", content: SKILL_default3 },
|
|
1930
|
+
{
|
|
1931
|
+
relativePath: "references/smell-rubric.md",
|
|
1932
|
+
content: smell_rubric_default
|
|
1933
|
+
},
|
|
1934
|
+
{
|
|
1935
|
+
relativePath: "references/refactor-workflow.md",
|
|
1936
|
+
content: refactor_workflow_default
|
|
1937
|
+
}
|
|
1938
|
+
]
|
|
1939
|
+
},
|
|
1940
|
+
{
|
|
1941
|
+
name: "flow-ui-quality",
|
|
1942
|
+
files: [
|
|
1943
|
+
{ relativePath: "SKILL.md", content: SKILL_default8 },
|
|
1944
|
+
{
|
|
1945
|
+
relativePath: "references/ui-rubric.md",
|
|
1946
|
+
content: ui_rubric_default
|
|
1947
|
+
},
|
|
1948
|
+
{
|
|
1949
|
+
relativePath: "references/visual-verification.md",
|
|
1950
|
+
content: visual_verification_default
|
|
1951
|
+
}
|
|
1952
|
+
]
|
|
1953
|
+
},
|
|
1954
|
+
{
|
|
1955
|
+
name: "flow-commit",
|
|
1956
|
+
files: [{ relativePath: "SKILL.md", content: SKILL_default2 }]
|
|
1957
|
+
}
|
|
1958
|
+
];
|
|
1959
|
+
|
|
1960
|
+
// src/distribution/sync.ts
|
|
1961
|
+
var MARKER_FILENAME = ".flow-skill-version";
|
|
1962
|
+
function homeDir() {
|
|
1963
|
+
return process.env.HOME ?? process.env.USERPROFILE ?? homedir();
|
|
1964
|
+
}
|
|
1965
|
+
function resolveFlowSkillsRoot(home = homeDir()) {
|
|
1966
|
+
return join(home, ".config", "opencode", "skills");
|
|
1967
|
+
}
|
|
1968
|
+
function sha256(value) {
|
|
1969
|
+
return createHash("sha256").update(value).digest("hex");
|
|
1970
|
+
}
|
|
1971
|
+
function markerFor(definition, version) {
|
|
1972
|
+
return [
|
|
1973
|
+
`version=${version}`,
|
|
1974
|
+
...definition.files.map((file) => `file=${file.relativePath} sha256=${sha256(file.content)}`),
|
|
1975
|
+
""
|
|
1976
|
+
].join(`
|
|
1977
|
+
`);
|
|
1978
|
+
}
|
|
1979
|
+
async function optionalRead(path) {
|
|
1980
|
+
try {
|
|
1981
|
+
return await readFile(path, "utf8");
|
|
1982
|
+
} catch (error) {
|
|
1983
|
+
if (error.code === "ENOENT")
|
|
1984
|
+
return null;
|
|
1985
|
+
throw error;
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
function parseMarkerFiles(content) {
|
|
1989
|
+
const files = new Map;
|
|
1990
|
+
if (!content)
|
|
1991
|
+
return files;
|
|
1992
|
+
for (const line of content.split(/\r?\n/)) {
|
|
1993
|
+
const match = /^file=(.+) sha256=([a-f0-9]{64})$/.exec(line) ?? /^file=(.+)=sha256:([a-f0-9]{64})$/.exec(line);
|
|
1994
|
+
if (match?.[1] && match[2])
|
|
1995
|
+
files.set(match[1], match[2]);
|
|
1996
|
+
const topLevelHash = /^hash=sha256:([a-f0-9]{64})$/.exec(line);
|
|
1997
|
+
if (topLevelHash?.[1] && !files.has("SKILL.md")) {
|
|
1998
|
+
files.set("SKILL.md", topLevelHash[1]);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
return files;
|
|
2002
|
+
}
|
|
2003
|
+
function parseMarkerVersion(content) {
|
|
2004
|
+
if (!content)
|
|
2005
|
+
return null;
|
|
2006
|
+
for (const line of content.split(/\r?\n/)) {
|
|
2007
|
+
const match = /^version=(.+)$/.exec(line);
|
|
2008
|
+
if (match?.[1])
|
|
2009
|
+
return match[1];
|
|
2010
|
+
}
|
|
2011
|
+
return null;
|
|
2012
|
+
}
|
|
2013
|
+
function resolveSkillFile(folder, relativePath) {
|
|
2014
|
+
const resolved = normalize(join(folder, ...relativePath.split("/")));
|
|
2015
|
+
if (resolved !== folder && resolved.startsWith(`${folder}${sep}`)) {
|
|
2016
|
+
return resolved;
|
|
2017
|
+
}
|
|
2018
|
+
throw new Error(`Unsafe skill file path '${relativePath}'.`);
|
|
2019
|
+
}
|
|
2020
|
+
async function writeBackup(path, content) {
|
|
2021
|
+
const basePath = `${path}.backup.${sha256(content).slice(0, 12)}`;
|
|
2022
|
+
for (let index = 0;; index += 1) {
|
|
2023
|
+
const backupPath = index === 0 ? basePath : `${basePath}.${index}`;
|
|
2024
|
+
try {
|
|
2025
|
+
await writeFile(backupPath, content, { encoding: "utf8", flag: "wx" });
|
|
2026
|
+
return backupPath;
|
|
2027
|
+
} catch (error) {
|
|
2028
|
+
if (error.code === "EEXIST")
|
|
2029
|
+
continue;
|
|
2030
|
+
throw error;
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
async function syncSkill(definition, version, root) {
|
|
2035
|
+
const folder = join(root, definition.name);
|
|
2036
|
+
const markerPath = join(folder, MARKER_FILENAME);
|
|
2037
|
+
const markerContent = await optionalRead(markerPath);
|
|
2038
|
+
const existingMarkerHashes = parseMarkerFiles(markerContent);
|
|
2039
|
+
const existingSkill = await optionalRead(join(folder, "SKILL.md"));
|
|
2040
|
+
if (existingSkill !== null && markerContent === null) {
|
|
2041
|
+
return { name: definition.name, action: "skipped_foreign" };
|
|
2042
|
+
}
|
|
2043
|
+
let changed = false;
|
|
2044
|
+
const backupPaths = [];
|
|
2045
|
+
const currentRelativePaths = new Set(definition.files.map((file) => file.relativePath));
|
|
2046
|
+
for (const file of definition.files) {
|
|
2047
|
+
const path = resolveSkillFile(folder, file.relativePath);
|
|
2048
|
+
const existing = await optionalRead(path);
|
|
2049
|
+
if (existing === file.content)
|
|
2050
|
+
continue;
|
|
2051
|
+
changed = true;
|
|
2052
|
+
const recordedHash = existingMarkerHashes.get(file.relativePath);
|
|
2053
|
+
const userEdited = existing !== null && (recordedHash ? sha256(existing) !== recordedHash : markerContent !== null);
|
|
2054
|
+
if (userEdited) {
|
|
2055
|
+
backupPaths.push(await writeBackup(path, existing));
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
for (const [relativePath, recordedHash] of existingMarkerHashes) {
|
|
2059
|
+
if (currentRelativePaths.has(relativePath))
|
|
2060
|
+
continue;
|
|
2061
|
+
const path = resolveSkillFile(folder, relativePath);
|
|
2062
|
+
const existing = await optionalRead(path);
|
|
2063
|
+
if (existing === null)
|
|
2064
|
+
continue;
|
|
2065
|
+
changed = true;
|
|
2066
|
+
if (sha256(existing) !== recordedHash) {
|
|
2067
|
+
backupPaths.push(await writeBackup(path, existing));
|
|
2068
|
+
}
|
|
2069
|
+
await rm(path, { force: true });
|
|
2070
|
+
}
|
|
2071
|
+
if (!changed && markerContent === markerFor(definition, version)) {
|
|
2072
|
+
return { name: definition.name, action: "unchanged" };
|
|
2073
|
+
}
|
|
2074
|
+
if (!changed) {
|
|
2075
|
+
await writeFile(markerPath, markerFor(definition, version), "utf8");
|
|
2076
|
+
return { name: definition.name, action: "marker_updated" };
|
|
2077
|
+
}
|
|
2078
|
+
const managedSkillExists = markerContent !== null;
|
|
2079
|
+
for (const file of definition.files) {
|
|
2080
|
+
const path = resolveSkillFile(folder, file.relativePath);
|
|
2081
|
+
await mkdir(dirname(path), { recursive: true });
|
|
2082
|
+
await writeFile(path, file.content, "utf8");
|
|
2083
|
+
}
|
|
2084
|
+
await writeFile(markerPath, markerFor(definition, version), "utf8");
|
|
2085
|
+
return {
|
|
2086
|
+
name: definition.name,
|
|
2087
|
+
action: backupPaths.length > 0 ? "updated_with_backup" : managedSkillExists ? "updated" : "installed",
|
|
2088
|
+
...backupPaths.length > 0 ? { backupPaths } : {}
|
|
2089
|
+
};
|
|
2090
|
+
}
|
|
2091
|
+
function expectedSkillNames() {
|
|
2092
|
+
return FLOW_SKILL_DEFINITIONS.map((definition) => definition.name);
|
|
2093
|
+
}
|
|
2094
|
+
function formatFlowDoctorCommand(version) {
|
|
2095
|
+
const pin = version === "0.0.0" ? "latest" : version;
|
|
2096
|
+
return `npx -y opencode-plugin-flow@${pin} doctor`;
|
|
2097
|
+
}
|
|
2098
|
+
function resolveFlowPluginVersion() {
|
|
2099
|
+
if (process.env.npm_package_version)
|
|
2100
|
+
return process.env.npm_package_version;
|
|
2101
|
+
try {
|
|
2102
|
+
const require2 = createRequire(import.meta.url);
|
|
2103
|
+
for (const path of ["../package.json", "../../package.json"]) {
|
|
2104
|
+
try {
|
|
2105
|
+
const manifest = require2(path);
|
|
2106
|
+
if (manifest.version)
|
|
2107
|
+
return manifest.version;
|
|
2108
|
+
} catch {}
|
|
2109
|
+
}
|
|
2110
|
+
} catch {}
|
|
2111
|
+
return "0.0.0";
|
|
2112
|
+
}
|
|
2113
|
+
async function syncFlowSkills(version, home = homeDir()) {
|
|
2114
|
+
const root = resolveFlowSkillsRoot(home);
|
|
2115
|
+
return Promise.all(FLOW_SKILL_DEFINITIONS.map((definition) => syncSkill(definition, version, root)));
|
|
2116
|
+
}
|
|
2117
|
+
async function inspectFlowSkillInstall(version = resolveFlowPluginVersion(), home = homeDir()) {
|
|
2118
|
+
const root = resolveFlowSkillsRoot(home);
|
|
2119
|
+
const expected = new Set(expectedSkillNames());
|
|
2120
|
+
const skills = await Promise.all(FLOW_SKILL_DEFINITIONS.map(async (definition) => {
|
|
2121
|
+
const folder = join(root, definition.name);
|
|
2122
|
+
const markerContent = await optionalRead(join(folder, MARKER_FILENAME));
|
|
2123
|
+
const markerVersion = parseMarkerVersion(markerContent);
|
|
2124
|
+
const markerHashes = parseMarkerFiles(markerContent);
|
|
2125
|
+
const existingSkill = await optionalRead(join(folder, "SKILL.md"));
|
|
2126
|
+
if (existingSkill === null) {
|
|
2127
|
+
return {
|
|
2128
|
+
name: definition.name,
|
|
2129
|
+
path: folder,
|
|
2130
|
+
status: "missing",
|
|
2131
|
+
markerVersion,
|
|
2132
|
+
missingFiles: definition.files.map((file) => file.relativePath),
|
|
2133
|
+
editedFiles: [],
|
|
2134
|
+
outdatedFiles: []
|
|
2135
|
+
};
|
|
2136
|
+
}
|
|
2137
|
+
if (markerContent === null) {
|
|
2138
|
+
return {
|
|
2139
|
+
name: definition.name,
|
|
2140
|
+
path: folder,
|
|
2141
|
+
status: "foreign",
|
|
2142
|
+
markerVersion,
|
|
2143
|
+
missingFiles: [],
|
|
2144
|
+
editedFiles: [],
|
|
2145
|
+
outdatedFiles: []
|
|
2146
|
+
};
|
|
2147
|
+
}
|
|
2148
|
+
const missingFiles = [];
|
|
2149
|
+
const editedFiles = [];
|
|
2150
|
+
const outdatedFiles = [];
|
|
2151
|
+
for (const file of definition.files) {
|
|
2152
|
+
const existing = await optionalRead(resolveSkillFile(folder, file.relativePath));
|
|
2153
|
+
if (existing === null) {
|
|
2154
|
+
missingFiles.push(file.relativePath);
|
|
2155
|
+
continue;
|
|
2156
|
+
}
|
|
2157
|
+
if (existing === file.content)
|
|
2158
|
+
continue;
|
|
2159
|
+
const recordedHash = markerHashes.get(file.relativePath);
|
|
2160
|
+
if (recordedHash && sha256(existing) !== recordedHash) {
|
|
2161
|
+
editedFiles.push(file.relativePath);
|
|
2162
|
+
continue;
|
|
2163
|
+
}
|
|
2164
|
+
outdatedFiles.push(file.relativePath);
|
|
2165
|
+
}
|
|
2166
|
+
const markerDrift = markerContent !== markerFor(definition, version);
|
|
2167
|
+
const status = missingFiles.length > 0 ? "incomplete" : editedFiles.length > 0 ? "edited" : markerDrift || outdatedFiles.length > 0 ? "outdated" : "ok";
|
|
2168
|
+
return {
|
|
2169
|
+
name: definition.name,
|
|
2170
|
+
path: folder,
|
|
2171
|
+
status,
|
|
2172
|
+
markerVersion,
|
|
2173
|
+
missingFiles,
|
|
2174
|
+
editedFiles,
|
|
2175
|
+
outdatedFiles
|
|
2176
|
+
};
|
|
2177
|
+
}));
|
|
2178
|
+
let entries = [];
|
|
2179
|
+
try {
|
|
2180
|
+
entries = await readdir(root);
|
|
2181
|
+
} catch (error) {
|
|
2182
|
+
if (error.code !== "ENOENT")
|
|
2183
|
+
throw error;
|
|
2184
|
+
}
|
|
2185
|
+
const unmanagedFlowSkills = entries.filter((name) => (name === "flow" || name.startsWith("flow-")) && !expected.has(name)).map((name) => join(root, name));
|
|
2186
|
+
const syncRequiredSkills = skills.filter((skill) => ["missing", "incomplete", "outdated"].includes(skill.status)).map((skill) => skill.name);
|
|
2187
|
+
const actionRequiredSkills = skills.filter((skill) => ["foreign", "edited"].includes(skill.status)).map((skill) => skill.name);
|
|
2188
|
+
const actionRequired = actionRequiredSkills.length > 0;
|
|
2189
|
+
const syncRequired = syncRequiredSkills.length > 0;
|
|
2190
|
+
return {
|
|
2191
|
+
status: actionRequired ? "action_required" : syncRequired ? "sync_required" : "ok",
|
|
2192
|
+
version,
|
|
2193
|
+
root,
|
|
2194
|
+
expectedSkills: [...expected],
|
|
2195
|
+
skills,
|
|
2196
|
+
syncRequiredSkills,
|
|
2197
|
+
actionRequiredSkills,
|
|
2198
|
+
unmanagedFlowSkills
|
|
2199
|
+
};
|
|
2200
|
+
}
|
|
2201
|
+
function appendSkillList(lines, label, skills) {
|
|
2202
|
+
if (skills.length === 0)
|
|
2203
|
+
return;
|
|
2204
|
+
lines.push(`- ${label}: ${skills.join(", ")}`);
|
|
2205
|
+
}
|
|
2206
|
+
function formatFlowSkillDoctor(report) {
|
|
2207
|
+
const lines = [
|
|
2208
|
+
"Flow doctor",
|
|
2209
|
+
`- status: ${report.status}`,
|
|
2210
|
+
`- plugin version: ${report.version}`,
|
|
2211
|
+
`- skills root: ${report.root}`,
|
|
2212
|
+
`- expected skills: ${report.expectedSkills.join(", ")}`
|
|
2213
|
+
];
|
|
2214
|
+
appendSkillList(lines, "startup sync can install/update", report.syncRequiredSkills);
|
|
2215
|
+
appendSkillList(lines, "needs user decision", report.actionRequiredSkills);
|
|
2216
|
+
lines.push("", "Skills:");
|
|
2217
|
+
for (const skill of report.skills) {
|
|
2218
|
+
lines.push(`- ${skill.name}: ${skill.status} (${skill.path})${skill.markerVersion ? ` marker=${skill.markerVersion}` : ""}`);
|
|
2219
|
+
if (skill.missingFiles.length > 0) {
|
|
2220
|
+
lines.push(` missing: ${skill.missingFiles.join(", ")}`);
|
|
2221
|
+
}
|
|
2222
|
+
if (skill.editedFiles.length > 0) {
|
|
2223
|
+
lines.push(` edited: ${skill.editedFiles.join(", ")}`);
|
|
2224
|
+
}
|
|
2225
|
+
if (skill.outdatedFiles.length > 0) {
|
|
2226
|
+
lines.push(` outdated: ${skill.outdatedFiles.join(", ")}`);
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
if (report.unmanagedFlowSkills.length > 0) {
|
|
2230
|
+
lines.push("", "Unmanaged Flow-like skill folders:");
|
|
2231
|
+
for (const path of report.unmanagedFlowSkills)
|
|
2232
|
+
lines.push(`- ${path}`);
|
|
2233
|
+
}
|
|
2234
|
+
lines.push("", "Recommendation:");
|
|
2235
|
+
if (report.status === "ok") {
|
|
2236
|
+
lines.push("- Flow skills are present and current.");
|
|
2237
|
+
} else if (report.status === "sync_required") {
|
|
2238
|
+
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.");
|
|
2239
|
+
} else {
|
|
2240
|
+
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.");
|
|
2241
|
+
}
|
|
2242
|
+
lines.push(`- Details command: ${formatFlowDoctorCommand(report.version)}`);
|
|
2243
|
+
return `${lines.join(`
|
|
1765
2244
|
`)}
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
2245
|
+
`;
|
|
2246
|
+
}
|
|
2247
|
+
async function listSkillFolderFiles(folder) {
|
|
2248
|
+
const entries = await readdir(folder, {
|
|
2249
|
+
recursive: true,
|
|
2250
|
+
withFileTypes: true
|
|
2251
|
+
});
|
|
2252
|
+
return entries.filter((entry) => entry.isFile()).map((entry) => join(entry.parentPath, entry.name).slice(folder.length + 1).split(sep).join("/"));
|
|
2253
|
+
}
|
|
2254
|
+
async function isPristineManagedFolder(folder, markerContent) {
|
|
2255
|
+
const hashes = parseMarkerFiles(markerContent);
|
|
2256
|
+
if (hashes.size === 0)
|
|
2257
|
+
return false;
|
|
2258
|
+
for (const relativePath of await listSkillFolderFiles(folder)) {
|
|
2259
|
+
if (relativePath === MARKER_FILENAME)
|
|
2260
|
+
continue;
|
|
2261
|
+
const recordedHash = hashes.get(relativePath);
|
|
2262
|
+
if (recordedHash === undefined)
|
|
2263
|
+
return false;
|
|
2264
|
+
const content = await optionalRead(resolveSkillFile(folder, relativePath));
|
|
2265
|
+
if (content === null || sha256(content) !== recordedHash)
|
|
2266
|
+
return false;
|
|
2267
|
+
}
|
|
2268
|
+
return true;
|
|
2269
|
+
}
|
|
2270
|
+
async function uninstallFlowSkills(home = homeDir(), options = {}) {
|
|
2271
|
+
const root = resolveFlowSkillsRoot(home);
|
|
2272
|
+
const removed = [];
|
|
2273
|
+
const kept = [];
|
|
2274
|
+
let entries;
|
|
2275
|
+
try {
|
|
2276
|
+
entries = await readdir(root);
|
|
2277
|
+
} catch (error) {
|
|
2278
|
+
if (error.code === "ENOENT") {
|
|
2279
|
+
return { removed, kept };
|
|
2280
|
+
}
|
|
2281
|
+
throw error;
|
|
2282
|
+
}
|
|
2283
|
+
for (const name of entries) {
|
|
2284
|
+
if (name !== "flow" && !name.startsWith("flow-"))
|
|
2285
|
+
continue;
|
|
2286
|
+
const folder = join(root, name);
|
|
2287
|
+
const markerContent = await optionalRead(join(folder, MARKER_FILENAME));
|
|
2288
|
+
if (markerContent === null || !await isPristineManagedFolder(folder, markerContent)) {
|
|
2289
|
+
kept.push(folder);
|
|
2290
|
+
continue;
|
|
2291
|
+
}
|
|
2292
|
+
if (!options.dryRun) {
|
|
2293
|
+
await rm(folder, { recursive: true, force: true });
|
|
2294
|
+
}
|
|
2295
|
+
removed.push(folder);
|
|
2296
|
+
}
|
|
2297
|
+
return { removed, kept };
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
// src/cli.ts
|
|
2301
|
+
function usage() {
|
|
2302
|
+
return [
|
|
2303
|
+
"usage: opencode-plugin-flow <doctor|sync|uninstall> [options]",
|
|
2304
|
+
"",
|
|
2305
|
+
"commands:",
|
|
2306
|
+
" doctor Inspect managed Flow skills",
|
|
2307
|
+
" sync Install or refresh managed Flow skills",
|
|
2308
|
+
" uninstall Remove pristine Flow-owned managed skills",
|
|
2309
|
+
"",
|
|
2310
|
+
"doctor options:",
|
|
2311
|
+
" --json Write the doctor report as JSON",
|
|
2312
|
+
" --check, --strict Exit nonzero when doctor status is not ok",
|
|
2313
|
+
"",
|
|
2314
|
+
"uninstall options:",
|
|
2315
|
+
" --dry-run Preview removals without deleting anything",
|
|
2316
|
+
"",
|
|
2317
|
+
"global options:",
|
|
2318
|
+
" --help Show this help",
|
|
2319
|
+
" --version Print the plugin version"
|
|
2320
|
+
].join(`
|
|
2321
|
+
`);
|
|
2322
|
+
}
|
|
2323
|
+
function hasOnlyKnownFlags(flags, known) {
|
|
2324
|
+
return flags.every((flag) => known.has(flag));
|
|
2325
|
+
}
|
|
2326
|
+
function writeDoctorReport(report, options) {
|
|
2327
|
+
if (options.json) {
|
|
2328
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}
|
|
2329
|
+
`);
|
|
2330
|
+
return;
|
|
2331
|
+
}
|
|
2332
|
+
process.stdout.write(formatFlowSkillDoctor(report));
|
|
2333
|
+
}
|
|
2334
|
+
async function main(argv) {
|
|
2335
|
+
const command = argv[2];
|
|
2336
|
+
const flags = argv.slice(3);
|
|
2337
|
+
if (command === "--help" || command === "-h") {
|
|
2338
|
+
process.stdout.write(`${usage()}
|
|
2339
|
+
`);
|
|
2340
|
+
return;
|
|
2341
|
+
}
|
|
2342
|
+
if (command === "--version" || command === "-v") {
|
|
2343
|
+
process.stdout.write(`${resolveFlowPluginVersion()}
|
|
2344
|
+
`);
|
|
2345
|
+
return;
|
|
2346
|
+
}
|
|
2347
|
+
if (command !== "uninstall" && command !== "doctor" && command !== "sync") {
|
|
2348
|
+
process.stderr.write(`${usage()}
|
|
2349
|
+
`);
|
|
2350
|
+
process.exitCode = 2;
|
|
2351
|
+
return;
|
|
2352
|
+
}
|
|
2353
|
+
if (command === "doctor") {
|
|
2354
|
+
const knownDoctorFlags = new Set(["--json", "--check", "--strict"]);
|
|
2355
|
+
if (!hasOnlyKnownFlags(flags, knownDoctorFlags)) {
|
|
2356
|
+
process.stderr.write(`${usage()}
|
|
2357
|
+
`);
|
|
2358
|
+
process.exitCode = 2;
|
|
2359
|
+
return;
|
|
2360
|
+
}
|
|
2361
|
+
const report = await inspectFlowSkillInstall();
|
|
2362
|
+
writeDoctorReport(report, { json: flags.includes("--json") });
|
|
2363
|
+
if ((report.status === "sync_required" || report.status === "action_required") && (flags.includes("--check") || flags.includes("--strict"))) {
|
|
2364
|
+
process.exitCode = 1;
|
|
2365
|
+
}
|
|
2366
|
+
return;
|
|
2367
|
+
}
|
|
2368
|
+
const knownUninstallFlags = new Set(["--dry-run"]);
|
|
2369
|
+
if (command === "uninstall" && !hasOnlyKnownFlags(flags, knownUninstallFlags)) {
|
|
2370
|
+
process.stderr.write(`${usage()}
|
|
2371
|
+
`);
|
|
2372
|
+
process.exitCode = 2;
|
|
2373
|
+
return;
|
|
2374
|
+
}
|
|
2375
|
+
if (command === "sync" && flags.length > 0) {
|
|
2376
|
+
process.stderr.write(`${usage()}
|
|
2377
|
+
`);
|
|
2378
|
+
process.exitCode = 2;
|
|
2379
|
+
return;
|
|
2380
|
+
}
|
|
2381
|
+
if (command === "sync") {
|
|
2382
|
+
const version = resolveFlowPluginVersion();
|
|
2383
|
+
const results = await syncFlowSkills(version);
|
|
2384
|
+
const changed = results.filter((result2) => ["installed", "updated", "updated_with_backup"].includes(result2.action));
|
|
2385
|
+
const actionRequired = results.filter((result2) => result2.action === "skipped_foreign");
|
|
2386
|
+
process.stdout.write(`Flow skill sync (${version})
|
|
2387
|
+
`);
|
|
2388
|
+
for (const result2 of results) {
|
|
2389
|
+
process.stdout.write(`- ${result2.name}: ${result2.action}
|
|
2390
|
+
`);
|
|
2391
|
+
for (const backupPath of result2.backupPaths ?? []) {
|
|
2392
|
+
process.stdout.write(` backup: ${backupPath}
|
|
2393
|
+
`);
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
if (changed.length > 0) {
|
|
2397
|
+
process.stdout.write(`Restart OpenCode so the refreshed skill registry is used.
|
|
2398
|
+
`);
|
|
2399
|
+
}
|
|
2400
|
+
if (actionRequired.length > 0) {
|
|
2401
|
+
process.stdout.write(`Some managed skill folders are user-owned or edited; run doctor for repair guidance.
|
|
2402
|
+
`);
|
|
2403
|
+
}
|
|
2404
|
+
return;
|
|
2405
|
+
}
|
|
2406
|
+
const dryRun = flags.includes("--dry-run");
|
|
2407
|
+
const result = await uninstallFlowSkills(undefined, { dryRun });
|
|
2408
|
+
for (const path of result.removed) {
|
|
2409
|
+
process.stdout.write(`${dryRun ? "Would remove" : "Removed"} Flow skill: ${path}
|
|
2410
|
+
`);
|
|
2411
|
+
}
|
|
2412
|
+
for (const path of result.kept) {
|
|
2413
|
+
process.stdout.write(`Kept non-Flow or user-edited skill: ${path}
|
|
2414
|
+
`);
|
|
2415
|
+
}
|
|
2416
|
+
process.stdout.write(dryRun ? `Dry run: no files were removed.
|
|
2417
|
+
` : `Remove opencode-plugin-flow from your OpenCode plugin config and restart OpenCode.
|
|
2418
|
+
`);
|
|
2419
|
+
}
|
|
2420
|
+
main(process.argv).catch((error) => {
|
|
2421
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}
|
|
2422
|
+
`);
|
|
2423
|
+
process.exitCode = 1;
|
|
2424
|
+
});
|
|
2425
|
+
|
|
2426
|
+
//# debugId=8ECEECE32879216C64756E2164756E21
|