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
@@ -0,0 +1,94 @@
1
+ # Deep Dive Codebase Audit
2
+
3
+ **When to use:** Pre-launch reviews, major refactoring, tech debt assessment, periodic health checks.
4
+
5
+ **Session setup:** Start in plan mode (`/plan`), set effort to max (`/effort max`).
6
+
7
+ ---
8
+
9
+ ## The Prompt
10
+
11
+ ```
12
+ Conduct a deep, thorough audit of our codebase. This is a [pre-launch review / periodic health check / tech debt assessment] and we will implement all confirmed findings — not just analyze them.
13
+
14
+ SCOPE AND EXPECTATIONS:
15
+
16
+ - Leave no file untouched. We value thoroughness and 100% coverage over speed.
17
+ - Take as long as you need. Slow down. Resist the urge to start editing before you've finished reading.
18
+ - Use resources freely — launch parallel exploration agents, analysis agents, and implementation agents. Do not optimize for token cost; optimize for coverage and correctness.
19
+ - Every change must be independently verified before we consider it done. Build verification into your plan, not as an afterthought.
20
+
21
+ DELIVERABLES:
22
+
23
+ 1. Build a complete inventory of every section, service, and function. Track progress in the plan file.
24
+ 2. Create a brief summary of each — how they work and how they're architected.
25
+ 3. Conduct deep analysis: identify duplication, structural issues, dead code, and simplification opportunities. Quantify everything — "15 hooks duplicate this pattern" not "some hooks are duplicated."
26
+ 4. Produce a tiered recommendation plan: Tier 1 (high impact, low risk), Tier 2 (high impact, moderate effort), Tier 3 (discuss first), and explicitly state what you considered but don't recommend.
27
+ 5. After implementation, produce a before/after metrics table and a verification report with pass/fail counts.
28
+
29
+ WORKFLOW:
30
+
31
+ - Do NOT write any code until the plan is reviewed and confirmed together. The plan is a separate deliverable from the implementation.
32
+ - During exploration (plan mode): use subagents for parallel coverage. Create lists that track progress.
33
+ - During implementation (after plan approval): execute one tier at a time. Typecheck and test after every individual change. Use parallel agents only for independent file sets.
34
+ - After implementation: launch independent verification agents to prove each work item is correct. Run the full validation pipeline. Do UI testing if frontend was modified.
35
+
36
+ [ADDITIONAL CONTEXT: describe any specific concerns, recent feature work, or areas you suspect need attention]
37
+ ```
38
+
39
+ ---
40
+
41
+ ## Why Each Section Exists
42
+
43
+ ### "Leave no file untouched" + "take as long as you need"
44
+ Overrides the default pressure to be fast and concise. Without this, the agent samples a few files and pattern-matches. With it, the agent inventories everything, which is what finds unexpected results like "zero dead code."
45
+
46
+ ### "Do not optimize for token cost"
47
+ Explicitly permits launching 3+ parallel agents per phase. Without this, the agent tries to do everything sequentially in one context window, which caps the achievable scope.
48
+
49
+ ### "Every change must be independently verified"
50
+ Knowing verification is coming makes the agent more careful during implementation. This instruction must be in the initial prompt, not added after implementation is done.
51
+
52
+ ### "Do NOT write any code until the plan is reviewed"
53
+ Forces the audit-then-plan-then-execute structure. Prevents the failure mode where the agent starts editing during exploration and introduces bugs while still forming its understanding.
54
+
55
+ ### "Quantify everything"
56
+ Prevents vague findings. "Some duplication" is not actionable. "15 hooks with identical fetch boilerplate across 500 lines" is actionable and lets you evaluate ROI.
57
+
58
+ ### "Explicitly state what you don't recommend"
59
+ Shows the agent considered and rejected options rather than missing them. The "Not recommended" section in a plan is often the most valuable — it prevents future sessions from re-investigating the same ideas.
60
+
61
+ ### Deliverable 5 (before/after + verification)
62
+ Defines what "done" looks like. Without this, the session ends with "I think everything is good" instead of "23/23 test files, 374/374 tests, 279 verification checks."
63
+
64
+ ---
65
+
66
+ ## Variations
67
+
68
+ ### Analysis Only (No Implementation)
69
+ Remove the "we will implement all confirmed findings" line and deliverable 5. Change the workflow section to end at plan delivery.
70
+
71
+ ### Targeted Audit (Specific Area)
72
+ Add to additional context:
73
+ ```
74
+ Focus on [server/hooks/frontend components]. The rest of the codebase is out of scope for this session.
75
+ ```
76
+
77
+ ### Post-Incident Review
78
+ Replace the scope section with:
79
+ ```
80
+ We just had [describe incident]. Audit the codebase for similar patterns that could cause the same class of problem. Don't fix unrelated issues — stay focused on this failure mode.
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Origin
86
+
87
+ Developed during the v0.3 pre-launch refactoring session (2026-04-10). That session achieved:
88
+ - 10 files decomposed (avg 832 → 291 lines, 65% reduction)
89
+ - 5 shared abstractions created (useFetch, useSocketListener, workflow-constants, json-fields, catchRoute)
90
+ - 40 new tests added
91
+ - 279 manual verification checks, all passing
92
+ - 23/23 UI checks across 4 views, zero console errors
93
+
94
+ The prompt structure — explicit permission to slow down, free resource usage, mandatory verification, plan-before-code discipline — was identified as the primary driver of the session's quality.
@@ -52,14 +52,14 @@ grep -rE "console\.(log|error|warn|info)" src --include="*.ts" --include="*.tsx"
52
52
 
53
53
  ### Rule 3: File Size Limit (400 lines)
54
54
 
55
- **Rule**: Production files must be < 400 lines, tests < 800 lines
56
- **Why**: Maintainability, cognitive load
55
+ **Rule**: Production files must be < 400 lines, tests < 800 lines. Applies to `src/`, `server/`, and `bin/`.
56
+ **Why**: The v0.3 refactor found 10 files over 500 lines. Large files mix concerns, resist review, and accumulate tech debt silently. The cleanup took a full session to unwind.
57
57
  **Verify**:
58
58
  ```bash
