@dv.nghiem/flowdeck 0.3.3 → 0.3.5

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 (116) hide show
  1. package/README.md +160 -8
  2. package/dist/agents/coder.d.ts +3 -1
  3. package/dist/agents/coder.d.ts.map +1 -1
  4. package/dist/agents/design.d.ts +3 -0
  5. package/dist/agents/design.d.ts.map +1 -0
  6. package/dist/agents/index.d.ts +4 -3
  7. package/dist/agents/index.d.ts.map +1 -1
  8. package/dist/agents/orchestrator.d.ts.map +1 -1
  9. package/dist/agents/reviewer.d.ts.map +1 -1
  10. package/dist/agents/specialist.d.ts +0 -1
  11. package/dist/agents/specialist.d.ts.map +1 -1
  12. package/dist/config/index.d.ts +1 -1
  13. package/dist/config/index.d.ts.map +1 -1
  14. package/dist/config/loader.d.ts +8 -0
  15. package/dist/config/loader.d.ts.map +1 -1
  16. package/dist/config/schema.d.ts +55 -2
  17. package/dist/config/schema.d.ts.map +1 -1
  18. package/dist/dashboard/server.mjs +24 -1
  19. package/dist/dashboard/types.d.ts +72 -0
  20. package/dist/dashboard/types.d.ts.map +1 -1
  21. package/dist/hooks/guard-rails.d.ts.map +1 -1
  22. package/dist/hooks/orchestrator-guard-hook.d.ts +4 -1
  23. package/dist/hooks/orchestrator-guard-hook.d.ts.map +1 -1
  24. package/dist/hooks/session-idle-hook.d.ts.map +1 -1
  25. package/dist/hooks/telemetry-hook.d.ts +14 -1
  26. package/dist/hooks/telemetry-hook.d.ts.map +1 -1
  27. package/dist/hooks/telemetry-hook.test.d.ts +2 -0
  28. package/dist/hooks/telemetry-hook.test.d.ts.map +1 -0
  29. package/dist/hooks/tool-guard.d.ts.map +1 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +810 -474
  32. package/dist/services/agent-contract-registry.d.ts +32 -0
  33. package/dist/services/agent-contract-registry.d.ts.map +1 -0
  34. package/dist/services/agent-performance.d.ts +1 -1
  35. package/dist/services/agent-performance.d.ts.map +1 -1
  36. package/dist/services/agent-trace-graph.d.ts +94 -0
  37. package/dist/services/agent-trace-graph.d.ts.map +1 -0
  38. package/dist/services/agent-validator.d.ts +56 -0
  39. package/dist/services/agent-validator.d.ts.map +1 -0
  40. package/dist/services/deadlock-detector.d.ts +34 -0
  41. package/dist/services/deadlock-detector.d.ts.map +1 -0
  42. package/dist/services/delegation-budget.d.ts +54 -0
  43. package/dist/services/delegation-budget.d.ts.map +1 -0
  44. package/dist/services/governance.test.d.ts +11 -0
  45. package/dist/services/governance.test.d.ts.map +1 -0
  46. package/dist/services/index.d.ts +6 -1
  47. package/dist/services/index.d.ts.map +1 -1
  48. package/dist/services/telemetry.d.ts +1 -1
  49. package/dist/services/telemetry.d.ts.map +1 -1
  50. package/dist/services/workflow-scorecard.d.ts +76 -0
  51. package/dist/services/workflow-scorecard.d.ts.map +1 -0
  52. package/dist/tools/council.d.ts.map +1 -1
  53. package/dist/tools/delegate.d.ts.map +1 -1
  54. package/dist/tools/dispatch-routing.d.ts +9 -0
  55. package/dist/tools/dispatch-routing.d.ts.map +1 -0
  56. package/dist/tools/dispatch-routing.test.d.ts +2 -0
  57. package/dist/tools/dispatch-routing.test.d.ts.map +1 -0
  58. package/dist/tools/planning-state-lib.d.ts +8 -0
  59. package/dist/tools/planning-state-lib.d.ts.map +1 -1
  60. package/dist/tools/planning-state.d.ts.map +1 -1
  61. package/dist/tools/run-pipeline.d.ts.map +1 -1
  62. package/docs/agents.md +104 -74
  63. package/docs/best-practices.md +1 -1
  64. package/docs/commands/fd-ask.md +2 -2
  65. package/docs/commands/fd-fix-bug.md +2 -2
  66. package/docs/commands/fd-new-feature.md +2 -2
  67. package/docs/commands/fd-quick.md +3 -1
  68. package/docs/commands.md +37 -7
  69. package/docs/configuration.md +76 -46
  70. package/docs/design-first-workflow.md +94 -0
  71. package/docs/feature-integration-architecture.md +3 -31
  72. package/docs/index.md +5 -2
  73. package/docs/installation.md +6 -17
  74. package/docs/intelligence.md +110 -34
  75. package/docs/multi-repo.md +1 -1
  76. package/docs/optimization-baseline.md +21 -0
  77. package/docs/rules.md +10 -37
  78. package/docs/skills.md +24 -15
  79. package/docs/workflows.md +18 -14
  80. package/package.json +4 -2
  81. package/src/commands/fd-ask.md +1 -0
  82. package/src/commands/fd-design.md +64 -0
  83. package/src/commands/fd-discuss.md +2 -0
  84. package/src/commands/fd-execute.md +7 -3
  85. package/src/commands/fd-fix-bug.md +2 -2
  86. package/src/commands/fd-multi-repo.md +3 -3
  87. package/src/commands/fd-plan.md +2 -0
  88. package/src/commands/fd-quick.md +4 -1
  89. package/src/commands/fd-verify.md +6 -0
  90. package/src/rules/README.md +10 -0
  91. package/src/rules/common/agent-orchestration.md +6 -6
  92. package/src/rules/common/coding-style.md +2 -2
  93. package/src/rules/typescript/patterns.md +1 -1
  94. package/src/skills/app-shell-design/SKILL.md +31 -0
  95. package/src/skills/backend-patterns/SKILL.md +6 -0
  96. package/src/skills/clean-architecture/SKILL.md +6 -0
  97. package/src/skills/cqrs/SKILL.md +6 -0
  98. package/src/skills/dashboard-design/SKILL.md +32 -0
  99. package/src/skills/ddd-architecture/SKILL.md +6 -0
  100. package/src/skills/decision-trace/SKILL.md +1 -1
  101. package/src/skills/design-audit/SKILL.md +37 -0
  102. package/src/skills/design-system-definition/SKILL.md +33 -0
  103. package/src/skills/event-driven-architecture/SKILL.md +6 -0
  104. package/src/skills/frontend-handoff/SKILL.md +31 -0
  105. package/src/skills/hexagonal-architecture/SKILL.md +6 -0
  106. package/src/skills/landing-page-design/SKILL.md +32 -0
  107. package/src/skills/layered-architecture/SKILL.md +6 -0
  108. package/src/skills/multi-repo/SKILL.md +3 -3
  109. package/src/skills/plan-task/SKILL.md +2 -2
  110. package/src/skills/postgres-patterns/SKILL.md +6 -0
  111. package/src/skills/responsive-review/SKILL.md +31 -0
  112. package/src/skills/saga-architecture/SKILL.md +6 -0
  113. package/src/skills/ui-ux-planning/SKILL.md +32 -0
  114. package/src/skills/wireframe-planning/SKILL.md +30 -0
  115. package/dist/services/model-router.d.ts +0 -35
  116. package/dist/services/model-router.d.ts.map +0 -1
