opencode-plugin-flow 4.1.2 → 4.1.4

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 CHANGED
@@ -3,6 +3,14 @@
3
3
  One short line per release. For the full rationale behind each entry, see the
4
4
  commit history and review evidence.
5
5
 
6
+ ## [4.1.4] - 2026-06-16
7
+
8
+ Make Flow skill loading restart-aware across every command, add manual sync repair, and treat missing optional helpers as explicit coverage gaps.
9
+
10
+ ## [4.1.3] - 2026-06-16
11
+
12
+ Sharpen Flow's skill/runtime contract with aligned final-review language, broader gate coverage, CLI smoke tests, and skill-aware preflight routing.
13
+
6
14
  ## [4.1.2] - 2026-06-15
7
15
 
8
16
  Make Flow's skill registry lag visible with restart-aware setup warnings, a doctor command, and a bundled review fallback for stale OpenCode startups.
package/README.md CHANGED
@@ -20,7 +20,7 @@ Add Flow to your OpenCode config:
20
20
 
21
21
  ```json
22
22
  {
23
- "plugin": ["opencode-plugin-flow@4.1.2"]
23
+ "plugin": ["opencode-plugin-flow@4.1.4"]
24
24
  }
25
25
  ```
26
26
 
@@ -50,9 +50,23 @@ disk while still being unavailable to that process. Flow reports this through
50
50
  To inspect the installed skill set:
51
51
 
52
52
  ```bash
53
- npx -y opencode-plugin-flow@4.1.2 doctor
53
+ npx -y opencode-plugin-flow@4.1.4 doctor
54
54
  ```
55
55
 
56
+ If a command reports `Skill "flow-review" not found. Available skills...` or a
57
+ similar Flow skill-loading error, run `/flow-status` or the doctor command above
58
+ first. Missing, incomplete, or outdated managed skills can be repaired with:
59
+
60
+ ```bash
61
+ npx -y opencode-plugin-flow@4.1.4 sync
62
+ ```
63
+
64
+ Then restart OpenCode so the refreshed registry is loaded. `sync` manages all
65
+ bundled Flow skills: `flow`, `flow-plan`, `flow-run`, `flow-review`,
66
+ `flow-deslop`, and `flow-ui-quality`. If doctor reports a foreign or edited
67
+ managed skill folder, Flow leaves it in place and asks for a user decision
68
+ instead of overwriting local work.
69
+
56
70
  ## Commands
57
71
 
58
72
  Commands are thin pointers into skills:
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{createHash as xe}from"node:crypto";import{mkdir as xa,readdir as K,readFile as _e,rm as Re,writeFile as _a}from"node:fs/promises";import{createRequire as Ie}from"node:module";import{dirname as Fa,join as l,normalize as Fe,sep as Ce}from"node:path";var F=`# Flow worker handoff contract
2
+ import{createHash as Fe}from"node:crypto";import{mkdir as Ce,readdir as ee,readFile as Ue,rm as qe,writeFile as y}from"node:fs/promises";import{createRequire as Ae}from"node:module";import{dirname as Te,join as l,normalize as Pe,sep as De}from"node:path";var j=`# Flow worker handoff contract
3
3
 
4
4
  Flow managers merge only the worker's final response. Treat that response as the
5
5
  worker report of record: it must include the assigned scope, what was actually
@@ -118,7 +118,7 @@ live-verified | test-verified | type-check-only | not-verified
118
118
 
119
119
  The manager must inspect and validate any candidate patch before recording Flow
120
120
  completion.
121
- `;var C=`# Parallel orchestration
121
+ `;var W=`# Parallel orchestration
122
122
 
123
123
  Use fan-out when Flow work is broad enough that independent workers can gather
124
124
  evidence faster than one linear pass. The manager still owns the Flow session:
@@ -160,9 +160,10 @@ Read these companion references before a broad wave:
160
160
 
161
161
  ## Modes
162
162
 
163
- When fanning out Flow work, select the matching hidden Flow agent by name. Do
164
- not use generic subagents for Flow slices because Flow workers carry the
165
- permission boundaries for each mode.
163
+ When fanning out Flow work, select the matching hidden Flow agent by name. These
164
+ workers are injected by the plugin config; invoke the named worker when it is
165
+ available. Do not use generic subagents for Flow slices because Flow workers
166
+ carry the permission boundaries for each mode.
166
167
 
167
168
  | Mode | Use agent | Worker output | Write access | Flow tools |
168
169
  | --- | --- | --- | --- | --- |
@@ -246,7 +247,7 @@ Start a follow-up wave when first-wave handoffs reveal:
246
247
 
247
248
  Do not recurse by default. If a worker says it needs another worker, the manager
248
249
  decides whether that is a second wave and writes the next bounded prompt.
249
- `;var U='# 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`.\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';var A=`# Verification gates
250
+ `;var z='# 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';var O=`# Verification gates
250
251
 
251
252
  Verification is how Flow keeps parallel work from turning into parallel
252
253
  guesswork. Worker handoffs are candidate evidence; the manager decides what can
@@ -336,7 +337,74 @@ Before presenting or recording the result:
336
337
 
