@runa-ai/runa-cli 0.5.72 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (528) hide show
  1. package/dist/build-V66FAQXB.js +1719 -0
  2. package/dist/cache-N7WNPEYF.js +111 -0
  3. package/dist/check-LOMVIRHX.js +12 -0
  4. package/dist/chunk-2APB25TT.js +442 -0
  5. package/dist/chunk-3FDQW524.js +544 -0
  6. package/dist/chunk-3WDV32GA.js +33 -0
  7. package/dist/chunk-5FT3F36G.js +59 -0
  8. package/dist/chunk-5NKWR4FF.js +254 -0
  9. package/dist/chunk-644FVGIQ.js +194 -0
  10. package/dist/chunk-6AALH2ED.js +121 -0
  11. package/dist/chunk-6FAU4IGR.js +63 -0
  12. package/dist/chunk-6Y3LAUGL.js +35 -0
  13. package/dist/chunk-7B5C6U2K.js +274 -0
  14. package/dist/chunk-AAIE4F2U.js +140 -0
  15. package/dist/chunk-AIP6MR42.js +12 -0
  16. package/dist/chunk-CCKG5R4Y.js +59 -0
  17. package/dist/chunk-DRSUEMAK.js +123 -0
  18. package/dist/chunk-FHG3ILE4.js +2011 -0
  19. package/dist/chunk-H2AHNI75.js +31 -0
  20. package/dist/chunk-HD74F6W2.js +460 -0
  21. package/dist/chunk-HKUWEGUX.js +36 -0
  22. package/dist/chunk-IBVVGH6X.js +33 -0
  23. package/dist/chunk-II7VYQEM.js +179 -0
  24. package/dist/chunk-JMJP4A47.js +204 -0
  25. package/dist/chunk-JQXOVCOP.js +574 -0
  26. package/dist/chunk-KE6QJBZG.js +41 -0
  27. package/dist/chunk-KWX3JHCY.js +85 -0
  28. package/dist/chunk-MXRWBNIY.js +74 -0
  29. package/dist/chunk-NPSRD26F.js +149 -0
  30. package/dist/chunk-QDF7QXBL.js +67 -0
  31. package/dist/chunk-QM53IQHM.js +209 -0
  32. package/dist/chunk-RZLYEO4U.js +219 -0
  33. package/dist/chunk-SGJG3BKD.js +351 -0
  34. package/dist/chunk-TYIAD6SB.js +74 -0
  35. package/dist/chunk-UWWSAPDR.js +31 -0
  36. package/dist/chunk-VM3IWOT5.js +458 -0
  37. package/dist/chunk-VRXHCR5K.js +42 -0
  38. package/dist/chunk-WJXC4MVY.js +75 -0
  39. package/dist/chunk-XDCHRVE3.js +215 -0
  40. package/dist/chunk-Z4Z5DNW4.js +1196 -0
  41. package/dist/chunk-ZZOXM6Q4.js +8 -0
  42. package/dist/ci-ZWRVWNFX.js +9298 -0
  43. package/dist/cli/contract-output.d.ts +1 -0
  44. package/dist/cli/index.d.ts +7 -1
  45. package/dist/cli/requested-command.d.ts +8 -0
  46. package/dist/cli-2JNBJUBB.js +704 -0
  47. package/dist/commands/build/actors/db-sync.d.ts +2 -0
  48. package/dist/commands/build/actors/static-checks.d.ts +7 -6
  49. package/dist/commands/build/actors/validate.d.ts +2 -0
  50. package/dist/commands/build/contract.d.ts +30 -30
  51. package/dist/commands/build/machine-dry-run.d.ts +3 -0
  52. package/dist/commands/build/machine-e2e-meta.d.ts +120 -0
  53. package/dist/commands/build/machine.d.ts +22 -22
  54. package/dist/commands/build/types.d.ts +2 -4
  55. package/dist/commands/check/commands/check.d.ts +8 -3
  56. package/dist/commands/ci/machine/actors/db/collect-schema-stats.d.ts +9 -6
  57. package/dist/commands/ci/machine/actors/db/schema-canonical-diff.d.ts +55 -0
  58. package/dist/commands/ci/machine/actors/db/schema-stats.d.ts +11 -0
  59. package/dist/commands/ci/machine/actors/db/sync-schema.d.ts +9 -1
  60. package/dist/commands/ci/machine/contract.d.ts +26 -26
  61. package/dist/commands/ci/machine/formatters/sections/final-comment.d.ts +1 -5
  62. package/dist/commands/ci/machine/formatters/sections/format-helpers.d.ts +5 -0
  63. package/dist/commands/ci/machine/formatters/sections/index.d.ts +2 -2
  64. package/dist/commands/ci/machine/formatters/sections/schema-matrix.d.ts +3 -3
  65. package/dist/commands/ci/machine/machine-execution-helpers.d.ts +40 -0
  66. package/dist/commands/ci/machine/machine-state-helpers.d.ts +14 -0
  67. package/dist/commands/ci/machine/machine.d.ts +12 -12
  68. package/dist/commands/ci/machine/types.d.ts +2 -5
  69. package/dist/commands/ci/utils/ci-summary.d.ts +15 -15
  70. package/dist/commands/ci/utils/execa-helpers.d.ts +2 -0
  71. package/dist/commands/db/apply/actors/idempotent-actors.d.ts +34 -0
  72. package/dist/commands/db/apply/actors/lock-actors.d.ts +16 -0
  73. package/dist/commands/db/apply/actors/pg-schema-diff-actors.d.ts +31 -0
  74. package/dist/commands/db/apply/actors/seed-actors.d.ts +11 -0
  75. package/dist/commands/db/apply/actors/shared.d.ts +9 -0
  76. package/dist/commands/db/apply/actors.d.ts +16 -65
  77. package/dist/commands/db/apply/contract.d.ts +8 -1
  78. package/dist/commands/db/apply/helpers/data-compatibility-checker.d.ts +3 -4
  79. package/dist/commands/db/apply/helpers/data-integrity-verifier.d.ts +37 -0
  80. package/dist/commands/db/apply/helpers/fresh-db-handler.d.ts +34 -0
  81. package/dist/commands/db/apply/helpers/hazard-handler.d.ts +60 -0
  82. package/dist/commands/db/apply/helpers/idempotent-object-registry.d.ts +96 -0
  83. package/dist/commands/db/apply/helpers/idempotent-transaction.d.ts +20 -0
  84. package/dist/commands/db/apply/helpers/index.d.ts +6 -0
  85. package/dist/commands/db/apply/helpers/partition-validator.d.ts +2 -15
  86. package/dist/commands/db/apply/helpers/pg-schema-diff-helpers.d.ts +18 -162
  87. package/dist/commands/db/apply/helpers/pg-schema-diff-patterns.d.ts +55 -0
  88. package/dist/commands/db/apply/helpers/pg-schema-diff-version.d.ts +50 -0
  89. package/dist/commands/db/apply/helpers/plan-validator.d.ts +4 -10
  90. package/dist/commands/db/apply/helpers/rbac-password-manager.d.ts +34 -0
  91. package/dist/commands/db/apply/helpers/retry-logic.d.ts +16 -2
  92. package/dist/commands/db/apply/helpers/shadow-db-manager.d.ts +1 -1
  93. package/dist/commands/db/apply/helpers/sql-utils.d.ts +26 -0
  94. package/dist/commands/db/apply/machine.d.ts +52 -1
  95. package/dist/commands/db/commands/db-apply.d.ts +18 -0
  96. package/dist/commands/db/commands/db-sync/boundary-classifier.d.ts +21 -0
  97. package/dist/commands/db/commands/db-sync/error-classifier.d.ts +9 -0
  98. package/dist/commands/db/commands/db-sync/plan-hazard-analyzer.d.ts +13 -0
  99. package/dist/commands/db/commands/db-sync/risk-reporter.d.ts +19 -0
  100. package/dist/commands/db/commands/db-sync/sql-parser.d.ts +25 -0
  101. package/dist/commands/db/commands/db-sync/types.d.ts +47 -0
  102. package/dist/commands/db/commands/db-sync.d.ts +14 -0
  103. package/dist/commands/db/sync/contract.d.ts +6 -2
  104. package/dist/commands/db/sync/machine.d.ts +2 -1
  105. package/dist/commands/db/types.d.ts +2 -0
  106. package/dist/commands/db/utils/boundary-policy/rule-compiler.d.ts +11 -0
  107. package/dist/commands/db/utils/boundary-policy/types.d.ts +105 -0
  108. package/dist/commands/db/utils/boundary-policy/validation.d.ts +20 -0
  109. package/dist/commands/db/utils/boundary-policy-runtime.d.ts +28 -0
  110. package/dist/commands/db/utils/boundary-policy.d.ts +5 -0
  111. package/dist/commands/db/utils/idempotent-risk-context.d.ts +29 -0
  112. package/dist/commands/db/utils/preflight-check.d.ts +14 -0
  113. package/dist/commands/db/utils/preflight-checks/domain-naming-checks.d.ts +106 -0
  114. package/dist/commands/db/utils/preflight-checks/orphan-checks.d.ts +36 -0
  115. package/dist/commands/db/utils/preflight-checks/schema-risk-checks.d.ts +22 -0
  116. package/dist/commands/db/utils/preflight-checks/supabase-checks.d.ts +55 -0
  117. package/dist/commands/db/utils/risk-detector-loader.d.ts +8 -0
  118. package/dist/commands/db/utils/schema-precheck-budget.d.ts +17 -0
  119. package/dist/commands/db/utils/sql-boundary-parser.d.ts +12 -0
  120. package/dist/commands/db/utils/sql-file-collector.d.ts +8 -0
  121. package/dist/commands/db/utils/sql-filename-parser.d.ts +20 -0
  122. package/dist/commands/db/utils/sql-table-extractor-ast.d.ts +19 -0
  123. package/dist/commands/db/utils/sql-table-extractor-regex.d.ts +50 -0
  124. package/dist/commands/db/utils/sql-table-extractor-rls.d.ts +13 -0
  125. package/dist/commands/db/utils/sql-table-extractor.d.ts +79 -1
  126. package/dist/commands/db/utils/table-registry-introspection.d.ts +68 -0
  127. package/dist/commands/db/utils/table-registry.d.ts +3 -38
  128. package/dist/commands/dev/actors/app-lifecycle.d.ts +18 -0
  129. package/dist/commands/dev/actors/index.d.ts +12 -2
  130. package/dist/commands/dev/actors/process-check.d.ts +12 -0
  131. package/dist/commands/dev/actors/shared.d.ts +15 -0
  132. package/dist/commands/dev/actors/tables-manifest.d.ts +16 -0
  133. package/dist/commands/dev/contract.d.ts +3 -3
  134. package/dist/commands/dev/guards.d.ts +24 -0
  135. package/dist/commands/dev/machine.d.ts +27 -32
  136. package/dist/commands/dev/types.d.ts +2 -0
  137. package/dist/commands/doctor.d.ts +9 -0
  138. package/dist/commands/env/commands/env-pull/auth.d.ts +13 -0
  139. package/dist/commands/env/commands/env-pull/dotenv-files.d.ts +14 -0
  140. package/dist/commands/env/commands/env-pull/security.d.ts +12 -0
  141. package/dist/commands/env/commands/env-pull/service.d.ts +8 -0
  142. package/dist/commands/env/commands/env-pull/shared.d.ts +79 -0
  143. package/dist/commands/env/commands/setup/types.d.ts +1 -1
  144. package/dist/commands/env/constants/local-supabase.d.ts +2 -0
  145. package/dist/commands/inject-test-attrs/defaults.d.ts +9 -0
  146. package/dist/commands/template-check/contract.d.ts +6 -6
  147. package/dist/commands/template-check/machine.d.ts +2 -2
  148. package/dist/commands/template-check/types.d.ts +0 -4
  149. package/dist/commands/template-check/utils/diff-analyzer.d.ts +0 -4
  150. package/dist/commands/utils/machine-state-logging.d.ts +20 -0
  151. package/dist/commands/utils/repo-root.d.ts +2 -0
  152. package/dist/config/env.d.ts +4 -4
  153. package/dist/config-loader-GT3HAQ7U.js +7 -0
  154. package/dist/db-XULCILOU.js +14137 -0
  155. package/dist/dev-5YXNPTCJ.js +992 -0
  156. package/dist/doctor-MZLOA53G.js +44 -0
  157. package/dist/env-HMMRSYCI.js +7 -0
  158. package/dist/env-SS66PZ4B.js +2623 -0
  159. package/dist/env-files-2UIUYLLR.js +8 -0
  160. package/dist/error-handler-HEXBRNVV.js +460 -0
  161. package/dist/hotfix-YA3DGLOM.js +1477 -0
  162. package/dist/index.d.ts +5 -1
  163. package/dist/index.js +48 -42995
  164. package/dist/init-ZIL6LRFO.js +631 -0
  165. package/dist/inject-test-attrs-P44BVTQS.js +23 -0
  166. package/dist/internal/machines/snapshot-helpers.d.ts +6 -0
  167. package/dist/lib/sql-comment-utils.d.ts +25 -0
  168. package/dist/license-OB7GVJQ2.js +468 -0
  169. package/dist/link-VSNDVZZD.js +59 -0
  170. package/dist/manifest-TMFLESHW.js +19 -0
  171. package/dist/prepare-32DOVHTE.js +250 -0
  172. package/dist/risk-detector-4U6ZJ2G5.js +6 -0
  173. package/dist/risk-detector-core-TK4OAI3N.js +166 -0
  174. package/dist/risk-detector-plpgsql-HWKS4OLR.js +1886 -0
  175. package/dist/sdk-XK6HQU7S.js +348 -0
  176. package/dist/services-7VK5KZTO.js +177 -0
  177. package/dist/session-SFW5QSXZ.js +142 -0
  178. package/dist/signal-handler-DO3OANW5.js +6 -0
  179. package/dist/status-UTKS63AB.js +94 -0
  180. package/dist/telemetry-P56UBLZ2.js +93 -0
  181. package/dist/template-check-3P4HZXVY.js +1944 -0
  182. package/dist/test-V4KQL574.js +650 -0
  183. package/dist/test-gen-FS4CEY3P.js +88 -0
  184. package/dist/ui-RJAMCWUI.js +331 -0
  185. package/dist/upgrade-NUK3ZBCL.js +637 -0
  186. package/dist/utils/config-loader.d.ts +0 -3
  187. package/dist/validate-CAAW4Y44.js +54 -0
  188. package/dist/validators/risk-detector-content-risks.d.ts +13 -0
  189. package/dist/validators/risk-detector-core.d.ts +25 -0
  190. package/dist/validators/risk-detector-patterns.d.ts +15 -0
  191. package/dist/validators/risk-detector-plpgsql-expression-resolver.d.ts +22 -0
  192. package/dist/validators/risk-detector-plpgsql-parser.d.ts +5 -0
  193. package/dist/validators/risk-detector-plpgsql-tokenizer.d.ts +18 -0
  194. package/dist/validators/risk-detector-plpgsql.d.ts +9 -0
  195. package/dist/validators/risk-detector-text-utils.d.ts +6 -0
  196. package/dist/validators/risk-detector-types.d.ts +16 -0
  197. package/dist/validators/risk-detector.d.ts +7 -26
  198. package/dist/vuln-check-2W7N5TA2.js +121 -0
  199. package/dist/vuln-checker-IQJ56RUV.js +3223 -0
  200. package/dist/watch-PNTKZYFB.js +911 -0
  201. package/dist/workflow-H75N4BXX.js +897 -0
  202. package/package.json +5 -2
  203. package/dist/cli/contract-mode.d.ts.map +0 -1
  204. package/dist/cli/contract-output.d.ts.map +0 -1
  205. package/dist/cli/early-flags.d.ts.map +0 -1
  206. package/dist/cli/error-handler.d.ts.map +0 -1
  207. package/dist/cli/exec.d.ts.map +0 -1
  208. package/dist/cli/index.d.ts.map +0 -1
  209. package/dist/cli/json-output.d.ts.map +0 -1
  210. package/dist/cli/non-interactive.d.ts.map +0 -1
  211. package/dist/cli/output-format.d.ts.map +0 -1
  212. package/dist/cli/signal-handler.d.ts.map +0 -1
  213. package/dist/commands/build/actors/build.d.ts.map +0 -1
  214. package/dist/commands/build/actors/clean.d.ts.map +0 -1
  215. package/dist/commands/build/actors/db-sync.d.ts.map +0 -1
  216. package/dist/commands/build/actors/index.d.ts.map +0 -1
  217. package/dist/commands/build/actors/manifest.d.ts.map +0 -1
  218. package/dist/commands/build/actors/setup.d.ts.map +0 -1
  219. package/dist/commands/build/actors/static-checks.d.ts.map +0 -1
  220. package/dist/commands/build/actors/validate.d.ts.map +0 -1
  221. package/dist/commands/build/commands/build.d.ts.map +0 -1
  222. package/dist/commands/build/contract.d.ts.map +0 -1
  223. package/dist/commands/build/guards.d.ts.map +0 -1
  224. package/dist/commands/build/index.d.ts.map +0 -1
  225. package/dist/commands/build/machine.d.ts.map +0 -1
  226. package/dist/commands/build/types.d.ts.map +0 -1
  227. package/dist/commands/cache.d.ts.map +0 -1
  228. package/dist/commands/check/commands/check.d.ts.map +0 -1
  229. package/dist/commands/check/index.d.ts.map +0 -1
  230. package/dist/commands/ci/commands/ci-checks.d.ts.map +0 -1
  231. package/dist/commands/ci/commands/ci-layer-content.d.ts.map +0 -1
  232. package/dist/commands/ci/commands/ci-pr-capabilities.d.ts.map +0 -1
  233. package/dist/commands/ci/commands/ci-prod-apply.d.ts.map +0 -1
  234. package/dist/commands/ci/commands/ci-prod-db-operations.d.ts.map +0 -1
  235. package/dist/commands/ci/commands/ci-prod-github.d.ts.map +0 -1
  236. package/dist/commands/ci/commands/ci-prod-types.d.ts.map +0 -1
  237. package/dist/commands/ci/commands/ci-prod-utils.d.ts.map +0 -1
  238. package/dist/commands/ci/commands/ci-prod-workflow.d.ts.map +0 -1
  239. package/dist/commands/ci/commands/ci-resolvers.d.ts.map +0 -1
  240. package/dist/commands/ci/commands/ci-static.d.ts.map +0 -1
  241. package/dist/commands/ci/commands/ci-supabase-local.d.ts.map +0 -1
  242. package/dist/commands/ci/index.d.ts.map +0 -1
  243. package/dist/commands/ci/machine/actors/build/app-build.d.ts.map +0 -1
  244. package/dist/commands/ci/machine/actors/build/app-start.d.ts.map +0 -1
  245. package/dist/commands/ci/machine/actors/build/build-and-playwright.d.ts.map +0 -1
  246. package/dist/commands/ci/machine/actors/build/index.d.ts.map +0 -1
  247. package/dist/commands/ci/machine/actors/build/playwright-install.d.ts.map +0 -1
  248. package/dist/commands/ci/machine/actors/build/static-checks.d.ts.map +0 -1
  249. package/dist/commands/ci/machine/actors/db/apply-seeds.d.ts.map +0 -1
  250. package/dist/commands/ci/machine/actors/db/collect-schema-stats.d.ts.map +0 -1
  251. package/dist/commands/ci/machine/actors/db/index.d.ts.map +0 -1
  252. package/dist/commands/ci/machine/actors/db/pgtap-install.d.ts.map +0 -1
  253. package/dist/commands/ci/machine/actors/db/production-preview.d.ts.map +0 -1
  254. package/dist/commands/ci/machine/actors/db/pull-production.d.ts.map +0 -1
  255. package/dist/commands/ci/machine/actors/db/reset.d.ts.map +0 -1
  256. package/dist/commands/ci/machine/actors/db/schema-stats.d.ts.map +0 -1
  257. package/dist/commands/ci/machine/actors/db/setup-roles.d.ts.map +0 -1
  258. package/dist/commands/ci/machine/actors/db/sync-schema.d.ts.map +0 -1
  259. package/dist/commands/ci/machine/actors/finalize/github.d.ts.map +0 -1
  260. package/dist/commands/ci/machine/actors/finalize/index.d.ts.map +0 -1
  261. package/dist/commands/ci/machine/actors/finalize/summary.d.ts.map +0 -1
  262. package/dist/commands/ci/machine/actors/index.d.ts.map +0 -1
  263. package/dist/commands/ci/machine/actors/setup/index.d.ts.map +0 -1
  264. package/dist/commands/ci/machine/actors/setup/local.d.ts.map +0 -1
  265. package/dist/commands/ci/machine/actors/setup/pr-common.d.ts.map +0 -1
  266. package/dist/commands/ci/machine/actors/setup/pr-local.d.ts.map +0 -1
  267. package/dist/commands/ci/machine/actors/test/capabilities.d.ts.map +0 -1
  268. package/dist/commands/ci/machine/actors/test/index.d.ts.map +0 -1
  269. package/dist/commands/ci/machine/actors/test/run-layers.d.ts.map +0 -1
  270. package/dist/commands/ci/machine/commands/ci-local.d.ts.map +0 -1
  271. package/dist/commands/ci/machine/commands/ci-pr.d.ts.map +0 -1
  272. package/dist/commands/ci/machine/commands/index.d.ts.map +0 -1
  273. package/dist/commands/ci/machine/commands/machine-runner.d.ts.map +0 -1
  274. package/dist/commands/ci/machine/commands/runtime-env.d.ts.map +0 -1
  275. package/dist/commands/ci/machine/contract.d.ts.map +0 -1
  276. package/dist/commands/ci/machine/formatters/github-comment-types.d.ts.map +0 -1
  277. package/dist/commands/ci/machine/formatters/github-comment.d.ts.map +0 -1
  278. package/dist/commands/ci/machine/formatters/index.d.ts.map +0 -1
  279. package/dist/commands/ci/machine/formatters/sections/final-comment.d.ts.map +0 -1
  280. package/dist/commands/ci/machine/formatters/sections/format-helpers.d.ts.map +0 -1
  281. package/dist/commands/ci/machine/formatters/sections/index.d.ts.map +0 -1
  282. package/dist/commands/ci/machine/formatters/sections/progress-comment.d.ts.map +0 -1
  283. package/dist/commands/ci/machine/formatters/sections/schema-matrix.d.ts.map +0 -1
  284. package/dist/commands/ci/machine/formatters/summary.d.ts.map +0 -1
  285. package/dist/commands/ci/machine/guards.d.ts.map +0 -1
  286. package/dist/commands/ci/machine/helpers.d.ts.map +0 -1
  287. package/dist/commands/ci/machine/index.d.ts.map +0 -1
  288. package/dist/commands/ci/machine/machine.d.ts.map +0 -1
  289. package/dist/commands/ci/machine/types.d.ts.map +0 -1
  290. package/dist/commands/ci/utils/ai-report.d.ts.map +0 -1
  291. package/dist/commands/ci/utils/app-process.d.ts.map +0 -1
  292. package/dist/commands/ci/utils/app-runtime.d.ts.map +0 -1
  293. package/dist/commands/ci/utils/ci-config.d.ts.map +0 -1
  294. package/dist/commands/ci/utils/ci-env-schema.d.ts.map +0 -1
  295. package/dist/commands/ci/utils/ci-logging.d.ts.map +0 -1
  296. package/dist/commands/ci/utils/ci-summary.d.ts.map +0 -1
  297. package/dist/commands/ci/utils/config-readers.d.ts.map +0 -1
  298. package/dist/commands/ci/utils/db-url-utils.d.ts.map +0 -1
  299. package/dist/commands/ci/utils/e2e-auth-setup.d.ts.map +0 -1
  300. package/dist/commands/ci/utils/env-security.d.ts.map +0 -1
  301. package/dist/commands/ci/utils/execa-helpers.d.ts.map +0 -1
  302. package/dist/commands/ci/utils/exit-code-computation.d.ts.map +0 -1
  303. package/dist/commands/ci/utils/github-api.d.ts.map +0 -1
  304. package/dist/commands/ci/utils/github.d.ts.map +0 -1
  305. package/dist/commands/ci/utils/index.d.ts.map +0 -1
  306. package/dist/commands/ci/utils/pgtap-installer.d.ts.map +0 -1
  307. package/dist/commands/ci/utils/rls-verification.d.ts.map +0 -1
  308. package/dist/commands/ci/utils/schema-operations.d.ts.map +0 -1
  309. package/dist/commands/ci/utils/seed-operations.d.ts.map +0 -1
  310. package/dist/commands/ci/utils/test-parallel.d.ts.map +0 -1
  311. package/dist/commands/ci/utils/timestamp-invariants.d.ts.map +0 -1
  312. package/dist/commands/ci/utils/workflow-idempotency.d.ts.map +0 -1
  313. package/dist/commands/db/apply/actors.d.ts.map +0 -1
  314. package/dist/commands/db/apply/contract.d.ts.map +0 -1
  315. package/dist/commands/db/apply/helpers/advisory-lock.d.ts.map +0 -1
  316. package/dist/commands/db/apply/helpers/data-compatibility-checker.d.ts.map +0 -1
  317. package/dist/commands/db/apply/helpers/index.d.ts.map +0 -1
  318. package/dist/commands/db/apply/helpers/partition-acl-cleaner.d.ts.map +0 -1
  319. package/dist/commands/db/apply/helpers/partition-prefilter.d.ts.map +0 -1
  320. package/dist/commands/db/apply/helpers/partition-validator.d.ts.map +0 -1
  321. package/dist/commands/db/apply/helpers/pg-schema-diff-helpers.d.ts.map +0 -1
  322. package/dist/commands/db/apply/helpers/plan-validator.d.ts.map +0 -1
  323. package/dist/commands/db/apply/helpers/retry-logic.d.ts.map +0 -1
  324. package/dist/commands/db/apply/helpers/shadow-db-manager.d.ts.map +0 -1
  325. package/dist/commands/db/apply/index.d.ts.map +0 -1
  326. package/dist/commands/db/apply/machine.d.ts.map +0 -1
  327. package/dist/commands/db/commands/db-apply.d.ts.map +0 -1
  328. package/dist/commands/db/commands/db-audit.d.ts.map +0 -1
  329. package/dist/commands/db/commands/db-backup.d.ts.map +0 -1
  330. package/dist/commands/db/commands/db-cleanup.d.ts.map +0 -1
  331. package/dist/commands/db/commands/db-derive-role-passwords.d.ts.map +0 -1
  332. package/dist/commands/db/commands/db-derive-urls.d.ts.map +0 -1
  333. package/dist/commands/db/commands/db-diagram.d.ts.map +0 -1
  334. package/dist/commands/db/commands/db-drizzle.d.ts.map +0 -1
  335. package/dist/commands/db/commands/db-extension.d.ts.map +0 -1
  336. package/dist/commands/db/commands/db-generate-password.d.ts.map +0 -1
  337. package/dist/commands/db/commands/db-lifecycle.d.ts.map +0 -1
  338. package/dist/commands/db/commands/db-rollback.d.ts.map +0 -1
  339. package/dist/commands/db/commands/db-schema.d.ts.map +0 -1
  340. package/dist/commands/db/commands/db-seed-metadata.d.ts.map +0 -1
  341. package/dist/commands/db/commands/db-seed-verify.d.ts.map +0 -1
  342. package/dist/commands/db/commands/db-seed.d.ts.map +0 -1
  343. package/dist/commands/db/commands/db-snapshot.d.ts.map +0 -1
  344. package/dist/commands/db/commands/db-stack.d.ts.map +0 -1
  345. package/dist/commands/db/commands/db-stats.d.ts.map +0 -1
  346. package/dist/commands/db/commands/db-sync.d.ts.map +0 -1
  347. package/dist/commands/db/commands/db-test.d.ts.map +0 -1
  348. package/dist/commands/db/constants.d.ts.map +0 -1
  349. package/dist/commands/db/extension-registry.d.ts.map +0 -1
  350. package/dist/commands/db/index.d.ts.map +0 -1
  351. package/dist/commands/db/preflight/actors.d.ts.map +0 -1
  352. package/dist/commands/db/preflight/contract.d.ts.map +0 -1
  353. package/dist/commands/db/preflight/index.d.ts.map +0 -1
  354. package/dist/commands/db/sync/actors.d.ts.map +0 -1
  355. package/dist/commands/db/sync/contract.d.ts.map +0 -1
  356. package/dist/commands/db/sync/index.d.ts.map +0 -1
  357. package/dist/commands/db/sync/machine.d.ts.map +0 -1
  358. package/dist/commands/db/types.d.ts.map +0 -1
  359. package/dist/commands/db/utils/db-target.d.ts.map +0 -1
  360. package/dist/commands/db/utils/db-url-builder.d.ts.map +0 -1
  361. package/dist/commands/db/utils/error-handlers.d.ts.map +0 -1
  362. package/dist/commands/db/utils/import-impact-analyzer.d.ts.map +0 -1
  363. package/dist/commands/db/utils/preflight-check.d.ts.map +0 -1
  364. package/dist/commands/db/utils/psql.d.ts.map +0 -1
  365. package/dist/commands/db/utils/schema-detector.d.ts.map +0 -1
  366. package/dist/commands/db/utils/schema-sync.d.ts.map +0 -1
  367. package/dist/commands/db/utils/script-runner.d.ts.map +0 -1
  368. package/dist/commands/db/utils/seed-manager.d.ts.map +0 -1
  369. package/dist/commands/db/utils/semantic-mapper.d.ts.map +0 -1
  370. package/dist/commands/db/utils/sql-table-extractor.d.ts.map +0 -1
  371. package/dist/commands/db/utils/stack-detector.d.ts.map +0 -1
  372. package/dist/commands/db/utils/table-registry.d.ts.map +0 -1
  373. package/dist/commands/db/utils/table-source-classifier.d.ts.map +0 -1
  374. package/dist/commands/dev/actors/index.d.ts.map +0 -1
  375. package/dist/commands/dev/commands/dev.d.ts.map +0 -1
  376. package/dist/commands/dev/contract.d.ts.map +0 -1
  377. package/dist/commands/dev/guards.d.ts.map +0 -1
  378. package/dist/commands/dev/helpers/stale-process-detector.d.ts.map +0 -1
  379. package/dist/commands/dev/machine.d.ts.map +0 -1
  380. package/dist/commands/dev/types.d.ts.map +0 -1
  381. package/dist/commands/env/commands/env-check.d.ts.map +0 -1
  382. package/dist/commands/env/commands/env-encrypt.d.ts.map +0 -1
  383. package/dist/commands/env/commands/env-pull.d.ts.map +0 -1
  384. package/dist/commands/env/commands/env-setup.d.ts.map +0 -1
  385. package/dist/commands/env/commands/env-sync.d.ts.map +0 -1
  386. package/dist/commands/env/commands/setup/action.d.ts.map +0 -1
  387. package/dist/commands/env/commands/setup/auth.d.ts.map +0 -1
  388. package/dist/commands/env/commands/setup/file-export.d.ts.map +0 -1
  389. package/dist/commands/env/commands/setup/github-api.d.ts.map +0 -1
  390. package/dist/commands/env/commands/setup/helpers.d.ts.map +0 -1
  391. package/dist/commands/env/commands/setup/index.d.ts.map +0 -1
  392. package/dist/commands/env/commands/setup/parsers.d.ts.map +0 -1
  393. package/dist/commands/env/commands/setup/prompts.d.ts.map +0 -1
  394. package/dist/commands/env/commands/setup/supabase-api.d.ts.map +0 -1
  395. package/dist/commands/env/commands/setup/types.d.ts.map +0 -1
  396. package/dist/commands/env/commands/setup/vercel-api.d.ts.map +0 -1
  397. package/dist/commands/env/constants/local-supabase.d.ts.map +0 -1
  398. package/dist/commands/env/index.d.ts.map +0 -1
  399. package/dist/commands/hotfix/actors.d.ts.map +0 -1
  400. package/dist/commands/hotfix/commands/hotfix-complete.d.ts.map +0 -1
  401. package/dist/commands/hotfix/commands/hotfix-create.d.ts.map +0 -1
  402. package/dist/commands/hotfix/commands/hotfix-deploy.d.ts.map +0 -1
  403. package/dist/commands/hotfix/commands/hotfix-status.d.ts.map +0 -1
  404. package/dist/commands/hotfix/contract.d.ts.map +0 -1
  405. package/dist/commands/hotfix/index.d.ts.map +0 -1
  406. package/dist/commands/hotfix/machine.d.ts.map +0 -1
  407. package/dist/commands/hotfix/metadata.d.ts.map +0 -1
  408. package/dist/commands/hotfix/utils/hotfix-machine-helper.d.ts.map +0 -1
  409. package/dist/commands/init.d.ts.map +0 -1
  410. package/dist/commands/inject-test-attrs/action.d.ts.map +0 -1
  411. package/dist/commands/inject-test-attrs/commands/inject-test-attrs.d.ts.map +0 -1
  412. package/dist/commands/inject-test-attrs/contract.d.ts.map +0 -1
  413. package/dist/commands/inject-test-attrs/detection-diagnostics.d.ts.map +0 -1
  414. package/dist/commands/inject-test-attrs/formatter.d.ts.map +0 -1
  415. package/dist/commands/inject-test-attrs/index.d.ts.map +0 -1
  416. package/dist/commands/inject-test-attrs/manifest-generator.d.ts.map +0 -1
  417. package/dist/commands/inject-test-attrs/processor-utils.d.ts.map +0 -1
  418. package/dist/commands/inject-test-attrs/processor.d.ts.map +0 -1
  419. package/dist/commands/inject-test-attrs/types.d.ts.map +0 -1
  420. package/dist/commands/link.d.ts.map +0 -1
  421. package/dist/commands/manifest/index.d.ts.map +0 -1
  422. package/dist/commands/prepare/commands/prepare.d.ts.map +0 -1
  423. package/dist/commands/prepare/index.d.ts.map +0 -1
  424. package/dist/commands/sdk/commands/publish.d.ts.map +0 -1
  425. package/dist/commands/sdk/index.d.ts.map +0 -1
  426. package/dist/commands/services/index.d.ts.map +0 -1
  427. package/dist/commands/session/index.d.ts.map +0 -1
  428. package/dist/commands/status.d.ts.map +0 -1
  429. package/dist/commands/telemetry.d.ts.map +0 -1
  430. package/dist/commands/template-check/actors/compare.d.ts.map +0 -1
  431. package/dist/commands/template-check/actors/discover.d.ts.map +0 -1
  432. package/dist/commands/template-check/actors/index.d.ts.map +0 -1
  433. package/dist/commands/template-check/actors/report.d.ts.map +0 -1
  434. package/dist/commands/template-check/commands/template-check.d.ts.map +0 -1
  435. package/dist/commands/template-check/config.d.ts.map +0 -1
  436. package/dist/commands/template-check/contract.d.ts.map +0 -1
  437. package/dist/commands/template-check/index.d.ts.map +0 -1
  438. package/dist/commands/template-check/machine.d.ts.map +0 -1
  439. package/dist/commands/template-check/types.d.ts.map +0 -1
  440. package/dist/commands/template-check/utils/diff-analyzer.d.ts.map +0 -1
  441. package/dist/commands/template-check/utils/normalizer.d.ts.map +0 -1
  442. package/dist/commands/template-check/utils/path-mapping.d.ts.map +0 -1
  443. package/dist/commands/test/commands/test-db.d.ts.map +0 -1
  444. package/dist/commands/test/commands/test-e2e.d.ts.map +0 -1
  445. package/dist/commands/test/commands/test-fast.d.ts.map +0 -1
  446. package/dist/commands/test/commands/test-integration.d.ts.map +0 -1
  447. package/dist/commands/test/commands/test-layer.d.ts.map +0 -1
  448. package/dist/commands/test/commands/test-owasp-generate.d.ts.map +0 -1
  449. package/dist/commands/test/commands/test-service.d.ts.map +0 -1
  450. package/dist/commands/test/commands/test-static.d.ts.map +0 -1
  451. package/dist/commands/test/commands/test.d.ts.map +0 -1
  452. package/dist/commands/test/index.d.ts.map +0 -1
  453. package/dist/commands/test-gen.d.ts.map +0 -1
  454. package/dist/commands/ui.d.ts.map +0 -1
  455. package/dist/commands/upgrade.d.ts.map +0 -1
  456. package/dist/commands/validate.d.ts.map +0 -1
  457. package/dist/commands/vuln-check.d.ts.map +0 -1
  458. package/dist/commands/watch.d.ts.map +0 -1
  459. package/dist/commands/workflow/commands/deploy-production.d.ts.map +0 -1
  460. package/dist/commands/workflow/commands/final-status.d.ts.map +0 -1
  461. package/dist/commands/workflow/commands/log.d.ts.map +0 -1
  462. package/dist/commands/workflow/commands/notify.d.ts.map +0 -1
  463. package/dist/commands/workflow/commands/paths.d.ts.map +0 -1
  464. package/dist/commands/workflow/commands/sync.d.ts.map +0 -1
  465. package/dist/commands/workflow/commands/validate.d.ts.map +0 -1
  466. package/dist/commands/workflow/commands/verify-credentials.d.ts.map +0 -1
  467. package/dist/commands/workflow/index.d.ts.map +0 -1
  468. package/dist/commands/workflow/types.d.ts.map +0 -1
  469. package/dist/config/env-files.d.ts.map +0 -1
  470. package/dist/config/env.d.ts.map +0 -1
  471. package/dist/constants/versions.d.ts.map +0 -1
  472. package/dist/contracts/envelope.d.ts.map +0 -1
  473. package/dist/errors/catalog.d.ts.map +0 -1
  474. package/dist/errors/exit-codes.d.ts.map +0 -1
  475. package/dist/errors/index.d.ts.map +0 -1
  476. package/dist/incremental/affected-tests.d.ts.map +0 -1
  477. package/dist/index.d.ts.map +0 -1
  478. package/dist/internal/machines/index.d.ts.map +0 -1
  479. package/dist/internal/machines/machine-runner.d.ts.map +0 -1
  480. package/dist/internal/machines/snapshot-helpers.d.ts.map +0 -1
  481. package/dist/internal/machines/types.d.ts.map +0 -1
  482. package/dist/internal/vuln-checker/analyzers/dependency-analyzer.d.ts.map +0 -1
  483. package/dist/internal/vuln-checker/analyzers/rls-analyzer.d.ts.map +0 -1
  484. package/dist/internal/vuln-checker/analyzers/secret-analyzer.d.ts.map +0 -1
  485. package/dist/internal/vuln-checker/analyzers/typescript-analyzer.d.ts.map +0 -1
  486. package/dist/internal/vuln-checker/config/loader.d.ts.map +0 -1
  487. package/dist/internal/vuln-checker/constants.d.ts.map +0 -1
  488. package/dist/internal/vuln-checker/ignore/matcher.d.ts.map +0 -1
  489. package/dist/internal/vuln-checker/index.d.ts.map +0 -1
  490. package/dist/internal/vuln-checker/reporters/console-reporter.d.ts.map +0 -1
  491. package/dist/internal/vuln-checker/reporters/json-reporter.d.ts.map +0 -1
  492. package/dist/internal/vuln-checker/reporters/markdown-reporter.d.ts.map +0 -1
  493. package/dist/internal/vuln-checker/reporters/sarif-reporter.d.ts.map +0 -1
  494. package/dist/internal/vuln-checker/security/path-validation.d.ts.map +0 -1
  495. package/dist/internal/vuln-checker/types.d.ts.map +0 -1
  496. package/dist/notifiers/desktop-notifier.d.ts.map +0 -1
  497. package/dist/ui/components/db-panel.d.ts.map +0 -1
  498. package/dist/ui/components/status-bar.d.ts.map +0 -1
  499. package/dist/ui/components/test-panel.d.ts.map +0 -1
  500. package/dist/ui/dashboard.d.ts.map +0 -1
  501. package/dist/ui/index.d.ts.map +0 -1
  502. package/dist/utils/config-loader.d.ts.map +0 -1
  503. package/dist/utils/config-updater.d.ts.map +0 -1
  504. package/dist/utils/diagnostics.d.ts.map +0 -1
  505. package/dist/utils/dotenvx.d.ts.map +0 -1
  506. package/dist/utils/env-local-bridge.d.ts.map +0 -1
  507. package/dist/utils/execution-plan.d.ts.map +0 -1
  508. package/dist/utils/github-output-security.d.ts.map +0 -1
  509. package/dist/utils/help-system.d.ts.map +0 -1
  510. package/dist/utils/license/admin-auth.d.ts.map +0 -1
  511. package/dist/utils/license/allowlist-checker.d.ts.map +0 -1
  512. package/dist/utils/license/ci-detector.d.ts.map +0 -1
  513. package/dist/utils/license/index.d.ts.map +0 -1
  514. package/dist/utils/license/owner-resolver.d.ts.map +0 -1
  515. package/dist/utils/license/types.d.ts.map +0 -1
  516. package/dist/utils/license/validate-owner.d.ts.map +0 -1
  517. package/dist/utils/path-security.d.ts.map +0 -1
  518. package/dist/utils/port-allocator.d.ts.map +0 -1
  519. package/dist/utils/secure-exec.d.ts.map +0 -1
  520. package/dist/utils/template-fetcher.d.ts.map +0 -1
  521. package/dist/utils/type-guards.d.ts.map +0 -1
  522. package/dist/utils/vercel-project.d.ts.map +0 -1
  523. package/dist/utils/workspace-detector.d.ts.map +0 -1
  524. package/dist/validators/risk-detector.d.ts.map +0 -1
  525. package/dist/validators/schema-validator.d.ts.map +0 -1
  526. package/dist/version.d.ts.map +0 -1
  527. package/dist/watchers/schema-watcher.d.ts.map +0 -1
  528. package/dist/watchers/test-watcher.d.ts.map +0 -1
