@vitest-agent/engine 3.1.0 → 3.1.2
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/index.d.ts +6 -6
- package/index.js +18 -18
- package/layers/EnvironmentDetectorLive.js +1 -1
- package/layers/LoggerLive.js +2 -2
- package/layers/ProjectDiscoveryLive.js +1 -1
- package/layers/ProjectIdentityLive.js +1 -1
- package/package.json +21 -21
- package/platform.js +3 -6
- package/programs/hook-paths.js +2 -2
- package/programs/platform-sidecar.js +1 -1
- package/programs/register-agent.js +1 -1
- package/project-dir.js +2 -2
- package/stores.js +20 -6
- package/testing.js +2 -2
- package/tsdoc-metadata.json +1 -1
- package/utils/ensure-migrated.js +2 -3
- package/utils/format-fatal-error.js +2 -2
- package/utils/resolve-project-key-from-cwd.js +2 -3
- package/version.js +1 -1
package/index.d.ts
CHANGED
|
@@ -1269,7 +1269,7 @@ export declare class EnvironmentDetector extends EnvironmentDetector_base {}
|
|
|
1269
1269
|
*
|
|
1270
1270
|
* @remarks
|
|
1271
1271
|
* The agent/CI/human split is `@effected/env`'s `Audience.detect`, so the
|
|
1272
|
-
* engine and every `@effected/cli` front end agree on who is running; this
|
|
1272
|
+
* engine and every `@effected/cli-kit` front end agree on who is running; this
|
|
1273
1273
|
* only refines CI into GitHub Actions versus any other CI.
|
|
1274
1274
|
*
|
|
1275
1275
|
* @param runtime - the `@effected/env` runtime snapshot to classify
|
|
@@ -1361,7 +1361,7 @@ export declare const HistoryTrackerTest: {
|
|
|
1361
1361
|
};
|
|
1362
1362
|
/**
|
|
1363
1363
|
* Create a structured JSON (NDJSON) logger layer for stderr, over
|
|
1364
|
-
* `@effected/cli`'s `CliLog` in its diagnostics-only mode
|
|
1364
|
+
* `@effected/cli-kit`'s `CliLog` in its diagnostics-only mode
|
|
1365
1365
|
* (`format: "json"`, `plainLogger: false`): the already-resolved level is
|
|
1366
1366
|
* passed as `level`, and no plain `CliLogger` is installed beside the sink, so
|
|
1367
1367
|
* each record prints once and nothing reads the audience or the terminal.
|
|
@@ -1905,7 +1905,7 @@ export interface PlatformOptions {
|
|
|
1905
1905
|
/**
|
|
1906
1906
|
* Whether `PlatformLive` installs its own logger set (`LoggerLive`, from
|
|
1907
1907
|
* `logLevel` / `logFile`). Defaults to `true`. Pass `false` when the caller
|
|
1908
|
-
* already owns the logger set (for example `@effected/cli`'s `CliLog`
|
|
1908
|
+
* already owns the logger set (for example `@effected/cli-kit`'s `CliLog`
|
|
1909
1909
|
* installed by `CliRuntime.main`'s `env.log`): `LoggerLive` replaces the
|
|
1910
1910
|
* installed loggers, so leaving it in would silence the caller's set.
|
|
1911
1911
|
* `logLevel` and `logFile` are ignored when this is `false`.
|
|
@@ -2026,7 +2026,7 @@ export type HookPathsError = XdgEnvError | AppDirsError$1 | PlatformError | Proj
|
|
|
2026
2026
|
*
|
|
2027
2027
|
* Precedence: the `CLAUDE_PLUGIN_DATA` env var, then
|
|
2028
2028
|
* `VITEST_AGENT_SESSION_MAP_DIR`, then `~/.vitest-agent/` (`HOME`, then
|
|
2029
|
-
* `USERPROFILE`). The two variables are read through `@effected/
|
|
2029
|
+
* `USERPROFILE`). The two variables are read through `@effected/kit`'s
|
|
2030
2030
|
* `LaunchContext.resolve`: a value is trimmed, and a blank or unsubstituted
|
|
2031
2031
|
* `${...}` placeholder value counts as unset. The chosen directory is created. Fails with
|
|
2032
2032
|
* `ProjectIdentityNotResolvableError` when no home directory is resolvable.
|
|
@@ -2555,7 +2555,7 @@ export declare const recoverSessionContextFromSessionEnv: (opts: {
|
|
|
2555
2555
|
* Precedence: `VITEST_AGENT_PROJECT_DIR` (hook-driven override), then
|
|
2556
2556
|
* `VITEST_AGENT_REPORTER_PROJECT_DIR` (the plugin-spawned MCP server's
|
|
2557
2557
|
* hand-off), then `CLAUDE_PROJECT_DIR` (Claude Code's own convention),
|
|
2558
|
-
* then `cwd`. Delegates to `@effected/
|
|
2558
|
+
* then `cwd`. Delegates to `@effected/kit`'s `LaunchContext.projectDir`:
|
|
2559
2559
|
* a value is trimmed, and an empty or whitespace-only value, or one a plugin
|
|
2560
2560
|
* host left as a literal unsubstituted `${...}` placeholder, counts as unset.
|
|
2561
2561
|
* Pure: both the env map and the working directory are injected by the caller.
|
|
@@ -2701,7 +2701,7 @@ export declare const computeFailureSignature: (input: FailureSignatureInput) =>
|
|
|
2701
2701
|
* is (one from `Effect.runPromiseExit` keeps every reason and the span
|
|
2702
2702
|
* trail), and anything else is rendered as a defect, `Cause.die(err)`: an
|
|
2703
2703
|
* unexpected throw is a bug to report, and a defect is the shape whose
|
|
2704
|
-
* document carries the stack. `@effected/cli`'s `CliFailure.toDoc` keeps
|
|
2704
|
+
* document carries the stack. `@effected/cli-kit`'s `CliFailure.toDoc` keeps
|
|
2705
2705
|
* the program's own frames, hides `node_modules` and runtime frames,
|
|
2706
2706
|
* follows an `Error.cause` chain, and renders a non-`Error` value as its
|
|
2707
2707
|
* text.
|
package/index.js
CHANGED
|
@@ -1,34 +1,20 @@
|
|
|
1
|
-
import { VitestAgentConfigFile } from "./services/Config.js";
|
|
2
1
|
import { ConfigLive } from "./layers/ConfigLive.js";
|
|
3
|
-
import { DataReader } from "./services/DataReader.js";
|
|
4
|
-
import { HistoryTracker, historyKey } from "./services/HistoryTracker.js";
|
|
5
2
|
import { DataReaderLive } from "./layers/DataReaderLive.js";
|
|
6
|
-
import { DataStore, INLINE_ATTACHMENT_BODY_CAP_BYTES } from "./services/DataStore.js";
|
|
7
|
-
import { withPersistSavepoint, withPersistTransaction } from "./utils/persist-transaction.js";
|
|
8
3
|
import { DataStoreLive } from "./layers/DataStoreLive.js";
|
|
9
|
-
import { DetailResolver } from "./services/DetailResolver.js";
|
|
10
4
|
import { DetailResolverLive } from "./layers/DetailResolverLive.js";
|
|
11
|
-
import { DiscoveryRegistry } from "./services/DiscoveryRegistry.js";
|
|
12
5
|
import { DiscoveryRegistryLive } from "./layers/DiscoveryRegistryLive.js";
|
|
13
|
-
import { EnvironmentDetector } from "./services/EnvironmentDetector.js";
|
|
14
6
|
import { EnvironmentDetectorLive, classifyEnvironment } from "./layers/EnvironmentDetectorLive.js";
|
|
15
7
|
import { EnvironmentDetectorTest } from "./layers/EnvironmentDetectorTest.js";
|
|
16
|
-
import { ExecutorResolver } from "./services/ExecutorResolver.js";
|
|
17
8
|
import { ExecutorResolverLive } from "./layers/ExecutorResolverLive.js";
|
|
18
9
|
import { HistoryTrackerLive } from "./layers/HistoryTrackerLive.js";
|
|
19
10
|
import { HistoryTrackerTest } from "./layers/HistoryTrackerTest.js";
|
|
20
11
|
import { LoggerLive, resolveLogFile, resolveLogLevel } from "./layers/LoggerLive.js";
|
|
21
12
|
import { OutputPipelineLive } from "./layers/OutputPipelineLive.js";
|
|
22
13
|
import { APP_NAMESPACE, DATA_FALLBACK_DIR, PathResolutionLive } from "./layers/PathResolutionLive.js";
|
|
23
|
-
import { PerClientSessionMapReader, PerClientSessionMapWriter } from "./services/PerClientSessionMap.js";
|
|
24
14
|
import { PerClientSessionMapReaderLive, PerClientSessionMapWriterLive } from "./layers/PerClientSessionMapLive.js";
|
|
25
|
-
import { ProjectDiscovery } from "./services/ProjectDiscovery.js";
|
|
26
15
|
import { ProjectDiscoveryLive } from "./layers/ProjectDiscoveryLive.js";
|
|
27
16
|
import { ProjectDiscoveryTest } from "./layers/ProjectDiscoveryTest.js";
|
|
28
|
-
import { ProjectIdentity, resolveProjectIdentityFromCandidates } from "./services/ProjectIdentity.js";
|
|
29
17
|
import { ProjectIdentityLive, ProjectIdentityTest } from "./layers/ProjectIdentityLive.js";
|
|
30
|
-
import { AgentContext, RunContext, RunContext$, RunContextService } from "./services/RunContext.js";
|
|
31
|
-
import { probeHostMetadataFromEnv } from "./utils/host-metadata.js";
|
|
32
18
|
import { RunContextLive, RunContextTest } from "./layers/RunContextLive.js";
|
|
33
19
|
import { formatStrayOutputLine, formatTriageEffect } from "./lib/format-triage.js";
|
|
34
20
|
import { formatWrapupEffect } from "./lib/format-wrapup.js";
|
|
@@ -37,26 +23,40 @@ import migration$1 from "./migrations/0002_test_artifacts.js";
|
|
|
37
23
|
import { PROJECT_MIGRATIONS } from "./migrations/index.js";
|
|
38
24
|
import migration$2 from "./migrations/registry_0001_initial.js";
|
|
39
25
|
import migration$3 from "./migrations/session_map_0001_initial.js";
|
|
40
|
-
import { RegistryStore, SessionMapStore } from "./stores.js";
|
|
41
26
|
import { NodePlatformLayer, PlatformLive, makeSqliteStack } from "./platform.js";
|
|
42
27
|
import { endAgentEffect } from "./programs/end-agent.js";
|
|
43
28
|
import { DATA_DB_FILENAME, REGISTRY_DB_FILENAME, REGISTRY_STORE_OPTIONS, SESSIONS_DB_FILENAME, resolveHookPaths, resolveSessionMapPath } from "./programs/hook-paths.js";
|
|
44
29
|
import { RegistryStoreLive, SessionMapStoreLive, SidecarPlatformLive } from "./programs/platform-sidecar.js";
|
|
45
30
|
import { recordSessionEnd, recordSessionStart } from "./programs/record-session.js";
|
|
46
|
-
import { resolveSessionForRecording } from "./programs/resolve-session-for-recording.js";
|
|
47
31
|
import { dispatchRecordTddArtifactEffect, recordTddArtifactByTaskIdEffect, recordTddArtifactEffect } from "./programs/record-tdd-artifact.js";
|
|
48
32
|
import { parseAndValidateTurnPayload, recordTurnEffect } from "./programs/record-turn.js";
|
|
49
33
|
import { recordRunWorkspaceChangesEffect } from "./programs/record-workspace-changes.js";
|
|
50
|
-
import { IDEMPOTENCY_ROOT_SENTINEL, deriveIdempotencyKey } from "./services/idempotency.js";
|
|
51
34
|
import { registerAgentEffect } from "./programs/register-agent.js";
|
|
35
|
+
import { resolveSessionForRecording } from "./programs/resolve-session-for-recording.js";
|
|
52
36
|
import { recoverSessionContextFromSessionEnv } from "./programs/session-env.js";
|
|
53
37
|
import { resolveProjectDir } from "./project-dir.js";
|
|
38
|
+
import { VitestAgentConfigFile } from "./services/Config.js";
|
|
39
|
+
import { DataReader } from "./services/DataReader.js";
|
|
40
|
+
import { DataStore, INLINE_ATTACHMENT_BODY_CAP_BYTES } from "./services/DataStore.js";
|
|
41
|
+
import { DetailResolver } from "./services/DetailResolver.js";
|
|
42
|
+
import { DiscoveryRegistry } from "./services/DiscoveryRegistry.js";
|
|
43
|
+
import { EnvironmentDetector } from "./services/EnvironmentDetector.js";
|
|
44
|
+
import { ExecutorResolver } from "./services/ExecutorResolver.js";
|
|
45
|
+
import { HistoryTracker, historyKey } from "./services/HistoryTracker.js";
|
|
46
|
+
import { IDEMPOTENCY_ROOT_SENTINEL, deriveIdempotencyKey } from "./services/idempotency.js";
|
|
47
|
+
import { PerClientSessionMapReader, PerClientSessionMapWriter } from "./services/PerClientSessionMap.js";
|
|
48
|
+
import { ProjectDiscovery } from "./services/ProjectDiscovery.js";
|
|
49
|
+
import { ProjectIdentity, resolveProjectIdentityFromCandidates } from "./services/ProjectIdentity.js";
|
|
50
|
+
import { AgentContext, RunContext, RunContext$, RunContextService } from "./services/RunContext.js";
|
|
54
51
|
import { assembleHistoryRecord, assembleManifest } from "./sql/assemblers.js";
|
|
52
|
+
import { RegistryStore, SessionMapStore } from "./stores.js";
|
|
55
53
|
import { ensureMigrated } from "./utils/ensure-migrated.js";
|
|
56
54
|
import { computeFailureSignature, normalizeAssertionShape } from "./utils/failure-signature.js";
|
|
57
55
|
import { formatFatalError } from "./utils/format-fatal-error.js";
|
|
58
|
-
import {
|
|
56
|
+
import { probeHostMetadataFromEnv } from "./utils/host-metadata.js";
|
|
57
|
+
import { withPersistSavepoint, withPersistTransaction } from "./utils/persist-transaction.js";
|
|
59
58
|
import { DATABASE_FILENAME, resolveDataPath } from "./utils/resolve-data-path.js";
|
|
59
|
+
import { resolveProjectKeyFromCwd, resolveProjectKeyFromCwdEffect } from "./utils/resolve-project-key-from-cwd.js";
|
|
60
60
|
import { resolveWorkspaceKey } from "./utils/resolve-workspace-key.js";
|
|
61
61
|
import { CURRENT_ENGINE_VERSION } from "./version.js";
|
|
62
62
|
|
|
@@ -11,7 +11,7 @@ const ciEnvironment = (ci) => ci === "github-actions" ? "ci-github" : "ci-generi
|
|
|
11
11
|
*
|
|
12
12
|
* @remarks
|
|
13
13
|
* The agent/CI/human split is `@effected/env`'s `Audience.detect`, so the
|
|
14
|
-
* engine and every `@effected/cli` front end agree on who is running; this
|
|
14
|
+
* engine and every `@effected/cli-kit` front end agree on who is running; this
|
|
15
15
|
* only refines CI into GitHub Actions versus any other CI.
|
|
16
16
|
*
|
|
17
17
|
* @param runtime - the `@effected/env` runtime snapshot to classify
|
package/layers/LoggerLive.js
CHANGED
|
@@ -2,12 +2,12 @@ import { Layer, Logger, Option } from "effect";
|
|
|
2
2
|
import { CurrentRuntimeEnv } from "@effected/env";
|
|
3
3
|
import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
|
|
4
4
|
import * as NodePath from "@effect/platform-node/NodePath";
|
|
5
|
-
import { CliLog } from "@effected/cli";
|
|
5
|
+
import { CliLog } from "@effected/cli-kit";
|
|
6
6
|
|
|
7
7
|
// src/layers/LoggerLive.ts
|
|
8
8
|
/**
|
|
9
9
|
* Create a structured JSON (NDJSON) logger layer for stderr, over
|
|
10
|
-
* `@effected/cli`'s `CliLog` in its diagnostics-only mode
|
|
10
|
+
* `@effected/cli-kit`'s `CliLog` in its diagnostics-only mode
|
|
11
11
|
* (`format: "json"`, `plainLogger: false`): the already-resolved level is
|
|
12
12
|
* passed as `level`, and no plain `CliLogger` is installed beside the sink, so
|
|
13
13
|
* each record prints once and nothing reads the audience or the terminal.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ProjectDiscovery } from "../services/ProjectDiscovery.js";
|
|
2
2
|
import { DiscoveryError, NON_DISCOVERABLE_DIRS } from "@vitest-agent/sdk";
|
|
3
3
|
import { Effect, FileSystem, Layer, Path } from "effect";
|
|
4
|
-
import { ErrorText } from "@effected/engine";
|
|
5
4
|
import { GlobPattern, GlobPatternOptions } from "@effected/glob";
|
|
5
|
+
import { ErrorText } from "@effected/kit";
|
|
6
6
|
import { descend } from "@effected/walker";
|
|
7
7
|
|
|
8
8
|
// src/layers/ProjectDiscoveryLive.ts
|
|
@@ -6,7 +6,7 @@ import { ProjectIdentityNotResolvableError, ProjectIdentitySourceError, VitestAg
|
|
|
6
6
|
import { Effect, FileSystem, Layer, Option, Result } from "effect";
|
|
7
7
|
import { WorkspaceDiscovery } from "@effected/workspaces";
|
|
8
8
|
import { AppDirs } from "@effected/xdg";
|
|
9
|
-
import { ErrorText } from "@effected/
|
|
9
|
+
import { ErrorText } from "@effected/kit";
|
|
10
10
|
import { LenientManifest } from "@effected/package-json";
|
|
11
11
|
|
|
12
12
|
// src/layers/ProjectIdentityLive.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest-agent/engine",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Shared services, layers, SQLite data layer, migrations and platform resolution for the vitest-agent CLI and MCP server.",
|
|
6
6
|
"keywords": [
|
|
@@ -40,26 +40,26 @@
|
|
|
40
40
|
"./package.json": "./package.json"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@effect/platform-node": "~4.1.
|
|
44
|
-
"@effect/sql-sqlite-node": "~4.1.
|
|
45
|
-
"@effected/app": "^0.
|
|
46
|
-
"@effected/cli": "^0.
|
|
47
|
-
"@effected/config-file": "^0.
|
|
48
|
-
"@effected/
|
|
49
|
-
"@effected/
|
|
50
|
-
"@effected/
|
|
51
|
-
"@effected/
|
|
52
|
-
"@effected/
|
|
53
|
-
"@effected/memfs": "^0.
|
|
54
|
-
"@effected/package-json": "^0.
|
|
55
|
-
"@effected/store": "^0.
|
|
56
|
-
"@effected/toml": "^0.
|
|
57
|
-
"@effected/walker": "^0.
|
|
58
|
-
"@effected/workspaces": "^0.
|
|
59
|
-
"@effected/xdg": "^0.
|
|
60
|
-
"@effected/yaml": "^0.
|
|
61
|
-
"@vitest-agent/sdk": "9.0.
|
|
62
|
-
"effect": "~4.1.
|
|
43
|
+
"@effect/platform-node": "~4.1.2",
|
|
44
|
+
"@effect/sql-sqlite-node": "~4.1.2",
|
|
45
|
+
"@effected/app": "^0.31.1",
|
|
46
|
+
"@effected/cli-kit": "^0.27.0",
|
|
47
|
+
"@effected/config-file": "^0.25.0",
|
|
48
|
+
"@effected/env": "^0.11.0",
|
|
49
|
+
"@effected/git": "^0.30.0",
|
|
50
|
+
"@effected/glob": "^0.19.0",
|
|
51
|
+
"@effected/jsonc": "^0.24.0",
|
|
52
|
+
"@effected/kit": "^0.13.0",
|
|
53
|
+
"@effected/memfs": "^0.24.0",
|
|
54
|
+
"@effected/package-json": "^0.30.0",
|
|
55
|
+
"@effected/store": "^0.24.0",
|
|
56
|
+
"@effected/toml": "^0.19.1",
|
|
57
|
+
"@effected/walker": "^0.25.1",
|
|
58
|
+
"@effected/workspaces": "^0.43.0",
|
|
59
|
+
"@effected/xdg": "^0.19.1",
|
|
60
|
+
"@effected/yaml": "^0.29.0",
|
|
61
|
+
"@vitest-agent/sdk": "9.0.3",
|
|
62
|
+
"effect": "~4.1.2"
|
|
63
63
|
},
|
|
64
64
|
"engines": {
|
|
65
65
|
"node": ">=24.11.0"
|
package/platform.js
CHANGED
|
@@ -5,7 +5,7 @@ import { LoggerLive } from "./layers/LoggerLive.js";
|
|
|
5
5
|
import { OutputPipelineLive } from "./layers/OutputPipelineLive.js";
|
|
6
6
|
import { ProjectDiscoveryLive } from "./layers/ProjectDiscoveryLive.js";
|
|
7
7
|
import { PROJECT_MIGRATIONS } from "./migrations/index.js";
|
|
8
|
-
import {
|
|
8
|
+
import { DATA_DB_CONNECTION_OPTIONS, LEDGER_OPTIONS } from "./stores.js";
|
|
9
9
|
import { Context, Effect, Layer } from "effect";
|
|
10
10
|
import { SqlClient } from "effect/sql/SqlClient";
|
|
11
11
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
@@ -34,11 +34,8 @@ const NodePlatformLayer = NodeServices.layer;
|
|
|
34
34
|
const makeSqliteStack = (filename, migrations = PROJECT_MIGRATIONS) => {
|
|
35
35
|
const SqliteLayer = layer({
|
|
36
36
|
filename,
|
|
37
|
-
|
|
38
|
-
}).pipe(Layer.tap((context) =>
|
|
39
|
-
const sql = Context.get(context, SqlClient);
|
|
40
|
-
return Effect.andThen(sql`PRAGMA synchronous = NORMAL`, applyConnectionPragmas(sql));
|
|
41
|
-
}));
|
|
37
|
+
...DATA_DB_CONNECTION_OPTIONS.client
|
|
38
|
+
}).pipe(Layer.tap((context) => DATA_DB_CONNECTION_OPTIONS.onConnect(Context.get(context, SqlClient))));
|
|
42
39
|
return {
|
|
43
40
|
SqliteLayer,
|
|
44
41
|
MigratorLayer: Layer.effectDiscard(Effect.void).pipe(Layer.provide(Store.layer({
|
package/programs/hook-paths.js
CHANGED
|
@@ -4,7 +4,7 @@ import { LEDGER_OPTIONS } from "../stores.js";
|
|
|
4
4
|
import { ProjectIdentityNotResolvableError } from "@vitest-agent/sdk";
|
|
5
5
|
import { Effect, FileSystem, Layer, Option, Path } from "effect";
|
|
6
6
|
import { AppDirs, Xdg } from "@effected/xdg";
|
|
7
|
-
import { LaunchContext } from "@effected/
|
|
7
|
+
import { LaunchContext } from "@effected/kit";
|
|
8
8
|
import { Store } from "@effected/store";
|
|
9
9
|
import { AppStore } from "@effected/app";
|
|
10
10
|
|
|
@@ -72,7 +72,7 @@ const hookAppDirs = (env) => {
|
|
|
72
72
|
*
|
|
73
73
|
* Precedence: the `CLAUDE_PLUGIN_DATA` env var, then
|
|
74
74
|
* `VITEST_AGENT_SESSION_MAP_DIR`, then `~/.vitest-agent/` (`HOME`, then
|
|
75
|
-
* `USERPROFILE`). The two variables are read through `@effected/
|
|
75
|
+
* `USERPROFILE`). The two variables are read through `@effected/kit`'s
|
|
76
76
|
* `LaunchContext.resolve`: a value is trimmed, and a blank or unsubstituted
|
|
77
77
|
* `${...}` placeholder value counts as unset. The chosen directory is created. Fails with
|
|
78
78
|
* `ProjectIdentityNotResolvableError` when no home directory is resolvable.
|
|
@@ -5,8 +5,8 @@ import { LoggerLive } from "../layers/LoggerLive.js";
|
|
|
5
5
|
import { PerClientSessionMapWriterLive } from "../layers/PerClientSessionMapLive.js";
|
|
6
6
|
import { RunContextLive } from "../layers/RunContextLive.js";
|
|
7
7
|
import migration from "../migrations/session_map_0001_initial.js";
|
|
8
|
-
import { CONNECTION_OPTIONS, LEDGER_OPTIONS, RegistryStore, SessionMapStore } from "../stores.js";
|
|
9
8
|
import { NodePlatformLayer, makeSqliteStack } from "../platform.js";
|
|
9
|
+
import { CONNECTION_OPTIONS, LEDGER_OPTIONS, RegistryStore, SessionMapStore } from "../stores.js";
|
|
10
10
|
import { REGISTRY_STORE_OPTIONS } from "./hook-paths.js";
|
|
11
11
|
import { Layer } from "effect";
|
|
12
12
|
import { Store } from "@effected/store";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DataReader } from "../services/DataReader.js";
|
|
2
2
|
import { DataStore } from "../services/DataStore.js";
|
|
3
|
+
import { deriveIdempotencyKey } from "../services/idempotency.js";
|
|
3
4
|
import { PerClientSessionMapWriter } from "../services/PerClientSessionMap.js";
|
|
4
5
|
import { RunContextService } from "../services/RunContext.js";
|
|
5
|
-
import { deriveIdempotencyKey } from "../services/idempotency.js";
|
|
6
6
|
import { Effect, Option } from "effect";
|
|
7
7
|
|
|
8
8
|
// src/programs/register-agent.ts
|
package/project-dir.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LaunchContext } from "@effected/
|
|
1
|
+
import { LaunchContext } from "@effected/kit";
|
|
2
2
|
|
|
3
3
|
// src/project-dir.ts
|
|
4
4
|
/**
|
|
@@ -16,7 +16,7 @@ const PROJECT_DIR_ENV_KEYS = [
|
|
|
16
16
|
* Precedence: `VITEST_AGENT_PROJECT_DIR` (hook-driven override), then
|
|
17
17
|
* `VITEST_AGENT_REPORTER_PROJECT_DIR` (the plugin-spawned MCP server's
|
|
18
18
|
* hand-off), then `CLAUDE_PROJECT_DIR` (Claude Code's own convention),
|
|
19
|
-
* then `cwd`. Delegates to `@effected/
|
|
19
|
+
* then `cwd`. Delegates to `@effected/kit`'s `LaunchContext.projectDir`:
|
|
20
20
|
* a value is trimmed, and an empty or whitespace-only value, or one a plugin
|
|
21
21
|
* host left as a literal unsubstituted `${...}` placeholder, counts as unset.
|
|
22
22
|
* Pure: both the env map and the working directory are injected by the caller.
|
package/stores.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context } from "effect";
|
|
1
|
+
import { Context, Effect } from "effect";
|
|
2
2
|
|
|
3
3
|
// src/stores.ts
|
|
4
4
|
/**
|
|
@@ -12,8 +12,6 @@ const LEDGER_OPTIONS = { adoptMigratorLedger: true };
|
|
|
12
12
|
* How long a connection waits on a locked database before `SQLITE_BUSY`:
|
|
13
13
|
* five seconds, the value the 2.x migrations set with `PRAGMA busy_timeout`.
|
|
14
14
|
* Passed as the driver's `busyTimeout`, which applies it on every open.
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
15
|
*/
|
|
18
16
|
const BUSY_TIMEOUT = "5 seconds";
|
|
19
17
|
/**
|
|
@@ -23,8 +21,6 @@ const BUSY_TIMEOUT = "5 seconds";
|
|
|
23
21
|
* migration can only do for the one connection that runs it; the
|
|
24
22
|
* `node:sqlite` driver happens to default both today, and this pins them
|
|
25
23
|
* so a driver default change cannot silently drop them.
|
|
26
|
-
*
|
|
27
|
-
* @internal
|
|
28
24
|
*/
|
|
29
25
|
const applyConnectionPragmas = (sql) => sql`PRAGMA foreign_keys = ON`;
|
|
30
26
|
/**
|
|
@@ -38,6 +34,24 @@ const CONNECTION_OPTIONS = {
|
|
|
38
34
|
onConnect: applyConnectionPragmas
|
|
39
35
|
};
|
|
40
36
|
/**
|
|
37
|
+
* The connection options every `data.db` connection opens with, on both of
|
|
38
|
+
* its open paths (`makeSqliteStack` and `ensureMigrated`): {@link CONNECTION_OPTIONS}
|
|
39
|
+
* plus `synchronous = NORMAL`, set as the connection opens and before any
|
|
40
|
+
* migration.
|
|
41
|
+
*
|
|
42
|
+
* WAL + `synchronous = NORMAL` is SQLite's documented pairing: a commit no
|
|
43
|
+
* longer fsyncs (the WAL is synced at checkpoint), and the database stays
|
|
44
|
+
* consistent across an application crash; only a power loss or OS crash can
|
|
45
|
+
* roll back the most recent commits. `sessions.db` and `registry.db` keep the
|
|
46
|
+
* driver's default.
|
|
47
|
+
*
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
const DATA_DB_CONNECTION_OPTIONS = {
|
|
51
|
+
client: CONNECTION_OPTIONS.client,
|
|
52
|
+
onConnect: (sql) => Effect.andThen(sql`PRAGMA synchronous = NORMAL`, CONNECTION_OPTIONS.onConnect(sql))
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
41
55
|
* The global discovery registry (`<XDG data>/vitest-agent/registry.db`).
|
|
42
56
|
* @internal
|
|
43
57
|
*/
|
|
@@ -48,4 +62,4 @@ var RegistryStore = class extends Context.Service()("vitest-agent/RegistryStore"
|
|
|
48
62
|
*/
|
|
49
63
|
var SessionMapStore = class extends Context.Service()("vitest-agent/SessionMapStore") {};
|
|
50
64
|
|
|
51
|
-
export {
|
|
65
|
+
export { CONNECTION_OPTIONS, DATA_DB_CONNECTION_OPTIONS, LEDGER_OPTIONS, RegistryStore, SessionMapStore };
|
package/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DataReader } from "./services/DataReader.js";
|
|
2
1
|
import { DataStore } from "./services/DataStore.js";
|
|
3
|
-
import { PROJECT_MIGRATIONS } from "./migrations/index.js";
|
|
4
2
|
import { DataStoreTestLayer, makeTestLayer } from "./testing/layers.js";
|
|
3
|
+
import { PROJECT_MIGRATIONS } from "./migrations/index.js";
|
|
4
|
+
import { DataReader } from "./services/DataReader.js";
|
|
5
5
|
import { Agent, AgentId, AgentNotFoundError, AgentReport, BehaviorDetail, BehaviorNotFoundError, BehaviorRow, BehaviorStatus, CacheManifest, ChatId, CoverageBaselines, CoverageReport, DataStoreError, FileCoverageReport, GoalDetail, GoalNotFoundError, GoalRow, GoalStatus, HistoryRecord, IdempotencyHit, IllegalStatusTransitionError, RegistrationConflictError, RunRetentionPolicy, TddTaskAlreadyEndedError, TddTaskNotFoundError, TrendEntry, TrendRecord } from "@vitest-agent/sdk";
|
|
6
6
|
import { Effect, Layer } from "effect";
|
|
7
7
|
|
package/tsdoc-metadata.json
CHANGED
package/utils/ensure-migrated.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LoggerLive } from "../layers/LoggerLive.js";
|
|
2
2
|
import { PROJECT_MIGRATIONS } from "../migrations/index.js";
|
|
3
|
-
import { BUSY_TIMEOUT, LEDGER_OPTIONS, applyConnectionPragmas } from "../stores.js";
|
|
4
3
|
import { NodePlatformLayer } from "../platform.js";
|
|
4
|
+
import { DATA_DB_CONNECTION_OPTIONS, LEDGER_OPTIONS } from "../stores.js";
|
|
5
5
|
import { Effect } from "effect";
|
|
6
6
|
import { Store } from "@effected/store";
|
|
7
7
|
|
|
@@ -40,8 +40,7 @@ function ensureMigrated(dbPath, logLevel, logFile, env) {
|
|
|
40
40
|
filename: dbPath,
|
|
41
41
|
migrations: PROJECT_STORE_MIGRATIONS,
|
|
42
42
|
...LEDGER_OPTIONS,
|
|
43
|
-
|
|
44
|
-
onConnect: (sql) => Effect.andThen(sql`PRAGMA synchronous = NORMAL`, applyConnectionPragmas(sql))
|
|
43
|
+
...DATA_DB_CONNECTION_OPTIONS
|
|
45
44
|
}).pipe(Effect.provide(NodePlatformLayer), Effect.provide(LoggerLive(logLevel, logFile, env))));
|
|
46
45
|
}
|
|
47
46
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Cause } from "effect";
|
|
2
|
-
import { CliFailure, Render } from "@effected/cli";
|
|
2
|
+
import { CliFailure, Render } from "@effected/cli-kit";
|
|
3
3
|
|
|
4
4
|
// src/utils/format-fatal-error.ts
|
|
5
5
|
const ISSUE_URL = "https://github.com/spencerbeggs/vitest-agent/issues";
|
|
@@ -18,7 +18,7 @@ const CONTEXT = Render.contextOf({ audience: "human" });
|
|
|
18
18
|
* is (one from `Effect.runPromiseExit` keeps every reason and the span
|
|
19
19
|
* trail), and anything else is rendered as a defect, `Cause.die(err)`: an
|
|
20
20
|
* unexpected throw is a bug to report, and a defect is the shape whose
|
|
21
|
-
* document carries the stack. `@effected/cli`'s `CliFailure.toDoc` keeps
|
|
21
|
+
* document carries the stack. `@effected/cli-kit`'s `CliFailure.toDoc` keeps
|
|
22
22
|
* the program's own frames, hides `node_modules` and runtime frames,
|
|
23
23
|
* follows an `Error.cause` chain, and renders a non-`Error` value as its
|
|
24
24
|
* text.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { repositoryUrlOf } from "./package-manifest.js";
|
|
2
2
|
import { gitUrlToProjectKey } from "@vitest-agent/sdk";
|
|
3
|
-
import { Effect, FileSystem,
|
|
4
|
-
import * as NodePath from "@effect/platform-node/NodePath";
|
|
3
|
+
import { Effect, FileSystem, Option, Path, Result } from "effect";
|
|
5
4
|
import { AppDirs } from "@effected/xdg";
|
|
6
5
|
import { Walker } from "@effected/walker";
|
|
7
6
|
import { LenientManifest } from "@effected/package-json";
|
|
@@ -31,7 +30,7 @@ const basenameKey = (path, cwd) => {
|
|
|
31
30
|
const basename = path.basename(cwd);
|
|
32
31
|
return basename.length === 0 ? "anonymous-project" : Result.getOrElse(AppDirs.segment(basename), () => "anonymous-project");
|
|
33
32
|
};
|
|
34
|
-
const NodeSyncPlatform =
|
|
33
|
+
const NodeSyncPlatform = NodeSyncFileSystem.layerWithPath;
|
|
35
34
|
/**
|
|
36
35
|
* Compute the project key for a workspace by reading `package.json`
|
|
37
36
|
* fields directly. Returns the canonical `host__path` form when a git
|
package/version.js
CHANGED