@dv.nghiem/flowdeck 0.4.7 → 0.4.8

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 (50) hide show
  1. package/README.md +14 -1
  2. package/dist/agents/orchestrator.d.ts +2 -5
  3. package/dist/agents/orchestrator.d.ts.map +1 -1
  4. package/dist/config/schema.d.ts +1 -15
  5. package/dist/config/schema.d.ts.map +1 -1
  6. package/dist/dashboard/server.mjs +14 -1
  7. package/dist/hooks/orchestrator-guard-hook.d.ts +5 -15
  8. package/dist/hooks/orchestrator-guard-hook.d.ts.map +1 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +617 -2045
  11. package/dist/{tools/dispatch-routing.d.ts → lib/task-routing.d.ts} +1 -3
  12. package/dist/lib/task-routing.d.ts.map +1 -0
  13. package/dist/services/agent-contract-registry.d.ts.map +1 -1
  14. package/dist/services/agent-performance.d.ts +1 -1
  15. package/dist/services/agent-performance.d.ts.map +1 -1
  16. package/dist/services/cost-estimator.d.ts +0 -88
  17. package/dist/services/cost-estimator.d.ts.map +1 -1
  18. package/dist/services/event-logger.d.ts +1 -1
  19. package/dist/services/event-logger.d.ts.map +1 -1
  20. package/dist/services/quick-router.d.ts +24 -0
  21. package/dist/services/quick-router.d.ts.map +1 -1
  22. package/dist/services/supervisor-binding.d.ts +6 -0
  23. package/dist/services/supervisor-binding.d.ts.map +1 -1
  24. package/dist/services/workflow-router.d.ts +57 -0
  25. package/dist/services/workflow-router.d.ts.map +1 -0
  26. package/dist/services/workflow-scorecard.d.ts.map +1 -1
  27. package/dist/tools/planning-state-lib.d.ts +23 -0
  28. package/dist/tools/planning-state-lib.d.ts.map +1 -1
  29. package/docs/concepts/workflows.md +48 -0
  30. package/docs/index.md +15 -2
  31. package/docs/reference/workflow-router.md +337 -0
  32. package/package.json +1 -1
  33. package/src/commands/fd-discuss.md +8 -1
  34. package/src/commands/fd-execute.md +25 -3
  35. package/src/commands/fd-new-feature.md +97 -4
  36. package/src/commands/fd-plan.md +14 -4
  37. package/src/commands/fd-quick.md +43 -16
  38. package/src/rules/common/agent-orchestration.md +52 -18
  39. package/src/skills/agent-harness-construction/SKILL.md +5 -5
  40. package/dist/services/delegation-budget.d.ts +0 -54
  41. package/dist/services/delegation-budget.d.ts.map +0 -1
  42. package/dist/services/prompt-cache.d.ts +0 -61
  43. package/dist/services/prompt-cache.d.ts.map +0 -1
  44. package/dist/services/token-metrics.d.ts +0 -97
  45. package/dist/services/token-metrics.d.ts.map +0 -1
  46. package/dist/tools/delegate.d.ts +0 -4
  47. package/dist/tools/delegate.d.ts.map +0 -1
  48. package/dist/tools/dispatch-routing.d.ts.map +0 -1
  49. package/dist/tools/run-pipeline.d.ts +0 -4
  50. package/dist/tools/run-pipeline.d.ts.map +0 -1
