@cnc-tools/storm 0.9.0 → 0.9.1

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 (80) hide show
  1. package/bin/storm.js +3 -14
  2. package/dist/application.d.ts +18 -10
  3. package/dist/application.js +10 -11
  4. package/dist/bin/storm.js +97 -41
  5. package/dist/build-info.js +1 -1
  6. package/dist/chunks/chunk-5CQCRX2L.js +5768 -0
  7. package/dist/chunks/chunk-5U5Q6VZR.js +556 -0
  8. package/dist/chunks/chunk-7O6UN63H.js +63 -0
  9. package/dist/chunks/chunk-I5GZLOLQ.js +38 -0
  10. package/dist/chunks/chunk-NX55IJ5S.js +1842 -0
  11. package/dist/chunks/chunk-OCZJE5XV.js +910 -0
  12. package/dist/chunks/chunk-RRQ2ZGSE.js +1512 -0
  13. package/dist/chunks/chunk-S5NAIZYS.js +13 -0
  14. package/dist/chunks/chunk-UHO5OCEX.js +360 -0
  15. package/dist/chunks/chunk-WBIHJM7D.js +188 -0
  16. package/dist/chunks/chunk-WV6WQFC6.js +436 -0
  17. package/dist/chunks/live-app-X3PW2W42.js +89 -0
  18. package/dist/chunks/version-X7RMSKZI.js +12 -0
  19. package/dist/commands/exec/command.js +35 -21
  20. package/dist/commands/exec/metadata.js +66 -58
  21. package/dist/commands/exec/redaction.js +1 -1
  22. package/dist/commands/exec/run-collector.d.ts +1 -1
  23. package/dist/commands/exec/run-collector.js +1 -1
  24. package/dist/commands/exec/run-record.d.ts +1 -1
  25. package/dist/commands/exec/tests-summary.d.ts +1 -1
  26. package/dist/commands/exec/worker-chart.d.ts +1 -1
  27. package/dist/commands/runs/list/command.js +136 -33
  28. package/dist/commands/runs/list/metadata.js +22 -18
  29. package/dist/commands/runs/logs/command.js +131 -48
  30. package/dist/commands/runs/logs/metadata.js +24 -20
  31. package/dist/commands/runs/metadata.js +6 -2
  32. package/dist/commands/runs/past-run.d.ts +1 -1
  33. package/dist/commands/runs/past-run.js +1 -1
  34. package/dist/commands/runs/show/command.js +396 -74
  35. package/dist/commands/runs/show/metadata.js +24 -20
  36. package/dist/commands/vitest/command.js +195 -128
  37. package/dist/commands/vitest/metadata.js +45 -37
  38. package/dist/context.d.ts +1 -1
  39. package/dist/core/events.d.ts +1 -1
  40. package/dist/core/payload.d.ts +1 -1
  41. package/dist/core/payload.js +1 -1
  42. package/dist/core/provider.d.ts +12 -2
  43. package/dist/core/run.js +1 -1
  44. package/dist/live-app.d.ts +9 -0
  45. package/dist/live-app.js +21 -0
  46. package/dist/resource-commands.d.ts +13 -0
  47. package/dist/resource-commands.js +22 -0
  48. package/dist/resources/github/provider.d.ts +1 -1
  49. package/dist/resources/testserver/command-tree.d.ts +4 -0
  50. package/dist/resources/testserver/command-tree.js +12 -0
  51. package/dist/resources/testserver/commands/create/command.js +373 -194
  52. package/dist/resources/testserver/commands/create/metadata.js +52 -48
  53. package/dist/resources/testserver/commands/list/command.js +195 -50
  54. package/dist/resources/testserver/commands/list/metadata.js +12 -8
  55. package/dist/resources/testserver/provider.d.ts +1 -1
  56. package/dist/resources/testserver/resource-provider.js +2 -8
  57. package/dist/resources.d.ts +0 -3
  58. package/dist/resources.js +5 -10
  59. package/dist/runner/recipe.js +1 -1
  60. package/dist/runner/remote-command.js +1 -1
  61. package/dist/sdk/host.d.ts +2 -0
  62. package/dist/sdk/host.js +7 -0
  63. package/dist/version.d.ts +2 -2
  64. package/dist/version.js +10 -11
  65. package/dist/vitest/config.d.ts +4 -8
  66. package/dist/vitest/config.js +5 -9
  67. package/dist/vitest/container-scope.d.ts +12 -5
  68. package/dist/vitest/container-scope.js +27 -4
  69. package/dist/vitest/diagnostics.d.ts +8 -2
  70. package/dist/vitest/diagnostics.js +7 -4
  71. package/dist/vitest/fixtures.d.ts +4 -1
  72. package/dist/vitest/fixtures.js +17 -6
  73. package/dist/vitest/plan.d.ts +1 -1
  74. package/dist/vitest/plan.js +2 -2
  75. package/dist/vitest/sandbox.d.ts +6 -0
  76. package/dist/vitest/sandbox.js +6 -0
  77. package/package.json +4 -3
  78. package/bin/node-version.js +0 -24
  79. package/dist/closed-terminal.d.ts +0 -7
  80. package/dist/closed-terminal.js +0 -18
