@vitest-agent/cli 4.1.5 → 4.1.7

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
@@ -3,7 +3,8 @@ import { recordCommand } from "./record.js";
3
3
  import { triageCommand } from "./triage.js";
4
4
  import { wrapupCommand } from "./wrapup.js";
5
5
  import * as NodeServices from "@effect/platform-node/NodeServices";
6
- import { SidecarPlatformLive, endAgentEffect, registerAgentEffect, resolveHookPaths, resolveProjectKeyFromCwd } from "@vitest-agent/engine";
6
+ import { CliExit } from "@effected/cli-kit";
7
+ import { SidecarPlatformLive, endAgentEffect, registerAgentEffect, resolveHookPaths, resolveProjectKeyFromCwdEffect } from "@vitest-agent/engine";
7
8
  import { Cause, Effect, Option } from "effect";
8
9
  import { Argument, Command, Flag } from "effect/cli";
9
10
  import { existsSync, readFileSync } from "node:fs";
@@ -18,11 +19,17 @@ import { resolveSidecarBinaryPath } from "@vitest-agent/sidecar";
18
19
  const writeStdout = (line) => Effect.sync(() => {
19
20
  process.stdout.write(`${line}\n`);
20
21
  });
21
- const writeStderrAndExit = (exitCode, tag, message) => Effect.sync(() => {
22
+ /**
23
+ * Writes the sidecar family's `<exit_code> <error_tag>: <message>` line on
24
+ * stderr and records the code through `CliExit` (highest code wins;
25
+ * `CliRuntime.main` exits with it). It SUCCEEDS on purpose: a failure would
26
+ * carry its own exit code, which beats the `CliExit` cell. The caller must
27
+ * return after it so nothing else reaches stdout.
28
+ */
29
+ const writeStderrAndSetExit = (exitCode, tag, message) => Effect.sync(() => {
22
30
  process.stderr.write(`${exitCode} ${tag}: ${message}\n`);
23
- process.exit(exitCode);
24
- });
25
- const mapDefectToExit = (cause) => {
31
+ }).pipe(Effect.andThen(CliExit.set(exitCode)));
32
+ const reportCause = (cause) => {
26
33
  const failures = cause.reasons.filter(Cause.isFailReason);
27
34
  if (failures.length > 0) {
28
35
  const error = failures[0].error;
@@ -30,12 +37,18 @@ const mapDefectToExit = (cause) => {
30
37
  const tag = tagged._tag ?? "UnknownError";
31
38
  const message = tagged.reason ?? tagged.message ?? String(error);
32
39
  const exitCode = exitCodeForTag(tag);
33
- return writeStderrAndExit(exitCode, tag, message);
40
+ return writeStderrAndSetExit(exitCode, tag, message);
34
41
  }
35
42
  const defect = cause.reasons.filter(Cause.isDieReason)[0]?.defect;
36
43
  const message = defect instanceof Error ? defect.message : String(defect ?? "unknown defect");
37
- return writeStderrAndExit(5, "Defect", message);
44
+ return writeStderrAndSetExit(5, "Defect", message);
38
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()))));
39
52
  const hostKindOpt = Flag.String("host-kind").pipe(Flag.withDescription("Host vendor identifier; e.g. 'claude-code', 'cursor', 'goose'"));
40
53
  const agentTypeOpt = Flag.String("agent-type").pipe(Flag.withDescription("Agent type, must begin with the host-kind prefix"));
41
54
  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)"));