@@ -0,0 +1,337 @@
1
+ # Workflow Router API Reference
2
+
3
+ ## Overview
4
+
5
+ The Workflow Router (`src/services/workflow-router.ts`) provides **adaptive workflow routing** for FlowDeck. It replaces the fixed pipeline (`discuss → plan → execute → review`) with a scoring-based system that selects the minimal sufficient workflow for each task.
6
+
7
+ ## When to Use
8
+
9
+ Use the workflow router when:
10
+ - You need to select a workflow class based on task characteristics
11
+ - You want to score tasks across multiple dimensions (complexity, risk, confidence)
12
+ - You need to escalate from a lightweight workflow to a richer one
13
+ - You want to log routing decisions for observability
14
+
15
+ ## Workflow Classes
16
+
17
+ | Class | Stages | When Selected |
18
+ |-------|--------|---------------|
19
+ | `quick` | `execute → verify` | Score ≥ 0.75 for simple/docs tasks |
20
+ | `standard` | `plan → execute → verify` | Default for normal implementations |
21
+ | `explore` | `discuss → plan → execute → verify` | Low confidence (< 0.60) or ambiguous tasks |
22
+ | `ui-heavy` | `discuss → design → plan → execute → verify` | UI/UX-heavy tasks |
23
+ | `bugfix` | `discuss → fix-bug → verify` | Bug signal dominates classification |
24
+ | `docs-only` | `write-docs → verify` | Documentation-only changes |
25
+ | `verify-heavy` | `plan → execute → verify` | High blast radius (≥ 5 files) or sensitive paths |
26
+
27
+ ## Types
28
+
29
+ ### `WorkflowClass`
30
+
31
+ ```typescript
32
+ type WorkflowClass =
33
+ | "quick"
34
+ | "standard"
35
+ | "explore"
36
+ | "ui-heavy"
37
+ | "bugfix"
38
+ | "docs-only"
39
+ | "verify-heavy"
40
+ ```
41
+
42
+ ### `RoutingCriteria`
43
+
44
+ Input data for the routing decision.
45
+
46
+ ```typescript
47
+ interface RoutingCriteria {
48
+ taskType: TaskType
49
+ complexity: "cheap" | "standard" | "expensive"
50
+ confidence: number // 0.0–1.0
51
+ blastRadius: number // estimated files affected
52
+ isSensitive: boolean // touches auth/payment/infra paths
53
+ codebaseFreshness: "fresh" | "stale" | "unknown"
54
+ requiresTests: boolean
55
+ }
56
+ ```
57
+
58
+ | Field | Type | Description |
59
+ |-------|------|-------------|
60
+ | `taskType` | `TaskType` | Classification from `quick-router.ts` |
61
+ | `complexity` | `"cheap" \| "standard" \| "expensive"` | From `model-router.ts` |
62
+ | `confidence` | `number` | Classification confidence (0.0–1.0) |
63
+ | `blastRadius` | `number` | Estimated number of files affected |
64
+ | `isSensitive` | `boolean` | Whether the task touches sensitive paths (auth, payment, etc.) |
65
+ | `codebaseFreshness` | `"fresh" \| "stale" \| "unknown"` | Whether `.codebase/` mapping is recent (< 24h) |
66
+ | `requiresTests` | `boolean` | Whether the task needs tests |
67
+
68
+ ### `RoutingScore`
69
+
70
+ Score breakdown for a routing decision.
71
+
72
+ ```typescript
73
+ interface RoutingScore {
74
+ simplicity: number // 0–0.30
75
+ confidence: number // 0–0.20
76
+ lowRisk: number // 0–0.20
77
+ knownCodebase: number // 0–0.15
78
+ cheapComplexity: number // 0–0.15
79
+ total: number // 0–1.0
80
+ }
81
+ ```
82
+
83
+ ### `WorkflowRoute`
84
+
85
+ The complete routing result.
86
+
87
+ ```typescript
88
+ interface WorkflowRoute {
89
+ workflowClass: WorkflowClass
90
+ stages: WorkflowStage[]
91
+ criteria: RoutingCriteria
92
+ scores: RoutingScore
93
+ reason: string
94
+ }
95
+ ```
96
+
97
+ ### `RoutingDecision`
98
+
99
+ Persisted routing decision with escalation history.
100
+
101
+ ```typescript
102
+ interface RoutingDecision {
103
+ route: WorkflowRoute
104
+ escalationHistory: EscalationEvent[]
105
+ skippedStages: string[]
106
+ loggedAt: string
107
+ }
108
+ ```
109
+
110
+ ## Functions
111
+
112
+ ### `scoreTaskForRouting`
113
+
114
+ Scores a task across 5 weighted dimensions.
115
+
116
+ ```typescript
117
+ export function scoreTaskForRouting(criteria: RoutingCriteria): RoutingScore
118
+ ```
119
+
120
+ **Scoring dimensions:**
121
+
122
+ | Dimension | Weight | Formula |
123
+ |-----------|--------|---------|
124
+ | Simplicity | 30% | `taskType === "simple" ? 1 : 0` |
125
+ | Confidence | 20% | `confidence` (raw value) |
126
+ | Low Risk | 20% | `!isSensitive && blastRadius < 3 ? 1 : 0` |
127
+ | Known Codebase | 15% | `codebaseFreshness === "fresh" ? 1 : 0` |
128
+ | Cheap Complexity | 15% | `complexity === "cheap" ? 1 : 0` |
129
+
130
+ **Example:**
131
+
132
+ ```typescript
133
+ import { scoreTaskForRouting } from "@/services/workflow-router"
134
+
135
+ const criteria = {
136
+ taskType: "simple",
137
+ complexity: "cheap",
138
+ confidence: 1.0,
139
+ blastRadius: 1,
140
+ isSensitive: false,
141
+ codebaseFreshness: "fresh",
142
+ requiresTests: false,
143
+ }
144
+
145
+ const score = scoreTaskForRouting(criteria)
146
+ // score.simplicity = 0.30
147
+ // score.confidence = 0.20
148
+ // score.lowRisk = 0.20
149
+ // score.knownCodebase = 0.15
150
+ // score.cheapComplexity = 0.15
151
+ // score.total = 1.00
152
+ ```
153
+
154
+ ### `buildAdaptiveStageSequence`
155
+
156
+ Selects the workflow class and stage sequence based on criteria.
157
+
158
+ ```typescript
159
+ export function buildAdaptiveStageSequence(criteria: RoutingCriteria): WorkflowRoute
160
+ ```
161
+
162
+ **Selection rules** (evaluated in order):
163
+
164
+ 1. **Quick workflow**: `totalScore >= 0.75` AND (`taskType === "simple"` OR `taskType === "docs"`)
165
+ 2. **Bugfix workflow**: `taskType === "bugfix"`
166
+ 3. **Docs-only workflow**: `taskType === "docs"` AND `totalScore < 0.75`
167
+ 4. **UI-heavy workflow**: `taskType === "ui-feature"`
168
+ 5. **Verify-heavy workflow**: `blastRadius >= 5` OR `isSensitive`
169
+ 6. **Explore workflow**: `confidence < 0.60` OR `taskType === "ambiguous"`
170
+ 7. **Standard workflow**: default fallback
171
+
172
+ **Example:**
173
+
174
+ ```typescript
175
+ import { buildAdaptiveStageSequence } from "@/services/workflow-router"
176
+
177
+ const route = buildAdaptiveStageSequence({
178
+ taskType: "simple",
179
+ complexity: "cheap",
180
+ confidence: 1.0,
181
+ blastRadius: 1,
182
+ isSensitive: false,
183
+ codebaseFreshness: "fresh",
184
+ requiresTests: false,
185
+ })
186
+
187
+ // route.workflowClass = "quick"
188
+ // route.stages = [{ name: "execute", command: "fd-execute", skippable: true }, ...]
189
+ // route.reason = "Quick workflow: score 1.00 >= 0.75 for simple task"
190
+ ```
191
+
192
+ ### `shouldEscalate`
193
+
194
+ Determines if a workflow should escalate to a richer class during execution.
195
+
196
+ ```typescript
197
+ export function shouldEscalate(
198
+ currentClass: WorkflowClass,
199
+ evidence: {
200
+ blastRadius?: number
201
+ isSensitive?: boolean
202
+ testsFailing?: boolean
203
+ designNeeded?: boolean
204
+ },
205
+ ): WorkflowClass | null
206
+ ```
207
+
208
+ **Escalation rules:**
209
+
210
+ | From | To | Trigger |
211
+ |------|-----|---------|
212
+ | `quick` | `standard` | `blastRadius > 3` |
213
+ | `quick` | `standard` | `testsFailing` |
214
+ | `standard` | `verify-heavy` | `isSensitive` |
215
+ | `standard` | `verify-heavy` | `blastRadius >= 5` |
216
+ | `standard` | `ui-heavy` | `designNeeded` |
217
+
218
+ Returns `null` if no escalation is needed.
219
+
220
+ **Example:**
221
+
222
+ ```typescript
223
+ import { shouldEscalate } from "@/services/workflow-router"
224
+
225
+ // During execution, more files are affected than expected
226
+ const newClass = shouldEscalate("quick", { blastRadius: 4 })
227
+ // newClass = "standard"
228
+ ```
229
+
230
+ ### `logRoutingDecision`
231
+
232
+ Appends a routing decision to `.codebase/WORKFLOW_ROUTING.jsonl`.
233
+
234
+ ```typescript
235
+ export function logRoutingDecision(dir: string, decision: RoutingDecision): void
236
+ ```
237
+
238
+ **Example:**
239
+
240
+ ```typescript
241
+ import { logRoutingDecision, buildAdaptiveStageSequence } from "@/services/workflow-router"
242
+
243
+ const route = buildAdaptiveStageSequence(criteria)
244
+ const decision = {
245
+ route,
246
+ escalationHistory: [],
247
+ skippedStages: ["discuss", "plan"],
248
+ loggedAt: new Date().toISOString(),
249
+ }
250
+
251
+ logRoutingDecision("/path/to/project", decision)
252
+ // Appends JSON line to .codebase/WORKFLOW_ROUTING.jsonl
253
+ ```
254
+
255
+ ### `getHistoricalCompliance`
256
+
257
+ Reads historical stage compliance from `.codebase/SCORECARDS.jsonl`.
258
+
259
+ ```typescript
260
+ export function getHistoricalCompliance(dir: string, taskType: TaskType): number | null
261
+ ```
262
+
263
+ Averages the `stageCompliance` dimension from scorecard entries matching the given `taskType`. Returns `null` if no data exists.
264
+
265
+ **Example:**
266
+
267
+ ```typescript
268
+ import { getHistoricalCompliance } from "@/services/workflow-router"
269
+
270
+ const compliance = getHistoricalCompliance("/path/to/project", "feature")
271
+ // compliance = 0.85 (or null if no scorecards)
272
+ ```
273
+
274
+ ## Integration
275
+
276
+ ### With `quick-router.ts`
277
+
278
+ The `buildAdaptiveWorkflow()` function in `quick-router.ts` calls `buildAdaptiveStageSequence()` to replace the deprecated `buildStageSequence()`:
279
+
280
+ ```typescript
281
+ // Old (fixed)
282
+ const stages = buildStageSequence("feature") // always returns discuss→plan→execute→verify
283
+
284
+ // New (adaptive)
285
+ const result = buildAdaptiveWorkflow(description, exploration)
286
+ // result.workflowClass = "quick" | "standard" | ...
287
+ // result.stageSequence = dynamically selected stages
288
+ ```
289
+
290
+ ### With `supervisor-binding.ts`
291
+
292
+ The supervisor reads `workflowClass` from `SupervisorContext` to apply conditional phase checks:
293
+
294
+ - `quick` / `docs-only` workflows skip the `fd-execute` phase check
295
+ - `quick` / `docs-only` workflows skip the UI-heavy design approval check
296
+
297
+ ### With `planning-state-lib.ts`
298
+
299
+ New `PlanningState` fields track routing decisions:
300
+
301
+ ```typescript
302
+ interface PlanningState {
303
+ workflowClass?: string
304
+ skippedStages?: string[]
305
+ escalationHistory?: Array<{ from: string; to: string; trigger: string; reason: string; timestamp: string }>
306
+ routingScores?: { simplicity: number; confidence: number; lowRisk: number; knownCodebase: number; cheapComplexity: number; total: number }
307
+ routingReason?: string
308
+ }
309
+ ```
310
+
311
+ ## File Output
312
+
313
+ ### `.codebase/WORKFLOW_ROUTING.jsonl`
314
+
315
+ Each routing decision is appended as a JSON line:
316
+
317
+ ```json
318
+ {
319
+ "route": {
320
+ "workflowClass": "quick",
321
+ "stages": [...],
322
+ "criteria": { ... },
323
+ "scores": { "simplicity": 0.30, "confidence": 0.20, "lowRisk": 0.20, "knownCodebase": 0.15, "cheapComplexity": 0.15, "total": 1.00 },
324
+ "reason": "Quick workflow: score 1.00 >= 0.75 for simple task"
325
+ },
326
+ "escalationHistory": [],
327
+ "skippedStages": ["discuss", "plan"],
328
+ "loggedAt": "2026-06-02T04:30:00Z"
329
+ }
330
+ ```
331
+
332
+ ## See Also
333
+
334
+ - [`quick-router.ts`](../services/quick-router.md) — Task classification and stage sequencing
335
+ - [`model-router.ts`](../services/model-router.md) — Task complexity classification
336
+ - [`supervisor-binding.ts`](../services/supervisor-binding.md) — Policy enforcement
337
+ - [`planning-state-lib.ts`](../tools/planning-state-lib.md) — State management
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dv.nghiem/flowdeck",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "description": "FlowDeck — structured planning and execution workflows for OpenCode",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -195,7 +195,14 @@ RQ-01: [question]
195
195
 
