orbital-command 0.3.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 (160) 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 +95 -870
  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-CPy85_J6.js → arrow-down-DVPp6_qp.js} +1 -1
  18. package/dist/assets/bot-NFaJBDn_.js +6 -0
  19. package/dist/assets/{charts-DbDg0Psc.js → charts-LGLb8hyU.js} +1 -1
  20. package/dist/assets/{circle-x-Cwz6ZQDV.js → circle-x-IsFCkBZu.js} +1 -1
  21. package/dist/assets/{file-text-C46Xr65c.js → file-text-J1cebZXF.js} +1 -1
  22. package/dist/assets/{globe-Cn2yNZUD.js → globe-WzeyHsUc.js} +1 -1
  23. package/dist/assets/index-BdJ57EhC.css +1 -0
  24. package/dist/assets/index-o4ScMAuR.js +349 -0
  25. package/dist/assets/{key-OPaNTWJ5.js → key-CKR8JJSj.js} +1 -1
  26. package/dist/assets/{minus-GMsbpKym.js → minus-CHBsJyjp.js} +1 -1
  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-DwAFkDYI.js → shield-TdB1yv_a.js} +1 -1
  30. package/dist/assets/useSocketListener-0L5yiN5i.js +1 -0
  31. package/dist/assets/useWorkflowEditor-CqeRWVQX.js +11 -0
  32. package/dist/assets/workflow-constants-Rw-GmgHZ.js +6 -0
  33. package/dist/assets/zap-C9wqYMpl.js +6 -0
  34. package/dist/index.html +3 -3
  35. package/dist/server/server/__tests__/data-routes.test.js +2 -0
  36. package/dist/server/server/__tests__/scope-routes.test.js +1 -0
  37. package/dist/server/server/config-migrator.js +0 -3
  38. package/dist/server/server/config.js +35 -6
  39. package/dist/server/server/database.js +0 -22
  40. package/dist/server/server/index.js +26 -814
  41. package/dist/server/server/init.js +32 -399
  42. package/dist/server/server/launch.js +1 -1
  43. package/dist/server/server/parsers/event-parser.js +4 -1
  44. package/dist/server/server/project-context.js +19 -9
  45. package/dist/server/server/project-manager.js +6 -6
  46. package/dist/server/server/routes/aggregate-routes.js +871 -0
  47. package/dist/server/server/routes/config-routes.js +41 -88
  48. package/dist/server/server/routes/data-routes.js +5 -15
  49. package/dist/server/server/routes/dispatch-routes.js +24 -8
  50. package/dist/server/server/routes/manifest-routes.js +1 -1
  51. package/dist/server/server/routes/scope-routes.js +10 -7
  52. package/dist/server/server/schema.js +1 -0
  53. package/dist/server/server/services/batch-orchestrator.js +17 -3
  54. package/dist/server/server/services/config-service.js +10 -1
  55. package/dist/server/server/services/scope-service.js +7 -7
  56. package/dist/server/server/services/sprint-orchestrator.js +24 -11
  57. package/dist/server/server/services/sprint-service.js +2 -2
  58. package/dist/server/server/uninstall.js +195 -0
  59. package/dist/server/server/update.js +212 -0
  60. package/dist/server/server/utils/dispatch-utils.js +8 -6
  61. package/dist/server/server/utils/flag-builder.js +54 -0
  62. package/dist/server/server/utils/json-fields.js +14 -0
  63. package/dist/server/server/utils/json-fields.test.js +73 -0
  64. package/dist/server/server/utils/route-helpers.js +37 -0
  65. package/dist/server/server/utils/route-helpers.test.js +115 -0
  66. package/dist/server/server/watchers/event-watcher.js +28 -13
  67. package/dist/server/server/wizard/config-editor.js +4 -4
  68. package/dist/server/server/wizard/doctor.js +2 -2
  69. package/dist/server/server/wizard/index.js +224 -39
  70. package/dist/server/server/wizard/phases/welcome.js +1 -4
  71. package/dist/server/server/wizard/ui.js +6 -7
  72. package/dist/server/shared/api-types.js +80 -1
  73. package/dist/server/shared/workflow-engine.js +1 -1
  74. package/package.json +20 -20
  75. package/schemas/orbital.config.schema.json +1 -19
  76. package/scripts/postinstall.js +6 -42
  77. package/scripts/release.sh +53 -0
  78. package/server/__tests__/data-routes.test.ts +2 -0
  79. package/server/__tests__/scope-routes.test.ts +1 -0
  80. package/server/config-migrator.ts +0 -3
  81. package/server/config.ts +39 -11
  82. package/server/database.ts +0 -26
  83. package/server/global-config.ts +4 -0
  84. package/server/index.ts +29 -894
  85. package/server/init.ts +32 -443
  86. package/server/launch.ts +1 -1
  87. package/server/parsers/event-parser.ts +4 -1
  88. package/server/project-context.ts +26 -10
  89. package/server/project-manager.ts +5 -6
  90. package/server/routes/aggregate-routes.ts +968 -0
  91. package/server/routes/config-routes.ts +41 -81
  92. package/server/routes/data-routes.ts +7 -16
  93. package/server/routes/dispatch-routes.ts +29 -8
  94. package/server/routes/manifest-routes.ts +1 -1
  95. package/server/routes/scope-routes.ts +12 -7
  96. package/server/schema.ts +1 -0
  97. package/server/services/batch-orchestrator.ts +18 -2
  98. package/server/services/config-service.ts +10 -1
  99. package/server/services/scope-service.ts +6 -6
  100. package/server/services/sprint-orchestrator.ts +24 -9
  101. package/server/services/sprint-service.ts +2 -2
  102. package/server/uninstall.ts +214 -0
  103. package/server/update.ts +263 -0
  104. package/server/utils/dispatch-utils.ts +8 -6
  105. package/server/utils/flag-builder.ts +56 -0
  106. package/server/utils/json-fields.test.ts +83 -0
  107. package/server/utils/json-fields.ts +14 -0
  108. package/server/utils/route-helpers.test.ts +144 -0
  109. package/server/utils/route-helpers.ts +38 -0
  110. package/server/watchers/event-watcher.ts +24 -12
  111. package/server/wizard/config-editor.ts +4 -4
  112. package/server/wizard/doctor.ts +2 -2
  113. package/server/wizard/index.ts +291 -40
  114. package/server/wizard/phases/welcome.ts +1 -5
  115. package/server/wizard/ui.ts +6 -7
  116. package/shared/api-types.ts +106 -0
  117. package/shared/workflow-engine.ts +1 -1
  118. package/templates/agents/QUICK-REFERENCE.md +1 -0
  119. package/templates/agents/README.md +1 -0
  120. package/templates/agents/SKILL-TRIGGERS.md +11 -0
  121. package/templates/agents/green-team/deep-dive.md +361 -0
  122. package/templates/hooks/end-session.sh +1 -0
  123. package/templates/hooks/init-session.sh +1 -0
  124. package/templates/hooks/scope-commit-logger.sh +2 -2
  125. package/templates/hooks/scope-create-gate.sh +2 -4
  126. package/templates/hooks/scope-gate.sh +4 -6
  127. package/templates/hooks/scope-helpers.sh +10 -1
  128. package/templates/hooks/scope-lifecycle-gate.sh +14 -5
  129. package/templates/hooks/scope-prepare.sh +1 -1
  130. package/templates/hooks/scope-transition.sh +14 -6
  131. package/templates/hooks/time-tracker.sh +2 -5
  132. package/templates/orbital.config.json +1 -4
  133. package/templates/presets/development.json +4 -4
  134. package/templates/presets/gitflow.json +7 -0
  135. package/templates/prompts/README.md +23 -0
  136. package/templates/prompts/deep-dive-audit.md +94 -0
  137. package/templates/quick/rules.md +56 -5
  138. package/templates/skills/git-commit/SKILL.md +21 -6
  139. package/templates/skills/git-dev/SKILL.md +8 -4
  140. package/templates/skills/git-main/SKILL.md +8 -4
  141. package/templates/skills/git-production/SKILL.md +6 -3
  142. package/templates/skills/git-staging/SKILL.md +6 -3
  143. package/templates/skills/scope-fix-review/SKILL.md +8 -4
  144. package/templates/skills/scope-implement/SKILL.md +13 -5
  145. package/templates/skills/scope-post-review/SKILL.md +16 -4
  146. package/templates/skills/scope-pre-review/SKILL.md +6 -2
  147. package/dist/assets/PrimitivesConfig-CrmQXYh4.js +0 -32
  148. package/dist/assets/QualityGates-BbasOsF3.js +0 -21
  149. package/dist/assets/SessionTimeline-CGeJsVvy.js +0 -1
  150. package/dist/assets/Settings-oiM496mc.js +0 -12
  151. package/dist/assets/SourceControl-B1fP2nJL.js +0 -41
  152. package/dist/assets/WorkflowVisualizer-CWLYf-f0.js +0 -74
  153. package/dist/assets/formatDistanceToNow-BMqsSP44.js +0 -1
  154. package/dist/assets/index-Aj4sV8Al.css +0 -1
  155. package/dist/assets/index-Bc9dK3MW.js +0 -354
  156. package/dist/assets/useWorkflowEditor-BJkTX_NR.js +0 -16
  157. package/dist/assets/zap-DfbUoOty.js +0 -11
  158. package/dist/server/server/services/telemetry-service.js +0 -143
  159. package/server/services/telemetry-service.ts +0 -195
  160. /package/{shared/default-workflow.json → templates/presets/default.json} +0 -0
