@vitest-agent/cli 2.0.17 → 2.1.1

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/commands/agent.js CHANGED
@@ -6,10 +6,13 @@ import { recordCommand } from "./record.js";
6
6
  import { triageCommand } from "./triage.js";
7
7
  import { wrapupCommand } from "./wrapup.js";
8
8
  import * as NodeServices from "@effect/platform-node/NodeServices";
9
- import { resolveProjectKeyFromCwd } from "@vitest-agent/sdk";
9
+ import { classifyTestPath, findOwningWorkspace, resolveProjectKeyFromCwd } from "@vitest-agent/sdk";
10
10
  import { Cause, Effect, Option } from "effect";
11
- import { join } from "node:path";
12
- import { Command, Flag } from "effect/unstable/cli";
11
+ import { existsSync } from "node:fs";
12
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
13
+ import { Argument, Command, Flag } from "effect/unstable/cli";
14
+ import { findWorkspaceRootSync, getWorkspacePackagesSync } from "@effected/workspaces";
15
+ import { nodeSyncOps } from "@effected/workspaces/node-sync";
13
16
  import { exitCodeForTag, injectEnv } from "@vitest-agent/sdk/dispatch";
14
17
  import { resolveSidecarBinaryPath } from "@vitest-agent/sidecar";
15
18
 
@@ -36,6 +39,10 @@ import { resolveSidecarBinaryPath } from "@vitest-agent/sidecar";
36
39
  * 4 = project identity not resolvable
37
40
  * 5 = other unexpected defect
38
41
  *
42
+ * `check-test-path` is not part of that family and does not share the
43
+ * taxonomy: it exits 1, with nothing on stdout, to mean "no verdict was
44
+ * rendered — fail open."
45
+ *
39
46
  * @packageDocumentation
40
47
  */
41
48
  const writeStdout = (line) => Effect.sync(() => {
@@ -150,6 +157,44 @@ const sidecarPathSubcommand = Command.make("sidecar-path", {}, () => Effect.sync
150
157
  if (path === null) process.exit(1);
151
158
  process.stdout.write(`${path}\n`);
152
159
  })).pipe(Command.withDescription("Print the absolute path of the platform sidecar binary resolved via require.resolve"));
160
+ const testPathArg = Argument.string("path").pipe(Argument.withDescription("Path to classify against the workspace test layout; relative paths resolve against VITEST_AGENT_PROJECT_DIR, or cwd when that is unset"));
161
+ /**
162
+ * True when any directory between `ownerPath` and `filePath`'s own directory
163
+ * declares its own `package.json`.
164
+ *
165
+ * This is the one boundary `classifyTestPath` cannot check: a nested manifest
166
+ * marks an independent unit — a vendored upstream checkout under `.repos/`, a
167
+ * fixture package shaped like a real one — whose tests belong to a different
168
+ * discovery pass. `findTestFiles` stops there, so the layout rule has nothing
169
+ * to say about what sits beyond it, and the caller must fail open. The probe
170
+ * lives in this seam rather than in the pure classifier because it needs the
171
+ * filesystem.
172
+ *
173
+ * @internal
174
+ */
175
+ function crossesNestedPackageBoundary(ownerPath, filePath) {
176
+ const rel = relative(ownerPath, dirname(filePath));
177
+ if (rel === "" || rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) return false;
178
+ let dir = ownerPath;
179
+ for (const segment of rel.split(sep)) {
180
+ dir = join(dir, segment);
181
+ if (existsSync(join(dir, "package.json"))) return true;
182
+ }
183
+ return false;
184
+ }
185
+ const checkTestPathSubcommand = Command.make("check-test-path", { path: testPathArg }, (opts) => Effect.sync(() => {
186
+ const from = process.env.VITEST_AGENT_PROJECT_DIR ?? process.cwd();
187
+ const absolute = isAbsolute(opts.path) ? opts.path : resolve(from, opts.path);
188
+ const root = findWorkspaceRootSync(from, nodeSyncOps);
189
+ if (root === null) process.exit(1);
190
+ const packages = getWorkspacePackagesSync(root, nodeSyncOps);
191
+ const owner = findOwningWorkspace(packages, absolute);
192
+ if (owner === null) process.exit(1);
193
+ if (crossesNestedPackageBoundary(owner.path, absolute)) process.exit(1);
194
+ const classification = classifyTestPath(packages, absolute);
195
+ if (classification === null) process.exit(1);
196
+ process.stdout.write(`${JSON.stringify(classification)}\n`);
197
+ })).pipe(Command.withDescription("Classify a test file path as valid, excluded, or invalid for Vitest discovery"));
153
198
  const agentParent = Command.make("agent").pipe(Command.withDescription("Commands intended for agents and hook scripts — humans typically don't invoke these directly."));
154
199
  const agentCommand = agentParent.pipe(Command.withSubcommands([
155
200
  triageCommand,
@@ -158,8 +203,9 @@ const agentCommand = agentParent.pipe(Command.withSubcommands([
158
203
  registerAgentSubcommand,
159
204
  endAgentSubcommand,
160
205
  injectEnvSubcommand,
161
- sidecarPathSubcommand
206
+ sidecarPathSubcommand,
207
+ checkTestPathSubcommand
162
208
  ]));
163
209
 
164
210
  //#endregion
165
- export { agentCommand, endAgentSubcommand, injectEnvSubcommand, registerAgentSubcommand, sidecarPathSubcommand };
211
+ export { agentCommand, checkTestPathSubcommand, endAgentSubcommand, injectEnvSubcommand, registerAgentSubcommand, sidecarPathSubcommand };
package/index.js CHANGED
@@ -11,7 +11,7 @@ import { DATA_DB_FILENAME, REGISTRY_DB_FILENAME, SESSIONS_DB_FILENAME, resolvePr
11
11
  *
12
12
  * @public
13
13
  */
14
- const CURRENT_CLI_VERSION = "2.0.17";
14
+ const CURRENT_CLI_VERSION = "2.1.1";
15
15
 
16
16
  //#endregion
17
17
  export { CURRENT_CLI_VERSION, CliLive, DATA_DB_FILENAME, REGISTRY_DB_FILENAME, SESSIONS_DB_FILENAME, SidecarLive, registerAgentEffect, resolveProjectDataDir, resolveRegistryDir, resolveSessionMapPath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitest-agent/cli",
3
- "version": "2.0.17",
3
+ "version": "2.1.1",
4
4
  "private": false,
5
5
  "description": "On-demand CLI for vitest-agent. Reads cached test data and reports status, overview, coverage, history, trends, and cache health.",
6
6
  "keywords": [
@@ -40,8 +40,9 @@
40
40
  "dependencies": {
41
41
  "@effect/platform-node": "4.0.0-beta.107",
42
42
  "@effect/sql-sqlite-node": "4.0.0-beta.107",
43
- "@vitest-agent/sdk": "2.1.0",
44
- "@vitest-agent/sidecar": "2.0.9",
43
+ "@effected/workspaces": "^0.11.2",
44
+ "@vitest-agent/sdk": "2.2.1",
45
+ "@vitest-agent/sidecar": "2.0.11",
45
46
  "effect": "4.0.0-beta.107"
46
47
  },
47
48
  "engines": {