196
196
  ## Next Steps
197
197
 
198
- - Run /fd-plan to create implementation plan from these decisions
198
+ Read STATE.md to determine `workflowClass`:
199
+
200
+ - For `quick` workflows: Next step is `/fd-execute` (planning skipped for simple tasks).
201
+ - For `docs-only` workflows: Next step is `/fd-write-docs`.
202
+ - For `bugfix` workflows: Next step is `/fd-fix-bug`.
203
+ - For all other workflows: Run `/fd-plan` to create implementation plan from these decisions.
204
+
205
+ If the workflow class is not yet set, default to `/fd-plan`.
199
206
  ```
200
207
 
201
208
  ## D-05 Compliance
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Execute feature implementation from PLAN.md — TDD pipeline with backend-coder, frontend-coder, devops, tester, reviewer, and STATE.md update
2
+ description: Execute feature implementation from PLAN.md — adaptive TDD pipeline with backend-coder, frontend-coder, devops, tester, reviewer, and STATE.md update
3
3
  argument-hint: [--phase=N] [--override]
4
4
  ---
5
5
 
@@ -57,6 +57,21 @@ BEHAVIOR → RED → GREEN → REFACTOR → next step
57
57
 
58
58
  ## Process
59
59
 
60
+ ## Workflow-Aware Execution
61
+
62
+ Read STATE.md to determine the workflow class:
63
+ - `quick` / `docs-only`: Skip full TDD cycle. Run tests once after changes.
64
+ - `standard` / `explore` / `ui-heavy` / `verify-heavy` / `bugfix`: Follow full TDD cycle.
65
+
66
+ For `quick` workflows:
67
+ - Step 5 (Write Failing Tests) → Skip. Run existing tests after implementation.
68
+ - Step 6 (Confirm RED) → Skip.
69
+ - Step 7 (Implement Minimum) → Run directly.
70
+ - Step 8 (Confirm GREEN) → Run tests after implementation.
71
+ - Step 9 (Refactor) → Optional. Skip if no refactoring needed.
72
+
73
+ For all other workflows, follow the full TDD cycle below.
74
+
60
75
  ### Step 1: Guard Check
61
76
 
62
77
  Verify prerequisites:
@@ -99,13 +114,18 @@ Check TDD stage — only proceed if stage is appropriate for the step.
99
114
 
100
115
  ### Step 5: Write Failing Tests (RED)
101
116
 
102
- Spawn `@tester` to write tests for the step's behavior:
117
+ For `quick` / `docs-only` workflows: **SKIP this step.** Run existing tests after implementation in Step 8.
118
+
119
+ For all other workflows, spawn `@tester` to write tests for the step's behavior:
103
120
  - **Tests MUST fail** before implementation
104
121
  - Cover acceptance cases and edge cases
105
122
  - Use AAA pattern (Arrange-Act-Assert)
106
123
 
107
124
  ### Step 6: Confirm RED
108
125
 
126
+ For `quick` / `docs-only` workflows: **SKIP this step.**
127
+
128
+ For all other workflows:
109
129
  Run failing tests:
110
130
  - **GUARD: Do NOT proceed to Step 7 until tests fail**
111
131
  - If tests pass unexpectedly, tests don't correctly describe behavior
@@ -125,7 +145,9 @@ Run tests:
125
145
 
126
146
  ### Step 9: Refactor (REFACTOR)
127
147
 
128
- Only if GREEN:
148
+ For `quick` / `docs-only` workflows: **SKIP this step** unless the user explicitly requests cleanup.
149
+
150
+ For all other workflows, only if GREEN:
129
151
  - Clean up code for this step
130
152
  - Remove dead code
131
153
  - Improve readability
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Start a new feature — initialize feature context in .planning/, capture description, and guide through discuss plan execute → verify
2
+ description: Start a new feature — initialize feature context in .planning/, classify the task, select the adaptive workflow, and guide through the minimal sufficient stage sequence
3
3
  argument-hint: [feature name or description]
4
4
  ---
5
5
 
@@ -65,20 +65,113 @@ Update the current phase entry in STATE.md:
65
65
  - Set `status` to `defined`
66
66
  - Set `last_action` to `"Feature defined: $ARGUMENTS"`
67
67
 
68
- ### Step 4: Present Feature Workflow
68
+ ### Step 4: Classify and Present Workflow
69
+
70
+ Classify the task using `classifyTask($ARGUMENTS)` and score it for routing.
71
+
72
+ Record the classification in STATE.md:
73
+ ```yaml
74
+ workflowClass: <quick|standard|explore|ui-heavy|bugfix|docs-only|verify-heavy>
75
+ routingScores:
76
+ simplicity: <0-1>
77
+ confidence: <0-1>
78
+ lowRisk: <0-1>
79
+ knownCodebase: <0-1>
80
+ cheapComplexity: <0-1>
81
+ total: <0-1>
82
+ routingReason: <why this workflow was selected>
83
+ ```
84
+
85
+ Report what was created and present the next steps based on workflow class:
86
+
87
+ For `quick` workflows:
88
+ ```
89
+ ✅ Feature initialized: $ARGUMENTS
90
+ Phase: <N>
91
+ Workflow: quick (score: <total>)
92
+ File: .planning/phases/phase-<N>/FEATURE.md
93
+
94
+ Next step:
95
+ 1. /fd-execute — run implementation directly (discuss and plan skipped)
96
+ ```
97
+
98
+ For `standard` workflows:
99
+ ```
100
+ ✅ Feature initialized: $ARGUMENTS
101
+ Phase: <N>
102
+ Workflow: standard (score: <total>)
103
+ File: .planning/phases/phase-<N>/FEATURE.md
69
104
 