@@ -147,9 +147,9 @@ Each FlowDeck project stores its settings in `.planning/config.json`. This file
147
147
 
148
148
  ---
149
149
 
150
- ## flowdeck.json (Agent Model Overrides)
150
+ ## flowdeck.json (Agent and Governance Config)
151
151
 
152
- The `flowdeck.json` file lets you assign specific AI models to individual FlowDeck agents. This is useful when you want the `@planner` to use a more capable model while lighter agents like `@tester` use a faster, cheaper one.
152
+ The `flowdeck.json` file controls two things: per-agent model overrides and the governance layer. **No model is hardcoded** if an agent is not listed, it uses whatever model is currently selected in OpenCode.
153
153
 
154
154
  ### Locations
155
155
 
@@ -160,7 +160,7 @@ The `flowdeck.json` file lets you assign specific AI models to individual FlowDe
160
160
 
161
161
  Project config takes precedence over global config.
162
162
 
163
- ### Schema
163
+ ### Full schema
164
164
 
165
165
  ```json
166
166
  {
@@ -168,61 +168,91 @@ Project config takes precedence over global config.
168
168
  "<agent-name>": {
169
169
  "model": "<provider>/<model-id>"
170
170
  }
171
+ },
172
+ "designFirst": {
173
+ "enabled": true,
174
+ "enforcement": "strict",
175
+ "requireApprovalBeforeImplementation": true,
176
+ "modelOverrides": {
177
+ "design": "anthropic/claude-sonnet-4"
178
+ },
179
+ "defaultSkillsByTaskType": {
180
+ "landing-page": ["landing-page-design", "wireframe-planning", "design-system-definition", "frontend-handoff"]
181
+ }
182
+ },
183
+ "governance": {
184
+ "validator": {
185
+ "mode": "advisory"
186
+ },
187
+ "delegationBudget": {
188
+ "maxToolCalls": 200,
189
+ "maxDelegatedAgents": 30,
190
+ "maxRetries": 10,
191
+ "maxDepth": 8,
192
+ "maxSameStepRetries": 3
193
+ },
194
+ "deadlockDetection": {
195
+ "enabled": true,
196
+ "bounceThreshold": 3,
197
+ "stageStallMinutes": 30,
198
+ "autoStop": false
199
+ },
200
+ "scorecard": {
201
+ "enabled": true
202
+ }
171
203
  }
172
204
  }
173
205
  ```
174
206
 
