@dv.nghiem/flowdeck 0.3.9 → 0.4.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 (124) hide show
  1. package/README.md +13 -21
  2. package/dist/agents/code-explorer.d.ts.map +1 -1
  3. package/dist/agents/mapper.d.ts.map +1 -1
  4. package/dist/agents/orchestrator.d.ts.map +1 -1
  5. package/dist/agents/planner.d.ts.map +1 -1
  6. package/dist/agents/specialist.d.ts.map +1 -1
  7. package/dist/dashboard/server.mjs +12 -2
  8. package/dist/hooks/compaction-hook.d.ts +1 -2
  9. package/dist/hooks/compaction-hook.d.ts.map +1 -1
  10. package/dist/hooks/file-tracker.d.ts +6 -0
  11. package/dist/hooks/file-tracker.d.ts.map +1 -1
  12. package/dist/hooks/notifications.d.ts.map +1 -1
  13. package/dist/hooks/session-start.d.ts.map +1 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +742 -794
  16. package/dist/lib/completion-validator.d.ts +51 -0
  17. package/dist/lib/completion-validator.d.ts.map +1 -0
  18. package/dist/lib/recommended-question.d.ts +24 -0
  19. package/dist/lib/recommended-question.d.ts.map +1 -0
  20. package/dist/lib/research-gate.d.ts +97 -0
  21. package/dist/lib/research-gate.d.ts.map +1 -0
  22. package/dist/lib/research-gate.test.d.ts +2 -0
  23. package/dist/lib/research-gate.test.d.ts.map +1 -0
  24. package/dist/mcp/index.d.ts +12 -2
  25. package/dist/mcp/index.d.ts.map +1 -1
  26. package/dist/services/codegraph.d.ts +36 -0
  27. package/dist/services/codegraph.d.ts.map +1 -0
  28. package/dist/services/codegraph.test.d.ts +2 -0
  29. package/dist/services/codegraph.test.d.ts.map +1 -0
  30. package/dist/services/question-guard.d.ts +4 -0
  31. package/dist/services/question-guard.d.ts.map +1 -1
  32. package/dist/services/recommended-question.test.d.ts +2 -0
  33. package/dist/services/recommended-question.test.d.ts.map +1 -0
  34. package/dist/services/supervisor-binding.d.ts +3 -1
  35. package/dist/services/supervisor-binding.d.ts.map +1 -1
  36. package/dist/tools/codebase-index.d.ts +30 -0
  37. package/dist/tools/codebase-index.d.ts.map +1 -0
  38. package/dist/tools/codebase-index.test.d.ts +2 -0
  39. package/dist/tools/codebase-index.test.d.ts.map +1 -0
  40. package/dist/tools/codegraph-tool.d.ts +3 -0
  41. package/dist/tools/codegraph-tool.d.ts.map +1 -0
  42. package/dist/tools/planning-state-lib.d.ts +23 -0
  43. package/dist/tools/planning-state-lib.d.ts.map +1 -1
  44. package/docs/agents/index.md +154 -0
  45. package/docs/commands/fd-ask.md +71 -39
  46. package/docs/commands/fd-checkpoint.md +63 -8
  47. package/docs/commands/fd-deploy-check.md +166 -9
  48. package/docs/commands/fd-design.md +101 -0
  49. package/docs/commands/fd-discuss.md +87 -20
  50. package/docs/commands/fd-doctor.md +100 -13
  51. package/docs/commands/fd-done.md +215 -0
  52. package/docs/commands/fd-execute.md +104 -0
  53. package/docs/commands/fd-fix-bug.md +144 -24
  54. package/docs/commands/fd-map-codebase.md +85 -21
  55. package/docs/commands/fd-multi-repo.md +155 -40
  56. package/docs/commands/fd-new-feature.md +63 -19
  57. package/docs/commands/fd-plan.md +80 -27
  58. package/docs/commands/fd-quick.md +143 -29
  59. package/docs/commands/fd-reflect.md +81 -13
  60. package/docs/commands/fd-resume.md +65 -8
  61. package/docs/commands/fd-status.md +80 -12
  62. package/docs/commands/fd-suggest.md +114 -0
  63. package/docs/commands/fd-translate-intent.md +69 -9
  64. package/docs/commands/fd-verify.md +71 -14
  65. package/docs/commands/fd-write-docs.md +121 -8
  66. package/docs/concepts/architecture.md +163 -0
  67. package/docs/concepts/governance.md +242 -0
  68. package/docs/concepts/intelligence.md +145 -0
  69. package/docs/concepts/multi-repo.md +227 -0
  70. package/docs/concepts/workflows.md +205 -0
  71. package/docs/configuration/index.md +208 -0
  72. package/docs/configuration/opencode-settings.md +98 -0
  73. package/docs/getting-started/first-project.md +126 -0
  74. package/docs/getting-started/installation.md +73 -0
  75. package/docs/getting-started/quick-start.md +74 -0
  76. package/docs/index.md +36 -72
  77. package/docs/reference/hooks.md +176 -0
  78. package/docs/reference/rules.md +109 -0
  79. package/docs/skills/code-review.md +47 -0
  80. package/docs/skills/index.md +148 -0
  81. package/docs/skills/planning.md +39 -0
  82. package/package.json +1 -1
  83. package/src/commands/fd-discuss.md +74 -10
  84. package/src/commands/fd-done.md +196 -0
  85. package/src/commands/fd-execute.md +43 -6
  86. package/src/commands/fd-fix-bug.md +43 -6
  87. package/src/commands/fd-map-codebase.md +99 -19
  88. package/src/commands/fd-new-feature.md +14 -5
  89. package/src/commands/fd-plan.md +38 -1
  90. package/src/commands/fd-quick.md +1 -1
  91. package/src/commands/fd-resume.md +1 -1
  92. package/src/commands/fd-status.md +1 -1
  93. package/src/commands/fd-verify.md +16 -2
  94. package/src/commands/fd-write-docs.md +30 -5
  95. package/src/skills/context-load/SKILL.md +1 -1
  96. package/dist/hooks/memory-hook.d.ts +0 -28
  97. package/dist/hooks/memory-hook.d.ts.map +0 -1
  98. package/dist/services/memory-store.d.ts +0 -73
  99. package/dist/services/memory-store.d.ts.map +0 -1
  100. package/dist/services/memory-store.test.d.ts +0 -2
  101. package/dist/services/memory-store.test.d.ts.map +0 -1
  102. package/dist/tools/memory-search.d.ts +0 -3
  103. package/dist/tools/memory-search.d.ts.map +0 -1
  104. package/dist/tools/memory-status.d.ts +0 -3
  105. package/dist/tools/memory-status.d.ts.map +0 -1
  106. package/docs/USER_GUIDE.md +0 -20
  107. package/docs/agents.md +0 -544
  108. package/docs/best-practices.md +0 -47
  109. package/docs/commands/fd-new-project.md +0 -24
  110. package/docs/commands.md +0 -557
  111. package/docs/configuration.md +0 -325
  112. package/docs/design-first-workflow.md +0 -94
  113. package/docs/feature-integration-architecture.md +0 -227
  114. package/docs/installation.md +0 -123
  115. package/docs/intelligence.md +0 -370
  116. package/docs/memory.md +0 -69
  117. package/docs/multi-repo.md +0 -201
  118. package/docs/notifications.md +0 -170
  119. package/docs/optimization-baseline.md +0 -21
  120. package/docs/quick-start.md +0 -197
  121. package/docs/rules.md +0 -432
  122. package/docs/skills.md +0 -417
  123. package/docs/workflows.md +0 -134
  124. package/src/commands/fd-new-project.md +0 -114
