@vitest-agent/plugin 6.0.6 → 6.0.8
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 +10 -3
- package/bin/vitest-agent.js +10 -3
- package/package.json +9 -9
- package/utils/build-module-info.js +31 -29
- package/utils/find-test-files.js +1 -1
- package/version.js +1 -1
package/bin/vitest-agent-mcp.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { CURRENT_PLUGIN_VERSION } from "../version.js";
|
|
3
|
-
import { main } from "@vitest-agent/mcp/main";
|
|
4
|
-
|
|
5
2
|
// src/bin/vitest-agent-mcp.ts
|
|
3
|
+
if (import.meta.url.endsWith(".ts")) {
|
|
4
|
+
const { register } = await import([
|
|
5
|
+
"tsx",
|
|
6
|
+
"esm",
|
|
7
|
+
"api"
|
|
8
|
+
].join("/"));
|
|
9
|
+
register();
|
|
10
|
+
}
|
|
11
|
+
const { main } = await import("@vitest-agent/mcp/main");
|
|
12
|
+
const { CURRENT_PLUGIN_VERSION } = await import("../version.js");
|
|
6
13
|
main({ distribution: {
|
|
7
14
|
name: "@vitest-agent/plugin",
|
|
8
15
|
version: CURRENT_PLUGIN_VERSION
|
package/bin/vitest-agent.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { CURRENT_PLUGIN_VERSION } from "../version.js";
|
|
3
|
-
import { main } from "@vitest-agent/cli/main";
|
|
4
|
-
|
|
5
2
|
// src/bin/vitest-agent.ts
|
|
3
|
+
if (import.meta.url.endsWith(".ts")) {
|
|
4
|
+
const { register } = await import([
|
|
5
|
+
"tsx",
|
|
6
|
+
"esm",
|
|
7
|
+
"api"
|
|
8
|
+
].join("/"));
|
|
9
|
+
register();
|
|
10
|
+
}
|
|
11
|
+
const { main } = await import("@vitest-agent/cli/main");
|
|
12
|
+
const { CURRENT_PLUGIN_VERSION } = await import("../version.js");
|
|
6
13
|
main({ distribution: {
|
|
7
14
|
name: "@vitest-agent/plugin",
|
|
8
15
|
version: CURRENT_PLUGIN_VERSION
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest-agent/plugin",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.8",
|
|
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,16 +44,16 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@effect/platform-node": "~4.1.2",
|
|
47
|
-
"@effected/cli-kit": "^0.27.
|
|
47
|
+
"@effected/cli-kit": "^0.27.1",
|
|
48
48
|
"@effected/commands": "^0.20.0",
|
|
49
49
|
"@effected/env": "^0.11.0",
|
|
50
|
-
"@effected/glob": "^0.
|
|
51
|
-
"@effected/walker": "^0.
|
|
52
|
-
"@effected/workspaces": "^0.
|
|
53
|
-
"@vitest-agent/cli": "4.1.
|
|
54
|
-
"@vitest-agent/engine": "3.1
|
|
55
|
-
"@vitest-agent/mcp": "6.1.
|
|
56
|
-
"@vitest-agent/reporter": "6.1.
|
|
50
|
+
"@effected/glob": "^0.20.0",
|
|
51
|
+
"@effected/walker": "^0.26.0",
|
|
52
|
+
"@effected/workspaces": "^0.44.1",
|
|
53
|
+
"@vitest-agent/cli": "4.1.10",
|
|
54
|
+
"@vitest-agent/engine": "3.2.1",
|
|
55
|
+
"@vitest-agent/mcp": "6.1.4",
|
|
56
|
+
"@vitest-agent/reporter": "6.1.6",
|
|
57
57
|
"@vitest-agent/sdk": "9.0.3",
|
|
58
58
|
"effect": "~4.1.2",
|
|
59
59
|
"magic-string": "^1.4.5"
|
|
@@ -1,45 +1,47 @@
|
|
|
1
1
|
import { toPosixPath } from "./to-posix-path.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { basename, dirname, join, relative } from "node:path";
|
|
3
|
+
import { Option } from "effect";
|
|
4
|
+
import { Walker } from "@effected/walker";
|
|
5
|
+
import { nodeWalkerFileSystem } from "@effected/walker/node-sync";
|
|
4
6
|
|
|
5
7
|
// src/utils/build-module-info.ts
|
|
6
|
-
const nodeBuildModuleInfoFs = {
|
|
7
|
-
exists: (path) => existsSync(path),
|
|
8
|
-
readFile: (path) => readFileSync(path, "utf8")
|
|
9
|
-
};
|
|
10
8
|
const NOT_FOUND = {
|
|
11
9
|
packageName: "",
|
|
12
10
|
packagePath: ""
|
|
13
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Each directory's verdict, a valid manifest's `name` or none, kept across
|
|
14
|
+
* calls so one tree is read once per directory over the whole run.
|
|
15
|
+
*/
|
|
14
16
|
const cache = /* @__PURE__ */ new Map();
|
|
15
|
-
|
|
17
|
+
/** `dirname(filePath)` and every ancestor up to the root, nearest first. */
|
|
18
|
+
const ancestors = (filePath) => {
|
|
19
|
+
const dirs = [];
|
|
16
20
|
let dir = dirname(filePath);
|
|
17
|
-
const visited = [];
|
|
18
21
|
while (true) {
|
|
19
|
-
|
|
20
|
-
if (cached !== void 0) {
|
|
21
|
-
for (const v of visited) cache.set(v, cached);
|
|
22
|
-
return cached;
|
|
23
|
-
}
|
|
24
|
-
visited.push(dir);
|
|
25
|
-
const pkgJsonPath = `${dir}/package.json`;
|
|
26
|
-
if (fs.exists(pkgJsonPath)) try {
|
|
27
|
-
const pkg = JSON.parse(fs.readFile(pkgJsonPath));
|
|
28
|
-
const result = {
|
|
29
|
-
packageName: typeof pkg.name === "string" ? pkg.name : "",
|
|
30
|
-
packagePath: dir
|
|
31
|
-
};
|
|
32
|
-
for (const v of visited) cache.set(v, result);
|
|
33
|
-
return result;
|
|
34
|
-
} catch {}
|
|
22
|
+
dirs.push(dir);
|
|
35
23
|
const parent = dirname(dir);
|
|
36
|
-
if (parent === dir)
|
|
37
|
-
for (const v of visited) cache.set(v, NOT_FOUND);
|
|
38
|
-
return NOT_FOUND;
|
|
39
|
-
}
|
|
24
|
+
if (parent === dir) return dirs;
|
|
40
25
|
dir = parent;
|
|
41
26
|
}
|
|
42
27
|
};
|
|
28
|
+
const resolvePackageInfo = (filePath, fs) => {
|
|
29
|
+
const found = Walker.findUpwardSyncWith(ancestors(filePath), (dir) => {
|
|
30
|
+
try {
|
|
31
|
+
const pkg = JSON.parse(fs.readFile(join(dir, "package.json")));
|
|
32
|
+
return Option.some(typeof pkg.name === "string" ? pkg.name : "");
|
|
33
|
+
} catch {
|
|
34
|
+
return Option.none();
|
|
35
|
+
}
|
|
36
|
+
}, { cache });
|
|
37
|
+
return Option.match(found, {
|
|
38
|
+
onNone: () => NOT_FOUND,
|
|
39
|
+
onSome: ({ dir, value }) => ({
|
|
40
|
+
packageName: value,
|
|
41
|
+
packagePath: dir
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
};
|
|
43
45
|
/**
|
|
44
46
|
* Build a {@link ModuleInfo} for the given file path by walking up the
|
|
45
47
|
* directory tree to locate the nearest `package.json`. Results are cached
|
|
@@ -55,7 +57,7 @@ const resolvePackageInfo = (filePath, fs) => {
|
|
|
55
57
|
* and keyed only by directory, so a test injecting a volume should use
|
|
56
58
|
* roots no other caller walks, or call {@link clearBuildModuleInfoCache}.
|
|
57
59
|
*/
|
|
58
|
-
const buildModuleInfo = (filePath, fs =
|
|
60
|
+
const buildModuleInfo = (filePath, fs = nodeWalkerFileSystem) => {
|
|
59
61
|
const queryIndex = filePath.indexOf("?");
|
|
60
62
|
const cleanId = queryIndex === -1 ? filePath : filePath.slice(0, queryIndex);
|
|
61
63
|
const { packageName, packagePath } = resolvePackageInfo(cleanId, fs);
|
package/utils/find-test-files.js
CHANGED
|
@@ -2,8 +2,8 @@ import { join } from "node:path";
|
|
|
2
2
|
import { NON_DISCOVERABLE_DIRS } from "@vitest-agent/sdk";
|
|
3
3
|
import { Result } from "effect";
|
|
4
4
|
import { GlobPattern } from "@effected/glob";
|
|
5
|
-
import { nodeWalkerSyncOps } from "@effected/walker/node-sync";
|
|
6
5
|
import { descendEntriesSync, descendSync } from "@effected/walker";
|
|
6
|
+
import { nodeWalkerSyncOps } from "@effected/walker/node-sync";
|
|
7
7
|
|
|
8
8
|
// src/utils/find-test-files.ts
|
|
9
9
|
const GLOB_OPTIONS = {
|