175
- ### Supported Agents
176
-
177
- | Agent | Default Model | Override Example |
178
- |-------|--------------|-----------------|
179
- | `@architect` | `claude-opus-4-5` | `anthropic/claude-opus-4-5` |
180
- | `@build-error-resolver` | `claude-sonnet-4-5` | `anthropic/claude-sonnet-4-5` |
181
- | `@code-explorer` | `claude-haiku-4-5` | `anthropic/claude-haiku-4-5` |
182
- | `@coder` | `claude-opus-4-5` | `anthropic/claude-opus-4-5` |
183
- | `@debug-specialist` | `claude-sonnet-4-5` | `anthropic/claude-sonnet-4-5` |
184
- | `@discusser` | `claude-sonnet-4-5` | `anthropic/claude-sonnet-4-5` |
185
- | `@doc-updater` | `claude-sonnet-4-5` | `anthropic/claude-sonnet-4-5` |
186
- | `@orchestrator` | `claude-sonnet-4-5` | `anthropic/claude-sonnet-4-5` |
187
- | `@plan-checker` | `claude-sonnet-4-5` | `anthropic/claude-sonnet-4-5` |
188
- | `@planner` | `claude-sonnet-4-5` | `anthropic/claude-sonnet-4-5` |
189
- | `@mapper` | `gemini-2.5-flash` | `google/gemini-2.5-flash` |
190
- | `@multi-repo-coordinator` | `claude-sonnet-4-5` | `anthropic/claude-sonnet-4-5` |
191
- | `@orchestrator` | `claude-sonnet-4-5` | `anthropic/claude-sonnet-4-5` |
192
- | `@parallel-coordinator` | `claude-sonnet-4-5` | `anthropic/claude-sonnet-4-5` |
193
- | `@performance-optimizer` | `claude-sonnet-4-5` | `anthropic/claude-sonnet-4-5` |
194
- | `@planner` | `claude-opus-4-5` | `anthropic/claude-opus-4-5` |
195
- | `@refactor-guide` | `claude-sonnet-4-5` | `anthropic/claude-sonnet-4-5` |
196
- | `@researcher` | `gpt-4o` | `openai/gpt-4o` |
197
- | `@reviewer` | `gemini-2.5-flash` | `google/gemini-2.5-flash` |
198
- | `@security-auditor` | `claude-sonnet-4-5` | `anthropic/claude-sonnet-4-5` |
199
- | `@task-splitter` | `claude-sonnet-4-5` | `anthropic/claude-sonnet-4-5` |
200
- | `@tester` | `claude-haiku-4-5` | `anthropic/claude-haiku-4-5` |
201
- | `@writer` | `claude-haiku-4-5` | `anthropic/claude-haiku-4-5` |
202
-
203
- ### Example
207
+ ### Agent model overrides
208
+
209
+ All agents default to the model currently selected in OpenCode. Only list agents you want to override:
204
210
 
205
211
  ```json
206
212
  {
207
213
  "agents": {
208
- "planner": {
209
- "model": "anthropic/claude-opus-4-5"
210
- },
211
- "orchestrator": {
212
- "model": "anthropic/claude-sonnet-4-5"
213
- },
214
- "tester": {
215
- "model": "anthropic/claude-haiku-4-5"
216
- }
214
+ "planner": { "model": "anthropic/claude-opus-4" },
215
+ "orchestrator": { "model": "anthropic/claude-sonnet-4" },
216
+ "tester": { "model": "openai/gpt-4o-mini" },
217
+ "reviewer": { "model": "google/gemini-2.5-flash" }
217
218
  }
218
219
  }
219
220
  ```
220
221
 
221
- ### Notes
222
-
223
- - If an agent is not listed in `agents`, it uses the model currently selected in OpenCode.
224
- - Only list agents you want to override — omitted agents inherit the session default.
225
- - Model strings must match the format `provider/model-id` (e.g., `anthropic/claude-sonnet-4-5`).
222
+ Model strings must use the format `provider/model-id`. Common examples:
223
+
224
+ | Provider | Example model string |
225
+ |----------|---------------------|
226
+ | Anthropic | `anthropic/claude-opus-4`, `anthropic/claude-sonnet-4`, `anthropic/claude-haiku-4` |
227
+ | OpenAI | `openai/gpt-4o`, `openai/gpt-4o-mini` |
228
+ | Google | `google/gemini-2.5-flash`, `google/gemini-2.5-pro` |
229
+ | GitHub Copilot | `github-copilot/sonnet-4.6` |
230
+ | Minimax | `minimax/minimax-m2.7-highspeed` |
231
+
232
+ Agents with no entry in `agents` inherit the session model selected in OpenCode's model picker.
233
+
234
+ ### Governance config
235
+
236
+ | Field | Default | Description |
237
+ |-------|---------|-------------|
238
+ | `governance.validator.mode` | `"advisory"` | `"off"` — disabled; `"advisory"` — warn but never block; `"strict"` — block on contract violations |
239
+ | `governance.delegationBudget.maxToolCalls` | `200` | Total tool calls allowed per workflow run before escalation |
240
+ | `governance.delegationBudget.maxDelegatedAgents` | `30` | Maximum number of sub-agent delegations per run |
241
+ | `governance.delegationBudget.maxRetries` | `10` | Total retries allowed across all steps |
242
+ | `governance.delegationBudget.maxDepth` | `8` | Maximum delegation nesting depth |
243
+ | `governance.delegationBudget.maxSameStepRetries` | `3` | Retries allowed on a single failing step before escalation |
244
+ | `governance.deadlockDetection.enabled` | `true` | Enable deadlock and loop detection |
245
+ | `governance.deadlockDetection.bounceThreshold` | `3` | Agent-pair invocations before bounce is flagged |
246
+ | `governance.deadlockDetection.stageStallMinutes` | `30` | Minutes without stage progress before stall is flagged |
247
+ | `governance.deadlockDetection.autoStop` | `false` | Stop automatically on detection; `false` emits warning only |
248
+ | `governance.scorecard.enabled` | `true` | Generate a quality scorecard after every run |
249
+
250
+ ### Design-first defaults
251
+
252
+ - `designFirst.enabled`: defaults to `true`
253
+ - `designFirst.enforcement`: defaults to `strict` (`advisory` supported)
254
+ - `designFirst.requireApprovalBeforeImplementation`: defaults to `true`
255
+ - UI-heavy tasks are blocked from implementation until design handoff is approved, unless explicit override is recorded.
226
256
 
227
257
  ---
228
258
 
