sedum-cli 0.1.0-alpha.0 → 0.1.0-alpha.10
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.
- package/README.md +64 -0
- package/dist/affected-selection-ENIH4AGP.js +206 -0
- package/dist/{chunk-TU5MIKGA.js → chunk-4LEXNO2M.js} +502 -187
- package/dist/chunk-7M7YUTRH.js +132 -0
- package/dist/{chunk-BEV24G7S.js → chunk-EFRMSNBD.js} +37 -171
- package/dist/{chunk-OB6ZUJ6X.js → chunk-H4QXVVQI.js} +83 -22
- package/dist/chunk-NOGCXR4U.js +208 -0
- package/dist/{chunk-TZGSCV23.js → chunk-VNGIF7AY.js} +186 -15
- package/dist/cli.js +31 -5
- package/dist/{doctor-command-2PMOA32Y.js → doctor-command-XRE6PEGU.js} +2 -2
- package/dist/index.d.ts +54 -11
- package/dist/index.js +11 -4
- package/dist/{init-command-54R2FQ2U.js → init-command-SXAVPVX6.js} +38 -20
- package/dist/run-command-DEWAPQML.js +1605 -0
- package/package.json +23 -4
- package/dist/run-command-VAVFPCWG.js +0 -1269
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MAX_PARALLEL,
|
|
3
3
|
clearLocatorCache,
|
|
4
|
-
parseParallel
|
|
4
|
+
parseParallel
|
|
5
|
+
} from "./chunk-EFRMSNBD.js";
|
|
6
|
+
import {
|
|
7
|
+
configDiagnostic,
|
|
8
|
+
createCliProvider,
|
|
5
9
|
renderDiagnostic
|
|
6
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-NOGCXR4U.js";
|
|
7
11
|
import {
|
|
8
12
|
ProjectConfigError,
|
|
9
13
|
discoverConfiguredTests,
|
|
10
14
|
loadProjectConfig
|
|
11
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-VNGIF7AY.js";
|
|
16
|
+
|
|
17
|
+
// src/invocation.ts
|
|
18
|
+
function sedumCommand(env = process.env, script = process.argv[1] ?? "") {
|
|
19
|
+
if (env.npm_command === "exec" || env.npm_lifecycle_event === "npx")
|
|
20
|
+
return "npx sedum";
|
|
21
|
+
return /[\\/]node_modules[\\/]/.test(script) ? "npx sedum" : "sedum";
|
|
22
|
+
}
|
|
23
|
+
var SUBCOMMAND = /(?<![\w./-]|npx )sedum (?=(?:run|browsers|doctor|validate|init|list)\b|--help\b|--version\b)/g;
|
|
24
|
+
function withCommand(text, command) {
|
|
25
|
+
return command === "sedum" ? text : text.replace(SUBCOMMAND, `${command} `);
|
|
26
|
+
}
|
|
12
27
|
|
|
13
28
|
// src/exit-policy.ts
|
|
14
29
|
import {
|
|
@@ -33,6 +48,7 @@ function listExitCode(listing, failedBeforeListing) {
|
|
|
33
48
|
|
|
34
49
|
// src/output.ts
|
|
35
50
|
import { validateRunResult as validateRunResult2 } from "@sedum-dev/core";
|
|
51
|
+
import { testLabel, usageLines, visionSummary } from "@sedum-dev/reporters";
|
|
36
52
|
var ansi = {
|
|
37
53
|
green: "\x1B[32m",
|
|
38
54
|
red: "\x1B[31m",
|
|
@@ -50,16 +66,16 @@ function stateLabel(state, verdict) {
|
|
|
50
66
|
if (state === "running") return { text: "INCOMPLETE", color: "yellow" };
|
|
51
67
|
return { text: "ERROR", color: "red" };
|
|
52
68
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
function compact(lines) {
|
|
70
|
+
return lines.filter((line) => line !== null);
|
|
71
|
+
}
|
|
72
|
+
function resultSteps(value) {
|
|
73
|
+
return value.tests.flatMap(
|
|
74
|
+
(test) => test.attempts.flatMap((attempt) => attempt.steps)
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
function resultCalls(value) {
|
|
78
|
+
return [
|
|
63
79
|
...value.setupCalls,
|
|
64
80
|
...value.tests.flatMap(
|
|
65
81
|
(test) => test.attempts.flatMap((attempt) => [
|
|
@@ -68,92 +84,180 @@ function executionLines(value) {
|
|
|
68
84
|
])
|
|
69
85
|
)
|
|
70
86
|
];
|
|
87
|
+
}
|
|
88
|
+
function reportsExecutionPlan(execution) {
|
|
89
|
+
if (execution.parallel.lanes > 1) return true;
|
|
90
|
+
return execution.shard !== null;
|
|
91
|
+
}
|
|
92
|
+
function executionPlanLine(value) {
|
|
93
|
+
const execution = value.execution;
|
|
94
|
+
if (!execution) return null;
|
|
95
|
+
if (!reportsExecutionPlan(execution)) return null;
|
|
96
|
+
const shard = execution.shard ? `, shard ${execution.shard.index}/${execution.shard.count} of ${execution.shard.globalSelectedTests} selected` : "";
|
|
97
|
+
return `lanes ${execution.parallel.lanes}, provider concurrency ${execution.providerConcurrency}${shard}`;
|
|
98
|
+
}
|
|
99
|
+
function visionOutcomeLine(model, attempts) {
|
|
100
|
+
if (attempts.length === 0)
|
|
101
|
+
return `vision ${model}: enabled, no fallback attempted`;
|
|
102
|
+
const selected = attempts.filter(
|
|
103
|
+
(attempt) => attempt.outcome === "selected"
|
|
104
|
+
).length;
|
|
105
|
+
const abstained = attempts.filter(
|
|
106
|
+
(attempt) => attempt.outcome === "abstained"
|
|
107
|
+
).length;
|
|
108
|
+
const failed = attempts.filter(
|
|
109
|
+
(attempt) => attempt.outcome === "failed" || !attempt.outcome && attempt.failure
|
|
110
|
+
).length;
|
|
111
|
+
const unrecorded = attempts.length - selected - abstained - failed;
|
|
112
|
+
const unrecordedText = unrecorded ? `, ${unrecorded} outcome unrecorded` : "";
|
|
113
|
+
return `vision ${model}: attempted on ${attempts.length} step(s); ${selected} selected, ${abstained} abstained, ${failed} failed${unrecordedText}`;
|
|
114
|
+
}
|
|
115
|
+
function failedClickVisionLine(steps) {
|
|
116
|
+
const failedClicks = steps.filter(
|
|
117
|
+
(step) => step.operation === "click" && (step.verdict === "failed" || step.state === "error") && !step.locator?.vision
|
|
118
|
+
).length;
|
|
119
|
+
return failedClicks ? `vision not attempted on ${failedClicks} failed click step(s); see step errors for details` : null;
|
|
120
|
+
}
|
|
121
|
+
function visionExecutionLines(value, steps) {
|
|
122
|
+
const vision = value.execution?.vision;
|
|
123
|
+
if (!vision) return [];
|
|
124
|
+
const attempts = steps.flatMap(
|
|
125
|
+
(step) => step.locator?.vision ? [step.locator.vision] : []
|
|
126
|
+
);
|
|
127
|
+
const warnings = {
|
|
128
|
+
accepted: null,
|
|
129
|
+
rejected: "vision warning: OpenRouter rejected OPEN_ROUTER_API_KEY, so vision fallback cannot work. Check it with `sedum doctor --vision`.",
|
|
130
|
+
unreachable: "vision warning: OpenRouter could not be reached to check OPEN_ROUTER_API_KEY."
|
|
131
|
+
};
|
|
132
|
+
return compact([
|
|
133
|
+
visionOutcomeLine(vision.model, attempts),
|
|
134
|
+
failedClickVisionLine(steps),
|
|
135
|
+
warnings[vision.key]
|
|
136
|
+
]);
|
|
137
|
+
}
|
|
138
|
+
function rateLimitLine(value) {
|
|
139
|
+
const calls = resultCalls(value);
|
|
71
140
|
const limited = calls.filter((call) => call.rateLimited).length;
|
|
141
|
+
if (limited === 0) return null;
|
|
72
142
|
const waitMs = calls.reduce(
|
|
73
143
|
(sum, call) => sum + (call.rateLimitWaitMs ?? 0),
|
|
74
144
|
0
|
|
75
145
|
);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
146
|
+
return `provider rate limited ${limited} call(s), waited ${(waitMs / 1e3).toFixed(1)}s in shared cooldowns`;
|
|
147
|
+
}
|
|
148
|
+
function cacheConflictLine(steps) {
|
|
149
|
+
const conflicts = steps.filter(
|
|
150
|
+
(step) => step.locator?.cache?.reason === "conflict"
|
|
151
|
+
).length;
|
|
152
|
+
return conflicts > 0 ? `cache ${conflicts} locator cache write conflict(s); the model result was used` : null;
|
|
153
|
+
}
|
|
154
|
+
function executionLines(value) {
|
|
155
|
+
const steps = resultSteps(value);
|
|
156
|
+
return [
|
|
157
|
+
...compact([executionPlanLine(value)]),
|
|
158
|
+
...visionExecutionLines(value, steps),
|
|
159
|
+
...compact([rateLimitLine(value), cacheConflictLine(steps)])
|
|
160
|
+
];
|
|
161
|
+
}
|
|
162
|
+
function cacheLine(step) {
|
|
163
|
+
const cache = step.locator?.cache;
|
|
164
|
+
if (!cache) return null;
|
|
165
|
+
const reason = cache.reason ? ` (${cache.reason})` : "";
|
|
166
|
+
const fallback = cache.fallbackCalledModel ? ", model fallback" : "";
|
|
167
|
+
const changed = cache.targetChanged ? ", target changed" : "";
|
|
168
|
+
return ` step ${step.index}: cache ${cache.outcome}${reason}${fallback}${changed}`;
|
|
169
|
+
}
|
|
170
|
+
function testDetailLines(test, flagCounts) {
|
|
171
|
+
const retry = test.attempts.length > 1 ? ` attempts ${test.attempts.length} (${test.attempts.map((attempt) => attempt.verdict ?? attempt.state).join(" -> ")})` : null;
|
|
172
|
+
const selected = test.attempts.find(
|
|
173
|
+
(attempt) => attempt.id === test.selectedAttemptId
|
|
174
|
+
);
|
|
175
|
+
const caches = (selected?.steps ?? []).flatMap((step) => {
|
|
176
|
+
for (const flag of step.flags) flagCounts[flag] += 1;
|
|
177
|
+
const line = cacheLine(step);
|
|
178
|
+
return line ? [line] : [];
|
|
179
|
+
});
|
|
180
|
+
const details = [...compact([retry]), ...caches];
|
|
181
|
+
return details.length ? [testLabel(test), ...details] : [];
|
|
182
|
+
}
|
|
183
|
+
function hasOutsideGitStep(value) {
|
|
184
|
+
return resultSteps(value).some(
|
|
185
|
+
(step) => step.locator?.cache?.reason === "outside_git"
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
function discoveryLine(problem) {
|
|
189
|
+
const location = problem.line === void 0 ? "" : `:${problem.line}:${problem.col ?? 1}`;
|
|
190
|
+
return `discovery ${problem.file}${location}: ${problem.message} Fix: ${problem.fix}`;
|
|
191
|
+
}
|
|
192
|
+
function testCountLine(value) {
|
|
193
|
+
const errored = value.tests.filter((test) => test.state === "error").length;
|
|
194
|
+
const errorCount = errored ? `, ${errored} could not run` : "";
|
|
195
|
+
return `tests ${value.totals.selectedTests} selected, ${value.totals.executedTests} executed, ${value.totals.passedTests} passed, ${value.totals.failedTests} failed${errorCount}`;
|
|
196
|
+
}
|
|
197
|
+
function flagCountLine(value, counts) {
|
|
198
|
+
const flaky = value.tests.filter(
|
|
199
|
+
(test) => test.flags.includes("flaky")
|
|
200
|
+
).length;
|
|
201
|
+
return `flags ${value.totals.flaggedSteps} flagged step(s), low_confidence ${counts.low_confidence}, contradiction ${counts.contradiction}, flaky ${flaky} test(s)`;
|
|
202
|
+
}
|
|
203
|
+
function visionDetailLines(value) {
|
|
204
|
+
return value.tests.flatMap(
|
|
205
|
+
(test) => test.attempts.flatMap(
|
|
206
|
+
(attempt) => attempt.steps.flatMap((step) => {
|
|
207
|
+
const vision = visionSummary(step);
|
|
208
|
+
if (!vision) return [];
|
|
209
|
+
return [
|
|
210
|
+
`${test.file} \xB7 attempt ${attempt.ordinal} \xB7 step ${step.index}: ${vision}`.replace(
|
|
211
|
+
// Strip terminal control characters from provider metadata.
|
|
212
|
+
// eslint-disable-next-line no-control-regex
|
|
213
|
+
/[\u0000-\u001f\u007f-\u009f]/g,
|
|
214
|
+
" "
|
|
215
|
+
)
|
|
216
|
+
];
|
|
217
|
+
})
|
|
218
|
+
)
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
function artifactLines(artifacts) {
|
|
222
|
+
if (!artifacts.authoritative)
|
|
223
|
+
return [`result unavailable (intended ${artifacts.resultPath})`];
|
|
224
|
+
return compact([
|
|
225
|
+
`result ${artifacts.resultPath}`,
|
|
226
|
+
artifacts.htmlPath ? `html ${artifacts.htmlPath}` : null,
|
|
227
|
+
artifacts.markdownPath ? `markdown ${artifacts.markdownPath}` : null,
|
|
228
|
+
artifacts.junitPath ? `junit ${artifacts.junitPath}` : null,
|
|
229
|
+
artifacts.reporterPath ? `reporter ${artifacts.reporterPath}` : null
|
|
230
|
+
]);
|
|
231
|
+
}
|
|
232
|
+
function costLines(value) {
|
|
233
|
+
const unknown = !value.totals.costComplete || value.totals.costUsd === null ? "cost unknown or incomplete" : null;
|
|
234
|
+
return [...usageLines(value), ...compact([unknown])];
|
|
86
235
|
}
|
|
87
236
|
function renderRunSummary(result, capabilities, artifacts, showCosts) {
|
|
88
237
|
const value = validateRunResult2(result);
|
|
89
238
|
const color = capabilities.stdoutIsTTY && capabilities.color;
|
|
90
239
|
const lines = [];
|
|
91
240
|
const flagCounts = { low_confidence: 0, contradiction: 0 };
|
|
92
|
-
for (const test of value.tests)
|
|
93
|
-
|
|
94
|
-
|
|
241
|
+
for (const test of value.tests)
|
|
242
|
+
lines.push(...testDetailLines(test, flagCounts));
|
|
243
|
+
if (hasOutsideGitStep(value))
|
|
95
244
|
lines.push(
|
|
96
|
-
`
|
|
245
|
+
"cache off: this project is not a Git checkout; run `git init` to cache locator results"
|
|
97
246
|
);
|
|
98
|
-
if (test.attempts.length > 1)
|
|
99
|
-
lines.push(
|
|
100
|
-
` attempts ${test.attempts.length} (${test.attempts.map((attempt) => attempt.verdict ?? attempt.state).join(" -> ")})`
|
|
101
|
-
);
|
|
102
|
-
const selected = test.attempts.find(
|
|
103
|
-
(attempt) => attempt.id === test.selectedAttemptId
|
|
104
|
-
);
|
|
105
|
-
for (const step of selected?.steps ?? []) {
|
|
106
|
-
for (const flag of step.flags) flagCounts[flag] += 1;
|
|
107
|
-
const cache = step.locator?.cache;
|
|
108
|
-
if (cache) {
|
|
109
|
-
const reason = cache.reason ? ` (${cache.reason})` : "";
|
|
110
|
-
const fallback = cache.fallbackCalledModel ? ", model fallback" : "";
|
|
111
|
-
const changed = cache.targetChanged ? ", target changed" : "";
|
|
112
|
-
lines.push(
|
|
113
|
-
` step ${step.index}: cache ${cache.outcome}${reason}${fallback}${changed}`
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
247
|
const runLabel = stateLabel(value.state, value.verdict);
|
|
119
248
|
lines.push(`run ${paint(runLabel.text, runLabel.color, color)}`);
|
|
120
249
|
for (const problem of value.discoveryProblems ?? [])
|
|
121
|
-
lines.push(
|
|
122
|
-
|
|
123
|
-
);
|
|
124
|
-
lines.push(
|
|
125
|
-
`tests ${value.totals.selectedTests} selected, ${value.totals.executedTests} executed, ${value.totals.passedTests} passed, ${value.totals.failedTests} failed`
|
|
126
|
-
);
|
|
127
|
-
lines.push(
|
|
128
|
-
`flags ${value.totals.flaggedSteps} flagged step(s), low_confidence ${flagCounts.low_confidence}, contradiction ${flagCounts.contradiction}`
|
|
129
|
-
);
|
|
250
|
+
lines.push(discoveryLine(problem));
|
|
251
|
+
lines.push(testCountLine(value), flagCountLine(value, flagCounts));
|
|
130
252
|
lines.push(...executionLines(value));
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
lines.push(`result ${artifacts.resultPath}`);
|
|
134
|
-
if (artifacts.htmlPath) lines.push(`html ${artifacts.htmlPath}`);
|
|
135
|
-
if (artifacts.markdownPath)
|
|
136
|
-
lines.push(`markdown ${artifacts.markdownPath}`);
|
|
137
|
-
if (artifacts.junitPath) lines.push(`junit ${artifacts.junitPath}`);
|
|
138
|
-
if (artifacts.reporterPath)
|
|
139
|
-
lines.push(`reporter ${artifacts.reporterPath}`);
|
|
140
|
-
} else {
|
|
141
|
-
lines.push(`result unavailable (intended ${artifacts.resultPath})`);
|
|
142
|
-
}
|
|
143
|
-
if (capabilities.stdoutIsTTY || showCosts) {
|
|
144
|
-
lines.push(
|
|
145
|
-
`model ${value.totals.modelCalls} call(s), ${value.totals.inputTokens} input tokens, ${value.totals.outputTokens} output tokens`
|
|
146
|
-
);
|
|
147
|
-
lines.push(
|
|
148
|
-
value.totals.costComplete && value.totals.costUsd !== null ? `cost $${value.totals.costUsd.toFixed(6)}` : "cost unknown or incomplete"
|
|
149
|
-
);
|
|
150
|
-
}
|
|
253
|
+
lines.push(...visionDetailLines(value), ...artifactLines(artifacts));
|
|
254
|
+
if (capabilities.stdoutIsTTY || showCosts) lines.push(...costLines(value));
|
|
151
255
|
return `${lines.join("\n")}
|
|
152
256
|
`;
|
|
153
257
|
}
|
|
154
258
|
|
|
155
259
|
// src/run-cli.ts
|
|
156
|
-
import { Command, CommanderError
|
|
260
|
+
import { Command as Command2, CommanderError } from "commander";
|
|
157
261
|
import {
|
|
158
262
|
createTerminalReporter,
|
|
159
263
|
ReporterLifecycle
|
|
@@ -162,7 +266,7 @@ import {
|
|
|
162
266
|
// src/list-command.ts
|
|
163
267
|
import {
|
|
164
268
|
listTests,
|
|
165
|
-
|
|
269
|
+
loadListingEntries
|
|
166
270
|
} from "@sedum-dev/core";
|
|
167
271
|
|
|
168
272
|
// src/project-context.ts
|
|
@@ -265,12 +369,9 @@ async function executeListCommand(options) {
|
|
|
265
369
|
const { discovery } = context;
|
|
266
370
|
if (discovery.problems.length)
|
|
267
371
|
return { discovery, configErrors: [], listing: null };
|
|
268
|
-
const parsed =
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
file,
|
|
272
|
-
result: await loadFlowFile(file, { repoRoot: discovery.root })
|
|
273
|
-
});
|
|
372
|
+
const parsed = await loadListingEntries(discovery.tests, {
|
|
373
|
+
repoRoot: discovery.root
|
|
374
|
+
});
|
|
274
375
|
return {
|
|
275
376
|
discovery,
|
|
276
377
|
configErrors: [],
|
|
@@ -285,32 +386,37 @@ import {
|
|
|
285
386
|
validateProject
|
|
286
387
|
} from "@sedum-dev/core";
|
|
287
388
|
import path2 from "path";
|
|
288
|
-
var CLASSIFICATION_MODEL = "jev-latest";
|
|
289
|
-
var createTypeSafeClassifier = async ({
|
|
290
|
-
apiKey
|
|
291
|
-
}) => {
|
|
292
|
-
const { TypeSafeAdapter } = await import("@sedum-dev/provider-typesafe");
|
|
293
|
-
return new TypeSafeAdapter(apiKey ? { apiKey } : {});
|
|
294
|
-
};
|
|
295
389
|
function emptyProjectProblem(paths, testDirectory) {
|
|
296
390
|
const shown = paths.length ? paths.join(", ") : testDirectory || ".";
|
|
297
391
|
return {
|
|
298
392
|
code: "missing_path",
|
|
299
393
|
path: shown,
|
|
300
|
-
message: `No *.test.yaml or *.module.yaml files were found under ${shown}.`,
|
|
394
|
+
message: `No *.test.ts, *.test.yaml, or *.module.yaml files were found under ${shown}.`,
|
|
301
395
|
fix: paths.length ? "Pass paths relative to the project root that contain tests or modules." : "Add tests under tests.directory, or correct tests.directory/include/exclude in sedum.config.yaml."
|
|
302
396
|
};
|
|
303
397
|
}
|
|
304
398
|
var missingKey = {
|
|
305
399
|
code: "missing_key",
|
|
306
|
-
message: "`sedum validate --online` needs a configured
|
|
307
|
-
fix: "Set
|
|
400
|
+
message: "`sedum validate --online` needs a configured model provider.",
|
|
401
|
+
fix: "Set the selected provider's credentials (TYPESAFE_API_KEY, or CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_AUTH_TOKEN/CLOUDFLARE_API_TOKEN) and rerun; otherwise omit --online."
|
|
308
402
|
};
|
|
309
403
|
async function onlineProvider(options) {
|
|
310
404
|
try {
|
|
311
|
-
const
|
|
312
|
-
return
|
|
405
|
+
const config = await loadProjectConfig(options.cwd);
|
|
406
|
+
return {
|
|
407
|
+
provider: await options.createProvider({
|
|
408
|
+
...config.apiKey ? { apiKey: config.apiKey } : {},
|
|
409
|
+
baseURL: config.providerBaseUrl,
|
|
410
|
+
model: config.providerModel,
|
|
411
|
+
...config.providerName === "clef" ? {
|
|
412
|
+
providerName: config.providerName,
|
|
413
|
+
...config.cloudflareAccountId ? { accountId: config.cloudflareAccountId } : {}
|
|
414
|
+
} : {}
|
|
415
|
+
}),
|
|
416
|
+
model: config.providerModel
|
|
417
|
+
};
|
|
313
418
|
} catch (error) {
|
|
419
|
+
if (error instanceof ProjectConfigError) return configDiagnostic(error);
|
|
314
420
|
if (error instanceof ProviderError && error.code === "configuration")
|
|
315
421
|
return missingKey;
|
|
316
422
|
return {
|
|
@@ -320,6 +426,13 @@ async function onlineProvider(options) {
|
|
|
320
426
|
};
|
|
321
427
|
}
|
|
322
428
|
}
|
|
429
|
+
var createSelectedClassifier = (options) => createCliProvider({
|
|
430
|
+
providerName: options.providerName ?? "typesafe",
|
|
431
|
+
apiKey: options.apiKey,
|
|
432
|
+
cloudflareAccountId: options.accountId,
|
|
433
|
+
providerModel: options.model,
|
|
434
|
+
providerBaseUrl: options.baseURL
|
|
435
|
+
});
|
|
323
436
|
async function executeValidateCommand(options) {
|
|
324
437
|
const context = await loadProjectContext(options.paths, options.cwd);
|
|
325
438
|
if (!context.config)
|
|
@@ -351,14 +464,17 @@ async function executeValidateCommand(options) {
|
|
|
351
464
|
null
|
|
352
465
|
);
|
|
353
466
|
let provider;
|
|
467
|
+
let classificationModel = config.providerModel;
|
|
354
468
|
if (options.online) {
|
|
355
469
|
const prepared = await onlineProvider(options);
|
|
356
470
|
if ("code" in prepared) return stop(discovery, prepared);
|
|
357
|
-
provider = prepared;
|
|
471
|
+
provider = prepared.provider;
|
|
472
|
+
classificationModel = prepared.model;
|
|
358
473
|
}
|
|
359
474
|
const cache = await FileClassificationCache.load(
|
|
360
475
|
path2.join(discovery.root, ".sedum", "classifications.json"),
|
|
361
|
-
|
|
476
|
+
classificationModel,
|
|
477
|
+
config.providerName
|
|
362
478
|
);
|
|
363
479
|
const result = await validateProject(discovery, {
|
|
364
480
|
repoRoot: discovery.root,
|
|
@@ -393,7 +509,7 @@ function renderValidation(result, root, capabilities) {
|
|
|
393
509
|
for (const item of result.diagnostics) {
|
|
394
510
|
const where = `${displayPath(root, item.source.file)}:${item.source.line}:${item.source.col}`;
|
|
395
511
|
const label = item.severity === "warning" ? paint2(`warning ${item.code}`, "yellow", capabilities) : item.code === NOT_CHECKED_OFFLINE_CODE ? paint2("not checked offline", "yellow", capabilities) : paint2(`error ${item.code}`, "red", capabilities);
|
|
396
|
-
const fix = item.code === NOT_CHECKED_OFFLINE_CODE ? "Rephrase with a supported verb, or run `sedum validate --online` with
|
|
512
|
+
const fix = item.code === NOT_CHECKED_OFFLINE_CODE ? "Rephrase with a supported verb, or run `sedum validate --online` with a provider API key configured and commit .sedum/classifications.json." : item.fix;
|
|
397
513
|
lines.push(`${where}: ${label}: ${item.message}`, ` Fix: ${fix}`);
|
|
398
514
|
}
|
|
399
515
|
const { counts } = result;
|
|
@@ -478,90 +594,175 @@ function renderListJson(listing) {
|
|
|
478
594
|
`;
|
|
479
595
|
}
|
|
480
596
|
|
|
481
|
-
// src/
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
597
|
+
// src/cli-arguments.ts
|
|
598
|
+
import { InvalidArgumentError } from "commander";
|
|
599
|
+
var RawOptionText = class {
|
|
600
|
+
constructor(value) {
|
|
601
|
+
this.value = value;
|
|
602
|
+
}
|
|
603
|
+
value;
|
|
604
|
+
get trimmed() {
|
|
605
|
+
return this.value.trim();
|
|
606
|
+
}
|
|
607
|
+
get number() {
|
|
608
|
+
return Number(this.value);
|
|
609
|
+
}
|
|
610
|
+
get projectRelativeGlob() {
|
|
611
|
+
return [
|
|
612
|
+
this.trimmed.length > 0,
|
|
613
|
+
!this.value.startsWith("/"),
|
|
614
|
+
!/^[A-Za-z]:[/\\]/u.test(this.value),
|
|
615
|
+
!this.value.split(/[/\\]/u).includes("..")
|
|
616
|
+
].every(Boolean);
|
|
617
|
+
}
|
|
486
618
|
};
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
throw new InvalidArgumentError(
|
|
492
|
-
`Invalid origin ${JSON.stringify(value)}. Use an absolute URL such as https://example.com.`
|
|
493
|
-
);
|
|
619
|
+
var CommanderScalarParser = class {
|
|
620
|
+
callback;
|
|
621
|
+
constructor(parser) {
|
|
622
|
+
this.callback = (value) => parser.parse(new RawOptionText(value));
|
|
494
623
|
}
|
|
624
|
+
};
|
|
625
|
+
var CommanderCollector = class {
|
|
626
|
+
callback;
|
|
627
|
+
constructor(parser) {
|
|
628
|
+
this.callback = (value, previous) => parser.parse(new RawOptionText(value), previous);
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
function invalid(message) {
|
|
632
|
+
throw new InvalidArgumentError(message);
|
|
495
633
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
for (const item of value.split(",").map((name) => name.trim())) {
|
|
504
|
-
if (!REPORTERS.includes(item))
|
|
505
|
-
throw new InvalidArgumentError(
|
|
506
|
-
`Unknown reporter ${JSON.stringify(item)}. Use list or steps for terminal output, or terminal, json, markdown, or junit.`
|
|
634
|
+
var OriginCollector = class {
|
|
635
|
+
parse(text, previous) {
|
|
636
|
+
try {
|
|
637
|
+
return [...previous, new URL(text.value).origin];
|
|
638
|
+
} catch {
|
|
639
|
+
return invalid(
|
|
640
|
+
`Invalid origin ${JSON.stringify(text.value)}. Use an absolute URL such as https://example.com.`
|
|
507
641
|
);
|
|
508
|
-
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
var ValueCollector = class {
|
|
646
|
+
parse(text, previous) {
|
|
647
|
+
if (!text.trimmed) invalid("Value must not be blank.");
|
|
648
|
+
return [...previous, text.value];
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
var REPORTERS = ["list", "steps", "terminal", "json", "markdown", "junit"];
|
|
652
|
+
var ReporterCollector = class {
|
|
653
|
+
parse(text, previous) {
|
|
654
|
+
const selected = [...previous];
|
|
655
|
+
for (const item of text.value.split(",").map((name) => name.trim())) {
|
|
656
|
+
if (!REPORTERS.includes(item))
|
|
657
|
+
invalid(
|
|
658
|
+
`Unknown reporter ${JSON.stringify(item)}. Use list or steps for terminal output, or terminal, json, markdown, or junit.`
|
|
659
|
+
);
|
|
660
|
+
if (!selected.includes(item)) selected.push(item);
|
|
661
|
+
}
|
|
662
|
+
return selected;
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
var GlobCollector = class {
|
|
666
|
+
parse(text, previous) {
|
|
667
|
+
if (!text.projectRelativeGlob)
|
|
668
|
+
invalid("Glob must be a nonempty project-relative path without '..'.");
|
|
669
|
+
return [...previous, text.value];
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
var LabelCollector = class {
|
|
673
|
+
parse(text, previous) {
|
|
674
|
+
const labels = text.value.split(",").map((item) => item.trim());
|
|
675
|
+
if (labels.some((item) => !item))
|
|
676
|
+
invalid("Labels must be nonempty comma-separated tags.");
|
|
677
|
+
return [...previous, ...labels];
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
var RangedNumberParser = class {
|
|
681
|
+
constructor(range) {
|
|
682
|
+
this.range = range;
|
|
509
683
|
}
|
|
510
|
-
|
|
684
|
+
range;
|
|
685
|
+
parse(text) {
|
|
686
|
+
const { number } = text;
|
|
687
|
+
const minimumSatisfied = this.range.minimumInclusive ? number >= this.range.minimum : number > this.range.minimum;
|
|
688
|
+
const valid = [
|
|
689
|
+
Number.isFinite(number),
|
|
690
|
+
minimumSatisfied,
|
|
691
|
+
number <= this.range.maximum,
|
|
692
|
+
!this.range.safeInteger || Number.isSafeInteger(number),
|
|
693
|
+
!this.range.digitsOnly || /^[1-9]\d*$/u.test(text.value),
|
|
694
|
+
!this.range.nonblank || text.trimmed.length > 0
|
|
695
|
+
];
|
|
696
|
+
return valid.every(Boolean) ? number : invalid(this.range.error);
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
var ParallelParser = class {
|
|
700
|
+
parse(text) {
|
|
701
|
+
return parseParallel(text.value) ?? invalid(`Expected auto or an integer from 1 to ${MAX_PARALLEL}.`);
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
function scalar(parser) {
|
|
705
|
+
return new CommanderScalarParser(parser).callback;
|
|
511
706
|
}
|
|
512
|
-
function
|
|
513
|
-
|
|
514
|
-
throw new InvalidArgumentError(
|
|
515
|
-
"Glob must be a nonempty project-relative path without '..'."
|
|
516
|
-
);
|
|
517
|
-
return [...previous, value];
|
|
707
|
+
function collector(parser) {
|
|
708
|
+
return new CommanderCollector(parser).callback;
|
|
518
709
|
}
|
|
519
|
-
function
|
|
520
|
-
|
|
521
|
-
if (labels.some((item) => !item))
|
|
522
|
-
throw new InvalidArgumentError(
|
|
523
|
-
"Labels must be nonempty comma-separated tags."
|
|
524
|
-
);
|
|
525
|
-
return [...previous, ...labels];
|
|
526
|
-
}
|
|
527
|
-
function nonnegativeInteger(value) {
|
|
528
|
-
const number = Number(value);
|
|
529
|
-
if (!Number.isSafeInteger(number) || number < 0 || number > 20)
|
|
530
|
-
throw new InvalidArgumentError("Expected an integer from 0 to 20.");
|
|
531
|
-
return number;
|
|
532
|
-
}
|
|
533
|
-
function nonnegativeSlow(value) {
|
|
534
|
-
const number = Number(value);
|
|
535
|
-
if (!Number.isSafeInteger(number) || number < 0 || number > 3e4)
|
|
536
|
-
throw new InvalidArgumentError("Expected milliseconds from 0 to 30000.");
|
|
537
|
-
return number;
|
|
538
|
-
}
|
|
539
|
-
function parallelValue(value) {
|
|
540
|
-
const parsed = parseParallel(value);
|
|
541
|
-
if (parsed === null)
|
|
542
|
-
throw new InvalidArgumentError(
|
|
543
|
-
`Expected auto or an integer from 1 to ${MAX_PARALLEL}.`
|
|
544
|
-
);
|
|
545
|
-
return parsed;
|
|
710
|
+
function rangedNumber(range) {
|
|
711
|
+
return scalar(new RangedNumberParser(range));
|
|
546
712
|
}
|
|
713
|
+
var collectOrigin = collector(new OriginCollector());
|
|
714
|
+
var collectValue = collector(new ValueCollector());
|
|
715
|
+
var collectReporter = collector(new ReporterCollector());
|
|
716
|
+
var collectGlob = collector(new GlobCollector());
|
|
717
|
+
var collectLabels = collector(new LabelCollector());
|
|
718
|
+
var nonnegativeInteger = rangedNumber({
|
|
719
|
+
minimum: 0,
|
|
720
|
+
maximum: 20,
|
|
721
|
+
minimumInclusive: true,
|
|
722
|
+
safeInteger: true,
|
|
723
|
+
digitsOnly: false,
|
|
724
|
+
nonblank: false,
|
|
725
|
+
error: "Expected an integer from 0 to 20."
|
|
726
|
+
});
|
|
727
|
+
var nonnegativeSlow = rangedNumber({
|
|
728
|
+
minimum: 0,
|
|
729
|
+
maximum: 3e4,
|
|
730
|
+
minimumInclusive: true,
|
|
731
|
+
safeInteger: true,
|
|
732
|
+
digitsOnly: false,
|
|
733
|
+
nonblank: false,
|
|
734
|
+
error: "Expected milliseconds from 0 to 30000."
|
|
735
|
+
});
|
|
736
|
+
var parallelValue = scalar(new ParallelParser());
|
|
547
737
|
function positiveCount(maximum) {
|
|
548
|
-
return (
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}
|
|
557
|
-
function positiveMinutes(value) {
|
|
558
|
-
const number = Number(value);
|
|
559
|
-
if (!Number.isFinite(number) || number <= 0 || number > 1440)
|
|
560
|
-
throw new InvalidArgumentError(
|
|
561
|
-
"Expected minutes greater than 0 and at most 1440."
|
|
562
|
-
);
|
|
563
|
-
return number;
|
|
738
|
+
return rangedNumber({
|
|
739
|
+
minimum: 1,
|
|
740
|
+
maximum,
|
|
741
|
+
minimumInclusive: true,
|
|
742
|
+
safeInteger: true,
|
|
743
|
+
digitsOnly: true,
|
|
744
|
+
nonblank: false,
|
|
745
|
+
error: `Expected an integer from 1 to ${maximum}.`
|
|
746
|
+
});
|
|
564
747
|
}
|
|
748
|
+
var positiveMinutes = rangedNumber({
|
|
749
|
+
minimum: 0,
|
|
750
|
+
maximum: 1440,
|
|
751
|
+
minimumInclusive: false,
|
|
752
|
+
safeInteger: false,
|
|
753
|
+
digitsOnly: false,
|
|
754
|
+
nonblank: false,
|
|
755
|
+
error: "Expected minutes greater than 0 and at most 1440."
|
|
756
|
+
});
|
|
757
|
+
var relevanceThreshold = rangedNumber({
|
|
758
|
+
minimum: 0,
|
|
759
|
+
maximum: 1,
|
|
760
|
+
minimumInclusive: true,
|
|
761
|
+
safeInteger: false,
|
|
762
|
+
digitsOnly: false,
|
|
763
|
+
nonblank: true,
|
|
764
|
+
error: "Expected a probability from 0 to 1."
|
|
765
|
+
});
|
|
565
766
|
function commandHelp(command, writeErr) {
|
|
566
767
|
command.outputHelp({ error: true });
|
|
567
768
|
const commandPath = [];
|
|
@@ -573,16 +774,26 @@ function commandHelp(command, writeErr) {
|
|
|
573
774
|
`
|
|
574
775
|
);
|
|
575
776
|
}
|
|
777
|
+
|
|
778
|
+
// src/run-cli.ts
|
|
779
|
+
var plainOutput = {
|
|
780
|
+
stdoutIsTTY: false,
|
|
781
|
+
stderrIsTTY: false,
|
|
782
|
+
color: false
|
|
783
|
+
};
|
|
576
784
|
async function runCli(args, version, runtime = {}) {
|
|
577
785
|
const stdout = [];
|
|
578
786
|
const stderr = [];
|
|
579
|
-
const
|
|
580
|
-
const
|
|
787
|
+
const command = runtime.command ?? "sedum";
|
|
788
|
+
const rawOut = runtime.stdout ?? ((value) => stdout.push(value));
|
|
789
|
+
const rawErr = runtime.stderr ?? ((value) => stderr.push(value));
|
|
790
|
+
const writeOut = (value) => rawOut(withCommand(value, command));
|
|
791
|
+
const writeErr = (value) => rawErr(withCommand(value, command));
|
|
581
792
|
const capabilities = runtime.capabilities ?? plainOutput;
|
|
582
|
-
const executeRun = runtime.executeRun ?? (async (options) => (await import("./run-command-
|
|
793
|
+
const executeRun = runtime.executeRun ?? (async (options) => (await import("./run-command-DEWAPQML.js")).executeRunCommand(options));
|
|
583
794
|
const cwd = runtime.cwd ?? process.cwd();
|
|
584
795
|
let exitCode = 3;
|
|
585
|
-
const program = new
|
|
796
|
+
const program = new Command2().name("sedum").description(
|
|
586
797
|
"Run plain-English browser tests with deterministic automation."
|
|
587
798
|
).version(version, "-v, --version", "print the installed Sedum version").helpOption("-h, --help", "show command help").showSuggestionAfterError().showHelpAfterError("Run `sedum --help` to see available commands.").exitOverride().configureOutput({
|
|
588
799
|
writeOut,
|
|
@@ -597,7 +808,7 @@ async function runCli(args, version, runtime = {}) {
|
|
|
597
808
|
"after",
|
|
598
809
|
"\nCreates a config, a SauceDemo example, .env.example, and ignore rules.\nExisting files are never replaced.\n"
|
|
599
810
|
).action(async () => {
|
|
600
|
-
const { executeInitCommand } = await import("./init-command-
|
|
811
|
+
const { executeInitCommand } = await import("./init-command-SXAVPVX6.js");
|
|
601
812
|
const interactive = capabilities.stdoutIsTTY && (process.stdin.isTTY === true || runtime.confirmInit !== void 0);
|
|
602
813
|
const confirm = runtime.confirmInit ?? (interactive ? async (question) => {
|
|
603
814
|
const { createInterface } = await import("readline/promises");
|
|
@@ -626,6 +837,18 @@ async function runCli(args, version, runtime = {}) {
|
|
|
626
837
|
program.command("run").description("run configured tests, files, or directories").argument(
|
|
627
838
|
"[paths...]",
|
|
628
839
|
"test files or directories relative to the project root"
|
|
840
|
+
).option(
|
|
841
|
+
"--affected",
|
|
842
|
+
"experimental: send Git diff and test sources to the text provider; run relevant tests",
|
|
843
|
+
false
|
|
844
|
+
).option("--base <ref>", "base ref for --affected (default main or master)").option(
|
|
845
|
+
"--threshold <probability>",
|
|
846
|
+
"minimum relevance probability for --affected (default 0.1)",
|
|
847
|
+
relevanceThreshold
|
|
848
|
+
).option(
|
|
849
|
+
"--selection-only",
|
|
850
|
+
"with --affected, print selection JSON without running tests (calls the text provider)",
|
|
851
|
+
false
|
|
629
852
|
).option(
|
|
630
853
|
"--include <glob>",
|
|
631
854
|
"include matching project-relative paths (repeatable)",
|
|
@@ -646,7 +869,12 @@ async function runCli(args, version, runtime = {}) {
|
|
|
646
869
|
"match id or description substring (repeatable)",
|
|
647
870
|
collectValue,
|
|
648
871
|
[]
|
|
649
|
-
).option(
|
|
872
|
+
).option(
|
|
873
|
+
"--id <id>",
|
|
874
|
+
"select a test by its exact id (repeatable)",
|
|
875
|
+
collectValue,
|
|
876
|
+
[]
|
|
877
|
+
).option("--env <name>", "select a named environment").option("--browser <kind>", "chrome or chromium").option("--vision", "enable vision fallback for ambiguous clicks").option("--no-vision", "disable vision fallback").option("--vision-model <model>", "override the OpenRouter vision model").option(
|
|
650
878
|
"--url-override <url>",
|
|
651
879
|
"replace entry URL origin for preview deployments"
|
|
652
880
|
).option("--output-dir <path>", "run output directory").option("--reporter-dir <path>", "reporter artifact directory").option("--headed", "show the browser", false).option(
|
|
@@ -694,7 +922,7 @@ async function runCli(args, version, runtime = {}) {
|
|
|
694
922
|
false
|
|
695
923
|
).addHelpText(
|
|
696
924
|
"after",
|
|
697
|
-
"\nPrerequisites:\n Install Chromium with `sedum browsers install chromium` and set TYPESAFE_API_KEY.\n\nExamples:\n sedum run tests/login.test.
|
|
925
|
+
"\nPrerequisites:\n Install Chromium with `sedum browsers install chromium` and set TYPESAFE_API_KEY (and TYPESAFE_BASE_URL for a compatible provider).\n\nExamples:\n sedum run tests/login.test.ts\n sedum run tests/login.test.ts --id 'tests/login.test.ts#signs in'\n sedum run tests/login.test.yaml --strict --costs\n"
|
|
698
926
|
).action(
|
|
699
927
|
async (paths, options) => {
|
|
700
928
|
if (options.shardIndex === void 0 !== (options.shardCount === void 0) || options.shardIndex !== void 0 && options.shardIndex > options.shardCount) {
|
|
@@ -708,6 +936,78 @@ async function runCli(args, version, runtime = {}) {
|
|
|
708
936
|
exitCode = 3;
|
|
709
937
|
return;
|
|
710
938
|
}
|
|
939
|
+
if (options.affected && (options.shardCount ?? 1) > 1) {
|
|
940
|
+
writeErr(
|
|
941
|
+
renderDiagnostic({
|
|
942
|
+
code: "affected_sharding_unsupported",
|
|
943
|
+
message: "--affected cannot be combined with multiple shards: independent relevance selections can leave tests unexecuted.",
|
|
944
|
+
fix: "Remove the shard options, or run without --affected. --parallel is supported."
|
|
945
|
+
})
|
|
946
|
+
);
|
|
947
|
+
exitCode = 3;
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
if (!options.affected && (options.base !== void 0 || options.threshold !== void 0 || options.selectionOnly)) {
|
|
951
|
+
writeErr(
|
|
952
|
+
"--base, --threshold, and --selection-only require --affected.\n"
|
|
953
|
+
);
|
|
954
|
+
exitCode = 3;
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
if (options.affected) {
|
|
958
|
+
const { selectAffectedTests, AffectedSelectionError } = await import("./affected-selection-ENIH4AGP.js");
|
|
959
|
+
const { ProviderError: ProviderError2 } = await import("@sedum-dev/core");
|
|
960
|
+
writeErr(
|
|
961
|
+
"Experimental selection sends the tracked Git diff and test/module sources to the configured provider. Full CI is still recommended.\n"
|
|
962
|
+
);
|
|
963
|
+
try {
|
|
964
|
+
const selection = await selectAffectedTests({
|
|
965
|
+
cwd,
|
|
966
|
+
paths,
|
|
967
|
+
filters: {
|
|
968
|
+
include: options.include,
|
|
969
|
+
exclude: options.exclude,
|
|
970
|
+
labels: options.labels,
|
|
971
|
+
names: options.name,
|
|
972
|
+
ids: options.id
|
|
973
|
+
},
|
|
974
|
+
threshold: options.threshold ?? 0.1,
|
|
975
|
+
...options.base !== void 0 ? { base: options.base } : {},
|
|
976
|
+
...options.env ? { environment: options.env } : {},
|
|
977
|
+
...runtime.signal ? { signal: runtime.signal } : {},
|
|
978
|
+
...runtime.createRelevanceProvider ? { createProvider: runtime.createRelevanceProvider } : {}
|
|
979
|
+
});
|
|
980
|
+
paths = selection.tests.filter((test) => test.selected).map((test) => test.file);
|
|
981
|
+
if (options.selectionOnly) {
|
|
982
|
+
writeOut(`${JSON.stringify(selection, null, 2)}
|
|
983
|
+
`);
|
|
984
|
+
exitCode = 0;
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
writeErr(
|
|
988
|
+
`Affected selection: ${paths.length}/${selection.tests.length} tests, threshold ${selection.threshold}, base ${selection.base}.
|
|
989
|
+
`
|
|
990
|
+
);
|
|
991
|
+
for (const test of selection.tests)
|
|
992
|
+
writeErr(
|
|
993
|
+
`${test.selected ? "RUN " : "SKIP"} ${test.probability.toFixed(4)} ${JSON.stringify(test.file)} (${test.reason})
|
|
994
|
+
`
|
|
995
|
+
);
|
|
996
|
+
if (!paths.length) {
|
|
997
|
+
writeErr("No relevant tests selected; no tests were executed.\n");
|
|
998
|
+
exitCode = 0;
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
} catch (error) {
|
|
1002
|
+
writeErr(
|
|
1003
|
+
`${error instanceof AffectedSelectionError || error instanceof ProviderError2 ? error.message : "Affected selection could not complete."}
|
|
1004
|
+
No tests were run. Fix the selection error or run without --affected.
|
|
1005
|
+
`
|
|
1006
|
+
);
|
|
1007
|
+
exitCode = 3;
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
711
1011
|
const lifecycle = new ReporterLifecycle();
|
|
712
1012
|
const terminalNames = options.reporter.length ? options.reporter.filter(
|
|
713
1013
|
(name) => name !== "json" && name !== "markdown" && name !== "junit"
|
|
@@ -744,15 +1044,20 @@ async function runCli(args, version, runtime = {}) {
|
|
|
744
1044
|
}
|
|
745
1045
|
};
|
|
746
1046
|
const execution = await executeRun({
|
|
1047
|
+
command,
|
|
1048
|
+
...runtime.onStrayRejection ? { onStrayRejection: runtime.onStrayRejection } : {},
|
|
747
1049
|
paths,
|
|
748
1050
|
filters: {
|
|
749
1051
|
include: options.include,
|
|
750
1052
|
exclude: options.exclude,
|
|
751
1053
|
labels: options.labels,
|
|
752
|
-
names: options.name
|
|
1054
|
+
names: options.name,
|
|
1055
|
+
ids: options.id
|
|
753
1056
|
},
|
|
754
1057
|
...options.env ? { environment: options.env } : {},
|
|
755
1058
|
...options.browser ? { browser: options.browser } : {},
|
|
1059
|
+
...options.vision !== void 0 ? { vision: options.vision } : {},
|
|
1060
|
+
...options.visionModel !== void 0 ? { visionModel: options.visionModel } : {},
|
|
756
1061
|
...options.urlOverride ? { urlOverride: options.urlOverride } : {},
|
|
757
1062
|
...options.outputDir ? { outputDir: options.outputDir } : {},
|
|
758
1063
|
...options.reporterDir ? { reporterDir: options.reporterDir } : {},
|
|
@@ -834,12 +1139,18 @@ async function runCli(args, version, runtime = {}) {
|
|
|
834
1139
|
);
|
|
835
1140
|
exitCode = 0;
|
|
836
1141
|
});
|
|
837
|
-
program.command("doctor").description("check whether this environment can run Sedum").option("--json", "print versioned JSON checks on stdout", false).
|
|
1142
|
+
program.command("doctor").description("check whether this environment can run Sedum").option("--json", "print versioned JSON checks on stdout", false).option(
|
|
1143
|
+
"--vision",
|
|
1144
|
+
"also check the vision fallback's OPEN_ROUTER_API_KEY (automatic when vision.enabled is true)",
|
|
1145
|
+
false
|
|
1146
|
+
).addHelpText(
|
|
838
1147
|
"after",
|
|
839
1148
|
"\nThe authenticated API check makes one small, potentially billable request.\n\nExit codes:\n 0 all checks passed\n 3 one or more prerequisites failed\n"
|
|
840
1149
|
).action(async (options) => {
|
|
841
|
-
const { executeDoctorCommand, renderDoctorText } = await import("./doctor-command-
|
|
842
|
-
const result = await executeDoctorCommand(cwd, runtime.doctorProbes
|
|
1150
|
+
const { executeDoctorCommand, renderDoctorText } = await import("./doctor-command-XRE6PEGU.js");
|
|
1151
|
+
const result = await executeDoctorCommand(cwd, runtime.doctorProbes, {
|
|
1152
|
+
vision: options.vision
|
|
1153
|
+
});
|
|
843
1154
|
writeOut(
|
|
844
1155
|
options.json ? `${JSON.stringify(result)}
|
|
845
1156
|
` : renderDoctorText(result)
|
|
@@ -853,7 +1164,7 @@ async function runCli(args, version, runtime = {}) {
|
|
|
853
1164
|
"test files, module files, or directories relative to the project root (default: configured tests)"
|
|
854
1165
|
).option(
|
|
855
1166
|
"--online",
|
|
856
|
-
"classify sentences the offline cache cannot, using
|
|
1167
|
+
"classify sentences the offline cache cannot, using the configured provider API key, and update .sedum/classifications.json",
|
|
857
1168
|
false
|
|
858
1169
|
).addHelpText(
|
|
859
1170
|
"after",
|
|
@@ -863,7 +1174,7 @@ async function runCli(args, version, runtime = {}) {
|
|
|
863
1174
|
paths,
|
|
864
1175
|
online: options.online,
|
|
865
1176
|
cwd,
|
|
866
|
-
createProvider: runtime.createClassificationProvider ??
|
|
1177
|
+
createProvider: runtime.createClassificationProvider ?? createSelectedClassifier,
|
|
867
1178
|
...runtime.signal ? { signal: runtime.signal } : {}
|
|
868
1179
|
});
|
|
869
1180
|
const problems = execution.discovery?.problems ?? [];
|
|
@@ -947,8 +1258,11 @@ Fix: use \`sedum browsers install chromium\`.
|
|
|
947
1258
|
"Fix: correct the command shown above and rerun it, or use `sedum --help`.\n"
|
|
948
1259
|
);
|
|
949
1260
|
} else {
|
|
1261
|
+
const detail = error instanceof Error ? `${error.name}: ${error.message.split("\n")[0].slice(0, 200)}` : "unknown error";
|
|
950
1262
|
writeErr(
|
|
951
|
-
|
|
1263
|
+
`Sedum stopped on an unexpected internal error (${detail}).
|
|
1264
|
+
Fix: rerun the command; if it happens again, report it with the run's result.json.
|
|
1265
|
+
`
|
|
952
1266
|
);
|
|
953
1267
|
exitCode = 3;
|
|
954
1268
|
}
|
|
@@ -957,6 +1271,7 @@ Fix: use \`sedum browsers install chromium\`.
|
|
|
957
1271
|
}
|
|
958
1272
|
|
|
959
1273
|
export {
|
|
1274
|
+
sedumCommand,
|
|
960
1275
|
runExitCode,
|
|
961
1276
|
renderRunSummary,
|
|
962
1277
|
runCli
|