@dv.nghiem/flowdeck 0.3.8 → 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 (136) hide show
  1. package/README.md +13 -122
  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.map +1 -1
  9. package/dist/hooks/file-tracker.d.ts +6 -0
  10. package/dist/hooks/file-tracker.d.ts.map +1 -1
  11. package/dist/hooks/notifications.d.ts.map +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +752 -785
  14. package/dist/lib/completion-validator.d.ts +51 -0
  15. package/dist/lib/completion-validator.d.ts.map +1 -0
  16. package/dist/lib/recommended-question.d.ts +24 -0
  17. package/dist/lib/recommended-question.d.ts.map +1 -0
  18. package/dist/lib/research-gate.d.ts +97 -0
  19. package/dist/lib/research-gate.d.ts.map +1 -0
  20. package/dist/lib/research-gate.test.d.ts +2 -0
  21. package/dist/lib/research-gate.test.d.ts.map +1 -0
  22. package/dist/mcp/index.d.ts +14 -3
  23. package/dist/mcp/index.d.ts.map +1 -1
  24. package/dist/services/codegraph.d.ts +36 -0
  25. package/dist/services/codegraph.d.ts.map +1 -0
  26. package/dist/services/codegraph.test.d.ts +2 -0
  27. package/dist/services/codegraph.test.d.ts.map +1 -0
  28. package/dist/services/command-validator.d.ts +11 -0
  29. package/dist/services/command-validator.d.ts.map +1 -1
  30. package/dist/services/preflight-explorer.d.ts +130 -0
  31. package/dist/services/preflight-explorer.d.ts.map +1 -0
  32. package/dist/services/preflight-explorer.test.d.ts +25 -0
  33. package/dist/services/preflight-explorer.test.d.ts.map +1 -0
  34. package/dist/services/question-guard.d.ts +96 -0
  35. package/dist/services/question-guard.d.ts.map +1 -0
  36. package/dist/services/quick-router.d.ts +40 -1
  37. package/dist/services/quick-router.d.ts.map +1 -1
  38. package/dist/services/recommended-question.test.d.ts +2 -0
  39. package/dist/services/recommended-question.test.d.ts.map +1 -0
  40. package/dist/services/supervisor-binding.d.ts +3 -1
  41. package/dist/services/supervisor-binding.d.ts.map +1 -1
  42. package/dist/tools/codebase-index.d.ts +30 -0
  43. package/dist/tools/codebase-index.d.ts.map +1 -0
  44. package/dist/tools/codebase-index.test.d.ts +2 -0
  45. package/dist/tools/codebase-index.test.d.ts.map +1 -0
  46. package/dist/tools/codegraph-tool.d.ts +3 -0
  47. package/dist/tools/codegraph-tool.d.ts.map +1 -0
  48. package/dist/tools/planning-state-lib.d.ts +23 -0
  49. package/dist/tools/planning-state-lib.d.ts.map +1 -1
  50. package/docs/agents/index.md +154 -0
  51. package/docs/commands/fd-ask.md +71 -39
  52. package/docs/commands/fd-checkpoint.md +63 -8
  53. package/docs/commands/fd-deploy-check.md +166 -9
  54. package/docs/commands/fd-design.md +101 -0
  55. package/docs/commands/fd-discuss.md +87 -20
  56. package/docs/commands/fd-doctor.md +100 -13
  57. package/docs/commands/fd-done.md +215 -0
  58. package/docs/commands/fd-execute.md +104 -0
  59. package/docs/commands/fd-fix-bug.md +144 -24
  60. package/docs/commands/fd-map-codebase.md +85 -21
  61. package/docs/commands/fd-multi-repo.md +155 -40
  62. package/docs/commands/fd-new-feature.md +63 -19
  63. package/docs/commands/fd-plan.md +80 -27
  64. package/docs/commands/fd-quick.md +143 -29
  65. package/docs/commands/fd-reflect.md +81 -13
  66. package/docs/commands/fd-resume.md +65 -8
  67. package/docs/commands/fd-status.md +80 -12
  68. package/docs/commands/fd-suggest.md +114 -0
  69. package/docs/commands/fd-translate-intent.md +69 -9
  70. package/docs/commands/fd-verify.md +71 -14
  71. package/docs/commands/fd-write-docs.md +121 -8
  72. package/docs/concepts/architecture.md +163 -0
  73. package/docs/concepts/governance.md +242 -0
  74. package/docs/concepts/intelligence.md +145 -0
  75. package/docs/concepts/multi-repo.md +227 -0
  76. package/docs/concepts/workflows.md +205 -0
  77. package/docs/configuration/index.md +208 -0
  78. package/docs/configuration/opencode-settings.md +98 -0
  79. package/docs/getting-started/first-project.md +126 -0
  80. package/docs/getting-started/installation.md +73 -0
  81. package/docs/getting-started/quick-start.md +74 -0
  82. package/docs/index.md +36 -72
  83. package/docs/reference/hooks.md +176 -0
  84. package/docs/reference/rules.md +109 -0
  85. package/docs/skills/code-review.md +47 -0
  86. package/docs/skills/index.md +148 -0
  87. package/docs/skills/planning.md +39 -0
  88. package/package.json +1 -1
  89. package/src/commands/fd-deploy-check.md +2 -2
  90. package/src/commands/fd-discuss.md +128 -7
  91. package/src/commands/fd-done.md +196 -0
  92. package/src/commands/fd-execute.md +43 -6
  93. package/src/commands/fd-fix-bug.md +43 -6
  94. package/src/commands/fd-map-codebase.md +100 -20
  95. package/src/commands/fd-multi-repo.md +1 -1
  96. package/src/commands/fd-new-feature.md +14 -5
  97. package/src/commands/fd-plan.md +38 -1
  98. package/src/commands/fd-quick.md +77 -14
  99. package/src/commands/fd-resume.md +1 -1
  100. package/src/commands/fd-status.md +1 -1
  101. package/src/commands/fd-verify.md +16 -2
  102. package/src/commands/fd-write-docs.md +30 -5
  103. package/src/rules/common/behavioral.md +63 -0
  104. package/src/skills/codebase-mapping/SKILL.md +1 -1
  105. package/src/skills/context-load/SKILL.md +1 -1
  106. package/src/skills/multi-repo/SKILL.md +1 -1
  107. package/src/skills/repo-memory-graph/SKILL.md +1 -1
  108. package/dist/hooks/memory-hook.d.ts +0 -28
  109. package/dist/hooks/memory-hook.d.ts.map +0 -1
  110. package/dist/services/memory-store.d.ts +0 -73
  111. package/dist/services/memory-store.d.ts.map +0 -1
  112. package/dist/services/memory-store.test.d.ts +0 -2
  113. package/dist/services/memory-store.test.d.ts.map +0 -1
  114. package/dist/tools/memory-search.d.ts +0 -3
  115. package/dist/tools/memory-search.d.ts.map +0 -1
  116. package/dist/tools/memory-status.d.ts +0 -3
  117. package/dist/tools/memory-status.d.ts.map +0 -1
  118. package/docs/USER_GUIDE.md +0 -20
  119. package/docs/agents.md +0 -544
  120. package/docs/best-practices.md +0 -47
  121. package/docs/commands/fd-new-project.md +0 -24
  122. package/docs/commands.md +0 -557
  123. package/docs/configuration.md +0 -325
  124. package/docs/design-first-workflow.md +0 -94
  125. package/docs/feature-integration-architecture.md +0 -227
  126. package/docs/installation.md +0 -123
  127. package/docs/intelligence.md +0 -370
  128. package/docs/memory.md +0 -69
  129. package/docs/multi-repo.md +0 -201
  130. package/docs/notifications.md +0 -170
  131. package/docs/optimization-baseline.md +0 -21
  132. package/docs/quick-start.md +0 -197
  133. package/docs/rules.md +0 -432
  134. package/docs/skills.md +0 -417
  135. package/docs/workflows.md +0 -134
  136. package/src/commands/fd-new-project.md +0 -114