70
- Report what was created and present the next steps clearly:
105
+ Next steps (in order):
106
+ 1. /fd-plan — create implementation plan
107
+ 2. /fd-execute — run TDD pipeline to implement the plan
108
+ 3. /fd-verify — run full test + review pipeline
109
+ ```
71
110
 
111
+ For `explore` workflows:
72
112
  ```
73
113
  ✅ Feature initialized: $ARGUMENTS
74
114
  Phase: <N>
115
+ Workflow: explore (score: <total>)
75
116
  File: .planning/phases/phase-<N>/FEATURE.md
76
117
 
77
118
  Next steps (in order):
78
119
  1. /fd-discuss — capture requirements, scope, and acceptance criteria
79
120
  2. /fd-plan — create implementation plan from discussion decisions
80
121
  3. /fd-execute — run TDD pipeline to implement the plan
81
- 4. /fd-verify — run full test + review + deploy-check pipeline
122
+ 4. /fd-verify — run full test + review pipeline
123
+ ```
124
+
125
+ For `ui-heavy` workflows:
126
+ ```
127
+ ✅ Feature initialized: $ARGUMENTS
128
+ Phase: <N>
129
+ Workflow: ui-heavy (score: <total>)
130
+ File: .planning/phases/phase-<N>/FEATURE.md
131
+
132
+ Next steps (in order):
133
+ 1. /fd-discuss — capture requirements
134
+ 2. /fd-design — create design system and wireframes
135
+ 3. /fd-plan — create implementation plan
136
+ 4. /fd-execute — run TDD pipeline
137
+ 5. /fd-verify — run full test + review pipeline
138
+ ```
139
+
140
+ For `bugfix` workflows:
141
+ ```
142
+ ✅ Feature initialized: $ARGUMENTS
143
+ Phase: <N>
144
+ Workflow: bugfix (score: <total>)
145
+ File: .planning/phases/phase-<N>/FEATURE.md
146
+
147
+ Next steps (in order):
148
+ 1. /fd-discuss — reproduce and confirm the bug
149
+ 2. /fd-fix-bug — fix with regression test
150
+ 3. /fd-verify — verify the fix
151
+ ```
152
+
153
+ For `docs-only` workflows:
154
+ ```
155
+ ✅ Feature initialized: $ARGUMENTS
156
+ Phase: <N>
157
+ Workflow: docs-only (score: <total>)
158
+ File: .planning/phases/phase-<N>/FEATURE.md
159
+
160
+ Next step:
161
+ 1. /fd-write-docs — write documentation directly
162
+ ```
163
+
164
+ For `verify-heavy` workflows:
165
+ ```
166
+ ✅ Feature initialized: $ARGUMENTS
167
+ Phase: <N>
168
+ Workflow: verify-heavy (score: <total>)
169
+ File: .planning/phases/phase-<N>/FEATURE.md
170
+
171
+ Next steps (in order):
172
+ 1. /fd-plan — create detailed implementation plan
173
+ 2. /fd-execute — implement with enhanced verification
174
+ 3. /fd-verify — run full test + security review + deploy-check
82
175
  ```
83
176
 
84
177
  ## Error Handling
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Create detailed implementation plan from DISCUSS.md decisions — research-first, save PLAN.md, update STATE.md, require CONFIRM before execution
2
+ description: Create detailed implementation plan — research-first, adaptive guard check (skip discuss for quick workflows), save PLAN.md, update STATE.md, require CONFIRM before execution
3
3
  argument-hint: [--phase=N] [--yes]
4
4
  ---
5
5
 
@@ -50,14 +50,24 @@ If research is stale or missing:
50
50
 
51
51
  ### Step 1: Guard Check
52
52
 
53
- D-06: Verify DISCUSS.md exists and is confirmed.
53
+ D-06: Verify prerequisites for planning.
54
54
 
55
- If no DISCUSS.md found:
55
+ Read STATE.md to check `workflowClass`:
56
+
57
+ **For `quick` / `docs-only` workflows:**
58
+ - DISCUSS.md is NOT required.
59
+ - Proceed directly to Step 2.
60
+ - Log: "Quick workflow — skipping DISCUSS.md guard"
61
+
62
+ **For all other workflows:**
63
+ - Verify DISCUSS.md exists and is confirmed.
64
+
65
+ If no DISCUSS.md found (and not quick/docs-only):
56
66
  ```
