opencode-plugin-flow 4.1.18 → 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 +83 -23
- package/README.md +102 -163
- package/dist/cli.js +797 -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 +2468 -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,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\`.
|
|
427
|
+
|
|
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
|
+
`;
|
|
410
433
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
decision, review payload, or docs patch. Raw handoffs and unverified suggestions
|
|
414
|
-
do not move into the next pass or user-facing answer.
|
|
415
|
-
`;var z=`# Parallel pass patterns
|
|
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,7 +643,10 @@ 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
|
-
`;
|
|
646
|
+
`;
|
|
647
|
+
|
|
648
|
+
// skills/flow/SKILL.md
|
|
649
|
+
var SKILL_default = `---
|
|
622
650
|
name: flow
|
|
623
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.
|
|
624
652
|
---
|
|
@@ -630,10 +658,8 @@ Use Flow as a minimal state ledger, not as a framework. Skills provide judgment;
|
|
|
630
658
|
## Loop
|
|
631
659
|
|
|
632
660
|
1. Call \`flow_status\` first. Trust its active session and next action over conversation memory.
|
|
633
|
-
If the result includes \`setup.skills\`,
|
|
634
|
-
|
|
635
|
-
continue with their embedded instructions, but a just-synced native skill can
|
|
636
|
-
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.
|
|
637
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.
|
|
638
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.
|
|
639
665
|
4. Load \`flow-review\` for the required feature review. The reviewer reports a \`featureReview\` payload; the manager records it inside \`flow_feature_complete\`.
|
|
@@ -693,7 +719,10 @@ Planning and running require loaded Flow tools; do not simulate plan approval or
|
|
|
693
719
|
- Unknown runtime error: read \`summary\` and \`recovery\`; see \`references/recovery-playbook.md\` for common cases.
|
|
694
720
|
|
|
695
721
|
Never fabricate validation output, backfill review approval you did not perform, or close as \`deferred\`/\`abandoned\` merely to avoid an unfinished-work blocker.
|
|
696
|
-
`;
|
|
722
|
+
`;
|
|
723
|
+
|
|
724
|
+
// skills/flow-commit/SKILL.md
|
|
725
|
+
var SKILL_default2 = `---
|
|
697
726
|
name: flow-commit
|
|
698
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.
|
|
699
728
|
---
|
|
@@ -765,18 +794,12 @@ Before commit creation, check the staged diff for:
|
|
|
765
794
|
- Generated artifacts that are not normally versioned.
|
|
766
795
|
- Package or version metadata drift unrelated to the requested change.
|
|
767
796
|
|
|
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.
|
|
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.
|
|
780
803
|
|
|
781
804
|
Use the repository's documented broad validation gate when a full local check is
|
|
782
805
|
appropriate, such as package scripts, AGENTS/docs, or CI guidance. Treat broad
|
|
@@ -809,7 +832,10 @@ Before running \`git commit\`, report:
|
|
|
809
832
|
|
|
810
833
|
After a successful commit, report the commit hash and leave push or release
|
|
811
834
|
actions for a separate explicit request.
|
|
812
|
-
`;
|
|
835
|
+
`;
|
|
836
|
+
|
|
837
|
+
// skills/flow-deslop/references/refactor-workflow.md
|
|
838
|
+
var refactor_workflow_default = `# Safe refactor workflow
|
|
813
839
|
|
|
814
840
|
Refactoring is a behavior-preserving sequence of small changes. This workflow keeps cleanup from becoming an unreviewable rewrite.
|
|
815
841
|
|
|
@@ -851,7 +877,10 @@ Weak evidence includes:
|
|
|
851
877
|
- Public contracts and compatibility shims remain intact or were explicitly planned.
|
|
852
878
|
- Deleted code is actually unreachable or obsolete.
|
|
853
879
|
- Validation can catch a realistic mistake in the refactor.
|
|
854
|
-
`;
|
|
880
|
+
`;
|
|
881
|
+
|
|
882
|
+
// skills/flow-deslop/references/smell-rubric.md
|
|
883
|
+
var smell_rubric_default = `# Deslop smell rubric
|
|
855
884
|
|
|
856
885
|
Use this rubric to turn vague cleanup instincts into reviewable findings.
|
|
857
886
|
|
|
@@ -885,7 +914,10 @@ class; severity; location; evidence read; refutation checked; why it matters; sa
|
|
|
885
914
|
\`\`\`
|
|
886
915
|
|
|
887
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.
|
|
888
|
-
`;
|
|
917
|
+
`;
|
|
918
|
+
|
|
919
|
+
// skills/flow-deslop/SKILL.md
|
|
920
|
+
var SKILL_default3 = `---
|
|
889
921
|
name: flow-deslop
|
|
890
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.
|
|
891
923
|
---
|
|
@@ -927,7 +959,10 @@ For each claimed smell removal, verify:
|
|
|
927
959
|
- **blast radius** — public contracts and downstream callers still work.
|
|
928
960
|
|
|
929
961
|
Never approve cleanup because it "looks cleaner" without evidence. Tests passing is necessary but not sufficient when the refactor changes structure across files.
|
|
930
|
-
`;
|
|
962
|
+
`;
|
|
963
|
+
|
|
964
|
+
// skills/flow-plan/references/parallel-discovery.md
|
|
965
|
+
var parallel_discovery_default = `# Parallel discovery
|
|
931
966
|
|
|
932
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.
|
|
933
968
|
|
|
@@ -943,26 +978,17 @@ Use its pre-fan-out coverage gate and
|
|
|
943
978
|
- Risk lenses such as security, persistence, accessibility, migration, or performance.
|
|
944
979
|
- Documentation and operator-contract checks.
|
|
945
980
|
|
|
946
|
-
##
|
|
947
|
-
|
|
948
|
-
For this repository, good first-pass slices are:
|
|
981
|
+
## Deriving first-pass slices
|
|
949
982
|
|
|
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.
|
|
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".
|
|
962
988
|
|
|
963
|
-
Treat
|
|
964
|
-
choose the relevant entries and de-overlap shared docs,
|
|
965
|
-
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.
|
|
966
992
|
|
|
967
993
|
## Coverage gate
|
|
968
994
|
|
|
@@ -975,8 +1001,8 @@ state the completeness rule, such as "all changed files plus callers."
|
|
|
975
1001
|
|
|
976
1002
|
\`\`\`text
|
|
977
1003
|
Inspect <slice> for <goal>. Read-only. Do not edit files or call
|
|
978
|
-
state-changing Flow tools. Return the
|
|
979
|
-
|
|
1004
|
+
state-changing Flow tools. Return only the Flow handoff in this exact shape:
|
|
1005
|
+
<matching handoff template copied verbatim from handoff-format.md>
|
|
980
1006
|
\`\`\`
|
|
981
1007
|
|
|
982
1008
|
For validation-oriented discovery:
|
|
@@ -984,11 +1010,14 @@ For validation-oriented discovery:
|
|
|
984
1010
|
\`\`\`text
|
|
985
1011
|
Inspect <slice> for validation risk. Read-only. Do not edit files or call
|
|
986
1012
|
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
|
-
|
|
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>
|
|
990
1016
|
\`\`\`
|
|
991
1017
|
|
|
1018
|
+
Workers cannot read reference files themselves; paste the matching handoff
|
|
1019
|
+
template from \`../../flow/references/handoff-format.md\` into the prompt.
|
|
1020
|
+
|
|
992
1021
|
## Synthesis
|
|
993
1022
|
|
|
994
1023
|
Convert only evidence-backed work into plan fields:
|
|
@@ -1003,7 +1032,10 @@ If workers disagree, inspect the source artifact yourself. If a candidate findin
|
|
|
1003
1032
|
Apply the manager synthesis barrier from
|
|
1004
1033
|
\`../../flow/references/verification-gates.md\`: only distilled, evidence-backed
|
|
1005
1034
|
claims become plan fields.
|
|
1006
|
-
`;
|
|
1035
|
+
`;
|
|
1036
|
+
|
|
1037
|
+
// skills/flow-plan/references/planning-examples.md
|
|
1038
|
+
var planning_examples_default = `# Planning examples
|
|
1007
1039
|
|
|
1008
1040
|
## Rate limiting feature set
|
|
1009
1041
|
|
|
@@ -1088,7 +1120,10 @@ Better plan:
|
|
|
1088
1120
|
- Validation that only says "manual testing".
|
|
1089
1121
|
- Targets that name the entire repo.
|
|
1090
1122
|
- Features with hidden dependencies instead of \`dependsOn\`.
|
|
1091
|
-
`;
|
|
1123
|
+
`;
|
|
1124
|
+
|
|
1125
|
+
// skills/flow-plan/SKILL.md
|
|
1126
|
+
var SKILL_default4 = `---
|
|
1092
1127
|
name: flow-plan
|
|
1093
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."
|
|
1094
1129
|
---
|
|
@@ -1103,14 +1138,13 @@ If \`flow_plan_save\` or \`flow_plan_approve\` is unavailable, stop and tell the
|
|
|
1103
1138
|
|
|
1104
1139
|
- Read the files, docs, tests, package scripts, and local conventions that determine the work.
|
|
1105
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.
|
|
1106
1144
|
- 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.
|
|
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\`.
|
|
1114
1148
|
- Do not invent findings. Broad "review and fix" goals start with a review-first feature whose deliverable is evidence-backed findings.
|
|
1115
1149
|
|
|
1116
1150
|
## Plan shape
|
|
@@ -1158,7 +1192,10 @@ Use only \`finalReviewPolicy: "broad"\` or \`"detailed"\`. These are the canonic
|
|
|
1158
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.
|
|
1159
1193
|
|
|
1160
1194
|
See \`references/planning-examples.md\` for payload examples and decomposition anti-patterns.
|
|
1161
|
-
`;
|
|
1195
|
+
`;
|
|
1196
|
+
|
|
1197
|
+
// skills/flow-review/references/review-rubric.md
|
|
1198
|
+
var review_rubric_default = `# Review rubric
|
|
1162
1199
|
|
|
1163
1200
|
Use this to decide whether a \`featureReview\` or \`finalReview\` payload may pass.
|
|
1164
1201
|
|
|
@@ -1246,7 +1283,10 @@ When reviewing a findings report, verify findings adversarially:
|
|
|
1246
1283
|
- Downgrade or reject findings that do not survive refutation.
|
|
1247
1284
|
|
|
1248
1285
|
Approve only on evidence actually inspected. A review is a claim of coverage, not a courtesy stamp.
|
|
1249
|
-
`;
|
|
1286
|
+
`;
|
|
1287
|
+
|
|
1288
|
+
// skills/flow-review/SKILL.md
|
|
1289
|
+
var SKILL_default5 = `---
|
|
1250
1290
|
name: flow-review
|
|
1251
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."
|
|
1252
1292
|
---
|
|
@@ -1259,15 +1299,30 @@ If Flow tools, required Flow skills, or required references are unavailable or
|
|
|
1259
1299
|
stale, perform an advisory review and say that no Flow-gated review payload was
|
|
1260
1300
|
recorded.
|
|
1261
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
|
+
|
|
1262
1316
|
## Start
|
|
1263
1317
|
|
|
1264
1318
|
- Call \`flow_status\` when available.
|
|
1265
1319
|
- Identify whether this is a feature review or final review.
|
|
1266
1320
|
- Read the approved plan fields relevant to the work: \`requirements\`, \`decisions\`, feature \`targets\`, feature \`validation\`, and dependencies.
|
|
1267
1321
|
- 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
|
-
|
|
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.
|
|
1271
1326
|
- Load \`references/review-rubric.md\` for severity, depth, and payload shape.
|
|
1272
1327
|
|
|
1273
1328
|
## Feature Review Depth
|
|
@@ -1305,18 +1360,23 @@ Use \`status: "failed"\` when any blocking finding remains. Advisory findings ma
|
|
|
1305
1360
|
|
|
1306
1361
|
## Special cases
|
|
1307
1362
|
|
|
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.
|
|
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.
|
|
1310
1365
|
- 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.
|
|
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.
|
|
1317
1374
|
|
|
1318
1375
|
Never approve to unblock completion, fix findings in the review pass, or vouch for validation you did not inspect.
|
|
1319
|
-
`;
|
|
1376
|
+
`;
|
|
1377
|
+
|
|
1378
|
+
// skills/flow-run/references/audit-rubric.md
|
|
1379
|
+
var audit_rubric_default = `# Audit findings rubric
|
|
1320
1380
|
|
|
1321
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.
|
|
1322
1382
|
|
|
@@ -1369,7 +1429,10 @@ follow-up order — correctness and persisted/user-input surfaces first
|
|
|
1369
1429
|
\`\`\`
|
|
1370
1430
|
|
|
1371
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.
|
|
1372
|
-
`;
|
|
1432
|
+
`;
|
|
1433
|
+
|
|
1434
|
+
// skills/flow-run/references/validation-rubric.md
|
|
1435
|
+
var validation_rubric_default = `# Validation evidence rubric
|
|
1373
1436
|
|
|
1374
1437
|
Use this before recording \`flow_feature_complete\`.
|
|
1375
1438
|
|
|
@@ -1426,7 +1489,10 @@ Broad validation usually means the repo's full check command, full relevant test
|
|
|
1426
1489
|
- If validation needs external access, missing credentials, or ambiguous user input, record \`status: "needs_input"\` with an honest \`outcome\`.
|
|
1427
1490
|
|
|
1428
1491
|
Never trim failing output, relabel a failed command as passed, or use "not run" as completion evidence.
|
|
1429
|
-
`;
|
|
1492
|
+
`;
|
|
1493
|
+
|
|
1494
|
+
// skills/flow-run/SKILL.md
|
|
1495
|
+
var SKILL_default6 = `---
|
|
1430
1496
|
name: flow-run
|
|
1431
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."
|
|
1432
1498
|
---
|
|
@@ -1442,9 +1508,10 @@ If \`flow_run_start\` is unavailable, stop and tell the user to check that \`ope
|
|
|
1442
1508
|
- Call \`flow_status\`.
|
|
1443
1509
|
- Call \`flow_run_start\` with no \`featureId\` unless the user or plan requires a specific runnable feature.
|
|
1444
1510
|
- Treat the returned feature as the sole scope until it is completed, blocked, or reset.
|
|
1445
|
-
-
|
|
1446
|
-
|
|
1447
|
-
- 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.
|
|
1448
1515
|
|
|
1449
1516
|
## Implement
|
|
1450
1517
|
|
|
@@ -1462,8 +1529,7 @@ If \`flow_run_start\` is unavailable, stop and tell the user to check that \`ope
|
|
|
1462
1529
|
|
|
1463
1530
|
- For complex validation, regression-sensitive changes, browser QA, route QA,
|
|
1464
1531
|
failure-prone checks, unclear coverage, exploratory QA, or
|
|
1465
|
-
\`validationRun\` summarization, load \`flow-test
|
|
1466
|
-
the coverage gap and keep validation claims conservative.
|
|
1532
|
+
\`validationRun\` summarization, load \`flow-test\` (helper rule applies).
|
|
1467
1533
|
- Read \`references/validation-rubric.md\` before completing.
|
|
1468
1534
|
- Run the strongest practical checks for the changed behavior.
|
|
1469
1535
|
- Record concrete command names, status, and observed results. "Tests pass" is not evidence.
|
|
@@ -1513,7 +1579,10 @@ Complete with:
|
|
|
1513
1579
|
\`\`\`
|
|
1514
1580
|
|
|
1515
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.
|
|
1516
|
-
`;
|
|
1582
|
+
`;
|
|
1583
|
+
|
|
1584
|
+
// skills/flow-test/SKILL.md
|
|
1585
|
+
var SKILL_default7 = `---
|
|
1517
1586
|
name: flow-test
|
|
1518
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.
|
|
1519
1588
|
---
|
|
@@ -1637,7 +1706,10 @@ covered. Static inspection alone is a gap for behavioral changes.
|
|
|
1637
1706
|
|
|
1638
1707
|
Never relabel a failed command as passed, invent output, or use "not run" as
|
|
1639
1708
|
completion evidence.
|
|
1640
|
-
`;
|
|
1709
|
+
`;
|
|
1710
|
+
|
|
1711
|
+
// skills/flow-ui-quality/references/ui-rubric.md
|
|
1712
|
+
var ui_rubric_default = `# UI quality rubric
|
|
1641
1713
|
|
|
1642
1714
|
Use this rubric for frontend planning, implementation, and review.
|
|
1643
1715
|
|
|
@@ -1681,7 +1753,10 @@ class; severity; location or screenshot area; evidence inspected; user impact; f
|
|
|
1681
1753
|
\`\`\`
|
|
1682
1754
|
|
|
1683
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.
|
|
1684
|
-
`;
|
|
1756
|
+
`;
|
|
1757
|
+
|
|
1758
|
+
// skills/flow-ui-quality/references/visual-verification.md
|
|
1759
|
+
var visual_verification_default = `# Visual verification workflow
|
|
1685
1760
|
|
|
1686
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.
|
|
1687
1762
|
|
|
@@ -1721,7 +1796,10 @@ Record the reason and use the strongest available substitute:
|
|
|
1721
1796
|
- code inspection against existing component patterns.
|
|
1722
1797
|
|
|
1723
1798
|
Do not claim visual polish was verified if no visual artifact was inspected.
|
|
1724
|
-
`;
|
|
1799
|
+
`;
|
|
1800
|
+
|
|
1801
|
+
// skills/flow-ui-quality/SKILL.md
|
|
1802
|
+
var SKILL_default8 = `---
|
|
1725
1803
|
name: flow-ui-quality
|
|
1726
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.
|
|
1727
1805
|
---
|
|
@@ -1769,23 +1847,580 @@ Approve only when the interface is both useful and inspectable:
|
|
|
1769
1847
|
- Screenshot/browser evidence supports the claim whenever feasible.
|
|
1770
1848
|
|
|
1771
1849
|
Never approve a UI change based only on code shape. If users will judge it visually, Flow evidence should include visual inspection.
|
|
1772
|
-
`;
|
|
1773
|
-
|
|
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(`
|
|
1774
2244
|
`)}
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
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
|