@dv.nghiem/flowdeck 0.3.9 → 0.4.1

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 (129) 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 +73 -8
  13. package/dist/hooks/notifications.d.ts.map +1 -1
  14. package/dist/hooks/notifications.test.d.ts +14 -0
  15. package/dist/hooks/notifications.test.d.ts.map +1 -0
  16. package/dist/hooks/session-idle-hook.d.ts +5 -3
  17. package/dist/hooks/session-idle-hook.d.ts.map +1 -1
  18. package/dist/hooks/session-start.d.ts.map +1 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +822 -796
  21. package/dist/lib/completion-validator.d.ts +51 -0
  22. package/dist/lib/completion-validator.d.ts.map +1 -0
  23. package/dist/lib/recommended-question.d.ts +24 -0
  24. package/dist/lib/recommended-question.d.ts.map +1 -0
  25. package/dist/lib/research-gate.d.ts +97 -0
  26. package/dist/lib/research-gate.d.ts.map +1 -0
  27. package/dist/lib/research-gate.test.d.ts +2 -0
  28. package/dist/lib/research-gate.test.d.ts.map +1 -0
  29. package/dist/mcp/index.d.ts +12 -2
  30. package/dist/mcp/index.d.ts.map +1 -1
  31. package/dist/services/codegraph.d.ts +36 -0
  32. package/dist/services/codegraph.d.ts.map +1 -0
  33. package/dist/services/codegraph.test.d.ts +2 -0
  34. package/dist/services/codegraph.test.d.ts.map +1 -0
  35. package/dist/services/question-guard.d.ts +4 -0
  36. package/dist/services/question-guard.d.ts.map +1 -1
  37. package/dist/services/recommended-question.test.d.ts +2 -0
  38. package/dist/services/recommended-question.test.d.ts.map +1 -0
  39. package/dist/services/supervisor-binding.d.ts +3 -1
  40. package/dist/services/supervisor-binding.d.ts.map +1 -1
  41. package/dist/tools/codebase-index.d.ts +30 -0
  42. package/dist/tools/codebase-index.d.ts.map +1 -0
  43. package/dist/tools/codebase-index.test.d.ts +2 -0
  44. package/dist/tools/codebase-index.test.d.ts.map +1 -0
  45. package/dist/tools/codegraph-tool.d.ts +3 -0
  46. package/dist/tools/codegraph-tool.d.ts.map +1 -0
  47. package/dist/tools/planning-state-lib.d.ts +23 -0
  48. package/dist/tools/planning-state-lib.d.ts.map +1 -1
  49. package/docs/agents/index.md +154 -0
  50. package/docs/commands/fd-ask.md +71 -39
  51. package/docs/commands/fd-checkpoint.md +63 -8
  52. package/docs/commands/fd-deploy-check.md +166 -9
  53. package/docs/commands/fd-design.md +101 -0
  54. package/docs/commands/fd-discuss.md +87 -20
  55. package/docs/commands/fd-doctor.md +100 -13
  56. package/docs/commands/fd-done.md +215 -0
  57. package/docs/commands/fd-execute.md +104 -0
  58. package/docs/commands/fd-fix-bug.md +144 -24
  59. package/docs/commands/fd-map-codebase.md +85 -21
  60. package/docs/commands/fd-multi-repo.md +155 -40
  61. package/docs/commands/fd-new-feature.md +63 -19
  62. package/docs/commands/fd-plan.md +80 -27
  63. package/docs/commands/fd-quick.md +143 -29
  64. package/docs/commands/fd-reflect.md +81 -13
  65. package/docs/commands/fd-resume.md +65 -8
  66. package/docs/commands/fd-status.md +80 -12
  67. package/docs/commands/fd-suggest.md +114 -0
  68. package/docs/commands/fd-translate-intent.md +69 -9
  69. package/docs/commands/fd-verify.md +71 -14
  70. package/docs/commands/fd-write-docs.md +121 -8
  71. package/docs/concepts/architecture.md +163 -0
  72. package/docs/concepts/governance.md +242 -0
  73. package/docs/concepts/intelligence.md +145 -0
  74. package/docs/concepts/multi-repo.md +227 -0
  75. package/docs/concepts/workflows.md +205 -0
  76. package/docs/configuration/index.md +208 -0
  77. package/docs/configuration/opencode-settings.md +98 -0
  78. package/docs/getting-started/first-project.md +126 -0
  79. package/docs/getting-started/installation.md +73 -0
  80. package/docs/getting-started/quick-start.md +74 -0
  81. package/docs/index.md +36 -72
  82. package/docs/reference/hooks.md +176 -0
  83. package/docs/reference/rules.md +109 -0
  84. package/docs/skills/code-review.md +47 -0
  85. package/docs/skills/index.md +148 -0
  86. package/docs/skills/planning.md +39 -0
  87. package/package.json +1 -1
  88. package/src/commands/fd-discuss.md +74 -10
  89. package/src/commands/fd-done.md +196 -0
  90. package/src/commands/fd-execute.md +43 -6
  91. package/src/commands/fd-fix-bug.md +43 -6
  92. package/src/commands/fd-map-codebase.md +99 -19
  93. package/src/commands/fd-new-feature.md +14 -5
  94. package/src/commands/fd-plan.md +38 -1
  95. package/src/commands/fd-quick.md +1 -1
  96. package/src/commands/fd-resume.md +1 -1
  97. package/src/commands/fd-status.md +1 -1
  98. package/src/commands/fd-verify.md +16 -2
  99. package/src/commands/fd-write-docs.md +30 -5
  100. package/src/skills/context-load/SKILL.md +1 -1
  101. package/dist/hooks/memory-hook.d.ts +0 -28
  102. package/dist/hooks/memory-hook.d.ts.map +0 -1
  103. package/dist/services/memory-store.d.ts +0 -73
  104. package/dist/services/memory-store.d.ts.map +0 -1
  105. package/dist/services/memory-store.test.d.ts +0 -2
  106. package/dist/services/memory-store.test.d.ts.map +0 -1
  107. package/dist/tools/memory-search.d.ts +0 -3
  108. package/dist/tools/memory-search.d.ts.map +0 -1
  109. package/dist/tools/memory-status.d.ts +0 -3
  110. package/dist/tools/memory-status.d.ts.map +0 -1
  111. package/docs/USER_GUIDE.md +0 -20
  112. package/docs/agents.md +0 -544
  113. package/docs/best-practices.md +0 -47
  114. package/docs/commands/fd-new-project.md +0 -24
  115. package/docs/commands.md +0 -557
  116. package/docs/configuration.md +0 -325
  117. package/docs/design-first-workflow.md +0 -94
  118. package/docs/feature-integration-architecture.md +0 -227
  119. package/docs/installation.md +0 -123
  120. package/docs/intelligence.md +0 -370
  121. package/docs/memory.md +0 -69
  122. package/docs/multi-repo.md +0 -201
  123. package/docs/notifications.md +0 -170
  124. package/docs/optimization-baseline.md +0 -21
  125. package/docs/quick-start.md +0 -197
  126. package/docs/rules.md +0 -432
  127. package/docs/skills.md +0 -417
  128. package/docs/workflows.md +0 -134
  129. package/src/commands/fd-new-project.md +0 -114
