@vitest-agent/sdk 7.1.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ import { FiniteNumber } from "./Common.js";
1
2
  import { Effect, Schema } from "effect";
2
3
 
3
4
  // src/schemas/Thresholds.ts
@@ -6,10 +7,10 @@ import { Effect, Schema } from "effect";
6
7
  * @public
7
8
  */
8
9
  const MetricThresholds = Schema.Struct({
9
- lines: Schema.optional(Schema.Number),
10
- functions: Schema.optional(Schema.Number),
11
- branches: Schema.optional(Schema.Number),
12
- statements: Schema.optional(Schema.Number)
10
+ lines: Schema.optional(FiniteNumber),
11
+ functions: Schema.optional(FiniteNumber),
12
+ branches: Schema.optional(FiniteNumber),
13
+ statements: Schema.optional(FiniteNumber)
13
14
  }).annotate({ identifier: "MetricThresholds" });
14
15
  /**
15
16
  * A `perFile` setting. Vitest 5 allows either a plain boolean or a
@@ -99,5 +99,31 @@ function collectConsoleLeakEntries(files) {
99
99
  }
100
100
  return entries;
101
101
  }
102
+ const MAX_NOTE_FILES = 3;
103
+ /**
104
+ * The note a renderer prints for a run's console leaks: one line naming the
105
+ * write count, the file count and the fix, then up to three files with
106
+ * their stream split and sample, how many files it left out, and the output
107
+ * from failing tests that the leak count excludes. Empty when the run has no
108
+ * leak from a passing test (output from failing tests alone is not a leak).
109
+ * @public
110
+ */
111
+ const formatConsoleLeaksNote = (leaks) => {
112
+ if (leaks.total === 0) return [];
113
+ const files = leaks.byFile.length;
114
+ const lines = [`Console leaks: passing tests wrote ${leaks.total} console ${leaks.total === 1 ? "line" : "lines"} in ${files} ${files === 1 ? "file" : "files"}; Vitest captured them, so they are noise an agent never sees. Remove the logging or route it through a logger the tests silence.`];
115
+ const shown = leaks.byFile.slice(0, MAX_NOTE_FILES);
116
+ for (const file of shown) {
117
+ const streams = [file.stdout > 0 ? `${file.stdout} stdout` : "", file.stderr > 0 ? `${file.stderr} stderr` : ""].filter((part) => part.length > 0).join(", ");
118
+ const sample = file.sample !== void 0 ? `: ${file.sample}` : "";
119
+ lines.push(` ${file.file} (${streams})${sample}`);
120
+ }
121
+ const more = leaks.byFile.length - shown.length;
122
+ if (more > 0) lines.push(` (+${more} more ${more === 1 ? "file" : "files"}${leaks.truncated === true ? ", list truncated" : ""})`);
123
+ else if (leaks.truncated === true) lines.push(" (file list truncated)");
124
+ const failing = leaks.fromFailingTests;
125
+ if (failing !== void 0 && failing.total > 0) lines.push(` (${failing.total} more ${failing.total === 1 ? "line" : "lines"} from failing tests in ${failing.files} ${failing.files === 1 ? "file" : "files"}, not counted as leaks)`);
126
+ return lines;
127
+ };
102
128
 
103
- export { buildConsoleLeaks, collectConsoleLeakEntries };
129
+ export { buildConsoleLeaks, collectConsoleLeakEntries, formatConsoleLeaksNote };
package/version.js CHANGED
@@ -11,6 +11,6 @@
11
11
  * survives into the published artifact.
12
12
  * @public
13
13
  */
14
- const CURRENT_SDK_VERSION = "7.1.0";
14
+ const CURRENT_SDK_VERSION = "8.0.0";
15
15
 
16
16
  export { CURRENT_SDK_VERSION };
@@ -1,10 +0,0 @@
1
- // src/utils/hyperlink.ts
2
- const ESC = "\x1B";
3
- const BEL = "\x07";
4
- /** @public */
5
- const osc8 = (url, label, options) => {
6
- if (!options.enabled) return label;
7
- return `${ESC}]8;;${url}${BEL}${label}${ESC}]8;;${BEL}`;
8
- };
9
-
10
- export { osc8 };