@vitest-agent/plugin 1.0.1 → 1.1.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.
package/index.d.ts CHANGED
@@ -207,7 +207,7 @@ interface AgentPluginConstructorOptions extends AgentPluginOptions {
207
207
  * The version of this package, inlined at build time from
208
208
  * `package.json#version` via rslib-builder's `__PACKAGE_VERSION__` substitution.
209
209
  * Re-exported from the package barrel as the public symbol; defined here so
210
- * the drift-check code path can read it without a circular import.
210
+ * consumers can introspect the running plugin version without a circular import.
211
211
  *
212
212
  * @public
213
213
  */
@@ -987,13 +987,22 @@ declare function findTestFiles(dir: string, patterns: ReadonlyArray<string>): Pr
987
987
  * Composition layer for a single `AgentReporter` run. Wires SQLite, migrations, and all service layers.
988
988
  * @public
989
989
  */
990
- declare const ReporterLive: (dbPath: string, logLevel?: LogLevel.LogLevel, logFile?: string) => Layer.Layer<import("@vitest-agent/sdk").DataStore | import("@effect/sql/SqlClient").SqlClient | CoverageAnalyzer | import("@vitest-agent/sdk").HistoryTracker | import("@vitest-agent/sdk").DataReader | import("@vitest-agent/sdk").FormatSelector | import("@vitest-agent/sdk").ExecutorResolver | import("@vitest-agent/sdk").DetailResolver | import("@vitest-agent/sdk").EnvironmentDetector | import("@vitest-agent/sdk").OutputRenderer | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | NodeContext.NodeContext, import("@effect/sql/SqlError").SqlError | SqliteMigrator.MigrationError | import("effect/ConfigError").ConfigError, never>;
990
+ declare const ReporterLive: (dbPath: string, logLevel?: LogLevel.LogLevel, logFile?: string) => Layer.Layer<CoverageAnalyzer | import("@vitest-agent/sdk").DataReader | import("@vitest-agent/sdk").DataStore | import("@vitest-agent/sdk").DetailResolver | import("@vitest-agent/sdk").EnvironmentDetector | import("@vitest-agent/sdk").ExecutorResolver | import("@vitest-agent/sdk").FormatSelector | import("@vitest-agent/sdk").HistoryTracker | import("@vitest-agent/sdk").OutputRenderer | import("@effect/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | NodeContext.NodeContext, SqliteMigrator.MigrationError | import("@effect/sql/SqlError").SqlError | import("effect/ConfigError").ConfigError, never>;
991
991
  //#endregion
992
992
  //#region src/services/CoverageAnalyzer.d.ts
993
+ /**
994
+ * Options passed to `CoverageAnalyzer.process` and `CoverageAnalyzer.processScoped`.
995
+ *
996
+ * @public
997
+ */
993
998
  interface CoverageOptions {
999
+ /** Resolved coverage thresholds to check the report against. */
994
1000
  readonly thresholds: ResolvedThresholds;
1001
+ /** Per-file or global coverage targets for policy enforcement. */
995
1002
  readonly targets?: ResolvedThresholds;
1003
+ /** Persisted baselines used to compute coverage trends. */
996
1004
  readonly baselines?: CoverageBaselines;
1005
+ /** When true, include files with zero coverage rather than omitting them. */
997
1006
  readonly includeBareZero: boolean;
998
1007
  }
999
1008
  declare const CoverageAnalyzer_base: Context.TagClass<CoverageAnalyzer, "vitest-agent/CoverageAnalyzer", {
@@ -1212,5 +1221,5 @@ declare const COVERAGE_AUTOUPDATE: Readonly<{
1212
1221
  lenient: (n: number) => number;
1213
1222
  }>;
1214
1223
  //#endregion
1215
- export { type AddProjectInput, AgentPlugin, type AgentPluginConstructorOptions, AgentReporter, type AgentReporterConstructorOptions, CONSOLE_REPORTERS, COVERAGE_AUTOUPDATE, COVERAGE_LEVELS, COVERAGE_LEVELS_PER_FILE, CURRENT_PLUGIN_VERSION, type ClassifyContext, type ClassifyFn, ConfigValidation, ConfigValidationLive, ConfigValidationTest, CoverageAnalyzer, CoverageAnalyzerLive, CoverageAnalyzerTest, type CoverageInput, CoverageLevel, type CoverageLevelName, type CoverageLevelPreset, DefaultDiscoverStrategy, type DiscoverBuilder, type DiscoverInput, type PackageJson as DiscoverPackageJson, type DiscoverProjectsOptions, type DiscoverProjectsResult, type DiscoverResult, DiscoverStrategy, type DiscoverStrategyCreateOptions, type DiscoverStrategyExtendOptions, type InjectTagsResult, type ModuleInfo, ReporterLive, Tag, type TagOptions, type ValidationError, type ValidationInfo, type ValidationInput, type ValidationResult, type ValidationWarning, type VitestErrorLike, type VitestStackFrameLike, type VitestThresholdsInput, captureEnvVars, captureSettings, classifyByDirectory, classifyByFilename, combineClassifiers, discoverProjects, findTestFiles, hashSettings, processFailure, resolveCoverageInput, resolveThresholds, stripConsoleReporters, validateCoverageConfig };
1224
+ export { type AddProjectInput, AgentPlugin, type AgentPluginConstructorOptions, AgentReporter, type AgentReporterConstructorOptions, CONSOLE_REPORTERS, COVERAGE_AUTOUPDATE, COVERAGE_LEVELS, COVERAGE_LEVELS_PER_FILE, CURRENT_PLUGIN_VERSION, type ClassifyContext, type ClassifyFn, ConfigValidation, ConfigValidationLive, ConfigValidationTest, CoverageAnalyzer, CoverageAnalyzerLive, CoverageAnalyzerTest, type CoverageInput, CoverageLevel, type CoverageLevelName, type CoverageLevelPreset, type CoverageOptions, DefaultDiscoverStrategy, type DiscoverBuilder, type DiscoverInput, type PackageJson as DiscoverPackageJson, type DiscoverProjectsOptions, type DiscoverProjectsResult, type DiscoverResult, DiscoverStrategy, type DiscoverStrategyCreateOptions, type DiscoverStrategyExtendOptions, type InjectTagsResult, type ModuleInfo, ReporterLive, Tag, type TagOptions, type ValidationError, type ValidationInfo, type ValidationInput, type ValidationResult, type ValidationWarning, type VitestErrorLike, type VitestStackFrameLike, type VitestThresholdsInput, captureEnvVars, captureSettings, classifyByDirectory, classifyByFilename, combineClassifiers, discoverProjects, findTestFiles, hashSettings, processFailure, resolveCoverageInput, resolveThresholds, stripConsoleReporters, validateCoverageConfig };
1216
1225
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitest-agent/plugin",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "private": false,
5
5
  "description": "Vitest plugin for the vitest-agent ecosystem: owns persistence, classification, baselines, trends, and dispatches rendering to a configurable reporter.",
6
6
  "keywords": [
@@ -44,8 +44,8 @@
44
44
  "@effect/rpc": "^0.75.1",
45
45
  "@effect/sql": "^0.51.1",
46
46
  "@effect/sql-sqlite-node": "^0.52.0",
47
- "@vitest-agent/reporter": "1.0.1",
48
- "@vitest-agent/sdk": "1.0.1",
47
+ "@vitest-agent/reporter": "1.0.2",
48
+ "@vitest-agent/sdk": "1.1.0",
49
49
  "acorn": "^8.17.0",
50
50
  "acorn-typescript": "^1.4.13",
51
51
  "effect": "^3.21.4",
@@ -53,8 +53,8 @@
53
53
  "workspaces-effect": "^1.2.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "@vitest-agent/cli": "1.0.1",
57
- "@vitest-agent/mcp": "1.0.1",
56
+ "@vitest-agent/cli": "^1.0.2",
57
+ "@vitest-agent/mcp": "^1.1.0",
58
58
  "@vitest/coverage-istanbul": "^4.1.0",
59
59
  "@vitest/coverage-v8": "^4.1.0",
60
60
  "vitest": "^4.1.0"
package/plugin.js CHANGED
@@ -8,9 +8,8 @@ import { discoverProjects } from "./utils/discover-projects.js";
8
8
  import { injectTags } from "./utils/inject-tags.js";
9
9
  import { stripConsoleReporters } from "./utils/strip-console-reporters.js";
10
10
  import { execSync } from "node:child_process";
11
- import { CURRENT_REPORTER_VERSION } from "@vitest-agent/reporter";
12
- import { CURRENT_SDK_VERSION, CoverageLevel, EnvironmentDetector, EnvironmentDetectorLive, formatFatalError, resolveLogLevel } from "@vitest-agent/sdk";
13
- import { Effect } from "effect";
11
+ import { AgentConsoleMode, CiConsoleMode, CoverageLevel, EnvironmentDetector, EnvironmentDetectorLive, HumanConsoleMode, formatFatalError, resolveLogLevel } from "@vitest-agent/sdk";
12
+ import { Effect, Schema } from "effect";
14
13
 
15
14
  //#region src/plugin.ts
16
15
  /**
@@ -32,6 +31,13 @@ import { Effect } from "effect";
32
31
  * @internal
33
32
  */
34
33
  function resolveConsoleMode(options, executor, _env) {
34
+ const override = process.env.VITEST_AGENT_CONSOLE;
35
+ if (override !== void 0 && override !== "") {
36
+ if (executor === "human" && Schema.is(HumanConsoleMode)(override)) return override;
37
+ if (executor === "agent" && Schema.is(AgentConsoleMode)(override)) return override;
38
+ if (executor !== "human" && executor !== "agent" && Schema.is(CiConsoleMode)(override)) return override;
39
+ process.stderr.write(`[vitest-agent:plugin] ignoring invalid VITEST_AGENT_CONSOLE="${override}" for ${executor} executor\n`);
40
+ }
35
41
  const console = options.console;
36
42
  if (executor === "human") return console?.human ?? "passthrough";
37
43
  if (executor === "agent") return console?.agent ?? "agent";
@@ -87,48 +93,11 @@ const aggregatedReporterByVitest = /* @__PURE__ */ new WeakSet();
87
93
  * The version of this package, inlined at build time from
88
94
  * `package.json#version` via rslib-builder's `__PACKAGE_VERSION__` substitution.
89
95
  * Re-exported from the package barrel as the public symbol; defined here so
90
- * the drift-check code path can read it without a circular import.
96
+ * consumers can introspect the running plugin version without a circular import.
91
97
  *
92
98
  * @public
93
99
  */
94
- const CURRENT_PLUGIN_VERSION = "1.0.1";
95
- /**
96
- * Cross-package version drift warning state. Module-scoped so multi-project
97
- * Vitest configs construct one plugin per project but only emit the
98
- * warning once per Node process. See the root CLAUDE.md
99
- * "Cross-package version drift" section.
100
- *
101
- * @internal
102
- */
103
- let _hasWarnedDrift = false;
104
- /**
105
- * Compare CURRENT_PLUGIN_VERSION against each runtime peer the plugin
106
- * orchestrates and write one stderr line per mismatch. The check is
107
- * observation-only — never throws, never exits. Suppressed after the
108
- * first call in the same process so multi-project Vitest configs do
109
- * not duplicate the warning.
110
- *
111
- * The `"0.0.0"` fallback (from process.env.__PACKAGE_VERSION__ ??
112
- * "0.0.0" in the constant source) marks a dev build where rslib-builder
113
- * has not substituted the literal — typically when this module is
114
- * loaded directly from source rather than from dist. Skip the check
115
- * in that case; the asymmetry between source-loaded plugin and
116
- * dist-loaded peers would fire a spurious warning on every dev test
117
- * run otherwise.
118
- *
119
- * @internal
120
- */
121
- function checkVersionDrift(pluginVersion) {
122
- if (_hasWarnedDrift) return;
123
- if (pluginVersion === "0.0.0") return;
124
- const peers = [["@vitest-agent/sdk", CURRENT_SDK_VERSION], ["@vitest-agent/reporter", CURRENT_REPORTER_VERSION]];
125
- let warned = false;
126
- for (const [peerName, peerVersion] of peers) if (peerVersion !== pluginVersion) {
127
- process.stderr.write(`[@vitest-agent/plugin] version drift: @vitest-agent/plugin@${pluginVersion} with ${peerName}@${peerVersion}. Reinstall @vitest-agent/* packages so versions match.\n`);
128
- warned = true;
129
- }
130
- if (warned) _hasWarnedDrift = true;
131
- }
100
+ const CURRENT_PLUGIN_VERSION = "1.1.0";
132
101
  const TEST_FILE_SUFFIX_RE = /\.(?:test|spec)\.(?:ts|tsx|js|jsx)$/;
133
102
  const TEST_FILE_DIR_RE = /\/(?:src|__test__)\//;
134
103
  const isTestFile = (id) => TEST_FILE_SUFFIX_RE.test(id) && TEST_FILE_DIR_RE.test(id);
@@ -155,7 +124,6 @@ function envToExecutor(env) {
155
124
  * @public
156
125
  */
157
126
  function AgentPlugin(options = {}, _layer) {
158
- checkVersionDrift(CURRENT_PLUGIN_VERSION);
159
127
  const layer = _layer ?? EnvironmentDetectorLive;
160
128
  const logLevel = resolveLogLevel();
161
129
  const log = logLevel !== void 0 && logLevel._tag !== "None" ? (...args) => process.stderr.write(`[vitest-agent:plugin] ${args.map(String).join(" ")}\n`) : (..._args) => {};
@@ -326,4 +294,4 @@ function makeDiscoverBuilder(options) {
326
294
  })(AgentPlugin || (AgentPlugin = {}));
327
295
 
328
296
  //#endregion
329
- export { AgentPlugin, CURRENT_PLUGIN_VERSION };
297
+ export { AgentPlugin, CURRENT_PLUGIN_VERSION, resolveConsoleMode };
package/reporter.js CHANGED
@@ -7,13 +7,13 @@ import { captureSettings, hashSettings } from "./utils/capture-settings.js";
7
7
  import { processFailure } from "./utils/process-failure.js";
8
8
  import { routeRenderedOutput } from "./utils/route-rendered-output.js";
9
9
  import { stringifyFailureValue } from "./utils/stringify-failure-value.js";
10
- import { DefaultVitestAgentReporter } from "@vitest-agent/reporter";
11
10
  import { DataReader, DataStore, DetailResolver, EnvironmentDetector, ExecutorResolver, FormatSelector, HistoryTracker, OutputPipelineLive, PathResolutionLive, buildAgentReport, computeTrend, ensureMigrated, formatFatalError, isTimeoutError, probeHostMetadataFromEnv, resolveDataPath, resolveLogFile, resolveLogLevel } from "@vitest-agent/sdk";
12
11
  import { Effect, Option, PubSub } from "effect";
13
12
  import { randomUUID } from "node:crypto";
14
13
  import { mkdirSync } from "node:fs";
15
14
  import { dirname } from "node:path";
16
15
  import { NodeContext } from "@effect/platform-node";
16
+ import { DefaultVitestAgentReporter } from "@vitest-agent/reporter";
17
17
 
18
18
  //#region src/reporter.ts
19
19
  /**