@@ -54,13 +67,14 @@ const registerAgentSubcommand = Command.make("register-agent", {
54
67
  clientNonce: clientNonceOpt,
55
68
  projectKeyOverride: projectKeyOverrideOpt
56
69
  }, (opts) => Effect.gen(function* () {
57
- const projectKey = Option.isSome(opts.projectKeyOverride) ? opts.projectKeyOverride.value : resolveProjectKeyFromCwd(opts.cwd);
58
- const paths = yield* resolveHookPaths({
70
+ const projectKey = Option.isSome(opts.projectKeyOverride) ? opts.projectKeyOverride.value : yield* resolveProjectKeyFromCwdEffect(opts.cwd);
71
+ const pathsOpt = yield* orReportCause(resolveHookPaths({
59
72
  env: process.env,
60
73
  projectKey
61
- }).pipe(Effect.catchCause(mapDefectToExit));
62
- const sidecar = SidecarPlatformLive(paths, process.env);
63
- const result = yield* registerAgentEffect({
74
+ }));
75
+ if (Option.isNone(pathsOpt)) return;
76
+ const sidecar = SidecarPlatformLive(pathsOpt.value, process.env);
77
+ const program = registerAgentEffect({
64
78
  hostSessionId: opts.hostSessionId,
65
79
  transcriptPath: opts.transcriptPath,
66
80
  cwd: opts.cwd,
@@ -69,7 +83,10 @@ const registerAgentSubcommand = Command.make("register-agent", {
69
83
  projectKey,
70
84
  ...Option.isSome(opts.parentAgentId) && { parentAgentId: opts.parentAgentId.value },
71
85
  ...Option.isSome(opts.clientNonce) && { clientNonce: opts.clientNonce.value }
72
- }).pipe(Effect.provide(sidecar, { local: true }), Effect.catchCause(mapDefectToExit));
86
+ });
87
+ const resultOpt = yield* orReportCause(program.pipe(Effect.provide(sidecar, { local: true })));
88
+ if (Option.isNone(resultOpt)) return;
89
+ const result = resultOpt.value;
73
90
  yield* writeStdout(JSON.stringify({
74
91
  agentId: result.agentId,
75
92
  conversationId: result.conversationId,
@@ -90,18 +107,19 @@ const endAgentSubcommand = Command.make("end-agent", {
90
107
  cwd: endCwdOpt,
91
108
  projectKeyOverride: endProjectKeyOverrideOpt
92
109
  }, (opts) => Effect.gen(function* () {
93
- const projectKey = Option.isSome(opts.projectKeyOverride) ? opts.projectKeyOverride.value : resolveProjectKeyFromCwd(opts.cwd);
94
- const paths = yield* resolveHookPaths({
110
+ const projectKey = Option.isSome(opts.projectKeyOverride) ? opts.projectKeyOverride.value : yield* resolveProjectKeyFromCwdEffect(opts.cwd);
111
+ const pathsOpt = yield* orReportCause(resolveHookPaths({
95
112
  env: process.env,
96
113
  projectKey
97
- }).pipe(Effect.catchCause(mapDefectToExit));
98
- const sidecar = SidecarPlatformLive(paths, process.env);
114
+ }));
115
+ if (Option.isNone(pathsOpt)) return;
116
+ const sidecar = SidecarPlatformLive(pathsOpt.value, process.env);
99
117
  const endedAt = Option.isSome(opts.endedAt) ? opts.endedAt.value : Math.floor(Date.now() / 1e3);
100
- yield* endAgentEffect({
118
+ yield* orReportCause(endAgentEffect({
101
119
  agentId: opts.agentId,
102
120
  endedAt,
103
121
  ...Option.isSome(opts.hostSessionId) && { hostSessionId: opts.hostSessionId.value }
104
- }).pipe(Effect.provide(sidecar, { local: true }), Effect.catchCause(mapDefectToExit));
122
+ }).pipe(Effect.provide(sidecar, { local: true })));
105
123
  }).pipe(Effect.provide(NodeServices.layer))).pipe(Command.withDescription("Mark an agent (and optionally its session) as ended"));
106
124
  const commandOpt = Flag.String("command").pipe(Flag.withDescription("The Bash command to (possibly) rewrite with VITEST_AGENT_* env-prefix"));
107
125
  const cwdInjectOpt = Flag.String("cwd").pipe(Flag.withDefault(currentCwd), Flag.withDescription("Working directory; used to find package.json scripts"));
@@ -117,10 +135,10 @@ const injectEnvSubcommand = Command.make("inject-env", {
117
135
  });
118
136
  process.stdout.write(`${out}\n`);
119
137
  })).pipe(Command.withDescription("Rewrite a Bash command to prepend VITEST_AGENT_* env vars when it invokes Vitest"));
120
- const sidecarPathSubcommand = Command.make("sidecar-path", {}, () => Effect.sync(() => {
138
+ const sidecarPathSubcommand = Command.make("sidecar-path", {}, () => Effect.gen(function* () {
121
139
  const path = resolveSidecarBinaryPath();
122
- if (path === null) process.exit(1);
123
- process.stdout.write(`${path}\n`);
140
+ if (path === null) return yield* CliExit.set(1);
141
+ yield* writeStdout(path);
124
142
  })).pipe(Command.withDescription("Print the absolute path of the platform sidecar binary resolved via require.resolve"));
125
143
  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"));
126
144
  /**
@@ -170,20 +188,29 @@ function readWorkspaceVitestConfigSource(root) {
170
188
  }
171
189
  return null;
172
190
  }
173
- const checkTestPathSubcommand = Command.make("check-test-path", { path: testPathArg }, (opts) => Effect.sync(() => {
174
- const from = process.env.VITEST_AGENT_PROJECT_DIR ?? process.cwd();
175
- const absolute = isAbsolute(opts.path) ? opts.path : resolve(from, opts.path);
191
+ /**
192
+ * The `check-test-path` verdict, or `null` when no verdict can be rendered and
193
+ * the caller must fail open.
194
+ *
195
+ * @internal
196
+ */
197
+ function checkTestPath(path, from) {
198
+ const absolute = isAbsolute(path) ? path : resolve(from, path);
176
199
  const root = findWorkspaceRootSync(from, nodeSyncOps);
177
- if (root === null) process.exit(1);
200
+ if (root === null) return null;
178
201
  const configSource = readWorkspaceVitestConfigSource(root);
179
- if (configSource === null || detectNonDefaultDiscoverStrategy(configSource)) process.exit(1);
202
+ if (configSource === null || detectNonDefaultDiscoverStrategy(configSource)) return null;
180
203
  const packages = getWorkspacePackagesSync(root, nodeSyncOps);
181
204
  const owner = findOwningWorkspace(packages, absolute);
182
- if (owner === null) process.exit(1);
183
- if (crossesNestedPackageBoundary(owner.path, absolute)) process.exit(1);
184
- const classification = classifyTestPath(packages, absolute);
185
- if (classification === null) process.exit(1);
186
- process.stdout.write(`${JSON.stringify(classification)}\n`);
205
+ if (owner === null) return null;
206
+ if (crossesNestedPackageBoundary(owner.path, absolute)) return null;
207
+ return classifyTestPath(packages, absolute);
208
+ }
209
+ const checkTestPathSubcommand = Command.make("check-test-path", { path: testPathArg }, (opts) => Effect.gen(function* () {
210
+ const from = process.env.VITEST_AGENT_PROJECT_DIR ?? process.cwd();
211
+ const classification = yield* Effect.sync(() => checkTestPath(opts.path, from));
212
+ if (classification === null) return yield* CliExit.set(1);
213
+ yield* writeStdout(JSON.stringify(classification));
187
214
  })).pipe(Command.withDescription("Classify a test file path as valid, excluded, or invalid for Vitest discovery"));
188
215
  const agentParent = Command.make("agent").pipe(Command.withDescription("Commands intended for agents and hook scripts — humans typically don't invoke these directly."));
189
216
  const agentCommand = agentParent.pipe(Command.withSubcommands([
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";
@@ -100,9 +100,8 @@ const queryCommand = Command.make("query", {
100
100
  if (sql.trim().length === 0) {
101
101
  yield* Effect.sync(() => {
102
102
  process.stderr.write("db query: missing sql\n");
103
- process.exit(2);
104
103
  });
105
- return;
104
+ return yield* CliExit.set(2);
106
105
  }
107
106
  const { dir } = yield* ProjectDir;
108
107
  const dbPath = yield* resolveDataPath(dir);
@@ -116,8 +115,7 @@ const queryCommand = Command.make("query", {
116
115
  readonly: true
117
116
  })), Effect.catch((error) => Effect.sync(() => {
118
117
  process.stderr.write(`db query: ${Fmt.errorText(error)}\n`);
119
- process.exit(3);
120
- })));
118
+ }).pipe(Effect.andThen(CliExit.set(3)))));
121
119
  })).pipe(Command.withDescription("Run a read-only SQL query against the database"));
122
120
  const dbParent = Command.make("db").pipe(Command.withDescription("Manage the vitest-agent database"));
123
121
  const dbCommand = dbParent.pipe(Command.withSubcommands([
@@ -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 { 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";
@@ -27,8 +27,7 @@ const doctorCommand = Command.make("doctor", { format: formatOption }, ({ format
27
27
  detail: "no test run data found in database"
28
28
  });
29
29
  yield* writeOutput(results, format);
30
- yield* Effect.sync(() => process.exit(1));
31
- return;
30
+ return yield* CliExit.set(1);
32
31
  }
33
32
  const manifest = manifestOpt.value;
34
33
  results.push({
@@ -102,7 +101,7 @@ const doctorCommand = Command.make("doctor", { format: formatOption }, ({ format
102
101
  });
103
102
  }
104
103
  yield* writeOutput(results, format);
105
- if (results.some((r) => !r.passed)) yield* Effect.sync(() => process.exit(1));
104
+ if (results.some((r) => !r.passed)) yield* CliExit.set(1);
106
105
  })).pipe(Command.provide(ProjectDataLive));
107
106
 
108
107
  export { doctorCommand };
@@ -1,11 +1,19 @@
1
- import { nowIso } from "./flag-defaults.js";
2
1
  import { ProjectDataLive } from "../layers/project-data.js";
3
- import { Fmt } from "@effected/cli";
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
+ /**
10
+ * Writes `record <name>: <error>` on stderr and records exit code 1 through
11
+ * `CliExit`. It succeeds on purpose (a failure's own exit code would beat the
12
+ * cell); it runs in place of the stdout write, so stdout stays empty.
13
+ */
14
+ const reportFailure = (name) => (err) => Effect.sync(() => {
15
+ process.stderr.write(`record ${name}: ${Fmt.describe(err)}\n`);
16
+ }).pipe(Effect.andThen(CliExit.set(1)));
9
17
  const chatId = Flag.String("chat-id").pipe(Flag.withDescription("Host chat id (`session_id` in the Claude Code hook envelope; equivalent in other clients)"));
10
18
  const occurredAt = Flag.String("occurred-at").pipe(Flag.withDefault(nowIso), Flag.withDescription("ISO 8601 timestamp; defaults to now"));
11
19
  const payloadArg = Argument.String("payload-json").pipe(Argument.withDescription("Stringified JSON payload (validated against TurnPayload)"));
@@ -25,10 +33,7 @@ const turnSubcommand = Command.make("turn", {
25
33
  occurredAt,
26
34
  ...project._tag === "Some" && { project: project.value },
27
35
  cwd: cwd._tag === "Some" ? cwd.value : process.cwd()
28
- }).pipe(Effect.flatMap((result) => Effect.sync(() => process.stdout.write(`${JSON.stringify(result)}\n`))), Effect.catch((err) => Effect.sync(() => {
29
- process.stderr.write(`record turn: ${Fmt.describe(err)}\n`);
30
- process.exit(1);
31
- })))).pipe(Command.withDescription("Validate a TurnPayload JSON and write a turn row"));
36
+ }).pipe(Effect.flatMap((result) => Effect.sync(() => process.stdout.write(`${JSON.stringify(result)}\n`))), Effect.catch(reportFailure("turn")))).pipe(Command.withDescription("Validate a TurnPayload JSON and write a turn row"));
32
37
  const agentKind = Flag.Literals("agent-kind", ["main", "subagent"]).pipe(Flag.withDefault("main"));
33
38
  const agentType = Flag.optional(Flag.String("agent-type"));
34
39
  const parentChatId = Flag.optional(Flag.String("parent-chat-id"));
@@ -52,10 +57,7 @@ const sessionStartSubcommand = Command.make("session-start", {
52
57
  ...opts.parentChatId._tag === "Some" && { parentChatId: opts.parentChatId.value },
53
58
  triageWasNonEmpty: opts.triageWasNonEmpty,
54
59
  startedAt: opts.startedAt
55
- }).pipe(Effect.flatMap((result) => Effect.sync(() => process.stdout.write(`${JSON.stringify(result)}\n`))), Effect.catch((err) => Effect.sync(() => {
56
- process.stderr.write(`record session-start: ${Fmt.describe(err)}\n`);
57
- process.exit(1);
58
- })))).pipe(Command.withDescription("Insert a new sessions row"));
60
+ }).pipe(Effect.flatMap((result) => Effect.sync(() => process.stdout.write(`${JSON.stringify(result)}\n`))), Effect.catch(reportFailure("session-start")))).pipe(Command.withDescription("Insert a new sessions row"));
59
61
  const endedAt = Flag.String("ended-at").pipe(Flag.withDefault(nowIso));