@@ -1,325 +0,0 @@
1
- # Configuration
2
-
3
- FlowDeck has two levels of configuration: the global OpenCode config (`opencode.json`) and the per-project config (`.planning/config.json`). This document covers both, plus environment variables and the plugin tools that FlowDeck exposes to every OpenCode session.
4
-
5
- ---
6
-
7
- ## opencode.json
8
-
9
- OpenCode reads `~/.config/opencode/opencode.json` at startup. FlowDeck requires one entry in the `plugin` array and supports optional entries in `instructions` to load rule files.
10
-
11
- ### Minimal configuration
12
-
13
- ```json
14
- {
15
- "$schema": "https://opencode.ai/config.json",
16
- "plugin": ["@dv.nghiem/flowdeck"]
17
- }
18
- ```
19
-
20
- The `plugin` entry is written automatically by the FlowDeck installer. If it is missing, agents, skills, and commands will not load.
21
-
22
- ### Full configuration with rules
23
-
24
- ```json
25
- {
26
- "$schema": "https://opencode.ai/config.json",
27
- "plugin": ["@dv.nghiem/flowdeck"],
28
- "instructions": [
29
- ".planning/PROJECT.md",
30
- "flowdeck-rules/common/coding-style.md",
31
- "flowdeck-rules/typescript/patterns.md"
32
- ]
33
- }
34
- ```
35
-
36
- Files listed under `instructions` are injected into every agent's context at session start. Use this to load project context and language-specific coding standards automatically.
37
-
38
- ---
39
-
40
- ## Using Language Rules
41
-
42
- FlowDeck installs rule files under the npm package cache path:
43
-
44
- ```
45
- ~/.cache/opencode/packages/@dv.nghiem/flowdeck@latest/rules/
46
- ```
47
-
48
- To activate rules, reference them by their path in the `instructions` array. Examples for each supported language:
49
-
50
- **TypeScript**
51
- ```json
52
- "instructions": [
53
- "flowdeck-rules/common/coding-style.md",
54
- "flowdeck-rules/common/security.md",
55
- "flowdeck-rules/common/testing.md",
56
- "flowdeck-rules/typescript/patterns.md"
57
- ]
58
- ```
59
-
60
- **Python**
61
- ```json
62
- "instructions": [
63
- "flowdeck-rules/common/coding-style.md",
64
- "flowdeck-rules/common/testing.md",
65
- "flowdeck-rules/python/patterns.md"
66
- ]
67
- ```
68
-
69
- **Go**
70
- ```json
71
- "instructions": [
72
- "flowdeck-rules/common/coding-style.md",
73
- "flowdeck-rules/common/git-workflow.md",
74
- "flowdeck-rules/golang/patterns.md"
75
- ]
76
- ```
77
-
78
- **Java**
79
- ```json
80
- "instructions": [
81
- "flowdeck-rules/common/coding-style.md",
82
- "flowdeck-rules/common/security.md",
83
- "flowdeck-rules/java/patterns.md"
84
- ]
85
- ```
86
-
87
- **Rust**
88
- ```json
89
- "instructions": [
90
- "flowdeck-rules/common/coding-style.md",
91
- "flowdeck-rules/rust/patterns.md"
92
- ]
93
- ```
94
-
95
- **Common rules (all projects)**
96
-
97
- | File | Purpose |
98
- |------|---------|
99
- | `flowdeck-rules/common/coding-style.md` | Formatting, naming conventions, comment standards |
100
- | `flowdeck-rules/common/testing.md` | Test structure, coverage targets, assertion patterns |
101
- | `flowdeck-rules/common/security.md` | Input validation, secrets handling, OWASP reminders |
102
- | `flowdeck-rules/common/git-workflow.md` | Branching strategy, commit message format, PR workflow |
103
- | `flowdeck-rules/common/agent-orchestration.md` | How agents hand off context and coordinate work |
104
-
105
- ---
106
-
107
- ## Project Config (.planning/config.json)
108
-
109
- Each FlowDeck project stores its settings in `.planning/config.json`. This file is created by `/fd-new-project` and updated by `/fd-settings`.
110
-
111
- ### Full schema
112
-
113
- ```json
114
- {
115
- "project_name": "MyApp",
116
- "workspace_mode": "single",
117
- "active_phase": 1,
118
- "plan_confirmed": false,
119
- "enforce_guardrails": true,
120
- "sub_repos": [
121
- {
122
- "name": "user-service",
123
- "path": "../user-service",
124
- "role": "upstream-api",
125
- "tech_stack": "node+typescript",
126
- "owner_team": "platform"
127
- }
128
- ]
129
- }
130
- ```
131
-
132
- ### Field reference
133
-
134
- | Field | Type | Description |
135
- |-------|------|-------------|
136
- | `project_name` | string | Human-readable name shown in `/fd-dashboard` and state files |
137
- | `workspace_mode` | `"single"` \| `"multi"` | `"single"` for one repo; `"multi"` enables the multi-repo coordinator |
138
- | `active_phase` | integer | The current phase number. `@orchestrator` reads this to determine which plan to execute |
139
- | `plan_confirmed` | boolean | Set to `true` when you type `CONFIRMED` after `/fd-plan`. Guards against unreviewed execution |
140
- | `enforce_guardrails` | boolean | When `true`, the `@plan-checker` must approve a plan before `@orchestrator` runs it |
141
- | `sub_repos` | array | List of additional repositories involved in this project (multi-repo mode only) |
142
- | `sub_repos[].name` | string | Short identifier used in cross-repo task delegation |
143
- | `sub_repos[].path` | string | Relative or absolute path to the repository on disk |
144
- | `sub_repos[].role` | string | Describes the relationship: `"upstream-api"`, `"downstream-consumer"`, `"shared-lib"`, etc. |
145
- | `sub_repos[].tech_stack` | string | Primary language and framework, used by `@multi-repo-coordinator` for context |
146
- | `sub_repos[].owner_team` | string | Informational — used in planning notes and review assignments |
147
-
148
- ---
149
-
150
- ## flowdeck.json (Agent and Governance Config)
151
-
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
-
154
- ### Locations
155
-
156
- | Scope | Path |
157
- |-------|------|
158
- | Global | `~/.config/opencode/flowdeck.json` |
159
- | Project | `<project>/.opencode/flowdeck.json` |
160
-
161
- Project config takes precedence over global config.
162
-
163
- ### Full schema
164
-
165
- ```json
166
- {
167
- "agents": {
168
- "<agent-name>": {
169
- "model": "<provider>/<model-id>"
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
- }
203
- }
204
- }
205
- ```
206
-
207
- ### Agent model overrides
208
-
209
- All agents default to the model currently selected in OpenCode. Only list agents you want to override:
210
-
211
- ```json
212
- {
213
- "agents": {
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" }
218
- }
219
- }
220
- ```
221
-
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.
256
-
257
- ---
258
-
259
- ## Settings Command
260
-
261
- To view or modify project configuration interactively, run inside an OpenCode session:
262
-
263
- ```
264
- /fd-settings
265
- ```
266
-
267
- `/fd-settings` displays the current values from `.planning/config.json`, lists active model assignments for each agent, and presents options to:
268
-
269
- - Switch `workspace_mode` between `single` and `multi`
270
- - Change the `active_phase`
271
- - Toggle `enforce_guardrails`
272
- - Register or remove sub-repos
273
- - Run `/fd-doctor` to verify environment health
274
-
275
- Changes are written back to `.planning/config.json` immediately.
276
-
277
- ---
278
-
279
- ## Built-in MCP Servers
280
-
281
- FlowDeck automatically registers three free, read-only remote Model Context Protocol (MCP) servers to give your agents extended capabilities:
282
-
283
- | MCP | Endpoint | Purpose |
284
- |---|---|---|
285
- | **Context7** | `mcp.context7.com/mcp` | Fast library and API documentation lookup |
286
- | **Exa Websearch** | `mcp.exa.ai/mcp` | General web search capabilities |
287
- | **Grep.app** | `mcp.grep.app` | Global code search across open-source repositories |
288
-
289
- These are enabled by default. If you have API keys (e.g., `CONTEXT7_API_KEY`, `EXA_API_KEY`), FlowDeck will automatically inject them. To disable any of these, use the `FLOWDECK_DISABLE_MCP` environment variable (e.g., `FLOWDECK_DISABLE_MCP=context7,websearch`).
290
-
291
- ---
292
-
293
- ## Environment Variables
294
-
295
- | Variable | Default | Description |
296
- |----------|---------|-------------|
297
- | `OPENCODE_CONFIG_DIR` | `~/.config/opencode` | Override the directory where FlowDeck looks for agents, skills, and commands |
298
- | `XDG_CONFIG_HOME` | `~/.config` | Standard XDG base directory; used to resolve `OPENCODE_CONFIG_DIR` when not explicitly set |
299
- | `FLOWDECK_CONTEXT_LIMIT` | `200000` | Token limit used by the Context Window Monitor to warn when context usage exceeds 70% |
300
- | `FLOWDECK_DISABLE_MCP` | (empty) | Comma-separated list of remote MCPs to disable. Valid options: `context7`, `websearch`, `grep_app` |
301
- | `FLOWDECK_ORCHESTRATOR_GUARD` | `off` | Enable the orchestrator guard hook. When `on`, the orchestrator session cannot use write/bash tools directly and must delegate all implementation work. |
302
- | `FLOWDECK_PATCH_TRUST_HIGH_RISK_ENABLED` | `off` | Enable blocking of high-risk AI-generated edits (score < 40). When `true` or `1`, the patch trust hook blocks edits flagged as high-risk. When `false`, `0`, or unset (default), high-risk edits are allowed without blocking. |
303
- | `FLOWDECK_GUARD_RAILS_ENABLED` | `off` | Enable the guard rails hook. When `on`, write/edit tools are warned/blocked based on plan confirmation state, .codebase/ existence, and execution mode. |
304
- | `FLOWDECK_TOOL_GUARD_ENABLED` | `off` | Enable the tool guard hook. When `on`, blocks dangerous bash commands (rm -rf), access to secret files (.env, .pem, .key), writes to node_modules, arch-constraint violations, and premature phase writes. |
305
- | `FLOWDECK_APPROVAL_HOOK_ENABLED` | `off` | Enable the approval hook. When `on`, blocks write/edit on sensitive files (auth/payment/secrets/infra) unless a recent approval exists. |
306
- | `TELEMETRY_ENABLED` | `false` | Enable telemetry events from hooks. When `true`, events are written to `.codebase/TELEMETRY.jsonl`. |
307
-
308
- ---
309
-
310
- ## FlowDeck Plugin Tools
311
-
312
- When the `@dv.nghiem/flowdeck` plugin is loaded, six tools become available to every agent in your OpenCode session. You do not need to invoke these directly — they are used automatically by FlowDeck agents and workflows.
313
-
314
- | `planning-state` | Read and write `.planning/` state files (`STATE.md`, `PLAN.md`, `DISCUSS.md`, `config.json`). Used by every agent that needs project context. |
315
- | `codebase-state` | Read `.codebase/` documentation files generated by `@mapper`. Gives agents access to `STACK.md`, `ARCHITECTURE.md`, and `CONVENTIONS.md`. |
316
- | `workspace-state` | Read workspace and multi-repo metadata. Returns the current project config, sub-repo list, and active phase. |
317
- | `run-pipeline` | Execute a sequence of agent tasks in strict order, passing each step's output as input to the next. Used by `@orchestrator` for ordered workflows. |
318
- | `delegate` | Invoke a specific named agent with a given prompt and context. The core primitive used by orchestration agents to hand off work. |
319
- | `hash-edit` | Reliable file editing with content verification. Takes target content and its expected hash to prevent edits on stale versions. |
320
- | `council` | Ensemble-based reasoning. Runs 3 specialized agents in parallel and synthesizes their consensus for complex decisions. |
321
- | `context-generator` | Auto-generate/update hierarchical `AGENTS.md` and `CLAUDE.md` files throughout the project for better agent grounding. |
322
-
323
- ---
324
-
325
- ← [Back to Index](index.md)
@@ -1,94 +0,0 @@
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
- ```
@@ -1,227 +0,0 @@
1
- # FlowDeck Integration Architecture
2
-
3
- Second-layer integration: trust, routing, observability, and repo-intelligence.
4
-
5
- ---
6
-
7
- ## Overview
8
-
9
- This layer adds 8 capabilities behind the existing command architecture without expanding the top-level command surface:
10
-
11
- | Capability | Implementation | Data File |
12
- |---|---|---|
13
- | Patch Trust Engine | `src/hooks/patch-trust.ts` | `.codebase/DECISIONS.jsonl` |
14
- | Agent Performance Memory | `src/services/agent-performance.ts` | `.codebase/AGENT_PERF.json` |
15
- | Approval-Aware Execution | `src/services/approval-manager.ts` + `src/hooks/approval-hook.ts` | `.codebase/APPROVALS.json` |
16
- | Workflow Replay + Diff | `src/services/run-trace.ts` | `.codebase/RUNS.jsonl` |
17
- | Agent Performance Memory | `src/services/agent-performance.ts` | `.codebase/AGENT_PERF.json` |
18
- | Structured Telemetry | `src/services/telemetry.ts` + `src/hooks/telemetry-hook.ts` | `.codebase/TELEMETRY.jsonl` |
19
- | Dashboard Integration | `src/dashboard/` | reads all `.codebase/` files |
20
- | Failure-to-Rule Learning | `src/services/policy-compiler.ts` (`learnFromFailure`) | `.codebase/POLICIES.json` |
21
-
22
- ---
23
-
24
- ## Services Layer (`src/services/`)
25
-
26
- ### telemetry.ts
27
- Appends structured `TelemetryEvent` records to `.codebase/TELEMETRY.jsonl`.
28
-
29
- ```typescript
30
- appendEvent(dir, { session_id, run_id, event, command, tool, model, duration_ms, status, risk_score })
31
- readEvents(dir, limit)
32
- getCommandSummary(dir)
33
- getRunEvents(dir, run_id)
34
- getRecentToolFailures(dir)
35
- ```
36
-
37
- Event types: `command.start`, `command.end`, `tool.call`, `tool.complete`, `agent.dispatch`, `approval.request`, `approval.resolve`, `run.complete`, `run.fail`, `policy.violation`, `patch.scored`
38
-
39
- ### run-trace.ts
40
- Records command execution runs with files touched, risk scores, and outcomes.
41
-
42
- ```typescript
43
- startTrace(dir, command, args, session_id) → RunTrace
44
- endTrace(dir, run_id, status, outcome?, error?)
45
- touchFile(dir, run_id, filePath)
46
- setRiskScore(dir, run_id, score)
47
- getTrace(dir, run_id)
48
- listTraces(dir, limit)
49
- diffTraces(dir, run_id_a, run_id_b) → RunDiff
50
- ```
51
-
52
- ### approval-manager.ts
53
- Manages approval state for high-risk operations.
54
-
55
- ```typescript
56
- requestApproval(dir, run_id, trigger, reason, options) → ApprovalRequest
57
- resolveApproval(dir, approval_id, "approved" | "rejected")
58
- checkApproval(dir, file_path, command) → ApprovalRequest | null
59
- getPendingApprovals(dir)
60
- isApprovalRequired(filePath, riskScore) → boolean
61
- isSensitivePath(filePath) → boolean
62
- ```
63
-
64
- **Approval TTL:** 30 minutes. Sensitive path patterns: auth, payment, secrets, migrations, infra, production config.
65
-
66
- ### agent-performance.ts
67
- Tracks success rates, costs, and durations per agent+model+task combination.
68
-
69
- ```typescript
70
- recordRun(dir, agent, model, task_type, success, duration_ms, cost?)
71
- getStats(dir, filter?) → AgentPerfEntry[]
72
- getBestAgentForTask(dir, task_type) → AgentRecommendation | null
73
- getAgentLeaderboard(dir) → AgentRecommendation[]
74
- ```
75
-
76
- Requires ≥ 3 runs per combination before making routing recommendations. Model is tracked from the actual call — no hardcoded model list.
77
-
78
- ---
79
-
80
- ## Hooks Layer (`src/hooks/`)
81
-
82
- ### Hook execution order (tool.execute.before)
83
- 1. `telemetryHook` — record tool invocation
84
- 2. `approvalHook` — block writes on sensitive files without approval
85
- 3. `guardRailsHook` — enforce execution mode (auto/guarded/review-only)
86
- 4. `toolGuardHook` — enforce architectural constraints
87
- 5. `patchTrustHook` — score patch risk
88
- 6. `decisionTraceHook` — record edit rationale
89
-
90
- ### approval-hook.ts
91
- Intercepts write/edit tool calls on sensitive file paths. Throws with `APPROVAL_REQUIRED:` prefix to block. Emits `approval.request` telemetry event.
92
-
93
- Monitored tools: `write_file`, `edit_file`, `create_file`, `apply_patch`, `str_replace_editor`, `write`
94
-
95
- ### telemetry-hook.ts
96
- Emits `tool.call` events for all tool invocations. Lightweight — never blocks.
97
-
98
- ---
99
-
100
- ## Command Integration
101
-
102
- ### /fd-new-feature
103
- - Calls `startTrace()` on entry → `run_id` included in config
104
- - Emits `command.start` telemetry event with risk score and phase
105
-
106
- ### /fd-fix-bug
107
- - Calls `startTrace()` on entry → `run_id` included in config
108
- - Emits `command.start` telemetry with prior failure count in metadata
109
-
110
- ### /fd-analyze-change
111
- - Consumes all impact services (impact radar, blast radius, volatility, regression)
112
- - Returns structured output with risk summary for dashboard
113
-
114
- ### /fd-dashboard
115
- - Reads `DashboardData` including: `telemetrySummary`, `recentRuns`, `pendingApprovals`, `agentPerf`, `toolFailureCount`
116
- - Displays operational control plane sections alongside phase progress
117
-
118
- ### /fd-guarded-edit
119
- - Run approval gate before risky operations
120
- - Uses `isApprovalRequired()` + `requestApproval()` pattern
121
-
122
- ---
123
-
124
- ## Dashboard Sections
125
-
126
- The dashboard at `http://localhost:<port>` now includes:
127
-
128
- 1. **Milestone Progress** — phase timeline (existing)
129
- 2. **Blockers** — from STATE.md (existing)
130
- 3. **⚠ Pending Approvals** — approval requests waiting on user
131
- 4. **Recent Runs** — last 10 command runs with status, risk, files touched
132
- 5. **Command Telemetry** — aggregate stats per command (total runs, success rate, avg duration)
133
- 6. **Agent Performance** — success rate per agent/model/task combination
134
-
135
- ---
136
-
137
- ## Data Schema
138
-
139
- ### TELEMETRY.jsonl (append-only)
140
- ```json
141
- {"id":"uuid","ts":"ISO","session_id":"s","run_id":"r","event":"command.end","command":"fd-fix-bug","status":"ok","duration_ms":1200,"risk_score":72}
142
- ```
143
-
144
- ### RUNS.jsonl (append-only, rewritten on end/update)
145
- ```json
146
- {"run_id":"uuid","session_id":"s","command":"fd-new-feature","args":{},"started_at":"ISO","ended_at":"ISO","status":"complete","files_touched":["src/auth.ts"],"event_ids":[],"risk_score":65,"outcome":"Feature merged"}
147
- ```
148
-
149
- ### APPROVALS.json
150
- ```json
151
- {"requests":[{"id":"uuid","run_id":"r","session_id":"s","requested_at":"ISO","status":"pending","trigger":"sensitive_file","reason":"Auth change","risk_score":25,"file_path":"src/auth.ts"}]}
152
- ```
153
-
154
- ### AGENT_PERF.json
155
- ```json
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"}
157
- ```
158
-
159
- ---
160
-
161
- ## Config Additions
162
-
163
- No new required config. Optional per-repo overrides:
164
-
165
- - `.codebase/POLICIES.json` — runtime policy rules (existing, enhanced)
166
- - `.codebase/CONSTRAINTS.md` — architectural constraints (existing)
167
-
168
- ---
169
-
170
- ## Agents
171
-
172
- Three new specialist agents available for programmatic invocation:
173
-
174
- | Agent | File | Purpose |
175
- |---|---|---|
176
- | `replay-analyst` | `agents/replay-analyst.md` | Diff run traces, surface regressions |
177
- | `eval-reviewer` | `agents/eval-reviewer.md` | Evaluate agent/model routing quality |
178
- | `cost-optimizer` | `agents/cost-optimizer.md` | Recommend cheaper routing with no quality loss |
179
-
180
- ---
181
-
182
- ## Policy Compiler Service (`src/services/policy-compiler.ts`)
183
-
184
- Compiles active policies from `POLICIES.json` into runtime evaluators.
185
-
186
- ```typescript
187
- evaluatePolicies(dir, ctx) → PolicyViolation[]
188
- learnFromFailure(failure_type, affected_paths, root_cause?) → ProposedPolicy | null
189
- formatViolations(violations) → string
190
- ```
191
-
192
- **PolicyContext fields:** `command`, `file_path`, `change_description`, `tool`, `risk_score`
193
-
194
- **Severity derivation:** Rules containing "require approval", "never", "must not" → `block`; otherwise → `warn`
195
-
196
- **Pattern learning:** Proposes policies for recognized failure types (`auth_bypass`, `payment_failure`, `migration_failure`, `infra_change`, `secrets_exposure`). Returns `null` for unrecognized patterns.
197
-
198
- ---
199
-
200
- ## `/fd-approve` Command (`src/commands/governance/approve.ts`)
201
-
202
- Governance command for managing approval gates raised by the approval hook.
203
-
204
- ```
205
- /fd-approve # list all pending approvals
206
- /fd-approve --id <uuid> # approve → operation may proceed
207
- /fd-approve --id <uuid> --reject # reject → operation stays blocked
208
- /fd-approve --recent # last 10 resolved approvals
209
- /fd-approve --json # machine-readable output
210
- ```
211
-
212
- Resolving an approval emits an `approval.resolve` telemetry event and records the decision in `APPROVALS.json`.
213
-
214
- ---
215
-
216
- ## Migration Notes
217
-
218
- All existing commands continue to work unchanged. New capabilities are additive:
219
-
220
- - `fd-new-feature` — now uses model router instead of hardcoded models; emits telemetry
221
- - `fd-fix-bug` — emits run trace on entry, evaluates policies, proposes new policies from failures
222
- - `fd-verify` — shows policy violations in output table
223
- - Dashboard — new operational sections appear only when data exists (no empty-state noise)
224
- - Approval hook — only triggers for write operations on sensitive file patterns; safe paths are unaffected
225
- - Telemetry — append-only, never read during hook execution, cannot slow down tool calls
226
-
227
- First-run behavior: all new `.codebase/` data files are created on first use. No migration needed.