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.
- package/README.md +67 -42
- package/bin/commands/config.js +19 -0
- package/bin/commands/events.js +40 -0
- package/bin/commands/launch.js +126 -0
- package/bin/commands/manifest.js +283 -0
- package/bin/commands/registry.js +104 -0
- package/bin/commands/update.js +24 -0
- package/bin/lib/helpers.js +229 -0
- package/bin/orbital.js +147 -319
- package/dist/assets/Landing-CfQdHR0N.js +11 -0
- package/dist/assets/PrimitivesConfig-DThSipFy.js +32 -0
- package/dist/assets/QualityGates-B4kxM5UU.js +26 -0
- package/dist/assets/SessionTimeline-Bz1iZnmg.js +1 -0
- package/dist/assets/Settings-DLcZwbCT.js +12 -0
- package/dist/assets/SourceControl-BMNIz7Lt.js +36 -0
- package/dist/assets/WorkflowVisualizer-CxuSBOYu.js +69 -0
- package/dist/assets/arrow-down-DVPp6_qp.js +6 -0
- package/dist/assets/bot-NFaJBDn_.js +6 -0
- package/dist/assets/charts-LGLb8hyU.js +68 -0
- package/dist/assets/circle-x-IsFCkBZu.js +6 -0
- package/dist/assets/file-text-J1cebZXF.js +6 -0
- package/dist/assets/globe-WzeyHsUc.js +6 -0
- package/dist/assets/index-BdJ57EhC.css +1 -0
- package/dist/assets/index-o4ScMAuR.js +349 -0
- package/dist/assets/key-CKR8JJSj.js +6 -0
- package/dist/assets/minus-CHBsJyjp.js +6 -0
- package/dist/assets/radio-xqZaR-Uk.js +6 -0
- package/dist/assets/rocket-D_xvvNG6.js +6 -0
- package/dist/assets/shield-TdB1yv_a.js +6 -0
- package/dist/assets/ui-BmsSg9jU.js +53 -0
- package/dist/assets/useSocketListener-0L5yiN5i.js +1 -0
- package/dist/assets/useWorkflowEditor-CqeRWVQX.js +11 -0
- package/dist/assets/{vendor-Dzv9lrRc.js → vendor-Bqt8AJn2.js} +1 -1
- package/dist/assets/workflow-constants-Rw-GmgHZ.js +6 -0
- package/dist/assets/zap-C9wqYMpl.js +6 -0
- package/dist/favicon.svg +1 -0
- package/dist/index.html +6 -5
- package/dist/server/server/__tests__/data-routes.test.js +126 -0
- package/dist/server/server/__tests__/helpers/db.js +17 -0
- package/dist/server/server/__tests__/helpers/mock-emitter.js +8 -0
- package/dist/server/server/__tests__/scope-routes.test.js +138 -0
- package/dist/server/server/__tests__/sprint-routes.test.js +102 -0
- package/dist/server/server/__tests__/workflow-routes.test.js +107 -0
- package/dist/server/server/config-migrator.js +135 -0
- package/dist/server/server/config.js +51 -7
- package/dist/server/server/database.js +21 -28
- package/dist/server/server/global-config.js +143 -0
- package/dist/server/server/index.js +118 -276
- package/dist/server/server/init.js +243 -225
- package/dist/server/server/launch.js +29 -0
- package/dist/server/server/manifest-types.js +8 -0
- package/dist/server/server/manifest.js +454 -0
- package/dist/server/server/migrate-legacy.js +229 -0
- package/dist/server/server/parsers/event-parser.js +4 -1
- package/dist/server/server/parsers/event-parser.test.js +117 -0
- package/dist/server/server/parsers/scope-parser.js +74 -28
- package/dist/server/server/parsers/scope-parser.test.js +230 -0
- package/dist/server/server/project-context.js +265 -0
- package/dist/server/server/project-emitter.js +41 -0
- package/dist/server/server/project-manager.js +297 -0
- package/dist/server/server/routes/aggregate-routes.js +871 -0
- package/dist/server/server/routes/config-routes.js +41 -90
- package/dist/server/server/routes/data-routes.js +25 -123
- package/dist/server/server/routes/dispatch-routes.js +37 -15
- package/dist/server/server/routes/git-routes.js +74 -0
- package/dist/server/server/routes/manifest-routes.js +319 -0
- package/dist/server/server/routes/scope-routes.js +45 -28
- package/dist/server/server/routes/sync-routes.js +134 -0
- package/dist/server/server/routes/version-routes.js +1 -15
- package/dist/server/server/routes/workflow-routes.js +9 -3
- package/dist/server/server/schema.js +3 -0
- package/dist/server/server/services/batch-orchestrator.js +41 -17
- package/dist/server/server/services/claude-session-service.js +17 -14
- package/dist/server/server/services/config-service.js +10 -1
- package/dist/server/server/services/deploy-service.test.js +119 -0
- package/dist/server/server/services/event-service.js +64 -1
- package/dist/server/server/services/event-service.test.js +191 -0
- package/dist/server/server/services/gate-service.test.js +105 -0
- package/dist/server/server/services/git-service.js +108 -4
- package/dist/server/server/services/github-service.js +110 -2
- package/dist/server/server/services/readiness-service.test.js +190 -0
- package/dist/server/server/services/scope-cache.js +5 -1
- package/dist/server/server/services/scope-cache.test.js +142 -0
- package/dist/server/server/services/scope-service.js +222 -131
- package/dist/server/server/services/scope-service.test.js +137 -0
- package/dist/server/server/services/sprint-orchestrator.js +29 -15
- package/dist/server/server/services/sprint-service.js +23 -3
- package/dist/server/server/services/sprint-service.test.js +238 -0
- package/dist/server/server/services/sync-service.js +434 -0
- package/dist/server/server/services/sync-types.js +2 -0
- package/dist/server/server/services/workflow-service.js +26 -5
- package/dist/server/server/services/workflow-service.test.js +159 -0
- package/dist/server/server/settings-sync.js +284 -0
- package/dist/server/server/uninstall.js +195 -0
- package/dist/server/server/update-planner.js +279 -0
- package/dist/server/server/update.js +212 -0
- package/dist/server/server/utils/cc-hooks-parser.js +3 -0
- package/dist/server/server/utils/cc-hooks-parser.test.js +86 -0
- package/dist/server/server/utils/dispatch-utils.js +83 -24
- package/dist/server/server/utils/dispatch-utils.test.js +182 -0
- package/dist/server/server/utils/flag-builder.js +54 -0
- package/dist/server/server/utils/json-fields.js +14 -0
- package/dist/server/server/utils/json-fields.test.js +73 -0
- package/dist/server/server/utils/logger.js +37 -3
- package/dist/server/server/utils/package-info.js +30 -0
- package/dist/server/server/utils/route-helpers.js +47 -0
- package/dist/server/server/utils/route-helpers.test.js +115 -0
- package/dist/server/server/utils/terminal-launcher.js +79 -25
- package/dist/server/server/utils/worktree-manager.js +13 -4
- package/dist/server/server/validator.js +230 -0
- package/dist/server/server/watchers/event-watcher.js +28 -13
- package/dist/server/server/watchers/global-watcher.js +63 -0
- package/dist/server/server/watchers/scope-watcher.js +27 -12
- package/dist/server/server/wizard/config-editor.js +237 -0
- package/dist/server/server/wizard/detect.js +96 -0
- package/dist/server/server/wizard/doctor.js +115 -0
- package/dist/server/server/wizard/index.js +340 -0
- package/dist/server/server/wizard/phases/confirm.js +39 -0
- package/dist/server/server/wizard/phases/project-setup.js +90 -0
- package/dist/server/server/wizard/phases/setup-wizard.js +66 -0
- package/dist/server/server/wizard/phases/welcome.js +32 -0
- package/dist/server/server/wizard/phases/workflow-setup.js +22 -0
- package/dist/server/server/wizard/types.js +29 -0
- package/dist/server/server/wizard/ui.js +73 -0
- package/dist/server/shared/__fixtures__/workflow-configs.js +75 -0
- package/dist/server/shared/api-types.js +80 -1
- package/dist/server/shared/default-workflow.json +65 -0
- package/dist/server/shared/onboarding-tour.test.js +81 -0
- package/dist/server/shared/project-colors.js +24 -0
- package/dist/server/shared/workflow-config.test.js +84 -0
- package/dist/server/shared/workflow-engine.js +1 -1
- package/dist/server/shared/workflow-engine.test.js +302 -0
- package/dist/server/shared/workflow-normalizer.js +101 -0
- package/dist/server/shared/workflow-normalizer.test.js +100 -0
- package/dist/server/src/components/onboarding/tour-steps.js +84 -0
- package/package.json +34 -29
- package/schemas/orbital.config.schema.json +2 -5
- package/scripts/postinstall.js +18 -6
- package/scripts/release.sh +53 -0
- package/server/__tests__/data-routes.test.ts +151 -0
- package/server/__tests__/helpers/db.ts +19 -0
- package/server/__tests__/helpers/mock-emitter.ts +10 -0
- package/server/__tests__/scope-routes.test.ts +158 -0
- package/server/__tests__/sprint-routes.test.ts +118 -0
- package/server/__tests__/workflow-routes.test.ts +120 -0
- package/server/config-migrator.ts +160 -0
- package/server/config.ts +64 -12
- package/server/database.ts +22 -31
- package/server/global-config.ts +204 -0
- package/server/index.ts +139 -316
- package/server/init.ts +266 -234
- package/server/launch.ts +32 -0
- package/server/manifest-types.ts +145 -0
- package/server/manifest.ts +494 -0
- package/server/migrate-legacy.ts +290 -0
- package/server/parsers/event-parser.test.ts +135 -0
- package/server/parsers/event-parser.ts +4 -1
- package/server/parsers/scope-parser.test.ts +270 -0
- package/server/parsers/scope-parser.ts +79 -31
- package/server/project-context.ts +325 -0
- package/server/project-emitter.ts +50 -0
- package/server/project-manager.ts +368 -0
- package/server/routes/aggregate-routes.ts +968 -0
- package/server/routes/config-routes.ts +43 -85
- package/server/routes/data-routes.ts +34 -156
- package/server/routes/dispatch-routes.ts +46 -17
- package/server/routes/git-routes.ts +77 -0
- package/server/routes/manifest-routes.ts +388 -0
- package/server/routes/scope-routes.ts +39 -30
- package/server/routes/sync-routes.ts +175 -0
- package/server/routes/version-routes.ts +1 -16
- package/server/routes/workflow-routes.ts +9 -3
- package/server/schema.ts +3 -0
- package/server/services/batch-orchestrator.ts +41 -17
- package/server/services/claude-session-service.ts +16 -14
- package/server/services/config-service.ts +10 -1
- package/server/services/deploy-service.test.ts +145 -0
- package/server/services/deploy-service.ts +2 -2
- package/server/services/event-service.test.ts +242 -0
- package/server/services/event-service.ts +92 -3
- package/server/services/gate-service.test.ts +131 -0
- package/server/services/gate-service.ts +2 -2
- package/server/services/git-service.ts +137 -4
- package/server/services/github-service.ts +120 -2
- package/server/services/readiness-service.test.ts +217 -0
- package/server/services/scope-cache.test.ts +167 -0
- package/server/services/scope-cache.ts +4 -1
- package/server/services/scope-service.test.ts +169 -0
- package/server/services/scope-service.ts +224 -130
- package/server/services/sprint-orchestrator.ts +30 -15
- package/server/services/sprint-service.test.ts +271 -0
- package/server/services/sprint-service.ts +29 -5
- package/server/services/sync-service.ts +482 -0
- package/server/services/sync-types.ts +77 -0
- package/server/services/workflow-service.test.ts +190 -0
- package/server/services/workflow-service.ts +29 -9
- package/server/settings-sync.ts +359 -0
- package/server/uninstall.ts +214 -0
- package/server/update-planner.ts +346 -0
- package/server/update.ts +263 -0
- package/server/utils/cc-hooks-parser.test.ts +96 -0
- package/server/utils/cc-hooks-parser.ts +4 -0
- package/server/utils/dispatch-utils.test.ts +245 -0
- package/server/utils/dispatch-utils.ts +102 -30
- package/server/utils/flag-builder.ts +56 -0
- package/server/utils/json-fields.test.ts +83 -0
- package/server/utils/json-fields.ts +14 -0
- package/server/utils/logger.ts +40 -3
- package/server/utils/package-info.ts +32 -0
- package/server/utils/route-helpers.test.ts +144 -0
- package/server/utils/route-helpers.ts +50 -0
- package/server/utils/terminal-launcher.ts +85 -25
- package/server/utils/worktree-manager.ts +9 -4
- package/server/validator.ts +270 -0
- package/server/watchers/event-watcher.ts +24 -12
- package/server/watchers/global-watcher.ts +77 -0
- package/server/watchers/scope-watcher.ts +21 -9
- package/server/wizard/config-editor.ts +248 -0
- package/server/wizard/detect.ts +104 -0
- package/server/wizard/doctor.ts +114 -0
- package/server/wizard/index.ts +438 -0
- package/server/wizard/phases/confirm.ts +45 -0
- package/server/wizard/phases/project-setup.ts +106 -0
- package/server/wizard/phases/setup-wizard.ts +78 -0
- package/server/wizard/phases/welcome.ts +39 -0
- package/server/wizard/phases/workflow-setup.ts +28 -0
- package/server/wizard/types.ts +56 -0
- package/server/wizard/ui.ts +92 -0
- package/shared/__fixtures__/workflow-configs.ts +80 -0
- package/shared/api-types.ts +106 -0
- package/shared/onboarding-tour.test.ts +94 -0
- package/shared/project-colors.ts +24 -0
- package/shared/workflow-config.test.ts +111 -0
- package/shared/workflow-config.ts +7 -0
- package/shared/workflow-engine.test.ts +388 -0
- package/shared/workflow-engine.ts +1 -1
- package/shared/workflow-normalizer.test.ts +119 -0
- package/shared/workflow-normalizer.ts +118 -0
- package/templates/agents/QUICK-REFERENCE.md +1 -0
- package/templates/agents/README.md +1 -0
- package/templates/agents/SKILL-TRIGGERS.md +11 -0
- package/templates/agents/green-team/deep-dive.md +361 -0
- package/templates/hooks/end-session.sh +4 -1
- package/templates/hooks/init-session.sh +1 -0
- package/templates/hooks/orbital-emit.sh +2 -2
- package/templates/hooks/orbital-report-deploy.sh +4 -4
- package/templates/hooks/orbital-report-gates.sh +4 -4
- package/templates/hooks/orbital-scope-update.sh +1 -1
- package/templates/hooks/scope-commit-logger.sh +2 -2
- package/templates/hooks/scope-create-cleanup.sh +2 -2
- package/templates/hooks/scope-create-gate.sh +2 -5
- package/templates/hooks/scope-gate.sh +4 -6
- package/templates/hooks/scope-helpers.sh +28 -1
- package/templates/hooks/scope-lifecycle-gate.sh +14 -5
- package/templates/hooks/scope-prepare.sh +67 -12
- package/templates/hooks/scope-transition.sh +14 -6
- package/templates/hooks/time-tracker.sh +2 -5
- package/templates/migrations/renames.json +1 -0
- package/templates/orbital.config.json +8 -6
- package/{shared/default-workflow.json → templates/presets/default.json} +65 -0
- package/templates/presets/development.json +4 -4
- package/templates/presets/gitflow.json +7 -0
- package/templates/prompts/README.md +23 -0
- package/templates/prompts/deep-dive-audit.md +94 -0
- package/templates/quick/rules.md +56 -5
- package/templates/settings-hooks.json +1 -1
- package/templates/skills/git-commit/SKILL.md +27 -7
- package/templates/skills/git-dev/SKILL.md +13 -4
- package/templates/skills/git-main/SKILL.md +13 -3
- package/templates/skills/git-production/SKILL.md +9 -2
- package/templates/skills/git-staging/SKILL.md +11 -3
- package/templates/skills/scope-create/SKILL.md +17 -3
- package/templates/skills/scope-fix-review/SKILL.md +14 -7
- package/templates/skills/scope-implement/SKILL.md +15 -4
- package/templates/skills/scope-post-review/SKILL.md +77 -7
- package/templates/skills/scope-pre-review/SKILL.md +11 -4
- package/templates/skills/scope-verify/SKILL.md +5 -3
- package/templates/skills/test-code-review/SKILL.md +41 -33
- package/templates/skills/test-scaffold/SKILL.md +222 -0
- package/dist/assets/WorkflowVisualizer-BZ21PIIF.js +0 -84
- package/dist/assets/charts-D__PA1zp.js +0 -72
- package/dist/assets/index-D1G6i0nS.css +0 -1
- package/dist/assets/index-DpItvKpf.js +0 -419
- package/dist/assets/ui-BvF022GT.js +0 -53
- package/index.html +0 -15
- package/postcss.config.js +0 -6
- package/src/App.tsx +0 -33
- package/src/components/AgentBadge.tsx +0 -40
- package/src/components/BatchPreflightModal.tsx +0 -115
- package/src/components/CardDisplayToggle.tsx +0 -74
- package/src/components/ColumnHeaderActions.tsx +0 -55
- package/src/components/ColumnMenu.tsx +0 -99
- package/src/components/DeployHistory.tsx +0 -141
- package/src/components/DispatchModal.tsx +0 -164
- package/src/components/DispatchPopover.tsx +0 -139
- package/src/components/DragOverlay.tsx +0 -25
- package/src/components/DriftSidebar.tsx +0 -140
- package/src/components/EnvironmentStrip.tsx +0 -88
- package/src/components/ErrorBoundary.tsx +0 -62
- package/src/components/FilterChip.tsx +0 -105
- package/src/components/GateIndicator.tsx +0 -33
- package/src/components/IdeaDetailModal.tsx +0 -190
- package/src/components/IdeaFormDialog.tsx +0 -113
- package/src/components/KanbanColumn.tsx +0 -201
- package/src/components/MarkdownRenderer.tsx +0 -114
- package/src/components/NeonGrid.tsx +0 -128
- package/src/components/PromotionQueue.tsx +0 -89
- package/src/components/ScopeCard.tsx +0 -234
- package/src/components/ScopeDetailModal.tsx +0 -255
- package/src/components/ScopeFilterBar.tsx +0 -152
- package/src/components/SearchInput.tsx +0 -102
- package/src/components/SessionPanel.tsx +0 -335
- package/src/components/SprintContainer.tsx +0 -303
- package/src/components/SprintDependencyDialog.tsx +0 -78
- package/src/components/SprintPreflightModal.tsx +0 -138
- package/src/components/StatusBar.tsx +0 -168
- package/src/components/SwimCell.tsx +0 -67
- package/src/components/SwimLaneRow.tsx +0 -94
- package/src/components/SwimlaneBoardView.tsx +0 -108
- package/src/components/VersionBadge.tsx +0 -139
- package/src/components/ViewModeSelector.tsx +0 -114
- package/src/components/config/AgentChip.tsx +0 -53
- package/src/components/config/AgentCreateDialog.tsx +0 -321
- package/src/components/config/AgentEditor.tsx +0 -175
- package/src/components/config/DirectoryTree.tsx +0 -582
- package/src/components/config/FileEditor.tsx +0 -550
- package/src/components/config/HookChip.tsx +0 -50
- package/src/components/config/StageCard.tsx +0 -198
- package/src/components/config/TransitionZone.tsx +0 -173
- package/src/components/config/UnifiedWorkflowPipeline.tsx +0 -216
- package/src/components/config/WorkflowPipeline.tsx +0 -161
- package/src/components/source-control/BranchList.tsx +0 -93
- package/src/components/source-control/BranchPanel.tsx +0 -105
- package/src/components/source-control/CommitLog.tsx +0 -100
- package/src/components/source-control/CommitRow.tsx +0 -47
- package/src/components/source-control/GitHubPanel.tsx +0 -110
- package/src/components/source-control/GitHubSetupGuide.tsx +0 -52
- package/src/components/source-control/GitOverviewBar.tsx +0 -101
- package/src/components/source-control/PullRequestList.tsx +0 -69
- package/src/components/source-control/WorktreeList.tsx +0 -80
- package/src/components/ui/badge.tsx +0 -41
- package/src/components/ui/button.tsx +0 -55
- package/src/components/ui/card.tsx +0 -78
- package/src/components/ui/dialog.tsx +0 -94
- package/src/components/ui/popover.tsx +0 -33
- package/src/components/ui/scroll-area.tsx +0 -54
- package/src/components/ui/separator.tsx +0 -28
- package/src/components/ui/tabs.tsx +0 -52
- package/src/components/ui/toggle-switch.tsx +0 -35
- package/src/components/ui/tooltip.tsx +0 -27
- package/src/components/workflow/AddEdgeDialog.tsx +0 -217
- package/src/components/workflow/AddListDialog.tsx +0 -201
- package/src/components/workflow/ChecklistEditor.tsx +0 -239
- package/src/components/workflow/CommandPrefixManager.tsx +0 -118
- package/src/components/workflow/ConfigSettingsPanel.tsx +0 -189
- package/src/components/workflow/DirectionSelector.tsx +0 -133
- package/src/components/workflow/DispatchConfigPanel.tsx +0 -180
- package/src/components/workflow/EdgeDetailPanel.tsx +0 -236
- package/src/components/workflow/EdgePropertyEditor.tsx +0 -251
- package/src/components/workflow/EditToolbar.tsx +0 -138
- package/src/components/workflow/HookDetailPanel.tsx +0 -250
- package/src/components/workflow/HookExecutionLog.tsx +0 -24
- package/src/components/workflow/HookSourceModal.tsx +0 -129
- package/src/components/workflow/HooksDashboard.tsx +0 -363
- package/src/components/workflow/ListPropertyEditor.tsx +0 -251
- package/src/components/workflow/MigrationPreviewDialog.tsx +0 -237
- package/src/components/workflow/MovementRulesPanel.tsx +0 -188
- package/src/components/workflow/NodeDetailPanel.tsx +0 -245
- package/src/components/workflow/PresetSelector.tsx +0 -414
- package/src/components/workflow/SkillCommandBuilder.tsx +0 -174
- package/src/components/workflow/WorkflowEdgeComponent.tsx +0 -145
- package/src/components/workflow/WorkflowNode.tsx +0 -147
- package/src/components/workflow/graphLayout.ts +0 -186
- package/src/components/workflow/mergeHooks.ts +0 -85
- package/src/components/workflow/useEditHistory.ts +0 -88
- package/src/components/workflow/useWorkflowEditor.ts +0 -262
- package/src/components/workflow/validateConfig.ts +0 -70
- package/src/hooks/useActiveDispatches.ts +0 -198
- package/src/hooks/useBoardSettings.ts +0 -170
- package/src/hooks/useCardDisplay.ts +0 -57
- package/src/hooks/useCcHooks.ts +0 -24
- package/src/hooks/useConfigTree.ts +0 -51
- package/src/hooks/useEnforcementRules.ts +0 -46
- package/src/hooks/useEvents.ts +0 -59
- package/src/hooks/useFileEditor.ts +0 -165
- package/src/hooks/useGates.ts +0 -57
- package/src/hooks/useIdeaActions.ts +0 -53
- package/src/hooks/useKanbanDnd.ts +0 -410
- package/src/hooks/useOrbitalConfig.ts +0 -54
- package/src/hooks/usePipeline.ts +0 -47
- package/src/hooks/usePipelineData.ts +0 -338
- package/src/hooks/useReconnect.ts +0 -25
- package/src/hooks/useScopeFilters.ts +0 -125
- package/src/hooks/useScopeSessions.ts +0 -44
- package/src/hooks/useScopes.ts +0 -67
- package/src/hooks/useSearch.ts +0 -67
- package/src/hooks/useSettings.tsx +0 -187
- package/src/hooks/useSocket.ts +0 -25
- package/src/hooks/useSourceControl.ts +0 -105
- package/src/hooks/useSprintPreflight.ts +0 -55
- package/src/hooks/useSprints.ts +0 -154
- package/src/hooks/useStatusBarHighlight.ts +0 -18
- package/src/hooks/useSwimlaneBoardSettings.ts +0 -104
- package/src/hooks/useTheme.ts +0 -9
- package/src/hooks/useTransitionReadiness.ts +0 -53
- package/src/hooks/useVersion.ts +0 -155
- package/src/hooks/useViolations.ts +0 -65
- package/src/hooks/useWorkflow.tsx +0 -125
- package/src/hooks/useZoomModifier.ts +0 -19
- package/src/index.css +0 -797
- package/src/layouts/DashboardLayout.tsx +0 -113
- package/src/lib/collisionDetection.ts +0 -20
- package/src/lib/scope-fields.ts +0 -61
- package/src/lib/swimlane.ts +0 -146
- package/src/lib/utils.ts +0 -15
- package/src/main.tsx +0 -19
- package/src/socket.ts +0 -11
- package/src/types/index.ts +0 -497
- package/src/views/AgentFeed.tsx +0 -339
- package/src/views/DeployPipeline.tsx +0 -59
- package/src/views/EnforcementView.tsx +0 -378
- package/src/views/PrimitivesConfig.tsx +0 -500
- package/src/views/QualityGates.tsx +0 -1012
- package/src/views/ScopeBoard.tsx +0 -454
- package/src/views/SessionTimeline.tsx +0 -516
- package/src/views/Settings.tsx +0 -183
- package/src/views/SourceControl.tsx +0 -95
- package/src/views/WorkflowVisualizer.tsx +0 -382
- package/tailwind.config.js +0 -161
- package/tsconfig.json +0 -25
- package/vite.config.ts +0 -38
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import type { SyncService } from '../services/sync-service.js';
|
|
3
|
+
import type { ProjectManager } from '../project-manager.js';
|
|
4
|
+
import { isValidRelativePath } from '../utils/route-helpers.js';
|
|
5
|
+
|
|
6
|
+
interface SyncRouteDeps {
|
|
7
|
+
syncService: SyncService;
|
|
8
|
+
projectManager: ProjectManager;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function createSyncRoutes({ syncService, projectManager }: SyncRouteDeps): Router {
|
|
12
|
+
const router = Router();
|
|
13
|
+
|
|
14
|
+
// ─── Sync State ─────────────────────────────────────────
|
|
15
|
+
|
|
16
|
+
/** GET /sync/state/:projectId — sync state for a specific project */
|
|
17
|
+
router.get('/sync/state/:projectId', (req, res) => {
|
|
18
|
+
const ctx = projectManager.getContext(req.params.projectId);
|
|
19
|
+
if (!ctx) return res.status(404).json({ error: 'Project not found' });
|
|
20
|
+
|
|
21
|
+
const report = syncService.computeSyncState(ctx.id, ctx.config.projectRoot);
|
|
22
|
+
res.json(report);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
/** GET /sync/global-state — matrix view across all projects */
|
|
26
|
+
router.get('/sync/global-state', (_req, res) => {
|
|
27
|
+
const report = syncService.computeGlobalSyncState();
|
|
28
|
+
res.json(report);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// ─── Override Operations ────────────────────────────────
|
|
32
|
+
|
|
33
|
+
/** POST /sync/override — create an override for a file in a project */
|
|
34
|
+
router.post('/sync/override', (req, res) => {
|
|
35
|
+
const { projectId, relativePath, reason } = req.body as {
|
|
36
|
+
projectId: string; relativePath: string; reason?: string;
|
|
37
|
+
};
|
|
38
|
+
if (!projectId || !relativePath) {
|
|
39
|
+
return res.status(400).json({ error: 'projectId and relativePath required' });
|
|
40
|
+
}
|
|
41
|
+
if (!isValidRelativePath(relativePath)) {
|
|
42
|
+
return res.status(400).json({ error: 'Invalid relativePath' });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const ctx = projectManager.getContext(projectId);
|
|
46
|
+
if (!ctx) return res.status(404).json({ error: 'Project not found' });
|
|
47
|
+
|
|
48
|
+
syncService.createOverride(ctx.config.projectRoot, relativePath, reason);
|
|
49
|
+
res.json({ success: true });
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
/** POST /sync/revert — revert an override back to global */
|
|
53
|
+
router.post('/sync/revert', (req, res) => {
|
|
54
|
+
const { projectId, relativePath } = req.body as {
|
|
55
|
+
projectId: string; relativePath: string;
|
|
56
|
+
};
|
|
57
|
+
if (!projectId || !relativePath) {
|
|
58
|
+
return res.status(400).json({ error: 'projectId and relativePath required' });
|
|
59
|
+
}
|
|
60
|
+
if (!isValidRelativePath(relativePath)) {
|
|
61
|
+
return res.status(400).json({ error: 'Invalid relativePath' });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const ctx = projectManager.getContext(projectId);
|
|
65
|
+
if (!ctx) return res.status(404).json({ error: 'Project not found' });
|
|
66
|
+
|
|
67
|
+
syncService.revertOverride(ctx.config.projectRoot, relativePath);
|
|
68
|
+
res.json({ success: true });
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
/** POST /sync/promote — promote a project override to global */
|
|
72
|
+
router.post('/sync/promote', (req, res) => {
|
|
73
|
+
const { projectId, relativePath } = req.body as {
|
|
74
|
+
projectId: string; relativePath: string;
|
|
75
|
+
};
|
|
76
|
+
if (!projectId || !relativePath) {
|
|
77
|
+
return res.status(400).json({ error: 'projectId and relativePath required' });
|
|
78
|
+
}
|
|
79
|
+
if (!isValidRelativePath(relativePath)) {
|
|
80
|
+
return res.status(400).json({ error: 'Invalid relativePath' });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const ctx = projectManager.getContext(projectId);
|
|
84
|
+
if (!ctx) return res.status(404).json({ error: 'Project not found' });
|
|
85
|
+
|
|
86
|
+
const result = syncService.promoteOverride(ctx.config.projectRoot, relativePath);
|
|
87
|
+
res.json({ success: true, ...result });
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
/** POST /sync/resolve-drift — resolve a drifted file */
|
|
91
|
+
router.post('/sync/resolve-drift', (req, res) => {
|
|
92
|
+
const { projectId, relativePath, resolution } = req.body as {
|
|
93
|
+
projectId: string; relativePath: string; resolution: 'pin-override' | 'reset-global';
|
|
94
|
+
};
|
|
95
|
+
if (!projectId || !relativePath || !resolution) {
|
|
96
|
+
return res.status(400).json({ error: 'projectId, relativePath, and resolution required' });
|
|
97
|
+
}
|
|
98
|
+
if (!isValidRelativePath(relativePath)) {
|
|
99
|
+
return res.status(400).json({ error: 'Invalid relativePath' });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const ctx = projectManager.getContext(projectId);
|
|
103
|
+
if (!ctx) return res.status(404).json({ error: 'Project not found' });
|
|
104
|
+
|
|
105
|
+
syncService.resolveDrift(ctx.config.projectRoot, relativePath, resolution);
|
|
106
|
+
res.json({ success: true });
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// ─── Impact Preview ─────────────────────────────────────
|
|
110
|
+
|
|
111
|
+
/** GET /sync/impact?path=<relativePath> — preview impact of a global change */
|
|
112
|
+
router.get('/sync/impact', (req, res) => {
|
|
113
|
+
const relativePath = req.query.path as string;
|
|
114
|
+
if (!relativePath) {
|
|
115
|
+
return res.status(400).json({ error: 'path query parameter required' });
|
|
116
|
+
}
|
|
117
|
+
if (!isValidRelativePath(relativePath)) {
|
|
118
|
+
return res.status(400).json({ error: 'Invalid path' });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const preview = syncService.getImpactPreview(relativePath);
|
|
122
|
+
res.json(preview);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// ─── Project Management ─────────────────────────────────
|
|
126
|
+
|
|
127
|
+
/** GET /projects — list all registered projects */
|
|
128
|
+
router.get('/projects', (req, res) => {
|
|
129
|
+
const include = req.query.include as string | undefined;
|
|
130
|
+
res.json(projectManager.getProjectList({
|
|
131
|
+
includeWorkflow: include?.includes('workflow'),
|
|
132
|
+
}));
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
/** POST /projects — register a new project */
|
|
136
|
+
router.post('/projects', async (req, res) => {
|
|
137
|
+
const { path: projectPath, name, color } = req.body as {
|
|
138
|
+
path: string; name?: string; color?: string;
|
|
139
|
+
};
|
|
140
|
+
if (!projectPath) {
|
|
141
|
+
return res.status(400).json({ error: 'path required' });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
const summary = await projectManager.addProject(projectPath, { name, color });
|
|
146
|
+
res.status(201).json(summary);
|
|
147
|
+
} catch (err) {
|
|
148
|
+
res.status(500).json({ error: String(err) });
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
/** DELETE /projects/:id — unregister a project */
|
|
153
|
+
router.delete('/projects/:id', async (req, res) => {
|
|
154
|
+
const removed = await projectManager.removeProject(req.params.id);
|
|
155
|
+
if (!removed) return res.status(404).json({ error: 'Project not found' });
|
|
156
|
+
res.json({ success: true });
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
/** PATCH /projects/:id — update project metadata */
|
|
160
|
+
router.patch('/projects/:id', async (req, res) => {
|
|
161
|
+
const { name, color, enabled } = req.body as {
|
|
162
|
+
name?: string; color?: string; enabled?: boolean;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
if (name !== undefined && !name.trim()) {
|
|
166
|
+
return res.status(400).json({ error: 'Name cannot be empty' });
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const updated = await projectManager.updateProject(req.params.id, { name, color, enabled });
|
|
170
|
+
if (!updated) return res.status(404).json({ error: 'Project not found' });
|
|
171
|
+
res.json(updated);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
return router;
|
|
175
|
+
}
|
|
@@ -3,9 +3,9 @@ import { execFile } from 'child_process';
|
|
|
3
3
|
import { promisify } from 'util';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import fs from 'fs';
|
|
6
|
-
import { fileURLToPath } from 'url';
|
|
7
6
|
import type { Server } from 'socket.io';
|
|
8
7
|
import { createLogger } from '../utils/logger.js';
|
|
8
|
+
import { getOrbitalRoot } from '../utils/package-info.js';
|
|
9
9
|
|
|
10
10
|
const log = createLogger('version');
|
|
11
11
|
|
|
@@ -15,21 +15,6 @@ interface VersionRouteDeps {
|
|
|
15
15
|
io: Server;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
/** Resolve the root directory of the orbital-command package itself. */
|
|
19
|
-
function getOrbitalRoot(): string {
|
|
20
|
-
const __selfDir = path.dirname(fileURLToPath(import.meta.url));
|
|
21
|
-
// Walk up until we find package.json (handles both dev and compiled paths)
|
|
22
|
-
let dir = __selfDir;
|
|
23
|
-
for (let i = 0; i < 6; i++) {
|
|
24
|
-
if (fs.existsSync(path.join(dir, 'package.json'))) {
|
|
25
|
-
return dir;
|
|
26
|
-
}
|
|
27
|
-
dir = path.dirname(dir);
|
|
28
|
-
}
|
|
29
|
-
// Fallback: assume dev layout (server/routes/ → 2 levels up)
|
|
30
|
-
return path.resolve(__selfDir, '../..');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
18
|
async function git(args: string[], cwd: string, timeoutMs = 15_000): Promise<string> {
|
|
34
19
|
const { stdout } = await execFileAsync('git', args, { cwd, timeout: timeoutMs });
|
|
35
20
|
return stdout.trim();
|
|
@@ -4,6 +4,7 @@ import path from 'node:path';
|
|
|
4
4
|
import type { WorkflowConfig } from '../../shared/workflow-config.js';
|
|
5
5
|
import type { WorkflowService } from '../services/workflow-service.js';
|
|
6
6
|
import { parseCcHooks } from '../utils/cc-hooks-parser.js';
|
|
7
|
+
import { errMsg } from '../utils/route-helpers.js';
|
|
7
8
|
|
|
8
9
|
interface WorkflowRouteDeps {
|
|
9
10
|
workflowService: WorkflowService;
|
|
@@ -130,6 +131,10 @@ export function createWorkflowRoutes({ workflowService, projectRoot }: WorkflowR
|
|
|
130
131
|
return;
|
|
131
132
|
}
|
|
132
133
|
const filePath = path.resolve(projectRoot, hook.target);
|
|
134
|
+
if (!filePath.startsWith(projectRoot + path.sep) && filePath !== projectRoot) {
|
|
135
|
+
res.status(400).json({ success: false, error: 'Path outside project root' });
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
133
138
|
const content = await readFile(filePath, 'utf-8');
|
|
134
139
|
const lineCount = content.split('\n').length;
|
|
135
140
|
res.json({ success: true, data: { hookId, filePath: hook.target, content, lineCount } });
|
|
@@ -164,6 +169,10 @@ export function createWorkflowRoutes({ workflowService, projectRoot }: WorkflowR
|
|
|
164
169
|
return;
|
|
165
170
|
}
|
|
166
171
|
const filePath = path.resolve(projectRoot, hookPath);
|
|
172
|
+
if (!filePath.startsWith(projectRoot + path.sep) && filePath !== projectRoot) {
|
|
173
|
+
res.status(400).json({ success: false, error: 'Path outside project root' });
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
167
176
|
const content = await readFile(filePath, 'utf-8');
|
|
168
177
|
const lineCount = content.split('\n').length;
|
|
169
178
|
res.json({ success: true, data: { filePath: hookPath, content, lineCount } });
|
|
@@ -193,6 +202,3 @@ export function createWorkflowRoutes({ workflowService, projectRoot }: WorkflowR
|
|
|
193
202
|
return router;
|
|
194
203
|
}
|
|
195
204
|
|
|
196
|
-
function errMsg(err: unknown): string {
|
|
197
|
-
return err instanceof Error ? err.message : String(err);
|
|
198
|
-
}
|
package/server/schema.ts
CHANGED
|
@@ -81,10 +81,13 @@ CREATE TABLE IF NOT EXISTS sprint_scopes (
|
|
|
81
81
|
CREATE INDEX IF NOT EXISTS idx_events_type ON events(type);
|
|
82
82
|
CREATE INDEX IF NOT EXISTS idx_events_timestamp ON events(timestamp);
|
|
83
83
|
CREATE INDEX IF NOT EXISTS idx_events_scope_id ON events(scope_id);
|
|
84
|
+
CREATE INDEX IF NOT EXISTS idx_events_type_timestamp ON events(type, timestamp);
|
|
84
85
|
CREATE INDEX IF NOT EXISTS idx_gates_scope_id ON quality_gates(scope_id);
|
|
85
86
|
CREATE INDEX IF NOT EXISTS idx_gates_run_at ON quality_gates(run_at);
|
|
86
87
|
CREATE INDEX IF NOT EXISTS idx_deployments_env ON deployments(environment);
|
|
87
88
|
CREATE INDEX IF NOT EXISTS idx_sessions_scope ON sessions(scope_id);
|
|
89
|
+
CREATE INDEX IF NOT EXISTS idx_sessions_claude_id ON sessions(claude_session_id);
|
|
88
90
|
CREATE INDEX IF NOT EXISTS idx_sprints_status ON sprints(status);
|
|
89
91
|
CREATE INDEX IF NOT EXISTS idx_sprint_scopes_sprint ON sprint_scopes(sprint_id);
|
|
92
|
+
CREATE INDEX IF NOT EXISTS idx_events_dispatch_unresolved ON events(type, scope_id) WHERE type = 'DISPATCH' AND JSON_EXTRACT(data, '$.resolved') IS NULL;
|
|
90
93
|
`;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type Database from 'better-sqlite3';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Emitter } from '../project-emitter.js';
|
|
3
3
|
import type { SprintService } from './sprint-service.js';
|
|
4
4
|
import type { ScopeService } from './scope-service.js';
|
|
5
|
-
import { launchInCategorizedTerminal, escapeForAnsiC, snapshotSessionPids, discoverNewSession, isSessionPidAlive } from '../utils/terminal-launcher.js';
|
|
5
|
+
import { launchInCategorizedTerminal, escapeForAnsiC, shellQuote, snapshotSessionPids, discoverNewSession, isSessionPidAlive } from '../utils/terminal-launcher.js';
|
|
6
6
|
import { linkPidToDispatch, resolveDispatchEvent } from '../utils/dispatch-utils.js';
|
|
7
7
|
import type { WorkflowEngine } from '../../shared/workflow-engine.js';
|
|
8
|
-
import {
|
|
8
|
+
import type { OrbitalConfig } from '../config.js';
|
|
9
|
+
import { buildClaudeFlags, buildEnvVarPrefix } from '../utils/flag-builder.js';
|
|
9
10
|
import { createLogger } from '../utils/logger.js';
|
|
10
11
|
|
|
11
12
|
const log = createLogger('batch');
|
|
@@ -16,10 +17,12 @@ const VALID_MERGE_MODES = ['push', 'pr'] as const;
|
|
|
16
17
|
export class BatchOrchestrator {
|
|
17
18
|
constructor(
|
|
18
19
|
private db: Database.Database,
|
|
19
|
-
private io:
|
|
20
|
+
private io: Emitter,
|
|
20
21
|
private sprintService: SprintService,
|
|
21
22
|
private scopeService: ScopeService,
|
|
22
23
|
private engine: WorkflowEngine,
|
|
24
|
+
private projectRoot: string,
|
|
25
|
+
private config: OrbitalConfig,
|
|
23
26
|
) {}
|
|
24
27
|
|
|
25
28
|
/** Dispatch a batch — validates constraints and routes to column-specific handler */
|
|
@@ -70,8 +73,10 @@ export class BatchOrchestrator {
|
|
|
70
73
|
|
|
71
74
|
// Launch single CLI session with BATCH_SCOPE_IDS prepended to command
|
|
72
75
|
const escaped = escapeForAnsiC(command);
|
|
73
|
-
const
|
|
74
|
-
const
|
|
76
|
+
const flagsStr = buildClaudeFlags(this.config.claude.dispatchFlags);
|
|
77
|
+
const envPrefix = buildEnvVarPrefix(this.config.dispatch.envVars);
|
|
78
|
+
const fullCmd = `cd '${shellQuote(this.projectRoot)}' && ${envPrefix}ORBITAL_DISPATCH_ID='${shellQuote(eventId)}' BATCH_SCOPE_IDS='${scopeIdsStr}' MERGE_MODE='${mergeModeStr}' claude ${flagsStr} $'${escaped}'`;
|
|
79
|
+
const beforePids = snapshotSessionPids(this.projectRoot);
|
|
75
80
|
|
|
76
81
|
try {
|
|
77
82
|
await launchInCategorizedTerminal(command, fullCmd);
|
|
@@ -82,7 +87,7 @@ export class BatchOrchestrator {
|
|
|
82
87
|
});
|
|
83
88
|
|
|
84
89
|
// Fire-and-forget: discover session PID and link to dispatch
|
|
85
|
-
discoverNewSession(
|
|
90
|
+
discoverNewSession(this.projectRoot, beforePids)
|
|
86
91
|
.then((session) => {
|
|
87
92
|
if (!session) return;
|
|
88
93
|
linkPidToDispatch(this.db, eventId, session.pid);
|
|
@@ -106,7 +111,7 @@ export class BatchOrchestrator {
|
|
|
106
111
|
} catch (err) {
|
|
107
112
|
this.sprintService.updateStatus(batchId, 'failed');
|
|
108
113
|
resolveDispatchEvent(this.db, this.io, eventId, 'failed', String(err));
|
|
109
|
-
return { ok: false, error: `Failed to launch terminal: ${err}` };
|
|
114
|
+
return { ok: false, error: `Failed to launch terminal: ${err instanceof Error ? err.message : String(err)}` };
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
117
|
|
|
@@ -148,6 +153,17 @@ export class BatchOrchestrator {
|
|
|
148
153
|
if (batch.status !== 'dispatched' && batch.status !== 'in_progress') return;
|
|
149
154
|
|
|
150
155
|
const scopes = this.sprintService.getSprintScopes(batchId);
|
|
156
|
+
|
|
157
|
+
// If batch never reached 'in_progress', the session never started —
|
|
158
|
+
// don't credit any scope regardless of their current workflow status
|
|
159
|
+
if (batch.status === 'dispatched') {
|
|
160
|
+
this.sprintService.updateStatus(batchId, 'failed');
|
|
161
|
+
for (const ss of scopes) {
|
|
162
|
+
this.sprintService.updateScopeStatus(batchId, ss.scope_id, 'failed', 'Session never started');
|
|
163
|
+
}
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
151
167
|
const allTransitioned = scopes.every((ss) => ss.dispatch_status === 'completed');
|
|
152
168
|
|
|
153
169
|
if (allTransitioned) {
|
|
@@ -210,16 +226,24 @@ export class BatchOrchestrator {
|
|
|
210
226
|
let pidDead = false;
|
|
211
227
|
|
|
212
228
|
if (dispatchEvent) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
229
|
+
let data: Record<string, unknown>;
|
|
230
|
+
try {
|
|
231
|
+
data = JSON.parse(dispatchEvent.data) as Record<string, unknown>;
|
|
232
|
+
} catch {
|
|
216
233
|
pidDead = true;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
//
|
|
221
|
-
|
|
222
|
-
|
|
234
|
+
// Fall through to resolution below
|
|
235
|
+
}
|
|
236
|
+
if (!pidDead) {
|
|
237
|
+
// If the dispatch event is already resolved, the session is definitely done
|
|
238
|
+
if (data!.resolved != null) {
|
|
239
|
+
pidDead = true;
|
|
240
|
+
} else if (typeof data!.pid === 'number') {
|
|
241
|
+
pidDead = !isSessionPidAlive(data!.pid);
|
|
242
|
+
} else {
|
|
243
|
+
// No PID recorded — check if batch is old enough to consider stale
|
|
244
|
+
const dispatchedAt = batch.dispatched_at ? new Date(batch.dispatched_at).getTime() : 0;
|
|
245
|
+
pidDead = Date.now() - dispatchedAt > STALE_THRESHOLD_MS;
|
|
246
|
+
}
|
|
223
247
|
}
|
|
224
248
|
} else {
|
|
225
249
|
// No dispatch event at all — check age
|
|
@@ -3,7 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import readline from 'readline';
|
|
4
4
|
import type Database from 'better-sqlite3';
|
|
5
5
|
import type { ScopeService } from './scope-service.js';
|
|
6
|
-
import {
|
|
6
|
+
import { getClaudeSessionsDir } from '../config.js';
|
|
7
7
|
|
|
8
8
|
export interface ClaudeSession {
|
|
9
9
|
id: string;
|
|
@@ -59,11 +59,12 @@ export interface SessionStats {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function getSessionsDir(): string {
|
|
63
|
-
|
|
62
|
+
function getSessionsDir(projectRoot?: string): string {
|
|
63
|
+
if (!projectRoot) throw new Error('projectRoot is required for getSessionsDir');
|
|
64
|
+
return getClaudeSessionsDir(projectRoot);
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
const cacheByDir = new Map<string, { sessions: ClaudeSession[]; expiry: number }>();
|
|
67
68
|
const CACHE_TTL_MS = 60_000;
|
|
68
69
|
|
|
69
70
|
/**
|
|
@@ -146,12 +147,13 @@ async function parseSessionFile(filePath: string): Promise<ClaudeSession | null>
|
|
|
146
147
|
};
|
|
147
148
|
}
|
|
148
149
|
|
|
149
|
-
export async function getClaudeSessions(since?: string): Promise<ClaudeSession[]> {
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
export async function getClaudeSessions(since?: string, projectRoot?: string): Promise<ClaudeSession[]> {
|
|
151
|
+
const sessionsDir = getSessionsDir(projectRoot);
|
|
152
|
+
const cached = cacheByDir.get(sessionsDir);
|
|
153
|
+
if (cached && Date.now() < cached.expiry) {
|
|
154
|
+
return filterSince(cached.sessions, since);
|
|
152
155
|
}
|
|
153
156
|
|
|
154
|
-
const sessionsDir = getSessionsDir();
|
|
155
157
|
if (!fs.existsSync(sessionsDir)) return [];
|
|
156
158
|
|
|
157
159
|
const files = fs
|
|
@@ -171,7 +173,7 @@ export async function getClaudeSessions(since?: string): Promise<ClaudeSession[]
|
|
|
171
173
|
(a, b) => new Date(b.lastActiveAt).getTime() - new Date(a.lastActiveAt).getTime(),
|
|
172
174
|
);
|
|
173
175
|
|
|
174
|
-
|
|
176
|
+
cacheByDir.set(sessionsDir, { sessions, expiry: Date.now() + CACHE_TTL_MS });
|
|
175
177
|
return filterSince(sessions, since);
|
|
176
178
|
}
|
|
177
179
|
|
|
@@ -248,8 +250,8 @@ function extractFirstUserMessage(lines: string[], max: number): string | null {
|
|
|
248
250
|
* Parse a full JSONL file and return detailed stats grouped by line type.
|
|
249
251
|
* This is heavier than parseSessionFile — only called for the detail view.
|
|
250
252
|
*/
|
|
251
|
-
export function getSessionStats(claudeSessionId: string): SessionStats | null {
|
|
252
|
-
const filePath = path.join(getSessionsDir(), `${claudeSessionId}.jsonl`);
|
|
253
|
+
export function getSessionStats(claudeSessionId: string, projectRoot?: string): SessionStats | null {
|
|
254
|
+
const filePath = path.join(getSessionsDir(projectRoot), `${claudeSessionId}.jsonl`);
|
|
253
255
|
if (!fs.existsSync(filePath)) return null;
|
|
254
256
|
|
|
255
257
|
const stats: SessionStats = {
|
|
@@ -360,8 +362,8 @@ export function getSessionStats(claudeSessionId: string): SessionStats | null {
|
|
|
360
362
|
* 2. For each scope, parse the sessions JSON: Record<phase, uuid[]>
|
|
361
363
|
* 3. For each (phase, uuid), UPSERT into sessions table with JSONL metadata if available
|
|
362
364
|
*/
|
|
363
|
-
export async function syncClaudeSessionsToDB(db: Database.Database, scopeService: ScopeService): Promise<number> {
|
|
364
|
-
|
|
365
|
+
export async function syncClaudeSessionsToDB(db: Database.Database, scopeService: ScopeService, projectRoot?: string): Promise<number> {
|
|
366
|
+
cacheByDir.clear(); // Force fresh read from filesystem
|
|
365
367
|
|
|
366
368
|
const scopeRows = scopeService.getAll()
|
|
367
369
|
.filter(s => Object.keys(s.sessions).length > 0)
|
|
@@ -389,7 +391,7 @@ export async function syncClaudeSessionsToDB(db: Database.Database, scopeService
|
|
|
389
391
|
if (typeof uuid !== 'string' || !uuid) continue;
|
|
390
392
|
|
|
391
393
|
// Check if JSONL file exists for metadata enrichment
|
|
392
|
-
const jsonlPath = path.join(getSessionsDir(), `${uuid}.jsonl`);
|
|
394
|
+
const jsonlPath = path.join(getSessionsDir(projectRoot), `${uuid}.jsonl`);
|
|
393
395
|
let startedAt: string | null = null;
|
|
394
396
|
let endedAt: string | null = null;
|
|
395
397
|
let summary: string | null = null;
|
|
@@ -120,7 +120,16 @@ export class ConfigService {
|
|
|
120
120
|
const fullPath = path.join(currentPath, entry.name);
|
|
121
121
|
const relPath = path.relative(basePath, fullPath);
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
// Resolve symlinks: Dirent.isDirectory() returns false for symlinks-to-dirs.
|
|
124
|
+
// Self-hosted projects symlink .claude/agents/*, .claude/hooks/*, etc. into templates/.
|
|
125
|
+
let stat: fs.Stats;
|
|
126
|
+
try {
|
|
127
|
+
stat = fs.statSync(fullPath);
|
|
128
|
+
} catch {
|
|
129
|
+
continue; // broken symlink — skip silently
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (stat.isDirectory()) {
|
|
124
133
|
const children = this.walkDir(fullPath, basePath, parseFrontmatter);
|
|
125
134
|
nodes.push({ name: entry.name, path: relPath, type: 'folder', children });
|
|
126
135
|
} else {
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
2
|
+
import { DeployService } from './deploy-service.js';
|
|
3
|
+
import { createTestDb } from '../__tests__/helpers/db.js';
|
|
4
|
+
import { createMockEmitter } from '../__tests__/helpers/mock-emitter.js';
|
|
5
|
+
import type Database from 'better-sqlite3';
|
|
6
|
+
import type { Emitter } from '../project-emitter.js';
|
|
7
|
+
|
|
8
|
+
describe('DeployService', () => {
|
|
9
|
+
let db: Database.Database;
|
|
10
|
+
let cleanup: () => void;
|
|
11
|
+
let emitter: Emitter & { emit: ReturnType<typeof vi.fn> };
|
|
12
|
+
let service: DeployService;
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
({ db, cleanup } = createTestDb());
|
|
16
|
+
emitter = createMockEmitter();
|
|
17
|
+
service = new DeployService(db, emitter);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
cleanup?.();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// ─── record() ─────────────────────────────────────────────
|
|
25
|
+
|
|
26
|
+
describe('record()', () => {
|
|
27
|
+
it('inserts deployment and returns ID', () => {
|
|
28
|
+
const id = service.record({
|
|
29
|
+
environment: 'staging',
|
|
30
|
+
status: 'deploying',
|
|
31
|
+
commit_sha: 'abc1234',
|
|
32
|
+
branch: 'main',
|
|
33
|
+
pr_number: null,
|
|
34
|
+
health_check_url: null,
|
|
35
|
+
details: null,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
expect(id).toBe(1);
|
|
39
|
+
const row = db.prepare('SELECT * FROM deployments WHERE id = ?').get(id) as Record<string, unknown>;
|
|
40
|
+
expect(row.environment).toBe('staging');
|
|
41
|
+
expect(row.status).toBe('deploying');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('emits deploy:updated with inserted row', () => {
|
|
45
|
+
service.record({
|
|
46
|
+
environment: 'production',
|
|
47
|
+
status: 'deploying',
|
|
48
|
+
commit_sha: 'def5678',
|
|
49
|
+
branch: 'main',
|
|
50
|
+
pr_number: 42,
|
|
51
|
+
health_check_url: 'https://example.com/health',
|
|
52
|
+
details: { version: '1.0.0' },
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
expect(emitter.emit).toHaveBeenCalledWith('deploy:updated', expect.objectContaining({
|
|
56
|
+
environment: 'production',
|
|
57
|
+
branch: 'main',
|
|
58
|
+
pr_number: 42,
|
|
59
|
+
}));
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// ─── updateStatus() ──────────────────────────────────────
|
|
64
|
+
|
|
65
|
+
describe('updateStatus()', () => {
|
|
66
|
+
let deployId: number;
|
|
67
|
+
|
|
68
|
+
beforeEach(() => {
|
|
69
|
+
deployId = service.record({
|
|
70
|
+
environment: 'staging',
|
|
71
|
+
status: 'deploying',
|
|
72
|
+
commit_sha: 'abc',
|
|
73
|
+
branch: 'main',
|
|
74
|
+
pr_number: null,
|
|
75
|
+
health_check_url: null,
|
|
76
|
+
details: null,
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('updates status and emits deploy:updated', () => {
|
|
81
|
+
service.updateStatus(deployId, 'healthy');
|
|
82
|
+
|
|
83
|
+
const row = db.prepare('SELECT * FROM deployments WHERE id = ?').get(deployId) as Record<string, unknown>;
|
|
84
|
+
expect(row.status).toBe('healthy');
|
|
85
|
+
// 1 from record + 1 from updateStatus
|
|
86
|
+
expect(emitter.emit).toHaveBeenCalledTimes(2);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('sets completed_at for terminal status: healthy', () => {
|
|
90
|
+
service.updateStatus(deployId, 'healthy');
|
|
91
|
+
const row = db.prepare('SELECT completed_at FROM deployments WHERE id = ?').get(deployId) as { completed_at: string | null };
|
|
92
|
+
expect(row.completed_at).not.toBeNull();
|
|
93
|
+
expect(row.completed_at).toMatch(/^\d{4}-\d{2}-\d{2}T/);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('sets completed_at for terminal status: failed', () => {
|
|
97
|
+
service.updateStatus(deployId, 'failed');
|
|
98
|
+
const row = db.prepare('SELECT completed_at FROM deployments WHERE id = ?').get(deployId) as { completed_at: string | null };
|
|
99
|
+
expect(row.completed_at).not.toBeNull();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('sets completed_at for terminal status: rolled-back', () => {
|
|
103
|
+
service.updateStatus(deployId, 'rolled-back');
|
|
104
|
+
const row = db.prepare('SELECT completed_at FROM deployments WHERE id = ?').get(deployId) as { completed_at: string | null };
|
|
105
|
+
expect(row.completed_at).not.toBeNull();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('does not set completed_at for non-terminal status', () => {
|
|
109
|
+
service.updateStatus(deployId, 'deploying');
|
|
110
|
+
const row = db.prepare('SELECT completed_at FROM deployments WHERE id = ?').get(deployId) as { completed_at: string | null };
|
|
111
|
+
expect(row.completed_at).toBeNull();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// ─── getRecent() ──────────────────────────────────────────
|
|
116
|
+
|
|
117
|
+
describe('getRecent()', () => {
|
|
118
|
+
it('returns deployments ordered by started_at DESC with limit', () => {
|
|
119
|
+
service.record({ environment: 'staging', status: 'healthy', commit_sha: 'a', branch: 'main', pr_number: null, health_check_url: null, details: null });
|
|
120
|
+
service.record({ environment: 'production', status: 'deploying', commit_sha: 'b', branch: 'main', pr_number: null, health_check_url: null, details: null });
|
|
121
|
+
|
|
122
|
+
const recent = service.getRecent(1);
|
|
123
|
+
expect(recent).toHaveLength(1);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// ─── getLatestPerEnv() ────────────────────────────────────
|
|
128
|
+
|
|
129
|
+
describe('getLatestPerEnv()', () => {
|
|
130
|
+
it('returns one deployment per environment', () => {
|
|
131
|
+
service.record({ environment: 'staging', status: 'healthy', commit_sha: 'a', branch: 'main', pr_number: null, health_check_url: null, details: null });
|
|
132
|
+
service.record({ environment: 'staging', status: 'deploying', commit_sha: 'b', branch: 'main', pr_number: null, health_check_url: null, details: null });
|
|
133
|
+
service.record({ environment: 'production', status: 'healthy', commit_sha: 'c', branch: 'main', pr_number: null, health_check_url: null, details: null });
|
|
134
|
+
|
|
135
|
+
const latest = service.getLatestPerEnv();
|
|
136
|
+
expect(latest).toHaveLength(2);
|
|
137
|
+
const envs = latest.map(d => d.environment).sort();
|
|
138
|
+
expect(envs).toEqual(['production', 'staging']);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('returns empty when no deployments exist', () => {
|
|
142
|
+
expect(service.getLatestPerEnv()).toEqual([]);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type Database from 'better-sqlite3';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Emitter } from '../project-emitter.js';
|
|
3
3
|
import type { DeployStatus, DeployEnvironment } from '../../shared/api-types.js';
|
|
4
4
|
import { createLogger } from '../utils/logger.js';
|
|
5
5
|
|
|
@@ -31,7 +31,7 @@ export interface DeployRow {
|
|
|
31
31
|
export class DeployService {
|
|
32
32
|
constructor(
|
|
33
33
|
private db: Database.Database,
|
|
34
|
-
private io:
|
|
34
|
+
private io: Emitter
|
|
35
35
|
) {}
|
|
36
36
|
|
|
37
37
|
/** Record a deployment event */
|