jumpstart-mode 1.1.11 → 1.1.13

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 (188) hide show
  1. package/.github/agents/jumpstart-adversary.agent.md +2 -1
  2. package/.github/agents/jumpstart-architect.agent.md +6 -7
  3. package/.github/agents/jumpstart-challenger.agent.md +2 -1
  4. package/.github/agents/jumpstart-developer.agent.md +1 -1
  5. package/.github/agents/jumpstart-devops.agent.md +2 -2
  6. package/.github/agents/jumpstart-diagram-verifier.agent.md +2 -1
  7. package/.github/agents/jumpstart-maintenance.agent.md +1 -0
  8. package/.github/agents/jumpstart-performance.agent.md +1 -0
  9. package/.github/agents/jumpstart-pm.agent.md +1 -1
  10. package/.github/agents/jumpstart-refactor.agent.md +1 -0
  11. package/.github/agents/jumpstart-requirements-extractor.agent.md +1 -0
  12. package/.github/agents/jumpstart-researcher.agent.md +1 -0
  13. package/.github/agents/jumpstart-retrospective.agent.md +1 -0
  14. package/.github/agents/jumpstart-reviewer.agent.md +2 -0
  15. package/.github/agents/jumpstart-scout.agent.md +1 -1
  16. package/.github/agents/jumpstart-scrum-master.agent.md +1 -0
  17. package/.github/agents/jumpstart-security.agent.md +2 -1
  18. package/.github/agents/jumpstart-tech-writer.agent.md +1 -0
  19. package/.github/agents/jumpstart-uiux-designer.agent.md +66 -0
  20. package/.github/workflows/quality.yml +19 -2
  21. package/.jumpstart/agents/analyst.md +38 -0
  22. package/.jumpstart/agents/architect.md +39 -1
  23. package/.jumpstart/agents/challenger.md +38 -0
  24. package/.jumpstart/agents/developer.md +41 -0
  25. package/.jumpstart/agents/pm.md +38 -0
  26. package/.jumpstart/agents/scout.md +33 -0
  27. package/.jumpstart/agents/ux-designer.md +29 -9
  28. package/.jumpstart/commands/commands.md +6 -5
  29. package/.jumpstart/config.yaml +25 -1
  30. package/.jumpstart/roadmap.md +1 -1
  31. package/.jumpstart/schemas/timeline.schema.json +1 -0
  32. package/.jumpstart/skills/README.md +1 -0
  33. package/.jumpstart/skills/quality-gates/SKILL.md +126 -0
  34. package/.jumpstart/skills/skill-creator/SKILL.md +485 -357
  35. package/.jumpstart/skills/skill-creator/agents/analyzer.md +274 -0
  36. package/.jumpstart/skills/skill-creator/agents/comparator.md +202 -0
  37. package/.jumpstart/skills/skill-creator/agents/grader.md +223 -0
  38. package/.jumpstart/skills/skill-creator/assets/eval_review.html +146 -0
  39. package/.jumpstart/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  40. package/.jumpstart/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  41. package/.jumpstart/skills/skill-creator/references/schemas.md +430 -0
  42. package/.jumpstart/skills/skill-creator/scripts/__init__.py +0 -0
  43. package/.jumpstart/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  44. package/.jumpstart/skills/skill-creator/scripts/generate_report.py +326 -0
  45. package/.jumpstart/skills/skill-creator/scripts/improve_description.py +247 -0
  46. package/.jumpstart/skills/skill-creator/scripts/package_skill.py +136 -110
  47. package/.jumpstart/skills/skill-creator/scripts/run_eval.py +310 -0
  48. package/.jumpstart/skills/skill-creator/scripts/run_loop.py +328 -0
  49. package/.jumpstart/skills/skill-creator/scripts/utils.py +47 -0
  50. package/.jumpstart/skills/ui-ux-pro-max/SKILL.md +266 -0
  51. package/.jumpstart/skills/ui-ux-pro-max/data/charts.csv +26 -0
  52. package/.jumpstart/skills/ui-ux-pro-max/data/colors.csv +97 -0
  53. package/.jumpstart/skills/ui-ux-pro-max/data/icons.csv +101 -0
  54. package/.jumpstart/skills/ui-ux-pro-max/data/landing.csv +31 -0
  55. package/.jumpstart/skills/ui-ux-pro-max/data/products.csv +97 -0
  56. package/.jumpstart/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  57. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  58. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  59. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  60. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  61. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  62. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  63. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  64. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  65. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  66. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  67. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  68. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  69. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  70. package/.jumpstart/skills/ui-ux-pro-max/data/styles.csv +68 -0
  71. package/.jumpstart/skills/ui-ux-pro-max/data/typography.csv +58 -0
  72. package/.jumpstart/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  73. package/.jumpstart/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  74. package/.jumpstart/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  75. package/.jumpstart/skills/ui-ux-pro-max/scripts/core.py +253 -0
  76. package/.jumpstart/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
  77. package/.jumpstart/skills/ui-ux-pro-max/scripts/search.py +114 -0
  78. package/.jumpstart/state/timeline.json +659 -0
  79. package/.jumpstart/templates/model-map.md +1 -1
  80. package/.jumpstart/templates/ux-design.md +3 -3
  81. package/.jumpstart/usage-log.json +74 -3
  82. package/AGENTS.md +1 -1
  83. package/README.md +64 -3
  84. package/bin/cli.js +3217 -1
  85. package/bin/headless-runner.js +62 -2
  86. package/bin/lib/agent-checkpoint.js +168 -0
  87. package/bin/lib/ai-evaluation.js +104 -0
  88. package/bin/lib/ai-intake.js +152 -0
  89. package/bin/lib/ambiguity-heatmap.js +152 -0
  90. package/bin/lib/artifact-comparison.js +104 -0
  91. package/bin/lib/ast-edit-engine.js +157 -0
  92. package/bin/lib/backlog-sync.js +338 -0
  93. package/bin/lib/bcdr-planning.js +158 -0
  94. package/bin/lib/bidirectional-trace.js +199 -0
  95. package/bin/lib/branch-workflow.js +266 -0
  96. package/bin/lib/cab-output.js +119 -0
  97. package/bin/lib/chat-integration.js +122 -0
  98. package/bin/lib/ci-cd-integration.js +208 -0
  99. package/bin/lib/codebase-retrieval.js +125 -0
  100. package/bin/lib/collaboration.js +168 -0
  101. package/bin/lib/compliance-packs.js +213 -0
  102. package/bin/lib/context-chunker.js +128 -0
  103. package/bin/lib/context-onboarding.js +122 -0
  104. package/bin/lib/contract-first.js +124 -0
  105. package/bin/lib/cost-router.js +148 -0
  106. package/bin/lib/credential-boundary.js +155 -0
  107. package/bin/lib/data-classification.js +180 -0
  108. package/bin/lib/data-contracts.js +129 -0
  109. package/bin/lib/db-evolution.js +158 -0
  110. package/bin/lib/decision-conflicts.js +299 -0
  111. package/bin/lib/delivery-confidence.js +361 -0
  112. package/bin/lib/dependency-upgrade.js +153 -0
  113. package/bin/lib/design-system.js +133 -0
  114. package/bin/lib/deterministic-artifacts.js +151 -0
  115. package/bin/lib/diagram-studio.js +115 -0
  116. package/bin/lib/domain-ontology.js +140 -0
  117. package/bin/lib/ea-review-packet.js +151 -0
  118. package/bin/lib/enterprise-search.js +123 -0
  119. package/bin/lib/enterprise-templates.js +140 -0
  120. package/bin/lib/environment-promotion.js +220 -0
  121. package/bin/lib/estimation-studio.js +130 -0
  122. package/bin/lib/event-modeling.js +133 -0
  123. package/bin/lib/evidence-collector.js +179 -0
  124. package/bin/lib/finops-planner.js +182 -0
  125. package/bin/lib/fitness-functions.js +279 -0
  126. package/bin/lib/focus.js +448 -0
  127. package/bin/lib/governance-dashboard.js +165 -0
  128. package/bin/lib/guided-handoff.js +120 -0
  129. package/bin/lib/impact-analysis.js +190 -0
  130. package/bin/lib/incident-feedback.js +157 -0
  131. package/bin/lib/integrate.js +1 -1
  132. package/bin/lib/knowledge-graph.js +122 -0
  133. package/bin/lib/legacy-modernizer.js +160 -0
  134. package/bin/lib/migration-planner.js +144 -0
  135. package/bin/lib/model-governance.js +185 -0
  136. package/bin/lib/model-router.js +144 -0
  137. package/bin/lib/multi-repo.js +272 -0
  138. package/bin/lib/next-phase.js +53 -8
  139. package/bin/lib/ops-ownership.js +152 -0
  140. package/bin/lib/parallel-agents.js +257 -0
  141. package/bin/lib/pattern-library.js +115 -0
  142. package/bin/lib/persona-packs.js +99 -0
  143. package/bin/lib/plan-executor.js +366 -0
  144. package/bin/lib/platform-engineering.js +119 -0
  145. package/bin/lib/playback-summaries.js +126 -0
  146. package/bin/lib/policy-engine.js +240 -0
  147. package/bin/lib/portfolio-reporting.js +357 -0
  148. package/bin/lib/pr-package.js +197 -0
  149. package/bin/lib/project-memory.js +235 -0
  150. package/bin/lib/prompt-governance.js +130 -0
  151. package/bin/lib/promptless-mode.js +128 -0
  152. package/bin/lib/quality-graph.js +193 -0
  153. package/bin/lib/raci-matrix.js +188 -0
  154. package/bin/lib/refactor-planner.js +167 -0
  155. package/bin/lib/reference-architectures.js +304 -0
  156. package/bin/lib/release-readiness.js +171 -0
  157. package/bin/lib/repo-graph.js +262 -0
  158. package/bin/lib/requirements-baseline.js +358 -0
  159. package/bin/lib/risk-register.js +211 -0
  160. package/bin/lib/role-approval.js +249 -0
  161. package/bin/lib/role-views.js +142 -0
  162. package/bin/lib/root-cause-analysis.js +132 -0
  163. package/bin/lib/runtime-debugger.js +154 -0
  164. package/bin/lib/safe-rename.js +135 -0
  165. package/bin/lib/secret-scanner.js +313 -0
  166. package/bin/lib/semantic-diff.js +335 -0
  167. package/bin/lib/sla-slo.js +210 -0
  168. package/bin/lib/smoke-tester.js +344 -0
  169. package/bin/lib/spec-comments.js +147 -0
  170. package/bin/lib/spec-maturity.js +287 -0
  171. package/bin/lib/sre-integration.js +154 -0
  172. package/bin/lib/structured-elicitation.js +174 -0
  173. package/bin/lib/telemetry-feedback.js +118 -0
  174. package/bin/lib/test-generator.js +146 -0
  175. package/bin/lib/timeline.js +2 -1
  176. package/bin/lib/tool-bridge.js +159 -0
  177. package/bin/lib/tool-guardrails.js +139 -0
  178. package/bin/lib/tool-schemas.js +281 -3
  179. package/bin/lib/transcript-ingestion.js +150 -0
  180. package/bin/lib/type-checker.js +261 -0
  181. package/bin/lib/uat-coverage.js +411 -0
  182. package/bin/lib/vendor-risk.js +173 -0
  183. package/bin/lib/waiver-workflow.js +174 -0
  184. package/bin/lib/web-dashboard.js +126 -0
  185. package/bin/lib/workshop-mode.js +165 -0
  186. package/bin/lib/workstream-ownership.js +104 -0
  187. package/package.json +1 -1
  188. package/.github/agents/jumpstart-ux-designer.agent.md +0 -45