@@ -0,0 +1,215 @@
1
+ # /fd-done
2
+
3
+ **Purpose:** Mark a feature or phase complete, validate readiness, finalize state, and refresh the codebase mapping.
4
+
5
+ ## Usage
6
+
7
+ /fd-done [--skip-verify] [--phase=N]
8
+
9
+ ## Arguments
10
+
11
+ - `--skip-verify` (optional) — allow closing without a prior `/fd-verify` run
12
+ - `--phase=N` (optional) — target a specific phase
13
+
14
+ ## What Happens
15
+
16
+ ### Step 0: Pre-flight
17
+
18
+ 1. Check `.planning/STATE.md` exists. If not: error "No active feature. Run `/fd-map-codebase` then `/fd-new-feature` to start a feature."
19
+ 2. Read current STATE.md using `planning_state action=read`.
20
+ 3. Record: `phase`, `status`, `plan_confirmed`, `blockers`, `steps_complete`, `requires_design_first`, `design_stage`, `design_approved`.
21
+
22
+ ### Step 1: Completion Readiness Validation
23
+
24
+ Before marking done, verify the workflow is in a finishable state.
25
+
26
+ | Check | Pass condition |
27
+ |-------|---------------|
28
+ | Plan confirmed | `plan_confirmed: true` |
29
+ | Not already done | `status != "complete"` |
30
+ | Work has started | `status != "planned"` OR `steps_complete` is non-empty |
31
+ | No active blockers | `blockers` list is empty or contains only `"none"` |
32
+ | Design gate (if required) | `requires_design_first: false` OR `design_stage: handoff_complete` AND `design_approved: true` OR `design_override: true` |
33
+
34
+ If any check fails, stop and report all failures. Do NOT update any state when validation fails.
35
+
36
+ **Verify check:**
37
+ - If `status != "verified"` and `--skip-verify` was NOT passed: warn that `/fd-verify` has not been run
38
+ - If `--skip-verify` is passed: log that verification was skipped
39
+
40
+ ### Step 2: Collect Completion Evidence
41
+
42
+ Gather files changed in this feature:
43
+ ```bash
44
+ git diff --name-only HEAD
45
+ git diff --name-only HEAD~1..HEAD 2>/dev/null || echo "(no commits yet)"
46
+ ```
47
+
48
+ Record `changedFiles[]` for the summary artifact.
49
+
50
+ ### Step 3: Codebase Mapping — Refresh or Reuse
51
+
52
+ Check codegraph state: `codegraph action=status`
53
+
54
+ - **If mapping is fresh** (indexed, `freshnessStatus: fresh`, no changed files since last index):
55
+ - Log: "[fd-done] Codebase mapping is current — skipping remap"
56
+ - Record: `mappingRefreshed: false`, `mappingFreshnessStatus: fresh`
57
+
58
+ - **If mapping is stale, absent, or changed files exist since last index:**
59
+ - Log: "[fd-done] Refreshing codebase mapping..."
60
+ - Run: `codegraph action=refresh agent=fd-done`
61
+ - Record result: `mappingRefreshed: true`, `mappingFreshnessStatus: fresh|stale`
62
+ - If refresh fails: log error, set `mappingFreshnessStatus: stale`, continue — do not abort
63
+
64
+ ### Step 4: Mark Feature Complete
65
+
66
+ Update STATE.md:
67
+ ```
68
+ planning_state action=update updates={
69
+ status: "complete",
70
+ last_action: "Phase <N> marked done via /fd-done",
71
+ next_action: "Run /fd-status to review project state, or /fd-new-feature to start the next phase"
72
+ }
73
+ ```
74
+
75
+ Additional fields to upsert:
76
+ ```
77
+ completed_at: "<ISO timestamp>"
78
+ completed_by: "fd-done"
79
+ verify_skipped: <true|false>
80
+ mapping_refreshed_at_done: "<ISO timestamp if refreshed, else skipped>"
81
+ mapping_freshness_at_done: "<fresh|stale|skipped>"
82
+ ```
83
+
84
+ ### Step 5: Write Completion Artifact
85
+
86
+ Write `.planning/phases/phase-<N>/DONE.md`:
87
+ ```markdown
88
+ # Phase <N> — Done
89
+
90
+ **Completed:** <ISO timestamp>
91
+ **Completed by:** fd-done
92
+ **Prior status:** <status before this run>
93
+ **Steps complete:** <list>
94
+
95
+ ## Verification
96
+
97
+ ✅ /fd-verify ran — all checks passed before closing
98
+ — OR —
99
+ ⚠️ /fd-verify not run — skipped by user (--skip-verify)
100
+ — OR —
101
+ ⚠️ /fd-verify not run — consider running before deploying
102
+
103
+ ## Codebase Mapping
104
+
105
+ ✅ Codebase mapping refreshed (status: fresh)
106
+ — OR —
107
+ ℹ️ Codebase mapping reused — already fresh (status: fresh)
108
+ — OR —
109
+ ⚠️ Codebase mapping refresh failed (status: stale)
110
+
111
+ ## Changed Files
112
+
113
+ - <file 1>
114
+ - <file 2>
115
+ ...
116
+
117
+ ## Next Steps
118
+
119
+ - Run `/fd-status` to see the full project state
120
+ - Run `/fd-new-feature` or increment the phase to start the next feature
121
+ - Run `/fd-deploy-check` if preparing for production deployment
122
+ ```
123
+
124
+ ### Step 6: Update ROADMAP.md (if present)
125
+
126
+ If `.planning/ROADMAP.md` exists:
127
+ - Find the entry for Phase N
128
+ - Update its status to `completed`
129
+ - Preserve all other phases unchanged
130
+
131
+ ### Step 7: Report Completion
132
+
133
+ Print final summary with completion timestamp, prior status, steps complete, changed files count, verification status, and mapping freshness.
134
+
135
+ ## Error Handling
136
+
137
+ - STATE.md not found → error with remediation ("No active feature. Run `/fd-map-codebase` then `/fd-new-feature` to start a feature.")
138
+ - Completion validation fails → list all failures, do not update state
139
+ - Mapping refresh fails → log error, continue with `mappingFreshnessStatus: stale`
140
+ - DONE.md write fails → log error, do not fail overall — state is already updated
141
+ - ROADMAP.md update fails → log error, do not fail overall
142
+
143
+ No partial state writes. Either the validation passes and full state is written, or nothing is written.
144
+
145
+ ## Output / State
146
+
147
+ - `.planning/STATE.md` — status set to `complete`
148
+ - `.planning/phases/phase-<N>/DONE.md` — completion artifact written
149
+ - `.planning/ROADMAP.md` — phase marked as completed (if exists)
150
+ - Codebase mapping refreshed (if needed)
151
+
152
+ ### DONE.md Artifact Format
153
+
154
+ The completion artifact at `.planning/phases/phase-<N>/DONE.md` uses this structure:
155
+
156
+ ```markdown
157
+ # Phase <N> — Done
158
+
159
+ **Completed:** <ISO timestamp>
160
+ **Completed by:** fd-done
161
+ **Prior status:** <status before this run>
162
+ **Steps complete:** <list>
163
+
164
+ ## Verification
165
+
166
+ ✅ /fd-verify ran — all checks passed before closing
167
+ — OR —
168
+ ⚠️ /fd-verify not run — skipped by user (--skip-verify)
169
+ — OR —
170
+ ⚠️ /fd-verify not run — consider running before deploying
171
+
172
+ ## Codebase Mapping
173
+
174
+ ✅ Codebase mapping refreshed (status: fresh)
175
+ — OR —
176
+ ℹ️ Codebase mapping reused — already fresh (status: fresh)
177
+ — OR —
178
+ ⚠️ Codebase mapping refresh failed (status: stale)
179
+
180
+ ## Changed Files
181
+
182
+ - <file 1>
183
+ - <file 2>
184
+ ...
185
+
186
+ ## Next Steps
187
+
188
+ - Run `/fd-status` to see the full project state
189
+ - Run `/fd-new-feature` or increment the phase to start the next feature
190
+ - Run `/fd-deploy-check` if preparing for production deployment
191
+ ```
192
+
193
+ ## Examples
194
+
195
+ **Mark current phase complete:**
196
+ ```
197
+ /fd-done
198
+ ```
199
+
200
+ **Mark specific phase complete:**
201
+ ```
202
+ /fd-done --phase=2
203
+ ```
204
+
205
+ **Close without prior verification:**
206
+ ```
207
+ /fd-done --skip-verify
208
+ ```
209
+
210
+ ## Related Commands
211
+
212
+ - `/fd-status` — review the completed project state
213
+ - `/fd-new-feature` — start the next feature
214
+ - `/fd-deploy-check` — pre-deployment checks after completing a phase
215
+ - `/fd-verify` — full verification before marking done (recommended)
@@ -0,0 +1,104 @@
1
+ # /fd-execute
2
+
3
+ **Purpose:** Implement the current phase's plan using TDD discipline and a parallel agent pipeline — delegates to specialist agents via orchestrator, cycles through RED-GREEN-REFACTOR per step, and updates STATE.md throughout.
4
+
5
+ ## Usage
6
+
7
+ /fd-execute [--phase=N] [--override]
8
+
9
+ ## What Happens
10
+
11
+ 1. **Research gate (before touching any code).**
12
+ - CodeGraph intelligence check (`codegraph action=check`)
13
+ - If indexed and fresh: use `codegraph_context` and `codegraph_impact`
14
+ - Standard pre-flight: verify STATE.md freshness, check CODEBASE_INDEX.md for changes since plan was written
15
+ - Reuse persisted research if fresh; run fresh pass and persist if stale
16
+ - Verify design handoff is complete if `requires_design_first: true`
17
+
18
+ 2. **Guard check.**
19
+ - Verify `.planning/` and `.codebase/` exist
20
+ - Verify `plan_confirmed: true` in STATE.md
21
+ - Verify PLAN.md exists in current phase directory
22
+ - If `requires_design_first: true`: require `design_stage: handoff_complete` and `design_approved: true` (or `--override` with logged reason)
23
+ - Initialize TDD state (`stage: behavior`, `cycle: 1`)
24
+
25
+ 3. **Load PLAN.md.** Parse tasks and identify which steps are already complete.
26
+
27
+ 4. **TDD cycle per step** (repeat for each incomplete step):
28
+
29
+ a. **Define behaviors** — spawn `@orchestrator` to generate behavior checklist from the step
30
+
31
+ b. **RED** — spawn `@tester` to write failing tests (tests MUST fail before implementation)
32
+
33
+ c. **Confirm RED** — run failing tests; block until tests fail
34
+
35
+ d. **GREEN** — spawn appropriate implementation agent (`@backend-coder`, `@frontend-coder`, or `@devops`) to write minimum code to pass the failing tests
36
+
37
+ e. **Confirm GREEN** — run tests; block until they pass; return to (d) if they fail
38
+
39
+ f. **REFACTOR** — clean up code (only if GREEN); block if not GREEN
40
+
41
+ g. **Verify** — run full test suite; revert refactoring if any test fails
42
+
43
+ h. **Review step** — spawn `@reviewer` to check quality, security, TDD discipline, >= 80% test coverage
44
+
45
+ i. **Update STATE.md** — mark step complete, increment TDD cycle
46
+
47
+ j. **Refresh codegraph index** — run `codegraph action=refresh agent=fd-execute` after each source change
48
+
49
+ 5. **Wave-based execution.** Wave 1 steps execute first; Wave 2 after Wave 1; Wave 3 after Wave 2. No intra-wave dependencies.
50
+
51
+ 6. **Complete phase.**
52
+ - Update phase status to `complete` in STATE.md
53
+ - Update ROADMAP.md progress
54
+ - Present completion summary
55
+
56
+ ## Output / State
57
+
58
+ STATE.md per-step update:
59
+ ```yaml
60
+ steps_complete: [1, 2]
61
+ steps_pending: [3, 4, 5]
62
+ last_action: "Step 2 TDD complete: [behavior] (RED→GREEN→REFACTOR)"
63
+ tdd:
64
+ stage: behavior
65
+ cycle: 2
66
+ behaviors_completed: 2
67
+ ```
68
+
69
+ STATE.md on full phase completion:
70
+ ```yaml
71
+ status: complete
72
+ last_action: "Phase N TDD complete — all steps finished"
73
+ tdd:
74
+ stage: complete
75
+ cycles_used: N
76
+ behaviors_completed: M
77
+ ```
78
+
79
+ ## Examples
80
+
81
+ ```
82
+ /fd-execute
83
+ ```
84
+
85
+ Run the TDD pipeline for all steps in the current phase's PLAN.md.
86
+
87
+ ```
88
+ /fd-execute --phase=2
89
+ ```
90
+
91
+ Execute phase 2's plan instead of the current phase.
92
+
93
+ ```
94
+ /fd-execute --override
95
+ ```
96
+
97
+ Override design-first requirement (with logged reason). Use sparingly.
98
+
99
+ ## Related Commands
100
+
101
+ - `/fd-plan` — create the plan before executing
102
+ - `/fd-verify` — run full verification after execution
103
+ - `/fd-resume` — reload state and continue if execution was interrupted
104
+ - `/fd-checkpoint` — save checkpoint before a long execution session
@@ -1,24 +1,144 @@
1
- ---
2
- description: Debug and fix a bug — scope analysis, mini-plan, implementation-agent fix, regression test, reviewer confirmation
3
- argument-hint: "[bug description or issue number]"
4
- ---
5
-
6
- Systematically debug and fix a bug using FlowDeck's structured approach.
7
-
8
- **What this does:**
9
- 1. Reads `.codebase/` for architecture context
10
- 2. Delegates to `@debug-specialist` to locate the root cause
11
- 3. Creates a mini-plan (fix + regression test)
12
- 4. Delegates fix to `@backend-coder`, `@frontend-coder`, or `@devops` based on scope
13
- 5. Delegates regression test writing to `@tester`
14
- 6. Verifies the fix via `@reviewer`
15
- 7. Writes a brief post-mortem to `.planning/bugs/`
16
-
17
- **Root cause first:** Does not implement a fix until root cause is confirmed — no symptom masking.
18
-
19
- ## What Next?
20
-
21
- 1. **Run code review** → `/fd-verify`
22
- 2. **Check for more bugs** → `/fd-fix-bug [next-issue]`
23
- 3. **Update documentation**`/fd-write-docs`
24
- 4. **Deploy check** → `/fd-deploy-check`
1
+ # /fd-fix-bug
2
+
3
+ **Purpose:** Diagnose, fix, and verify a bug using TDD-based workflow with regression test.
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ /fd-fix-bug [bug description] [--scope=path]
9
+ ```
10
+
11
+ **Note:** `bug description` is required. `--scope=path` is optional.
12
+
13
+ ## Arguments
14
+
15
+ - `bug description` description of the bug or reproduction steps
16
+ - `--scope=path` (optional) — limit search scope to a specific path
17
+
18
+ ## What Happens
19
+
20
+ The workflow enforces the TDD cycle with guards at each transition:
21
+
22
+ ```
23
+ BEHAVIOR REDGREEN → REFACTOR → complete
24
+ ↑______________| |
25
+ (loop if needed) |
26
+ Only if GREEN
27
+ ```
28
+
29
+ ### Pre-flight: Research Gate
30
+
31
+ Before investigating the bug, inspect relevant context:
32
+
33
+ 1. Check codegraph availability (`codegraph action=check`). If indexed, use `codegraph_context`, `codegraph_callers`, `codegraph_callees`, and `codegraph_impact` for symbol-level understanding.
34
+ 2. Read `.planning/STATE.md` — current phase, freshness.
35
+ 3. Read `.codebase/FAILURES.json` — check for prior similar failures.
36
+ 4. Read `.codebase/ARCHITECTURE.md` and `.codebase/CODEGRAPH.md` if available.
37
+ 5. Check `research_fix-bug` evidence in STATE.md from prior research passes.
38
+ 6. Check recent changes via `git log --oneline -10` on relevant files.
39
+
40
+ If research is fresh (within 5 minutes), reuse it and log: "Research skipped — fresh evidence reused from prior pass."
41
+
42
+ ### Steps 1-2: Explore and Research
43
+
44
+ - **@researcher** investigates bug scope, traces root cause via ARCHITECTURE.md and source files.
45
+ - **@researcher** identifies all affected components and prior similar failures from FAILURES.json.
46
+ - Reproduce the bug with minimal case; document inputs and expected vs actual behavior.
47
+
48
+ ### Step 3: Define Behaviors
49
+
50
+ Write acceptance cases describing what should happen after the bug is fixed.
51
+
52
+ ### Step 4: Isolate Root Cause
53
+
54
+ - Trace the execution path.
55
+ - Read stack trace completely.
56
+ - Check recent changes: `git log --oneline -20 -- <file>`.
57
+ - Identify root cause (not symptom).
58
+
59
+ ### Step 5: RED — Write Failing Test
60
+
61
+ - **@tester** writes a regression test that reproduces the bug (it MUST fail right now).
62
+ - Show test output proving it fails.
63
+
64
+ **GUARD: Do NOT proceed if test does not fail RED.**
65
+
66
+ ### Step 6: GREEN — Implement Fix
67
+
68
+ - Implementation agent (`@backend-coder`, `@frontend-coder`, or `@devops`) implements the minimum code change that makes the regression test pass.
69
+ - Do not refactor yet.
70
+
71
+ **GUARD: Do NOT proceed if test does not pass GREEN.**
72
+
73
+ ### Step 7: REFACTOR
74
+
75
+ Clean up the implementation. Run tests again to confirm they still pass.
76
+
77
+ ### Steps 8-9: Full Suite and Review
78
+
79
+ - Run the full test suite. All tests must pass.
80
+ - **@reviewer** confirms fix is correct, no regressions, TDD discipline followed.
81
+
82
+ ### Step 10: Record
83
+
84
+ Append entry to `.codebase/FAILURES.json`:
85
+ ```json
86
+ {
87
+ "id": "F-<N>",
88
+ "type": "bug",
89
+ "description": "<bug description>",
90
+ "affected_paths": ["<files changed>"],
91
+ "root_cause": "<root cause>",
92
+ "fix_applied": "<fix summary>",
93
+ "regression_test": "<test file path>",
94
+ "resolved_at": "<timestamp>"
95
+ }
96
+ ```
97
+
98
+ Refresh the codegraph index after recording:
99
+ ```
100
+ codegraph action=refresh agent=fd-fix-bug
101
+ ```
102
+
103
+ ## Guards Summary
104
+
105
+ | Transition | Guard | If Violated |
106
+ |-----------|-------|-------------|
107
+ | behavior → red | Test written and fails | Block until test fails |
108
+ | red → green | Test exists and fails | Block until test passes |
109
+ | green → refactor | Tests are green | Block until green |
110
+ | refactor → complete | All tests pass | Block until all pass |
111
+
112
+ ## Error Handling
113
+
114
+ - **GUARD VIOLATION**: If implementation agent attempts to skip RED or GREEN phase, block and return to correct phase.
115
+ - **Override mechanism**: User can override with `/fd-fix-bug --override` but every override is logged in `override_log`.
116
+ - If root cause unclear: spawn `@debug-specialist` for deeper analysis.
117
+ - If fix breaks tests: revert, reassess root cause, never suppress error.
118
+
119
+ ## Output / State
120
+
121
+ - Root cause identified
122
+ - Fix applied to affected files
123
+ - Regression test created at `<test file path>`
124
+ - Reviewer sign-off received
125
+ - Entry appended to `.codebase/FAILURES.json`
126
+ - Codegraph index refreshed
127
+
128
+ ## Examples
129
+
130
+ **Fix a bug with description:**
131
+ ```
132
+ /fd-fix-bug "Login fails when password contains special characters"
133
+ ```
134
+
135
+ **Fix a bug scoped to a specific path:**
136
+ ```
137
+ /fd-fix-bug "Session timeout error" --scope=src/auth
138
+ ```
139
+
140
+ ## Related Commands
141
+
142
+ - `/fd-verify` — run full verification suite after fix
143
+ - `/fd-discuss` — investigate before filing a bug report
144
+ - `/fd-deploy-check` — run pre-deployment checks after fix is complete
@@ -1,27 +1,91 @@
1
- ---
2
- description: Map the codebase structure into .codebase/ files for AI context
3
- argument-hint: "[--full] [--update]"
4
- ---
1
+ # /fd-map-codebase
5
2
 
6
- Analyze and document the codebase for AI agent context.
3
+ **Purpose:** Analyze and index the codebase into structured `.codebase/` documentation files.
7
4
 
8
- **What this does:**
9
- 1. Scans the project structure (entry points, modules, dependencies)
10
- 2. Identifies key files, patterns, and conventions
11
- 3. Writes structured summaries to `.codebase/`:
12
- - `ARCHITECTURE.md` — high-level system design
13
- - `CONVENTIONS.md` — naming, style, and patterns used in this project
14
- - `DEPENDENCIES.md` — external packages and what they're used for
15
- - `INDEX.md` — file-by-file inventory
5
+ ## Usage
16
6
 
17
- **Flags:**
18
- - `--full` — Deep scan (reads every file, slower but thorough)
19
- - `--update` — Refresh existing `.codebase/` files with recent changes
7
+ /fd-map-codebase [--incremental] [--force]
20
8
 
21
- **Why this matters:** Agents use `.codebase/` for context instead of re-scanning on every task.
9
+ ## Arguments
22
10
 
23
- ## What Next?
11
+ - `--incremental` — only update files where the underlying source has changed since the last mapping
12
+ - `--force` — skip the existing-index confirmation prompt and rebuild from scratch
24
13
 
25
- 1. **Start discussion** → `/fd-discuss`
26
- 2. **Write documentation** → `/fd-write-docs`
27
- 3. **View dashboard** → `/fd-dashboard`
14
+ ## What Happens
15
+
16
+ ### Pre-flight
17
+
18
+ 1. Check codegraph installation using `codegraph action=check`.
19
+ 2. Log the result: installed and indexed, installed but not indexed, or not installed.
20
+ 3. Auto-install codegraph if missing (`codegraph action=install`).
21
+ 4. Initialize or refresh the codegraph index (`codegraph action=init` or `codegraph action=refresh`).
22
+
23
+ ### Process
24
+
25
+ 1. Check if `.codebase/` documentation directory already exists. If it does and `--force` is not set, prompt for confirmation before overwriting.
26
+ 2. Initialize 6 isolated worktrees for parallel mapper agents:
27
+ - `flowdeck-mapper-stack`
28
+ - `flowdeck-mapper-arch`
29
+ - `flowdeck-mapper-structure`
30
+ - `flowdeck-mapper-conventions`
31
+ - `flowdeck-mapper-testing`
32
+ - `flowdeck-mapper-concerns`
33
+ 3. Spawn 6 `@mapper` agents in parallel, each producing one documentation file:
34
+ - `@mapper` → `.codebase/STACK.md` — tech stack, dependencies, versions
35
+ - `@mapper` → `.codebase/ARCHITECTURE.md` — system design, components, data flow
36
+ - `@mapper` → `.codebase/STRUCTURE.md` — file organization, directory layout
37
+ - `@mapper` → `.codebase/CONVENTIONS.md` — coding standards, naming, patterns
38
+ - `@mapper` → `.codebase/TESTING.md` — test strategy, coverage, frameworks
39
+ - `@mapper` → `.codebase/CONCERNS.md` — known issues, technical debt, risks
40
+
41
+ Each mapper uses codegraph MCP tools for symbol-level analysis, falling back to direct file reads when codegraph does not cover a specific detail.
42
+
43
+ ### Cleanup
44
+
45
+ Remove all worktrees regardless of outcome after agents complete.
46
+
47
+ ### Verify
48
+
49
+ Check that all 6 doc files exist and contain non-empty content.
50
+
51
+ ### Finalize
52
+
53
+ 1. Write timestamp to `.codebase/last_mapped`.
54
+ 2. Update codegraph state with `codegraph action=status`.
55
+
56
+ ## Output / State
57
+
58
+ Files created in `.codebase/`:
59
+ - `STACK.md` — technology stack and dependencies
60
+ - `ARCHITECTURE.md` — system architecture and component relationships
61
+ - `STRUCTURE.md` — directory layout and file organization
62
+ - `CONVENTIONS.md` — coding standards and patterns
63
+ - `TESTING.md` — test coverage and frameworks
64
+ - `CONCERNS.md` — technical debt and known risks
65
+ - `last_mapped` — timestamp file
66
+ - `CODEGRAPH.md` — codegraph index status
67
+
68
+ Report includes: codegraph install/index status, files created per mapper, key findings per category.
69
+
70
+ ## Examples
71
+
72
+ **Full codebase mapping:**
73
+ ```
74
+ /fd-map-codebase
75
+ ```
76
+
77
+ **Incremental update (only changed files):**
78
+ ```
79
+ /fd-map-codebase --incremental
80
+ ```
81
+
82
+ **Force rebuild (skip confirmation):**
83
+ ```
84
+ /fd-map-codebase --force
85
+ ```
86
+
87
+ ## Related Commands
88
+
89
+ - `/fd-doctor` — check environment health including codegraph status
90
+ - `/fd-discuss` — uses codegraph for code intelligence during discussions
91
+ - `/fd-plan` — uses codegraph for impact analysis during planning