@@ -0,0 +1,1477 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from 'module';
3
+ import './chunk-ZZOXM6Q4.js';
4
+ import { createError } from './chunk-JQXOVCOP.js';
5
+ import { tryResolveDatabaseUrl } from './chunk-KWX3JHCY.js';
6
+ import './chunk-NPSRD26F.js';
7
+ import { loadEnvFiles } from './chunk-644FVGIQ.js';
8
+ import { isPathContained } from './chunk-DRSUEMAK.js';
9
+ import './chunk-II7VYQEM.js';
10
+ import './chunk-VM3IWOT5.js';
11
+ import './chunk-JMJP4A47.js';
12
+ import { init_esm_shims } from './chunk-VRXHCR5K.js';
13
+ import { Command } from 'commander';
14
+ import { CLIError, createCLILogger, createDbSnapshot } from '@runa-ai/runa';
15
+ import { execa } from 'execa';
16
+ import { fromPromise, setup, assign, createActor } from 'xstate';
17
+ import { existsSync } from 'fs';
18
+ import { writeFile, rm, readFile, mkdir, readdir } from 'fs/promises';
19
+ import path from 'path';
20
+ import { z } from 'zod';
21
+
22
+ createRequire(import.meta.url);
23
+
24
+ // src/commands/hotfix/index.ts
25
+ init_esm_shims();
26
+
27
+ // src/commands/hotfix/commands/hotfix-complete.ts
28
+ init_esm_shims();
29
+
30
+ // src/commands/hotfix/utils/hotfix-machine-helper.ts
31
+ init_esm_shims();
32
+
33
+ // src/commands/hotfix/machine.ts
34
+ init_esm_shims();
35
+
36
+ // src/commands/hotfix/actors.ts
37
+ init_esm_shims();
38
+
39
+ // src/commands/hotfix/metadata.ts
40
+ init_esm_shims();
41
+
42
+ // src/commands/hotfix/contract.ts
43
+ init_esm_shims();
44
+ var HotfixStatusSchema = z.enum(["in_progress", "deployed", "completed", "cancelled"]);
45
+ var HotfixMetadataSchema = z.object({
46
+ branch: z.string(),
47
+ base: z.string(),
48
+ snapshot: z.string().optional(),
49
+ createdAt: z.string(),
50
+ createdBy: z.string(),
51
+ status: HotfixStatusSchema,
52
+ deployedAt: z.string().optional(),
53
+ completedAt: z.string().optional()
54
+ }).strict();
55
+ z.object({
56
+ /** Hotfix name (will be prefixed with hotfix/) */
57
+ name: z.string().min(1, "Hotfix name is required"),
58
+ /** Base commit/tag to branch from */
59
+ base: z.string().optional(),
60
+ /** Skip pre-hotfix database snapshot */
61
+ skipSnapshot: z.boolean().default(false),
62
+ /** Target directory (defaults to cwd) */
63
+ targetDir: z.string().optional()
64
+ }).strict();
65
+ var CreateHotfixMetadataInputSchema = z.object({
66
+ /** Validated branch name (e.g., hotfix/fix-auth-bug) */
67
+ branch: z.string().min(1),
68
+ /** Base commit/tag to branch from */
69
+ base: z.string().min(1),
70
+ /** Skip pre-hotfix database snapshot */
71
+ skipSnapshot: z.boolean().optional(),
72
+ /** Target directory (defaults to cwd) */
73
+ targetDir: z.string().optional()
74
+ }).strict();
75
+ z.object({
76
+ /** Skip confirmation prompts */
77
+ autoApprove: z.boolean().default(false),
78
+ /** Skip type check and build */
79
+ skipChecks: z.boolean().default(false),
80
+ /** Preview without applying */
81
+ dryRun: z.boolean().default(false),
82
+ /** Target directory (defaults to cwd) */
83
+ targetDir: z.string().optional()
84
+ }).strict();
85
+ z.object({
86
+ /** Direct merge without PR (dangerous) */
87
+ noPr: z.boolean().default(false),
88
+ /** Skip confirmation prompts */
89
+ autoApprove: z.boolean().default(false),
90
+ /** Preview without applying */
91
+ dryRun: z.boolean().default(false),
92
+ /** Keep hotfix branch after merge */
93
+ deleteBranch: z.boolean().default(true),
94
+ /** Target directory (defaults to cwd) */
95
+ targetDir: z.string().optional()
96
+ }).strict();
97
+ var GetHotfixInputSchema = z.object({
98
+ targetDir: z.string().optional()
99
+ }).strict();
100
+ var UpdateHotfixInputSchema = z.object({
101
+ status: HotfixStatusSchema,
102
+ deployedAt: z.string().optional(),
103
+ completedAt: z.string().optional(),
104
+ targetDir: z.string().optional()
105
+ }).strict();
106
+ var ListArchivedHotfixesInputSchema = z.object({
107
+ limit: z.number().optional(),
108
+ targetDir: z.string().optional()
109
+ }).strict();
110
+ var ListArchivedHotfixesOutputSchema = z.object({
111
+ hotfixes: z.array(HotfixMetadataSchema)
112
+ }).strict();
113
+ z.object({
114
+ metadata: HotfixMetadataSchema,
115
+ snapshotFile: z.string().optional()
116
+ });
117
+ z.object({
118
+ deployedAt: z.string()
119
+ });
120
+ z.object({
121
+ prUrl: z.string(),
122
+ completedAt: z.string()
123
+ });
124
+ z.object({
125
+ targetDir: z.string().optional(),
126
+ existingMetadata: HotfixMetadataSchema.nullable().optional()
127
+ });
128
+ z.object({
129
+ success: z.boolean(),
130
+ exitCode: z.union([z.literal(0), z.literal(1), z.literal(2)]),
131
+ finalState: z.string(),
132
+ metadata: HotfixMetadataSchema.nullable(),
133
+ prUrl: z.string().optional(),
134
+ error: z.string().optional()
135
+ });
136
+
137
+ // src/commands/hotfix/metadata.ts
138
+ function getHotfixDir(targetDir) {
139
+ return path.join(targetDir, ".runa", "hotfix");
140
+ }
141
+ function getCurrentFile(targetDir) {
142
+ return path.join(getHotfixDir(targetDir), "current.json");
143
+ }
144
+ function getArchiveDir(targetDir) {
145
+ return path.join(getHotfixDir(targetDir), "archive");
146
+ }
147
+ async function ensureHotfixDir(targetDir) {
148
+ await mkdir(getHotfixDir(targetDir), { recursive: true });
149
+ }
150
+ async function ensureArchiveDir(targetDir) {
151
+ await mkdir(getArchiveDir(targetDir), { recursive: true });
152
+ }
153
+ async function getHotfixMetadata(input = {}) {
154
+ const parsed = GetHotfixInputSchema.parse(input);
155
+ const targetDir = parsed.targetDir ? path.resolve(parsed.targetDir) : process.cwd();
156
+ const currentFile = getCurrentFile(targetDir);
157
+ if (!existsSync(currentFile)) {
158
+ return null;
159
+ }
160
+ const content = await readFile(currentFile, "utf-8");
161
+ return HotfixMetadataSchema.parse(JSON.parse(content));
162
+ }
163
+ async function createHotfixMetadata(input) {
164
+ const parsed = CreateHotfixMetadataInputSchema.parse(input);
165
+ const targetDir = parsed.targetDir ? path.resolve(parsed.targetDir) : process.cwd();
166
+ await ensureHotfixDir(targetDir);
167
+ const metadata = {
168
+ branch: parsed.branch,
169
+ base: parsed.base,
170
+ snapshot: parsed.skipSnapshot ? void 0 : `snapshot-${Date.now()}`,
171
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
172
+ createdBy: process.env.USER || process.env.GITHUB_ACTOR || "unknown",
173
+ status: "in_progress"
174
+ };
175
+ const currentFile = getCurrentFile(targetDir);
176
+ await writeFile(currentFile, `${JSON.stringify(metadata, null, 2)}
177
+ `, "utf-8");
178
+ return metadata;
179
+ }
180
+ async function updateHotfixStatus(input) {
181
+ const parsed = UpdateHotfixInputSchema.parse(input);
182
+ const targetDir = parsed.targetDir ? path.resolve(parsed.targetDir) : process.cwd();
183
+ const current = await getHotfixMetadata({ targetDir });
184
+ if (!current) {
185
+ throw createError("HOTFIX_NOT_FOUND");
186
+ }
187
+ const updated = {
188
+ ...current,
189
+ status: parsed.status,
190
+ deployedAt: parsed.deployedAt || current.deployedAt,
191
+ completedAt: parsed.completedAt || current.completedAt
192
+ };
193
+ const currentFile = getCurrentFile(targetDir);
194
+ await writeFile(currentFile, `${JSON.stringify(updated, null, 2)}
195
+ `, "utf-8");
196
+ return updated;
197
+ }
198
+ async function archiveHotfix(targetDir) {
199
+ const dir = targetDir ? path.resolve(targetDir) : process.cwd();
200
+ const current = await getHotfixMetadata({ targetDir: dir });
201
+ if (!current) {
202
+ throw createError("HOTFIX_NOT_FOUND");
203
+ }
204
+ await ensureArchiveDir(dir);
205
+ const archiveFile = path.join(
206
+ getArchiveDir(dir),
207
+ `${current.branch.replace(/\//g, "-")}-${Date.now()}.json`
208
+ );
209
+ const archived = {
210
+ ...current,
211
+ status: current.status === "in_progress" ? "completed" : current.status,
212
+ completedAt: current.completedAt || (/* @__PURE__ */ new Date()).toISOString()
213
+ };
214
+ await writeFile(archiveFile, `${JSON.stringify(archived, null, 2)}
215
+ `, "utf-8");
216
+ const currentFile = getCurrentFile(dir);
217
+ await rm(currentFile, { force: true });
218
+ return archived;
219
+ }
220
+ async function cancelHotfix(targetDir) {
221
+ const dir = targetDir ? path.resolve(targetDir) : process.cwd();
222
+ await updateHotfixStatus({
223
+ status: "cancelled",
224
+ completedAt: (/* @__PURE__ */ new Date()).toISOString(),
225
+ targetDir: dir
226
+ });
227
+ return archiveHotfix(dir);
228
+ }
229
+ async function listArchivedHotfixes(input = {}) {
230
+ const parsed = ListArchivedHotfixesInputSchema.parse(input);
231
+ const targetDir = parsed.targetDir ? path.resolve(parsed.targetDir) : process.cwd();
232
+ const archiveDir = getArchiveDir(targetDir);
233
+ if (!existsSync(archiveDir)) {
234
+ return { hotfixes: [] };
235
+ }
236
+ const files = await readdir(archiveDir);
237
+ const hotfixes = [];
238
+ for (const file of files.filter((f) => f.endsWith(".json"))) {
239
+ try {
240
+ const filePath = path.join(archiveDir, file);
241
+ if (!isPathContained(archiveDir, filePath)) {
242
+ continue;
243
+ }
244
+ const content = await readFile(filePath, "utf-8");
245
+ hotfixes.push(HotfixMetadataSchema.parse(JSON.parse(content)));
246
+ } catch {
247
+ }
248
+ }
249
+ hotfixes.sort((a, b) => {
250
+ const dateA = new Date(a.completedAt || a.createdAt);
251
+ const dateB = new Date(b.completedAt || b.createdAt);
252
+ return dateB.getTime() - dateA.getTime();
253
+ });
254
+ const limited = parsed.limit ? hotfixes.slice(0, parsed.limit) : hotfixes;
255
+ return ListArchivedHotfixesOutputSchema.parse({ hotfixes: limited });
256
+ }
257
+ function validateHotfixName(name) {
258
+ const sanitized = name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
259
+ if (!sanitized) {
260
+ throw createError("HOTFIX_INVALID_NAME", { name });
261
+ }
262
+ return `hotfix/${sanitized}`;
263
+ }
264
+
265
+ // src/commands/hotfix/actors.ts
266
+ var createHotfix = fromPromise(
267
+ async ({ input }) => {
268
+ const branchName = validateHotfixName(input.name);
269
+ const metadata = await createHotfixMetadata({
270
+ branch: branchName,
271
+ base: input.base || "origin/main",
272
+ targetDir: input.targetDir
273
+ });
274
+ return { metadata };
275
+ }
276
+ );
277
+ var deployHotfix = fromPromise(
278
+ async ({ input }) => {
279
+ const deployedAt = (/* @__PURE__ */ new Date()).toISOString();
280
+ await updateHotfixStatus({
281
+ status: "deployed",
282
+ deployedAt,
283
+ targetDir: input.targetDir
284
+ });
285
+ return { deployedAt };
286
+ }
287
+ );
288
+ var completeHotfix = fromPromise(
289
+ async ({ input }) => {
290
+ const completedAt = (/* @__PURE__ */ new Date()).toISOString();
291
+ await archiveHotfix(input.targetDir);
292
+ return { prUrl: "", completedAt };
293
+ }
294
+ );
295
+ var cancelHotfix2 = fromPromise(
296
+ async ({ input }) => {
297
+ await cancelHotfix(input.targetDir);
298
+ }
299
+ );
300
+ var loadMetadata = fromPromise(
301
+ async ({ input }) => {
302
+ return getHotfixMetadata({ targetDir: input.targetDir });
303
+ }
304
+ );
305
+
306
+ // src/commands/hotfix/machine.ts
307
+ var e2eMeta = {
308
+ loading: {
309
+ description: "Load existing hotfix metadata to determine current state",
310
+ severity: "blocking",
311
+ observables: {
312
+ log: "Loading hotfix metadata",
313
+ fs: ".hotfix/metadata.json (read)"
314
+ },
315
+ assertions: [
316
+ "expect(log).toContain('Loading hotfix metadata')",
317
+ "expect(ctx.metadata).toBeDefined().or.toBeNull()"
318
+ ],
319
+ nextStates: ["idle", "inProgress", "deployed"]
320
+ },
321
+ idle: {
322
+ description: "No active hotfix - ready to create new one",
323
+ severity: "non-critical",
324
+ observables: {
325
+ log: "No active hotfix"
326
+ },
327
+ assertions: ["expect(log).toContain('No active hotfix')", "expect(ctx.metadata).toBeNull()"],
328
+ nextStates: ["creating"]
329
+ },
330
+ creating: {
331
+ description: "Create hotfix branch and metadata",
332
+ severity: "blocking",
333
+ observables: {
334
+ log: "Creating hotfix branch",
335
+ fs: ".hotfix/metadata.json (created)",
336
+ git: "hotfix/* branch created"
337
+ },
338
+ assertions: [
339
+ "expect(log).toContain('Creating hotfix branch')",
340
+ "expect(file('.hotfix/metadata.json')).toExist()"
341
+ ],
342
+ nextStates: ["inProgress", "idle"]
343
+ },
344
+ inProgress: {
345
+ description: "Hotfix created and being worked on",
346
+ severity: "non-critical",
347
+ observables: {
348
+ log: "Hotfix in progress"
349
+ },
350
+ assertions: [
351
+ "expect(log).toContain('Hotfix in progress')",
352
+ "expect(ctx.metadata.status).toBe('in_progress')"
353
+ ],
354
+ nextStates: ["deploying", "cancelling"]
355
+ },
356
+ deploying: {
357
+ description: "Deploy hotfix to production",
358
+ severity: "blocking",
359
+ observables: {
360
+ log: "Deploying hotfix to production",
361
+ api: "Vercel deployment triggered"
362
+ },
363
+ assertions: ["expect(log).toContain('Deploying hotfix to production')"],
364
+ nextStates: ["deployed", "inProgress"]
365
+ },
366
+ deployed: {
367
+ description: "Hotfix successfully deployed to production",
368
+ severity: "non-critical",
369
+ observables: {
370
+ log: "Hotfix deployed successfully"
371
+ },
372
+ assertions: [
373
+ "expect(log).toContain('Hotfix deployed successfully')",
374
+ "expect(ctx.metadata.status).toBe('deployed')"
375
+ ],
376
+ nextStates: ["completing", "cancelling"]
377
+ },
378
+ completing: {
379
+ description: "Complete hotfix by merging back to main",
380
+ severity: "blocking",
381
+ observables: {
382
+ log: "Completing hotfix",
383
+ git: "PR created or direct merge"
384
+ },
385
+ assertions: ["expect(log).toContain('Completing hotfix')"],
386
+ nextStates: ["completed", "deployed"]
387
+ },
388
+ cancelling: {
389
+ description: "Cancel hotfix and restore original state",
390
+ severity: "blocking",
391
+ observables: {
392
+ log: "Cancelling hotfix",
393
+ git: "Branch deleted, snapshot restored"
394
+ },
395
+ assertions: ["expect(log).toContain('Cancelling hotfix')"],
396
+ nextStates: ["cancelled", "inProgress"]
397
+ },
398
+ completed: {
399
+ description: "Hotfix workflow completed successfully",
400
+ severity: "final",
401
+ observables: {
402
+ log: "Hotfix completed successfully",
403
+ exit: 0
404
+ },
405
+ assertions: [
406
+ "expect(log).toContain('Hotfix completed successfully')",
407
+ "expect(exitCode).toBe(0)"
408
+ ],
409
+ nextStates: []
410
+ },
411
+ cancelled: {
412
+ description: "Hotfix workflow cancelled by user",
413
+ severity: "final",
414
+ observables: {
415
+ log: "Hotfix cancelled",
416
+ exit: 2
417
+ },
418
+ assertions: ["expect(log).toContain('Hotfix cancelled')", "expect(exitCode).toBe(2)"],
419
+ nextStates: []
420
+ }
421
+ };
422
+ var hotfixMachine = setup({
423
+ types: {
424
+ context: {},
425
+ input: {},
426
+ events: {},
427
+ output: {}
428
+ },
429
+ actors: {
430
+ createHotfix,
431
+ deployHotfix,
432
+ completeHotfix,
433
+ cancelHotfix: cancelHotfix2,
434
+ loadMetadata
435
+ },
436
+ guards: {
437
+ hasActiveHotfix: ({ context }) => context.metadata !== null,
438
+ isInProgress: ({ context }) => context.metadata?.status === "in_progress",
439
+ isDeployed: ({ context }) => context.metadata?.status === "deployed"
440
+ },
441
+ actions: {
442
+ setMetadata: assign({
443
+ metadata: (_, params) => params.metadata
444
+ }),
445
+ setError: assign({
446
+ error: (_, params) => params.error
447
+ }),
448
+ setPrUrl: assign({
449
+ prUrl: (_, params) => params.prUrl
450
+ }),
451
+ clearError: assign({
452
+ error: () => void 0
453
+ })
454
+ }
455
+ }).createMachine({
456
+ id: "hotfix",
457
+ initial: "loading",
458
+ context: ({ input }) => ({
459
+ targetDir: input?.targetDir || process.cwd(),
460
+ metadata: input?.existingMetadata || null
461
+ }),
462
+ // Machine output (returned on completion)
463
+ output: ({ context, self }) => {
464
+ const state = self.getSnapshot().value;
465
+ const isCancelled = state === "cancelled";
466
+ const isSuccess = state === "completed";
467
+ return {
468
+ success: isSuccess,
469
+ exitCode: isCancelled ? 2 : isSuccess ? 0 : 1,
470
+ finalState: state,
471
+ metadata: context.metadata,
472
+ prUrl: context.prUrl,
473
+ error: context.error
474
+ };
475
+ },
476
+ states: {
477
+ // Initial state: Load existing metadata to determine current state
478
+ loading: {
479
+ meta: { e2e: e2eMeta.loading },
480
+ invoke: {
481
+ id: "loadMetadata",
482
+ src: "loadMetadata",
483
+ input: ({ context }) => ({ targetDir: context.targetDir }),
484
+ onDone: [
485
+ {
486
+ guard: ({ event }) => event.output?.status === "in_progress",
487
+ target: "inProgress",
488
+ actions: assign({ metadata: ({ event }) => event.output })
489
+ },
490
+ {
491
+ guard: ({ event }) => event.output?.status === "deployed",
492
+ target: "deployed",
493
+ actions: assign({ metadata: ({ event }) => event.output })
494
+ },
495
+ {
496
+ target: "idle",
497
+ actions: assign({ metadata: ({ event }) => event.output })
498
+ }
499
+ ],
500
+ onError: {
501
+ target: "idle",
502
+ actions: assign({ error: ({ event }) => String(event.error) })
503
+ }
504
+ }
505
+ },
506
+ // No active hotfix
507
+ idle: {
508
+ meta: { e2e: e2eMeta.idle },
509
+ on: {
510
+ CREATE: {
511
+ target: "creating"
512
+ }
513
+ }
514
+ },
515
+ // Creating hotfix branch and metadata
516
+ creating: {
517
+ meta: { e2e: e2eMeta.creating },
518
+ invoke: {
519
+ id: "createHotfix",
520
+ src: "createHotfix",
521
+ input: ({ context, event }) => {
522
+ if (event.type !== "CREATE") {
523
+ throw new Error("Invalid event type for creating state");
524
+ }
525
+ return {
526
+ targetDir: context.targetDir,
527
+ name: event.name,
528
+ base: event.base,
529
+ skipSnapshot: event.skipSnapshot
530
+ };
531
+ },
532
+ onDone: {
533
+ target: "inProgress",
534
+ actions: assign({ metadata: ({ event }) => event.output.metadata })
535
+ },
536
+ onError: {
537
+ target: "idle",
538
+ actions: assign({ error: ({ event }) => String(event.error) })
539
+ }
540
+ }
541
+ },
542
+ // Hotfix created, being worked on
543
+ inProgress: {
544
+ meta: { e2e: e2eMeta.inProgress },
545
+ on: {
546
+ DEPLOY: {
547
+ target: "deploying"
548
+ },
549
+ CANCEL: {
550
+ target: "cancelling"
551
+ }
552
+ }
553
+ },
554
+ // Deploying to production
555
+ deploying: {
556
+ meta: { e2e: e2eMeta.deploying },
557
+ invoke: {
558
+ id: "deployHotfix",
559
+ src: "deployHotfix",
560
+ input: ({ context, event }) => {
561
+ if (event.type !== "DEPLOY") {
562
+ throw new Error("Invalid event type for deploying state");
563
+ }
564
+ return {
565
+ targetDir: context.targetDir,
566
+ autoApprove: event.autoApprove,
567
+ skipChecks: event.skipChecks
568
+ };
569
+ },
570
+ onDone: {
571
+ target: "deployed",
572
+ actions: assign({
573
+ metadata: ({ context, event }) => context.metadata ? {
574
+ ...context.metadata,
575
+ status: "deployed",
576
+ deployedAt: event.output.deployedAt
577
+ } : null
578
+ })
579
+ },
580
+ onError: {
581
+ target: "inProgress",
582
+ actions: assign({ error: ({ event }) => String(event.error) })
583
+ }
584
+ }
585
+ },
586
+ // Deployed to production
587
+ deployed: {
588
+ meta: { e2e: e2eMeta.deployed },
589
+ on: {
590
+ COMPLETE: {
591
+ target: "completing"
592
+ },
593
+ CANCEL: {
594
+ target: "cancelling"
595
+ }
596
+ }
597
+ },
598
+ // Completing hotfix (merging back)
599
+ completing: {
600
+ meta: { e2e: e2eMeta.completing },
601
+ invoke: {
602
+ id: "completeHotfix",
603
+ src: "completeHotfix",
604
+ input: ({ context, event }) => {
605
+ if (event.type !== "COMPLETE") {
606
+ throw new Error("Invalid event type for completing state");
607
+ }
608
+ return {
609
+ targetDir: context.targetDir,
610
+ noPr: event.noPr,
611
+ autoApprove: event.autoApprove
612
+ };
613
+ },
614
+ onDone: {
615
+ target: "completed",
616
+ actions: assign({
617
+ prUrl: ({ event }) => event.output.prUrl,
618
+ metadata: ({ context, event }) => context.metadata ? {
619
+ ...context.metadata,
620
+ status: "completed",
621
+ completedAt: event.output.completedAt
622
+ } : null
623
+ })
624
+ },
625
+ onError: {
626
+ target: "deployed",
627
+ actions: assign({ error: ({ event }) => String(event.error) })
628
+ }
629
+ }
630
+ },
631
+ // Cancelling hotfix
632
+ cancelling: {
633
+ meta: { e2e: e2eMeta.cancelling },
634
+ invoke: {
635
+ id: "cancelHotfix",
636
+ src: "cancelHotfix",
637
+ input: ({ context }) => ({ targetDir: context.targetDir }),
638
+ onDone: {
639
+ target: "cancelled",
640
+ actions: assign({
641
+ metadata: ({ context }) => context.metadata ? {
642
+ ...context.metadata,
643
+ status: "cancelled",
644
+ completedAt: (/* @__PURE__ */ new Date()).toISOString()
645
+ } : null
646
+ })
647
+ },
648
+ onError: {
649
+ target: "inProgress",
650
+ actions: assign({ error: ({ event }) => String(event.error) })
651
+ }
652
+ }
653
+ },
654
+ // Final states
655
+ completed: {
656
+ meta: { e2e: e2eMeta.completed },
657
+ type: "final"
658
+ },
659
+ cancelled: {
660
+ meta: { e2e: e2eMeta.cancelled },
661
+ type: "final"
662
+ }
663
+ }
664
+ });
665
+ function getHotfixStateName(snapshot) {
666
+ return snapshot.value;
667
+ }
668
+ function isHotfixComplete(snapshot) {
669
+ return snapshot.status === "done";
670
+ }
671
+ function getAvailableHotfixEvents(snapshot) {
672
+ const state = snapshot.value;
673
+ switch (state) {
674
+ case "idle":
675
+ return ["CREATE"];
676
+ case "inProgress":
677
+ return ["DEPLOY", "CANCEL"];
678
+ case "deployed":
679
+ return ["COMPLETE", "CANCEL"];
680
+ default:
681
+ return [];
682
+ }
683
+ }
684
+
685
+ // src/commands/hotfix/utils/hotfix-machine-helper.ts
686
+ async function createHotfixActor(targetDir = process.cwd(), options = {}) {
687
+ const { timeout = 1e4 } = options;
688
+ const actor = createActor(hotfixMachine, {
689
+ input: { targetDir }
690
+ });
691
+ return new Promise((resolve, reject) => {
692
+ const timeoutId = setTimeout(() => {
693
+ actor.stop();
694
+ reject(new Error("Hotfix machine initialization timed out"));
695
+ }, timeout);
696
+ actor.subscribe((snapshot) => {
697
+ const state = snapshot.value;
698
+ if (state !== "loading") {
699
+ clearTimeout(timeoutId);
700
+ resolve(actor);
701
+ }
702
+ });
703
+ actor.start();
704
+ });
705
+ }
706
+ async function sendAndWait(actor, event, targetStates, options = {}) {
707
+ const { timeout = 6e4, transitionStates = [] } = options;
708
+ actor.send(event);
709
+ return new Promise((resolve, reject) => {
710
+ const timeoutId = setTimeout(() => {
711
+ reject(new Error(`State transition timed out after sending ${event.type}`));
712
+ }, timeout);
713
+ const subscription = actor.subscribe((snapshot) => {
714
+ const state = snapshot.value;
715
+ const error = snapshot.context.error;
716
+ if (targetStates.includes(state)) {
717
+ clearTimeout(timeoutId);
718
+ subscription.unsubscribe();
719
+ resolve(snapshot);
720
+ return;
721
+ }
722
+ if (error && !transitionStates.includes(state) && !targetStates.includes(state)) {
723
+ clearTimeout(timeoutId);
724
+ subscription.unsubscribe();
725
+ reject(new Error(error));
726
+ return;
727
+ }
728
+ if (snapshot.status === "done") {
729
+ clearTimeout(timeoutId);
730
+ subscription.unsubscribe();
731
+ resolve(snapshot);
732
+ }
733
+ });
734
+ });
735
+ }
736
+ function getHotfixState(snapshot) {
737
+ return {
738
+ state: getHotfixStateName(snapshot),
739
+ isComplete: isHotfixComplete(snapshot),
740
+ availableEvents: getAvailableHotfixEvents(snapshot),
741
+ metadata: snapshot.context.metadata ? {
742
+ branch: snapshot.context.metadata.branch,
743
+ base: snapshot.context.metadata.base,
744
+ status: snapshot.context.metadata.status,
745
+ createdAt: snapshot.context.metadata.createdAt,
746
+ deployedAt: snapshot.context.metadata.deployedAt
747
+ } : null,
748
+ error: snapshot.context.error,
749
+ prUrl: snapshot.context.prUrl
750
+ };
751
+ }
752
+ function canSendEvent(snapshot, eventType) {
753
+ return getAvailableHotfixEvents(snapshot).includes(eventType);
754
+ }
755
+
756
+ // src/commands/hotfix/commands/hotfix-complete.ts
757
+ var completeStateErrors = {
758
+ idle: {
759
+ code: "HOTFIX_NOT_FOUND",
760
+ hints: ["No hotfix in progress", "Check: runa hotfix status"]
761
+ },
762
+ inProgress: {
763
+ code: "HOTFIX_NOT_DEPLOYED",
764
+ hints: ["Deploy first: runa hotfix deploy --auto-approve"]
765
+ },
766
+ completed: {
767
+ code: "HOTFIX_ALREADY_COMPLETED",
768
+ hints: ["Run: runa hotfix status"]
769
+ },
770
+ cancelled: {
771
+ code: "HOTFIX_ALREADY_COMPLETED",
772
+ hints: ["Run: runa hotfix status"]
773
+ }
774
+ };
775
+ function validateCanComplete(actor) {
776
+ const snapshot = actor.getSnapshot();
777
+ const initialState = getHotfixState(snapshot);
778
+ if (!canSendEvent(snapshot, "COMPLETE")) {
779
+ const currentState = initialState.state;
780
+ const errorInfo = completeStateErrors[currentState];
781
+ if (errorInfo) {
782
+ const message = currentState === "idle" ? "No active hotfix found" : currentState === "inProgress" ? "Hotfix not deployed yet" : `Hotfix already ${currentState}`;
783
+ throw new CLIError(message, errorInfo.code, errorInfo.hints);
784
+ }
785
+ throw new CLIError(`Cannot complete in state: ${currentState}`, "HOTFIX_INVALID_STATE", [
786
+ "Run: runa hotfix status"
787
+ ]);
788
+ }
789
+ const metadata = initialState.metadata;
790
+ if (!metadata?.branch) {
791
+ throw new CLIError("Hotfix metadata is missing branch info", "HOTFIX_METADATA_INVALID");
792
+ }
793
+ return { branch: metadata.branch, mainBranch: getMainBranch() };
794
+ }
795
+ async function getMainBranch() {
796
+ try {
797
+ await execa("git", ["rev-parse", "--verify", "origin/main"], { stdio: "pipe" });
798
+ return "main";
799
+ } catch {
800
+ return "master";
801
+ }
802
+ }
803
+ async function createPullRequest(branchName, mainBranch, _logger) {
804
+ try {
805
+ await execa("gh", ["--version"], { stdio: "pipe" });
806
+ } catch {
807
+ throw new CLIError("GitHub CLI not found", "HOTFIX_GH_NOT_FOUND", [
808
+ "Install GitHub CLI: brew install gh",
809
+ "Or create PR manually on GitHub"
810
+ ]);
811
+ }
812
+ const prTitle = `Hotfix: ${branchName.replace("hotfix/", "")}`;
813
+ const prBody = `## Hotfix PR
814
+
815
+ This PR contains emergency fixes deployed via \`runa hotfix\`.
816
+
817
+ ### Changes
818
+ - See commits for details
819
+
820
+ ### Checklist
821
+ - [x] Deployed to production
822
+ - [ ] Verified in production
823
+ - [ ] Ready to merge to ${mainBranch}
824
+ `;
825
+ try {
826
+ const result = await execa(
827
+ "gh",
828
+ [
829
+ "pr",
830
+ "create",
831
+ "--base",
832
+ mainBranch,
833
+ "--head",
834
+ branchName,
835
+ "--title",
836
+ prTitle,
837
+ "--body",
838
+ prBody
839
+ ],
840
+ { stdio: "pipe" }
841
+ );
842
+ return result.stdout.trim();
843
+ } catch {
844
+ try {
845
+ const viewResult = await execa("gh", ["pr", "view", branchName, "--json", "url"], {
846
+ stdio: "pipe"
847
+ });
848
+ const prData = JSON.parse(viewResult.stdout);
849
+ return prData.url;
850
+ } catch {
851
+ throw new CLIError("Failed to create PR", "HOTFIX_PR_CREATE_FAILED", [
852
+ "Check gh CLI authentication",
853
+ "Create PR manually on GitHub"
854
+ ]);
855
+ }
856
+ }
857
+ }
858
+ async function mergePullRequest(branchName, _logger) {
859
+ try {
860
+ await execa("gh", ["pr", "merge", branchName, "--squash", "--delete-branch"], {
861
+ stdio: "inherit"
862
+ });
863
+ } catch {
864
+ throw new CLIError("Failed to merge PR", "HOTFIX_PR_MERGE_FAILED", [
865
+ "Merge manually on GitHub",
866
+ "Check for merge conflicts"
867
+ ]);
868
+ }
869
+ }
870
+ async function directMerge(branchName, mainBranch, logger) {
871
+ logger.warn("\u26A0\uFE0F Direct merge without PR (not recommended)");
872
+ await execa("git", ["checkout", mainBranch], { stdio: "inherit" });
873
+ await execa("git", ["pull", "origin", mainBranch], { stdio: "inherit" });
874
+ try {
875
+ await execa("git", ["merge", branchName, "--no-ff", "-m", `Merge ${branchName}`], {
876
+ stdio: "inherit"
877
+ });
878
+ } catch {
879
+ throw new CLIError("Merge conflict detected", "HOTFIX_MERGE_CONFLICT", [
880
+ "Resolve conflicts manually",
881
+ "Then: git add . && git commit",
882
+ "Finally: runa hotfix complete"
883
+ ]);
884
+ }
885
+ await execa("git", ["push", "origin", mainBranch], { stdio: "inherit" });
886
+ }
887
+ async function deleteBranch(branchName, logger) {
888
+ try {
889
+ await execa("git", ["branch", "-D", branchName], { stdio: "pipe" });
890
+ logger.info(`Deleted local branch: ${branchName}`);
891
+ } catch {
892
+ logger.warn(`Could not delete local branch: ${branchName}`);
893
+ }
894
+ try {
895
+ await execa("git", ["push", "origin", "--delete", branchName], { stdio: "pipe" });
896
+ logger.info(`Deleted remote branch: ${branchName}`);
897
+ } catch {
898
+ logger.warn(`Could not delete remote branch: ${branchName}`);
899
+ }
900
+ }
901
+ async function runCompleteAction(options) {
902
+ const logger = createCLILogger("hotfix:complete");
903
+ logger.step("Initializing hotfix workflow", 1);
904
+ const actor = await createHotfixActor(process.cwd());
905
+ const { branch, mainBranch: mainBranchPromise } = validateCanComplete(actor);
906
+ const mainBranch = await mainBranchPromise;
907
+ logger.section("Hotfix Completion");
908
+ logger.info(`Branch: ${branch}`);
909
+ logger.info(`Target: ${mainBranch}`);
910
+ if (options.dryRun) {
911
+ logger.info("\n[DRY RUN] Would complete hotfix:");
912
+ logger.info(` 1. Create PR: ${branch} \u2192 ${mainBranch}`);
913
+ logger.info(" 2. Merge PR (squash)");
914
+ if (options.deleteBranch !== false) {
915
+ logger.info(` 3. Delete branch: ${branch}`);
916
+ }
917
+ actor.stop();
918
+ return;
919
+ }
920
+ if (!options.autoApprove) {
921
+ throw new CLIError(
922
+ "Hotfix completion requires explicit confirmation",
923
+ "HOTFIX_COMPLETE_CONFIRM_REQUIRED",
924
+ ["Use --auto-approve to confirm", "Use --dry-run to preview"]
925
+ );
926
+ }
927
+ let prUrl;
928
+ if (options.noPr) {
929
+ await directMerge(branch, mainBranch, logger);
930
+ } else {
931
+ logger.step("Creating PR", 2);
932
+ prUrl = await createPullRequest(branch, mainBranch);
933
+ logger.success(`PR created: ${prUrl}`);
934
+ logger.step("Merging PR", 3);
935
+ await mergePullRequest(branch);
936
+ logger.success("PR merged");
937
+ }
938
+ if (options.noPr && options.deleteBranch !== false) {
939
+ logger.step("Cleaning up branch", 4);
940
+ await deleteBranch(branch, logger);
941
+ }
942
+ logger.step("Archiving hotfix metadata", 5);
943
+ try {
944
+ const snapshot = await sendAndWait(
945
+ actor,
946
+ { type: "COMPLETE", noPr: options.noPr, autoApprove: options.autoApprove },
947
+ ["completed"],
948
+ { transitionStates: ["completing"], timeout: 1e4 }
949
+ );
950
+ const finalState = getHotfixState(snapshot);
951
+ if (finalState.error) {
952
+ throw new Error(finalState.error);
953
+ }
954
+ } catch (error) {
955
+ throw new CLIError(
956
+ error instanceof Error ? error.message : "Failed to archive hotfix metadata",
957
+ "HOTFIX_ARCHIVE_FAILED",
958
+ ["Merge succeeded but archiving failed", "Run: runa hotfix status"]
959
+ );
960
+ }
961
+ try {
962
+ await execa("git", ["checkout", mainBranch], { stdio: "pipe" });
963
+ await execa("git", ["pull", "origin", mainBranch], { stdio: "pipe" });
964
+ } catch {
965
+ }
966
+ actor.stop();
967
+ logger.success("\n\u2705 Hotfix completed");
968
+ logger.info("\nSummary:");
969
+ logger.info(` \u2713 Merged to ${mainBranch}`);
970
+ logger.info(` \u2713 Branch ${branch} cleaned up`);
971
+ logger.info(" \u2713 Metadata archived");
972
+ if (prUrl) {
973
+ logger.info(` \u2713 PR: ${prUrl}`);
974
+ }
975
+ }
976
+ var completeCommand = new Command("complete").description("Complete hotfix: merge to main and cleanup").option("--no-pr", "Direct merge without PR (dangerous)").option("--auto-approve", "Skip confirmation prompts").option("--dry-run", "Show what would happen without applying").option("--no-delete-branch", "Keep hotfix branch after merge").action(async (options) => {
977
+ try {
978
+ await runCompleteAction(options);
979
+ } catch (error) {
980
+ if (error instanceof CLIError) throw error;
981
+ throw new CLIError(
982
+ error instanceof Error ? error.message : "Hotfix completion failed",
983
+ "HOTFIX_COMPLETE_FAILED",
984
+ ["Check git status", "Verify GitHub CLI authentication"],
985
+ error instanceof Error ? error : void 0
986
+ );
987
+ }
988
+ });
989
+
990
+ // src/commands/hotfix/commands/hotfix-create.ts
991
+ init_esm_shims();
992
+ function validateCanCreate(actor) {
993
+ const snapshot = actor.getSnapshot();
994
+ const initialState = getHotfixState(snapshot);
995
+ if (canSendEvent(snapshot, "CREATE")) return;
996
+ const currentState = initialState.state;
997
+ if (currentState === "inProgress" || currentState === "deployed") {
998
+ throw new CLIError("A hotfix is already in progress", "HOTFIX_ALREADY_EXISTS", [
999
+ `Current state: ${currentState}`,
1000
+ `Branch: ${initialState.metadata?.branch ?? "unknown"}`,
1001
+ "Complete or cancel existing hotfix first",
1002
+ "Run: runa hotfix status"
1003
+ ]);
1004
+ }
1005
+ throw new CLIError(`Cannot create hotfix in state: ${currentState}`, "HOTFIX_INVALID_STATE", [
1006
+ "Run: runa hotfix status"
1007
+ ]);
1008
+ }
1009
+ async function createPreHotfixSnapshot(baseBranch, logger) {
1010
+ logger.step("Creating pre-hotfix snapshot (safety)", 2);
1011
+ try {
1012
+ loadEnvFiles({ runaEnv: "production", silent: true });
1013
+ const productionUrl = tryResolveDatabaseUrl("production");
1014
+ if (!productionUrl) {
1015
+ logger.warn("No production database URL found, skipping snapshot");
1016
+ return void 0;
1017
+ }
1018
+ const result = await createDbSnapshot({
1019
+ databaseUrl: productionUrl,
1020
+ environment: "production",
1021
+ commit: baseBranch,
1022
+ targetDir: process.cwd()
1023
+ });
1024
+ logger.success(`Snapshot created: ${result.filename}`);
1025
+ return result.filename;
1026
+ } catch (error) {
1027
+ logger.warn(`Snapshot failed: ${error instanceof Error ? error.message : "Unknown"}`);
1028
+ logger.warn("Continuing without snapshot");
1029
+ return void 0;
1030
+ }
1031
+ }
1032
+ async function rollbackBranch(branchName, logger) {
1033
+ logger.warn("Metadata save failed, rolling back branch...");
1034
+ try {
1035
+ await execa("git", ["checkout", "-"], { stdio: "pipe" });
1036
+ await execa("git", ["branch", "-D", branchName], { stdio: "pipe" });
1037
+ } catch {
1038
+ }
1039
+ }
1040
+ async function getProductionBase(base) {
1041
+ if (base) return base;
1042
+ try {
1043
+ const result = await execa("git", ["describe", "--tags", "--abbrev=0", "--match", "v*"], {
1044
+ stdio: "pipe"
1045
+ });
1046
+ return result.stdout.trim();
1047
+ } catch {
1048
+ try {
1049
+ await execa("git", ["rev-parse", "--verify", "origin/main"], { stdio: "pipe" });
1050
+ return "origin/main";
1051
+ } catch {
1052
+ return "origin/master";
1053
+ }
1054
+ }
1055
+ }
1056
+ async function checkGitStatus() {
1057
+ try {
1058
+ const statusResult = await execa("git", ["status", "--porcelain"], { stdio: "pipe" });
1059
+ if (statusResult.stdout.trim()) {
1060
+ throw new CLIError("Uncommitted changes detected", "HOTFIX_DIRTY_WORKING_TREE", [
1061
+ "Commit or stash changes before creating hotfix",
1062
+ "Run: git stash"
1063
+ ]);
1064
+ }
1065
+ } catch (error) {
1066
+ if (error instanceof CLIError) throw error;
1067
+ throw new CLIError("Failed to check git status", "HOTFIX_GIT_STATUS_FAILED");
1068
+ }
1069
+ }
1070
+ async function runCreateAction(name, options) {
1071
+ const logger = createCLILogger("hotfix:create");
1072
+ logger.step("Initializing hotfix workflow", 1);
1073
+ const actor = await createHotfixActor(process.cwd());
1074
+ validateCanCreate(actor);
1075
+ let branchName;
1076
+ try {
1077
+ branchName = validateHotfixName(name);
1078
+ } catch {
1079
+ throw new CLIError("Invalid hotfix name", "HOTFIX_INVALID_NAME", [
1080
+ "Use alphanumeric characters and hyphens",
1081
+ "Example: fix-payment-bug"
1082
+ ]);
1083
+ }
1084
+ const baseBranch = await getProductionBase(options.base);
1085
+ logger.section("Hotfix Creation");
1086
+ logger.info(`Name: ${name}`);
1087
+ logger.info(`Branch: ${branchName}`);
1088
+ logger.info(`Base: ${baseBranch}`);
1089
+ await checkGitStatus();
1090
+ if (!options.skipSnapshot) {
1091
+ await createPreHotfixSnapshot(baseBranch, logger);
1092
+ }
1093
+ logger.step("Fetching latest changes", 3);
1094
+ await execa("git", ["fetch", "--all", "--tags"], { stdio: "inherit" });
1095
+ logger.step(`Creating branch: ${branchName}`, 4);
1096
+ try {
1097
+ await execa("git", ["checkout", "-b", branchName, baseBranch], { stdio: "inherit" });
1098
+ } catch {
1099
+ throw new CLIError(`Failed to create branch: ${branchName}`, "HOTFIX_BRANCH_CREATE_FAILED", [
1100
+ "Branch may already exist",
1101
+ `Delete existing: git branch -D ${branchName}`,
1102
+ "Or use different name"
1103
+ ]);
1104
+ }
1105
+ logger.step("Saving hotfix metadata", 5);
1106
+ try {
1107
+ const snapshot = await sendAndWait(
1108
+ actor,
1109
+ { type: "CREATE", name, base: baseBranch, skipSnapshot: options.skipSnapshot },
1110
+ ["inProgress"],
1111
+ { transitionStates: ["creating"], timeout: 1e4 }
1112
+ );
1113
+ const finalState = getHotfixState(snapshot);
1114
+ if (finalState.error) {
1115
+ throw new Error(finalState.error);
1116
+ }
1117
+ } catch (error) {
1118
+ await rollbackBranch(branchName, logger);
1119
+ throw new CLIError(
1120
+ error instanceof Error ? error.message : "Failed to save hotfix metadata",
1121
+ "HOTFIX_METADATA_FAILED",
1122
+ ["Check .runa/hotfix directory permissions"]
1123
+ );
1124
+ }
1125
+ actor.stop();
1126
+ logger.success("\n\u2705 Hotfix branch created");
1127
+ logger.info("\nNext steps:");
1128
+ logger.info(" 1. Make your emergency fix");
1129
+ logger.info(' 2. Commit changes: git commit -m "hotfix: description"');
1130
+ logger.info(" 3. Deploy: runa hotfix deploy");
1131
+ logger.info(" 4. Complete: runa hotfix complete");
1132
+ }
1133
+ var createCommand = new Command("create").description("Create a hotfix branch from production").argument("<name>", 'Hotfix name (e.g., "fix-payment-bug")').option("--base <ref>", "Base commit/tag (default: latest production tag)").option("--skip-snapshot", "Skip pre-hotfix database snapshot").action(async (name, options) => {
1134
+ try {
1135
+ await runCreateAction(name, options);
1136
+ } catch (error) {
1137
+ if (error instanceof CLIError) throw error;
1138
+ throw new CLIError(
1139
+ error instanceof Error ? error.message : "Hotfix creation failed",
1140
+ "HOTFIX_CREATE_FAILED",
1141
+ ["Check git repository state", "Ensure you have write access"],
1142
+ error instanceof Error ? error : void 0
1143
+ );
1144
+ }
1145
+ });
1146
+
1147
+ // src/commands/hotfix/commands/hotfix-deploy.ts
1148
+ init_esm_shims();
1149
+ var deployStateErrors = {
1150
+ idle: {
1151
+ code: "HOTFIX_NOT_FOUND",
1152
+ hints: ['Create hotfix first: runa hotfix create "fix-name"']
1153
+ },
1154
+ deployed: {
1155
+ code: "HOTFIX_ALREADY_DEPLOYED",
1156
+ hints: ["Complete hotfix: runa hotfix complete", "Or cancel: runa hotfix status"]
1157
+ }
1158
+ };
1159
+ function validateCanDeploy(actor) {
1160
+ const snapshot = actor.getSnapshot();
1161
+ const initialState = getHotfixState(snapshot);
1162
+ if (!canSendEvent(snapshot, "DEPLOY")) {
1163
+ const currentState = initialState.state;
1164
+ const errorInfo = deployStateErrors[currentState];
1165
+ if (errorInfo) {
1166
+ const message = currentState === "idle" ? "No active hotfix found" : "Hotfix already deployed";
1167
+ throw new CLIError(message, errorInfo.code, errorInfo.hints);
1168
+ }
1169
+ throw new CLIError(`Cannot deploy in state: ${currentState}`, "HOTFIX_INVALID_STATE", [
1170
+ "Run: runa hotfix status"
1171
+ ]);
1172
+ }
1173
+ const metadata = initialState.metadata;
1174
+ if (!metadata?.branch) {
1175
+ throw new CLIError("Hotfix metadata is missing branch info", "HOTFIX_METADATA_INVALID");
1176
+ }
1177
+ return {
1178
+ branch: metadata.branch,
1179
+ base: metadata.base,
1180
+ createdAt: metadata.createdAt
1181
+ };
1182
+ }
1183
+ async function verifyHotfixBranch(expectedBranch) {
1184
+ const result = await execa("git", ["branch", "--show-current"], { stdio: "pipe" });
1185
+ const currentBranch = result.stdout.trim();
1186
+ if (currentBranch !== expectedBranch) {
1187
+ throw new CLIError(
1188
+ `Not on hotfix branch. Current: ${currentBranch}, Expected: ${expectedBranch}`,
1189
+ "HOTFIX_WRONG_BRANCH",
1190
+ [`Checkout hotfix branch: git checkout ${expectedBranch}`]
1191
+ );
1192
+ }
1193
+ }
1194
+ async function runMinimalChecks(logger) {
1195
+ logger.step("Running minimal CI checks", 2);
1196
+ logger.info(" \u2192 Type checking...");
1197
+ try {
1198
+ await execa("pnpm", ["type-check"], { stdio: "pipe" });
1199
+ logger.info(" \u2713 Type check passed");
1200
+ } catch {
1201
+ throw new CLIError("Type check failed", "HOTFIX_TYPECHECK_FAILED", [
1202
+ "Fix type errors before deploying",
1203
+ "Run: pnpm type-check"
1204
+ ]);
1205
+ }
1206
+ logger.info(" \u2192 Building...");
1207
+ try {
1208
+ await execa("pnpm", ["build"], { stdio: "pipe" });
1209
+ logger.info(" \u2713 Build passed");
1210
+ } catch {
1211
+ throw new CLIError("Build failed", "HOTFIX_BUILD_FAILED", [
1212
+ "Fix build errors before deploying",
1213
+ "Run: pnpm build"
1214
+ ]);
1215
+ }
1216
+ logger.info(" \u2192 Linting...");
1217
+ try {
1218
+ await execa("pnpm", ["lint"], { stdio: "pipe" });
1219
+ logger.info(" \u2713 Lint passed");
1220
+ } catch {
1221
+ logger.warn(" \u26A0 Lint warnings (non-blocking)");
1222
+ }
1223
+ }
1224
+ async function deployToProduction(logger) {
1225
+ logger.step("Deploying to production", 3);
1226
+ try {
1227
+ await execa("vercel", ["--version"], { stdio: "pipe" });
1228
+ } catch {
1229
+ throw new CLIError("Vercel CLI not found", "HOTFIX_VERCEL_NOT_FOUND", [
1230
+ "Install Vercel CLI: npm i -g vercel",
1231
+ "Or deploy manually through Vercel dashboard"
1232
+ ]);
1233
+ }
1234
+ logger.info(" \u2192 Running vercel deploy --prod...");
1235
+ try {
1236
+ await execa("vercel", ["deploy", "--prod", "--yes"], {
1237
+ stdio: "inherit",
1238
+ env: {
1239
+ ...process.env,
1240
+ VERCEL_ORG_ID: process.env.VERCEL_ORG_ID,
1241
+ VERCEL_PROJECT_ID: process.env.VERCEL_PROJECT_ID
1242
+ }
1243
+ });
1244
+ logger.success(" \u2713 Deployed to production");
1245
+ } catch {
1246
+ throw new CLIError("Vercel deployment failed", "HOTFIX_DEPLOY_FAILED", [
1247
+ "Check Vercel CLI authentication",
1248
+ "Verify VERCEL_ORG_ID and VERCEL_PROJECT_ID are set",
1249
+ "Try manual deploy: vercel deploy --prod"
1250
+ ]);
1251
+ }
1252
+ }
1253
+ async function runDeployAction(options) {
1254
+ const logger = createCLILogger("hotfix:deploy");
1255
+ logger.step("Initializing hotfix workflow", 1);
1256
+ const actor = await createHotfixActor(process.cwd());
1257
+ const metadata = validateCanDeploy(actor);
1258
+ logger.section("Hotfix Deployment");
1259
+ logger.info(`Branch: ${metadata.branch}`);
1260
+ logger.info(`Base: ${metadata.base ?? "unknown"}`);
1261
+ logger.info(`Created: ${metadata.createdAt ?? "unknown"}`);
1262
+ logger.step("Verifying hotfix branch", 1);
1263
+ await verifyHotfixBranch(metadata.branch);
1264
+ logger.success(" \u2713 On correct branch");
1265
+ const statusResult = await execa("git", ["status", "--porcelain"], { stdio: "pipe" });
1266
+ if (statusResult.stdout.trim()) {
1267
+ throw new CLIError("Uncommitted changes detected", "HOTFIX_UNCOMMITTED_CHANGES", [
1268
+ "Commit all changes before deploying",
1269
+ 'Run: git commit -am "hotfix: description"'
1270
+ ]);
1271
+ }
1272
+ if (!options.skipChecks) {
1273
+ await runMinimalChecks(logger);
1274
+ } else {
1275
+ logger.warn("Skipping CI checks (--skip-checks)");
1276
+ }
1277
+ if (options.dryRun) {
1278
+ logger.info("\n[DRY RUN] Would deploy to production");
1279
+ logger.info("Re-run without --dry-run to apply");
1280
+ actor.stop();
1281
+ return;
1282
+ }
1283
+ if (!options.autoApprove) {
1284
+ throw new CLIError(
1285
+ "Production deployment requires explicit confirmation",
1286
+ "HOTFIX_CONFIRM_REQUIRED",
1287
+ [
1288
+ "Use --auto-approve to confirm deployment",
1289
+ "Use --dry-run to preview",
1290
+ "\u26A0\uFE0F This will deploy directly to production"
1291
+ ]
1292
+ );
1293
+ }
1294
+ logger.step("Pushing hotfix branch", 3);
1295
+ try {
1296
+ await execa("git", ["push", "-u", "origin", metadata.branch], { stdio: "inherit" });
1297
+ } catch {
1298
+ logger.warn("Push failed (may already exist)");
1299
+ }
1300
+ await deployToProduction(logger);
1301
+ logger.step("Updating hotfix status", 4);
1302
+ try {
1303
+ const snapshot = await sendAndWait(
1304
+ actor,
1305
+ { type: "DEPLOY", autoApprove: options.autoApprove, skipChecks: options.skipChecks },
1306
+ ["deployed"],
1307
+ { transitionStates: ["deploying"], timeout: 1e4 }
1308
+ );
1309
+ const finalState = getHotfixState(snapshot);
1310
+ if (finalState.error) {
1311
+ throw new Error(finalState.error);
1312
+ }
1313
+ } catch (error) {
1314
+ throw new CLIError(
1315
+ error instanceof Error ? error.message : "Failed to update hotfix status",
1316
+ "HOTFIX_STATUS_UPDATE_FAILED",
1317
+ ["Deployment succeeded but status update failed", "Run: runa hotfix status"]
1318
+ );
1319
+ }
1320
+ actor.stop();
1321
+ logger.success("\n\u2705 Hotfix deployed to production");
1322
+ logger.info("\nNext step:");
1323
+ logger.info(" runa hotfix complete # Merge back to main");
1324
+ }
1325
+ var deployCommand = new Command("deploy").description("Deploy hotfix to production (minimal CI)").option("--auto-approve", "Skip confirmation prompts").option("--dry-run", "Show what would be deployed without applying").option("--skip-checks", "Skip type check and build (dangerous)").action(async (options) => {
1326
+ try {
1327
+ await runDeployAction(options);
1328
+ } catch (error) {
1329
+ if (error instanceof CLIError) throw error;
1330
+ throw new CLIError(
1331
+ error instanceof Error ? error.message : "Hotfix deployment failed",
1332
+ "HOTFIX_DEPLOY_FAILED",
1333
+ ["Check deployment logs", "Verify production credentials"],
1334
+ error instanceof Error ? error : void 0
1335
+ );
1336
+ }
1337
+ });
1338
+
1339
+ // src/commands/hotfix/commands/hotfix-status.ts
1340
+ init_esm_shims();
1341
+ function formatDate(dateStr) {
1342
+ const date = new Date(dateStr);
1343
+ return date.toLocaleString();
1344
+ }
1345
+ function formatDuration(startStr, endStr) {
1346
+ const start = new Date(startStr);
1347
+ const end = endStr ? new Date(endStr) : /* @__PURE__ */ new Date();
1348
+ const diffMs = end.getTime() - start.getTime();
1349
+ const hours = Math.floor(diffMs / (1e3 * 60 * 60));
1350
+ const minutes = Math.floor(diffMs % (1e3 * 60 * 60) / (1e3 * 60));
1351
+ if (hours > 0) {
1352
+ return `${hours}h ${minutes}m`;
1353
+ }
1354
+ return `${minutes}m`;
1355
+ }
1356
+ function getStateLabel(state) {
1357
+ const labels = {
1358
+ idle: "\u{1F4A4} No active hotfix",
1359
+ loading: "\u23F3 Loading...",
1360
+ creating: "\u{1F504} Creating...",
1361
+ inProgress: "\u{1F527} In Progress",
1362
+ deploying: "\u{1F680} Deploying...",
1363
+ deployed: "\u2705 Deployed",
1364
+ completing: "\u{1F504} Completing...",
1365
+ completed: "\u2705 Completed",
1366
+ cancelling: "\u{1F504} Cancelling...",
1367
+ cancelled: "\u274C Cancelled"
1368
+ };
1369
+ return labels[state] ?? state;
1370
+ }
1371
+ var eventCommandMap = {
1372
+ CREATE: '\u2022 runa hotfix create "fix-name"',
1373
+ DEPLOY: "\u2022 runa hotfix deploy --auto-approve",
1374
+ COMPLETE: "\u2022 runa hotfix complete --auto-approve",
1375
+ CANCEL: "\u2022 (cancel not yet implemented)"
1376
+ };
1377
+ function displayAvailableActions(events, logger) {
1378
+ if (events.length === 0) return;
1379
+ logger.info("\n Available actions:");
1380
+ for (const event of events) {
1381
+ const command = eventCommandMap[event];
1382
+ if (command) {
1383
+ logger.info(` ${command}`);
1384
+ }
1385
+ }
1386
+ }
1387
+ function displayNextSteps(state, logger) {
1388
+ const nextStepsMap = {
1389
+ inProgress: [
1390
+ "1. Make fixes and commit",
1391
+ "2. runa hotfix deploy --auto-approve",
1392
+ "3. runa hotfix complete --auto-approve"
1393
+ ],
1394
+ deployed: ["1. Verify production", "2. runa hotfix complete --auto-approve"]
1395
+ };
1396
+ const steps = nextStepsMap[state];
1397
+ if (steps) {
1398
+ logger.info("\n Next steps:");
1399
+ for (const step of steps) {
1400
+ logger.info(` ${step}`);
1401
+ }
1402
+ }
1403
+ }
1404
+ function displayActiveHotfix(stateInfo, logger) {
1405
+ const { metadata, state, availableEvents } = stateInfo;
1406
+ if (!metadata) {
1407
+ logger.info("\n No active hotfix");
1408
+ logger.info(' Create one with: runa hotfix create "fix-name"');
1409
+ return;
1410
+ }
1411
+ logger.info("\n\u{1F527} Active Hotfix:");
1412
+ logger.info(` Branch: ${metadata.branch ?? "unknown"}`);
1413
+ logger.info(` Base: ${metadata.base ?? "unknown"}`);
1414
+ if (metadata.createdAt) {
1415
+ logger.info(` Created: ${formatDate(metadata.createdAt)}`);
1416
+ logger.info(` Duration: ${formatDuration(metadata.createdAt, metadata.deployedAt)}`);
1417
+ }
1418
+ logger.info(` Status: ${metadata.status ?? state}`);
1419
+ if (metadata.deployedAt) {
1420
+ logger.info(` Deployed: ${formatDate(metadata.deployedAt)}`);
1421
+ }
1422
+ displayAvailableActions(availableEvents, logger);
1423
+ displayNextSteps(state, logger);
1424
+ }
1425
+ async function displayArchivedHotfixes(logger) {
1426
+ try {
1427
+ const { hotfixes: archived } = await listArchivedHotfixes({ limit: 5 });
1428
+ if (archived.length === 0) return;
1429
+ logger.info("\n\u{1F4C1} Recent Hotfixes:");
1430
+ for (const hotfix of archived) {
1431
+ const duration = formatDuration(hotfix.createdAt, hotfix.completedAt);
1432
+ logger.info(` \u2022 ${hotfix.branch}`);
1433
+ logger.info(` Completed: ${formatDate(hotfix.completedAt || hotfix.createdAt)}`);
1434
+ logger.info(` Duration: ${duration}`);
1435
+ }
1436
+ } catch {
1437
+ }
1438
+ }
1439
+ async function runStatusAction() {
1440
+ const logger = createCLILogger("hotfix:status");
1441
+ const actor = await createHotfixActor(process.cwd());
1442
+ const stateInfo = getHotfixState(actor.getSnapshot());
1443
+ actor.stop();
1444
+ logger.section("Hotfix Status");
1445
+ logger.info(`
1446
+ State: ${getStateLabel(stateInfo.state)}`);
1447
+ displayActiveHotfix(stateInfo, logger);
1448
+ if (stateInfo.error) {
1449
+ logger.warn(`
1450
+ \u26A0\uFE0F Error: ${stateInfo.error}`);
1451
+ }
1452
+ await displayArchivedHotfixes(logger);
1453
+ }
1454
+ var statusCommand = new Command("status").description("Show current hotfix status").action(async () => {
1455
+ try {
1456
+ await runStatusAction();
1457
+ } catch (error) {
1458
+ if (error instanceof CLIError) throw error;
1459
+ throw new CLIError(
1460
+ error instanceof Error ? error.message : "Status check failed",
1461
+ "HOTFIX_STATUS_FAILED",
1462
+ ["Check .runa/hotfix directory"],
1463
+ error instanceof Error ? error : void 0
1464
+ );
1465
+ }
1466
+ });
1467
+
1468
+ // src/commands/hotfix/index.ts
1469
+ var hotfixCommand = new Command("hotfix").description(
1470
+ "Emergency production fix workflow (create \u2192 deploy \u2192 complete)"
1471
+ );
1472
+ hotfixCommand.addCommand(createCommand);
1473
+ hotfixCommand.addCommand(deployCommand);
1474
+ hotfixCommand.addCommand(completeCommand);
1475
+ hotfixCommand.addCommand(statusCommand);
1476
+
1477
+ export { hotfixCommand };