@@ -4,23 +4,16 @@ import { Server } from 'socket.io';
4
4
  import path from 'path';
5
5
  import fs from 'fs';
6
6
  import { fileURLToPath } from 'url';
7
- import { launchInTerminal } from './utils/terminal-launcher.js';
8
- import { getClaudeSessions, getSessionStats } from './services/claude-session-service.js';
9
- import { getActiveScopeIds, getAbandonedScopeIds } from './utils/dispatch-utils.js';
10
- import { ConfigService, isValidPrimitiveType } from './services/config-service.js';
11
- import { GLOBAL_PRIMITIVES_DIR } from './global-config.js';
12
7
  import { createVersionRoutes } from './routes/version-routes.js';
13
- import { getHookEnforcement } from '../shared/workflow-config.js';
8
+ import { createAggregateRoutes } from './routes/aggregate-routes.js';
14
9
  import { createLogger, setLogLevel } from './utils/logger.js';
15
10
  // ─── Central Server ─────────────────────────────────────────
16
11
  import { ProjectManager } from './project-manager.js';
17
12
  import { SyncService } from './services/sync-service.js';
18
13
  import { startGlobalWatcher } from './watchers/global-watcher.js';
19
14
  import { createSyncRoutes } from './routes/sync-routes.js';
20
- import { seedGlobalPrimitives, runUpdate } from './init.js';
21
- import { loadManifest, refreshFileStatuses, summarizeManifest } from './manifest.js';
22
- import { getPackageVersion } from './utils/package-info.js';
23
- import { ensureOrbitalHome, loadGlobalConfig, registerProject as registerProjectGlobal, ORBITAL_HOME, } from './global-config.js';
15
+ import { seedGlobalPrimitives } from './init.js';
16
+ import { ensureOrbitalHome, loadGlobalConfig, registerProject as registerProjectGlobal, GLOBAL_PRIMITIVES_DIR, ORBITAL_HOME, } from './global-config.js';
24
17
  export async function startCentralServer(overrides) {
25
18
  ensureOrbitalHome();
26
19
  const envLevel = process.env.ORBITAL_LOG_LEVEL;
@@ -52,6 +45,26 @@ export async function startCentralServer(overrides) {
52
45
  },
53
46
  });
54
47
  app.use(express.json());
48
+ // ─── Bind port early ──────────────────────────────────────
49
+ // Listen before async init so Vite's proxy doesn't get ECONNREFUSED
50
+ const actualPort = await new Promise((resolve, reject) => {
51
+ let attempt = 0;
52
+ const maxAttempts = 10;
53
+ httpServer.on('error', (err) => {
54
+ if (err.code === 'EADDRINUSE' && attempt < maxAttempts) {
55
+ attempt++;
56
+ httpServer.listen(port + attempt);
57
+ }
58
+ else {
59
+ reject(new Error(`Failed to start server: ${err.message}`));
60
+ }
61
+ });
62
+ httpServer.on('listening', () => {
63
+ const addr = httpServer.address();
64
+ resolve(typeof addr === 'object' && addr ? addr.port : port);
65
+ });
66
+ httpServer.listen(port);
67
+ });
55
68
  // Initialize ProjectManager and boot all registered projects