60
62
  const endReason = Flag.optional(Flag.String("end-reason"));
61
63
  const sessionEndSubcommand = Command.make("session-end", {
@@ -66,10 +68,7 @@ const sessionEndSubcommand = Command.make("session-end", {
66
68
  chatId: opts.chatId,
67
69
  endedAt: opts.endedAt,
68
70
  endReason: opts.endReason._tag === "Some" ? opts.endReason.value : null
69
- }).pipe(Effect.flatMap(() => Effect.sync(() => process.stdout.write(`{"ok":true}\n`))), Effect.catch((err) => Effect.sync(() => {
70
- process.stderr.write(`record session-end: ${Fmt.describe(err)}\n`);
71
- process.exit(1);
72
- })))).pipe(Command.withDescription("Update sessions.ended_at + end_reason"));
71
+ }).pipe(Effect.flatMap(() => Effect.sync(() => process.stdout.write(`{"ok":true}\n`))), Effect.catch(reportFailure("session-end")))).pipe(Command.withDescription("Update sessions.ended_at + end_reason"));
73
72
  const artifactKindOpt = Flag.Literals("artifact-kind", [
74
73
  "test_written",
75
74
  "test_failed_run",
@@ -117,10 +116,7 @@ const tddArtifactSubcommand = Command.make("tdd-artifact", {
117
116
  recordedAt: opts.recordedAt,
118
117
  suite: opts.suite
119
118
  });
120
- }).pipe(Effect.flatMap((result) => Effect.sync(() => process.stdout.write(`${JSON.stringify(result)}\n`))), Effect.catch((err) => Effect.sync(() => {
121
- process.stderr.write(`record tdd-artifact: ${Fmt.describe(err)}\n`);
122
- process.exit(1);
123
- })))).pipe(Command.withDescription("Record a TDD artifact (D7: CLI-only)"));
119
+ }).pipe(Effect.flatMap((result) => Effect.sync(() => process.stdout.write(`${JSON.stringify(result)}\n`))), Effect.catch(reportFailure("tdd-artifact")))).pipe(Command.withDescription("Record a TDD artifact (D7: CLI-only)"));
124
120
  const testCaseTurnsSubcommand = Command.make("test-case-turns", { chatId }, ({ chatId }) => Effect.gen(function* () {
125
121
  const store = yield* DataStore;
126
122
  const reader = yield* DataReader;
@@ -130,10 +126,7 @@ const testCaseTurnsSubcommand = Command.make("test-case-turns", { chatId }, ({ c
130
126
  updated,
131
127
  latestTestCaseId: Option.getOrNull(latestId)
132
128
  };
133
- }).pipe(Effect.flatMap((result) => Effect.sync(() => process.stdout.write(`${JSON.stringify(result)}\n`))), Effect.catch((err) => Effect.sync(() => {
134
- process.stderr.write(`record test-case-turns: ${Fmt.describe(err)}\n`);
135
- process.exit(1);
136
- })))).pipe(Command.withDescription("Backfill test_cases.created_turn_id from file_edits in the current session (BUG-2 fix)"));
129
+ }).pipe(Effect.flatMap((result) => Effect.sync(() => process.stdout.write(`${JSON.stringify(result)}\n`))), Effect.catch(reportFailure("test-case-turns")))).pipe(Command.withDescription("Backfill test_cases.created_turn_id from file_edits in the current session (BUG-2 fix)"));
137
130
  const invocationMethodOpt = Flag.Literals("invocation-method", [
138
131
  "bash",
139
132
  "mcp",
@@ -147,10 +140,7 @@ const runTriggerSubcommand = Command.make("run-trigger", {
147
140
  chatId,
148
141
  invocationMethod
149
142
  });
150
- }).pipe(Effect.catch((err) => Effect.sync(() => {
151
- process.stderr.write(`record run-trigger: ${Fmt.describe(err)}\n`);
152
- process.exit(1);
153
- })))).pipe(Command.withDescription("Associate the latest test run with the current Claude Code session"));
143
+ }).pipe(Effect.catch(reportFailure("run-trigger")))).pipe(Command.withDescription("Associate the latest test run with the current Claude Code session"));
154
144
  const shaOpt = Flag.String("sha");
