opencode-plugin-flow 4.3.9 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/README.md +59 -48
  3. package/dist/application/errors.d.ts +5 -0
  4. package/dist/{runtime/api.d.ts → application/flow-service.d.ts} +89 -57
  5. package/dist/application/ports/session-repository.d.ts +11 -0
  6. package/dist/{runtime → application}/schema.d.ts +291 -371
  7. package/dist/cli.js +283 -2773
  8. package/dist/cli.js.map +7 -6
  9. package/dist/config-shared.d.ts +30 -16
  10. package/dist/config.d.ts +1 -1
  11. package/dist/distribution/legacy-cleanup.d.ts +25 -0
  12. package/dist/domain/feature-id.d.ts +3 -0
  13. package/dist/domain/limits.d.ts +1 -0
  14. package/dist/domain/orchestration-policy.d.ts +27 -0
  15. package/dist/domain/session.d.ts +181 -0
  16. package/dist/domain/transitions.d.ts +80 -0
  17. package/dist/guidance/catalog.d.ts +18 -0
  18. package/dist/guidance/ids.d.ts +4 -0
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.js +2676 -1929
  21. package/dist/index.js.map +24 -16
  22. package/dist/infrastructure/fs/session-repository.d.ts +2 -0
  23. package/dist/infrastructure/fs/workspace-flow-service.d.ts +9 -0
  24. package/dist/{runtime → infrastructure/fs}/workspace.d.ts +10 -14
  25. package/dist/infrastructure/system/transition-environment.d.ts +2 -0
  26. package/dist/platform/opencode/config.d.ts +2 -0
  27. package/dist/{adapters → platform}/opencode/plugin.d.ts +1 -1
  28. package/dist/{adapters → platform}/opencode/sdk.d.ts +0 -1
  29. package/dist/platform/opencode/tools.d.ts +6 -0
  30. package/dist/prompt-baseline-fixtures.d.ts +19 -0
  31. package/dist/prompt-model-evaluation.d.ts +88 -0
  32. package/dist/prompt-quality.d.ts +73 -0
  33. package/dist/prompt-surfaces.d.ts +28 -0
  34. package/dist/version.d.ts +1 -0
  35. package/package.json +19 -12
  36. package/dist/adapters/opencode/config.d.ts +0 -3
  37. package/dist/adapters/opencode/tools.d.ts +0 -322
  38. package/dist/distribution/flow-skill-definitions.d.ts +0 -9
  39. package/dist/distribution/sync.d.ts +0 -69
  40. package/dist/runtime/time.d.ts +0 -2
  41. package/dist/runtime/transitions.d.ts +0 -230
  42. /package/dist/{runtime/json/strict-object.d.ts → infrastructure/fs/strict-json-object.d.ts} +0 -0
  43. /package/dist/{adapters → platform}/opencode/logging.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,90 @@
2
2
 
3
3
  One short entry per release, written for users deciding whether to upgrade.
4
4
 