57
67
  Error: DISCUSS.md not found. Run /fd-discuss [topic] first.
58
68
  ```
59
69
 
60
- If DISCUSS.md exists but not confirmed:
70
+ If DISCUSS.md exists but not confirmed (and not quick/docs-only):
61
71
  ```
62
72
  Error: DISCUSS.md not yet confirmed. Complete the discuss phase first.
63
73
  ```
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Autonomous workflow launcher — classifies the task, selects the correct existing workflow, and runs the full stage sequence (discuss → plan → execute → verify and variants) end-to-end with minimal user input
2
+ description: Autonomous workflow launcher — classifies the task, selects the adaptive workflow class via scoring, and runs the minimal sufficient stage sequence end-to-end with minimal user input
3
3
  argument-hint: [task description]
4
4
  ---
5
5
 
@@ -86,14 +86,14 @@ question are resolved by evidence (e.g., tech stack, existing patterns, prior de
86
86
 
87
87
  ### Signal Classification Table
88
88
 
89
- | Task Type | Strong Signal Keywords | Stage Sequence |
90
- |-----------|------------------------|----------------|
91
- | **bugfix** | fix, bug, broken, not working, error, crash, regression, debug, exception, failing, root cause, why is, stack trace | `discuss → fix-bug → verify` |
92
- | **ui-feature** | landing page, dashboard, admin panel, app screen, onboarding, wireframe, design system, ux flow, web app, website, responsive layout, navbar, modal, sidebar, frontend page | `discuss → design → plan → execute → verify` |
93
- | **docs** | docs, documentation, readme, api docs, usage guide, write docs, document, changelog, tutorial, docstring | `discuss write-docs → verify` |
94
- | **simple** | rename, move file, minor, typo, update constant, update config, bump version, one-liner | `execute → verify` |
95
- | **feature** | (substantive description, 8+ words, no above signals) | `discuss plan → execute → verify` |
96
- | **ambiguous** | (short, vague, or unclear — only after exploration cannot resolve) | *(clarify via supervisor see Step 3)* |
89
+ | Task Type | Strong Signal Keywords | Workflow Class | Typical Stages |
90
+ |-----------|------------------------|----------------|----------------|
91
+ | **bugfix** | fix, bug, broken, not working, error, crash, regression, debug, exception, failing, root cause, why is, stack trace | `bugfix` | `discuss → fix-bug → verify` |
92
+ | **ui-feature** | landing page, dashboard, admin panel, app screen, onboarding, wireframe, design system, ux flow, web app, website, responsive layout, navbar, modal, sidebar, frontend page | `ui-heavy` | `discuss → design → plan → execute → verify` |
93
+ | **docs** | docs, documentation, readme, api docs, usage guide, write docs, document, changelog, tutorial, docstring | `docs-only` | `write-docs → verify` |
94
+ | **simple** | rename, move file, minor, typo, update constant, update config, bump version, one-liner | `quick` | `execute → verify` |
95
+ | **feature** | (substantive description, 8+ words, no above signals) | `standard` | `plan → execute → verify` |
96
+ | **ambiguous** | (short, vague, or unclear — only after exploration cannot resolve) | `explore` | `discuss plan execute → verify` |
97
97
 
98
98
  ### Classification Rules
99
99
 
@@ -104,6 +104,25 @@ question are resolved by evidence (e.g., tech stack, existing patterns, prior de
104
104
  5. **Feature**: substantive description (8+ words) with no specific signal type.
105
105
  6. **Ambiguous** (only when exploration cannot resolve): description is too short (<5 words) or matches a bare imperative with no object (e.g., "improve", "add", "make it better") AND repo evidence does not clarify scope or type.
106
106
 
107
+ ### Adaptive Workflow Selection
108
+
109
+ After classification, the router scores the task across multiple dimensions:
110
+ - **Simplicity** (30%): Is this a simple, focused change?
111
+ - **Confidence** (20%): How well does the description match known patterns?
112
+ - **Low Risk** (20%): Is blast radius < 3 files and no sensitive paths?
113
+ - **Known Codebase** (15%): Is the codebase mapping fresh (< 24h)?
114
+ - **Cheap Complexity** (15%): Is the task cheap (classify, validate, summarize)?
115
+
116
+ The workflow class is selected based on the total score and task type:
117
+ - Score >= 0.75 + simple/docs → `quick` workflow
118
+ - Bug signals dominate → `bugfix` workflow
119
+ - UI signals present → `ui-heavy` workflow
120
+ - Blast radius >= 5 or sensitive paths → `verify-heavy` workflow
121
+ - Confidence < 0.60 or ambiguous → `explore` workflow
122
+ - Default → `standard` workflow
123
+
124
+ The router prefers the lightest workflow that is sufficient. Escalation occurs during execution if the initial path proves insufficient.
125
+
107
126
  Record the classification result:
108
127
  ```yaml