56
69
  const projectManager = new ProjectManager(io);
57
70
  await projectManager.initializeAll();
@@ -87,791 +100,8 @@ export async function startCentralServer(overrides) {
87
100
  }
88
101
  router(req, res, next);
89
102
  });
90
- // Aggregate endpoints
91
- app.get('/api/orbital/aggregate/scopes', (_req, res) => {
92
- const allScopes = [];
93
- for (const [projectId, ctx] of projectManager.getAllContexts()) {
94
- for (const scope of ctx.scopeService.getAll()) {
95
- allScopes.push({ ...scope, project_id: projectId });
96
- }
97
- }
98
- res.json(allScopes);
99
- });
100
- app.get('/api/orbital/aggregate/events', (req, res) => {
101
- const limit = Number(req.query.limit) || 50;
102
- const allEvents = [];
103
- for (const [projectId, ctx] of projectManager.getAllContexts()) {
104
- const events = ctx.db.prepare(`SELECT * FROM events ORDER BY timestamp DESC LIMIT ?`).all(limit);
105
- for (const event of events) {
106
- allEvents.push({ ...event, project_id: projectId });
107
- }
108
- }
109
- // Sort by timestamp descending across all projects
110
- allEvents.sort((a, b) => String(b.timestamp).localeCompare(String(a.timestamp)));
111
- res.json(allEvents.slice(0, limit));
112
- });
113
- // Aggregate sessions across all projects
114
- const JSON_FIELDS = ['tags', 'blocked_by', 'blocks', 'data', 'discoveries', 'next_steps', 'details'];
115
- function parseJsonFields(row) {
116
- const parsed = { ...row };
117
- for (const field of JSON_FIELDS) {
118
- if (typeof parsed[field] === 'string') {
119
- try {
120
- parsed[field] = JSON.parse(parsed[field]);
121
- }
122
- catch { /* keep string */ }
123
- }
124
- }
125
- return parsed;
126
- }
127
- app.get('/api/orbital/aggregate/sessions', (_req, res) => {
128
- const allRows = [];
129
- for (const [projectId, ctx] of projectManager.getAllContexts()) {
130
- const rows = ctx.db.prepare('SELECT * FROM sessions ORDER BY started_at DESC').all();
131
- for (const row of rows) {
132
- allRows.push({ ...parseJsonFields(row), project_id: projectId });
133
- }
134
- }
135
- // Deduplicate by claude_session_id, aggregate scope_ids and actions
136
- const seen = new Map();
137
- const scopeMap = new Map();
138
- const actionMap = new Map();
139
- for (const row of allRows) {
140
- const key = row.claude_session_id ?? row.id;
141
- if (!seen.has(key)) {
142
- seen.set(key, row);
143
- scopeMap.set(key, []);
144
- actionMap.set(key, []);
145
- }
146
- const sid = row.scope_id;
147
- if (sid != null) {
148
- const arr = scopeMap.get(key);
149
- if (!arr.includes(sid))
150
- arr.push(sid);
151
- }
152
- const action = row.action;
153
- if (action) {
154
- const actions = actionMap.get(key);
155
- if (!actions.includes(action))
156
- actions.push(action);
157
- }
158
- }
159
- const results = [...seen.values()].map((row) => {
160
- const key = row.claude_session_id ?? row.id;
161
- return { ...row, scope_ids: scopeMap.get(key) ?? [], actions: actionMap.get(key) ?? [] };
162
- });
163
- // Sort by started_at descending across all projects
164
- results.sort((a, b) => String(b.started_at ?? '').localeCompare(String(a.started_at ?? '')));
165
- res.json(results.slice(0, 50));
166
- });
167
- app.get('/api/orbital/aggregate/sessions/:id/content', async (req, res) => {
168
- const sessionId = req.params.id;
169
- // Find the session across all project databases
170
- let session;
171
- let matchedProjectRoot;
172
- for (const [, ctx] of projectManager.getAllContexts()) {
173
- const row = ctx.db.prepare('SELECT * FROM sessions WHERE id = ?').get(sessionId);
174
- if (row) {
175
- session = parseJsonFields(row);
176
- matchedProjectRoot = ctx.config.projectRoot;
177
- break;
178
- }
179
- }
180
- if (!session || !matchedProjectRoot) {
181
- res.status(404).json({ error: 'Session not found' });
182
- return;
183
- }
184
- let content = '';
185
- let meta = null;
186
- let stats = null;
187
- if (session.claude_session_id && typeof session.claude_session_id === 'string') {
188
- const claudeSessions = await getClaudeSessions(undefined, matchedProjectRoot);
189
- const match = claudeSessions.find(s => s.id === session.claude_session_id);
190
- if (match) {
191
- meta = {
192
- slug: match.slug,
193
- branch: match.branch,
194
- fileSize: match.fileSize,
195
- summary: match.summary,
196
- startedAt: match.startedAt,
197
- lastActiveAt: match.lastActiveAt,
198
- };
199
- }
200
- stats = getSessionStats(session.claude_session_id, matchedProjectRoot);
201
- }
202
- if (!content) {
203
- const parts = [];
204
- if (session.summary)
205
- parts.push(`# ${session.summary}\n`);
206
- const discoveries = Array.isArray(session.discoveries) ? session.discoveries : [];
207
- if (discoveries.length > 0) {
208
- parts.push('## Completed\n');
209
- for (const d of discoveries)
210
- parts.push(`- ${d}`);
211
- parts.push('');
212
- }
213
- const nextSteps = Array.isArray(session.next_steps) ? session.next_steps : [];
214
- if (nextSteps.length > 0) {
215
- parts.push('## Next Steps\n');
216
- for (const n of nextSteps)
217
- parts.push(`- ${n}`);
218
- }
219
- content = parts.join('\n');
220
- }
221
- res.json({
222
- id: session.id,
223
- content,
224
- claude_session_id: session.claude_session_id ?? null,
225
- meta,
226
- stats,
227
- });
228
- });
229
- app.post('/api/orbital/aggregate/sessions/:id/resume', async (req, res) => {
230
- const sessionId = req.params.id;
231
- const { claude_session_id } = req.body;
232
- if (!claude_session_id || !/^[0-9a-f-]{36}$/i.test(claude_session_id)) {
233
- res.status(400).json({ error: 'Valid claude_session_id (UUID) required' });
234
- return;
235
- }
236
- // Find the session's project root
237
- let matchedProjectRoot;
238
- for (const [, ctx] of projectManager.getAllContexts()) {
239
- const row = ctx.db.prepare('SELECT * FROM sessions WHERE id = ?').get(sessionId);
240
- if (row) {
241
- matchedProjectRoot = ctx.config.projectRoot;
242
- break;
243
- }
244
- }
245
- if (!matchedProjectRoot) {
246
- res.status(404).json({ error: 'Session not found' });
247
- return;
248
- }
249
- const resumeCmd = `cd '${matchedProjectRoot}' && claude --dangerously-skip-permissions --resume '${claude_session_id}'`;
250
- try {
251
- await launchInTerminal(resumeCmd);
252
- res.json({ ok: true, session_id: claude_session_id });
253
- }
254
- catch (err) {
255
- log.error('Terminal launch failed', { error: String(err) });
256
- res.status(500).json({ error: 'Failed to launch terminal', details: String(err) });
257
- }
258
- });
259
- // ─── Aggregate: Enforcement & Gates ──────────────────────
260
- app.get('/api/orbital/aggregate/events/violations/summary', (_req, res) => {
261
- try {
262
- const mergedByRule = new Map();
263
- const mergedByFile = new Map();
264
- let allOverrides = [];
265
- let totalViolations = 0;
266
- let totalOverrides = 0;
267
- for (const [, ctx] of projectManager.getAllContexts()) {
268
- const byRule = ctx.db.prepare(`SELECT JSON_EXTRACT(data, '$.rule') as rule, COUNT(*) as count, MAX(timestamp) as last_seen
269
- FROM events WHERE type = 'VIOLATION' GROUP BY rule ORDER BY count DESC`).all();
270
- for (const r of byRule) {
271
- const existing = mergedByRule.get(r.rule);
272
- if (existing) {
273
- existing.count += r.count;
274
- if (r.last_seen > existing.last_seen)
275
- existing.last_seen = r.last_seen;
276
- }
277
- else {
278
- mergedByRule.set(r.rule, { ...r });
279
- }
280
- }
281
- const byFile = ctx.db.prepare(`SELECT JSON_EXTRACT(data, '$.file') as file, COUNT(*) as count FROM events
282
- WHERE type = 'VIOLATION' AND JSON_EXTRACT(data, '$.file') IS NOT NULL AND JSON_EXTRACT(data, '$.file') != ''
283
- GROUP BY file ORDER BY count DESC LIMIT 20`).all();
284
- for (const f of byFile) {
285
- const existing = mergedByFile.get(f.file);
286
- if (existing) {
287
- existing.count += f.count;
288
- }
289
- else {
290
- mergedByFile.set(f.file, { ...f });
291
- }
292
- }
293
- const overrides = ctx.db.prepare(`SELECT JSON_EXTRACT(data, '$.rule') as rule, JSON_EXTRACT(data, '$.reason') as reason, timestamp as date
294
- FROM events WHERE type = 'OVERRIDE' ORDER BY timestamp DESC LIMIT 50`).all();
295
- allOverrides = allOverrides.concat(overrides);
296
- const tv = ctx.db.prepare(`SELECT COUNT(*) as count FROM events WHERE type = 'VIOLATION'`).get();
297
- const to = ctx.db.prepare(`SELECT COUNT(*) as count FROM events WHERE type = 'OVERRIDE'`).get();
298
- totalViolations += tv.count;
299
- totalOverrides += to.count;
300
- }
301
- const byRule = [...mergedByRule.values()].sort((a, b) => b.count - a.count);
302
- const byFile = [...mergedByFile.values()].sort((a, b) => b.count - a.count).slice(0, 20);
303
- allOverrides.sort((a, b) => b.date.localeCompare(a.date));
304
- res.json({ byRule, byFile, overrides: allOverrides.slice(0, 50), totalViolations, totalOverrides });
305
- }
306
- catch (err) {
307
- log.error('Violations summary failed', { error: String(err) });
308
- res.status(500).json({ error: 'Failed to aggregate violations summary' });
309
- }
310
- });
311
- app.get('/api/orbital/aggregate/enforcement/rules', (_req, res) => {
312
- try {
313
- const hookMap = new Map();
314
- const summary = { guards: 0, gates: 0, lifecycle: 0, observers: 0 };
315
- const edgeIdSet = new Set();
316
- let totalEdges = 0;
317
- for (const [, ctx] of projectManager.getAllContexts()) {
318
- const allHooks = ctx.workflowEngine.getAllHooks();
319
- const allEdges = ctx.workflowEngine.getAllEdges();
320
- // Build edge map for this project
321
- const hookEdgeMap = new Map();
322
- for (const edge of allEdges) {
323
- const edgeKey = `${edge.from}->${edge.to}`;
324
- if (!edgeIdSet.has(edgeKey)) {
325
- edgeIdSet.add(edgeKey);
326
- totalEdges++;
327
- }
328
- for (const hookId of edge.hooks ?? []) {
329
- if (!hookEdgeMap.has(hookId))
330
- hookEdgeMap.set(hookId, []);
331
- hookEdgeMap.get(hookId).push({ from: edge.from, to: edge.to, label: edge.label });
332
- }
333
- }
334
- // Query stats from this project's DB
335
- const violationStats = ctx.db.prepare(`SELECT JSON_EXTRACT(data, '$.rule') as rule, COUNT(*) as count, MAX(timestamp) as last_seen
336
- FROM events WHERE type = 'VIOLATION' GROUP BY rule`).all();
337
- const overrideStats = ctx.db.prepare(`SELECT JSON_EXTRACT(data, '$.rule') as rule, COUNT(*) as count
338
- FROM events WHERE type = 'OVERRIDE' GROUP BY rule`).all();
339
- const violationMap = new Map(violationStats.map((v) => [v.rule, v]));
340
- const overrideMap = new Map(overrideStats.map((o) => [o.rule, o]));
341
- for (const hook of allHooks) {
342
- const existing = hookMap.get(hook.id);
343
- const projViolations = violationMap.get(hook.id)?.count ?? 0;
344
- const projOverrides = overrideMap.get(hook.id)?.count ?? 0;
345
- const projLastTriggered = violationMap.get(hook.id)?.last_seen ?? null;
346
- if (existing) {
347
- // Sum stats across projects
348
- existing.stats.violations += projViolations;
349
- existing.stats.overrides += projOverrides;
350
- if (projLastTriggered && (!existing.stats.last_triggered || projLastTriggered > existing.stats.last_triggered)) {
351
- existing.stats.last_triggered = projLastTriggered;
352
- }
353
- // Union edges
354
- const existingEdgeKeys = new Set(existing.edges.map((e) => `${e.from}->${e.to}`));
355
- for (const edge of hookEdgeMap.get(hook.id) ?? []) {
356
- if (!existingEdgeKeys.has(`${edge.from}->${edge.to}`)) {
357
- existing.edges.push(edge);
358
- }
359
- }
360
- }
361
- else {
362
- // First time seeing this hook — count it in summary
363
- if (hook.category === 'guard')
364
- summary.guards++;
365
- else if (hook.category === 'gate')
366
- summary.gates++;
367
- else if (hook.category === 'lifecycle')
368
- summary.lifecycle++;
369
- else if (hook.category === 'observer')
370
- summary.observers++;
371
- hookMap.set(hook.id, {
372
- hook,
373
- enforcement: getHookEnforcement(hook),
374
- edges: hookEdgeMap.get(hook.id) ?? [],
375
- stats: {
376
- violations: projViolations,
377
- overrides: projOverrides,
378
- last_triggered: projLastTriggered,
379
- },
380
- });
381
- }
382
- }
383
- }
384
- res.json({ summary, rules: [...hookMap.values()], totalEdges });
385
- }
386
- catch (err) {
387
- log.error('Enforcement rules failed', { error: String(err) });
388
- res.status(500).json({ error: 'Failed to aggregate enforcement rules' });
389
- }
390
- });
391
- app.get('/api/orbital/aggregate/events/violations/trend', (req, res) => {
392
- try {
393
- const days = Number(req.query.days) || 30;
394
- const merged = new Map();
395
- for (const [, ctx] of projectManager.getAllContexts()) {
396
- const trend = ctx.db.prepare(`SELECT date(timestamp) as day, JSON_EXTRACT(data, '$.rule') as rule, COUNT(*) as count
397
- FROM events WHERE type = 'VIOLATION' AND timestamp >= datetime('now', ? || ' days')
398
- GROUP BY day, rule ORDER BY day ASC`).all(`-${days}`);
399
- for (const t of trend) {
400
- const key = `${t.day}:${t.rule}`;
401
- const existing = merged.get(key);
402
- if (existing) {
403
- existing.count += t.count;
404
- }
405
- else {
406
- merged.set(key, { ...t });
407
- }
408
- }
409
- }
410
- const result = [...merged.values()].sort((a, b) => a.day.localeCompare(b.day));
411
- res.json(result);
412
- }
413
- catch (err) {
414
- log.error('Violation trends failed', { error: String(err) });
415
- res.status(500).json({ error: 'Failed to aggregate violation trends' });
416
- }
417
- });
418
- app.get('/api/orbital/aggregate/gates', (req, res) => {
419
- try {
420
- const scopeId = req.query.scope_id;
421
- const filterProjectId = req.query.project_id;
422
- const mergedGates = new Map();
423
- for (const [projectId, ctx] of projectManager.getAllContexts()) {
424
- if (filterProjectId && projectId !== filterProjectId)
425
- continue;
426
- const gates = scopeId
427
- ? ctx.gateService.getLatestForScope(Number(scopeId))
428
- : ctx.gateService.getLatestRun();
429
- for (const gate of gates) {
430
- const existing = mergedGates.get(gate.gate_name);
431
- if (!existing || gate.run_at > existing.run_at) {
432
- mergedGates.set(gate.gate_name, { ...gate, project_id: projectId });
433
- }
434
- }
435
- }
436
- res.json([...mergedGates.values()]);
437
- }
438
- catch (err) {
439
- log.error('Gates aggregation failed', { error: String(err) });
440
- res.status(500).json({ error: 'Failed to aggregate gates' });
441
- }
442
- });
443
- app.get('/api/orbital/aggregate/gates/stats', (_req, res) => {
444
- try {
445
- const merged = new Map();
446
- for (const [, ctx] of projectManager.getAllContexts()) {
447
- const stats = ctx.gateService.getStats();
448
- for (const s of stats) {
449
- const existing = merged.get(s.gate_name);
450
- if (existing) {
451
- existing.total += s.total;
452
- existing.passed += s.passed;
453
- existing.failed += s.failed;
454
- }
455
- else {
456
- merged.set(s.gate_name, { ...s });
457
- }
458
- }
459
- }
460
- res.json([...merged.values()]);
461
- }
462
- catch (err) {
463
- log.error('Gate stats failed', { error: String(err) });
464
- res.status(500).json({ error: 'Failed to aggregate gate stats' });
465
- }
466
- });
467
- // ─── Aggregate: Git & GitHub ───────────────────────────────
468
- app.get('/api/orbital/aggregate/git/overview', async (_req, res) => {
469
- try {
470
- const projects = projectManager.getProjectList();
471
- const results = await Promise.allSettled(projects.filter(p => p.enabled && p.status === 'active').map(async (proj) => {
472
- const ctx = projectManager.getContext(proj.id);
473
- if (!ctx)
474
- throw new Error('Project offline');
475
- const config = ctx.workflowEngine.getConfig();
476
- const overview = await ctx.gitService.getOverview(config.branchingMode ?? 'trunk');
477
- return {
478
- projectId: proj.id,
479
- projectName: proj.name,
480
- projectColor: proj.color,
481
- status: 'ok',
482
- overview,
483
- };
484
- }));
485
- const overviews = results.map((r, i) => {
486
- if (r.status === 'fulfilled')
487
- return r.value;
488
- const proj = projects.filter(p => p.enabled && p.status === 'active')[i];
489
- return {
490
- projectId: proj.id,
491
- projectName: proj.name,
492
- projectColor: proj.color,
493
- status: 'error',
494
- error: String(r.reason),
495
- };
496
- });
497
- res.json(overviews);
498
- }
499
- catch (err) {
500
- log.error('Git overviews failed', { error: String(err) });
501
- res.status(500).json({ error: 'Failed to aggregate git overviews' });
502
- }
503
- });
504
- app.get('/api/orbital/aggregate/git/commits', async (req, res) => {
505
- try {
506
- const limit = Number(req.query.limit) || 50;
507
- const projects = projectManager.getProjectList().filter(p => p.enabled && p.status === 'active');
508
- const results = await Promise.allSettled(projects.map(async (proj) => {
509
- const ctx = projectManager.getContext(proj.id);
510
- if (!ctx)
511
- return [];
512
- const commits = await ctx.gitService.getCommits({ limit });
513
- return commits.map(c => ({
514
- ...c,
515
- project_id: proj.id,
516
- projectName: proj.name,
517
- projectColor: proj.color,
518
- }));
519
- }));
520
- const allCommits = [];
521
- for (const r of results) {
522
- if (r.status === 'fulfilled')
523
- allCommits.push(...r.value);
524
- }
525
- allCommits.sort((a, b) => String(b.date).localeCompare(String(a.date)));
526
- res.json(allCommits.slice(0, limit));
527
- }
528
- catch (err) {
529
- log.error('Commits aggregation failed', { error: String(err) });
530
- res.status(500).json({ error: 'Failed to aggregate commits' });
531
- }
532
- });
533
- app.get('/api/orbital/aggregate/github/prs', async (_req, res) => {
534
- try {
535
- const projects = projectManager.getProjectList().filter(p => p.enabled && p.status === 'active');
536
- const results = await Promise.allSettled(projects.map(async (proj) => {
537
- const ctx = projectManager.getContext(proj.id);
538
- if (!ctx)
539
- return [];
540
- const prs = await ctx.githubService.getOpenPRs();
541
- return prs.map(pr => ({
542
- ...pr,
543
- project_id: proj.id,
544
- projectName: proj.name,
545
- projectColor: proj.color,
546
- }));
547
- }));
548
- const allPrs = [];
549
- for (const r of results) {
550
- if (r.status === 'fulfilled')
551
- allPrs.push(...r.value);
552
- }
553
- allPrs.sort((a, b) => String(b.createdAt).localeCompare(String(a.createdAt)));
554
- res.json(allPrs);
555
- }
556
- catch (err) {
557
- log.error('PRs aggregation failed', { error: String(err) });
558
- res.status(500).json({ error: 'Failed to aggregate PRs' });
559
- }
560
- });
561
- app.get('/api/orbital/aggregate/git/health', async (_req, res) => {
562
- try {
563
- const projects = projectManager.getProjectList().filter(p => p.enabled && p.status === 'active');
564
- const results = await Promise.allSettled(projects.map(async (proj) => {
565
- const ctx = projectManager.getContext(proj.id);
566
- if (!ctx)
567
- throw new Error('offline');
568
- const branches = await ctx.gitService.getBranches();
569
- const config = ctx.workflowEngine.getConfig();
570
- const listsWithBranch = config.lists.filter(l => l.gitBranch).sort((a, b) => a.order - b.order);
571
- const driftPairs = [];
572
- for (let i = 0; i < listsWithBranch.length - 1; i++) {
573
- driftPairs.push({ from: listsWithBranch[i].gitBranch, to: listsWithBranch[i + 1].gitBranch });
574
- }
575
- const drift = driftPairs.length > 0 ? await ctx.gitService.getDrift(driftPairs) : [];
576
- const maxDrift = Math.max(0, ...drift.map(d => d.count));
577
- const staleBranches = branches.filter(b => b.isStale && !b.isRemote);
578
- return {
579
- projectId: proj.id,
580
- projectName: proj.name,
581
- projectColor: proj.color,
582
- branchCount: branches.filter(b => !b.isRemote).length,
583
- staleBranchCount: staleBranches.length,
584
- featureBranchCount: branches.filter(b => !b.isRemote && /(?:feat|fix|scope)[/-]/.test(b.name)).length,
585
- maxDriftSeverity: maxDrift === 0 ? 'clean' : maxDrift <= 5 ? 'low' : maxDrift <= 20 ? 'moderate' : 'high',
586
- };
587
- }));
588
- const health = [];
589
- for (const r of results) {
590
- if (r.status === 'fulfilled')
591
- health.push(r.value);
592
- }
593
- res.json(health);
594
- }
595
- catch (err) {
596
- log.error('Branch health failed', { error: String(err) });
597
- res.status(500).json({ error: 'Failed to aggregate branch health' });
598
- }
599
- });
600
- app.get('/api/orbital/aggregate/git/activity', async (req, res) => {
601
- try {
602
- const days = Number(req.query.days) || 30;
603
- const projects = projectManager.getProjectList().filter(p => p.enabled && p.status === 'active');
604
- const results = await Promise.allSettled(projects.map(async (proj) => {
605
- const ctx = projectManager.getContext(proj.id);
606
- if (!ctx)
607
- return { projectId: proj.id, series: [] };
608
- const series = await ctx.gitService.getActivitySeries(days);
609
- return { projectId: proj.id, projectName: proj.name, projectColor: proj.color, series };
610
- }));
611
- const activity = [];
612
- for (const r of results) {
613
- if (r.status === 'fulfilled')
614
- activity.push(r.value);
615
- }
616
- res.json(activity);
617
- }
618
- catch (err) {
619
- log.error('Activity aggregation failed', { error: String(err) });
620
- res.status(500).json({ error: 'Failed to aggregate activity' });
621
- }
622
- });
623
- app.get('/api/orbital/aggregate/scopes/:id/readiness', (req, res) => {
624
- const scopeId = Number(req.params.id);
625
- const projectId = req.query.project_id;
626
- for (const [pid, ctx] of projectManager.getAllContexts()) {
627
- if (projectId && pid !== projectId)
628
- continue;
629
- const scope = ctx.scopeService.getById(scopeId);
630
- if (scope) {
631
- const readiness = ctx.readinessService.getReadiness(scopeId);
632
- if (readiness) {
633
- res.json(readiness);
634
- return;
635
- }
636
- }
637
- }
638
- res.status(404).json({ error: 'Scope not found in any project' });
639
- });
640
- app.get('/api/orbital/aggregate/dispatch/active-scopes', (_req, res) => {
641
- const allActive = [];
642
- const seenActive = new Set();
643
- const allAbandoned = [];
644
- const seenAbandoned = new Set();
645
- for (const [projectId, ctx] of projectManager.getAllContexts()) {
646
- const activeIds = getActiveScopeIds(ctx.db, ctx.scopeService, ctx.workflowEngine);
647
- for (const id of activeIds) {
648
- const key = `${projectId}::${id}`;
649
- if (!seenActive.has(key)) {
650
- seenActive.add(key);
651
- allActive.push({ scope_id: id, project_id: projectId });
652
- }
653
- }
654
- const abandoned = getAbandonedScopeIds(ctx.db, ctx.scopeService, ctx.workflowEngine, activeIds);
655
- for (const entry of abandoned) {
656
- const key = `${projectId}::${entry.scope_id}`;
657
- if (!seenAbandoned.has(key)) {
658
- seenAbandoned.add(key);
659
- allAbandoned.push({ ...entry, project_id: projectId });
660
- }
661
- }
662
- }
663
- res.json({ scope_ids: allActive, abandoned_scopes: allAbandoned });
664
- });
665
- app.get('/api/orbital/aggregate/dispatch/active', (req, res) => {
666
- const scopeId = Number(req.query.scope_id);
667
- if (isNaN(scopeId) || scopeId <= 0) {
668
- res.status(400).json({ error: 'Valid scope_id query param required' });
669
- return;
670
- }
671
- for (const [, ctx] of projectManager.getAllContexts()) {
672
- const scope = ctx.scopeService.getById(scopeId);
673
- if (!scope)
674
- continue;
675
- const active = ctx.db.prepare(`SELECT id, timestamp, JSON_EXTRACT(data, '$.command') as command
676
- FROM events
677
- WHERE type = 'DISPATCH' AND scope_id = ? AND JSON_EXTRACT(data, '$.resolved') IS NULL
678
- ORDER BY timestamp DESC LIMIT 1`).get(scopeId);
679
- res.json({ active: active ?? null });
680
- return;
681
- }
682
- res.json({ active: null });
683
- });
684
- // ─── Aggregate: Manifest Health ────────────────────────────
685
- app.get('/api/orbital/aggregate/manifest/status', (_req, res) => {
686
- try {
687
- const projects = projectManager.getProjectList().filter(p => p.enabled);
688
- const pkgVersion = getPackageVersion();
689
- const projectOverviews = projects.map((proj) => {
690
- const ctx = projectManager.getContext(proj.id);
691
- if (!ctx) {
692
- return {
693
- projectId: proj.id,
694
- projectName: proj.name,
695
- projectColor: proj.color,
696
- status: 'error',
697
- manifest: null,
698
- error: 'Project offline',
699
- };
700
- }
701
- try {
702
- const manifest = loadManifest(ctx.config.projectRoot);
703
- if (!manifest) {
704
- return {
705
- projectId: proj.id,
706
- projectName: proj.name,
707
- projectColor: proj.color,
708
- status: 'no-manifest',
709
- manifest: null,
710
- };
711
- }
712
- const claudeDir = path.join(ctx.config.projectRoot, '.claude');
713
- refreshFileStatuses(manifest, claudeDir);
714
- const summary = summarizeManifest(manifest);
715
- return {
716
- projectId: proj.id,
717
- projectName: proj.name,
718
- projectColor: proj.color,
719
- status: 'ok',
720
- manifest: {
721
- exists: true,
722
- packageVersion: pkgVersion,
723
- installedVersion: manifest.packageVersion,
724
- needsUpdate: manifest.packageVersion !== pkgVersion,
725
- preset: manifest.preset,
726
- files: summary,
727
- lastUpdated: manifest.updatedAt,
728
- },
729
- };
730
- }
731
- catch (err) {
732
- return {
733
- projectId: proj.id,
734
- projectName: proj.name,
735
- projectColor: proj.color,
736
- status: 'error',
737
- manifest: null,
738
- error: String(err),
739
- };
740
- }
741
- });
742
- const projectsUpToDate = projectOverviews.filter(p => p.status === 'ok' && !p.manifest?.needsUpdate).length;
743
- const projectsOutdated = projectOverviews.filter(p => p.status === 'ok' && p.manifest?.needsUpdate).length;
744
- const noManifest = projectOverviews.filter(p => p.status === 'no-manifest').length;
745
- const totalOutdated = projectOverviews.reduce((sum, p) => sum + (p.manifest?.files.outdated ?? 0), 0);
746
- const totalModified = projectOverviews.reduce((sum, p) => sum + (p.manifest?.files.modified ?? 0), 0);
747
- const totalPinned = projectOverviews.reduce((sum, p) => sum + (p.manifest?.files.pinned ?? 0), 0);
748
- const totalMissing = projectOverviews.reduce((sum, p) => sum + (p.manifest?.files.missing ?? 0), 0);
749
- const totalSynced = projectOverviews.reduce((sum, p) => sum + (p.manifest?.files.synced ?? 0), 0);
750
- const totalUserOwned = projectOverviews.reduce((sum, p) => sum + (p.manifest?.files.userOwned ?? 0), 0);
751
- res.json({
752
- total: projects.length,
753
- projectsUpToDate,
754
- projectsOutdated,
755
- noManifest,
756
- totalOutdated,
757
- totalModified,
758
- totalPinned,
759
- totalMissing,
760
- totalSynced,
761
- totalUserOwned,
762
- projects: projectOverviews,
763
- });
764
- }
765
- catch (err) {
766
- log.error('Manifest status failed', { error: String(err) });
767
- res.status(500).json({ error: 'Failed to aggregate manifest status' });
768
- }
769
- });
770
- app.post('/api/orbital/aggregate/manifest/update-all', (_req, res) => {
771
- try {
772
- const projects = projectManager.getProjectList().filter(p => p.enabled);
773
- const pkgVersion = getPackageVersion();
774
- const results = [];
775
- for (const proj of projects) {
776
- const ctx = projectManager.getContext(proj.id);
777
- if (!ctx) {
778
- results.push({ projectId: proj.id, success: false, error: 'Project offline' });
779
- continue;
780
- }
781
- const manifest = loadManifest(ctx.config.projectRoot);
782
- if (!manifest)
783
- continue; // uninitialized — skip
784
- // Refresh statuses and check if there's anything to update
785
- const claudeDir = path.join(ctx.config.projectRoot, '.claude');
786
- refreshFileStatuses(manifest, claudeDir);
787
- const manifestSummary = summarizeManifest(manifest);
788
- if (manifest.packageVersion === pkgVersion && manifestSummary.outdated === 0 && manifestSummary.missing === 0) {
789
- continue; // fully up to date
790
- }
791
- try {
792
- runUpdate(ctx.config.projectRoot, { dryRun: false });
793
- ctx.emitter.emit('manifest:changed', { action: 'updated' });
794
- results.push({ projectId: proj.id, success: true });
795
- }
796
- catch (err) {
797
- results.push({ projectId: proj.id, success: false, error: String(err) });
798
- }
799
- }
800
- res.json({ success: true, results });
801
- }
802
- catch (err) {
803
- log.error('Update all projects failed', { error: String(err) });
804
- res.status(500).json({ error: 'Failed to update all projects' });
805
- }
806
- });
807
- // ─── Aggregate: Config Primitives (Global) ────────────────
808
- // In aggregate mode, config reads/writes target ~/.orbital/primitives/
809
- // Writes propagate to all synced (non-overridden) projects via SyncService.
810
- const globalConfigService = new ConfigService(GLOBAL_PRIMITIVES_DIR);
811
- app.get('/api/orbital/aggregate/config/:type/tree', (req, res) => {
812
- const type = req.params.type;
813
- if (!isValidPrimitiveType(type)) {
814
- res.status(400).json({ success: false, error: `Invalid type "${type}". Must be one of: agents, skills, hooks` });
815
- return;
816
- }
817
- try {
818
- const basePath = path.join(GLOBAL_PRIMITIVES_DIR, type);
819
- const tree = globalConfigService.scanDirectory(basePath);
820
- res.json({ success: true, data: tree });
821
- }
822
- catch (err) {
823
- log.error('Config tree read failed', { type, error: String(err) });
824
- res.status(500).json({ success: false, error: 'Failed to read global config tree' });
825
- }
826
- });
827
- app.get('/api/orbital/aggregate/config/:type/file', (req, res) => {
828
- const type = req.params.type;
829
- if (!isValidPrimitiveType(type)) {
830
- res.status(400).json({ success: false, error: `Invalid type "${type}". Must be one of: agents, skills, hooks` });
831
- return;
832
- }
833
- const filePath = req.query.path;
834
- if (!filePath) {
835
- res.status(400).json({ success: false, error: 'path query parameter is required' });
836
- return;
837
- }
838
- try {
839
- const basePath = path.join(GLOBAL_PRIMITIVES_DIR, type);
840
- const content = globalConfigService.readFile(basePath, filePath);
841
- res.json({ success: true, data: { path: filePath, content } });
842
- }
843
- catch (err) {
844
- const msg = err instanceof Error ? err.message : String(err);
845
- const status = msg.includes('traversal') ? 403 : msg.includes('ENOENT') || msg.includes('not found') ? 404 : 500;
846
- res.status(status).json({ success: false, error: msg });
847
- }
848
- });
849
- app.put('/api/orbital/aggregate/config/:type/file', (req, res) => {
850
- const type = req.params.type;
851
- if (!isValidPrimitiveType(type)) {
852
- res.status(400).json({ success: false, error: `Invalid type "${type}". Must be one of: agents, skills, hooks` });
853
- return;
854
- }
855
- const { path: filePath, content } = req.body;
856
- if (!filePath || content === undefined) {
857
- res.status(400).json({ success: false, error: 'path and content are required' });
858
- return;
859
- }
860
- try {
861
- const basePath = path.join(GLOBAL_PRIMITIVES_DIR, type);
862
- globalConfigService.writeFile(basePath, filePath, content);
863
- // Propagate to all synced projects
864
- const relativePath = path.join(type, filePath);
865
- const result = syncService.propagateGlobalChange(relativePath);
866
- io.emit(`config:${type}:changed`, { action: 'updated', path: filePath, global: true });
867
- res.json({ success: true, propagation: result });
868
- }
869
- catch (err) {
870
- const msg = err instanceof Error ? err.message : String(err);
871
- const status = msg.includes('traversal') ? 403 : msg.includes('not found') ? 404 : 500;
872
- res.status(status).json({ success: false, error: msg });
873
- }
874
- });
103
+ // Aggregate endpoints (cross-project)
104
+ app.use('/api/orbital', createAggregateRoutes({ projectManager, io, syncService }));
875
105
  // ─── Static File Serving ─────────────────────────────────