59
- find src -name "*.ts" -o -name "*.tsx" | xargs wc -l | awk '$1 > 400' | grep -v __tests__
59
+ find src server -name "*.ts" -o -name "*.tsx" | xargs wc -l | sort -rn | awk '$1 > 400 && !/test|__fixtures__/' | head -20
60
60
  ```
61
- **Expected**: No output
62
- **Fix**: Split into focused modules
61
+ **Expected**: No output (or only justified exceptions like types/index.ts, aggregate-routes.ts)
62
+ **Fix**: Extract sub-components, split into focused modules, move types to companion files
63
63
 
64
64
  ---
65
65
 
@@ -202,6 +202,57 @@ it('should return user by ID', async () => {
202
202
 
203
203
  ---
204
204
 
205
+ ## Duplication Prevention Rules
206
+
207
+ ### Rule 13: Single Source of Truth for Constants
208
+
209
+ **Rule**: Color maps, config objects, icon maps, and display constants must be defined once and imported everywhere. Never define inline.
210
+ **Why**: The v0.3 audit found ENFORCEMENT_COLORS defined 3x, CATEGORY_CONFIG 4x, and CATEGORY_HEX 2x across the codebase. Each copy drifted slightly (singular vs plural labels, different lifecycle colors).
211
+ **Verify**:
212
+ ```bash
213
+ grep -rn "const.*COLORS.*Record\|const.*CONFIG.*Record.*icon\|const.*HEX.*Record" src/components src/views --include="*.tsx" --include="*.ts" | grep -v "import "
214
+ ```
215
+ **Expected**: No output — all constants come from `src/lib/workflow-constants.ts` or similar shared modules
216
+ **Fix**: Move to `src/lib/workflow-constants.ts` and import
217
+
218
+ ---
219
+
220
+ ### Rule 14: Use Shared Hook Primitives
221
+
222
+ **Rule**: Data-fetching hooks must use `useFetch()`. Socket listeners must use `useSocketListener()`. Never duplicate the fetch lifecycle or socket.on/off pattern manually.
223
+ **Why**: The v0.3 audit found 15+ hooks with identical fetch boilerplate (useState triple, AbortController, useReconnect) and 86 manual socket.on/off calls. This was ~500 lines of pure duplication.
224
+ **Verify**:
225
+ ```bash
226
+ # Check no hook manually manages AbortController (should be in useFetch)
227
+ grep -rn "new AbortController" src/hooks --include="*.ts" | grep -v useFetch | grep -v test
228
+ ```
229
+ **Expected**: No output (only useFetch.ts should create AbortControllers)
230
+ **Fix**: Use `useFetch(fetchFn)` for data fetching, `useSocketListener(event, handler, deps)` for socket events
231
+
232
+ ---
233
+
234
+ ### Rule 15: Use catchRoute for Express Handlers
235
+
236
+ **Rule**: Route handlers that can throw must use `catchRoute()` from `server/utils/route-helpers.ts` instead of inline try-catch.
237
+ **Why**: The v0.3 audit found identical try-catch + errMsg + status-inference blocks in 7+ route handlers. The pattern is mechanical and should be centralized.
238
+ **Verify**:
239
+ ```bash
240
+ grep -rn "try {" server/routes --include="*.ts" | grep -v test | grep -v node_modules
241
+ ```
242
+ **Expected**: Minimal matches — most routes should use catchRoute
243
+ **Fix**: Wrap handler with `catchRoute(fn)` or `catchRoute(fn, inferErrorStatus)`
244
+
245
+ ---
246
+
247
+ ### Rule 16: No Inline Utility Functions in Large Files
248
+
249
+ **Rule**: Pure functions (parsers, formatters, validators) that don't close over component/hook state must live in companion `*-utils.ts` files, not inline in the consuming file.
250
+ **Why**: The v0.3 audit found `parseJsonFields` copied verbatim between two files, and `parseDragId` + `checkActiveDispatch` buried inside a 490-line hook. Extracting them enabled testing and reuse.
251
+ **Verify**: Manual review — if a function doesn't reference `useState`, `useCallback`, or local state, it belongs in a utils file
252
+ **Fix**: Extract to a companion file (e.g., `useKanbanDnd.ts` → `kanban-dnd-utils.ts`)
253
+
254
+ ---
255
+
205
256
  ## Quick Verification Checklist
206
257
 
207
258
  Run before every commit:
@@ -20,7 +20,8 @@ BRANCHING_MODE=$(grep '^WORKFLOW_BRANCHING_MODE=' .claude/config/workflow-manife
20
20
  ### Step 0b: Record Session ID
21
21
 
22
22
  1. Run: `bash .claude/hooks/get-session-id.sh`
23
- 2. For each scope in `scopes/review/` with a passing verdict:
23
+ 2. For each scope in `scopes/review/` with a passing verdict
24
+ (if BATCH_SCOPE_IDS is set, only record on those specific scopes):
24
25
  - Append session UUID to `sessions.commit` in frontmatter
25
26
 
26
27
  ### Step 1: Check Branch
@@ -39,6 +40,9 @@ Find scopes in `scopes/review/` that have a passing verdict:
39
40
 
40
41
  1. List files in `scopes/review/*.md`
41
42
  2. For each, extract the scope number and check `.claude/review-verdicts/{NNN}.json`
43
+
44
+ If BATCH_SCOPE_IDS is set, only process those specific scopes (skip any not in the list).
45
+
42
46
  3. If verdict exists and `verdict === "PASS"`:
43
47
  - Transition: `bash .claude/hooks/scope-transition.sh --from review --to completed --scope {NNN}`
44
48
  - Update DASHBOARD: `📦 **Status**: Committed`
@@ -49,25 +53,36 @@ Find scopes in `scopes/review/` that have a passing verdict:
49
53
 
50
54
  ### Step 3: Commit
51
55
 
56
+ **Determine which files to stage** — scope-aware, not a blanket `git add .`:
57
+
58
+ 1. For each scope being committed (from Step 2), read its **Files Summary** table from the scope document (`scopes/review/{NNN}*.md` or `scopes/completed/{NNN}*.md`)
59
+ 2. Also check `.claude/review-findings/{NNN}.json` — each finding has a `file` field listing reviewed files
60
+ 3. Cross-reference against `git status` — only stage files that appear in the scope's Files Summary or review findings
61
+ 4. If files exist in `git status` that don't belong to any scope being committed, leave them unstaged
62
+
52
63
  ```bash
53
- git add <specific code files scopes are gitignored>
64
+ git add <files from scope Files Summary + review findings>
54
65
  git commit -m "type(scope): description"
55
66
  ```
56
67
 
57
- - Stage only code files (scopes/ is gitignored, no need to worry about them)
68
+ - Stage only scope-owned code files (scopes/ is gitignored, no need to worry about them)
69
+ - If multiple scopes are being committed (batch), include files from ALL scopes in the batch
58
70
  - Follow conventional commit format
59
71
  - Do NOT push or create PRs — those are separate skills
60
72
 
61
73
  ### Step 4: Signal Completion (REQUIRED)
62
74
 
63
- **Always emit after a successful commit** — this is not optional:
75
+ **Always emit when finished** — this is not optional. Emit success or failure so the dispatch resolves immediately:
64
76
 
65
77
  ```bash
66
- # With a scope:
78
+ # On success — with a scope:
67
79
  bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"success","action":"save"}' --scope "{NNN}"
68
80
 
69
- # Without a scope (general commit):
81
+ # On success — without a scope (general commit):
70
82
  bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"success","action":"save"}'
83
+
84
+ # On failure (commit failed, no files to stage, etc.):
85
+ bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"failure","action":"save"}' --scope "{NNN}"
71
86
  ```
72
87
 
73
88
  The `--scope` flag is optional. Omit it when committing work that isn't tied to a specific scope.
@@ -19,7 +19,8 @@ Direct merge from feature branch into dev. The review gate already provides the
19
19
  ### Step 0: Record Session ID
20
20
 
21
21
  1. Run: `bash .claude/hooks/get-session-id.sh`
22
- 2. For each scope in `scopes/completed/`:
22
+ 2. For each scope in `scopes/completed/`
23
+ (if BATCH_SCOPE_IDS is set, only record on those specific scopes):
23
24
  - Append session UUID to `sessions.prDev` in frontmatter
24
25
 
25
26
  ### Step 1: Verify Ready State
@@ -69,14 +70,17 @@ If merge conflicts occur, resolve them before continuing.
69
70
 
70
71
  ### Step 4: Signal Completion (REQUIRED)
71
72
 
72
- **Always emit after a successful merge** — this is not optional:
73
+ **Always emit when finished** — this is not optional. Emit success or failure so the dispatch resolves immediately:
73
74
 
74
75
  ```bash
75
- # With a scope:
76
+ # On success — with a scope:
76
77
  bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"success","action":"pr_dev"}' --scope "{NNN}"
77
78
 
78
- # Without a scope:
79
+ # On success — without a scope:
79
80
  bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"success","action":"pr_dev"}'
81
+
82
+ # On failure (merge conflicts, push rejected, etc.):
83
+ bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"failure","action":"pr_dev"}' --scope "{NNN}"
80
84
  ```
81
85
 
82
86
  ## Output
@@ -20,7 +20,8 @@ BRANCHING_MODE=$(grep '^WORKFLOW_BRANCHING_MODE=' .claude/config/workflow-manife
20
20
  ### Step 1: Record Session ID
21
21
 
22
22
  1. Run: `bash .claude/hooks/get-session-id.sh` — capture the UUID output
23
- 2. For each scope in `scopes/completed/`:
23
+ 2. For each scope in `scopes/completed/`
24
+ (if BATCH_SCOPE_IDS is set, only record on those specific scopes):
24
25
  - Append session UUID to `sessions.pushToMain` in frontmatter
25
26
 
26
27
  ### Step 2: Check Current Branch
@@ -65,14 +66,17 @@ bash .claude/hooks/scope-transition.sh --from completed --to main --scope NNN
65
66
 
66
67
  ### Step 5: Signal Completion (REQUIRED)
67
68
 
68
- **Always emit after a successful push/PR** — this is not optional:
69
+ **Always emit when finished** — this is not optional. Emit success or failure so the dispatch resolves immediately:
69
70
 
70
71
  ```bash
71
- # With a scope:
72
+ # On success — with a scope:
72
73
  bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"success","action":"pr_main"}' --scope "{NNN}"
73
74
 
74
- # Without a scope:
75
+ # On success — without a scope:
75
76
  bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"success","action":"pr_main"}'
77
+
78
+ # On failure (push rejected, PR failed, merge conflicts, etc.):
79
+ bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"failure","action":"pr_main"}' --scope "{NNN}"
76
80
  ```
77
81
 
78
82
  ## Batch Support
@@ -98,14 +98,17 @@ gh pr merge --merge
98
98
 
99
99
  ### Step 6: Signal Completion (REQUIRED)
100
100
 
101
- **Always emit after a successful merge** — this is not optional:
101
+ **Always emit when finished** — this is not optional. Emit success or failure so the dispatch resolves immediately:
102
102
 
103
103
  ```bash
104
- # With a scope:
104
+ # On success — with a scope:
105
105
  bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"success","action":"pr_production"}' --scope "{NNN}"
106
106
 
107
- # Without a scope:
107
+ # On success — without a scope:
108
108
  bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"success","action":"pr_production"}'
109
+
110
+ # On failure (PR failed, merge conflicts, health check failed, etc.):
111
+ bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"failure","action":"pr_production"}' --scope "{NNN}"
109
112
  ```
110
113
 
111
114
  ### Step 7: Verify Production
@@ -60,14 +60,17 @@ gh pr create --base staging --head dev \
60
60
 
61
61
  ### Step 4: Signal Completion (REQUIRED)
62
62
 
63
- **Always emit after a successful PR creation** — this is not optional:
63
+ **Always emit when finished** — this is not optional. Emit success or failure so the dispatch resolves immediately:
64
64
 
65
65
  ```bash
66
- # With a scope:
66
+ # On success — with a scope:
67
67
  bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"success","action":"pr_staging"}' --scope "{NNN}"
68
68
 
69
- # Without a scope:
69
+ # On success — without a scope:
70
70
  bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"success","action":"pr_staging"}'
71
+
72
+ # On failure (PR creation failed, push rejected, etc.):
73
+ bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"failure","action":"pr_staging"}' --scope "{NNN}"
71
74
  ```
72
75
 
73
76
  ### Step 5: Monitor CI
@@ -145,12 +145,16 @@ Agent(
145
145
  ╚═══════════════════════════════════════════════════════════════╝
146
146
  ```
147
147
 
148
- ### Step 8: Emit Completion Event
148
+ ### Step 8: Signal Completion (REQUIRED)
149
+
150
+ **Always emit when finished** — this is not optional. Emit success or failure so the dispatch resolves immediately:
149
151
 
150
152
  ```bash
151
- bash .claude/hooks/orbital-emit.sh REVIEW_FIXES_COMPLETED \
152
- '{"scope_id":"NNN","findings_total":YY,"findings_fixed":XX,"agents_used":N}' \
153
- --scope "NNN"
153
+ # On success:
154
+ bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"success","action":"fix_review","findings_total":YY,"findings_fixed":XX}' --scope "{NNN}"
155
+
156
+ # On failure (agents couldn't resolve, verification failed, etc.):
157
+ bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"failure","action":"fix_review","findings_total":YY,"findings_fixed":XX}' --scope "{NNN}"
154
158
  ```
155
159
 
156
160
  ## Important Rules
@@ -26,11 +26,15 @@ user-invocable: true
26
26
 
27
27
  ### 2. Implement
28
28
 
29
- **Before starting Phase 1**: Transition the scope and update the DASHBOARD to `🔄 **Status**: Implementing`:
29
+ **Before starting Phase 1**: Read the scope's frontmatter `status` field. If the scope is not already in `implementing`, transition it and update the DASHBOARD to `🔄 **Status**: Implementing`:
30
+
30
31
  ```bash
31
- bash .claude/hooks/scope-transition.sh --from backlog --to implementing --scope {NNN}
32
+ # Use the scope's CURRENT status as the source (backlog, planning, review, completed, etc.)
33
+ bash .claude/hooks/scope-transition.sh --from <current-status> --to implementing --scope {NNN}
32
34
  ```
33
35
 
36
+ If the scope is already `status: implementing` (resuming), skip the transition.
37
+
34
38
  For each phase:
35
39
 
36
40
  1. **Update DASHBOARD** — Mark phase as `🔄 In Progress`
@@ -92,12 +96,16 @@ After Step 3, the scope remains in `scopes/implementing/` with `status: implemen
92
96
 
93
97
  **Do NOT proceed to review in this session.** The review gate enforces session separation to ensure the implementing agent doesn't approve its own work.
94
98
 
95
- ### 4. Signal Completion
99
+ ### 4. Signal Completion (REQUIRED)
96
100
 
97
- Emit the agent completion event so the Orbital Command dashboard turns off the progress indicator:
101
+ **Always emit when finished** this is not optional. Emit success or failure so the dispatch resolves immediately:
98
102
 
99
103
  ```bash
100
- bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"success"}' --scope "{NNN}"
104
+ # On success:
105
+ bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"success","action":"implement"}' --scope "{NNN}"
106
+
107
+ # On failure (build errors, blocked, etc.):
108
+ bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"failure","action":"implement"}' --scope "{NNN}"
101
109
  ```
102
110
 
103
111
  ## Resuming After Compaction
@@ -86,7 +86,10 @@ Ensure the project has a test suite before running quality gates. This runs in a
86
86
  ║ tests. Fix manually and re-run: /scope-post-review NNN ║
87
87
  ╚═══════════════════════════════════════════════════════════════╝
88
88
  ```
89
- **STOP** — do not proceed to Phase 1 with broken tests.
89
+ Emit failure and **STOP** — do not proceed to Phase 1 with broken tests:
90
+ ```bash
91
+ bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"failure","action":"post_review","phase":0}' --scope "{NNN}"
92
+ ```
90
93
  - **If tests pass** → continue to Phase 1.
91
94
 
92
95
  ### Phase 1: Quality Gates (`/test-checks`)
@@ -102,7 +105,10 @@ Run the 13 quality gates. This is the cheapest and fastest check.
102
105
  ║ Fix the failing gates and re-run: /scope-post-review NNN ║
103
106
  ╚═══════════════════════════════════════════════════════════════╝
104
107
  ```
105
- **STOP** — do not proceed to Phase 2.
108
+ Emit failure and **STOP** — do not proceed to Phase 2:
109
+ ```bash
110
+ bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"failure","action":"post_review","phase":1}' --scope "{NNN}"
111
+ ```
106
112
  3. If all gates PASS → continue to Phase 2.
107
113
 
108
114
  ### Phase 2: Formal Verification (`/scope-verify NNN`)
@@ -118,7 +124,10 @@ Run the scope-specific formal review gate.
118
124
  ║ Fix the issues and re-run: /scope-post-review NNN ║
119
125
  ╚═══════════════════════════════════════════════════════════════╝
120
126
  ```
121
- **STOP** — do not proceed to Phase 3.
127
+ Emit failure and **STOP** — do not proceed to Phase 3:
128
+ ```bash
129
+ bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"failure","action":"post_review","phase":2}' --scope "{NNN}"
130
+ ```
122
131
  3. If verdict is PASS → continue to Phase 3.
123
132
 
124
133
  ### Phase 3: AI Code Review (`/test-code-review`)
@@ -150,7 +159,10 @@ Execute all Phase 3 findings using a coordinated agent team. **This phase requir
150
159
  ```
151
160
  Skill(skill: "test-checks")
152
161
  ```
153
- If any gate fails, report which gates regressed and **STOP**.
162
+ If any gate fails, report which gates regressed, emit failure and **STOP**:
163
+ ```bash
164
+ bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"failure","action":"post_review","phase":4}' --scope "{NNN}"
165
+ ```
154
166
  3. If **not enabled**:
155
167
  - Read `~/.claude/settings.json`
156
168
  - Merge `"env": { "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1" }` into the existing JSON (preserve all other settings)
@@ -196,12 +196,16 @@ After applying spec fixes and writing the AGENT REVIEW:
196
196
  - Update DASHBOARD Quick Status: `🟢 **Status**: Backlog | **Spec Locked**: Yes`
197
197
  - Add to Recent Activity: `Review completed — N blockers, M warnings. X items applied to spec, K clarifications resolved.`
198
198
 
199
- ### Step 9: Signal Completion
199
+ ### Step 9: Signal Completion (REQUIRED)
200
200
 
201
- Emit the agent completion event so the Orbital Command dashboard turns off the progress indicator:
201
+ **Always emit when finished** this is not optional. Emit success or failure so the dispatch resolves immediately:
202
202
 
203
203
  ```bash
204
+ # On success:
204
205
  bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"success","action":"team_review"}' --scope "{NNN}"
206
+
207
+ # On failure (agent launch failed, unrecoverable error, etc.):
208
+ bash .claude/hooks/orbital-emit.sh AGENT_COMPLETED '{"outcome":"failure","action":"team_review"}' --scope "{NNN}"
205
209
  ```
206
210
 
207
211
  ## Modes