vika-cli 0.0.0-stage → 0.1.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 (243) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -2
  3. package/dist/cli.js +32 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/commands/approve-and-create-tickets.js +51 -0
  6. package/dist/commands/approve-and-create-tickets.js.map +1 -0
  7. package/dist/commands/create-tickets-command.js +30 -0
  8. package/dist/commands/create-tickets-command.js.map +1 -0
  9. package/dist/commands/doctor-command.js +59 -0
  10. package/dist/commands/doctor-command.js.map +1 -0
  11. package/dist/commands/init-command.js +21 -0
  12. package/dist/commands/init-command.js.map +1 -0
  13. package/dist/commands/mark-deploy-command.js +59 -0
  14. package/dist/commands/mark-deploy-command.js.map +1 -0
  15. package/dist/commands/report-command.js +40 -0
  16. package/dist/commands/report-command.js.map +1 -0
  17. package/dist/commands/run-cli.js +197 -0
  18. package/dist/commands/run-cli.js.map +1 -0
  19. package/dist/commands/run-exit-code.js +11 -0
  20. package/dist/commands/run-exit-code.js.map +1 -0
  21. package/dist/commands/serve-command.js +49 -0
  22. package/dist/commands/serve-command.js.map +1 -0
  23. package/dist/configuration/configuration-errors.js +43 -0
  24. package/dist/configuration/configuration-errors.js.map +1 -0
  25. package/dist/configuration/configuration-schema.js +69 -0
  26. package/dist/configuration/configuration-schema.js.map +1 -0
  27. package/dist/configuration/database-url-checks.js +43 -0
  28. package/dist/configuration/database-url-checks.js.map +1 -0
  29. package/dist/configuration/describe-configuration-safely.js +20 -0
  30. package/dist/configuration/describe-configuration-safely.js.map +1 -0
  31. package/dist/configuration/hide-secrets.js +44 -0
  32. package/dist/configuration/hide-secrets.js.map +1 -0
  33. package/dist/configuration/load-configuration.js +97 -0
  34. package/dist/configuration/load-configuration.js.map +1 -0
  35. package/dist/configuration/read-environment-file.js +77 -0
  36. package/dist/configuration/read-environment-file.js.map +1 -0
  37. package/dist/dashboard/dashboard-page.js +267 -0
  38. package/dist/dashboard/dashboard-page.js.map +1 -0
  39. package/dist/dashboard/dashboard-server.js +144 -0
  40. package/dist/dashboard/dashboard-server.js.map +1 -0
  41. package/dist/dashboard/github-issue-link.js +23 -0
  42. package/dist/dashboard/github-issue-link.js.map +1 -0
  43. package/dist/dashboard/request-guard.js +34 -0
  44. package/dist/dashboard/request-guard.js.map +1 -0
  45. package/dist/database/database-store.js +425 -0
  46. package/dist/database/database-store.js.map +1 -0
  47. package/dist/database/store-types.js +2 -0
  48. package/dist/database/store-types.js.map +1 -0
  49. package/dist/deploys/check-sha-on-branch.js +21 -0
  50. package/dist/deploys/check-sha-on-branch.js.map +1 -0
  51. package/dist/deploys/commits-in-range.js +31 -0
  52. package/dist/deploys/commits-in-range.js.map +1 -0
  53. package/dist/deploys/marker-deploys.js +18 -0
  54. package/dist/deploys/marker-deploys.js.map +1 -0
  55. package/dist/deploys/merge-log.js +33 -0
  56. package/dist/deploys/merge-log.js.map +1 -0
  57. package/dist/deploys/pull-request-number.js +5 -0
  58. package/dist/deploys/pull-request-number.js.map +1 -0
  59. package/dist/deploys/read-merge-deploys.js +46 -0
  60. package/dist/deploys/read-merge-deploys.js.map +1 -0
  61. package/dist/deploys/record-deploys.js +12 -0
  62. package/dist/deploys/record-deploys.js.map +1 -0
  63. package/dist/deploys/run-git.js +49 -0
  64. package/dist/deploys/run-git.js.map +1 -0
  65. package/dist/deploys/starting-point.js +5 -0
  66. package/dist/deploys/starting-point.js.map +1 -0
  67. package/dist/deploys/utc-timestamp.js +6 -0
  68. package/dist/deploys/utc-timestamp.js.map +1 -0
  69. package/dist/doctor/check-configuration.js +46 -0
  70. package/dist/doctor/check-configuration.js.map +1 -0
  71. package/dist/doctor/check-database.js +30 -0
  72. package/dist/doctor/check-database.js.map +1 -0
  73. package/dist/doctor/check-deploys.js +22 -0
  74. package/dist/doctor/check-deploys.js.map +1 -0
  75. package/dist/doctor/check-service-logs.js +107 -0
  76. package/dist/doctor/check-service-logs.js.map +1 -0
  77. package/dist/doctor/check-service-repository.js +43 -0
  78. package/dist/doctor/check-service-repository.js.map +1 -0
  79. package/dist/doctor/check-tracker.js +20 -0
  80. package/dist/doctor/check-tracker.js.map +1 -0
  81. package/dist/doctor/check-webhook.js +13 -0
  82. package/dist/doctor/check-webhook.js.map +1 -0
  83. package/dist/doctor/doctor-check-types.js +4 -0
  84. package/dist/doctor/doctor-check-types.js.map +1 -0
  85. package/dist/doctor/format-doctor-report.js +15 -0
  86. package/dist/doctor/format-doctor-report.js.map +1 -0
  87. package/dist/doctor/suggest-path-map.js +35 -0
  88. package/dist/doctor/suggest-path-map.js.map +1 -0
  89. package/dist/error-grouping/build-clusters.js +77 -0
  90. package/dist/error-grouping/build-clusters.js.map +1 -0
  91. package/dist/error-grouping/cluster-types.js +3 -0
  92. package/dist/error-grouping/cluster-types.js.map +1 -0
  93. package/dist/error-grouping/exception-type.js +6 -0
  94. package/dist/error-grouping/exception-type.js.map +1 -0
  95. package/dist/error-grouping/fingerprints.js +18 -0
  96. package/dist/error-grouping/fingerprints.js.map +1 -0
  97. package/dist/error-grouping/normalize-message.js +29 -0
  98. package/dist/error-grouping/normalize-message.js.map +1 -0
  99. package/dist/error-grouping/template-miner.js +75 -0
  100. package/dist/error-grouping/template-miner.js.map +1 -0
  101. package/dist/log-parsing/assemble-log-entries.js +49 -0
  102. package/dist/log-parsing/assemble-log-entries.js.map +1 -0
  103. package/dist/log-parsing/build-log-entry.js +33 -0
  104. package/dist/log-parsing/build-log-entry.js.map +1 -0
  105. package/dist/log-parsing/detect-log-format.js +44 -0
  106. package/dist/log-parsing/detect-log-format.js.map +1 -0
  107. package/dist/log-parsing/json-log-format.js +56 -0
  108. package/dist/log-parsing/json-log-format.js.map +1 -0
  109. package/dist/log-parsing/line-readers.js +14 -0
  110. package/dist/log-parsing/line-readers.js.map +1 -0
  111. package/dist/log-parsing/log-entry-types.js +3 -0
  112. package/dist/log-parsing/log-entry-types.js.map +1 -0
  113. package/dist/log-parsing/log-levels.js +21 -0
  114. package/dist/log-parsing/log-levels.js.map +1 -0
  115. package/dist/log-parsing/nginx-log-format.js +56 -0
  116. package/dist/log-parsing/nginx-log-format.js.map +1 -0
  117. package/dist/log-parsing/parse-log-lines.js +11 -0
  118. package/dist/log-parsing/parse-log-lines.js.map +1 -0
  119. package/dist/log-parsing/read-line-timestamp.js +21 -0
  120. package/dist/log-parsing/read-line-timestamp.js.map +1 -0
  121. package/dist/log-parsing/read-log-command.js +68 -0
  122. package/dist/log-parsing/read-log-command.js.map +1 -0
  123. package/dist/log-parsing/read-log-file.js +32 -0
  124. package/dist/log-parsing/read-log-file.js.map +1 -0
  125. package/dist/log-parsing/stack-frames.js +10 -0
  126. package/dist/log-parsing/stack-frames.js.map +1 -0
  127. package/dist/log-parsing/text-log-format.js +24 -0
  128. package/dist/log-parsing/text-log-format.js.map +1 -0
  129. package/dist/log-parsing/timestamps.js +22 -0
  130. package/dist/log-parsing/timestamps.js.map +1 -0
  131. package/dist/pipeline/analyze-service.js +45 -0
  132. package/dist/pipeline/analyze-service.js.map +1 -0
  133. package/dist/pipeline/build-stored-report.js +24 -0
  134. package/dist/pipeline/build-stored-report.js.map +1 -0
  135. package/dist/pipeline/ingest-service-logs.js +39 -0
  136. package/dist/pipeline/ingest-service-logs.js.map +1 -0
  137. package/dist/pipeline/load-deploys-for-service.js +16 -0
  138. package/dist/pipeline/load-deploys-for-service.js.map +1 -0
  139. package/dist/pipeline/prepare-ticket-drafts.js +33 -0
  140. package/dist/pipeline/prepare-ticket-drafts.js.map +1 -0
  141. package/dist/pipeline/read-new-log-lines.js +39 -0
  142. package/dist/pipeline/read-new-log-lines.js.map +1 -0
  143. package/dist/pipeline/run-all-services.js +73 -0
  144. package/dist/pipeline/run-all-services.js.map +1 -0
  145. package/dist/pipeline/timestamp-range.js +20 -0
  146. package/dist/pipeline/timestamp-range.js.map +1 -0
  147. package/dist/project-setup/detect-project.js +76 -0
  148. package/dist/project-setup/detect-project.js.map +1 -0
  149. package/dist/project-setup/write-starter-files.js +68 -0
  150. package/dist/project-setup/write-starter-files.js.map +1 -0
  151. package/dist/redaction/redact-ip-addresses.js +26 -0
  152. package/dist/redaction/redact-ip-addresses.js.map +1 -0
  153. package/dist/redaction/redact-sensitive-text.js +40 -0
  154. package/dist/redaction/redact-sensitive-text.js.map +1 -0
  155. package/dist/redaction/redaction-kinds.js +5 -0
  156. package/dist/redaction/redaction-kinds.js.map +1 -0
  157. package/dist/regression-detection/count-series.js +38 -0
  158. package/dist/regression-detection/count-series.js.map +1 -0
  159. package/dist/regression-detection/detect-regressions.js +162 -0
  160. package/dist/regression-detection/detect-regressions.js.map +1 -0
  161. package/dist/regression-detection/detection-types.js +9 -0
  162. package/dist/regression-detection/detection-types.js.map +1 -0
  163. package/dist/regression-detection/noise-check.js +7 -0
  164. package/dist/regression-detection/noise-check.js.map +1 -0
  165. package/dist/regression-detection/restore-time.js +19 -0
  166. package/dist/regression-detection/restore-time.js.map +1 -0
  167. package/dist/regression-detection/severity.js +12 -0
  168. package/dist/regression-detection/severity.js.map +1 -0
  169. package/dist/regression-detection/time-units.js +12 -0
  170. package/dist/regression-detection/time-units.js.map +1 -0
  171. package/dist/reporting/build-report.js +77 -0
  172. package/dist/reporting/build-report.js.map +1 -0
  173. package/dist/reporting/compute-metrics.js +42 -0
  174. package/dist/reporting/compute-metrics.js.map +1 -0
  175. package/dist/reporting/format-terminal-report.js +104 -0
  176. package/dist/reporting/format-terminal-report.js.map +1 -0
  177. package/dist/reporting/report-schema.js +96 -0
  178. package/dist/reporting/report-schema.js.map +1 -0
  179. package/dist/reporting/report-types.js +2 -0
  180. package/dist/reporting/report-types.js.map +1 -0
  181. package/dist/suspect-attribution/apply-path-map.js +31 -0
  182. package/dist/suspect-attribution/apply-path-map.js.map +1 -0
  183. package/dist/suspect-attribution/attribute-regression.js +176 -0
  184. package/dist/suspect-attribution/attribute-regression.js.map +1 -0
  185. package/dist/suspect-attribution/bot-authors.js +8 -0
  186. package/dist/suspect-attribution/bot-authors.js.map +1 -0
  187. package/dist/suspect-attribution/callee-files.js +53 -0
  188. package/dist/suspect-attribution/callee-files.js.map +1 -0
  189. package/dist/suspect-attribution/changed-file-categories.js +39 -0
  190. package/dist/suspect-attribution/changed-file-categories.js.map +1 -0
  191. package/dist/suspect-attribution/crash-line-inputs.js +81 -0
  192. package/dist/suspect-attribution/crash-line-inputs.js.map +1 -0
  193. package/dist/suspect-attribution/function-names.js +42 -0
  194. package/dist/suspect-attribution/function-names.js.map +1 -0
  195. package/dist/suspect-attribution/git-blame-reader.js +160 -0
  196. package/dist/suspect-attribution/git-blame-reader.js.map +1 -0
  197. package/dist/suspect-attribution/score-suspects.js +100 -0
  198. package/dist/suspect-attribution/score-suspects.js.map +1 -0
  199. package/dist/suspect-attribution/suspect-types.js +2 -0
  200. package/dist/suspect-attribution/suspect-types.js.map +1 -0
  201. package/dist/ticket-trackers/create-tracker.js +21 -0
  202. package/dist/ticket-trackers/create-tracker.js.map +1 -0
  203. package/dist/ticket-trackers/jira-document.js +34 -0
  204. package/dist/ticket-trackers/jira-document.js.map +1 -0
  205. package/dist/ticket-trackers/jira-tracker.js +65 -0
  206. package/dist/ticket-trackers/jira-tracker.js.map +1 -0
  207. package/dist/ticket-trackers/linear-tracker.js +109 -0
  208. package/dist/ticket-trackers/linear-tracker.js.map +1 -0
  209. package/dist/ticket-trackers/send-tracker-request.js +84 -0
  210. package/dist/ticket-trackers/send-tracker-request.js.map +1 -0
  211. package/dist/ticket-trackers/tracker-types.js +3 -0
  212. package/dist/ticket-trackers/tracker-types.js.map +1 -0
  213. package/dist/ticketing/build-ticket-comment.js +14 -0
  214. package/dist/ticketing/build-ticket-comment.js.map +1 -0
  215. package/dist/ticketing/build-ticket-draft.js +172 -0
  216. package/dist/ticketing/build-ticket-draft.js.map +1 -0
  217. package/dist/ticketing/choose-assignee.js +30 -0
  218. package/dist/ticketing/choose-assignee.js.map +1 -0
  219. package/dist/ticketing/create-ticket.js +92 -0
  220. package/dist/ticketing/create-ticket.js.map +1 -0
  221. package/dist/ticketing/describe-ticket-outcome.js +24 -0
  222. package/dist/ticketing/describe-ticket-outcome.js.map +1 -0
  223. package/dist/ticketing/read-code-owners.js +82 -0
  224. package/dist/ticketing/read-code-owners.js.map +1 -0
  225. package/dist/ticketing/render-ticket-text.js +22 -0
  226. package/dist/ticketing/render-ticket-text.js.map +1 -0
  227. package/dist/ticketing/ticket-types.js +2 -0
  228. package/dist/ticketing/ticket-types.js.map +1 -0
  229. package/dist/webhook/build-webhook-payload.js +29 -0
  230. package/dist/webhook/build-webhook-payload.js.map +1 -0
  231. package/dist/webhook/send-regression-webhooks.js +57 -0
  232. package/dist/webhook/send-regression-webhooks.js.map +1 -0
  233. package/dist/webhook/sign-webhook-body.js +16 -0
  234. package/dist/webhook/sign-webhook-body.js.map +1 -0
  235. package/dist/webhook/webhook-payload-schema.js +32 -0
  236. package/dist/webhook/webhook-payload-schema.js.map +1 -0
  237. package/migrations/001_init.sql +66 -0
  238. package/migrations/002_bookmark_history_start.sql +9 -0
  239. package/migrations/003_tickets.sql +20 -0
  240. package/migrations/004_ticket_comment_count.sql +10 -0
  241. package/migrations/005_webhook_events.sql +18 -0
  242. package/migrations/README.md +1 -0
  243. package/package.json +37 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Your Name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,38 @@
