@dv.nghiem/flowdeck 0.1.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 (331) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +136 -0
  3. package/bin/flowdeck.js +108 -0
  4. package/dist/agents/architect.d.ts +3 -0
  5. package/dist/agents/architect.d.ts.map +1 -0
  6. package/dist/agents/code-explorer.d.ts +3 -0
  7. package/dist/agents/code-explorer.d.ts.map +1 -0
  8. package/dist/agents/coder.d.ts +3 -0
  9. package/dist/agents/coder.d.ts.map +1 -0
  10. package/dist/agents/debug.d.ts +4 -0
  11. package/dist/agents/debug.d.ts.map +1 -0
  12. package/dist/agents/doc-updater.d.ts +3 -0
  13. package/dist/agents/doc-updater.d.ts.map +1 -0
  14. package/dist/agents/flowdeck.d.ts +5 -0
  15. package/dist/agents/flowdeck.d.ts.map +1 -0
  16. package/dist/agents/index.d.ts +38 -0
  17. package/dist/agents/index.d.ts.map +1 -0
  18. package/dist/agents/mapper.d.ts +3 -0
  19. package/dist/agents/mapper.d.ts.map +1 -0
  20. package/dist/agents/orchestrator.d.ts +10 -0
  21. package/dist/agents/orchestrator.d.ts.map +1 -0
  22. package/dist/agents/performance.d.ts +4 -0
  23. package/dist/agents/performance.d.ts.map +1 -0
  24. package/dist/agents/planner.d.ts +3 -0
  25. package/dist/agents/planner.d.ts.map +1 -0
  26. package/dist/agents/policy-enforcer.d.ts +3 -0
  27. package/dist/agents/policy-enforcer.d.ts.map +1 -0
  28. package/dist/agents/researcher.d.ts +3 -0
  29. package/dist/agents/researcher.d.ts.map +1 -0
  30. package/dist/agents/reviewer.d.ts +3 -0
  31. package/dist/agents/reviewer.d.ts.map +1 -0
  32. package/dist/agents/risk-analyst.d.ts +3 -0
  33. package/dist/agents/risk-analyst.d.ts.map +1 -0
  34. package/dist/agents/security-auditor.d.ts +3 -0
  35. package/dist/agents/security-auditor.d.ts.map +1 -0
  36. package/dist/agents/specialist.d.ts +5 -0
  37. package/dist/agents/specialist.d.ts.map +1 -0
  38. package/dist/agents/tester.d.ts +3 -0
  39. package/dist/agents/tester.d.ts.map +1 -0
  40. package/dist/agents/types.d.ts +20 -0
  41. package/dist/agents/types.d.ts.map +1 -0
  42. package/dist/agents/writer.d.ts +3 -0
  43. package/dist/agents/writer.d.ts.map +1 -0
  44. package/dist/commands/analysis/analysis.test.d.ts +2 -0
  45. package/dist/commands/analysis/analysis.test.d.ts.map +1 -0
  46. package/dist/commands/analysis/analyze-change.d.ts +148 -0
  47. package/dist/commands/analysis/analyze-change.d.ts.map +1 -0
  48. package/dist/commands/analysis/evaluate-risk.d.ts +77 -0
  49. package/dist/commands/analysis/evaluate-risk.d.ts.map +1 -0
  50. package/dist/commands/analysis/guarded-edit.d.ts +72 -0
  51. package/dist/commands/analysis/guarded-edit.d.ts.map +1 -0
  52. package/dist/commands/execution/deploy-check.d.ts +91 -0
  53. package/dist/commands/execution/deploy-check.d.ts.map +1 -0
  54. package/dist/commands/execution/fix-bug.d.ts +187 -0
  55. package/dist/commands/execution/fix-bug.d.ts.map +1 -0
  56. package/dist/commands/execution/new-feature.d.ts +171 -0
  57. package/dist/commands/execution/new-feature.d.ts.map +1 -0
  58. package/dist/commands/execution/review-code.d.ts +130 -0
  59. package/dist/commands/execution/review-code.d.ts.map +1 -0
  60. package/dist/commands/execution/write-docs.d.ts +94 -0
  61. package/dist/commands/execution/write-docs.d.ts.map +1 -0
  62. package/dist/commands/governance/approve.d.ts +80 -0
  63. package/dist/commands/governance/approve.d.ts.map +1 -0
  64. package/dist/commands/intelligence/blast-radius.d.ts +67 -0
  65. package/dist/commands/intelligence/blast-radius.d.ts.map +1 -0
  66. package/dist/commands/intelligence/impact-radar.d.ts +71 -0
  67. package/dist/commands/intelligence/impact-radar.d.ts.map +1 -0
  68. package/dist/commands/intelligence/intelligence.test.d.ts +2 -0
  69. package/dist/commands/intelligence/intelligence.test.d.ts.map +1 -0
  70. package/dist/commands/intelligence/regression-predict.d.ts +75 -0
  71. package/dist/commands/intelligence/regression-predict.d.ts.map +1 -0
  72. package/dist/commands/intelligence/review-route.d.ts +65 -0
  73. package/dist/commands/intelligence/review-route.d.ts.map +1 -0
  74. package/dist/commands/intelligence/test-gap.d.ts +73 -0
  75. package/dist/commands/intelligence/test-gap.d.ts.map +1 -0
  76. package/dist/commands/intelligence/translate-intent.d.ts +87 -0
  77. package/dist/commands/intelligence/translate-intent.d.ts.map +1 -0
  78. package/dist/commands/intelligence/volatility-map-cmd.d.ts +68 -0
  79. package/dist/commands/intelligence/volatility-map-cmd.d.ts.map +1 -0
  80. package/dist/commands/planning/ask.d.ts +62 -0
  81. package/dist/commands/planning/ask.d.ts.map +1 -0
  82. package/dist/commands/planning/ask.test.d.ts +2 -0
  83. package/dist/commands/planning/ask.test.d.ts.map +1 -0
  84. package/dist/commands/planning/dashboard.d.ts +30 -0
  85. package/dist/commands/planning/dashboard.d.ts.map +1 -0
  86. package/dist/commands/planning/discuss.d.ts +39 -0
  87. package/dist/commands/planning/discuss.d.ts.map +1 -0
  88. package/dist/commands/planning/plan.d.ts +67 -0
  89. package/dist/commands/planning/plan.d.ts.map +1 -0
  90. package/dist/commands/planning/roadmap.d.ts +105 -0
  91. package/dist/commands/planning/roadmap.d.ts.map +1 -0
  92. package/dist/commands/setup/doctor.d.ts +10 -0
  93. package/dist/commands/setup/doctor.d.ts.map +1 -0
  94. package/dist/commands/setup/map-codebase.d.ts +62 -0
  95. package/dist/commands/setup/map-codebase.d.ts.map +1 -0
  96. package/dist/commands/setup/new-project.d.ts +19 -0
  97. package/dist/commands/setup/new-project.d.ts.map +1 -0
  98. package/dist/commands/setup/settings.d.ts +57 -0
  99. package/dist/commands/setup/settings.d.ts.map +1 -0
  100. package/dist/commands/state/checkpoint.d.ts +27 -0
  101. package/dist/commands/state/checkpoint.d.ts.map +1 -0
  102. package/dist/commands/state/multi-repo.d.ts +63 -0
  103. package/dist/commands/state/multi-repo.d.ts.map +1 -0
  104. package/dist/commands/state/progress.d.ts +57 -0
  105. package/dist/commands/state/progress.d.ts.map +1 -0
  106. package/dist/commands/state/resume.d.ts +11 -0
  107. package/dist/commands/state/resume.d.ts.map +1 -0
  108. package/dist/commands/state/workspace-commands.d.ts +207 -0
  109. package/dist/commands/state/workspace-commands.d.ts.map +1 -0
  110. package/dist/dashboard/lib/port-finder.d.ts +10 -0
  111. package/dist/dashboard/lib/port-finder.d.ts.map +1 -0
  112. package/dist/dashboard/lib/port-finder.test.d.ts +2 -0
  113. package/dist/dashboard/lib/port-finder.test.d.ts.map +1 -0
  114. package/dist/dashboard/lib/state-reader.d.ts +3 -0
  115. package/dist/dashboard/lib/state-reader.d.ts.map +1 -0
  116. package/dist/dashboard/server.d.ts +2 -0
  117. package/dist/dashboard/server.d.ts.map +1 -0
  118. package/dist/dashboard/server.mjs +13649 -0
  119. package/dist/dashboard/types.d.ts +72 -0
  120. package/dist/dashboard/types.d.ts.map +1 -0
  121. package/dist/dashboard/views/index.ejs +391 -0
  122. package/dist/dashboard/views/partials/blockers.ejs +10 -0
  123. package/dist/dashboard/views/partials/header.ejs +20 -0
  124. package/dist/dashboard/views/partials/phase-timeline.ejs +40 -0
  125. package/dist/dashboard/views/partials/progress.ejs +12 -0
  126. package/dist/hooks/approval-hook.d.ts +13 -0
  127. package/dist/hooks/approval-hook.d.ts.map +1 -0
  128. package/dist/hooks/compaction-hook.d.ts +23 -0
  129. package/dist/hooks/compaction-hook.d.ts.map +1 -0
  130. package/dist/hooks/context-window-monitor.d.ts +21 -0
  131. package/dist/hooks/context-window-monitor.d.ts.map +1 -0
  132. package/dist/hooks/decision-trace-hook.d.ts +13 -0
  133. package/dist/hooks/decision-trace-hook.d.ts.map +1 -0
  134. package/dist/hooks/file-tracker.d.ts +29 -0
  135. package/dist/hooks/file-tracker.d.ts.map +1 -0
  136. package/dist/hooks/guard-rails.d.ts +33 -0
  137. package/dist/hooks/guard-rails.d.ts.map +1 -0
  138. package/dist/hooks/index.d.ts +5 -0
  139. package/dist/hooks/index.d.ts.map +1 -0
  140. package/dist/hooks/notifications.d.ts +21 -0
  141. package/dist/hooks/notifications.d.ts.map +1 -0
  142. package/dist/hooks/patch-trust.d.ts +27 -0
  143. package/dist/hooks/patch-trust.d.ts.map +1 -0
  144. package/dist/hooks/patch-trust.test.d.ts +2 -0
  145. package/dist/hooks/patch-trust.test.d.ts.map +1 -0
  146. package/dist/hooks/session-events.d.ts +8 -0
  147. package/dist/hooks/session-events.d.ts.map +1 -0
  148. package/dist/hooks/session-idle-hook.d.ts +21 -0
  149. package/dist/hooks/session-idle-hook.d.ts.map +1 -0
  150. package/dist/hooks/session-start.d.ts +10 -0
  151. package/dist/hooks/session-start.d.ts.map +1 -0
  152. package/dist/hooks/shell-env-hook.d.ts +21 -0
  153. package/dist/hooks/shell-env-hook.d.ts.map +1 -0
  154. package/dist/hooks/telemetry-hook.d.ts +25 -0
  155. package/dist/hooks/telemetry-hook.d.ts.map +1 -0
  156. package/dist/hooks/todo-hook.d.ts +25 -0
  157. package/dist/hooks/todo-hook.d.ts.map +1 -0
  158. package/dist/hooks/tool-guard.d.ts +41 -0
  159. package/dist/hooks/tool-guard.d.ts.map +1 -0
  160. package/dist/hooks/tool-guard.test.d.ts +2 -0
  161. package/dist/hooks/tool-guard.test.d.ts.map +1 -0
  162. package/dist/index.d.ts +4 -0
  163. package/dist/index.d.ts.map +1 -0
  164. package/dist/index.js +6639 -0
  165. package/dist/lib/confirmation.d.ts +20 -0
  166. package/dist/lib/confirmation.d.ts.map +1 -0
  167. package/dist/lib/impact-radar.d.ts +35 -0
  168. package/dist/lib/impact-radar.d.ts.map +1 -0
  169. package/dist/lib/signatures.d.ts +12 -0
  170. package/dist/lib/signatures.d.ts.map +1 -0
  171. package/dist/lib/timestamps.d.ts +23 -0
  172. package/dist/lib/timestamps.d.ts.map +1 -0
  173. package/dist/mcp/index.d.ts +20 -0
  174. package/dist/mcp/index.d.ts.map +1 -0
  175. package/dist/services/agent-performance.d.ts +29 -0
  176. package/dist/services/agent-performance.d.ts.map +1 -0
  177. package/dist/services/approval-manager.d.ts +30 -0
  178. package/dist/services/approval-manager.d.ts.map +1 -0
  179. package/dist/services/index.d.ts +7 -0
  180. package/dist/services/index.d.ts.map +1 -0
  181. package/dist/services/model-router.d.ts +35 -0
  182. package/dist/services/model-router.d.ts.map +1 -0
  183. package/dist/services/policy-compiler.d.ts +27 -0
  184. package/dist/services/policy-compiler.d.ts.map +1 -0
  185. package/dist/services/run-trace.d.ts +34 -0
  186. package/dist/services/run-trace.d.ts.map +1 -0
  187. package/dist/services/services.test.d.ts +2 -0
  188. package/dist/services/services.test.d.ts.map +1 -0
  189. package/dist/services/telemetry.d.ts +34 -0
  190. package/dist/services/telemetry.d.ts.map +1 -0
  191. package/dist/tools/agent-dispatch.test.d.ts +2 -0
  192. package/dist/tools/agent-dispatch.test.d.ts.map +1 -0
  193. package/dist/tools/codebase-state.d.ts +4 -0
  194. package/dist/tools/codebase-state.d.ts.map +1 -0
  195. package/dist/tools/context-generator.d.ts +3 -0
  196. package/dist/tools/context-generator.d.ts.map +1 -0
  197. package/dist/tools/council.d.ts +4 -0
  198. package/dist/tools/council.d.ts.map +1 -0
  199. package/dist/tools/decision-trace.d.ts +16 -0
  200. package/dist/tools/decision-trace.d.ts.map +1 -0
  201. package/dist/tools/delegate.d.ts +4 -0
  202. package/dist/tools/delegate.d.ts.map +1 -0
  203. package/dist/tools/failure-replay.d.ts +19 -0
  204. package/dist/tools/failure-replay.d.ts.map +1 -0
  205. package/dist/tools/failure-replay.test.d.ts +2 -0
  206. package/dist/tools/failure-replay.test.d.ts.map +1 -0
  207. package/dist/tools/hash-edit.d.ts +3 -0
  208. package/dist/tools/hash-edit.d.ts.map +1 -0
  209. package/dist/tools/planning-state-lib.d.ts +65 -0
  210. package/dist/tools/planning-state-lib.d.ts.map +1 -0
  211. package/dist/tools/planning-state.d.ts +3 -0
  212. package/dist/tools/planning-state.d.ts.map +1 -0
  213. package/dist/tools/policy-engine.d.ts +19 -0
  214. package/dist/tools/policy-engine.d.ts.map +1 -0
  215. package/dist/tools/repo-memory.d.ts +20 -0
  216. package/dist/tools/repo-memory.d.ts.map +1 -0
  217. package/dist/tools/repo-memory.test.d.ts +2 -0
  218. package/dist/tools/repo-memory.test.d.ts.map +1 -0
  219. package/dist/tools/run-parallel.d.ts +4 -0
  220. package/dist/tools/run-parallel.d.ts.map +1 -0
  221. package/dist/tools/run-pipeline.d.ts +4 -0
  222. package/dist/tools/run-pipeline.d.ts.map +1 -0
  223. package/dist/tools/volatility-map.d.ts +18 -0
  224. package/dist/tools/volatility-map.d.ts.map +1 -0
  225. package/dist/tools/volatility-map.test.d.ts +2 -0
  226. package/dist/tools/volatility-map.test.d.ts.map +1 -0
  227. package/dist/tools/workspace-state.d.ts +3 -0
  228. package/dist/tools/workspace-state.d.ts.map +1 -0
  229. package/docs/USER_GUIDE.md +20 -0
  230. package/docs/agents.md +562 -0
  231. package/docs/best-practices.md +47 -0
  232. package/docs/command-migration.md +175 -0
  233. package/docs/commands/fd-analyze-change.md +107 -0
  234. package/docs/commands/fd-ask.md +51 -0
  235. package/docs/commands/fd-checkpoint.md +10 -0
  236. package/docs/commands/fd-dashboard.md +11 -0
  237. package/docs/commands/fd-deploy-check.md +11 -0
  238. package/docs/commands/fd-discuss.md +28 -0
  239. package/docs/commands/fd-evaluate-risk.md +134 -0
  240. package/docs/commands/fd-fix-bug.md +24 -0
  241. package/docs/commands/fd-guarded-edit.md +105 -0
  242. package/docs/commands/fd-map-codebase.md +27 -0
  243. package/docs/commands/fd-multi-repo.md +63 -0
  244. package/docs/commands/fd-new-feature.md +25 -0
  245. package/docs/commands/fd-new-project.md +24 -0
  246. package/docs/commands/fd-plan.md +33 -0
  247. package/docs/commands/fd-progress.md +11 -0
  248. package/docs/commands/fd-resume.md +10 -0
  249. package/docs/commands/fd-review-code.md +29 -0
  250. package/docs/commands/fd-roadmap.md +10 -0
  251. package/docs/commands/fd-settings.md +10 -0
  252. package/docs/commands/fd-write-docs.md +10 -0
  253. package/docs/commands.md +476 -0
  254. package/docs/configuration.md +211 -0
  255. package/docs/feature-integration-architecture.md +255 -0
  256. package/docs/index.md +75 -0
  257. package/docs/installation.md +134 -0
  258. package/docs/intelligence.md +294 -0
  259. package/docs/multi-repo.md +201 -0
  260. package/docs/notifications.md +170 -0
  261. package/docs/parallel-execution.md +227 -0
  262. package/docs/quick-start.md +174 -0
  263. package/docs/rules.md +459 -0
  264. package/docs/skills.md +408 -0
  265. package/docs/workflows.md +376 -0
  266. package/package.json +58 -0
  267. package/postinstall.mjs +102 -0
  268. package/src/rules/README.md +37 -0
  269. package/src/rules/common/agent-orchestration.md +86 -0
  270. package/src/rules/common/coding-style.md +120 -0
  271. package/src/rules/common/git-workflow.md +77 -0
  272. package/src/rules/common/security.md +94 -0
  273. package/src/rules/common/testing.md +105 -0
  274. package/src/rules/golang/patterns.md +187 -0
  275. package/src/rules/java/patterns.md +204 -0
  276. package/src/rules/python/patterns.md +141 -0
  277. package/src/rules/rust/patterns.md +210 -0
  278. package/src/rules/typescript/patterns.md +168 -0
  279. package/src/skills/api-design/SKILL.md +143 -0
  280. package/src/skills/arch-constraint-guard/SKILL.md +61 -0
  281. package/src/skills/blast-radius-preview/SKILL.md +65 -0
  282. package/src/skills/change-impact-radar/SKILL.md +63 -0
  283. package/src/skills/code-review/SKILL.md +108 -0
  284. package/src/skills/code-tour/SKILL.md +101 -0
  285. package/src/skills/codebase-mapping/SKILL.md +87 -0
  286. package/src/skills/codebase-onboarding/SKILL.md +133 -0
  287. package/src/skills/confidence-aware-planning/SKILL.md +67 -0
  288. package/src/skills/context-load/SKILL.md +63 -0
  289. package/src/skills/debug-flow/SKILL.md +75 -0
  290. package/src/skills/decision-trace/SKILL.md +72 -0
  291. package/src/skills/dependency-audit/SKILL.md +126 -0
  292. package/src/skills/deploy-check/SKILL.md +87 -0
  293. package/src/skills/documentation-writer/SKILL.md +154 -0
  294. package/src/skills/failure-replay-engine/SKILL.md +59 -0
  295. package/src/skills/git-release/SKILL.md +94 -0
  296. package/src/skills/git-workflow/SKILL.md +177 -0
  297. package/src/skills/golang-patterns/SKILL.md +511 -0
  298. package/src/skills/human-review-routing/SKILL.md +65 -0
  299. package/src/skills/intent-translator/SKILL.md +57 -0
  300. package/src/skills/java-patterns/SKILL.md +479 -0
  301. package/src/skills/multi-repo/SKILL.md +187 -0
  302. package/src/skills/parallel-execute/SKILL.md +92 -0
  303. package/src/skills/patch-trust-score/SKILL.md +44 -0
  304. package/src/skills/performance-profiling/SKILL.md +153 -0
  305. package/src/skills/plan-task/SKILL.md +101 -0
  306. package/src/skills/python-patterns/SKILL.md +529 -0
  307. package/src/skills/refactor-guide/SKILL.md +117 -0
  308. package/src/skills/regression-prediction/SKILL.md +57 -0
  309. package/src/skills/repo-memory-graph/SKILL.md +49 -0
  310. package/src/skills/rust-patterns/SKILL.md +492 -0
  311. package/src/skills/security-scan/SKILL.md +91 -0
  312. package/src/skills/self-healing-policies/SKILL.md +76 -0
  313. package/src/skills/tdd-workflow/SKILL.md +126 -0
  314. package/src/skills/test-coverage/SKILL.md +94 -0
  315. package/src/skills/test-gap-detector/SKILL.md +58 -0
  316. package/src/skills/volatility-map/SKILL.md +52 -0
  317. package/src/workflows/debug-flow.md +119 -0
  318. package/src/workflows/deploy-check-flow.md +98 -0
  319. package/src/workflows/discuss-flow.md +97 -0
  320. package/src/workflows/execute-flow.md +233 -0
  321. package/src/workflows/execute-phase.md +142 -0
  322. package/src/workflows/fix-bug-flow.md +210 -0
  323. package/src/workflows/map-codebase-flow.md +92 -0
  324. package/src/workflows/multi-repo-flow.md +226 -0
  325. package/src/workflows/parallel-execution-flow.md +236 -0
  326. package/src/workflows/plan-flow.md +126 -0
  327. package/src/workflows/plan-phase.md +101 -0
  328. package/src/workflows/refactor-flow.md +122 -0
  329. package/src/workflows/review-code-flow.md +105 -0
  330. package/src/workflows/spec-driven-flow.md +43 -0
  331. package/src/workflows/write-docs-flow.md +95 -0