5
+ ## [5.0.0] - 2026-07-18
6
+
7
+ TypeScript 7 hard-cutover lore makes Flow 5 smaller, stricter, and easier to
8
+ recover without carrying a v4 compatibility layer:
9
+
10
+ - The compiler is TypeScript 7.0.2; the pinned toolchain is Bun 1.3.14,
11
+ Biome 2.5.4, OpenCode plugin 1.18.3, and Zod 4.4.3. Published code now
12
+ requires Node.js 24 or newer and CI covers Node 24 and 26.
13
+ - Source code now follows `domain -> application -> infrastructure ->
14
+ platform`: pure transitions use injected time and IDs, application use cases
15
+ depend on repository ports, filesystem state is an outer implementation,
16
+ and OpenCode owns only host transport and rendering.
17
+ - OpenCode's embedded validator is private to the host adapter. Flow's core
18
+ schemas use its direct Zod dependency, shared fixtures keep both wire
19
+ contracts aligned, and declaration emit no longer leaks package-manager or
20
+ nested-validator paths.
21
+ - Persisted sessions use schema version 3. Version 2 sessions are not migrated;
22
+ they are reported as unsupported and preserved in quarantine so a new v5
23
+ session can start safely.
24
+ - Public use-case results have an explicit typed operation status. Repository-
25
+ and caller-controlled prose is confined to `workflowData`; top-level
26
+ summaries, next actions, and recovery fields remain plugin-authored. Feature
27
+ and session IDs are branded, feature IDs are consistently lowercase
28
+ kebab-case at every input boundary, and all superseded `src/runtime` and
29
+ `src/adapters` entrypoints are removed.
30
+ - Source and declaration imports follow NodeNext ESM rules with explicit `.js`
31
+ specifiers, and the packed-package smoke test compiles a strict NodeNext
32
+ consumer without skipping library checks before importing the plugin in Node.
33
+ - Workspace roots are canonicalized and every Flow-managed directory and file
34
+ rejects symbolic links before read or mutation. Archive publication is
35
+ no-clobber and retry-safe, while lock contention and malformed owner metadata
36
+ fail closed for manual inspection instead of using age or liveness to steal a
37
+ lock. Completion outcomes require an explicit discriminator, and domain
38
+ transitions copy caller-owned plan and evidence collections before recording
39
+ them.
40
+ - Flow no longer synchronizes Markdown into OpenCode's global skill registry.
41
+ Core command guidance and optional helpers are embedded in the plugin;
42
+ `flow_guidance` returns exact package-versioned documents by stable id, plugin
43
+ startup performs no global skill filesystem work, and `flow_status` no longer
44
+ carries setup/restart health.
45
+ - Plugin configuration only registers commands and agents; it performs no
46
+ workspace filesystem I/O and maintains no ambient instruction projection.
47
+ `/flow-review` validates OpenCode's native subtask identity and agent before
48
+ rewriting only its prompt, so malformed dispatch fails closed.
49
+ - Orchestration telemetry retains at most 50 recent pass records and accepts at
50
+ most 50 per completion. Deduplication is scoped to that retained telemetry
51
+ window, and failed completion mutations now update `timestamps.updatedAt`
52
+ from the same instant recorded in `lastError`.
53
+ - The experimental compaction hook, token telemetry, phase boundaries, resume
54
+ packets, and acknowledgement protocol are gone. Review retry exhaustion uses
55
+ the ordinary blocked-feature/reset path, while a recorded closure makes the
56
+ session archive-only until retry-safe publication succeeds.
57
+ - The old doctor/sync/uninstall CLI is replaced by explicit
58
+ `legacy-cleanup --dry-run|--apply`. Apply never deletes: it moves only
59
+ marker-proven pristine v4 folders to a recovery archive and refuses
60
+ foreign, edited, extra, malformed, or symlinked content.
61
+
62
+ ## [4.4.0] - 2026-07-17
63
+
64
+ Prompt economy lore makes Flow's instructions smaller, more role-specific, and
65
+ easier to verify without weakening runtime, validation, or review gates:
66
+
67
+ - Public commands and hidden workers now compile role- and phase-specific
68
+ prompts from canonical skill fragments instead of concatenating whole skills
69
+ or maintaining parallel prompt copies in TypeScript.
70
+ - Parallel guidance uses progressive disclosure: a short routing index loads
71
+ decision rules first, manifest and execution rules only after fan-out is
72
+ selected, and synthesis rules only when handoffs return. Serial-decision
73
+ context is about 76% smaller while the complete advanced contract remains
74
+ available.
75
+ - Each hidden worker receives one role contract and one matching handoff schema;
76
+ empty, malformed, partial, and blocked handoffs remain explicit coverage gaps,
77
+ and candidate implementation stays subordinate to the root `flow-run`
78
+ manager.
79
+ - Runtime-unavailable guards, planned review depth, cleanup/UI/audit evidence,
80
+ bounded review repair, and root-manager state ownership are covered across
81
+ the compiled surfaces.
82
+ - Skills no longer estimate context pressure or request host compaction, and
83
+ the experimental compaction hook and environment switch have been removed;
84
+ durable runtime phase boundaries remain the continuation mechanism.
85
+ - New deterministic prompt-quality tooling covers 18 scenarios and 52 static
86
+ criteria, with an opt-in structured model evaluator for GPT-5.4, GPT-5.6 Sol,
87
+ and other configured OpenCode models.
88
+
5
89
  ## [4.3.9] - 2026-07-08
6
90
 
7
91
  Candidate accounting coherence lore makes the 4.3.8 orchestration accounting
package/README.md CHANGED
@@ -6,10 +6,10 @@ then implement one feature at a time with enforced validation and review
6
6
  evidence. State lives in `.flow/session.json`, so a session survives restarts,