1
- # Temporary Holding Version
1
+ # Vika
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A CLI that reads server logs and git history, finds error patterns that first
4
+ appeared after a deploy, and names the suspect commit/PR with a confidence level.
5
+
6
+ ## Setup
7
+
8
+ Needs Node.js 20.12+ and Docker.
9
+
10
+ ```sh
11
+ npm install
12
+ cp .env.example .env
13
+ ```
14
+
15
+ ## Start Postgres
16
+
17
+ ```sh
18
+ docker compose up -d --wait db # dev database on localhost:5433 (data kept in a named volume)
19
+ ```
20
+
21
+ ## Run tests
22
+
23
+ Tests use a separate, throwaway database on port 5434. Its data lives in memory,
24
+ so it is wiped whenever the container stops.
25
+
26
+ ```sh
27
+ docker compose --profile test up -d --wait db-test
28
+ npm test
29
+ docker compose --profile test rm -sf db-test # throw it away
30
+ ```
31
+
32
+ ## Other scripts
33
+
34
+ ```sh
35
+ npm run typecheck # type-check src and tests
36
+ npm run build # compile src/ to dist/
37
+ node dist/cli.js --help
38
+ ```
package/dist/cli.js ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env node
2
+ // The `vika` executable. The only place that touches the real process:
3
+ // its arguments, input and output, environment, network and the clock.
4
+ import { createInterface } from "node:readline/promises";
5
+ import { runCli } from "./commands/run-cli.js";
6
+ process.exitCode = await runCli(process.argv.slice(2), {
7
+ writeOutput: (text) => process.stdout.write(text),
8
+ writeError: (text) => process.stderr.write(text),
9
+ isOutputTerminal: process.stdout.isTTY === true,
10
+ isInputTerminal: process.stdin.isTTY === true,
11
+ // Questions go to stderr, so they never mix into --json output.
12
+ ask: async (question) => {
13
+ const lineReader = createInterface({ input: process.stdin, output: process.stderr });
14
+ try {
15
+ return await lineReader.question(question);
16
+ }
17
+ finally {
18
+ lineReader.close();
19
+ }
20
+ },
21
+ fetchFunction: (url, init) => fetch(url, init),
22
+ environment: process.env,
23
+ workingDirectory: process.cwd(),
24
+ clock: () => new Date(),
25
+ // Ctrl+C (or a service manager's stop) ends `serve` cleanly: the server and
26
+ // the database pool are closed before vika exits.
27
+ waitForStopSignal: () => new Promise((resolve) => {
28
+ process.once("SIGINT", () => resolve());
29
+ process.once("SIGTERM", () => resolve());
30
+ }),
31
+ });
32
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,uEAAuE;AACvE,uEAAuE;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,CAAC,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IACrD,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;IACjD,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;IAChD,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI;IAC/C,eAAe,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI;IAC7C,gEAAgE;IAChE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;QACtB,MAAM,UAAU,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QACrF,IAAI,CAAC;YACH,OAAO,MAAM,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC;gBAAS,CAAC;YACT,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;IACH,CAAC;IACD,aAAa,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC;IAC9C,WAAW,EAAE,OAAO,CAAC,GAAG;IACxB,gBAAgB,EAAE,OAAO,CAAC,GAAG,EAAE;IAC/B,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;IACvB,4EAA4E;IAC5E,kDAAkD;IAClD,iBAAiB,EAAE,GAAG,EAAE,CACtB,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QAC5B,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACxC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3C,CAAC,CAAC;CACL,CAAC,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { describeAssignee, describeOutcome } from "../ticketing/describe-ticket-outcome.js";
2
+ export const APPROVAL_QUESTION = "Create ticket? [y]es / [n]o / [e]dit title ";
3
+ function describeDraft(draft, draftNumber, draftCount) {
4
+ const topSuspect = draft.assignmentFacts.topSuspect;
5
+ const suspectText = topSuspect === null
6
+ ? "none (no strong suspect in this deploy; may be external)"
7
+ : `${topSuspect.prNumber === null ? `commit ${topSuspect.commitSha.slice(0, 7)}` : `PR #${topSuspect.prNumber}`} by ${topSuspect.author.name}, ` +
8
+ `${topSuspect.lineNumber === null ? topSuspect.filePath : `${topSuspect.filePath}:${topSuspect.lineNumber}`}, confidence ${topSuspect.confidence}`;
9
+ return [
10
+ "",
11
+ `Ticket draft ${draftNumber} of ${draftCount}`,
12
+ ` Title: ${draft.title}`,
13
+ // A suggestion: the tracker confirms it when the ticket is filed.
14
+ ` Assignee: ${describeAssignee(draft.suggestedAssignee)}`,
15
+ ` Top suspect: ${suspectText}`,
16
+ ` Occurrences: ${draft.totalOccurrences} (log-derived)`,
17
+ "",
18
+ ].join("\n");
19
+ }
20
+ export async function approveAndCreateTickets(drafts, approvalConsole, createTicket) {
21
+ if (drafts.length === 0) {
22
+ approvalConsole.write("\nNo tickets to file: no deploy has a medium or high regression.\n");
23
+ return [];
24
+ }
25
+ if (!approvalConsole.isInteractive) {
26
+ approvalConsole.write(`\n${drafts.length} ticket ${drafts.length === 1 ? "draft" : "drafts"} not filed: approving tickets needs an interactive terminal. ` +
27
+ "Run vika report --create-tickets in a terminal.\n");
28
+ return drafts.map((draft) => ({ draft, decision: "not interactive", outcome: null }));
29
+ }
30
+ const results = [];
31
+ for (const [draftIndex, originalDraft] of drafts.entries()) {
32
+ let draft = originalDraft;
33
+ approvalConsole.write(describeDraft(draft, draftIndex + 1, drafts.length));
34
+ const answer = (await approvalConsole.ask(APPROVAL_QUESTION)).trim().toLowerCase();
35
+ if (answer === "e") {
36
+ const newTitle = (await approvalConsole.ask("New title: ")).trim();
37
+ if (newTitle !== "")
38
+ draft = { ...draft, title: newTitle };
39
+ }
40
+ else if (answer !== "y") {
41
+ approvalConsole.write("Skipped.\n");
42
+ results.push({ draft, decision: "skipped", outcome: null });
43
+ continue;
44
+ }
45
+ const outcome = await createTicket(draft);
46
+ approvalConsole.write(`${describeOutcome(outcome)}\n`);
47
+ results.push({ draft, decision: "approved", outcome });
48
+ }
49
+ return results;
50
+ }
51
+ //# sourceMappingURL=approve-and-create-tickets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approve-and-create-tickets.js","sourceRoot":"","sources":["../../src/commands/approve-and-create-tickets.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAg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,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YAC5D,SAAS;QACX,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC;QAC1C,eAAe,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACvD,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,30 @@
1
+ // `vika report --create-tickets`: after the report, turn each bad deploy into
2
+ // a ticket draft, ask a person to approve each one, and file the approved
3
+ // ones. Only this command ever talks to a tracker; `report` without the
4
+ // flag makes no tracker calls at all.
5
+ import { collectSecrets, runWithSecretsHidden } from "../configuration/hide-secrets.js";
6
+ import { openStore } from "../database/database-store.js";
7
+ import { prepareTicketDrafts } from "../pipeline/prepare-ticket-drafts.js";
8
+ import { createTracker } from "../ticket-trackers/create-tracker.js";
9
+ import { createTicket } from "../ticketing/create-ticket.js";
10
+ import { approveAndCreateTickets } from "./approve-and-create-tickets.js";
11
+ export async function runCreateTicketsCommand(options) {
12
+ const { configuration } = options;
13
+ const secrets = collectSecrets(configuration);
14
+ return runWithSecretsHidden(configuration, async () => {
15
+ const tracker = createTracker(configuration, options.fetchFunction, secrets);
16
+ if (tracker === null) {
17
+ options.approvalConsole.write('\ntracker.type is "none" in vika.yaml, so no tickets can be filed.\n');
18
+ return [];
19
+ }
20
+ const store = await openStore(configuration.databaseUrl, options.storeOptions);
21
+ try {
22
+ const drafts = await prepareTicketDrafts(store, configuration, options.report);
23
+ return await approveAndCreateTickets(drafts, options.approvalConsole, (draft) => createTicket({ store, tracker, draft, secrets }));
24
+ }
25
+ finally {
26
+ await store.close();
27
+ }
28
+ });
29
+ }
30
+ //# sourceMappingURL=create-tickets-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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K,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QACrI,CAAC;gBAAS,CAAC;YACT,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,59 @@
1
+ // `vika doctor`: checks everything vika depends on and says, in plain
2
+ // English, what to fix. Read-only: it never migrates, writes or files
3
+ // anything (a log command is run once). Exit code 1 if anything FAILs.
4
+ import { dirname } from "node:path";
5
+ import { collectSecrets, hideSecrets } from "../configuration/hide-secrets.js";
6
+ import { inspectDatabase } from "../database/database-store.js";
7
+ import { checkConfiguration } from "../doctor/check-configuration.js";
8
+ import { checkDatabase } from "../doctor/check-database.js";
9
+ import { checkDeploys } from "../doctor/check-deploys.js";
10
+ import { checkServiceLogs } from "../doctor/check-service-logs.js";
11
+ import { checkServiceRepository } from "../doctor/check-service-repository.js";
12
+ import { checkTracker } from "../doctor/check-tracker.js";
13
+ import { checkWebhook } from "../doctor/check-webhook.js";
14
+ import { readFileAtCommit } from "../suspect-attribution/git-blame-reader.js";
15
+ import { createTracker } from "../ticket-trackers/create-tracker.js";
16
+ export async function runDoctorCommand(options) {
17
+ const configurationResult = checkConfiguration(options);
18
+ const checks = [...configurationResult.checks];
19
+ const configuration = configurationResult.configuration;
20
+ if (configuration === null)
21
+ return { checks, exitCode: 1 };
22
+ const secrets = collectSecrets(configuration);
23
+ const serviceNames = Object.keys(configuration.services).sort();
24
+ const inspection = await inspectDatabase(configuration.databaseUrl, serviceNames, options.storeOptions);
25
+ const databaseName = decodeURIComponent(new URL(configuration.databaseUrl).pathname.replace(/^\//, "")) || "(none)";
26
+ checks.push(...checkDatabase(inspection, configuration.warnings, databaseName));
27
+ for (const serviceName of serviceNames) {
28
+ const serviceSettings = configuration.services[serviceName];
29
+ const storedDeploys = inspection.status === "connected" ? (inspection.deploysByService[serviceName] ?? []) : null;
30
+ const repositoryResult = await checkServiceRepository({
31
+ serviceName,
32
+ repoPath: serviceSettings.repo,
33
+ branch: serviceSettings.branch,
34
+ latestStoredDeploy: storedDeploys?.at(-1) ?? null,
35
+ });
36
+ checks.push(...repositoryResult.checks);
37
+ checks.push(...(await checkServiceLogs({
38
+ serviceName,
39
+ logs: serviceSettings.logs,
40
+ configurationDirectory: dirname(configuration.configurationFilePath),
41
+ pathMap: serviceSettings.pathMap,
42
+ doesRepoFileExist: repositoryResult.isBranchReadable
43
+ ? async (repoPath) => (await readFileAtCommit(serviceSettings.repo, serviceSettings.branch, repoPath)) !== undefined
44
+ : undefined,
45
+ ...(options.commandTimeoutMs === undefined ? {} : { commandTimeoutMs: options.commandTimeoutMs }),
46
+ })));
47
+ checks.push(...checkDeploys({ serviceName, source: serviceSettings.deploys.source, branch: serviceSettings.branch, storedDeployCount: storedDeploys?.length ?? null }));
48
+ }
49
+ checks.push(...(await checkTracker(createTracker(configuration, options.fetchFunction, secrets), secrets)));
50
+ checks.push(...checkWebhook(configuration.webhook));
51
+ // Belt and braces: no check message or fix ever shows a secret.
52
+ const maskedChecks = checks.map((check) => ({
53
+ ...check,
54
+ message: hideSecrets(check.message, secrets),
55
+ fix: check.fix === null ? null : hideSecrets(check.fix, secrets),
56
+ }));
57
+ return { checks: maskedChecks, exitCode: maskedChecks.some((check) => check.level === "FAIL") ? 1 : 0 };
58
+ }
59
+ //# sourceMappingURL=doctor-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor-command.js","sourceRoot":"","sources":["../../src/commands/doctor-command.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,uEAAuE;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAE/E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EA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,IAAI,CAAC,GAAG,YAAY,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1K,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,YAAY,CAAC,aAAa,CAAC,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5G,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAEpD,gEAAgE;IAChE,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC1C,GAAG,KAAK;QACR,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC;QAC5C,GAAG,EAAE,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC;KACjE,CAAC,CAAC,CAAC;IACJ,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1G,CAAC"}
@@ -0,0 +1,21 @@
1
+ // `vika init`: writes a starter vika.yaml and .env.example into a project
2
+ // folder, from what it can detect there. Asks nothing. Never overwrites: if
3
+ // either file already exists, it writes neither and says which one exists.
4
+ import { existsSync, writeFileSync } from "node:fs";
5
+ import { join, resolve } from "node:path";
6
+ import { detectProject } from "../project-setup/detect-project.js";
7
+ import { buildStarterEnvironmentExample, buildStarterVikaYaml, NEXT_STEPS } from "../project-setup/write-starter-files.js";
8
+ export const STARTER_FILE_NAMES = ["vika.yaml", ".env.example"];
9
+ export async function runInitCommand(options) {
10
+ const directory = resolve(options.directory);
11
+ const targetPaths = STARTER_FILE_NAMES.map((fileName) => join(directory, fileName));
12
+ const existingFiles = targetPaths.filter((targetPath) => existsSync(targetPath));
13
+ if (existingFiles.length > 0)
14
+ return { status: "refused", existingFiles };
15
+ const detection = await detectProject(directory, options.logFolders, options.readers);
16
+ const contents = [buildStarterVikaYaml(detection), buildStarterEnvironmentExample()];
17
+ // "wx": fail rather than overwrite, even if a file appeared in the meantime.
18
+ targetPaths.forEach((targetPath, fileIndex) => writeFileSync(targetPath, contents[fileIndex], { flag: "wx" }));
19
+ return { status: "written", writtenFiles: targetPaths, detection, nextSteps: NEXT_STEPS };
20
+ }
21
+ //# sourceMappingURL=init-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-command.js","sourceRoot":"","sources":["../../src/commands/init-command.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,4EAA4E;AAC5E,2EAA2E;AAC3E,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAgD,MAAM,oCAAoC,CAAC;AACjH,OAAO,EAAE,8BAA8B,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAE3H,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,cAAc,CAAU,CAAC;AAYzE,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAA2B;IAC9D,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;IACpF,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;IACjF,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;IAE1E,MAAM,SAAS,GAAG,MAAM,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACtF,MAAM,QAAQ,GAAG,CAAC,oBAAoB,CAAC,SAAS,CAAC,EAAE,8BAA8B,EAAE,CAAC,CAAC;IACrF,6EAA6E;IAC7E,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,SAAS,CAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAChH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AAC5F,CAAC"}
@@ -0,0 +1,59 @@
1
+ // `vika mark-deploy`: records that a service went live at a commit (the
2
+ // "marker" deploy source). Marking the same sha at the same time twice
3
+ // saves one row.
4
+ //
5
+ // previousSha, when not given, is the latest stored deploy before this
6
+ // one, so the range previousSha..sha is what this deploy shipped.
7
+ import { loadConfiguration } from "../configuration/load-configuration.js";
8
+ import { openStore } from "../database/database-store.js";
9
+ import { buildMarkerDeploy } from "../deploys/marker-deploys.js";
10
+ import { runWithSecretsHidden } from "../configuration/hide-secrets.js";
11
+ const FULL_SHA = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
12
+ // Full shas only: a short sha can become ambiguous as the repo grows.
13
+ function readSha(value, optionName) {
14
+ const sha = value.trim().toLowerCase();
15
+ if (!FULL_SHA.test(sha))
16
+ throw new Error(`${optionName} must be a full 40-character commit sha (got "${value}")`);
17
+ return sha;
18
+ }
19
+ function readTime(value) {
20
+ const timestampMs = Date.parse(value);
21
+ if (Number.isNaN(timestampMs))
22
+ throw new Error(`--time must be an ISO date and time, like 2026-03-06T14:00:00Z (got "${value}")`);
23
+ return new Date(timestampMs).toISOString();
24
+ }
25
+ export async function runMarkDeployCommand(options) {
26
+ // Check the arguments first: no need to touch anything if they're wrong.
27
+ const sha = readSha(options.sha, "--sha");
28
+ const previousSha = options.previousSha === undefined ? undefined : readSha(options.previousSha, "--previous-sha");
29
+ const time = options.time === undefined ? options.clock().toISOString() : readTime(options.time);
30
+ const configuration = loadConfiguration({
31
+ workingDirectory: options.workingDirectory,
32
+ ...(options.configurationPath === undefined ? {} : { configurationPath: options.configurationPath }),
33
+ ...(options.environment === undefined ? {} : { environment: options.environment }),
34
+ });
35
+ const serviceNames = Object.keys(configuration.services);
36
+ if (!serviceNames.includes(options.serviceName)) {
37
+ throw new Error(`service "${options.serviceName}" is not in ${configuration.configurationFilePath} (services: ${serviceNames.join(", ")})`);
38
+ }
39
+ return runWithSecretsHidden(configuration, async () => {
40
+ const store = await openStore(configuration.databaseUrl, options.storeOptions);
41
+ try {
42
+ // The deploy before this one: the latest stored deploy earlier in time,
43
+ // skipping this same sha (marking a deploy again must not point at itself).
44
+ const earlierDeploys = (await store.listDeploys(options.serviceName)).filter((deploy) => deploy.time < time && deploy.sha !== sha);
45
+ const deploy = buildMarkerDeploy({
46
+ service: options.serviceName,
47
+ sha,
48
+ time,
49
+ ...(previousSha === undefined ? {} : { previousSha }),
50
+ lastKnownSha: earlierDeploys.at(-1)?.sha ?? null,
51
+ });
52
+ return { deploy, isNew: await store.saveDeploy(deploy), configuration };
53
+ }
54
+ finally {
55
+ await store.close();
56
+ }
57
+ });
58
+ }
59
+ //# sourceMappingURL=mark-deploy-command.js.map
@@ -0,0 +1 @@
1
+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AAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;YACnI,MAAM,MAAM,GAAG,iBAAiB,CAAC;gBAC/B,OAAO,EAAE,OAAO,CAAC,WAAW;gBAC5B,GAAG;gBACH,IAAI;gBACJ,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;gBACrD,YAAY,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,IAAI;aACjD,CAAC,CAAC;YACH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;QAC1E,CAAC;gBAAS,CAAC;YACT,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,40 @@
1
+ // `vika report` (and `vika run`, which shares it): for every service in
2
+ // vika.yaml, read new logs, bring the deploy timeline up to date, detect
3
+ // regressions, name suspects, and build one report. A dry run as far as the
4
+ // outside world goes: it writes only to vika's own Postgres, never to a
5
+ // ticket tracker. One service failing doesn't stop the others.
6
+ import { runWithSecretsHidden } from "../configuration/hide-secrets.js";
7
+ import { loadConfiguration } from "../configuration/load-configuration.js";
8
+ import { openStore } from "../database/database-store.js";
9
+ import { runAllServices } from "../pipeline/run-all-services.js";
10
+ import { buildReport } from "../reporting/build-report.js";
11
+ import { sendRegressionWebhooks } from "../webhook/send-regression-webhooks.js";
12
+ export async function runReportCommand(options) {
13
+ const configuration = loadConfiguration({
14
+ workingDirectory: options.workingDirectory,
15
+ ...(options.configurationPath === undefined ? {} : { configurationPath: options.configurationPath }),
16
+ ...(options.environment === undefined ? {} : { environment: options.environment }),
17
+ });
18
+ return runWithSecretsHidden(configuration, async () => {
19
+ const store = await openStore(configuration.databaseUrl, options.storeOptions);
20
+ try {
21
+ const allServices = await runAllServices(store, configuration);
22
+ const report = buildReport(allServices.serviceInputs);
23
+ const webhookResult = options.webhookFetchFunction !== undefined && configuration.webhook !== null
24
+ ? await sendRegressionWebhooks({ store, webhook: configuration.webhook, report, fetchFunction: options.webhookFetchFunction })
25
+ : { deliveredCount: 0, warnings: [] };
26
+ return {
27
+ report,
28
+ configuration,
29
+ serviceStatuses: allServices.serviceStatuses,
30
+ runNotes: allServices.runNotes,
31
+ webhookWarnings: webhookResult.warnings,
32
+ webhookDeliveredCount: webhookResult.deliveredCount,
33
+ };
34
+ }
35
+ finally {
36
+ await store.close();
37
+ }
38
+ });
39
+ }
40
+ //# sourceMappingURL=report-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report-command.js","sourceRoot":"","sources":["../../src/commands/report-command.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,yEAAyE;AACzE,4EAA4E;AAC5E,wEAAwE;AACxE,+DAA+D;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAA4B,MAAM,wCAAwC,CAAC;AACrG,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAyB,MAAM,iCAAiC,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAsBhF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAA6B;IAClE,MAAM,aAAa,GAAG,iBAAiB,CAAC;QACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,GAAG,CAAC,OAAO,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,EAAE,CAAC;QACpG,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;KACnF,CAAC,CAAC;IAEH,OAAO,oBAAoB,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;QACpD,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;QAC/E,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;YAC/D,MAAM,MAAM,GAAG,WAAW,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;YACtD,MAAM,aAAa,GACjB,OAAO,CAAC,oBAAoB,KAAK,SAAS,IAAI,aAAa,CAAC,OAAO,KAAK,IAAI;gBAC1E,CAAC,CAAC,MAAM,sBAAsB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,oBAAoB,EAAE,CAAC;gBAC9H,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;YAC1C,OAAO;gBACL,MAAM;gBACN,aAAa;gBACb,eAAe,EAAE,WAAW,CAAC,eAAe;gBAC5C,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,eAAe,EAAE,aAAa,CAAC,QAAQ;gBACvC,qBAAqB,EAAE,aAAa,CAAC,cAAc;aACpD,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,197 @@
1
+ // The `vika` command line: parses arguments and runs a command. Everything
2
+ // from the outside world (output streams, environment, working directory,
3
+ // clock) is passed in, so tests can run it like a user would.
4
+ //
5
+ // Failures print one plain-English line to stderr and give exit code 1.
6
+ // Nothing printed ever contains a secret: configuration is shown through
7
+ // describeConfigurationSafely, and command errors are masked.
8
+ import { resolve } from "node:path";
9
+ import { Command, CommanderError } from "commander";
10
+ import { describeConfigurationSafely } from "../configuration/describe-configuration-safely.js";
11
+ import { formatTerminalReport } from "../reporting/format-terminal-report.js";
12
+ import { formatDoctorReport } from "../doctor/format-doctor-report.js";
13
+ import { runCreateTicketsCommand } from "./create-tickets-command.js";
14
+ import { runDoctorCommand } from "./doctor-command.js";
15
+ import { runInitCommand } from "./init-command.js";
16
+ import { parsePort, runServeCommand } from "./serve-command.js";
17
+ import { DEFAULT_DASHBOARD_PORT } from "../dashboard/dashboard-server.js";
18
+ import { runMarkDeployCommand } from "./mark-deploy-command.js";
19
+ import { runReportCommand } from "./report-command.js";
20
+ import { chooseRunExitCode, EXIT_CODE_BUSY, EXIT_CODE_OK } from "./run-exit-code.js";
21
+ export async function runCli(argumentList, cli) {
22
+ const program = new Command();
23
+ // Set before adding commands, so the commands inherit them.
24
+ program
25
+ .configureOutput({ writeOut: cli.writeOutput, writeErr: cli.writeError })
26
+ .exitOverride()
27
+ .name("vika")
28
+ .description("Find error patterns that first appeared after a deploy and name the suspect commit/PR.")
29
+ .version("0.0.0");
30
+ const commonOptions = (configurationPath) => ({
31
+ workingDirectory: cli.workingDirectory,
32
+ environment: cli.environment,
33
+ ...(configurationPath === undefined ? {} : { configurationPath }),
34
+ ...(cli.storeOptions === undefined ? {} : { storeOptions: cli.storeOptions }),
35
+ });
36
+ // The exit code when the command ran to the end; errors that stop a
37
+ // command early still give 1 (see the catch at the bottom).
38
+ let finishedExitCode = EXIT_CODE_OK;
39
+ // `report` and `run` do the same work and print the same report. `run` is
40
+ // for cron: it never asks anything unless a person is at a terminal (no
41
+ // terminal: no tickets, and it says so), and it uses exit code 2 for busy.
42
+ const runReportFlow = async (options, isRunCommand) => {
43
+ const result = await runReportCommand({
44
+ ...commonOptions(options.config),
45
+ // Only `run` posts to the webhook; `report` never does.
46
+ ...(isRunCommand ? { webhookFetchFunction: cli.fetchFunction } : {}),
47
+ });
48
+ const safeConfiguration = describeConfigurationSafely(result.configuration);
49
+ // With --json, stdout is only the JSON; everything else goes to stderr.
50
+ const writeInfo = options.json ? cli.writeError : cli.writeOutput;
51
+ writeInfo(`Configuration: ${safeConfiguration.configurationFilePath}\nDatabase: ${safeConfiguration.databaseUrl}\n`);
52
+ for (const warning of safeConfiguration.warnings)
53
+ writeInfo(`Warning: ${warning}\n`);
54
+ for (const runNote of result.runNotes)
55
+ writeInfo(`${runNote}\n`);
56
+ if (result.webhookDeliveredCount > 0)
57
+ writeInfo(`Webhook: posted ${result.webhookDeliveredCount} new ${result.webhookDeliveredCount === 1 ? "regression" : "regressions"}\n`);
58
+ for (const webhookWarning of result.webhookWarnings)
59
+ writeInfo(`Warning: ${webhookWarning}\n`);
60
+ for (const serviceStatus of result.serviceStatuses) {
61
+ if (serviceStatus.status === "failed")
62
+ writeInfo(`FAILED ${serviceStatus.serviceName}: ${serviceStatus.message}\n`);
63
+ if (serviceStatus.status === "busy")
64
+ writeInfo(`BUSY ${serviceStatus.serviceName}: ${serviceStatus.message}\n`);
65
+ }
66
+ if (options.json)
67
+ cli.writeOutput(`${JSON.stringify(result.report, null, 2)}\n`);
68
+ else
69
+ cli.writeOutput(`\n${formatTerminalReport(result.report, { useColor: cli.isOutputTerminal })}`);
70
+ let hasTicketFailure = false;
71
+ // Without the flag, nothing below runs: no tracker is even created.
72
+ if (options.createTickets) {
73
+ const ticketResults = await runCreateTicketsCommand({
74
+ configuration: result.configuration,
75
+ report: result.report,
76
+ fetchFunction: cli.fetchFunction,
77
+ // Only a person at a terminal can approve; otherwise nothing is filed.
78
+ approvalConsole: { isInteractive: cli.isInputTerminal && cli.isOutputTerminal, write: writeInfo, ask: cli.ask },
79
+ ...(cli.storeOptions === undefined ? {} : { storeOptions: cli.storeOptions }),
80
+ });
81
+ hasTicketFailure = ticketResults.some((ticketResult) => ticketResult.outcome?.status === "failed");
82
+ }
83
+ const exitCode = chooseRunExitCode(result.serviceStatuses, hasTicketFailure);
84
+ // `report` treats busy as fine (exit 0); only `run` reports it with 2.
85
+ finishedExitCode = !isRunCommand && exitCode === EXIT_CODE_BUSY ? EXIT_CODE_OK : exitCode;
86
+ };
87
+ program
88
+ .command("report")
89
+ .description("Read new logs, find regressions after deploys and name suspects. Writes only to vika's own database.")
90
+ .option("--config <path>", "path to vika.yaml (default: ./vika.yaml)")
91
+ .option("--json", "print the report as JSON")
92
+ .option("--create-tickets", "after the report, ask for approval and file one ticket per bad deploy")
93
+ .action((options) => runReportFlow(options, false));
94
+ program
95
+ .command("run")
96
+ .description("Like report, built for cron: never asks without a terminal. Exit 0 ok, 1 failure, 2 busy.")
97
+ .option("--config <path>", "path to vika.yaml (default: ./vika.yaml)")
98
+ .option("--create-tickets", "file tickets after approval; without a terminal nothing is filed")
99
+ .action((options) => runReportFlow(options, true));
100
+ program
101
+ .command("serve")
102
+ .description("Show the dashboard in a browser. Listens on 127.0.0.1 only (never 0.0.0.0), so nothing outside this computer can reach it. " +
103
+ "Shows stored data only: run `vika run` (e.g. on cron) for new data.")
104
+ .option("--config <path>", "path to vika.yaml (default: ./vika.yaml)")
105
+ .option("--port <number>", "port on 127.0.0.1", String(DEFAULT_DASHBOARD_PORT))
106
+ .action(async (options) => {
107
+ const running = await runServeCommand({ ...commonOptions(options.config), fetchFunction: cli.fetchFunction, port: parsePort(options.port) });
108
+ cli.writeOutput([
109
+ `vika dashboard: ${running.dashboard.url}`,
110
+ "Listening on 127.0.0.1 only: nothing outside this computer can reach it.",
111
+ "It shows what is stored; run `vika run` on a schedule (cron) for new data.",
112
+ "Press Ctrl+C to stop.",
113
+ "",
114
+ ].join("\n"));
115
+ try {
116
+ await (cli.waitForStopSignal?.() ?? Promise.resolve());
117
+ }
118
+ finally {
119
+ await running.stop();
120
+ cli.writeOutput("Stopped.\n");
121
+ }
122
+ });
123
+ program
124
+ .command("doctor")
125
+ .description("Check vika.yaml, the database, each service's repo, logs and deploys, and the tracker. Changes nothing.")
126
+ .option("--config <path>", "path to vika.yaml (default: ./vika.yaml)")
127
+ .action(async (options) => {
128
+ const result = await runDoctorCommand({
129
+ workingDirectory: cli.workingDirectory,
130
+ environment: cli.environment,
131
+ fetchFunction: cli.fetchFunction,
132
+ ...(options.config === undefined ? {} : { configurationPath: options.config }),
133
+ ...(cli.storeOptions === undefined ? {} : { storeOptions: cli.storeOptions }),
134
+ });
135
+ cli.writeOutput(formatDoctorReport(result.checks));
136
+ finishedExitCode = result.exitCode;
137
+ });
138
+ program
139
+ .command("init")
140
+ .description("Write a starter vika.yaml and .env.example from what vika can detect. Never overwrites.")
141
+ .option("--directory <path>", "the project folder (default: the current folder)")
142
+ .action(async (options) => {
143
+ const result = await runInitCommand({ directory: resolve(cli.workingDirectory, options.directory ?? ".") });
144
+ if (result.status === "refused") {
145
+ cli.writeError(`vika: not writing anything: ${result.existingFiles.join(" and ")} already ${result.existingFiles.length === 1 ? "exists. Edit it, or move it" : "exist. Edit them, or move them"} away and run init again.\n`);
146
+ finishedExitCode = 1;
147
+ return;
148
+ }
149
+ const { detection } = result;
150
+ cli.writeOutput([
151
+ ...result.writtenFiles.map((filePath) => `Wrote ${filePath}`),
152
+ "",
153
+ "Detected:",
154
+ ` service name: ${detection.serviceName}`,
155
+ ` git repository: ${detection.isGitRepo ? "yes" : "no (set repo in vika.yaml)"}`,
156
+ ` default branch: ${detection.defaultBranch ?? "not detected (assumed main)"}`,
157
+ ` log file: ${detection.logFiles[0]?.path ?? "not found (set logs in vika.yaml)"}`,
158
+ ` log format: ${detection.logFormat ?? "not detected"}`,
159
+ "",
160
+ result.nextSteps,
161
+ "",
162
+ ].join("\n"));
163
+ });
164
+ program
165
+ .command("mark-deploy")
166
+ .description("Record that a service went live at a commit.")
167
+ .requiredOption("--service <name>", "service name from vika.yaml")
168
+ .requiredOption("--sha <sha>", "full commit sha that went live")
169
+ .option("--previous-sha <sha>", "the sha that was live before (default: the latest stored deploy)")
170
+ .option("--time <iso>", "when it went live, e.g. 2026-03-06T14:00:00Z (default: now)")
171
+ .option("--config <path>", "path to vika.yaml (default: ./vika.yaml)")
172
+ .action(async (options) => {
173
+ const result = await runMarkDeployCommand({
174
+ ...commonOptions(options.config),
175
+ serviceName: options.service,
176
+ sha: options.sha,
177
+ ...(options.previousSha === undefined ? {} : { previousSha: options.previousSha }),
178
+ ...(options.time === undefined ? {} : { time: options.time }),
179
+ clock: cli.clock,
180
+ });
181
+ const { deploy } = result;
182
+ cli.writeOutput(`${result.isNew ? "Saved" : "Already saved"}: ${deploy.service} deploy of ${deploy.sha} at ${deploy.time}` +
183
+ ` (previous: ${deploy.previousSha ?? "none, a starting point"})\n`);
184
+ });
185
+ try {
186
+ await program.parseAsync(argumentList, { from: "user" });
187
+ return finishedExitCode;
188
+ }
189
+ catch (error) {
190
+ // Commander has already printed its own message (unknown option, --help, ...).
191
+ if (error instanceof CommanderError)
192
+ return error.exitCode;
193
+ cli.writeError(`vika: ${error instanceof Error ? error.message : String(error)}\n`);
194
+ return 1;
195
+ }
196
+ }
197
+ //# sourceMappingURL=run-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-cli.js","sourceRoot":"","sources":["../../src/commands/run-cli.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,0EAA0E;AAC1E,8DAA8D;AAC9D,EAAE;AACF,wEAAwE;AACxE,yEAAyE;AACzE,8DAA8D;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AAEhG,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAE9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAA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