@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
@@ -1,1172 +0,0 @@
1
- /**
2
- * Questionnaire Command
3
- *
4
- * Interactive questionnaire flow for generating infrastructure code
5
- *
6
- * Usage:
7
- * nimbus questionnaire terraform
8
- * nimbus questionnaire kubernetes
9
- * nimbus questionnaire helm
10
- * nimbus generate terraform --interactive
11
- */
12
-
13
- import { logger } from '../utils';
14
- import { ui } from '../wizard/ui';
15
- import { select, input, confirm, multiSelect } from '../wizard/prompts';
16
-
17
- export interface QuestionnaireOptions {
18
- /** Questionnaire type */
19
- type: 'terraform' | 'kubernetes' | 'helm';
20
- /** Non-interactive mode (use answers file) */
21
- nonInteractive?: boolean;
22
- /** Path to answers file (JSON) */
23
- answersFile?: string;
24
- /** Output directory for generated code */
25
- outputDir?: string;
26
- /** Skip generation, just collect answers */
27
- dryRun?: boolean;
28
- }
29
-
30
- interface Question {
31
- id: string;
32
- type: 'select' | 'multiselect' | 'text' | 'number' | 'confirm';
33
- label: string;
34
- description?: string;
35
- options?: Array<{ value: string; label: string; description?: string }>;
36
- default?: unknown;
37
- validation?: Array<{ type: string; value?: unknown; message: string }>;
38
- }
39
-
40
- interface QuestionnaireStep {
41
- id: string;
42
- title: string;
43
- description?: string;
44
- questions: Question[];
45
- }
46
-
47
- interface _QuestionnaireResponse {
48
- session: {
49
- id: string;
50
- type: string;
51
- completed: boolean;
52
- };
53
- currentStep?: QuestionnaireStep;
54
- nextStep?: QuestionnaireStep;
55
- progress: {
56
- current: number;
57
- total: number;
58
- percentage: number;
59
- };
60
- }
61
-
62
- /**
63
- * Run questionnaire command
64
- */
65
- export async function questionnaireCommand(options: QuestionnaireOptions): Promise<void> {
66
- logger.info('Starting questionnaire', { type: options.type });
67
-
68
- ui.newLine();
69
- ui.header(`${capitalize(options.type)} Configuration Wizard`);
70
-
71
- await runLocal(options);
72
- }
73
-
74
- /**
75
- * Run questionnaire locally
76
- */
77
- async function runLocal(options: QuestionnaireOptions): Promise<void> {
78
- ui.info('Starting local questionnaire...');
79
- ui.newLine();
80
-
81
- const answers: Record<string, unknown> = {};
82
-
83
- // Get questionnaire steps based on type
84
- const steps = getLocalQuestionnaireSteps(options.type);
85
-
86
- for (let i = 0; i < steps.length; i++) {
87
- const step = steps[i];
88
-
89
- // Check step condition
90
- if (step.condition && !step.condition(answers)) {
91
- continue;
92
- }
93
-
94
- // Display step header
95
- ui.print(ui.bold(`Step ${i + 1}/${steps.length}: ${step.title}`));
96
- if (step.description) {
97
- ui.print(ui.dim(step.description));
98
- }
99
- ui.newLine();
100
-
101
- // Process questions
102
- for (const question of step.questions) {
103
- // Check question dependency
104
- if (question.dependsOn) {
105
- const depValue = answers[question.dependsOn.questionId];
106
- if (depValue !== question.dependsOn.value) {
107
- continue;
108
- }
109
- }
110
-
111
- const answer = await askQuestion(question, answers);
112
- answers[question.id] = answer;
113
- }
114
-
115
- // Show progress
116
- displayProgress({
117
- current: i + 1,
118
- total: steps.length,
119
- percentage: Math.round(((i + 1) / steps.length) * 100),
120
- });
121
- }
122
-
123
- ui.newLine();
124
- ui.success('Questionnaire completed!');
125
-
126
- if (!options.dryRun) {
127
- // Generate code from answers
128
- await generateFromAnswers(answers, options.type, options);
129
- } else {
130
- ui.newLine();
131
- ui.print(ui.bold('Collected answers:'));
132
- ui.print(JSON.stringify(answers, null, 2));
133
- }
134
- }
135
-
136
- /**
137
- * Ask a single question and return the answer
138
- */
139
- async function askQuestion(
140
- question: Question,
141
- currentAnswers: Record<string, unknown>
142
- ): Promise<unknown> {
143
- // Substitute variables in label and description
144
- const label = substituteVariables(question.label, currentAnswers);
145
- const _description = question.description
146
- ? substituteVariables(question.description, currentAnswers)
147
- : undefined;
148
-
149
- switch (question.type) {
150
- case 'select':
151
- return select({
152
- message: label,
153
- options: question.options || [],
154
- });
155
-
156
- case 'multiselect':
157
- return multiSelect({
158
- message: label,
159
- options: question.options || [],
160
- });
161
-
162
- case 'text':
163
- return input({
164
- message: label,
165
- defaultValue: question.default as string,
166
- });
167
-
168
- case 'number': {
169
- const numStr = await input({
170
- message: label,
171
- defaultValue: String(question.default ?? ''),
172
- });
173
- return parseInt(numStr, 10);
174
- }
175
-
176
- case 'confirm':
177
- return confirm({
178
- message: label,
179
- defaultValue: question.default as boolean,
180
- });
181
-
182
- default:
183
- return input({
184
- message: label,
185
- defaultValue: question.default as string,
186
- });
187
- }
188
- }
189
-
190
- /**
191
- * Substitute variables in text ({{variable}} format)
192
- */
193
- function substituteVariables(text: string, answers: Record<string, unknown>): string {
194
- return text.replace(/\{\{(\w+)\}\}/g, (_, key) => {
195
- const value = answers[key];
196
- return value !== undefined ? String(value) : `{{${key}}}`;
197
- });
198
- }
199
-
200
- /**
201
- * Display progress bar
202
- */
203
- function displayProgress(progress: { current: number; total: number; percentage: number }): void {
204
- const barWidth = 30;
205
- const filled = Math.round((progress.current / progress.total) * barWidth);
206
- const empty = barWidth - filled;
207
- const bar = ui.color('█'.repeat(filled), 'green') + ui.dim('░'.repeat(empty));
208
-
209
- ui.newLine();
210
- ui.print(` Progress: ${bar} ${progress.percentage}%`);
211
- }
212
-
213
- /**
214
- * Generate code from answers
215
- */
216
- async function generateFromAnswers(
217
- answers: Record<string, unknown>,
218
- type: string,
219
- options: QuestionnaireOptions
220
- ): Promise<void> {
221
- ui.newLine();
222
- ui.startSpinner({ message: 'Generating code...' });
223
-
224
- try {
225
- const outputDir = options.outputDir || `./${type}`;
226
- const fs = await import('fs/promises');
227
- const path = await import('path');
228
-
229
- // Ensure output directory exists
230
- await fs.mkdir(outputDir, { recursive: true });
231
-
232
- // Generate code based on type
233
- let files: string[] = [];
234
-
235
- if (type === 'terraform') {
236
- files = await generateTerraformCode(answers, outputDir, fs, path);
237
- } else if (type === 'kubernetes') {
238
- files = await generateKubernetesCode(answers, outputDir, fs, path);
239
- } else if (type === 'helm') {
240
- files = await generateHelmCode(answers, outputDir, fs, path);
241
- }
242
-
243
- ui.stopSpinnerSuccess('Code generated successfully');
244
-
245
- // Display generated files
246
- ui.newLine();
247
- ui.print(ui.bold('Generated files:'));
248
- for (const file of files) {
249
- ui.print(` ${ui.color('●', 'green')} ${file}`);
250
- }
251
- ui.newLine();
252
- ui.print(`Output directory: ${outputDir}`);
253
-
254
- // Run post-generation validation for Terraform
255
- if (type === 'terraform') {
256
- await runPostGenerationValidation(outputDir);
257
- }
258
- } catch (error) {
259
- ui.stopSpinnerFail('Code generation failed');
260
- ui.error((error as Error).message);
261
- }
262
- }
263
-
264
- /**
265
- * Generate Terraform code from answers
266
- */
267
- async function generateTerraformCode(
268
- answers: Record<string, unknown>,
269
- outputDir: string,
270
- fs: typeof import('fs/promises'),
271
- path: typeof import('path')
272
- ): Promise<string[]> {
273
- const files: string[] = [];
274
-
275
- // Generate main.tf
276
- const mainContent = generateTerraformMain(answers);
277
- const mainPath = path.join(outputDir, 'main.tf');
278
- await fs.writeFile(mainPath, mainContent);
279
- files.push('main.tf');
280
-
281
- // Generate variables.tf
282
- const varsContent = generateTerraformVariables(answers);
283
- const varsPath = path.join(outputDir, 'variables.tf');
284
- await fs.writeFile(varsPath, varsContent);
285
- files.push('variables.tf');
286
-
287
- // Generate outputs.tf
288
- const outputsContent = generateTerraformOutputs(answers);
289
- const outputsPath = path.join(outputDir, 'outputs.tf');
290
- await fs.writeFile(outputsPath, outputsContent);
291
- files.push('outputs.tf');
292
-
293
- // Generate environment directories if environments were selected
294
- const environments = answers.environments as string[] | undefined;
295
- if (environments && environments.length > 0) {
296
- const envFiles = await generateEnvironmentDirs(answers, outputDir, fs, path);
297
- files.push(...envFiles);
298
- }
299
-
300
- return files;
301
- }
302
-
303
- /**
304
- * Generate Terraform main.tf content
305
- */
306
- function generateTerraformMain(answers: Record<string, unknown>): string {
307
- const provider = (answers.provider as string) || 'aws';
308
- const _region = (answers.region as string) || 'us-east-1';
309
-
310
- let content = `# Generated by Nimbus CLI
311
-
312
- terraform {
313
- required_version = ">= 1.0.0"
314
-
315
- required_providers {
316
- ${provider} = {
317
- source = "hashicorp/${provider}"
318
- version = "~> 5.0"
319
- }
320
- }
321
- }
322
-
323
- provider "${provider}" {
324
- region = var.region
325
- }
326
- `;
327
-
328
- // Add VPC if selected
329
- const components = (answers.components as string[]) || [];
330
- if (components.includes('vpc')) {
331
- const vpcCidr = (answers.vpc_cidr as string) || '10.0.0.0/16';
332
- content += `
333
- # VPC
334
- module "vpc" {
335
- source = "terraform-aws-modules/vpc/aws"
336
- version = "~> 5.0"
337
-
338
- name = var.project_name
339
- cidr = "${vpcCidr}"
340
-
341
- azs = var.availability_zones
342
- private_subnets = var.private_subnets
343
- public_subnets = var.public_subnets
344
-
345
- enable_nat_gateway = true
346
- single_nat_gateway = true
347
-
348
- tags = var.tags
349
- }
350
- `;
351
- }
352
-
353
- return content;
354
- }
355
-
356
- /**
357
- * Generate Terraform variables.tf content
358
- */
359
- function generateTerraformVariables(answers: Record<string, unknown>): string {
360
- const projectName = (answers.project_name as string) || 'my-project';
361
-
362
- return `# Generated by Nimbus CLI
363
-
364
- variable "region" {
365
- description = "AWS region"
366
- type = string
367
- default = "us-east-1"
368
- }
369
-
370
- variable "project_name" {
371
- description = "Project name"
372
- type = string
373
- default = "${projectName}"
374
- }
375
-
376
- variable "environment" {
377
- description = "Environment (dev, staging, prod)"
378
- type = string
379
- default = "dev"
380
- }
381
-
382
- variable "availability_zones" {
383
- description = "List of availability zones"
384
- type = list(string)
385
- default = ["us-east-1a", "us-east-1b", "us-east-1c"]
386
- }
387
-
388
- variable "private_subnets" {
389
- description = "Private subnet CIDRs"
390
- type = list(string)
391
- default = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
392
- }
393
-
394
- variable "public_subnets" {
395
- description = "Public subnet CIDRs"
396
- type = list(string)
397
- default = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
398
- }
399
-
400
- variable "tags" {
401
- description = "Tags to apply to resources"
402
- type = map(string)
403
- default = {}
404
- }
405
- `;
406
- }
407
-
408
- /**
409
- * Generate Terraform outputs.tf content
410
- */
411
- function generateTerraformOutputs(answers: Record<string, unknown>): string {
412
- const components = (answers.components as string[]) || [];
413
-
414
- let content = `# Generated by Nimbus CLI
415
- `;
416
-
417
- if (components.includes('vpc')) {
418
- content += `
419
- output "vpc_id" {
420
- description = "VPC ID"
421
- value = module.vpc.vpc_id
422
- }
423
-
424
- output "private_subnets" {
425
- description = "Private subnet IDs"
426
- value = module.vpc.private_subnets
427
- }
428
-
429
- output "public_subnets" {
430
- description = "Public subnet IDs"
431
- value = module.vpc.public_subnets
432
- }
433
- `;
434
- }
435
-
436
- return content;
437
- }
438
-
439
- /**
440
- * Generate Kubernetes code from answers
441
- */
442
- async function generateKubernetesCode(
443
- answers: Record<string, unknown>,
444
- outputDir: string,
445
- fs: typeof import('fs/promises'),
446
- path: typeof import('path')
447
- ): Promise<string[]> {
448
- const files: string[] = [];
449
- const appName = (answers.app_name as string) || 'my-app';
450
-
451
- // Generate deployment.yaml
452
- const deploymentContent = `# Generated by Nimbus CLI
453
- apiVersion: apps/v1
454
- kind: Deployment
455
- metadata:
456
- name: ${appName}
457
- labels:
458
- app: ${appName}
459
- spec:
460
- replicas: ${answers.replicas || 2}
461
- selector:
462
- matchLabels:
463
- app: ${appName}
464
- template:
465
- metadata:
466
- labels:
467
- app: ${appName}
468
- spec:
469
- containers:
470
- - name: ${appName}
471
- image: ${answers.image || 'nginx:latest'}
472
- ports:
473
- - containerPort: ${answers.port || 80}
474
- resources:
475
- requests:
476
- cpu: ${answers.cpu_request || '100m'}
477
- memory: ${answers.memory_request || '128Mi'}
478
- limits:
479
- cpu: ${answers.cpu_limit || '500m'}
480
- memory: ${answers.memory_limit || '512Mi'}
481
- `;
482
-
483
- const deploymentPath = path.join(outputDir, 'deployment.yaml');
484
- await fs.writeFile(deploymentPath, deploymentContent);
485
- files.push('deployment.yaml');
486
-
487
- // Generate service.yaml if enabled
488
- if (answers.create_service !== false) {
489
- const serviceContent = `# Generated by Nimbus CLI
490
- apiVersion: v1
491
- kind: Service
492
- metadata:
493
- name: ${appName}
494
- spec:
495
- selector:
496
- app: ${appName}
497
- ports:
498
- - protocol: TCP
499
- port: ${answers.service_port || 80}
500
- targetPort: ${answers.port || 80}
501
- type: ${answers.service_type || 'ClusterIP'}
502
- `;
503
-
504
- const servicePath = path.join(outputDir, 'service.yaml');
505
- await fs.writeFile(servicePath, serviceContent);
506
- files.push('service.yaml');
507
- }
508
-
509
- return files;
510
- }
511
-
512
- /**
513
- * Generate Helm chart code from answers
514
- */
515
- async function generateHelmCode(
516
- answers: Record<string, unknown>,
517
- outputDir: string,
518
- fs: typeof import('fs/promises'),
519
- path: typeof import('path')
520
- ): Promise<string[]> {
521
- const files: string[] = [];
522
- const chartName = (answers.chart_name as string) || 'my-chart';
523
-
524
- // Create templates directory
525
- const templatesDir = path.join(outputDir, 'templates');
526
- await fs.mkdir(templatesDir, { recursive: true });
527
-
528
- // Generate Chart.yaml
529
- const chartContent = `# Generated by Nimbus CLI
530
- apiVersion: v2
531
- name: ${chartName}
532
- description: ${answers.description || 'A Helm chart for Kubernetes'}
533
- type: application
534
- version: ${answers.version || '0.1.0'}
535
- appVersion: "${answers.app_version || '1.0.0'}"
536
- `;
537
-
538
- const chartPath = path.join(outputDir, 'Chart.yaml');
539
- await fs.writeFile(chartPath, chartContent);
540
- files.push('Chart.yaml');
541
-
542
- // Generate values.yaml
543
- const valuesContent = `# Generated by Nimbus CLI
544
- # Default values for ${chartName}
545
-
546
- replicaCount: ${answers.replicas || 1}
547
-
548
- image:
549
- repository: ${answers.image_repository || 'nginx'}
550
- tag: ${answers.image_tag || 'latest'}
551
- pullPolicy: IfNotPresent
552
-
553
- service:
554
- type: ${answers.service_type || 'ClusterIP'}
555
- port: ${answers.service_port || 80}
556
-
557
- resources:
558
- requests:
559
- cpu: ${answers.cpu_request || '100m'}
560
- memory: ${answers.memory_request || '128Mi'}
561
- limits:
562
- cpu: ${answers.cpu_limit || '500m'}
563
- memory: ${answers.memory_limit || '512Mi'}
564
- `;
565
-
566
- const valuesPath = path.join(outputDir, 'values.yaml');
567
- await fs.writeFile(valuesPath, valuesContent);
568
- files.push('values.yaml');
569
-
570
- return files;
571
- }
572
-
573
- /**
574
- * Generate per-environment directories with module references
575
- */
576
- async function generateEnvironmentDirs(
577
- answers: Record<string, unknown>,
578
- outputDir: string,
579
- fs: typeof import('fs/promises'),
580
- path: typeof import('path')
581
- ): Promise<string[]> {
582
- const environments = answers.environments as string[];
583
- const projectName = (answers.project_name as string) || 'my-project';
584
- const _provider = (answers.cloud as string) || (answers.provider as string) || 'aws';
585
- const region = (answers.region as string) || 'us-east-1';
586
- const useRemoteState = answers.use_remote_state as boolean;
587
- const files: string[] = [];
588
-
589
- const envsDir = path.join(outputDir, 'environments');
590
- await fs.mkdir(envsDir, { recursive: true });
591
-
592
- for (const env of environments) {
593
- const envDir = path.join(envsDir, env);
594
- await fs.mkdir(envDir, { recursive: true });
595
-
596
- // main.tf — module source pointing to root
597
- const mainContent = `# ${env.charAt(0).toUpperCase() + env.slice(1)} Environment
598
- # Generated by Nimbus CLI
599
-
600
- module "infrastructure" {
601
- source = "../../"
602
-
603
- project_name = "${projectName}"
604
- environment = "${env}"
605
- region = var.region
606
-
607
- tags = merge(var.tags, {
608
- Environment = "${env}"
609
- })
610
- }
611
- `;
612
- await fs.writeFile(path.join(envDir, 'main.tf'), mainContent);
613
- files.push(`environments/${env}/main.tf`);
614
-
615
- // terraform.tfvars
616
- const _instanceSize =
617
- env === 'prod' ? 't3.large' : env === 'staging' ? 't3.medium' : 't3.small';
618
- const tfvarsContent = `# ${env.charAt(0).toUpperCase() + env.slice(1)} environment variables
619
- # Generated by Nimbus CLI
620
-
621
- region = "${region}"
622
-
623
- tags = {
624
- Environment = "${env}"
625
- Project = "${projectName}"
626
- ManagedBy = "terraform"
627
- }
628
- `;
629
- await fs.writeFile(path.join(envDir, 'terraform.tfvars'), tfvarsContent);
630
- files.push(`environments/${env}/terraform.tfvars`);
631
-
632
- // backend.tf — remote state if selected
633
- if (useRemoteState) {
634
- const backendContent = `# Remote state configuration for ${env}
635
- # Generated by Nimbus CLI
636
-
637
- terraform {
638
- backend "s3" {
639
- bucket = "${projectName}-tfstate"
640
- key = "${env}/terraform.tfstate"
641
- region = "${region}"
642
- encrypt = true
643
- dynamodb_table = "${projectName}-tflock"
644
- }
645
- }
646
- `;
647
- await fs.writeFile(path.join(envDir, 'backend.tf'), backendContent);
648
- files.push(`environments/${env}/backend.tf`);
649
- }
650
- }
651
-
652
- return files;
653
- }
654
-
655
- /**
656
- * Run post-generation validation on Terraform files
657
- */
658
- async function runPostGenerationValidation(outputDir: string): Promise<void> {
659
- const { execFile } = await import('child_process');
660
- const { promisify } = await import('util');
661
- const execFileAsync = promisify(execFile);
662
-
663
- ui.newLine();
664
- ui.section('Post-Generation Validation');
665
-
666
- // Check if terraform CLI is available
667
- let _hasTerraform = false;
668
- try {
669
- await execFileAsync('terraform', ['version'], { timeout: 5000 });
670
- _hasTerraform = true;
671
- } catch {
672
- ui.info('Terraform CLI not found - skipping validation');
673
- ui.print(ui.dim(' Install terraform for automatic validation'));
674
- return;
675
- }
676
-
677
- // Run terraform fmt -check
678
- try {
679
- ui.startSpinner({ message: 'Running terraform fmt...' });
680
- await execFileAsync('terraform', ['fmt', '-check', '-diff'], {
681
- cwd: outputDir,
682
- timeout: 15000,
683
- });
684
- ui.stopSpinnerSuccess('Code formatting valid');
685
- } catch (error: any) {
686
- ui.stopSpinnerFail('Formatting issues found');
687
- // Try to auto-fix
688
- try {
689
- await execFileAsync('terraform', ['fmt'], { cwd: outputDir, timeout: 15000 });
690
- ui.success('Auto-formatted Terraform files');
691
- } catch {
692
- ui.warning('Could not auto-format files');
693
- }
694
- }
695
-
696
- // Run terraform init -backend=false for validation
697
- try {
698
- ui.startSpinner({ message: 'Running terraform validate...' });
699
- await execFileAsync('terraform', ['init', '-backend=false', '-no-color'], {
700
- cwd: outputDir,
701
- timeout: 30000,
702
- });
703
- const { stdout } = await execFileAsync('terraform', ['validate', '-no-color'], {
704
- cwd: outputDir,
705
- timeout: 15000,
706
- });
707
- ui.stopSpinnerSuccess('Terraform validation passed');
708
- if (stdout.includes('Success')) {
709
- ui.print(ui.dim(` ${stdout.trim()}`));
710
- }
711
- } catch (error: any) {
712
- ui.stopSpinnerFail('Terraform validation failed');
713
- const output = error.stdout || error.stderr || error.message;
714
- ui.print(ui.dim(` ${output}`));
715
- }
716
-
717
- // Check if tflint is available
718
- try {
719
- await execFileAsync('tflint', ['--version'], { timeout: 5000 });
720
- ui.startSpinner({ message: 'Running tflint...' });
721
- const { stdout } = await execFileAsync('tflint', ['--no-color'], {
722
- cwd: outputDir,
723
- timeout: 15000,
724
- });
725
- ui.stopSpinnerSuccess('tflint check passed');
726
- if (stdout) {
727
- ui.print(ui.dim(` ${stdout.trim()}`));
728
- }
729
- } catch (error: any) {
730
- if (error.code === 'ENOENT') {
731
- ui.info('tflint not found - skipping lint check');
732
- ui.print(ui.dim(' Install tflint for additional validation'));
733
- } else {
734
- ui.warning('tflint found issues');
735
- const output = error.stdout || error.stderr || error.message;
736
- ui.print(ui.dim(` ${output}`));
737
- }
738
- }
739
-
740
- // Check if checkov is available for security scanning
741
- try {
742
- await execFileAsync('checkov', ['--version'], { timeout: 5000 });
743
- ui.startSpinner({ message: 'Running checkov security scan...' });
744
- const { stdout } = await execFileAsync(
745
- 'checkov',
746
- ['-d', outputDir, '--framework', 'terraform', '--compact', '--quiet'],
747
- { timeout: 60000 }
748
- );
749
- ui.stopSpinnerSuccess('checkov security scan passed');
750
- // Parse passed/failed from output
751
- const passedMatch = stdout.match(/Passed checks: (\d+)/);
752
- const failedMatch = stdout.match(/Failed checks: (\d+)/);
753
- if (passedMatch || failedMatch) {
754
- const passed = passedMatch ? passedMatch[1] : '0';
755
- const failed = failedMatch ? failedMatch[1] : '0';
756
- ui.print(ui.dim(` Passed: ${passed}, Failed: ${failed}`));
757
- } else if (stdout.trim()) {
758
- ui.print(ui.dim(` ${stdout.trim()}`));
759
- }
760
- } catch (error: any) {
761
- if (error.code === 'ENOENT') {
762
- ui.info('Security scanning available with checkov. Install: pip install checkov');
763
- } else {
764
- ui.warning('checkov found security issues');
765
- const output = error.stdout || error.stderr || error.message;
766
- // Parse passed/failed from output even on non-zero exit
767
- const passedMatch = output.match(/Passed checks: (\d+)/);
768
- const failedMatch = output.match(/Failed checks: (\d+)/);
769
- if (passedMatch || failedMatch) {
770
- const passed = passedMatch ? passedMatch[1] : '0';
771
- const failed = failedMatch ? failedMatch[1] : '0';
772
- ui.print(ui.dim(` Passed: ${passed}, Failed: ${failed}`));
773
- } else {
774
- ui.print(ui.dim(` ${output}`));
775
- }
776
- }
777
- }
778
- }
779
-
780
- /**
781
- * Get local questionnaire steps based on type
782
- */
783
- function getLocalQuestionnaireSteps(type: 'terraform' | 'kubernetes' | 'helm'): Array<{
784
- id: string;
785
- title: string;
786
- description?: string;
787
- questions: Array<Question & { dependsOn?: { questionId: string; value: unknown } }>;
788
- condition?: (answers: Record<string, unknown>) => boolean;
789
- }> {
790
- switch (type) {
791
- case 'terraform':
792
- return getTerraformSteps();
793
- case 'kubernetes':
794
- return getKubernetesSteps();
795
- case 'helm':
796
- return getHelmSteps();
797
- default:
798
- return [];
799
- }
800
- }
801
-
802
- /**
803
- * Terraform questionnaire steps (local fallback)
804
- */
805
- function getTerraformSteps() {
806
- return [
807
- {
808
- id: 'provider',
809
- title: 'Cloud Provider',
810
- description: 'Select your cloud provider and region',
811
- questions: [
812
- {
813
- id: 'cloud',
814
- type: 'select' as const,
815
- label: 'Which cloud provider?',
816
- options: [
817
- { value: 'aws', label: 'AWS', description: 'Amazon Web Services' },
818
- { value: 'gcp', label: 'GCP', description: 'Google Cloud Platform' },
819
- { value: 'azure', label: 'Azure', description: 'Microsoft Azure' },
820
- ],
821
- default: 'aws',
822
- },
823
- {
824
- id: 'region',
825
- type: 'select' as const,
826
- label: 'Which region?',
827
- options: [
828
- { value: 'us-east-1', label: 'US East (N. Virginia)' },
829
- { value: 'us-west-2', label: 'US West (Oregon)' },
830
- { value: 'eu-west-1', label: 'EU (Ireland)' },
831
- { value: 'ap-southeast-1', label: 'Asia Pacific (Singapore)' },
832
- ],
833
- default: 'us-east-1',
834
- dependsOn: { questionId: 'cloud', value: 'aws' },
835
- },
836
- {
837
- id: 'project_name',
838
- type: 'text' as const,
839
- label: 'Project name',
840
- default: 'my-project',
841
- },
842
- {
843
- id: 'environment',
844
- type: 'select' as const,
845
- label: 'Environment',
846
- options: [
847
- { value: 'dev', label: 'Development' },
848
- { value: 'staging', label: 'Staging' },
849
- { value: 'prod', label: 'Production' },
850
- ],
851
- default: 'dev',
852
- },
853
- ],
854
- },
855
- {
856
- id: 'components',
857
- title: 'Infrastructure Components',
858
- description: 'Select the components you need',
859
- questions: [
860
- {
861
- id: 'components',
862
- type: 'multiselect' as const,
863
- label: 'What components do you need?',
864
- options: [
865
- { value: 'vpc', label: 'VPC / Network' },
866
- { value: 'eks', label: 'Kubernetes (EKS)' },
867
- { value: 'rds', label: 'Database (RDS)' },
868
- { value: 's3', label: 'Object Storage (S3)' },
869
- { value: 'ecs', label: 'Container Service (ECS)' },
870
- ],
871
- default: ['vpc'],
872
- },
873
- ],
874
- },
875
- {
876
- id: 'environments',
877
- title: 'Environment Separation',
878
- description: 'Configure environment-specific deployments',
879
- questions: [
880
- {
881
- id: 'environments',
882
- type: 'multiselect' as const,
883
- label: 'Which environments do you need?',
884
- options: [
885
- { value: 'dev', label: 'Development' },
886
- { value: 'staging', label: 'Staging' },
887
- { value: 'prod', label: 'Production' },
888
- ],
889
- default: ['dev'],
890
- },
891
- {
892
- id: 'use_remote_state',
893
- type: 'confirm' as const,
894
- label: 'Use remote state backend (S3)?',
895
- default: true,
896
- },
897
- ],
898
- },
899
- {
900
- id: 'vpc_config',
901
- title: 'VPC Configuration',
902
- condition: (answers: Record<string, unknown>) => {
903
- const components = answers.components as string[];
904
- return components && components.includes('vpc');
905
- },
906
- questions: [
907
- {
908
- id: 'vpc_cidr',
909
- type: 'text' as const,
910
- label: 'VPC CIDR block',
911
- default: '10.0.0.0/16',
912
- },
913
- {
914
- id: 'availability_zones',
915
- type: 'number' as const,
916
- label: 'Number of availability zones',
917
- default: 3,
918
- },
919
- {
920
- id: 'nat_gateway',
921
- type: 'select' as const,
922
- label: 'NAT Gateway configuration',
923
- options: [
924
- { value: 'single', label: 'Single NAT (~$32/month)' },
925
- { value: 'ha', label: 'HA NAT (one per AZ)' },
926
- { value: 'none', label: 'No NAT Gateway' },
927
- ],
928
- default: 'single',
929
- },
930
- ],
931
- },
932
- ];
933
- }
934
-
935
- /**
936
- * Kubernetes questionnaire steps (local fallback)
937
- */
938
- function getKubernetesSteps() {
939
- return [
940
- {
941
- id: 'workload',
942
- title: 'Workload Type',
943
- description: 'Configure your Kubernetes workload',
944
- questions: [
945
- {
946
- id: 'workload_type',
947
- type: 'select' as const,
948
- label: 'What type of workload?',
949
- options: [
950
- {
951
- value: 'deployment',
952
- label: 'Deployment',
953
- description: 'Standard stateless workload',
954
- },
955
- {
956
- value: 'statefulset',
957
- label: 'StatefulSet',
958
- description: 'Stateful workload with persistent storage',
959
- },
960
- { value: 'daemonset', label: 'DaemonSet', description: 'Run on every node' },
961
- { value: 'cronjob', label: 'CronJob', description: 'Scheduled job' },
962
- ],
963
- default: 'deployment',
964
- },
965
- {
966
- id: 'name',
967
- type: 'text' as const,
968
- label: 'Workload name',
969
- default: 'my-app',
970
- },
971
- {
972
- id: 'namespace',
973
- type: 'text' as const,
974
- label: 'Namespace',
975
- default: 'default',
976
- },
977
- ],
978
- },
979
- {
980
- id: 'container',
981
- title: 'Container Configuration',
982
- questions: [
983
- {
984
- id: 'image',
985
- type: 'text' as const,
986
- label: 'Container image',
987
- default: 'nginx:latest',
988
- },
989
- {
990
- id: 'replicas',
991
- type: 'number' as const,
992
- label: 'Number of replicas',
993
- default: 3,
994
- },
995
- {
996
- id: 'port',
997
- type: 'number' as const,
998
- label: 'Container port',
999
- default: 80,
1000
- },
1001
- ],
1002
- },
1003
- {
1004
- id: 'service',
1005
- title: 'Service Configuration',
1006
- questions: [
1007
- {
1008
- id: 'service_type',
1009
- type: 'select' as const,
1010
- label: 'Service type',
1011
- options: [
1012
- { value: 'ClusterIP', label: 'ClusterIP', description: 'Internal only' },
1013
- { value: 'NodePort', label: 'NodePort', description: 'External via node port' },
1014
- { value: 'LoadBalancer', label: 'LoadBalancer', description: 'External load balancer' },
1015
- ],
1016
- default: 'ClusterIP',
1017
- },
1018
- {
1019
- id: 'create_ingress',
1020
- type: 'confirm' as const,
1021
- label: 'Create Ingress?',
1022
- default: false,
1023
- },
1024
- ],
1025
- },
1026
- {
1027
- id: 'resources',
1028
- title: 'Resource Limits',
1029
- questions: [
1030
- {
1031
- id: 'cpu_request',
1032
- type: 'text' as const,
1033
- label: 'CPU request',
1034
- default: '100m',
1035
- },
1036
- {
1037
- id: 'cpu_limit',
1038
- type: 'text' as const,
1039
- label: 'CPU limit',
1040
- default: '500m',
1041
- },
1042
- {
1043
- id: 'memory_request',
1044
- type: 'text' as const,
1045
- label: 'Memory request',
1046
- default: '128Mi',
1047
- },
1048
- {
1049
- id: 'memory_limit',
1050
- type: 'text' as const,
1051
- label: 'Memory limit',
1052
- default: '512Mi',
1053
- },
1054
- ],
1055
- },
1056
- ];
1057
- }
1058
-
1059
- /**
1060
- * Helm questionnaire steps (local fallback)
1061
- */
1062
- function getHelmSteps() {
1063
- return [
1064
- {
1065
- id: 'chart',
1066
- title: 'Chart Information',
1067
- description: 'Basic Helm chart configuration',
1068
- questions: [
1069
- {
1070
- id: 'chart_name',
1071
- type: 'text' as const,
1072
- label: 'Chart name',
1073
- default: 'my-chart',
1074
- },
1075
- {
1076
- id: 'chart_version',
1077
- type: 'text' as const,
1078
- label: 'Chart version',
1079
- default: '0.1.0',
1080
- },
1081
- {
1082
- id: 'app_version',
1083
- type: 'text' as const,
1084
- label: 'Application version',
1085
- default: '1.0.0',
1086
- },
1087
- {
1088
- id: 'description',
1089
- type: 'text' as const,
1090
- label: 'Chart description',
1091
- default: 'A Helm chart for my application',
1092
- },
1093
- ],
1094
- },
1095
- {
1096
- id: 'deployment',
1097
- title: 'Deployment Configuration',
1098
- questions: [
1099
- {
1100
- id: 'image_repository',
1101
- type: 'text' as const,
1102
- label: 'Image repository',
1103
- default: 'nginx',
1104
- },
1105
- {
1106
- id: 'image_tag',
1107
- type: 'text' as const,
1108
- label: 'Image tag',
1109
- default: 'latest',
1110
- },
1111
- {
1112
- id: 'replica_count',
1113
- type: 'number' as const,
1114
- label: 'Replica count',
1115
- default: 1,
1116
- },
1117
- ],
1118
- },
1119
- {
1120
- id: 'service',
1121
- title: 'Service Configuration',
1122
- questions: [
1123
- {
1124
- id: 'service_type',
1125
- type: 'select' as const,
1126
- label: 'Service type',
1127
- options: [
1128
- { value: 'ClusterIP', label: 'ClusterIP' },
1129
- { value: 'NodePort', label: 'NodePort' },
1130
- { value: 'LoadBalancer', label: 'LoadBalancer' },
1131
- ],
1132
- default: 'ClusterIP',
1133
- },
1134
- {
1135
- id: 'service_port',
1136
- type: 'number' as const,
1137
- label: 'Service port',
1138
- default: 80,
1139
- },
1140
- ],
1141
- },
1142
- {
1143
- id: 'ingress',
1144
- title: 'Ingress Configuration',
1145
- questions: [
1146
- {
1147
- id: 'ingress_enabled',
1148
- type: 'confirm' as const,
1149
- label: 'Enable Ingress?',
1150
- default: false,
1151
- },
1152
- {
1153
- id: 'ingress_host',
1154
- type: 'text' as const,
1155
- label: 'Ingress hostname',
1156
- default: 'chart.local',
1157
- dependsOn: { questionId: 'ingress_enabled', value: true },
1158
- },
1159
- ],
1160
- },
1161
- ];
1162
- }
1163
-
1164
- /**
1165
- * Capitalize first letter
1166
- */
1167
- function capitalize(str: string): string {
1168
- return str.charAt(0).toUpperCase() + str.slice(1);
1169
- }
1170
-
1171
- // Export as default
1172
- export default questionnaireCommand;