337
338
  \`Status: success\` only says the worker believes its slice is done. The manager
338
339
  still checks coverage and evidence before trusting the result.
339
- `;var q="---\nname: flow\ndescription: Main Flow loop for skills-first OpenCode work. Use when a user asks for Flow-guided planning, autonomous execution, resumable implementation, session status, or end-to-end delivery with validation and review gates.\n---\n\n# Flow\n\nUse Flow as a minimal state ledger, not as a framework. Skills provide judgment; the runtime only records the approved plan, active feature, validation evidence, review evidence, and closure.\n\n## Loop\n\n1. Call `flow_status` first. Trust its active session and next action over conversation memory.\n2. If there is no active session and the user gave a goal, load `flow-plan`, save a plan with `flow_plan_save`, then approve it with `flow_plan_approve`. If there is no goal, ask for one.\n3. Load `flow-run`, call `flow_run_start`, implement exactly one feature, validate it, and prepare a `flow_feature_complete` payload.\n4. Load `flow-review` for the required feature review. The reviewer reports a `featureReview` payload; the manager records it inside `flow_feature_complete`.\n5. On the final feature, run broad validation and include `finalReview` in the same `flow_feature_complete` call. Its `reviewDepth` must match the plan's `finalReviewPolicy`.\n6. After all features are complete, archive the session with `flow_session_close` using `kind: \"completed\"`.\n\nUse `references/parallel-orchestration.md` for broad read-only discovery, audit, validation, review, verification, or candidate implementation waves. Its `references/handoff-format.md` and `references/verification-gates.md` companions define the worker contracts. The manager owns every `flow_*` state change.\n\n## Runtime Surface\n\n- `flow_status`: read the active session.\n- `flow_plan_save`: create a session and/or save a draft plan.\n- `flow_plan_approve`: lock the draft plan.\n- `flow_run_start`: start one runnable feature.\n- `flow_feature_complete`: record completion or a real blocker with validation and review evidence.\n- `flow_feature_reset`: reset one feature and its dependents.\n- `flow_session_close`: archive the active session as `completed`, `deferred`, or `abandoned`.\n\nThere is no `flow_context`, no separate review-record tool, and no multi-session activation surface. The single active source of truth is `.flow/session.json`; closed sessions are archived under `.flow/history/`.\n\n## Hard Gates\n\n- Approved plans are immutable. To change direction, reset affected features or close the session and start a new goal.\n- Only one feature can be active at a time.\n- Completion requires at least one passing `validationRun` entry.\n- Non-final completion requires `validationScope: \"targeted\"`.\n- Final completion requires `validationScope: \"broad\"` and a passing `finalReview`.\n- Every completed feature requires a passing `featureReview` with no blocking findings.\n- `flow_session_close` accepts `kind: \"completed\"` only after an approved plan has passed final completion.\n\n## Recovery\n\n- Confused state: call `flow_status` and follow `nextAction`.\n- Wrong assumption or failed implementation path: use `flow_feature_reset` for the feature and dependents, then rerun from the corrected plan.\n- Missing validation or review evidence: gather real evidence, then call `flow_feature_complete`.\n- Approved plan is materially wrong: reset the affected features, save a revised plan if the session is back in planning; otherwise close and start a new goal.\n- Unknown runtime error: read `summary` and `recovery`; see `references/recovery-playbook.md` for common cases.\n\nNever fabricate validation output, backfill review approval you did not perform, or close as `deferred`/`abandoned` merely to avoid an unfinished-work blocker.\n";var T=`# Safe refactor workflow
340
+ `;var B=`---
341
+ name: flow
342
+ description: Main Flow loop for skills-first OpenCode work. Use when a user asks for Flow-guided planning, autonomous execution, resumable implementation, session status, or end-to-end delivery with validation and review gates.
343
+ ---
344
+
345
+ # Flow
346
+
347
+ Use Flow as a minimal state ledger, not as a framework. Skills provide judgment; the runtime only records the approved plan, active feature, validation evidence, review evidence, and closure.
348
+
349
+ ## Loop
350
+
351
+ 1. Call \`flow_status\` first. Trust its active session and next action over conversation memory.
352
+ If the result includes \`setup.skills\`, report that setup status and do not
353
+ load Flow skills in this startup. A just-synced skill can be on disk while
354
+ unavailable to the running OpenCode process.
355
+ 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.
356
+ 3. Load \`flow-run\`, call \`flow_run_start\`, implement exactly one feature, validate it, and prepare a \`flow_feature_complete\` payload.
357
+ 4. Load \`flow-review\` for the required feature review. The reviewer reports a \`featureReview\` payload; the manager records it inside \`flow_feature_complete\`.
358
+ 5. On the final feature, run broad validation and include \`finalReview\` in the same \`flow_feature_complete\` call. Its \`reviewDepth\` must match the plan's \`finalReviewPolicy\`.
359
+ 6. After all features are complete, archive the session with \`flow_session_close\` using \`kind: "completed"\`.
360
+
361
+ Use \`references/parallel-orchestration.md\` for broad read-only discovery, audit, validation, review, verification, or candidate implementation waves. Hidden Flow workers are injected by plugin config; invoke the named worker when it is available. Its \`references/handoff-format.md\` and \`references/verification-gates.md\` companions define the worker contracts. The manager owns every \`flow_*\` state change.
362
+
363
+ ## Skill Availability
364
+
365
+ If \`flow_status\` returns \`setup.skills\`, report that setup status and stop
366
+ loading Flow skills in the current OpenCode startup. Missing, incomplete, or
367
+ outdated managed skills require a sync/restart cycle before their instructions
368
+ can be trusted by the running process.
369
+
370
+ If optional helper skills such as \`flow-deslop\` or \`flow-ui-quality\` are
371
+ unavailable, continue only with explicit coverage gaps. Do not copy their
372
+ rubrics into another skill and do not claim their quality checks were completed.
373
+
374
+ ## Runtime Surface
375
+
376
+ - \`flow_status\`: read the active session.
377
+ - \`flow_plan_save\`: create a session and/or save a draft plan.
378
+ - \`flow_plan_approve\`: lock the draft plan.
379
+ - \`flow_run_start\`: start one runnable feature.
380
+ - \`flow_feature_complete\`: record completion or a real blocker with validation and review evidence.
381
+ - \`flow_feature_reset\`: reset one feature and its dependents.
382
+ - \`flow_session_close\`: archive the active session as \`completed\`, \`deferred\`, or \`abandoned\`.
383
+
384
+ There is no \`flow_context\`, no separate review-record tool, and no multi-session activation surface. The single active source of truth is \`.flow/session.json\`; closed sessions are archived under \`.flow/history/\`.
385
+
386
+ Planning and running require loaded Flow tools; do not simulate plan approval or feature completion when the runtime is unavailable. Review may still return advisory output when tools, skills, or references are stale or unavailable, but the manager must not record it as Flow-gated evidence.
387
+
388
+ ## Hard Gates
389
+
390
+ - Approved plans are immutable. To change direction, reset affected features or close the session and start a new goal.
391
+ - Only one feature can be active at a time.
392
+ - Completion requires at least one passing \`validationRun\` entry.
393
+ - Non-final completion requires \`validationScope: "targeted"\`.
394
+ - Final completion requires \`validationScope: "broad"\` and a passing \`finalReview\`.
395
+ - Every completed feature requires a passing \`featureReview\` with no blocking findings.
396
+ - \`flow_session_close\` accepts \`kind: "completed"\` only after an approved plan has passed final completion.
397
+
398
+ ## Recovery
399
+
400
+ - Confused state: call \`flow_status\` and follow \`nextAction\`.
401
+ - Wrong assumption or failed implementation path: use \`flow_feature_reset\` for the feature and dependents, then rerun from the corrected plan.
402
+ - Missing validation or review evidence: gather real evidence, then call \`flow_feature_complete\`.
403
+ - Approved plan is materially wrong: reset the affected features, save a revised plan if the session is back in planning; otherwise close and start a new goal.
404
+ - Unknown runtime error: read \`summary\` and \`recovery\`; see \`references/recovery-playbook.md\` for common cases.
405
+
406
+ Never fabricate validation output, backfill review approval you did not perform, or close as \`deferred\`/\`abandoned\` merely to avoid an unfinished-work blocker.
407
+ `;var N=`# Safe refactor workflow
340
408
 
341
409
  Refactoring is a behavior-preserving sequence of small changes. This workflow keeps cleanup from becoming an unreviewable rewrite.
342
410
 
@@ -378,7 +446,7 @@ Weak evidence includes:
378
446
  - Public contracts and compatibility shims remain intact or were explicitly planned.
379
447
  - Deleted code is actually unreachable or obsolete.
380
448
  - Validation can catch a realistic mistake in the refactor.
381
- `;var P=`# Deslop smell rubric
449
+ `;var V=`# Deslop smell rubric
382
450
 
383
451
  Use this rubric to turn vague cleanup instincts into reviewable findings.
384
452
 
@@ -412,7 +480,7 @@ class; severity; location; evidence read; refutation checked; why it matters; sa
412
480
  \`\`\`
413
481
 
414
482
  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.
415
- `;var D=`---
483
+ `;var E=`---
416
484
  name: flow-deslop
417
485
  description: Flow guidance for evidence-backed code smell cleanup, AI-slop removal, overengineering reduction, maintainability refactors, and behavior-preserving cleanup. Use when planning, executing, or reviewing broad cleanup/refactor work, code smell findings, duplicated or bloated code, speculative abstractions, dead code, or agent-introduced mess.
418
486
  ---
@@ -454,7 +522,7 @@ For each claimed smell removal, verify:
454
522
  - **blast radius** — public contracts and downstream callers still work.
455
523
 
456
524
  Never approve cleanup because it "looks cleaner" without evidence. Tests passing is necessary but not sufficient when the refactor changes structure across files.
457
- `;var j=`# Parallel discovery
525
+ `;var S=`# Parallel discovery
458
526
 
459
527
  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.
460
528
 
@@ -520,7 +588,7 @@ Convert only evidence-backed work into plan fields:
520
588
  - feature \`validation\`: checks expected to prove the feature.
521
589
 
522
590
  If workers disagree, inspect the source artifact yourself. If a candidate finding lacks a concrete citation or refutation pass, make it a review-first deliverable rather than a fix feature.
523
- `;var W=`# Planning examples
591
+ `;var G=`# Planning examples
524
592
 
525
593
  ## Rate limiting feature set
526
594
 
@@ -605,7 +673,7 @@ Better plan:
605
673
  - Validation that only says "manual testing".
606
674
  - Targets that name the entire repo.
607
675
  - Features with hidden dependencies instead of \`dependsOn\`.
608
- `;var z=`---
676
+ `;var M=`---
609
677
  name: flow-plan
610
678
  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.
611
679
  ---
@@ -614,14 +682,17 @@ description: Plan Flow work for the v4 skills-first runtime: inspect the repo, d
614
682
 
615
683
  Use this skill before implementation. The output is a compact plan the runtime can enforce and future agents can execute without rediscovering the goal.
616
684
 
617
- If \`flow_plan_save\` is unavailable, stop and tell the user to check that \`opencode-plugin-flow\` is loaded in OpenCode.
685
+ If \`flow_plan_save\` or \`flow_plan_approve\` is unavailable, stop and tell the user to check that \`opencode-plugin-flow\` is loaded in OpenCode. Planning requires the loaded Flow runtime.
618
686
 
619
687
  ## Inspect first
620
688
 
621
689
  - Read the files, docs, tests, package scripts, and local conventions that determine the work.
622
690
  - 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.
623
- - For cleanup/refactor goals, load \`flow-deslop\`.
624
- - For UI/frontend goals, load \`flow-ui-quality\`.
691
+ - For cleanup/refactor goals, load \`flow-deslop\`. If it is unavailable, record
692
+ a planning gap and keep cleanup claims conservative.
693
+ - For UI/frontend goals, load \`flow-ui-quality\`. If it is unavailable, record a
694
+ planning gap and require next-best UI evidence rather than claiming visual
695
+ quality was reviewed.
625
696
  - Do not invent findings. Broad "review and fix" goals start with a review-first feature whose deliverable is evidence-backed findings.
626
697
 
627
698
  ## Plan shape
@@ -651,7 +722,7 @@ Call \`flow_plan_save\` with:
651
722
  }
652
723
  \`\`\`
653
724
 
654
- Use \`finalReviewPolicy: "broad"\` only for low-risk, narrow work. Use \`"detailed"\` for behavioral changes, cross-module edits, migrations, releases, security-sensitive code, or large refactors.
725
+ Use only \`finalReviewPolicy: "broad"\` or \`"detailed"\`. These are the canonical final-review policy and \`reviewDepth\` enum values. Use \`"broad"\` only for low-risk, narrow work. Use \`"detailed"\` for behavioral changes, cross-module edits, migrations, releases, security-sensitive code, or large refactors.
655
726
 
656
727
  ## Feature sizing
657
728
 
@@ -663,10 +734,10 @@ Use \`finalReviewPolicy: "broad"\` only for low-risk, narrow work. Use \`"detail
663
734
 
664
735
  ## Approval
665
736
 
666
- After saving, summarize the plan to the user or proceed if they already authorized implementation. Then call \`flow_plan_approve\`. Approved plans are immutable; changing them later requires reset/closure rather than silent edits.
737
+ 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.
667
738
 
668
739
  See \`references/planning-examples.md\` for payload examples and decomposition anti-patterns.
669
- `;var B=`# Review rubric
740
+ `;var L=`# Review rubric
670
741
 
671
742
  Use this to decide whether a \`featureReview\` or \`finalReview\` payload may pass.
672
743
 
@@ -700,7 +771,7 @@ If unsure whether a finding is real, read more or downgrade it. Do not promote g
700
771
 
701
772
  - Every feature is complete and together they satisfy the original goal.
702
773
  - Broad validation ran and passed.
703
- - The final review depth equals the approved \`finalReviewPolicy\`.
774
+ - The final \`reviewDepth\` equals the approved \`finalReviewPolicy\`; the only final-review enum values are \`broad\` and \`detailed\`.
704
775
  - Feature-level reviews have no unresolved blocking findings.
705
776
  - Docs, commands, package metadata, and release surfaces match the delivered behavior.
706
777
  - Remaining gaps are explicit and do not contradict \`kind: "completed"\`.
@@ -754,7 +825,7 @@ When reviewing a findings report, verify findings adversarially:
754
825
  - Downgrade or reject findings that do not survive refutation.
755
826
 
756
827
  Approve only on evidence actually inspected. A review is a claim of coverage, not a courtesy stamp.
757
- `;var O=`---
828
+ `;var $=`---
758
829
  name: flow-review
759
830
  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.
760
831
  ---
@@ -763,7 +834,9 @@ description: Review Flow work in the v4 runtime: inspect feature or final-sessio
763
834
 
764
835
  Use this skill for review. The reviewer is usually read-only and does not mutate Flow state. The manager records the returned review payload inside \`flow_feature_complete\`.
765
836
 
766
- If Flow tools are unavailable, perform an advisory review and say that no Flow-gated review payload was recorded.
837
+ If Flow tools, required Flow skills, or required references are unavailable or
838
+ stale, perform an advisory review and say that no Flow-gated review payload was
839
+ recorded.
767
840
 
768
841
  ## Start
769
842
 
@@ -773,13 +846,13 @@ If Flow tools are unavailable, perform an advisory review and say that no Flow-g
773
846
  - Inspect the actual diff, changed files, tests, and validation output. Do not review only the completion summary.
774
847
  - Load \`references/review-rubric.md\` for severity, depth, and payload shape.
775
848
 
776
- ## Depth
849
+ ## Feature Review Depth
777
850
 
778
851
  - **quick**: docs, comments, config-only changes, or mechanical changes fully covered by tooling.
779
852
  - **standard**: default feature review. Read every changed file and relevant tests.
780
- - **detailed**: final review, risky behavior, persistence, security, cross-module refactors, migrations, releases, or weak validation.
853
+ - **detailed**: risky behavior, persistence, security, cross-module refactors, migrations, releases, or weak validation.
781
854
 
782
- Claim only the depth actually performed. Missing evidence is a finding, not a nuisance.
855
+ \`quick\` and \`standard\` are feature-review depth descriptions only. Final reviews use \`reviewDepth: "broad"\` or \`"detailed"\` to match the plan's \`finalReviewPolicy\`; these runtime enum values are the canonical final-review terms. Claim only the depth actually performed. Missing evidence is a finding, not a nuisance.
783
856
 
784
857
  ## Output
785
858
 
@@ -808,8 +881,8 @@ Use \`status: "failed"\` when any blocking finding remains. Advisory findings ma
808
881
 
809
882
  ## Special cases
810
883
 
811
- - Cleanup/refactor: load \`flow-deslop\`; verify the smell was real, refutation paths were checked, and behavior was preserved.
812
- - UI/frontend: load \`flow-ui-quality\`; verify state coverage and visual evidence when a local target was available.
884
+ - 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.
885
+ - 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.
813
886
  - Audit reports: use \`flow-run/references/audit-rubric.md\`; findings must survive refutation before they can drive fix features.
814
887
  - Large reviews: use \`../flow/references/parallel-orchestration.md\` for
815
888
  read-only slices by changed-file group, risk lens, or validation surface.
@@ -819,7 +892,7 @@ Use \`status: "failed"\` when any blocking finding remains. Advisory findings ma
819
892
  \`finalReview\` payload.
820
893
 
821
894
  Never approve to unblock completion, fix findings in the review pass, or vouch for validation you did not inspect.
822
- `;var N=`# Audit findings rubric
895
+ `;var K=`# Audit findings rubric
823
896
 
824
897
  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.
825
898
 
@@ -872,7 +945,7 @@ follow-up order — correctness and persisted/user-input surfaces first
872
945
  \`\`\`
873
946
 
874
947
  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.
875
- `;var V=`# Validation evidence rubric
948
+ `;var X=`# Validation evidence rubric
876
949
 
877
950
  Use this before recording \`flow_feature_complete\`.
878
951
 
@@ -929,7 +1002,84 @@ Broad validation usually means the repo's full check command, full relevant test
929
1002
  - If validation needs external access, missing credentials, or ambiguous user input, record \`status: "needs_input"\` with an honest \`outcome\`.
930
1003
 
931
1004
  Never trim failing output, relabel a failed command as passed, or use "not run" as completion evidence.
932
- `;var E="---\nname: flow-run\ndescription: 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.\n---\n\n# Flow Run\n\nUse this skill for implementation after a Flow plan is approved. Work one feature at a time.\n\nIf `flow_run_start` is unavailable, stop and tell the user to check that `opencode-plugin-flow` is loaded in OpenCode.\n\n## Start\n\n- Call `flow_status`.\n- Call `flow_run_start` with no `featureId` unless the user or plan requires a specific runnable feature.\n- Treat the returned feature as the sole scope until it is completed, blocked, or reset.\n- Load `flow-deslop` for cleanup/refactor features.\n- Load `flow-ui-quality` for frontend, UX, responsive, accessibility, or visual work.\n\n## Implement\n\n- Read the feature `targets`, `summary`, `validation`, dependencies, and plan `requirements`/`decisions`.\n- Keep edits scoped to the active feature. If new scope appears, stop and replan or defer it to another feature.\n- Preserve unrelated user changes in the worktree.\n- When a wrong assumption invalidates the feature, use `flow_feature_reset`; do not pile patches onto a bad path.\n\n## Validate\n\n- Read `references/validation-rubric.md` before completing.\n- Run the strongest practical checks for the changed behavior.\n- Record concrete command names, status, and observed results. \"Tests pass\" is not evidence.\n- Non-final features complete with `validationScope: \"targeted\"`.\n- The final feature must run a broad project-level gate and use `validationScope: \"broad\"`.\n\nFor broad validation research, risky changes, or unclear coverage, use\n`../flow/references/parallel-orchestration.md` to fan out named Flow workers.\nUse the mode-to-agent mapping in that reference instead of generic subagents.\nWorkers must use the handoff format and verification gates from that reference.\nThey may report command output they actually ran or propose focused checks; the\nmanager decides what is strong enough to record.\n\nFor independent implementation attempts, use candidate workers only with\nexplicit user authorization plus isolated worktrees or exact non-overlapping\npath ownership. Treat their output as candidate patches. The manager inspects,\nmerges, validates, and records Flow state serially.\n\n## Review and complete\n\nBefore `flow_feature_complete`, obtain a `featureReview` payload. Load `flow-review`; for read-only subagent reviews, the manager receives the payload and records it.\n\nFor the final feature, also obtain a `finalReview` payload whose `reviewDepth` equals the approved plan's `finalReviewPolicy`.\n\nComplete with:\n\n```json\n{\n \"status\": \"ok\",\n \"featureId\": \"active-feature-id\",\n \"summary\": \"what changed\",\n \"artifactsChanged\": [{ \"path\": \"src/file.ts\" }],\n \"validationRun\": [\n { \"command\": \"bun test tests/foo.test.ts\", \"status\": \"passed\", \"summary\": \"3 pass, exercised foo behavior\" }\n ],\n \"validationScope\": \"targeted\",\n \"featureReview\": { \"status\": \"passed\", \"summary\": \"review summary\", \"blockingFindings\": [] }\n}\n```\n\nIf 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.\n";var G=`# UI quality rubric
1005
+ `;var Y=`---
1006
+ name: flow-run
1007
+ 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.
1008
+ ---
1009
+
1010
+ # Flow Run
1011
+
1012
+ Use this skill for implementation after a Flow plan is approved. Work one feature at a time.
1013
+
1014
+ If \`flow_run_start\` is unavailable, stop and tell the user to check that \`opencode-plugin-flow\` is loaded in OpenCode.
1015
+
1016
+ ## Start
1017
+
1018
+ - Call \`flow_status\`.
1019
+ - Call \`flow_run_start\` with no \`featureId\` unless the user or plan requires a specific runnable feature.
1020
+ - Treat the returned feature as the sole scope until it is completed, blocked, or reset.
1021
+ - Load \`flow-deslop\` for cleanup/refactor features. If it is unavailable,
1022
+ record the gap and do not overclaim cleanup quality.
1023
+ - Load \`flow-ui-quality\` for frontend, UX, responsive, accessibility, or visual work. If it is unavailable, record the gap and use next-best UI evidence.
1024
+
1025
+ ## Implement
1026
+
1027
+ - Read the feature \`targets\`, \`summary\`, \`validation\`, dependencies, and plan \`requirements\`/\`decisions\`.
1028
+ - Keep edits scoped to the active feature. If new scope appears, stop and replan or defer it to another feature.
1029
+ - Preserve unrelated user changes in the worktree.
1030
+ - When a wrong assumption invalidates the feature, use \`flow_feature_reset\`; do not pile patches onto a bad path.
1031
+
1032
+ ## Validate
1033
+
1034
+ - Read \`references/validation-rubric.md\` before completing.
1035
+ - Run the strongest practical checks for the changed behavior.
1036
+ - Record concrete command names, status, and observed results. "Tests pass" is not evidence.
1037
+ - Non-final features complete with \`validationScope: "targeted"\`.
1038
+ - The final feature must run a broad project-level gate and use \`validationScope: "broad"\`.
1039
+
1040
+ For broad validation research, risky changes, or unclear coverage, use
1041
+ \`../flow/references/parallel-orchestration.md\` to fan out named Flow workers.
1042
+ Use the mode-to-agent mapping in that reference instead of generic subagents.
1043
+ Workers must use the handoff format and verification gates from that reference.
1044
+ They may report command output they actually ran or propose focused checks; the
1045
+ manager decides what is strong enough to record.
1046
+
1047
+ For independent implementation attempts, use candidate workers only with
1048
+ explicit user authorization plus isolated worktrees or exact non-overlapping
1049
+ path ownership. Treat their output as candidate patches. The manager inspects,
1050
+ merges, validates, and records Flow state serially.
1051
+
1052
+ ## Review and complete
1053
+
1054
+ Before \`flow_feature_complete\`, obtain a \`featureReview\` payload. Load
1055
+ \`flow-review\`; for read-only subagent reviews, the manager receives the payload
1056
+ and records it.
1057
+
1058
+ If \`flow_status\` reports \`setup.skills\` or \`flow-review\` cannot be loaded, do
1059
+ not record a Flow-gated \`featureReview\` or \`finalReview\`. You may perform an
1060
+ advisory review using available context or bundled reviewer fallback text, then
1061
+ complete with \`status: "needs_input"\` if review evidence is required to proceed.
1062
+
1063
+ For the final feature, also obtain a \`finalReview\` payload whose \`reviewDepth\` equals the approved plan's \`finalReviewPolicy\`.
1064
+
1065
+ Complete with:
1066
+
1067
+ \`\`\`json
1068
+ {
1069
+ "status": "ok",
1070
+ "featureId": "active-feature-id",
1071
+ "summary": "what changed",
1072
+ "artifactsChanged": [{ "path": "src/file.ts" }],
1073
+ "validationRun": [
1074
+ { "command": "bun test tests/foo.test.ts", "status": "passed", "summary": "3 pass, exercised foo behavior" }
1075
+ ],
1076
+ "validationScope": "targeted",
1077
+ "featureReview": { "status": "passed", "summary": "review summary", "blockingFindings": [] }
1078
+ }
1079
+ \`\`\`
1080
+
1081
+ 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.
1082
+ `;var J=`# UI quality rubric
933
1083
 
934
1084
  Use this rubric for frontend planning, implementation, and review.
935
1085
 
@@ -973,7 +1123,7 @@ class; severity; location or screenshot area; evidence inspected; user impact; f
973
1123
  \`\`\`
974
1124
 
975
1125
  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.
976
- `;var L=`# Visual verification workflow
1126
+ `;var Z=`# Visual verification workflow
977
1127
 
978
1128
  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.
979
1129
 
@@ -1013,7 +1163,7 @@ Record the reason and use the strongest available substitute:
1013
1163
  - code inspection against existing component patterns.
1014
1164
 
1015
1165
  Do not claim visual polish was verified if no visual artifact was inspected.
1016
- `;var M=`---
1166
+ `;var Q=`---
1017
1167
  name: flow-ui-quality
1018
1168
  description: Flow guidance for UX/UI design, frontend polish, visual quality review, responsive and accessible interfaces, and avoiding generic AI-generated UI. Use when planning, executing, or reviewing frontend pages, components, dashboards, visual redesigns, interaction states, screenshots, or browser-verified UI work.
1019
1169
  ---
@@ -1058,12 +1208,16 @@ Approve only when the interface is both useful and inspectable:
1058
1208
  - Screenshot/browser evidence supports the claim whenever feasible.
1059
1209
 
1060
1210
  Never approve a UI change based only on code shape. If users will judge it visually, Flow evidence should include visual inspection.
1061
- `;var x=[{name:"flow",files:[{relativePath:"SKILL.md",content:q},{relativePath:"references/recovery-playbook.md",content:U},{relativePath:"references/parallel-orchestration.md",content:C},{relativePath:"references/handoff-format.md",content:F},{relativePath:"references/verification-gates.md",content:A}]},{name:"flow-plan",files:[{relativePath:"SKILL.md",content:z},{relativePath:"references/planning-examples.md",content:W},{relativePath:"references/parallel-discovery.md",content:j}]},{name:"flow-run",files:[{relativePath:"SKILL.md",content:E},{relativePath:"references/validation-rubric.md",content:V},{relativePath:"references/audit-rubric.md",content:N}]},{name:"flow-review",files:[{relativePath:"SKILL.md",content:O},{relativePath:"references/review-rubric.md",content:B}]},{name:"flow-deslop",files:[{relativePath:"SKILL.md",content:D},{relativePath:"references/smell-rubric.md",content:P},{relativePath:"references/refactor-workflow.md",content:T}]},{name:"flow-ui-quality",files:[{relativePath:"SKILL.md",content:M},{relativePath:"references/ui-rubric.md",content:G},{relativePath:"references/visual-verification.md",content:L}]}];var X=".flow-skill-version";function _(){return process.env.HOME??process.env.USERPROFILE??""}function $(e=_()){return l(e,".config","opencode","skills")}function R(e){return xe("sha256").update(e).digest("hex")}function Ue(e,t){return[`version=${t}`,...e.files.map((a)=>`file=${a.relativePath} sha256=${R(a.content)}`),""].join(`
1062
- `)}async function p(e){try{return await _e(e,"utf8")}catch(t){if(t.code==="ENOENT")return null;throw t}}function Y(e){let t=new Map;if(!e)return t;for(let a of e.split(/\r?\n/)){let r=/^file=(.+) sha256=([a-f0-9]{64})$/.exec(a)??/^file=(.+)=sha256:([a-f0-9]{64})$/.exec(a);if(r?.[1]&&r[2])t.set(r[1],r[2]);let n=/^hash=sha256:([a-f0-9]{64})$/.exec(a);if(n?.[1]&&!t.has("SKILL.md"))t.set("SKILL.md",n[1])}return t}function Ae(e){if(!e)return null;for(let t of e.split(/\r?\n/)){let a=/^version=(.+)$/.exec(t);if(a?.[1])return a[1]}return null}function J(e,t){let a=Fe(l(e,...t.split("/")));if(a!==e&&a.startsWith(`${e}${Ce}`))return a;throw Error(`Unsafe skill file path '${t}'.`)}function qe(){return x.map((e)=>e.name)}function Te(e){return`npx -y opencode-plugin-flow@${e} doctor`}function Pe(){if(process.env.npm_package_version)return process.env.npm_package_version;try{let e=Ie(import.meta.url);for(let t of["../package.json","../../package.json"])try{let a=e(t);if(a.version)return a.version}catch{}}catch{}return"0.0.0"}async function Z(e=Pe(),t=_()){let a=$(t),r=new Set(qe()),n=await Promise.all(x.map(async(o)=>{let i=l(a,o.name),m=await p(l(i,X)),g=Ae(m),ee=Y(m);if(await p(l(i,"SKILL.md"))===null)return{name:o.name,path:i,status:"missing",markerVersion:g,missingFiles:o.files.map((d)=>d.relativePath),editedFiles:[],outdatedFiles:[]};if(m===null)return{name:o.name,path:i,status:"foreign",markerVersion:g,missingFiles:[],editedFiles:[],outdatedFiles:[]};let w=[],y=[],b=[];for(let d of o.files){let k=await p(J(i,d.relativePath));if(k===null){w.push(d.relativePath);continue}if(k===d.content)continue;let I=ee.get(d.relativePath);if(I&&R(k)!==I){y.push(d.relativePath);continue}b.push(d.relativePath)}let ae=m!==Ue(o,e),te=w.length>0?"incomplete":y.length>0?"edited":ae||b.length>0?"outdated":"ok";return{name:o.name,path:i,status:te,markerVersion:g,missingFiles:w,editedFiles:y,outdatedFiles:b}})),s=[];try{s=await K(a)}catch(o){if(o.code!=="ENOENT")throw o}let c=s.filter((o)=>(o==="flow"||o.startsWith("flow-"))&&!r.has(o)).map((o)=>l(a,o)),u=n.filter((o)=>["missing","incomplete","outdated"].includes(o.status)).map((o)=>o.name),h=n.filter((o)=>["foreign","edited"].includes(o.status)).map((o)=>o.name),f=h.length>0,v=u.length>0;return{status:f?"action_required":v?"sync_required":"ok",version:e,root:a,expectedSkills:[...r],skills:n,syncRequiredSkills:u,actionRequiredSkills:h,unmanagedFlowSkills:c}}function S(e,t,a){if(a.length===0)return;e.push(`- ${t}: ${a.join(", ")}`)}function Q(e){let t=["Flow doctor",`- status: ${e.status}`,`- plugin version: ${e.version}`,`- skills root: ${e.root}`,`- expected skills: ${e.expectedSkills.join(", ")}`];S(t,"startup sync can install/update",e.syncRequiredSkills),S(t,"needs user decision",e.actionRequiredSkills),t.push("","Skills:");for(let a of e.skills){if(t.push(`- ${a.name}: ${a.status} (${a.path})${a.markerVersion?` marker=${a.markerVersion}`:""}`),a.missingFiles.length>0)t.push(` missing: ${a.missingFiles.join(", ")}`);if(a.editedFiles.length>0)t.push(` edited: ${a.editedFiles.join(", ")}`);if(a.outdatedFiles.length>0)t.push(` outdated: ${a.outdatedFiles.join(", ")}`)}if(e.unmanagedFlowSkills.length>0){t.push("","Unmanaged Flow-like skill folders:");for(let a of e.unmanagedFlowSkills)t.push(`- ${a}`)}if(t.push("","Recommendation:"),e.status==="ok")t.push("- Flow skills are present and current.");else if(e.status==="sync_required")t.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.");else t.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.");return t.push(`- Details command: ${Te(e.version)}`),`${t.join(`
1211
+ `;var w=[{name:"flow",files:[{relativePath:"SKILL.md",content:B},{relativePath:"references/recovery-playbook.md",content:z},{relativePath:"references/parallel-orchestration.md",content:W},{relativePath:"references/handoff-format.md",content:j},{relativePath:"references/verification-gates.md",content:O}]},{name:"flow-plan",files:[{relativePath:"SKILL.md",content:M},{relativePath:"references/planning-examples.md",content:G},{relativePath:"references/parallel-discovery.md",content:S}]},{name:"flow-run",files:[{relativePath:"SKILL.md",content:Y},{relativePath:"references/validation-rubric.md",content:X},{relativePath:"references/audit-rubric.md",content:K}]},{name:"flow-review",files:[{relativePath:"SKILL.md",content:$},{relativePath:"references/review-rubric.md",content:L}]},{name:"flow-deslop",files:[{relativePath:"SKILL.md",content:E},{relativePath:"references/smell-rubric.md",content:V},{relativePath:"references/refactor-workflow.md",content:N}]},{name:"flow-ui-quality",files:[{relativePath:"SKILL.md",content:Q},{relativePath:"references/ui-rubric.md",content:J},{relativePath:"references/visual-verification.md",content:Z}]}];var U=".flow-skill-version";function x(){return process.env.HOME??process.env.USERPROFILE??""}function q(e=x()){return l(e,".config","opencode","skills")}function _(e){return Fe("sha256").update(e).digest("hex")}function b(e,a){return[`version=${a}`,...e.files.map((t)=>`file=${t.relativePath} sha256=${_(t.content)}`),""].join(`
1212
+ `)}async function f(e){try{return await Ue(e,"utf8")}catch(a){if(a.code==="ENOENT")return null;throw a}}function A(e){let a=new Map;if(!e)return a;for(let t of e.split(/\r?\n/)){let r=/^file=(.+) sha256=([a-f0-9]{64})$/.exec(t)??/^file=(.+)=sha256:([a-f0-9]{64})$/.exec(t);if(r?.[1]&&r[2])a.set(r[1],r[2]);let n=/^hash=sha256:([a-f0-9]{64})$/.exec(t);if(n?.[1]&&!a.has("SKILL.md"))a.set("SKILL.md",n[1])}return a}function je(e){if(!e)return null;for(let a of e.split(/\r?\n/)){let t=/^version=(.+)$/.exec(a);if(t?.[1])return t[1]}return null}function k(e,a){let t=Pe(l(e,...a.split("/")));if(t!==e&&t.startsWith(`${e}${De}`))return t;throw Error(`Unsafe skill file path '${a}'.`)}async function We(e,a,t){let r=l(t,e.name),n=l(r,U),s=await f(n),d=A(s);if(await f(l(r,"SKILL.md"))!==null&&s===null)return{name:e.name,action:"skipped_foreign"};let p=!1,m=!1;for(let o of e.files){let i=k(r,o.relativePath),u=await f(i);if(u===o.content)continue;p=!0;let v=d.get(o.relativePath);if(u!==null&&(v?_(u)!==v:s!==null))await y(`${i}.backup`,u,"utf8"),m=!0}if(!p&&s===b(e,a))return{name:e.name,action:"unchanged"};if(!p)return await y(n,b(e,a),"utf8"),{name:e.name,action:"marker_updated"};let g=s!==null;for(let o of e.files){let i=k(r,o.relativePath);await Ce(Te(i),{recursive:!0}),await y(i,o.content,"utf8")}return await y(n,b(e,a),"utf8"),{name:e.name,action:m?"updated_with_backup":g?"updated":"installed"}}function ze(){return w.map((e)=>e.name)}function Oe(e){return`npx -y opencode-plugin-flow@${e} doctor`}function T(){if(process.env.npm_package_version)return process.env.npm_package_version;try{let e=Ae(import.meta.url);for(let a of["../package.json","../../package.json"])try{let t=e(a);if(t.version)return t.version}catch{}}catch{}return"0.0.0"}async function ae(e,a=x()){let t=q(a);return Promise.all(w.map((r)=>We(r,e,t)))}async function te(e=T(),a=x()){let t=q(a),r=new Set(ze()),n=await Promise.all(w.map(async(o)=>{let i=l(t,o.name),u=await f(l(i,U)),v=je(u),P=A(u);if(await f(l(i,"SKILL.md"))===null)return{name:o.name,path:i,status:"missing",markerVersion:v,missingFiles:o.files.map((h)=>h.relativePath),editedFiles:[],outdatedFiles:[]};if(u===null)return{name:o.name,path:i,status:"foreign",markerVersion:v,missingFiles:[],editedFiles:[],outdatedFiles:[]};let I=[],R=[],F=[];for(let h of o.files){let C=await f(k(i,h.relativePath));if(C===null){I.push(h.relativePath);continue}if(C===h.content)continue;let D=P.get(h.relativePath);if(D&&_(C)!==D){R.push(h.relativePath);continue}F.push(h.relativePath)}let ne=u!==b(o,e),se=I.length>0?"incomplete":R.length>0?"edited":ne||F.length>0?"outdated":"ok";return{name:o.name,path:i,status:se,markerVersion:v,missingFiles:I,editedFiles:R,outdatedFiles:F}})),s=[];try{s=await ee(t)}catch(o){if(o.code!=="ENOENT")throw o}let d=s.filter((o)=>(o==="flow"||o.startsWith("flow-"))&&!r.has(o)).map((o)=>l(t,o)),c=n.filter((o)=>["missing","incomplete","outdated"].includes(o.status)).map((o)=>o.name),p=n.filter((o)=>["foreign","edited"].includes(o.status)).map((o)=>o.name),m=p.length>0,g=c.length>0;return{status:m?"action_required":g?"sync_required":"ok",version:e,root:t,expectedSkills:[...r],skills:n,syncRequiredSkills:c,actionRequiredSkills:p,unmanagedFlowSkills:d}}function H(e,a,t){if(t.length===0)return;e.push(`- ${a}: ${t.join(", ")}`)}function oe(e){let a=["Flow doctor",`- status: ${e.status}`,`- plugin version: ${e.version}`,`- skills root: ${e.root}`,`- expected skills: ${e.expectedSkills.join(", ")}`];H(a,"startup sync can install/update",e.syncRequiredSkills),H(a,"needs user decision",e.actionRequiredSkills),a.push("","Skills:");for(let t of e.skills){if(a.push(`- ${t.name}: ${t.status} (${t.path})${t.markerVersion?` marker=${t.markerVersion}`:""}`),t.missingFiles.length>0)a.push(` missing: ${t.missingFiles.join(", ")}`);if(t.editedFiles.length>0)a.push(` edited: ${t.editedFiles.join(", ")}`);if(t.outdatedFiles.length>0)a.push(` outdated: ${t.outdatedFiles.join(", ")}`)}if(e.unmanagedFlowSkills.length>0){a.push("","Unmanaged Flow-like skill folders:");for(let t of e.unmanagedFlowSkills)a.push(`- ${t}`)}if(a.push("","Recommendation:"),e.status==="ok")a.push("- Flow skills are present and current.");else if(e.status==="sync_required")a.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.");else a.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.");return a.push(`- Details command: ${Oe(e.version)}`),`${a.join(`
1063
1213
  `)}