@@ -1,22 +1,26 @@
1
- export const metadata = {
2
- description: "Print a log of a run from its run directory, as it is, on stdout. The command log holds all the output of the command: the output of its tests, and output that no test owns, such as the output of a beforeAll, a global setup, a raw write to stdout or stderr, or a child process. A step log holds the output of one step of a runner run: install, build, apply or snapshot. Each line of a step log starts with its time. Without an id, it prints a log of the newest run of the storm.config.ts found from the working directory, or of every config with --all. That run can still be going: then it prints the log as it is now. Changes nothing.",
3
- summary: "Print the command log or a step log of a run.",
4
- usages: ["[<id>] [--step command|install|build|apply|snapshot] [--all]"],
5
- fields: {
6
- id: {
7
- valueLabel: "id",
8
- description: "The run id, such as 20261103T192655-8277, which `storm vitest`, `storm exec` and `storm runs list` print.",
9
- },
10
- step: {
11
- valueLabel: "STEP",
12
- description: "The log to print: command (the default) for the output of the command, or install, build, apply or snapshot for the log of that step.",
13
- },
14
- all: { description: "Without an id, use the newest run of any config file." },
1
+ // src/commands/runs/logs/metadata.ts
2
+ var metadata = {
3
+ description: "Print a log of a run from its run directory, as it is, on stdout. The command log holds all the output of the command: the output of its tests, and output that no test owns, such as the output of a beforeAll, a global setup, a raw write to stdout or stderr, or a child process. A step log holds the output of one step of a runner run: install, build, apply or snapshot. Each line of a step log starts with its time. Without an id, it prints a log of the newest run of the storm.config.ts found from the working directory, or of every config with --all. That run can still be going: then it prints the log as it is now. Changes nothing.",
4
+ summary: "Print the command log or a step log of a run.",
5
+ usages: ["[<id>] [--step command|install|build|apply|snapshot] [--all]"],
6
+ fields: {
7
+ id: {
8
+ valueLabel: "id",
9
+ description: "The run id, such as 20261103T192655-8277, which `storm vitest`, `storm exec` and `storm runs list` print."
15
10
  },
16
- examples: [
17
- { argv: "20261103T192655-8277", description: "Print the command log of a run." },
18
- { argv: "", description: "Print the command log of the newest run. Pipe it to grep to find lines." },
19
- { argv: "20261103T192655-8277 --step install", description: "Print the install log of a runner run." },
20
- { argv: "20261103T192655-8277 --json", description: "Print the command log as JSON, with its path." },
21
- ],
11
+ step: {
12
+ valueLabel: "STEP",
13
+ description: "The log to print: command (the default) for the output of the command, or install, build, apply or snapshot for the log of that step."
14
+ },
15
+ all: { description: "Without an id, use the newest run of any config file." }
16
+ },
17
+ examples: [
18
+ { argv: "20261103T192655-8277", description: "Print the command log of a run." },
19
+ { argv: "", description: "Print the command log of the newest run. Pipe it to grep to find lines." },
20
+ { argv: "20261103T192655-8277 --step install", description: "Print the install log of a runner run." },
21
+ { argv: "20261103T192655-8277 --json", description: "Print the command log as JSON, with its path." }
22
+ ]
23
+ };
24
+ export {
25
+ metadata
22
26
  };
@@ -1,3 +1,7 @@
1
- export const metadata = {
2
- description: "Read past runs back from their run directories.",
1
+ // src/commands/runs/metadata.ts
2
+ var metadata = {
3
+ description: "Read past runs back from their run directories."
4
+ };
5
+ export {
6
+ metadata
3
7
  };
@@ -1,7 +1,7 @@
1
1
  import type { z } from "zod";
2
2
  import type { ListedRunDirectory, PastRunDirectory } from "../../core/index.ts";
3
3
  import type { StormTimeline } from "../../resources.ts";
4
- import { type TestEvent, type TestResultEvent } from "../../sdk/index.ts";
4
+ import { type TestEvent, type TestResultEvent } from "../../sdk/host.ts";
5
5
  import { timelineSchema } from "../exec/outcomes.ts";
6
6
  import { type RunRecord } from "../exec/run-record.ts";
7
7
  /**
@@ -2,7 +2,7 @@
2
2
  // `run.json`, `tests.jsonl` and `timeline.json` say, and how a person reads those facts. Pure: the commands hand it
3
3
  // what the run directory gateway read. Files it can't read, or from an older storm, leave facts unknown, never
4
4
  // an error.
5
- import { parseTestEvent } from "../../sdk/index.js";
5
+ import { parseTestEvent } from "../../sdk/host.js";
6
6
  import { timelineSchema } from "../exec/outcomes.js";
7
7
  import { parseRunRecord } from "../exec/run-record.js";
8
8
  /** The scope for `--all` and the config file found from the working directory, if any. */
@@ -1,76 +1,398 @@
1
+ import {
2
+ waterfallLines
3
+ } from "../../../chunks/chunk-WV6WQFC6.js";
4
+ import {
5
+ LOG_STEPS,
6
+ commandText,
7
+ exitText,
8
+ exitTone,
9
+ finalResults,
10
+ gitText,
11
+ keptText,
12
+ newestFinished,
13
+ pastRun,
14
+ runFacts,
15
+ runFactsSchema,
16
+ runNotFound,
17
+ runScope,
18
+ runsInScope,
19
+ runsUnreadable,
20
+ scopeFacts,
21
+ scopeSchema,
22
+ selected,
23
+ startedText,
24
+ timelineFromFacts,
25
+ tookText,
26
+ totalsText,
27
+ totalsTone
28
+ } from "../../../chunks/chunk-UHO5OCEX.js";
29
+ import {
30
+ timelineSchema
31
+ } from "../../../chunks/chunk-5U5Q6VZR.js";
32
+ import {
33
+ RESOURCE_REPORTS,
34
+ short
35
+ } from "../../../chunks/chunk-NX55IJ5S.js";
36
+ import {
37
+ findConfigFile
38
+ } from "../../../chunks/chunk-OCZJE5XV.js";
39
+ import {
40
+ runLogFile
41
+ } from "../../../chunks/chunk-5CQCRX2L.js";
42
+ import "../../../chunks/chunk-S5NAIZYS.js";
43
+
44
+ // src/commands/runs/show/command.ts
45
+ import { z as z2 } from "zod";
46
+
47
+ // src/commands/runs/show/outcomes.ts
48
+ import { capsFor } from "@vercel/clinkr/vcli-kit";
49
+ import { bold, paint } from "@vercel/clinkr/vcli-kit/theme";
50
+ import { defineOutcomes } from "@vercel/clinkr";
1
51
  import { z } from "zod";
2
- import { findConfigFile } from "../../../config/index.js";
3
- import { runLogFile } from "../../../core/index.js";
4
- import { LOG_STEPS, runFacts, scopeFacts } from "../facts.js";
5
- import { finalResults, newestFinished, pastRun, runScope, runsInScope, selected } from "../past-run.js";
6
- import { outcomes } from "./outcomes.js";
7
- /**
8
- * Shows a past run: run `id`, or without one the newest finished run of the config file found from the working
9
- * directory, or of every run with `--all` or when none is found. It reads the run's `run.json`, its `timeline.json`,
10
- * its `tests.jsonl`, which the run writes redacted once it is over, and which run logs it has, and changes nothing. `--failed` and
11
- * `--test` select tests whose errors and test output it shows.
12
- */
13
- export function command(cmd) {
14
- return cmd.define({
15
- requestSchema: z.object({
16
- id: z.string().min(1).optional(),
17
- failed: z.boolean().default(false),
18
- test: z.string().min(1).optional(),
19
- all: z.boolean().default(false),
20
- }),
21
- cli: { positionals: ["id"] },
22
- response: outcomes,
23
- handler: async ({ app }, request) => {
24
- const now = app.context.clock.now();
25
- let id = request.id;
26
- if (id === undefined) {
27
- const listed = await app.context.runDirectories.list({ now });
28
- if (!listed.ok)
29
- return outcomes.runsUnreadable({ ...listed.failure });
30
- const scope = runScope(request.all, await findConfigFile(app.context.config, app.cwd));
31
- const newest = newestFinished(runsInScope(listed.runs, scope));
32
- if (newest === undefined)
33
- return outcomes.noRuns({ scope: scopeFacts(scope) });
34
- id = newest.id;
35
- }
36
- const read = await app.context.runDirectories.read({ id, now });
37
- if (read.kind === "failed")
38
- return outcomes.runsUnreadable({ ...read.failure });
39
- if (read.kind === "not-found")
40
- return outcomes.runNotFound({ id });
41
- const run = pastRun(read.directory);
42
- const filters = { failed: request.failed, test: request.test };
43
- const selecting = request.failed || request.test !== undefined;
44
- return outcomes.shown({
45
- ...runFacts(run, now),
46
- finished: run.finished,
47
- logs: LOG_STEPS.filter((step) => read.directory.logs.includes(step)).map((step) => ({
48
- step,
49
- path: `${run.path}/${runLogFile(step)}`,
50
- })),
51
- unreadableTestLines: run.unreadableTestLines,
52
- timeline: run.timeline ?? null,
53
- selection: { failed: request.failed, test: request.test ?? null },
54
- tests: finalResults(run.events).map((result) => {
55
- const chosen = selecting && selected(result, filters);
56
- return {
57
- id: result.id,
58
- file: result.file,
59
- test: result.test,
60
- state: result.state,
61
- retryCount: result.retryCount,
62
- flaky: result.flaky,
63
- errors: (result.errors ?? []).map((error) => ({
64
- name: error.name,
65
- message: error.message,
66
- stack: error.stack ?? null,
67
- diff: error.diff ?? null,
68
- })),
69
- selected: chosen,
70
- output: chosen && result.output !== undefined ? { ...result.output } : null,
71
- };
72
- }),
73
- });
74
- },
75
- });
52
+ var testSchema = z.object({
53
+ /** Vitest's id for the test, unique within the run. */
54
+ id: z.string(),
55
+ /** The test file, relative to the project. */
56
+ file: z.string(),
57
+ /** The test's full name. */
58
+ test: z.string(),
59
+ /** How it finally ended. */
60
+ state: z.enum(["pass", "fail", "skip"]),
61
+ /** How many times it was retried. */
62
+ retryCount: z.number(),
63
+ /** Whether it passed on a retry. */
64
+ flaky: z.boolean(),
65
+ /** Its errors: a failed test's, or a flaky pass's retries'. */
66
+ errors: z.array(
67
+ z.object({ name: z.string(), message: z.string(), stack: z.string().nullable(), diff: z.string().nullable() })
68
+ ),
69
+ /** Whether --failed or --test selected it. */
70
+ selected: z.boolean(),
71
+ /**
72
+ * Its test output, for a selected test that printed any: the last characters of what it printed (`text`) and how
73
+ * many earlier ones were dropped (`droppedChars`); null otherwise.
74
+ */
75
+ output: z.object({ text: z.string(), droppedChars: z.number() }).nullable()
76
+ });
77
+ var shownSchema = runFactsSchema.extend({
78
+ /** Whether the run finished, so its test results were saved. */
79
+ finished: z.boolean(),
80
+ /** The run logs it has, which `storm runs logs <id> --step <step>` prints: the command log (`command`) and each step's. */
81
+ logs: z.array(z.object({ step: z.enum(LOG_STEPS), path: z.string() })),
82
+ /** How many lines of its tests.jsonl held no test event. */
83
+ unreadableTestLines: z.number(),
84
+ /** Its waterfall, as its timeline.json holds it; null when it has none storm can read. */
85
+ timeline: timelineSchema.nullable(),
86
+ /** The tests --failed and --test select. */
87
+ selection: z.object({ failed: z.boolean(), test: z.string().nullable() }),
88
+ /** Each test's final result, in the order the run reported them. */
89
+ tests: z.array(testSchema)
90
+ });
91
+ var outcomes = defineOutcomes({
92
+ results: {
93
+ shown: {
94
+ schema: shownSchema,
95
+ description: "The run, its waterfall, and its tests, with the selected tests' errors and test output.",
96
+ render: (shown) => shownRendered(shown)
97
+ }
98
+ },
99
+ errors: {
100
+ runsUnreadable,
101
+ runNotFound,
102
+ noRuns: {
103
+ exitCode: 1,
104
+ description: "Without an id, no run in the scope has finished.",
105
+ schema: z.object({
106
+ /** Which runs it looked through. */
107
+ scope: scopeSchema
108
+ }),
109
+ render: ({ scope }) => scope.kind === "config" ? {
110
+ message: `Couldn't find a finished run of ${scope.configFile}.`,
111
+ next: [
112
+ {
113
+ type: "command",
114
+ argv: ["storm", "runs", "show", "--all"],
115
+ label: "Show the newest finished run of any config file"
116
+ }
117
+ ]
118
+ } : {
119
+ message: "Couldn't find a finished run.",
120
+ next: [{ type: "text", text: "Start one with storm vitest or storm exec." }]
121
+ }
122
+ }
123
+ }
124
+ });
125
+ var WATERFALL_WIDTH = 80;
126
+ var LABEL_WIDTH = 16;
127
+ var NO_PAINT = { tone: (_intent, text) => text, strong: (text) => text };
128
+ function painterFor(caps) {
129
+ if (caps.colorDepth === "none") return NO_PAINT;
130
+ return { tone: (intent, text) => text === "" ? text : paint(caps, intent, text), strong: (text) => bold(text) };
76
131
  }
132
+ function shownRendered(shown) {
133
+ return {
134
+ content: { text: shownText(shown, NO_PAINT) },
135
+ draw: (terminal) => ({ report: "", answer: shownText(shown, painterFor(capsFor(terminal.stdout, terminal))) })
136
+ };
137
+ }
138
+ function shownText(shown, p) {
139
+ const exitColor = exitTone(shown);
140
+ const totalsColor = totalsTone(shown);
141
+ const exit = exitText(shown);
142
+ const totals = totalsText(shown);
143
+ const facts = [
144
+ ["Run", shown.id],
145
+ ["Command", commandText(shown)],
146
+ ["Config", shown.configFile ?? (shown.argv === null ? "-" : "none")],
147
+ ["Directory", shown.cwd ?? "-"],
148
+ ["Git", gitText(shown)],
149
+ ["Started", startedText(shown)],
150
+ ["Took", tookText(shown)],
151
+ ["Exit", exitColor === void 0 ? exit : { text: exit, tone: exitColor }],
152
+ ["Tests", totalsColor === void 0 ? totals : { text: totals, tone: totalsColor }],
153
+ ["Run directory", `${shown.path}/`],
154
+ ...logsRows(shown)
155
+ ];
156
+ const blocks = [rowLines(facts, p)];
157
+ const where = [...whereRows(shown), ...RESOURCE_REPORTS.ranRows(shown.ended?.resources ?? {})];
158
+ if (where.length > 0) blocks.push(rowLines(where, p));
159
+ if (shown.timeline !== null && shown.timeline.rows.length > 0)
160
+ blocks.push(waterfallLines(timelineFromFacts(shown.timeline), { width: WATERFALL_WIDTH, logs: void 0 }));
161
+ const note = (text) => [` ${p.tone("muted", text)}`];
162
+ if (!shown.finished) {
163
+ blocks.push(
164
+ note(
165
+ shown.active ? "The run is still going. Its test results are saved once it finishes." : "The run didn't finish, so its test results weren't saved."
166
+ )
167
+ );
168
+ return joinBlocks(blocks);
169
+ }
170
+ const { failed, test } = shown.selection;
171
+ const selecting = failed || test !== null;
172
+ const chosen = shown.tests.filter((each) => each.selected);
173
+ if (shown.tests.length === 0) blocks.push(note("No final test results."));
174
+ else if (!selecting) blocks.push(testTable(shown.tests, p));
175
+ else if (chosen.length > 0)
176
+ blocks.push([
177
+ ...testTable(chosen, p),
178
+ ` ${p.tone("muted", `${chosen.length} of ${shown.tests.length} ${shown.tests.length === 1 ? "test" : "tests"}`)}`
179
+ ]);
180
+ if (shown.unreadableTestLines > 0)
181
+ blocks.push(note(`${shown.unreadableTestLines} lines of tests.jsonl held no test event.`));
182
+ const incomplete = shown.ended?.testsIncomplete ?? null;
183
+ if (incomplete !== null)
184
+ blocks.push(
185
+ note(
186
+ `The test results may be incomplete: storm couldn't read the test events file once the command ended: ${incomplete}`
187
+ )
188
+ );
189
+ if (selecting) {
190
+ if (chosen.length === 0)
191
+ blocks.push(
192
+ note(
193
+ failed && test === null ? "No test failed." : `No ${failed ? "failed " : ""}test's name or file holds ${JSON.stringify(test)}.`
194
+ )
195
+ );
196
+ for (const each of chosen) blocks.push(testSection(each, p));
197
+ }
198
+ return joinBlocks(blocks);
199
+ }
200
+ function logsRows(shown) {
201
+ if (shown.logs.length === 0) return [];
202
+ const width = Math.max(...shown.logs.map(({ step }) => step.length));
203
+ return [["Logs", shown.logs.map(({ step }) => `${step.padEnd(width)} storm runs logs ${shown.id} --step ${step}`)]];
204
+ }
205
+ function rowLines(rows, p) {
206
+ return rows.flatMap(([label, value]) => {
207
+ const [first = "", ...rest] = isLineList(value) ? value : [value];
208
+ const gutter = ` ${" ".repeat(LABEL_WIDTH)}`;
209
+ return [
210
+ ` ${p.tone("muted", label)}${" ".repeat(Math.max(0, LABEL_WIDTH - label.length))}${lineText(first, p)}`,
211
+ ...rest.map((line) => `${gutter}${lineText(line, p)}`)
212
+ ];
213
+ });
214
+ }
215
+ function isLineList(value) {
216
+ return Array.isArray(value);
217
+ }
218
+ var URL_PATTERN = /https?:\/\/\S+/g;
219
+ function lineText(line, p) {
220
+ if (typeof line !== "string") return p.tone(line.tone, line.text);
221
+ return line.replace(URL_PATTERN, (url) => p.tone("accent", url));
222
+ }
223
+ function whereRows(shown) {
224
+ const { where, ended } = shown;
225
+ if (where === null) return [];
226
+ if (where.kind === "local") return [["Ran on", "this machine"]];
227
+ const shape = `${where.region}, ${where.vcpus} vCPUs, ${where.runtime}`;
228
+ const sandbox = where.sandbox !== null ? `runner sandbox ${where.sandbox} (${shape})` : ended === null ? `runner sandbox (${shape})` : `runner sandbox, none started (${shape})`;
229
+ const { snapshot } = where;
230
+ return [
231
+ ["Ran in", sandbox],
232
+ ...where.sandboxUrl === null ? [] : [["Sandbox page", where.sandboxUrl]],
233
+ ...keptRows(shown),
234
+ ["Vercel project", `${where.team}/${where.project}`],
235
+ ["Base", `${short(where.base)}, HEAD's merge-base with ${where.baseRef}`],
236
+ ...snapshot === null ? [] : [
237
+ [
238
+ "Snapshot",
239
+ [
240
+ `${snapshot.id} of ${short(snapshot.base)}, ${snapshot.built ? "built" : "reused"}${snapshot.branch === null || snapshot.head === null ? "" : `, branch ${snapshot.branch} at ${short(snapshot.head)}`}`,
241
+ ` ${snapshot.url}`
242
+ ]
243
+ ]
244
+ ],
245
+ ...saveRows(where.save)
246
+ ];
247
+ }
248
+ var SAVE_STEPS = { scrub: "scrub", "save-snapshot": "save" };
249
+ function saveRows(save) {
250
+ if (save === null) return [];
251
+ switch (save.kind) {
252
+ case "saved":
253
+ return [
254
+ [
255
+ "Saved",
256
+ [
257
+ `${save.snapshotId} of ${short(save.base)}, branch ${save.branch} at ${short(save.head)}${save.entryWritten ? "" : ", not in the cache"}`,
258
+ ` ${save.url}`
259
+ ]
260
+ ]
261
+ ];
262
+ case "skipped":
263
+ return [["Saved", { text: "nothing: HEAD was detached", tone: "muted" }]];
264
+ case "failed":
265
+ return [["Saved", { text: `nothing: the ${SAVE_STEPS[save.step]} failed: ${save.message}`, tone: "muted" }]];
266
+ case "stopped":
267
+ return [["Saved", { text: "nothing: the run stopped", tone: "muted" }]];
268
+ }
269
+ }
270
+ function keptRows(shown) {
271
+ const kept = keptText(shown);
272
+ if (kept === void 0 || shown.where?.kind !== "runner") return [];
273
+ const { sandboxUrl, keptMinutesLeft } = shown.where;
274
+ if (sandboxUrl === null || keptMinutesLeft === null || keptMinutesLeft === 0)
275
+ return [["Sandbox kept", { text: kept, tone: "muted" }]];
276
+ return [["Sandbox kept", [{ text: kept, tone: "success" }, `connect: ${sandboxUrl}/connect`]]];
277
+ }
278
+ var STATE_TONES = { pass: "success", fail: "error", skip: "muted" };
279
+ function testTable(tests, p) {
280
+ const header = ["STATE", "RETRIES", "FLAKY", "FILE", "TEST"];
281
+ const rows = tests.map((each) => [
282
+ each.state,
283
+ String(each.retryCount),
284
+ each.flaky ? "yes" : "no",
285
+ each.file,
286
+ each.test
287
+ ]);
288
+ const widths = header.map((_, column) => Math.max(...[header, ...rows].map((row) => row[column]?.length ?? 0)));
289
+ const line = (cells, paintCell) => ` ${cells.map(
290
+ (cell, column) => column === cells.length - 1 ? paintCell(cell, column) : `${paintCell(cell, column)}${" ".repeat((widths[column] ?? 0) - cell.length)}`
291
+ ).join(" ")}`.trimEnd();
292
+ return [
293
+ line(header, (cell) => p.strong(cell)),
294
+ ...tests.map(
295
+ (each, index) => line(
296
+ rows[index] ?? [],
297
+ (cell, column) => column === 0 ? p.tone(STATE_TONES[each.state], cell) : column === 2 && each.flaky ? p.tone("warn", cell) : cell
298
+ )
299
+ )
300
+ ];
301
+ }
302
+ function testSection(test, p) {
303
+ const retried = test.retryCount === 0 ? "" : ` \xB7 retried ${test.retryCount}${test.flaky ? ", flaky" : ""}`;
304
+ const lines = [
305
+ `${p.tone(STATE_TONES[test.state], test.state)}${p.strong(` \xB7 ${test.file} \xB7 ${test.test}${retried}`)}`
306
+ ];
307
+ for (const error of test.errors) {
308
+ const [first = "", ...rest] = error.message.replace(/\n+$/, "").split("\n");
309
+ lines.push(` ${p.tone("error", `${error.name}: ${first}`)}`, ...indented(rest.join("\n"), 4));
310
+ if (error.stack !== null)
311
+ lines.push(` ${p.tone("muted", "stack:")}`, ...indented(error.stack, 4).map((line) => p.tone("muted", line)));
312
+ if (error.diff !== null)
313
+ lines.push(` ${p.tone("muted", "diff:")}`, ...indented(error.diff, 4).map((line) => diffLine(line, p)));
314
+ }
315
+ if (test.output === null) lines.push(` ${p.tone("muted", "no test output")}`);
316
+ else {
317
+ const dropped = test.output.droppedChars === 0 ? "" : `, the last ${test.output.text.length} characters (${test.output.droppedChars} earlier ones dropped)`;
318
+ lines.push(` ${p.tone("muted", `test output${dropped}:`)}`, ...indented(test.output.text, 4));
319
+ }
320
+ return lines;
321
+ }
322
+ function diffLine(line, p) {
323
+ const marker = line.trimStart()[0];
324
+ return marker === "+" ? p.tone("success", line) : marker === "-" ? p.tone("error", line) : line;
325
+ }
326
+ function indented(text, by) {
327
+ const trimmed = text.replace(/\n+$/, "");
328
+ if (trimmed === "") return [];
329
+ return trimmed.split("\n").map((line) => line === "" ? "" : `${" ".repeat(by)}${line}`);
330
+ }
331
+ function joinBlocks(blocks) {
332
+ return blocks.map((block) => block.join("\n")).join("\n\n");
333
+ }
334
+
335
+ // src/commands/runs/show/command.ts
336
+ function command(cmd) {
337
+ return cmd.define({
338
+ requestSchema: z2.object({
339
+ id: z2.string().min(1).optional(),
340
+ failed: z2.boolean().default(false),
341
+ test: z2.string().min(1).optional(),
342
+ all: z2.boolean().default(false)
343
+ }),
344
+ cli: { positionals: ["id"] },
345
+ response: outcomes,
346
+ handler: async ({ app }, request) => {
347
+ const now = app.context.clock.now();
348
+ let id = request.id;
349
+ if (id === void 0) {
350
+ const listed = await app.context.runDirectories.list({ now });
351
+ if (!listed.ok) return outcomes.runsUnreadable({ ...listed.failure });
352
+ const scope = runScope(request.all, await findConfigFile(app.context.config, app.cwd));
353
+ const newest = newestFinished(runsInScope(listed.runs, scope));
354
+ if (newest === void 0) return outcomes.noRuns({ scope: scopeFacts(scope) });
355
+ id = newest.id;
356
+ }
357
+ const read = await app.context.runDirectories.read({ id, now });
358
+ if (read.kind === "failed") return outcomes.runsUnreadable({ ...read.failure });
359
+ if (read.kind === "not-found") return outcomes.runNotFound({ id });
360
+ const run = pastRun(read.directory);
361
+ const filters = { failed: request.failed, test: request.test };
362
+ const selecting = request.failed || request.test !== void 0;
363
+ return outcomes.shown({
364
+ ...runFacts(run, now),
365
+ finished: run.finished,
366
+ logs: LOG_STEPS.filter((step) => read.directory.logs.includes(step)).map((step) => ({
367
+ step,
368
+ path: `${run.path}/${runLogFile(step)}`
369
+ })),
370
+ unreadableTestLines: run.unreadableTestLines,
371
+ timeline: run.timeline ?? null,
372
+ selection: { failed: request.failed, test: request.test ?? null },
373
+ tests: finalResults(run.events).map((result) => {
374
+ const chosen = selecting && selected(result, filters);
375
+ return {
376
+ id: result.id,
377
+ file: result.file,
378
+ test: result.test,
379
+ state: result.state,
380
+ retryCount: result.retryCount,
381
+ flaky: result.flaky,
382
+ errors: (result.errors ?? []).map((error) => ({
383
+ name: error.name,
384
+ message: error.message,
385
+ stack: error.stack ?? null,
386
+ diff: error.diff ?? null
387
+ })),
388
+ selected: chosen,
389
+ output: chosen && result.output !== void 0 ? { ...result.output } : null
390
+ };
391
+ })
392
+ });
393
+ }
394
+ });
395
+ }
396
+ export {
397
+ command
398
+ };
@@ -1,22 +1,26 @@
1
- export const metadata = {
2
- description: "Show a past run from its run directory: its command, config file, working directory, the branch and commit it started from, start, how long it took and how it ended; where its command ran, on this machine or in a runner sandbox, with the sandbox's name, region, vCPUs, runtime and page in the Vercel dashboard, until when the run kept it running, with its Connect page while it runs, its control plane team and project, the run's base and the runner snapshot it started from, with a branch snapshot's branch and commit, and its page, and the branch snapshot the run saved, with its page, or why it saved none; each Testserver sandbox it used, with its log viewer URL; the run logs it has, each with the storm runs logs command that prints it; its waterfall; and each test's final result, in color on a terminal that takes it. With --failed or --test, only the selected tests, how many of all they are, and each one's errors and test output, the last 8 MiB of what it printed, failure reports included. Without an id, the newest finished run of the storm.config.ts found from the working directory, or of every config with --all; pass the id `storm vitest` or `storm exec` printed when another run may have finished since. A run's test results are saved once it finishes. Changes nothing.",
3
- summary: "Show a past run and its tests.",
4
- usages: ["[<id>] [--failed] [--test <TEXT>] [--all]"],
5
- fields: {
6
- id: {
7
- valueLabel: "id",
8
- description: "The run id, such as 20261103T192655-8277, which `storm vitest`, `storm exec` and `storm runs list` print.",
9
- },
10
- failed: { description: "Show each failed test's errors and test output." },
11
- test: {
12
- valueLabel: "TEXT",
13
- description: "Show the errors and test output of each test whose full name or file holds TEXT, in any state; with --failed, only failed ones.",
14
- },
15
- all: { description: "Without an id, show the newest finished run of any config file." },
1
+ // src/commands/runs/show/metadata.ts
2
+ var metadata = {
3
+ description: "Show a past run from its run directory: its command, config file, working directory, the branch and commit it started from, start, how long it took and how it ended; where its command ran, on this machine or in a runner sandbox, with the sandbox's name, region, vCPUs, runtime and page in the Vercel dashboard, until when the run kept it running, with its Connect page while it runs, its control plane team and project, the run's base and the runner snapshot it started from, with a branch snapshot's branch and commit, and its page, and the branch snapshot the run saved, with its page, or why it saved none; each Testserver sandbox it used, with its log viewer URL; the run logs it has, each with the storm runs logs command that prints it; its waterfall; and each test's final result, in color on a terminal that takes it. With --failed or --test, only the selected tests, how many of all they are, and each one's errors and test output, the last 8 MiB of what it printed, failure reports included. Without an id, the newest finished run of the storm.config.ts found from the working directory, or of every config with --all; pass the id `storm vitest` or `storm exec` printed when another run may have finished since. A run's test results are saved once it finishes. Changes nothing.",
4
+ summary: "Show a past run and its tests.",
5
+ usages: ["[<id>] [--failed] [--test <TEXT>] [--all]"],
6
+ fields: {
7
+ id: {
8
+ valueLabel: "id",
9
+ description: "The run id, such as 20261103T192655-8277, which `storm vitest`, `storm exec` and `storm runs list` print."
16
10
  },
17
- examples: [
18
- { argv: "20261103T192655-8277 --failed", description: "Show a run and its failed tests' errors and output." },
19
- { argv: "--test whoami", description: "Show the newest run, and the output of every test about whoami." },
20
- { argv: "20261103T192655-8277 --json", description: "Show a run as JSON." },
21
- ],
11
+ failed: { description: "Show each failed test's errors and test output." },
12
+ test: {
13
+ valueLabel: "TEXT",
14
+ description: "Show the errors and test output of each test whose full name or file holds TEXT, in any state; with --failed, only failed ones."
15
+ },
16
+ all: { description: "Without an id, show the newest finished run of any config file." }
17
+ },
18
+ examples: [
19
+ { argv: "20261103T192655-8277 --failed", description: "Show a run and its failed tests' errors and output." },
20
+ { argv: "--test whoami", description: "Show the newest run, and the output of every test about whoami." },
21
+ { argv: "20261103T192655-8277 --json", description: "Show a run as JSON." }
22
+ ]
23
+ };
24
+ export {
25
+ metadata
22
26
  };