@build-astron-co/nimbus 0.4.2 → 0.4.3

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 (430) hide show
  1. package/dist/src/agent/compaction-agent.js +24 -12
  2. package/dist/src/agent/context-manager.js +2 -1
  3. package/dist/src/agent/expand-files.js +2 -1
  4. package/dist/src/agent/loop.js +71 -33
  5. package/dist/src/agent/permissions.js +4 -2
  6. package/dist/src/agent/system-prompt.js +34 -17
  7. package/dist/src/app.js +1 -1
  8. package/dist/src/auth/keychain.js +8 -4
  9. package/dist/src/auth/store.js +70 -107
  10. package/dist/src/cli/init.js +35 -19
  11. package/dist/src/cli/run.js +18 -10
  12. package/dist/src/cli/serve.js +4 -2
  13. package/dist/src/cli.js +52 -11
  14. package/dist/src/commands/alias.js +5 -3
  15. package/dist/src/commands/audit/index.js +2 -1
  16. package/dist/src/commands/aws-terraform.js +36 -18
  17. package/dist/src/commands/completions.js +1 -1
  18. package/dist/src/commands/config.js +3 -2
  19. package/dist/src/commands/connect-github.js +92 -0
  20. package/dist/src/commands/cost/index.js +3 -2
  21. package/dist/src/commands/deploy.js +15 -10
  22. package/dist/src/commands/doctor.js +6 -3
  23. package/dist/src/commands/drift/index.js +2 -1
  24. package/dist/src/commands/export.js +5 -3
  25. package/dist/src/commands/generate-terraform.js +110 -2
  26. package/dist/src/commands/import.js +3 -3
  27. package/dist/src/commands/incident.js +10 -5
  28. package/dist/src/commands/login.js +8 -93
  29. package/dist/src/commands/logs.js +16 -8
  30. package/dist/src/commands/onboarding.js +6 -4
  31. package/dist/src/commands/pipeline.js +6 -3
  32. package/dist/src/commands/plugin.js +3 -2
  33. package/dist/src/commands/profile.js +27 -14
  34. package/dist/src/commands/questionnaire.js +1 -1
  35. package/dist/src/commands/rollback.js +3 -2
  36. package/dist/src/commands/rollout.js +5 -3
  37. package/dist/src/commands/runbook.js +17 -10
  38. package/dist/src/commands/schedule.js +10 -5
  39. package/dist/src/commands/status.js +2 -1
  40. package/dist/src/commands/team-context.js +12 -7
  41. package/dist/src/commands/template.js +1 -1
  42. package/dist/src/commands/tf/index.js +6 -3
  43. package/dist/src/commands/version.js +6 -3
  44. package/dist/src/commands/watch.js +6 -3
  45. package/dist/src/compat/sqlite.js +5 -3
  46. package/dist/src/config/mode-store.js +2 -1
  47. package/dist/src/config/profiles.js +4 -2
  48. package/dist/src/config/types.js +2 -1
  49. package/dist/src/engine/executor.js +8 -4
  50. package/dist/src/engine/planner.js +9 -5
  51. package/dist/src/llm/providers/anthropic.js +6 -3
  52. package/dist/src/llm/providers/ollama.js +1 -1
  53. package/dist/src/llm/router.js +22 -7
  54. package/dist/src/sessions/manager.js +6 -3
  55. package/dist/src/sharing/viewer.js +2 -1
  56. package/dist/src/tools/file-ops.js +1 -2
  57. package/dist/src/tools/schemas/devops.js +197 -108
  58. package/dist/src/tools/schemas/standard.js +1 -1
  59. package/dist/src/ui/App.js +25 -13
  60. package/dist/src/ui/FileDiffModal.js +22 -11
  61. package/dist/src/ui/HelpModal.js +2 -1
  62. package/dist/src/ui/InputBox.js +6 -3
  63. package/dist/src/ui/MessageList.js +40 -20
  64. package/dist/src/ui/TerminalPane.js +2 -1
  65. package/dist/src/ui/ToolCallDisplay.js +12 -6
  66. package/dist/src/ui/TreePane.js +2 -1
  67. package/dist/src/ui/ink/index.js +37 -21
  68. package/dist/src/watcher/index.js +8 -4
  69. package/package.json +3 -5
  70. package/src/__tests__/alias.test.ts +0 -133
  71. package/src/__tests__/app.test.ts +0 -76
  72. package/src/__tests__/audit.test.ts +0 -877
  73. package/src/__tests__/circuit-breaker.test.ts +0 -116
  74. package/src/__tests__/cli-run.test.ts +0 -351
  75. package/src/__tests__/compat-sqlite.test.ts +0 -68
  76. package/src/__tests__/context-manager.test.ts +0 -632
  77. package/src/__tests__/context.test.ts +0 -242
  78. package/src/__tests__/devops-terminal-gaps.test.ts +0 -718
  79. package/src/__tests__/doctor.test.ts +0 -48
  80. package/src/__tests__/enterprise.test.ts +0 -401
  81. package/src/__tests__/export.test.ts +0 -236
  82. package/src/__tests__/gap-11-18-20.test.ts +0 -958
  83. package/src/__tests__/generator.test.ts +0 -433
  84. package/src/__tests__/helm-streaming.test.ts +0 -127
  85. package/src/__tests__/hooks.test.ts +0 -582
  86. package/src/__tests__/incident.test.ts +0 -179
  87. package/src/__tests__/init.test.ts +0 -487
  88. package/src/__tests__/intent-parser.test.ts +0 -229
  89. package/src/__tests__/llm-router.test.ts +0 -209
  90. package/src/__tests__/logs.test.ts +0 -107
  91. package/src/__tests__/loop-errors.test.ts +0 -244
  92. package/src/__tests__/lsp.test.ts +0 -293
  93. package/src/__tests__/modes.test.ts +0 -336
  94. package/src/__tests__/perf-optimizations.test.ts +0 -847
  95. package/src/__tests__/permissions.test.ts +0 -338
  96. package/src/__tests__/pipeline.test.ts +0 -50
  97. package/src/__tests__/polish-phase3.test.ts +0 -340
  98. package/src/__tests__/profile.test.ts +0 -237
  99. package/src/__tests__/rollback.test.ts +0 -83
  100. package/src/__tests__/runbook.test.ts +0 -219
  101. package/src/__tests__/schedule.test.ts +0 -206
  102. package/src/__tests__/serve.test.ts +0 -275
  103. package/src/__tests__/sessions.test.ts +0 -322
  104. package/src/__tests__/sharing.test.ts +0 -340
  105. package/src/__tests__/snapshots.test.ts +0 -581
  106. package/src/__tests__/standalone-migration.test.ts +0 -199
  107. package/src/__tests__/state-db.test.ts +0 -334
  108. package/src/__tests__/status.test.ts +0 -158
  109. package/src/__tests__/stream-with-tools.test.ts +0 -778
  110. package/src/__tests__/subagents.test.ts +0 -176
  111. package/src/__tests__/system-prompt.test.ts +0 -248
  112. package/src/__tests__/terminal-gap-v2.test.ts +0 -395
  113. package/src/__tests__/terminal-parity.test.ts +0 -393
  114. package/src/__tests__/tf-apply.test.ts +0 -187
  115. package/src/__tests__/tool-converter.test.ts +0 -256
  116. package/src/__tests__/tool-schemas.test.ts +0 -602
  117. package/src/__tests__/tools.test.ts +0 -144
  118. package/src/__tests__/version-json.test.ts +0 -184
  119. package/src/__tests__/version.test.ts +0 -49
  120. package/src/__tests__/watch.test.ts +0 -129
  121. package/src/agent/compaction-agent.ts +0 -266
  122. package/src/agent/context-manager.ts +0 -499
  123. package/src/agent/context.ts +0 -427
  124. package/src/agent/deploy-preview.ts +0 -487
  125. package/src/agent/expand-files.ts +0 -108
  126. package/src/agent/index.ts +0 -68
  127. package/src/agent/loop.ts +0 -1998
  128. package/src/agent/modes.ts +0 -429
  129. package/src/agent/permissions.ts +0 -513
  130. package/src/agent/subagents/base.ts +0 -116
  131. package/src/agent/subagents/cost.ts +0 -51
  132. package/src/agent/subagents/explore.ts +0 -42
  133. package/src/agent/subagents/general.ts +0 -54
  134. package/src/agent/subagents/index.ts +0 -102
  135. package/src/agent/subagents/infra.ts +0 -59
  136. package/src/agent/subagents/security.ts +0 -69
  137. package/src/agent/system-prompt.ts +0 -990
  138. package/src/app.ts +0 -180
  139. package/src/audit/activity-log.ts +0 -290
  140. package/src/audit/compliance-checker.ts +0 -540
  141. package/src/audit/cost-tracker.ts +0 -318
  142. package/src/audit/index.ts +0 -23
  143. package/src/audit/security-scanner.ts +0 -641
  144. package/src/auth/guard.ts +0 -75
  145. package/src/auth/index.ts +0 -56
  146. package/src/auth/keychain.ts +0 -82
  147. package/src/auth/oauth.ts +0 -465
  148. package/src/auth/providers.ts +0 -470
  149. package/src/auth/sso.ts +0 -113
  150. package/src/auth/store.ts +0 -505
  151. package/src/auth/types.ts +0 -187
  152. package/src/build.ts +0 -141
  153. package/src/cli/index.ts +0 -16
  154. package/src/cli/init.ts +0 -1227
  155. package/src/cli/openapi-spec.ts +0 -356
  156. package/src/cli/run.ts +0 -628
  157. package/src/cli/serve-auth.ts +0 -80
  158. package/src/cli/serve.ts +0 -539
  159. package/src/cli/web.ts +0 -71
  160. package/src/cli.ts +0 -1728
  161. package/src/clients/core-engine-client.ts +0 -227
  162. package/src/clients/enterprise-client.ts +0 -334
  163. package/src/clients/generator-client.ts +0 -351
  164. package/src/clients/git-client.ts +0 -627
  165. package/src/clients/github-client.ts +0 -410
  166. package/src/clients/helm-client.ts +0 -504
  167. package/src/clients/index.ts +0 -80
  168. package/src/clients/k8s-client.ts +0 -497
  169. package/src/clients/llm-client.ts +0 -161
  170. package/src/clients/rest-client.ts +0 -130
  171. package/src/clients/service-discovery.ts +0 -38
  172. package/src/clients/terraform-client.ts +0 -482
  173. package/src/clients/tools-client.ts +0 -1843
  174. package/src/clients/ws-client.ts +0 -115
  175. package/src/commands/alias.ts +0 -100
  176. package/src/commands/analyze/index.ts +0 -352
  177. package/src/commands/apply/helm.ts +0 -473
  178. package/src/commands/apply/index.ts +0 -213
  179. package/src/commands/apply/k8s.ts +0 -454
  180. package/src/commands/apply/terraform.ts +0 -582
  181. package/src/commands/ask.ts +0 -167
  182. package/src/commands/audit/index.ts +0 -357
  183. package/src/commands/auth-cloud.ts +0 -407
  184. package/src/commands/auth-list.ts +0 -134
  185. package/src/commands/auth-profile.ts +0 -121
  186. package/src/commands/auth-refresh.ts +0 -187
  187. package/src/commands/auth-status.ts +0 -141
  188. package/src/commands/aws/ec2.ts +0 -501
  189. package/src/commands/aws/iam.ts +0 -397
  190. package/src/commands/aws/index.ts +0 -133
  191. package/src/commands/aws/lambda.ts +0 -396
  192. package/src/commands/aws/rds.ts +0 -439
  193. package/src/commands/aws/s3.ts +0 -439
  194. package/src/commands/aws/vpc.ts +0 -393
  195. package/src/commands/aws-discover.ts +0 -542
  196. package/src/commands/aws-terraform.ts +0 -755
  197. package/src/commands/azure/aks.ts +0 -376
  198. package/src/commands/azure/functions.ts +0 -253
  199. package/src/commands/azure/index.ts +0 -116
  200. package/src/commands/azure/storage.ts +0 -478
  201. package/src/commands/azure/vm.ts +0 -355
  202. package/src/commands/billing/index.ts +0 -256
  203. package/src/commands/chat.ts +0 -320
  204. package/src/commands/completions.ts +0 -268
  205. package/src/commands/config.ts +0 -372
  206. package/src/commands/cost/cloud-cost-estimator.ts +0 -266
  207. package/src/commands/cost/estimator.ts +0 -79
  208. package/src/commands/cost/index.ts +0 -810
  209. package/src/commands/cost/parsers/terraform.ts +0 -273
  210. package/src/commands/cost/parsers/types.ts +0 -25
  211. package/src/commands/cost/pricing/aws.ts +0 -544
  212. package/src/commands/cost/pricing/azure.ts +0 -499
  213. package/src/commands/cost/pricing/gcp.ts +0 -396
  214. package/src/commands/cost/pricing/index.ts +0 -40
  215. package/src/commands/demo.ts +0 -250
  216. package/src/commands/deploy.ts +0 -260
  217. package/src/commands/doctor.ts +0 -1386
  218. package/src/commands/drift/index.ts +0 -787
  219. package/src/commands/explain.ts +0 -277
  220. package/src/commands/export.ts +0 -146
  221. package/src/commands/feedback.ts +0 -389
  222. package/src/commands/fix.ts +0 -324
  223. package/src/commands/fs/index.ts +0 -402
  224. package/src/commands/gcp/compute.ts +0 -325
  225. package/src/commands/gcp/functions.ts +0 -271
  226. package/src/commands/gcp/gke.ts +0 -438
  227. package/src/commands/gcp/iam.ts +0 -344
  228. package/src/commands/gcp/index.ts +0 -129
  229. package/src/commands/gcp/storage.ts +0 -284
  230. package/src/commands/generate-helm.ts +0 -1249
  231. package/src/commands/generate-k8s.ts +0 -1508
  232. package/src/commands/generate-terraform.ts +0 -1202
  233. package/src/commands/gh/index.ts +0 -863
  234. package/src/commands/git/index.ts +0 -1343
  235. package/src/commands/helm/index.ts +0 -1126
  236. package/src/commands/help.ts +0 -715
  237. package/src/commands/history.ts +0 -149
  238. package/src/commands/import.ts +0 -868
  239. package/src/commands/incident.ts +0 -166
  240. package/src/commands/index.ts +0 -367
  241. package/src/commands/init.ts +0 -1051
  242. package/src/commands/k8s/index.ts +0 -1137
  243. package/src/commands/login.ts +0 -716
  244. package/src/commands/logout.ts +0 -83
  245. package/src/commands/logs.ts +0 -167
  246. package/src/commands/onboarding.ts +0 -405
  247. package/src/commands/pipeline.ts +0 -186
  248. package/src/commands/plan/display.ts +0 -279
  249. package/src/commands/plan/index.ts +0 -599
  250. package/src/commands/plugin.ts +0 -398
  251. package/src/commands/preview.ts +0 -452
  252. package/src/commands/profile.ts +0 -342
  253. package/src/commands/questionnaire.ts +0 -1172
  254. package/src/commands/resume.ts +0 -47
  255. package/src/commands/rollback.ts +0 -315
  256. package/src/commands/rollout.ts +0 -88
  257. package/src/commands/runbook.ts +0 -346
  258. package/src/commands/schedule.ts +0 -236
  259. package/src/commands/status.ts +0 -252
  260. package/src/commands/team/index.ts +0 -346
  261. package/src/commands/team-context.ts +0 -220
  262. package/src/commands/template.ts +0 -233
  263. package/src/commands/tf/index.ts +0 -1093
  264. package/src/commands/upgrade.ts +0 -609
  265. package/src/commands/usage/index.ts +0 -134
  266. package/src/commands/version.ts +0 -174
  267. package/src/commands/watch.ts +0 -153
  268. package/src/compat/index.ts +0 -2
  269. package/src/compat/runtime.ts +0 -12
  270. package/src/compat/sqlite.ts +0 -177
  271. package/src/config/index.ts +0 -17
  272. package/src/config/manager.ts +0 -530
  273. package/src/config/mode-store.ts +0 -62
  274. package/src/config/profiles.ts +0 -84
  275. package/src/config/safety-policy.ts +0 -358
  276. package/src/config/schema.ts +0 -125
  277. package/src/config/types.ts +0 -609
  278. package/src/config/workspace-state.ts +0 -53
  279. package/src/context/context-db.ts +0 -199
  280. package/src/demo/index.ts +0 -349
  281. package/src/demo/scenarios/full-journey.ts +0 -229
  282. package/src/demo/scenarios/getting-started.ts +0 -127
  283. package/src/demo/scenarios/helm-release.ts +0 -341
  284. package/src/demo/scenarios/k8s-deployment.ts +0 -194
  285. package/src/demo/scenarios/terraform-vpc.ts +0 -170
  286. package/src/demo/types.ts +0 -92
  287. package/src/engine/cost-estimator.ts +0 -480
  288. package/src/engine/diagram-generator.ts +0 -256
  289. package/src/engine/drift-detector.ts +0 -902
  290. package/src/engine/executor.ts +0 -1066
  291. package/src/engine/index.ts +0 -76
  292. package/src/engine/orchestrator.ts +0 -636
  293. package/src/engine/planner.ts +0 -787
  294. package/src/engine/safety.ts +0 -743
  295. package/src/engine/verifier.ts +0 -770
  296. package/src/enterprise/audit.ts +0 -348
  297. package/src/enterprise/auth.ts +0 -270
  298. package/src/enterprise/billing.ts +0 -822
  299. package/src/enterprise/index.ts +0 -17
  300. package/src/enterprise/teams.ts +0 -443
  301. package/src/generator/best-practices.ts +0 -1608
  302. package/src/generator/helm.ts +0 -630
  303. package/src/generator/index.ts +0 -37
  304. package/src/generator/intent-parser.ts +0 -514
  305. package/src/generator/kubernetes.ts +0 -976
  306. package/src/generator/terraform.ts +0 -1875
  307. package/src/history/index.ts +0 -8
  308. package/src/history/manager.ts +0 -250
  309. package/src/history/types.ts +0 -34
  310. package/src/hooks/config.ts +0 -432
  311. package/src/hooks/engine.ts +0 -392
  312. package/src/hooks/index.ts +0 -4
  313. package/src/llm/auth-bridge.ts +0 -198
  314. package/src/llm/circuit-breaker.ts +0 -140
  315. package/src/llm/config-loader.ts +0 -201
  316. package/src/llm/cost-calculator.ts +0 -171
  317. package/src/llm/index.ts +0 -8
  318. package/src/llm/model-aliases.ts +0 -115
  319. package/src/llm/provider-registry.ts +0 -63
  320. package/src/llm/providers/anthropic.ts +0 -462
  321. package/src/llm/providers/bedrock.ts +0 -477
  322. package/src/llm/providers/google.ts +0 -405
  323. package/src/llm/providers/ollama.ts +0 -767
  324. package/src/llm/providers/openai-compatible.ts +0 -340
  325. package/src/llm/providers/openai.ts +0 -328
  326. package/src/llm/providers/openrouter.ts +0 -338
  327. package/src/llm/router.ts +0 -1104
  328. package/src/llm/types.ts +0 -232
  329. package/src/lsp/client.ts +0 -298
  330. package/src/lsp/languages.ts +0 -119
  331. package/src/lsp/manager.ts +0 -294
  332. package/src/mcp/client.ts +0 -402
  333. package/src/mcp/index.ts +0 -5
  334. package/src/mcp/manager.ts +0 -133
  335. package/src/nimbus.ts +0 -234
  336. package/src/plugins/index.ts +0 -27
  337. package/src/plugins/loader.ts +0 -334
  338. package/src/plugins/manager.ts +0 -376
  339. package/src/plugins/types.ts +0 -284
  340. package/src/scanners/cicd-scanner.ts +0 -258
  341. package/src/scanners/cloud-scanner.ts +0 -466
  342. package/src/scanners/framework-scanner.ts +0 -469
  343. package/src/scanners/iac-scanner.ts +0 -388
  344. package/src/scanners/index.ts +0 -539
  345. package/src/scanners/language-scanner.ts +0 -276
  346. package/src/scanners/package-manager-scanner.ts +0 -277
  347. package/src/scanners/types.ts +0 -172
  348. package/src/sessions/manager.ts +0 -472
  349. package/src/sessions/types.ts +0 -44
  350. package/src/sharing/sync.ts +0 -300
  351. package/src/sharing/viewer.ts +0 -163
  352. package/src/snapshots/index.ts +0 -2
  353. package/src/snapshots/manager.ts +0 -530
  354. package/src/state/artifacts.ts +0 -147
  355. package/src/state/audit.ts +0 -137
  356. package/src/state/billing.ts +0 -240
  357. package/src/state/checkpoints.ts +0 -117
  358. package/src/state/config.ts +0 -67
  359. package/src/state/conversations.ts +0 -14
  360. package/src/state/credentials.ts +0 -154
  361. package/src/state/db.ts +0 -58
  362. package/src/state/index.ts +0 -26
  363. package/src/state/messages.ts +0 -115
  364. package/src/state/projects.ts +0 -123
  365. package/src/state/schema.ts +0 -236
  366. package/src/state/sessions.ts +0 -147
  367. package/src/state/teams.ts +0 -200
  368. package/src/telemetry.ts +0 -108
  369. package/src/tools/aws-ops.ts +0 -952
  370. package/src/tools/azure-ops.ts +0 -579
  371. package/src/tools/file-ops.ts +0 -615
  372. package/src/tools/gcp-ops.ts +0 -625
  373. package/src/tools/git-ops.ts +0 -773
  374. package/src/tools/github-ops.ts +0 -799
  375. package/src/tools/helm-ops.ts +0 -943
  376. package/src/tools/index.ts +0 -17
  377. package/src/tools/k8s-ops.ts +0 -819
  378. package/src/tools/schemas/converter.ts +0 -184
  379. package/src/tools/schemas/devops.ts +0 -3502
  380. package/src/tools/schemas/index.ts +0 -73
  381. package/src/tools/schemas/standard.ts +0 -1148
  382. package/src/tools/schemas/types.ts +0 -735
  383. package/src/tools/spawn-exec.ts +0 -148
  384. package/src/tools/terraform-ops.ts +0 -862
  385. package/src/types/ambient.d.ts +0 -193
  386. package/src/types/config.ts +0 -83
  387. package/src/types/drift.ts +0 -116
  388. package/src/types/enterprise.ts +0 -335
  389. package/src/types/index.ts +0 -20
  390. package/src/types/plan.ts +0 -44
  391. package/src/types/request.ts +0 -65
  392. package/src/types/response.ts +0 -54
  393. package/src/types/service.ts +0 -51
  394. package/src/ui/App.tsx +0 -2114
  395. package/src/ui/DeployPreview.tsx +0 -174
  396. package/src/ui/FileDiffModal.tsx +0 -162
  397. package/src/ui/Header.tsx +0 -131
  398. package/src/ui/HelpModal.tsx +0 -57
  399. package/src/ui/InputBox.tsx +0 -503
  400. package/src/ui/MessageList.tsx +0 -1032
  401. package/src/ui/PermissionPrompt.tsx +0 -163
  402. package/src/ui/StatusBar.tsx +0 -277
  403. package/src/ui/TerminalPane.tsx +0 -84
  404. package/src/ui/ToolCallDisplay.tsx +0 -643
  405. package/src/ui/TreePane.tsx +0 -132
  406. package/src/ui/chat-ui.ts +0 -850
  407. package/src/ui/index.ts +0 -33
  408. package/src/ui/ink/index.ts +0 -1444
  409. package/src/ui/streaming.ts +0 -176
  410. package/src/ui/theme.ts +0 -104
  411. package/src/ui/types.ts +0 -75
  412. package/src/utils/analytics.ts +0 -72
  413. package/src/utils/cost-warning.ts +0 -27
  414. package/src/utils/env.ts +0 -46
  415. package/src/utils/errors.ts +0 -69
  416. package/src/utils/event-bus.ts +0 -38
  417. package/src/utils/index.ts +0 -24
  418. package/src/utils/logger.ts +0 -171
  419. package/src/utils/rate-limiter.ts +0 -121
  420. package/src/utils/service-auth.ts +0 -49
  421. package/src/utils/validation.ts +0 -53
  422. package/src/version.ts +0 -4
  423. package/src/watcher/index.ts +0 -214
  424. package/src/wizard/approval.ts +0 -383
  425. package/src/wizard/index.ts +0 -25
  426. package/src/wizard/prompts.ts +0 -338
  427. package/src/wizard/types.ts +0 -172
  428. package/src/wizard/ui.ts +0 -556
  429. package/src/wizard/wizard.ts +0 -304
  430. package/tsconfig.json +0 -24