1064
- `}async function H(e=_()){let t=$(e),a=[],r=[],n;try{n=await K(t)}catch(s){if(s.code==="ENOENT")return{removed:a,kept:r};throw s}for(let s of n){if(s!=="flow"&&!s.startsWith("flow-"))continue;let c=l(t,s),u=await p(l(c,X));if(u===null){r.push(c);continue}let h=Y(u),f=!1;for(let[v,o]of h){let i=await p(J(c,v));if(i!==null&&R(i)!==o){f=!0;break}}if(f){r.push(c);continue}await Re(c,{recursive:!0,force:!0}),a.push(c)}return{removed:a,kept:r}}async function De(e){let t=e[2];if(t!=="uninstall"&&t!=="doctor"){process.stderr.write(`usage: opencode-plugin-flow <doctor|uninstall>
1065
- `),process.exitCode=2;return}if(t==="doctor"){process.stdout.write(Q(await Z()));return}let a=await H();for(let r of a.removed)process.stdout.write(`Removed Flow skill: ${r}
1066
- `);for(let r of a.kept)process.stdout.write(`Kept non-Flow or user-edited skill: ${r}
1214
+ `}async function re(e=x()){let a=q(e),t=[],r=[],n;try{n=await ee(a)}catch(s){if(s.code==="ENOENT")return{removed:t,kept:r};throw s}for(let s of n){if(s!=="flow"&&!s.startsWith("flow-"))continue;let d=l(a,s),c=await f(l(d,U));if(c===null){r.push(d);continue}let p=A(c),m=!1;for(let[g,o]of p){let i=await f(k(d,g));if(i!==null&&_(i)!==o){m=!0;break}}if(m){r.push(d);continue}await qe(d,{recursive:!0,force:!0}),t.push(d)}return{removed:t,kept:r}}async function Be(e){let a=e[2];if(a!=="uninstall"&&a!=="doctor"&&a!=="sync"){process.stderr.write(`usage: opencode-plugin-flow <doctor|sync|uninstall>
1215
+ `),process.exitCode=2;return}if(a==="doctor"){process.stdout.write(oe(await te()));return}if(a==="sync"){let r=T(),n=await ae(r),s=n.filter((c)=>["installed","updated","updated_with_backup"].includes(c.action)),d=n.filter((c)=>c.action==="skipped_foreign");process.stdout.write(`Flow skill sync (${r})
1216
+ `);for(let c of n)process.stdout.write(`- ${c.name}: ${c.action}
1217
+ `);if(s.length>0)process.stdout.write(`Restart OpenCode so the refreshed skill registry is used.
1218
+ `);if(d.length>0)process.stdout.write(`Some managed skill folders are user-owned or edited; run doctor for repair guidance.
1219
+ `);return}let t=await re();for(let r of t.removed)process.stdout.write(`Removed Flow skill: ${r}
1220
+ `);for(let r of t.kept)process.stdout.write(`Kept non-Flow or user-edited skill: ${r}
1067
1221
  `);process.stdout.write(`Remove "opencode-plugin-flow" from opencode.json and restart OpenCode.
1068
- `)}De(process.argv).catch((e)=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
1222
+ `)}Be(process.argv).catch((e)=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
1069
1223
  `),process.exitCode=1});