@@ -0,0 +1,255 @@
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
+ | Adaptive Model Router | `src/services/model-router.ts` | `.codebase/MODEL_ROUTER.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
+ ### model-router.ts
67
+ Routes task types to the best available model.
68
+
69
+ ```typescript
70
+ routeModel(dir, task_type, risk_score?) → RoutedModel
71
+ buildAgentConfig(dir, agents) → AgentConfig[]
72
+ getRouterConfig(dir) → ModelRouterConfig
73
+ ```
74
+
75
+ **Default routing:**
76
+ | Task | Primary | High-Risk Override |
77
+ |---|---|---|
78
+ | planning | claude-sonnet-4-5 | — |
79
+ | implementation | claude-opus-4-5 | claude-opus-4-5 |
80
+ | debugging | claude-sonnet-4-5 | claude-opus-4-5 |
81
+ | review | gemini-2.5-flash | — |
82
+ | testing | claude-haiku-4-5 | — |
83
+ | security | claude-opus-4-5 | claude-opus-4-5 |
84
+
85
+ Override by creating `.codebase/MODEL_ROUTER.json` with `{ "task_type": { "primary": "model-name" } }`.
86
+
87
+ ### agent-performance.ts
88
+ Tracks success rates, costs, and durations per agent+model+task combination.
89
+
90
+ ```typescript
91
+ recordRun(dir, agent, model, task_type, success, duration_ms, cost?)
92
+ getStats(dir, filter?) → AgentPerfEntry[]
93
+ getBestAgentForTask(dir, task_type) → AgentRecommendation | null
94
+ getAgentLeaderboard(dir) → AgentRecommendation[]
95
+ ```
96
+
97
+ Requires ≥ 3 runs per combination before making routing recommendations.
98
+
99
+ ---
100
+
101
+ ## Hooks Layer (`src/hooks/`)
102
+
103
+ ### Hook execution order (tool.execute.before)
104
+ 1. `telemetryHook` — record tool invocation
105
+ 2. `approvalHook` — block writes on sensitive files without approval
106
+ 3. `guardRailsHook` — enforce execution mode (auto/guarded/review-only)
107
+ 4. `toolGuardHook` — enforce architectural constraints
108
+ 5. `patchTrustHook` — score patch risk
109
+ 6. `decisionTraceHook` — record edit rationale
110
+
111
+ ### approval-hook.ts
112
+ Intercepts write/edit tool calls on sensitive file paths. Throws with `APPROVAL_REQUIRED:` prefix to block. Emits `approval.request` telemetry event.
113
+
114
+ Monitored tools: `write_file`, `edit_file`, `create_file`, `apply_patch`, `str_replace_editor`, `write`
115
+
116
+ ### telemetry-hook.ts
117
+ Emits `tool.call` events for all tool invocations. Lightweight — never blocks.
118
+
119
+ ---
120
+
121
+ ## Command Integration
122
+
123
+ ### /fd-new-feature
124
+ - Calls `startTrace()` on entry → `run_id` included in config
125
+ - Calls `buildAgentConfig()` from model-router → no hardcoded models
126
+ - Emits `command.start` telemetry event with risk score and phase
127
+
128
+ ### /fd-fix-bug
129
+ - Calls `startTrace()` on entry → `run_id` included in config
130
+ - Emits `command.start` telemetry with prior failure count in metadata
131
+
132
+ ### /fd-analyze-change
133
+ - Consumes all impact services (impact radar, blast radius, volatility, regression)
134
+ - Returns structured output with risk summary for dashboard
135
+
136
+ ### /fd-dashboard
137
+ - Reads `DashboardData` including: `telemetrySummary`, `recentRuns`, `pendingApprovals`, `agentPerf`, `toolFailureCount`
138
+ - Displays operational control plane sections alongside phase progress
139
+
140
+ ### /fd-guarded-edit
141
+ - Run approval gate before risky operations
142
+ - Uses `isApprovalRequired()` + `requestApproval()` pattern
143
+
144
+ ---
145
+
146
+ ## Dashboard Sections
147
+
148
+ The dashboard at `http://localhost:<port>` now includes:
149
+
150
+ 1. **Milestone Progress** — phase timeline (existing)
151
+ 2. **Blockers** — from STATE.md (existing)
152
+ 3. **⚠ Pending Approvals** — approval requests waiting on user
153
+ 4. **Recent Runs** — last 10 command runs with status, risk, files touched
154
+ 5. **Command Telemetry** — aggregate stats per command (total runs, success rate, avg duration)
155
+ 6. **Agent Performance** — success rate per agent/model/task combination
156
+
157
+ ---
158
+
159
+ ## Data Schema
160
+
161
+ ### TELEMETRY.jsonl (append-only)
162
+ ```json
163
+ {"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}
164
+ ```
165
+
166
+ ### RUNS.jsonl (append-only, rewritten on end/update)
167
+ ```json
168
+ {"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"}
169
+ ```
170
+
171
+ ### APPROVALS.json
172
+ ```json
173
+ {"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"}]}
174
+ ```
175
+
176
+ ### AGENT_PERF.json
177
+ ```json
178
+ {"entries":[{"agent":"coder","model":"claude-opus-4-5","task_type":"implementation","runs":12,"successes":11,"failures":1,"total_duration_ms":60000,"total_cost":0.48,"last_run":"ISO","last_status":"success"}],"updated_at":"ISO"}
179
+ ```
180
+
181
+ ### MODEL_ROUTER.json (optional override)
182
+ ```json
183
+ {"implementation":{"primary":"claude-sonnet-4-5","temperature":0.2},"review":{"primary":"claude-haiku-4-5"}}
184
+ ```
185
+
186
+ ---
187
+
188
+ ## Config Additions
189
+
190
+ No new required config. Optional per-repo overrides:
191
+
192
+ - `.codebase/MODEL_ROUTER.json` — override model routing per task type
193
+ - `.codebase/POLICIES.json` — runtime policy rules (existing, enhanced)
194
+ - `.codebase/CONSTRAINTS.md` — architectural constraints (existing)
195
+
196
+ ---
197
+
198
+ ## Agents
199
+
200
+ Three new specialist agents available for programmatic invocation:
201
+
202
+ | Agent | File | Purpose |
203
+ |---|---|---|
204
+ | `replay-analyst` | `agents/replay-analyst.md` | Diff run traces, surface regressions |
205
+ | `eval-reviewer` | `agents/eval-reviewer.md` | Evaluate agent/model routing quality |
206
+ | `cost-optimizer` | `agents/cost-optimizer.md` | Recommend cheaper routing with no quality loss |
207
+
208
+ ---
209
+
210
+ ## Policy Compiler Service (`src/services/policy-compiler.ts`)
211
+
212
+ Compiles active policies from `POLICIES.json` into runtime evaluators.
213
+
214
+ ```typescript
215
+ evaluatePolicies(dir, ctx) → PolicyViolation[]
216
+ learnFromFailure(failure_type, affected_paths, root_cause?) → ProposedPolicy | null
217
+ formatViolations(violations) → string
218
+ ```
219
+
220
+ **PolicyContext fields:** `command`, `file_path`, `change_description`, `tool`, `risk_score`
221
+
222
+ **Severity derivation:** Rules containing "require approval", "never", "must not" → `block`; otherwise → `warn`
223
+
224
+ **Pattern learning:** Proposes policies for recognized failure types (`auth_bypass`, `payment_failure`, `migration_failure`, `infra_change`, `secrets_exposure`). Returns `null` for unrecognized patterns.
225
+
226
+ ---
227
+
228
+ ## `/fd-approve` Command (`src/commands/governance/approve.ts`)
229
+
230
+ Governance command for managing approval gates raised by the approval hook.
231
+
232
+ ```
233
+ /fd-approve # list all pending approvals
234
+ /fd-approve --id <uuid> # approve → operation may proceed
235
+ /fd-approve --id <uuid> --reject # reject → operation stays blocked
236
+ /fd-approve --recent # last 10 resolved approvals
237
+ /fd-approve --json # machine-readable output
238
+ ```
239
+
240
+ Resolving an approval emits an `approval.resolve` telemetry event and records the decision in `APPROVALS.json`.
241
+
242
+ ---
243
+
244
+ ## Migration Notes
245
+
246
+ All existing commands continue to work unchanged. New capabilities are additive:
247
+
248
+ - `fd-new-feature` — now uses model router instead of hardcoded models; emits telemetry
249
+ - `fd-fix-bug` — emits run trace on entry, evaluates policies, proposes new policies from failures
250
+ - `fd-review-code` — shows policy violations in output table
251
+ - Dashboard — new operational sections appear only when data exists (no empty-state noise)
252
+ - Approval hook — only triggers for write operations on sensitive file patterns; safe paths are unaffected
253
+ - Telemetry — append-only, never read during hook execution, cannot slow down tool calls
254
+
255
+ First-run behavior: all new `.codebase/` data files are created on first use. No migration needed.
package/docs/index.md ADDED
@@ -0,0 +1,75 @@
1
+ # FlowDeck Documentation
2
+
3
+ FlowDeck is an OpenCode plugin that brings structured, multi-agent workflow orchestration to your development sessions. It coordinates 29 specialist agents through a four-phase cycle — discuss, plan, execute, review — with persistent state stored in your project's `.planning/` directory.
4
+
5
+ ---
6
+
7
+ ## Getting Started
8
+
9
+ | Document | Description |
10
+ |----------|-------------|
11
+ | [Installation](installation.md) | Prerequisites, all three install methods, verification commands, and how to uninstall |
12
+ | [Quick Start](quick-start.md) | Step-by-step walkthrough of your first 15 minutes with FlowDeck |
13
+ | [Best Practices](best-practices.md) | Maximize efficiency and safety with Spec-Driven Development and Ensemble Reasoning |
14
+
15
+ ---
16
+
17
+ ## Reference
18
+
19
+ | Document | Description |
20
+ |----------|-------------|
21
+ | [Agents](agents.md) | All 29 agents — names, roles, models, and when to invoke each one |
22
+ | [Skills](skills.md) | All 24 skills — what each skill does and example prompts that activate it |
23
+ | [Commands](commands.md) | All 27 slash commands — syntax, arguments, and what each command triggers |
24
+ | [Workflows](workflows.md) | All 15 built-in workflows — flow diagrams, inputs, outputs, and agent involvement |
25
+ | [Rules](rules.md) | Language and common rule files — what they enforce and how to activate them |
26
+ | [Intelligence Features](intelligence.md) | 15 AI-safety features: impact radar, patch trust, blast radius, decision trace, and more |
27
+
28
+ ---
29
+
30
+ ## Advanced
31
+
32
+ | Document | Description |
33
+ |----------|-------------|
34
+ | [Parallel Execution](parallel-execution.md) | How FlowDeck fans out independent tasks across multiple agents simultaneously |
35
+ | [Multi-Repo](multi-repo.md) | Coordinating changes across two or more repositories in a single session |
36
+ | [Notifications](notifications.md) | Desktop and system alerts for long-running task completion |
37
+
38
+ ---
39
+
40
+ ## Setup & Maintenance
41
+
42
+ | Document | Description |
43
+ |----------|-------------|
44
+ | [Configuration](configuration.md) | `opencode.json` fields, project config schema, environment variables, and plugin tools |
45
+ | [Troubleshooting](troubleshooting.md) | Fixes for the most common problems: missing agents, corrupted state, build failures |
46
+
47
+ ---
48
+
49
+ ## Quick Command Cheat Sheet
50
+
51
+ | Command | What it does |
52
+ |---------|--------------|
53
+ | `/fd-new-project <name>` | Initialize `.planning/` directory structure for a new project |
54
+ | `/fd-discuss <phase>` | Run structured requirements Q&A with `@discusser` |
55
+ | `/fd-plan <phase>` | Generate a wave-structured `PLAN.md` (requires `CONFIRMED` to execute) |
56
+ | `/fd-new-feature "<description>"` | Execute full feature workflow via `@orchestrator` |
57
+ | `/fd-review-code [staged\|branch]` | Parallel review by `@reviewer`, `@security-auditor`, `@tester` |
58
+ | `/fd-fix-bug "<description>"` | Diagnose and fix a bug with regression test |
59
+ | `/fd-checkpoint` | Save current state — safe to close the session after this |
60
+ | `/fd-resume` | Reload `STATE.md` and `PLAN.md` context in a new session |
61
+ | `/fd-progress` | Print current state, active plan, and recent results |
62
+ | `/fd-map-codebase` | Generate `.codebase/` documentation from source analysis |
63
+ | `/fd-roadmap` | View or update phase statuses and milestones |
64
+ | `/fd-dashboard` | Open the project dashboard with phase progress and blockers |
65
+ | `/fd-deploy-check` | Run pre-deployment checks and produce a go/no-go verdict |
66
+ | `/fd-write-docs` | Generate or update project documentation |
67
+ | `/fd-multi-repo` | Coordinate a change across multiple registered repositories |
68
+ | `/fd-settings` | View or update FlowDeck model assignments and configuration |
69
+ | `/fd-impact-radar` | Predict affected files/APIs/tests before editing |
70
+ | `/fd-blast-radius` | Show downstream consequences and hidden dependencies of a change |
71
+ | `/fd-translate-intent` | Convert vague request into ranked concrete implementation options |
72
+ | `/fd-volatility-map` | Show unstable code zones by churn and hotfix frequency |
73
+ | `/fd-regression-predict` | Estimate likely regression categories before making a change |
74
+ | `/fd-test-gap` | Identify weakly-tested areas in a proposed change |
75
+ | `/fd-review-route` | Route risky patches to security, backend, infra, or domain reviewers |
@@ -0,0 +1,134 @@
1
+ # FlowDeck Installation
2
+
3
+ This guide covers all three ways to install FlowDeck, how to verify the installation, how to keep it up to date, and how to remove it cleanly.
4
+
5
+ ---
6
+
7
+ ## Prerequisites
8
+
9
+ Before installing FlowDeck, ensure the following tools are available:
10
+
11
+ | Requirement | Minimum version | Check command |
12
+ |-------------|----------------|---------------|
13
+ | OpenCode | 1.0 | `opencode --version` |
14
+ | Node.js | 18 | `node --version` |
15
+ | npm | 9 | `npm --version` |
16
+
17
+ If OpenCode is not yet installed, follow the [OpenCode installation guide](https://opencode.ai/docs) before continuing.
18
+
19
+ ---
20
+
21
+ ## Method 1: curl (recommended)
22
+
23
+ The install script downloads the latest release, copies all agents, skills, commands, and workflows to `~/.config/opencode/`, and registers `@dv.nghiem/flowdeck` as a plugin in `opencode.json`.
24
+
25
+ ```bash
26
+ curl -fsSL https://raw.githubusercontent.com/DVNghiem/flowdeck/main/install.sh | bash
27
+ ```
28
+
29
+ What the script does:
30
+
31
+ 1. Detects your config directory (`$OPENCODE_CONFIG_DIR` or `~/.config/opencode`)
32
+ 2. Copies `agents/*.md` → `~/.config/opencode/agent/` (markdown agents for OpenCode compatibility)
33
+ 3. Compiles TypeScript agents from `src/agents/` → `dist/agents/` (for plugin-based loading)
34
+ 4. Copies `skills/*/` → `~/.config/opencode/skills/`
35
+ 5. Registers `@dv.nghiem/flowdeck` as a plugin in `opencode.json`
36
+ 6. Sets `orchestrator` as the default agent
37
+
38
+ ---
39
+
40
+ ## Method 2: npx (no git required)
41
+
42
+ If you prefer not to clone the repository, run FlowDeck's bundled installer directly through npm:
43
+
44
+ ```bash
45
+ npx @dv.nghiem/flowdeck install
46
+ ```
47
+
48
+ This fetches the latest published package from the npm registry and runs the same installation steps as the curl method.
49
+
50
+ ---
51
+
52
+ Steps explained:
53
+
54
+ - `npm install` — fetches Node.js dependencies
55
+ - `npm run build` — compiles TypeScript source in `src/` to `dist/`
56
+ - `bash install.sh` — copies built assets to `~/.config/opencode/` and updates `opencode.json`
57
+
58
+ ---
59
+
60
+ ## Verification
61
+
62
+ After any install method, run these commands to confirm everything landed correctly:
63
+
64
+ ```bash
65
+ # Should print 23 or more
66
+ ls ~/.config/opencode/agent/ | grep -c "\.md"
67
+
68
+ # Should list 24 or more directories
69
+ ls ~/.config/opencode/skills/
70
+
71
+ # Should list 16 or more files
72
+ ls ~/.config/opencode/command/
73
+
74
+ # Should print @dv.nghiem/flowdeck
75
+ cat ~/.config/opencode/opencode.json | grep flowdeck
76
+ ```
77
+
78
+ Expected output for the last command:
79
+
80
+ ```
81
+ "@dv.nghiem/flowdeck"
82
+ ```
83
+
84
+ If any count is lower than expected, re-run the install command. If the `opencode.json` line is missing, the plugin will not load — add it manually (see [Configuration](configuration.md)).
85
+
86
+ ---
87
+
88
+ ## Updating FlowDeck
89
+
90
+ ### curl method
91
+
92
+ Re-running the install script downloads and applies the latest version:
93
+
94
+ ```bash
95
+ curl -fsSL https://raw.githubusercontent.com/DVNghiem/flowdeck/main/install.sh | bash
96
+ ```
97
+
98
+ The script overwrites existing FlowDeck files and updates the plugin cache.
99
+
100
+ ### npm method
101
+
102
+ ```bash
103
+ npm update -g @dv.nghiem/flowdeck && npx @dv.nghiem/flowdeck install
104
+ ```
105
+
106
+ ---
107
+
108
+ ## Uninstalling
109
+
110
+ ```bash
111
+ bash uninstall.sh
112
+ ```
113
+ You can also add the `--local` flag to uninstall from a local project `.opencode/` directory instead of the global config.
114
+
115
+ The uninstall script automatically scans the FlowDeck package and safely removes any installed agents, skills, and commands from your OpenCode config directory. It does not delete your project's `.planning/` directory or any state files.
116
+
117
+ ---
118
+
119
+ ## Environment Variables
120
+
121
+ | Variable | Default | Description |
122
+ |----------|---------|-------------|
123
+ | `OPENCODE_CONFIG_DIR` | `~/.config/opencode` | Override the directory where FlowDeck installs agents, skills, and commands |
124
+ | `XDG_CONFIG_HOME` | `~/.config` | Standard XDG base directory; used when `OPENCODE_CONFIG_DIR` is not set |
125
+
126
+ Set `OPENCODE_CONFIG_DIR` before running the install script to place FlowDeck files in a non-default location:
127
+
128
+ ```bash
129
+ OPENCODE_CONFIG_DIR=/custom/path bash install.sh
130
+ ```
131
+
132
+ ---
133
+
134
+ ← [Back to Index](index.md)