orbital-command 0.2.0 → 1.0.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 (431) hide show
  1. package/README.md +67 -42
  2. package/bin/commands/config.js +19 -0
  3. package/bin/commands/events.js +40 -0
  4. package/bin/commands/launch.js +126 -0
  5. package/bin/commands/manifest.js +283 -0
  6. package/bin/commands/registry.js +104 -0
  7. package/bin/commands/update.js +24 -0
  8. package/bin/lib/helpers.js +229 -0
  9. package/bin/orbital.js +147 -319
  10. package/dist/assets/Landing-CfQdHR0N.js +11 -0
  11. package/dist/assets/PrimitivesConfig-DThSipFy.js +32 -0
  12. package/dist/assets/QualityGates-B4kxM5UU.js +26 -0
  13. package/dist/assets/SessionTimeline-Bz1iZnmg.js +1 -0
  14. package/dist/assets/Settings-DLcZwbCT.js +12 -0
  15. package/dist/assets/SourceControl-BMNIz7Lt.js +36 -0
  16. package/dist/assets/WorkflowVisualizer-CxuSBOYu.js +69 -0
  17. package/dist/assets/arrow-down-DVPp6_qp.js +6 -0
  18. package/dist/assets/bot-NFaJBDn_.js +6 -0
  19. package/dist/assets/charts-LGLb8hyU.js +68 -0
  20. package/dist/assets/circle-x-IsFCkBZu.js +6 -0
  21. package/dist/assets/file-text-J1cebZXF.js +6 -0
  22. package/dist/assets/globe-WzeyHsUc.js +6 -0
  23. package/dist/assets/index-BdJ57EhC.css +1 -0
  24. package/dist/assets/index-o4ScMAuR.js +349 -0
  25. package/dist/assets/key-CKR8JJSj.js +6 -0
  26. package/dist/assets/minus-CHBsJyjp.js +6 -0
  27. package/dist/assets/radio-xqZaR-Uk.js +6 -0
  28. package/dist/assets/rocket-D_xvvNG6.js +6 -0
  29. package/dist/assets/shield-TdB1yv_a.js +6 -0
  30. package/dist/assets/ui-BmsSg9jU.js +53 -0
  31. package/dist/assets/useSocketListener-0L5yiN5i.js +1 -0
  32. package/dist/assets/useWorkflowEditor-CqeRWVQX.js +11 -0
  33. package/dist/assets/{vendor-Dzv9lrRc.js → vendor-Bqt8AJn2.js} +1 -1
  34. package/dist/assets/workflow-constants-Rw-GmgHZ.js +6 -0
  35. package/dist/assets/zap-C9wqYMpl.js +6 -0
  36. package/dist/favicon.svg +1 -0
  37. package/dist/index.html +6 -5
  38. package/dist/server/server/__tests__/data-routes.test.js +126 -0
  39. package/dist/server/server/__tests__/helpers/db.js +17 -0
  40. package/dist/server/server/__tests__/helpers/mock-emitter.js +8 -0
  41. package/dist/server/server/__tests__/scope-routes.test.js +138 -0
  42. package/dist/server/server/__tests__/sprint-routes.test.js +102 -0
  43. package/dist/server/server/__tests__/workflow-routes.test.js +107 -0
  44. package/dist/server/server/config-migrator.js +135 -0
  45. package/dist/server/server/config.js +51 -7
  46. package/dist/server/server/database.js +21 -28
  47. package/dist/server/server/global-config.js +143 -0
  48. package/dist/server/server/index.js +118 -276
  49. package/dist/server/server/init.js +243 -225
  50. package/dist/server/server/launch.js +29 -0
  51. package/dist/server/server/manifest-types.js +8 -0
  52. package/dist/server/server/manifest.js +454 -0
  53. package/dist/server/server/migrate-legacy.js +229 -0
  54. package/dist/server/server/parsers/event-parser.js +4 -1
  55. package/dist/server/server/parsers/event-parser.test.js +117 -0
  56. package/dist/server/server/parsers/scope-parser.js +74 -28
  57. package/dist/server/server/parsers/scope-parser.test.js +230 -0
  58. package/dist/server/server/project-context.js +265 -0
  59. package/dist/server/server/project-emitter.js +41 -0
  60. package/dist/server/server/project-manager.js +297 -0
  61. package/dist/server/server/routes/aggregate-routes.js +871 -0
  62. package/dist/server/server/routes/config-routes.js +41 -90
  63. package/dist/server/server/routes/data-routes.js +25 -123
  64. package/dist/server/server/routes/dispatch-routes.js +37 -15
  65. package/dist/server/server/routes/git-routes.js +74 -0
  66. package/dist/server/server/routes/manifest-routes.js +319 -0
  67. package/dist/server/server/routes/scope-routes.js +45 -28
  68. package/dist/server/server/routes/sync-routes.js +134 -0
  69. package/dist/server/server/routes/version-routes.js +1 -15
  70. package/dist/server/server/routes/workflow-routes.js +9 -3
  71. package/dist/server/server/schema.js +3 -0
  72. package/dist/server/server/services/batch-orchestrator.js +41 -17
  73. package/dist/server/server/services/claude-session-service.js +17 -14
  74. package/dist/server/server/services/config-service.js +10 -1
  75. package/dist/server/server/services/deploy-service.test.js +119 -0
  76. package/dist/server/server/services/event-service.js +64 -1
  77. package/dist/server/server/services/event-service.test.js +191 -0
  78. package/dist/server/server/services/gate-service.test.js +105 -0
  79. package/dist/server/server/services/git-service.js +108 -4
  80. package/dist/server/server/services/github-service.js +110 -2
  81. package/dist/server/server/services/readiness-service.test.js +190 -0
  82. package/dist/server/server/services/scope-cache.js +5 -1
  83. package/dist/server/server/services/scope-cache.test.js +142 -0
  84. package/dist/server/server/services/scope-service.js +222 -131
  85. package/dist/server/server/services/scope-service.test.js +137 -0
  86. package/dist/server/server/services/sprint-orchestrator.js +29 -15
  87. package/dist/server/server/services/sprint-service.js +23 -3
  88. package/dist/server/server/services/sprint-service.test.js +238 -0
  89. package/dist/server/server/services/sync-service.js +434 -0
  90. package/dist/server/server/services/sync-types.js +2 -0
  91. package/dist/server/server/services/workflow-service.js +26 -5
  92. package/dist/server/server/services/workflow-service.test.js +159 -0
  93. package/dist/server/server/settings-sync.js +284 -0
  94. package/dist/server/server/uninstall.js +195 -0
  95. package/dist/server/server/update-planner.js +279 -0
  96. package/dist/server/server/update.js +212 -0
  97. package/dist/server/server/utils/cc-hooks-parser.js +3 -0
  98. package/dist/server/server/utils/cc-hooks-parser.test.js +86 -0
  99. package/dist/server/server/utils/dispatch-utils.js +83 -24
  100. package/dist/server/server/utils/dispatch-utils.test.js +182 -0
  101. package/dist/server/server/utils/flag-builder.js +54 -0
  102. package/dist/server/server/utils/json-fields.js +14 -0
  103. package/dist/server/server/utils/json-fields.test.js +73 -0
  104. package/dist/server/server/utils/logger.js +37 -3
  105. package/dist/server/server/utils/package-info.js +30 -0
  106. package/dist/server/server/utils/route-helpers.js +47 -0
  107. package/dist/server/server/utils/route-helpers.test.js +115 -0
  108. package/dist/server/server/utils/terminal-launcher.js +79 -25
  109. package/dist/server/server/utils/worktree-manager.js +13 -4
  110. package/dist/server/server/validator.js +230 -0
  111. package/dist/server/server/watchers/event-watcher.js +28 -13
  112. package/dist/server/server/watchers/global-watcher.js +63 -0
  113. package/dist/server/server/watchers/scope-watcher.js +27 -12
  114. package/dist/server/server/wizard/config-editor.js +237 -0
  115. package/dist/server/server/wizard/detect.js +96 -0
  116. package/dist/server/server/wizard/doctor.js +115 -0
  117. package/dist/server/server/wizard/index.js +340 -0
  118. package/dist/server/server/wizard/phases/confirm.js +39 -0
  119. package/dist/server/server/wizard/phases/project-setup.js +90 -0
  120. package/dist/server/server/wizard/phases/setup-wizard.js +66 -0
  121. package/dist/server/server/wizard/phases/welcome.js +32 -0
  122. package/dist/server/server/wizard/phases/workflow-setup.js +22 -0
  123. package/dist/server/server/wizard/types.js +29 -0
  124. package/dist/server/server/wizard/ui.js +73 -0
  125. package/dist/server/shared/__fixtures__/workflow-configs.js +75 -0
  126. package/dist/server/shared/api-types.js +80 -1
  127. package/dist/server/shared/default-workflow.json +65 -0
  128. package/dist/server/shared/onboarding-tour.test.js +81 -0
  129. package/dist/server/shared/project-colors.js +24 -0
  130. package/dist/server/shared/workflow-config.test.js +84 -0
  131. package/dist/server/shared/workflow-engine.js +1 -1
  132. package/dist/server/shared/workflow-engine.test.js +302 -0
  133. package/dist/server/shared/workflow-normalizer.js +101 -0
  134. package/dist/server/shared/workflow-normalizer.test.js +100 -0
  135. package/dist/server/src/components/onboarding/tour-steps.js +84 -0
  136. package/package.json +34 -29
  137. package/schemas/orbital.config.schema.json +2 -5
  138. package/scripts/postinstall.js +18 -6
  139. package/scripts/release.sh +53 -0
  140. package/server/__tests__/data-routes.test.ts +151 -0
  141. package/server/__tests__/helpers/db.ts +19 -0
  142. package/server/__tests__/helpers/mock-emitter.ts +10 -0
  143. package/server/__tests__/scope-routes.test.ts +158 -0
  144. package/server/__tests__/sprint-routes.test.ts +118 -0
  145. package/server/__tests__/workflow-routes.test.ts +120 -0
  146. package/server/config-migrator.ts +160 -0
  147. package/server/config.ts +64 -12
  148. package/server/database.ts +22 -31
  149. package/server/global-config.ts +204 -0
  150. package/server/index.ts +139 -316
  151. package/server/init.ts +266 -234
  152. package/server/launch.ts +32 -0
  153. package/server/manifest-types.ts +145 -0
  154. package/server/manifest.ts +494 -0
  155. package/server/migrate-legacy.ts +290 -0
  156. package/server/parsers/event-parser.test.ts +135 -0
  157. package/server/parsers/event-parser.ts +4 -1
  158. package/server/parsers/scope-parser.test.ts +270 -0
  159. package/server/parsers/scope-parser.ts +79 -31
  160. package/server/project-context.ts +325 -0
  161. package/server/project-emitter.ts +50 -0
  162. package/server/project-manager.ts +368 -0
  163. package/server/routes/aggregate-routes.ts +968 -0
  164. package/server/routes/config-routes.ts +43 -85
  165. package/server/routes/data-routes.ts +34 -156
  166. package/server/routes/dispatch-routes.ts +46 -17
  167. package/server/routes/git-routes.ts +77 -0
  168. package/server/routes/manifest-routes.ts +388 -0
  169. package/server/routes/scope-routes.ts +39 -30
  170. package/server/routes/sync-routes.ts +175 -0
  171. package/server/routes/version-routes.ts +1 -16
  172. package/server/routes/workflow-routes.ts +9 -3
  173. package/server/schema.ts +3 -0
  174. package/server/services/batch-orchestrator.ts +41 -17
  175. package/server/services/claude-session-service.ts +16 -14
  176. package/server/services/config-service.ts +10 -1
  177. package/server/services/deploy-service.test.ts +145 -0
  178. package/server/services/deploy-service.ts +2 -2
  179. package/server/services/event-service.test.ts +242 -0
  180. package/server/services/event-service.ts +92 -3
  181. package/server/services/gate-service.test.ts +131 -0
  182. package/server/services/gate-service.ts +2 -2
  183. package/server/services/git-service.ts +137 -4
  184. package/server/services/github-service.ts +120 -2
  185. package/server/services/readiness-service.test.ts +217 -0
  186. package/server/services/scope-cache.test.ts +167 -0
  187. package/server/services/scope-cache.ts +4 -1
  188. package/server/services/scope-service.test.ts +169 -0
  189. package/server/services/scope-service.ts +224 -130
  190. package/server/services/sprint-orchestrator.ts +30 -15
  191. package/server/services/sprint-service.test.ts +271 -0
  192. package/server/services/sprint-service.ts +29 -5
  193. package/server/services/sync-service.ts +482 -0
  194. package/server/services/sync-types.ts +77 -0
  195. package/server/services/workflow-service.test.ts +190 -0
  196. package/server/services/workflow-service.ts +29 -9
  197. package/server/settings-sync.ts +359 -0
  198. package/server/uninstall.ts +214 -0
  199. package/server/update-planner.ts +346 -0
  200. package/server/update.ts +263 -0
  201. package/server/utils/cc-hooks-parser.test.ts +96 -0
  202. package/server/utils/cc-hooks-parser.ts +4 -0
  203. package/server/utils/dispatch-utils.test.ts +245 -0
  204. package/server/utils/dispatch-utils.ts +102 -30
  205. package/server/utils/flag-builder.ts +56 -0
  206. package/server/utils/json-fields.test.ts +83 -0
  207. package/server/utils/json-fields.ts +14 -0
  208. package/server/utils/logger.ts +40 -3
  209. package/server/utils/package-info.ts +32 -0
  210. package/server/utils/route-helpers.test.ts +144 -0
  211. package/server/utils/route-helpers.ts +50 -0
  212. package/server/utils/terminal-launcher.ts +85 -25
  213. package/server/utils/worktree-manager.ts +9 -4
  214. package/server/validator.ts +270 -0
  215. package/server/watchers/event-watcher.ts +24 -12
  216. package/server/watchers/global-watcher.ts +77 -0
  217. package/server/watchers/scope-watcher.ts +21 -9
  218. package/server/wizard/config-editor.ts +248 -0
  219. package/server/wizard/detect.ts +104 -0
  220. package/server/wizard/doctor.ts +114 -0
  221. package/server/wizard/index.ts +438 -0
  222. package/server/wizard/phases/confirm.ts +45 -0
  223. package/server/wizard/phases/project-setup.ts +106 -0
  224. package/server/wizard/phases/setup-wizard.ts +78 -0
  225. package/server/wizard/phases/welcome.ts +39 -0
  226. package/server/wizard/phases/workflow-setup.ts +28 -0
  227. package/server/wizard/types.ts +56 -0
  228. package/server/wizard/ui.ts +92 -0
  229. package/shared/__fixtures__/workflow-configs.ts +80 -0
  230. package/shared/api-types.ts +106 -0
  231. package/shared/onboarding-tour.test.ts +94 -0
  232. package/shared/project-colors.ts +24 -0
  233. package/shared/workflow-config.test.ts +111 -0
  234. package/shared/workflow-config.ts +7 -0
  235. package/shared/workflow-engine.test.ts +388 -0
  236. package/shared/workflow-engine.ts +1 -1
  237. package/shared/workflow-normalizer.test.ts +119 -0
  238. package/shared/workflow-normalizer.ts +118 -0
  239. package/templates/agents/QUICK-REFERENCE.md +1 -0
  240. package/templates/agents/README.md +1 -0
  241. package/templates/agents/SKILL-TRIGGERS.md +11 -0
  242. package/templates/agents/green-team/deep-dive.md +361 -0
  243. package/templates/hooks/end-session.sh +4 -1
  244. package/templates/hooks/init-session.sh +1 -0
  245. package/templates/hooks/orbital-emit.sh +2 -2
  246. package/templates/hooks/orbital-report-deploy.sh +4 -4
  247. package/templates/hooks/orbital-report-gates.sh +4 -4
  248. package/templates/hooks/orbital-scope-update.sh +1 -1
  249. package/templates/hooks/scope-commit-logger.sh +2 -2
  250. package/templates/hooks/scope-create-cleanup.sh +2 -2
  251. package/templates/hooks/scope-create-gate.sh +2 -5
  252. package/templates/hooks/scope-gate.sh +4 -6
  253. package/templates/hooks/scope-helpers.sh +28 -1
  254. package/templates/hooks/scope-lifecycle-gate.sh +14 -5
  255. package/templates/hooks/scope-prepare.sh +67 -12
  256. package/templates/hooks/scope-transition.sh +14 -6
  257. package/templates/hooks/time-tracker.sh +2 -5
  258. package/templates/migrations/renames.json +1 -0
  259. package/templates/orbital.config.json +8 -6
  260. package/{shared/default-workflow.json → templates/presets/default.json} +65 -0
  261. package/templates/presets/development.json +4 -4
  262. package/templates/presets/gitflow.json +7 -0
  263. package/templates/prompts/README.md +23 -0
  264. package/templates/prompts/deep-dive-audit.md +94 -0
  265. package/templates/quick/rules.md +56 -5
  266. package/templates/settings-hooks.json +1 -1
  267. package/templates/skills/git-commit/SKILL.md +27 -7
  268. package/templates/skills/git-dev/SKILL.md +13 -4
  269. package/templates/skills/git-main/SKILL.md +13 -3
  270. package/templates/skills/git-production/SKILL.md +9 -2
  271. package/templates/skills/git-staging/SKILL.md +11 -3
  272. package/templates/skills/scope-create/SKILL.md +17 -3
  273. package/templates/skills/scope-fix-review/SKILL.md +14 -7
  274. package/templates/skills/scope-implement/SKILL.md +15 -4
  275. package/templates/skills/scope-post-review/SKILL.md +77 -7
  276. package/templates/skills/scope-pre-review/SKILL.md +11 -4
  277. package/templates/skills/scope-verify/SKILL.md +5 -3
  278. package/templates/skills/test-code-review/SKILL.md +41 -33
  279. package/templates/skills/test-scaffold/SKILL.md +222 -0
  280. package/dist/assets/WorkflowVisualizer-BZ21PIIF.js +0 -84
  281. package/dist/assets/charts-D__PA1zp.js +0 -72
  282. package/dist/assets/index-D1G6i0nS.css +0 -1
  283. package/dist/assets/index-DpItvKpf.js +0 -419
  284. package/dist/assets/ui-BvF022GT.js +0 -53
  285. package/index.html +0 -15
  286. package/postcss.config.js +0 -6
  287. package/src/App.tsx +0 -33
  288. package/src/components/AgentBadge.tsx +0 -40
  289. package/src/components/BatchPreflightModal.tsx +0 -115
  290. package/src/components/CardDisplayToggle.tsx +0 -74
  291. package/src/components/ColumnHeaderActions.tsx +0 -55
  292. package/src/components/ColumnMenu.tsx +0 -99
  293. package/src/components/DeployHistory.tsx +0 -141
  294. package/src/components/DispatchModal.tsx +0 -164
  295. package/src/components/DispatchPopover.tsx +0 -139
  296. package/src/components/DragOverlay.tsx +0 -25
  297. package/src/components/DriftSidebar.tsx +0 -140
  298. package/src/components/EnvironmentStrip.tsx +0 -88
  299. package/src/components/ErrorBoundary.tsx +0 -62
  300. package/src/components/FilterChip.tsx +0 -105
  301. package/src/components/GateIndicator.tsx +0 -33
  302. package/src/components/IdeaDetailModal.tsx +0 -190
  303. package/src/components/IdeaFormDialog.tsx +0 -113
  304. package/src/components/KanbanColumn.tsx +0 -201
  305. package/src/components/MarkdownRenderer.tsx +0 -114
  306. package/src/components/NeonGrid.tsx +0 -128
  307. package/src/components/PromotionQueue.tsx +0 -89
  308. package/src/components/ScopeCard.tsx +0 -234
  309. package/src/components/ScopeDetailModal.tsx +0 -255
  310. package/src/components/ScopeFilterBar.tsx +0 -152
  311. package/src/components/SearchInput.tsx +0 -102
  312. package/src/components/SessionPanel.tsx +0 -335
  313. package/src/components/SprintContainer.tsx +0 -303
  314. package/src/components/SprintDependencyDialog.tsx +0 -78
  315. package/src/components/SprintPreflightModal.tsx +0 -138
  316. package/src/components/StatusBar.tsx +0 -168
  317. package/src/components/SwimCell.tsx +0 -67
  318. package/src/components/SwimLaneRow.tsx +0 -94
  319. package/src/components/SwimlaneBoardView.tsx +0 -108
  320. package/src/components/VersionBadge.tsx +0 -139
  321. package/src/components/ViewModeSelector.tsx +0 -114
  322. package/src/components/config/AgentChip.tsx +0 -53
  323. package/src/components/config/AgentCreateDialog.tsx +0 -321
  324. package/src/components/config/AgentEditor.tsx +0 -175
  325. package/src/components/config/DirectoryTree.tsx +0 -582
  326. package/src/components/config/FileEditor.tsx +0 -550
  327. package/src/components/config/HookChip.tsx +0 -50
  328. package/src/components/config/StageCard.tsx +0 -198
  329. package/src/components/config/TransitionZone.tsx +0 -173
  330. package/src/components/config/UnifiedWorkflowPipeline.tsx +0 -216
  331. package/src/components/config/WorkflowPipeline.tsx +0 -161
  332. package/src/components/source-control/BranchList.tsx +0 -93
  333. package/src/components/source-control/BranchPanel.tsx +0 -105
  334. package/src/components/source-control/CommitLog.tsx +0 -100
  335. package/src/components/source-control/CommitRow.tsx +0 -47
  336. package/src/components/source-control/GitHubPanel.tsx +0 -110
  337. package/src/components/source-control/GitHubSetupGuide.tsx +0 -52
  338. package/src/components/source-control/GitOverviewBar.tsx +0 -101
  339. package/src/components/source-control/PullRequestList.tsx +0 -69
  340. package/src/components/source-control/WorktreeList.tsx +0 -80
  341. package/src/components/ui/badge.tsx +0 -41
  342. package/src/components/ui/button.tsx +0 -55
  343. package/src/components/ui/card.tsx +0 -78
  344. package/src/components/ui/dialog.tsx +0 -94
  345. package/src/components/ui/popover.tsx +0 -33
  346. package/src/components/ui/scroll-area.tsx +0 -54
  347. package/src/components/ui/separator.tsx +0 -28
  348. package/src/components/ui/tabs.tsx +0 -52
  349. package/src/components/ui/toggle-switch.tsx +0 -35
  350. package/src/components/ui/tooltip.tsx +0 -27
  351. package/src/components/workflow/AddEdgeDialog.tsx +0 -217
  352. package/src/components/workflow/AddListDialog.tsx +0 -201
  353. package/src/components/workflow/ChecklistEditor.tsx +0 -239
  354. package/src/components/workflow/CommandPrefixManager.tsx +0 -118
  355. package/src/components/workflow/ConfigSettingsPanel.tsx +0 -189
  356. package/src/components/workflow/DirectionSelector.tsx +0 -133
  357. package/src/components/workflow/DispatchConfigPanel.tsx +0 -180
  358. package/src/components/workflow/EdgeDetailPanel.tsx +0 -236
  359. package/src/components/workflow/EdgePropertyEditor.tsx +0 -251
  360. package/src/components/workflow/EditToolbar.tsx +0 -138
  361. package/src/components/workflow/HookDetailPanel.tsx +0 -250
  362. package/src/components/workflow/HookExecutionLog.tsx +0 -24
  363. package/src/components/workflow/HookSourceModal.tsx +0 -129
  364. package/src/components/workflow/HooksDashboard.tsx +0 -363
  365. package/src/components/workflow/ListPropertyEditor.tsx +0 -251
  366. package/src/components/workflow/MigrationPreviewDialog.tsx +0 -237
  367. package/src/components/workflow/MovementRulesPanel.tsx +0 -188
  368. package/src/components/workflow/NodeDetailPanel.tsx +0 -245
  369. package/src/components/workflow/PresetSelector.tsx +0 -414
  370. package/src/components/workflow/SkillCommandBuilder.tsx +0 -174
  371. package/src/components/workflow/WorkflowEdgeComponent.tsx +0 -145
  372. package/src/components/workflow/WorkflowNode.tsx +0 -147
  373. package/src/components/workflow/graphLayout.ts +0 -186
  374. package/src/components/workflow/mergeHooks.ts +0 -85
  375. package/src/components/workflow/useEditHistory.ts +0 -88
  376. package/src/components/workflow/useWorkflowEditor.ts +0 -262
  377. package/src/components/workflow/validateConfig.ts +0 -70
  378. package/src/hooks/useActiveDispatches.ts +0 -198
  379. package/src/hooks/useBoardSettings.ts +0 -170
  380. package/src/hooks/useCardDisplay.ts +0 -57
  381. package/src/hooks/useCcHooks.ts +0 -24
  382. package/src/hooks/useConfigTree.ts +0 -51
  383. package/src/hooks/useEnforcementRules.ts +0 -46
  384. package/src/hooks/useEvents.ts +0 -59
  385. package/src/hooks/useFileEditor.ts +0 -165
  386. package/src/hooks/useGates.ts +0 -57
  387. package/src/hooks/useIdeaActions.ts +0 -53
  388. package/src/hooks/useKanbanDnd.ts +0 -410
  389. package/src/hooks/useOrbitalConfig.ts +0 -54
  390. package/src/hooks/usePipeline.ts +0 -47
  391. package/src/hooks/usePipelineData.ts +0 -338
  392. package/src/hooks/useReconnect.ts +0 -25
  393. package/src/hooks/useScopeFilters.ts +0 -125
  394. package/src/hooks/useScopeSessions.ts +0 -44
  395. package/src/hooks/useScopes.ts +0 -67
  396. package/src/hooks/useSearch.ts +0 -67
  397. package/src/hooks/useSettings.tsx +0 -187
  398. package/src/hooks/useSocket.ts +0 -25
  399. package/src/hooks/useSourceControl.ts +0 -105
  400. package/src/hooks/useSprintPreflight.ts +0 -55
  401. package/src/hooks/useSprints.ts +0 -154
  402. package/src/hooks/useStatusBarHighlight.ts +0 -18
  403. package/src/hooks/useSwimlaneBoardSettings.ts +0 -104
  404. package/src/hooks/useTheme.ts +0 -9
  405. package/src/hooks/useTransitionReadiness.ts +0 -53
  406. package/src/hooks/useVersion.ts +0 -155
  407. package/src/hooks/useViolations.ts +0 -65
  408. package/src/hooks/useWorkflow.tsx +0 -125
  409. package/src/hooks/useZoomModifier.ts +0 -19
  410. package/src/index.css +0 -797
  411. package/src/layouts/DashboardLayout.tsx +0 -113
  412. package/src/lib/collisionDetection.ts +0 -20
  413. package/src/lib/scope-fields.ts +0 -61
  414. package/src/lib/swimlane.ts +0 -146
  415. package/src/lib/utils.ts +0 -15
  416. package/src/main.tsx +0 -19
  417. package/src/socket.ts +0 -11
  418. package/src/types/index.ts +0 -497
  419. package/src/views/AgentFeed.tsx +0 -339
  420. package/src/views/DeployPipeline.tsx +0 -59
  421. package/src/views/EnforcementView.tsx +0 -378
  422. package/src/views/PrimitivesConfig.tsx +0 -500
  423. package/src/views/QualityGates.tsx +0 -1012
  424. package/src/views/ScopeBoard.tsx +0 -454
  425. package/src/views/SessionTimeline.tsx +0 -516
  426. package/src/views/Settings.tsx +0 -183
  427. package/src/views/SourceControl.tsx +0 -95
  428. package/src/views/WorkflowVisualizer.tsx +0 -382
  429. package/tailwind.config.js +0 -161
  430. package/tsconfig.json +0 -25
  431. package/vite.config.ts +0 -38