7
7
  model switches, and context loss.
8
8
 
9
- The design is skills-first: the skills carry planning, execution, validation,
10
- review, and orchestration judgment, while the plugin runtime stays deliberately
11
- small — it keeps the session ledger and enforces the hard gates prompts should
12
- not be trusted to remember.
9
+ The design is guidance-first: package-owned Markdown carries planning,
10
+ execution, validation, review, and orchestration judgment, while the plugin
11
+ runtime stays deliberately small — it keeps the session ledger and enforces the
12
+ hard gates prompts should not be trusted to remember.
13
13
 
14
14
  Full project documentation is available in the
15
15
  [Flow OpenCode wiki](https://github.com/ddv1982/flow-opencode/wiki).
@@ -17,11 +17,10 @@ Full project documentation is available in the
17
17
  ## Quick start
18
18
 
19
19
  ```bash
20
- opencode plugin opencode-plugin-flow@4.3.9 --global --force
21
- npx -y opencode-plugin-flow@4.3.9 sync
20
+ opencode plugin opencode-plugin-flow@5.0.0 --global --force
22
21
  ```
23
22
 
24
- Restart OpenCode, then give Flow a goal:
23
+ Start or restart OpenCode, then give Flow a goal:
25
24
 
26
25
  ```text
27
26
  /flow-auto add rate limiting to the public API
@@ -52,8 +51,9 @@ restart.
52
51
  ...
53
52
 
54
53
  > /flow-status
55
- status: running, 1/3 features completed
56
- nextAction: complete feature "per-route-config"
54
+ status: ok
55
+ workflowData.session.status: running, 1/3 features completed
56
+ nextAction: complete the feature under workflowData.session.activeFeature
57
57
  ```
58
58
 
59
59
  Interrupt at any point; `/flow-run` resumes the next approved feature. On the
@@ -65,26 +65,30 @@ completed.
65
65
 
66
66
  | Command | Purpose |
67
67
  | --- | --- |
68
- | `/flow-auto <goal>` | Drive the full skill-guided loop. |
68
+ | `/flow-auto <goal>` | Drive the full guidance-driven loop. |
69
69
  | `/flow-plan <goal>` | Create or approve a plan. |
70
70
  | `/flow-run` | Execute one approved feature. |
71
71
  | `/flow-review` | Run a read-only review. |
72
72
  | `/flow-status` | Show the active session and next action. |
73
73
 
74
- Commands are bundled entrypoints: they carry their own instructions, so they
75
- keep working even when OpenCode's native skill discovery lags behind a fresh
76
- install (see [docs/troubleshooting.md](docs/troubleshooting.md)).
74
+ Commands are compiled entrypoints: manager commands carry only their applicable
75
+ core instructions, while `/flow-review` runs against the reserved reviewer's
76
+ role-specific agent contract. Flow does not install files into OpenCode's
77
+ global skill registry and does not depend on native skill discovery.
77
78
 
78
- `flow-test`, `flow-deslop`, `flow-ui-quality`, and `flow-commit` are managed
79
- helper skills, not public commands.
80
- `flow-commit` is user-triggered only and stays outside the autonomous loop.
79
+ `flow-test`, `flow-deslop`, `flow-ui-quality`, and `flow-commit` are optional
80
+ package-owned guides loaded on demand through `flow_guidance`, not public
81
+ commands. `flow-commit` is user-triggered only and stays outside the autonomous
82
+ loop.
81
83
 
82
84
  ## Tools
83
85
 
84
- The runtime exposes seven tools:
86
+ The plugin exposes eight tools. `flow_guidance` is read-only and returns embedded
87
+ Markdown; the other seven form the stateful runtime surface:
85
88
 
86
89
  | Tool | Purpose |
87
90
  | --- | --- |
91
+ | `flow_guidance` | Load exact package-owned guidance by stable id. |
88
92
  | `flow_status` | Read the active session and next action. |
89
93
  | `flow_plan_save` | Create a session and/or save a draft plan. |
90
94
  | `flow_plan_approve` | Approve the draft plan. |
@@ -99,7 +103,7 @@ final feature also needs a passing `finalReview`.
99
103
 
100
104
  ## What the runtime enforces
101
105
 
102
- The runtime owns only safety; judgment lives in the skills:
106
+ The runtime owns only safety; judgment lives in package-owned guidance:
103
107
 
104
108
  - `.flow/session.json` is the single source of truth; writes are locked and
105
109
  atomic, and closed sessions are archived under `.flow/history/`.
@@ -112,21 +116,22 @@ The runtime owns only safety; judgment lives in the skills:
112
116
  that is shallower than the approved feature requires.
113
117
  - Failed reviews are bounded: a failed review pauses by default, and autonomous
114
118
  repair is limited to one repair plus one retry before the feature blocks.
115
- - Completed feature counts are telemetry only; Flow does not stop an approved
116
- plan just because several features have completed. Review retry boundaries
117
- still return a compact resume packet and require explicit `phaseBoundaryAck`
118
- before starting the next feature.
119
+ - Review exhaustion uses the ordinary blocked-feature state; continuing requires
120
+ an explicit `flow_feature_reset`, not a second checkpoint protocol.
121
+ - Once a closure is recorded, the session is archive-only. If publication fails,
122
+ retry `flow_session_close`; no run, reset, approval, or replan can reopen it.
119
123
  - A session can close as `completed` only after final completion has passed.
120
- - Crash recovery is built in: stale session locks expire automatically and
121
- unreadable session files are quarantined with recovery guidance, never
122
- silently deleted.
124
+ - Session locks fail closed: Flow never guesses that an old lock is abandoned,
125
+ and only the unique owner may release it. Unreadable session files are
126
+ quarantined with recovery guidance, never silently deleted.
123
127
  - Flow writes `.flow/.gitignore` so session state stays out of Git by default.
124
- - `.flow/opencode-instructions.md` is a generated projection of the active
125
- session that keeps ambient context accurate; do not edit it.
128
+ - `.flow/session.json` is the only active-state representation. Canonical Flow
129
+ commands call `flow_status` before acting; plugin configuration does not read,
130
+ refresh, or project workspace state.
126
131
 
127
132
  ## Hidden workers
128
133
 
129
- For broad work, Flow's manager can fan out read-only workers
134
+ For broad work, Flow's manager can fan out isolated hidden workers
130
135
  (`flow-evidence-worker`, `flow-validation-worker`, `flow-audit-worker`,
131
136
  `flow-candidate-worker`, `flow-verifier-worker`, and the `flow-reviewer`) with
132
137
  locked-down permissions. Workers gather evidence; they never approve plans,
@@ -134,39 +139,44 @@ complete features, or close sessions. Flow reserves those agent ids and the
134
139
  public command ids while the plugin is enabled, and warns if they collide with
135
140
  your own config.
136
141
 
142
+ Each hidden worker receives only its applicable handoff schema. The manager
143
+ contract treats empty or malformed handoffs as coverage gaps instead of
144
+ success. The offline handoff validator detects missing headings, empty sections,
145
+ unresolved placeholders, and invalid statuses; current OpenCode worker output
146
+ remains plain text, so runtime acceptance still depends on the manager applying
147
+ that contract. Inspect rendered surfaces and static contracts with
148
+ `bun run prompt:quality`; run opt-in model decisions with
149
+ `bun run prompt:model-eval -- --model <provider/model> --timeout-ms 300000`;
150
+ see
151
+ [docs/prompt-quality.md](docs/prompt-quality.md).
152
+
137
153
  For broad implementation, the manager records whether work stayed serial,
138
154
  used exact-path candidate workers, used isolated worktrees, ran a tournament, or
139
- skipped eligible candidates. Feature completion can carry compact
155
+ skipped eligible candidates. Feature completion can carry bounded
140
156
  `orchestrationPasses` with candidate eligibility, decision, and structured
141
157
  factors; `flow_status` reports the aggregate under
142
- `session.budget.orchestration`.
158
+ `workflowData.session.budget.orchestration`.
143
159
 
144
- ## Install details, doctor, repair, uninstall
160
+ ## Install details and legacy cleanup
145
161
 
146
- See [docs/troubleshooting.md](docs/troubleshooting.md) for skill sync
147
- mechanics, the `doctor`/`sync` CLI, older-OpenCode install fallback, stuck
148
- session recovery, and uninstall (`uninstall --dry-run` previews removals).
162
+ See [docs/troubleshooting.md](docs/troubleshooting.md) for updates,
163
+ older-OpenCode install fallback, stuck session recovery, and removal of global
164
+ Flow skill folders left by v4.
149
165
 
150
- To update a pinned Flow version, rerun the install command with the new
151
- version. To inspect skill health:
166
+ To update a pinned Flow version, rerun the install command with the new version.
167
+ Flow starts with the new package-owned guidance immediately; no second restart
168
+ or sync command is required. To preview recoverable migration of pristine v4
169
+ global skill folders:
152
170
 
153
171
  ```bash
154
- npx -y opencode-plugin-flow@4.3.9 doctor
172
+ npx -y opencode-plugin-flow@5.0.0 legacy-cleanup --dry-run
155
173
  ```
156
174
 
157
- ## Experimental: compaction context
158
-
159
- Flow's ambient context uses stable OpenCode configuration by default. If you
160
- want the active session summary injected into OpenCode's session compaction as
161
- well, opt in with the environment variable `FLOW_EXPERIMENTAL_COMPACTION=1`.
162
- This uses OpenCode's experimental compaction hook and may change with OpenCode
163
- versions; the default remains hook-free.
164
-
165
175
  ## Development
166
176
 
167
177
  ```bash
168
178
  bun install
169
- bun run check # typecheck + lint + build + tests
179
+ bun run check # typecheck + lint + prompt quality + build + tests
170
180
  bun run smoke:live # boots a real OpenCode server against the packed tarball
171
181
  ```
172
182
 
@@ -178,7 +188,8 @@ import flowPlugin from "opencode-plugin-flow";
178
188
 
179
189
  See [docs/development.md](docs/development.md) and
180
190
  [docs/maintainer-contract.md](docs/maintainer-contract.md) for the
181
- runtime/skills split and release process.
191
+ v5 domain/application/infrastructure/platform boundaries, guidance split, and
192
+ release process.
182
193
 
183
194
  ## Credits
184
195
 
@@ -188,5 +199,5 @@ work on parallel agent workflows. Flow also draws conceptual inspiration from
188
199
  emphasis on codebase orientation, context engineering, agent orchestration,
189
200
  and reviewable handoffs.
190
201
 
191
- The Flow version is its own OpenCode-native design: skills-first,
202
+ The Flow version is its own OpenCode-native design: package-owned guidance,
192
203
  manager-owned state, hidden workers, and no extra runtime ledger.
@@ -0,0 +1,5 @@
1
+ export declare class UnreadableFlowSessionError extends Error {
2
+ readonly code = "UNREADABLE_FLOW_SESSION";
3
+ readonly reason: string;
4
+ constructor(message: string, reason: string);
5
+ }
@@ -1,5 +1,48 @@
1
1
  import { z } from "zod";
2
- export type RuntimeResponse = Record<string, unknown>;
2
+ import type { Feature, Session, SessionId } from "../domain/session.js";
3
+ import { summarizeSession, type TransitionEnvironment } from "../domain/transitions.js";
4
+ import type { SessionRepository } from "./ports/session-repository.js";
5
+ type StatusResponse = ReturnType<typeof summarizeSession>;
6
+ type ActiveStatusResponse = Extract<StatusResponse, {
7
+ workflowData: unknown;
8
+ }>;
9
+ type SessionWorkflowData = ActiveStatusResponse["workflowData"]["session"];
10
+ type WorkflowData = {
11
+ session?: SessionWorkflowData;
12
+ failure?: {
13
+ summary: string;
14
+ recovery?: string;
15
+ };
16
+ startedFeature?: Feature;
17
+ archive?: {
18
+ sessionId: SessionId;
19
+ closure: Session["closure"];
20
+ };
21
+ quarantine?: {
22
+ reason: string;
23
+ preservedAt?: string;
24
+ };
25
+ };
26
+ type ResponseContext = {
27
+ statusSummary?: string;
28
+ nextAction?: string;
29
+ dataNote?: string;
30
+ workflowData?: WorkflowData;
31
+ recovery?: string;
32
+ };
33
+ export type FlowResponse = ResponseContext & {
34
+ status: "ok" | "error" | "missing_goal" | "missing_session";
35
+ summary: string;
36
+ };
37
+ export type FlowService = {
38
+ status(): Promise<FlowResponse>;
39
+ planSave(input: unknown): Promise<FlowResponse>;
40
+ planApprove(): Promise<FlowResponse>;
41
+ runStart(input: unknown): Promise<FlowResponse>;
42
+ featureComplete(input: unknown): Promise<FlowResponse>;
43
+ featureReset(input: unknown): Promise<FlowResponse>;
44
+ sessionClose(input: unknown): Promise<FlowResponse>;
45
+ };
3
46
  export declare const FlowPlanSaveSchema: z.ZodObject<{
4
47
  goal: z.ZodOptional<z.ZodString>;
5
48
  plan: z.ZodOptional<z.ZodObject<{
@@ -12,47 +55,46 @@ export declare const FlowPlanSaveSchema: z.ZodObject<{
12
55
  detailed: "detailed";
13
56
  }>>;
14
57
  features: z.ZodArray<z.ZodObject<{
15
- summary: z.ZodString;
16
- id: z.ZodString;
58
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<import("../domain/session.js").FeatureId, string>>;
17
59
  title: z.ZodString;
60
+ summary: z.ZodString;
18
61
  status: z.ZodOptional<z.ZodEnum<{
19
- pending: "pending";
20
- in_progress: "in_progress";
21
- completed: "completed";
22
62
  blocked: "blocked";
63
+ completed: "completed";
64
+ in_progress: "in_progress";
65
+ pending: "pending";
23
66
  }>>;
24
67
  reviewDepth: z.ZodOptional<z.ZodEnum<{
68
+ detailed: "detailed";
25
69
  quick: "quick";
26
70
  standard: "standard";
27
- detailed: "detailed";
28
71
  }>>;
29
72
  targets: z.ZodOptional<z.ZodArray<z.ZodString>>;
30
73
  validation: z.ZodOptional<z.ZodArray<z.ZodString>>;
31
- dependsOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
74
+ dependsOn: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("../domain/session.js").FeatureId, string>>>>;
32
75
  }, z.core.$strict>>;
33
76
  }, z.core.$strict>>;
34
77
  }, z.core.$strict>;
35
78
  export declare const FlowRunStartSchema: z.ZodObject<{
36
- featureId: z.ZodOptional<z.ZodString>;
37
- phaseBoundaryAck: z.ZodOptional<z.ZodBoolean>;
79
+ featureId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("../domain/session.js").FeatureId, string>>>;
38
80
  }, z.core.$strict>;
39
81
  export declare const FlowFeatureResetSchema: z.ZodObject<{
40
- featureId: z.ZodString;
82
+ featureId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../domain/session.js").FeatureId, string>>;
41
83
  }, z.core.$strict>;
42
84
  export declare const FlowSessionCloseSchema: z.ZodObject<{
43
85
  kind: z.ZodEnum<{
86
+ abandoned: "abandoned";
44
87
  completed: "completed";
45
88
  deferred: "deferred";
46
- abandoned: "abandoned";
47
89
  }>;
48
90
  summary: z.ZodOptional<z.ZodString>;
49
91
  }, z.core.$strict>;
50
92
  export declare const FlowFeatureCompleteToolSchema: z.ZodObject<{
51
93
  status: z.ZodEnum<{
52
- ok: "ok";
53
94
  needs_input: "needs_input";
95
+ ok: "ok";
54
96
  }>;
55
- featureId: z.ZodString;
97
+ featureId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../domain/session.js").FeatureId, string>>;
56
98
  summary: z.ZodString;
57
99
  artifactsChanged: z.ZodOptional<z.ZodArray<z.ZodObject<{
58
100
  path: z.ZodString;
@@ -60,45 +102,45 @@ export declare const FlowFeatureCompleteToolSchema: z.ZodObject<{
60
102
  validationRun: z.ZodOptional<z.ZodArray<z.ZodObject<{
61
103
  command: z.ZodString;
62
104
  status: z.ZodEnum<{
63
- passed: "passed";
64
105
  failed: "failed";
106
+ passed: "passed";
65
107
  }>;
66
108
  summary: z.ZodString;
67
109
  }, z.core.$strict>>>;
68
110
  validationScope: z.ZodOptional<z.ZodEnum<{
69
- targeted: "targeted";
70
111
  broad: "broad";
112
+ targeted: "targeted";
71
113
  }>>;
72
114
  featureReviewDepth: z.ZodOptional<z.ZodEnum<{
115
+ detailed: "detailed";
73
116
  quick: "quick";
74
117
  standard: "standard";
75
- detailed: "detailed";
76
118
  }>>;
77
119
  featureReview: z.ZodOptional<z.ZodObject<{
78
120
  status: z.ZodEnum<{
79
- passed: "passed";
80
121
  failed: "failed";
122
+ passed: "passed";
81
123
  }>;
82
124
  summary: z.ZodString;
83
125
  blockingFindings: z.ZodDefault<z.ZodArray<z.ZodObject<{
84
126
  summary: z.ZodString;
85
127
  severity: z.ZodDefault<z.ZodEnum<{
86
- blocking: "blocking";
87
128
  advisory: "advisory";
129
+ blocking: "blocking";
88
130
  }>>;
89
131
  }, z.core.$strict>>>;
90
132
  }, z.core.$strict>>;
91
133
  finalReview: z.ZodOptional<z.ZodObject<{
92
134
  status: z.ZodEnum<{
93
- passed: "passed";
94
135
  failed: "failed";
136
+ passed: "passed";
95
137
  }>;
96
138
  summary: z.ZodString;
97
139
  blockingFindings: z.ZodDefault<z.ZodArray<z.ZodObject<{
98
140
  summary: z.ZodString;
99
141
  severity: z.ZodDefault<z.ZodEnum<{
100
- blocking: "blocking";
101
142
  advisory: "advisory";
143
+ blocking: "blocking";
102
144
  }>>;
103
145
  }, z.core.$strict>>>;
104
146
  reviewDepth: z.ZodEnum<{
@@ -106,42 +148,37 @@ export declare const FlowFeatureCompleteToolSchema: z.ZodObject<{
106
148
  detailed: "detailed";
107
149
  }>;
108
150
  }, z.core.$strict>>;
109
- outcome: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
110
- kind: z.ZodDefault<z.ZodEnum<{
111
- completed: "completed";
112
- blocked: "blocked";
113
- needs_input: "needs_input";
114
- replan_required: "replan_required";
115
- }>>;
151
+ outcome: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
152
+ kind: z.ZodLiteral<"completed">;
116
153
  summary: z.ZodOptional<z.ZodString>;
117
154
  resolutionHint: z.ZodOptional<z.ZodString>;
118
155
  }, z.core.$strict>, z.ZodObject<{
119
- kind: z.ZodDefault<z.ZodEnum<{
156
+ kind: z.ZodEnum<{
120
157
  blocked: "blocked";
121
158
  needs_input: "needs_input";
122
159
  replan_required: "replan_required";
123
- }>>;
160
+ }>;
124
161
  summary: z.ZodString;
125
162
  resolutionHint: z.ZodOptional<z.ZodString>;
126
- }, z.core.$strict>]>>;
163
+ }, z.core.$strict>], "kind">>;
127
164
  orchestrationPasses: z.ZodOptional<z.ZodArray<z.ZodObject<{
128
165
  id: z.ZodString;
129
166
  kind: z.ZodEnum<{
130
- discovery: "discovery";
131
167
  audit: "audit";
168
+ candidate: "candidate";
169
+ discovery: "discovery";
170
+ "implementation-decision": "implementation-decision";
132
171
  review: "review";
133
172
  validation: "validation";
134
173
  verification: "verification";
135
- candidate: "candidate";
136
- "implementation-decision": "implementation-decision";
137
174
  }>;
138
175
  decision: z.ZodOptional<z.ZodEnum<{
139
- serial: "serial";
140
- parallel: "parallel";
141
176
  "candidate-exact-path": "candidate-exact-path";
142
177
  "candidate-worktree": "candidate-worktree";
143
- tournament: "tournament";
178
+ parallel: "parallel";
179
+ serial: "serial";
144
180
  skipped: "skipped";
181
+ tournament: "tournament";
145
182
  }>>;
146
183
  decisionReason: z.ZodOptional<z.ZodString>;
147
184
  candidateEligibility: z.ZodDefault<z.ZodEnum<{
@@ -150,25 +187,25 @@ export declare const FlowFeatureCompleteToolSchema: z.ZodObject<{
150
187
  unknown: "unknown";
151
188
  }>>;
152
189
  candidateDecision: z.ZodOptional<z.ZodEnum<{
190
+ serial_required: "serial_required";
153
191
  skipped: "skipped";
154
192
  used: "used";
155
- serial_required: "serial_required";
156
193
  }>>;
157
194
  decisionFactors: z.ZodDefault<z.ZodArray<z.ZodEnum<{
158
- shared_state: "shared_state";
195
+ independent_surface: "independent_surface";
196
+ needs_manager_judgment: "needs_manager_judgment";
159
197
  overlapping_files: "overlapping_files";
198
+ shared_state: "shared_state";
160
199
  small_slice: "small_slice";
161
- needs_manager_judgment: "needs_manager_judgment";
162
- independent_surface: "independent_surface";
163
200
  validation_available: "validation_available";
164
201
  }>>>;
165
202
  modes: z.ZodDefault<z.ZodArray<z.ZodEnum<{
166
203
  audit: "audit";
204
+ "candidate-implementation": "candidate-implementation";
205
+ evidence: "evidence";
167
206
  review: "review";
168
207
  validation: "validation";
169
- evidence: "evidence";
170
208
  verifier: "verifier";
171
- "candidate-implementation": "candidate-implementation";
172
209
  }>>>;
173
210
  workerCount: z.ZodDefault<z.ZodNumber>;
174
211
  candidateWorkerCount: z.ZodDefault<z.ZodNumber>;
@@ -176,36 +213,31 @@ export declare const FlowFeatureCompleteToolSchema: z.ZodObject<{
176
213
  sliceIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
177
214
  dependsOn: z.ZodDefault<z.ZodArray<z.ZodString>>;
178
215
  writeScope: z.ZodDefault<z.ZodEnum<{
179
- none: "none";
180
- "manager-serial": "manager-serial";
181
216
  "exact-path": "exact-path";
182
217
  "isolated-worktree": "isolated-worktree";
218
+ "manager-serial": "manager-serial";
183
219
  mixed: "mixed";
220
+ none: "none";
184
221
  }>>;
185
222
  handoffRefs: z.ZodDefault<z.ZodArray<z.ZodString>>;
186
223
  verificationStatus: z.ZodDefault<z.ZodEnum<{
187
- pending: "pending";
188
- passed: "passed";
224
+ downgraded: "downgraded";
189
225
  failed: "failed";
190
226
  mixed: "mixed";
191
227
  "not-needed": "not-needed";
192
- downgraded: "downgraded";
228
+ passed: "passed";
229
+ pending: "pending";
193
230
  }>>;
194
231
  outcome: z.ZodDefault<z.ZodEnum<{
195
232
  accepted: "accepted";
196
233
  modified: "modified";
197
- rejected: "rejected";
198
- partial: "partial";
199
234
  "not-covered": "not-covered";
235
+ partial: "partial";
236
+ rejected: "rejected";
200
237
  superseded: "superseded";
201
238
  }>>;
202
239
  synthesisRef: z.ZodOptional<z.ZodString>;
203
240
  }, z.core.$strict>>>;
204
241
  }, z.core.$strict>;
205
- export declare function flowStatus(worktree: string): Promise<RuntimeResponse>;
206
- export declare function flowPlanSave(worktree: string, input: unknown): Promise<RuntimeResponse>;
207
- export declare function flowPlanApprove(worktree: string): Promise<RuntimeResponse>;
208
- export declare function flowRunStart(worktree: string, input: unknown): Promise<RuntimeResponse>;
209
- export declare function flowFeatureComplete(worktree: string, input: unknown): Promise<RuntimeResponse>;
210
- export declare function flowFeatureReset(worktree: string, input: unknown): Promise<RuntimeResponse>;
211
- export declare function flowSessionClose(worktree: string, input: unknown): Promise<RuntimeResponse>;
242
+ export declare function createFlowService(repository: SessionRepository, environment: TransitionEnvironment): FlowService;
243
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { Session } from "../../domain/session.js";
2
+ export type SessionTransaction = {
3
+ load(): Promise<Session | null>;
4
+ save(session: Session): Promise<Session>;
5
+ archiveAndClear(session: Session): Promise<void>;
6
+ quarantineUnreadable(): Promise<string | null>;
7
+ };
8
+ export interface SessionRepository {
9
+ read(): Promise<Session | null>;
10
+ transact<T>(task: (transaction: SessionTransaction) => Promise<T>): Promise<T>;
11
+ }