@@ -0,0 +1,145 @@
1
+ # Intelligence
2
+
3
+ FlowDeck's intelligence layer evaluates every change before it is applied. It scores edit safety, tracks file change history, reproduces prior failures, predicts regressions, and enforces workflow discipline through phase gating. All intelligence services run as hooks on every tool execution — no additional commands needed.
4
+
5
+ ---
6
+
7
+ ## Patch Trust Score
8
+
9
+ Before any `edit` tool call is applied, the **patch trust scorer** evaluates the edit and assigns a trust score from 0.0 (dangerous) to 1.0 (safe).
10
+
11
+ The score is computed from:
12
+
13
+ | Factor | Weight | What it measures |
14
+ |--------|--------|-----------------|
15
+ | File volatility | 25% | Historical change frequency from `.codebase/VOLATILITY.json` |
16
+ | Edit scope | 20% | Lines changed vs. file total — large rewrites score lower |
17
+ | Context window pressure | 15% | Remaining context space — edits under pressure score lower |
18
+ | Agent history | 20% | Historical failure rate of the calling agent on this file |
19
+ | Rule compliance | 20% | Does the edit violate project rules from `.flowdeck/rules/` |
20
+
21
+ **Threshold behavior:**
22
+
23
+ - Score >= 0.8 — edit applied automatically
24
+ - Score 0.5–0.8 — user notified; edit applied with confirmation prompt
25
+ - Score < 0.5 — edit blocked; user must resolve concerns or override explicitly
26
+
27
+ The `@policy-enforcer` agent is invoked automatically when the score is below threshold. The score is logged in the tool span metadata.
28
+
29
+ ---
30
+
31
+ ## Volatility Map
32
+
33
+ The **volatility map** tracks change frequency per file over the session and across sessions. It is maintained by the `volatility-map` tool and stored in `.codebase/VOLATILITY.json`.
34
+
35
+ ```json
36
+ {
37
+ "src/auth/login.ts": {
38
+ "changeCount": 7,
39
+ "lastChanged": "2026-05-26T09:30:00Z",
40
+ "avgRevisionsPerSession": 3.2,
41
+ "risk": "high"
42
+ },
43
+ "src/config/default.ts": {
44
+ "changeCount": 1,
45
+ "lastChanged": "2026-05-25T14:00:00Z",
46
+ "avgRevisionsPerSession": 0.4,
47
+ "risk": "low"
48
+ }
49
+ }
50
+ ```
51
+
52
+ Files with high volatility:
53
+
54
+ - Receive lower Patch Trust Scores automatically
55
+ - Trigger `@risk-analyst` review before large refactors
56
+ - Are flagged in the Workflow Scorecard under `context_preserved` if they change frequently within a single session
57
+
58
+ The volatility map is rebuilt on first session start and incrementally updated on each `edit` tool call.
59
+
60
+ ---
61
+
62
+ ## Failure Replay
63
+
64
+ When a task fails (test failure, build error, runtime crash), the **failure replay** service can reproduce the failure in isolation to generate a clean diagnostic trace.
65
+
66
+ Invoked by the `@debugger` agent via the `failure-replay` tool:
67
+
68
+ 1. The tool reads the original error context from the failed span in `AGENT_SPANS.jsonl`
69
+ 2. It re-runs the minimal subset of the task that caused the failure
70
+ 3. The trace is written to `.codebase/FAILURE_REPLAY.jsonl`:
71
+
72
+ ```json
73
+ {
74
+ "replay_id": "fr-001",
75
+ "original_span": "s1a2b3c",
76
+ "task": "Run user authentication tests",
77
+ "reproduced": true,
78
+ "root_cause": "Missing mock for auth service in test environment",
79
+ "trace": [
80
+ "Step 1: npm test src/auth/login.test.ts",
81
+ "Error: Cannot read property 'validate' of undefined",
82
+ "Step 2: Mock auth service — result: test passes"
83
+ ],
84
+ "fix_suggestion": "Add mock for auth service in login.test.ts line 42"
85
+ }
86
+ ```
87
+
88
+ Replays are deterministic — the same failure will reproduce the same trace. This prevents "heisenbugs" that only appear in full runs.
89
+
90
+ ---
91
+
92
+ ## Regression Prediction
93
+
94
+ Before a plan is executed, the **regression predictor** evaluates the planned changes against the volatility map and historical failure data to predict which tasks are likely to break tests.
95
+
96
+ The predictor runs as a pre-execution check in `/fd-execute`:
97
+
98
+ 1. For each task in the plan, look up every file the task will modify in `VOLATILITY.json`
99
+ 2. Cross-reference with historical failure data in `SCORECARDS.jsonl` — if similar changes broke tests before, flag the task
100
+ 3. Assign a regression probability score (0.0–1.0) per task and per wave
101
+
102
+ **Output appended to PLAN.md:**
103
+
104
+ ```markdown
105
+ ## Regression Predictions
106
+
107
+ | Task | Files | Regression Probability | Flag |
108
+ |------|-------|----------------------|------|
109
+ | 1a: Write user model | src/models/user.ts | 0.15 | low |
110
+ | 1b: Refactor auth service | src/auth/login.ts | 0.72 | high — historically fragile |
111
+ | 2a: Integration tests | src/auth/*.test.ts | 0.31 | medium |
112
+ ```
113
+
114
+ Tasks flagged `high` are presented to the user before `CONFIRM` in `/fd-plan`. The user may choose to skip, refactor, or add additional test coverage before proceeding.
115
+
116
+ ---
117
+
118
+ ## Phase Gating
119
+
120
+ Phase gating enforces workflow discipline by blocking entry into a phase unless the prerequisites from the previous phase are satisfied.
121
+
122
+ | Transition | Gate |
123
+ |------------|------|
124
+ | `/fd-new-feature` → `/fd-discuss` | `DISCUSS.md` must exist and have at least 3 Q&A entries |
125
+ | `/fd-discuss` → `/fd-plan` | `DISCUSS.md` must have a risk summary section |
126
+ | `/fd-plan` → `/fd-execute` | User must type `CONFIRM`; no blockers in regression predictions |
127
+ | `/fd-execute` → `/fd-verify` | All plan tasks must be marked `done` or `skipped` |
128
+
129
+ If a gate check fails, the command exits with a descriptive error listing the missing prerequisites. The user resolves them before retrying.
130
+
131
+ Phase gating is implemented by the `guard-rails` hook running in `tool.execute.before` — it intercepts command invocations and validates prerequisites before the command logic runs.
132
+
133
+ ---
134
+
135
+ ## Intelligence Tool Summary
136
+
137
+ | Tool / Hook | Service | Purpose |
138
+ |-------------|---------|---------|
139
+ | `patch-trust` hook | Patch Trust Score | Score edits before application |
140
+ | `volatility-map` tool + hook | Volatility Map | Track per-file change frequency |
141
+ | `failure-replay` tool | Failure Replay | Reproduce and trace prior failures |
142
+ | Regression predictor (in `/fd-plan`) | Regression Prediction | Score planned changes for breakage risk |
143
+ | `guard-rails` hook | Phase Gating | Enforce workflow discipline at phase boundaries |
144
+ | `policy-engine` tool | Rule Compliance | Evaluate edits against project rules |
145
+ | `hash-edit` tool | Edit Hashing | Content-address edits for deduplication |
@@ -0,0 +1,227 @@
1
+ # Multi-Repo
2
+
3
+ FlowDeck can coordinate changes across multiple repositories in a single session. Each repository is registered with the session, assigned a role, and managed through the `/fd-multi-repo` command. Coordination state is persisted in `.planning/multi-repo/` so sessions can be resumed.
4
+
5
+ ---
6
+
7
+ ## /fd-multi-repo Command
8
+
9
+ The `fd-multi-repo` command is the entry point for all multi-repo operations. It supports four subcommands:
10
+
11
+ | Subcommand | Description |
12
+ |------------|-------------|
13
+ | `fd-multi-repo add <path> [role]` | Register a repository at `<path>` with an optional role |
14
+ | `fd-multi-repo remove <path>` | Unregister a repository |
15
+ | `fd-multi-repo list` | Print all registered repositories and their roles |
16
+ | `fd-multi-repo status` | Show sync state, pending changes, and divergence status |
17
+
18
+ **Roles** classify the repository's purpose in the session:
19
+
20
+ | Role | Meaning |
21
+ |------|---------|
22
+ | `primary` | The main development repository (default for the first added) |
23
+ | `library` | An internal library or shared module |
24
+ | `service` | A microservice or backend API |
25
+ | `frontend` | A frontend application |
26
+ | `config` | A configuration or infrastructure repository |
27
+
28
+ The role determines how FlowDeck routes planning and which agents are responsible for changes to that repo.
29
+
30
+ ### Adding a Repository
31
+
32
+ ```bash
33
+ fd-multi-repo add /home/user/project-lib library
34
+ ```
35
+
36
+ This:
37
+
38
+ 1. Verifies the path exists and is a git repository
39
+ 2. Reads the `flowdeck.json` config if present in that repo
40
+ 3. Records the repo in `.planning/multi-repo/REPOSITORIES.json`
41
+ 4. Runs `/fd-map-codebase` on the new repository to index it into `.codebase/<repo-name>/`
42
+
43
+ ### Removing a Repository
44
+
45
+ ```bash
46
+ fd-multi-repo remove /home/user/project-lib
47
+ ```
48
+
49
+ This removes the repository from `REPOSITORIES.json` and deletes its `.codebase/<repo-name>/` index. It does not delete any files.
50
+
51
+ ---
52
+
53
+ ## Coordination State
54
+
55
+ All multi-repo state lives under `.planning/multi-repo/`:
56
+
57
+ ```
58
+ .planning/multi-repo/
59
+ REPOSITORIES.json — registered repos, roles, paths
60
+ CHANGES.json — pending cross-repo changes
61
+ DEPENDENCIES.json — dependency graph between repos
62
+ SYNC.json — sync status and divergence flags
63
+ ```
64
+
65
+ ### REPOSITORIES.json
66
+
67
+ ```json
68
+ {
69
+ "repositories": [
70
+ {
71
+ "name": "flowdeck",
72
+ "path": "/home/user/flowdeck",
73
+ "role": "primary",
74
+ "addedAt": "2026-05-26T08:00:00Z",
75
+ "lastSynced": "2026-05-26T10:00:00Z"
76
+ },
77
+ {
78
+ "name": "flowdeck-lib",
79
+ "path": "/home/user/flowdeck-lib",
80
+ "role": "library",
81
+ "addedAt": "2026-05-26T08:05:00Z",
82
+ "lastSynced": "2026-05-26T09:55:00Z"
83
+ }
84
+ ]
85
+ }
86
+ ```
87
+
88
+ ### CHANGES.json
89
+
90
+ Tracks planned or in-progress changes that span multiple repositories:
91
+
92
+ ```json
93
+ {
94
+ "changes": [
95
+ {
96
+ "id": "ch-001",
97
+ "description": "Add telemetry API to flowdeck-lib",
98
+ "status": "planned",
99
+ "affectedRepos": ["flowdeck-lib", "flowdeck"],
100
+ "planRef": ".planning/PLAN.md#ch-001"
101
+ }
102
+ ]
103
+ }
104
+ ```
105
+
106
+ ### DEPENDENCIES.json
107
+
108
+ Records declared dependencies between repositories (e.g., `flowdeck` imports `flowdeck-lib`):
109
+
110
+ ```json
111
+ {
112
+ "dependencies": [
113
+ {
114
+ "from": "flowdeck",
115
+ "to": "flowdeck-lib",
116
+ "type": "import",
117
+ "files": ["src/lib/telemetry.ts"]
118
+ }
119
+ ]
120
+ }
121
+ ```
122
+
123
+ Dependencies are inferred from import analysis during `/fd-map-codebase` but can be manually overridden in `flowdeck.json`.
124
+
125
+ ---
126
+
127
+ ## Cross-Repo Planning
128
+
129
+ When `/fd-plan` runs in a multi-repo session:
130
+
131
+ 1. The `@planner` agent reads `DISCUSS.md` and `FEATURE.md` as usual
132
+ 2. For each planned task, it checks `DEPENDENCIES.json` to determine which repository the task belongs to
133
+ 3. Tasks are organized by repository, then by wave within each repository
134
+ 4. Tasks that span multiple repositories (e.g., adding an API to a library and updating callers in the primary) are marked as **cross-repo tasks** and placed in a shared wave
135
+
136
+ **Cross-repo wave execution:**
137
+
138
+ ```
139
+ Wave 1 (parallel across repos)
140
+ ├── [flowdeck-lib] Task 1a: Add telemetry API → @coder (flowdeck-lib)
141
+ └── [flowdeck] Task 1b: Update telemetry callers → @coder (flowdeck)
142
+
143
+ Wave 2 (sequential, primary waits for library)
144
+ └── [flowdeck] Task 2a: Run integration tests → @tester
145
+ ```
146
+
147
+ The orchestrator enforces that all tasks in Wave 1 complete before Wave 2 begins, even across repositories.
148
+
149
+ ---
150
+
151
+ ## Cross-Repo Execution
152
+
153
+ During `/fd-execute`, the orchestrator:
154
+
155
+ 1. Iterates through waves
156
+ 2. For each wave, dispatches tasks to their target repositories in parallel
157
+ 3. Each agent operates in its assigned repository's working directory
158
+ 4. The `DEADLOCK_SIGNALS.jsonl` from each repository is aggregated into the primary repo's `.codebase/`
159
+ 5. If a task in one repository depends on output from another, the orchestrator waits for the source task to complete first
160
+
161
+ ### File Coordination
162
+
163
+ When a change in one repository depends on a change in another:
164
+
165
+ - The dependency is declared in `DEPENDENCIES.json`
166
+ - The planner ensures the source task runs before the dependent task
167
+ - If both repos are on the same filesystem, FlowDeck uses absolute paths
168
+ - If repos are on different machines, FlowDeck uses git worktree references or suggests a shared git remote
169
+
170
+ ---
171
+
172
+ ## Multi-Repo State Sync
173
+
174
+ Use `fd-multi-repo status` to see the current state:
175
+
176
+ ```
177
+ fd-multi-repo status
178
+
179
+ Repository: flowdeck (primary)
180
+ Path: /home/user/flowdeck
181
+ Role: primary
182
+ Last synced: 2026-05-26 10:00:00
183
+ Status: clean ✓
184
+
185
+ Repository: flowdeck-lib (library)
186
+ Path: /home/user/flowdeck-lib
187
+ Role: library
188
+ Last synced: 2026-05-26 09:55:00
189
+ Status: 2 commits ahead of remote
190
+ Pending:
191
+ - ch-001: Add telemetry API
192
+
193
+ Cross-repo changes:
194
+ ch-001: Add telemetry API to flowdeck-lib
195
+ Status: planned
196
+ Affects: flowdeck-lib, flowdeck
197
+ Blocker: none
198
+ ```
199
+
200
+ ---
201
+
202
+ ## Configuration
203
+
204
+ Declare multi-repo dependencies explicitly in `flowdeck.json` to override inferred dependencies:
205
+
206
+ ```json
207
+ {
208
+ "multiRepo": {
209
+ "repositories": [
210
+ {
211
+ "name": "flowdeck-lib",
212
+ "path": "/home/user/flowdeck-lib",
213
+ "role": "library"
214
+ }
215
+ ],
216
+ "dependencies": [
217
+ {
218
+ "from": "flowdeck",
219
+ "to": "flowdeck-lib",
220
+ "type": "import"
221
+ }
222
+ ]
223
+ }
224
+ }
225
+ ```
226
+
227
+ This is useful when FlowDeck cannot infer dependencies from imports (e.g., binary dependencies, API contracts, or generated files).
@@ -0,0 +1,205 @@
1
+ # Workflows
2
+
3
+ FlowDeck structures every feature through a six-step command cycle. Each step has a clear purpose, produces specific artifacts, and transitions the project state forward.
4
+
5
+ ## The Six-Step Cycle
6
+
7
+ ```
8
+ /fd-map-codebase
9
+
10
+
11
+ /fd-new-feature ─────────────────────────────────────────┐
12
+ │ │
13
+ ▼ │
14
+ /fd-discuss ─────────────────────────────────────────┐ │
15
+ │ │ │
16
+ ▼ │ │
17
+ /fd-plan ─────────────────────────────────────────┐ │ │
18
+ │ │ │ │
19
+ ▼ │ │ │
20
+ /fd-execute ──────────────────────────────────┐ │ │ │
21
+ │ │ │ │ │
22
+ ▼ │ │ │ │
23
+ /fd-verify ───────────────────────────────────┘ │ │ │
24
+ │ │ │
25
+ (loop back to /fd-new-feature) ◄───┘ └───┘
26
+ ```
27
+
28
+ Each command reads the current `STATE.md` and writes updated state when it completes. Use `/fd-checkpoint` at any time to save a mid-session snapshot and `/fd-resume` to restore it in a new session.
29
+
30
+ ---
31
+
32
+ ## /fd-map-codebase
33
+
34
+ **Purpose:** Analyse and index the codebase into structured `.codebase/` files — required before starting any feature.
35
+
36
+ **Files created:**
37
+ - `.codebase/CODEGRAPH.json`
38
+ - `.codebase/CONVENTIONS.md`
39
+ - `.codebase/CODEBASE_INDEX.md`
40
+
41
+ **Step-by-step:**
42
+
43
+ 1. Scan the project files and detect languages, frameworks, and patterns.
44
+ 2. Build a structured dependency graph and write it to `.codebase/CODEGRAPH.json`.
45
+ 3. Extract conventions and write them to `.codebase/CONVENTIONS.md`.
46
+ 4. Write a high-level index to `.codebase/CODEBASE_INDEX.md`.
47
+
48
+ ---
49
+
50
+ ## /fd-new-feature
51
+
52
+ **Purpose:** Define a new feature and initialize its context. Requires codebase mapping (`.codebase/`) to exist.
53
+
54
+ **Files created/modified:**
55
+ - `.planning/FEATURE.md` (created)
56
+ - `.planning/STATE.md` (created if missing, phase updated)
57
+ - `.planning/ROADMAP.md` (feature entry added)
58
+
59
+ **Step-by-step:**
60
+
61
+ 1. Verify `.codebase/` exists — error if not (codebase mapping is required first).
62
+ 2. Initialize `.planning/` and `STATE.md` lazily if they do not exist.
63
+ 3. Parse the feature description from the command argument.
64
+ 4. Create `FEATURE.md` with: feature name, summary, acceptance criteria, estimated complexity, related files.
65
+ 5. Append the feature to `ROADMAP.md` with status `pending`.
66
+ 6. Update `STATE.md` — set `phase: define`, `feature: <name>`, `status: in_progress`.
67
+
68
+ ---
69
+
70
+ ## /fd-discuss
71
+
72
+ **Purpose:** Pre-planning structured Q&A to capture design decisions before a plan is written.
73
+
74
+ **Files created/modified:**
75
+ - `.planning/DISCUSS.md` (created)
76
+ - `.planning/STATE.md` (phase updated)
77
+
78
+ **Step-by-step:**
79
+
80
+ 1. The `@discusser` agent asks a series of targeted questions covering: scope boundaries, edge cases, dependencies, non-functional requirements, and known risks.
81
+ 2. Each answer is recorded in `DISCUSS.md` under a corresponding heading.
82
+ 3. The `@risk-analyst` agent reviews the Q&A log and adds a risk summary section.
83
+ 4. `STATE.md` is updated — set `phase: discuss`, `status: ready_to_plan`.
84
+
85
+ The output of `/fd-discuss` is a signed decision log that the planner treats as authoritative input.
86
+
87
+ ---
88
+
89
+ ## /fd-plan
90
+
91
+ **Purpose:** Build a wave-structured execution plan from the discuss decisions.
92
+
93
+ **Files created/modified:**
94
+ - `.planning/PLAN.md` (created)
95
+ - `.planning/STATE.md` (phase updated)
96
+
97
+ **Step-by-step:**
98
+
99
+ 1. The `@planner` agent reads `DISCUSS.md`, `FEATURE.md`, and `PROJECT.md`.
100
+ 2. It breaks the feature into **waves** — groups of tasks that can run in parallel within a wave, with waves ordered sequentially.
101
+ 3. Each task records: description, responsible agent, files affected, rollback plan, and dependencies.
102
+ 4. The plan is written to `PLAN.md`.
103
+ 5. The user reviews the plan. Typing `CONFIRM` (case-insensitive) proceeds to execution; anything else aborts.
104
+ 6. `STATE.md` is updated — set `phase: plan_confirmed`, `status: ready_to_execute`.
105
+
106
+ Wave-structured planning prevents agents from blocking on tasks that could run in parallel. Wave 1 tasks that are independent run simultaneously. Wave 2 does not start until all Wave 1 tasks are complete.
107
+
108
+ ---
109
+
110
+ ## /fd-execute
111
+
112
+ **Purpose:** Implement the feature following TDD discipline, with parallel agent delegation.
113
+
114
+ **Files created/modified:**
115
+ - Implementation files (modified)
116
+ - `.planning/STATE.md` (phase updated)
117
+ - `.planning/PLAN.md` (tasks marked complete)
118
+
119
+ **Step-by-step:**
120
+
121
+ 1. The `@orchestrator` reads `PLAN.md` and iterates through waves.
122
+ 2. For each wave, it calls `run-pipeline` or `delegate` to invoke specialist agents in parallel:
123
+ - `@architect` — validates structural decisions before coding
124
+ - `@coder` — writes implementation following TDD (red/green/refactor)
125
+ - `@tester` — writes and runs tests alongside each implementation task
126
+ - `@reviewer` — reviews each completed task
127
+ 3. Each agent writes its output to the implementation files and updates `PLAN.md`.
128
+ 4. Governance hooks run after every tool execution — patch trust scoring, budget tracking, and deadlock detection.
129
+ 5. `STATE.md` is updated — set `phase: execute`, `status: in_progress`. On full completion, set `status: complete`.
130
+
131
+ If the deadlock detector triggers, execution pauses and the user is notified with the bounce signal.
132
+
133
+ ---
134
+
135
+ ## /fd-verify
136
+
137
+ **Purpose:** Full verification pipeline — tests, code review, security scan, and deploy check.
138
+
139
+ **Files created/modified:**
140
+ - Verification reports (printed to console)
141
+ - `.planning/STATE.md` (phase updated)
142
+ - `.codebase/SCORECARDS.jsonl` (new scorecard entry)
143
+
144
+ **Step-by-step:**
145
+
146
+ 1. Run the full test suite — `@tester` executes all test commands.
147
+ 2. Run `@reviewer` on every changed file since the last phase.
148
+ 3. Run `@policy-enforcer` to validate architectural constraint compliance.
149
+ 4. Run security scan (if configured) and deploy check (if configured).
150
+ 5. Compute and print the Workflow Scorecard (10 dimensions).
151
+ 6. Write a scorecard entry to `.codebase/SCORECARDS.jsonl`.
152
+ 7. Update `STATE.md` — set `phase: verify`, `status: verified` or `status: issues_found`.
153
+ 8. If issues are found, the user decides whether to loop back to `/fd-execute` or fix manually.
154
+
155
+ ---
156
+
157
+ ## State Transition Table
158
+
159
+ The following table shows how the key fields in `STATE.md` change at each phase:
160
+
161
+ | Field | `/fd-map-codebase` | `/fd-new-feature` | `/fd-discuss` | `/fd-plan` | `/fd-execute` | `/fd-verify` |
162
+ |-------|--------------------|-------------------|---------------|------------|---------------|--------------|
163
+ | `phase` | — | `define` | `discuss` | `plan_confirmed` | `execute` | `verify` |
164
+ | `status` | — | `in_progress` | `ready_to_plan` | `ready_to_execute` | `in_progress` → `complete` | `verified` |
165
+ | `feature` | — | set | — | — | — | — |
166
+ | `planConfirmed` | — | — | — | `true` | — | — |
167
+ | `checkpoint` | — | — | — | — | on `/fd-checkpoint` | — |
168
+
169
+ ---
170
+
171
+ ## Wave-Structured Execution
172
+
173
+ Wave structure is the mechanism that makes parallel execution safe.
174
+
175
+ ```
176
+ Wave 1 (parallel)
177
+ ├── Task 1a: Write user model → @coder
178
+ ├── Task 1b: Write auth service → @coder
179
+ └── Task 1c: Write user tests → @tester
180
+
181
+ Wave 2 (parallel, starts after all Wave 1 tasks complete)
182
+ ├── Task 2a: Integrate auth → @coder
183
+ └── Task 2b: Write integration → @tester
184
+ tests
185
+
186
+ Wave 3 (sequential)
187
+ └── Task 3a: Deploy configuration → @architect
188
+ ```
189
+
190
+ Dependencies between waves are explicit. Tasks within a wave are independent — no task in Wave 1 depends on another task in Wave 1. This maximizes parallelism while preserving ordering guarantees.
191
+
192
+ The orchestrator enforces wave ordering. It will not dispatch Wave 2 tasks until all Wave 1 tasks report completion. If a Wave 1 task fails, the orchestrator reports the failure and stops — Wave 2 is not entered.
193
+
194
+ ---
195
+
196
+ ## Mid-Session Checkpointing
197
+
198
+ Any step can be paused and resumed:
199
+
200
+ ```bash
201
+ /fd-checkpoint # Save current STATE.md snapshot
202
+ /fd-resume # Reload latest checkpoint and continue
203
+ ```
204
+
205
+ Checkpoints are written to `.planning/STATE.md`. The `/fd-resume` command reloads `STATE.md` and `PLAN.md` (if present) and reinitializes the context for the next phase step.