sedum-cli 0.1.0-alpha.3 → 0.1.0-alpha.5
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/dist/{affected-selection-YIHBKUST.js → affected-selection-OHKZUPYG.js} +17 -3
- package/dist/{chunk-AZJ7JJ6P.js → chunk-2BOXJT7M.js} +110 -39
- package/dist/{chunk-BI32AXS7.js → chunk-BEY4UNIW.js} +34 -2
- package/dist/{chunk-3MCSCE7X.js → chunk-DRCPO7W3.js} +12 -16
- package/dist/{chunk-YXSAX7E3.js → chunk-GYFQYSYT.js} +90 -12
- package/dist/{chunk-CZDCGWWD.js → chunk-NMAMFLDA.js} +42 -3
- package/dist/cli.js +30 -5
- package/dist/{doctor-command-A4FTFRUH.js → doctor-command-5HKQX3DN.js} +2 -2
- package/dist/index.d.ts +30 -1
- package/dist/index.js +10 -4
- package/dist/{init-command-EOS2MSWW.js → init-command-62UOTXTO.js} +20 -16
- package/dist/{run-command-P72XF5MI.js → run-command-YNDKEUUU.js} +136 -20
- package/package.json +4 -4
|
@@ -5,15 +5,16 @@ import {
|
|
|
5
5
|
outputDiagnostic,
|
|
6
6
|
planLanes,
|
|
7
7
|
runPool,
|
|
8
|
-
setupDiagnostic
|
|
9
|
-
|
|
8
|
+
setupDiagnostic,
|
|
9
|
+
stopsRun
|
|
10
|
+
} from "./chunk-BEY4UNIW.js";
|
|
10
11
|
import {
|
|
11
12
|
discoverRunTests
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-DRCPO7W3.js";
|
|
13
14
|
import {
|
|
14
15
|
ProjectConfigError,
|
|
15
16
|
loadProjectConfig
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-GYFQYSYT.js";
|
|
17
18
|
|
|
18
19
|
// src/run-command.ts
|
|
19
20
|
import {
|
|
@@ -21,9 +22,14 @@ import {
|
|
|
21
22
|
PlaywrightBrowserDriver,
|
|
22
23
|
ReusableBrowserDriver,
|
|
23
24
|
RunRecorder,
|
|
25
|
+
OpenRouterVisionResolver,
|
|
26
|
+
isScriptTestFile,
|
|
27
|
+
probeOpenRouterKey,
|
|
24
28
|
runFlow,
|
|
29
|
+
runScriptTest,
|
|
25
30
|
safeText,
|
|
26
|
-
validateRunResult as validateRunResult2
|
|
31
|
+
validateRunResult as validateRunResult2,
|
|
32
|
+
RejectionRouter
|
|
27
33
|
} from "@sedum-dev/core";
|
|
28
34
|
import {
|
|
29
35
|
DEFAULT_PROVIDER_CONCURRENCY,
|
|
@@ -64,6 +70,8 @@ var ProgressWriter = class _ProgressWriter {
|
|
|
64
70
|
draining = null;
|
|
65
71
|
attemptFolders = /* @__PURE__ */ new Map();
|
|
66
72
|
files;
|
|
73
|
+
/** How to invoke sedum in report rerun hints. */
|
|
74
|
+
command = "sedum";
|
|
67
75
|
static async create(root, runId, outputDirectory = path.join(root, ".sedum", "runs"), files = {}) {
|
|
68
76
|
if (!/^[a-zA-Z0-9-]+$/.test(runId)) throw new Error("Invalid run ID");
|
|
69
77
|
const resolvedRoot = path.resolve(root);
|
|
@@ -198,7 +206,10 @@ var ProgressWriter = class _ProgressWriter {
|
|
|
198
206
|
const frames = await this.loadReplayFrames(snapshot);
|
|
199
207
|
await this.atomicWrite(
|
|
200
208
|
"report.html",
|
|
201
|
-
renderHtml(snapshot,
|
|
209
|
+
renderHtml(snapshot, {
|
|
210
|
+
...frames ? { replayFrames: frames } : {},
|
|
211
|
+
command: this.command
|
|
212
|
+
})
|
|
202
213
|
);
|
|
203
214
|
} catch (cause) {
|
|
204
215
|
throw new ProgressWriterError(this.htmlPath, { cause });
|
|
@@ -206,7 +217,10 @@ var ProgressWriter = class _ProgressWriter {
|
|
|
206
217
|
}
|
|
207
218
|
if (this.files.markdown) {
|
|
208
219
|
try {
|
|
209
|
-
await this.atomicWrite(
|
|
220
|
+
await this.atomicWrite(
|
|
221
|
+
"report.md",
|
|
222
|
+
renderMarkdown(snapshot, { command: this.command })
|
|
223
|
+
);
|
|
210
224
|
} catch (cause) {
|
|
211
225
|
throw new ProgressWriterError(this.markdownPath, { cause });
|
|
212
226
|
}
|
|
@@ -214,7 +228,10 @@ var ProgressWriter = class _ProgressWriter {
|
|
|
214
228
|
const junit = this.files.junit;
|
|
215
229
|
if (junit) {
|
|
216
230
|
try {
|
|
217
|
-
await this.atomicWrite(
|
|
231
|
+
await this.atomicWrite(
|
|
232
|
+
"junit.xml",
|
|
233
|
+
renderJunit(snapshot, { ...junit, command: this.command })
|
|
234
|
+
);
|
|
218
235
|
} catch (cause) {
|
|
219
236
|
throw new ProgressWriterError(this.junitPath, { cause });
|
|
220
237
|
}
|
|
@@ -404,6 +421,29 @@ var SUPPORTED_REPORTERS = [
|
|
|
404
421
|
"markdown",
|
|
405
422
|
"junit"
|
|
406
423
|
];
|
|
424
|
+
function strayRejectionDiagnostic(strays, config) {
|
|
425
|
+
const stray = strays[0];
|
|
426
|
+
const where = stray.source ? `${path3.relative(config.projectRoot, stray.source.file).split(path3.sep).join("/")}:${stray.source.line}: ` : "";
|
|
427
|
+
const message = safeDiscoveryText(stray.message, config);
|
|
428
|
+
const more = strays.length > 1 ? ` (${strays.length - 1} more rejected outside their tests; see the terminal.)` : "";
|
|
429
|
+
if (stray.reason === "internal")
|
|
430
|
+
return {
|
|
431
|
+
code: "internal_rejection",
|
|
432
|
+
message: `Sedum hit an unexpected error during the run: ${message}${more}`,
|
|
433
|
+
fix: "Rerun the command; if it repeats, report it at https://github.com/sedum-dev/sedum/issues with the run's progress.json."
|
|
434
|
+
};
|
|
435
|
+
const what = {
|
|
436
|
+
finished: `a promise ${stray.test ? `\`${safeDiscoveryText(stray.test, config)}\`` : "a test"} did not await rejected after that test finished`,
|
|
437
|
+
shared: "a promise nobody awaited rejected in lines several tests share, such as tests declared in a loop, so no test is blamed",
|
|
438
|
+
outside: "a promise nobody awaited rejected outside any running test, so no test is blamed",
|
|
439
|
+
unknown: "a promise nobody awaited rejected with a value that has no stack"
|
|
440
|
+
}[stray.reason];
|
|
441
|
+
return {
|
|
442
|
+
code: "stray_rejection",
|
|
443
|
+
message: `${where}${what}: ${message}${more}`,
|
|
444
|
+
fix: "Add `await` before the page, expect, API, and ai calls the test starts."
|
|
445
|
+
};
|
|
446
|
+
}
|
|
407
447
|
function safeDiscoveryText(value, config) {
|
|
408
448
|
const withoutUrls = value.replace(/https?:\/\/[^\s`"'<>]+/giu, "[URL]");
|
|
409
449
|
return safeText(
|
|
@@ -451,11 +491,13 @@ async function openReportCopy(root, runId, canonical, outputDir, reporterDir, se
|
|
|
451
491
|
return void 0;
|
|
452
492
|
}
|
|
453
493
|
if (!selection.json && !junit) return void 0;
|
|
454
|
-
|
|
494
|
+
const writer = await ProgressWriter.create(root, runId, reporterDir, {
|
|
455
495
|
json: selection.json,
|
|
456
496
|
html: false,
|
|
457
497
|
junit
|
|
458
498
|
});
|
|
499
|
+
writer.command = canonical.command;
|
|
500
|
+
return writer;
|
|
459
501
|
}
|
|
460
502
|
function reportFormat(target) {
|
|
461
503
|
const name = path3.basename(target);
|
|
@@ -595,6 +637,9 @@ async function preExecutionFailure(root, runId, outputDir, reporterDir, selectio
|
|
|
595
637
|
}
|
|
596
638
|
async function executeRunCommand(options) {
|
|
597
639
|
const invocationRoot = process.cwd();
|
|
640
|
+
let rejections;
|
|
641
|
+
let strayConfig;
|
|
642
|
+
let reportedStrays = 0;
|
|
598
643
|
const reportFiles = reportSelection(options);
|
|
599
644
|
const runId = randomUUID();
|
|
600
645
|
let committed = false;
|
|
@@ -641,8 +686,26 @@ async function executeRunCommand(options) {
|
|
|
641
686
|
...options.environment ? { environment: options.environment } : {},
|
|
642
687
|
...options.browser ? { browser: options.browser } : {},
|
|
643
688
|
...options.outputDir ? { outputDir: options.outputDir } : {},
|
|
644
|
-
...options.reporterDir ? { reporterDir: options.reporterDir } : {}
|
|
689
|
+
...options.reporterDir ? { reporterDir: options.reporterDir } : {},
|
|
690
|
+
...options.vision !== void 0 || options.visionModel !== void 0 ? {
|
|
691
|
+
vision: {
|
|
692
|
+
...options.vision !== void 0 ? { enabled: options.vision } : {},
|
|
693
|
+
...options.visionModel !== void 0 ? { model: options.visionModel } : {}
|
|
694
|
+
}
|
|
695
|
+
} : {}
|
|
645
696
|
});
|
|
697
|
+
if (config.vision.enabled && !config.visionApiKey)
|
|
698
|
+
throw new ProjectConfigError([
|
|
699
|
+
{
|
|
700
|
+
code: "missing_vision_api_key",
|
|
701
|
+
file: path3.join(config.projectRoot, ".env"),
|
|
702
|
+
line: 1,
|
|
703
|
+
col: 1,
|
|
704
|
+
key: "OPEN_ROUTER_API_KEY",
|
|
705
|
+
message: "Vision fallback requires OPEN_ROUTER_API_KEY.",
|
|
706
|
+
fix: "Set OPEN_ROUTER_API_KEY in the invoking process or project-root .env, or disable vision."
|
|
707
|
+
}
|
|
708
|
+
]);
|
|
646
709
|
} catch (error) {
|
|
647
710
|
const diagnostic = setupDiagnostic(error);
|
|
648
711
|
const fallbackRoot = error instanceof ProjectConfigError && error.diagnostics[0]?.file ? path3.dirname(error.diagnostics[0].file) : invocationRoot;
|
|
@@ -697,6 +760,7 @@ async function executeRunCommand(options) {
|
|
|
697
760
|
config.outputDir,
|
|
698
761
|
{ markdown: reportFiles.markdown }
|
|
699
762
|
);
|
|
763
|
+
writer.command = options.command ?? "sedum";
|
|
700
764
|
} catch {
|
|
701
765
|
commit();
|
|
702
766
|
const intended = path3.join(config.outputDir, runId);
|
|
@@ -861,6 +925,9 @@ async function executeRunCommand(options) {
|
|
|
861
925
|
let files;
|
|
862
926
|
let globalSelectedTests = 0;
|
|
863
927
|
let discoveryProblems = [];
|
|
928
|
+
strayConfig = config;
|
|
929
|
+
rejections = new RejectionRouter(config.projectRoot);
|
|
930
|
+
rejections.install();
|
|
864
931
|
try {
|
|
865
932
|
const selection = await discoverRunTests(
|
|
866
933
|
config,
|
|
@@ -869,7 +936,10 @@ async function executeRunCommand(options) {
|
|
|
869
936
|
);
|
|
870
937
|
globalSelectedTests = selection.tests.length;
|
|
871
938
|
const selected = options.shard ? shardTests(selection.tests, options.shard) : selection.tests;
|
|
872
|
-
files = selected.map((test) =>
|
|
939
|
+
files = selected.map((test) => ({
|
|
940
|
+
file: path3.join(config.projectRoot, test.file),
|
|
941
|
+
id: test.id
|
|
942
|
+
}));
|
|
873
943
|
discoveryProblems = [
|
|
874
944
|
...selection.problems,
|
|
875
945
|
...selection.invalid.flatMap(
|
|
@@ -934,6 +1004,18 @@ async function executeRunCommand(options) {
|
|
|
934
1004
|
await recorder.finish(canonicalDiagnosticError(diagnostic));
|
|
935
1005
|
return terminalExecution(diagnostic);
|
|
936
1006
|
}
|
|
1007
|
+
if (files.length === 0 && discoveryProblems.length) {
|
|
1008
|
+
const [first] = discoveryProblems;
|
|
1009
|
+
const diagnostic = {
|
|
1010
|
+
code: "discovery_error",
|
|
1011
|
+
message: discoveryProblems.length === 1 ? `${first.file}: ${first.message}` : `${discoveryProblems.length} test file or path problem(s) were found; the first: ${first.file}: ${first.message}`,
|
|
1012
|
+
fix: first.fix
|
|
1013
|
+
};
|
|
1014
|
+
await recorder.addDiscoveryProblems(discoveryProblems);
|
|
1015
|
+
commit();
|
|
1016
|
+
await recorder.finish(canonicalDiagnosticError(diagnostic));
|
|
1017
|
+
return terminalExecution(diagnostic);
|
|
1018
|
+
}
|
|
937
1019
|
if (files.length === 0) {
|
|
938
1020
|
const error = new ProjectConfigError([
|
|
939
1021
|
{
|
|
@@ -943,7 +1025,7 @@ async function executeRunCommand(options) {
|
|
|
943
1025
|
col: 1,
|
|
944
1026
|
key: "tests.include",
|
|
945
1027
|
message: "The selection matched no valid test files.",
|
|
946
|
-
fix: "Add a matching *.test.yaml file or correct paths and filters."
|
|
1028
|
+
fix: "Add a matching *.test.ts or *.test.yaml file, or correct paths and filters."
|
|
947
1029
|
}
|
|
948
1030
|
]);
|
|
949
1031
|
const diagnostic = setupDiagnostic(error);
|
|
@@ -960,10 +1042,14 @@ async function executeRunCommand(options) {
|
|
|
960
1042
|
files.length
|
|
961
1043
|
);
|
|
962
1044
|
const providerConcurrency = options.providerConcurrency ?? Math.min(DEFAULT_PROVIDER_CONCURRENCY, lanes * 2);
|
|
1045
|
+
const visionKey = config.vision.enabled ? await (options.probeVisionKey ?? probeOpenRouterKey)(
|
|
1046
|
+
config.visionApiKey
|
|
1047
|
+
).catch(() => "unreachable") : null;
|
|
963
1048
|
await recorder.selectTests(files.length, {
|
|
964
1049
|
parallel: { requested: options.parallel ?? 1, lanes },
|
|
965
1050
|
shard: options.shard ? { ...options.shard, globalSelectedTests } : null,
|
|
966
|
-
providerConcurrency
|
|
1051
|
+
providerConcurrency,
|
|
1052
|
+
...visionKey ? { vision: { model: config.vision.model, key: visionKey } } : {}
|
|
967
1053
|
});
|
|
968
1054
|
if (discoveryProblems.length)
|
|
969
1055
|
await recorder.addDiscoveryProblems(discoveryProblems);
|
|
@@ -984,28 +1070,37 @@ async function executeRunCommand(options) {
|
|
|
984
1070
|
ciOptIn: options.locatorCacheCi ?? false,
|
|
985
1071
|
env: process.env
|
|
986
1072
|
});
|
|
1073
|
+
const visionResolver = config.vision.enabled ? new OpenRouterVisionResolver({
|
|
1074
|
+
apiKey: config.visionApiKey,
|
|
1075
|
+
model: config.vision.model,
|
|
1076
|
+
timeoutMs: config.vision.timeoutMs
|
|
1077
|
+
}) : void 0;
|
|
987
1078
|
let operational = null;
|
|
1079
|
+
let erroredTests = 0;
|
|
988
1080
|
const driver = new PlaywrightBrowserDriver();
|
|
989
1081
|
const browsers = Array.from(
|
|
990
1082
|
{ length: lanes },
|
|
991
1083
|
() => new ReusableBrowserDriver(driver)
|
|
992
1084
|
);
|
|
1085
|
+
const router = rejections;
|
|
993
1086
|
try {
|
|
994
1087
|
await runPool({
|
|
995
1088
|
items: files,
|
|
996
1089
|
lanes,
|
|
997
1090
|
signal,
|
|
998
|
-
run: async (file, lane, ordinal) => {
|
|
1091
|
+
run: async ({ file, id }, lane, ordinal) => {
|
|
999
1092
|
const browser = browsers[lane];
|
|
1093
|
+
const execute = (dependencies) => isScriptTestFile(file) ? runScriptTest(file, id, dependencies) : runFlow(file, dependencies);
|
|
1000
1094
|
for (let attempt = 0; attempt <= (options.retries ?? 0); attempt++) {
|
|
1001
1095
|
if (attempt > 0)
|
|
1002
1096
|
await recorder.testAt(ordinal)?.startAttempt(lane);
|
|
1003
|
-
const result = await
|
|
1097
|
+
const result = await execute({
|
|
1004
1098
|
repoRoot: config.projectRoot,
|
|
1005
1099
|
browser,
|
|
1006
1100
|
provider,
|
|
1007
1101
|
classificationCache: cache,
|
|
1008
1102
|
locatorCache,
|
|
1103
|
+
...visionResolver ? { visionResolver } : {},
|
|
1009
1104
|
// Per-attempt values let tests keep backend data apart, like
|
|
1010
1105
|
// Playwright's TEST_PARALLEL_INDEX. They are env-derived, so
|
|
1011
1106
|
// they stay opaque in model input and reports.
|
|
@@ -1024,6 +1119,7 @@ async function executeRunCommand(options) {
|
|
|
1024
1119
|
...options.headed ? { headedOverlay: true } : {},
|
|
1025
1120
|
...options.slowMoMs !== void 0 ? { slowMoMs: options.slowMoMs } : {},
|
|
1026
1121
|
signal,
|
|
1122
|
+
rejections: router,
|
|
1027
1123
|
report: {
|
|
1028
1124
|
recorder,
|
|
1029
1125
|
slot: { ordinal, lane },
|
|
@@ -1040,10 +1136,15 @@ async function executeRunCommand(options) {
|
|
|
1040
1136
|
if (signal.aborted) return "stop";
|
|
1041
1137
|
if (result.status === "could_not_run") {
|
|
1042
1138
|
await browser.recycle();
|
|
1043
|
-
|
|
1044
|
-
|
|
1139
|
+
const diagnostic = flowDiagnostic(result);
|
|
1140
|
+
operational ??= diagnostic;
|
|
1141
|
+
if (stopsRun(result.code)) return "stop";
|
|
1142
|
+
erroredTests += 1;
|
|
1143
|
+
await recorder.testAt(ordinal)?.errorTest(canonicalDiagnosticError(diagnostic));
|
|
1144
|
+
break;
|
|
1045
1145
|
}
|
|
1046
|
-
if (result.status === "passed")
|
|
1146
|
+
if (result.status === "passed" || result.retryable === false)
|
|
1147
|
+
break;
|
|
1047
1148
|
}
|
|
1048
1149
|
return "continue";
|
|
1049
1150
|
}
|
|
@@ -1052,6 +1153,10 @@ async function executeRunCommand(options) {
|
|
|
1052
1153
|
gate.close();
|
|
1053
1154
|
await Promise.all(browsers.map((browser) => browser.recycle()));
|
|
1054
1155
|
}
|
|
1156
|
+
if (router.unattributed.length && !operational) {
|
|
1157
|
+
reportedStrays = router.unattributed.length;
|
|
1158
|
+
operational = strayRejectionDiagnostic(router.unattributed, config);
|
|
1159
|
+
}
|
|
1055
1160
|
if (signal.aborted) {
|
|
1056
1161
|
const diagnostic = timedOut ? {
|
|
1057
1162
|
code: "run_timeout",
|
|
@@ -1070,7 +1175,12 @@ async function executeRunCommand(options) {
|
|
|
1070
1175
|
return terminalExecution(diagnostic);
|
|
1071
1176
|
}
|
|
1072
1177
|
if (operational) {
|
|
1073
|
-
const
|
|
1178
|
+
const first = operational;
|
|
1179
|
+
const diagnostic = erroredTests > 1 ? {
|
|
1180
|
+
code: "test_errors",
|
|
1181
|
+
message: `${erroredTests} tests could not run. First: ${first.message}`,
|
|
1182
|
+
fix: "Fix the tests named under needs attention, then rerun them."
|
|
1183
|
+
} : first;
|
|
1074
1184
|
commit();
|
|
1075
1185
|
await recorder.finish(canonicalDiagnosticError(diagnostic));
|
|
1076
1186
|
return terminalExecution(diagnostic);
|
|
@@ -1137,8 +1247,14 @@ async function executeRunCommand(options) {
|
|
|
1137
1247
|
} finally {
|
|
1138
1248
|
if (timeout) clearTimeout(timeout);
|
|
1139
1249
|
options.signal?.removeEventListener("abort", onExternalAbort);
|
|
1250
|
+
rejections?.dispose();
|
|
1251
|
+
for (const late of rejections?.unattributed.slice(reportedStrays) ?? [])
|
|
1252
|
+
options.onStrayRejection?.(
|
|
1253
|
+
strayRejectionDiagnostic([late], strayConfig).message
|
|
1254
|
+
);
|
|
1140
1255
|
}
|
|
1141
1256
|
}
|
|
1142
1257
|
export {
|
|
1143
|
-
executeRunCommand
|
|
1258
|
+
executeRunCommand,
|
|
1259
|
+
strayRejectionDiagnostic
|
|
1144
1260
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sedum-cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"repository": "https://github.com/sedum-dev/sedum",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"commander": "14.0.2",
|
|
26
26
|
"minimatch": "10.2.6",
|
|
27
27
|
"yaml": "2.9.1",
|
|
28
|
-
"@sedum-dev/core": "0.1.0-alpha.
|
|
29
|
-
"@sedum-dev/
|
|
30
|
-
"@sedum-dev/
|
|
28
|
+
"@sedum-dev/core": "0.1.0-alpha.5",
|
|
29
|
+
"@sedum-dev/reporters": "0.1.0-alpha.5",
|
|
30
|
+
"@sedum-dev/provider-typesafe": "0.1.0-alpha.5"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsup src/index.ts src/cli.ts --format esm --dts --clean --out-dir dist",
|