package/src/cli.ts DELETED
@@ -1,1728 +0,0 @@
1
- /**
2
- * CLI Command Router
3
- *
4
- * Dispatches CLI commands to their implementations in src/commands/.
5
- */
6
-
7
- import { analytics } from './utils';
8
- import { VERSION } from './version';
9
- import {
10
- generateTerraformCommand,
11
- type GenerateTerraformOptions,
12
- awsDiscoverCommand,
13
- type AwsDiscoverOptions,
14
- awsTerraformCommand,
15
- type AwsTerraformOptions,
16
- loginCommand,
17
- type LoginOptions,
18
- logoutCommand,
19
- type LogoutOptions,
20
- authStatusCommand,
21
- type AuthStatusOptions,
22
- authListCommand,
23
- type AuthListOptions,
24
- chatCommand,
25
- type ChatOptions,
26
- configCommand,
27
- type ConfigSetOptions,
28
- type ConfigGetOptions,
29
- type ConfigListOptions,
30
- type ConfigInitOptions,
31
- initCommand,
32
- type InitOptions,
33
- // Infrastructure tool commands
34
- tfCommand,
35
- k8sCommand,
36
- helmCommand,
37
- gitCommand,
38
- // FS commands
39
- fsCommand,
40
- // History command
41
- historyCommand,
42
- historyShowCommand,
43
- type HistoryOptions,
44
- // GitHub CLI commands
45
- ghCommand,
46
- // Enterprise commands
47
- teamCommand,
48
- billingCommand,
49
- usageCommand,
50
- parseUsageOptions,
51
- auditCommand,
52
- analyzeCommand,
53
- parseAnalyzeOptions,
54
- // Cloud provider commands
55
- awsCommand,
56
- azureCommand,
57
- gcpCommand,
58
- // Cost and drift commands
59
- costCommand,
60
- driftCommand,
61
- // Demo, feedback, preview, import, questionnaire commands
62
- demoCommand,
63
- parseDemoOptions,
64
- feedbackCommand,
65
- parseFeedbackOptions,
66
- previewCommand,
67
- type PreviewOptions,
68
- importCommand,
69
- parseImportOptions,
70
- questionnaireCommand,
71
- type QuestionnaireOptions,
72
- // Cloud auth command
73
- authCloudCommand,
74
- type AuthCloudOptions,
75
- // Generate commands
76
- generateK8sCommand,
77
- type GenerateK8sOptions,
78
- generateHelmCommand,
79
- type GenerateHelmOptions,
80
- // Utility commands
81
- versionCommand,
82
- type VersionOptions,
83
- helpCommand,
84
- type HelpOptions,
85
- doctorCommand,
86
- type DoctorOptions,
87
- // Apply commands
88
- applyCommand,
89
- // AI-powered commands
90
- askCommand,
91
- type AskOptions,
92
- explainCommand,
93
- type ExplainOptions,
94
- fixCommand,
95
- type FixOptions,
96
- // Plan command
97
- planCommand,
98
- parsePlanOptions,
99
- // Resume command
100
- resumeCommand,
101
- // Template commands
102
- templateCommand,
103
- // Auth profile commands
104
- authProfileCommand,
105
- } from './commands';
106
- import { upgradeCommand, type UpgradeOptions } from './commands/upgrade';
107
- import { statusCommand, type StatusOptions } from './commands/status';
108
- import { rollbackCommand, type RollbackOptions } from './commands/rollback';
109
- import { rolloutCommand, type RolloutOptions } from './commands/rollout';
110
- import { requiresAuth, type LLMProviderName } from './auth';
111
-
112
- /** Top-level command aliases for convenience shortcuts. */
113
- const COMMAND_ALIASES: Record<string, string[]> = {
114
- pr: ['gh', 'pr'],
115
- issue: ['gh', 'issue'],
116
- read: ['fs', 'read'],
117
- tree: ['fs', 'tree'],
118
- search: ['fs', 'search'],
119
- write: ['fs', 'write'],
120
- // Short command aliases
121
- terraform: ['tf'],
122
- k: ['k8s'],
123
- g: ['generate'],
124
- h: ['helm'],
125
- };
126
-
127
- async function showSubcommandHelp(command: string, _args: string[]): Promise<void> {
128
- const { helpCommand } = await import('./commands/help');
129
- // Print command-specific help based on command name
130
- const COMMAND_HELP: Record<string, string> = {
131
- chat: 'Usage: nimbus chat [--model <model>] [--mode plan|build|deploy] [--continue]\n Start interactive AI chat session.',
132
- run: 'Usage: nimbus run "<prompt>" [--auto-approve] [--format json|text] [--model <model>]\n Run a non-interactive agent task.',
133
- init: 'Usage: nimbus init [--cwd <dir>] [--quiet]\n Generate NIMBUS.md with detected project context.',
134
- login: 'Usage: nimbus login [--provider <name>]\n Configure LLM provider credentials.',
135
- logout: 'Usage: nimbus logout [--provider <name>]\n Remove stored credentials.',
136
- doctor: 'Usage: nimbus doctor [--fix] [--verbose] [--json] [--metrics]\n Run diagnostic checks on Nimbus installation.',
137
- cost: 'Usage: nimbus cost [--days <n>] [--json]\n Show LLM usage costs.',
138
- sessions: 'Usage: nimbus sessions [list|resume|delete] [<id>]\n Manage chat sessions.',
139
- audit: 'Usage: nimbus audit [--format json|text]\n Run security and compliance audit.',
140
- share: 'Usage: nimbus share [--session <id>] [--ttl <hours>]\n Share a session.',
141
- upgrade: 'Usage: nimbus upgrade\n Upgrade Nimbus to the latest version.',
142
- serve: 'Usage: nimbus serve [--port <port>] [--auth <user:pass>]\n Start HTTP API server with SSE streaming.',
143
- web: 'Usage: nimbus web [--port <port>]\n Open Web UI in browser.',
144
- 'auth-refresh': 'Usage: nimbus auth-refresh [--provider aws|gcp|azure]\n Refresh cloud provider credentials.',
145
- completions: 'Usage: nimbus completions <install|uninstall>\n Manage shell tab completions.',
146
- alias: 'Usage: nimbus alias <list|create|remove> [<name>] [<expansion>]\n Manage command aliases.',
147
- logs: 'Usage: nimbus logs [--tail <n>] [--follow] [--namespace <ns>]\n Stream Kubernetes/cloud logs.',
148
- pipeline: 'Usage: nimbus pipeline [list|trigger|status] [<args>]\n Manage CI/CD pipelines.',
149
- drift: 'Usage: nimbus drift [--notify slack|email]\n Detect infrastructure drift.',
150
- deploy: 'Usage: nimbus deploy [--auto-approve] [--workspace <ws>] [--namespace <ns>] [--dry-run] [--no-apply]\n Orchestrate full terraform plan + apply + kubectl rollout workflow.',
151
- rollback: 'Usage: nimbus rollback [<resource>] [--dry-run]\n Safely roll back infrastructure.',
152
- profile: 'Usage: nimbus profile <name>\n Set AWS_PROFILE for current session.',
153
- schedule: 'Usage: nimbus schedule [list|add|remove] [<args>]\n Manage scheduled agent tasks.',
154
- incident: 'Usage: nimbus incident [create|list|update] [<args>]\n Manage incidents.',
155
- status: 'Usage: nimbus status [--json]\n Show Nimbus and infra status.',
156
- export: 'Usage: nimbus export [--session <id>] [--output <file>]\n Export session as Markdown runbook.',
157
- plugin: 'Usage: nimbus plugin <install|uninstall|list> [<name>]\n Manage MCP plugins.',
158
- runbook: 'Usage: nimbus runbook <file> [--dry-run]\n Execute a runbook YAML file.',
159
- };
160
- const help = COMMAND_HELP[command];
161
- if (help) {
162
- process.stdout.write(help + '\n');
163
- } else {
164
- await helpCommand({});
165
- }
166
- }
167
-
168
- /**
169
- * Run a CLI command directly.
170
- *
171
- * This is the main entry point for `nimbus <command> <subcommand>`.
172
- * It resolves aliases, checks authentication, and dispatches to
173
- * the appropriate command handler.
174
- */
175
- export async function runCommand(args: string[]): Promise<void> {
176
- // Resolve top-level command aliases
177
- if (COMMAND_ALIASES[args[0]]) {
178
- args = [...COMMAND_ALIASES[args[0]], ...args.slice(1)];
179
- }
180
-
181
- // --profile <name> global flag: load and apply a named config profile before
182
- // dispatching to the subcommand. Non-critical — errors are silently swallowed.
183
- const profileIdx = args.indexOf('--profile');
184
- if (profileIdx !== -1 && args[profileIdx + 1]) {
185
- const profileName = args[profileIdx + 1];
186
- try {
187
- const { loadProfile, applyProfile } = await import('./config/profiles');
188
- const profile = loadProfile(profileName);
189
- if (profile) {
190
- applyProfile(profile);
191
- } else {
192
- process.stderr.write(`Profile not found: ${profileName}\n`);
193
- }
194
- } catch { /* non-critical */ }
195
- args = [...args.slice(0, profileIdx), ...args.slice(profileIdx + 2)];
196
- }
197
-
198
- const command = args[0];
199
- const subcommand = args[1];
200
-
201
- // GAP-15: --help/-h flag on any subcommand
202
- if (args.includes('--help') || args.includes('-h')) {
203
- await showSubcommandHelp(command, args);
204
- return;
205
- }
206
-
207
- // Fire-and-forget analytics tracking for every CLI command invocation.
208
- // This is a no-op when POSTHOG_API_KEY is not set.
209
- const commandName =
210
- subcommand && !subcommand.startsWith('-') ? `${command} ${subcommand}` : command;
211
- analytics.trackEvent('command_executed', { command: commandName }).catch(() => {});
212
-
213
- // ==========================================
214
- // Auth commands (always available, no guard)
215
- // ==========================================
216
-
217
- // nimbus login
218
- if (command === 'login') {
219
- // G8: --cloud <provider> flag for cloud provider login
220
- const cloudIdx = args.findIndex(a => a === '--cloud');
221
- if (cloudIdx !== -1 && args[cloudIdx + 1]) {
222
- const cloudProvider = args[cloudIdx + 1] as 'aws' | 'gcp' | 'azure';
223
- if (['aws', 'gcp', 'azure'].includes(cloudProvider)) {
224
- const { loginCloudCommand } = await import('./commands/login');
225
- await loginCloudCommand(cloudProvider);
226
- return;
227
- }
228
- }
229
-
230
- const options: LoginOptions = {};
231
-
232
- for (let i = 1; i < args.length; i++) {
233
- const arg = args[i];
234
-
235
- if (arg === '--skip-github') {
236
- options.skipGitHub = true;
237
- } else if (arg === '--provider' && args[i + 1]) {
238
- options.provider = args[++i] as LLMProviderName;
239
- } else if (arg === '--api-key' && args[i + 1]) {
240
- options.apiKey = args[++i];
241
- } else if (arg === '--model' && args[i + 1]) {
242
- options.model = args[++i];
243
- } else if (arg === '--non-interactive') {
244
- options.nonInteractive = true;
245
- } else if (arg === '--sso') {
246
- options.sso = true;
247
- }
248
- }
249
-
250
- await loginCommand(options);
251
- return;
252
- }
253
-
254
- // nimbus logout
255
- if (command === 'logout') {
256
- const options: LogoutOptions = {};
257
-
258
- for (let i = 1; i < args.length; i++) {
259
- const arg = args[i];
260
-
261
- if (arg === '--force' || arg === '-f') {
262
- options.force = true;
263
- }
264
- }
265
-
266
- await logoutCommand(options);
267
- return;
268
- }
269
-
270
- // nimbus auth status
271
- if (command === 'auth' && subcommand === 'status') {
272
- const options: AuthStatusOptions = {};
273
-
274
- for (let i = 2; i < args.length; i++) {
275
- const arg = args[i];
276
-
277
- if (arg === '--json') {
278
- options.json = true;
279
- }
280
- }
281
-
282
- await authStatusCommand(options);
283
- return;
284
- }
285
-
286
- // nimbus auth list
287
- if (command === 'auth' && subcommand === 'list') {
288
- const options: AuthListOptions = {};
289
-
290
- for (let i = 2; i < args.length; i++) {
291
- const arg = args[i];
292
-
293
- if (arg === '--json') {
294
- options.json = true;
295
- }
296
- }
297
-
298
- await authListCommand(options);
299
- return;
300
- }
301
-
302
- // nimbus auth cloud|aws|gcp|azure
303
- if (
304
- command === 'auth' &&
305
- (subcommand === 'cloud' ||
306
- subcommand === 'aws' ||
307
- subcommand === 'gcp' ||
308
- subcommand === 'azure')
309
- ) {
310
- const provider = subcommand === 'cloud' ? args[2] || 'aws' : subcommand;
311
- const options: AuthCloudOptions = {};
312
-
313
- const startIdx = subcommand === 'cloud' ? 3 : 2;
314
- for (let i = startIdx; i < args.length; i++) {
315
- const arg = args[i];
316
-
317
- if (arg === '--profile' && args[i + 1]) {
318
- options.profile = args[++i];
319
- } else if (arg === '--project' && args[i + 1]) {
320
- options.project = args[++i];
321
- } else if (arg === '--subscription' && args[i + 1]) {
322
- options.subscription = args[++i];
323
- } else if (arg === '--region' && args[i + 1]) {
324
- options.region = args[++i];
325
- }
326
- }
327
-
328
- await authCloudCommand(provider, options);
329
- return;
330
- }
331
-
332
- // nimbus onboarding (first-run setup wizard)
333
- if (command === 'onboarding') {
334
- const { onboardingCommand } = await import('./commands/onboarding');
335
- await onboardingCommand({});
336
- return;
337
- }
338
-
339
- // nimbus version
340
- if (command === 'version' || command === '-v' || command === '--version') {
341
- const options: VersionOptions = {};
342
-
343
- for (let i = 1; i < args.length; i++) {
344
- const arg = args[i];
345
-
346
- if (arg === '--verbose' || arg === '-v') {
347
- options.verbose = true;
348
- } else if (arg === '--json') {
349
- options.json = true;
350
- }
351
- }
352
-
353
- await versionCommand(options);
354
- return;
355
- }
356
-
357
- // nimbus help
358
- if (command === 'help' || command === '-h' || command === '--help') {
359
- const options: HelpOptions = {};
360
-
361
- // Check for command-specific help
362
- if (subcommand && !subcommand.startsWith('-')) {
363
- options.command = subcommand;
364
- }
365
-
366
- await helpCommand(options);
367
- return;
368
- }
369
-
370
- // nimbus doctor
371
- if (command === 'doctor') {
372
- const options: DoctorOptions = {};
373
-
374
- for (let i = 1; i < args.length; i++) {
375
- const arg = args[i];
376
-
377
- if (arg === '--fix') {
378
- options.fix = true;
379
- } else if (arg === '--verbose' || arg === '-v') {
380
- options.verbose = true;
381
- } else if (arg === '--json') {
382
- options.json = true;
383
- }
384
- }
385
-
386
- await doctorCommand(options);
387
- return;
388
- }
389
-
390
- // nimbus upgrade
391
- if (command === 'upgrade' || command === 'update') {
392
- const options: UpgradeOptions = {};
393
-
394
- for (let i = 1; i < args.length; i++) {
395
- const arg = args[i];
396
-
397
- if (arg === '--force' || arg === '-f') {
398
- options.force = true;
399
- } else if (arg === '--check' || arg === '-c') {
400
- options.check = true;
401
- } else if (arg === '--dry-run') {
402
- options.dryRun = true;
403
- } else if (arg === '--changelog') {
404
- options.changelog = true;
405
- }
406
- }
407
-
408
- await upgradeCommand(options);
409
- return;
410
- }
411
-
412
- // nimbus init
413
- if (command === 'init') {
414
- const options: InitOptions = {};
415
-
416
- for (let i = 1; i < args.length; i++) {
417
- const arg = args[i];
418
-
419
- if (arg === '--force' || arg === '-f') {
420
- options.force = true;
421
- } else if ((arg === '--name' || arg === '-n') && args[i + 1]) {
422
- options.name = args[++i];
423
- } else if (arg === '--provider' && args[i + 1]) {
424
- options.provider = args[++i];
425
- } else if ((arg === '--output' || arg === '-o') && args[i + 1]) {
426
- options.output = args[++i];
427
- } else if (arg === '--non-interactive') {
428
- options.nonInteractive = true;
429
- } else if (arg === '--merge') {
430
- options.merge = true;
431
- }
432
- }
433
-
434
- await initCommand(options);
435
- return;
436
- }
437
-
438
- // nimbus serve — headless API server (no auth guard)
439
- if (command === 'serve') {
440
- const { serveCommand } = await import('./cli/serve');
441
- const serveOptions: { port?: number; host?: string; auth?: string; background?: boolean; stop?: boolean } = {};
442
-
443
- // M1: nimbus serve stop
444
- if (subcommand === 'stop') {
445
- serveOptions.stop = true;
446
- await serveCommand(serveOptions);
447
- return;
448
- }
449
-
450
- for (let i = 1; i < args.length; i++) {
451
- const arg = args[i];
452
-
453
- if ((arg === '--port' || arg === '-p') && args[i + 1]) {
454
- serveOptions.port = parseInt(args[++i], 10);
455
- } else if (arg === '--host' && args[i + 1]) {
456
- serveOptions.host = args[++i];
457
- } else if (arg === '--auth' && args[i + 1]) {
458
- serveOptions.auth = args[++i];
459
- } else if (arg === '--background' || arg === '-b') {
460
- serveOptions.background = true;
461
- }
462
- }
463
-
464
- await serveCommand(serveOptions);
465
- return;
466
- }
467
-
468
- // nimbus web
469
- if (command === 'web') {
470
- const { webCommand } = await import('./cli/web');
471
- await webCommand({
472
- port: args.includes('--port') ? parseInt(args[args.indexOf('--port') + 1], 10) : undefined,
473
- host: args.includes('--host') ? args[args.indexOf('--host') + 1] : undefined,
474
- auth: args.includes('--auth') ? args[args.indexOf('--auth') + 1] : undefined,
475
- uiUrl: args.includes('--ui-url') ? args[args.indexOf('--ui-url') + 1] : undefined,
476
- noOpen: args.includes('--no-open'),
477
- });
478
- return;
479
- }
480
-
481
- // nimbus logs <pod> — H1 shorthand
482
- if (command === 'logs') {
483
- const { logsCommand, parseLogsArgs } = await import('./commands/logs');
484
- const { pod, options: logsOpts } = parseLogsArgs(args.slice(1));
485
- await logsCommand(pod, logsOpts);
486
- return;
487
- }
488
-
489
- // nimbus pipeline [subcommand] — H2
490
- if (command === 'pipeline') {
491
- const { pipelineCommand } = await import('./commands/pipeline');
492
- await pipelineCommand(subcommand || 'status', args.slice(2));
493
- return;
494
- }
495
-
496
- // nimbus alias — L2
497
- if (command === 'alias') {
498
- const { aliasCommand } = await import('./commands/alias');
499
- await aliasCommand(subcommand || 'list', args.slice(2));
500
- return;
501
- }
502
-
503
- // nimbus incident <url-or-id> [--notes "..."] — G14
504
- if (command === 'incident') {
505
- const { incidentCommand } = await import('./commands/incident');
506
- const incidentInput = args[1] ?? '';
507
- const notesIdx = args.indexOf('--notes');
508
- const notes = notesIdx !== -1 ? args[notesIdx + 1] : undefined;
509
- await incidentCommand(incidentInput, { notes });
510
- return;
511
- }
512
-
513
- // nimbus runbook <list|run|create> — G15
514
- if (command === 'runbook') {
515
- const { runbookCommand } = await import('./commands/runbook');
516
- await runbookCommand(subcommand || 'list', args.slice(2));
517
- return;
518
- }
519
-
520
- // nimbus schedule <list|add|remove|run-now> — G13
521
- if (command === 'schedule') {
522
- const { scheduleCommand } = await import('./commands/schedule');
523
- await scheduleCommand(subcommand || 'list', args.slice(2));
524
- return;
525
- }
526
-
527
- // nimbus export [session-id] [--format md|html|json] [--output file] — G19
528
- if (command === 'export') {
529
- const { exportCommand } = await import('./commands/export');
530
- const formatIdx = args.indexOf('--format');
531
- const format = formatIdx !== -1 ? (args[formatIdx + 1] as 'md' | 'html' | 'json') : 'md';
532
- const outputIdx = args.indexOf('--output');
533
- const output = outputIdx !== -1 ? args[outputIdx + 1] : undefined;
534
- const sessionId = args.slice(1).find(a => !a.startsWith('-') && a !== args[formatIdx + 1] && a !== args[outputIdx + 1]);
535
- await exportCommand({ format, output, sessionId });
536
- return;
537
- }
538
-
539
- // ==========================================
540
- // Auth guard - check authentication for other commands
541
- // ==========================================
542
- // Check if running in non-interactive mode
543
- const isNonInteractive = args.includes('--non-interactive');
544
-
545
- if (requiresAuth()) {
546
- if (isNonInteractive) {
547
- console.error('');
548
- console.error('Error: Authentication required but running in non-interactive mode.');
549
- console.error(
550
- 'Please run `nimbus login` first, or set provider API keys via environment variables.'
551
- );
552
- console.error('');
553
- process.exit(1);
554
- }
555
-
556
- console.log('');
557
- console.log('Welcome to Nimbus! You need to set up authentication first.');
558
- console.log('');
559
-
560
- const success = await loginCommand({});
561
- if (!success) {
562
- process.exit(1);
563
- }
564
- console.log('');
565
- }
566
-
567
- // ==========================================
568
- // Infrastructure commands (require auth)
569
- // ==========================================
570
-
571
- // nimbus run "prompt" [options]
572
- if (command === 'run') {
573
- const { parseRunArgs, executeRun } = await import('./cli/run');
574
- const { getAppContext } = await import('./app');
575
-
576
- const ctx = getAppContext();
577
- if (!ctx) {
578
- console.error('Error: App not initialised.');
579
- process.exit(1);
580
- }
581
-
582
- const runOptions = parseRunArgs(args.slice(1));
583
- await executeRun(ctx.router, runOptions);
584
- return;
585
- }
586
-
587
- // nimbus generate terraform
588
- if (command === 'generate' && subcommand === 'terraform') {
589
- const options: GenerateTerraformOptions = {};
590
-
591
- for (let i = 2; i < args.length; i++) {
592
- const arg = args[i];
593
-
594
- if (arg === '--profile' && args[i + 1]) {
595
- options.profile = args[++i];
596
- } else if (arg === '--regions' && args[i + 1]) {
597
- options.regions = args[++i].split(',');
598
- } else if (arg === '--services' && args[i + 1]) {
599
- options.services = args[++i].split(',');
600
- } else if (arg === '--output' && args[i + 1]) {
601
- options.output = args[++i];
602
- } else if (arg === '--non-interactive') {
603
- options.nonInteractive = true;
604
- } else if (arg === '--accept-all-improvements') {
605
- options.acceptAllImprovements = true;
606
- } else if (arg === '--reject-all-improvements') {
607
- options.rejectAllImprovements = true;
608
- } else if (arg === '--mock') {
609
- options.mock = true;
610
- }
611
- }
612
-
613
- await generateTerraformCommand(options);
614
- return;
615
- }
616
-
617
- // nimbus generate k8s (or nimbus generate-k8s)
618
- if ((command === 'generate' && subcommand === 'k8s') || command === 'generate-k8s') {
619
- const options: GenerateK8sOptions = {};
620
- const startIdx = command === 'generate-k8s' ? 1 : 2;
621
-
622
- for (let i = startIdx; i < args.length; i++) {
623
- const arg = args[i];
624
-
625
- if ((arg === '--workload-type' || arg === '--type') && args[i + 1]) {
626
- options.workloadType = args[++i] as GenerateK8sOptions['workloadType'];
627
- } else if ((arg === '--namespace' || arg === '-n') && args[i + 1]) {
628
- options.namespace = args[++i];
629
- } else if (arg === '--name' && args[i + 1]) {
630
- options.name = args[++i];
631
- } else if (arg === '--image' && args[i + 1]) {
632
- options.image = args[++i];
633
- } else if (arg === '--replicas' && args[i + 1]) {
634
- options.replicas = parseInt(args[++i], 10);
635
- } else if (arg === '--port' && args[i + 1]) {
636
- options.port = parseInt(args[++i], 10);
637
- } else if (arg === '--service-type' && args[i + 1]) {
638
- options.serviceType = args[++i] as GenerateK8sOptions['serviceType'];
639
- } else if ((arg === '--output' || arg === '-o') && args[i + 1]) {
640
- options.output = args[++i];
641
- } else if (arg === '--non-interactive') {
642
- options.nonInteractive = true;
643
- } else if (arg === '--include-ingress') {
644
- options.includeIngress = true;
645
- } else if (arg === '--include-hpa') {
646
- options.includeHpa = true;
647
- } else if (arg === '--include-pdb') {
648
- options.includePdb = true;
649
- } else if (arg === '--include-configmap') {
650
- options.includeConfigMap = true;
651
- } else if (arg === '--include-secret') {
652
- options.includeSecret = true;
653
- } else if (arg === '--cpu-request' && args[i + 1]) {
654
- options.cpuRequest = args[++i];
655
- } else if (arg === '--cpu-limit' && args[i + 1]) {
656
- options.cpuLimit = args[++i];
657
- } else if (arg === '--memory-request' && args[i + 1]) {
658
- options.memoryRequest = args[++i];
659
- } else if (arg === '--memory-limit' && args[i + 1]) {
660
- options.memoryLimit = args[++i];
661
- }
662
- }
663
-
664
- await generateK8sCommand(options);
665
- return;
666
- }
667
-
668
- // nimbus generate helm (or nimbus generate-helm)
669
- if ((command === 'generate' && subcommand === 'helm') || command === 'generate-helm') {
670
- const options: GenerateHelmOptions = {};
671
- const startIdx = command === 'generate-helm' ? 1 : 2;
672
-
673
- for (let i = startIdx; i < args.length; i++) {
674
- const arg = args[i];
675
-
676
- if (arg === '--chart' && args[i + 1]) {
677
- options.chart = args[++i];
678
- } else if ((arg === '--release' || arg === '--release-name') && args[i + 1]) {
679
- options.releaseName = args[++i];
680
- } else if ((arg === '--namespace' || arg === '-n') && args[i + 1]) {
681
- options.namespace = args[++i];
682
- } else if ((arg === '--output' || arg === '-o') && args[i + 1]) {
683
- options.output = args[++i];
684
- } else if (arg === '--non-interactive') {
685
- options.nonInteractive = true;
686
- } else if (arg === '--include-secrets') {
687
- options.includeSecrets = true;
688
- } else if (arg === '--no-secrets') {
689
- options.includeSecrets = false;
690
- } else if (arg === '--environment' && args[i + 1]) {
691
- options.environment = args[++i] as GenerateHelmOptions['environment'];
692
- } else if (arg === '--version' && args[i + 1]) {
693
- options.version = args[++i];
694
- } else if (arg === '--repo' && args[i + 1]) {
695
- options.repo = args[++i];
696
- } else if (arg === '--values-file' && args[i + 1]) {
697
- options.valuesFile = args[++i];
698
- }
699
- }
700
-
701
- await generateHelmCommand(options);
702
- return;
703
- }
704
-
705
- // nimbus aws discover
706
- if (command === 'aws' && subcommand === 'discover') {
707
- const options: AwsDiscoverOptions = {};
708
-
709
- for (let i = 2; i < args.length; i++) {
710
- const arg = args[i];
711
-
712
- if (arg === '--profile' && args[i + 1]) {
713
- options.profile = args[++i];
714
- } else if (arg === '--regions' && args[i + 1]) {
715
- options.regions = args[++i].split(',');
716
- } else if (arg === '--services' && args[i + 1]) {
717
- options.services = args[++i].split(',');
718
- } else if (arg === '--exclude-services' && args[i + 1]) {
719
- options.excludeServices = args[++i].split(',');
720
- } else if (arg === '--output-format' && args[i + 1]) {
721
- options.outputFormat = args[++i] as 'json' | 'table' | 'summary';
722
- } else if (arg === '--output-file' && args[i + 1]) {
723
- options.outputFile = args[++i];
724
- } else if (arg === '--non-interactive') {
725
- options.nonInteractive = true;
726
- }
727
- }
728
-
729
- await awsDiscoverCommand(options);
730
- return;
731
- }
732
-
733
- // nimbus aws terraform
734
- if (command === 'aws' && subcommand === 'terraform') {
735
- const options: AwsTerraformOptions = {};
736
-
737
- for (let i = 2; i < args.length; i++) {
738
- const arg = args[i];
739
-
740
- if (arg === '--profile' && args[i + 1]) {
741
- options.profile = args[++i];
742
- } else if (arg === '--regions' && args[i + 1]) {
743
- options.regions = args[++i].split(',');
744
- } else if (arg === '--services' && args[i + 1]) {
745
- options.services = args[++i].split(',');
746
- } else if (arg === '--session-id' && args[i + 1]) {
747
- options.sessionId = args[++i];
748
- } else if (arg === '--resources-file' && args[i + 1]) {
749
- options.resourcesFile = args[++i];
750
- } else if (arg === '--output' && args[i + 1]) {
751
- options.output = args[++i];
752
- } else if (arg === '--terraform-version' && args[i + 1]) {
753
- options.terraformVersion = args[++i];
754
- } else if (arg === '--organize-by-service') {
755
- options.organizeByService = true;
756
- } else if (arg === '--no-organize-by-service') {
757
- options.organizeByService = false;
758
- } else if (arg === '--import-blocks') {
759
- options.importBlocks = true;
760
- } else if (arg === '--no-import-blocks') {
761
- options.importBlocks = false;
762
- } else if (arg === '--import-script') {
763
- options.importScript = true;
764
- } else if (arg === '--no-import-script') {
765
- options.importScript = false;
766
- } else if (arg === '--starter-kit') {
767
- options.includeStarterKit = true;
768
- } else if (arg === '--no-starter-kit') {
769
- options.includeStarterKit = false;
770
- } else if (arg === '--non-interactive') {
771
- options.nonInteractive = true;
772
- } else if (arg === '--skip-discovery') {
773
- options.skipDiscovery = true;
774
- }
775
- }
776
-
777
- await awsTerraformCommand(options);
778
- return;
779
- }
780
-
781
- // nimbus aws <service> <action> (catch-all for other AWS subcommands)
782
- if (command === 'aws' && subcommand && subcommand !== 'discover' && subcommand !== 'terraform') {
783
- await awsCommand(subcommand, args.slice(2));
784
- return;
785
- }
786
-
787
- // nimbus azure <service> <action>
788
- if (command === 'azure') {
789
- if (!subcommand) {
790
- console.error('Usage: nimbus azure <service> <action>');
791
- console.log('');
792
- console.log('Available services:');
793
- console.log(' vm - Virtual machine operations');
794
- console.log(' storage - Storage account operations');
795
- console.log(' aks - Azure Kubernetes Service operations');
796
- console.log(' functions - Azure Functions operations');
797
- process.exit(1);
798
- }
799
-
800
- await azureCommand(subcommand, args.slice(2));
801
- return;
802
- }
803
-
804
- // nimbus gcp <service> <action>
805
- if (command === 'gcp') {
806
- if (!subcommand) {
807
- console.error('Usage: nimbus gcp <service> <action>');
808
- console.log('');
809
- console.log('Available services:');
810
- console.log(' compute - Compute Engine operations');
811
- console.log(' storage - Cloud Storage operations');
812
- console.log(' gke - Google Kubernetes Engine operations');
813
- console.log(' functions - Cloud Functions operations');
814
- console.log(' iam - IAM operations');
815
- process.exit(1);
816
- }
817
-
818
- await gcpCommand(subcommand, args.slice(2));
819
- return;
820
- }
821
-
822
- // nimbus cost <subcommand>
823
- if (command === 'cost') {
824
- await costCommand(args.slice(1));
825
- return;
826
- }
827
-
828
- // nimbus drift <subcommand>
829
- if (command === 'drift') {
830
- await driftCommand(args.slice(1));
831
- return;
832
- }
833
-
834
- // nimbus demo [options]
835
- if (command === 'demo') {
836
- const options = parseDemoOptions(args.slice(1));
837
- await demoCommand(options);
838
- return;
839
- }
840
-
841
- // nimbus feedback [options]
842
- if (command === 'feedback') {
843
- const options = parseFeedbackOptions(args.slice(1));
844
- await feedbackCommand(options);
845
- return;
846
- }
847
-
848
- // nimbus preview <type> [options]
849
- if (command === 'preview') {
850
- const options: PreviewOptions = {
851
- type: (subcommand as PreviewOptions['type']) || 'terraform',
852
- };
853
-
854
- for (let i = 2; i < args.length; i++) {
855
- const arg = args[i];
856
-
857
- if ((arg === '--directory' || arg === '-d') && args[i + 1]) {
858
- options.directory = args[++i];
859
- } else if (arg === '--format' && args[i + 1]) {
860
- options.format = args[++i] as PreviewOptions['format'];
861
- } else if (arg === '--verbose' || arg === '-v') {
862
- options.verbose = true;
863
- } else if (arg === '--skip-safety') {
864
- options.skipSafety = true;
865
- } else if (arg === '--target' && args[i + 1]) {
866
- options.target = args[++i];
867
- } else if ((arg === '--namespace' || arg === '-n') && args[i + 1]) {
868
- options.namespace = args[++i];
869
- } else if (arg === '--release' && args[i + 1]) {
870
- options.release = args[++i];
871
- } else if (arg === '--values-file' && args[i + 1]) {
872
- options.valuesFile = args[++i];
873
- }
874
- }
875
-
876
- await previewCommand(options);
877
- return;
878
- }
879
-
880
- // nimbus import [options]
881
- if (command === 'import') {
882
- const options = parseImportOptions(args.slice(1));
883
- await importCommand(options);
884
- return;
885
- }
886
-
887
- // nimbus questionnaire <type> [options]
888
- if (command === 'questionnaire') {
889
- const options: QuestionnaireOptions = {
890
- type: (subcommand as QuestionnaireOptions['type']) || 'terraform',
891
- };
892
-
893
- for (let i = 2; i < args.length; i++) {
894
- const arg = args[i];
895
-
896
- if (arg === '--non-interactive') {
897
- options.nonInteractive = true;
898
- } else if (arg === '--answers-file' && args[i + 1]) {
899
- options.answersFile = args[++i];
900
- } else if ((arg === '--output' || arg === '-o') && args[i + 1]) {
901
- options.outputDir = args[++i];
902
- } else if (arg === '--dry-run') {
903
- options.dryRun = true;
904
- }
905
- }
906
-
907
- await questionnaireCommand(options);
908
- return;
909
- }
910
-
911
- // nimbus chat
912
- if (command === 'chat') {
913
- const options: ChatOptions = {};
914
-
915
- for (let i = 1; i < args.length; i++) {
916
- const arg = args[i];
917
-
918
- if ((arg === '--model' || arg === '-M') && args[i + 1]) {
919
- options.model = args[++i];
920
- } else if ((arg === '--message' || arg === '-m') && args[i + 1]) {
921
- options.message = args[++i];
922
- options.nonInteractive = true;
923
- } else if (arg === '--system-prompt' && args[i + 1]) {
924
- options.systemPrompt = args[++i];
925
- } else if (arg === '--show-tokens') {
926
- options.showTokenCount = true;
927
- } else if (arg === '--non-interactive') {
928
- options.nonInteractive = true;
929
- } else if (arg === '--ui' && args[i + 1]) {
930
- options.ui = args[++i] as ChatOptions['ui'];
931
- } else if (arg.startsWith('--ui=')) {
932
- options.ui = arg.slice('--ui='.length) as ChatOptions['ui'];
933
- } else if (arg === '--continue' || arg === '--resume') {
934
- options.continue = true;
935
- }
936
- }
937
-
938
- await chatCommand(options);
939
- return;
940
- }
941
-
942
- // nimbus config <subcommand>
943
- if (command === 'config') {
944
- const isNonInteractive = args.includes('--non-interactive');
945
-
946
- // nimbus config set <key> <value>
947
- if (subcommand === 'set') {
948
- const options: ConfigSetOptions = { nonInteractive: isNonInteractive };
949
-
950
- for (let i = 2; i < args.length; i++) {
951
- const arg = args[i];
952
- if (!arg.startsWith('-')) {
953
- if (!options.key) {
954
- options.key = arg;
955
- } else if (!options.value) {
956
- options.value = arg;
957
- }
958
- }
959
- }
960
-
961
- await configCommand.set(options);
962
- return;
963
- }
964
-
965
- // nimbus config get <key>
966
- if (subcommand === 'get') {
967
- const options: ConfigGetOptions = { nonInteractive: isNonInteractive };
968
-
969
- for (let i = 2; i < args.length; i++) {
970
- const arg = args[i];
971
- if (!arg.startsWith('-') && !options.key) {
972
- options.key = arg;
973
- }
974
- }
975
-
976
- await configCommand.get(options);
977
- return;
978
- }
979
-
980
- // nimbus config list
981
- if (subcommand === 'list') {
982
- const options: ConfigListOptions = { nonInteractive: isNonInteractive };
983
-
984
- for (let i = 2; i < args.length; i++) {
985
- const arg = args[i];
986
- if (arg === '--json') {
987
- options.json = true;
988
- } else if (arg === '--changed') {
989
- options.changed = true;
990
- }
991
- }
992
-
993
- await configCommand.list(options);
994
- return;
995
- }
996
-
997
- // nimbus config init
998
- if (subcommand === 'init') {
999
- const options: ConfigInitOptions = { nonInteractive: isNonInteractive };
1000
-
1001
- for (let i = 2; i < args.length; i++) {
1002
- const arg = args[i];
1003
- if (arg === '--force' || arg === '-f') {
1004
- options.force = true;
1005
- }
1006
- }
1007
-
1008
- await configCommand.init(options);
1009
- return;
1010
- }
1011
-
1012
- // nimbus config reset
1013
- if (subcommand === 'reset') {
1014
- await configCommand.reset({ nonInteractive: isNonInteractive });
1015
- return;
1016
- }
1017
-
1018
- // nimbus config telemetry <enable|disable|status>
1019
- if (subcommand === 'telemetry') {
1020
- const telemetryAction = args[2];
1021
- const fs = await import('node:fs');
1022
- const nodePath = await import('node:path');
1023
- const { homedir } = await import('os');
1024
- const { randomUUID } = await import('crypto');
1025
- const configPath = nodePath.join(homedir(), '.nimbus', 'config.json');
1026
- const configDir = nodePath.join(homedir(), '.nimbus');
1027
-
1028
- // Ensure directory exists
1029
- if (!fs.existsSync(configDir)) {
1030
- fs.mkdirSync(configDir, { recursive: true });
1031
- }
1032
-
1033
- // Read existing config
1034
- let config: any = {};
1035
- try {
1036
- if (fs.existsSync(configPath)) {
1037
- config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
1038
- }
1039
- } catch {
1040
- /* ignore */
1041
- }
1042
-
1043
- if (telemetryAction === 'enable') {
1044
- config.telemetry = {
1045
- ...config.telemetry,
1046
- enabled: true,
1047
- anonymousId: config.telemetry?.anonymousId || randomUUID(),
1048
- };
1049
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
1050
- console.log(
1051
- 'Telemetry enabled. Anonymous usage data will be collected to help improve Nimbus.'
1052
- );
1053
- console.log(`Anonymous ID: ${config.telemetry.anonymousId}`);
1054
- return;
1055
- }
1056
-
1057
- if (telemetryAction === 'disable') {
1058
- config.telemetry = { ...config.telemetry, enabled: false };
1059
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
1060
- console.log('Telemetry disabled. No usage data will be collected.');
1061
- return;
1062
- }
1063
-
1064
- if (telemetryAction === 'status' || !telemetryAction) {
1065
- const enabled = config.telemetry?.enabled === true;
1066
- console.log(`Telemetry: ${enabled ? 'enabled' : 'disabled'}`);
1067
- if (config.telemetry?.anonymousId) {
1068
- console.log(`Anonymous ID: ${config.telemetry.anonymousId}`);
1069
- }
1070
- return;
1071
- }
1072
-
1073
- console.error(`Unknown telemetry action: ${telemetryAction}`);
1074
- console.log('Usage: nimbus config telemetry <enable|disable|status>');
1075
- process.exit(1);
1076
- }
1077
-
1078
- // No subcommand - show list
1079
- if (!subcommand) {
1080
- await configCommand.list({ nonInteractive: isNonInteractive });
1081
- return;
1082
- }
1083
-
1084
- console.error(`Unknown config subcommand: ${subcommand}`);
1085
- console.log('');
1086
- console.log('Available config commands:');
1087
- console.log(' nimbus config list - List all configuration');
1088
- console.log(' nimbus config get <key> - Get a configuration value');
1089
- console.log(' nimbus config set <key> <value> - Set a configuration value');
1090
- console.log(' nimbus config init - Initialize configuration interactively');
1091
- console.log(' nimbus config reset - Reset configuration to defaults');
1092
- console.log(' nimbus config telemetry - Manage telemetry settings');
1093
- process.exit(1);
1094
- }
1095
-
1096
- // ==========================================
1097
- // Infrastructure tool commands (require auth)
1098
- // ==========================================
1099
-
1100
- // nimbus tf <subcommand>
1101
- if (command === 'tf') {
1102
- if (subcommand === '--version' || subcommand === '-v') {
1103
- console.log(`nimbus ${VERSION}`);
1104
- return;
1105
- }
1106
- if (!subcommand) {
1107
- console.error('Usage: nimbus tf <subcommand>');
1108
- console.log('');
1109
- console.log('Available subcommands:');
1110
- console.log(' init - Initialize Terraform working directory');
1111
- console.log(' plan - Generate execution plan');
1112
- console.log(' apply - Apply changes');
1113
- console.log(' validate - Validate configuration');
1114
- console.log(' destroy - Destroy infrastructure');
1115
- console.log(' show - Show state');
1116
- console.log(' fmt - Format configuration files');
1117
- console.log(' workspace - Manage workspaces (list, select, new, delete)');
1118
- console.log(' import - Import existing infrastructure');
1119
- console.log(' output - Show output values');
1120
- process.exit(1);
1121
- }
1122
-
1123
- await tfCommand(subcommand, args.slice(2));
1124
- return;
1125
- }
1126
-
1127
- // nimbus k8s <subcommand>
1128
- if (command === 'k8s') {
1129
- if (subcommand === '--version' || subcommand === '-v') {
1130
- console.log(`nimbus ${VERSION}`);
1131
- return;
1132
- }
1133
- if (!subcommand) {
1134
- console.error('Usage: nimbus k8s <subcommand>');
1135
- console.log('');
1136
- console.log('Available subcommands:');
1137
- console.log(' get <resource> [name] - Get Kubernetes resources');
1138
- console.log(' apply <manifest> - Apply manifests');
1139
- console.log(' delete <resource> <name> - Delete resources');
1140
- console.log(' logs <pod> - Get pod logs');
1141
- console.log(' describe <resource> <name> - Describe resource');
1142
- console.log(' scale <resource> <name> <replicas> - Scale deployment');
1143
- console.log(' exec <pod> -- <cmd...> - Execute command in pod');
1144
- console.log(' rollout <action> <resource> - Manage rollouts');
1145
- process.exit(1);
1146
- }
1147
-
1148
- await k8sCommand(subcommand, args.slice(2));
1149
- return;
1150
- }
1151
-
1152
- // nimbus helm <subcommand>
1153
- if (command === 'helm') {
1154
- if (subcommand === '--version' || subcommand === '-v') {
1155
- console.log(`nimbus ${VERSION}`);
1156
- return;
1157
- }
1158
- if (!subcommand) {
1159
- console.error('Usage: nimbus helm <subcommand>');
1160
- console.log('');
1161
- console.log('Available subcommands:');
1162
- console.log(' list - List releases');
1163
- console.log(' install <name> <chart> - Install a chart');
1164
- console.log(' upgrade <name> <chart> - Upgrade a release');
1165
- console.log(' uninstall <name> - Uninstall a release');
1166
- console.log(' rollback <name> <rev> - Rollback to revision');
1167
- console.log(' history <name> - Show release history');
1168
- console.log(' search <keyword> - Search for charts');
1169
- console.log(' show <chart> - Show chart information');
1170
- console.log(' repo add <name> <url> - Add repository');
1171
- console.log(' repo update - Update repositories');
1172
- process.exit(1);
1173
- }
1174
-
1175
- await helmCommand(subcommand, args.slice(2));
1176
- return;
1177
- }
1178
-
1179
- // nimbus apply <type> [target] [options]
1180
- if (command === 'apply') {
1181
- await applyCommand(subcommand, args.slice(2));
1182
- return;
1183
- }
1184
-
1185
- // nimbus ask "<question>" [options]
1186
- if (command === 'ask') {
1187
- const options: AskOptions = {};
1188
- let question = '';
1189
-
1190
- for (let i = 1; i < args.length; i++) {
1191
- const arg = args[i];
1192
-
1193
- if ((arg === '--context' || arg === '-c') && args[i + 1]) {
1194
- options.context = args[++i];
1195
- } else if (arg === '--context-file' && args[i + 1]) {
1196
- options.contextFile = args[++i];
1197
- } else if (arg === '--model' && args[i + 1]) {
1198
- options.model = args[++i];
1199
- } else if (arg === '--json') {
1200
- options.json = true;
1201
- } else if (!arg.startsWith('-')) {
1202
- question = arg;
1203
- }
1204
- }
1205
-
1206
- await askCommand(question, options);
1207
- return;
1208
- }
1209
-
1210
- // nimbus explain <target> [options]
1211
- if (command === 'explain') {
1212
- const options: ExplainOptions = {};
1213
- let target = '';
1214
-
1215
- for (let i = 1; i < args.length; i++) {
1216
- const arg = args[i];
1217
-
1218
- if (arg === '--type' && args[i + 1]) {
1219
- options.type = args[++i] as ExplainOptions['type'];
1220
- } else if (arg === '--file' && args[i + 1]) {
1221
- options.file = args[++i];
1222
- } else if (arg === '--verbose' || arg === '-v') {
1223
- options.verbose = true;
1224
- } else if (arg === '--json') {
1225
- options.json = true;
1226
- } else if (!arg.startsWith('-')) {
1227
- target = arg;
1228
- }
1229
- }
1230
-
1231
- await explainCommand(target, options);
1232
- return;
1233
- }
1234
-
1235
- // nimbus fix <error-or-file> [options]
1236
- if (command === 'fix') {
1237
- const options: FixOptions = {};
1238
- let errorOrFile = '';
1239
-
1240
- for (let i = 1; i < args.length; i++) {
1241
- const arg = args[i];
1242
-
1243
- if (arg === '--file' && args[i + 1]) {
1244
- options.file = args[++i];
1245
- } else if (arg === '--auto-apply' || arg === '-y') {
1246
- options.autoApply = true;
1247
- } else if (arg === '--dry-run') {
1248
- options.dryRun = true;
1249
- } else if (arg === '--json') {
1250
- options.json = true;
1251
- } else if (!arg.startsWith('-')) {
1252
- errorOrFile = arg;
1253
- }
1254
- }
1255
-
1256
- await fixCommand(errorOrFile, options);
1257
- return;
1258
- }
1259
-
1260
- // nimbus plan [options]
1261
- if (command === 'plan') {
1262
- const options = parsePlanOptions(args.slice(1));
1263
- await planCommand(options);
1264
- return;
1265
- }
1266
-
1267
- // nimbus resume <task-id>
1268
- if (command === 'resume') {
1269
- const taskId = subcommand;
1270
- await resumeCommand(taskId || {});
1271
- return;
1272
- }
1273
-
1274
- // nimbus git <subcommand>
1275
- if (command === 'git') {
1276
- if (!subcommand) {
1277
- console.error('Usage: nimbus git <subcommand>');
1278
- console.log('');
1279
- console.log('Available subcommands:');
1280
- console.log(' status - Show git status');
1281
- console.log(' add <files...> - Stage files');
1282
- console.log(' commit -m "message" - Create commit');
1283
- console.log(' push - Push to remote');
1284
- console.log(' pull - Pull from remote');
1285
- console.log(' fetch - Fetch from remote');
1286
- console.log(' log - Show commit log');
1287
- console.log(' branch - List branches');
1288
- console.log(' checkout <branch> - Checkout branch');
1289
- console.log(' diff - Show diff');
1290
- console.log(' merge <branch> - Merge a branch');
1291
- console.log(
1292
- ' stash <action> - Stash operations (push, pop, list, drop, apply, clear)'
1293
- );
1294
- process.exit(1);
1295
- }
1296
-
1297
- await gitCommand(subcommand, args.slice(2));
1298
- return;
1299
- }
1300
-
1301
- // nimbus diff — top-level alias for nimbus fs diff (M1)
1302
- if (command === 'diff') {
1303
- await fsCommand('diff', args.slice(1));
1304
- return;
1305
- }
1306
-
1307
- // nimbus fs <subcommand>
1308
- if (command === 'fs' || command === 'files') {
1309
- if (!subcommand) {
1310
- console.error('Usage: nimbus fs <subcommand>');
1311
- console.log('');
1312
- console.log('Available subcommands:');
1313
- console.log(' list [path] - List directory contents');
1314
- console.log(' tree [path] - List directory contents recursively');
1315
- console.log(' search <pattern> [path] - Search for files');
1316
- console.log(' read <file> - Read file contents');
1317
- console.log(' write <path> <content> - Write content to a file');
1318
- console.log(' diff <file1> <file2> - Show diff between two files');
1319
- process.exit(1);
1320
- }
1321
-
1322
- await fsCommand(subcommand, args.slice(2));
1323
- return;
1324
- }
1325
-
1326
- // nimbus history
1327
- if (command === 'history') {
1328
- // nimbus history show <id>
1329
- if (subcommand === 'show' && args[2]) {
1330
- await historyShowCommand(args[2]);
1331
- return;
1332
- }
1333
-
1334
- // nimbus history [options]
1335
- const options: HistoryOptions = {};
1336
-
1337
- for (let i = 1; i < args.length; i++) {
1338
- const arg = args[i];
1339
-
1340
- if ((arg === '--limit' || arg === '-n') && args[i + 1]) {
1341
- options.limit = parseInt(args[++i], 10);
1342
- } else if ((arg === '--filter' || arg === '-f') && args[i + 1]) {
1343
- options.filter = args[++i];
1344
- } else if (arg === '--since' && args[i + 1]) {
1345
- options.since = args[++i];
1346
- } else if (arg === '--until' && args[i + 1]) {
1347
- options.until = args[++i];
1348
- } else if (arg === '--status' && args[i + 1]) {
1349
- options.status = args[++i] as 'success' | 'failure' | 'pending';
1350
- } else if (arg === '--json') {
1351
- options.json = true;
1352
- } else if (arg === '--clear') {
1353
- options.clear = true;
1354
- }
1355
- }
1356
-
1357
- await historyCommand(options);
1358
- return;
1359
- }
1360
-
1361
- // nimbus gh <subcommand>
1362
- if (command === 'gh') {
1363
- if (!subcommand) {
1364
- console.error('Usage: nimbus gh <subcommand>');
1365
- console.log('');
1366
- console.log('Available subcommands:');
1367
- console.log(' pr list - List pull requests');
1368
- console.log(' pr view <number> - View a pull request');
1369
- console.log(' pr create - Create a pull request');
1370
- console.log(' pr merge <number> - Merge a pull request');
1371
- console.log(' issue list - List issues');
1372
- console.log(' issue view <number> - View an issue');
1373
- console.log(' issue create - Create an issue');
1374
- console.log(' issue close <number> - Close an issue');
1375
- console.log(' issue comment <n> - Add a comment');
1376
- console.log(' repo info - Show repository info');
1377
- console.log(' repo branches - List branches');
1378
- process.exit(1);
1379
- }
1380
-
1381
- await ghCommand(subcommand, args.slice(2));
1382
- return;
1383
- }
1384
-
1385
- // ==========================================
1386
- // Enterprise commands
1387
- // ==========================================
1388
-
1389
- // nimbus team <subcommand>
1390
- if (command === 'team') {
1391
- await teamCommand(subcommand || '', args.slice(2));
1392
- return;
1393
- }
1394
-
1395
- // nimbus billing <subcommand>
1396
- if (command === 'billing') {
1397
- await billingCommand(subcommand || '', args.slice(2));
1398
- return;
1399
- }
1400
-
1401
- // nimbus usage
1402
- if (command === 'usage') {
1403
- await usageCommand(parseUsageOptions(args.slice(1)));
1404
- return;
1405
- }
1406
-
1407
- // nimbus audit <subcommand>
1408
- if (command === 'audit') {
1409
- await auditCommand(subcommand || '', args.slice(2));
1410
- return;
1411
- }
1412
-
1413
- // nimbus analyze
1414
- if (command === 'analyze') {
1415
- await analyzeCommand(parseAnalyzeOptions(args.slice(1)));
1416
- return;
1417
- }
1418
-
1419
- // nimbus template <subcommand>
1420
- if (command === 'template') {
1421
- if (!subcommand) {
1422
- console.error('Usage: nimbus template <subcommand>');
1423
- console.log('');
1424
- console.log('Available subcommands:');
1425
- console.log(' list - List all templates');
1426
- console.log(' get <id> - Get template details');
1427
- console.log(' save --name <n> [--file] - Save a new template');
1428
- console.log(' delete <id> - Delete a template');
1429
- process.exit(1);
1430
- }
1431
-
1432
- await templateCommand(subcommand, args.slice(2));
1433
- return;
1434
- }
1435
-
1436
- // nimbus auth-profile <subcommand>
1437
- if (command === 'auth-profile') {
1438
- if (!subcommand) {
1439
- console.error('Usage: nimbus auth-profile <subcommand>');
1440
- console.log('');
1441
- console.log('Available subcommands:');
1442
- console.log(' list - List configured providers');
1443
- console.log(' show - Show current default provider');
1444
- console.log(' switch <provider> - Switch default provider');
1445
- process.exit(1);
1446
- }
1447
-
1448
- await authProfileCommand(subcommand, args.slice(2));
1449
- return;
1450
- }
1451
-
1452
- // nimbus watch <glob> --run "prompt" (M3)
1453
- if (command === 'watch') {
1454
- const { watchCommand } = await import('./commands/watch');
1455
- const watchOptions: import('./commands/watch').WatchOptions = { glob: subcommand ?? '' };
1456
- for (let i = 1; i < args.length; i++) {
1457
- const arg = args[i];
1458
- if (arg === '--run' && args[i + 1]) {
1459
- watchOptions.run = args[++i];
1460
- } else if (arg === '--debounce' && args[i + 1]) {
1461
- watchOptions.debounce = parseInt(args[++i], 10);
1462
- } else if (arg === '--auto-approve' || arg === '-y') {
1463
- watchOptions.autoApprove = true;
1464
- } else if (arg === '--max-runs' && args[i + 1]) {
1465
- watchOptions.maxRuns = parseInt(args[++i], 10);
1466
- } else if (!arg.startsWith('--') && !watchOptions.glob) {
1467
- watchOptions.glob = arg;
1468
- }
1469
- }
1470
- await watchCommand(watchOptions);
1471
- return;
1472
- }
1473
-
1474
- // nimbus whoami — shorthand for auth status (H5)
1475
- if (command === 'whoami') {
1476
- await authStatusCommand({});
1477
- return;
1478
- }
1479
-
1480
- // nimbus auth-refresh [--provider aws|gcp|azure]
1481
- if (command === 'auth-refresh') {
1482
- const { authRefreshCommand } = await import('./commands/auth-refresh');
1483
- const refreshOptions: { provider?: 'aws' | 'gcp' | 'azure' | 'all' } = {};
1484
-
1485
- for (let i = 1; i < args.length; i++) {
1486
- const arg = args[i];
1487
- if (arg === '--provider' && args[i + 1]) {
1488
- refreshOptions.provider = args[++i] as 'aws' | 'gcp' | 'azure' | 'all';
1489
- }
1490
- }
1491
-
1492
- await authRefreshCommand(refreshOptions);
1493
- return;
1494
- }
1495
-
1496
- // nimbus plugin <list|add|remove|init> (L3)
1497
- if (command === 'plugin') {
1498
- const { pluginCommand } = await import('./commands/plugin');
1499
- await pluginCommand(subcommand ?? 'list', args.slice(2));
1500
- return;
1501
- }
1502
-
1503
- // nimbus mcp <list|add|remove|test> (M5) — MCP server management
1504
- if (command === 'mcp') {
1505
- const { mcpCommand } = await import('./commands/plugin');
1506
- await mcpCommand(subcommand ?? 'list', args.slice(2));
1507
- return;
1508
- }
1509
-
1510
- // nimbus completions <install|uninstall> (L7)
1511
- if (command === 'completions') {
1512
- const { completionsCommand } = await import('./commands/completions');
1513
- await completionsCommand(subcommand ?? 'install');
1514
- return;
1515
- }
1516
-
1517
- // nimbus team-context <push|pull> (L6)
1518
- if (command === 'team-context') {
1519
- const { teamContextCommand } = await import('./commands/team-context');
1520
- await teamContextCommand(subcommand ?? 'push', args.slice(2));
1521
- return;
1522
- }
1523
-
1524
- // nimbus profile <list|create|set|delete|show> (H1)
1525
- if (command === 'profile') {
1526
- const { profileCommand } = await import('./commands/profile');
1527
- await profileCommand(subcommand ?? 'list', args.slice(2));
1528
- return;
1529
- }
1530
-
1531
- // nimbus status — infrastructure status dashboard (G18)
1532
- if (command === 'status') {
1533
- const statusOptions: StatusOptions = {};
1534
- for (let i = 1; i < args.length; i++) {
1535
- if (args[i] === '--json') statusOptions.json = true;
1536
- }
1537
- await statusCommand(statusOptions);
1538
- return;
1539
- }
1540
-
1541
- // nimbus context — full context snapshot (L3): alias for status with verbose details
1542
- if (command === 'context') {
1543
- const contextOptions: StatusOptions = { verbose: true };
1544
- for (let i = 1; i < args.length; i++) {
1545
- if (args[i] === '--json') contextOptions.json = true;
1546
- }
1547
- await statusCommand(contextOptions);
1548
- return;
1549
- }
1550
-
1551
- // nimbus rollout — watch Kubernetes deployment rollout (L1)
1552
- if (command === 'rollout') {
1553
- const deployment = args[0];
1554
- if (!deployment) {
1555
- console.error('Usage: nimbus rollout <deployment> [--namespace <ns>] [--timeout <duration>]');
1556
- process.exit(1);
1557
- }
1558
- const rolloutOptions: RolloutOptions = { deployment };
1559
- for (let i = 1; i < args.length; i++) {
1560
- const arg = args[i];
1561
- if ((arg === '--namespace' || arg === '-n') && args[i + 1]) rolloutOptions.namespace = args[++i];
1562
- else if (arg === '--timeout' && args[i + 1]) rolloutOptions.timeout = args[++i];
1563
- }
1564
- await rolloutCommand(rolloutOptions);
1565
- return;
1566
- }
1567
-
1568
- // nimbus rollback — guided infrastructure rollback (G20)
1569
- if (command === 'rollback') {
1570
- const rollbackOptions: RollbackOptions = {};
1571
- for (let i = 1; i < args.length; i++) {
1572
- const arg = args[i];
1573
- if (arg === '--helm' && args[i + 1]) rollbackOptions.helm = args[++i];
1574
- else if (arg === '--k8s' && args[i + 1]) rollbackOptions.k8s = args[++i];
1575
- else if (arg === '--namespace' && args[i + 1]) rollbackOptions.namespace = args[++i];
1576
- else if (arg === '--tf') rollbackOptions.tf = true;
1577
- else if (arg === '--terraform') rollbackOptions.terraform = true;
1578
- else if (arg === '--tf-dir' && args[i + 1]) rollbackOptions.tfDir = args[++i];
1579
- }
1580
- await rollbackCommand(rollbackOptions);
1581
- return;
1582
- }
1583
-
1584
- // nimbus deploy — orchestrate full terraform + kubectl deployment workflow (C1)
1585
- if (command === 'deploy') {
1586
- const { deployCommand } = await import('./commands/deploy');
1587
- await deployCommand(args.slice(1));
1588
- return;
1589
- }
1590
-
1591
- // Unknown command
1592
- console.error(`Unknown command: ${command} ${subcommand || ''}`);
1593
- console.log('');
1594
- console.log('Available commands:');
1595
- console.log('');
1596
- console.log(' Chat & AI:');
1597
- console.log(' nimbus chat - Start interactive chat with AI');
1598
- console.log(' nimbus chat -m "..." - Send a single message');
1599
- console.log(' nimbus run "prompt" - Non-interactive agent run with tools');
1600
- console.log(' nimbus ask "question" - Quick question/answer');
1601
- console.log(' nimbus explain <file> - Explain code or infrastructure');
1602
- console.log(' nimbus fix <error> - AI-assisted error fixing');
1603
- console.log('');
1604
- console.log(' Workspace:');
1605
- console.log(' nimbus init - Initialize workspace in current directory');
1606
- console.log('');
1607
- console.log(' Configuration:');
1608
- console.log(' nimbus config - List all configuration');
1609
- console.log(' nimbus config set <k> <v> - Set a configuration value');
1610
- console.log(' nimbus config get <key> - Get a configuration value');
1611
- console.log(' nimbus config init - Initialize global configuration');
1612
- console.log(' nimbus config telemetry - Manage telemetry (enable|disable|status)');
1613
- console.log('');
1614
- console.log(' Authentication:');
1615
- console.log(' nimbus login - Set up authentication and LLM providers');
1616
- console.log(' nimbus logout - Clear all credentials');
1617
- console.log(' nimbus auth status - Show current authentication status');
1618
- console.log(' nimbus auth list - List all available providers');
1619
- console.log(' nimbus auth-refresh - Re-validate and refresh cloud credentials');
1620
- console.log('');
1621
- console.log(' Infrastructure Generation:');
1622
- console.log(
1623
- ' nimbus generate terraform - Generate Terraform from AWS infrastructure (wizard)'
1624
- );
1625
- console.log(' nimbus generate k8s - Generate Kubernetes manifests (wizard)');
1626
- console.log(' nimbus generate helm - Generate Helm values files (wizard)');
1627
- console.log(' nimbus aws discover - Discover AWS infrastructure resources');
1628
- console.log(' nimbus aws terraform - Generate Terraform from AWS resources');
1629
- console.log('');
1630
- console.log(' Cloud Providers:');
1631
- console.log(
1632
- ' nimbus aws <service> <action> - AWS operations (ec2, s3, rds, lambda, iam, vpc)'
1633
- );
1634
- console.log(
1635
- ' nimbus azure <service> <action> - Azure operations (vm, storage, aks, functions)'
1636
- );
1637
- console.log(
1638
- ' nimbus gcp <service> <action> - GCP operations (compute, storage, gke, functions, iam)'
1639
- );
1640
- console.log(' nimbus auth aws|gcp|azure - Validate cloud credentials');
1641
- console.log('');
1642
- console.log(' Infrastructure Management:');
1643
- console.log(' nimbus cost estimate - Estimate infrastructure costs');
1644
- console.log(' nimbus cost history - View cost history');
1645
- console.log(' nimbus drift detect - Detect infrastructure drift');
1646
- console.log(' nimbus drift fix - Remediate drift');
1647
- console.log(' nimbus preview <type> - Preview infrastructure changes');
1648
- console.log(' nimbus import - Import existing cloud resources');
1649
- console.log('');
1650
- console.log(' Infrastructure Tools:');
1651
- console.log(' nimbus plan - Preview infrastructure changes');
1652
- console.log(' nimbus apply <type> - Apply infrastructure (terraform, k8s, helm)');
1653
- console.log(' nimbus resume <task-id> - Resume a task from its last checkpoint');
1654
- console.log(
1655
- ' nimbus tf <cmd> - Terraform operations (init, plan, apply, validate, destroy, show, fmt, workspace, import, output)'
1656
- );
1657
- console.log(
1658
- ' nimbus k8s <cmd> - Kubernetes operations (get, apply, delete, logs, describe, scale, exec, rollout)'
1659
- );
1660
- console.log(
1661
- ' nimbus helm <cmd> - Helm operations (list, install, upgrade, uninstall, rollback, show)'
1662
- );
1663
- console.log(
1664
- ' nimbus git <cmd> - Git operations (status, add, commit, push, pull, fetch, log, merge, stash)'
1665
- );
1666
- console.log(
1667
- ' nimbus fs <cmd> - File system operations (list, search, read, write, diff)'
1668
- );
1669
- console.log('');
1670
- console.log(' Wizards & Tools:');
1671
- console.log(' nimbus questionnaire <type> - Interactive infrastructure questionnaire');
1672
- console.log(' nimbus demo - Run demo scenarios');
1673
- console.log(' nimbus feedback - Submit feedback');
1674
- console.log('');
1675
- console.log(' GitHub:');
1676
- console.log(' nimbus gh pr <cmd> - PR operations (list, view, create, merge)');
1677
- console.log(
1678
- ' nimbus gh issue <cmd> - Issue operations (list, view, create, close, comment)'
1679
- );
1680
- console.log(' nimbus gh repo <cmd> - Repo operations (info, branches)');
1681
- console.log('');
1682
- console.log(' Aliases:');
1683
- console.log(' nimbus terraform <cmd> - Alias for nimbus tf <cmd>');
1684
- console.log(' nimbus k <cmd> - Alias for nimbus k8s <cmd>');
1685
- console.log(' nimbus g <type> - Alias for nimbus generate <type>');
1686
- console.log(' nimbus h <cmd> - Alias for nimbus helm <cmd>');
1687
- console.log(' nimbus pr <cmd> - Alias for nimbus gh pr <cmd>');
1688
- console.log(' nimbus issue <cmd> - Alias for nimbus gh issue <cmd>');
1689
- console.log(' nimbus read <file> - Alias for nimbus fs read <file>');
1690
- console.log(' nimbus tree [path] - Alias for nimbus fs tree [path]');
1691
- console.log(' nimbus search <pattern> - Alias for nimbus fs search <pattern>');
1692
- console.log(' nimbus write <path> <c> - Alias for nimbus fs write <path> <content>');
1693
- console.log('');
1694
- console.log(' History:');
1695
- console.log(' nimbus history - View command history');
1696
- console.log(' nimbus history show <id> - Show details for a history entry');
1697
- console.log(' nimbus history --clear - Clear all history');
1698
- console.log('');
1699
- console.log(' Team & Enterprise:');
1700
- console.log(' nimbus team create <name> - Create a team');
1701
- console.log(' nimbus team invite <email> - Invite a member');
1702
- console.log(' nimbus team members - List team members');
1703
- console.log(' nimbus team switch - Switch active team');
1704
- console.log(' nimbus billing status - View billing status');
1705
- console.log(' nimbus billing upgrade - Upgrade plan');
1706
- console.log(' nimbus usage - View usage dashboard');
1707
- console.log(' nimbus audit - View audit logs');
1708
- console.log('');
1709
- console.log(' Analysis:');
1710
- console.log(' nimbus analyze - Analyze codebase for improvements');
1711
- console.log('');
1712
- console.log(' Server:');
1713
- console.log(' nimbus serve - Start headless API server (default port 4200)');
1714
- console.log(' nimbus serve --port 8080 - Start on custom port');
1715
- console.log(' nimbus serve --host 0.0.0.0 - Bind to all interfaces');
1716
- console.log(' nimbus serve --auth u:p - Enable HTTP Basic Auth');
1717
- console.log(' nimbus web [--port N] [--ui-url URL] - Start API server and open Web UI');
1718
- console.log('');
1719
- console.log(' Utilities:');
1720
- console.log(' nimbus version - Show version information');
1721
- console.log(' nimbus help - Show this help message');
1722
- console.log(' nimbus help <command> - Show help for a specific command');
1723
- console.log(' nimbus doctor - Run diagnostic checks');
1724
- console.log(' nimbus upgrade - Check for and install updates');
1725
- console.log('');
1726
- console.log('Use --help with any command for more options');
1727
- process.exit(1);
1728
- }