@@ -0,0 +1,94 @@
1
+ # Design-First Workflow
2
+
3
+ FlowDeck enforces a design-first path for UI-heavy tasks by default.
4
+
5
+ ## Trigger Conditions
6
+
7
+ Design-first is triggered when tasks mention user-facing work such as:
8
+ - landing page
9
+ - dashboard
10
+ - admin panel
11
+ - website redesign
12
+ - onboarding UX
13
+ - app screen/mobile UI
14
+
15
+ Backend-only or infra-only tasks skip design-first.
16
+
17
+ ## Workflow
18
+
19
+ ```text
20
+ task intake
21
+ → task classification
22
+ → design discovery
23
+ → UX structure
24
+ → wireframe/layout planning
25
+ → visual system definition
26
+ → design review/approval
27
+ → implementation handoff
28
+ → frontend implementation
29
+ → QA/review
30
+ ```
31
+
32
+ ## Commands
33
+
34
+ - `/fd-design --mode=draft`: produce design artifact and handoff
35
+ - `/fd-design --mode=review`: compare implementation to approved design artifact
36
+ - `/fd-design --mode=system`: create/update token and component consistency guidance
37
+
38
+ ## Design Artifact Schema
39
+
40
+ Each design run should persist:
41
+ - `task_type`
42
+ - `user_goals`
43
+ - `target_audience`
44
+ - `core_user_flows`
45
+ - `page_map_or_screen_map`
46
+ - `section_structure`
47
+ - `layout_plan`
48
+ - `component_list`
49
+ - `state_list`
50
+ - `responsive_behavior_notes`
51
+ - `visual_direction`
52
+ - `design_tokens_guidance`
53
+ - `accessibility_notes`
54
+ - `implementation_handoff_checklist`
55
+ - `approval_status`
56
+
57
+ ## Example: Landing Page
58
+
59
+ ```yaml
60
+ task_type: landing-page
61
+ user_goals:
62
+ - understand value in <10 seconds
63
+ - complete signup CTA
64
+ core_user_flows:
65
+ - hero -> social-proof -> pricing -> CTA
66
+ layout_plan:
67
+ - hero_section: headline, subheadline, primary_cta, secondary_cta
68
+ - proof_section: logos, testimonials
69
+ - pricing_section: tier_cards, comparison_table
70
+ state_list: [loading, empty, error, success]
71
+ approval_status: approved
72
+ ```
73
+
74
+ ## Example: App Screen Redesign
75
+
76
+ ```yaml
77
+ task_type: app-screen
78
+ target_audience:
79
+ - returning mobile users
80
+ core_user_flows:
81
+ - home -> quick-action -> detail -> completion
82
+ section_structure:
83
+ - top_nav
84
+ - summary_cards
85
+ - task_list
86
+ - persistent_action_bar
87
+ responsive_behavior_notes:
88
+ - compact_nav_on_small_screens
89
+ - collapse_secondary_panels_under_768
90
+ design_tokens_guidance:
91
+ - spacing_scale: [4, 8, 12, 16, 24, 32]
92
+ - text_scale: [12, 14, 16, 20, 24]
93
+ approval_status: approved
94
+ ```
@@ -11,7 +11,7 @@ This layer adds 8 capabilities behind the existing command architecture without
11
11
  | Capability | Implementation | Data File |
12
12
  |---|---|---|
13
13
  | Patch Trust Engine | `src/hooks/patch-trust.ts` | `.codebase/DECISIONS.jsonl` |
14
- | Adaptive Model Router | `src/services/model-router.ts` | `.codebase/MODEL_ROUTER.json` |
14
+ | Agent Performance Memory | `src/services/agent-performance.ts` | `.codebase/AGENT_PERF.json` |
15
15
  | Approval-Aware Execution | `src/services/approval-manager.ts` + `src/hooks/approval-hook.ts` | `.codebase/APPROVALS.json` |
16
16
  | Workflow Replay + Diff | `src/services/run-trace.ts` | `.codebase/RUNS.jsonl` |
17
17
  | Agent Performance Memory | `src/services/agent-performance.ts` | `.codebase/AGENT_PERF.json` |
@@ -63,27 +63,6 @@ isSensitivePath(filePath) → boolean
63
63
 
64
64
  **Approval TTL:** 30 minutes. Sensitive path patterns: auth, payment, secrets, migrations, infra, production config.
65
65
 
66
- ### model-router.ts
67
- Routes task types to the best available model.
68
-
69
- ```typescript
70
- routeModel(dir, task_type, risk_score?) → RoutedModel
71
- buildAgentConfig(dir, agents) → AgentConfig[]
72
- getRouterConfig(dir) → ModelRouterConfig
73
- ```
74
-
75
- **Default routing:**
76
- | Task | Primary | High-Risk Override |
77
- |---|---|---|
78
- | planning | claude-sonnet-4-5 | — |
79
- | implementation | claude-opus-4-5 | claude-opus-4-5 |
80
- | debugging | claude-sonnet-4-5 | claude-opus-4-5 |
81
- | review | gemini-2.5-flash | — |
82
- | testing | claude-haiku-4-5 | — |
83
- | security | claude-opus-4-5 | claude-opus-4-5 |
84
-
85
- Override by creating `.codebase/MODEL_ROUTER.json` with `{ "task_type": { "primary": "model-name" } }`.
86
-
87
66
  ### agent-performance.ts
88
67
  Tracks success rates, costs, and durations per agent+model+task combination.
89
68
 
@@ -94,7 +73,7 @@ getBestAgentForTask(dir, task_type) → AgentRecommendation | null
94
73
  getAgentLeaderboard(dir) → AgentRecommendation[]