package/bin/cli.js CHANGED
@@ -125,6 +125,7 @@ function showHelp() {
125
125
  console.log(' timeline View, query, export, or clear interaction timeline');
126
126
  console.log(' validate-all Proactive validation & suggestion engine');
127
127
  console.log(' quickstart 5-minute quickstart wizard');
128
+ console.log(' focus <action> Phase focus mode (set/list/clear/status)');
128
129
  console.log(' rewind <phase> Rewind to target phase, archiving downstream artifacts');
129
130
  console.log(' approve [path] Approve current or specified phase artifact');
130
131
  console.log(' reject [path] Reject artifact with reason');
@@ -136,7 +137,106 @@ function showHelp() {
136
137
  console.log(' integrate Rebuild skill integration files');
137
138
  console.log(' update [item] Update installed items to latest');
138
139
  console.log(' upgrade Safely upgrade framework files (preserves user content)');
139
- console.log(' upgrade --restore Restore files from upgrade backups\n');
140
+ console.log(' upgrade --restore Restore files from upgrade backups');
141
+ console.log(' multi-repo <action> Multi-repo program orchestration (init/status/link/plan)');
142
+ console.log(' bidirectional-trace Bidirectional code-to-spec traceability (scan/report)');
143
+ console.log(' impact <file> Agentic change impact analysis');
144
+ console.log(' repo-graph <action> Automated repo understanding graph (build/query)');
145
+ console.log(' memory <action> Persistent project memory (add/list/search/recall)');
146
+ console.log(' policy <action> Enterprise policy engine (check/list/add)');
147
+ console.log(' branch-workflow Branch-aware workflow engine (track/status/sync)');
148
+ console.log(' pr-package <action> PR-native execution mode (create/list/export)');
149
+ console.log(' parallel-agents Multi-agent concurrent execution (run/status/reconcile)');
150
+ console.log(' role-approval Human approval workflows with roles (assign/approve/status)');
151
+ console.log(' requirements-baseline Requirements baseline & change control (freeze/check/impact/status)');
152
+ console.log(' semantic-diff Cross-artifact semantic diffing (compare/cross-artifact)');
153
+ console.log(' backlog-sync Native backlog synchronization (extract/export/status)');
154
+ console.log(' delivery-confidence Delivery confidence scoring (score/project)');
155
+ console.log(' plan-executor Rich plan execution engine (init/status/update/verify/reset)');
156
+ console.log(' fitness-functions Architectural fitness functions (evaluate/add/list)');
157
+ console.log(' reference-arch Org-wide reusable reference architectures (list/get/register/instantiate)');
158
+ console.log(' decision-conflicts Decision conflict detection (detect)');
159
+ console.log(' spec-maturity Spec maturity model (assess/project)');
160
+ console.log(' portfolio Portfolio reporting layer (register/status/refresh/snapshot/remove)');
161
+ console.log(' ci-cd-integration CI/CD pipeline integration (generate/validate/status)');
162
+ console.log(' env-promotion Environment promotion governance (promote/gate/status)');
163
+ console.log(' raci-matrix RACI-aware approvals (define/check/report)');
164
+ console.log(' compliance-packs Compliance framework packs (list/apply/check)');
165
+ console.log(' evidence-collector Evidence collection automation (collect/package/status)');
166
+ console.log(' release-readiness Release readiness reviews (assess/report)');
167
+ console.log(' waiver-workflow Exception & waiver workflow (request/approve/list/expire)');
168
+ console.log(' sla-slo SLA & SLO specification (define/check/report)');
169
+ console.log(' risk-register Risk register tracking (add/update/list/report)');
170
+ console.log(' data-classification Data classification controls (classify/check/report)');
171
+ console.log(' credential-boundary Secrets & credential boundary checks (scan/report)');
172
+ console.log(' ea-review-packet Enterprise architecture review packet (generate)');
173
+ console.log(' model-governance Model governance workflows (register/evaluate/report)');
174
+ console.log(' ai-intake AI use case intake templates (create/list/assess)');
175
+ console.log(' finops-planner FinOps-aware architecture planning (estimate/optimize/report)');
176
+ console.log(' vendor-risk Vendor & dependency risk scoring (scan/assess/report)');
177
+ console.log(' cab-output Change advisory board output (generate)');
178
+ console.log(' bcdr-planning Business continuity & DR planning (define/check/report)');
179
+ console.log(' ops-ownership Operational ownership modeling (define/check/report)');
180
+ console.log(' governance-dashboard Governance dashboards for leadership');
181
+ console.log(' codebase-retrieval Codebase-native retrieval layer (index/query)');
182
+ console.log(' ast-edit AST-aware edit engine (analyze/validate)');
183
+ console.log(' refactor-planner Refactor planner with dependency safety (plan/validate/report)');
184
+ console.log(' test-generator Test generation from acceptance criteria (generate/coverage)');
185
+ console.log(' contract-first Contract-first implementation assistant (extract/verify)');
186
+ console.log(' runtime-debugger Runtime-aware debugging mode (analyze/correlate)');
187
+ console.log(' migration-planner Brownfield migration planner (plan/status/report)');
188
+ console.log(' legacy-modernizer Legacy code modernization mode (assess/plan/report)');
189
+ console.log(' db-evolution Database evolution planner (plan/validate/report)');
190
+ console.log(' safe-rename Safe large-scale rename & move engine (plan/validate)');
191
+ console.log(' dependency-upgrade Dependency upgrade autopilot (scan/plan/report)');
192
+ console.log(' incident-feedback Incident-to-spec feedback loop (log/analyze/report)');
193
+ console.log(' context-chunker Implementation chunking by context window (chunk/estimate)');
194
+ console.log(' model-router Multi-model routing (route/config/report)');
195
+ console.log(' cost-router Cost-aware model routing (route/budget/report)');
196
+ console.log(' deterministic Deterministic artifact generation (normalize/verify)');
197
+ console.log(' agent-checkpoint Agent self-checkpoint & resume (save/restore/list/clean)');
198
+ console.log(' tool-guardrails Tool execution guardrails (check/validate)');
199
+ console.log(' root-cause Root cause analysis for failures (analyze/report)');
200
+ console.log(' quality-graph Code quality smell graph (scan/report)');
201
+ console.log(' web-dashboard Rich web UI / local dashboard (config/data/status)');
202
+ console.log(' role-views Role-based project views (generate/list)');
203
+ console.log(' spec-comments Inline spec review comments (add/resolve/list)');
204
+ console.log(' workshop-mode Live workshop mode (start/status)');
205
+ console.log(' collaboration Real-time collaboration sessions (create/status)');
206
+ console.log(' elicitation Facilitated Q&A with structured elicitation (start/report)');
207
+ console.log(' enterprise-templates Guided enterprise templates (list/get/apply)');
208
+ console.log(' playback-summaries Stakeholder playback summaries (generate/list)');
209
+ console.log(' design-system Design system integration (register/check/report)');
210
+ console.log(' diagram-studio Diagram studio (generate/validate/compare/list)');
211
+ console.log(' ambiguity-heatmap Requirement ambiguity heatmap (scan/report)');
212
+ console.log(' estimation-studio Feature estimation studio (estimate/report/calibrate)');
213
+ console.log(' guided-handoff Guided handoff packages by team (generate/list/validate)');
214
+ console.log(' transcript-ingestion Meeting transcript ingestion (ingest/extract/list)');
215
+ console.log(' chat-integration Slack and Teams integration (configure/notify)');
216
+ console.log(' context-onboarding Context-aware onboarding (generate/customize)');
217
+ console.log(' promptless-mode Promptless wizard mode (start/step/status)');
218
+ console.log(' artifact-comparison Artifact comparison across versions (compare/history)');
219
+ console.log(' workstream-ownership Workstream ownership visualization (define/query/report)');
220
+ console.log(' persona-packs Persona packs for enterprise roles (list/get/apply)');
221
+ console.log(' knowledge-graph Knowledge graph across initiatives (add/query/report)');
222
+ console.log(' pattern-library Inner-source pattern library (register/search/get/list)');
223
+ console.log(' domain-ontology Domain ontology support (define/query/validate/report)');
224
+ console.log(' data-contracts Data contract governance (register/validate/lineage/report)');
225
+ console.log(' event-modeling Event-driven architecture modeling (define/validate/report)');
226
+ console.log(' platform-engineering Platform engineering integration (register/list/instantiate/report)');
227
+ console.log(' ai-evaluation AI system evaluation framework (evaluate/report/configure)');
228
+ console.log(' prompt-governance Prompt and agent version governance (register/version/approve/list)');
229
+ console.log(' sre-integration SRE integration (generate/configure/report)');
230
+ console.log(' telemetry-feedback Production telemetry feedback loop (ingest/analyze/report)');
231
+ console.log(' enterprise-search Enterprise search over artifacts (index/search)');
232
+ console.log(' revert <path> Archive rejected artifact draft and restore previous version');
233
+ console.log(' adr <action> Search/index Architecture Decision Records (build/search)');
234
+ console.log(' complexity [path] Calculate adaptive planning depth (quick/standard/deep)');
235
+ console.log(' crossref [dir] Validate markdown cross-references and detect orphans');
236
+ console.log(' init Interactive initialization wizard (skill level, preferences)');
237
+ console.log(' lock <action> Artifact file locking for concurrent agents (acquire/release/list)');
238
+ console.log(' timestamp <action> UTC timestamp utilities (now/validate/audit)');
239
+ console.log(' scan [dir] Discover project context and tech stack\n');
140
240
  console.log(chalk.bold('OPTIONS:'));
141
241
  console.log(' <directory> Target directory (default: current directory)');
142
242
  console.log(' --name <name> Set project name in config');
@@ -176,6 +276,11 @@ function showHelp() {
176
276
  console.log(' npx jumpstart-mode checkpoint restore cp-1234567890');
177
277
  console.log(' npx jumpstart-mode handoff');
178
278
  console.log(' npx jumpstart-mode handoff --output ./export/handoff.md --json');
279
+ console.log(' npx jumpstart-mode focus list');
280
+ console.log(' npx jumpstart-mode focus set business-analyst');
281
+ console.log(' npx jumpstart-mode focus set --start 1 --end 2');
282
+ console.log(' npx jumpstart-mode focus status');
283
+ console.log(' npx jumpstart-mode focus clear');
179
284
  console.log(' npx jumpstart-mode upgrade');
180
285
  console.log(' npx jumpstart-mode upgrade --dry-run');
181
286
  console.log(' npx jumpstart-mode upgrade --restore\n');
@@ -698,6 +803,42 @@ async function install(config) {
698
803
  const qaLogDest = path.join(targetPath, 'specs', 'qa-log.md');
699
804
  copyFile(qaLogSrc, qaLogDest, copyOptions);
700
805
 
806
+ // 4c. Seed timeline and usage log if they don't already exist
807
+ if (!config.dryRun) {
808
+ const timelinePath = path.join(targetPath, JUMPSTART_DIR, 'state', 'timeline.json');
809
+ if (!fs.existsSync(timelinePath)) {
810
+ const stateDir = path.join(targetPath, JUMPSTART_DIR, 'state');
811
+ if (!fs.existsSync(stateDir)) fs.mkdirSync(stateDir, { recursive: true });
812
+ const sessionId = `ses-init-${Date.now().toString(36)}`;
813
+ const now = new Date().toISOString();
814
+ const seed = {
815
+ version: '1.0.0',
816
+ session_id: sessionId,
817
+ started_at: now,
818
+ ended_at: now,
819
+ events: [{
820
+ id: `evt-init-${Date.now().toString(36)}`,
821
+ timestamp: now,
822
+ session_id: sessionId,
823
+ phase: 'init',
824
+ agent: 'System',
825
+ parent_agent: null,
826
+ event_type: 'phase_start',
827
+ action: 'Jump Start framework initialized — workspace scaffolded',
828
+ metadata: { project_type: config.projectType || 'unknown', config_path: '.jumpstart/config.yaml' },
829
+ duration_ms: null
830
+ }]
831
+ };
832
+ fs.writeFileSync(timelinePath, JSON.stringify(seed, null, 2) + '\n', 'utf8');
833
+ stats.created.push(timelinePath);
834
+ }
835
+ const usageLogPath = path.join(targetPath, JUMPSTART_DIR, 'usage-log.json');
836
+ if (!fs.existsSync(usageLogPath)) {
837
+ fs.writeFileSync(usageLogPath, JSON.stringify({ entries: [], total_tokens: 0, total_cost_usd: 0 }, null, 2) + '\n', 'utf8');
838
+ stats.created.push(usageLogPath);
839
+ }
840
+ }
841
+
701
842
  // 5-6. Persist bootstrap answers in config.yaml
702
843
  const configPath = path.join(targetPath, JUMPSTART_DIR, 'config.yaml');
703
844
  const hasBootstrapAnswers = Boolean(config.projectName || config.projectType || config.approverName);
@@ -1671,6 +1812,92 @@ async function main() {
1671
1812
  return;
1672
1813
  }
1673
1814
 
1815
+ if (subcommand === 'focus') {
1816
+ // Phase focus mode — restrict workflow to specific phases
1817
+ const { listPresets, buildFocusConfig, writeFocusToConfig, clearFocusFromConfig, getFocusStatus, VALID_PRESETS } = await import('./lib/focus.js');
1818
+ const action = process.argv[3];
1819
+ const io = require('./lib/io');
1820
+ const configPath = path.join(process.cwd(), '.jumpstart', 'config.yaml');
1821
+
1822
+ if (action === 'list') {
1823
+ const presets = listPresets();
1824
+ io.writeResult({ presets });
1825
+ return;
1826
+ }
1827
+
1828
+ if (action === 'set') {
1829
+ const arg = process.argv[4];
1830
+ const startIdx = process.argv.indexOf('--start');
1831
+ const endIdx = process.argv.indexOf('--end');
1832
+
1833
+ let focusConfig;
1834
+ if (startIdx !== -1 && endIdx !== -1) {
1835
+ // Custom range: focus set --start 1 --end 2
1836
+ const start = parseInt(process.argv[startIdx + 1], 10);
1837
+ const end = parseInt(process.argv[endIdx + 1], 10);
1838
+ if (isNaN(start) || isNaN(end)) {
1839
+ console.error(chalk.red('Usage: jumpstart-mode focus set --start <phase> --end <phase>'));
1840
+ process.exit(1);
1841
+ }
1842
+ try {
1843
+ focusConfig = buildFocusConfig({ start_phase: start, end_phase: end });
1844
+ } catch (err) {
1845
+ console.error(chalk.red(err.message));
1846
+ process.exit(1);
1847
+ }
1848
+ } else if (arg && !arg.startsWith('-')) {
1849
+ // Preset: focus set business-analyst
1850
+ if (!VALID_PRESETS.includes(arg)) {
1851
+ console.error(chalk.red(`Unknown preset: "${arg}". Valid presets: ${VALID_PRESETS.join(', ')}`));
1852
+ process.exit(1);
1853
+ }
1854
+ focusConfig = buildFocusConfig({ preset: arg });
1855
+ } else {
1856
+ console.error(chalk.red('Usage: jumpstart-mode focus set <preset> | focus set --start <phase> --end <phase>'));
1857
+ console.error(chalk.gray(` Presets: ${VALID_PRESETS.join(', ')}`));
1858
+ process.exit(1);
1859
+ }
1860
+
1861
+ if (!fs.existsSync(configPath)) {
1862
+ console.error(chalk.red('Config file not found. Run jumpstart-mode init first.'));
1863
+ process.exit(1);
1864
+ }
1865
+
1866
+ const writeResult = writeFocusToConfig(configPath, focusConfig);
1867
+ if (!writeResult.success) {
1868
+ console.error(chalk.red(writeResult.error));
1869
+ process.exit(1);
1870
+ }
1871
+
1872
+ console.log(chalk.green(`Focus mode set: ${focusConfig.description}`));
1873
+ if (focusConfig.phases) {
1874
+ console.log(chalk.gray(` Phases: ${focusConfig.phases.map(p => p.name || p).join(' → ')}`));
1875
+ }
1876
+ return;
1877
+ }
1878
+
1879
+ if (action === 'clear') {
1880
+ if (!fs.existsSync(configPath)) {
1881
+ console.error(chalk.red('Config file not found. Run jumpstart-mode init first.'));
1882
+ process.exit(1);
1883
+ }
1884
+ clearFocusFromConfig(configPath);
1885
+ console.log(chalk.green('Focus mode cleared — full workflow restored.'));
1886
+ return;
1887
+ }
1888
+
1889
+ if (action === 'status') {
1890
+ const status = getFocusStatus({ root: process.cwd() });
1891
+ io.writeResult(status);
1892
+ return;
1893
+ }
1894
+
1895
+ // Default: show status
1896
+ const status = getFocusStatus({ root: process.cwd() });
1897
+ io.writeResult(status);
1898
+ return;
1899
+ }
1900
+
1674
1901
  if (subcommand === 'summarize') {
1675
1902
  // Smart context summarizer (UX Feature 9)
1676
1903
  const { generateContextPacket, renderContextMarkdown } = require('./lib/context-summarizer');
@@ -2116,6 +2343,2995 @@ async function main() {
2116
2343
  return;
2117
2344
  }
2118
2345
 
2346
+ // ── Feature 1: Multi-Repo Program Orchestration ─────────────────────────
2347
+ if (subcommand === 'multi-repo') {
2348
+ const multiRepo = require('./lib/multi-repo');
2349
+ const action = process.argv[3] || 'status';
2350
+ const jsonMode = process.argv.includes('--json');
2351
+ const io = require('./lib/io');
2352
+
2353
+ if (action === 'init') {
2354
+ const name = process.argv[4];
2355
+ if (!name) {
2356
+ console.error(chalk.red('Usage: jumpstart-mode multi-repo init <program-name>'));
2357
+ process.exit(1);
2358
+ }
2359
+ const result = multiRepo.initProgram(name, { stateFile: path.join(process.cwd(), '.jumpstart', 'state', 'multi-repo.json') });
2360
+ if (jsonMode) { io.writeResult(result); } else {
2361
+ console.log(result.success ? chalk.green(`āœ… ${result.message}`) : chalk.red(`āŒ ${result.error}`));
2362
+ }
2363
+ } else if (action === 'link') {
2364
+ const repoUrl = process.argv[4];
2365
+ const role = process.argv[5] || 'other';
2366
+ if (!repoUrl) {
2367
+ console.error(chalk.red('Usage: jumpstart-mode multi-repo link <repo-url> [role]'));
2368
+ process.exit(1);
2369
+ }
2370
+ const result = multiRepo.linkRepo(repoUrl, role, { stateFile: path.join(process.cwd(), '.jumpstart', 'state', 'multi-repo.json') });
2371
+ if (jsonMode) { io.writeResult(result); } else {
2372
+ console.log(result.success ? chalk.green(`āœ… Repo linked: ${repoUrl} (${role})`) : chalk.red(`āŒ ${result.error}`));
2373
+ }
2374
+ } else if (action === 'plan') {
2375
+ const result = multiRepo.getProgramStatus({ stateFile: path.join(process.cwd(), '.jumpstart', 'state', 'multi-repo.json') });
2376
+ if (jsonMode) { io.writeResult(result); } else {
2377
+ console.log(chalk.bold(`\nšŸ“¦ Program: ${result.program_name || '(not initialized)'}`));
2378
+ console.log(` Repos: ${result.repo_count} Shared specs: ${result.shared_spec_count} Dependencies: ${result.dependency_count}`);
2379
+ if (result.release_plan && result.release_plan.milestones.length > 0) {
2380
+ console.log(` Milestones: ${result.release_plan.milestones.map(m => m.name).join(', ')}`);
2381
+ }
2382
+ console.log('');
2383
+ }
2384
+ } else {
2385
+ // status (default)
2386
+ const result = multiRepo.getProgramStatus({ stateFile: path.join(process.cwd(), '.jumpstart', 'state', 'multi-repo.json') });
2387
+ if (jsonMode) { io.writeResult(result); } else {
2388
+ console.log(chalk.bold(`\nšŸ—‚ Multi-Repo Program Status`));
2389
+ console.log(` Program: ${result.program_name || '(not initialized)'}`);
2390
+ console.log(` Repos: ${result.repo_count}`);
2391
+ if (result.repo_count > 0) {
2392
+ for (const repo of result.repos) {
2393
+ console.log(` • [${repo.role}] ${repo.url}`);
2394
+ }
2395
+ }
2396
+ console.log(` Shared specs: ${result.shared_spec_count}`);
2397
+ console.log(` Cross-repo deps: ${result.dependency_count}`);
2398
+ console.log('');
2399
+ }
2400
+ }
2401
+ return;
2402
+ }
2403
+
2404
+ // ── Feature 2: Bidirectional Code-to-Spec Traceability ──────────────────
2405
+ if (subcommand === 'bidirectional-trace') {
2406
+ const btrace = require('./lib/bidirectional-trace');
2407
+ const action = process.argv[3] || 'scan';
2408
+ const jsonMode = process.argv.includes('--json');
2409
+ const io = require('./lib/io');
2410
+
2411
+ if (action === 'scan' || action === 'report') {
2412
+ const traceMap = btrace.scanTraceLinks(process.cwd());
2413
+ if (action === 'report') {
2414
+ const report = btrace.buildCoverageReport(process.cwd(), traceMap);
2415
+ if (jsonMode) { io.writeResult(report); } else {
2416
+ console.log(chalk.bold('\nšŸ”— Bidirectional Traceability Report'));
2417
+ console.log(` Spec IDs: ${report.total_spec_ids} Covered: ${report.covered} Gaps: ${report.gaps} Coverage: ${report.coverage_pct}%`);
2418
+ if (report.gap_list.length > 0) {
2419
+ console.log(chalk.yellow('\n Unlinked spec IDs:'));
2420
+ for (const id of report.gap_list) console.log(` • ${id}`);
2421
+ }
2422
+ console.log('');
2423
+ }
2424
+ } else {
2425
+ if (jsonMode) { io.writeResult(traceMap); } else {
2426
+ console.log(chalk.bold('\nšŸ”— Trace Scan Complete'));
2427
+ console.log(` Spec IDs found: ${traceMap.stats.total_spec_ids}`);
2428
+ console.log(` Files with links: ${traceMap.stats.total_files_with_links}`);
2429
+ console.log(` Total links: ${traceMap.stats.total_links}`);
2430
+ console.log('');
2431
+ }
2432
+ }
2433
+ } else {
2434
+ console.error(chalk.red('Usage: jumpstart-mode bidirectional-trace [scan|report] [--json]'));
2435
+ process.exit(1);
2436
+ }
2437
+ return;
2438
+ }
2439
+
2440
+ // ── Feature 3: Agentic Change Impact Analysis ────────────────────────────
2441
+ if (subcommand === 'impact') {
2442
+ const { analyzeImpact, renderImpactReport } = require('./lib/impact-analysis');
2443
+ const fileArg = process.argv[3];
2444
+ const symbolIdx = process.argv.indexOf('--symbol');
2445
+ const specIdIdx = process.argv.indexOf('--spec');
2446
+ const jsonMode = process.argv.includes('--json');
2447
+ const io = require('./lib/io');
2448
+
2449
+ const target = {};
2450
+ if (fileArg && !fileArg.startsWith('--')) target.file = fileArg;
2451
+ if (symbolIdx !== -1) target.symbol = process.argv[symbolIdx + 1];
2452
+ if (specIdIdx !== -1) target.specId = process.argv[specIdIdx + 1];
2453
+
2454
+ if (!target.file && !target.symbol && !target.specId) {
2455
+ console.error(chalk.red('Usage: jumpstart-mode impact <file> [--symbol <name>] [--spec <id>] [--json]'));
2456
+ process.exit(1);
2457
+ }
2458
+
2459
+ const result = analyzeImpact(process.cwd(), target);
2460
+ if (jsonMode) { io.writeResult(result); } else {
2461
+ console.log(renderImpactReport(result));
2462
+ }
2463
+ return;
2464
+ }
2465
+
2466
+ // ── Feature 4: Automated Repo Understanding Graph ───────────────────────
2467
+ if (subcommand === 'repo-graph') {
2468
+ const repoGraphLib = require('./lib/repo-graph');
2469
+ const action = process.argv[3] || 'build';
2470
+ const jsonMode = process.argv.includes('--json');
2471
+ const io = require('./lib/io');
2472
+ const graphFile = path.join(process.cwd(), '.jumpstart', 'state', 'repo-graph.json');
2473
+
2474
+ if (action === 'build') {
2475
+ const result = repoGraphLib.buildRepoGraph(process.cwd(), { graphFile });
2476
+ if (jsonMode) { io.writeResult(result); } else {
2477
+ console.log(chalk.green(`āœ… Repo graph built: ${result.node_count} nodes, ${result.edge_count} edges`));
2478
+ console.log(chalk.gray(` Saved to: ${result.graph_file}`));
2479
+ }
2480
+ } else if (action === 'query') {
2481
+ const graph = repoGraphLib.loadRepoGraph(graphFile);
2482
+ const typeArg = process.argv.indexOf('--type') !== -1 ? process.argv[process.argv.indexOf('--type') + 1] : null;
2483
+ const nameArg = process.argv.indexOf('--name') !== -1 ? process.argv[process.argv.indexOf('--name') + 1] : null;
2484
+ const results = repoGraphLib.queryGraph(graph, { type: typeArg, nameContains: nameArg });
2485
+ if (jsonMode) { io.writeResult(results); } else {
2486
+ console.log(chalk.bold(`\nšŸ—ŗ Repo Graph Query (${results.length} nodes)`));
2487
+ for (const n of results) console.log(` [${n.type}] ${n.id} — ${n.name || ''}`);
2488
+ console.log('');
2489
+ }
2490
+ } else {
2491
+ console.error(chalk.red('Usage: jumpstart-mode repo-graph [build|query] [--type <type>] [--name <name>] [--json]'));
2492
+ process.exit(1);
2493
+ }
2494
+ return;
2495
+ }
2496
+
2497
+ // ── Feature 5: Persistent Long-Term Project Memory ──────────────────────
2498
+ if (subcommand === 'memory') {
2499
+ const memLib = require('./lib/project-memory');
2500
+ const action = process.argv[3] || 'list';
2501
+ const jsonMode = process.argv.includes('--json');
2502
+ const io = require('./lib/io');
2503
+ const memFile = path.join(process.cwd(), '.jumpstart', 'state', 'project-memory.json');
2504
+
2505
+ if (action === 'add') {
2506
+ const typeArg = process.argv.indexOf('--type') !== -1 ? process.argv[process.argv.indexOf('--type') + 1] : 'insight';
2507
+ const titleIdx = process.argv.indexOf('--title');
2508
+ const contentIdx = process.argv.indexOf('--content');
2509
+ if (titleIdx === -1 || contentIdx === -1) {
2510
+ console.error(chalk.red('Usage: jumpstart-mode memory add --type <type> --title <title> --content <content>'));
2511
+ process.exit(1);
2512
+ }
2513
+ const result = memLib.addMemory({
2514
+ type: typeArg,
2515
+ title: process.argv[titleIdx + 1],
2516
+ content: process.argv[contentIdx + 1]
2517
+ }, { memoryFile: memFile });
2518
+ if (jsonMode) { io.writeResult(result); } else {
2519
+ console.log(result.success ? chalk.green(`āœ… Memory added: ${result.entry.id}`) : chalk.red(`āŒ ${result.error}`));
2520
+ }
2521
+ } else if (action === 'search') {
2522
+ const keyword = process.argv[4];
2523
+ if (!keyword) { console.error(chalk.red('Usage: jumpstart-mode memory search <keyword>')); process.exit(1); }
2524
+ const result = memLib.searchMemories(keyword, { memoryFile: memFile });
2525
+ if (jsonMode) { io.writeResult(result); } else {
2526
+ console.log(chalk.bold(`\n🧠 Memory Search: "${keyword}" (${result.total} results)`));
2527
+ for (const e of result.entries) console.log(` [${e.type}] ${e.title} — ${e.id}`);
2528
+ console.log('');
2529
+ }
2530
+ } else if (action === 'recall') {
2531
+ const id = process.argv[4];
2532
+ if (!id) { console.error(chalk.red('Usage: jumpstart-mode memory recall <id>')); process.exit(1); }
2533
+ const result = memLib.recallMemory(id, { memoryFile: memFile });
2534
+ if (jsonMode) { io.writeResult(result); } else {
2535
+ if (result.success) {
2536
+ console.log(chalk.bold(`\n🧠 ${result.entry.title}`));
2537
+ console.log(chalk.gray(`Type: ${result.entry.type} | Created: ${result.entry.created_at}`));
2538
+ console.log('');
2539
+ console.log(result.entry.content);
2540
+ console.log('');
2541
+ } else { console.error(chalk.red(`āŒ ${result.error}`)); }
2542
+ }
2543
+ } else {
2544
+ // list (default)
2545
+ const typeFilter = process.argv.indexOf('--type') !== -1 ? process.argv[process.argv.indexOf('--type') + 1] : undefined;
2546
+ const result = memLib.listMemories(typeFilter ? { type: typeFilter } : {}, { memoryFile: memFile });
2547
+ if (jsonMode) { io.writeResult(result); } else {
2548
+ console.log(chalk.bold(`\n🧠 Project Memory (${result.total} entries)`));
2549
+ for (const e of result.entries) console.log(` [${e.type}] ${e.title} — ${e.id}`);
2550
+ console.log('');
2551
+ }
2552
+ }
2553
+ return;
2554
+ }
2555
+
2556
+ // ── Feature 6: Enterprise Policy Engine ────────────────────────────────
2557
+ if (subcommand === 'policy') {
2558
+ const policyLib = require('./lib/policy-engine');
2559
+ const action = process.argv[3] || 'check';
2560
+ const jsonMode = process.argv.includes('--json');
2561
+ const io = require('./lib/io');
2562
+ const policyFile = path.join(process.cwd(), '.jumpstart', 'policies.json');
2563
+
2564
+ if (action === 'check') {
2565
+ const result = policyLib.checkPolicies(process.cwd(), { policyFile });
2566
+ if (jsonMode) { io.writeResult(result); } else {
2567
+ const icon = result.summary.passed ? 'āœ…' : 'āŒ';
2568
+ console.log(chalk.bold(`\n${icon} Policy Check: ${result.summary.passed ? 'PASSED' : 'FAILED'}`));
2569
+ console.log(` Policies checked: ${result.summary.total_policies_checked}`);
2570
+ console.log(` Violations: ${result.summary.violations} Warnings: ${result.summary.warnings}`);
2571
+ if (result.violations.length > 0) {
2572
+ console.log(chalk.red('\n Violations:'));
2573
+ for (const v of result.violations) console.log(` āŒ [${v.category}] ${v.file}: ${v.policy_name}`);
2574
+ }
2575
+ if (result.warnings.length > 0) {
2576
+ console.log(chalk.yellow('\n Warnings:'));
2577
+ for (const w of result.warnings) console.log(` ⚠ [${w.category}] ${w.file}: ${w.policy_name}`);
2578
+ }
2579
+ console.log('');
2580
+ }
2581
+ } else if (action === 'list') {
2582
+ const result = policyLib.listPolicies({}, { policyFile });
2583
+ if (jsonMode) { io.writeResult(result); } else {
2584
+ console.log(chalk.bold(`\nšŸ“‹ Policies (${result.total})`));
2585
+ for (const p of result.policies) console.log(` [${p.category}/${p.severity}] ${p.name} — ${p.id}`);
2586
+ console.log('');
2587
+ }
2588
+ } else if (action === 'add') {
2589
+ const nameIdx = process.argv.indexOf('--name');
2590
+ const descIdx = process.argv.indexOf('--desc');
2591
+ const catIdx = process.argv.indexOf('--category');
2592
+ if (nameIdx === -1 || descIdx === -1) {
2593
+ console.error(chalk.red('Usage: jumpstart-mode policy add --name <name> --desc <desc> [--category <cat>] [--severity <sev>]'));
2594
+ process.exit(1);
2595
+ }
2596
+ const sevIdx = process.argv.indexOf('--severity');
2597
+ const patIdx = process.argv.indexOf('--pattern');
2598
+ const result = policyLib.addPolicy({
2599
+ name: process.argv[nameIdx + 1],
2600
+ description: process.argv[descIdx + 1],
2601
+ category: catIdx !== -1 ? process.argv[catIdx + 1] : 'other',
2602
+ severity: sevIdx !== -1 ? process.argv[sevIdx + 1] : 'warning',
2603
+ pattern: patIdx !== -1 ? process.argv[patIdx + 1] : null
2604
+ }, { policyFile });
2605
+ if (jsonMode) { io.writeResult(result); } else {
2606
+ console.log(result.success ? chalk.green(`āœ… Policy added: ${result.policy.id}`) : chalk.red(`āŒ ${result.error}`));
2607
+ }
2608
+ } else {
2609
+ console.error(chalk.red('Usage: jumpstart-mode policy [check|list|add] [options]'));
2610
+ process.exit(1);
2611
+ }
2612
+ return;
2613
+ }
2614
+
2615
+ // ── Feature 7: Branch-Aware Workflow Engine ─────────────────────────────
2616
+ if (subcommand === 'branch-workflow') {
2617
+ const branchLib = require('./lib/branch-workflow');
2618
+ const action = process.argv[3] || 'status';
2619
+ const jsonMode = process.argv.includes('--json');
2620
+ const io = require('./lib/io');
2621
+
2622
+ if (action === 'track') {
2623
+ const prNumIdx = process.argv.indexOf('--pr');
2624
+ const result = branchLib.trackBranch(process.cwd(), {
2625
+ pr_number: prNumIdx !== -1 ? parseInt(process.argv[prNumIdx + 1]) : undefined
2626
+ });
2627
+ if (jsonMode) { io.writeResult(result); } else {
2628
+ console.log(result.success ? chalk.green(`āœ… Branch tracked: ${result.branch.branch}`) : chalk.red(`āŒ ${result.error}`));
2629
+ }
2630
+ } else if (action === 'status') {
2631
+ const branchArg = process.argv[4];
2632
+ const result = branchLib.getBranchStatus(process.cwd(), { branch: branchArg });
2633
+ if (jsonMode) { io.writeResult(result); } else {
2634
+ if (result.tracked) {
2635
+ console.log(chalk.bold(`\n🌿 Branch: ${result.branch}`));
2636
+ console.log(` Phases recorded: ${result.phase_count} Approvals: ${result.approved_count}`);
2637
+ if (result.data.pr_number) console.log(` PR #${result.data.pr_number}`);
2638
+ } else {
2639
+ console.log(chalk.yellow(`\n⚠ ${result.message}`));
2640
+ }
2641
+ console.log('');
2642
+ }
2643
+ } else if (action === 'sync') {
2644
+ const result = branchLib.listTrackedBranches();
2645
+ if (jsonMode) { io.writeResult(result); } else {
2646
+ console.log(chalk.bold(`\n🌿 Tracked Branches (${result.total})`));
2647
+ for (const b of result.branches) console.log(` ${b.branch} phases=${b.phase_snapshots ? b.phase_snapshots.length : 0} PR=${b.pr_number || '-'}`);
2648
+ console.log('');
2649
+ }
2650
+ } else {
2651
+ console.error(chalk.red('Usage: jumpstart-mode branch-workflow [track|status|sync] [--pr <number>] [--json]'));
2652
+ process.exit(1);
2653
+ }
2654
+ return;
2655
+ }
2656
+
2657
+ // ── Feature 8: PR-Native Execution Mode ────────────────────────────────
2658
+ if (subcommand === 'pr-package') {
2659
+ const prLib = require('./lib/pr-package');
2660
+ const action = process.argv[3] || 'list';
2661
+ const jsonMode = process.argv.includes('--json');
2662
+ const io = require('./lib/io');
2663
+
2664
+ if (action === 'create') {
2665
+ const titleIdx = process.argv.indexOf('--title');
2666
+ const summaryIdx = process.argv.indexOf('--summary');
2667
+ const rollbackIdx = process.argv.indexOf('--rollback');
2668
+ const riskIdx = process.argv.indexOf('--risk');
2669
+ if (titleIdx === -1 || summaryIdx === -1) {
2670
+ console.error(chalk.red('Usage: jumpstart-mode pr-package create --title <title> --summary <summary> [--risk <note>] [--rollback <steps>]'));
2671
+ process.exit(1);
2672
+ }
2673
+ const result = prLib.createPRPackage({
2674
+ title: process.argv[titleIdx + 1],
2675
+ summary: process.argv[summaryIdx + 1],
2676
+ risk_notes: riskIdx !== -1 ? [process.argv[riskIdx + 1]] : [],
2677
+ rollback: rollbackIdx !== -1 ? process.argv[rollbackIdx + 1] : undefined
2678
+ }, process.cwd());
2679
+ if (jsonMode) { io.writeResult(result); } else {
2680
+ console.log(result.success ? chalk.green(`āœ… PR package created: ${result.id}`) : chalk.red(`āŒ ${result.error}`));
2681
+ if (result.success) console.log(chalk.gray(` Saved to: ${result.output_file}`));
2682
+ }
2683
+ } else if (action === 'export') {
2684
+ const packageId = process.argv[4];
2685
+ if (!packageId) { console.error(chalk.red('Usage: jumpstart-mode pr-package export <id>')); process.exit(1); }
2686
+ const result = prLib.exportPRPackage(packageId, process.cwd());
2687
+ if (jsonMode) { io.writeResult(result); } else {
2688
+ if (result.success) { console.log(result.content); } else { console.error(chalk.red(`āŒ ${result.error}`)); }
2689
+ }
2690
+ } else {
2691
+ // list (default)
2692
+ const result = prLib.listPRPackages(process.cwd());
2693
+ if (jsonMode) { io.writeResult(result); } else {
2694
+ console.log(chalk.bold(`\nšŸ“¦ PR Packages (${result.total})`));
2695
+ for (const p of result.packages) console.log(` ${p.id} ${p.created_at.split('T')[0]} ${p.file}`);
2696
+ console.log('');
2697
+ }
2698
+ }
2699
+ return;
2700
+ }
2701
+
2702
+ // ── Feature 9: Multi-Agent Concurrent Execution ─────────────────────────
2703
+ if (subcommand === 'parallel-agents') {
2704
+ const parallelLib = require('./lib/parallel-agents');
2705
+ const action = process.argv[3] || 'status';
2706
+ const jsonMode = process.argv.includes('--json');
2707
+ const io = require('./lib/io');
2708
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'parallel-agents.json');
2709
+
2710
+ if (action === 'run') {
2711
+ const agentsArg = process.argv[4];
2712
+ const agents = agentsArg ? agentsArg.split(',') : [];
2713
+ const result = parallelLib.scheduleRun(agents, { root: process.cwd() }, { stateFile });
2714
+ if (jsonMode) { io.writeResult(result); } else {
2715
+ console.log(result.success ? chalk.green(`āœ… Run scheduled: ${result.run_id}`) : chalk.red(`āŒ ${result.error}`));
2716
+ if (result.success) console.log(chalk.gray(` Agents: ${result.agents.join(', ')}`));
2717
+ }
2718
+ } else if (action === 'reconcile') {
2719
+ const runId = process.argv[4];
2720
+ if (!runId) { console.error(chalk.red('Usage: jumpstart-mode parallel-agents reconcile <run-id>')); process.exit(1); }
2721
+ const result = parallelLib.reconcileRun(runId, { stateFile });
2722
+ if (jsonMode) { io.writeResult(result); } else {
2723
+ if (result.success) {
2724
+ console.log(chalk.bold(`\nšŸ”€ Reconciliation: ${runId}`));
2725
+ console.log(` Total findings: ${result.reconciliation.total_findings}`);
2726
+ console.log(` Conflicts: ${result.reconciliation.conflicts}`);
2727
+ } else { console.error(chalk.red(`āŒ ${result.error}`)); }
2728
+ console.log('');
2729
+ }
2730
+ } else {
2731
+ // status (default) / list
2732
+ const runs = parallelLib.listRuns({ stateFile });
2733
+ if (jsonMode) { io.writeResult(runs); } else {
2734
+ console.log(chalk.bold(`\nšŸ¤– Parallel Agent Runs (${runs.total})`));
2735
+ for (const r of runs.runs) console.log(` ${r.id} [${r.status}] agents=${r.agent_count} ${r.scheduled_at.split('T')[0]}`);
2736
+ console.log('');
2737
+ }
2738
+ }
2739
+ return;
2740
+ }
2741
+
2742
+ // ── Feature 10: Human Approval Workflows with Roles ─────────────────────
2743
+ if (subcommand === 'role-approval') {
2744
+ const roleLib = require('./lib/role-approval');
2745
+ const action = process.argv[3] || 'status';
2746
+ const jsonMode = process.argv.includes('--json');
2747
+ const io = require('./lib/io');
2748
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'role-approvals.json');
2749
+
2750
+ if (action === 'assign') {
2751
+ const artifactArg = process.argv[4];
2752
+ const rolesArg = process.argv[5];
2753
+ if (!artifactArg || !rolesArg) {
2754
+ console.error(chalk.red('Usage: jumpstart-mode role-approval assign <artifact> <role1,role2,...>'));
2755
+ process.exit(1);
2756
+ }
2757
+ const roles = rolesArg.split(',').map(r => ({ role: r.trim(), required: true }));
2758
+ const result = roleLib.assignApprovers(artifactArg, roles, { stateFile });
2759
+ if (jsonMode) { io.writeResult(result); } else {
2760
+ console.log(result.success ? chalk.green(`āœ… Approvers assigned to ${result.artifact}`) : chalk.red(`āŒ ${result.error}`));
2761
+ if (result.success) console.log(chalk.gray(` Roles: ${result.approvers.map(a => a.role).join(', ')}`));
2762
+ }
2763
+ } else if (action === 'approve') {
2764
+ const artifactArg = process.argv[4];
2765
+ const roleArg = process.argv[5];
2766
+ if (!artifactArg || !roleArg) {
2767
+ console.error(chalk.red('Usage: jumpstart-mode role-approval approve <artifact> <role> [--approver <name>]'));
2768
+ process.exit(1);
2769
+ }
2770
+ const nameIdx = process.argv.indexOf('--approver');
2771
+ const result = roleLib.recordRoleAction(artifactArg, roleArg, 'approve', {
2772
+ stateFile,
2773
+ approverName: nameIdx !== -1 ? process.argv[nameIdx + 1] : undefined
2774
+ });
2775
+ if (jsonMode) { io.writeResult(result); } else {
2776
+ console.log(result.success ? chalk.green(`āœ… Approved [${roleArg}]: ${artifactArg} Status: ${result.workflow_status}`) : chalk.red(`āŒ ${result.error}`));
2777
+ if (result.success && result.pending_roles.length > 0) console.log(chalk.gray(` Pending: ${result.pending_roles.join(', ')}`));
2778
+ }
2779
+ } else if (action === 'reject') {
2780
+ const artifactArg = process.argv[4];
2781
+ const roleArg = process.argv[5];
2782
+ if (!artifactArg || !roleArg) {
2783
+ console.error(chalk.red('Usage: jumpstart-mode role-approval reject <artifact> <role>'));
2784
+ process.exit(1);
2785
+ }
2786
+ const result = roleLib.recordRoleAction(artifactArg, roleArg, 'reject', { stateFile });
2787
+ if (jsonMode) { io.writeResult(result); } else {
2788
+ console.log(result.success ? chalk.yellow(`🚫 Rejected [${roleArg}]: ${artifactArg}`) : chalk.red(`āŒ ${result.error}`));
2789
+ }
2790
+ } else {
2791
+ // status (default)
2792
+ const artifactArg = process.argv[4];
2793
+ if (artifactArg) {
2794
+ const result = roleLib.getApprovalStatus(artifactArg, { stateFile });
2795
+ if (jsonMode) { io.writeResult(result); } else {
2796
+ if (result.has_workflow) {
2797
+ const icon = result.fully_approved ? 'āœ…' : 'ā³';
2798
+ console.log(chalk.bold(`\n${icon} Approval Status: ${artifactArg}`));
2799
+ console.log(` Status: ${result.status}`);
2800
+ if (result.pending_roles.length > 0) console.log(` Pending: ${result.pending_roles.join(', ')}`);
2801
+ if (result.approved_roles.length > 0) console.log(` Approved: ${result.approved_roles.join(', ')}`);
2802
+ } else {
2803
+ console.log(chalk.gray(`\n ${result.message}`));
2804
+ }
2805
+ console.log('');
2806
+ }
2807
+ } else {
2808
+ const result = roleLib.listApprovalWorkflows({}, { stateFile });
2809
+ if (jsonMode) { io.writeResult(result); } else {
2810
+ console.log(chalk.bold(`\nšŸ‘„ Approval Workflows (${result.total})`));
2811
+ for (const w of result.workflows) console.log(` [${w.status}] ${w.artifact} roles=${w.approvers.length}`);
2812
+ console.log('');
2813
+ }
2814
+ }
2815
+ }
2816
+ return;
2817
+ }
2818
+
2819
+ // ── Feature 11: Requirements Baseline & Change Control ────────────────
2820
+ if (subcommand === 'requirements-baseline') {
2821
+ const baselineLib = require('./lib/requirements-baseline');
2822
+ const action = process.argv[3] || 'status';
2823
+ const jsonMode = process.argv.includes('--json');
2824
+ const io = require('./lib/io');
2825
+ const root = process.cwd();
2826
+
2827
+ if (action === 'freeze') {
2828
+ const result = baselineLib.freezeBaseline(root, {
2829
+ approver: process.argv.includes('--approver') ? process.argv[process.argv.indexOf('--approver') + 1] : undefined
2830
+ });
2831
+ if (jsonMode) { io.writeResult(result); } else {
2832
+ if (result.success) {
2833
+ console.log(chalk.green(`\nšŸ”’ Requirements baseline frozen`));
2834
+ console.log(` Baseline ID: ${result.baseline_id}`);
2835
+ console.log(` Artifacts frozen: ${result.artifacts_frozen}`);
2836
+ console.log(` Total requirements: ${result.total_requirements}`);
2837
+ for (const s of result.snapshots) console.log(` ${s.type}: ${s.requirements} requirements`);
2838
+ } else { console.error(chalk.red(`āŒ ${result.error}`)); }
2839
+ console.log('');
2840
+ }
2841
+ } else if (action === 'check') {
2842
+ const result = baselineLib.checkBaseline(root);
2843
+ if (jsonMode) { io.writeResult(result); } else {
2844
+ if (result.frozen) {
2845
+ const icon = result.drifted ? 'āš ļø' : 'āœ…';
2846
+ console.log(chalk.bold(`\n${icon} Baseline Check`));
2847
+ console.log(` Baseline: ${result.baseline_id}`);
2848
+ console.log(` Changed: ${result.summary.changed} Unchanged: ${result.summary.unchanged}`);
2849
+ for (const c of result.changes) console.log(` ${c.severity === 'critical' ? 'šŸ”“' : '🟔'} ${c.path}: ${c.change}`);
2850
+ } else { console.log(chalk.gray('\n No frozen baseline found')); }
2851
+ console.log('');
2852
+ }
2853
+ } else if (action === 'impact') {
2854
+ const artifactPath = process.argv[4];
2855
+ if (!artifactPath) { console.error(chalk.red('Usage: jumpstart-mode requirements-baseline impact <artifact-path>')); process.exit(1); }
2856
+ const result = baselineLib.assessImpact(artifactPath, root);
2857
+ if (jsonMode) { io.writeResult(result); } else {
2858
+ console.log(chalk.bold(`\nšŸ“Š Impact Assessment: ${result.artifact || artifactPath}`));
2859
+ console.log(` Impact level: ${result.impact}`);
2860
+ if (result.assessment) {
2861
+ console.log(` Change type: ${result.assessment.change_type}`);
2862
+ if (result.assessment.requires_re_approval) console.log(chalk.yellow(' āš ļø Requires re-approval'));
2863
+ }
2864
+ console.log('');
2865
+ }
2866
+ } else {
2867
+ const result = baselineLib.getBaselineStatus();
2868
+ if (jsonMode) { io.writeResult(result); } else {
2869
+ console.log(chalk.bold('\nšŸ“‹ Requirements Baseline Status'));
2870
+ console.log(` Frozen: ${result.frozen ? 'Yes' : 'No'}`);
2871
+ console.log(` Baselines: ${result.total_baselines}`);
2872
+ console.log(` Pending change requests: ${result.pending_change_requests}`);
2873
+ console.log('');
2874
+ }
2875
+ }
2876
+ return;
2877
+ }
2878
+
2879
+ // ── Feature 12: Cross-artifact Semantic Diffing ───────────────────────
2880
+ if (subcommand === 'semantic-diff') {
2881
+ const diffLib = require('./lib/semantic-diff');
2882
+ const action = process.argv[3] || 'cross-artifact';
2883
+ const jsonMode = process.argv.includes('--json');
2884
+ const io = require('./lib/io');
2885
+ const root = process.cwd();
2886
+
2887
+ if (action === 'compare') {
2888
+ const pathA = process.argv[4];
2889
+ const pathB = process.argv[5];
2890
+ if (!pathA || !pathB) { console.error(chalk.red('Usage: jumpstart-mode semantic-diff compare <file1> <file2>')); process.exit(1); }
2891
+ const result = diffLib.compareFiles(pathA, pathB);
2892
+ if (jsonMode) { io.writeResult(result); } else {
2893
+ if (result.success) {
2894
+ console.log(chalk.bold(`\nšŸ” Semantic Diff`));
2895
+ console.log(` Similarity: ${result.overall_similarity}%`);
2896
+ console.log(` Breaking changes: ${result.has_breaking_changes ? 'Yes' : 'No'}`);
2897
+ console.log(` Sections: +${result.summary.sections_added} -${result.summary.sections_removed} ~${result.summary.sections_modified}`);
2898
+ console.log(` Requirements: +${result.summary.requirements_added} -${result.summary.requirements_removed}`);
2899
+ console.log(` APIs: +${result.summary.apis_added} -${result.summary.apis_removed}`);
2900
+ } else { console.error(chalk.red(`āŒ ${result.error}`)); }
2901
+ console.log('');
2902
+ }
2903
+ } else {
2904
+ const result = diffLib.crossArtifactDiff(root);
2905
+ if (jsonMode) { io.writeResult(result); } else {
2906
+ if (result.success) {
2907
+ console.log(chalk.bold(`\nšŸ” Cross-artifact Semantic Analysis`));
2908
+ console.log(` Artifacts analyzed: ${result.artifacts_analyzed}`);
2909
+ console.log(` Inconsistencies: ${result.summary.total_inconsistencies}`);
2910
+ for (const inc of result.inconsistencies) {
2911
+ console.log(` āš ļø ${inc.type}: ${inc.upstream} → ${inc.downstream}: ${inc.missing_requirements.length} gaps`);
2912
+ }
2913
+ } else { console.error(chalk.red(`āŒ ${result.error}`)); }
2914
+ console.log('');
2915
+ }
2916
+ }
2917
+ return;
2918
+ }
2919
+
2920
+ // ── Feature 13: Native Backlog Synchronization ───────────────────────
2921
+ if (subcommand === 'backlog-sync') {
2922
+ const backlogLib = require('./lib/backlog-sync');
2923
+ const action = process.argv[3] || 'extract';
2924
+ const jsonMode = process.argv.includes('--json');
2925
+ const io = require('./lib/io');
2926
+ const root = process.cwd();
2927
+
2928
+ if (action === 'extract') {
2929
+ const result = backlogLib.extractBacklog(root);
2930
+ if (jsonMode) { io.writeResult(result); } else {
2931
+ console.log(chalk.bold('\nšŸ“‹ Backlog Extraction'));
2932
+ console.log(` Epics: ${result.epics} Stories: ${result.stories} Tasks: ${result.tasks}`);
2933
+ console.log('');
2934
+ }
2935
+ } else if (action === 'export') {
2936
+ const target = process.argv[4];
2937
+ if (!target) { console.error(chalk.red('Usage: jumpstart-mode backlog-sync export <github|jira|azure-devops>')); process.exit(1); }
2938
+ const result = backlogLib.exportBacklog(root, target);
2939
+ if (jsonMode) { io.writeResult(result); } else {
2940
+ if (result.success) {
2941
+ console.log(chalk.green(`\nāœ… Backlog exported for ${target}`));
2942
+ console.log(` Items: ${result.items_exported}`);
2943
+ console.log(` Output: ${result.output}`);
2944
+ } else { console.error(chalk.red(`āŒ ${result.error}`)); }
2945
+ console.log('');
2946
+ }
2947
+ } else {
2948
+ const syncState = backlogLib.loadSyncState(path.join(root, '.jumpstart', 'state', 'backlog-sync.json'));
2949
+ if (jsonMode) { io.writeResult(syncState); } else {
2950
+ console.log(chalk.bold('\nšŸ“‹ Backlog Sync Status'));
2951
+ console.log(` Last sync: ${syncState.last_sync || 'never'}`);
2952
+ console.log(` Exports: ${syncState.export_history.length}`);
2953
+ console.log('');
2954
+ }
2955
+ }
2956
+ return;
2957
+ }
2958
+
2959
+ // ── Feature 14: Delivery Confidence Scoring ──────────────────────────
2960
+ if (subcommand === 'delivery-confidence') {
2961
+ const confLib = require('./lib/delivery-confidence');
2962
+ const action = process.argv[3] || 'project';
2963
+ const jsonMode = process.argv.includes('--json');
2964
+ const io = require('./lib/io');
2965
+ const root = process.cwd();
2966
+
2967
+ if (action === 'score') {
2968
+ const filePath = process.argv[4];
2969
+ if (!filePath) { console.error(chalk.red('Usage: jumpstart-mode delivery-confidence score <file>')); process.exit(1); }
2970
+ const result = confLib.scoreFile(filePath, { root });
2971
+ if (jsonMode) { io.writeResult(result); } else {
2972
+ if (result.success) {
2973
+ console.log(chalk.bold(`\n${result.confidence_emoji} Delivery Confidence: ${result.overall_score}% (${result.confidence_level})`));
2974
+ for (const [dim, data] of Object.entries(result.dimensions)) {
2975
+ console.log(` ${dim}: ${data.score}%`);
2976
+ }
2977
+ if (result.top_gaps.length > 0) console.log(` Gaps: ${result.top_gaps.join(', ')}`);
2978
+ } else { console.error(chalk.red(`āŒ ${result.error}`)); }
2979
+ console.log('');
2980
+ }
2981
+ } else {
2982
+ const result = confLib.scoreProject(root);
2983
+ if (jsonMode) { io.writeResult(result); } else {
2984
+ if (result.success) {
2985
+ console.log(chalk.bold(`\n${result.project_emoji} Project Confidence: ${result.project_score}% (${result.project_confidence})`));
2986
+ for (const a of result.artifacts) {
2987
+ console.log(` ${a.confidence_emoji || 'ā—‹'} ${a.artifact}: ${a.overall_score || 0}%`);
2988
+ }
2989
+ } else { console.error(chalk.red(`āŒ ${result.error}`)); }
2990
+ console.log('');
2991
+ }
2992
+ }
2993
+ return;
2994
+ }
2995
+
2996
+ // ── Feature 15: Rich Plan Execution Engine ───────────────────────────
2997
+ if (subcommand === 'plan-executor') {
2998
+ const execLib = require('./lib/plan-executor');
2999
+ const action = process.argv[3] || 'status';
3000
+ const jsonMode = process.argv.includes('--json');
3001
+ const io = require('./lib/io');
3002
+ const root = process.cwd();
3003
+ const stateFile = path.join(root, '.jumpstart', 'state', 'plan-execution.json');
3004
+
3005
+ if (action === 'init') {
3006
+ const result = execLib.initializeExecution(root, { stateFile });
3007
+ if (jsonMode) { io.writeResult(result); } else {
3008
+ if (result.success) {
3009
+ console.log(chalk.green(`\nāœ… Plan execution initialized`));
3010
+ console.log(` Jobs: ${result.total_jobs}`);
3011
+ console.log(` Milestones: ${result.milestones.join(', ')}`);
3012
+ } else { console.error(chalk.red(`āŒ ${result.error}`)); }
3013
+ console.log('');
3014
+ }
3015
+ } else if (action === 'update') {
3016
+ const jobId = process.argv[4];
3017
+ const status = process.argv[5];
3018
+ if (!jobId || !status) { console.error(chalk.red('Usage: jumpstart-mode plan-executor update <job-id> <status>')); process.exit(1); }
3019
+ const result = execLib.updateJobStatus(jobId, status, { stateFile });
3020
+ if (jsonMode) { io.writeResult(result); } else {
3021
+ console.log(result.success ? chalk.green(`āœ… ${jobId}: ${result.previous_status} → ${result.new_status}`) : chalk.red(`āŒ ${result.error}`));
3022
+ console.log('');
3023
+ }
3024
+ } else if (action === 'verify') {
3025
+ const jobId = process.argv[4];
3026
+ if (!jobId) { console.error(chalk.red('Usage: jumpstart-mode plan-executor verify <job-id>')); process.exit(1); }
3027
+ const result = execLib.verifyJob(jobId, root, { stateFile });
3028
+ if (jsonMode) { io.writeResult(result); } else {
3029
+ console.log(result.success ? (result.verified ? chalk.green(`āœ… ${jobId}: verified`) : chalk.yellow(`āš ļø ${jobId}: verification failed`)) : chalk.red(`āŒ ${result.error}`));
3030
+ console.log('');
3031
+ }
3032
+ } else if (action === 'reset') {
3033
+ const result = execLib.resetExecution({ stateFile });
3034
+ if (jsonMode) { io.writeResult(result); } else {
3035
+ console.log(chalk.green(`āœ… Execution reset (${result.jobs_reset} jobs)`));
3036
+ console.log('');
3037
+ }
3038
+ } else {
3039
+ const result = execLib.getExecutionStatus({ stateFile });
3040
+ if (jsonMode) { io.writeResult(result); } else {
3041
+ if (result.initialized) {
3042
+ console.log(chalk.bold(`\n⚔ Plan Execution: ${result.progress}%`));
3043
+ console.log(` Total: ${result.total_jobs} Completed: ${result.status_counts.completed} In Progress: ${result.status_counts.in_progress} Pending: ${result.status_counts.pending}`);
3044
+ if (result.next_tasks.length > 0) {
3045
+ console.log(' Next tasks:');
3046
+ for (const t of result.next_tasks.slice(0, 5)) console.log(` → ${t.id}: ${t.title}`);
3047
+ }
3048
+ } else { console.log(chalk.gray('\n No execution plan loaded. Run: jumpstart-mode plan-executor init')); }
3049
+ console.log('');
3050
+ }
3051
+ }
3052
+ return;
3053
+ }
3054
+
3055
+ // ── Feature 16: Architectural Fitness Functions ──────────────────────
3056
+ if (subcommand === 'fitness-functions') {
3057
+ const fitnessLib = require('./lib/fitness-functions');
3058
+ const action = process.argv[3] || 'evaluate';
3059
+ const jsonMode = process.argv.includes('--json');
3060
+ const io = require('./lib/io');
3061
+ const root = process.cwd();
3062
+ const registryFile = path.join(root, '.jumpstart', 'fitness-functions.json');
3063
+
3064
+ if (action === 'add') {
3065
+ const name = process.argv[4];
3066
+ const category = process.argv[5];
3067
+ if (!name || !category) { console.error(chalk.red('Usage: jumpstart-mode fitness-functions add <name> <category> [--pattern <regex>] [--threshold <n>]')); process.exit(1); }
3068
+ const patternIdx = process.argv.indexOf('--pattern');
3069
+ const thresholdIdx = process.argv.indexOf('--threshold');
3070
+ const result = fitnessLib.addFitnessFunction({
3071
+ name,
3072
+ category,
3073
+ description: `Fitness function: ${name}`,
3074
+ pattern: patternIdx !== -1 ? process.argv[patternIdx + 1] : null,
3075
+ threshold: thresholdIdx !== -1 ? parseInt(process.argv[thresholdIdx + 1]) : null
3076
+ }, { registryFile });
3077
+ if (jsonMode) { io.writeResult(result); } else {
3078
+ console.log(result.success ? chalk.green(`āœ… Fitness function added: ${name}`) : chalk.red(`āŒ ${result.error}`));
3079
+ console.log('');
3080
+ }
3081
+ } else if (action === 'list') {
3082
+ const result = fitnessLib.listFitnessFunctions({}, { registryFile });
3083
+ if (jsonMode) { io.writeResult(result); } else {
3084
+ console.log(chalk.bold(`\nšŸ‹ļø Fitness Functions (${result.total})`));
3085
+ for (const f of result.functions) console.log(` [${f.enabled ? 'āœ“' : 'āœ—'}] ${f.name} (${f.category})`);
3086
+ console.log('');
3087
+ }
3088
+ } else {
3089
+ const result = fitnessLib.evaluateFitness(root, { registryFile });
3090
+ if (jsonMode) { io.writeResult(result); } else {
3091
+ const icon = result.all_passed ? 'āœ…' : 'āŒ';
3092
+ console.log(chalk.bold(`\n${icon} Fitness Evaluation`));
3093
+ console.log(` Functions: ${result.summary.total_functions} Passed: ${result.summary.passed} Failed: ${result.summary.failed}`);
3094
+ for (const r of result.results.filter(r => !r.passed)) {
3095
+ console.log(` šŸ”“ ${r.name}: ${r.violations} violations`);
3096
+ }
3097
+ console.log('');
3098
+ }
3099
+ }
3100
+ return;
3101
+ }
3102
+
3103
+ // ── Feature 17: Org-wide Reusable Reference Architectures ───────────
3104
+ if (subcommand === 'reference-arch') {
3105
+ const refLib = require('./lib/reference-architectures');
3106
+ const action = process.argv[3] || 'list';
3107
+ const jsonMode = process.argv.includes('--json');
3108
+ const io = require('./lib/io');
3109
+ const root = process.cwd();
3110
+
3111
+ if (action === 'get') {
3112
+ const patternId = process.argv[4];
3113
+ if (!patternId) { console.error(chalk.red('Usage: jumpstart-mode reference-arch get <pattern-id>')); process.exit(1); }
3114
+ const result = refLib.getPattern(patternId);
3115
+ if (jsonMode) { io.writeResult(result); } else {
3116
+ if (result.success) {
3117
+ const p = result.pattern;
3118
+ console.log(chalk.bold(`\nšŸ“ ${p.name} (${p.category})`));
3119
+ console.log(` ${p.description}`);
3120
+ console.log(` Components: ${p.components.join(', ')}`);
3121
+ console.log(' Structure:');
3122
+ for (const [dir, desc] of Object.entries(p.structure || {})) console.log(` ${dir} — ${desc}`);
3123
+ if (p.nfrs.length > 0) console.log(` NFRs: ${p.nfrs.join('; ')}`);
3124
+ } else { console.error(chalk.red(`āŒ ${result.error}`)); }
3125
+ console.log('');
3126
+ }
3127
+ } else if (action === 'register') {
3128
+ const name = process.argv[4];
3129
+ const category = process.argv[5];
3130
+ if (!name) { console.error(chalk.red('Usage: jumpstart-mode reference-arch register <name> [category]')); process.exit(1); }
3131
+ const result = refLib.registerPattern({ name, category: category || 'other', description: `Custom pattern: ${name}` });
3132
+ if (jsonMode) { io.writeResult(result); } else {
3133
+ console.log(result.success ? chalk.green(`āœ… Pattern registered: ${name}`) : chalk.red(`āŒ ${result.error}`));
3134
+ console.log('');
3135
+ }
3136
+ } else if (action === 'instantiate') {
3137
+ const patternId = process.argv[4];
3138
+ if (!patternId) { console.error(chalk.red('Usage: jumpstart-mode reference-arch instantiate <pattern-id>')); process.exit(1); }
3139
+ const result = refLib.instantiatePattern(patternId, root);
3140
+ if (jsonMode) { io.writeResult(result); } else {
3141
+ if (result.success) {
3142
+ console.log(chalk.green(`\nāœ… Pattern instantiated: ${result.pattern_name}`));
3143
+ console.log(` Directories created: ${result.directories_created.length}`);
3144
+ console.log(` Components: ${result.components.join(', ')}`);
3145
+ } else { console.error(chalk.red(`āŒ ${result.error}`)); }
3146
+ console.log('');
3147
+ }
3148
+ } else {
3149
+ const result = refLib.listPatterns();
3150
+ if (jsonMode) { io.writeResult(result); } else {
3151
+ console.log(chalk.bold(`\nšŸ“ Reference Architectures (${result.total})`));
3152
+ for (const p of result.patterns) console.log(` ${p.id} (${p.category}): ${p.name} — ${p.components} components`);
3153
+ console.log(` Categories: ${result.categories.join(', ')}`);
3154
+ console.log('');
3155
+ }
3156
+ }
3157
+ return;
3158
+ }
3159
+
3160
+ // ── Feature 18: Decision Conflict Detection ─────────────────────────
3161
+ if (subcommand === 'decision-conflicts') {
3162
+ const conflictsLib = require('./lib/decision-conflicts');
3163
+ const jsonMode = process.argv.includes('--json');
3164
+ const io = require('./lib/io');
3165
+ const root = process.cwd();
3166
+
3167
+ const result = conflictsLib.detectConflicts(root);
3168
+ if (jsonMode) { io.writeResult(result); } else {
3169
+ if (result.success) {
3170
+ const icon = result.summary.has_conflicts ? 'āš ļø' : 'āœ…';
3171
+ console.log(chalk.bold(`\n${icon} Decision Conflict Analysis`));
3172
+ console.log(` Decisions analyzed: ${result.total_decisions}`);
3173
+ console.log(` Conflicts found: ${result.summary.total_conflicts}`);
3174
+ for (const c of result.conflicts) {
3175
+ console.log(` šŸ”ø ${c.type}: ${c.description}`);
3176
+ console.log(` Sources: ${c.sources.join(', ')}`);
3177
+ }
3178
+ } else { console.error(chalk.red(`āŒ ${result.error}`)); }
3179
+ console.log('');
3180
+ }
3181
+ return;
3182
+ }
3183
+
3184
+ // ── Feature 19: Spec Maturity Model ─────────────────────────────────
3185
+ if (subcommand === 'spec-maturity') {
3186
+ const maturityLib = require('./lib/spec-maturity');
3187
+ const action = process.argv[3] || 'project';
3188
+ const jsonMode = process.argv.includes('--json');
3189
+ const io = require('./lib/io');
3190
+ const root = process.cwd();
3191
+
3192
+ if (action === 'assess') {
3193
+ const filePath = process.argv[4];
3194
+ if (!filePath) { console.error(chalk.red('Usage: jumpstart-mode spec-maturity assess <file>')); process.exit(1); }
3195
+ const result = maturityLib.assessFile(filePath);
3196
+ if (jsonMode) { io.writeResult(result); } else {
3197
+ if (result.success) {
3198
+ console.log(chalk.bold(`\nšŸ“Š Maturity: L${result.maturity_level} ${result.maturity_name} (${result.overall_score}%)`));
3199
+ for (const [cat, data] of Object.entries(result.category_scores)) {
3200
+ console.log(` ${cat}: ${data.score}% (${data.passed}/${data.total})`);
3201
+ }
3202
+ if (result.next_level) console.log(` Next level: L${result.next_level.level} ${result.next_level.name} (need +${result.next_level.points_needed} points)`);
3203
+ if (result.gaps.length > 0) console.log(` Gaps: ${result.gaps.slice(0, 5).map(g => g.check).join(', ')}`);
3204
+ } else { console.error(chalk.red(`āŒ ${result.error}`)); }
3205
+ console.log('');
3206
+ }
3207
+ } else {
3208
+ const result = maturityLib.assessProject(root);
3209
+ if (jsonMode) { io.writeResult(result); } else {
3210
+ if (result.success) {
3211
+ console.log(chalk.bold(`\nšŸ“Š Project Maturity: L${result.project_level} ${result.project_maturity} (${result.project_score}%)`));
3212
+ for (const a of result.artifacts) {
3213
+ console.log(` L${a.maturity_level || 1} ${a.artifact}: ${a.overall_score || 0}% (${a.maturity_name || 'Draft'})`);
3214
+ }
3215
+ console.log(` Production-ready: ${result.summary.production_ready}/${result.summary.artifacts_assessed}`);
3216
+ } else { console.error(chalk.red(`āŒ ${result.error}`)); }
3217
+ console.log('');
3218
+ }
3219
+ }
3220
+ return;
3221
+ }
3222
+
3223
+ // ── Feature 20: Portfolio Reporting Layer ────────────────────────────
3224
+ if (subcommand === 'portfolio') {
3225
+ const portfolioLib = require('./lib/portfolio-reporting');
3226
+ const action = process.argv[3] || 'status';
3227
+ const jsonMode = process.argv.includes('--json');
3228
+ const io = require('./lib/io');
3229
+ const portfolioFile = path.join(process.cwd(), '.jumpstart', 'state', 'portfolio.json');
3230
+
3231
+ if (action === 'register') {
3232
+ const name = process.argv[4];
3233
+ if (!name) { console.error(chalk.red('Usage: jumpstart-mode portfolio register <name> [--path <dir>] [--owner <name>]')); process.exit(1); }
3234
+ const pathIdx = process.argv.indexOf('--path');
3235
+ const ownerIdx = process.argv.indexOf('--owner');
3236
+ const result = portfolioLib.registerInitiative({
3237
+ name,
3238
+ path: pathIdx !== -1 ? process.argv[pathIdx + 1] : null,
3239
+ owner: ownerIdx !== -1 ? process.argv[ownerIdx + 1] : null
3240
+ }, { portfolioFile });
3241
+ if (jsonMode) { io.writeResult(result); } else {
3242
+ console.log(result.success ? chalk.green(`āœ… Initiative registered: ${name}`) : chalk.red(`āŒ ${result.error}`));
3243
+ console.log('');
3244
+ }
3245
+ } else if (action === 'refresh') {
3246
+ const initId = process.argv[4];
3247
+ if (!initId) { console.error(chalk.red('Usage: jumpstart-mode portfolio refresh <initiative-id>')); process.exit(1); }
3248
+ const result = portfolioLib.refreshInitiative(initId, { portfolioFile });
3249
+ if (jsonMode) { io.writeResult(result); } else {
3250
+ if (result.success) {
3251
+ const i = result.initiative;
3252
+ console.log(chalk.bold(`\nšŸ”„ ${i.name}`));
3253
+ console.log(` Status: ${i.status} Phase: ${i.current_phase} Progress: ${i.phase_progress}%`);
3254
+ } else { console.error(chalk.red(`āŒ ${result.error}`)); }
3255
+ console.log('');
3256
+ }
3257
+ } else if (action === 'snapshot') {
3258
+ const result = portfolioLib.takeSnapshot({ portfolioFile });
3259
+ if (jsonMode) { io.writeResult(result); } else {
3260
+ console.log(chalk.green(`āœ… Portfolio snapshot taken at ${result.snapshot.taken_at}`));
3261
+ console.log('');
3262
+ }
3263
+ } else if (action === 'remove') {
3264
+ const initId = process.argv[4];
3265
+ if (!initId) { console.error(chalk.red('Usage: jumpstart-mode portfolio remove <initiative-id>')); process.exit(1); }
3266
+ const result = portfolioLib.removeInitiative(initId, { portfolioFile });
3267
+ if (jsonMode) { io.writeResult(result); } else {
3268
+ console.log(result.success ? chalk.green(`āœ… Removed: ${result.removed}`) : chalk.red(`āŒ ${result.error}`));
3269
+ console.log('');
3270
+ }
3271
+ } else {
3272
+ const result = portfolioLib.getPortfolioStatus({ portfolioFile });
3273
+ if (jsonMode) { io.writeResult(result); } else {
3274
+ console.log(chalk.bold(`\nšŸ“Š Portfolio Status (${result.total_initiatives} initiatives)`));
3275
+ console.log(` Average progress: ${result.average_progress}%`);
3276
+ console.log(` On-track: ${result.status_counts['on-track']} At-risk: ${result.status_counts['at-risk']} Blocked: ${result.status_counts['blocked']} Completed: ${result.status_counts['completed']}`);
3277
+ if (result.budget.total > 0) console.log(` Budget: $${result.budget.spent}/$${result.budget.total} (${Math.round((result.budget.spent/result.budget.total)*100)}%)`);
3278
+ for (const i of result.initiatives) {
3279
+ console.log(` [${i.status}] ${i.name}: ${i.progress}% (${i.readiness})`);
3280
+ }
3281
+ if (result.blockers.length > 0) {
3282
+ console.log(' Blockers:');
3283
+ for (const b of result.blockers) console.log(` šŸ”“ ${b.initiative}: ${b.blocker}`);
3284
+ }
3285
+ console.log('');
3286
+ }
3287
+ }
3288
+ return;
3289
+ }
3290
+
3291
+ // ── Feature 21: CI/CD Integration ─────────────────────────────────────
3292
+ if (subcommand === 'ci-cd-integration') {
3293
+ const lib = require('./lib/ci-cd-integration');
3294
+ const action = process.argv[3] || 'status';
3295
+ const jsonMode = process.argv.includes('--json');
3296
+ const io = require('./lib/io');
3297
+ if (action === 'generate') {
3298
+ const platform = process.argv[4] || 'github-actions';
3299
+ const result = lib.generatePipeline(platform);
3300
+ if (jsonMode) { io.writeResult(result); } else {
3301
+ console.log(result.success ? chalk.green(`āœ… Pipeline generated for ${platform}: ${result.path}`) : chalk.red(`āŒ ${result.error}`));
3302
+ }
3303
+ } else if (action === 'validate') {
3304
+ const result = lib.validatePipeline(process.cwd());
3305
+ if (jsonMode) { io.writeResult(result); } else {
3306
+ console.log(chalk.bold('\nšŸ”„ CI/CD Pipeline Validation'));
3307
+ for (const p of result.pipelines) console.log(` ${p.exists ? 'āœ…' : 'āŒ'} ${p.platform}: ${p.path}`);
3308
+ console.log('');
3309
+ }
3310
+ } else {
3311
+ const result = lib.getStatus();
3312
+ if (jsonMode) { io.writeResult(result); } else {
3313
+ console.log(chalk.bold(`\nšŸ”„ CI/CD Integration Status`));
3314
+ console.log(` Available checks: ${result.available_checks}`);
3315
+ console.log(` Pipelines: ${result.pipelines} Runs: ${result.total_runs}\n`);
3316
+ }
3317
+ }
3318
+ return;
3319
+ }
3320
+
3321
+ // ── Feature 22: Environment Promotion ────────────────────────────────────
3322
+ if (subcommand === 'env-promotion') {
3323
+ const lib = require('./lib/environment-promotion');
3324
+ const action = process.argv[3] || 'status';
3325
+ const jsonMode = process.argv.includes('--json');
3326
+ const io = require('./lib/io');
3327
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'environment-promotion.json');
3328
+ if (action === 'promote') {
3329
+ const target = process.argv[4];
3330
+ if (!target) { console.error(chalk.red('Usage: jumpstart-mode env-promotion promote <environment>')); process.exit(1); }
3331
+ const result = lib.promote(target, { stateFile });
3332
+ if (jsonMode) { io.writeResult(result); } else {
3333
+ console.log(result.success ? chalk.green(`āœ… Promoted to ${result.to}`) : chalk.red(`āŒ ${result.error}`));
3334
+ }
3335
+ } else if (action === 'gate') {
3336
+ const env = process.argv[4];
3337
+ if (!env) { console.error(chalk.red('Usage: jumpstart-mode env-promotion gate <environment>')); process.exit(1); }
3338
+ const result = lib.checkGates(env, { stateFile });
3339
+ if (jsonMode) { io.writeResult(result); } else {
3340
+ console.log(chalk.bold(`\n🚦 Gate Status: ${env}`));
3341
+ console.log(` Passed: ${result.passed.join(', ') || 'none'}`);
3342
+ console.log(` Pending: ${result.pending.join(', ') || 'none'}\n`);
3343
+ }
3344
+ } else {
3345
+ const result = lib.getStatus({ stateFile });
3346
+ if (jsonMode) { io.writeResult(result); } else {
3347
+ console.log(chalk.bold(`\nšŸŒ Environment Promotion Status`));
3348
+ console.log(` Current: ${result.current_environment}`);
3349
+ for (const e of result.environments) console.log(` ${e.ready ? 'āœ…' : 'ā³'} ${e.name}: ${e.gates_passed}/${e.gates_total} gates`);
3350
+ console.log('');
3351
+ }
3352
+ }
3353
+ return;
3354
+ }
3355
+
3356
+ // ── Feature 23: RACI Matrix ──────────────────────────────────────────────
3357
+ if (subcommand === 'raci-matrix') {
3358
+ const lib = require('./lib/raci-matrix');
3359
+ const action = process.argv[3] || 'report';
3360
+ const jsonMode = process.argv.includes('--json');
3361
+ const io = require('./lib/io');
3362
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'raci-matrix.json');
3363
+ if (action === 'define') {
3364
+ const artifact = process.argv[4];
3365
+ const accountable = process.argv[5];
3366
+ if (!artifact || !accountable) { console.error(chalk.red('Usage: jumpstart-mode raci-matrix define <artifact> <accountable>')); process.exit(1); }
3367
+ const result = lib.defineAssignment(artifact, { accountable }, { stateFile });
3368
+ if (jsonMode) { io.writeResult(result); } else {
3369
+ console.log(result.success ? chalk.green(`āœ… RACI defined for ${artifact}`) : chalk.red(`āŒ ${result.error}`));
3370
+ }
3371
+ } else if (action === 'check') {
3372
+ const artifact = process.argv[4];
3373
+ const actor = process.argv[5];
3374
+ if (!artifact || !actor) { console.error(chalk.red('Usage: jumpstart-mode raci-matrix check <artifact> <actor>')); process.exit(1); }
3375
+ const result = lib.checkPermission(artifact, actor, 'approve', { stateFile });
3376
+ if (jsonMode) { io.writeResult(result); } else {
3377
+ console.log(result.allowed ? chalk.green(`āœ… ${result.reason}`) : chalk.red(`āŒ ${result.reason}`));
3378
+ }
3379
+ } else {
3380
+ const result = lib.generateReport({ stateFile });
3381
+ if (jsonMode) { io.writeResult(result); } else {
3382
+ console.log(chalk.bold(`\nšŸ“‹ RACI Matrix (${result.total_assignments} assignments, ${result.coverage}% coverage)`));
3383
+ for (const row of result.matrix) console.log(` ${row.artifact}: R=${row.R} A=${row.A} C=${row.C || '-'} I=${row.I || '-'}`);
3384
+ if (result.gaps.length > 0) console.log(chalk.yellow(` Gaps: ${result.gaps.join(', ')}`));
3385
+ console.log('');
3386
+ }
3387
+ }
3388
+ return;
3389
+ }
3390
+
3391
+ // ── Feature 24: Compliance Packs ─────────────────────────────────────────
3392
+ if (subcommand === 'compliance-packs') {
3393
+ const lib = require('./lib/compliance-packs');
3394
+ const action = process.argv[3] || 'list';
3395
+ const jsonMode = process.argv.includes('--json');
3396
+ const io = require('./lib/io');
3397
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'compliance.json');
3398
+ if (action === 'list') {
3399
+ const result = lib.listFrameworks();
3400
+ if (jsonMode) { io.writeResult(result); } else {
3401
+ console.log(chalk.bold(`\nšŸ“¦ Compliance Frameworks (${result.total})`));
3402
+ for (const fw of result.frameworks) console.log(` ${fw.id}: ${fw.name} (${fw.controls} controls)`);
3403
+ console.log('');
3404
+ }
3405
+ } else if (action === 'apply') {
3406
+ const fw = process.argv[4];
3407
+ if (!fw) { console.error(chalk.red('Usage: jumpstart-mode compliance-packs apply <framework-id>')); process.exit(1); }
3408
+ const result = lib.applyFramework(fw, { stateFile });
3409
+ if (jsonMode) { io.writeResult(result); } else {
3410
+ console.log(result.success ? chalk.green(`āœ… Applied ${result.name} (${result.controls_added} controls)`) : chalk.red(`āŒ ${result.error}`));
3411
+ }
3412
+ } else if (action === 'check') {
3413
+ const result = lib.checkCompliance({ stateFile });
3414
+ if (jsonMode) { io.writeResult(result); } else {
3415
+ console.log(chalk.bold(`\nšŸ” Compliance Check`));
3416
+ console.log(` Frameworks: ${result.applied_frameworks?.join(', ') || 'none'}`);
3417
+ console.log(` Controls: ${result.total_controls || 0} Compliant: ${result.compliant}\n`);
3418
+ }
3419
+ }
3420
+ return;
3421
+ }
3422
+
3423
+ // ── Feature 25: Evidence Collector ────────────────────────────────────────
3424
+ if (subcommand === 'evidence-collector') {
3425
+ const lib = require('./lib/evidence-collector');
3426
+ const action = process.argv[3] || 'status';
3427
+ const jsonMode = process.argv.includes('--json');
3428
+ const io = require('./lib/io');
3429
+ const root = process.cwd();
3430
+ if (action === 'collect') {
3431
+ const result = lib.collectEvidence(root);
3432
+ if (jsonMode) { io.writeResult(result); } else {
3433
+ console.log(chalk.green(`āœ… Collected ${result.items_collected} evidence items`));
3434
+ }
3435
+ } else if (action === 'package') {
3436
+ const result = lib.packageEvidence(root);
3437
+ if (jsonMode) { io.writeResult(result); } else {
3438
+ console.log(result.success ? chalk.green(`āœ… Evidence packaged: ${result.output}`) : chalk.red(`āŒ ${result.error}`));
3439
+ }
3440
+ } else {
3441
+ const result = lib.getStatus();
3442
+ if (jsonMode) { io.writeResult(result); } else {
3443
+ console.log(chalk.bold(`\nšŸ“¦ Evidence Status: ${result.total_items} items, ${result.collections} collections\n`));
3444
+ }
3445
+ }
3446
+ return;
3447
+ }
3448
+
3449
+ // ── Feature 26: Release Readiness ────────────────────────────────────────
3450
+ if (subcommand === 'release-readiness') {
3451
+ const lib = require('./lib/release-readiness');
3452
+ const action = process.argv[3] || 'report';
3453
+ const jsonMode = process.argv.includes('--json');
3454
+ const io = require('./lib/io');
3455
+ const root = process.cwd();
3456
+ if (action === 'assess') {
3457
+ const result = lib.assessReadiness(root);
3458
+ if (jsonMode) { io.writeResult(result); } else {
3459
+ console.log(chalk.bold(`\nšŸš€ Release Readiness: ${result.level} (${result.total_score}%)`));
3460
+ console.log(` Recommendation: ${result.recommendation}`);
3461
+ if (result.blockers.length > 0) console.log(chalk.red(` Blockers: ${result.blockers.join(', ')}`));
3462
+ console.log('');
3463
+ }
3464
+ } else {
3465
+ const result = lib.generateReport({ stateFile: path.join(root, '.jumpstart', 'state', 'release-readiness.json') });
3466
+ if (jsonMode) { io.writeResult(result); } else {
3467
+ if (result.success) {
3468
+ console.log(chalk.bold(`\nšŸš€ Release Readiness Report: ${result.level} (${result.total_score}%)`));
3469
+ for (const cat of result.categories) console.log(` ${cat.status === 'pass' ? 'āœ…' : cat.status === 'warning' ? 'āš ļø' : 'āŒ'} ${cat.name}: ${cat.score}%`);
3470
+ } else {
3471
+ console.log(chalk.yellow(` ${result.error}`));
3472
+ }
3473
+ console.log('');
3474
+ }
3475
+ }
3476
+ return;
3477
+ }
3478
+
3479
+ // ── Feature 27: Waiver Workflow ──────────────────────────────────────────
3480
+ if (subcommand === 'waiver-workflow') {
3481
+ const lib = require('./lib/waiver-workflow');
3482
+ const action = process.argv[3] || 'list';
3483
+ const jsonMode = process.argv.includes('--json');
3484
+ const io = require('./lib/io');
3485
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'waivers.json');
3486
+ if (action === 'request') {
3487
+ const title = process.argv[4];
3488
+ const owner = process.argv[5];
3489
+ if (!title || !owner) { console.error(chalk.red('Usage: jumpstart-mode waiver-workflow request <title> <owner>')); process.exit(1); }
3490
+ const result = lib.requestWaiver({ title, owner, justification: 'CLI request' }, { stateFile });
3491
+ if (jsonMode) { io.writeResult(result); } else {
3492
+ console.log(result.success ? chalk.green(`āœ… Waiver requested: ${result.waiver.id}`) : chalk.red(`āŒ ${result.error}`));
3493
+ }
3494
+ } else if (action === 'approve') {
3495
+ const waiverId = process.argv[4];
3496
+ if (!waiverId) { console.error(chalk.red('Usage: jumpstart-mode waiver-workflow approve <waiver-id>')); process.exit(1); }
3497
+ const result = lib.resolveWaiver(waiverId, 'approve', { stateFile });
3498
+ if (jsonMode) { io.writeResult(result); } else {
3499
+ console.log(result.success ? chalk.green(`āœ… Waiver approved: ${waiverId}`) : chalk.red(`āŒ ${result.error}`));
3500
+ }
3501
+ } else if (action === 'expire') {
3502
+ const result = lib.expireWaivers({ stateFile });
3503
+ if (jsonMode) { io.writeResult(result); } else {
3504
+ console.log(chalk.green(`āœ… Expired ${result.expired} waivers`));
3505
+ }
3506
+ } else {
3507
+ const result = lib.listWaivers({}, { stateFile });
3508
+ if (jsonMode) { io.writeResult(result); } else {
3509
+ console.log(chalk.bold(`\nšŸ“‹ Waivers (${result.total})`));
3510
+ for (const w of result.waivers) console.log(` [${w.status}] ${w.id}: ${w.title} (${w.owner})`);
3511
+ console.log('');
3512
+ }
3513
+ }
3514
+ return;
3515
+ }
3516
+
3517
+ // ── Feature 28: SLA/SLO ──────────────────────────────────────────────────
3518
+ if (subcommand === 'sla-slo') {
3519
+ const lib = require('./lib/sla-slo');
3520
+ const action = process.argv[3] || 'report';
3521
+ const jsonMode = process.argv.includes('--json');
3522
+ const io = require('./lib/io');
3523
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'sla-slo.json');
3524
+ if (action === 'define') {
3525
+ const name = process.argv[4];
3526
+ const service = process.argv[5];
3527
+ const target = process.argv[6];
3528
+ if (!name || !service || !target) { console.error(chalk.red('Usage: jumpstart-mode sla-slo define <name> <service> <target>')); process.exit(1); }
3529
+ const result = lib.defineSLO({ name, service, target: parseFloat(target) }, { stateFile });
3530
+ if (jsonMode) { io.writeResult(result); } else {
3531
+ console.log(result.success ? chalk.green(`āœ… SLO defined: ${result.slo.id}`) : chalk.red(`āŒ ${result.error}`));
3532
+ }
3533
+ } else if (action === 'check') {
3534
+ const result = lib.checkSLOCoverage(process.cwd(), { stateFile });
3535
+ if (jsonMode) { io.writeResult(result); } else {
3536
+ console.log(chalk.bold(`\nšŸ“Š SLO Coverage: ${result.defined_slos} SLOs defined`));
3537
+ console.log(` Architecture mentions SLO: ${result.architecture_mentions_slo}`);
3538
+ console.log(` PRD mentions SLO: ${result.prd_mentions_slo}\n`);
3539
+ }
3540
+ } else {
3541
+ const result = lib.generateReport({ stateFile });
3542
+ if (jsonMode) { io.writeResult(result); } else {
3543
+ console.log(chalk.bold(`\nšŸ“Š SLA/SLO Report: ${result.total_slos} SLOs, ${result.total_slas} SLAs\n`));
3544
+ }
3545
+ }
3546
+ return;
3547
+ }
3548
+
3549
+ // ── Feature 29: Risk Register ────────────────────────────────────────────
3550
+ if (subcommand === 'risk-register') {
3551
+ const lib = require('./lib/risk-register');
3552
+ const action = process.argv[3] || 'report';
3553
+ const jsonMode = process.argv.includes('--json');
3554
+ const io = require('./lib/io');
3555
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'risk-register.json');
3556
+ if (action === 'add') {
3557
+ const title = process.argv[4];
3558
+ if (!title) { console.error(chalk.red('Usage: jumpstart-mode risk-register add <title>')); process.exit(1); }
3559
+ const result = lib.addRisk({ title, description: title }, { stateFile });
3560
+ if (jsonMode) { io.writeResult(result); } else {
3561
+ console.log(result.success ? chalk.green(`āœ… Risk added: ${result.risk.id} (score: ${result.risk.score})`) : chalk.red(`āŒ ${result.error}`));
3562
+ }
3563
+ } else if (action === 'list') {
3564
+ const result = lib.listRisks({}, { stateFile });
3565
+ if (jsonMode) { io.writeResult(result); } else {
3566
+ console.log(chalk.bold(`\nāš ļø Risk Register (${result.total})`));
3567
+ for (const r of result.risks) console.log(` [${r.status}] ${r.id}: ${r.title} (${r.likelihood}/${r.impact}, score=${r.score})`);
3568
+ console.log('');
3569
+ }
3570
+ } else {
3571
+ const result = lib.generateReport({ stateFile });
3572
+ if (jsonMode) { io.writeResult(result); } else {
3573
+ console.log(chalk.bold(`\nāš ļø Risk Report: ${result.total_risks} risks, avg score=${result.average_score}`));
3574
+ console.log(` High: ${result.high_risks} Unmitigated: ${result.unmitigated}\n`);
3575
+ }
3576
+ }
3577
+ return;
3578
+ }
3579
+
3580
+ // ── Feature 30: Data Classification ──────────────────────────────────────
3581
+ if (subcommand === 'data-classification') {
3582
+ const lib = require('./lib/data-classification');
3583
+ const action = process.argv[3] || 'report';
3584
+ const jsonMode = process.argv.includes('--json');
3585
+ const io = require('./lib/io');
3586
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'data-classification.json');
3587
+ if (action === 'classify') {
3588
+ const name = process.argv[4];
3589
+ if (!name) { console.error(chalk.red('Usage: jumpstart-mode data-classification classify <asset-name>')); process.exit(1); }
3590
+ const result = lib.classifyAsset({ name }, { stateFile });
3591
+ if (jsonMode) { io.writeResult(result); } else {
3592
+ console.log(result.success ? chalk.green(`āœ… Classified: ${result.asset.classification}`) : chalk.red(`āŒ ${result.error}`));
3593
+ }
3594
+ } else if (action === 'check') {
3595
+ const result = lib.checkCompliance({ stateFile });
3596
+ if (jsonMode) { io.writeResult(result); } else {
3597
+ console.log(chalk.bold(`\nšŸ·ļø Data Classification: ${result.total_assets} assets, ${result.violations} violations\n`));
3598
+ }
3599
+ } else {
3600
+ const result = lib.generateReport({ stateFile });
3601
+ if (jsonMode) { io.writeResult(result); } else {
3602
+ console.log(chalk.bold(`\nšŸ·ļø Data Classification Report: ${result.total_assets} assets`));
3603
+ for (const [level, count] of Object.entries(result.by_level)) console.log(` ${level}: ${count}`);
3604
+ console.log('');
3605
+ }
3606
+ }
3607
+ return;
3608
+ }
3609
+
3610
+ // ── Feature 31: Credential Boundary ──────────────────────────────────────
3611
+ if (subcommand === 'credential-boundary') {
3612
+ const lib = require('./lib/credential-boundary');
3613
+ const action = process.argv[3] || 'scan';
3614
+ const jsonMode = process.argv.includes('--json');
3615
+ const io = require('./lib/io');
3616
+ const root = process.cwd();
3617
+ const result = lib.scanProject(root);
3618
+ if (jsonMode) { io.writeResult(result); } else {
3619
+ console.log(chalk.bold(`\nšŸ” Credential Boundary Scan`));
3620
+ console.log(` Files scanned: ${result.files_scanned}`);
3621
+ console.log(` Findings: ${result.total_findings} (${result.critical} critical, ${result.high} high)`);
3622
+ console.log(` ${result.pass ? chalk.green('āœ… PASS') : chalk.red('āŒ FAIL')}\n`);
3623
+ }
3624
+ return;
3625
+ }
3626
+
3627
+ // ── Feature 32: EA Review Packet ─────────────────────────────────────────
3628
+ if (subcommand === 'ea-review-packet') {
3629
+ const lib = require('./lib/ea-review-packet');
3630
+ const jsonMode = process.argv.includes('--json');
3631
+ const io = require('./lib/io');
3632
+ const result = lib.generatePacket(process.cwd());
3633
+ if (jsonMode) { io.writeResult(result); } else {
3634
+ console.log(chalk.bold(`\nšŸ¢ EA Review Packet: ${result.completeness}% complete`));
3635
+ for (const [section, data] of Object.entries(result.sections)) console.log(` ${data.present ? 'āœ…' : 'āŒ'} ${section}`);
3636
+ if (result.gaps.length > 0) console.log(chalk.yellow(` Gaps: ${result.gaps.join(', ')}`));
3637
+ console.log('');
3638
+ }
3639
+ return;
3640
+ }
3641
+
3642
+ // ── Feature 33: Model Governance ─────────────────────────────────────────
3643
+ if (subcommand === 'model-governance') {
3644
+ const lib = require('./lib/model-governance');
3645
+ const action = process.argv[3] || 'report';
3646
+ const jsonMode = process.argv.includes('--json');
3647
+ const io = require('./lib/io');
3648
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'model-governance.json');
3649
+ if (action === 'register') {
3650
+ const name = process.argv[4];
3651
+ const provider = process.argv[5];
3652
+ if (!name || !provider) { console.error(chalk.red('Usage: jumpstart-mode model-governance register <name> <provider>')); process.exit(1); }
3653
+ const result = lib.registerModel({ name, provider }, { stateFile });
3654
+ if (jsonMode) { io.writeResult(result); } else {
3655
+ console.log(result.success ? chalk.green(`āœ… Model registered: ${result.model.id}`) : chalk.red(`āŒ ${result.error}`));
3656
+ }
3657
+ } else {
3658
+ const result = lib.generateReport({ stateFile });
3659
+ if (jsonMode) { io.writeResult(result); } else {
3660
+ console.log(chalk.bold(`\nšŸ¤– Model Governance: ${result.total_models} models, ${result.total_evaluations} evaluations`));
3661
+ if (result.high_risk_models.length > 0) console.log(chalk.yellow(` High risk: ${result.high_risk_models.map(m => m.name).join(', ')}`));
3662
+ console.log('');
3663
+ }
3664
+ }
3665
+ return;
3666
+ }
3667
+
3668
+ // ── Feature 34: AI Intake ────────────────────────────────────────────────
3669
+ if (subcommand === 'ai-intake') {
3670
+ const lib = require('./lib/ai-intake');
3671
+ const action = process.argv[3] || 'list';
3672
+ const jsonMode = process.argv.includes('--json');
3673
+ const io = require('./lib/io');
3674
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'ai-intake.json');
3675
+ if (action === 'create') {
3676
+ const name = process.argv[4];
3677
+ if (!name) { console.error(chalk.red('Usage: jumpstart-mode ai-intake create <name>')); process.exit(1); }
3678
+ const result = lib.createIntake({ name, description: name }, { stateFile });
3679
+ if (jsonMode) { io.writeResult(result); } else {
3680
+ console.log(result.success ? chalk.green(`āœ… AI intake created: ${result.intake.id} (Risk tier: ${result.intake.risk_tier})`) : chalk.red(`āŒ ${result.error}`));
3681
+ }
3682
+ } else {
3683
+ const result = lib.listIntakes({}, { stateFile });
3684
+ if (jsonMode) { io.writeResult(result); } else {
3685
+ console.log(chalk.bold(`\n🧠 AI Use Case Intakes (${result.total})`));
3686
+ for (const i of result.intakes) console.log(` ${i.id}: ${i.name} (Tier ${i.risk_tier}: ${i.risk_label})`);
3687
+ console.log('');
3688
+ }
3689
+ }
3690
+ return;
3691
+ }
3692
+
3693
+ // ── Feature 35: FinOps Planner ───────────────────────────────────────────
3694
+ if (subcommand === 'finops-planner') {
3695
+ const lib = require('./lib/finops-planner');
3696
+ const action = process.argv[3] || 'report';
3697
+ const jsonMode = process.argv.includes('--json');
3698
+ const io = require('./lib/io');
3699
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'finops.json');
3700
+ if (action === 'optimize') {
3701
+ const result = lib.getOptimizations({ stateFile });
3702
+ if (jsonMode) { io.writeResult(result); } else {
3703
+ console.log(chalk.bold(`\nšŸ’° FinOps Optimizations (${result.total})`));
3704
+ for (const r of result.recommendations) console.log(` ${r.recommendation} (${r.potential_savings})`);
3705
+ console.log('');
3706
+ }
3707
+ } else {
3708
+ const result = lib.generateReport({ stateFile });
3709
+ if (jsonMode) { io.writeResult(result); } else {
3710
+ console.log(chalk.bold(`\nšŸ’° FinOps Report: $${result.total_monthly}/mo ($${result.total_annual}/yr)`));
3711
+ console.log(` Estimates: ${result.total_estimates}\n`);
3712
+ }
3713
+ }
3714
+ return;
3715
+ }
3716
+
3717
+ // ── Feature 36: Vendor Risk ──────────────────────────────────────────────
3718
+ if (subcommand === 'vendor-risk') {
3719
+ const lib = require('./lib/vendor-risk');
3720
+ const action = process.argv[3] || 'report';
3721
+ const jsonMode = process.argv.includes('--json');
3722
+ const io = require('./lib/io');
3723
+ const root = process.cwd();
3724
+ const stateFile = path.join(root, '.jumpstart', 'state', 'vendor-risk.json');
3725
+ if (action === 'scan') {
3726
+ const result = lib.scanDependencies(root);
3727
+ if (jsonMode) { io.writeResult(result); } else {
3728
+ console.log(chalk.bold(`\nšŸ“¦ Vendor Scan: ${result.total} dependencies found\n`));
3729
+ }
3730
+ } else {
3731
+ const result = lib.generateReport({ stateFile });
3732
+ if (jsonMode) { io.writeResult(result); } else {
3733
+ console.log(chalk.bold(`\nšŸ“¦ Vendor Risk Report: ${result.total_assessed} assessed`));
3734
+ console.log(` Avg score: ${result.average_score} High risk: ${result.high_risk.length}\n`);
3735
+ }
3736
+ }
3737
+ return;
3738
+ }
3739
+
3740
+ // ── Feature 37: CAB Output ───────────────────────────────────────────────
3741
+ if (subcommand === 'cab-output') {
3742
+ const lib = require('./lib/cab-output');
3743
+ const jsonMode = process.argv.includes('--json');
3744
+ const io = require('./lib/io');
3745
+ const result = lib.generateCABSummary(process.cwd());
3746
+ if (jsonMode) { io.writeResult(result); } else {
3747
+ console.log(chalk.bold(`\nšŸ“‹ CAB Summary: ${result.completeness}% complete (Risk: ${result.risk_level})`));
3748
+ console.log(` ${result.recommendation}`);
3749
+ if (result.gaps.length > 0) console.log(chalk.yellow(` Gaps: ${result.gaps.join(', ')}`));
3750
+ console.log('');
3751
+ }
3752
+ return;
3753
+ }
3754
+
3755
+ // ── Feature 38: BCDR Planning ────────────────────────────────────────────
3756
+ if (subcommand === 'bcdr-planning') {
3757
+ const lib = require('./lib/bcdr-planning');
3758
+ const action = process.argv[3] || 'report';
3759
+ const jsonMode = process.argv.includes('--json');
3760
+ const io = require('./lib/io');
3761
+ const root = process.cwd();
3762
+ const stateFile = path.join(root, '.jumpstart', 'state', 'bcdr.json');
3763
+ if (action === 'define') {
3764
+ const name = process.argv[4];
3765
+ const tier = process.argv[5] || 'silver';
3766
+ if (!name) { console.error(chalk.red('Usage: jumpstart-mode bcdr-planning define <service-name> [tier]')); process.exit(1); }
3767
+ const result = lib.defineService({ name, tier }, { stateFile });
3768
+ if (jsonMode) { io.writeResult(result); } else {
3769
+ console.log(result.success ? chalk.green(`āœ… BC/DR defined: RTO=${result.service.rto_hours}h RPO=${result.service.rpo_hours}h`) : chalk.red(`āŒ ${result.error}`));
3770
+ }
3771
+ } else if (action === 'check') {
3772
+ const result = lib.checkCoverage(root);
3773
+ if (jsonMode) { io.writeResult(result); } else {
3774
+ console.log(chalk.bold(`\nšŸ›”ļø BC/DR Coverage: ${result.coverage}%`));
3775
+ if (result.gaps.length > 0) console.log(chalk.yellow(` Gaps: ${result.gaps.join(', ')}`));
3776
+ console.log('');
3777
+ }
3778
+ } else {
3779
+ const result = lib.generateReport({ stateFile });
3780
+ if (jsonMode) { io.writeResult(result); } else {
3781
+ console.log(chalk.bold(`\nšŸ›”ļø BC/DR Report: ${result.total_services} services\n`));
3782
+ }
3783
+ }
3784
+ return;
3785
+ }
3786
+
3787
+ // ── Feature 39: Ops Ownership ────────────────────────────────────────────
3788
+ if (subcommand === 'ops-ownership') {
3789
+ const lib = require('./lib/ops-ownership');
3790
+ const action = process.argv[3] || 'report';
3791
+ const jsonMode = process.argv.includes('--json');
3792
+ const io = require('./lib/io');
3793
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'ops-ownership.json');
3794
+ if (action === 'define') {
3795
+ const name = process.argv[4];
3796
+ const owner = process.argv[5];
3797
+ if (!name || !owner) { console.error(chalk.red('Usage: jumpstart-mode ops-ownership define <service> <owner>')); process.exit(1); }
3798
+ const result = lib.defineOwnership({ name, service_owner: owner }, { stateFile });
3799
+ if (jsonMode) { io.writeResult(result); } else {
3800
+ console.log(result.success ? chalk.green(`āœ… Ownership defined for ${name}`) : chalk.red(`āŒ ${result.error}`));
3801
+ }
3802
+ } else if (action === 'check') {
3803
+ const result = lib.checkCompleteness({ stateFile });
3804
+ if (jsonMode) { io.writeResult(result); } else {
3805
+ console.log(chalk.bold(`\nšŸ‘¤ Ops Ownership: ${result.complete}/${result.total_services} complete\n`));
3806
+ }
3807
+ } else {
3808
+ const result = lib.generateReport({ stateFile });
3809
+ if (jsonMode) { io.writeResult(result); } else {
3810
+ console.log(chalk.bold(`\nšŸ‘¤ Ops Ownership Report: ${result.total_services} services\n`));
3811
+ }
3812
+ }
3813
+ return;
3814
+ }
3815
+
3816
+ // ── Feature 40: Governance Dashboard ─────────────────────────────────────
3817
+ if (subcommand === 'governance-dashboard') {
3818
+ const lib = require('./lib/governance-dashboard');
3819
+ const jsonMode = process.argv.includes('--json');
3820
+ const io = require('./lib/io');
3821
+ const result = lib.gatherGovernanceData(process.cwd());
3822
+ if (jsonMode) { io.writeResult(result); } else {
3823
+ console.log(lib.renderDashboardText(result));
3824
+ }
3825
+ return;
3826
+ }
3827
+
3828
+ // ── Feature 41: Codebase Retrieval ───────────────────────────────────────
3829
+ if (subcommand === 'codebase-retrieval') {
3830
+ const lib = require('./lib/codebase-retrieval');
3831
+ const action = process.argv[3] || 'index';
3832
+ const jsonMode = process.argv.includes('--json');
3833
+ const io = require('./lib/io');
3834
+ const root = process.cwd();
3835
+ if (action === 'query') {
3836
+ const query = process.argv[4];
3837
+ if (!query) { console.error(chalk.red('Usage: jumpstart-mode codebase-retrieval query <search-term>')); process.exit(1); }
3838
+ const result = lib.queryFiles(root, query);
3839
+ if (jsonMode) { io.writeResult(result); } else {
3840
+ console.log(chalk.bold(`\nšŸ” Codebase Query: "${query}" (${result.total_results} results)`));
3841
+ for (const r of result.results.slice(0, 10)) console.log(` ${r.file} (${r.matches} matches)`);
3842
+ console.log('');
3843
+ }
3844
+ } else {
3845
+ const result = lib.indexProject(root);
3846
+ if (jsonMode) { io.writeResult(result); } else {
3847
+ console.log(chalk.bold(`\nšŸ“ Codebase Index: ${result.total_files} files`));
3848
+ for (const c of result.categories) console.log(` ${c.type}: ${c.count}`);
3849
+ console.log('');
3850
+ }
3851
+ }
3852
+ return;
3853
+ }
3854
+
3855
+ // ── Feature 42: AST Edit Engine ──────────────────────────────────────────
3856
+ if (subcommand === 'ast-edit') {
3857
+ const lib = require('./lib/ast-edit-engine');
3858
+ const action = process.argv[3] || 'analyze';
3859
+ const jsonMode = process.argv.includes('--json');
3860
+ const io = require('./lib/io');
3861
+ const filePath = process.argv[4];
3862
+ if (!filePath) { console.error(chalk.red('Usage: jumpstart-mode ast-edit analyze|validate <file>')); process.exit(1); }
3863
+ const result = lib.analyzeStructure(filePath);
3864
+ if (jsonMode) { io.writeResult(result); } else {
3865
+ if (result.success) {
3866
+ console.log(chalk.bold(`\n🌳 AST Analysis: ${result.file} (${result.language})`));
3867
+ console.log(` Lines: ${result.total_lines} Symbols: ${result.symbol_count}`);
3868
+ for (const s of result.symbols) console.log(` L${s.line}: ${s.type} ${s.name}`);
3869
+ } else { console.log(chalk.red(`āŒ ${result.error}`)); }
3870
+ console.log('');
3871
+ }
3872
+ return;
3873
+ }
3874
+
3875
+ // ── Feature 43: Refactor Planner ─────────────────────────────────────────
3876
+ if (subcommand === 'refactor-planner') {
3877
+ const lib = require('./lib/refactor-planner');
3878
+ const action = process.argv[3] || 'report';
3879
+ const jsonMode = process.argv.includes('--json');
3880
+ const io = require('./lib/io');
3881
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'refactor-plan.json');
3882
+ const result = lib.generateReport({ stateFile });
3883
+ if (jsonMode) { io.writeResult(result); } else {
3884
+ console.log(chalk.bold(`\nšŸ”§ Refactor Planner: ${result.total_plans} plans, ${result.completed} completed\n`));
3885
+ }
3886
+ return;
3887
+ }
3888
+
3889
+ // ── Feature 44: Test Generator ───────────────────────────────────────────
3890
+ if (subcommand === 'test-generator') {
3891
+ const lib = require('./lib/test-generator');
3892
+ const action = process.argv[3] || 'coverage';
3893
+ const jsonMode = process.argv.includes('--json');
3894
+ const io = require('./lib/io');
3895
+ const root = process.cwd();
3896
+ if (action === 'coverage') {
3897
+ const result = lib.checkCoverage(root);
3898
+ if (jsonMode) { io.writeResult(result); } else {
3899
+ if (result.success) {
3900
+ console.log(chalk.bold(`\n🧪 Test Coverage vs Acceptance Criteria: ${result.coverage}%`));
3901
+ console.log(` Total criteria: ${result.total_criteria} Covered: ${result.covered}`);
3902
+ } else { console.log(chalk.yellow(` ${result.error}`)); }
3903
+ console.log('');
3904
+ }
3905
+ } else {
3906
+ const prdFile = path.join(root, 'specs', 'prd.md');
3907
+ if (!fs.existsSync(prdFile)) { console.error(chalk.red('PRD not found at specs/prd.md')); process.exit(1); }
3908
+ const content = fs.readFileSync(prdFile, 'utf8');
3909
+ const criteria = lib.extractCriteria(content);
3910
+ const result = lib.generateTestStubs(criteria);
3911
+ if (jsonMode) { io.writeResult(result); } else {
3912
+ console.log(chalk.bold(`\n🧪 Test Generator: ${result.test_files} files from ${result.total_criteria} criteria\n`));
3913
+ }
3914
+ }
3915
+ return;
3916
+ }
3917
+
3918
+ // ── Feature 45: Contract First ───────────────────────────────────────────
3919
+ if (subcommand === 'contract-first') {
3920
+ const lib = require('./lib/contract-first');
3921
+ const action = process.argv[3] || 'extract';
3922
+ const jsonMode = process.argv.includes('--json');
3923
+ const io = require('./lib/io');
3924
+ const root = process.cwd();
3925
+ if (action === 'verify') {
3926
+ const result = lib.verifyCompliance(root);
3927
+ if (jsonMode) { io.writeResult(result); } else {
3928
+ console.log(chalk.bold(`\nšŸ“ Contract Compliance: ${result.compliance}%`));
3929
+ console.log(` Contracts: ${result.total_contracts} Implemented: ${result.implemented} Violations: ${result.violations}\n`);
3930
+ }
3931
+ } else {
3932
+ const result = lib.extractContracts(root);
3933
+ if (jsonMode) { io.writeResult(result); } else {
3934
+ console.log(chalk.bold(`\nšŸ“ Contracts Found: ${result.total_contracts}`));
3935
+ for (const c of (result.contracts || [])) console.log(` ${c.type}: ${c.method || ''} ${c.path || c.name}`);
3936
+ console.log('');
3937
+ }
3938
+ }
3939
+ return;
3940
+ }
3941
+
3942
+ // ── Feature 46: Runtime Debugger ─────────────────────────────────────────
3943
+ if (subcommand === 'runtime-debugger') {
3944
+ const lib = require('./lib/runtime-debugger');
3945
+ const action = process.argv[3] || 'analyze';
3946
+ const jsonMode = process.argv.includes('--json');
3947
+ const io = require('./lib/io');
3948
+ const filePath = process.argv[4];
3949
+ if (!filePath) { console.error(chalk.red('Usage: jumpstart-mode runtime-debugger analyze <log-file>')); process.exit(1); }
3950
+ const result = lib.analyzeLogFile(filePath);
3951
+ if (jsonMode) { io.writeResult(result); } else {
3952
+ if (result.success) {
3953
+ console.log(chalk.bold(`\nšŸ› Log Analysis: ${result.total_findings} findings`));
3954
+ console.log(` Errors: ${result.summary.errors} Warnings: ${result.summary.warnings} Exceptions: ${result.summary.exceptions}\n`);
3955
+ } else { console.log(chalk.red(`āŒ ${result.error}`)); }
3956
+ }
3957
+ return;
3958
+ }
3959
+
3960
+ // ── Feature 47: Migration Planner ────────────────────────────────────────
3961
+ if (subcommand === 'migration-planner') {
3962
+ const lib = require('./lib/migration-planner');
3963
+ const action = process.argv[3] || 'report';
3964
+ const jsonMode = process.argv.includes('--json');
3965
+ const io = require('./lib/io');
3966
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'migration-plan.json');
3967
+ const result = lib.generateReport({ stateFile });
3968
+ if (jsonMode) { io.writeResult(result); } else {
3969
+ console.log(chalk.bold(`\nšŸ”„ Migration Planner: ${result.total_migrations} migrations\n`));
3970
+ }
3971
+ return;
3972
+ }
3973
+
3974
+ // ── Feature 48: Legacy Modernizer ────────────────────────────────────────
3975
+ if (subcommand === 'legacy-modernizer') {
3976
+ const lib = require('./lib/legacy-modernizer');
3977
+ const action = process.argv[3] || 'report';
3978
+ const jsonMode = process.argv.includes('--json');
3979
+ const io = require('./lib/io');
3980
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'legacy-modernization.json');
3981
+ const result = lib.generateReport({ stateFile });
3982
+ if (jsonMode) { io.writeResult(result); } else {
3983
+ console.log(chalk.bold(`\nšŸšļø Legacy Modernizer: ${result.total_assessments} assessments, ${result.total_plans} plans\n`));
3984
+ }
3985
+ return;
3986
+ }
3987
+
3988
+ // ── Feature 49: DB Evolution ─────────────────────────────────────────────
3989
+ if (subcommand === 'db-evolution') {
3990
+ const lib = require('./lib/db-evolution');
3991
+ const action = process.argv[3] || 'report';
3992
+ const jsonMode = process.argv.includes('--json');
3993
+ const io = require('./lib/io');
3994
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'db-evolution.json');
3995
+ const result = lib.generateReport({ stateFile });
3996
+ if (jsonMode) { io.writeResult(result); } else {
3997
+ console.log(chalk.bold(`\nšŸ—„ļø DB Evolution: ${result.total_migrations} migrations\n`));
3998
+ }
3999
+ return;
4000
+ }
4001
+
4002
+ // ── Feature 50: Safe Rename ──────────────────────────────────────────────
4003
+ if (subcommand === 'safe-rename') {
4004
+ const lib = require('./lib/safe-rename');
4005
+ const action = process.argv[3] || 'plan';
4006
+ const jsonMode = process.argv.includes('--json');
4007
+ const io = require('./lib/io');
4008
+ const root = process.cwd();
4009
+ if (action === 'plan') {
4010
+ const oldPath = process.argv[4];
4011
+ const newPath = process.argv[5];
4012
+ if (!oldPath || !newPath) { console.error(chalk.red('Usage: jumpstart-mode safe-rename plan <old-path> <new-path>')); process.exit(1); }
4013
+ const result = lib.planRename(root, oldPath, newPath);
4014
+ if (jsonMode) { io.writeResult(result); } else {
4015
+ console.log(chalk.bold(`\nšŸ“¦ Safe Rename: ${oldPath} → ${newPath}`));
4016
+ console.log(` References: ${result.references_found} Files affected: ${result.affected_files.length}\n`);
4017
+ }
4018
+ } else if (action === 'validate') {
4019
+ const oldPath = process.argv[4];
4020
+ const newPath = process.argv[5];
4021
+ if (!oldPath || !newPath) { console.error(chalk.red('Usage: jumpstart-mode safe-rename validate <old-path> <new-path>')); process.exit(1); }
4022
+ const result = lib.validateRename(root, oldPath, newPath);
4023
+ if (jsonMode) { io.writeResult(result); } else {
4024
+ console.log(result.clean ? chalk.green('āœ… Rename validated') : chalk.yellow(`āš ļø ${result.stale_references} stale references found`));
4025
+ }
4026
+ }
4027
+ return;
4028
+ }
4029
+
4030
+ // ── Feature 51: Dependency Upgrade ───────────────────────────────────────
4031
+ if (subcommand === 'dependency-upgrade') {
4032
+ const lib = require('./lib/dependency-upgrade');
4033
+ const action = process.argv[3] || 'report';
4034
+ const jsonMode = process.argv.includes('--json');
4035
+ const io = require('./lib/io');
4036
+ const root = process.cwd();
4037
+ if (action === 'scan') {
4038
+ const result = lib.scanUpgrades(root);
4039
+ if (jsonMode) { io.writeResult(result); } else {
4040
+ console.log(chalk.bold(`\nšŸ“¦ Dependency Scan: ${result.total} dependencies\n`));
4041
+ }
4042
+ } else {
4043
+ const stateFile = path.join(root, '.jumpstart', 'state', 'dependency-upgrades.json');
4044
+ const result = lib.generateReport({ stateFile });
4045
+ if (jsonMode) { io.writeResult(result); } else {
4046
+ console.log(chalk.bold(`\nšŸ“¦ Dependency Upgrade Report: ${result.total_plans} plans\n`));
4047
+ }
4048
+ }
4049
+ return;
4050
+ }
4051
+
4052
+ // ── Feature 52: Incident Feedback ────────────────────────────────────────
4053
+ if (subcommand === 'incident-feedback') {
4054
+ const lib = require('./lib/incident-feedback');
4055
+ const action = process.argv[3] || 'report';
4056
+ const jsonMode = process.argv.includes('--json');
4057
+ const io = require('./lib/io');
4058
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'incidents.json');
4059
+ if (action === 'log') {
4060
+ const title = process.argv[4];
4061
+ const severity = process.argv[5] || 'sev3';
4062
+ if (!title) { console.error(chalk.red('Usage: jumpstart-mode incident-feedback log <title> [severity]')); process.exit(1); }
4063
+ const result = lib.logIncident({ title, severity, description: title }, { stateFile });
4064
+ if (jsonMode) { io.writeResult(result); } else {
4065
+ console.log(result.success ? chalk.green(`āœ… Incident logged: ${result.incident.id}`) : chalk.red(`āŒ ${result.error}`));
4066
+ }
4067
+ } else {
4068
+ const result = lib.generateReport({ stateFile });
4069
+ if (jsonMode) { io.writeResult(result); } else {
4070
+ console.log(chalk.bold(`\n🚨 Incident Feedback: ${result.total_incidents} incidents, ${result.total_spec_updates} spec updates\n`));
4071
+ }
4072
+ }
4073
+ return;
4074
+ }
4075
+
4076
+ // ── Feature 53: Context Chunker ──────────────────────────────────────────
4077
+ if (subcommand === 'context-chunker') {
4078
+ const lib = require('./lib/context-chunker');
4079
+ const jsonMode = process.argv.includes('--json');
4080
+ const io = require('./lib/io');
4081
+ const root = process.cwd();
4082
+ const result = lib.chunkImplementationPlan(root);
4083
+ if (jsonMode) { io.writeResult(result); } else {
4084
+ if (result.success) {
4085
+ console.log(chalk.bold(`\nšŸ“¦ Context Chunking: ${result.total_sections} sections, ${result.total_tokens} tokens`));
4086
+ for (const r of result.model_recommendations) {
4087
+ console.log(` ${r.model}: ${r.fits_in_single_call ? 'āœ… fits' : `needs ${r.chunks_needed} chunks`}`);
4088
+ }
4089
+ } else { console.log(chalk.yellow(` ${result.error}`)); }
4090
+ console.log('');
4091
+ }
4092
+ return;
4093
+ }
4094
+
4095
+ // ── Feature 54: Model Router ─────────────────────────────────────────────
4096
+ if (subcommand === 'model-router') {
4097
+ const lib = require('./lib/model-router');
4098
+ const action = process.argv[3] || 'report';
4099
+ const jsonMode = process.argv.includes('--json');
4100
+ const io = require('./lib/io');
4101
+ if (action === 'route') {
4102
+ const taskType = process.argv[4];
4103
+ if (!taskType) { console.error(chalk.red('Usage: jumpstart-mode model-router route <task-type>')); process.exit(1); }
4104
+ const result = lib.routeTask(taskType);
4105
+ if (jsonMode) { io.writeResult(result); } else {
4106
+ console.log(result.success ? chalk.green(`āœ… Route: ${taskType} → ${result.model} (${result.reason})`) : chalk.red(`āŒ ${result.error}`));
4107
+ }
4108
+ } else {
4109
+ const result = lib.generateReport();
4110
+ if (jsonMode) { io.writeResult(result); } else {
4111
+ console.log(chalk.bold(`\nšŸ”€ Model Router: ${result.unique_models} models across ${result.task_types} task types\n`));
4112
+ }
4113
+ }
4114
+ return;
4115
+ }
4116
+
4117
+ // ── Feature 55: Cost Router ──────────────────────────────────────────────
4118
+ if (subcommand === 'cost-router') {
4119
+ const lib = require('./lib/cost-router');
4120
+ const action = process.argv[3] || 'report';
4121
+ const jsonMode = process.argv.includes('--json');
4122
+ const io = require('./lib/io');
4123
+ if (action === 'route') {
4124
+ const result = lib.routeByCost({ type: process.argv[4] || 'coding' });
4125
+ if (jsonMode) { io.writeResult(result); } else {
4126
+ console.log(chalk.green(`āœ… Cost route: ${result.selected_model} ($${result.estimated_cost})`));
4127
+ }
4128
+ } else {
4129
+ const result = lib.generateReport();
4130
+ if (jsonMode) { io.writeResult(result); } else {
4131
+ console.log(chalk.bold(`\nšŸ’µ Cost Router: ${result.budget_profile} profile, $${result.total_cost} total\n`));
4132
+ }
4133
+ }
4134
+ return;
4135
+ }
4136
+
4137
+ // ── Feature 56: Deterministic Artifacts ──────────────────────────────────
4138
+ if (subcommand === 'deterministic') {
4139
+ const lib = require('./lib/deterministic-artifacts');
4140
+ const action = process.argv[3] || 'normalize';
4141
+ const jsonMode = process.argv.includes('--json');
4142
+ const io = require('./lib/io');
4143
+ const root = process.cwd();
4144
+ if (action === 'verify') {
4145
+ const file1 = process.argv[4];
4146
+ const file2 = process.argv[5];
4147
+ if (!file1 || !file2) { console.error(chalk.red('Usage: jumpstart-mode deterministic verify <file1> <file2>')); process.exit(1); }
4148
+ const result = lib.verifyStability(file1, file2);
4149
+ if (jsonMode) { io.writeResult(result); } else {
4150
+ console.log(result.identical ? chalk.green('āœ… Files are identical') : chalk.yellow(`āš ļø ${result.similarity}% similar (${result.diff_lines} diff lines)`));
4151
+ }
4152
+ } else {
4153
+ const result = lib.normalizeSpecs(root, { write: process.argv.includes('--write') });
4154
+ if (jsonMode) { io.writeResult(result); } else {
4155
+ console.log(chalk.bold(`\nšŸ“ Normalized ${result.files} spec files (${result.modified} modified)\n`));
4156
+ }
4157
+ }
4158
+ return;
4159
+ }
4160
+
4161
+ // ── Feature 57: Agent Checkpoint ─────────────────────────────────────────
4162
+ if (subcommand === 'agent-checkpoint') {
4163
+ const lib = require('./lib/agent-checkpoint');
4164
+ const action = process.argv[3] || 'list';
4165
+ const jsonMode = process.argv.includes('--json');
4166
+ const io = require('./lib/io');
4167
+ const stateFile = path.join(process.cwd(), '.jumpstart', 'state', 'agent-checkpoints.json');
4168
+ if (action === 'save') {
4169
+ const agent = process.argv[4] || 'cli';
4170
+ const result = lib.saveCheckpoint({ agent, type: 'manual' }, { stateFile });
4171
+ if (jsonMode) { io.writeResult(result); } else {
4172
+ console.log(chalk.green(`āœ… Checkpoint saved: ${result.checkpoint.id}`));
4173
+ }
4174
+ } else if (action === 'restore') {
4175
+ const cpId = process.argv[4];
4176
+ const result = lib.restoreCheckpoint(cpId, { stateFile });
4177
+ if (jsonMode) { io.writeResult(result); } else {
4178
+ console.log(result.success ? chalk.green(`āœ… Restored: ${result.checkpoint.id}`) : chalk.red(`āŒ ${result.error}`));
4179
+ }
4180
+ } else if (action === 'clean') {
4181
+ const result = lib.cleanCheckpoints({ stateFile });
4182
+ if (jsonMode) { io.writeResult(result); } else {
4183
+ console.log(chalk.green(`āœ… Cleaned ${result.removed} checkpoints, ${result.remaining} remaining`));
4184
+ }
4185
+ } else {
4186
+ const result = lib.listCheckpoints({}, { stateFile });
4187
+ if (jsonMode) { io.writeResult(result); } else {
4188
+ console.log(chalk.bold(`\nšŸ’¾ Checkpoints (${result.total})`));
4189
+ for (const c of result.checkpoints) console.log(` ${c.id}: ${c.agent} ${c.phase || ''} (${c.saved_at})`);
4190
+ console.log('');
4191
+ }
4192
+ }
4193
+ return;
4194
+ }
4195
+
4196
+ // ── Feature 58: Tool Guardrails ──────────────────────────────────────────
4197
+ if (subcommand === 'tool-guardrails') {
4198
+ const lib = require('./lib/tool-guardrails');
4199
+ const action = process.argv[3] || 'check';
4200
+ const jsonMode = process.argv.includes('--json');
4201
+ const io = require('./lib/io');
4202
+ const operation = process.argv[4];
4203
+ if (!operation) { console.error(chalk.red('Usage: jumpstart-mode tool-guardrails check <operation>')); process.exit(1); }
4204
+ const result = lib.checkOperation(operation);
4205
+ if (jsonMode) { io.writeResult(result); } else {
4206
+ console.log(result.allowed ? chalk.green(`āœ… Operation allowed (${result.risk_level})`) : chalk.red(`āŒ Operation blocked (${result.risk_level})`));
4207
+ for (const v of result.violations) console.log(` āš ļø ${v.description}`);
4208
+ }
4209
+ return;
4210
+ }
4211
+
4212
+ // ── Feature 59: Root Cause Analysis ──────────────────────────────────────
4213
+ if (subcommand === 'root-cause') {
4214
+ const lib = require('./lib/root-cause-analysis');
4215
+ const jsonMode = process.argv.includes('--json');
4216
+ const io = require('./lib/io');
4217
+ const filePath = process.argv[4] || process.argv[3];
4218
+ if (!filePath || filePath === 'analyze' || filePath === 'report') {
4219
+ console.error(chalk.red('Usage: jumpstart-mode root-cause <output-file>'));
4220
+ process.exit(1);
4221
+ }
4222
+ const result = lib.analyzeTestFile(filePath);
4223
+ if (jsonMode) { io.writeResult(result); } else {
4224
+ if (result.success) {
4225
+ console.log(chalk.bold(`\nšŸ” Root Cause Analysis: ${result.total_hypotheses} hypotheses`));
4226
+ if (result.hypotheses.length > 0) {
4227
+ console.log(` Primary: ${result.hypotheses[0].category} — ${result.hypotheses[0].suggested_fix}`);
4228
+ }
4229
+ for (const a of (result.hypotheses || []).slice(0, 5)) console.log(` ${a.category}: ${a.detail.substring(0, 80)}`);
4230
+ } else { console.log(chalk.red(`āŒ ${result.error}`)); }
4231
+ console.log('');
4232
+ }
4233
+ return;
4234
+ }
4235
+
4236
+ // ── Feature 60: Quality Graph ────────────────────────────────────────────
4237
+ if (subcommand === 'quality-graph') {
4238
+ const lib = require('./lib/quality-graph');
4239
+ const jsonMode = process.argv.includes('--json');
4240
+ const io = require('./lib/io');
4241
+ const root = process.cwd();
4242
+ const result = lib.scanQuality(root);
4243
+ if (jsonMode) { io.writeResult(result); } else {
4244
+ console.log(chalk.bold(`\nšŸ“Š Code Quality Graph: ${result.total_files} files`));
4245
+ console.log(` Average score: ${result.summary.average_score}%`);
4246
+ console.log(` Critical hotspots: ${result.summary.critical_hotspots} High risk: ${result.summary.high_risk}`);
4247
+ if (result.hotspots.length > 0) {
4248
+ console.log(' Top hotspots:');
4249
+ for (const h of result.hotspots.slice(0, 5)) console.log(` ${h.file}: ${h.overall_score}% (${h.total_lines} lines, depth=${h.max_nesting_depth})`);
4250
+ }
4251
+ console.log('');
4252
+ }
4253
+ return;
4254
+ }
4255
+
4256
+ // ─── Item 61: Web Dashboard ──────────────────────────────────────────────
4257
+ if (subcommand === 'web-dashboard') {
4258
+ const lib = require('./lib/web-dashboard');
4259
+ const jsonMode = process.argv.includes('--json');
4260
+ const io = require('./lib/io');
4261
+ const root = process.cwd();
4262
+ const action = process.argv[3] || 'data';
4263
+ if (action === 'config') {
4264
+ const result = lib.generateConfig(root, { port: parseInt(process.argv[4]) || undefined });
4265
+ if (jsonMode) { io.writeResult(result); } else {
4266
+ console.log(chalk.bold('\nšŸ–„ļø Dashboard Configuration'));
4267
+ console.log(` Port: ${result.config.port} Host: ${result.config.host}`);
4268
+ console.log(` Sections: ${result.config.sections.join(', ')}\n`);
4269
+ }
4270
+ } else if (action === 'status') {
4271
+ const result = lib.getServerStatus();
4272
+ if (jsonMode) { io.writeResult(result); } else {
4273
+ console.log(chalk.bold('\nšŸ–„ļø Dashboard Status'));
4274
+ console.log(` Running: ${result.running} Port: ${result.port}\n`);
4275
+ }
4276
+ } else {
4277
+ const result = lib.gatherDashboardData(root);
4278
+ if (jsonMode) { io.writeResult(result); } else {
4279
+ console.log(chalk.bold('\nšŸ–„ļø Dashboard Data'));
4280
+ console.log(` Phase: ${result.sections.phases.current_phase} Artifacts: ${result.sections.artifacts.total}\n`);
4281
+ }
4282
+ }
4283
+ return;
4284
+ }
4285
+
4286
+ // ─── Item 62: Role Views ─────────────────────────────────────────────────
4287
+ if (subcommand === 'role-views') {
4288
+ const lib = require('./lib/role-views');
4289
+ const jsonMode = process.argv.includes('--json');
4290
+ const io = require('./lib/io');
4291
+ const root = process.cwd();
4292
+ const action = process.argv[3] || 'list';
4293
+ if (action === 'list') {
4294
+ const result = lib.listRoles();
4295
+ if (jsonMode) { io.writeResult(result); } else {
4296
+ console.log(chalk.bold('\nšŸ‘„ Available Roles'));
4297
+ for (const r of result.roles) console.log(` ${r.id}: ${r.label} — focus: ${r.focus.join(', ')}`);
4298
+ console.log('');
4299
+ }
4300
+ } else if (action === 'generate') {
4301
+ const role = process.argv[4] || 'engineer';
4302
+ const result = lib.generateView(root, role);
4303
+ if (jsonMode) { io.writeResult(result); } else {
4304
+ if (!result.success) { console.log(chalk.red(`\nāŒ ${result.error}\n`)); } else {
4305
+ console.log(chalk.bold(`\nšŸ‘¤ ${result.view.label}`));
4306
+ console.log(` Focus: ${result.view.focus_areas.join(', ')}`);
4307
+ console.log(` Phase: ${result.view.sections.phase_status.current_phase}\n`);
4308
+ }
4309
+ }
4310
+ }
4311
+ return;
4312
+ }
4313
+
4314
+ // ─── Item 63: Spec Comments ──────────────────────────────────────────────
4315
+ if (subcommand === 'spec-comments') {
4316
+ const lib = require('./lib/spec-comments');
4317
+ const jsonMode = process.argv.includes('--json');
4318
+ const io = require('./lib/io');
4319
+ const action = process.argv[3] || 'list';
4320
+ if (action === 'add') {
4321
+ const artifact = process.argv[4]; const text = process.argv[5];
4322
+ const result = lib.addComment(artifact, null, text);
4323
+ if (jsonMode) { io.writeResult(result); } else {
4324
+ if (result.success) console.log(chalk.green(`\nāœ… Comment ${result.comment.id} added to ${artifact}\n`));
4325
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4326
+ }
4327
+ } else if (action === 'resolve') {
4328
+ const commentId = process.argv[4]; const resolution = process.argv[5];
4329
+ const result = lib.resolveComment(commentId, resolution);
4330
+ if (jsonMode) { io.writeResult(result); } else {
4331
+ if (result.success) console.log(chalk.green(`\nāœ… Comment ${commentId} resolved\n`));
4332
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4333
+ }
4334
+ } else {
4335
+ const result = lib.listComments({ status: process.argv[4] });
4336
+ if (jsonMode) { io.writeResult(result); } else {
4337
+ console.log(chalk.bold(`\nšŸ’¬ Spec Comments (${result.total})`));
4338
+ for (const c of result.comments) console.log(` [${c.status}] ${c.id}: ${c.text.substring(0, 60)}`);
4339
+ console.log('');
4340
+ }
4341
+ }
4342
+ return;
4343
+ }
4344
+
4345
+ // ─── Item 64: Workshop Mode ──────────────────────────────────────────────
4346
+ if (subcommand === 'workshop-mode') {
4347
+ const lib = require('./lib/workshop-mode');
4348
+ const jsonMode = process.argv.includes('--json');
4349
+ const io = require('./lib/io');
4350
+ const action = process.argv[3] || 'status';
4351
+ if (action === 'start') {
4352
+ const name = process.argv[4] || 'Workshop';
4353
+ const result = lib.startSession(name);
4354
+ if (jsonMode) { io.writeResult(result); } else {
4355
+ if (result.success) console.log(chalk.green(`\nāœ… Workshop ${result.session.id} started: ${name}\n`));
4356
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4357
+ }
4358
+ } else {
4359
+ const result = lib.getSessionStatus();
4360
+ if (jsonMode) { io.writeResult(result); } else {
4361
+ console.log(chalk.bold(`\nšŸŽÆ Workshop Sessions (${result.total_sessions})`));
4362
+ for (const s of result.sessions) console.log(` ${s.id}: ${s.name} [${s.status}] (${s.captures} captures)`);
4363
+ console.log('');
4364
+ }
4365
+ }
4366
+ return;
4367
+ }
4368
+
4369
+ // ─── Item 65: Collaboration ──────────────────────────────────────────────
4370
+ if (subcommand === 'collaboration') {
4371
+ const lib = require('./lib/collaboration');
4372
+ const jsonMode = process.argv.includes('--json');
4373
+ const io = require('./lib/io');
4374
+ const action = process.argv[3] || 'status';
4375
+ if (action === 'create') {
4376
+ const name = process.argv[4] || 'Session';
4377
+ const result = lib.createSession(name);
4378
+ if (jsonMode) { io.writeResult(result); } else {
4379
+ if (result.success) console.log(chalk.green(`\nāœ… Collaboration ${result.session.id} created\n`));
4380
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4381
+ }
4382
+ } else {
4383
+ const result = lib.getStatus();
4384
+ if (jsonMode) { io.writeResult(result); } else {
4385
+ console.log(chalk.bold(`\nšŸ¤ Collaboration Status`));
4386
+ console.log(` Active sessions: ${result.active_sessions} Active locks: ${result.active_locks}\n`);
4387
+ }
4388
+ }
4389
+ return;
4390
+ }
4391
+
4392
+ // ─── Item 66: Structured Elicitation ─────────────────────────────────────
4393
+ if (subcommand === 'elicitation') {
4394
+ const lib = require('./lib/structured-elicitation');
4395
+ const jsonMode = process.argv.includes('--json');
4396
+ const io = require('./lib/io');
4397
+ const action = process.argv[3] || 'start';
4398
+ if (action === 'start') {
4399
+ const domain = process.argv[4] || 'general';
4400
+ const result = lib.startElicitation(domain);
4401
+ if (jsonMode) { io.writeResult(result); } else {
4402
+ if (result.success) {
4403
+ console.log(chalk.green(`\nāœ… Elicitation ${result.session.id} started for domain: ${domain}`));
4404
+ console.log(` Questions: ${result.session.questions.length}\n`);
4405
+ } else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4406
+ }
4407
+ } else if (action === 'report') {
4408
+ const sessionId = process.argv[4];
4409
+ const result = lib.generateReport(sessionId);
4410
+ if (jsonMode) { io.writeResult(result); } else {
4411
+ if (result.success) {
4412
+ console.log(chalk.bold(`\nšŸ“‹ Elicitation Report: ${result.completion_pct}% complete`));
4413
+ console.log(` Answered: ${result.answered}/${result.total_questions}\n`);
4414
+ } else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4415
+ }
4416
+ }
4417
+ return;
4418
+ }
4419
+
4420
+ // ─── Item 67: Enterprise Templates ───────────────────────────────────────
4421
+ if (subcommand === 'enterprise-templates') {
4422
+ const lib = require('./lib/enterprise-templates');
4423
+ const jsonMode = process.argv.includes('--json');
4424
+ const io = require('./lib/io');
4425
+ const action = process.argv[3] || 'list';
4426
+ if (action === 'list') {
4427
+ const result = lib.listTemplates();
4428
+ if (jsonMode) { io.writeResult(result); } else {
4429
+ console.log(chalk.bold('\nšŸ¢ Enterprise Templates'));
4430
+ for (const t of result.templates) console.log(` ${t.id}: ${t.label} (${t.compliance_count} compliance, ${t.persona_count} personas)`);
4431
+ console.log('');
4432
+ }
4433
+ } else if (action === 'get') {
4434
+ const vertical = process.argv[4];
4435
+ const result = lib.getTemplate(vertical);
4436
+ if (jsonMode) { io.writeResult(result); } else {
4437
+ if (result.success) {
4438
+ console.log(chalk.bold(`\nšŸ¢ ${result.template.label}`));
4439
+ console.log(` Compliance: ${result.template.compliance.join(', ')}`);
4440
+ console.log(` Personas: ${result.template.personas.join(', ')}\n`);
4441
+ } else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4442
+ }
4443
+ } else if (action === 'apply') {
4444
+ const vertical = process.argv[4];
4445
+ const result = lib.applyTemplate(process.cwd(), vertical);
4446
+ if (jsonMode) { io.writeResult(result); } else {
4447
+ if (result.success) console.log(chalk.green(`\nāœ… Template ${result.applied.label} applied\n`));
4448
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4449
+ }
4450
+ }
4451
+ return;
4452
+ }
4453
+
4454
+ // ─── Item 68: Playback Summaries ─────────────────────────────────────────
4455
+ if (subcommand === 'playback-summaries') {
4456
+ const lib = require('./lib/playback-summaries');
4457
+ const jsonMode = process.argv.includes('--json');
4458
+ const io = require('./lib/io');
4459
+ const action = process.argv[3] || 'list';
4460
+ if (action === 'generate') {
4461
+ const audience = process.argv[4] || 'executive';
4462
+ const result = lib.generateSummary(process.cwd(), audience);
4463
+ if (jsonMode) { io.writeResult(result); } else {
4464
+ if (result.success) {
4465
+ console.log(chalk.bold(`\nšŸ“£ ${result.summary.label}`));
4466
+ console.log(` Tone: ${result.summary.tone} Focus: ${result.summary.focus_areas.join(', ')}\n`);
4467
+ } else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4468
+ }
4469
+ } else {
4470
+ const result = lib.listAudiences();
4471
+ if (jsonMode) { io.writeResult(result); } else {
4472
+ console.log(chalk.bold('\nšŸ“£ Available Audiences'));
4473
+ for (const a of result.audiences) console.log(` ${a.id}: ${a.label} (${a.tone})`);
4474
+ console.log('');
4475
+ }
4476
+ }
4477
+ return;
4478
+ }
4479
+
4480
+ // ─── Item 69: Design System ──────────────────────────────────────────────
4481
+ if (subcommand === 'design-system') {
4482
+ const lib = require('./lib/design-system');
4483
+ const jsonMode = process.argv.includes('--json');
4484
+ const io = require('./lib/io');
4485
+ const action = process.argv[3] || 'report';
4486
+ if (action === 'check') {
4487
+ const result = lib.checkCompliance();
4488
+ if (jsonMode) { io.writeResult(result); } else {
4489
+ console.log(chalk.bold('\nšŸŽØ Design System Compliance'));
4490
+ console.log(` Compliant: ${result.compliant} Issues: ${result.issues.length}\n`);
4491
+ }
4492
+ } else {
4493
+ const result = lib.generateReport();
4494
+ if (jsonMode) { io.writeResult(result); } else {
4495
+ console.log(chalk.bold('\nšŸŽØ Design System Report'));
4496
+ console.log(` Components: ${result.components} Level: ${result.accessibility_level}\n`);
4497
+ }
4498
+ }
4499
+ return;
4500
+ }
4501
+
4502
+ // ─── Item 70: Diagram Studio ─────────────────────────────────────────────
4503
+ if (subcommand === 'diagram-studio') {
4504
+ const lib = require('./lib/diagram-studio');
4505
+ const jsonMode = process.argv.includes('--json');
4506
+ const io = require('./lib/io');
4507
+ const action = process.argv[3] || 'list';
4508
+ if (action === 'generate') {
4509
+ const type = process.argv[4] || 'sequence';
4510
+ const result = lib.generateDiagram(type);
4511
+ if (jsonMode) { io.writeResult(result); } else {
4512
+ if (result.success) { console.log(chalk.bold(`\nšŸ“ Diagram: ${type}`)); console.log(result.content + '\n'); }
4513
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4514
+ }
4515
+ } else if (action === 'validate') {
4516
+ const file = process.argv[4];
4517
+ if (file && fs.existsSync(file)) {
4518
+ const content = fs.readFileSync(file, 'utf8');
4519
+ const result = lib.validateDiagram(content);
4520
+ if (jsonMode) { io.writeResult(result); } else {
4521
+ console.log(chalk.bold(`\nšŸ“ Diagram Validation: ${result.valid ? 'Valid' : 'Issues Found'}`));
4522
+ for (const i of result.issues) console.log(` [${i.type}] ${i.message}`);
4523
+ console.log('');
4524
+ }
4525
+ } else console.log(chalk.red('\nāŒ File path required for validate\n'));
4526
+ } else {
4527
+ const result = lib.listDiagramTypes();
4528
+ if (jsonMode) { io.writeResult(result); } else {
4529
+ console.log(chalk.bold('\nšŸ“ Diagram Types'));
4530
+ for (const t of result.types) console.log(` ${t}`);
4531
+ console.log('');
4532
+ }
4533
+ }
4534
+ return;
4535
+ }
4536
+
4537
+ // ─── Item 71: Ambiguity Heatmap ──────────────────────────────────────────
4538
+ if (subcommand === 'ambiguity-heatmap') {
4539
+ const lib = require('./lib/ambiguity-heatmap');
4540
+ const jsonMode = process.argv.includes('--json');
4541
+ const io = require('./lib/io');
4542
+ const action = process.argv[3] || 'report';
4543
+ if (action === 'scan') {
4544
+ const file = process.argv[4];
4545
+ if (file) {
4546
+ const result = lib.scanFile(file);
4547
+ if (jsonMode) { io.writeResult(result); } else {
4548
+ if (result.success) {
4549
+ console.log(chalk.bold(`\nšŸ”„ Ambiguity Scan: ${result.total_findings} findings`));
4550
+ console.log(` Vague terms: ${result.metrics.vague_terms} Missing constraints: ${result.metrics.missing_constraints} Density: ${result.metrics.ambiguity_density}%\n`);
4551
+ } else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4552
+ }
4553
+ } else console.log(chalk.red('\nāŒ File path required for scan\n'));
4554
+ } else {
4555
+ const result = lib.generateHeatmap(process.cwd());
4556
+ if (jsonMode) { io.writeResult(result); } else {
4557
+ console.log(chalk.bold(`\nšŸ”„ Ambiguity Heatmap: ${result.files_scanned} files`));
4558
+ console.log(` Total findings: ${result.overall.total_findings}\n`);
4559
+ }
4560
+ }
4561
+ return;
4562
+ }
4563
+
4564
+ // ─── Item 72: Estimation Studio ──────────────────────────────────────────
4565
+ if (subcommand === 'estimation-studio') {
4566
+ const lib = require('./lib/estimation-studio');
4567
+ const jsonMode = process.argv.includes('--json');
4568
+ const io = require('./lib/io');
4569
+ const action = process.argv[3] || 'report';
4570
+ if (action === 'estimate') {
4571
+ const name = process.argv[4]; const size = process.argv[5];
4572
+ const result = lib.estimateFeature(name, size);
4573
+ if (jsonMode) { io.writeResult(result); } else {
4574
+ if (result.success) {
4575
+ console.log(chalk.bold(`\nšŸ“Š Estimate: ${name}`));
4576
+ console.log(` Size: ${result.estimate.tshirt_size} Points: ${result.estimate.story_points} Days: ${result.estimate.ideal_days}`);
4577
+ console.log(` ROM: $${result.estimate.rom_cost.min}–$${result.estimate.rom_cost.max}\n`);
4578
+ } else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4579
+ }
4580
+ } else {
4581
+ const result = lib.generateReport();
4582
+ if (jsonMode) { io.writeResult(result); } else {
4583
+ console.log(chalk.bold(`\nšŸ“Š Estimation Report: ${result.total_features} features`));
4584
+ console.log(` Total points: ${result.total_story_points} Total days: ${result.total_ideal_days}\n`);
4585
+ }
4586
+ }
4587
+ return;
4588
+ }
4589
+
4590
+ // ─── Item 73: Guided Handoff ─────────────────────────────────────────────
4591
+ if (subcommand === 'guided-handoff') {
4592
+ const lib = require('./lib/guided-handoff');
4593
+ const jsonMode = process.argv.includes('--json');
4594
+ const io = require('./lib/io');
4595
+ const action = process.argv[3] || 'list';
4596
+ if (action === 'generate') {
4597
+ const type = process.argv[4] || 'product-to-engineering';
4598
+ const result = lib.generateHandoff(type, process.cwd());
4599
+ if (jsonMode) { io.writeResult(result); } else {
4600
+ if (result.success) {
4601
+ console.log(chalk.bold(`\nšŸ“¦ Handoff: ${result.label}`));
4602
+ console.log(` Complete: ${result.complete} Missing: ${result.missing_required.join(', ') || 'none'}\n`);
4603
+ } else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4604
+ }
4605
+ } else {
4606
+ const result = lib.listHandoffTypes();
4607
+ if (jsonMode) { io.writeResult(result); } else {
4608
+ console.log(chalk.bold('\nšŸ“¦ Handoff Types'));
4609
+ for (const t of result.types) console.log(` ${t.id}: ${t.label} (${t.required_count} required, ${t.optional_count} optional)`);
4610
+ console.log('');
4611
+ }
4612
+ }
4613
+ return;
4614
+ }
4615
+
4616
+ // ─── Item 74: Transcript Ingestion ───────────────────────────────────────
4617
+ if (subcommand === 'transcript-ingestion') {
4618
+ const lib = require('./lib/transcript-ingestion');
4619
+ const jsonMode = process.argv.includes('--json');
4620
+ const io = require('./lib/io');
4621
+ const action = process.argv[3] || 'list';
4622
+ if (action === 'ingest') {
4623
+ const file = process.argv[4];
4624
+ if (file && fs.existsSync(file)) {
4625
+ const text = fs.readFileSync(file, 'utf8');
4626
+ const result = lib.ingestTranscript(text, { title: path.basename(file) });
4627
+ if (jsonMode) { io.writeResult(result); } else {
4628
+ if (result.success) {
4629
+ console.log(chalk.green(`\nāœ… Transcript ingested: ${result.transcript.id}`));
4630
+ console.log(` Actions: ${result.transcript.actions.length} Decisions: ${result.transcript.decisions.length}\n`);
4631
+ }
4632
+ }
4633
+ } else console.log(chalk.red('\nāŒ File path required for ingest\n'));
4634
+ } else {
4635
+ const result = lib.listTranscripts();
4636
+ if (jsonMode) { io.writeResult(result); } else {
4637
+ console.log(chalk.bold(`\nšŸŽ™ļø Transcripts (${result.total})`));
4638
+ for (const t of result.transcripts) console.log(` ${t.id}: ${t.title} (${t.actions} actions, ${t.decisions} decisions)`);
4639
+ console.log('');
4640
+ }
4641
+ }
4642
+ return;
4643
+ }
4644
+
4645
+ // ─── Item 75: Chat Integration ───────────────────────────────────────────
4646
+ if (subcommand === 'chat-integration') {
4647
+ const lib = require('./lib/chat-integration');
4648
+ const jsonMode = process.argv.includes('--json');
4649
+ const io = require('./lib/io');
4650
+ const action = process.argv[3] || 'status';
4651
+ if (action === 'configure') {
4652
+ const platform = process.argv[4] || 'slack';
4653
+ const result = lib.configure(platform);
4654
+ if (jsonMode) { io.writeResult(result); } else {
4655
+ if (result.success) console.log(chalk.green(`\nāœ… ${platform} integration configured: ${result.configuration.id}\n`));
4656
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4657
+ }
4658
+ } else if (action === 'notify') {
4659
+ const eventType = process.argv[4]; const message = process.argv[5];
4660
+ const result = lib.queueNotification(eventType, message);
4661
+ if (jsonMode) { io.writeResult(result); } else {
4662
+ if (result.success) console.log(chalk.green(`\nāœ… Notification queued: ${result.notification.id}\n`));
4663
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4664
+ }
4665
+ } else {
4666
+ const result = lib.getStatus();
4667
+ if (jsonMode) { io.writeResult(result); } else {
4668
+ console.log(chalk.bold('\nšŸ’¬ Chat Integration Status'));
4669
+ console.log(` Configurations: ${result.configurations} Active: ${result.active} Queued: ${result.notifications_queued}\n`);
4670
+ }
4671
+ }
4672
+ return;
4673
+ }
4674
+
4675
+ // ─── Item 76: Context Onboarding ─────────────────────────────────────────
4676
+ if (subcommand === 'context-onboarding') {
4677
+ const lib = require('./lib/context-onboarding');
4678
+ const jsonMode = process.argv.includes('--json');
4679
+ const io = require('./lib/io');
4680
+ const role = process.argv[3] || 'engineer';
4681
+ const result = lib.generateOnboarding(process.cwd(), { role });
4682
+ if (jsonMode) { io.writeResult(result); } else {
4683
+ if (result.success) {
4684
+ const ob = result.onboarding;
4685
+ console.log(chalk.bold(`\nšŸŽ“ Onboarding Package (${ob.role})`));
4686
+ console.log(` Decisions: ${ob.sections.decisions.total} Risks: ${ob.sections.risks.total}`);
4687
+ console.log(` Specs: ${ob.sections.specs.total} Phase: ${ob.sections.project_status.current_phase}\n`);
4688
+ }
4689
+ }
4690
+ return;
4691
+ }
4692
+
4693
+ // ─── Item 77: Promptless Mode ────────────────────────────────────────────
4694
+ if (subcommand === 'promptless-mode') {
4695
+ const lib = require('./lib/promptless-mode');
4696
+ const jsonMode = process.argv.includes('--json');
4697
+ const io = require('./lib/io');
4698
+ const action = process.argv[3] || 'status';
4699
+ if (action === 'start') {
4700
+ const wizard = process.argv[4] || 'new-project';
4701
+ const result = lib.startWizard(wizard);
4702
+ if (jsonMode) { io.writeResult(result); } else {
4703
+ if (result.success) {
4704
+ console.log(chalk.green(`\nāœ… Wizard started: ${result.session.id}`));
4705
+ if (result.next_step) console.log(` Next: ${result.next_step.prompt}`);
4706
+ console.log('');
4707
+ } else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4708
+ }
4709
+ } else {
4710
+ const result = lib.getWizardStatus();
4711
+ if (jsonMode) { io.writeResult(result); } else {
4712
+ console.log(chalk.bold('\nšŸ§™ Promptless Mode'));
4713
+ console.log(` Available wizards: ${result.available_wizards.join(', ')}`);
4714
+ for (const s of result.sessions) console.log(` ${s.id}: ${s.wizard} [${s.status}] (${s.progress})`);
4715
+ console.log('');
4716
+ }
4717
+ }
4718
+ return;
4719
+ }
4720
+
4721
+ // ─── Item 78: Artifact Comparison ────────────────────────────────────────
4722
+ if (subcommand === 'artifact-comparison') {
4723
+ const lib = require('./lib/artifact-comparison');
4724
+ const jsonMode = process.argv.includes('--json');
4725
+ const io = require('./lib/io');
4726
+ const action = process.argv[3] || 'history';
4727
+ if (action === 'compare') {
4728
+ const fileA = process.argv[4]; const fileB = process.argv[5];
4729
+ if (fileA && fileB) {
4730
+ const result = lib.compareFiles(fileA, fileB);
4731
+ if (jsonMode) { io.writeResult(result); } else {
4732
+ if (result.success) {
4733
+ console.log(chalk.bold(`\nšŸ“„ Artifact Comparison: ${result.total_changes} changes`));
4734
+ console.log(` Lines: ${result.lines_before} → ${result.lines_after} (${result.line_diff >= 0 ? '+' : ''}${result.line_diff})`);
4735
+ for (const c of result.changes) console.log(` [${c.type}] ${c.summary}`);
4736
+ console.log('');
4737
+ } else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4738
+ }
4739
+ } else console.log(chalk.red('\nāŒ Two file paths required for compare\n'));
4740
+ } else {
4741
+ const artifact = process.argv[4] || 'prd.md';
4742
+ const result = lib.getArtifactHistory(process.cwd(), artifact);
4743
+ if (jsonMode) { io.writeResult(result); } else {
4744
+ console.log(chalk.bold(`\nšŸ“„ Artifact History: ${result.artifact}`));
4745
+ console.log(` Versions: ${result.versions}\n`);
4746
+ }
4747
+ }
4748
+ return;
4749
+ }
4750
+
4751
+ // ─── Item 79: Workstream Ownership ───────────────────────────────────────
4752
+ if (subcommand === 'workstream-ownership') {
4753
+ const lib = require('./lib/workstream-ownership');
4754
+ const jsonMode = process.argv.includes('--json');
4755
+ const io = require('./lib/io');
4756
+ const action = process.argv[3] || 'report';
4757
+ if (action === 'define') {
4758
+ const name = process.argv[4];
4759
+ const result = lib.defineWorkstream(name, { team: process.argv[5] });
4760
+ if (jsonMode) { io.writeResult(result); } else {
4761
+ if (result.success) console.log(chalk.green(`\nāœ… Workstream ${result.workstream.id} defined: ${name}\n`));
4762
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4763
+ }
4764
+ } else {
4765
+ const result = lib.generateReport();
4766
+ if (jsonMode) { io.writeResult(result); } else {
4767
+ console.log(chalk.bold(`\nšŸ”— Workstream Report: ${result.total_workstreams} workstreams, ${result.total_dependencies} dependencies\n`));
4768
+ }
4769
+ }
4770
+ return;
4771
+ }
4772
+
4773
+ // ─── Item 80: Persona Packs ──────────────────────────────────────────────
4774
+ if (subcommand === 'persona-packs') {
4775
+ const lib = require('./lib/persona-packs');
4776
+ const jsonMode = process.argv.includes('--json');
4777
+ const io = require('./lib/io');
4778
+ const action = process.argv[3] || 'list';
4779
+ if (action === 'get') {
4780
+ const id = process.argv[4];
4781
+ const result = lib.getPersona(id);
4782
+ if (jsonMode) { io.writeResult(result); } else {
4783
+ if (result.success) {
4784
+ console.log(chalk.bold(`\nšŸ‘¤ ${result.persona.label}`));
4785
+ console.log(` Focus: ${result.persona.focus.join(', ')}`);
4786
+ console.log(` Tools: ${result.persona.tools.join(', ')}\n`);
4787
+ } else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4788
+ }
4789
+ } else if (action === 'apply') {
4790
+ const id = process.argv[4];
4791
+ const result = lib.applyPersona(id);
4792
+ if (jsonMode) { io.writeResult(result); } else {
4793
+ if (result.success) console.log(chalk.green(`\nāœ… Persona ${result.label} applied\n`));
4794
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4795
+ }
4796
+ } else {
4797
+ const result = lib.listPersonas();
4798
+ if (jsonMode) { io.writeResult(result); } else {
4799
+ console.log(chalk.bold('\nšŸ‘¤ Persona Packs'));
4800
+ for (const p of result.personas) console.log(` ${p.id}: ${p.label} (${p.focus_count} focus, ${p.tools_count} tools)`);
4801
+ console.log('');
4802
+ }
4803
+ }
4804
+ return;
4805
+ }
4806
+
4807
+ // ─── Item 81: Knowledge Graph ────────────────────────────────────────────
4808
+ if (subcommand === 'knowledge-graph') {
4809
+ const lib = require('./lib/knowledge-graph');
4810
+ const jsonMode = process.argv.includes('--json');
4811
+ const io = require('./lib/io');
4812
+ const action = process.argv[3] || 'report';
4813
+ if (action === 'add') {
4814
+ const name = process.argv[4]; const type = process.argv[5];
4815
+ const result = lib.addNode(name, type);
4816
+ if (jsonMode) { io.writeResult(result); } else {
4817
+ if (result.success) console.log(chalk.green(`\nāœ… Node ${result.node.id} added: ${name} (${type})\n`));
4818
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4819
+ }
4820
+ } else if (action === 'query') {
4821
+ const search = process.argv[4];
4822
+ const result = lib.queryGraph({ search });
4823
+ if (jsonMode) { io.writeResult(result); } else {
4824
+ console.log(chalk.bold(`\n🧠 Knowledge Graph: ${result.nodes} nodes, ${result.edges} edges`));
4825
+ for (const n of result.results) console.log(` ${n.id}: ${n.name} (${n.type})`);
4826
+ console.log('');
4827
+ }
4828
+ } else {
4829
+ const result = lib.generateReport();
4830
+ if (jsonMode) { io.writeResult(result); } else {
4831
+ console.log(chalk.bold(`\n🧠 Knowledge Graph Report: ${result.total_nodes} nodes, ${result.total_edges} edges\n`));
4832
+ }
4833
+ }
4834
+ return;
4835
+ }
4836
+
4837
+ // ─── Item 82: Pattern Library ────────────────────────────────────────────
4838
+ if (subcommand === 'pattern-library') {
4839
+ const lib = require('./lib/pattern-library');
4840
+ const jsonMode = process.argv.includes('--json');
4841
+ const io = require('./lib/io');
4842
+ const action = process.argv[3] || 'list';
4843
+ if (action === 'register') {
4844
+ const name = process.argv[4]; const category = process.argv[5];
4845
+ const result = lib.registerPattern(name, category);
4846
+ if (jsonMode) { io.writeResult(result); } else {
4847
+ if (result.success) console.log(chalk.green(`\nāœ… Pattern ${result.pattern.id} registered: ${name}\n`));
4848
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4849
+ }
4850
+ } else if (action === 'search') {
4851
+ const query = process.argv[4];
4852
+ const result = lib.searchPatterns(query);
4853
+ if (jsonMode) { io.writeResult(result); } else {
4854
+ console.log(chalk.bold(`\nšŸ“š Pattern Search: ${result.total} results`));
4855
+ for (const p of result.patterns) console.log(` ${p.id}: ${p.name} (${p.category})`);
4856
+ console.log('');
4857
+ }
4858
+ } else {
4859
+ const result = lib.listPatterns();
4860
+ if (jsonMode) { io.writeResult(result); } else {
4861
+ console.log(chalk.bold(`\nšŸ“š Pattern Library: ${result.total} patterns`));
4862
+ for (const p of result.patterns) console.log(` ${p.id}: ${p.name} [${p.category}]`);
4863
+ console.log('');
4864
+ }
4865
+ }
4866
+ return;
4867
+ }
4868
+
4869
+ // ─── Item 83: Domain Ontology ────────────────────────────────────────────
4870
+ if (subcommand === 'domain-ontology') {
4871
+ const lib = require('./lib/domain-ontology');
4872
+ const jsonMode = process.argv.includes('--json');
4873
+ const io = require('./lib/io');
4874
+ const action = process.argv[3] || 'report';
4875
+ if (action === 'define') {
4876
+ const domain = process.argv[4]; const name = process.argv[5]; const type = process.argv[6];
4877
+ const result = lib.defineElement(domain, name, type);
4878
+ if (jsonMode) { io.writeResult(result); } else {
4879
+ if (result.success) console.log(chalk.green(`\nāœ… Element ${result.element.id} defined: ${name} (${type})\n`));
4880
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4881
+ }
4882
+ } else if (action === 'query') {
4883
+ const domain = process.argv[4];
4884
+ const result = lib.queryOntology(domain);
4885
+ if (jsonMode) { io.writeResult(result); } else {
4886
+ console.log(chalk.bold(`\nšŸ·ļø Ontology: ${result.domain} (${result.total} elements)\n`));
4887
+ }
4888
+ } else {
4889
+ const result = lib.generateReport();
4890
+ if (jsonMode) { io.writeResult(result); } else {
4891
+ console.log(chalk.bold(`\nšŸ·ļø Domain Ontology Report: ${result.total_domains} domains\n`));
4892
+ }
4893
+ }
4894
+ return;
4895
+ }
4896
+
4897
+ // ─── Item 84: Data Contracts ─────────────────────────────────────────────
4898
+ if (subcommand === 'data-contracts') {
4899
+ const lib = require('./lib/data-contracts');
4900
+ const jsonMode = process.argv.includes('--json');
4901
+ const io = require('./lib/io');
4902
+ const action = process.argv[3] || 'report';
4903
+ if (action === 'register') {
4904
+ const name = process.argv[4];
4905
+ const result = lib.registerContract(name, { field1: 'string' });
4906
+ if (jsonMode) { io.writeResult(result); } else {
4907
+ if (result.success) console.log(chalk.green(`\nāœ… Contract ${result.contract.id} registered: ${name}\n`));
4908
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4909
+ }
4910
+ } else {
4911
+ const result = lib.generateReport();
4912
+ if (jsonMode) { io.writeResult(result); } else {
4913
+ console.log(chalk.bold(`\nšŸ“œ Data Contracts: ${result.total_contracts} contracts, ${result.total_lineage} lineage entries\n`));
4914
+ }
4915
+ }
4916
+ return;
4917
+ }
4918
+
4919
+ // ─── Item 85: Event Modeling ─────────────────────────────────────────────
4920
+ if (subcommand === 'event-modeling') {
4921
+ const lib = require('./lib/event-modeling');
4922
+ const jsonMode = process.argv.includes('--json');
4923
+ const io = require('./lib/io');
4924
+ const action = process.argv[3] || 'report';
4925
+ if (action === 'define') {
4926
+ const name = process.argv[4]; const type = process.argv[5] || 'topic';
4927
+ if (type === 'topic') {
4928
+ const result = lib.defineTopic(name);
4929
+ if (jsonMode) { io.writeResult(result); } else {
4930
+ if (result.success) console.log(chalk.green(`\nāœ… Topic ${result.topic.id} defined: ${name}\n`));
4931
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4932
+ }
4933
+ }
4934
+ } else {
4935
+ const result = lib.generateReport();
4936
+ if (jsonMode) { io.writeResult(result); } else {
4937
+ console.log(chalk.bold(`\nšŸ“” Event Model: ${result.total_topics} topics, ${result.total_events} events, ${result.total_sagas} sagas\n`));
4938
+ }
4939
+ }
4940
+ return;
4941
+ }
4942
+
4943
+ // ─── Item 86: Platform Engineering ───────────────────────────────────────
4944
+ if (subcommand === 'platform-engineering') {
4945
+ const lib = require('./lib/platform-engineering');
4946
+ const jsonMode = process.argv.includes('--json');
4947
+ const io = require('./lib/io');
4948
+ const action = process.argv[3] || 'report';
4949
+ if (action === 'register') {
4950
+ const name = process.argv[4]; const type = process.argv[5] || 'service';
4951
+ const result = lib.registerTemplate(name, type);
4952
+ if (jsonMode) { io.writeResult(result); } else {
4953
+ if (result.success) console.log(chalk.green(`\nāœ… Template ${result.template.id} registered: ${name}\n`));
4954
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4955
+ }
4956
+ } else if (action === 'list') {
4957
+ const result = lib.listTemplates();
4958
+ if (jsonMode) { io.writeResult(result); } else {
4959
+ console.log(chalk.bold(`\nšŸ—ļø Platform Templates: ${result.total}`));
4960
+ for (const t of result.templates) console.log(` ${t.id}: ${t.name} (${t.type})`);
4961
+ console.log('');
4962
+ }
4963
+ } else {
4964
+ const result = lib.generateReport();
4965
+ if (jsonMode) { io.writeResult(result); } else {
4966
+ console.log(chalk.bold(`\nšŸ—ļø Platform Report: ${result.total_templates} templates, ${result.total_instances} instances\n`));
4967
+ }
4968
+ }
4969
+ return;
4970
+ }
4971
+
4972
+ // ─── Item 90: AI Evaluation ──────────────────────────────────────────────
4973
+ if (subcommand === 'ai-evaluation') {
4974
+ const lib = require('./lib/ai-evaluation');
4975
+ const jsonMode = process.argv.includes('--json');
4976
+ const io = require('./lib/io');
4977
+ const action = process.argv[3] || 'report';
4978
+ if (action === 'evaluate') {
4979
+ const name = process.argv[4];
4980
+ const result = lib.evaluate(name, { groundedness: 80, hallucination: 90, safety: 85 });
4981
+ if (jsonMode) { io.writeResult(result); } else {
4982
+ if (result.success) {
4983
+ console.log(chalk.bold(`\nšŸ¤– AI Evaluation: ${name}`));
4984
+ console.log(` Overall: ${result.evaluation.overall}%\n`);
4985
+ } else console.log(chalk.red(`\nāŒ ${result.error}\n`));
4986
+ }
4987
+ } else {
4988
+ const result = lib.generateReport();
4989
+ if (jsonMode) { io.writeResult(result); } else {
4990
+ console.log(chalk.bold(`\nšŸ¤– AI Evaluation Report: ${result.total_evaluations} evaluations\n`));
4991
+ }
4992
+ }
4993
+ return;
4994
+ }
4995
+
4996
+ // ─── Item 91: Prompt Governance ──────────────────────────────────────────
4997
+ if (subcommand === 'prompt-governance') {
4998
+ const lib = require('./lib/prompt-governance');
4999
+ const jsonMode = process.argv.includes('--json');
5000
+ const io = require('./lib/io');
5001
+ const action = process.argv[3] || 'list';
5002
+ if (action === 'register') {
5003
+ const name = process.argv[4]; const type = process.argv[5] || 'prompt';
5004
+ const result = lib.registerAsset(name, type, 'content');
5005
+ if (jsonMode) { io.writeResult(result); } else {
5006
+ if (result.success) console.log(chalk.green(`\nāœ… Asset ${result.asset.id} registered: ${name}\n`));
5007
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
5008
+ }
5009
+ } else if (action === 'approve') {
5010
+ const assetId = process.argv[4]; const version = process.argv[5] || '1.0.0';
5011
+ const result = lib.approveVersion(assetId, version);
5012
+ if (jsonMode) { io.writeResult(result); } else {
5013
+ if (result.success) console.log(chalk.green(`\nāœ… Version ${version} approved\n`));
5014
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
5015
+ }
5016
+ } else {
5017
+ const result = lib.listAssets();
5018
+ if (jsonMode) { io.writeResult(result); } else {
5019
+ console.log(chalk.bold(`\nšŸ“‹ Prompt Governance: ${result.total} assets`));
5020
+ for (const a of result.assets) console.log(` ${a.id}: ${a.name} [${a.type}] v${a.current_version}`);
5021
+ console.log('');
5022
+ }
5023
+ }
5024
+ return;
5025
+ }
5026
+
5027
+ // ─── Item 94: SRE Integration ────────────────────────────────────────────
5028
+ if (subcommand === 'sre-integration') {
5029
+ const lib = require('./lib/sre-integration');
5030
+ const jsonMode = process.argv.includes('--json');
5031
+ const io = require('./lib/io');
5032
+ const action = process.argv[3] || 'report';
5033
+ if (action === 'generate') {
5034
+ const type = process.argv[4] || 'monitor';
5035
+ if (type === 'monitor') {
5036
+ const name = process.argv[5] || 'default-monitor';
5037
+ const result = lib.generateMonitor(name, 'uptime');
5038
+ if (jsonMode) { io.writeResult(result); } else {
5039
+ if (result.success) console.log(chalk.green(`\nāœ… Monitor ${result.monitor.id} generated: ${name}\n`));
5040
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
5041
+ }
5042
+ } else if (type === 'alert') {
5043
+ const name = process.argv[5] || 'default-alert';
5044
+ const result = lib.generateAlert(name, 'warning');
5045
+ if (jsonMode) { io.writeResult(result); } else {
5046
+ if (result.success) console.log(chalk.green(`\nāœ… Alert ${result.alert.id} generated: ${name}\n`));
5047
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
5048
+ }
5049
+ } else if (type === 'runbook') {
5050
+ const name = process.argv[5] || 'default-runbook';
5051
+ const result = lib.generateRunbook(name, ['Check status', 'Restart service', 'Verify recovery']);
5052
+ if (jsonMode) { io.writeResult(result); } else {
5053
+ if (result.success) console.log(chalk.green(`\nāœ… Runbook ${result.runbook.id} generated: ${name}\n`));
5054
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
5055
+ }
5056
+ }
5057
+ } else {
5058
+ const result = lib.generateReport();
5059
+ if (jsonMode) { io.writeResult(result); } else {
5060
+ console.log(chalk.bold(`\nšŸ”§ SRE Report: ${result.total_monitors} monitors, ${result.total_alerts} alerts, ${result.total_runbooks} runbooks\n`));
5061
+ }
5062
+ }
5063
+ return;
5064
+ }
5065
+
5066
+ // ─── Item 95: Telemetry Feedback ─────────────────────────────────────────
5067
+ if (subcommand === 'telemetry-feedback') {
5068
+ const lib = require('./lib/telemetry-feedback');
5069
+ const jsonMode = process.argv.includes('--json');
5070
+ const io = require('./lib/io');
5071
+ const action = process.argv[3] || 'report';
5072
+ if (action === 'ingest') {
5073
+ const name = process.argv[4]; const type = process.argv[5]; const value = parseFloat(process.argv[6]);
5074
+ const result = lib.ingestMetric(name, type, value);
5075
+ if (jsonMode) { io.writeResult(result); } else {
5076
+ if (result.success) console.log(chalk.green(`\nāœ… Metric ingested: ${result.metric.id}\n`));
5077
+ else console.log(chalk.red(`\nāŒ ${result.error}\n`));
5078
+ }
5079
+ } else if (action === 'analyze') {
5080
+ const result = lib.analyzeMetrics();
5081
+ if (jsonMode) { io.writeResult(result); } else {
5082
+ console.log(chalk.bold(`\nšŸ“ˆ Telemetry Analysis: ${result.total_metrics} metrics\n`));
5083
+ }
5084
+ } else {
5085
+ const result = lib.generateFeedbackReport();
5086
+ if (jsonMode) { io.writeResult(result); } else {
5087
+ console.log(chalk.bold(`\nšŸ“ˆ Telemetry Report: ${result.total_metrics} metrics`));
5088
+ if (result.recommendations.length > 0) {
5089
+ for (const r of result.recommendations) console.log(` āš ļø ${r}`);
5090
+ }
5091
+ console.log('');
5092
+ }
5093
+ }
5094
+ return;
5095
+ }
5096
+
5097
+ // ─── Item 96: Enterprise Search ──────────────────────────────────────────
5098
+ if (subcommand === 'enterprise-search') {
5099
+ const lib = require('./lib/enterprise-search');
5100
+ const jsonMode = process.argv.includes('--json');
5101
+ const io = require('./lib/io');
5102
+ const root = process.cwd();
5103
+ const action = process.argv[3] || 'index';
5104
+ if (action === 'search') {
5105
+ const query = process.argv[4];
5106
+ const result = lib.searchProject(root, query);
5107
+ if (jsonMode) { io.writeResult(result); } else {
5108
+ if (result.success) {
5109
+ console.log(chalk.bold(`\nšŸ” Search: "${query}" — ${result.total_results} results`));
5110
+ for (const r of result.results) console.log(` [${r.type}] ${r.path} (${r.matches} matches)`);
5111
+ console.log('');
5112
+ } else console.log(chalk.red(`\nāŒ ${result.error}\n`));
5113
+ }
5114
+ } else {
5115
+ const result = lib.indexProject(root);
5116
+ if (jsonMode) { io.writeResult(result); } else {
5117
+ console.log(chalk.bold(`\nšŸ” Enterprise Search Index: ${result.total_entries} entries\n`));
5118
+ }
5119
+ }
5120
+ return;
5121
+ }
5122
+
5123
+ // ─── Item 40: Revert / Rollback Workflows ────────────────────────────────
5124
+ if (subcommand === 'revert') {
5125
+ const { revertArtifact } = await import('./lib/revert.js');
5126
+ const jsonMode = process.argv.includes('--json');
5127
+ const io = require('./lib/io');
5128
+ const artifactPath = process.argv[3];
5129
+ if (!artifactPath || artifactPath.startsWith('--')) {
5130
+ console.error(chalk.red('Usage: jumpstart-mode revert <artifact-path> [--reason "..."]'));
5131
+ process.exit(1);
5132
+ }
5133
+ const reasonIdx = process.argv.indexOf('--reason');
5134
+ const reason = reasonIdx > -1 ? process.argv[reasonIdx + 1] : undefined;
5135
+ const result = revertArtifact({ artifact: artifactPath, reason });
5136
+ if (jsonMode) { io.writeResult(result); } else {
5137
+ if (result.success) {
5138
+ console.log(chalk.green(`\nāœ… Reverted: ${artifactPath}`));
5139
+ console.log(` Archived to: ${result.archived_to}`);
5140
+ console.log(` Restored from: ${result.restored_from || 'none (archive only)'}`);
5141
+ console.log(` Reason: ${result.reason}\n`);
5142
+ } else { console.log(chalk.red(`\nāŒ ${result.error}\n`)); }
5143
+ }
5144
+ return;
5145
+ }
5146
+
5147
+ // ─── Item 51: ADR Index ──────────────────────────────────────────────────
5148
+ if (subcommand === 'adr') {
5149
+ const { buildIndex, searchIndex } = await import('./lib/adr-index.js');
5150
+ const jsonMode = process.argv.includes('--json');
5151
+ const io = require('./lib/io');
5152
+ const root = process.cwd();
5153
+ const action = process.argv[3] || 'build';
5154
+ if (action === 'search') {
5155
+ const query = process.argv[4] || '';
5156
+ const tag = process.argv.includes('--tag') ? process.argv[process.argv.indexOf('--tag') + 1] : undefined;
5157
+ const index = buildIndex(root);
5158
+ const result = searchIndex(index, query, { tag });
5159
+ if (jsonMode) { io.writeResult(result); } else {
5160
+ console.log(chalk.bold(`\nšŸ“‹ ADR Search: "${query}" — ${result.total} results`));
5161
+ for (const r of result.results) console.log(` ${r.id}: ${r.title} [${r.status}]`);
5162
+ console.log('');
5163
+ }
5164
+ } else {
5165
+ const result = buildIndex(root);
5166
+ if (jsonMode) { io.writeResult(result); } else {
5167
+ console.log(chalk.bold(`\nšŸ“‹ ADR Index: ${result.indexed} records indexed`));
5168
+ console.log(` Index path: ${result.index_path}\n`);
5169
+ }
5170
+ }
5171
+ return;
5172
+ }
5173
+
5174
+ // ─── Item 33: Complexity Calculator ──────────────────────────────────────
5175
+ if (subcommand === 'complexity') {
5176
+ const { calculateComplexity } = await import('./lib/complexity.js');
5177
+ const jsonMode = process.argv.includes('--json');
5178
+ const io = require('./lib/io');
5179
+ const desc = process.argv[3] && !process.argv[3].startsWith('--') ? process.argv[3] : '';
5180
+ const result = calculateComplexity({ description: desc, root: process.cwd() });
5181
+ if (jsonMode) { io.writeResult(result); } else {
5182
+ console.log(chalk.bold(`\nšŸ“Š Complexity Assessment`));
5183
+ console.log(` Recommended depth: ${result.recommended_depth}`);
5184
+ console.log(` Score: ${result.score}`);
5185
+ console.log(` Reasoning: ${result.reasoning}\n`);
5186
+ }
5187
+ return;
5188
+ }
5189
+
5190
+ // ─── Item 47: Cross-Reference Validation ────────────────────────────────
5191
+ if (subcommand === 'crossref') {
5192
+ const { validateCrossRefs } = await import('./lib/crossref.js');
5193
+ const jsonMode = process.argv.includes('--json');
5194
+ const io = require('./lib/io');
5195
+ const specsDir = process.argv[3] && !process.argv[3].startsWith('--') ? process.argv[3] : 'specs';
5196
+ const root = process.cwd();
5197
+ const result = validateCrossRefs(specsDir, root);
5198
+ if (jsonMode) { io.writeResult(result); } else {
5199
+ console.log(chalk.bold(`\nšŸ”— Cross-Reference Validation`));
5200
+ console.log(` Files scanned: ${result.files_scanned} Total links: ${result.total_links}`);
5201
+ console.log(` Valid: ${result.valid_links} Broken: ${result.broken_links.length}`);
5202
+ console.log(` Score: ${result.score}% ${result.pass ? chalk.green('PASS') : chalk.red('FAIL')}`);
5203
+ if (result.broken_links.length > 0) {
5204
+ console.log(' Broken links:');
5205
+ for (const b of result.broken_links.slice(0, 10)) console.log(` ${b.file}:${b.line} → ${b.target}`);
5206
+ }
5207
+ console.log('');
5208
+ }
5209
+ return;
5210
+ }
5211
+
5212
+ // ─── Item 76: Interactive Init ───────────────────────────────────────────
5213
+ if (subcommand === 'init') {
5214
+ const { generateInitConfig } = await import('./lib/init.js');
5215
+ const jsonMode = process.argv.includes('--json');
5216
+ const io = require('./lib/io');
5217
+ const skillLevel = process.argv[3] && !process.argv[3].startsWith('--') ? process.argv[3] : 'intermediate';
5218
+ const projectType = process.argv.includes('--type') ? process.argv[process.argv.indexOf('--type') + 1] : 'greenfield';
5219
+ const result = generateInitConfig({ skill_level: skillLevel, project_type: projectType });
5220
+ if (jsonMode) { io.writeResult(result); } else {
5221
+ console.log(chalk.bold(`\nšŸŽÆ Init Configuration (${result.skill_level})`));
5222
+ console.log(` Explanation depth: ${result.explanation_depth}`);
5223
+ console.log(` Project type: ${result.project_type}`);
5224
+ console.log(' Recommendations:');
5225
+ for (const r of result.recommendations) console.log(` • ${r}`);
5226
+ console.log('');
5227
+ }
5228
+ return;
5229
+ }
5230
+
5231
+ // ─── Item 45: File Locking ──────────────────────────────────────────────
5232
+ if (subcommand === 'lock') {
5233
+ const { acquireLock, releaseLock, lockStatus, listLocks } = await import('./lib/locks.js');
5234
+ const jsonMode = process.argv.includes('--json');
5235
+ const io = require('./lib/io');
5236
+ const action = process.argv[3] || 'list';
5237
+ if (action === 'acquire') {
5238
+ const file = process.argv[4];
5239
+ const agent = process.argv[5] || 'cli';
5240
+ if (!file) { console.error(chalk.red('Usage: jumpstart-mode lock acquire <file> [agent]')); process.exit(1); }
5241
+ const result = acquireLock(file, agent);
5242
+ if (jsonMode) { io.writeResult(result); } else {
5243
+ console.log(result.success ? chalk.green(`\nāœ… Lock acquired: ${file} by ${agent}\n`) : chalk.red(`\nāŒ ${result.error}\n`));
5244
+ }
5245
+ } else if (action === 'release') {
5246
+ const file = process.argv[4];
5247
+ const agent = process.argv[5] || 'cli';
5248
+ if (!file) { console.error(chalk.red('Usage: jumpstart-mode lock release <file> [agent]')); process.exit(1); }
5249
+ const result = releaseLock(file, agent);
5250
+ if (jsonMode) { io.writeResult(result); } else {
5251
+ console.log(result.success ? chalk.green(`\nāœ… Lock released: ${file}\n`) : chalk.red(`\nāŒ ${result.error}\n`));
5252
+ }
5253
+ } else if (action === 'status') {
5254
+ const file = process.argv[4];
5255
+ if (!file) { console.error(chalk.red('Usage: jumpstart-mode lock status <file>')); process.exit(1); }
5256
+ const result = lockStatus(file);
5257
+ if (jsonMode) { io.writeResult(result); } else {
5258
+ console.log(chalk.bold('\nšŸ”’ Lock Status'));
5259
+ console.log(` File: ${file}`);
5260
+ console.log(` Locked: ${result.locked}`);
5261
+ if (result.lock) console.log(` By: ${result.lock.agent} Since: ${result.lock.acquired_at}`);
5262
+ console.log('');
5263
+ }
5264
+ } else {
5265
+ const result = listLocks();
5266
+ if (jsonMode) { io.writeResult(result); } else {
5267
+ console.log(chalk.bold(`\nšŸ”’ Active Locks (${result.total})`));
5268
+ for (const l of result.locks) console.log(` ${l.file}: ${l.agent} (${l.acquired_at})`);
5269
+ if (result.total === 0) console.log(' No active locks');
5270
+ console.log('');
5271
+ }
5272
+ }
5273
+ return;
5274
+ }
5275
+
5276
+ // ─── Item 60: Timestamp Utilities ────────────────────────────────────────
5277
+ if (subcommand === 'timestamp') {
5278
+ const { now, validate: validateTs, audit: auditTs } = await import('./lib/timestamps.js');
5279
+ const jsonMode = process.argv.includes('--json');
5280
+ const io = require('./lib/io');
5281
+ const action = process.argv[3] || 'now';
5282
+ if (action === 'validate') {
5283
+ const value = process.argv[4];
5284
+ if (!value) { console.error(chalk.red('Usage: jumpstart-mode timestamp validate <timestamp>')); process.exit(1); }
5285
+ const result = validateTs(value);
5286
+ if (jsonMode) { io.writeResult(result); } else {
5287
+ console.log(result.valid ? chalk.green(`\nāœ… Valid: ${value}\n`) : chalk.red(`\nāŒ Invalid: ${result.error}\n`));
5288
+ }
5289
+ } else if (action === 'audit') {
5290
+ const file = process.argv[4];
5291
+ if (!file) { console.error(chalk.red('Usage: jumpstart-mode timestamp audit <file>')); process.exit(1); }
5292
+ const result = auditTs(file);
5293
+ if (jsonMode) { io.writeResult(result); } else {
5294
+ console.log(chalk.bold(`\nšŸ• Timestamp Audit: ${file}`));
5295
+ console.log(` Entries: ${result.entries} Valid: ${result.valid} Invalid: ${result.invalid.length}`);
5296
+ if (result.invalid.length > 0) {
5297
+ for (const inv of result.invalid.slice(0, 5)) console.log(` Line ${inv.line}: ${inv.value}`);
5298
+ }
5299
+ console.log('');
5300
+ }
5301
+ } else {
5302
+ const ts = now();
5303
+ if (jsonMode) { io.writeResult({ timestamp: ts }); } else {
5304
+ console.log(`\nšŸ• ${ts}\n`);
5305
+ }
5306
+ }
5307
+ return;
5308
+ }
5309
+
5310
+ // ─── Item 49: Project Scanner ────────────────────────────────────────────
5311
+ if (subcommand === 'scan') {
5312
+ const { scan: scanProject } = await import('./lib/scanner.js');
5313
+ const jsonMode = process.argv.includes('--json');
5314
+ const io = require('./lib/io');
5315
+ const root = process.argv[3] && !process.argv[3].startsWith('--') ? process.argv[3] : process.cwd();
5316
+ const result = scanProject({ root });
5317
+ if (jsonMode) { io.writeResult(result); } else {
5318
+ console.log(chalk.bold('\nšŸ” Project Scan Results'));
5319
+ console.log(` Files: ${result.stats.files} Directories: ${result.stats.directories}`);
5320
+ if (result.stack) {
5321
+ const s = result.stack;
5322
+ if (s.language) console.log(` Language: ${Array.isArray(s.language) ? s.language.join(', ') : s.language}`);
5323
+ if (s.runtime) console.log(` Runtime: ${s.runtime}`);
5324
+ if (s.framework) console.log(` Framework: ${Array.isArray(s.framework) ? s.framework.join(', ') : s.framework}`);
5325
+ }
5326
+ if (result.risks && result.risks.length > 0) {
5327
+ console.log(' Risks:');
5328
+ for (const r of result.risks.slice(0, 5)) console.log(` ⚠ ${r}`);
5329
+ }
5330
+ console.log('');
5331
+ }
5332
+ return;
5333
+ }
5334
+
2119
5335
  let config = parseArgs();
2120
5336
 
2121
5337
  if (config.help) {