opencode-plugin-flow 4.1.6 → 4.1.7
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 +4 -0
- package/README.md +23 -15
- package/dist/cli.js +297 -32
- package/dist/index.js +297 -32
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -105,6 +105,9 @@ recorded.
|
|
|
105
105
|
- Identify whether this is a feature review or final review.
|
|
106
106
|
- Read the approved plan fields relevant to the work: \`requirements\`, \`decisions\`, feature \`targets\`, feature \`validation\`, and dependencies.
|
|
107
107
|
- Inspect the actual diff, changed files, tests, and validation output. Do not review only the completion summary.
|
|
108
|
+
- Load \`flow-test\` for validation-heavy, regression-sensitive, browser/UI, or
|
|
109
|
+
unclear coverage reviews. If it is unavailable, record a coverage gap and
|
|
110
|
+
treat missing validation evidence as a gap or blocker based on user impact.
|
|
108
111
|
- Load \`references/review-rubric.md\` for severity, depth, and payload shape.
|
|
109
112
|
|
|
110
113
|
## Feature Review Depth
|
|
@@ -153,9 +156,9 @@ Use \`status: "failed"\` when any blocking finding remains. Advisory findings ma
|
|
|
153
156
|
\`finalReview\` payload.
|
|
154
157
|
|
|
155
158
|
Never approve to unblock completion, fix findings in the review pass, or vouch for validation you did not inspect.
|
|
156
|
-
`;var
|
|
159
|
+
`;var Ft=["Use Flow review mode. Call `flow_status` before loading review skills. If Flow setup reports stale/unavailable skills or the skill loader reports that `flow-review` is unavailable, continue with the bundled review instructions below as advisory review only. Do not present advisory review as Flow-gated `featureReview` or `finalReview` evidence.","","## Bundled Flow review fallback","","## Bundled flow-review/SKILL.md",j,"## Bundled flow-review/references/review-rubric.md",U].join(`
|
|
157
160
|
|
|
158
|
-
`),pe="Call `flow_status` first. If the result includes `setup.skills`, report the setup status and do not load Flow skills in this startup.";function L(e,a){return`${pe} Otherwise load the \`${e}\` skill and ${a}`}var
|
|
161
|
+
`),pe="Call `flow_status` first. If the result includes `setup.skills`, report the setup status and do not load Flow skills in this startup.";function L(e,a){return`${pe} Otherwise load the \`${e}\` skill and ${a}`}var _t={"flow-reviewer":{mode:"subagent",hidden:!0,description:"Internal read-only reviewer for Flow-guided work.",prompt:Ft,permission:{edit:"deny",bash:"deny",task:{"*":"deny"},"flow_*":"deny",flow_status:"allow"}},"flow-evidence-worker":{mode:"subagent",hidden:!0,description:"Internal read-only evidence worker for Flow planning and execution support.",prompt:"Use Flow evidence mode. Inspect only the assigned slice, do not edit files, do not call state-changing Flow tools, and return coverage, evidence inspected, confidence-tagged findings or facts, gaps, and manager follow-ups.",permission:{edit:"deny",bash:"deny",task:{"*":"deny"},"flow_*":"deny",flow_status:"allow"}},"flow-validation-worker":{mode:"subagent",hidden:!0,description:"Internal validation worker for Flow check selection and command evidence.",prompt:"Use Flow validation mode. Run only manager-specified commands or propose focused checks, do not edit files, do not call state-changing Flow tools, and report exact command, status, raw outcome summary, coverage, confidence, gaps, and manager follow-ups.",permission:{edit:"deny",bash:"ask",task:{"*":"deny"},"flow_*":"deny",flow_status:"allow"}},"flow-audit-worker":{mode:"subagent",hidden:!0,description:"Internal read-only audit worker for refuted or surviving finding candidates.",prompt:"Use Flow audit mode. Inspect only the assigned slice, actively refute candidate findings before reporting them, do not edit files, do not call state-changing Flow tools, and return coverage, evidence, guards checked, confidence, gaps, and manager follow-ups.",permission:{edit:"deny",bash:"ask",task:{"*":"deny"},"flow_*":"deny",flow_status:"allow"}},"flow-candidate-worker":{mode:"subagent",hidden:!0,description:"Internal candidate implementation worker for isolated Flow worktrees or exact non-overlapping path ownership.",prompt:"Use Flow candidate-implementation mode only when the manager assigned an isolated worktree or exact non-overlapping path ownership. Do not edit .flow/**, do not call state-changing Flow tools, do not complete Flow state, and return changed or proposed patch, verification run, coverage, confidence, merge risks, and manager follow-ups.",permission:{edit:"ask",bash:"ask",task:{"*":"deny"},"flow_*":"deny",flow_status:"allow"}},"flow-verifier-worker":{mode:"subagent",hidden:!0,description:"Internal verifier worker for checking Flow worker claims against cited evidence.",prompt:"Use Flow verifier mode. Verify only the assigned claims against the provided sources, commands, counts, or current docs. Do not generate new scope, do not edit files, do not call state-changing Flow tools, and return supported, partly-supported, unsupported, or source-not-found per claim with evidence, confidence, gaps, and manager follow-ups.",permission:{edit:"deny",bash:"ask",task:{"*":"deny"},"flow_*":"deny",flow_status:"allow"}}},Q={"flow-auto":{description:"Drive Flow skills against the minimal runtime ledger",template:L("flow","drive the Flow loop until completion or a real blocker: $ARGUMENTS")},"flow-plan":{description:"Create or approve a Flow plan",template:L("flow-plan","plan: $ARGUMENTS")},"flow-run":{description:"Run one approved Flow feature",template:L("flow-run","execute the next approved feature. $ARGUMENTS")},"flow-review":{description:"Run a read-only Flow review",agent:"flow-reviewer",subtask:!0,template:`${pe} If setup is clear, load \`flow-review\`; if loading fails because the skill is unavailable, use the bundled review fallback as advisory review only. Review: $ARGUMENTS`},"flow-status":{description:"Inspect the active Flow session",template:"Call flow_status and report the session state and next action."}};function It(){return{agent:Object.fromEntries(Object.entries(_t).map(([e,a])=>{let t=a.permission?{...a.permission,...a.permission.task?{task:{...a.permission.task}}:{}}:void 0;return[e,{...a,...t?{permission:t}:{}}]})),command:Object.fromEntries(Object.entries(Q).map(([e,a])=>[e,{...a}]))}}function fe(e){let a=It();e.agent={...e.agent??{},...a.agent},e.command={...e.command??{},...a.command}}import{createHash as Jt}from"node:crypto";import{mkdir as Kt,readdir as Er,readFile as Lt,rm as Or,writeFile as q}from"node:fs/promises";import{createRequire as Qt}from"node:module";import{dirname as Xt,join as P,normalize as Yt,sep as Ht}from"node:path";var me=`# Flow worker handoff contract
|
|
159
162
|
|
|
160
163
|
Flow managers merge only the worker's final response. Treat that response as the
|
|
161
164
|
worker report of record: it must include the assigned scope, what was actually
|
|
@@ -495,7 +498,7 @@ Before presenting or recording the result:
|
|
|
495
498
|
still checks coverage and evidence before trusting the result.
|
|
496
499
|
`;var we=`---
|
|
497
500
|
name: flow
|
|
498
|
-
description:
|
|
501
|
+
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.
|
|
499
502
|
---
|
|
500
503
|
|
|
501
504
|
# Flow
|
|
@@ -509,13 +512,17 @@ Use Flow as a minimal state ledger, not as a framework. Skills provide judgment;
|
|
|
509
512
|
load Flow skills in this startup. A just-synced skill can be on disk while
|
|
510
513
|
unavailable to the running OpenCode process.
|
|
511
514
|
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.
|
|
512
|
-
3. Load \`flow-run\`, call \`flow_run_start\`, implement exactly one feature, validate it, and prepare a \`flow_feature_complete\` payload.
|
|
515
|
+
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, or browser/UI work, use \`flow-test\` to choose and summarize evidence before completion.
|
|
513
516
|
4. Load \`flow-review\` for the required feature review. The reviewer reports a \`featureReview\` payload; the manager records it inside \`flow_feature_complete\`.
|
|
514
517
|
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\`.
|
|
515
518
|
6. After all features are complete, archive the session with \`flow_session_close\` using \`kind: "completed"\`.
|
|
516
519
|
|
|
517
520
|
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.
|
|
518
521
|
|
|
522
|
+
Do not commit, push, amend, rebase, publish, or mutate releases during the
|
|
523
|
+
autonomous Flow loop. Load \`flow-commit\` only when the user explicitly asks for
|
|
524
|
+
commit preparation or commit creation.
|
|
525
|
+
|
|
519
526
|
## Skill Availability
|
|
520
527
|
|
|
521
528
|
If \`flow_status\` returns \`setup.skills\`, report that setup status and stop
|
|
@@ -523,9 +530,10 @@ loading Flow skills in the current OpenCode startup. Missing, incomplete, or
|
|
|
523
530
|
outdated managed skills require a sync/restart cycle before their instructions
|
|
524
531
|
can be trusted by the running process.
|
|
525
532
|
|
|
526
|
-
If optional helper skills such as \`flow-
|
|
527
|
-
unavailable, continue only with explicit coverage gaps. Do
|
|
528
|
-
rubrics into another skill and do not claim their quality checks
|
|
533
|
+
If optional helper skills such as \`flow-test\`, \`flow-deslop\`, or
|
|
534
|
+
\`flow-ui-quality\` are unavailable, continue only with explicit coverage gaps. Do
|
|
535
|
+
not copy their rubrics into another skill and do not claim their quality checks
|
|
536
|
+
were completed.
|
|
529
537
|
|
|
530
538
|
## Runtime Surface
|
|
531
539
|
|
|
@@ -560,7 +568,121 @@ Planning and running require loaded Flow tools; do not simulate plan approval or
|
|
|
560
568
|
- Unknown runtime error: read \`summary\` and \`recovery\`; see \`references/recovery-playbook.md\` for common cases.
|
|
561
569
|
|
|
562
570
|
Never fabricate validation output, backfill review approval you did not perform, or close as \`deferred\`/\`abandoned\` merely to avoid an unfinished-work blocker.
|
|
563
|
-
`;var ye
|
|
571
|
+
`;var ye=`---
|
|
572
|
+
name: flow-commit
|
|
573
|
+
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.
|
|
574
|
+
---
|
|
575
|
+
|
|
576
|
+
# Flow Commit
|
|
577
|
+
|
|
578
|
+
Use this skill only when the user asks to prepare or create a commit, write a
|
|
579
|
+
commit message, stage intended work, or validate staged changes before
|
|
580
|
+
committing. It is not part of the autonomous Flow loop and must not be loaded
|
|
581
|
+
automatically by \`flow\`, \`flow-run\`, or \`flow_feature_complete\`.
|
|
582
|
+
|
|
583
|
+
When a Flow session exists, a commit never substitutes for Flow completion. The
|
|
584
|
+
manager still records validation and review evidence through
|
|
585
|
+
\`flow_feature_complete\` before claiming a Flow feature is done. Default to commit
|
|
586
|
+
preparation only after \`flow_feature_complete\` has recorded the relevant
|
|
587
|
+
completion evidence. If the user explicitly asks for a WIP commit, preserve
|
|
588
|
+
failing or incomplete validation context in the message.
|
|
589
|
+
|
|
590
|
+
## Boundaries
|
|
591
|
+
|
|
592
|
+
- Preserve unrelated user work.
|
|
593
|
+
- Stage explicit paths or hunks only. Do not default to \`git add .\` or
|
|
594
|
+
\`git add -A\`.
|
|
595
|
+
- Do not commit \`.flow/**\` state unless the maintainer explicitly asks to
|
|
596
|
+
archive those exact files.
|
|
597
|
+
- Do not push, amend, rebase, squash, reset, force-push, tag, release, publish,
|
|
598
|
+
or mutate remote state unless the user explicitly authorizes that exact
|
|
599
|
+
operation.
|
|
600
|
+
- Stop before committing secrets, local config, credentials, private keys,
|
|
601
|
+
generated release artifacts, or suspicious environment files.
|
|
602
|
+
- Stop when validation fails unless the user explicitly wants an unfinished WIP
|
|
603
|
+
commit and the commit message says so.
|
|
604
|
+
|
|
605
|
+
## Inspect
|
|
606
|
+
|
|
607
|
+
Start with the worktree and intent:
|
|
608
|
+
|
|
609
|
+
1. Run \`git status --short\`.
|
|
610
|
+
2. Inspect unstaged and staged changes separately with \`git diff\` and
|
|
611
|
+
\`git diff --cached\`.
|
|
612
|
+
3. Inspect untracked files before deciding whether they belong.
|
|
613
|
+
4. Group changes by intent, feature, and risk. Prefer one coherent commit over
|
|
614
|
+
one large mixed commit.
|
|
615
|
+
5. Identify exclusions: unrelated files, local notes, \`.flow/**\`, generated
|
|
616
|
+
artifacts, logs, caches, credentials, and temporary outputs.
|
|
617
|
+
|
|
618
|
+
If the commit boundary is unclear, propose the boundary and ask before staging.
|
|
619
|
+
|
|
620
|
+
## Stage
|
|
621
|
+
|
|
622
|
+
Stage only the intended boundary:
|
|
623
|
+
|
|
624
|
+
- Use explicit file paths for whole-file staging.
|
|
625
|
+
- Use patch staging for mixed-intent files.
|
|
626
|
+
- Re-run \`git status --short\` and \`git diff --cached --stat\` after staging.
|
|
627
|
+
- Review the full staged diff before validation and commit.
|
|
628
|
+
|
|
629
|
+
Never undo or rewrite user changes to make staging easier. If a file contains
|
|
630
|
+
mixed user and agent work, either stage selected hunks or ask for direction.
|
|
631
|
+
|
|
632
|
+
## Screen and Validate
|
|
633
|
+
|
|
634
|
+
Before commit creation, check the staged diff for:
|
|
635
|
+
|
|
636
|
+
- Secrets, tokens, private keys, credentials, cookies, and unredacted personal
|
|
637
|
+
data.
|
|
638
|
+
- \`.env\`, local config, machine-specific paths, and editor files.
|
|
639
|
+
- \`.flow/**\` state.
|
|
640
|
+
- Generated artifacts that are not normally versioned.
|
|
641
|
+
- Package or version metadata drift unrelated to the requested change.
|
|
642
|
+
|
|
643
|
+
When this repository-local contribution preflight exists, defer to it for staged
|
|
644
|
+
and outgoing validation instead of duplicating its checks:
|
|
645
|
+
|
|
646
|
+
\`\`\`bash
|
|
647
|
+
.agents/skills/flow-contribution-check/scripts/preflight.sh commit
|
|
648
|
+
\`\`\`
|
|
649
|
+
|
|
650
|
+
Run it after staging and rerun it after any staging change. The preflight
|
|
651
|
+
validates staged or outgoing work; it does not choose commit boundaries or write
|
|
652
|
+
commit messages. If the script is absent, use the repository's documented commit
|
|
653
|
+
preflight from package scripts, AGENTS/docs, or CI guidance.
|
|
654
|
+
|
|
655
|
+
Use the repository's documented broad validation gate when a full local check is
|
|
656
|
+
appropriate, such as package scripts, AGENTS/docs, or CI guidance. Use narrower
|
|
657
|
+
tests only when the user has asked for a lighter pass or when the change is
|
|
658
|
+
intentionally not ready for the broad gate.
|
|
659
|
+
|
|
660
|
+
## Message
|
|
661
|
+
|
|
662
|
+
Propose a commit message that reflects the staged diff:
|
|
663
|
+
|
|
664
|
+
- Subject: imperative, specific, and scoped.
|
|
665
|
+
- Body when useful: context, changed areas, validation run, and remaining risk.
|
|
666
|
+
- Do not mention unstaged or excluded work as if it were included.
|
|
667
|
+
- Include WIP or failing-validation context only when the user explicitly chose
|
|
668
|
+
that path.
|
|
669
|
+
|
|
670
|
+
## Create Commit
|
|
671
|
+
|
|
672
|
+
Create the commit only after the user explicitly asks for commit creation or has
|
|
673
|
+
already authorized it in the current request.
|
|
674
|
+
|
|
675
|
+
Before running \`git commit\`, report:
|
|
676
|
+
|
|
677
|
+
- Staged paths.
|
|
678
|
+
- Excluded dirty or untracked paths.
|
|
679
|
+
- Validation command and result.
|
|
680
|
+
- Proposed message.
|
|
681
|
+
- Any risks or gaps.
|
|
682
|
+
|
|
683
|
+
After a successful commit, report the commit hash and leave push or release
|
|
684
|
+
actions for a separate explicit request.
|
|
685
|
+
`;var be=`# Safe refactor workflow
|
|
564
686
|
|
|
565
687
|
Refactoring is a behavior-preserving sequence of small changes. This workflow keeps cleanup from becoming an unreviewable rewrite.
|
|
566
688
|
|
|
@@ -602,7 +724,7 @@ Weak evidence includes:
|
|
|
602
724
|
- Public contracts and compatibility shims remain intact or were explicitly planned.
|
|
603
725
|
- Deleted code is actually unreachable or obsolete.
|
|
604
726
|
- Validation can catch a realistic mistake in the refactor.
|
|
605
|
-
`;var
|
|
727
|
+
`;var ke=`# Deslop smell rubric
|
|
606
728
|
|
|
607
729
|
Use this rubric to turn vague cleanup instincts into reviewable findings.
|
|
608
730
|
|
|
@@ -636,9 +758,9 @@ class; severity; location; evidence read; refutation checked; why it matters; sa
|
|
|
636
758
|
\`\`\`
|
|
637
759
|
|
|
638
760
|
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.
|
|
639
|
-
`;var
|
|
761
|
+
`;var xe=`---
|
|
640
762
|
name: flow-deslop
|
|
641
|
-
description:
|
|
763
|
+
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.
|
|
642
764
|
---
|
|
643
765
|
|
|
644
766
|
# Flow deslop
|
|
@@ -678,7 +800,7 @@ For each claimed smell removal, verify:
|
|
|
678
800
|
- **blast radius** — public contracts and downstream callers still work.
|
|
679
801
|
|
|
680
802
|
Never approve cleanup because it "looks cleaner" without evidence. Tests passing is necessary but not sufficient when the refactor changes structure across files.
|
|
681
|
-
`;var
|
|
803
|
+
`;var Re=`# Parallel discovery
|
|
682
804
|
|
|
683
805
|
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.
|
|
684
806
|
|
|
@@ -744,7 +866,7 @@ Convert only evidence-backed work into plan fields:
|
|
|
744
866
|
- feature \`validation\`: checks expected to prove the feature.
|
|
745
867
|
|
|
746
868
|
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.
|
|
747
|
-
`;var
|
|
869
|
+
`;var Fe=`# Planning examples
|
|
748
870
|
|
|
749
871
|
## Rate limiting feature set
|
|
750
872
|
|
|
@@ -829,7 +951,7 @@ Better plan:
|
|
|
829
951
|
- Validation that only says "manual testing".
|
|
830
952
|
- Targets that name the entire repo.
|
|
831
953
|
- Features with hidden dependencies instead of \`dependsOn\`.
|
|
832
|
-
`;var
|
|
954
|
+
`;var _e=`---
|
|
833
955
|
name: flow-plan
|
|
834
956
|
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.
|
|
835
957
|
---
|
|
@@ -844,6 +966,9 @@ If \`flow_plan_save\` or \`flow_plan_approve\` is unavailable, stop and tell the
|
|
|
844
966
|
|
|
845
967
|
- Read the files, docs, tests, package scripts, and local conventions that determine the work.
|
|
846
968
|
- 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.
|
|
969
|
+
- For complex validation, regression-sensitive changes, browser/UI workflows,
|
|
970
|
+
or uncertain test strategy, load \`flow-test\`. If it is unavailable, record a
|
|
971
|
+
planning gap and keep validation claims conservative.
|
|
847
972
|
- For cleanup/refactor goals, load \`flow-deslop\`. If it is unavailable, record
|
|
848
973
|
a planning gap and keep cleanup claims conservative.
|
|
849
974
|
- For UI/frontend goals, load \`flow-ui-quality\`. If it is unavailable, record a
|
|
@@ -886,14 +1011,17 @@ Use only \`finalReviewPolicy: "broad"\` or \`"detailed"\`. These are the canonic
|
|
|
886
1011
|
- Split by dependency order: foundations before callers, schema before consumers, implementation before docs when docs depend on behavior.
|
|
887
1012
|
- Avoid "misc cleanup" features. Tie cleanup to evidence and targets.
|
|
888
1013
|
- Keep feature ids stable once the plan is approved.
|
|
889
|
-
- Put scope boundaries in \`targets\` and expected checks in \`validation\`.
|
|
1014
|
+
- Put scope boundaries in \`targets\` and expected checks in \`validation\`. Each
|
|
1015
|
+
validation entry should name the expected test level, such as targeted unit,
|
|
1016
|
+
integration, browser/e2e, package/build, docs/static, cleanup preservation, or
|
|
1017
|
+
broad project gate.
|
|
890
1018
|
|
|
891
1019
|
## Approval
|
|
892
1020
|
|
|
893
1021
|
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.
|
|
894
1022
|
|
|
895
1023
|
See \`references/planning-examples.md\` for payload examples and decomposition anti-patterns.
|
|
896
|
-
`;var
|
|
1024
|
+
`;var Ie=`# Audit findings rubric
|
|
897
1025
|
|
|
898
1026
|
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.
|
|
899
1027
|
|
|
@@ -1003,7 +1131,7 @@ Broad validation usually means the repo's full check command, full relevant test
|
|
|
1003
1131
|
- If validation needs external access, missing credentials, or ambiguous user input, record \`status: "needs_input"\` with an honest \`outcome\`.
|
|
1004
1132
|
|
|
1005
1133
|
Never trim failing output, relabel a failed command as passed, or use "not run" as completion evidence.
|
|
1006
|
-
`;var
|
|
1134
|
+
`;var Pe=`---
|
|
1007
1135
|
name: flow-run
|
|
1008
1136
|
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.
|
|
1009
1137
|
---
|
|
@@ -1029,9 +1157,18 @@ If \`flow_run_start\` is unavailable, stop and tell the user to check that \`ope
|
|
|
1029
1157
|
- Keep edits scoped to the active feature. If new scope appears, stop and replan or defer it to another feature.
|
|
1030
1158
|
- Preserve unrelated user changes in the worktree.
|
|
1031
1159
|
- When a wrong assumption invalidates the feature, use \`flow_feature_reset\`; do not pile patches onto a bad path.
|
|
1160
|
+
- Do not stage, commit, push, amend, rebase, publish, or mutate releases as part
|
|
1161
|
+
of feature execution. If the user explicitly asks for commit preparation, load
|
|
1162
|
+
\`flow-commit\` only after \`flow_feature_complete\` has been recorded, unless the
|
|
1163
|
+
user explicitly asks for a WIP commit path. Keep Git boundaries separate from
|
|
1164
|
+
Flow state recording.
|
|
1032
1165
|
|
|
1033
1166
|
## Validate
|
|
1034
1167
|
|
|
1168
|
+
- For complex validation, regression-sensitive changes, browser/UI workflows,
|
|
1169
|
+
failure-prone checks, unclear coverage, route QA, exploratory QA, or
|
|
1170
|
+
\`validationRun\` summarization, load \`flow-test\`. If it is unavailable, record
|
|
1171
|
+
the coverage gap and keep validation claims conservative.
|
|
1035
1172
|
- Read \`references/validation-rubric.md\` before completing.
|
|
1036
1173
|
- Run the strongest practical checks for the changed behavior.
|
|
1037
1174
|
- Record concrete command names, status, and observed results. "Tests pass" is not evidence.
|
|
@@ -1058,8 +1195,9 @@ and records it.
|
|
|
1058
1195
|
|
|
1059
1196
|
If \`flow_status\` reports \`setup.skills\` or \`flow-review\` cannot be loaded, do
|
|
1060
1197
|
not record a Flow-gated \`featureReview\` or \`finalReview\`. You may perform an
|
|
1061
|
-
advisory review using available context or bundled
|
|
1062
|
-
complete with \`status: "needs_input"\` if review evidence
|
|
1198
|
+
advisory review using available context or the bundled review fallback provided
|
|
1199
|
+
by plugin config, then complete with \`status: "needs_input"\` if review evidence
|
|
1200
|
+
is required to proceed.
|
|
1063
1201
|
|
|
1064
1202
|
For the final feature, also obtain a \`finalReview\` payload whose \`reviewDepth\` equals the approved plan's \`finalReviewPolicy\`.
|
|
1065
1203
|
|
|
@@ -1080,7 +1218,131 @@ Complete with:
|
|
|
1080
1218
|
\`\`\`
|
|
1081
1219
|
|
|
1082
1220
|
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.
|
|
1083
|
-
`;var
|
|
1221
|
+
`;var Ae=`---
|
|
1222
|
+
name: flow-test
|
|
1223
|
+
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.
|
|
1224
|
+
---
|
|
1225
|
+
|
|
1226
|
+
# Flow Test
|
|
1227
|
+
|
|
1228
|
+
Use this skill to decide and gather validation evidence. It produces validation
|
|
1229
|
+
evidence only: the manager still owns \`flow_feature_complete\`, review payloads,
|
|
1230
|
+
plan approval, session closure, and every other Flow state change.
|
|
1231
|
+
|
|
1232
|
+
Do not mutate \`.flow/**\`, approve plans, complete features, close sessions, or
|
|
1233
|
+
substitute for \`flow-review\`. If Flow tools are unavailable, this skill can still
|
|
1234
|
+
produce an advisory validation plan or test summary, but it cannot record Flow
|
|
1235
|
+
state.
|
|
1236
|
+
|
|
1237
|
+
## Inputs
|
|
1238
|
+
|
|
1239
|
+
Start from the smallest concrete surface:
|
|
1240
|
+
|
|
1241
|
+
- The approved feature \`summary\`, \`targets\`, and \`validation\` entries when a
|
|
1242
|
+
Flow session exists.
|
|
1243
|
+
- The actual diff, changed files, package scripts, docs, and test conventions.
|
|
1244
|
+
- Recent command output from this session or from a trusted worker handoff.
|
|
1245
|
+
- Any user-stated acceptance criteria, browser target, fixture, or environment
|
|
1246
|
+
constraint.
|
|
1247
|
+
|
|
1248
|
+
Prefer repository scripts and local conventions over invented commands. If a
|
|
1249
|
+
command has not been run in this session or directly reported by a trusted
|
|
1250
|
+
worker with raw outcome, recommend it instead of claiming it passed.
|
|
1251
|
+
|
|
1252
|
+
## Select Coverage
|
|
1253
|
+
|
|
1254
|
+
Choose checks from changed-surface risk, not from habit:
|
|
1255
|
+
|
|
1256
|
+
- **Targeted behavior**: unit, integration, CLI, route, or component tests that
|
|
1257
|
+
exercise the changed behavior and would fail without the fix.
|
|
1258
|
+
- **Integration and persistence**: database, filesystem, API, adapter, lock, or
|
|
1259
|
+
serialization paths touched by the feature.
|
|
1260
|
+
- **Browser or e2e**: user-visible workflows, responsive states, accessibility
|
|
1261
|
+
basics, form flows, and screenshots when a local target and browser tooling
|
|
1262
|
+
are available.
|
|
1263
|
+
- **Package and build shape**: typecheck, lint, build, generated distribution,
|
|
1264
|
+
or schema checks when public contracts, bundling, or package exports changed.
|
|
1265
|
+
- **Docs and mechanical edits**: markdown rendering, link/path sanity, spelling
|
|
1266
|
+
of commands, or the narrowest project check when behavior is unchanged.
|
|
1267
|
+
- **Cleanup/refactor**: behavior-preservation tests plus the relevant broad
|
|
1268
|
+
check; formatting alone is not evidence of preserved behavior.
|
|
1269
|
+
- **Final feature**: the repository's broad gate, full relevant suite, build, or
|
|
1270
|
+
equivalent release gate before \`validationScope: "broad"\` is recorded.
|
|
1271
|
+
|
|
1272
|
+
If the planned coverage is weaker than the risk, say so explicitly and list the
|
|
1273
|
+
missing evidence.
|
|
1274
|
+
|
|
1275
|
+
## Run Discipline
|
|
1276
|
+
|
|
1277
|
+
For each check:
|
|
1278
|
+
|
|
1279
|
+
1. State the hypothesis: what behavior or contract the check is expected to
|
|
1280
|
+
prove.
|
|
1281
|
+
2. Run the command or manual workflow when the environment allows it.
|
|
1282
|
+
3. Record exact command, status, and observed result.
|
|
1283
|
+
4. If it fails, classify the failure before editing:
|
|
1284
|
+
- product failure
|
|
1285
|
+
- test failure
|
|
1286
|
+
- environment failure
|
|
1287
|
+
- pre-existing failure
|
|
1288
|
+
- flake
|
|
1289
|
+
- unrelated failure
|
|
1290
|
+
5. Before a fix attempt, write a short failure hypothesis that names the likely
|
|
1291
|
+
cause and the file or behavior to inspect.
|
|
1292
|
+
6. After a fix, rerun the failing check and one appropriate regression check.
|
|
1293
|
+
|
|
1294
|
+
Do not trim failure output so far that the manager cannot understand the
|
|
1295
|
+
failure. Do redact secrets and credentials.
|
|
1296
|
+
|
|
1297
|
+
## Browser and Exploratory QA
|
|
1298
|
+
|
|
1299
|
+
For meaningful UI or browser workflow changes, browser evidence is expected when
|
|
1300
|
+
a local target can run:
|
|
1301
|
+
|
|
1302
|
+
- Open the relevant route or story with the available browser tooling.
|
|
1303
|
+
- Exercise the main changed workflow, not only page load.
|
|
1304
|
+
- Check desktop and mobile breakpoints when responsive behavior is in scope.
|
|
1305
|
+
- Capture screenshots or describe the viewport, route, steps, and observed
|
|
1306
|
+
result.
|
|
1307
|
+
- Inspect visible error states, empty states, long labels, focus behavior, and
|
|
1308
|
+
console or network failures when the tooling exposes them.
|
|
1309
|
+
|
|
1310
|
+
Browser claims are evidence requirements, not guaranteed coverage. If browser
|
|
1311
|
+
tooling, credentials, seed data, or a local server is unavailable, record the
|
|
1312
|
+
gap and provide the next-best evidence such as component tests, build output, or
|
|
1313
|
+
static inspection.
|
|
1314
|
+
|
|
1315
|
+
Exploratory QA should be scenario-based. Name the user path, the state varied,
|
|
1316
|
+
and the expected outcome. Do not replace automated evidence with exploratory QA
|
|
1317
|
+
when a practical automated check exists.
|
|
1318
|
+
|
|
1319
|
+
## Output
|
|
1320
|
+
|
|
1321
|
+
Return a concise validation summary and a \`validationRun\` array that the manager
|
|
1322
|
+
can record through \`flow_feature_complete\` if it accepts the evidence:
|
|
1323
|
+
|
|
1324
|
+
\`\`\`json
|
|
1325
|
+
{
|
|
1326
|
+
"validationRun": [
|
|
1327
|
+
{
|
|
1328
|
+
"command": "bun test tests/foo.test.ts",
|
|
1329
|
+
"status": "passed",
|
|
1330
|
+
"summary": "3 pass; covered foo creation, duplicate rejection, and reset behavior"
|
|
1331
|
+
}
|
|
1332
|
+
],
|
|
1333
|
+
"testSummary": "Targeted behavior and package shape passed. Browser evidence was not applicable.",
|
|
1334
|
+
"gaps": []
|
|
1335
|
+
}
|
|
1336
|
+
\`\`\`
|
|
1337
|
+
|
|
1338
|
+
Only passing checks belong in \`validationRun\` for completion. Failed, skipped,
|
|
1339
|
+
or unavailable checks belong in \`testSummary\`, \`gaps\`, or a blocker outcome.
|
|
1340
|
+
Each summary must state what behavior, file set, route, command, or state was
|
|
1341
|
+
covered. Static inspection alone is a gap for behavioral changes.
|
|
1342
|
+
|
|
1343
|
+
Never relabel a failed command as passed, invent output, or use "not run" as
|
|
1344
|
+
completion evidence.
|
|
1345
|
+
`;var Ce=`# UI quality rubric
|
|
1084
1346
|
|
|
1085
1347
|
Use this rubric for frontend planning, implementation, and review.
|
|
1086
1348
|
|
|
@@ -1124,7 +1386,7 @@ class; severity; location or screenshot area; evidence inspected; user impact; f
|
|
|
1124
1386
|
\`\`\`
|
|
1125
1387
|
|
|
1126
1388
|
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.
|
|
1127
|
-
`;var
|
|
1389
|
+
`;var Te=`# Visual verification workflow
|
|
1128
1390
|
|
|
1129
1391
|
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.
|
|
1130
1392
|
|
|
@@ -1164,9 +1426,9 @@ Record the reason and use the strongest available substitute:
|
|
|
1164
1426
|
- code inspection against existing component patterns.
|
|
1165
1427
|
|
|
1166
1428
|
Do not claim visual polish was verified if no visual artifact was inspected.
|
|
1167
|
-
`;var
|
|
1429
|
+
`;var Ue=`---
|
|
1168
1430
|
name: flow-ui-quality
|
|
1169
|
-
description: Flow
|
|
1431
|
+
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.
|
|
1170
1432
|
---
|
|
1171
1433
|
|
|
1172
1434
|
# Flow UI quality
|
|
@@ -1192,6 +1454,9 @@ Use this skill when Flow work changes what a user sees or how they interact with
|
|
|
1192
1454
|
## Verify visually
|
|
1193
1455
|
|
|
1194
1456
|
- For meaningful UI changes, run the app and capture screenshots when a local browser target is available.
|
|
1457
|
+
- For browser-driven QA, route selection, failure classification, and
|
|
1458
|
+
\`validationRun\` summaries, load \`flow-test\`. Keep visual judgment, design
|
|
1459
|
+
quality, and screenshot assessment in \`flow-ui-quality\`.
|
|
1195
1460
|
- Check desktop and mobile breakpoints, not only the viewport you developed in.
|
|
1196
1461
|
- Verify text does not overlap, truncate unintentionally, or escape controls; long labels and empty/error states must fit.
|
|
1197
1462
|
- Compare against provided screenshots, design references, or the stated product intent. List meaningful differences and fix the ones that violate the goal.
|
|
@@ -1209,12 +1474,12 @@ Approve only when the interface is both useful and inspectable:
|
|
|
1209
1474
|
- Screenshot/browser evidence supports the claim whenever feasible.
|
|
1210
1475
|
|
|
1211
1476
|
Never approve a UI change based only on code shape. If users will judge it visually, Flow evidence should include visual inspection.
|
|
1212
|
-
`;var
|
|
1213
|
-
`)}async function
|
|
1214
|
-
`)}function
|
|
1215
|
-
`),await
|
|
1216
|
-
`),await
|
|
1217
|
-
`);async function Qe(e){let a=F(J(e),".gitignore");try{if((await Ke(a,"utf8")).trim()==="session.lock/")await Be(a,Ge,"utf8")}catch(t){if(t.code!=="ENOENT")throw t;await Be(a,Ge,"utf8")}}function et(e){return async(a)=>{fe(a)}}function G(e){let a=e?.client,t=a?.app?.log;return(r,n)=>{if(typeof t!=="function")return;try{t.call(a?.app,{body:{service:"opencode-plugin-flow",level:r,message:n}})}catch{}}}import{z as f}from"zod";import{randomUUID as wa}from"node:crypto";var va=null;function h(){return va?.()??new Date().toISOString()}function u(e){return{ok:!0,value:e}}function l(e,a,t){return{ok:!1,message:e,...a?{recovery:a}:{},...t?{session:t}:{}}}function ya(e){let a=N.parse(e);return{summary:a.summary,overview:a.overview,requirements:a.requirements??[],decisions:a.decisions??[],finalReviewPolicy:a.finalReviewPolicy??"detailed",features:a.features.map((t)=>({id:t.id,title:t.title,summary:t.summary,status:"pending",targets:t.targets??[],validation:t.validation??[],dependsOn:t.dependsOn??[]}))}}function ba(e){let a=new Set;for(let s of e.features){if(a.has(s.id))return`Duplicate feature id '${s.id}'.`;a.add(s.id)}for(let s of e.features)for(let c of s.dependsOn){if(!a.has(c))return`Feature '${s.id}' depends on unknown feature '${c}'.`;if(c===s.id)return`Feature '${s.id}' cannot depend on itself.`}let t=new Set,r=new Set,n=new Map(e.features.map((s)=>[s.id,s]));function i(s){if(r.has(s))return!1;if(t.has(s))return!0;t.add(s);for(let c of n.get(s)?.dependsOn??[])if(i(c))return!0;return t.delete(s),r.add(s),!1}return e.features.some((s)=>i(s.id))?"Feature dependencies contain a cycle.":null}function K(e){let a=h();return{version:2,id:wa(),goal:e,status:"planning",approval:"pending",plan:null,activeFeatureId:null,history:[],closure:null,lastError:null,timestamps:{createdAt:a,updatedAt:a,completedAt:null}}}function b(e){return{...e,timestamps:{...e.timestamps,updatedAt:h()}}}function rt(e,a){if(e.approval==="approved"||e.status!=="planning")return l("Approved plans cannot be changed. Reset or start a new session.");let t=ya(a),r=ba(t);if(r)return l(r);return u(b({...e,status:"planning",approval:"pending",plan:t,activeFeatureId:null,history:[],closure:null,lastError:null,timestamps:{...e.timestamps,completedAt:null}}))}function nt(e){if(!e.plan)return l("There is no draft plan to approve.");if(e.approval==="approved"&&e.status==="ready")return u(e);if(e.status!=="planning")return l("Only planning sessions can be approved.");return u(b({...e,approval:"approved",status:"ready"}))}function tt(e,a){return e.status==="pending"&&e.dependsOn.every((t)=>a.has(t))}function ka(e,a){let t=new Set(e.filter((i)=>i.status==="completed").map((i)=>i.id)),r=new Map(e.map((i)=>[i.id,i]));if(a){let i=r.get(a);if(!i)return l(`Feature '${a}' is not in the plan.`);if(i.status==="completed")return l(`Feature '${a}' is already completed.`);if(i.status!=="pending")return l(`Feature '${a}' is ${i.status} and must be reset before it can run.`);if(!tt(i,t))return l(`Feature '${a}' has incomplete dependencies.`);return u(i)}let n=e.find((i)=>tt(i,t));return n?u(n):l("No runnable feature is available.")}function le(e,a,t){return e.map((r)=>r.id===a?{...r,status:t}:r.status==="in_progress"&&t==="in_progress"?{...r,status:"pending"}:r)}function ot(e,a){if(e.status==="completed")return l("This Flow session is already completed.");if(!e.plan||e.approval!=="approved")return l("There is no approved plan to run.");if(e.status==="blocked")return l("Blocked features must be reset before rerun.","Call flow_feature_reset for the blocked feature, then start it again.");if(e.activeFeatureId){if(!a||a===e.activeFeatureId){let i=e.plan.features.find((s)=>s.id===e.activeFeatureId);if(i)return u({session:e,feature:i})}return l(`Feature '${e.activeFeatureId}' is already in progress.`)}let t=ka(e.plan.features,a);if(!t.ok)return t;let r={...e.plan,features:le(e.plan.features,t.value.id,"in_progress")},n=b({...e,status:"running",plan:r,activeFeatureId:t.value.id,lastError:null});return u({session:n,feature:n.plan?.features.find((i)=>i.id===t.value.id)??t.value})}function at(e){return e.status==="passed"&&e.blockingFindings.length===0}function xa(e,a){if(!e.plan)return!1;return e.plan.features.every((t)=>t.id===a||t.status==="completed")}function g(e,a,t,r){return l(t,r,{...e,lastError:{tool:a,summary:t,recovery:r,recordedAt:h()}})}function Ra(e,a){let t=xa(e,a.featureId);if(a.validationRun.length===0)return g(e,"flow_feature_complete","Completion requires recorded validation evidence.","Run the targeted or broad validation command and record the result.");if(!a.validationRun.every((r)=>r.status==="passed"))return g(e,"flow_feature_complete","Completion requires all recorded validation to pass.","Fix failures, rerun validation, then complete the feature.");if(!t&&a.validationScope!=="targeted")return g(e,"flow_feature_complete","Non-final feature completion requires targeted validation.","Record validationScope: targeted for ordinary feature completion.");if(t&&a.validationScope!=="broad")return g(e,"flow_feature_complete","Final feature completion requires broad validation.","Run the project-level gate and record validationScope: broad.");if(!at(a.featureReview))return g(e,"flow_feature_complete","Completion requires a passing featureReview with no blocking findings.","Fix or acknowledge the review findings before completing.");if(t){if(!a.finalReview)return g(e,"flow_feature_complete","Final feature completion requires a finalReview.","Run final review and include the finalReview payload.");if(!at(a.finalReview))return g(e,"flow_feature_complete","Final completion requires a passing finalReview.","Resolve final review findings before completing the session.");let r=e.plan?.finalReviewPolicy??"detailed";if(a.finalReview.reviewDepth!==r)return g(e,"flow_feature_complete",`Final review depth must match the plan policy '${r}'.`,"Record a finalReview whose reviewDepth matches the approved plan.")}return u(void 0)}function it(e,a){if(!e.plan||e.status!=="running"||!e.activeFeatureId)return l("No feature is currently running.");let t=D.parse(a);if(t.featureId!==e.activeFeatureId)return l(`Worker result feature '${t.featureId}' does not match active feature '${e.activeFeatureId}'.`);if(t.status==="needs_input"){let p={featureId:t.featureId,status:"needs_input",summary:t.summary,recordedAt:h(),artifactsChanged:t.artifactsChanged,validationRun:t.validationRun,validationScope:t.validationScope,featureReview:t.featureReview,finalReview:t.finalReview,outcome:t.outcome};return u(b({...e,status:"blocked",activeFeatureId:null,plan:{...e.plan,features:le(e.plan.features,t.featureId,"blocked")},history:[...e.history,p]}))}let r=Ra(e,t);if(!r.ok)return r;let n={featureId:t.featureId,status:"completed",summary:t.summary,recordedAt:h(),artifactsChanged:t.artifactsChanged,validationRun:t.validationRun,validationScope:t.validationScope,featureReview:t.featureReview,finalReview:t.finalReview,outcome:t.outcome},i=le(e.plan.features,t.featureId,"completed"),s=i.every((p)=>p.status==="completed"),c=h();return u(b({...e,status:s?"completed":"ready",activeFeatureId:null,plan:{...e.plan,features:i},history:[...e.history,n],closure:s?{kind:"completed",summary:t.summary,recordedAt:c}:null,lastError:null,timestamps:{...e.timestamps,completedAt:s?c:e.timestamps.completedAt}}))}function Fa(e,a){let t=new Set([a]),r=!0;while(r){r=!1;for(let n of e){if(t.has(n.id))continue;if(n.dependsOn.some((i)=>t.has(i)))t.add(n.id),r=!0}}return t}function st(e,a){if(!e.plan)return l("There is no active plan to reset.");if(!e.plan.features.some((s)=>s.id===a))return l(`Feature '${a}' is not in the plan.`);let t=Fa(e.plan.features,a),r=e.activeFeatureId&&t.has(e.activeFeatureId)?null:e.activeFeatureId,n=e.plan.features.map((s)=>t.has(s.id)?{...s,status:"pending"}:s),i=e.approval!=="approved"?"planning":r?"running":n.some((s)=>s.status==="blocked")?"blocked":"ready";return u(b({...e,status:i,activeFeatureId:r,plan:{...e.plan,features:n},closure:null,lastError:null,timestamps:{...e.timestamps,completedAt:null}}))}function ct(e,a,t){if(a==="completed"){if(!e.plan||e.approval!=="approved")return l("Cannot close a Flow session as completed without an approved plan.");let n=e.plan.features.filter((i)=>i.status!=="completed");if(n.length>0)return l("Cannot close a Flow session as completed with unfinished features.",`Unfinished features: ${n.map((i)=>i.id).join(", ")}`);if(e.status!=="completed")return l("Cannot close a Flow session as completed before final completion gates pass.")}let r=h();return u(b({...e,status:a==="completed"?"completed":e.status,activeFeatureId:null,closure:{kind:a,summary:t??`Session closed as ${a}.`,recordedAt:r},timestamps:{...e.timestamps,completedAt:a==="completed"?r:e.timestamps.completedAt}}))}function k(e){if(!e)return{status:"missing_session",summary:"No active Flow session exists.",nextAction:"Start with /flow-plan <goal>."};let a=e.plan?.features??[],t=a.filter((s)=>s.status==="completed"),r=e.history.at(-1)??null,n=e.status==="blocked"?r:null,i=e.activeFeatureId?a.find((s)=>s.id===e.activeFeatureId):null;return{status:e.status,summary:e.closure?.summary??e.lastError?.summary??n?.summary??e.plan?.summary??"Flow session is active.",nextAction:_a(e),session:{id:e.id,goal:e.goal,status:e.status,approval:e.approval,activeFeature:i??null,progress:{completed:t.length,total:a.length},features:a,closure:e.closure,lastError:e.lastError,latestHistoryEntry:r,historyCount:e.history.length,timestamps:e.timestamps}}}function _a(e){if(!e.plan)return"Save a plan with flow_plan_save.";if(e.approval!=="approved")return"Approve the plan.";if(e.status==="ready")return"Start the next feature.";if(e.status==="running")return"Complete or reset the active feature.";if(e.status==="blocked")return"Reset the blocked feature or close the session.";if(e.status==="completed")return"Close/archive the session or start a new goal.";return"Inspect session state."}var Sa=f.object({goal:f.string().trim().min(1).optional(),plan:N.optional()}).strict(),Ia=f.object({featureId:f.string().min(1).optional()}).strict(),Pa=f.object({featureId:f.string().min(1)}).strict(),Aa=f.object({kind:f.enum(["completed","deferred","abandoned"]),summary:f.string().trim().min(1).optional()}).strict();function _(e){return{status:"error",summary:e.message,...e.recovery?{recovery:e.recovery}:{}}}async function S(e,a){return Ze(e,async()=>a(await C(e)))}async function lt(e){return k(await C(e))}async function dt(e,a){let t=Sa.parse(a??{});return S(e,async(r)=>{let n=t.goal??r?.goal;if(!n)return{status:"missing_goal",summary:"Provide a goal before saving a Flow plan.",nextAction:"/flow-plan <goal>"};if(r?.status==="completed")await ce(e,r);let i=r?.status==="completed"?K(n):r??K(n);if(i.goal!==n){if(i.approval==="approved")return{status:"error",summary:"An approved Flow session already exists for a different goal. Close it before starting a new one."}}let s=i.goal===n?i:K(n),c=t.plan?rt(s,t.plan):{ok:!0,value:s};if(!c.ok)return _(c);let p=await y(e,c.value);return{...k(p),status:"ok",summary:t.plan?"Flow plan saved.":"Flow session ready."}})}async function ut(e){return S(e,async(a)=>{if(!a)return{status:"missing_session",summary:"No active Flow session exists.",nextAction:"/flow-plan <goal>"};let t=nt(a);if(!t.ok)return _(t);let r=await y(e,t.value);return{...k(r),status:"ok",summary:"Flow plan approved."}})}async function pt(e,a){let t=Ia.parse(a??{});return S(e,async(r)=>{if(!r)return{status:"missing_session",summary:"No active Flow session exists.",nextAction:"/flow-plan <goal>"};let n=ot(r,t.featureId);if(!n.ok)return _(n);let i=await y(e,n.value.session);return{...k(i),status:"ok",summary:`Started feature '${n.value.feature.id}'.`,feature:n.value.feature}})}async function ft(e,a){let t=D.parse(a??{});return S(e,async(r)=>{if(!r)return{status:"missing_session",summary:"No active Flow session exists.",nextAction:"/flow-plan <goal>"};let n=it(r,t);if(!n.ok){if(n.session)await y(e,n.session);return _(n)}let i=await y(e,n.value);return{...k(i),status:"ok",summary:"Feature result recorded."}})}async function mt(e,a){let t=Pa.parse(a??{});return S(e,async(r)=>{if(!r)return{status:"missing_session",summary:"No active Flow session exists.",nextAction:"/flow-plan <goal>"};let n=st(r,t.featureId);if(!n.ok)return _(n);let i=await y(e,n.value);return{...k(i),status:"ok",summary:`Feature '${t.featureId}' reset.`}})}async function ht(e,a){let t=Aa.parse(a??{});return S(e,async(r)=>{if(!r)return{status:"missing_session",summary:"No active Flow session exists.",nextAction:"/flow-plan <goal>"};let n=ct(r,t.kind,t.summary);if(!n.ok)return _(n);return await ce(e,n.value),{status:"ok",summary:`Flow session closed as ${t.kind}.`,archivedSessionId:n.value.id,closure:n.value.closure}})}import{tool as m}from"@opencode-ai/plugin";var d=m.schema;function gt(e){return JSON.stringify(e,null,2)}function Ca(e){return gt({status:"error",summary:e instanceof Error?e.message:String(e)})}async function x(e,a){try{return gt(await a(Xe(e)))}catch(t){return Ca(t)}}async function Ta(e){let a=await lt(e),t=ee();if(!t)return a;return{...a,setup:{skills:t}}}function vt(e){return G(e)("info","Creating minimal Flow v4 tool surface."),{flow_status:m({description:"Show the active Flow session and next action",args:{},execute:(a,t)=>x(t,Ta)}),flow_plan_save:m({description:"Create or update a draft Flow plan for the active goal",args:{goal:d.string().optional(),plan:d.any().optional()},execute:(a,t)=>x(t,(r)=>dt(r,a))}),flow_plan_approve:m({description:"Approve the current draft Flow plan",args:{},execute:(a,t)=>x(t,ut)}),flow_run_start:m({description:"Start the next runnable approved Flow feature",args:{featureId:d.string().optional()},execute:(a,t)=>x(t,(r)=>pt(r,a))}),flow_feature_complete:m({description:"Record a completed or blocked active feature with validation and review evidence",args:{status:d.enum(["ok","needs_input"]),featureId:d.string(),summary:d.string(),artifactsChanged:d.array(d.object({path:d.string()})).optional(),validationRun:d.array(d.object({command:d.string(),status:d.enum(["passed","failed"]),summary:d.string()})).optional(),validationScope:d.enum(["targeted","broad"]).optional(),featureReview:d.any().optional(),finalReview:d.any().optional(),outcome:d.any().optional()},execute:(a,t)=>x(t,(r)=>ft(r,a))}),flow_feature_reset:m({description:"Reset one feature and its dependents to pending",args:{featureId:d.string()},execute:(a,t)=>x(t,(r)=>mt(r,a))}),flow_session_close:m({description:"Close and archive the active Flow session",args:{kind:d.enum(["completed","deferred","abandoned"]),summary:d.string().optional()},execute:(a,t)=>x(t,(r)=>ht(r,a))})}}async function wt(e){let a=e.worktree??e.directory;if(!a)return null;try{let t=await C(a);if(!t)return null;return["Flow session facts:",`- goal: ${t.goal}`,`- status: ${t.status}`,`- approval: ${t.approval}`,`- active feature: ${t.activeFeatureId??"none"}`,`- progress: ${t.plan?.features.filter((r)=>r.status==="completed").length??0}/${t.plan?.features.length??0}`,"Call flow_status before any Flow action."].join(`
|
|
1218
|
-
`)}catch{return null}}function
|
|
1219
|
-
|
|
1220
|
-
//# debugId=
|
|
1477
|
+
`;var X=[{name:"flow",files:[{relativePath:"SKILL.md",content:we},{relativePath:"references/recovery-playbook.md",content:ge},{relativePath:"references/parallel-orchestration.md",content:he},{relativePath:"references/handoff-format.md",content:me},{relativePath:"references/verification-gates.md",content:ve}]},{name:"flow-plan",files:[{relativePath:"SKILL.md",content:_e},{relativePath:"references/planning-examples.md",content:Fe},{relativePath:"references/parallel-discovery.md",content:Re}]},{name:"flow-run",files:[{relativePath:"SKILL.md",content:Pe},{relativePath:"references/validation-rubric.md",content:Se},{relativePath:"references/audit-rubric.md",content:Ie}]},{name:"flow-test",files:[{relativePath:"SKILL.md",content:Ae}]},{name:"flow-review",files:[{relativePath:"SKILL.md",content:j},{relativePath:"references/review-rubric.md",content:U}]},{name:"flow-deslop",files:[{relativePath:"SKILL.md",content:xe},{relativePath:"references/smell-rubric.md",content:ke},{relativePath:"references/refactor-workflow.md",content:be}]},{name:"flow-ui-quality",files:[{relativePath:"SKILL.md",content:Ue},{relativePath:"references/ui-rubric.md",content:Ce},{relativePath:"references/visual-verification.md",content:Te}]},{name:"flow-commit",files:[{relativePath:"SKILL.md",content:ye}]}];var Zt=".flow-skill-version",v=null;function Z(){return process.env.HOME??process.env.USERPROFILE??""}function qe(e=Z()){return P(e,".config","opencode","skills")}function Ee(e){return Jt("sha256").update(e).digest("hex")}function Y(e,a){return[`version=${a}`,...e.files.map((t)=>`file=${t.relativePath} sha256=${Ee(t.content)}`),""].join(`
|
|
1478
|
+
`)}async function H(e){try{return await Lt(e,"utf8")}catch(a){if(a.code==="ENOENT")return null;throw a}}function ea(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 o=/^hash=sha256:([a-f0-9]{64})$/.exec(t);if(o?.[1]&&!a.has("SKILL.md"))a.set("SKILL.md",o[1])}return a}function je(e,a){let t=Yt(P(e,...a.split("/")));if(t!==e&&t.startsWith(`${e}${Ht}`))return t;throw Error(`Unsafe skill file path '${a}'.`)}async function ta(e,a,t){let r=P(t,e.name),o=P(r,Zt),i=await H(o),s=ea(i);if(await H(P(r,"SKILL.md"))!==null&&i===null)return{name:e.name,action:"skipped_foreign"};let p=!1,de=!1;for(let R of e.files){let S=je(r,R.relativePath),T=await H(S);if(T===R.content)continue;p=!0;let ue=s.get(R.relativePath);if(T!==null&&(ue?Ee(T)!==ue:i!==null))await q(`${S}.backup`,T,"utf8"),de=!0}if(!p&&i===Y(e,a))return{name:e.name,action:"unchanged"};if(!p)return await q(o,Y(e,a),"utf8"),{name:e.name,action:"marker_updated"};let kt=i!==null;for(let R of e.files){let S=je(r,R.relativePath);await Kt(Xt(S),{recursive:!0}),await q(S,R.content,"utf8")}return await q(o,Y(e,a),"utf8"),{name:e.name,action:de?"updated_with_backup":kt?"updated":"installed"}}function Oe(){return X.map((e)=>e.name)}function aa(e,a,t){let r=t.filter((c)=>["installed","updated","updated_with_backup"].includes(c.action)).map((c)=>c.name),o=t.filter((c)=>c.action==="skipped_foreign").map((c)=>c.name),i=o.length>0?"action_required":r.length>0?"restart_required":"ok",s=i==="restart_required"?`Flow installed or updated skills during this startup (${r.join(", ")}). Restart OpenCode before loading Flow skills.`:i==="action_required"?`Flow found user-owned skill folders for managed skills (${o.join(", ")}). Run ${De(e)} for repair guidance.`:"Flow skills are synced.";return{status:i,version:e,root:a,checkedAt:new Date().toISOString(),expectedSkills:Oe(),results:t,changedSkills:r,actionRequiredSkills:o,restartRequired:i==="restart_required",summary:s}}function ra(e,a,t){let r=t instanceof Error?t.message:String(t);return{status:"error",version:e,root:a,checkedAt:new Date().toISOString(),expectedSkills:Oe(),results:[],changedSkills:[],actionRequiredSkills:[],restartRequired:!1,summary:`Flow skill sync failed: ${r}`,error:r}}function De(e){return`npx -y opencode-plugin-flow@${e} doctor`}function ee(e=v){if(!e||e.status==="ok")return null;return{status:e.status==="error"?"sync_failed":e.status,summary:e.summary,version:e.version,root:e.root,...e.changedSkills.length>0?{changed:e.changedSkills}:{},...e.actionRequiredSkills.length>0?{actionRequired:e.actionRequiredSkills}:{},...e.error?{error:e.error}:{}}}function E(e=v){let a=ee(e);if(!a)return null;return["Flow setup warning:",a.summary,`Skills root: ${a.root}`,`Use \`${De(a.version)}\` for details.`].join(`
|
|
1479
|
+
`)}function Ne(){if(process.env.npm_package_version)return process.env.npm_package_version;try{let e=Qt(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 oa(e,a=Z()){let t=qe(a);return Promise.all(X.map((r)=>ta(r,e,t)))}async function ze(e,a,t=Z()){let r=qe(t);try{let o=await oa(e,t);v=aa(e,r,o);let i=o.filter((s)=>s.action==="installed"||s.action==="updated"||s.action==="updated_with_backup");if(i.length>0)a("info",`Flow synced skills (${i.map((s)=>`${s.name}:${s.action}`).join(", ")}). Restart OpenCode if skills were just installed.`);if(v.status==="action_required")a("warn",v.summary)}catch(o){v=ra(e,r,o),a("warn",v.summary)}}import{randomUUID as pa}from"node:crypto";import{mkdir as $,open as Ge,readFile as Qe,rename as fa,rm as B,writeFile as Je}from"node:fs/promises";import{homedir as ma}from"node:os";import{dirname as Ke,isAbsolute as Lr,join as F,parse as ha,resolve as Xe}from"node:path";import{setTimeout as ga}from"node:timers/promises";function na(e){let a=[],t=0;while(t<e.length){let r=e[t];if(r==="{"){a.push({isObject:!0,keys:new Set,awaitingKey:!0}),t+=1;continue}if(r==="["){a.push({isObject:!1,keys:new Set,awaitingKey:!1}),t+=1;continue}if(r==="}"||r==="]"){a.pop(),t+=1;continue}if(r===","){let o=a.at(-1);if(o?.isObject)o.awaitingKey=!0;t+=1;continue}if(r===":"){let o=a.at(-1);if(o?.isObject)o.awaitingKey=!1;t+=1;continue}if(r==='"'){let o=t+1;while(o<e.length){if(e[o]==="\\"){o+=2;continue}if(e[o]==='"')break;o+=1}let i=a.at(-1);if(i?.isObject&&i.awaitingKey){let s=JSON.parse(e.slice(t,o+1));if(i.keys.has(s))return s;i.keys.add(s)}t=o+1;continue}t+=1}return null}function We(e,a){if(e.trim().length===0)return{ok:!1,error:`${a} is empty.`};let t;try{t=JSON.parse(e)}catch(o){return{ok:!1,error:o instanceof Error?`${a} is not valid JSON: ${o.message}`:`${a} is not valid JSON.`}}if(t===null||typeof t!=="object"||Array.isArray(t))return{ok:!1,error:`${a} must be a JSON object.`};let r=na(e);if(r)return{ok:!1,error:`${a} has duplicate key '${r}'.`};return{ok:!0,value:t}}import{z as n}from"zod";var w=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,A="Feature ids must be lowercase kebab-case",$e=n.enum(["pending","in_progress","completed","blocked"]),ia=n.enum(["planning","ready","running","blocked","completed"]),sa=n.enum(["passed","failed"]),ca=n.enum(["passed","failed"]),te=n.enum(["targeted","broad"]),ne=n.enum(["broad","detailed"]),la=n.object({summary:n.string().min(1),severity:n.enum(["blocking","advisory"]).default("blocking")}).strict(),O=n.object({status:sa,summary:n.string().min(1),blockingFindings:n.array(la).default([])}).strict(),ae=O.extend({reviewDepth:ne}).strict(),re=n.object({command:n.string().min(1),status:ca,summary:n.string().min(1)}).strict(),oe=n.object({path:n.string().min(1)}).strict(),Be=n.object({id:n.string().regex(w,A),title:n.string().min(1),summary:n.string().min(1),status:$e.default("pending"),targets:n.array(n.string().min(1)).default([]),validation:n.array(n.string().min(1)).default([]),dependsOn:n.array(n.string().regex(w)).default([])}).strict(),Ve=n.object({summary:n.string().min(1),overview:n.string().min(1),requirements:n.array(n.string().min(1)).default([]),decisions:n.array(n.string().min(1)).default([]),finalReviewPolicy:ne.default("detailed"),features:n.array(Be).min(1)}).strict(),D=Ve.omit({features:!0}).extend({finalReviewPolicy:ne.optional(),features:n.array(Be.omit({status:!0}).extend({status:$e.optional(),targets:n.array(n.string().min(1)).optional(),validation:n.array(n.string().min(1)).optional(),dependsOn:n.array(n.string().regex(w)).optional()}).strict()).min(1)}),Me=n.object({kind:n.enum(["completed","blocked","needs_input","replan_required"]).default("completed"),summary:n.string().min(1).optional(),resolutionHint:n.string().min(1).optional()}).strict(),da=n.object({kind:n.enum(["blocked","needs_input","replan_required"]).default("needs_input"),summary:n.string().min(1),resolutionHint:n.string().min(1).optional()}).strict(),N=n.discriminatedUnion("status",[n.object({status:n.literal("ok"),featureId:n.string().regex(w,A),summary:n.string().min(1),artifactsChanged:n.array(oe).default([]),validationRun:n.array(re).default([]),validationScope:te,featureReview:O,finalReview:ae.optional(),outcome:Me.optional()}).strict(),n.object({status:n.literal("needs_input"),featureId:n.string().regex(w,A),summary:n.string().min(1),artifactsChanged:n.array(oe).default([]),validationRun:n.array(re).default([]),validationScope:te.optional(),featureReview:O.optional(),finalReview:ae.optional(),outcome:da}).strict()]).superRefine((e,a)=>{if(e.status==="ok"&&e.outcome?.kind&&e.outcome.kind!=="completed")a.addIssue({code:"custom",path:["outcome","kind"],message:'ok worker results must use outcome.kind "completed".'})}),ua=n.object({featureId:n.string().regex(w,A),status:n.enum(["completed","blocked","needs_input"]),summary:n.string().min(1),recordedAt:n.string().min(1),artifactsChanged:n.array(oe).default([]),validationRun:n.array(re).default([]),validationScope:te.optional(),featureReview:O.optional(),finalReview:ae.optional(),outcome:Me.optional()}).strict(),z=n.object({version:n.literal(2),id:n.string().min(1),goal:n.string().min(1),status:ia,approval:n.enum(["pending","approved"]),plan:Ve.nullable(),activeFeatureId:n.string().regex(w,A).nullable(),history:n.array(ua).default([]),closure:n.object({kind:n.enum(["completed","deferred","abandoned"]),summary:n.string().min(1),recordedAt:n.string().min(1)}).strict().nullable(),lastError:n.object({tool:n.string().min(1),summary:n.string().min(1),recovery:n.string().min(1).optional(),recordedAt:n.string().min(1)}).strict().nullable().default(null),timestamps:n.object({createdAt:n.string().min(1),updatedAt:n.string().min(1),completedAt:n.string().min(1).nullable()}).strict()}).strict();class V extends Error{code="INVALID_FLOW_WORKSPACE_ROOT";constructor(e){super(e);this.name="InvalidFlowWorkspaceRootError"}}function ie(e){let a=e?.trim();if(!a)return null;let t=Xe(a);return ha(t).root===t?null:t}function M(e){let a=ie(e);if(!a)throw new V("Flow requires a non-root workspace path.");if(a===Xe(process.env.HOME??ma()))throw new V("Flow refuses to use $HOME itself as a mutable workspace root.");return a}function Ye(e){let a=ie(e.worktree)??ie(e.directory);if(!a)throw new V("Flow could not resolve a workspace root from tool context.");return M(a)}function G(e){return F(e,".flow")}function se(e){return F(G(e),"session.json")}function He(e){return F(G(e),"history")}function va(e,a){if(!/^[a-zA-Z0-9_-]+$/.test(a))throw Error("Invalid session id.");return F(He(e),`${a}.json`)}async function Ze(e,a){await $(Ke(e),{recursive:!0});let t=`${e}.${process.pid}.${pa()}.tmp`,r=await Ge(t,"w");try{await r.writeFile(a,"utf8"),await r.sync()}catch(i){throw await r.close(),await B(t,{force:!0}),i}await r.close();try{await fa(t,e)}catch(i){throw await B(t,{force:!0}),i}let o=await Ge(Ke(e),"r");try{await o.sync()}finally{await o.close()}}var W=new Map,wa=30000,ya=25;async function ba(e){let a=G(e),t=F(a,"session.lock"),r=Date.now();while(!0)try{return await $(t,{recursive:!1}),async()=>{await B(t,{recursive:!0,force:!0})}}catch(o){let i=o.code;if(i==="ENOENT"){await $(a,{recursive:!0});continue}if(i!=="EEXIST")throw o;if(Date.now()-r>wa)throw Error(`Timed out waiting for Flow session lock at ${t}.`);await ga(ya)}}async function et(e,a){let t=W.get(e)??Promise.resolve(),r=()=>{},o=new Promise((c)=>{r=c}),i=t.catch(()=>{return}).then(()=>o);W.set(e,i);let s=null;try{return await t.catch(()=>{return}),s=await ba(e),await a()}finally{try{await s?.()}finally{if(r(),W.get(e)===i)W.delete(e)}}}async function C(e){let a=M(e),t;try{t=await Qe(se(a),"utf8")}catch(o){if(o.code==="ENOENT")return null;throw o}let r=We(t,"Flow session file");if(!r.ok)throw Error(r.error);return z.parse(r.value)}async function y(e,a){let t=M(e),r=z.parse(a);return await Ze(se(t),`${JSON.stringify(r,null,2)}
|
|
1480
|
+
`),await tt(t),r}async function ce(e,a){let t=M(e);await $(He(t),{recursive:!0}),await Ze(va(t,a.id),`${JSON.stringify(z.parse(a),null,2)}
|
|
1481
|
+
`),await B(se(t),{force:!0}),await tt(t)}var Le=["session.json","history/","session.lock/",".gitignore",""].join(`
|
|
1482
|
+
`);async function tt(e){let a=F(G(e),".gitignore");try{if((await Qe(a,"utf8")).trim()==="session.lock/")await Je(a,Le,"utf8")}catch(t){if(t.code!=="ENOENT")throw t;await Je(a,Le,"utf8")}}function at(e){return async(a)=>{fe(a)}}function J(e){let a=e?.client,t=a?.app?.log;return(r,o)=>{if(typeof t!=="function")return;try{t.call(a?.app,{body:{service:"opencode-plugin-flow",level:r,message:o}})}catch{}}}import{z as f}from"zod";import{randomUUID as xa}from"node:crypto";var ka=null;function h(){return ka?.()??new Date().toISOString()}function u(e){return{ok:!0,value:e}}function l(e,a,t){return{ok:!1,message:e,...a?{recovery:a}:{},...t?{session:t}:{}}}function Ra(e){let a=D.parse(e);return{summary:a.summary,overview:a.overview,requirements:a.requirements??[],decisions:a.decisions??[],finalReviewPolicy:a.finalReviewPolicy??"detailed",features:a.features.map((t)=>({id:t.id,title:t.title,summary:t.summary,status:"pending",targets:t.targets??[],validation:t.validation??[],dependsOn:t.dependsOn??[]}))}}function Fa(e){let a=new Set;for(let s of e.features){if(a.has(s.id))return`Duplicate feature id '${s.id}'.`;a.add(s.id)}for(let s of e.features)for(let c of s.dependsOn){if(!a.has(c))return`Feature '${s.id}' depends on unknown feature '${c}'.`;if(c===s.id)return`Feature '${s.id}' cannot depend on itself.`}let t=new Set,r=new Set,o=new Map(e.features.map((s)=>[s.id,s]));function i(s){if(r.has(s))return!1;if(t.has(s))return!0;t.add(s);for(let c of o.get(s)?.dependsOn??[])if(i(c))return!0;return t.delete(s),r.add(s),!1}return e.features.some((s)=>i(s.id))?"Feature dependencies contain a cycle.":null}function K(e){let a=h();return{version:2,id:xa(),goal:e,status:"planning",approval:"pending",plan:null,activeFeatureId:null,history:[],closure:null,lastError:null,timestamps:{createdAt:a,updatedAt:a,completedAt:null}}}function b(e){return{...e,timestamps:{...e.timestamps,updatedAt:h()}}}function nt(e,a){if(e.approval==="approved"||e.status!=="planning")return l("Approved plans cannot be changed. Reset or start a new session.");let t=Ra(a),r=Fa(t);if(r)return l(r);return u(b({...e,status:"planning",approval:"pending",plan:t,activeFeatureId:null,history:[],closure:null,lastError:null,timestamps:{...e.timestamps,completedAt:null}}))}function it(e){if(!e.plan)return l("There is no draft plan to approve.");if(e.approval==="approved"&&e.status==="ready")return u(e);if(e.status!=="planning")return l("Only planning sessions can be approved.");return u(b({...e,approval:"approved",status:"ready"}))}function rt(e,a){return e.status==="pending"&&e.dependsOn.every((t)=>a.has(t))}function _a(e,a){let t=new Set(e.filter((i)=>i.status==="completed").map((i)=>i.id)),r=new Map(e.map((i)=>[i.id,i]));if(a){let i=r.get(a);if(!i)return l(`Feature '${a}' is not in the plan.`);if(i.status==="completed")return l(`Feature '${a}' is already completed.`);if(i.status!=="pending")return l(`Feature '${a}' is ${i.status} and must be reset before it can run.`);if(!rt(i,t))return l(`Feature '${a}' has incomplete dependencies.`);return u(i)}let o=e.find((i)=>rt(i,t));return o?u(o):l("No runnable feature is available.")}function le(e,a,t){return e.map((r)=>r.id===a?{...r,status:t}:r.status==="in_progress"&&t==="in_progress"?{...r,status:"pending"}:r)}function st(e,a){if(e.status==="completed")return l("This Flow session is already completed.");if(!e.plan||e.approval!=="approved")return l("There is no approved plan to run.");if(e.status==="blocked")return l("Blocked features must be reset before rerun.","Call flow_feature_reset for the blocked feature, then start it again.");if(e.activeFeatureId){if(!a||a===e.activeFeatureId){let i=e.plan.features.find((s)=>s.id===e.activeFeatureId);if(i)return u({session:e,feature:i})}return l(`Feature '${e.activeFeatureId}' is already in progress.`)}let t=_a(e.plan.features,a);if(!t.ok)return t;let r={...e.plan,features:le(e.plan.features,t.value.id,"in_progress")},o=b({...e,status:"running",plan:r,activeFeatureId:t.value.id,lastError:null});return u({session:o,feature:o.plan?.features.find((i)=>i.id===t.value.id)??t.value})}function ot(e){return e.status==="passed"&&e.blockingFindings.length===0}function Ia(e,a){if(!e.plan)return!1;return e.plan.features.every((t)=>t.id===a||t.status==="completed")}function g(e,a,t,r){return l(t,r,{...e,lastError:{tool:a,summary:t,recovery:r,recordedAt:h()}})}function Sa(e,a){let t=Ia(e,a.featureId);if(a.validationRun.length===0)return g(e,"flow_feature_complete","Completion requires recorded validation evidence.","Run the targeted or broad validation command and record the result.");if(!a.validationRun.every((r)=>r.status==="passed"))return g(e,"flow_feature_complete","Completion requires all recorded validation to pass.","Fix failures, rerun validation, then complete the feature.");if(!t&&a.validationScope!=="targeted")return g(e,"flow_feature_complete","Non-final feature completion requires targeted validation.","Record validationScope: targeted for ordinary feature completion.");if(t&&a.validationScope!=="broad")return g(e,"flow_feature_complete","Final feature completion requires broad validation.","Run the project-level gate and record validationScope: broad.");if(!ot(a.featureReview))return g(e,"flow_feature_complete","Completion requires a passing featureReview with no blocking findings.","Fix or acknowledge the review findings before completing.");if(t){if(!a.finalReview)return g(e,"flow_feature_complete","Final feature completion requires a finalReview.","Run final review and include the finalReview payload.");if(!ot(a.finalReview))return g(e,"flow_feature_complete","Final completion requires a passing finalReview.","Resolve final review findings before completing the session.");let r=e.plan?.finalReviewPolicy??"detailed";if(a.finalReview.reviewDepth!==r)return g(e,"flow_feature_complete",`Final review depth must match the plan policy '${r}'.`,"Record a finalReview whose reviewDepth matches the approved plan.")}return u(void 0)}function ct(e,a){if(!e.plan||e.status!=="running"||!e.activeFeatureId)return l("No feature is currently running.");let t=N.parse(a);if(t.featureId!==e.activeFeatureId)return l(`Worker result feature '${t.featureId}' does not match active feature '${e.activeFeatureId}'.`);if(t.status==="needs_input"){let p={featureId:t.featureId,status:"needs_input",summary:t.summary,recordedAt:h(),artifactsChanged:t.artifactsChanged,validationRun:t.validationRun,validationScope:t.validationScope,featureReview:t.featureReview,finalReview:t.finalReview,outcome:t.outcome};return u(b({...e,status:"blocked",activeFeatureId:null,plan:{...e.plan,features:le(e.plan.features,t.featureId,"blocked")},history:[...e.history,p]}))}let r=Sa(e,t);if(!r.ok)return r;let o={featureId:t.featureId,status:"completed",summary:t.summary,recordedAt:h(),artifactsChanged:t.artifactsChanged,validationRun:t.validationRun,validationScope:t.validationScope,featureReview:t.featureReview,finalReview:t.finalReview,outcome:t.outcome},i=le(e.plan.features,t.featureId,"completed"),s=i.every((p)=>p.status==="completed"),c=h();return u(b({...e,status:s?"completed":"ready",activeFeatureId:null,plan:{...e.plan,features:i},history:[...e.history,o],closure:s?{kind:"completed",summary:t.summary,recordedAt:c}:null,lastError:null,timestamps:{...e.timestamps,completedAt:s?c:e.timestamps.completedAt}}))}function Pa(e,a){let t=new Set([a]),r=!0;while(r){r=!1;for(let o of e){if(t.has(o.id))continue;if(o.dependsOn.some((i)=>t.has(i)))t.add(o.id),r=!0}}return t}function lt(e,a){if(!e.plan)return l("There is no active plan to reset.");if(!e.plan.features.some((s)=>s.id===a))return l(`Feature '${a}' is not in the plan.`);let t=Pa(e.plan.features,a),r=e.activeFeatureId&&t.has(e.activeFeatureId)?null:e.activeFeatureId,o=e.plan.features.map((s)=>t.has(s.id)?{...s,status:"pending"}:s),i=e.approval!=="approved"?"planning":r?"running":o.some((s)=>s.status==="blocked")?"blocked":"ready";return u(b({...e,status:i,activeFeatureId:r,plan:{...e.plan,features:o},closure:null,lastError:null,timestamps:{...e.timestamps,completedAt:null}}))}function dt(e,a,t){if(a==="completed"){if(!e.plan||e.approval!=="approved")return l("Cannot close a Flow session as completed without an approved plan.");let o=e.plan.features.filter((i)=>i.status!=="completed");if(o.length>0)return l("Cannot close a Flow session as completed with unfinished features.",`Unfinished features: ${o.map((i)=>i.id).join(", ")}`);if(e.status!=="completed")return l("Cannot close a Flow session as completed before final completion gates pass.")}let r=h();return u(b({...e,status:a==="completed"?"completed":e.status,activeFeatureId:null,closure:{kind:a,summary:t??`Session closed as ${a}.`,recordedAt:r},timestamps:{...e.timestamps,completedAt:a==="completed"?r:e.timestamps.completedAt}}))}function k(e){if(!e)return{status:"missing_session",summary:"No active Flow session exists.",nextAction:"Start with /flow-plan <goal>."};let a=e.plan?.features??[],t=a.filter((s)=>s.status==="completed"),r=e.history.at(-1)??null,o=e.status==="blocked"?r:null,i=e.activeFeatureId?a.find((s)=>s.id===e.activeFeatureId):null;return{status:e.status,summary:e.closure?.summary??e.lastError?.summary??o?.summary??e.plan?.summary??"Flow session is active.",nextAction:Aa(e),session:{id:e.id,goal:e.goal,status:e.status,approval:e.approval,activeFeature:i??null,progress:{completed:t.length,total:a.length},features:a,closure:e.closure,lastError:e.lastError,latestHistoryEntry:r,historyCount:e.history.length,timestamps:e.timestamps}}}function Aa(e){if(!e.plan)return"Save a plan with flow_plan_save.";if(e.approval!=="approved")return"Approve the plan.";if(e.status==="ready")return"Start the next feature.";if(e.status==="running")return"Complete or reset the active feature.";if(e.status==="blocked")return"Reset the blocked feature or close the session.";if(e.status==="completed")return"Close/archive the session or start a new goal.";return"Inspect session state."}var Ca=f.object({goal:f.string().trim().min(1).optional(),plan:D.optional()}).strict(),Ta=f.object({featureId:f.string().min(1).optional()}).strict(),Ua=f.object({featureId:f.string().min(1)}).strict(),ja=f.object({kind:f.enum(["completed","deferred","abandoned"]),summary:f.string().trim().min(1).optional()}).strict();function _(e){return{status:"error",summary:e.message,...e.recovery?{recovery:e.recovery}:{}}}async function I(e,a){return et(e,async()=>a(await C(e)))}async function ut(e){return k(await C(e))}async function pt(e,a){let t=Ca.parse(a??{});return I(e,async(r)=>{let o=t.goal??r?.goal;if(!o)return{status:"missing_goal",summary:"Provide a goal before saving a Flow plan.",nextAction:"/flow-plan <goal>"};if(r?.status==="completed")await ce(e,r);let i=r?.status==="completed"?K(o):r??K(o);if(i.goal!==o){if(i.approval==="approved")return{status:"error",summary:"An approved Flow session already exists for a different goal. Close it before starting a new one."}}let s=i.goal===o?i:K(o),c=t.plan?nt(s,t.plan):{ok:!0,value:s};if(!c.ok)return _(c);let p=await y(e,c.value);return{...k(p),status:"ok",summary:t.plan?"Flow plan saved.":"Flow session ready."}})}async function ft(e){return I(e,async(a)=>{if(!a)return{status:"missing_session",summary:"No active Flow session exists.",nextAction:"/flow-plan <goal>"};let t=it(a);if(!t.ok)return _(t);let r=await y(e,t.value);return{...k(r),status:"ok",summary:"Flow plan approved."}})}async function mt(e,a){let t=Ta.parse(a??{});return I(e,async(r)=>{if(!r)return{status:"missing_session",summary:"No active Flow session exists.",nextAction:"/flow-plan <goal>"};let o=st(r,t.featureId);if(!o.ok)return _(o);let i=await y(e,o.value.session);return{...k(i),status:"ok",summary:`Started feature '${o.value.feature.id}'.`,feature:o.value.feature}})}async function ht(e,a){let t=N.parse(a??{});return I(e,async(r)=>{if(!r)return{status:"missing_session",summary:"No active Flow session exists.",nextAction:"/flow-plan <goal>"};let o=ct(r,t);if(!o.ok){if(o.session)await y(e,o.session);return _(o)}let i=await y(e,o.value);return{...k(i),status:"ok",summary:"Feature result recorded."}})}async function gt(e,a){let t=Ua.parse(a??{});return I(e,async(r)=>{if(!r)return{status:"missing_session",summary:"No active Flow session exists.",nextAction:"/flow-plan <goal>"};let o=lt(r,t.featureId);if(!o.ok)return _(o);let i=await y(e,o.value);return{...k(i),status:"ok",summary:`Feature '${t.featureId}' reset.`}})}async function vt(e,a){let t=ja.parse(a??{});return I(e,async(r)=>{if(!r)return{status:"missing_session",summary:"No active Flow session exists.",nextAction:"/flow-plan <goal>"};let o=dt(r,t.kind,t.summary);if(!o.ok)return _(o);return await ce(e,o.value),{status:"ok",summary:`Flow session closed as ${t.kind}.`,archivedSessionId:o.value.id,closure:o.value.closure}})}import{tool as m}from"@opencode-ai/plugin";var d=m.schema;function wt(e){return JSON.stringify(e,null,2)}function qa(e){return wt({status:"error",summary:e instanceof Error?e.message:String(e)})}async function x(e,a){try{return wt(await a(Ye(e)))}catch(t){return qa(t)}}async function Ea(e){let a=await ut(e),t=ee();if(!t)return a;return{...a,setup:{skills:t}}}function yt(e){return J(e)("info","Creating minimal Flow v4 tool surface."),{flow_status:m({description:"Show the active Flow session and next action",args:{},execute:(a,t)=>x(t,Ea)}),flow_plan_save:m({description:"Create or update a draft Flow plan for the active goal",args:{goal:d.string().optional(),plan:d.any().optional()},execute:(a,t)=>x(t,(r)=>pt(r,a))}),flow_plan_approve:m({description:"Approve the current draft Flow plan",args:{},execute:(a,t)=>x(t,ft)}),flow_run_start:m({description:"Start the next runnable approved Flow feature",args:{featureId:d.string().optional()},execute:(a,t)=>x(t,(r)=>mt(r,a))}),flow_feature_complete:m({description:"Record a completed or blocked active feature with validation and review evidence",args:{status:d.enum(["ok","needs_input"]),featureId:d.string(),summary:d.string(),artifactsChanged:d.array(d.object({path:d.string()})).optional(),validationRun:d.array(d.object({command:d.string(),status:d.enum(["passed","failed"]),summary:d.string()})).optional(),validationScope:d.enum(["targeted","broad"]).optional(),featureReview:d.any().optional(),finalReview:d.any().optional(),outcome:d.any().optional()},execute:(a,t)=>x(t,(r)=>ht(r,a))}),flow_feature_reset:m({description:"Reset one feature and its dependents to pending",args:{featureId:d.string()},execute:(a,t)=>x(t,(r)=>gt(r,a))}),flow_session_close:m({description:"Close and archive the active Flow session",args:{kind:d.enum(["completed","deferred","abandoned"]),summary:d.string().optional()},execute:(a,t)=>x(t,(r)=>vt(r,a))})}}async function bt(e){let a=e.worktree??e.directory;if(!a)return null;try{let t=await C(a);if(!t)return null;return["Flow session facts:",`- goal: ${t.goal}`,`- status: ${t.status}`,`- approval: ${t.approval}`,`- active feature: ${t.activeFeatureId??"none"}`,`- progress: ${t.plan?.features.filter((r)=>r.status==="completed").length??0}/${t.plan?.features.length??0}`,"Call flow_status before any Flow action."].join(`
|
|
1483
|
+
`)}catch{return null}}function Oa(e){return async(a,t)=>{let r=E();if(r)t.system.push(r);let o=await bt(e);if(o)t.system.push(o)}}function Da(){let e=new Set(Object.keys(Q));return async(a,t)=>{let r=a.command.replace(/^\/+/,"");if(!e.has(r))return;let o=E();if(!o)return;t.parts.push({type:"text",text:o,synthetic:!0})}}var Na=async(e)=>{let a=J(e);return a("info","Flow v4 plugin initialized."),await ze(Ne(),a),{config:at(e),tool:yt(e),"command.execute.before":Da(),"experimental.chat.system.transform":Oa(e),"experimental.session.compacting":async(t,r)=>{let o=E();if(o)r.context=[...r.context??[],o];let i=await bt(e);if(!i)return;r.context=[...r.context??[],i]}}},za=Na;export{za as default};
|
|
1484
|
+
|
|
1485
|
+
//# debugId=58DD13EF10CCB89B64756E2164756E21
|