@vitest-agent/engine 3.2.8 → 3.3.0
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 +18 -3
- package/index.js +2 -2
- package/layers/ConfigLive.js +1 -1
- package/layers/DataReaderLive.js +5 -5
- package/layers/DataStoreLive.js +8 -7
- package/layers/DetailResolverLive.js +1 -1
- package/layers/DiscoveryRegistryLive.js +4 -4
- package/layers/EnvironmentDetectorLive.js +2 -2
- package/layers/EnvironmentDetectorTest.js +1 -1
- package/layers/ExecutorResolverLive.js +1 -1
- package/layers/HistoryTrackerLive.js +2 -2
- package/layers/HistoryTrackerTest.js +1 -1
- package/layers/LoggerLive.js +2 -2
- package/layers/OutputPipelineLive.js +1 -1
- package/layers/PathResolutionLive.js +2 -2
- package/layers/PerClientSessionMapLive.js +6 -6
- package/layers/ProjectDiscoveryLive.js +3 -3
- package/layers/ProjectDiscoveryTest.js +1 -1
- package/layers/ProjectIdentityLive.js +7 -7
- package/layers/RunContextLive.js +2 -2
- package/lib/format-triage.js +1 -1
- package/lib/format-wrapup.js +1 -1
- package/migrations/0005_scrub_ci_env_vars.js +24 -0
- package/migrations/index.js +3 -1
- package/package.json +8 -8
- package/platform.js +5 -5
- package/programs/end-agent.js +1 -1
- package/programs/hook-paths.js +6 -6
- package/programs/platform-sidecar.js +2 -2
- package/programs/record-session.js +1 -1
- package/programs/record-tdd-artifact.js +1 -1
- package/programs/record-turn.js +2 -2
- package/programs/record-workspace-changes.js +1 -1
- package/programs/register-agent.js +5 -5
- package/programs/resolve-session-for-recording.js +2 -2
- package/programs/session-env.js +3 -3
- package/services/DataStore.js +15 -2
- package/services/ProjectIdentity.js +1 -1
- package/testing/layers.js +1 -1
- package/testing.d.ts +17 -2
- package/testing.js +2 -2
- package/utils/ensure-migrated.js +2 -2
- package/utils/failure-signature.js +2 -1
- package/utils/format-fatal-error.js +1 -1
- package/utils/host-metadata.js +1 -1
- package/utils/package-manifest.js +1 -1
- package/utils/resolve-data-path.js +4 -4
- package/utils/resolve-project-key-from-cwd.js +5 -5
- package/utils/resolve-workspace-key.js +1 -1
- package/version.js +1 -1
package/index.d.ts
CHANGED
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @packageDocumentation
|
|
12
12
|
*/
|
|
13
|
-
import { ConfigCodecError, ConfigFileShape, ConfigReadError } from "@effected/config-file";
|
|
14
|
-
import { AppDirs, AppDirs as AppDirs$1, AppDirsError, AppDirsError as AppDirsError$1, AppDirsSegmentError, XdgEnvError } from "@effected/xdg";
|
|
15
13
|
import { Context, Effect, FileSystem, Layer, LogLevel, Option, Path, Schema } from "effect";
|
|
14
|
+
import { ConfigCodecError, ConfigFileShape, ConfigReadError } from "@effected/config-file";
|
|
16
15
|
import { Agent, AgentNotFoundError, AgentReport, ArtifactKind, ArtifactKind as ArtifactKind$1, ArtifactSuite, ArtifactSuite as ArtifactSuite$1, BehaviorDetail, BehaviorNotFoundError, BehaviorRow, BehaviorStatus, CacheManifest, CitedArtifact, CoverageBaselines, CoverageReport, DataStoreError, DetailLevel, DiscoveryError, Environment, Executor, FileCoverageReport, GoalDetail, GoalNotFoundError, GoalRow, GoalStatus, HistoryRecord, IdempotencyHit, IllegalStatusTransitionError, Phase, ProjectIdentityError, ProjectIdentityNotResolvableError, ProjectIdentitySourceError, RegistrationConflictError, ResolvedThresholds, RunRetentionPolicy, StrayOutput, TddTaskAlreadyEndedError, TddTaskNotFoundError, TestClassification, TestRun, TrendEntry, TrendRecord, TurnPayload, VitestAgentConfig } from "@vitest-agent/sdk";
|
|
17
16
|
import { SqlClient } from "effect/sql/SqlClient";
|
|
18
17
|
import { CiName, RuntimeEnv } from "@effected/env";
|
|
19
18
|
import { WorkspaceDiscovery, WorkspaceDiscoveryFailure, WorkspaceRootNotFoundError } from "@effected/workspaces";
|
|
19
|
+
import { AppDirs, AppDirs as AppDirs$1, AppDirsError, AppDirsError as AppDirsError$1, AppDirsSegmentError, XdgEnvError } from "@effected/xdg";
|
|
20
20
|
import { ChildProcessSpawner } from "effect/process";
|
|
21
21
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
22
22
|
import { SqliteClient } from "@effect/sql-sqlite-node/SqliteClient";
|
|
@@ -360,6 +360,13 @@ export interface FailureSignatureWriteInput {
|
|
|
360
360
|
readonly signatureHash: string;
|
|
361
361
|
readonly runId: number;
|
|
362
362
|
readonly seenAt: string;
|
|
363
|
+
/**
|
|
364
|
+
* Whether this write counts as an occurrence. Defaults to `true`. Pass `false`
|
|
365
|
+
* for an error from a recovered attempt (the test finally passed): the row is
|
|
366
|
+
* still upserted and `last_seen_at` advances, but `occurrence_count` is not
|
|
367
|
+
* incremented, and a brand-new signature starts at 0.
|
|
368
|
+
*/
|
|
369
|
+
readonly countOccurrence?: boolean;
|
|
363
370
|
}
|
|
364
371
|
/** @public */
|
|
365
372
|
export interface HypothesisInput {
|
|
@@ -434,8 +441,15 @@ export interface WriteCommitInput {
|
|
|
434
441
|
readonly committedAt?: string;
|
|
435
442
|
readonly branch?: string;
|
|
436
443
|
}
|
|
444
|
+
/**
|
|
445
|
+
* How a file changed in a recorded commit or working-tree snapshot. The same
|
|
446
|
+
* set the `run_changed_files.change_kind` CHECK constraint allows.
|
|
447
|
+
*
|
|
448
|
+
* @public
|
|
449
|
+
*/
|
|
450
|
+
export declare const ChangeKind: Schema.Literals<readonly ["added", "modified", "deleted", "renamed", "untracked-modified"]>;
|
|
437
451
|
/** @public */
|
|
438
|
-
export type ChangeKind =
|
|
452
|
+
export type ChangeKind = typeof ChangeKind.Type;
|
|
439
453
|
/** @public */
|
|
440
454
|
export interface RunChangedFile {
|
|
441
455
|
readonly filePath: string;
|
|
@@ -1820,6 +1834,7 @@ export declare const PROJECT_MIGRATIONS: {
|
|
|
1820
1834
|
readonly "0002_test_artifacts": import("effect/Effect").Effect<void, import("effect/sql/SqlError").SqlError, import("effect/sql/SqlClient").SqlClient>;
|
|
1821
1835
|
readonly "0003_run_retention": import("effect/Effect").Effect<void, import("effect/sql/SqlError").SqlError, import("effect/sql/SqlClient").SqlClient>;
|
|
1822
1836
|
readonly "0004_stray_output": import("effect/Effect").Effect<void, import("effect/sql/SqlError").SqlError, import("effect/sql/SqlClient").SqlClient>;
|
|
1837
|
+
readonly "0005_scrub_ci_env_vars": import("effect/Effect").Effect<void, import("effect/sql/SqlError").SqlError, import("effect/sql/SqlClient").SqlClient>;
|
|
1823
1838
|
};
|
|
1824
1839
|
/**
|
|
1825
1840
|
* Migration for the global discovery registry SQLite at
|
package/index.js
CHANGED
|
@@ -37,7 +37,7 @@ import { recoverSessionContextFromSessionEnv } from "./programs/session-env.js";
|
|
|
37
37
|
import { resolveProjectDir } from "./project-dir.js";
|
|
38
38
|
import { VitestAgentConfigFile } from "./services/Config.js";
|
|
39
39
|
import { DataReader } from "./services/DataReader.js";
|
|
40
|
-
import { DataStore, INLINE_ATTACHMENT_BODY_CAP_BYTES } from "./services/DataStore.js";
|
|
40
|
+
import { ChangeKind, DataStore, INLINE_ATTACHMENT_BODY_CAP_BYTES } from "./services/DataStore.js";
|
|
41
41
|
import { DetailResolver } from "./services/DetailResolver.js";
|
|
42
42
|
import { DiscoveryRegistry } from "./services/DiscoveryRegistry.js";
|
|
43
43
|
import { EnvironmentDetector } from "./services/EnvironmentDetector.js";
|
|
@@ -60,4 +60,4 @@ import { resolveProjectKeyFromCwd, resolveProjectKeyFromCwdEffect } from "./util
|
|
|
60
60
|
import { resolveWorkspaceKey } from "./utils/resolve-workspace-key.js";
|
|
61
61
|
import { CURRENT_ENGINE_VERSION } from "./version.js";
|
|
62
62
|
|
|
63
|
-
export { APP_NAMESPACE, AgentContext, CURRENT_ENGINE_VERSION, ConfigLive, DATABASE_FILENAME, DATA_DB_FILENAME, DATA_FALLBACK_DIR, DataReader, DataReaderLive, DataStore, DataStoreLive, DetailResolver, DetailResolverLive, DiscoveryRegistry, DiscoveryRegistryLive, EnvironmentDetector, EnvironmentDetectorLive, EnvironmentDetectorTest, ExecutorResolver, ExecutorResolverLive, HistoryTracker, HistoryTrackerLive, HistoryTrackerTest, IDEMPOTENCY_ROOT_SENTINEL, INLINE_ATTACHMENT_BODY_CAP_BYTES, LoggerLive, NodePlatformLayer, OutputPipelineLive, PROJECT_MIGRATIONS, PathResolutionLive, PerClientSessionMapReader, PerClientSessionMapReaderLive, PerClientSessionMapWriter, PerClientSessionMapWriterLive, PlatformLive, ProjectDiscovery, ProjectDiscoveryLive, ProjectDiscoveryTest, ProjectIdentity, ProjectIdentityLive, ProjectIdentityTest, REGISTRY_DB_FILENAME, REGISTRY_STORE_OPTIONS, RegistryStore, RegistryStoreLive, RunContext, RunContext$, RunContextLive, RunContextService, RunContextTest, SESSIONS_DB_FILENAME, SessionMapStore, SessionMapStoreLive, SidecarPlatformLive, VitestAgentConfigFile, assembleHistoryRecord, assembleManifest, classifyEnvironment, computeFailureSignature, deriveIdempotencyKey, dispatchRecordTddArtifactEffect, endAgentEffect, ensureMigrated, formatFatalError, formatStrayOutputLine, formatTriageEffect, formatWrapupEffect, historyKey, makeSqliteStack, migration as migration0001, migration$1 as migration0002, normalizeAssertionShape, parseAndValidateTurnPayload, probeHostMetadataFromEnv, recordRunWorkspaceChangesEffect, recordSessionEnd, recordSessionStart, recordTddArtifactByTaskIdEffect, recordTddArtifactEffect, recordTurnEffect, recoverSessionContextFromSessionEnv, registerAgentEffect, migration$2 as registryMigration0001, resolveDataPath, resolveHookPaths, resolveLogFile, resolveLogLevel, resolveProjectDir, resolveProjectIdentityFromCandidates, resolveProjectKeyFromCwd, resolveProjectKeyFromCwdEffect, resolveSessionForRecording, resolveSessionMapPath, resolveWorkspaceKey, migration$3 as sessionMapMigration0001, withPersistSavepoint, withPersistTransaction };
|
|
63
|
+
export { APP_NAMESPACE, AgentContext, CURRENT_ENGINE_VERSION, ChangeKind, ConfigLive, DATABASE_FILENAME, DATA_DB_FILENAME, DATA_FALLBACK_DIR, DataReader, DataReaderLive, DataStore, DataStoreLive, DetailResolver, DetailResolverLive, DiscoveryRegistry, DiscoveryRegistryLive, EnvironmentDetector, EnvironmentDetectorLive, EnvironmentDetectorTest, ExecutorResolver, ExecutorResolverLive, HistoryTracker, HistoryTrackerLive, HistoryTrackerTest, IDEMPOTENCY_ROOT_SENTINEL, INLINE_ATTACHMENT_BODY_CAP_BYTES, LoggerLive, NodePlatformLayer, OutputPipelineLive, PROJECT_MIGRATIONS, PathResolutionLive, PerClientSessionMapReader, PerClientSessionMapReaderLive, PerClientSessionMapWriter, PerClientSessionMapWriterLive, PlatformLive, ProjectDiscovery, ProjectDiscoveryLive, ProjectDiscoveryTest, ProjectIdentity, ProjectIdentityLive, ProjectIdentityTest, REGISTRY_DB_FILENAME, REGISTRY_STORE_OPTIONS, RegistryStore, RegistryStoreLive, RunContext, RunContext$, RunContextLive, RunContextService, RunContextTest, SESSIONS_DB_FILENAME, SessionMapStore, SessionMapStoreLive, SidecarPlatformLive, VitestAgentConfigFile, assembleHistoryRecord, assembleManifest, classifyEnvironment, computeFailureSignature, deriveIdempotencyKey, dispatchRecordTddArtifactEffect, endAgentEffect, ensureMigrated, formatFatalError, formatStrayOutputLine, formatTriageEffect, formatWrapupEffect, historyKey, makeSqliteStack, migration as migration0001, migration$1 as migration0002, normalizeAssertionShape, parseAndValidateTurnPayload, probeHostMetadataFromEnv, recordRunWorkspaceChangesEffect, recordSessionEnd, recordSessionStart, recordTddArtifactByTaskIdEffect, recordTddArtifactEffect, recordTurnEffect, recoverSessionContextFromSessionEnv, registerAgentEffect, migration$2 as registryMigration0001, resolveDataPath, resolveHookPaths, resolveLogFile, resolveLogLevel, resolveProjectDir, resolveProjectIdentityFromCandidates, resolveProjectKeyFromCwd, resolveProjectKeyFromCwdEffect, resolveSessionForRecording, resolveSessionMapPath, resolveWorkspaceKey, migration$3 as sessionMapMigration0001, withPersistSavepoint, withPersistTransaction };
|
package/layers/ConfigLive.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { VitestAgentConfigFile } from "../services/Config.js";
|
|
2
1
|
import { ConfigFile, ConfigResolver, MergeStrategy } from "@effected/config-file";
|
|
3
2
|
import { TomlCodec } from "@effected/config-file/toml";
|
|
4
3
|
import { Git } from "@effected/git";
|
|
5
4
|
import { VitestAgentConfig } from "@vitest-agent/sdk";
|
|
6
5
|
import { Effect, Layer, Option } from "effect";
|
|
7
6
|
import { ChildProcessSpawner } from "effect/process";
|
|
7
|
+
import { VitestAgentConfigFile } from "../services/Config.js";
|
|
8
8
|
|
|
9
9
|
// src/layers/ConfigLive.ts
|
|
10
10
|
const CONFIG_FILENAME = "vitest-agent.config.toml";
|
package/layers/DataReaderLive.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DataReader } from "../services/DataReader.js";
|
|
2
|
-
import { historyKey } from "../services/HistoryTracker.js";
|
|
3
1
|
import { DataStoreError, StrayOutputSample, extractSqlReason } from "@vitest-agent/sdk";
|
|
4
|
-
import { Effect, Layer, Option, Schema } from "effect";
|
|
2
|
+
import { DateTime, Effect, Layer, Option, Schema } from "effect";
|
|
5
3
|
import { SqlClient } from "effect/sql/SqlClient";
|
|
4
|
+
import { DataReader } from "../services/DataReader.js";
|
|
5
|
+
import { historyKey } from "../services/HistoryTracker.js";
|
|
6
6
|
|
|
7
7
|
// src/layers/DataReaderLive.ts
|
|
8
8
|
const decodeStraySamples = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Array(StrayOutputSample)));
|
|
@@ -321,7 +321,7 @@ const DataReaderLive = Layer.effect(DataReader, Effect.gen(function* () {
|
|
|
321
321
|
const ts = t.runs[0]?.timestamp ?? "";
|
|
322
322
|
if (ts > latest) return ts;
|
|
323
323
|
return latest;
|
|
324
|
-
}, "") || (
|
|
324
|
+
}, "") || DateTime.formatIso(yield* DateTime.now),
|
|
325
325
|
tests
|
|
326
326
|
};
|
|
327
327
|
}).pipe(Effect.annotateLogs("service", "DataReader"), Effect.mapError((e) => new DataStoreError({
|
|
@@ -855,7 +855,7 @@ const DataReaderLive = Layer.effect(DataReader, Effect.gen(function* () {
|
|
|
855
855
|
if (!r.last_run) return latest;
|
|
856
856
|
if (!latest || r.last_run > latest) return r.last_run;
|
|
857
857
|
return latest;
|
|
858
|
-
}, null) ?? (
|
|
858
|
+
}, null) ?? DateTime.formatIso(yield* DateTime.now),
|
|
859
859
|
cacheDir: dbPath,
|
|
860
860
|
projects
|
|
861
861
|
};
|
package/layers/DataStoreLive.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { DataStore, INLINE_ATTACHMENT_BODY_CAP_BYTES } from "../services/DataStore.js";
|
|
2
|
-
import { PersistBatch, withPersistSavepoint } from "../utils/persist-transaction.js";
|
|
3
|
-
import { Agent, AgentNotFoundError, BehaviorNotFoundError, DataStoreError, FileEditPayload, GoalNotFoundError, IdempotencyHit, IllegalStatusTransitionError, RegistrationConflictError, TddTaskAlreadyEndedError, TddTaskNotFoundError, ToolResultPayload, coerceErrorText, extractSqlReason } from "@vitest-agent/sdk";
|
|
4
|
-
import { Clock, Effect, Layer, Option, Schema, Struct } from "effect";
|
|
5
|
-
import { SqlClient } from "effect/sql/SqlClient";
|
|
6
1
|
import { Buffer } from "node:buffer";
|
|
2
|
+
import { Agent, AgentNotFoundError, BehaviorNotFoundError, DataStoreError, FileEditPayload, GoalNotFoundError, IdempotencyHit, IllegalStatusTransitionError, RegistrationConflictError, TddTaskAlreadyEndedError, TddTaskNotFoundError, ToolResultPayload, coerceErrorText, extractSqlReason } from "@vitest-agent/sdk";
|
|
3
|
+
import { Clock, DateTime, Effect, Layer, Option, Schema, Struct } from "effect";
|
|
7
4
|
import { SecureRandom } from "effect/crypto";
|
|
5
|
+
import { SqlClient } from "effect/sql/SqlClient";
|
|
6
|
+
import { DataStore, INLINE_ATTACHMENT_BODY_CAP_BYTES } from "../services/DataStore.js";
|
|
7
|
+
import { PersistBatch, withPersistSavepoint } from "../utils/persist-transaction.js";
|
|
8
8
|
|
|
9
9
|
// src/layers/DataStoreLive.ts
|
|
10
10
|
/**
|
|
@@ -300,7 +300,7 @@ const DataStoreLive = Layer.effect(DataStore, Effect.gen(function* () {
|
|
|
300
300
|
*/
|
|
301
301
|
const writeCoveragePolicy = (kind, policy) => savepoint(Effect.gen(function* () {
|
|
302
302
|
yield* Effect.logDebug("writeCoveragePolicy").pipe(Effect.annotateLogs({ kind }));
|
|
303
|
-
const updatedAt = (
|
|
303
|
+
const updatedAt = DateTime.formatIso(yield* DateTime.now);
|
|
304
304
|
const { global: g, patterns = [] } = policy;
|
|
305
305
|
const metrics = [
|
|
306
306
|
"lines",
|
|
@@ -522,7 +522,8 @@ const DataStoreLive = Layer.effect(DataStore, Effect.gen(function* () {
|
|
|
522
522
|
signatureHash: input.signatureHash,
|
|
523
523
|
runId: input.runId
|
|
524
524
|
}));
|
|
525
|
-
|
|
525
|
+
const increment = input.countOccurrence === false ? 0 : 1;
|
|
526
|
+
yield* sql`INSERT INTO failure_signatures (signature_hash, first_seen_run_id, first_seen_at, last_seen_at, occurrence_count) VALUES (${input.signatureHash}, ${input.runId}, ${input.seenAt}, ${input.seenAt}, ${increment}) ON CONFLICT(signature_hash) DO UPDATE SET occurrence_count = occurrence_count + ${increment}, last_seen_at = excluded.last_seen_at`;
|
|
526
527
|
}).pipe(Effect.annotateLogs("service", "DataStore"), Effect.mapError((e) => new DataStoreError({
|
|
527
528
|
operation: "write",
|
|
528
529
|
table: "failure_signatures",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DiscoveryRegistry } from "../services/DiscoveryRegistry.js";
|
|
2
1
|
import { DataStoreError, extractSqlReason } from "@vitest-agent/sdk";
|
|
3
|
-
import { Effect, Layer } from "effect";
|
|
2
|
+
import { Clock, Effect, Layer } from "effect";
|
|
4
3
|
import { SqlClient } from "effect/sql/SqlClient";
|
|
4
|
+
import { DiscoveryRegistry } from "../services/DiscoveryRegistry.js";
|
|
5
5
|
|
|
6
6
|
// src/layers/DiscoveryRegistryLive.ts
|
|
7
7
|
const TABLE = "known_projects";
|
|
@@ -20,7 +20,7 @@ const DiscoveryRegistryLive = Layer.effect(DiscoveryRegistry, Effect.gen(functio
|
|
|
20
20
|
const sql = yield* SqlClient;
|
|
21
21
|
return {
|
|
22
22
|
recordProject: (input) => Effect.gen(function* () {
|
|
23
|
-
const now =
|
|
23
|
+
const now = yield* Clock.currentTimeMillis;
|
|
24
24
|
yield* sql`
|
|
25
25
|
INSERT INTO ${sql(TABLE)} (
|
|
26
26
|
project_key, canonical_form, data_db_path, git_remote_origin, workspace_root,
|
|
@@ -54,7 +54,7 @@ const DiscoveryRegistryLive = Layer.effect(DiscoveryRegistry, Effect.gen(functio
|
|
|
54
54
|
reason: extractSqlReason(e)
|
|
55
55
|
}))),
|
|
56
56
|
prune: (maxAgeDays) => Effect.gen(function* () {
|
|
57
|
-
const cutoff =
|
|
57
|
+
const cutoff = (yield* Clock.currentTimeMillis) - maxAgeDays * dayInMs;
|
|
58
58
|
const removable = (yield* sql`SELECT COUNT(*) AS c FROM ${sql(TABLE)} WHERE last_seen_at < ${cutoff}`)[0]?.c ?? 0;
|
|
59
59
|
if (removable > 0) yield* sql`DELETE FROM ${sql(TABLE)} WHERE last_seen_at < ${cutoff}`;
|
|
60
60
|
return removable;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EnvironmentDetector } from "../services/EnvironmentDetector.js";
|
|
2
|
-
import { Effect, Layer, Option } from "effect";
|
|
3
1
|
import { Audience, CurrentRuntimeEnv } from "@effected/env";
|
|
2
|
+
import { Effect, Layer, Option } from "effect";
|
|
3
|
+
import { EnvironmentDetector } from "../services/EnvironmentDetector.js";
|
|
4
4
|
|
|
5
5
|
// src/layers/EnvironmentDetectorLive.ts
|
|
6
6
|
/** The engine environment for a CI `@effected/env` names: GitHub Actions gets its own, every other provider is generic. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EnvironmentDetector } from "../services/EnvironmentDetector.js";
|
|
2
1
|
import { Effect, Layer, Option } from "effect";
|
|
2
|
+
import { EnvironmentDetector } from "../services/EnvironmentDetector.js";
|
|
3
3
|
|
|
4
4
|
// src/layers/EnvironmentDetectorTest.ts
|
|
5
5
|
/** The CI vendor each environment implies when a test does not say otherwise. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DataReader } from "../services/DataReader.js";
|
|
2
|
-
import { HistoryTracker, historyKey } from "../services/HistoryTracker.js";
|
|
3
1
|
import { classifyTest } from "@vitest-agent/sdk";
|
|
4
2
|
import { Effect, Layer } from "effect";
|
|
3
|
+
import { DataReader } from "../services/DataReader.js";
|
|
4
|
+
import { HistoryTracker, historyKey } from "../services/HistoryTracker.js";
|
|
5
5
|
|
|
6
6
|
// src/layers/HistoryTrackerLive.ts
|
|
7
7
|
const WINDOW_SIZE = 10;
|
package/layers/LoggerLive.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Layer, Logger, Option } from "effect";
|
|
2
|
-
import { CurrentRuntimeEnv } from "@effected/env";
|
|
3
1
|
import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
|
|
4
2
|
import * as NodePath from "@effect/platform-node/NodePath";
|
|
5
3
|
import { CliLog } from "@effected/cli-kit";
|
|
4
|
+
import { CurrentRuntimeEnv } from "@effected/env";
|
|
5
|
+
import { Layer, Logger, Option } from "effect";
|
|
6
6
|
|
|
7
7
|
// src/layers/LoggerLive.ts
|
|
8
8
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
1
2
|
import { DetailResolverLive } from "./DetailResolverLive.js";
|
|
2
3
|
import { EnvironmentDetectorLive } from "./EnvironmentDetectorLive.js";
|
|
3
4
|
import { ExecutorResolverLive } from "./ExecutorResolverLive.js";
|
|
4
|
-
import { Layer } from "effect";
|
|
5
5
|
|
|
6
6
|
// src/layers/OutputPipelineLive.ts
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ConfigLive } from "./ConfigLive.js";
|
|
2
|
-
import { Layer } from "effect";
|
|
3
1
|
import { WorkspaceDiscovery, WorkspaceRoot } from "@effected/workspaces";
|
|
4
2
|
import { AppDirs, Xdg } from "@effected/xdg";
|
|
3
|
+
import { Layer } from "effect";
|
|
4
|
+
import { ConfigLive } from "./ConfigLive.js";
|
|
5
5
|
|
|
6
6
|
// src/layers/PathResolutionLive.ts
|
|
7
7
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { basename } from "node:path";
|
|
2
2
|
import { DataStoreError, extractSqlReason } from "@vitest-agent/sdk";
|
|
3
|
-
import { Effect, Layer, Option } from "effect";
|
|
4
|
-
import { SqlClient } from "effect/sql/SqlClient";
|
|
3
|
+
import { Clock, Effect, Layer, Option } from "effect";
|
|
5
4
|
import { SecureRandom } from "effect/crypto";
|
|
6
|
-
import {
|
|
5
|
+
import { SqlClient } from "effect/sql/SqlClient";
|
|
6
|
+
import { PerClientSessionMapReader, PerClientSessionMapWriter } from "../services/PerClientSessionMap.js";
|
|
7
7
|
|
|
8
8
|
// src/layers/PerClientSessionMapLive.ts
|
|
9
9
|
const sessionRowToContext = (row) => ({
|
|
@@ -78,7 +78,7 @@ const PerClientSessionMapWriterLive = Layer.effect(PerClientSessionMapWriter, Ef
|
|
|
78
78
|
const existing = yield* sql`
|
|
79
79
|
SELECT conversation_id FROM conversation_map WHERE transcript_uuid = ${uuid}
|
|
80
80
|
`;
|
|
81
|
-
const now =
|
|
81
|
+
const now = yield* Clock.currentTimeMillis;
|
|
82
82
|
if (existing.length > 0) {
|
|
83
83
|
yield* sql`UPDATE conversation_map SET last_seen_at = ${now} WHERE transcript_uuid = ${uuid}`;
|
|
84
84
|
return existing[0].conversation_id;
|
|
@@ -103,7 +103,7 @@ const PerClientSessionMapWriterLive = Layer.effect(PerClientSessionMapWriter, Ef
|
|
|
103
103
|
conversationId: existing[0].conversation_id
|
|
104
104
|
};
|
|
105
105
|
const mainAgentId = SecureRandom.uuidV4Unsafe();
|
|
106
|
-
const now =
|
|
106
|
+
const now = yield* Clock.currentTimeMillis;
|
|
107
107
|
yield* sql`
|
|
108
108
|
INSERT INTO session_map (
|
|
109
109
|
host_session_id, conversation_id, project_key, project_dir, main_agent_id, started_at, ended_at
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ProjectDiscovery } from "../services/ProjectDiscovery.js";
|
|
2
|
-
import { DiscoveryError, NON_DISCOVERABLE_DIRS } from "@vitest-agent/sdk";
|
|
3
|
-
import { Effect, FileSystem, Layer, Path } from "effect";
|
|
4
1
|
import { GlobPattern, GlobPatternOptions } from "@effected/glob";
|
|
5
2
|
import { ErrorText } from "@effected/kit";
|
|
6
3
|
import { descend } from "@effected/walker";
|
|
4
|
+
import { DiscoveryError, NON_DISCOVERABLE_DIRS } from "@vitest-agent/sdk";
|
|
5
|
+
import { Effect, FileSystem, Layer, Path } from "effect";
|
|
6
|
+
import { ProjectDiscovery } from "../services/ProjectDiscovery.js";
|
|
7
7
|
|
|
8
8
|
// src/layers/ProjectDiscoveryLive.ts
|
|
9
9
|
const SKIP_DIRS = [
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { VitestAgentConfigFile } from "../services/Config.js";
|
|
2
|
-
import { ProjectIdentity, resolveProjectIdentityFromCandidates } from "../services/ProjectIdentity.js";
|
|
3
|
-
import { repositoryUrlOf } from "../utils/package-manifest.js";
|
|
4
1
|
import { Git } from "@effected/git";
|
|
5
|
-
import { ProjectIdentityNotResolvableError, ProjectIdentitySourceError, VitestAgentConfig } from "@vitest-agent/sdk";
|
|
6
|
-
import { Effect, FileSystem, Layer, Option, Result } from "effect";
|
|
7
|
-
import { WorkspaceDiscovery } from "@effected/workspaces";
|
|
8
|
-
import { AppDirs } from "@effected/xdg";
|
|
9
2
|
import { ErrorText } from "@effected/kit";
|
|
10
3
|
import { LenientManifest } from "@effected/package-json";
|
|
4
|
+
import { WorkspaceDiscovery } from "@effected/workspaces";
|
|
5
|
+
import { AppDirs } from "@effected/xdg";
|
|
6
|
+
import { ProjectIdentityNotResolvableError, ProjectIdentitySourceError, VitestAgentConfig } from "@vitest-agent/sdk";
|
|
7
|
+
import { Effect, FileSystem, Layer, Option, Result } from "effect";
|
|
8
|
+
import { VitestAgentConfigFile } from "../services/Config.js";
|
|
9
|
+
import { ProjectIdentity, resolveProjectIdentityFromCandidates } from "../services/ProjectIdentity.js";
|
|
10
|
+
import { repositoryUrlOf } from "../utils/package-manifest.js";
|
|
11
11
|
|
|
12
12
|
// src/layers/ProjectIdentityLive.ts
|
|
13
13
|
/**
|
package/layers/RunContextLive.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AgentContext, RunContext, RunContextService } from "../services/RunContext.js";
|
|
2
|
-
import { probeHostMetadataFromEnv } from "../utils/host-metadata.js";
|
|
3
1
|
import { Git } from "@effected/git";
|
|
4
2
|
import { Effect, Layer, Option } from "effect";
|
|
3
|
+
import { AgentContext, RunContext, RunContextService } from "../services/RunContext.js";
|
|
4
|
+
import { probeHostMetadataFromEnv } from "../utils/host-metadata.js";
|
|
5
5
|
|
|
6
6
|
// src/layers/RunContextLive.ts
|
|
7
7
|
/** Every git failure (not a repository, no `git` on PATH, an unborn HEAD) is "no answer". */
|
package/lib/format-triage.js
CHANGED
package/lib/format-wrapup.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataReader } from "../services/DataReader.js";
|
|
2
1
|
import { Effect, Option } from "effect";
|
|
2
|
+
import { DataReader } from "../services/DataReader.js";
|
|
3
3
|
|
|
4
4
|
// src/lib/format-wrapup.ts
|
|
5
5
|
const FAILURE_PROMPT_PATTERN = /\b(?:test fail|fix\b[^.]*\btest|why\b[^.]*\bfail(?:ing)?|broken test)\b/i;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { SqlClient } from "effect/sql/SqlClient";
|
|
3
|
+
|
|
4
|
+
// src/migrations/0005_scrub_ci_env_vars.ts
|
|
5
|
+
const KEPT = [
|
|
6
|
+
"GITHUB_ACTIONS",
|
|
7
|
+
"GITHUB_RUN_ID",
|
|
8
|
+
"GITHUB_RUN_ATTEMPT",
|
|
9
|
+
"GITHUB_JOB",
|
|
10
|
+
"GITHUB_SHA",
|
|
11
|
+
"GITHUB_REF_NAME",
|
|
12
|
+
"RUNNER_OS",
|
|
13
|
+
"RUNNER_ARCH"
|
|
14
|
+
];
|
|
15
|
+
/** @internal */
|
|
16
|
+
const migration = Effect.gen(function* () {
|
|
17
|
+
const sql = yield* SqlClient;
|
|
18
|
+
yield* sql`
|
|
19
|
+
DELETE FROM settings_env_vars
|
|
20
|
+
WHERE (key LIKE 'GITHUB\\_%' ESCAPE '\\' OR key LIKE 'RUNNER\\_%' ESCAPE '\\')
|
|
21
|
+
AND key NOT IN ${sql.in(KEPT)}`;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export { migration as default };
|
package/migrations/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import migration from "./0001_initial.js";
|
|
|
2
2
|
import migration$1 from "./0002_test_artifacts.js";
|
|
3
3
|
import migration$2 from "./0003_run_retention.js";
|
|
4
4
|
import migration$3 from "./0004_stray_output.js";
|
|
5
|
+
import migration$4 from "./0005_scrub_ci_env_vars.js";
|
|
5
6
|
|
|
6
7
|
// src/migrations/index.ts
|
|
7
8
|
/**
|
|
@@ -25,7 +26,8 @@ const PROJECT_MIGRATIONS = {
|
|
|
25
26
|
"0001_initial": migration,
|
|
26
27
|
"0002_test_artifacts": migration$1,
|
|
27
28
|
"0003_run_retention": migration$2,
|
|
28
|
-
"0004_stray_output": migration$3
|
|
29
|
+
"0004_stray_output": migration$3,
|
|
30
|
+
"0005_scrub_ci_env_vars": migration$4
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
export { PROJECT_MIGRATIONS };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest-agent/engine",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
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,13 +40,13 @@
|
|
|
40
40
|
"./package.json": "./package.json"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@effect/platform-node": "4.1.
|
|
44
|
-
"@effect/sql-sqlite-node": "4.1.
|
|
43
|
+
"@effect/platform-node": "4.1.5",
|
|
44
|
+
"@effect/sql-sqlite-node": "4.1.5",
|
|
45
45
|
"@effected/app": "0.34.0",
|
|
46
|
-
"@effected/cli-kit": "0.30.
|
|
46
|
+
"@effected/cli-kit": "0.30.1",
|
|
47
47
|
"@effected/config-file": "0.29.0",
|
|
48
48
|
"@effected/env": "0.12.0",
|
|
49
|
-
"@effected/git": "0.
|
|
49
|
+
"@effected/git": "0.33.0",
|
|
50
50
|
"@effected/glob": "0.23.0",
|
|
51
51
|
"@effected/jsonc": "0.25.0",
|
|
52
52
|
"@effected/kit": "0.14.0",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"@effected/store": "0.25.0",
|
|
56
56
|
"@effected/toml": "0.20.0",
|
|
57
57
|
"@effected/walker": "0.30.0",
|
|
58
|
-
"@effected/workspaces": "0.48.
|
|
58
|
+
"@effected/workspaces": "0.48.2",
|
|
59
59
|
"@effected/xdg": "0.22.0",
|
|
60
60
|
"@effected/yaml": "0.30.0",
|
|
61
|
-
"@vitest-agent/sdk": "9.0
|
|
62
|
-
"effect": "4.1.
|
|
61
|
+
"@vitest-agent/sdk": "9.1.0",
|
|
62
|
+
"effect": "4.1.5"
|
|
63
63
|
},
|
|
64
64
|
"engines": {
|
|
65
65
|
"node": ">=24.11.0"
|
package/platform.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
2
|
+
import { layer } from "@effect/sql-sqlite-node/SqliteClient";
|
|
3
|
+
import { Store } from "@effected/store";
|
|
4
|
+
import { Context, Effect, Layer } from "effect";
|
|
5
|
+
import { SqlClient } from "effect/sql/SqlClient";
|
|
1
6
|
import { DataReaderLive } from "./layers/DataReaderLive.js";
|
|
2
7
|
import { DataStoreLive } from "./layers/DataStoreLive.js";
|
|
3
8
|
import { HistoryTrackerLive } from "./layers/HistoryTrackerLive.js";
|
|
@@ -6,11 +11,6 @@ import { OutputPipelineLive } from "./layers/OutputPipelineLive.js";
|
|
|
6
11
|
import { ProjectDiscoveryLive } from "./layers/ProjectDiscoveryLive.js";
|
|
7
12
|
import { PROJECT_MIGRATIONS } from "./migrations/index.js";
|
|
8
13
|
import { DATA_DB_CONNECTION_OPTIONS, LEDGER_OPTIONS } from "./stores.js";
|
|
9
|
-
import { Context, Effect, Layer } from "effect";
|
|
10
|
-
import { SqlClient } from "effect/sql/SqlClient";
|
|
11
|
-
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
12
|
-
import { layer } from "@effect/sql-sqlite-node/SqliteClient";
|
|
13
|
-
import { Store } from "@effected/store";
|
|
14
14
|
|
|
15
15
|
// src/platform.ts
|
|
16
16
|
/**
|
package/programs/end-agent.js
CHANGED
package/programs/hook-paths.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { AppStore } from "@effected/app";
|
|
2
|
+
import { LaunchContext } from "@effected/kit";
|
|
3
|
+
import { Store } from "@effected/store";
|
|
4
|
+
import { AppDirs, Xdg } from "@effected/xdg";
|
|
5
|
+
import { ProjectIdentityNotResolvableError } from "@vitest-agent/sdk";
|
|
6
|
+
import { Effect, FileSystem, Layer, Option, Path } from "effect";
|
|
1
7
|
import { APP_NAMESPACE, DATA_FALLBACK_DIR } from "../layers/PathResolutionLive.js";
|
|
2
8
|
import migration from "../migrations/registry_0001_initial.js";
|
|
3
9
|
import { LEDGER_OPTIONS } from "../stores.js";
|
|
4
|
-
import { ProjectIdentityNotResolvableError } from "@vitest-agent/sdk";
|
|
5
|
-
import { Effect, FileSystem, Layer, Option, Path } from "effect";
|
|
6
|
-
import { AppDirs, Xdg } from "@effected/xdg";
|
|
7
|
-
import { LaunchContext } from "@effected/kit";
|
|
8
|
-
import { Store } from "@effected/store";
|
|
9
|
-
import { AppStore } from "@effected/app";
|
|
10
10
|
|
|
11
11
|
// src/programs/hook-paths.ts
|
|
12
12
|
/**
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Store } from "@effected/store";
|
|
2
|
+
import { Layer } from "effect";
|
|
1
3
|
import { DataReaderLive } from "../layers/DataReaderLive.js";
|
|
2
4
|
import { DataStoreLive } from "../layers/DataStoreLive.js";
|
|
3
5
|
import { DiscoveryRegistryLive } from "../layers/DiscoveryRegistryLive.js";
|
|
@@ -8,8 +10,6 @@ import migration from "../migrations/session_map_0001_initial.js";
|
|
|
8
10
|
import { NodePlatformLayer, makeSqliteStack } from "../platform.js";
|
|
9
11
|
import { CONNECTION_OPTIONS, LEDGER_OPTIONS, RegistryStore, SessionMapStore } from "../stores.js";
|
|
10
12
|
import { REGISTRY_STORE_OPTIONS } from "./hook-paths.js";
|
|
11
|
-
import { Layer } from "effect";
|
|
12
|
-
import { Store } from "@effected/store";
|
|
13
13
|
|
|
14
14
|
// src/programs/platform-sidecar.ts
|
|
15
15
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Effect, Option } from "effect";
|
|
1
2
|
import { DataReader } from "../services/DataReader.js";
|
|
2
3
|
import { DataStore } from "../services/DataStore.js";
|
|
3
4
|
import { resolveSessionForRecording } from "./resolve-session-for-recording.js";
|
|
4
|
-
import { Effect, Option } from "effect";
|
|
5
5
|
|
|
6
6
|
// src/programs/record-tdd-artifact.ts
|
|
7
7
|
/**
|
package/programs/record-turn.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DataStore } from "../services/DataStore.js";
|
|
2
|
-
import { resolveSessionForRecording } from "./resolve-session-for-recording.js";
|
|
3
1
|
import { TurnPayload } from "@vitest-agent/sdk";
|
|
4
2
|
import { Effect, Result, Schema } from "effect";
|
|
3
|
+
import { DataStore } from "../services/DataStore.js";
|
|
4
|
+
import { resolveSessionForRecording } from "./resolve-session-for-recording.js";
|
|
5
5
|
|
|
6
6
|
// src/programs/record-turn.ts
|
|
7
7
|
const decodeTurnPayload = Schema.decodeUnknownResult(Schema.fromJsonString(TurnPayload));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Clock, DateTime, Effect, Option } from "effect";
|
|
1
2
|
import { DataReader } from "../services/DataReader.js";
|
|
2
3
|
import { DataStore } from "../services/DataStore.js";
|
|
3
4
|
import { deriveIdempotencyKey } from "../services/idempotency.js";
|
|
4
5
|
import { PerClientSessionMapWriter } from "../services/PerClientSessionMap.js";
|
|
5
6
|
import { RunContextService } from "../services/RunContext.js";
|
|
6
|
-
import { Effect, Option } from "effect";
|
|
7
7
|
|
|
8
8
|
// src/programs/register-agent.ts
|
|
9
9
|
const deriveDefaultClientNonce = (input) => {
|
|
@@ -36,16 +36,16 @@ const registerAgentEffect = (input) => Effect.gen(function* () {
|
|
|
36
36
|
});
|
|
37
37
|
const existingSession = yield* reader.getSessionByChatId(input.hostSessionId);
|
|
38
38
|
const sessionRowId = yield* Option.match(existingSession, {
|
|
39
|
-
onNone: () => store.writeSession({
|
|
39
|
+
onNone: () => Effect.flatMap(DateTime.now, (now) => store.writeSession({
|
|
40
40
|
chatId: input.hostSessionId,
|
|
41
41
|
project: input.projectKey,
|
|
42
42
|
cwd: input.cwd,
|
|
43
43
|
agentKind: input.parentAgentId === void 0 ? "main" : "subagent",
|
|
44
44
|
agentType: input.agentType,
|
|
45
45
|
triageWasNonEmpty: false,
|
|
46
|
-
startedAt:
|
|
46
|
+
startedAt: DateTime.formatIso(now),
|
|
47
47
|
conversationId
|
|
48
|
-
}),
|
|
48
|
+
})),
|
|
49
49
|
onSome: (s) => Effect.succeed(s.id)
|
|
50
50
|
});
|
|
51
51
|
yield* store.setSessionConversationIdIfNull({
|
|
@@ -64,7 +64,7 @@ const registerAgentEffect = (input) => Effect.gen(function* () {
|
|
|
64
64
|
agentType: input.agentType,
|
|
65
65
|
parentAgentId: input.parentAgentId ?? null,
|
|
66
66
|
conversationId,
|
|
67
|
-
startedAt: Math.floor(
|
|
67
|
+
startedAt: Math.floor((yield* Clock.currentTimeMillis) / 1e3),
|
|
68
68
|
...agentContext.startGitBranch !== null && { startGitBranch: agentContext.startGitBranch },
|
|
69
69
|
...agentContext.startGitCommitSha !== null && { startGitCommitSha: agentContext.startGitCommitSha },
|
|
70
70
|
...agentContext.startWorktreeDir !== null && { startWorktreeDir: agentContext.startWorktreeDir },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { LenientManifest } from "@effected/package-json";
|
|
2
|
+
import { Effect, FileSystem, Option, Path } from "effect";
|
|
1
3
|
import { DataReader } from "../services/DataReader.js";
|
|
2
4
|
import { DataStore } from "../services/DataStore.js";
|
|
3
|
-
import { Effect, FileSystem, Option, Path } from "effect";
|
|
4
|
-
import { LenientManifest } from "@effected/package-json";
|
|
5
5
|
|
|
6
6
|
// src/programs/resolve-session-for-recording.ts
|
|
7
7
|
/**
|
package/programs/session-env.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Result } from "effect";
|
|
2
|
-
import { ShellExports } from "@effected/env";
|
|
3
|
-
import { join, resolve } from "node:path";
|
|
4
1
|
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { ShellExports } from "@effected/env";
|
|
4
|
+
import { Result } from "effect";
|
|
5
5
|
|
|
6
6
|
// src/programs/session-env.ts
|
|
7
7
|
/** The default {@link SessionEnvFileSystem}: the real disk through `node:fs`. */
|
package/services/DataStore.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context } from "effect";
|
|
1
|
+
import { Context, Schema } from "effect";
|
|
2
2
|
|
|
3
3
|
// src/services/DataStore.ts
|
|
4
4
|
/**
|
|
@@ -8,7 +8,20 @@ import { Context } from "effect";
|
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
10
|
const INLINE_ATTACHMENT_BODY_CAP_BYTES = 65536;
|
|
11
|
+
/**
|
|
12
|
+
* How a file changed in a recorded commit or working-tree snapshot. The same
|
|
13
|
+
* set the `run_changed_files.change_kind` CHECK constraint allows.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
const ChangeKind = Schema.Literals([
|
|
18
|
+
"added",
|
|
19
|
+
"modified",
|
|
20
|
+
"deleted",
|
|
21
|
+
"renamed",
|
|
22
|
+
"untracked-modified"
|
|
23
|
+
]);
|
|
11
24
|
/** @public */
|
|
12
25
|
var DataStore = class extends Context.Service()("vitest-agent/DataStore") {};
|
|
13
26
|
|
|
14
|
-
export { DataStore, INLINE_ATTACHMENT_BODY_CAP_BYTES };
|
|
27
|
+
export { ChangeKind, DataStore, INLINE_ATTACHMENT_BODY_CAP_BYTES };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { AppDirs } from "@effected/xdg";
|
|
1
2
|
import { canonicalizeGitUrl, gitUrlToProjectKey } from "@vitest-agent/sdk";
|
|
2
3
|
import { Context, Result } from "effect";
|
|
3
|
-
import { AppDirs } from "@effected/xdg";
|
|
4
4
|
|
|
5
5
|
// src/services/ProjectIdentity.ts
|
|
6
6
|
const isUseful = (value) => value !== void 0 && value.trim().length > 0;
|
package/testing/layers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
1
2
|
import { DataReaderLive } from "../layers/DataReaderLive.js";
|
|
2
3
|
import { DataStoreLive } from "../layers/DataStoreLive.js";
|
|
3
4
|
import { NodePlatformLayer, makeSqliteStack } from "../platform.js";
|
|
4
|
-
import { Layer } from "effect";
|
|
5
5
|
|
|
6
6
|
// src/testing/layers.ts
|
|
7
7
|
/** @public */
|
package/testing.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Agent, Agent as Agent$1, AgentId, AgentNotFoundError, AgentNotFoundError as AgentNotFoundError$1, AgentReport, AgentReport as AgentReport$1, ArtifactKind, ArtifactKind as ArtifactKind$1, ArtifactKind as ArtifactKind$2, ArtifactSuite, ArtifactSuite as ArtifactSuite$1, ArtifactSuite as ArtifactSuite$2, BehaviorDetail, BehaviorDetail as BehaviorDetail$1, BehaviorNotFoundError, BehaviorNotFoundError as BehaviorNotFoundError$1, BehaviorRow, BehaviorRow as BehaviorRow$1, BehaviorStatus, BehaviorStatus as BehaviorStatus$1, CacheManifest, CacheManifest as CacheManifest$1, ChatId, CitedArtifact, CitedArtifact as CitedArtifact$1, CoverageBaselines, CoverageBaselines as CoverageBaselines$1, CoverageReport, CoverageReport as CoverageReport$1, DataStoreError, DataStoreError as DataStoreError$1, FileCoverageReport, FileCoverageReport as FileCoverageReport$1, GoalDetail, GoalDetail as GoalDetail$1, GoalNotFoundError, GoalNotFoundError as GoalNotFoundError$1, GoalRow, GoalRow as GoalRow$1, GoalStatus, GoalStatus as GoalStatus$1, HistoryRecord, HistoryRecord as HistoryRecord$1, IdempotencyHit, IdempotencyHit as IdempotencyHit$1, IllegalStatusTransitionEntity, IllegalStatusTransitionError, IllegalStatusTransitionError as IllegalStatusTransitionError$1, Phase, Phase as Phase$1, RegistrationConflictError, RegistrationConflictError as RegistrationConflictError$1, ResolvedThresholds, ResolvedThresholds as ResolvedThresholds$1, RunRetentionPolicy, RunRetentionPolicy as RunRetentionPolicy$1, StrayOutput, TddTaskAlreadyEndedError, TddTaskAlreadyEndedError as TddTaskAlreadyEndedError$1, TddTaskEndOutcome, TddTaskNotFoundError, TddTaskNotFoundError as TddTaskNotFoundError$1, TrendEntry, TrendEntry as TrendEntry$1, TrendRecord, TrendRecord as TrendRecord$1 } from "@vitest-agent/sdk";
|
|
2
|
-
import { Context, Effect, Layer, Option } from "effect";
|
|
2
|
+
import { Context, Effect, Layer, Option, Schema } from "effect";
|
|
3
3
|
import { StoreError, StoreMigrationError } from "@effected/store";
|
|
4
4
|
import { SqlError } from "effect/sql/SqlError";
|
|
5
5
|
/** @public */
|
|
@@ -289,6 +289,13 @@ interface FailureSignatureWriteInput {
|
|
|
289
289
|
readonly signatureHash: string;
|
|
290
290
|
readonly runId: number;
|
|
291
291
|
readonly seenAt: string;
|
|
292
|
+
/**
|
|
293
|
+
* Whether this write counts as an occurrence. Defaults to `true`. Pass `false`
|
|
294
|
+
* for an error from a recovered attempt (the test finally passed): the row is
|
|
295
|
+
* still upserted and `last_seen_at` advances, but `occurrence_count` is not
|
|
296
|
+
* incremented, and a brand-new signature starts at 0.
|
|
297
|
+
*/
|
|
298
|
+
readonly countOccurrence?: boolean;
|
|
292
299
|
}
|
|
293
300
|
/** @public */
|
|
294
301
|
interface HypothesisInput {
|
|
@@ -363,8 +370,15 @@ interface WriteCommitInput {
|
|
|
363
370
|
readonly committedAt?: string;
|
|
364
371
|
readonly branch?: string;
|
|
365
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* How a file changed in a recorded commit or working-tree snapshot. The same
|
|
375
|
+
* set the `run_changed_files.change_kind` CHECK constraint allows.
|
|
376
|
+
*
|
|
377
|
+
* @public
|
|
378
|
+
*/
|
|
379
|
+
declare const ChangeKind: Schema.Literals<readonly ["added", "modified", "deleted", "renamed", "untracked-modified"]>;
|
|
366
380
|
/** @public */
|
|
367
|
-
type ChangeKind =
|
|
381
|
+
type ChangeKind = typeof ChangeKind.Type;
|
|
368
382
|
/** @public */
|
|
369
383
|
interface RunChangedFile {
|
|
370
384
|
readonly filePath: string;
|
|
@@ -1147,6 +1161,7 @@ export declare const PROJECT_MIGRATIONS: {
|
|
|
1147
1161
|
readonly "0002_test_artifacts": import("effect/Effect").Effect<void, import("effect/sql/SqlError").SqlError, import("effect/sql/SqlClient").SqlClient>;
|
|
1148
1162
|
readonly "0003_run_retention": import("effect/Effect").Effect<void, import("effect/sql/SqlError").SqlError, import("effect/sql/SqlClient").SqlClient>;
|
|
1149
1163
|
readonly "0004_stray_output": import("effect/Effect").Effect<void, import("effect/sql/SqlError").SqlError, import("effect/sql/SqlClient").SqlClient>;
|
|
1164
|
+
readonly "0005_scrub_ci_env_vars": import("effect/Effect").Effect<void, import("effect/sql/SqlError").SqlError, import("effect/sql/SqlClient").SqlClient>;
|
|
1150
1165
|
};
|
|
1151
1166
|
/** @public */
|
|
1152
1167
|
export declare function makeTestLayer(filename: string): Layer.Layer<DataReader | DataStore | import("effect/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect/platform-node/NodeServices").NodeServices, PlatformLiveError, never>;
|
package/testing.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
1
2
|
import { DataStore } from "./services/DataStore.js";
|
|
2
3
|
import { DataStoreTestLayer, makeTestLayer } from "./testing/layers.js";
|
|
4
|
+
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";
|
|
3
5
|
import { PROJECT_MIGRATIONS } from "./migrations/index.js";
|
|
4
6
|
import { DataReader } from "./services/DataReader.js";
|
|
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
|
-
import { Effect, Layer } from "effect";
|
|
7
7
|
|
|
8
8
|
// src/testing/index.ts
|
|
9
9
|
/** @public */
|
package/utils/ensure-migrated.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Store } from "@effected/store";
|
|
2
|
+
import { Effect } from "effect";
|
|
1
3
|
import { LoggerLive } from "../layers/LoggerLive.js";
|
|
2
4
|
import { PROJECT_MIGRATIONS } from "../migrations/index.js";
|
|
3
5
|
import { NodePlatformLayer } from "../platform.js";
|
|
4
6
|
import { DATA_DB_CONNECTION_OPTIONS, LEDGER_OPTIONS } from "../stores.js";
|
|
5
|
-
import { Effect } from "effect";
|
|
6
|
-
import { Store } from "@effected/store";
|
|
7
7
|
|
|
8
8
|
// src/utils/ensure-migrated.ts
|
|
9
9
|
/**
|
|
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
|
|
3
3
|
// src/utils/failure-signature.ts
|
|
4
4
|
const ASSERTION_REGEX = /(toBe|toEqual|toContain|toMatch|toThrow|toBeNull|toBeUndefined|toBeTruthy|toBeFalsy|toBeGreaterThan|toBeLessThan|toBeInstanceOf|toBeCloseTo|toHaveBeenCalled|toHaveBeenCalledWith|toHaveProperty|toHaveLength)\s*\(([^)]*)\)/;
|
|
5
|
+
const TIMEOUT_ERROR_NAMES = /* @__PURE__ */ new Set(["TestTimeoutError", "HookTimeoutError"]);
|
|
5
6
|
const typeTagOf = (literal) => {
|
|
6
7
|
const trimmed = literal.trim();
|
|
7
8
|
if (trimmed === "" || trimmed === ")") return "";
|
|
@@ -26,7 +27,7 @@ const normalizeAssertionShape = (message) => {
|
|
|
26
27
|
const computeFailureSignature = (input) => {
|
|
27
28
|
const shape = normalizeAssertionShape(input.assertion_message) ?? "<unknown>";
|
|
28
29
|
const lineCoord = input.top_frame_function_boundary_line !== null ? `fb:${input.top_frame_function_boundary_line}` : input.top_frame_raw_line !== void 0 ? `raw:${Math.floor(input.top_frame_raw_line / 10) * 10}` : "raw:?";
|
|
29
|
-
const key = `${input.error_name}|${shape}|${input.top_frame_function_name}|${lineCoord}`;
|
|
30
|
+
const key = `${TIMEOUT_ERROR_NAMES.has(input.error_name) ? "Error" : input.error_name}|${shape}|${input.top_frame_function_name}|${lineCoord}`;
|
|
30
31
|
return createHash("sha256").update(key).digest("hex").substring(0, 16);
|
|
31
32
|
};
|
|
32
33
|
|
package/utils/host-metadata.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { AppDirs } from "@effected/xdg";
|
|
3
3
|
import { ProjectIdentitySourceError, VitestAgentConfig } from "@vitest-agent/sdk";
|
|
4
4
|
import { Effect, FileSystem, Result } from "effect";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { VitestAgentConfigFile } from "../services/Config.js";
|
|
6
|
+
import { resolveProjectKeyFromCwdEffect } from "./resolve-project-key-from-cwd.js";
|
|
7
7
|
|
|
8
8
|
// src/utils/resolve-data-path.ts
|
|
9
9
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NodeSyncFileSystem } from "@effected/memfs/node-sync";
|
|
2
|
+
import { LenientManifest } from "@effected/package-json";
|
|
3
|
+
import { Walker } from "@effected/walker";
|
|
4
|
+
import { AppDirs } from "@effected/xdg";
|
|
2
5
|
import { gitUrlToProjectKey } from "@vitest-agent/sdk";
|
|
3
6
|
import { Effect, FileSystem, Option, Path, Result } from "effect";
|
|
4
|
-
import {
|
|
5
|
-
import { Walker } from "@effected/walker";
|
|
6
|
-
import { LenientManifest } from "@effected/package-json";
|
|
7
|
-
import { NodeSyncFileSystem } from "@effected/memfs/node-sync";
|
|
7
|
+
import { repositoryUrlOf } from "./package-manifest.js";
|
|
8
8
|
|
|
9
9
|
// src/utils/resolve-project-key-from-cwd.ts
|
|
10
10
|
const PACKAGE_JSON = "package.json";
|
package/version.js
CHANGED