@@ -1,1012 +0,0 @@
1
- import { useState, useMemo, useEffect, useCallback } from 'react';
2
- import { useSearchParams } from 'react-router-dom';
3
- import {
4
- ShieldCheck, ArrowRight, CheckCircle2, XCircle, MinusCircle,
5
- AlertTriangle, Clock, Terminal, Shield, ShieldAlert, Eye, Cog,
6
- } from 'lucide-react';
7
- import { formatDistanceToNow } from 'date-fns';
8
- import {
9
- BarChart, Bar, XAxis, YAxis, Tooltip as RechartsTooltip,
10
- ResponsiveContainer, Cell, AreaChart, Area, CartesianGrid,
11
- PieChart, Pie, Legend,
12
- } from 'recharts';
13
- import { useScopes } from '@/hooks/useScopes';
14
- import { useTransitionReadiness } from '@/hooks/useTransitionReadiness';
15
- import { useGates } from '@/hooks/useGates';
16
- import { useViolations } from '@/hooks/useViolations';
17
- import { useEnforcementRules } from '@/hooks/useEnforcementRules';
18
- import { useWorkflow } from '@/hooks/useWorkflow';
19
- import { GateIndicator } from '@/components/GateIndicator';
20
- import { Badge } from '@/components/ui/badge';
21
- import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
22
- import { Button } from '@/components/ui/button';
23
- import { cn } from '@/lib/utils';
24
- import type { Scope, GateStatus, HookStatus, EnforcementRule, ViolationTrendPoint, OrbitalEvent } from '@/types';
25
-
26
- function formatGateName(name: string): string {
27
- return name.replace(/-/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
28
- }
29
-
30
- const ENFORCEMENT_COLORS: Record<string, string> = {
31
- blocker: 'text-red-400 bg-red-500/10 border-red-500/20',
32
- advisor: 'text-amber-400 bg-amber-500/10 border-amber-500/20',
33
- operator: 'text-cyan-400 bg-cyan-500/10 border-cyan-500/20',
34
- silent: 'text-zinc-400 bg-zinc-500/10 border-zinc-500/20',
35
- };
36
-
37
- const CATEGORY_LABELS: Record<string, string> = {
38
- guard: 'GUARD', gate: 'GATE', lifecycle: 'LIFECYCLE', observer: 'OBSERVER',
39
- };
40
-
41
- const CATEGORY_ICON: Record<string, typeof Shield> = {
42
- guard: Shield, gate: ShieldAlert, lifecycle: Cog, observer: Eye,
43
- };
44
-
45
- // ─── Main Page ──────────────────────────────────────────────
46
-
47
- export function QualityGates() {
48
- const { scopes } = useScopes();
49
- const { engine } = useWorkflow();
50
- const [searchParams, setSearchParams] = useSearchParams();
51
- const [selectedScopeId, setSelectedScopeId] = useState<number | null>(() => {
52
- const param = searchParams.get('scope');
53
- return param ? Number(param) : null;
54
- });
55
-
56
- useEffect(() => {
57
- if (selectedScopeId != null) {
58
- setSearchParams({ scope: String(selectedScopeId) }, { replace: true });
59
- }
60
- }, [selectedScopeId, setSearchParams]);
61
-
62
- const activeScopes = useMemo(() => {
63
- return scopes
64
- .filter((s) => !engine.isTerminalStatus(s.status) && s.status !== 'icebox' && !s.is_ghost)
65
- .sort((a, b) => a.id - b.id);
66
- }, [scopes, engine]);
67
-
68
- const scopesByStatus = useMemo(() => {
69
- const map = new Map<string, Scope[]>();
70
- for (const scope of activeScopes) {
71
- const existing = map.get(scope.status) ?? [];
72
- existing.push(scope);
73
- map.set(scope.status, existing);
74
- }
75
- return map;
76
- }, [activeScopes]);
77
-
78
- const effectiveScopeId = selectedScopeId ?? activeScopes[0]?.id ?? null;
79
- const { readiness, loading: readinessLoading } = useTransitionReadiness(effectiveScopeId);
80
- const selectedScope = activeScopes.find((s) => s.id === effectiveScopeId);
81
-
82
- return (
83
- <div className="flex-1 min-h-0 overflow-y-auto space-y-6">
84
- {/* ═══ Section 1: Transition Readiness ═══ */}
85
- <section>
86
- <div className="mb-4 flex items-center gap-3">
87
- <ShieldCheck className="h-4 w-4 text-primary" />
88
- <h1 className="text-xl font-light">Safeguards</h1>
89
- {readiness && (
90
- <Badge variant="secondary">
91
- {readiness.transitions.filter((t) => t.ready).length}/{readiness.transitions.length} ready
92
- </Badge>
93
- )}
94
- </div>
95
-
96
- {/* Scope Selector */}
97
- <div className="mb-4 flex flex-wrap gap-1.5">
98
- {engine.getLists()
99
- .filter((l) => !engine.isTerminalStatus(l.id) && l.id !== 'icebox' && scopesByStatus.has(l.id))
100
- .map((list) => (
101
- <div key={list.id} className="flex items-center gap-1">
102
- <span className="mr-0.5 text-[10px] uppercase tracking-wider text-muted-foreground/50">
103
- {list.label}
104
- </span>
105
- {(scopesByStatus.get(list.id) ?? []).map((scope) => (
106
- <button
107
- key={scope.id}
108
- onClick={() => setSelectedScopeId(scope.id)}
109
- className={cn(
110
- 'rounded border px-2 py-0.5 text-xs font-mono transition-all',
111
- scope.id === effectiveScopeId
112
- ? 'border-primary/50 bg-primary/10 text-primary'
113
- : 'border-border/50 bg-surface-light/30 text-muted-foreground hover:border-primary/30 hover:text-foreground',
114
- )}
115
- >
116
- {String(scope.id).padStart(3, '0')}
117
- </button>
118
- ))}
119
- <span className="mx-1.5 text-border">|</span>
120
- </div>
121
- ))}
122
- {activeScopes.length === 0 && (
123
- <span className="text-xs text-muted-foreground">No active scopes</span>
124
- )}
125
- </div>
126
-
127
- {/* Scope Readiness Overview Chart */}
128
- {activeScopes.length > 0 && (
129
- <ScopeReadinessOverview
130
- scopes={activeScopes}
131
- selectedId={effectiveScopeId}
132
- onSelect={setSelectedScopeId}
133
- />
134
- )}
135
-
136
- {/* Transition Cards + Scope Sidebar */}
137
- {effectiveScopeId && selectedScope && (
138
- <div className="grid gap-5 lg:grid-cols-3">
139
- <div className="lg:col-span-2 space-y-4">
140
- {readinessLoading ? (
141
- <div className="flex h-32 items-center justify-center">
142
- <div className="h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent" />
143
- </div>
144
- ) : readiness && readiness.transitions.length > 0 ? (
145
- readiness.transitions.map((transition) => (
146
- <TransitionCard
147
- key={`${transition.from}-${transition.to}`}
148
- transition={transition}
149
- scopeId={effectiveScopeId}
150
- />
151
- ))
152
- ) : (
153
- <Card>
154
- <CardContent className="py-8 text-center">
155
- <CheckCircle2 className="mx-auto mb-3 h-8 w-8 text-muted-foreground/50" />
156
- <p className="text-sm text-muted-foreground">
157
- No forward transitions from <span className="font-mono">{selectedScope.status}</span>
158
- </p>
159
- </CardContent>
160
- </Card>
161
- )}
162
- </div>
163
-
164
- <div className="space-y-4">
165
- <ScopeInfoCard scope={selectedScope} />
166
- {readiness && readiness.transitions.length > 0 && readiness.transitions[0].gates.length > 0 && (
167
- <CIGatesCard gates={readiness.transitions[0].gates} />
168
- )}
169
- </div>
170
- </div>
171
- )}
172
- </section>
173
-
174
- {/* ═══ Section 2: Rule Configuration ═══ */}
175
- <RuleConfigSection />
176
-
177
- {/* ═══ Section 3: Enforcement Activity ═══ */}
178
- <EnforcementActivitySection />
179
-
180
- {/* ═══ Section 4: CI Gates ═══ */}
181
- <GlobalCISection />
182
- </div>
183
- );
184
- }
185
-
186
- // ─── Section: Scope Info ────────────────────────────────────
187
-
188
- function ScopeInfoCard({ scope }: { scope: Scope }) {
189
- const id = String(scope.id).padStart(3, '0');
190
- const title = scope.title.length > 30 ? scope.title.slice(0, 30) + '...' : scope.title;
191
-
192
- return (
193
- <Card>
194
- <CardHeader className="pb-2">
195
- <CardTitle className="text-sm font-mono">{id} {title}</CardTitle>
196
- </CardHeader>
197
- <CardContent className="space-y-2 text-xs">
198
- <div className="flex justify-between">
199
- <span className="text-muted-foreground">Status</span>
200
- <Badge variant="outline" className="text-[10px]">{scope.status}</Badge>
201
- </div>
202
- {scope.priority && (
203
- <div className="flex justify-between">
204
- <span className="text-muted-foreground">Priority</span>
205
- <span>{scope.priority}</span>
206
- </div>
207
- )}
208
- {scope.blocked_by.length > 0 && (
209
- <div className="flex justify-between">
210
- <span className="text-muted-foreground">Blocked by</span>
211
- <span className="font-mono text-amber-400">
212
- {scope.blocked_by.map((bid) => String(bid).padStart(3, '0')).join(', ')}
213
- </span>
214
- </div>
215
- )}
216
- {Object.keys(scope.sessions).length > 0 && (
217
- <div className="pt-1 border-t border-border/50">
218
- <span className="text-muted-foreground text-[10px] uppercase tracking-wider">Sessions</span>
219
- {Object.entries(scope.sessions).map(([key, ids]) => (
220
- <div key={key} className="flex justify-between mt-1">
221
- <span className="text-muted-foreground">{key}</span>
222
- <span className="font-mono text-[10px]">{ids.length} recorded</span>
223
- </div>
224
- ))}
225
- </div>
226
- )}
227
- </CardContent>
228
- </Card>
229
- );
230
- }
231
-
232
- function CIGatesCard({ gates }: { gates: Array<{ gate_name: string; status: string; duration_ms: number | null }> }) {
233
- return (
234
- <Card>
235
- <CardHeader className="pb-2">
236
- <CardTitle className="text-sm">CI Gates</CardTitle>
237
- </CardHeader>
238
- <CardContent className="space-y-0.5">
239
- {gates.map((gate) => (
240
- <div key={gate.gate_name} className="flex items-center gap-2 py-0.5">
241
- <GateIndicator status={gate.status as GateStatus} />
242
- <span className="flex-1 text-[11px]">{formatGateName(gate.gate_name)}</span>
243
- {gate.duration_ms != null && (
244
- <span className="font-mono text-[10px] text-muted-foreground">
245
- {(gate.duration_ms / 1000).toFixed(1)}s
246
- </span>
247
- )}
248
- </div>
249
- ))}
250
- </CardContent>
251
- </Card>
252
- );
253
- }
254
-
255
- // ─── Section: Transition Card ───────────────────────────────
256
-
257
- function TransitionCard({
258
- transition,
259
- scopeId,
260
- }: {
261
- transition: import('@/types').TransitionReadiness;
262
- scopeId: number;
263
- }) {
264
- const [dispatching, setDispatching] = useState(false);
265
- const command = transition.edge.command?.replace('{id}', String(scopeId)) ?? null;
266
-
267
- async function handleDispatch() {
268
- if (!command) return;
269
- setDispatching(true);
270
- try {
271
- await fetch('/api/orbital/dispatch', {
272
- method: 'POST',
273
- headers: { 'Content-Type': 'application/json' },
274
- body: JSON.stringify({
275
- scope_id: scopeId,
276
- command,
277
- transition: { from: transition.from, to: transition.to },
278
- }),
279
- });
280
- } catch {
281
- // dispatch error
282
- } finally {
283
- setDispatching(false);
284
- }
285
- }
286
-
287
- return (
288
- <Card className={cn('transition-all', transition.ready ? 'border-bid-green/20' : 'border-border')}>
289
- <CardHeader className="pb-2">
290
- <div className="flex items-center justify-between">
291
- <div className="flex items-center gap-2">
292
- <Badge variant="outline" className="text-[10px] font-mono">{transition.from}</Badge>
293
- <ArrowRight className="h-3 w-3 text-muted-foreground" />
294
- <Badge variant="outline" className="text-[10px] font-mono">{transition.to}</Badge>
295
- <span className="text-xs text-muted-foreground ml-1">{transition.edge.label}</span>
296
- </div>
297
- <div className="flex items-center gap-2">
298
- {transition.ready && (
299
- <Badge className="bg-bid-green/10 text-bid-green border-bid-green/20 text-[10px]">Ready</Badge>
300
- )}
301
- {command && transition.edge.dispatchOnly && (
302
- <Button
303
- size="sm"
304
- variant={transition.ready ? 'default' : 'outline'}
305
- className="h-6 text-[11px] gap-1"
306
- disabled={!transition.ready || dispatching}
307
- onClick={handleDispatch}
308
- >
309
- <Terminal className="h-3 w-3" />
310
- {dispatching ? 'Dispatching...' : 'Dispatch'}
311
- </Button>
312
- )}
313
- </div>
314
- </div>
315
- {command && (
316
- <code className="text-[10px] font-mono text-muted-foreground/60 mt-1">{command}</code>
317
- )}
318
- </CardHeader>
319
- <CardContent className="space-y-3">
320
- {transition.hooks.length > 0 && (
321
- <div>
322
- <span className="text-[10px] uppercase tracking-wider text-muted-foreground/50 mb-1.5 block">
323
- Workflow Hooks
324
- </span>
325
- <div className="space-y-1">
326
- {transition.hooks.map((hook) => (
327
- <HookStatusRow key={hook.id} hook={hook} />
328
- ))}
329
- </div>
330
- </div>
331
- )}
332
- {transition.edge.checklist && transition.edge.checklist.length > 0 && (
333
- <div>
334
- <span className="text-[10px] uppercase tracking-wider text-muted-foreground/50 mb-1.5 block">Checklist</span>
335
- <div className="space-y-1">
336
- {transition.edge.checklist.map((item, idx) => (
337
- <div key={idx} className="flex items-start gap-2 text-xs text-muted-foreground">
338
- <MinusCircle className="h-3 w-3 mt-0.5 flex-shrink-0 text-muted-foreground/40" />
339
- <span>{item}</span>
340
- </div>
341
- ))}
342
- </div>
343
- </div>
344
- )}
345
- {transition.blockers.length > 0 && (
346
- <div className="rounded border border-red-500/20 bg-red-500/5 p-2">
347
- <div className="flex items-center gap-1.5 mb-1">
348
- <AlertTriangle className="h-3 w-3 text-red-400" />
349
- <span className="text-[10px] font-medium text-red-400">
350
- {transition.blockers.length} Blocker{transition.blockers.length !== 1 ? 's' : ''}
351
- </span>
352
- </div>
353
- {transition.blockers.map((blocker, idx) => (
354
- <p key={idx} className="text-[11px] text-red-400/80 ml-4.5">{blocker}</p>
355
- ))}
356
- </div>
357
- )}
358
- </CardContent>
359
- </Card>
360
- );
361
- }
362
-
363
- function HookStatusRow({ hook }: { hook: HookStatus }) {
364
- const statusIcon = hook.status === 'pass'
365
- ? <CheckCircle2 className="h-3.5 w-3.5 text-bid-green" />
366
- : hook.status === 'fail'
367
- ? <XCircle className="h-3.5 w-3.5 text-red-400" />
368
- : <MinusCircle className="h-3.5 w-3.5 text-muted-foreground/50" />;
369
-
370
- return (
371
- <div className="flex items-center gap-2 rounded px-2 py-1 hover:bg-surface-light/50">
372
- {statusIcon}
373
- <span className="flex-1 text-xs">{hook.label}</span>
374
- <Badge
375
- variant="outline"
376
- className={cn('text-[9px] px-1.5 py-0 h-4 border', ENFORCEMENT_COLORS[hook.enforcement])}
377
- >
378
- {CATEGORY_LABELS[hook.category]}
379
- </Badge>
380
- {hook.reason && (
381
- <span className="text-[10px] text-muted-foreground/60 max-w-[200px] truncate">{hook.reason}</span>
382
- )}
383
- </div>
384
- );
385
- }
386
-
387
- // ─── Section: Rule Configuration ────────────────────────────
388
-
389
- function RuleConfigSection() {
390
- const { data: rulesData, loading } = useEnforcementRules();
391
-
392
- if (loading || !rulesData || rulesData.rules.length === 0) return null;
393
-
394
- return (
395
- <section>
396
- <div className="mb-3 flex items-center gap-3">
397
- <Shield className="h-4 w-4 text-muted-foreground" />
398
- <h2 className="text-base font-light">Rule Configuration</h2>
399
- </div>
400
-
401
- {/* Summary strip + Donut */}
402
- <div className="mb-4 grid gap-4 lg:grid-cols-4">
403
- <div className="lg:col-span-3 flex flex-wrap items-center gap-3 rounded-lg border border-border/50 bg-surface-light/20 px-4 py-2 self-start">
404
- <SummaryChip count={rulesData.summary.guards} label="guards" color="text-red-400" />
405
- <SummaryChip count={rulesData.summary.gates} label="gates" color="text-amber-400" />
406
- <SummaryChip count={rulesData.summary.lifecycle} label="lifecycle" color="text-cyan-400" />
407
- <SummaryChip count={rulesData.summary.observers} label="observers" color="text-zinc-400" />
408
- <span className="text-border">|</span>
409
- <span className="text-xs text-muted-foreground">
410
- {rulesData.totalEdges} edge{rulesData.totalEdges !== 1 ? 's' : ''}
411
- </span>
412
- </div>
413
- <Card className="flex items-center justify-center">
414
- <CardContent className="p-2">
415
- <HookCategoryDonut summary={rulesData.summary} />
416
- </CardContent>
417
- </Card>
418
- </div>
419
-
420
- {/* Matrix */}
421
- <Card>
422
- <CardContent className="p-0">
423
- <div className="overflow-x-auto">
424
- <table className="w-full text-xs">
425
- <thead>
426
- <tr className="border-b border-border text-left text-[10px] text-muted-foreground uppercase tracking-wider">
427
- <th className="px-4 py-2 font-medium">Hook</th>
428
- <th className="px-4 py-2 font-medium">Category</th>
429
- <th className="px-4 py-2 font-medium">Level</th>
430
- <th className="px-4 py-2 font-medium">Edges</th>
431
- <th className="px-4 py-2 font-medium text-right">Violations</th>
432
- <th className="px-4 py-2 font-medium text-right">Overrides</th>
433
- <th className="px-4 py-2 font-medium text-right">Last Fired</th>
434
- </tr>
435
- </thead>
436
- <tbody>
437
- {rulesData.rules.map((rule) => (
438
- <RuleRow key={rule.hook.id} rule={rule} />
439
- ))}
440
- </tbody>
441
- </table>
442
- </div>
443
- </CardContent>
444
- </Card>
445
- </section>
446
- );
447
- }
448
-
449
- function RuleRow({ rule }: { rule: EnforcementRule }) {
450
- const Icon = CATEGORY_ICON[rule.hook.category] ?? Shield;
451
- return (
452
- <tr className="border-b border-border/30 last:border-0 hover:bg-surface-light/30">
453
- <td className="px-4 py-2">
454
- <div className="flex items-center gap-1.5">
455
- <Icon className="h-3 w-3 text-muted-foreground/50" />
456
- <span className="font-medium">{rule.hook.label}</span>
457
- </div>
458
- </td>
459
- <td className="px-4 py-2">
460
- <Badge variant="outline" className={cn('text-[9px] border', ENFORCEMENT_COLORS[rule.enforcement])}>
461
- {rule.hook.category}
462
- </Badge>
463
- </td>
464
- <td className="px-4 py-2">
465
- <span className={cn('text-[10px]', ENFORCEMENT_COLORS[rule.enforcement]?.split(' ')[0])}>
466
- {rule.enforcement}
467
- </span>
468
- </td>
469
- <td className="px-4 py-2">
470
- {rule.edges.length > 0 ? (
471
- <div className="flex flex-wrap gap-1">
472
- {rule.edges.slice(0, 3).map((e, idx) => (
473
- <span key={idx} className="inline-flex items-center gap-0.5 text-[9px] text-muted-foreground font-mono">
474
- {e.from}<ArrowRight className="h-2 w-2" />{e.to}
475
- </span>
476
- ))}
477
- {rule.edges.length > 3 && (
478
- <span className="text-[9px] text-muted-foreground">+{rule.edges.length - 3}</span>
479
- )}
480
- </div>
481
- ) : (
482
- <span className="text-[9px] text-muted-foreground">-</span>
483
- )}
484
- </td>
485
- <td className="px-4 py-2 text-right font-mono">
486
- {rule.stats.violations > 0 ? (
487
- <span className="text-red-400">{rule.stats.violations}</span>
488
- ) : (
489
- <span className="text-muted-foreground/40">0</span>
490
- )}
491
- </td>
492
- <td className="px-4 py-2 text-right font-mono">
493
- {rule.stats.overrides > 0 ? (
494
- <span className="text-amber-400">{rule.stats.overrides}</span>
495
- ) : (
496
- <span className="text-muted-foreground/40">0</span>
497
- )}
498
- </td>
499
- <td className="px-4 py-2 text-right text-muted-foreground/60">
500
- {rule.stats.last_triggered
501
- ? formatDistanceToNow(new Date(rule.stats.last_triggered), { addSuffix: true })
502
- : '-'}
503
- </td>
504
- </tr>
505
- );
506
- }
507
-
508
- // ─── Section: Enforcement Activity ──────────────────────────
509
-
510
- function EnforcementActivitySection() {
511
- const { byRule, overrides, totalViolations, totalOverrides, loading: violationsLoading } = useViolations();
512
- const { trend, loading: trendLoading } = useEnforcementRules();
513
-
514
- const [recentViolations, setRecentViolations] = useState<OrbitalEvent[]>([]);
515
- const fetchRecent = useCallback(async () => {
516
- try {
517
- const res = await fetch('/api/orbital/events?type=VIOLATION&limit=15');
518
- if (res.ok) setRecentViolations(await res.json());
519
- } catch { /* ok */ }
520
- }, []);
521
- useEffect(() => { fetchRecent(); }, [fetchRecent]);
522
-
523
- const overrideRate = (totalViolations + totalOverrides) > 0
524
- ? Math.round((totalOverrides / (totalViolations + totalOverrides)) * 100) : 0;
525
-
526
- const isLoading = violationsLoading || trendLoading;
527
-
528
- return (
529
- <section>
530
- {/* Header with inline stats */}
531
- <div className="mb-3 flex items-center gap-3 flex-wrap">
532
- <ShieldAlert className="h-4 w-4 text-red-400" />
533
- <h2 className="text-base font-light">Enforcement Activity</h2>
534
- <div className="flex items-center gap-3 ml-auto text-xs">
535
- <span><span className="text-red-400 font-medium">{totalViolations}</span> <span className="text-muted-foreground">violations</span></span>
536
- <span><span className="text-amber-400 font-medium">{totalOverrides}</span> <span className="text-muted-foreground">overrides</span></span>
537
- <span className={cn('font-medium', overrideRate > 50 ? 'text-amber-400' : 'text-muted-foreground')}>{overrideRate}% <span className="font-normal text-muted-foreground">override rate</span></span>
538
- </div>
539
- </div>
540
-
541
- {isLoading ? (
542
- <div className="flex h-20 items-center justify-center">
543
- <div className="h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent" />
544
- </div>
545
- ) : (
546
- <div className="grid gap-4 lg:grid-cols-2">
547
- {/* Left: charts */}
548
- <div className="space-y-4">
549
- <ViolationsVsOverridesChart byRule={byRule} overrides={overrides} />
550
- <ViolationTrendChart trend={trend} />
551
- </div>
552
-
553
- {/* Right: tables */}
554
- <div className="space-y-4">
555
- <Card>
556
- <CardHeader className="pb-1"><CardTitle className="text-sm">Recent Violations</CardTitle></CardHeader>
557
- <CardContent className={recentViolations.length > 0 ? 'p-0' : undefined}>
558
- {recentViolations.length === 0 ? (
559
- <p className="text-xs text-muted-foreground text-center py-3">No violations recorded</p>
560
- ) : (
561
- <div className="overflow-x-auto">
562
- <table className="w-full text-xs">
563
- <thead>
564
- <tr className="border-b border-border text-left text-[10px] text-muted-foreground uppercase tracking-wider">
565
- <th className="px-3 py-1.5 font-medium">Rule</th>
566
- <th className="px-3 py-1.5 font-medium">Scope</th>
567
- <th className="px-3 py-1.5 font-medium">Outcome</th>
568
- <th className="px-3 py-1.5 font-medium text-right">Time</th>
569
- </tr>
570
- </thead>
571
- <tbody>
572
- {recentViolations.map((v) => {
573
- const data = v.data as Record<string, string>;
574
- return (
575
- <tr key={v.id} className="border-b border-border/30 last:border-0 hover:bg-surface-light/30">
576
- <td className="px-3 py-1 font-mono text-red-400">{data?.rule ?? '-'}</td>
577
- <td className="px-3 py-1 font-mono text-muted-foreground">
578
- {v.scope_id ? String(v.scope_id).padStart(3, '0') : '-'}
579
- </td>
580
- <td className="px-3 py-1">
581
- <Badge variant="outline" className="text-[9px] border-red-500/30 text-red-400">
582
- {data?.outcome ?? 'blocked'}
583
- </Badge>
584
- </td>
585
- <td className="px-3 py-1 text-right text-muted-foreground/60">
586
- {v.timestamp ? formatDistanceToNow(new Date(v.timestamp), { addSuffix: true }) : '-'}
587
- </td>
588
- </tr>
589
- );
590
- })}
591
- </tbody>
592
- </table>
593
- </div>
594
- )}
595
- </CardContent>
596
- </Card>
597
-
598
- <Card>
599
- <CardHeader className="pb-1"><CardTitle className="text-sm">Recent Overrides</CardTitle></CardHeader>
600
- <CardContent>
601
- {overrides.length === 0 ? (
602
- <p className="text-xs text-muted-foreground text-center py-3">No overrides recorded</p>
603
- ) : (
604
- <div className="space-y-1.5">
605
- {overrides.slice(0, 8).map((o, idx) => (
606
- <div key={idx} className="rounded border border-amber-500/20 bg-amber-500/5 px-2.5 py-1.5">
607
- <div className="flex items-center justify-between gap-2">
608
- <span className="text-[11px] font-medium text-amber-400">{o.rule ?? 'unknown'}</span>
609
- <span className="flex-shrink-0 text-[9px] text-muted-foreground/50">
610
- {o.date ? formatDistanceToNow(new Date(o.date), { addSuffix: true }) : '-'}
611
- </span>
612
- </div>
613
- {o.reason && <p className="mt-0.5 text-[10px] text-muted-foreground line-clamp-1">{o.reason}</p>}
614
- </div>
615
- ))}
616
- </div>
617
- )}
618
- </CardContent>
619
- </Card>
620
- </div>
621
- </div>
622
- )}
623
- </section>
624
- );
625
- }
626
-
627
- // ─── Section: Global CI ─────────────────────────────────────
628
-
629
- function GlobalCISection() {
630
- const { gates, stats, loading } = useGates();
631
-
632
- const totalPassed = stats.reduce((sum, s) => sum + s.passed, 0);
633
- const totalRuns = stats.reduce((sum, s) => sum + s.total, 0);
634
- const passRate = totalRuns > 0 ? Math.round((totalPassed / totalRuns) * 100) : 0;
635
- const passing = gates.filter((g) => g.status === 'pass').length;
636
-
637
- return (
638
- <section>
639
- {/* Header with inline pass rate */}
640
- <div className="mb-3 flex items-center gap-3 flex-wrap">
641
- <CheckCircle2 className="h-4 w-4 text-muted-foreground" />
642
- <h2 className="text-base font-light">CI Gates</h2>
643
- {gates.length > 0 && (
644
- <Badge variant="secondary" className="text-[10px]">{passing}/{gates.length} passing</Badge>
645
- )}
646
- {totalRuns > 0 && (
647
- <div className="ml-auto flex items-center gap-2">
648
- <span className="text-xs text-muted-foreground">Pass rate</span>
649
- <span className="text-sm font-medium">{passRate}%</span>
650
- <div className="h-1.5 w-16 overflow-hidden rounded-full bg-muted">
651
- <div className="h-full rounded-full bg-bid-green transition-all" style={{ width: `${passRate}%` }} />
652
- </div>
653
- </div>
654
- )}
655
- </div>
656
-
657
- {loading ? (
658
- <div className="flex h-20 items-center justify-center">
659
- <div className="h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent" />
660
- </div>
661
- ) : (
662
- <div className="grid gap-4 lg:grid-cols-2">
663
- {/* Latest run */}
664
- <Card>
665
- <CardHeader className="pb-1"><CardTitle className="text-sm">Latest Run</CardTitle></CardHeader>
666
- <CardContent>
667
- {gates.length === 0 ? (
668
- <p className="text-xs text-muted-foreground text-center py-3">
669
- No gate results yet. Run <code className="rounded bg-muted px-1">/test-checks</code> to populate.
670
- </p>
671
- ) : (
672
- <div className="space-y-0.5">
673
- {gates.map((gate) => (
674
- <div key={gate.id} className="flex items-center gap-3 rounded px-2 py-0.5 hover:bg-surface-light/50">
675
- <GateIndicator status={gate.status as GateStatus} />
676
- <span className="flex-1 text-[11px]">{formatGateName(gate.gate_name)}</span>
677
- {gate.duration_ms != null && (
678
- <span className="font-mono text-[10px] text-muted-foreground">{(gate.duration_ms / 1000).toFixed(1)}s</span>
679
- )}
680
- <span className="text-[10px] text-muted-foreground/50">
681
- <Clock className="inline h-2.5 w-2.5 mr-0.5" />
682
- {formatDistanceToNow(new Date(gate.run_at), { addSuffix: true })}
683
- </span>
684
- </div>
685
- ))}
686
- </div>
687
- )}
688
- </CardContent>
689
- </Card>
690
-
691
- {/* Charts: history + duration */}
692
- <div className="space-y-4">
693
- <Card>
694
- <CardHeader className="pb-1"><CardTitle className="text-sm">Gate History</CardTitle></CardHeader>
695
- <CardContent>
696
- {stats.length === 0 ? (
697
- <ChartEmpty height={120} message="No history data" />
698
- ) : (
699
- <ResponsiveContainer width="100%" height={Math.max(120, stats.length * 18)}>
700
- <BarChart
701
- data={stats.map((s) => ({ name: s.gate_name.replace(/-/g, ' ').slice(0, 12), passed: s.passed, failed: s.failed }))}
702
- layout="vertical" margin={{ left: 0, right: 10, top: 0, bottom: 0 }}
703
- >
704
- <XAxis type="number" hide />
705
- <YAxis dataKey="name" type="category" width={85}
706
- tick={{ fontSize: 9, fill: 'hsl(var(--muted-foreground))' }} />
707
- <RechartsTooltip contentStyle={{
708
- background: 'hsl(var(--card))', border: '1px solid hsl(var(--border))',
709
- borderRadius: '6px', fontSize: '11px',
710
- }} />
711
- <Bar dataKey="passed" stackId="a" radius={[0, 0, 0, 0]}>
712
- {stats.map((_, idx) => <Cell key={idx} fill="#00c853" />)}
713
- </Bar>
714
- <Bar dataKey="failed" stackId="a" radius={[0, 4, 4, 0]}>
715
- {stats.map((_, idx) => <Cell key={idx} fill="#ff1744" />)}
716
- </Bar>
717
- </BarChart>
718
- </ResponsiveContainer>
719
- )}
720
- </CardContent>
721
- </Card>
722
-
723
- <Card>
724
- <CardHeader className="pb-1"><CardTitle className="text-sm">Gate Duration</CardTitle></CardHeader>
725
- <CardContent>
726
- {!gates.some((g) => g.duration_ms != null) ? (
727
- <ChartEmpty height={120} message="No duration data" />
728
- ) : (
729
- <ResponsiveContainer width="100%" height={Math.max(120, gates.filter((g) => g.duration_ms != null).length * 18)}>
730
- <BarChart
731
- data={gates
732
- .filter((g) => g.duration_ms != null)
733
- .map((g) => ({
734
- name: g.gate_name.replace(/-/g, ' ').slice(0, 12),
735
- seconds: Number((g.duration_ms! / 1000).toFixed(1)),
736
- status: g.status,
737
- }))}
738
- layout="vertical" margin={{ left: 0, right: 10, top: 0, bottom: 0 }}
739
- >
740
- <XAxis type="number" unit="s" tick={{ fontSize: 9, fill: 'hsl(var(--muted-foreground))' }} />
741
- <YAxis dataKey="name" type="category" width={85}
742
- tick={{ fontSize: 9, fill: 'hsl(var(--muted-foreground))' }} />
743
- <RechartsTooltip
744
- formatter={(val: number) => [`${val}s`, 'Duration']}
745
- contentStyle={{
746
- background: 'hsl(var(--card))', border: '1px solid hsl(var(--border))',
747
- borderRadius: '6px', fontSize: '11px',
748
- }}
749
- />
750
- <Bar dataKey="seconds" radius={[0, 4, 4, 0]}>
751
- {gates.filter((g) => g.duration_ms != null).map((g, idx) => (
752
- <Cell key={idx} fill={g.status === 'pass' ? '#00c85340' : g.status === 'fail' ? '#ff174440' : '#06b6d440'} />
753
- ))}
754
- </Bar>
755
- </BarChart>
756
- </ResponsiveContainer>
757
- )}
758
- </CardContent>
759
- </Card>
760
- </div>
761
- </div>
762
- )}
763
- </section>
764
- );
765
- }
766
-
767
- // ─── Shared Components ──────────────────────────────────────
768
-
769
- function SummaryChip({ count, label, color }: { count: number; label: string; color: string }) {
770
- return (
771
- <span className="flex items-center gap-1">
772
- <span className={cn('text-sm font-medium', color)}>{count}</span>
773
- <span className="text-[11px] text-muted-foreground">{label}</span>
774
- </span>
775
- );
776
- }
777
-
778
-
779
- // ─── Chart: Scope Readiness Overview ────────────────────────
780
-
781
- function ScopeReadinessOverview({
782
- scopes,
783
- }: {
784
- scopes: Scope[];
785
- selectedId: number | null;
786
- onSelect: (id: number) => void;
787
- }) {
788
- // For each scope, we show a mini readiness indicator
789
- // Fetch readiness for all active scopes would be expensive,
790
- // so we show a distribution bar based on scope status position in the workflow
791
- const { engine } = useWorkflow();
792
- const lists = engine.getLists().filter((l) => !engine.isTerminalStatus(l.id) && l.id !== 'icebox');
793
- const statusCounts = new Map<string, number>();
794
- for (const scope of scopes) {
795
- statusCounts.set(scope.status, (statusCounts.get(scope.status) ?? 0) + 1);
796
- }
797
-
798
- const chartData = lists
799
- .filter((l) => statusCounts.has(l.id))
800
- .map((l) => ({
801
- name: l.label,
802
- count: statusCounts.get(l.id) ?? 0,
803
- color: l.hex,
804
- }));
805
-
806
- if (chartData.length === 0) return null;
807
-
808
- return (
809
- <Card className="mb-4">
810
- <CardHeader className="pb-1">
811
- <CardTitle className="text-sm">Scope Distribution</CardTitle>
812
- </CardHeader>
813
- <CardContent>
814
- <ResponsiveContainer width="100%" height={100}>
815
- <BarChart data={chartData} margin={{ left: 0, right: 10, top: 5, bottom: 0 }}>
816
- <XAxis dataKey="name" tick={{ fontSize: 10, fill: 'hsl(var(--muted-foreground))' }} />
817
- <YAxis allowDecimals={false} tick={{ fontSize: 9, fill: 'hsl(var(--muted-foreground))' }} width={20} />
818
- <RechartsTooltip
819
- contentStyle={{
820
- background: 'hsl(var(--card))', border: '1px solid hsl(var(--border))',
821
- borderRadius: '6px', fontSize: '11px',
822
- }}
823
- />
824
- <Bar dataKey="count" radius={[4, 4, 0, 0]}>
825
- {chartData.map((d, idx) => <Cell key={idx} fill={d.color} fillOpacity={0.7} />)}
826
- </Bar>
827
- </BarChart>
828
- </ResponsiveContainer>
829
- </CardContent>
830
- </Card>
831
- );
832
- }
833
-
834
- // ─── Chart: Hook Category Donut ─────────────────────────────
835
-
836
- const CATEGORY_DONUT_COLORS: Record<string, string> = {
837
- guards: '#EF4444',
838
- gates: '#F59E0B',
839
- lifecycle: '#3B82F6',
840
- observers: '#71717A',
841
- };
842
-
843
- function HookCategoryDonut({ summary }: { summary: { guards: number; gates: number; lifecycle: number; observers: number } }) {
844
- const data = [
845
- { name: 'Guards', value: summary.guards },
846
- { name: 'Gates', value: summary.gates },
847
- { name: 'Lifecycle', value: summary.lifecycle },
848
- { name: 'Observers', value: summary.observers },
849
- ].filter((d) => d.value > 0);
850
-
851
- const colors = [
852
- CATEGORY_DONUT_COLORS.guards,
853
- CATEGORY_DONUT_COLORS.gates,
854
- CATEGORY_DONUT_COLORS.lifecycle,
855
- CATEGORY_DONUT_COLORS.observers,
856
- ];
857
-
858
- const total = data.reduce((sum, d) => sum + d.value, 0);
859
-
860
- return (
861
- <div className="relative">
862
- <ResponsiveContainer width={120} height={120}>
863
- <PieChart>
864
- <Pie
865
- data={data}
866
- cx="50%"
867
- cy="50%"
868
- innerRadius={32}
869
- outerRadius={50}
870
- paddingAngle={3}
871
- dataKey="value"
872
- stroke="none"
873
- >
874
- {data.map((_, idx) => <Cell key={idx} fill={colors[idx]} fillOpacity={0.8} />)}
875
- </Pie>
876
- <RechartsTooltip
877
- contentStyle={{
878
- background: 'hsl(var(--card))', border: '1px solid hsl(var(--border))',
879
- borderRadius: '6px', fontSize: '11px',
880
- }}
881
- />
882
- </PieChart>
883
- </ResponsiveContainer>
884
- <div className="absolute inset-0 flex items-center justify-center pointer-events-none">
885
- <span className="text-lg font-light text-foreground">{total}</span>
886
- </div>
887
- </div>
888
- );
889
- }
890
-
891
- // ─── Empty overlay for charts ───────────────────────────────
892
-
893
- function ChartEmpty({ height, message }: { height: number; message: string }) {
894
- return (
895
- <div className="relative">
896
- <div style={{ height }} className="opacity-30">
897
- <ResponsiveContainer width="100%" height={height}>
898
- <BarChart data={[{ name: '', value: 0 }]} layout="vertical" margin={{ left: 10, right: 20, top: 0, bottom: 0 }}>
899
- <CartesianGrid strokeDasharray="3 3" stroke="hsl(var(--border))" opacity={0.4} />
900
- <XAxis type="number" domain={[0, 10]} tick={{ fontSize: 9, fill: 'hsl(var(--muted-foreground))' }} />
901
- <YAxis dataKey="name" type="category" width={80} tick={{ fontSize: 9, fill: 'hsl(var(--muted-foreground))' }} />
902
- </BarChart>
903
- </ResponsiveContainer>
904
- </div>
905
- <div className="absolute inset-0 flex items-center justify-center">
906
- <span className="text-xs text-muted-foreground">{message}</span>
907
- </div>
908
- </div>
909
- );
910
- }
911
-
912
- // ─── Chart: Violations vs Overrides ─────────────────────────
913
-
914
- function ViolationsVsOverridesChart({
915
- byRule,
916
- overrides,
917
- }: {
918
- byRule: Array<{ rule: string; count: number }>;
919
- overrides: Array<{ rule: string }>;
920
- }) {
921
- const overrideCountByRule = new Map<string, number>();
922
- for (const o of overrides) {
923
- const rule = o.rule ?? 'unknown';
924
- overrideCountByRule.set(rule, (overrideCountByRule.get(rule) ?? 0) + 1);
925
- }
926
-
927
- const chartData = byRule.map((r) => ({
928
- name: String(r.rule ?? 'unknown').slice(0, 22),
929
- violations: r.count,
930
- overrides: overrideCountByRule.get(String(r.rule)) ?? 0,
931
- }));
932
-
933
- const empty = chartData.length === 0;
934
-
935
- return (
936
- <Card>
937
- <CardHeader className="pb-2"><CardTitle className="text-sm">Violations vs Overrides by Rule</CardTitle></CardHeader>
938
- <CardContent>
939
- {empty ? (
940
- <ChartEmpty height={120} message="No violation data yet" />
941
- ) : (
942
- <ResponsiveContainer width="100%" height={Math.max(140, chartData.length * 30)}>
943
- <BarChart data={chartData} layout="vertical" margin={{ left: 10, right: 20, top: 0, bottom: 0 }}>
944
- <XAxis type="number" hide />
945
- <YAxis dataKey="name" type="category" width={150}
946
- tick={{ fontSize: 10, fill: 'hsl(var(--muted-foreground))' }} />
947
- <RechartsTooltip contentStyle={{
948
- background: 'hsl(var(--card))', border: '1px solid hsl(var(--border))',
949
- borderRadius: '6px', fontSize: '11px',
950
- }} />
951
- <Legend verticalAlign="top" height={24} iconSize={8}
952
- wrapperStyle={{ fontSize: '10px', color: 'hsl(var(--muted-foreground))' }} />
953
- <Bar dataKey="violations" stackId="a" fill="#EF4444" fillOpacity={0.8} radius={[0, 0, 0, 0]} />
954
- <Bar dataKey="overrides" stackId="a" fill="#F59E0B" fillOpacity={0.8} radius={[0, 4, 4, 0]} />
955
- </BarChart>
956
- </ResponsiveContainer>
957
- )}
958
- </CardContent>
959
- </Card>
960
- );
961
- }
962
-
963
- // ─── Chart: Violation Trend ─────────────────────────────────
964
-
965
- function ViolationTrendChart({ trend }: { trend: ViolationTrendPoint[] }) {
966
- const dailyTotals = new Map<string, number>();
967
- for (const point of trend) {
968
- dailyTotals.set(point.day, (dailyTotals.get(point.day) ?? 0) + point.count);
969
- }
970
- const chartData = [...dailyTotals.entries()]
971
- .map(([day, count]) => ({ day: day.slice(5), count }))
972
- .slice(-30);
973
-
974
- const empty = chartData.length < 2;
975
-
976
- return (
977
- <Card>
978
- <CardHeader className="pb-2"><CardTitle className="text-sm">Violation Trend (30d)</CardTitle></CardHeader>
979
- <CardContent>
980
- {empty ? (
981
- <div className="relative">
982
- <div style={{ height: 120 }} className="opacity-30">
983
- <ResponsiveContainer width="100%" height={120}>
984
- <AreaChart data={[{ day: '', count: 0 }]} margin={{ left: 0, right: 10, top: 5, bottom: 0 }}>
985
- <CartesianGrid strokeDasharray="3 3" stroke="hsl(var(--border))" opacity={0.4} />
986
- <XAxis dataKey="day" tick={{ fontSize: 9, fill: 'hsl(var(--muted-foreground))' }} />
987
- <YAxis domain={[0, 10]} tick={{ fontSize: 9, fill: 'hsl(var(--muted-foreground))' }} width={30} />
988
- </AreaChart>
989
- </ResponsiveContainer>
990
- </div>
991
- <div className="absolute inset-0 flex items-center justify-center">
992
- <span className="text-xs text-muted-foreground">No trend data yet</span>
993
- </div>
994
- </div>
995
- ) : (
996
- <ResponsiveContainer width="100%" height={140}>
997
- <AreaChart data={chartData} margin={{ left: 0, right: 10, top: 5, bottom: 0 }}>
998
- <CartesianGrid strokeDasharray="3 3" stroke="hsl(var(--border))" opacity={0.3} />
999
- <XAxis dataKey="day" tick={{ fontSize: 9, fill: 'hsl(var(--muted-foreground))' }} />
1000
- <YAxis tick={{ fontSize: 9, fill: 'hsl(var(--muted-foreground))' }} width={30} />
1001
- <RechartsTooltip contentStyle={{
1002
- background: 'hsl(var(--card))', border: '1px solid hsl(var(--border))',
1003
- borderRadius: '6px', fontSize: '11px',
1004
- }} />
1005
- <Area type="monotone" dataKey="count" stroke="#EF4444" fill="#EF444420" strokeWidth={1.5} />
1006
- </AreaChart>
1007
- </ResponsiveContainer>
1008
- )}
1009
- </CardContent>
1010
- </Card>
1011
- );
1012
- }