876
106
  const __selfDir = path.dirname(fileURLToPath(import.meta.url));
877
107
  const distDir = path.resolve(__selfDir, '../dist');
@@ -920,25 +150,7 @@ export async function startCentralServer(overrides) {
920
150
  res.status(500).json({ ok: false, error: 'Internal server error' });
921
151
  }
922
152
  });
923
- // ─── Start Listening ─────────────────────────────────────
924
- const actualPort = await new Promise((resolve, reject) => {
925
- let attempt = 0;
926
- const maxAttempts = 10;
927
- httpServer.on('error', (err) => {
928
- if (err.code === 'EADDRINUSE' && attempt < maxAttempts) {
929
- attempt++;
930
- httpServer.listen(port + attempt);
931
- }
932
- else {
933
- reject(new Error(`Failed to start server: ${err.message}`));
934
- }
935
- });
936
- httpServer.on('listening', () => {
937
- const addr = httpServer.address();
938
- resolve(typeof addr === 'object' && addr ? addr.port : port);
939
- });
940
- httpServer.listen(port);
941
- });
153
+ // ─── Startup Banner ──────────────────────────────────────
942
154
  const projectList = projectManager.getProjectList();
943
155
  const projectLines = projectList.map(p => `║ ${p.status === 'active' ? '●' : '○'} ${p.name.padEnd(20)} ${String(p.scopeCount).padStart(3)} scopes ${p.status.padEnd(8)} ║`).join('\n');
944
156
  const dashboardPort = devMode ? clientPort : actualPort;