@vitest-agent/cli 4.1.7 → 4.1.9
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 +9 -30
- package/commands/record.js +3 -6
- package/lib/failure-code.js +20 -0
- package/main.d.ts +4 -2
- package/main.js +5 -2
- package/package.json +9 -9
- package/version.js +1 -1
package/commands/agent.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { failureCode } from "../lib/failure-code.js";
|
|
1
2
|
import { currentCwd } from "./flag-defaults.js";
|
|
2
3
|
import { recordCommand } from "./record.js";
|
|
3
4
|
import { triageCommand } from "./triage.js";
|
|
@@ -5,14 +6,14 @@ import { wrapupCommand } from "./wrapup.js";
|
|
|
5
6
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
6
7
|
import { CliExit } from "@effected/cli-kit";
|
|
7
8
|
import { SidecarPlatformLive, endAgentEffect, registerAgentEffect, resolveHookPaths, resolveProjectKeyFromCwdEffect } from "@vitest-agent/engine";
|
|
8
|
-
import {
|
|
9
|
+
import { Effect, Option } from "effect";
|
|
9
10
|
import { Argument, Command, Flag } from "effect/cli";
|
|
10
11
|
import { existsSync, readFileSync } from "node:fs";
|
|
11
12
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
12
13
|
import { findWorkspaceRootSync, getWorkspacePackagesSync } from "@effected/workspaces";
|
|
13
14
|
import { nodeSyncOps } from "@effected/workspaces/node-sync";
|
|
14
15
|
import { VITEST_CONFIG_FILES, classifyTestPath, detectNonDefaultDiscoverStrategy, findOwningWorkspace } from "@vitest-agent/sdk";
|
|
15
|
-
import {
|
|
16
|
+
import { injectEnv } from "@vitest-agent/sdk/dispatch";
|
|
16
17
|
import { resolveSidecarBinaryPath } from "@vitest-agent/sidecar";
|
|
17
18
|
|
|
18
19
|
// src/commands/agent.ts
|
|
@@ -20,35 +21,13 @@ const writeStdout = (line) => Effect.sync(() => {
|
|
|
20
21
|
process.stdout.write(`${line}\n`);
|
|
21
22
|
});
|
|
22
23
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* return
|
|
24
|
+
* Runs a hook step, turning any cause into the sidecar family's stderr line
|
|
25
|
+
* plus a recorded exit code. `CliExit.reportCause` SUCCEEDS on purpose: a
|
|
26
|
+
* failure would carry its own exit code, which beats the `CliExit` cell.
|
|
27
|
+
* `Option.none()` means the step failed and was reported: the handler must
|
|
28
|
+
* return without writing stdout.
|
|
28
29
|
*/
|
|
29
|
-
const
|
|
30
|
-
process.stderr.write(`${exitCode} ${tag}: ${message}\n`);
|
|
31
|
-
}).pipe(Effect.andThen(CliExit.set(exitCode)));
|
|
32
|
-
const reportCause = (cause) => {
|
|
33
|
-
const failures = cause.reasons.filter(Cause.isFailReason);
|
|
34
|
-
if (failures.length > 0) {
|
|
35
|
-
const error = failures[0].error;
|
|
36
|
-
const tagged = error;
|
|
37
|
-
const tag = tagged._tag ?? "UnknownError";
|
|
38
|
-
const message = tagged.reason ?? tagged.message ?? String(error);
|
|
39
|
-
const exitCode = exitCodeForTag(tag);
|
|
40
|
-
return writeStderrAndSetExit(exitCode, tag, message);
|
|
41
|
-
}
|
|
42
|
-
const defect = cause.reasons.filter(Cause.isDieReason)[0]?.defect;
|
|
43
|
-
const message = defect instanceof Error ? defect.message : String(defect ?? "unknown defect");
|
|
44
|
-
return writeStderrAndSetExit(5, "Defect", message);
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Runs a hook step, turning any cause into the stderr line plus a recorded
|
|
48
|
-
* exit code. `Option.none()` means the step failed and was reported: the
|
|
49
|
-
* handler must return without writing stdout.
|
|
50
|
-
*/
|
|
51
|
-
const orReportCause = (self) => self.pipe(Effect.map(Option.some), Effect.catchCause((cause) => reportCause(cause).pipe(Effect.as(Option.none()))));
|
|
30
|
+
const orReportCause = (self) => self.pipe(Effect.map(Option.some), Effect.catchCause((cause) => CliExit.reportCause(cause, failureCode).pipe(Effect.as(Option.none()))));
|
|
52
31
|
const hostKindOpt = Flag.String("host-kind").pipe(Flag.withDescription("Host vendor identifier; e.g. 'claude-code', 'cursor', 'goose'"));
|
|
53
32
|
const agentTypeOpt = Flag.String("agent-type").pipe(Flag.withDescription("Agent type, must begin with the host-kind prefix"));
|
|
54
33
|
const hostSessionIdOpt = Flag.String("host-session-id").pipe(Flag.withDescription("Host's native session id (host chat UUID; `session_id` in the CC hook payload)"));
|
package/commands/record.js
CHANGED
|
@@ -7,13 +7,10 @@ import { Argument, Command, Flag } from "effect/cli";
|
|
|
7
7
|
|
|
8
8
|
// src/commands/record.ts
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* cell); it runs in place of the stdout write, so stdout stays empty.
|
|
10
|
+
* The `record` family's one failure line, `record <name>: <error>`, with exit
|
|
11
|
+
* code 1. It runs in place of the stdout write, so stdout stays empty.
|
|
13
12
|
*/
|
|
14
|
-
const reportFailure = (name) => (err) =>
|
|
15
|
-
process.stderr.write(`record ${name}: ${Fmt.describe(err)}\n`);
|
|
16
|
-
}).pipe(Effect.andThen(CliExit.set(1)));
|
|
13
|
+
const reportFailure = (name) => (err) => CliExit.report(1, `record ${name}: ${Fmt.describe(err)}`);
|
|
17
14
|
const chatId = Flag.String("chat-id").pipe(Flag.withDescription("Host chat id (`session_id` in the Claude Code hook envelope; equivalent in other clients)"));
|
|
18
15
|
const occurredAt = Flag.String("occurred-at").pipe(Flag.withDefault(nowIso), Flag.withDescription("ISO 8601 timestamp; defaults to now"));
|
|
19
16
|
const payloadArg = Argument.String("payload-json").pipe(Argument.withDescription("Stringified JSON payload (validated against TurnPayload)"));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { exitCodeForTag } from "@vitest-agent/sdk/dispatch";
|
|
2
|
+
|
|
3
|
+
// src/lib/failure-code.ts
|
|
4
|
+
/**
|
|
5
|
+
* The exit code for a squashed failure: the sidecar family's code for its
|
|
6
|
+
* `_tag`, or the defect code when it has no string tag. The `codeOf` that
|
|
7
|
+
* `orReportCause` hands to `CliExit.reportCause`.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
const failureCode = (error) => {
|
|
12
|
+
try {
|
|
13
|
+
const tag = error?._tag;
|
|
14
|
+
return exitCodeForTag(typeof tag === "string" ? tag : "Defect");
|
|
15
|
+
} catch {
|
|
16
|
+
return exitCodeForTag("Defect");
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { failureCode };
|
package/main.d.ts
CHANGED
|
@@ -27,7 +27,9 @@ export interface MainOptions {
|
|
|
27
27
|
* before the version), and `CliRuntime.main`'s `distribution` option wraps
|
|
28
28
|
* it, so `--version` names the carrier (`via @vitest-agent/plugin <version>`)
|
|
29
29
|
* when `options.distribution` is given; the kit provides the same value as
|
|
30
|
-
* `CurrentDistribution`.
|
|
30
|
+
* `CurrentDistribution`. `env.helpFlags` collapses the audience flags in
|
|
31
|
+
* subcommand help to a one-line pointer; root `--help` still lists them. An
|
|
32
|
+
* audience flag recomputes `CliInteractive` from the
|
|
31
33
|
* TTY facts, so `--human` in an agent-detected shell (Claude Code's terminal)
|
|
32
34
|
* at a real terminal may prompt.
|
|
33
35
|
*
|
|
@@ -61,7 +63,7 @@ export interface MainOptions {
|
|
|
61
63
|
* usage error, `130` a cancelled prompt, `1` any other reported failure.
|
|
62
64
|
* Commands that carry their own code (`db reset` / `db query`, `doctor`, the
|
|
63
65
|
* `agent` sidecar family, `agent record`, `check-test-path`, `sidecar-path`)
|
|
64
|
-
* write their stderr line
|
|
66
|
+
* write their stderr line and record the code through `CliExit`, and succeed;
|
|
65
67
|
* `CliRuntime.main` exits with it after the log sinks drain. No command
|
|
66
68
|
* handler calls `process.exit`.
|
|
67
69
|
*
|
package/main.js
CHANGED
|
@@ -54,7 +54,9 @@ const rootCommand = Command.make("vitest-agent").pipe(Command.withSharedFlags(Cl
|
|
|
54
54
|
* before the version), and `CliRuntime.main`'s `distribution` option wraps
|
|
55
55
|
* it, so `--version` names the carrier (`via @vitest-agent/plugin <version>`)
|
|
56
56
|
* when `options.distribution` is given; the kit provides the same value as
|
|
57
|
-
* `CurrentDistribution`.
|
|
57
|
+
* `CurrentDistribution`. `env.helpFlags` collapses the audience flags in
|
|
58
|
+
* subcommand help to a one-line pointer; root `--help` still lists them. An
|
|
59
|
+
* audience flag recomputes `CliInteractive` from the
|
|
58
60
|
* TTY facts, so `--human` in an agent-detected shell (Claude Code's terminal)
|
|
59
61
|
* at a real terminal may prompt.
|
|
60
62
|
*
|
|
@@ -88,7 +90,7 @@ const rootCommand = Command.make("vitest-agent").pipe(Command.withSharedFlags(Cl
|
|
|
88
90
|
* usage error, `130` a cancelled prompt, `1` any other reported failure.
|
|
89
91
|
* Commands that carry their own code (`db reset` / `db query`, `doctor`, the
|
|
90
92
|
* `agent` sidecar family, `agent record`, `check-test-path`, `sidecar-path`)
|
|
91
|
-
* write their stderr line
|
|
93
|
+
* write their stderr line and record the code through `CliExit`, and succeed;
|
|
92
94
|
* `CliRuntime.main` exits with it after the log sinks drain. No command
|
|
93
95
|
* handler calls `process.exit`.
|
|
94
96
|
*
|
|
@@ -112,6 +114,7 @@ const main = (options = {}) => {
|
|
|
112
114
|
env: {
|
|
113
115
|
audienceEnvVar: AUDIENCE_ENV_VAR,
|
|
114
116
|
formatter: plainVersionFormatter,
|
|
117
|
+
helpFlags: { inheritedFlags: "summary" },
|
|
115
118
|
displayPath: { relativeTo: projectDir },
|
|
116
119
|
log: {
|
|
117
120
|
envVar: "VITEST_REPORTER_LOG_LEVEL",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest-agent/cli",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.9",
|
|
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": [
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@effect/platform-node": "~4.1.2",
|
|
47
47
|
"@effect/sql-sqlite-node": "~4.1.2",
|
|
48
|
-
"@effected/cli-kit": "^0.
|
|
49
|
-
"@effected/config-file": "^0.
|
|
50
|
-
"@effected/env": "^0.
|
|
51
|
-
"@effected/glob": "^0.
|
|
52
|
-
"@effected/kit": "^0.
|
|
53
|
-
"@effected/walker": "^0.
|
|
54
|
-
"@effected/workspaces": "^0.
|
|
55
|
-
"@vitest-agent/engine": "3.
|
|
48
|
+
"@effected/cli-kit": "^0.27.1",
|
|
49
|
+
"@effected/config-file": "^0.26.0",
|
|
50
|
+
"@effected/env": "^0.11.0",
|
|
51
|
+
"@effected/glob": "^0.20.0",
|
|
52
|
+
"@effected/kit": "^0.13.0",
|
|
53
|
+
"@effected/walker": "^0.26.0",
|
|
54
|
+
"@effected/workspaces": "^0.44.0",
|
|
55
|
+
"@vitest-agent/engine": "3.2.0",
|
|
56
56
|
"@vitest-agent/sdk": "9.0.3",
|
|
57
57
|
"@vitest-agent/sidecar": "2.2.18",
|
|
58
58
|
"effect": "~4.1.2"
|