155
145
  const parentShaOpt = Flag.optional(Flag.String("parent-sha"));
156
146
  const messageOpt = Flag.optional(Flag.String("message"));
@@ -183,10 +173,7 @@ const runWorkspaceChangesSubcommand = Command.make("run-workspace-changes", {
183
173
  ...opts.project._tag === "Some" && { project: opts.project.value },
184
174
  files: parsed
185
175
  });
186
- }).pipe(Effect.flatMap((result) => Effect.sync(() => process.stdout.write(`${JSON.stringify(result)}\n`))), Effect.catch((err) => Effect.sync(() => {
187
- process.stderr.write(`record run-workspace-changes: ${Fmt.describe(err)}\n`);
188
- process.exit(1);
189
- })))).pipe(Command.withDescription("Record a commit + its changed files (driven by post-commit hook)"));
176
+ }).pipe(Effect.flatMap((result) => Effect.sync(() => process.stdout.write(`${JSON.stringify(result)}\n`))), Effect.catch(reportFailure("run-workspace-changes")))).pipe(Command.withDescription("Record a commit + its changed files (driven by post-commit hook)"));
190
177
  const recordCommand = Command.make("record").pipe(Command.withSubcommands([
191
178
  turnSubcommand,
192
179
  sessionStartSubcommand,
@@ -1,4 +1,5 @@
1
1
  import { ProjectDataLive } from "../layers/project-data.js";
2
+ import { CliFormat } from "@effected/cli-kit";
2
3
  import { formatTriageEffect } from "@vitest-agent/engine";
3
4
  import { Effect } from "effect";
4
5
  import { Command, Flag } from "effect/cli";
@@ -22,7 +23,7 @@ const triageCommand = Command.make("triage", {
22
23
  });
23
24
  if (opts.format === "silent") return;
24
25
  if (opts.format === "json") {
25
- yield* Effect.sync(() => process.stdout.write(`${JSON.stringify({ triage: md })}\n`));
26
+ yield* CliFormat.printJson({ triage: md }, { indent: 0 });
26
27
  return;
27
28
  }
28
29
  yield* Effect.sync(() => process.stdout.write(md.length > 0 ? `${md}\n` : ""));
@@ -1,4 +1,5 @@
1
1
  import { ProjectDataLive } from "../layers/project-data.js";
2
+ import { CliFormat } from "@effected/cli-kit";
2
3
  import { formatWrapupEffect } from "@vitest-agent/engine";
3
4
  import { Effect } from "effect";
4
5
  import { Command, Flag } from "effect/cli";
@@ -29,7 +30,7 @@ const wrapupCommand = Command.make("wrapup", {
29
30
  ...opts.userPromptHint._tag === "Some" && { userPromptHint: opts.userPromptHint.value }
30
31
  });
31
32
  if (opts.format === "json") {
32
- yield* Effect.sync(() => process.stdout.write(`${JSON.stringify({ wrapup: md })}\n`));
33
+ yield* CliFormat.printJson({ wrapup: md }, { indent: 0 });
33
34
  return;
34
35
  }
35
36
  yield* Effect.sync(() => process.stdout.write(md.length > 0 ? `${md}\n` : ""));
@@ -1,4 +1,4 @@
1
- import { Fmt } from "@effected/cli";
1
+ import { Fmt } from "@effected/cli-kit";
2
2
 
3
3
  // src/lib/format-db-query.ts
4
4
  const renderCell = (value) => {
@@ -1,4 +1,4 @@
1
- import { Fmt } from "@effected/cli";
1
+ import { Fmt } from "@effected/cli-kit";
2
2
  import { Schema } from "effect";
3
3
 
4
4
  // src/lib/render-failure.ts
package/main.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Distribution } from "@effected/engine";
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`
@@ -59,8 +59,11 @@ export interface MainOptions {
59
59
  *
60
60
  * Exit codes are the kit's: `0` success (including bare `--help`), `64` a
61
61
  * usage error, `130` a cancelled prompt, `1` any other reported failure.
62
- * Commands that record their own code through `CliExit` (`db reset`) or
63
- * `process.exit` with it still exit with it.
62
+ * Commands that carry their own code (`db reset` / `db query`, `doctor`, the
63
+ * `agent` sidecar family, `agent record`, `check-test-path`, `sidecar-path`)
64
+ * write their stderr line, record the code through `CliExit`, and succeed;
65
+ * `CliRuntime.main` exits with it after the log sinks drain. No command
66
+ * handler calls `process.exit`.
64
67
  *
65
68
  * @public
66
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`
@@ -86,8 +86,11 @@ const rootCommand = Command.make("vitest-agent").pipe(Command.withSharedFlags(Cl
86
86
  *
87
87
  * Exit codes are the kit's: `0` success (including bare `--help`), `64` a
88
88
  * usage error, `130` a cancelled prompt, `1` any other reported failure.
89
- * Commands that record their own code through `CliExit` (`db reset`) or
90
- * `process.exit` with it still exit with it.
89
+ * Commands that carry their own code (`db reset` / `db query`, `doctor`, the
90
+ * `agent` sidecar family, `agent record`, `check-test-path`, `sidecar-path`)
91
+ * write their stderr line, record the code through `CliExit`, and succeed;
92
+ * `CliRuntime.main` exits with it after the log sinks drain. No command
93
+ * handler calls `process.exit`.
91
94
  *
92
95
  * @public
93
96
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitest-agent/cli",
3
- "version": "4.1.5",
3
+ "version": "4.1.7",
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.0.7",
47
- "@effect/sql-sqlite-node": "^4.0.7",
48
- "@effected/cli": "^0.24.0",
49
- "@effected/config-file": "^0.22.0",
50
- "@effected/engine": "^0.10.0",
51
- "@effected/env": "^0.7.0",
52
- "@effected/glob": "^0.16.0",
53
- "@effected/walker": "^0.22.0",
54
- "@effected/workspaces": "^0.40.0",
55
- "@vitest-agent/engine": "3.0.1",
56
- "@vitest-agent/sdk": "9.0.1",
57
- "@vitest-agent/sidecar": "2.2.16",
58
- "effect": "^4.0.7"
46
+ "@effect/platform-node": "~4.1.2",
47
+ "@effect/sql-sqlite-node": "~4.1.2",
48
+ "@effected/cli-kit": "^0.26.0",
49
+ "@effected/config-file": "^0.24.0",
50
+ "@effected/env": "^0.10.0",
51
+ "@effected/glob": "^0.18.0",
52
+ "@effected/kit": "^0.12.0",
53
+ "@effected/walker": "^0.25.0",
54
+ "@effected/workspaces": "^0.42.0",
55
+ "@vitest-agent/engine": "3.1.1",
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"
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.60.0"
8
+ "packageVersion": "7.60.1"
9
9
  }
10
10
  ]
11
11
  }
package/version.js CHANGED
@@ -7,6 +7,6 @@
7
7
  *
8
8
  * @public
9
9
  */
10
- const CURRENT_CLI_VERSION = "4.1.5";
10
+ const CURRENT_CLI_VERSION = "4.1.7";
11
11
 
12
12
  export { CURRENT_CLI_VERSION };