@vitest-agent/cli 4.0.13 → 4.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/db.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { ProjectDataLive, ProjectDir } from "../layers/project-data.js";
2
2
  import { formatDbQuery } from "../lib/format-db-query.js";
3
3
  import { Cancelled, CliExit, CliInteractive } from "@effected/cli";
4
- import { DataStore, resolveDataPath } from "@vitest-agent/engine";
5
- import { Console, Effect, FileSystem } from "effect";
4
+ import { ConfigLive, DataStore, VitestAgentConfigFile, resolveDataPath } from "@vitest-agent/engine";
5
+ import { Console, Effect, FileSystem, Layer, Option, Schema } from "effect";
6
6
  import { Argument, Command, Flag, Prompt } from "effect/cli";
7
+ import { RunRetentionPolicy, VitestAgentConfig } from "@vitest-agent/sdk";
7
8
  import { layer } from "@effect/sql-sqlite-node/SqliteClient";
8
9
  import { SqlClient } from "effect/sql/SqlClient";
9
10
 
@@ -14,10 +15,54 @@ const pathCommand = Command.make("path", {}, () => Effect.gen(function* () {
14
15
  yield* Effect.sync(() => process.stdout.write(`${dbPath}\n`));
15
16
  })).pipe(Command.withDescription("Print the resolved database path"));
16
17
  const keepRecentOption = Flag.withDefault(Flag.Int("keep-recent"), 30).pipe(Flag.withDescription("Number of most-recent sessions to keep in full"));
17
- const pruneCommand = Command.make("prune", { keepRecent: keepRecentOption }, ({ keepRecent }) => Effect.gen(function* () {
18
- const result = yield* (yield* DataStore).pruneSessions(keepRecent);
19
- yield* Effect.sync(() => process.stdout.write(`Pruned ${result.prunedTurns} turn row(s) across ${result.affectedSessions} session(s); session rows retained.\n`));
20
- })).pipe(Command.withDescription("Drop old sessions' turn history (W1 retention; keeps the last N in full)"), Command.provide(ProjectDataLive));
18
+ /** A whole number of runs or days, at least one — the same bound the `[retention]` table enforces. */
19
+ const PositiveInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
20
+ const keepRunsOption = Flag.Int("keep-runs").pipe(Flag.withSchema(PositiveInt), Flag.optional, Flag.withDescription(`Newest runs to keep per project (overrides [retention] keepRuns; default ${RunRetentionPolicy.DEFAULT_KEEP_RUNS})`));
21
+ const maxAgeDaysOption = Flag.Int("max-age-days").pipe(Flag.withSchema(PositiveInt), Flag.optional, Flag.withDescription("Also drop runs older than this many days (overrides [retention] maxAgeDays)"));
22
+ /**
23
+ * The `vitest-agent.config.toml` loader over the resolved project directory,
24
+ * for the run-retention policy `db prune` applies when no flag overrides it.
25
+ */
26
+ const ProjectConfigLive = Layer.unwrap(Effect.gen(function* () {
27
+ const { dir } = yield* ProjectDir;
28
+ return ConfigLive(dir);
29
+ }));
30
+ /**
31
+ * The run-retention policy a manual prune applies: the config's policy
32
+ * (default when the table is absent; none when `enabled = false`), with
33
+ * either flag overriding its field. A flag re-enables a disabled policy —
34
+ * the person asked for a prune by name.
35
+ */
36
+ const resolveRunRetention = (configured, keepRuns, maxAgeDays) => {
37
+ if (Option.isNone(keepRuns) && Option.isNone(maxAgeDays)) return configured;
38
+ const base = Option.getOrElse(configured, () => RunRetentionPolicy.make({ keepRuns: RunRetentionPolicy.DEFAULT_KEEP_RUNS }));
39
+ const age = Option.isSome(maxAgeDays) ? maxAgeDays.value : base.maxAgeDays;
40
+ return Option.some(RunRetentionPolicy.make({
41
+ keepRuns: Option.getOrElse(keepRuns, () => base.keepRuns),
42
+ ...age !== void 0 && { maxAgeDays: age }
43
+ }));
44
+ };
45
+ const pruneCommand = Command.make("prune", {
46
+ keepRecent: keepRecentOption,
47
+ keepRuns: keepRunsOption,
48
+ maxAgeDays: maxAgeDaysOption
49
+ }, ({ keepRecent, keepRuns, maxAgeDays }) => Effect.gen(function* () {
50
+ const store = yield* DataStore;
51
+ const sql = yield* SqlClient;
52
+ const configFile = yield* VitestAgentConfigFile;
53
+ const sessions = yield* store.pruneSessions(keepRecent);
54
+ yield* Effect.sync(() => process.stdout.write(`Pruned ${sessions.prunedTurns} turn row(s) across ${sessions.affectedSessions} session(s); session rows retained.\n`));
55
+ const config = yield* configFile.loadOrDefault(new VitestAgentConfig({}));
56
+ const policy = resolveRunRetention(RunRetentionPolicy.fromConfig(config), keepRuns, maxAgeDays);
57
+ if (Option.isNone(policy)) {
58
+ yield* Effect.sync(() => process.stdout.write("Run retention is disabled ([retention] enabled = false); no runs pruned.\n"));
59
+ return;
60
+ }
61
+ const runs = yield* store.pruneRuns(policy.value);
62
+ yield* sql`PRAGMA wal_checkpoint(TRUNCATE)`;
63
+ const age = policy.value.maxAgeDays === void 0 ? "" : `, none older than ${policy.value.maxAgeDays} day(s)`;
64
+ yield* Effect.sync(() => process.stdout.write(`Pruned ${runs.prunedRuns} run(s) and ${runs.prunedFiles} orphaned file row(s); kept the newest ${policy.value.keepRuns} run(s) per project${age}.\n`));
65
+ })).pipe(Command.withDescription("Drop old sessions' turn history (keeps the last N in full) and apply the run-retention policy to test runs"), Command.provide(Layer.mergeAll(ProjectDataLive, ProjectConfigLive)));
21
66
  const yesOption = Flag.Boolean("yes").pipe(Flag.withDefault(false), Flag.withDescription("Skip the interactive confirmation prompt"));
22
67
  const resetCommand = Command.make("reset", { yes: yesOption }, ({ yes }) => Effect.gen(function* () {
23
68
  const agentId = process.env.VITEST_AGENT_AGENT_ID;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitest-agent/cli",
3
- "version": "4.0.13",
3
+ "version": "4.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": [
@@ -52,9 +52,9 @@
52
52
  "@effected/glob": "^0.14.0",
53
53
  "@effected/walker": "^0.19.0",
54
54
  "@effected/workspaces": "^0.38.0",
55
- "@vitest-agent/engine": "1.1.2",
56
- "@vitest-agent/sdk": "7.0.5",
57
- "@vitest-agent/sidecar": "2.2.12",
55
+ "@vitest-agent/engine": "2.0.0",
56
+ "@vitest-agent/sdk": "8.0.0",
57
+ "@vitest-agent/sidecar": "2.2.14",
58
58
  "effect": "^4.0.6"
59
59
  },
60
60
  "engines": {
package/version.js CHANGED
@@ -7,6 +7,6 @@
7
7
  *
8
8
  * @public
9
9
  */
10
- const CURRENT_CLI_VERSION = "4.0.13";
10
+ const CURRENT_CLI_VERSION = "4.1.1";
11
11
 
12
12
  export { CURRENT_CLI_VERSION };