@vitest-agent/plugin 3.0.3 → 4.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.
- package/bin/vitest-agent-mcp.js +8 -0
- package/bin/vitest-agent.js +8 -0
- package/index.d.ts +10 -6
- package/layers/ReporterLive.js +8 -11
- package/package.json +12 -7
- package/plugin.js +5 -4
- package/reporter.js +13 -7
- package/utils/process-failure.js +2 -1
package/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { EnvironmentDetector, PlatformOptions, SettingsInput, StackFrameInput } from "@vitest-agent/engine";
|
|
2
|
+
import { AgentPluginOptions, AgentReporterOptions, ConsoleMode, CoverageBaselines, CoverageInput, CoverageLevel, CoverageLevelName, CoverageLevelName as CoverageLevelName$1, CoverageReport, OutputFormat, ResolvedReporterConfig, ResolvedThresholds, RunEvent, Transport, VitestAgentReporterFactory, resolveCoverageInput, validateCoverageConfig } from "@vitest-agent/sdk";
|
|
3
|
+
import { Context, Effect, Layer, Option } from "effect";
|
|
3
4
|
import { TestProjectInlineConfiguration, TestTagDefinition } from "vitest/config";
|
|
4
5
|
import { ResolvedConfig, VitestPluginContext } from "vitest/node";
|
|
5
6
|
import { SourceMap } from "magic-string";
|
|
6
7
|
import { WorkspacesSyncOptions } from "@effected/workspaces/node-sync";
|
|
7
|
-
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
8
|
-
import * as SqliteMigrator from "@effect/sql-sqlite-node/SqliteMigrator";
|
|
9
8
|
//#region src/utils/tag.d.ts
|
|
10
9
|
/**
|
|
11
10
|
* Options for a `Tag`, mirroring `TestTagDefinition` minus the `name` field.
|
|
@@ -1205,10 +1204,15 @@ export declare function findTestFiles(dir: string, patterns: ReadonlyArray<strin
|
|
|
1205
1204
|
//#endregion
|
|
1206
1205
|
//#region src/layers/ReporterLive.d.ts
|
|
1207
1206
|
/**
|
|
1208
|
-
* Composition layer for a single `AgentReporter` run
|
|
1207
|
+
* Composition layer for a single `AgentReporter` run: the engine's
|
|
1208
|
+
* `PlatformLive` (SQLite, migrations, Node platform services, logger and
|
|
1209
|
+
* the shared service layers) plus the plugin-only `CoverageAnalyzer`.
|
|
1210
|
+
*
|
|
1211
|
+
* @param options - forwarded to `PlatformLive`; the reporter passes
|
|
1212
|
+
* `process.env` as `env`
|
|
1209
1213
|
* @public
|
|
1210
1214
|
*/
|
|
1211
|
-
export declare const ReporterLive: (
|
|
1215
|
+
export declare const ReporterLive: (options: PlatformOptions) => Layer.Layer<CoverageAnalyzer | import("@vitest-agent/engine").PlatformServices, import("@effect/sql-sqlite-node/SqliteMigrator").MigrationError | import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
1212
1216
|
//#endregion
|
|
1213
1217
|
//#region src/services/CoverageAnalyzer.d.ts
|
|
1214
1218
|
/**
|
package/layers/ReporterLive.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { CoverageAnalyzerLive } from "./CoverageAnalyzerLive.js";
|
|
2
|
-
import {
|
|
2
|
+
import { PlatformLive } from "@vitest-agent/engine";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
5
|
-
import { layer } from "@effect/sql-sqlite-node/SqliteClient";
|
|
6
|
-
import * as SqliteMigrator from "@effect/sql-sqlite-node/SqliteMigrator";
|
|
7
4
|
|
|
8
5
|
//#region src/layers/ReporterLive.ts
|
|
9
6
|
/**
|
|
10
|
-
* Composition layer for a single `AgentReporter` run
|
|
7
|
+
* Composition layer for a single `AgentReporter` run: the engine's
|
|
8
|
+
* `PlatformLive` (SQLite, migrations, Node platform services, logger and
|
|
9
|
+
* the shared service layers) plus the plugin-only `CoverageAnalyzer`.
|
|
10
|
+
*
|
|
11
|
+
* @param options - forwarded to `PlatformLive`; the reporter passes
|
|
12
|
+
* `process.env` as `env`
|
|
11
13
|
* @public
|
|
12
14
|
*/
|
|
13
|
-
const ReporterLive = (
|
|
14
|
-
const SqliteLayer = layer({ filename: dbPath });
|
|
15
|
-
const PlatformLayer = NodeServices.layer;
|
|
16
|
-
const MigratorLayer = SqliteMigrator.layer({ loader: SqliteMigrator.fromRecord(PROJECT_MIGRATIONS) }).pipe(Layer.provide(Layer.merge(SqliteLayer, PlatformLayer)));
|
|
17
|
-
return Layer.mergeAll(DataStoreLive, CoverageAnalyzerLive, HistoryTrackerLive, OutputPipelineLive).pipe(Layer.provideMerge(DataReaderLive), Layer.provideMerge(MigratorLayer), Layer.provideMerge(SqliteLayer), Layer.provideMerge(PlatformLayer), Layer.provideMerge(LoggerLive(logLevel, logFile)));
|
|
18
|
-
};
|
|
15
|
+
const ReporterLive = (options) => CoverageAnalyzerLive.pipe(Layer.provideMerge(PlatformLive(options)));
|
|
19
16
|
|
|
20
17
|
//#endregion
|
|
21
18
|
export { ReporterLive };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest-agent/plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.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": [
|
|
@@ -38,16 +38,21 @@
|
|
|
38
38
|
},
|
|
39
39
|
"./package.json": "./package.json"
|
|
40
40
|
},
|
|
41
|
+
"bin": {
|
|
42
|
+
"vitest-agent": "bin/vitest-agent.js",
|
|
43
|
+
"vitest-agent-mcp": "bin/vitest-agent-mcp.js"
|
|
44
|
+
},
|
|
41
45
|
"dependencies": {
|
|
42
46
|
"@effect/platform-node": "4.0.0-rc.115",
|
|
43
47
|
"@effect/sql-sqlite-node": "4.0.0-rc.115",
|
|
44
|
-
"@effected/workspaces": "^0.21.
|
|
45
|
-
"@vitest-agent/cli": "
|
|
46
|
-
"@vitest-agent/
|
|
47
|
-
"@vitest-agent/
|
|
48
|
-
"@vitest-agent/
|
|
48
|
+
"@effected/workspaces": "^0.21.1",
|
|
49
|
+
"@vitest-agent/cli": "3.0.0",
|
|
50
|
+
"@vitest-agent/engine": "0.1.0",
|
|
51
|
+
"@vitest-agent/mcp": "4.0.0",
|
|
52
|
+
"@vitest-agent/reporter": "3.0.4",
|
|
53
|
+
"@vitest-agent/sdk": "4.0.0",
|
|
49
54
|
"effect": "4.0.0-rc.115",
|
|
50
|
-
"magic-string": "^1.
|
|
55
|
+
"magic-string": "^1.3.1"
|
|
51
56
|
},
|
|
52
57
|
"peerDependencies": {
|
|
53
58
|
"@vitest/coverage-istanbul": "^5.0.0",
|
package/plugin.js
CHANGED
|
@@ -19,7 +19,8 @@ import { execSync } from "node:child_process";
|
|
|
19
19
|
import { mkdtempSync, rmSync } from "node:fs";
|
|
20
20
|
import { tmpdir } from "node:os";
|
|
21
21
|
import { join } from "node:path";
|
|
22
|
-
import {
|
|
22
|
+
import { EnvironmentDetector, EnvironmentDetectorLive, resolveLogLevel } from "@vitest-agent/engine";
|
|
23
|
+
import { AgentConsoleMode, CiConsoleMode, CoverageLevel, HumanConsoleMode, SRC_DIR, TEST_DIR, formatFatalError, isTestFileName } from "@vitest-agent/sdk";
|
|
23
24
|
import { Effect, Schema } from "effect";
|
|
24
25
|
|
|
25
26
|
//#region src/plugin.ts
|
|
@@ -126,7 +127,7 @@ const coverageDirDecidedByVitest = /* @__PURE__ */ new WeakSet();
|
|
|
126
127
|
*
|
|
127
128
|
* @public
|
|
128
129
|
*/
|
|
129
|
-
const CURRENT_PLUGIN_VERSION = "
|
|
130
|
+
const CURRENT_PLUGIN_VERSION = "4.0.0";
|
|
130
131
|
const TEST_FILE_DIR_RE = new RegExp(`/(?:${SRC_DIR}|${TEST_DIR})/`);
|
|
131
132
|
const isTestFile = (id) => isTestFileName(id) && TEST_FILE_DIR_RE.test(id);
|
|
132
133
|
/**
|
|
@@ -177,8 +178,8 @@ function installViteSourceMapWarningFilter(resolvedConfig) {
|
|
|
177
178
|
* @public
|
|
178
179
|
*/
|
|
179
180
|
function AgentPlugin(options = {}, _layer) {
|
|
180
|
-
const layer = _layer ?? EnvironmentDetectorLive;
|
|
181
|
-
const logLevel = resolveLogLevel();
|
|
181
|
+
const layer = _layer ?? EnvironmentDetectorLive(process.env);
|
|
182
|
+
const logLevel = resolveLogLevel(process.env);
|
|
182
183
|
const log = logLevel !== void 0 && logLevel !== "None" ? (...args) => process.stderr.write(`[vitest-agent:plugin] ${args.map(String).join(" ")}\n`) : (..._args) => {};
|
|
183
184
|
const discoverStrategyResolved = options.discoverStrategy === false ? null : options.discoverStrategy ?? new DefaultDiscoverStrategy();
|
|
184
185
|
const classifyForCache = (id) => {
|
package/reporter.js
CHANGED
|
@@ -11,7 +11,8 @@ import { routeRenderedOutput } from "./utils/route-rendered-output.js";
|
|
|
11
11
|
import { stringifyFailureValue } from "./utils/stringify-failure-value.js";
|
|
12
12
|
import { mkdirSync, statSync } from "node:fs";
|
|
13
13
|
import { dirname } from "node:path";
|
|
14
|
-
import { DataReader, DataStore, DetailResolver, EnvironmentDetector, ExecutorResolver, FormatSelector, HistoryTracker, OutputPipelineLive, PathResolutionLive,
|
|
14
|
+
import { DataReader, DataStore, DetailResolver, EnvironmentDetector, ExecutorResolver, FormatSelector, HistoryTracker, OutputPipelineLive, PathResolutionLive, ensureMigrated, historyKey, resolveDataPath, resolveLogFile, resolveLogLevel } from "@vitest-agent/engine";
|
|
15
|
+
import { buildAgentReport, coerceErrorField, computeTrend, formatFatalError, isTimeoutError, probeHostMetadataFromEnv } from "@vitest-agent/sdk";
|
|
15
16
|
import { Effect, Option, PubSub } from "effect";
|
|
16
17
|
import { randomUUID } from "node:crypto";
|
|
17
18
|
import { NodeServices } from "@effect/platform-node";
|
|
@@ -387,8 +388,8 @@ var AgentReporter = class {
|
|
|
387
388
|
*/
|
|
388
389
|
neutralizedThresholdSnapshot = /* @__PURE__ */ new Map();
|
|
389
390
|
constructor(options = {}) {
|
|
390
|
-
this.logLevel = resolveLogLevel();
|
|
391
|
-
this.logFile = resolveLogFile();
|
|
391
|
+
this.logLevel = resolveLogLevel(process.env);
|
|
392
|
+
this.logFile = resolveLogFile(process.env);
|
|
392
393
|
this.onRunEvent = options.onRunEvent;
|
|
393
394
|
this.hasCustomReporter = options.reporter !== void 0;
|
|
394
395
|
this.runEvents = Effect.runSync(PubSub.unbounded());
|
|
@@ -512,7 +513,7 @@ var AgentReporter = class {
|
|
|
512
513
|
}, opts.detail)
|
|
513
514
|
};
|
|
514
515
|
});
|
|
515
|
-
const { env, executor, format, detail } = await Effect.runPromise(initProgram.pipe(Effect.provide(OutputPipelineLive), Effect.provide(NodeServices.layer)));
|
|
516
|
+
const { env, executor, format, detail } = await Effect.runPromise(initProgram.pipe(Effect.provide(OutputPipelineLive(process.env)), Effect.provide(NodeServices.layer)));
|
|
516
517
|
const kit = buildReporterKit({
|
|
517
518
|
env,
|
|
518
519
|
executor,
|
|
@@ -1139,7 +1140,7 @@ var AgentReporter = class {
|
|
|
1139
1140
|
...reportWriter !== null && { writeReport: reportWriter.write }
|
|
1140
1141
|
});
|
|
1141
1142
|
});
|
|
1142
|
-
await Effect.runPromise(uiProgram.pipe(Effect.provide(OutputPipelineLive), Effect.provide(NodeServices.layer))).catch((err) => {
|
|
1143
|
+
await Effect.runPromise(uiProgram.pipe(Effect.provide(OutputPipelineLive(process.env)), Effect.provide(NodeServices.layer))).catch((err) => {
|
|
1143
1144
|
process.stderr.write(`vitest-agent: ${formatFatalError(err)}\n`);
|
|
1144
1145
|
});
|
|
1145
1146
|
await reportWriter?.flush();
|
|
@@ -1624,7 +1625,12 @@ var AgentReporter = class {
|
|
|
1624
1625
|
});
|
|
1625
1626
|
let persistFailure;
|
|
1626
1627
|
let persistResult;
|
|
1627
|
-
if (persistDisabled === void 0 && dbPath !== void 0) persistResult = await Effect.runPromise(persistProgram.pipe(Effect.annotateLogs("service", "reporter"), Effect.provide(ReporterLive(
|
|
1628
|
+
if (persistDisabled === void 0 && dbPath !== void 0) persistResult = await Effect.runPromise(persistProgram.pipe(Effect.annotateLogs("service", "reporter"), Effect.provide(ReporterLive({
|
|
1629
|
+
dbPath,
|
|
1630
|
+
env: process.env,
|
|
1631
|
+
logLevel,
|
|
1632
|
+
logFile
|
|
1633
|
+
})))).catch((err) => {
|
|
1628
1634
|
persistFailure = formatFatalError(err);
|
|
1629
1635
|
});
|
|
1630
1636
|
const renderInputData = persistResult ?? {
|
|
@@ -1689,7 +1695,7 @@ var AgentReporter = class {
|
|
|
1689
1695
|
...reportWriter !== null && { writeReport: reportWriter.write }
|
|
1690
1696
|
});
|
|
1691
1697
|
});
|
|
1692
|
-
await Effect.runPromise(renderProgram.pipe(Effect.annotateLogs("service", "reporter"), Effect.provide(OutputPipelineLive), Effect.provide(NodeServices.layer))).catch((err) => {
|
|
1698
|
+
await Effect.runPromise(renderProgram.pipe(Effect.annotateLogs("service", "reporter"), Effect.provide(OutputPipelineLive(process.env)), Effect.provide(NodeServices.layer))).catch((err) => {
|
|
1693
1699
|
process.stderr.write(`vitest-agent: ${formatFatalError(err)}\n`);
|
|
1694
1700
|
});
|
|
1695
1701
|
await reportWriter?.flush();
|
package/utils/process-failure.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
|
-
import { computeFailureSignature
|
|
2
|
+
import { computeFailureSignature } from "@vitest-agent/engine";
|
|
3
|
+
import { findFunctionBoundary } from "@vitest-agent/sdk";
|
|
3
4
|
|
|
4
5
|
//#region src/utils/process-failure.ts
|
|
5
6
|
const FRAME_LINE_REGEX = /^\s*at\s+(?:([\w$.<>[\] ]+?)\s+)?\(?([^\n)]+):(\d+):(\d+)\)?\s*$/;
|