95
74
  ```
96
75
 
97
- Requires ≥ 3 runs per combination before making routing recommendations.
76
+ Requires ≥ 3 runs per combination before making routing recommendations. Model is tracked from the actual call — no hardcoded model list.
98
77
 
99
78
  ---
100
79
 
@@ -122,7 +101,6 @@ Emits `tool.call` events for all tool invocations. Lightweight — never blocks.
122
101
 
123
102
  ### /fd-new-feature
124
103
  - Calls `startTrace()` on entry → `run_id` included in config
125
- - Calls `buildAgentConfig()` from model-router → no hardcoded models
126
104
  - Emits `command.start` telemetry event with risk score and phase
127
105
 
128
106
  ### /fd-fix-bug
@@ -175,12 +153,7 @@ The dashboard at `http://localhost:<port>` now includes:
175
153
 
176
154
  ### AGENT_PERF.json
177
155
  ```json
178
- {"entries":[{"agent":"coder","model":"claude-opus-4-5","task_type":"implementation","runs":12,"successes":11,"failures":1,"total_duration_ms":60000,"total_cost":0.48,"last_run":"ISO","last_status":"success"}],"updated_at":"ISO"}
179
- ```
180
-
181
- ### MODEL_ROUTER.json (optional override)
182
- ```json
183
- {"implementation":{"primary":"claude-sonnet-4-5","temperature":0.2},"review":{"primary":"claude-haiku-4-5"}}
156
+ {"entries":[{"agent":"backend-coder","model":"<user-configured>","task_type":"implementation","runs":12,"successes":11,"failures":1,"total_duration_ms":60000,"total_cost":0.48,"last_run":"ISO","last_status":"success"}],"updated_at":"ISO"}
184
157
  ```
185
158
 
186
159
  ---
@@ -189,7 +162,6 @@ The dashboard at `http://localhost:<port>` now includes:
189
162
 
190
163
  No new required config. Optional per-repo overrides:
191
164
 
192
- - `.codebase/MODEL_ROUTER.json` — override model routing per task type
193
165
  - `.codebase/POLICIES.json` — runtime policy rules (existing, enhanced)
194
166
  - `.codebase/CONSTRAINTS.md` — architectural constraints (existing)
195
167
 
package/docs/index.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # FlowDeck Documentation
2
2
 
3
- FlowDeck is an OpenCode plugin that brings structured, multi-agent workflow orchestration to your development sessions. It coordinates specialist agents through a four-phase cycle — discuss, plan, execute, review — with persistent state stored in your project's `.planning/` directory.
3
+ FlowDeck is an OpenCode plugin that brings structured, multi-agent workflow orchestration to your development sessions. It coordinates specialist agents through a gated workflow — discuss, plan, design (UI-heavy), execute, review — with persistent state stored in your project's `.planning/` directory.
4
4
 
5
5
  ---
6
6
 
@@ -18,12 +18,14 @@ FlowDeck is an OpenCode plugin that brings structured, multi-agent workflow orch
18
18
 
19
19
  | Document | Description |
20
20
  |----------|-------------|
21
- | [Agents](agents.md) | All specialist agents — names, roles, models, and when to invoke each one |
21
+ | [Agents](agents.md) | All specialist agents — names, roles, and when to invoke each one |
22
22
  | [Skills](skills.md) | Reusable skill patterns for common tasks |
23
23
  | [Commands](commands.md) | All 18 slash commands — syntax, arguments, and what each command triggers |
24
24
  | [Workflows](workflows.md) | Built-in workflows for common scenarios |
25
+ | [Design-First Workflow](design-first-workflow.md) | UI-heavy workflow gates from design discovery to implementation handoff |
25
26
  | [Rules](rules.md) | Language and common rule files — what they enforce and how to activate them |
26
27
  | [Intelligence Features](intelligence.md) | AI-safety features for pre-change analysis and risk assessment |
