@vitest-agent/cli 4.1.6 → 4.1.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/commands/agent.js +10 -31
- package/commands/db.js +1 -1
- package/commands/doctor.js +1 -1
- package/commands/record.js +5 -8
- package/commands/triage.js +1 -1
- package/commands/wrapup.js +1 -1
- package/lib/failure-code.js +20 -0
- package/lib/format-db-query.js +1 -1
- package/lib/render-failure.js +1 -1
- package/main.d.ts +6 -4
- package/main.js +10 -7
- package/package.json +14 -14
- package/tsdoc-metadata.json +1 -1
- package/version.js +1 -1
package/commands/agent.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
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";
|
|
4
5
|
import { wrapupCommand } from "./wrapup.js";
|
|
5
6
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
6
|
-
import { CliExit } from "@effected/cli";
|
|
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/db.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProjectDataLive, ProjectDir } from "../layers/project-data.js";
|
|
2
2
|
import { formatDbQuery } from "../lib/format-db-query.js";
|
|
3
|
-
import { Cancelled, CliExit, CliInteractive, Fmt } from "@effected/cli";
|
|
3
|
+
import { Cancelled, CliExit, CliInteractive, Fmt } from "@effected/cli-kit";
|
|
4
4
|
import { ConfigLive, DataStore, VitestAgentConfigFile, resolveDataPath } from "@vitest-agent/engine";
|
|
5
5
|
import { Console, Effect, FileSystem, Layer, Option, Schema } from "effect";
|
|
6
6
|
import { Argument, Command, Flag, Prompt } from "effect/cli";
|
package/commands/doctor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProjectDataLive, ProjectDir } from "../layers/project-data.js";
|
|
2
2
|
import { formatDoctor } from "../lib/format-doctor.js";
|
|
3
|
-
import { CliExit, CliFormat } from "@effected/cli";
|
|
3
|
+
import { CliExit, CliFormat } from "@effected/cli-kit";
|
|
4
4
|
import { DataReader, resolveDataPath } from "@vitest-agent/engine";
|
|
5
5
|
import { Effect, Option } from "effect";
|
|
6
6
|
import { Command, Flag } from "effect/cli";
|
package/commands/record.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { nowIso } from "./flag-defaults.js";
|
|
2
1
|
import { ProjectDataLive } from "../layers/project-data.js";
|
|
3
|
-
import {
|
|
2
|
+
import { nowIso } from "./flag-defaults.js";
|
|
3
|
+
import { CliExit, Fmt } from "@effected/cli-kit";
|
|
4
4
|
import { DataReader, DataStore, dispatchRecordTddArtifactEffect, recordRunWorkspaceChangesEffect, recordSessionEnd, recordSessionStart, recordTurnEffect } from "@vitest-agent/engine";
|
|
5
5
|
import { Effect, Option } from "effect";
|
|
6
6
|
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)"));
|
package/commands/triage.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProjectDataLive } from "../layers/project-data.js";
|
|
2
|
-
import { CliFormat } from "@effected/cli";
|
|
2
|
+
import { CliFormat } from "@effected/cli-kit";
|
|
3
3
|
import { formatTriageEffect } from "@vitest-agent/engine";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
5
|
import { Command, Flag } from "effect/cli";
|
package/commands/wrapup.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProjectDataLive } from "../layers/project-data.js";
|
|
2
|
-
import { CliFormat } from "@effected/cli";
|
|
2
|
+
import { CliFormat } from "@effected/cli-kit";
|
|
3
3
|
import { formatWrapupEffect } from "@vitest-agent/engine";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
5
|
import { Command, Flag } from "effect/cli";
|
|
@@ -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/lib/format-db-query.js
CHANGED
package/lib/render-failure.js
CHANGED
package/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Distribution } from "@effected/
|
|
1
|
+
import { Distribution } from "@effected/kit";
|
|
2
2
|
/**
|
|
3
3
|
* Options the carrier's bin shim passes to {@link main}.
|
|
4
4
|
*
|
|
@@ -17,7 +17,7 @@ export interface MainOptions {
|
|
|
17
17
|
* re-exported from `index.ts` — a library consumer's import graph must not
|
|
18
18
|
* pull in the process-owning module.
|
|
19
19
|
*
|
|
20
|
-
* The one `@effected/cli` wiring: the root carries `CliAudience.flags()`
|
|
20
|
+
* The one `@effected/cli-kit` wiring: the root carries `CliAudience.flags()`
|
|
21
21
|
* (`--audience <human|agent|ci>`, `--human`, `--agent`, `--ci`), runs through
|
|
22
22
|
* `CliAudience.run`, and `CliRuntime.main`'s `env` option builds the
|
|
23
23
|
* `@effected/env` services (`Audience` with the `VITEST_AGENT_AUDIENCE`
|
|
@@ -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
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { CURRENT_CLI_VERSION } from "./version.js";
|
|
2
|
-
import { ProjectDir } from "./layers/project-data.js";
|
|
3
1
|
import { agentCommand } from "./commands/agent.js";
|
|
4
2
|
import { dbCommand } from "./commands/db.js";
|
|
5
3
|
import { doctorCommand } from "./commands/doctor.js";
|
|
4
|
+
import { ProjectDir } from "./layers/project-data.js";
|
|
6
5
|
import { renderFailure } from "./lib/render-failure.js";
|
|
7
6
|
import { plainVersionFormatter } from "./lib/version-formatter.js";
|
|
7
|
+
import { CURRENT_CLI_VERSION } from "./version.js";
|
|
8
8
|
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
|
9
9
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
10
|
-
import { CliAudience, CliRuntime } from "@effected/cli";
|
|
10
|
+
import { CliAudience, CliRuntime } from "@effected/cli-kit";
|
|
11
11
|
import { PathResolutionLive, resolveProjectDir } from "@vitest-agent/engine";
|
|
12
12
|
import { Layer } from "effect";
|
|
13
13
|
import { Command } from "effect/cli";
|
|
@@ -16,7 +16,7 @@ import { Command } from "effect/cli";
|
|
|
16
16
|
/**
|
|
17
17
|
* Assembled CLI program. Owns the process: resolves the project directory, wires the
|
|
18
18
|
* root platform (no database), and runs the root command through
|
|
19
|
-
* `@effected/cli`'s `CliRuntime.main` under `NodeRuntime.runMain`.
|
|
19
|
+
* `@effected/cli-kit`'s `CliRuntime.main` under `NodeRuntime.runMain`.
|
|
20
20
|
*
|
|
21
21
|
* `bin.ts` is the published bin shim (`#!/usr/bin/env node` +
|
|
22
22
|
* `main()`); this module is also published as the `./main` subpath so the
|
|
@@ -44,7 +44,7 @@ const rootCommand = Command.make("vitest-agent").pipe(Command.withSharedFlags(Cl
|
|
|
44
44
|
* re-exported from `index.ts` — a library consumer's import graph must not
|
|
45
45
|
* pull in the process-owning module.
|
|
46
46
|
*
|
|
47
|
-
* The one `@effected/cli` wiring: the root carries `CliAudience.flags()`
|
|
47
|
+
* The one `@effected/cli-kit` wiring: the root carries `CliAudience.flags()`
|
|
48
48
|
* (`--audience <human|agent|ci>`, `--human`, `--agent`, `--ci`), runs through
|
|
49
49
|
* `CliAudience.run`, and `CliRuntime.main`'s `env` option builds the
|
|
50
50
|
* `@effected/env` services (`Audience` with the `VITEST_AGENT_AUDIENCE`
|
|
@@ -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.8",
|
|
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": [
|
|
@@ -43,19 +43,19 @@
|
|
|
43
43
|
"vitest-agent": "bin/vitest-agent.js"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@effect/platform-node": "~4.1.
|
|
47
|
-
"@effect/sql-sqlite-node": "~4.1.
|
|
48
|
-
"@effected/cli": "^0.
|
|
49
|
-
"@effected/config-file": "^0.
|
|
50
|
-
"@effected/
|
|
51
|
-
"@effected/
|
|
52
|
-
"@effected/
|
|
53
|
-
"@effected/walker": "^0.
|
|
54
|
-
"@effected/workspaces": "^0.
|
|
55
|
-
"@vitest-agent/engine": "3.1.
|
|
56
|
-
"@vitest-agent/sdk": "9.0.
|
|
57
|
-
"@vitest-agent/sidecar": "2.2.
|
|
58
|
-
"effect": "~4.1.
|
|
46
|
+
"@effect/platform-node": "~4.1.2",
|
|
47
|
+
"@effect/sql-sqlite-node": "~4.1.2",
|
|
48
|
+
"@effected/cli-kit": "^0.27.0",
|
|
49
|
+
"@effected/config-file": "^0.25.0",
|
|
50
|
+
"@effected/env": "^0.11.0",
|
|
51
|
+
"@effected/glob": "^0.19.0",
|
|
52
|
+
"@effected/kit": "^0.13.0",
|
|
53
|
+
"@effected/walker": "^0.25.1",
|
|
54
|
+
"@effected/workspaces": "^0.43.0",
|
|
55
|
+
"@vitest-agent/engine": "3.1.2",
|
|
56
|
+
"@vitest-agent/sdk": "9.0.3",
|
|
57
|
+
"@vitest-agent/sidecar": "2.2.18",
|
|
58
|
+
"effect": "~4.1.2"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=24.11.0"
|
package/tsdoc-metadata.json
CHANGED