sedum-cli 0.1.0-alpha.0 → 0.1.0-alpha.4

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.
@@ -6,12 +6,14 @@ import {
6
6
  planLanes,
7
7
  runPool,
8
8
  setupDiagnostic
9
- } from "./chunk-BEV24G7S.js";
9
+ } from "./chunk-72CYPRWT.js";
10
+ import {
11
+ discoverRunTests
12
+ } from "./chunk-UVCFRFDV.js";
10
13
  import {
11
14
  ProjectConfigError,
12
- discoverConfiguredTests,
13
15
  loadProjectConfig
14
- } from "./chunk-TZGSCV23.js";
16
+ } from "./chunk-W2BEUHUB.js";
15
17
 
16
18
  // src/run-command.ts
17
19
  import {
@@ -19,6 +21,7 @@ import {
19
21
  PlaywrightBrowserDriver,
20
22
  ReusableBrowserDriver,
21
23
  RunRecorder,
24
+ OpenRouterVisionResolver,
22
25
  runFlow,
23
26
  safeText,
24
27
  validateRunResult as validateRunResult2
@@ -28,7 +31,7 @@ import {
28
31
  ProviderGate,
29
32
  TypeSafeAdapter
30
33
  } from "@sedum-dev/provider-typesafe";
31
- import path4 from "path";
34
+ import path3 from "path";
32
35
  import { availableParallelism } from "os";
33
36
  import { randomBytes, randomUUID } from "crypto";
34
37
 
@@ -43,9 +46,9 @@ import {
43
46
  renderMarkdown
44
47
  } from "@sedum-dev/reporters";
45
48
  var ProgressWriterError = class extends Error {
46
- constructor(path5, options) {
47
- super(`Could not write run output at ${path5}.`, options);
48
- this.path = path5;
49
+ constructor(path4, options) {
50
+ super(`Could not write run output at ${path4}.`, options);
51
+ this.path = path4;
49
52
  this.name = "ProgressWriterError";
50
53
  }
51
54
  path;
@@ -364,135 +367,6 @@ async function junitEvidenceDirectory(runDirectory, projectRoot, env) {
364
367
  return relative && isEvidenceDirectory(relative) ? relative : null;
365
368
  }
366
369
 
367
- // src/run-selection.ts
368
- import { lstat as lstat2, realpath as realpath2 } from "fs/promises";
369
- import path3 from "path";
370
- import { minimatch } from "minimatch";
371
- import {
372
- listTests,
373
- loadFlowFile,
374
- walkSuiteFiles
375
- } from "@sedum-dev/core";
376
- function contained(root, target) {
377
- const relative = path3.relative(root, target);
378
- return relative === "" || relative !== ".." && !relative.startsWith(`..${path3.sep}`) && !path3.isAbsolute(relative);
379
- }
380
- function selectRunTests(tests, filters) {
381
- const includes = filters.include ?? [];
382
- const excludes = filters.exclude ?? [];
383
- const labels = filters.labels ?? [];
384
- const names = filters.names ?? [];
385
- return tests.filter(
386
- (test) => (includes.length === 0 || includes.some((glob) => minimatch(test.file, glob))) && !excludes.some((glob) => minimatch(test.file, glob)) && labels.every((label) => test.tags.includes(label)) && (names.length === 0 || names.some(
387
- (name) => `${test.id}
388
- ${test.description ?? ""}`.toLowerCase().includes(name.toLowerCase())
389
- ))
390
- );
391
- }
392
- async function discoverRunTests(config, paths, filters = {}) {
393
- const problems = [];
394
- const files = /* @__PURE__ */ new Set();
395
- const root = await realpath2(config.projectRoot);
396
- if (paths.length === 0) {
397
- for (const file of await discoverConfiguredTests(config)) {
398
- const target = await realpath2(file);
399
- if (contained(root, target)) files.add(target);
400
- else
401
- problems.push({
402
- file: "<outside-project>",
403
- code: "outside_root",
404
- message: "A configured test is outside the project root.",
405
- fix: "Keep the test directory inside the project."
406
- });
407
- }
408
- } else {
409
- for (const requested of paths) {
410
- const candidate = path3.resolve(config.projectRoot, requested);
411
- const namedInside = contained(config.projectRoot, candidate);
412
- const file = namedInside ? path3.relative(config.projectRoot, candidate).split(path3.sep).join("/") : "<outside-project>";
413
- if (!namedInside) {
414
- problems.push({
415
- file,
416
- code: "outside_root",
417
- message: "Path is outside the project root.",
418
- fix: "Choose a path inside the project."
419
- });
420
- continue;
421
- }
422
- let info;
423
- try {
424
- info = await lstat2(candidate);
425
- } catch {
426
- problems.push({
427
- file,
428
- code: "missing_path",
429
- message: "Path does not exist.",
430
- fix: "Check the path and rerun."
431
- });
432
- continue;
433
- }
434
- if (info.isSymbolicLink()) {
435
- problems.push({
436
- file,
437
- code: "symlinked_path",
438
- message: "Symlinked test paths are not supported.",
439
- fix: "Name the regular file."
440
- });
441
- continue;
442
- }
443
- const target = await realpath2(candidate).catch(() => candidate);
444
- if (!contained(root, target)) {
445
- problems.push({
446
- file,
447
- code: "outside_root",
448
- message: "Path is outside the project root.",
449
- fix: "Choose a path inside the project."
450
- });
451
- continue;
452
- }
453
- if (info.isDirectory()) {
454
- for (const file2 of await walkSuiteFiles(
455
- target,
456
- [".test.yaml"],
457
- (folder) => {
458
- problems.push({
459
- file: path3.relative(root, folder),
460
- code: "unreadable_directory",
461
- message: "Directory could not be read.",
462
- fix: "Check permissions."
463
- });
464
- }
465
- ))
466
- files.add(file2);
467
- } else if (info.isFile() && candidate.endsWith(".test.yaml"))
468
- files.add(target);
469
- else
470
- problems.push({
471
- file,
472
- code: "unsupported_file",
473
- message: "Expected a *.test.yaml file or directory.",
474
- fix: "Choose a test path."
475
- });
476
- }
477
- }
478
- const parsed = [];
479
- for (const file of [...files].sort()) {
480
- parsed.push({
481
- file,
482
- result: await loadFlowFile(file, {
483
- repoRoot: root,
484
- rejectSymlinks: true
485
- })
486
- });
487
- }
488
- const listing = listTests(parsed, { repoRoot: root });
489
- return {
490
- tests: selectRunTests(listing.tests, filters),
491
- invalid: listing.invalid,
492
- problems
493
- };
494
- }
495
-
496
370
  // src/run-shard.ts
497
371
  import { createHash as createHash2 } from "crypto";
498
372
  function hashKey(key) {
@@ -573,7 +447,7 @@ async function openReportCopy(root, runId, canonical, outputDir, reporterDir, se
573
447
  process.env
574
448
  )
575
449
  } : null;
576
- if (path4.resolve(reporterDir) === path4.resolve(outputDir)) {
450
+ if (path3.resolve(reporterDir) === path3.resolve(outputDir)) {
577
451
  if (junit) canonical.includeJunit(junit);
578
452
  return void 0;
579
453
  }
@@ -585,7 +459,7 @@ async function openReportCopy(root, runId, canonical, outputDir, reporterDir, se
585
459
  });
586
460
  }
587
461
  function reportFormat(target) {
588
- const name = path4.basename(target);
462
+ const name = path3.basename(target);
589
463
  return name === "report.html" ? "HTML" : name === "report.md" ? "Markdown" : "JUnit";
590
464
  }
591
465
  async function finishRun(canonical, copy, result, recordCopyFailure) {
@@ -661,8 +535,8 @@ async function resultWithoutSink(runId, diagnostic) {
661
535
  return recorder.snapshot;
662
536
  }
663
537
  async function preExecutionFailure(root, runId, outputDir, reporterDir, selection, strict, diagnostic, commit) {
664
- const base = outputDir ?? path4.join(root, ".sedum", "runs");
665
- const intended = path4.join(base, runId);
538
+ const base = outputDir ?? path3.join(root, ".sedum", "runs");
539
+ const intended = path3.join(base, runId);
666
540
  let writer;
667
541
  try {
668
542
  writer = await ProgressWriter.create(root, runId, base, {
@@ -673,8 +547,8 @@ async function preExecutionFailure(root, runId, outputDir, reporterDir, selectio
673
547
  return {
674
548
  result: await resultWithoutSink(runId, diagnostic),
675
549
  artifacts: {
676
- progressPath: path4.join(intended, "progress.json"),
677
- resultPath: path4.join(intended, "result.json"),
550
+ progressPath: path3.join(intended, "progress.json"),
551
+ resultPath: path3.join(intended, "result.json"),
678
552
  authoritative: false
679
553
  },
680
554
  diagnostic
@@ -736,7 +610,7 @@ async function executeRunCommand(options) {
736
610
  throw new ProjectConfigError([
737
611
  {
738
612
  code: "invalid_browser",
739
- file: path4.join(invocationRoot, "sedum.config.yaml"),
613
+ file: path3.join(invocationRoot, "sedum.config.yaml"),
740
614
  line: 1,
741
615
  col: 1,
742
616
  key: "browser",
@@ -755,7 +629,7 @@ async function executeRunCommand(options) {
755
629
  throw new ProjectConfigError([
756
630
  {
757
631
  code: "invalid_url_override",
758
- file: path4.join(invocationRoot, "sedum.config.yaml"),
632
+ file: path3.join(invocationRoot, "sedum.config.yaml"),
759
633
  line: 1,
760
634
  col: 1,
761
635
  key: "urlOverride",
@@ -768,16 +642,34 @@ async function executeRunCommand(options) {
768
642
  ...options.environment ? { environment: options.environment } : {},
769
643
  ...options.browser ? { browser: options.browser } : {},
770
644
  ...options.outputDir ? { outputDir: options.outputDir } : {},
771
- ...options.reporterDir ? { reporterDir: options.reporterDir } : {}
645
+ ...options.reporterDir ? { reporterDir: options.reporterDir } : {},
646
+ ...options.vision !== void 0 || options.visionModel !== void 0 ? {
647
+ vision: {
648
+ ...options.vision !== void 0 ? { enabled: options.vision } : {},
649
+ ...options.visionModel !== void 0 ? { model: options.visionModel } : {}
650
+ }
651
+ } : {}
772
652
  });
653
+ if (config.vision.enabled && !config.visionApiKey)
654
+ throw new ProjectConfigError([
655
+ {
656
+ code: "missing_vision_api_key",
657
+ file: path3.join(config.projectRoot, ".env"),
658
+ line: 1,
659
+ col: 1,
660
+ key: "OPEN_ROUTER_API_KEY",
661
+ message: "Vision fallback requires OPEN_ROUTER_API_KEY.",
662
+ fix: "Set OPEN_ROUTER_API_KEY in the invoking process or project-root .env, or disable vision."
663
+ }
664
+ ]);
773
665
  } catch (error) {
774
666
  const diagnostic = setupDiagnostic(error);
775
- const fallbackRoot = error instanceof ProjectConfigError && error.diagnostics[0]?.file ? path4.dirname(error.diagnostics[0].file) : invocationRoot;
667
+ const fallbackRoot = error instanceof ProjectConfigError && error.diagnostics[0]?.file ? path3.dirname(error.diagnostics[0].file) : invocationRoot;
776
668
  return preExecutionFailure(
777
669
  fallbackRoot,
778
670
  runId,
779
671
  void 0,
780
- options.reporterDir ? path4.resolve(fallbackRoot, options.reporterDir) : path4.join(fallbackRoot, ".sedum", "reports"),
672
+ options.reporterDir ? path3.resolve(fallbackRoot, options.reporterDir) : path3.join(fallbackRoot, ".sedum", "reports"),
781
673
  reportFiles,
782
674
  options.strict ?? false,
783
675
  diagnostic,
@@ -826,13 +718,13 @@ async function executeRunCommand(options) {
826
718
  );
827
719
  } catch {
828
720
  commit();
829
- const intended = path4.join(config.outputDir, runId);
830
- const diagnostic = outputDiagnostic(path4.join(intended, "result.json"));
721
+ const intended = path3.join(config.outputDir, runId);
722
+ const diagnostic = outputDiagnostic(path3.join(intended, "result.json"));
831
723
  return {
832
724
  result: await resultWithoutSink(runId, diagnostic),
833
725
  artifacts: {
834
- progressPath: path4.join(intended, "progress.json"),
835
- resultPath: path4.join(intended, "result.json"),
726
+ progressPath: path3.join(intended, "progress.json"),
727
+ resultPath: path3.join(intended, "result.json"),
836
728
  authoritative: false
837
729
  },
838
730
  diagnostic
@@ -929,7 +821,7 @@ async function executeRunCommand(options) {
929
821
  );
930
822
  } catch {
931
823
  const diagnostic = outputDiagnostic(
932
- path4.join(config.reporterDir, runId, "result.json")
824
+ path3.join(config.reporterDir, runId, "result.json")
933
825
  );
934
826
  commit();
935
827
  await recorder.finish(canonicalDiagnosticError(diagnostic));
@@ -996,7 +888,7 @@ async function executeRunCommand(options) {
996
888
  );
997
889
  globalSelectedTests = selection.tests.length;
998
890
  const selected = options.shard ? shardTests(selection.tests, options.shard) : selection.tests;
999
- files = selected.map((test) => path4.join(config.projectRoot, test.file));
891
+ files = selected.map((test) => path3.join(config.projectRoot, test.file));
1000
892
  discoveryProblems = [
1001
893
  ...selection.problems,
1002
894
  ...selection.invalid.flatMap(
@@ -1065,7 +957,7 @@ async function executeRunCommand(options) {
1065
957
  const error = new ProjectConfigError([
1066
958
  {
1067
959
  code: "no_tests",
1068
- file: config.configPath ?? path4.join(config.projectRoot, "sedum.config.yaml"),
960
+ file: config.configPath ?? path3.join(config.projectRoot, "sedum.config.yaml"),
1069
961
  line: 1,
1070
962
  col: 1,
1071
963
  key: "tests.include",
@@ -1098,17 +990,24 @@ async function executeRunCommand(options) {
1098
990
  const gate = new ProviderGate({ concurrency: providerConcurrency });
1099
991
  const provider = new TypeSafeAdapter({
1100
992
  ...config.apiKey ? { apiKey: config.apiKey } : {},
993
+ baseURL: config.providerBaseUrl,
994
+ model: config.providerModel,
1101
995
  gate
1102
996
  });
1103
997
  const cache = await FileClassificationCache.load(
1104
- path4.join(config.projectRoot, ".sedum", "classifications.json"),
1105
- "jev-latest"
998
+ path3.join(config.projectRoot, ".sedum", "classifications.json"),
999
+ config.providerModel
1106
1000
  );
1107
1001
  const locatorCache = await openLocatorCache(config.projectRoot, {
1108
1002
  disabled: options.locatorCacheDisabled ?? false,
1109
1003
  ciOptIn: options.locatorCacheCi ?? false,
1110
1004
  env: process.env
1111
1005
  });
1006
+ const visionResolver = config.vision.enabled ? new OpenRouterVisionResolver({
1007
+ apiKey: config.visionApiKey,
1008
+ model: config.vision.model,
1009
+ timeoutMs: config.vision.timeoutMs
1010
+ }) : void 0;
1112
1011
  let operational = null;
1113
1012
  const driver = new PlaywrightBrowserDriver();
1114
1013
  const browsers = Array.from(
@@ -1131,6 +1030,7 @@ async function executeRunCommand(options) {
1131
1030
  provider,
1132
1031
  classificationCache: cache,
1133
1032
  locatorCache,
1033
+ ...visionResolver ? { visionResolver } : {},
1134
1034
  // Per-attempt values let tests keep backend data apart, like
1135
1035
  // Playwright's TEST_PARALLEL_INDEX. They are env-derived, so
1136
1036
  // they stay opaque in model input and reports.
@@ -1168,7 +1068,8 @@ async function executeRunCommand(options) {
1168
1068
  operational ??= flowDiagnostic(result);
1169
1069
  return "stop";
1170
1070
  }
1171
- if (result.status === "passed") break;
1071
+ if (result.status === "passed" || result.retryable === false)
1072
+ break;
1172
1073
  }
1173
1074
  return "continue";
1174
1075
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sedum-cli",
3
- "version": "0.1.0-alpha.0",
3
+ "version": "0.1.0-alpha.4",
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.0",
29
- "@sedum-dev/provider-typesafe": "0.1.0-alpha.0",
30
- "@sedum-dev/reporters": "0.1.0-alpha.0"
28
+ "@sedum-dev/core": "0.1.0-alpha.4",
29
+ "@sedum-dev/provider-typesafe": "0.1.0-alpha.4",
30
+ "@sedum-dev/reporters": "0.1.0-alpha.4"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsup src/index.ts src/cli.ts --format esm --dts --clean --out-dir dist",