28
+ | [Governance Layer](configuration.md#governance-config) | Agent contracts, validator, trace graph, budget, deadlock detection, and scorecards |
27
29
  | [Memory System](memory.md) | Persistent memory — recall past sessions, tool executions, and context across sessions |
28
30
 
29
31
  ---
@@ -53,6 +55,7 @@ FlowDeck is an OpenCode plugin that brings structured, multi-agent workflow orch
53
55
  | `/fd-new-project <name>` | Initialize project with planning structure and default config |
54
56
  | `/fd-discuss <topic>` | Run structured requirements Q&A to capture decisions |
55
57
  | `/fd-plan [--phase=N]` | Generate implementation plan from decisions (requires CONFIRM) |
58
+ | `/fd-design [--mode=draft\|review\|system]` | Run design-first planning and UI fidelity review for UI-heavy tasks |
56
59
  | `/fd-new-feature "<description>"` | Execute full feature workflow with TDD discipline |
57
60
  | `/fd-fix-bug "<description>"` | Diagnose and fix a bug with regression test |
58
61
  | `/fd-deploy-check [--check=deploy,review,analysis]` | Pre-deploy checks, code review, or pre-change analysis |
@@ -20,7 +20,7 @@ If OpenCode is not yet installed, follow the [OpenCode installation guide](https
20
20
 
21
21
  ## Method 1: curl (recommended)
22
22
 
23
- The install script downloads the latest release, copies all agents, skills, commands, and workflows to `~/.config/opencode/`, and registers `@dv.nghiem/flowdeck` as a plugin in `opencode.json`.
23
+ The install script registers `@dv.nghiem/flowdeck` as a plugin in `opencode.json` and sets `orchestrator` as default agent when missing.
24
24
 
25
25
  ```bash
26
26
  curl -fsSL https://raw.githubusercontent.com/DVNghiem/flowdeck/main/install.sh | bash
@@ -29,11 +29,9 @@ curl -fsSL https://raw.githubusercontent.com/DVNghiem/flowdeck/main/install.sh |
29
29
  What the script does:
30
30
 
31
31
  1. Detects your config directory (`$OPENCODE_CONFIG_DIR` or `~/.config/opencode`)
32
- 2. Copies `agents/*.md` → `~/.config/opencode/agent/` (markdown agents for OpenCode compatibility)
33
- 3. Compiles TypeScript agents from `src/agents/` `dist/agents/` (for plugin-based loading)
34
- 4. Copies `skills/*/` `~/.config/opencode/skills/`
35
- 5. Registers `@dv.nghiem/flowdeck` as a plugin in `opencode.json`
36
- 6. Sets `orchestrator` as the default agent
32
+ 2. Creates the config directory if needed
33
+ 3. Registers `@dv.nghiem/flowdeck` as a plugin in `opencode.json` if not present
34
+ 4. Sets `orchestrator` as the default agent if not already configured
37
35
 
38
36
  ---
39
37
 
@@ -59,18 +57,9 @@ Steps explained:
59
57
 
60
58
  ## Verification
61
59
 
62
- After any install method, run these commands to confirm everything landed correctly:
60
+ After any install method, run these commands to confirm registration:
63
61
 
64
62
  ```bash
65
- # Should print 23 or more
66
- ls ~/.config/opencode/agent/ | grep -c "\.md"
67
-
68
- # Should list 24 or more directories
69
- ls ~/.config/opencode/skills/
70
-
71
- # Should list 16 or more files
72
- ls ~/.config/opencode/command/
73
-
74
63
  # Should print @dv.nghiem/flowdeck
75
64
  cat ~/.config/opencode/opencode.json | grep flowdeck
76
65
  ```
@@ -81,7 +70,7 @@ Expected output for the last command:
81
70
  "@dv.nghiem/flowdeck"
82
71
  ```
83
72
 
84
- If any count is lower than expected, re-run the install command. If the `opencode.json` line is missing, the plugin will not load — add it manually (see [Configuration](configuration.md)).
73
+ If the `opencode.json` line is missing, the plugin will not load — add it manually (see [Configuration](configuration.md)).
85
74
 
86
75
  ---
87
76
 
@@ -8,19 +8,19 @@ FlowDeck's intelligence layer adds safety-first AI editing, persistent architect
8
8
 
9
9
  | Feature | Command / Hook | Storage |
10
10
  |---------|---------------|---------|
11
- | Change Impact Radar | `/fd-impact-radar` | VOLATILITY.json, MEMORY.json |
11
+ | Change Impact Radar | Integrated analysis workflow | VOLATILITY.json, MEMORY.json |
12
12
  | Patch Trust Score | Hook (automatic) | VOLATILITY.json, FAILURES.json |
13
- | Blast Radius Preview | `/fd-blast-radius` | MEMORY.json, FAILURES.json |
13
+ | Blast Radius Preview | Integrated analysis workflow | MEMORY.json, FAILURES.json |
14
14
  | Repo Memory Graph | `repo-memory` tool | `.codebase/MEMORY.json` |
15
15
  | Failure Replay Engine | `failure-replay` tool | `.codebase/FAILURES.json` |
16
16
  | Safe Execution Modes | Hook (automatic) | `.planning/config.json` |
17
- | Test Gap Detector | `/fd-test-gap` | VOLATILITY.json |
17
+ | Test Gap Detector | Integrated analysis workflow | VOLATILITY.json |
18
18
  | Architectural Constraint Guard | Hook (automatic) | `.codebase/CONSTRAINTS.md` |
19
19
  | Intent-to-Change Translator | `/fd-translate-intent` | — |
20
20
  | Confidence-Aware Planning | Skill | — |
21
- | Codebase Volatility Map | `/fd-volatility-map`, `volatility-map` tool | `.codebase/VOLATILITY.json` |
22
- | Human Review Routing | `/fd-review-route` | VOLATILITY.json, FAILURES.json |
23
- | Regression Prediction | `/fd-regression-predict` | — |
21
+ | Codebase Volatility Map | `volatility-map` tool | `.codebase/VOLATILITY.json` |
22
+ | Human Review Routing | Integrated analysis workflow | VOLATILITY.json, FAILURES.json |
23
+ | Regression Prediction | Integrated analysis workflow | — |
24
24
  | Decision Trace | `decision-trace` tool + hook | `.codebase/DECISIONS.jsonl` |
25
25
  | Self-Healing Policies | `policy-engine` tool | `.codebase/POLICIES.json` |
26
26
 
@@ -28,14 +28,11 @@ FlowDeck's intelligence layer adds safety-first AI editing, persistent architect
28
28
 
29
29
  ## Slash Commands
30
30
 
31
- ### `/fd-impact-radar`
31
+ ### Change Impact Radar
32
32
 
33
33
  Predicts which files, modules, APIs, tests, and database paths are likely to be affected before the AI edits anything.
34
34
 
35
- ```
36
- /fd-impact-radar --change "refactor auth token handling" --scope all
37
- /fd-impact-radar --change "drop users table" --json
38
- ```
35
+ Use `/fd-suggest` or `/fd-translate-intent` when you need pre-change analysis with impact context.
39
36
 
40
37
  **Arguments:**
41
38
  - `--change` — describe the proposed change (free text)
@@ -46,13 +43,11 @@ Predicts which files, modules, APIs, tests, and database paths are likely to be
46
43
 
47
44
  ---
48
45
 
49
- ### `/fd-blast-radius`
46
+ ### Blast Radius Preview
50
47
 
51
48
  Shows the likely downstream consequences of a proposed change — hidden dependencies, fragile integration points, and predicted test breakages.
52
49
 
53
- ```
54
- /fd-blast-radius --change "delete legacy session table" --depth 3
55
- ```
50
+ Use `/fd-suggest` for broad risk discovery and `/fd-deploy-check` before release changes.
56
51
 
57
52
  **Arguments:**
58
53
  - `--change` — describe the proposed change
@@ -78,14 +73,11 @@ Converts a vague request like "make checkout faster" into concrete, ranked imple
78
73
 
79
74
  ---
80
75
 
81
- ### `/fd-volatility-map`
76
+ ### Volatility Map
82
77
 
83
78
  Displays the Codebase Volatility Map — highlights unstable zones based on churn, hotfix frequency, and unresolved TODO clusters.
84
79
 
85
- ```
86
- /fd-volatility-map
87
- /fd-volatility-map --threshold volatile --limit 10
88
- ```
80
+ Use the `volatility-map` tool directly from delegated agents for incremental updates.
89
81
 
90
82
  **Arguments:**
91
83
  - `--threshold` — minimum stability level to show: `stable`, `moderate`, `volatile` (default), `critical`
@@ -96,13 +88,11 @@ Displays the Codebase Volatility Map — highlights unstable zones based on chur
96
88
 
97
89
  ---
98
90
 
99
- ### `/fd-regression-predict`
91
+ ### Regression Prediction
100
92
 
101
93
  Estimates the most likely regression categories for a change — performance, auth, schema, UI states, async flows, etc.
102
94
 
103
- ```
104
- /fd-regression-predict --change "add webhook retry logic" --categories all
105
- ```
95
+ FlowDeck derives regression risk from historical failures plus volatility data during analysis-oriented workflows.
106
96
 
107
97
  **Arguments:**
108
98
  - `--change` — describe the proposed change
@@ -111,14 +101,11 @@ Estimates the most likely regression categories for a change — performance, au
111
101
 
112
102
  ---
113
103
 
114
- ### `/fd-test-gap`
104
+ ### Test Gap Detector
115
105
 
116
106
  Identifies which areas of a proposed change are weakly covered by tests, and suggests the minimum high-value tests to add first.
117
107
 
118
- ```
119
- /fd-test-gap --change "add payment webhook handler"
120
- /fd-test-gap --change "update user schema" --scope unit
121
- ```
108
+ Use `/fd-verify` and `/fd-deploy-check` for current test-gap surfacing in production workflows.
122
109
 
123
110
  **Arguments:**
124
111
  - `--change` — describe the proposed change
@@ -127,13 +114,11 @@ Identifies which areas of a proposed change are weakly covered by tests, and sug
127
114
 
128
115
  ---
129
116
 
130
- ### `/fd-review-route`
117
+ ### Human Review Routing
131
118
 
132
119
  Routes risky patches to the right reviewer type — security, backend, infra, domain-owner, frontend, data, or devops — based on the file paths and change description.
133
120
 
134
- ```
135
- /fd-review-route --files "src/auth/token.ts,src/api/routes.ts" --change "new JWT rotation logic"
136
- ```
121
+ Routing to reviewer profiles is integrated into verification and deployment checks.
137
122
 
138
123
  **Arguments:**
139
124
  - `--files` — comma-separated file paths being changed
@@ -267,12 +252,103 @@ Manages `.codebase/POLICIES.json` — self-healing editing rules that update aft
267
252
  | `VOLATILITY.json` | JSON | Per-file churn and stability metrics |
268
253
  | `POLICIES.json` | JSON | Self-healing editing rule set |
269
254
  | `CONSTRAINTS.md` | Markdown | Forbidden path list for Arch Constraint Guard |
255
+ | `AGENT_SPANS.jsonl` | Newline-delimited JSON | Inter-agent trace graph (governance) |
256
+ | `BUDGETS.json` | JSON | Per-run delegation budget state (governance) |
257
+ | `DEADLOCK_SIGNALS.jsonl` | Newline-delimited JSON | Detected loops and deadlocks (governance) |
258
+ | `SCORECARDS.jsonl` | Newline-delimited JSON | 10-dimension workflow quality scores (governance) |
270
259
 
271
260
  > **Tip:** All `.codebase/` files should be committed to version control so the intelligence layer improves over time.
272
261
 
273
262
  ---
274
263
 
275
- ## Skills
264
+ ## Governance Layer
265
+
266
+ The governance layer makes multi-agent execution trustworthy and debuggable. It runs automatically as internal runtime services — no commands or manual wiring needed.
267
+
268
+ ### Agent Contracts
269
+
270
+ Every major agent has an explicit contract defining:
271
+
272
+ - **Allowed tools** — tools the agent may invoke
273
+ - **Forbidden actions** — things the agent must never do (e.g. `@reviewer` may not write files)
274
+ - **Required inputs** — what context must be present before the agent runs
275
+ - **Escalation conditions** — when to surface to human review
276
+ - **Success criteria** — what a good output looks like
277
+
278
+ Contracts are defined in `src/services/agent-contract-registry.ts` and cover: orchestrator, planner, plan-checker, design, backend-coder, frontend-coder, devops, tester, reviewer, security-auditor, researcher, architect, writer, and doc-updater.
279
+
280
+ ### Agent Validator
281
+
282
+ Before and after each agent invocation, the validator checks the execution context against the agent's contract. Configure the enforcement mode in `flowdeck.json`:
283
+
284
+ | Mode | Behaviour |
285
+ |------|-----------|
286
+ | `off` | Validation disabled |
287
+ | `advisory` | Validate and warn; never block execution (default) |
288
+ | `strict` | Block on contract violations of severity `block` |
289
+
290
+ Violations are emitted as `contract.violation` telemetry events and attached to the agent span.
291
+
292
+ ### Inter-Agent Trace Graph
293
+
294
+ Every delegation opens a **span** in the trace graph. Spans record:
295
+
296
+ - Invoker → agent direction
297
+ - Trace ID and parent span ID (causal chain)
298
+ - Tools used and outputs
299
+ - Contract violations attached to the span
300
+ - Latency and delegation depth
301
+
302
+ Spans are stored in `.codebase/AGENT_SPANS.jsonl`. The trace graph is dashboard-ready and can be rendered as a timeline, causality graph, or per-agent drilldown.
303
+
304
+ ### Delegation Budget
305
+
306
+ Each workflow run has a budget tracked in `.codebase/BUDGETS.json`:
307
+
308
+ | Limit | Default | Config key |
309
+ |-------|---------|------------|
310
+ | Max tool calls | 200 | `governance.delegationBudget.maxToolCalls` |
311
+ | Max delegated agents | 30 | `governance.delegationBudget.maxDelegatedAgents` |
312
+ | Max retries (total) | 10 | `governance.delegationBudget.maxRetries` |
313
+ | Max delegation depth | 8 | `governance.delegationBudget.maxDepth` |
314
+ | Max retries per step | 3 | `governance.delegationBudget.maxSameStepRetries` |
315
+
316
+ When a limit is exceeded the system escalates to human review or (if `autoStop: true`) stops safely and summarises what was completed.
317
+
318
+ ### Deadlock and Loop Detector
319
+
320
+ The detector runs four independent pattern checks after each agent invocation:
321
+
322
+ | Pattern | Trigger |
323
+ |---------|---------|
324
+ | `agent_bounce` | Same agent pair invoked ≥ N times without resolution |
325
+ | `step_retry_loop` | Same stage retried beyond the per-step limit |
326
+ | `circular_delegation` | DFS detects a cycle in the delegation graph — always triggers `auto_stop` |
327
+ | `stage_stall` | Workflow stage makes no progress within the stall window |
328
+
329
+ Signals are written to `.codebase/DEADLOCK_SIGNALS.jsonl`. Duplicate signals for the same trace and pattern are suppressed. A recovery action recommendation is attached to each signal.
330
+
331
+ ### Workflow Scorecard
332
+
333
+ After every completed or failed run, a scorecard is generated and appended to `.codebase/SCORECARDS.jsonl`. Ten dimensions are scored and combined into a weighted 0–100 score:
334
+
335
+ | Dimension | Weight |
336
+ |-----------|--------|
337
+ | Stage compliance | 15% |
338
+ | TDD compliance | 15% |
339
+ | Design-first compliance | 10% |
340
+ | Approval compliance | 10% |
341
+ | Review quality | 10% |
342
+ | Handoff quality | 10% |
343
+ | Budget efficiency | 10% |
344
+ | Tool reliability | 10% |
345
+ | Policy compliance | 5% |
346
+ | Override frequency | 5% |
347
+
348
+ Scorecards support trend analysis over time. Use `getScorecardTrend(dir, command)` and `computeAverageScore(dir)` from `src/services/workflow-scorecard.ts` to query them programmatically.
349
+
350
+ ---
351
+
276
352
 
277
353
  Each intelligence feature also has a corresponding skill that gives the OpenCode agent detailed workflow instructions. Skills are installed automatically by `install.sh`.
278
354
 
@@ -180,7 +180,7 @@ The `multi-repo-flow` workflow orchestrates the full end-to-end process:
180
180
  1. **Analyze** — `@code-explorer` runs in each registered repo and builds a combined dependency graph
181
181
  2. **Classify** — `@multi-repo-coordinator` identifies which changes are breaking vs non-breaking and determines service change order
182
182
  3. **Plan** — produces a CHANGE PLAN per repo in dependency order
183
- 4. **Execute** — `@coder` is invoked per repo in order; `@tester` runs per repo in parallel with `@coder` (using that repo's test suite)
183
+ 4. **Execute** — role-routed implementation agent (`@backend-coder`/`@frontend-coder`/`@devops`) is invoked per repo in order; `@tester` runs per repo in parallel with the selected implementation agent (using that repo's test suite)
184
184
  5. **Verify** — `@reviewer` and `@security-auditor` run per repo after implementation; integration tests are run across the full service mesh in staging before any production rollout
185
185
 
186
186
  Each step produces output files in `.planning/fd-multi-repo/` so the entire process is auditable.
@@ -0,0 +1,21 @@
1
+ # FlowDeck Optimization Baseline
2
+
3
+ Captured on 2026-05-07 before deep optimization implementation.
4
+
5
+ ## Dispatch Baseline
6
+
7
+ - Command: `bun test src/tools/agent-dispatch.test.ts`
8
+ - Result: 8 passing, 0 failing
9
+ - Suite runtime (bun): 135ms
10
+ - Wall clock runtime: 0.17s
11
+
12
+ ## Observability Baseline
13
+
14
+ - `.codebase/` does not exist yet in a clean repo checkout.
15
+ - Telemetry hooks emitted `status: "ok"` for all tool completions and did not classify failures.
16
+ - Session/run IDs defaulted to `session-0` and `run-0` when runtime env variables were not set.
17
+
18
+ ## Routing and Cost Baseline
19
+
20
+ - Dispatch tools did not call model routing or agent performance tracking.
21
+ - `src/services/model-router.ts` and `src/services/agent-performance.ts` were present but not wired into `delegate`/`run-pipeline`.