109
128
  quick_run:
@@ -288,15 +307,23 @@ If execution cannot continue at any stage:
288
307
 
289
308
  ---
290
309
 
291
- ## Workflow Discipline (Non-Negotiable)
310
+ ## Workflow Discipline (Adaptive)
311
+
312
+ The following gates apply based on the selected workflow class:
313
+
314
+ - **Design-first**: `ui-heavy` tasks MUST complete the `design` stage before `execute`. No override unless user explicitly requests it.
315
+ - **TDD**: `execute` and `fix-bug` stages enforce RED → GREEN → REFACTOR for `standard`, `explore`, `ui-heavy`, and `verify-heavy` workflows. `quick` and `docs-only` workflows run tests after changes instead.
316
+ - **Plan CONFIRM**: The `plan` stage requires explicit user CONFIRM (for workflows that include planning).
317
+ - **Regression test**: `bugfix` requires a failing regression test before implementation.
318
+ - **Verify**: All workflows end with `/fd-verify` when code files are changed. `quick` workflows may skip verify if no code was changed.
319
+
320
+ ### Skipped Stages
292
321
 
293
- These gates from the existing workflow system are **never bypassed by /fd-quick**:
322
+ For `quick` and `docs-only` workflows, the following stages are intentionally skipped:
323
+ - `discuss` — requirements are clear from the task description
324
+ - `plan` — the task is small enough to not need a formal plan
294
325
 
295
- - **Design-first**: `ui-feature` tasks MUST complete the `design` stage (with `@design` approval and handoff) before `execute` can begin. No `--override` unless user explicitly requests it.
296
- - **TDD**: `execute` and `fix-bug` stages enforce RED → GREEN → REFACTOR. `/fd-quick` does not skip tests.
297
- - **Plan CONFIRM**: The `plan` stage requires explicit user CONFIRM. `/fd-quick` presents the plan and waits.
298
- - **Regression test**: `fix-bug` requires a failing regression test before implementation (per `/fd-fix-bug`).
299
- - **Verify**: All workflows end with `/fd-verify` to confirm all checks pass before marking complete.
326
+ Skipped stages are logged in STATE.md under `skippedStages` with the reason "lightest sufficient workflow".
300
327
 
301
328
  ---
302
329