@vitest-agent/engine 1.0.6 → 1.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/index.d.ts +27 -116
- package/index.js +2 -1
- package/layers/ConfigLive.js +1 -2
- package/layers/DataReaderLive.js +1 -2
- package/layers/DataStoreLive.js +21 -6
- package/layers/DetailResolverLive.js +1 -2
- package/layers/DiscoveryRegistryLive.js +1 -2
- package/layers/EnvironmentDetectorLive.js +1 -2
- package/layers/EnvironmentDetectorTest.js +1 -2
- package/layers/ExecutorResolverLive.js +1 -2
- package/layers/HistoryTrackerLive.js +1 -2
- package/layers/HistoryTrackerTest.js +1 -2
- package/layers/LoggerLive.js +1 -2
- package/layers/OutputPipelineLive.js +1 -2
- package/layers/PathResolutionLive.js +1 -2
- package/layers/PerClientSessionMapLive.js +1 -2
- package/layers/ProjectDiscoveryLive.js +1 -2
- package/layers/ProjectDiscoveryTest.js +1 -2
- package/layers/ProjectIdentityLive.js +1 -2
- package/layers/RunContextLive.js +1 -2
- package/lib/format-triage.js +1 -2
- package/lib/format-wrapup.js +1 -2
- package/migrations/0001_initial.js +1 -2
- package/migrations/0002_test_artifacts.js +1 -2
- package/migrations/index.js +1 -2
- package/migrations/registry_0001_initial.js +1 -2
- package/migrations/session_map_0001_initial.js +1 -2
- package/package.json +18 -18
- package/platform.js +4 -4
- package/programs/end-agent.js +1 -2
- package/programs/hook-paths.js +1 -2
- package/programs/platform-sidecar.js +1 -2
- package/programs/record-session.js +1 -2
- package/programs/record-tdd-artifact.js +1 -2
- package/programs/record-turn.js +1 -2
- package/programs/record-workspace-changes.js +1 -2
- package/programs/register-agent.js +1 -2
- package/programs/resolve-session-for-recording.js +1 -2
- package/programs/session-env.js +1 -2
- package/project-dir.js +1 -2
- package/services/Config.js +1 -2
- package/services/DataReader.js +1 -2
- package/services/DataStore.js +1 -2
- package/services/DetailResolver.js +1 -2
- package/services/DiscoveryRegistry.js +1 -2
- package/services/EnvironmentDetector.js +1 -2
- package/services/ExecutorResolver.js +1 -2
- package/services/HistoryTracker.js +1 -2
- package/services/PerClientSessionMap.js +1 -2
- package/services/ProjectDiscovery.js +1 -2
- package/services/ProjectIdentity.js +1 -2
- package/services/RunContext.js +1 -2
- package/services/idempotency.js +1 -2
- package/sql/assemblers.js +1 -2
- package/stores.js +1 -2
- package/testing/layers.js +1 -2
- package/testing.d.ts +0 -12
- package/testing.js +1 -2
- package/utils/ensure-migrated.js +1 -2
- package/utils/failure-signature.js +1 -2
- package/utils/persist-transaction.js +84 -0
- package/utils/resolve-data-path.js +1 -2
- package/utils/resolve-project-key-from-cwd.js +1 -2
- package/utils/resolve-workspace-key.js +1 -2
- package/version.js +2 -3
package/index.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ import { SqliteClient } from "@effect/sql-sqlite-node/SqliteClient";
|
|
|
11
11
|
import { StoreError, StoreMigrationError } from "@effected/store";
|
|
12
12
|
import { SqlError } from "effect/sql/SqlError";
|
|
13
13
|
import { PlatformError } from "effect/PlatformError";
|
|
14
|
-
//#region src/services/Config.d.ts
|
|
15
14
|
/**
|
|
16
15
|
* Service shape that `ConfigLive(projectDir)` provides to downstream
|
|
17
16
|
* consumers. Re-exported so callers can spell out the concrete service
|
|
@@ -29,8 +28,6 @@ declare const VitestAgentConfigFile_base: import("effect/Context").ServiceClass<
|
|
|
29
28
|
* @public
|
|
30
29
|
*/
|
|
31
30
|
export declare class VitestAgentConfigFile extends VitestAgentConfigFile_base {}
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/layers/ConfigLive.d.ts
|
|
34
31
|
/**
|
|
35
32
|
* Build the live `ConfigFile` layer for a given project directory.
|
|
36
33
|
*
|
|
@@ -50,8 +47,6 @@ export declare class VitestAgentConfigFile extends VitestAgentConfigFile_base {}
|
|
|
50
47
|
* @public
|
|
51
48
|
*/
|
|
52
49
|
export declare const ConfigLive: (projectDir: string) => Layer.Layer<VitestAgentConfigFile, never, FileSystem.FileSystem | Path.Path>;
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region src/services/DataStore.d.ts
|
|
55
50
|
/** @public */
|
|
56
51
|
export interface CreateGoalInput {
|
|
57
52
|
readonly tddTaskId: number;
|
|
@@ -583,8 +578,6 @@ declare const DataStore_base: Context.ServiceClass<DataStore, "vitest-agent/Data
|
|
|
583
578
|
}>;
|
|
584
579
|
/** @public */
|
|
585
580
|
export declare class DataStore extends DataStore_base {}
|
|
586
|
-
//#endregion
|
|
587
|
-
//#region src/services/DataReader.d.ts
|
|
588
581
|
/** @public */
|
|
589
582
|
export interface ProjectRunSummary {
|
|
590
583
|
readonly project: string;
|
|
@@ -1114,16 +1107,10 @@ declare const DataReader_base: Context.ServiceClass<DataReader, "vitest-agent/Da
|
|
|
1114
1107
|
}>;
|
|
1115
1108
|
/** @public */
|
|
1116
1109
|
export declare class DataReader extends DataReader_base {}
|
|
1117
|
-
//#endregion
|
|
1118
|
-
//#region src/layers/DataReaderLive.d.ts
|
|
1119
1110
|
/** @public */
|
|
1120
1111
|
export declare const DataReaderLive: Layer.Layer<DataReader, never, SqlClient>;
|
|
1121
|
-
//#endregion
|
|
1122
|
-
//#region src/layers/DataStoreLive.d.ts
|
|
1123
1112
|
/** @public */
|
|
1124
1113
|
export declare const DataStoreLive: Layer.Layer<DataStore, never, SqlClient>;
|
|
1125
|
-
//#endregion
|
|
1126
|
-
//#region src/services/DetailResolver.d.ts
|
|
1127
1114
|
/** @public */
|
|
1128
1115
|
export interface RunHealth {
|
|
1129
1116
|
readonly hasFailures: boolean;
|
|
@@ -1135,12 +1122,8 @@ declare const DetailResolver_base: Context.ServiceClass<DetailResolver, "vitest-
|
|
|
1135
1122
|
}>;
|
|
1136
1123
|
/** @public */
|
|
1137
1124
|
export declare class DetailResolver extends DetailResolver_base {}
|
|
1138
|
-
//#endregion
|
|
1139
|
-
//#region src/layers/DetailResolverLive.d.ts
|
|
1140
1125
|
/** @public */
|
|
1141
1126
|
export declare const DetailResolverLive: Layer.Layer<DetailResolver, never, never>;
|
|
1142
|
-
//#endregion
|
|
1143
|
-
//#region src/services/DiscoveryRegistry.d.ts
|
|
1144
1127
|
/**
|
|
1145
1128
|
* Input for upserting a known project into the global discovery registry.
|
|
1146
1129
|
*
|
|
@@ -1188,12 +1171,8 @@ declare const DiscoveryRegistry_base: Context.ServiceClass<DiscoveryRegistry, "v
|
|
|
1188
1171
|
}>;
|
|
1189
1172
|
/** @public */
|
|
1190
1173
|
export declare class DiscoveryRegistry extends DiscoveryRegistry_base {}
|
|
1191
|
-
//#endregion
|
|
1192
|
-
//#region src/layers/DiscoveryRegistryLive.d.ts
|
|
1193
1174
|
/** @public */
|
|
1194
1175
|
export declare const DiscoveryRegistryLive: Layer.Layer<DiscoveryRegistry, never, SqlClient>;
|
|
1195
|
-
//#endregion
|
|
1196
|
-
//#region src/services/EnvironmentDetector.d.ts
|
|
1197
1176
|
declare const EnvironmentDetector_base: Context.ServiceClass<EnvironmentDetector, "vitest-agent/EnvironmentDetector", {
|
|
1198
1177
|
readonly detect: () => Effect.Effect<Environment>;
|
|
1199
1178
|
readonly isAgent: Effect.Effect<boolean>;
|
|
@@ -1201,8 +1180,6 @@ declare const EnvironmentDetector_base: Context.ServiceClass<EnvironmentDetector
|
|
|
1201
1180
|
}>;
|
|
1202
1181
|
/** @public */
|
|
1203
1182
|
export declare class EnvironmentDetector extends EnvironmentDetector_base {}
|
|
1204
|
-
//#endregion
|
|
1205
|
-
//#region src/layers/EnvironmentDetectorLive.d.ts
|
|
1206
1183
|
/**
|
|
1207
1184
|
* Pure classification behind {@link EnvironmentDetectorLive}: an agent shell
|
|
1208
1185
|
* wins, then GitHub Actions, then generic CI, else a terminal.
|
|
@@ -1230,25 +1207,17 @@ export declare const classifyEnvironment: (runtime: RuntimeEnv) => Environment;
|
|
|
1230
1207
|
* @public
|
|
1231
1208
|
*/
|
|
1232
1209
|
export declare const EnvironmentDetectorLive: (env: Record<string, string | undefined>) => Layer.Layer<EnvironmentDetector>;
|
|
1233
|
-
//#endregion
|
|
1234
|
-
//#region src/layers/EnvironmentDetectorTest.d.ts
|
|
1235
1210
|
/** @public */
|
|
1236
1211
|
export declare const EnvironmentDetectorTest: {
|
|
1237
1212
|
layer: (env?: Environment) => Layer.Layer<EnvironmentDetector, never, never>;
|
|
1238
1213
|
};
|
|
1239
|
-
//#endregion
|
|
1240
|
-
//#region src/services/ExecutorResolver.d.ts
|
|
1241
1214
|
declare const ExecutorResolver_base: Context.ServiceClass<ExecutorResolver, "vitest-agent/ExecutorResolver", {
|
|
1242
1215
|
readonly resolve: (env: Environment) => Effect.Effect<Executor>;
|
|
1243
1216
|
}>;
|
|
1244
1217
|
/** @public */
|
|
1245
1218
|
export declare class ExecutorResolver extends ExecutorResolver_base {}
|
|
1246
|
-
//#endregion
|
|
1247
|
-
//#region src/layers/ExecutorResolverLive.d.ts
|
|
1248
1219
|
/** @public */
|
|
1249
1220
|
export declare const ExecutorResolverLive: Layer.Layer<ExecutorResolver, never, never>;
|
|
1250
|
-
//#endregion
|
|
1251
|
-
//#region src/services/HistoryTracker.d.ts
|
|
1252
1221
|
/**
|
|
1253
1222
|
* Lightweight test outcome for history classification.
|
|
1254
1223
|
* @public
|
|
@@ -1278,12 +1247,8 @@ declare const HistoryTracker_base: Context.ServiceClass<HistoryTracker, "vitest-
|
|
|
1278
1247
|
}>;
|
|
1279
1248
|
/** @public */
|
|
1280
1249
|
export declare class HistoryTracker extends HistoryTracker_base {}
|
|
1281
|
-
//#endregion
|
|
1282
|
-
//#region src/layers/HistoryTrackerLive.d.ts
|
|
1283
1250
|
/** @public */
|
|
1284
1251
|
export declare const HistoryTrackerLive: Layer.Layer<HistoryTracker, never, DataReader>;
|
|
1285
|
-
//#endregion
|
|
1286
|
-
//#region src/layers/HistoryTrackerTest.d.ts
|
|
1287
1252
|
/** @public */
|
|
1288
1253
|
export interface HistoryTrackerTestState {
|
|
1289
1254
|
readonly classifyCalls: Array<{
|
|
@@ -1299,8 +1264,6 @@ export declare const HistoryTrackerTest: {
|
|
|
1299
1264
|
classifications: Map<string, TestClassification>;
|
|
1300
1265
|
}) => Layer.Layer<HistoryTracker>;
|
|
1301
1266
|
};
|
|
1302
|
-
//#endregion
|
|
1303
|
-
//#region src/layers/LoggerLive.d.ts
|
|
1304
1267
|
/**
|
|
1305
1268
|
* Create a structured JSON (NDJSON) logger layer for stderr, over
|
|
1306
1269
|
* `@effected/cli`'s `CliLog` in its diagnostics-only mode
|
|
@@ -1349,8 +1312,6 @@ export declare function resolveLogLevel(env: Record<string, string | undefined>,
|
|
|
1349
1312
|
* @public
|
|
1350
1313
|
*/
|
|
1351
1314
|
export declare function resolveLogFile(env: Record<string, string | undefined>, option?: string): string | undefined;
|
|
1352
|
-
//#endregion
|
|
1353
|
-
//#region src/layers/OutputPipelineLive.d.ts
|
|
1354
1315
|
/**
|
|
1355
1316
|
* The output pipeline: environment detection, executor resolution and detail
|
|
1356
1317
|
* resolution.
|
|
@@ -1360,8 +1321,6 @@ export declare function resolveLogFile(env: Record<string, string | undefined>,
|
|
|
1360
1321
|
* @public
|
|
1361
1322
|
*/
|
|
1362
1323
|
export declare const OutputPipelineLive: (env: Record<string, string | undefined>) => Layer.Layer<DetailResolver | EnvironmentDetector | ExecutorResolver, never, never>;
|
|
1363
|
-
//#endregion
|
|
1364
|
-
//#region src/layers/PathResolutionLive.d.ts
|
|
1365
1324
|
/**
|
|
1366
1325
|
* The XDG namespace every vitest-agent data directory lives under —
|
|
1367
1326
|
* `<XDG data>/vitest-agent`. The one place the name exists.
|
|
@@ -1398,8 +1357,6 @@ export declare const DATA_FALLBACK_DIR = ".local/share/vitest-agent";
|
|
|
1398
1357
|
* @public
|
|
1399
1358
|
*/
|
|
1400
1359
|
export declare const PathResolutionLive: (projectDir: string) => Layer.Layer<AppDirs | VitestAgentConfigFile | WorkspaceDiscovery, import("@effected/xdg").XdgEnvError, import("effect/FileSystem").FileSystem | import("effect/Path").Path>;
|
|
1401
|
-
//#endregion
|
|
1402
|
-
//#region src/services/PerClientSessionMap.d.ts
|
|
1403
1360
|
/** @public */
|
|
1404
1361
|
export interface MapSessionInput {
|
|
1405
1362
|
readonly hostSessionId: string;
|
|
@@ -1483,8 +1440,6 @@ declare const PerClientSessionMapWriter_base: Context.ServiceClass<PerClientSess
|
|
|
1483
1440
|
* @public
|
|
1484
1441
|
*/
|
|
1485
1442
|
export declare class PerClientSessionMapWriter extends PerClientSessionMapWriter_base {}
|
|
1486
|
-
//#endregion
|
|
1487
|
-
//#region src/layers/PerClientSessionMapLive.d.ts
|
|
1488
1443
|
/**
|
|
1489
1444
|
* Read-only layer. The entry point provides an `SqlClient` configured
|
|
1490
1445
|
* with the `?mode=ro` URI parameter; this layer wraps the read
|
|
@@ -1499,8 +1454,6 @@ export declare const PerClientSessionMapReaderLive: Layer.Layer<PerClientSession
|
|
|
1499
1454
|
* @public
|
|
1500
1455
|
*/
|
|
1501
1456
|
export declare const PerClientSessionMapWriterLive: Layer.Layer<PerClientSessionMapWriter | PerClientSessionMapReader, never, SqlClient>;
|
|
1502
|
-
//#endregion
|
|
1503
|
-
//#region src/services/ProjectDiscovery.d.ts
|
|
1504
1457
|
/** @public */
|
|
1505
1458
|
export interface TestFileEntry {
|
|
1506
1459
|
readonly testFile: string;
|
|
@@ -1512,18 +1465,12 @@ declare const ProjectDiscovery_base: Context.ServiceClass<ProjectDiscovery, "vit
|
|
|
1512
1465
|
}>;
|
|
1513
1466
|
/** @public */
|
|
1514
1467
|
export declare class ProjectDiscovery extends ProjectDiscovery_base {}
|
|
1515
|
-
//#endregion
|
|
1516
|
-
//#region src/layers/ProjectDiscoveryLive.d.ts
|
|
1517
1468
|
/** @public */
|
|
1518
1469
|
export declare const ProjectDiscoveryLive: Layer.Layer<ProjectDiscovery, never, FileSystem.FileSystem>;
|
|
1519
|
-
//#endregion
|
|
1520
|
-
//#region src/layers/ProjectDiscoveryTest.d.ts
|
|
1521
1470
|
/** @public */
|
|
1522
1471
|
export declare const ProjectDiscoveryTest: {
|
|
1523
1472
|
readonly layer: (entries: ReadonlyArray<TestFileEntry>) => Layer.Layer<ProjectDiscovery>;
|
|
1524
1473
|
};
|
|
1525
|
-
//#endregion
|
|
1526
|
-
//#region src/services/ProjectIdentity.d.ts
|
|
1527
1474
|
/**
|
|
1528
1475
|
* Result of a successful identity resolution.
|
|
1529
1476
|
*
|
|
@@ -1590,8 +1537,6 @@ declare const ProjectIdentity_base: Context.ServiceClass<ProjectIdentity, "vites
|
|
|
1590
1537
|
* @public
|
|
1591
1538
|
*/
|
|
1592
1539
|
export declare class ProjectIdentity extends ProjectIdentity_base {}
|
|
1593
|
-
//#endregion
|
|
1594
|
-
//#region src/layers/ProjectIdentityLive.d.ts
|
|
1595
1540
|
/**
|
|
1596
1541
|
* Effect environment type required by `collectCandidates` and the
|
|
1597
1542
|
* `ProjectIdentityLive` layer. Exported only so the layer's
|
|
@@ -1619,8 +1564,6 @@ export declare const ProjectIdentityLive: Layer.Layer<ProjectIdentity, never, Ca
|
|
|
1619
1564
|
* @public
|
|
1620
1565
|
*/
|
|
1621
1566
|
export declare const ProjectIdentityTest: (result: ResolvedIdentity | ProjectIdentityNotResolvableError) => Layer.Layer<ProjectIdentity, never, never>;
|
|
1622
|
-
//#endregion
|
|
1623
|
-
//#region src/services/RunContext.d.ts
|
|
1624
1567
|
declare const RunContext_base: Schema.Class<RunContext, Schema.Struct<{
|
|
1625
1568
|
readonly gitBranch: Schema.NullOr<Schema.String>;
|
|
1626
1569
|
readonly gitCommitSha: Schema.NullOr<Schema.String>;
|
|
@@ -1676,8 +1619,6 @@ export declare class RunContext$ extends RunContext$_base {}
|
|
|
1676
1619
|
export declare const RunContextService: typeof RunContext$;
|
|
1677
1620
|
/** @public */
|
|
1678
1621
|
export type RunContextService = RunContext$;
|
|
1679
|
-
//#endregion
|
|
1680
|
-
//#region src/layers/RunContextLive.d.ts
|
|
1681
1622
|
/**
|
|
1682
1623
|
* Live layer. Requires `ChildProcessSpawner` (provided by
|
|
1683
1624
|
* `NodeServices.layer` at the entry point). Host-metadata probes read
|
|
@@ -1697,8 +1638,6 @@ export declare const RunContextTest: (fixture: {
|
|
|
1697
1638
|
readonly runContext: RunContext;
|
|
1698
1639
|
readonly agentContext: AgentContext;
|
|
1699
1640
|
}) => Layer.Layer<RunContextService, never, never>;
|
|
1700
|
-
//#endregion
|
|
1701
|
-
//#region src/lib/format-triage.d.ts
|
|
1702
1641
|
/** @public */
|
|
1703
1642
|
interface FormatTriageOptions {
|
|
1704
1643
|
readonly project?: string;
|
|
@@ -1714,8 +1653,6 @@ interface FormatTriageOptions {
|
|
|
1714
1653
|
* @public
|
|
1715
1654
|
*/
|
|
1716
1655
|
export declare const formatTriageEffect: (options?: FormatTriageOptions) => Effect.Effect<string, never, DataReader>;
|
|
1717
|
-
//#endregion
|
|
1718
|
-
//#region src/lib/format-wrapup.d.ts
|
|
1719
1656
|
/** @public */
|
|
1720
1657
|
type WrapupKind = "stop" | "session_end" | "pre_compact" | "tdd_handoff" | "user_prompt_nudge";
|
|
1721
1658
|
/** @public */
|
|
@@ -1727,16 +1664,10 @@ interface FormatWrapupOptions {
|
|
|
1727
1664
|
}
|
|
1728
1665
|
/** @public */
|
|
1729
1666
|
export declare const formatWrapupEffect: (options: FormatWrapupOptions) => Effect.Effect<string, never, DataReader>;
|
|
1730
|
-
//#endregion
|
|
1731
|
-
//#region src/migrations/0001_initial.d.ts
|
|
1732
1667
|
/** @internal */
|
|
1733
1668
|
declare const migration: Effect.Effect<void, import("effect/sql/SqlError").SqlError, SqlClient>;
|
|
1734
|
-
//#endregion
|
|
1735
|
-
//#region src/migrations/0002_test_artifacts.d.ts
|
|
1736
1669
|
/** @internal */
|
|
1737
1670
|
declare const migration$1: Effect.Effect<void, import("effect/sql/SqlError").SqlError, SqlClient>;
|
|
1738
|
-
//#endregion
|
|
1739
|
-
//#region src/migrations/index.d.ts
|
|
1740
1671
|
/**
|
|
1741
1672
|
* Every migration that must run against a per-project `data.db`, keyed by
|
|
1742
1673
|
* migration id in application order.
|
|
@@ -1758,8 +1689,6 @@ export declare const PROJECT_MIGRATIONS: {
|
|
|
1758
1689
|
readonly "0001_initial": import("effect/Effect").Effect<void, import("effect/sql/SqlError").SqlError, import("effect/sql/SqlClient").SqlClient>;
|
|
1759
1690
|
readonly "0002_test_artifacts": import("effect/Effect").Effect<void, import("effect/sql/SqlError").SqlError, import("effect/sql/SqlClient").SqlClient>;
|
|
1760
1691
|
};
|
|
1761
|
-
//#endregion
|
|
1762
|
-
//#region src/migrations/registry_0001_initial.d.ts
|
|
1763
1692
|
/**
|
|
1764
1693
|
* Migration for the global discovery registry SQLite at
|
|
1765
1694
|
* `$XDG_DATA_HOME/vitest-agent/registry.db`.
|
|
@@ -1775,12 +1704,8 @@ export declare const PROJECT_MIGRATIONS: {
|
|
|
1775
1704
|
* @public
|
|
1776
1705
|
*/
|
|
1777
1706
|
declare const migration$2: Effect.Effect<void, import("effect/sql/SqlError").SqlError, SqlClient>;
|
|
1778
|
-
//#endregion
|
|
1779
|
-
//#region src/migrations/session_map_0001_initial.d.ts
|
|
1780
1707
|
/** @internal */
|
|
1781
1708
|
declare const migration$3: Effect.Effect<void, import("effect/sql/SqlError").SqlError, SqlClient>;
|
|
1782
|
-
//#endregion
|
|
1783
|
-
//#region src/stores.d.ts
|
|
1784
1709
|
/**
|
|
1785
1710
|
* A migration set in the effect/sql record shape: `"<id>_<name>"` →
|
|
1786
1711
|
* migration. The keys are the ones a 2.x `SqliteMigrator.fromRecord` recorded
|
|
@@ -1788,8 +1713,6 @@ declare const migration$3: Effect.Effect<void, import("effect/sql/SqlError").Sql
|
|
|
1788
1713
|
* @public
|
|
1789
1714
|
*/
|
|
1790
1715
|
type MigrationRecord = Record<string, Effect.Effect<void, SqlError, SqlClient>>;
|
|
1791
|
-
//#endregion
|
|
1792
|
-
//#region src/platform.d.ts
|
|
1793
1716
|
/**
|
|
1794
1717
|
* A SQLite connection plus the migrator that brings it to the head of a
|
|
1795
1718
|
* migration set. Returned by {@link makeSqliteStack}.
|
|
@@ -1876,8 +1799,6 @@ export type PlatformServices = DataReader | DataStore | ProjectDiscovery | Histo
|
|
|
1876
1799
|
* @public
|
|
1877
1800
|
*/
|
|
1878
1801
|
export declare const PlatformLive: (options: PlatformOptions) => Layer.Layer<PlatformServices, PlatformLiveError>;
|
|
1879
|
-
//#endregion
|
|
1880
|
-
//#region src/programs/end-agent.d.ts
|
|
1881
1802
|
/**
|
|
1882
1803
|
* Input for {@link endAgentEffect}: which `agents` row to close and when.
|
|
1883
1804
|
*
|
|
@@ -1902,8 +1823,6 @@ export interface EndAgentInput {
|
|
|
1902
1823
|
* @public
|
|
1903
1824
|
*/
|
|
1904
1825
|
export declare const endAgentEffect: (input: EndAgentInput) => Effect.Effect<void, import("@vitest-agent/sdk").AgentNotFoundError | import("@vitest-agent/sdk").DataStoreError, DataStore | PerClientSessionMapWriter>;
|
|
1905
|
-
//#endregion
|
|
1906
|
-
//#region src/programs/hook-paths.d.ts
|
|
1907
1826
|
/**
|
|
1908
1827
|
* Filename of the per-project test-data SQLite database.
|
|
1909
1828
|
*
|
|
@@ -1997,8 +1916,6 @@ export declare const resolveHookPaths: (input: {
|
|
|
1997
1916
|
readonly env: HookEnv;
|
|
1998
1917
|
readonly projectKey: string;
|
|
1999
1918
|
}) => Effect.Effect<HookPaths, HookPathsError, FileSystem.FileSystem | Path.Path>;
|
|
2000
|
-
//#endregion
|
|
2001
|
-
//#region src/programs/platform-sidecar.d.ts
|
|
2002
1919
|
/**
|
|
2003
1920
|
* SQLite database paths consumed by {@link SidecarPlatformLive}.
|
|
2004
1921
|
* Structurally a subset of `HookPaths` from `resolveHookPaths`, so the
|
|
@@ -2028,8 +1945,6 @@ export interface SidecarPaths {
|
|
|
2028
1945
|
* @public
|
|
2029
1946
|
*/
|
|
2030
1947
|
export declare const SidecarPlatformLive: (paths: SidecarPaths, env: Record<string, string | undefined>) => Layer.Layer<DataReader | DataStore | DiscoveryRegistry | PerClientSessionMapReader | PerClientSessionMapWriter | RunContext$ | import("@effect/platform-node/NodeServices").NodeServices, PlatformLiveError, never>;
|
|
2031
|
-
//#endregion
|
|
2032
|
-
//#region src/programs/record-session.d.ts
|
|
2033
1948
|
/**
|
|
2034
1949
|
* Input for {@link recordSessionStart}: the identity of the session row to upsert.
|
|
2035
1950
|
*
|
|
@@ -2087,8 +2002,6 @@ export interface RecordSessionEndInput {
|
|
|
2087
2002
|
export declare const recordSessionEnd: (input: RecordSessionEndInput) => Effect.Effect<{
|
|
2088
2003
|
ok: true;
|
|
2089
2004
|
}, Error, DataReader | DataStore>;
|
|
2090
|
-
//#endregion
|
|
2091
|
-
//#region src/programs/record-tdd-artifact.d.ts
|
|
2092
2005
|
/**
|
|
2093
2006
|
* Input for {@link recordTddArtifactEffect}: an artifact keyed by the host
|
|
2094
2007
|
* chat id, resolved to the open TDD task under that session.
|
|
@@ -2230,8 +2143,6 @@ export interface DispatchRecordTddArtifactInput {
|
|
|
2230
2143
|
* @public
|
|
2231
2144
|
*/
|
|
2232
2145
|
export declare const dispatchRecordTddArtifactEffect: (input: DispatchRecordTddArtifactInput) => Effect.Effect<RecordTddArtifactResult, DataStoreError | Error, DataReader | DataStore | FileSystem.FileSystem>;
|
|
2233
|
-
//#endregion
|
|
2234
|
-
//#region src/programs/record-turn.d.ts
|
|
2235
2146
|
/**
|
|
2236
2147
|
* Outcome of {@link parseAndValidateTurnPayload}: the decoded `TurnPayload`
|
|
2237
2148
|
* on success, or a human-readable error string.
|
|
@@ -2292,8 +2203,6 @@ export interface RecordTurnInput {
|
|
|
2292
2203
|
export declare const recordTurnEffect: (input: RecordTurnInput) => Effect.Effect<{
|
|
2293
2204
|
turnId: number;
|
|
2294
2205
|
}, Error, DataReader | DataStore | FileSystem.FileSystem>;
|
|
2295
|
-
//#endregion
|
|
2296
|
-
//#region src/programs/record-workspace-changes.d.ts
|
|
2297
2206
|
/**
|
|
2298
2207
|
* Input for {@link recordRunWorkspaceChangesEffect}: one commit plus the
|
|
2299
2208
|
* files it touched.
|
|
@@ -2340,8 +2249,6 @@ export interface RecordWorkspaceChangesResult {
|
|
|
2340
2249
|
* @public
|
|
2341
2250
|
*/
|
|
2342
2251
|
export declare const recordRunWorkspaceChangesEffect: (input: RecordWorkspaceChangesInput) => Effect.Effect<RecordWorkspaceChangesResult, DataStoreError, DataStore | SqlClient>;
|
|
2343
|
-
//#endregion
|
|
2344
|
-
//#region src/programs/register-agent.d.ts
|
|
2345
2252
|
/**
|
|
2346
2253
|
* Input for the end-to-end agent registration effect.
|
|
2347
2254
|
*
|
|
@@ -2399,8 +2306,6 @@ export declare const registerAgentEffect: (input: RegisterAgentProgramInput) =>
|
|
|
2399
2306
|
idempotencyKey: string;
|
|
2400
2307
|
idempotencyHit: boolean;
|
|
2401
2308
|
}, import("@vitest-agent/sdk").DataStoreError | import("@vitest-agent/sdk").RegistrationConflictError, DataReader | DataStore | PerClientSessionMapWriter | RunContext$>;
|
|
2402
|
-
//#endregion
|
|
2403
|
-
//#region src/programs/resolve-session-for-recording.d.ts
|
|
2404
2309
|
/**
|
|
2405
2310
|
* Input for {@link resolveSessionForRecording}.
|
|
2406
2311
|
*
|
|
@@ -2433,8 +2338,6 @@ export interface ResolveSessionForRecordingInput {
|
|
|
2433
2338
|
* @public
|
|
2434
2339
|
*/
|
|
2435
2340
|
export declare const resolveSessionForRecording: (input: ResolveSessionForRecordingInput) => Effect.Effect<SessionDetail, DataStoreError, DataReader | DataStore | FileSystem.FileSystem>;
|
|
2436
|
-
//#endregion
|
|
2437
|
-
//#region src/programs/session-env.d.ts
|
|
2438
2341
|
/**
|
|
2439
2342
|
* Recovered session attribution context — the canonical UUIDs the
|
|
2440
2343
|
* SessionStart hook wrote to `${CLAUDE_ENV_FILE}` (auto-sourced into the
|
|
@@ -2500,8 +2403,6 @@ export declare const recoverSessionContextFromSessionEnv: (opts: {
|
|
|
2500
2403
|
readonly homeDir: string;
|
|
2501
2404
|
readonly fileSystem?: SessionEnvFileSystem;
|
|
2502
2405
|
}) => SessionContext | null;
|
|
2503
|
-
//#endregion
|
|
2504
|
-
//#region src/project-dir.d.ts
|
|
2505
2406
|
/**
|
|
2506
2407
|
* Resolve the project directory the front ends anchor on.
|
|
2507
2408
|
*
|
|
@@ -2520,8 +2421,6 @@ export declare const resolveProjectDir: (input: {
|
|
|
2520
2421
|
readonly env: Record<string, string | undefined>;
|
|
2521
2422
|
readonly cwd: string;
|
|
2522
2423
|
}) => string;
|
|
2523
|
-
//#endregion
|
|
2524
|
-
//#region src/services/idempotency.d.ts
|
|
2525
2424
|
/**
|
|
2526
2425
|
* Sentinel substituted for `parentAgentId` when the value is `null`.
|
|
2527
2426
|
* Avoids ambiguity around hashing the literal string "null" or empty
|
|
@@ -2550,8 +2449,6 @@ export interface IdempotencyInput {
|
|
|
2550
2449
|
* @public
|
|
2551
2450
|
*/
|
|
2552
2451
|
export declare const deriveIdempotencyKey: (input: IdempotencyInput) => string;
|
|
2553
|
-
//#endregion
|
|
2554
|
-
//#region src/sql/assemblers.d.ts
|
|
2555
2452
|
/**
|
|
2556
2453
|
* Minimal shape of a test_runs aggregation row used to build the manifest.
|
|
2557
2454
|
* @public
|
|
@@ -2611,8 +2508,6 @@ export declare function assembleManifest(rows: ManifestRow[], dbPath: string): C
|
|
|
2611
2508
|
* @public
|
|
2612
2509
|
*/
|
|
2613
2510
|
export declare function assembleHistoryRecord(rows: HistoryRow[]): AssembledHistoryRecord;
|
|
2614
|
-
//#endregion
|
|
2615
|
-
//#region src/utils/ensure-migrated.d.ts
|
|
2616
2511
|
/**
|
|
2617
2512
|
* Ensure the SQLite database at `dbPath` is migrated. Runs migrations at
|
|
2618
2513
|
* most once per dbPath in the current process; concurrent calls share the
|
|
@@ -2633,8 +2528,6 @@ export declare function ensureMigrated(dbPath: string, logLevel?: LogLevel.LogLe
|
|
|
2633
2528
|
* @internal
|
|
2634
2529
|
*/
|
|
2635
2530
|
export declare function _resetMigrationCacheForTesting(): void;
|
|
2636
|
-
//#endregion
|
|
2637
|
-
//#region src/utils/failure-signature.d.ts
|
|
2638
2531
|
/** @public */
|
|
2639
2532
|
export interface FailureSignatureInput {
|
|
2640
2533
|
readonly error_name: string;
|
|
@@ -2647,8 +2540,33 @@ export interface FailureSignatureInput {
|
|
|
2647
2540
|
export declare const normalizeAssertionShape: (message: string) => string | null;
|
|
2648
2541
|
/** @public */
|
|
2649
2542
|
export declare const computeFailureSignature: (input: FailureSignatureInput) => string;
|
|
2650
|
-
|
|
2651
|
-
|
|
2543
|
+
/**
|
|
2544
|
+
* Run `effect` as one SQLite write transaction on the `data.db` connection:
|
|
2545
|
+
* every `DataStore` write inside it commits together or not at all, and a
|
|
2546
|
+
* failure rolls the whole block back before the error propagates.
|
|
2547
|
+
*
|
|
2548
|
+
* Built for the reporter's run-end persist phase, where per-statement
|
|
2549
|
+
* autocommits (one fsync each) dominated wall time. Inside the block
|
|
2550
|
+
* `DataStoreLive` caches tag and file ids and defers `writeHistory`'s
|
|
2551
|
+
* keep-10 prune to one statement per run, executed before commit; the
|
|
2552
|
+
* persisted rows are the same as without the block.
|
|
2553
|
+
*
|
|
2554
|
+
* The fiber does not yield to the scheduler while the block runs. node:sqlite
|
|
2555
|
+
* is synchronous, so the whole transaction executes in one turn of the event
|
|
2556
|
+
* loop: a second connection in the same process (another project's reporter,
|
|
2557
|
+
* or the MCP server's own connection while it runs Vitest in-process) can
|
|
2558
|
+
* neither interleave a write nor block the thread in SQLite's busy handler
|
|
2559
|
+
* while this connection holds the write lock. Keep `effect` free of
|
|
2560
|
+
* genuinely asynchronous work for that reason; CPU-heavy work that needs no
|
|
2561
|
+
* database belongs before the block.
|
|
2562
|
+
*
|
|
2563
|
+
* Nested `withTransaction` calls inside `effect` become savepoints. A
|
|
2564
|
+
* `DataReader` query inside it runs on the transaction's connection.
|
|
2565
|
+
*
|
|
2566
|
+
* @param effect - the writes (and the reads they depend on) to run atomically
|
|
2567
|
+
* @public
|
|
2568
|
+
*/
|
|
2569
|
+
export declare const withPersistTransaction: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | DataStoreError, R | SqlClient>;
|
|
2652
2570
|
/**
|
|
2653
2571
|
* Filename of the SQLite database that stores all reporter data.
|
|
2654
2572
|
* @public
|
|
@@ -2699,8 +2617,6 @@ export interface ResolveDataPathOptions {
|
|
|
2699
2617
|
* @public
|
|
2700
2618
|
*/
|
|
2701
2619
|
export declare const resolveDataPath: (projectDir: string, options?: ResolveDataPathOptions) => Effect.Effect<any, import("@effected/xdg").AppDirsError | import("effect/PlatformError").PlatformError | import("@effected/config-file").ConfigReadError, AppDirs | FileSystem.FileSystem | VitestAgentConfigFile>;
|
|
2702
|
-
//#endregion
|
|
2703
|
-
//#region src/utils/resolve-project-key-from-cwd.d.ts
|
|
2704
2620
|
/**
|
|
2705
2621
|
* Compute the project key for a workspace by reading `package.json`
|
|
2706
2622
|
* fields directly. Returns the canonical `host__path` form when a git
|
|
@@ -2729,8 +2645,6 @@ export declare const resolveProjectKeyFromCwd: (cwd: string) => string;
|
|
|
2729
2645
|
* @public
|
|
2730
2646
|
*/
|
|
2731
2647
|
export declare const resolveProjectKeyFromCwdEffect: (cwd: string) => Effect.Effect<string, never, FileSystem.FileSystem>;
|
|
2732
|
-
//#endregion
|
|
2733
|
-
//#region src/utils/resolve-workspace-key.d.ts
|
|
2734
2648
|
/**
|
|
2735
2649
|
* Resolve the normalized workspace key for the workspace containing
|
|
2736
2650
|
* `projectDir`.
|
|
@@ -2757,10 +2671,7 @@ export declare const resolveProjectKeyFromCwdEffect: (cwd: string) => Effect.Eff
|
|
|
2757
2671
|
* @public
|
|
2758
2672
|
*/
|
|
2759
2673
|
export declare const resolveWorkspaceKey: (projectDir: string) => Effect.Effect<string, WorkspaceRootNotFoundError | WorkspaceDiscoveryFailure, WorkspaceDiscovery>;
|
|
2760
|
-
//#endregion
|
|
2761
|
-
//#region src/version.d.ts
|
|
2762
2674
|
/** Build-time injected package version (see architecture.md D36). @public */
|
|
2763
2675
|
export declare const CURRENT_ENGINE_VERSION: string;
|
|
2764
|
-
//#endregion
|
|
2765
2676
|
export { type ArtifactKind, type ArtifactSuite, type FormatTriageOptions, type FormatWrapupOptions, type MigrationRecord, type Phase, type WrapupKind, migration as migration0001, migration$1 as migration0002, migration$2 as registryMigration0001, migration$3 as sessionMapMigration0001 };
|
|
2766
2677
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { DataReader } from "./services/DataReader.js";
|
|
|
4
4
|
import { HistoryTracker, historyKey } from "./services/HistoryTracker.js";
|
|
5
5
|
import { DataReaderLive } from "./layers/DataReaderLive.js";
|
|
6
6
|
import { DataStore, INLINE_ATTACHMENT_BODY_CAP_BYTES } from "./services/DataStore.js";
|
|
7
|
+
import { withPersistTransaction } from "./utils/persist-transaction.js";
|
|
7
8
|
import { DataStoreLive } from "./layers/DataStoreLive.js";
|
|
8
9
|
import { DetailResolver } from "./services/DetailResolver.js";
|
|
9
10
|
import { DetailResolverLive } from "./layers/DetailResolverLive.js";
|
|
@@ -56,4 +57,4 @@ import { DATABASE_FILENAME, resolveDataPath } from "./utils/resolve-data-path.js
|
|
|
56
57
|
import { resolveWorkspaceKey } from "./utils/resolve-workspace-key.js";
|
|
57
58
|
import { CURRENT_ENGINE_VERSION } from "./version.js";
|
|
58
59
|
|
|
59
|
-
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, RunContext, RunContext$, RunContextLive, RunContextService, RunContextTest, SESSIONS_DB_FILENAME, SidecarPlatformLive, VitestAgentConfigFile, _resetMigrationCacheForTesting, assembleHistoryRecord, assembleManifest, classifyEnvironment, computeFailureSignature, deriveIdempotencyKey, dispatchRecordTddArtifactEffect, endAgentEffect, ensureMigrated, formatTriageEffect, formatWrapupEffect, historyKey, makeSqliteStack, migration as migration0001, migration$1 as migration0002, normalizeAssertionShape, parseAndValidateTurnPayload, parseSessionEnvExports, 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 };
|
|
60
|
+
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, RunContext, RunContext$, RunContextLive, RunContextService, RunContextTest, SESSIONS_DB_FILENAME, SidecarPlatformLive, VitestAgentConfigFile, _resetMigrationCacheForTesting, assembleHistoryRecord, assembleManifest, classifyEnvironment, computeFailureSignature, deriveIdempotencyKey, dispatchRecordTddArtifactEffect, endAgentEffect, ensureMigrated, formatTriageEffect, formatWrapupEffect, historyKey, makeSqliteStack, migration as migration0001, migration$1 as migration0002, normalizeAssertionShape, parseAndValidateTurnPayload, parseSessionEnvExports, 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, withPersistTransaction };
|
package/layers/ConfigLive.js
CHANGED
|
@@ -2,7 +2,7 @@ import { VitestAgentConfigFile } from "../services/Config.js";
|
|
|
2
2
|
import { ConfigFile, ConfigResolver, MergeStrategy, TomlCodec } from "@effected/config-file";
|
|
3
3
|
import { VitestAgentConfig } from "@vitest-agent/sdk";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/layers/ConfigLive.ts
|
|
6
6
|
const CONFIG_FILENAME = "vitest-agent.config.toml";
|
|
7
7
|
/**
|
|
8
8
|
* Build the live `ConfigFile` layer for a given project directory.
|
|
@@ -42,5 +42,4 @@ const ConfigLive = (projectDir) => ConfigFile.layer(VitestAgentConfigFile, {
|
|
|
42
42
|
]
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
//#endregion
|
|
46
45
|
export { ConfigLive };
|
package/layers/DataReaderLive.js
CHANGED
|
@@ -4,7 +4,7 @@ import { DataStoreError, extractSqlReason } from "@vitest-agent/sdk";
|
|
|
4
4
|
import { Effect, Layer, Option } from "effect";
|
|
5
5
|
import { SqlClient } from "effect/sql/SqlClient";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/layers/DataReaderLive.ts
|
|
8
8
|
/** @public */
|
|
9
9
|
const DataReaderLive = Layer.effect(DataReader, Effect.gen(function* () {
|
|
10
10
|
const sql = yield* SqlClient;
|
|
@@ -1935,5 +1935,4 @@ function mapNoteRow(row) {
|
|
|
1935
1935
|
};
|
|
1936
1936
|
}
|
|
1937
1937
|
|
|
1938
|
-
//#endregion
|
|
1939
1938
|
export { DataReaderLive };
|
package/layers/DataStoreLive.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { DataStore, INLINE_ATTACHMENT_BODY_CAP_BYTES } from "../services/DataStore.js";
|
|
2
|
+
import { PersistBatch } from "../utils/persist-transaction.js";
|
|
2
3
|
import { Agent, AgentNotFoundError, BehaviorNotFoundError, DataStoreError, GoalNotFoundError, IdempotencyHit, IllegalStatusTransitionError, RegistrationConflictError, TddTaskAlreadyEndedError, TddTaskNotFoundError, coerceErrorText, extractSqlReason } from "@vitest-agent/sdk";
|
|
3
4
|
import { Effect, Layer, Option } from "effect";
|
|
4
5
|
import { SqlClient } from "effect/sql/SqlClient";
|
|
5
6
|
import { Buffer } from "node:buffer";
|
|
6
7
|
import { randomUUID } from "node:crypto";
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
// src/layers/DataStoreLive.ts
|
|
9
10
|
const isLegalLifecycleTransition = (from, to) => {
|
|
10
11
|
if (from === to) return true;
|
|
11
12
|
if (from === "done" || from === "abandoned") return false;
|
|
@@ -37,8 +38,13 @@ const DataStoreLive = Layer.effect(DataStore, Effect.gen(function* () {
|
|
|
37
38
|
yield* sql`PRAGMA foreign_keys=ON`.pipe(Effect.catch(() => Effect.void));
|
|
38
39
|
const ensureFile = (filePath) => Effect.gen(function* () {
|
|
39
40
|
yield* Effect.logDebug("ensureFile").pipe(Effect.annotateLogs({ filePath }));
|
|
41
|
+
const batch = yield* PersistBatch;
|
|
42
|
+
const cached = batch?.fileIds.get(filePath);
|
|
43
|
+
if (cached !== void 0) return cached;
|
|
40
44
|
yield* sql`INSERT OR IGNORE INTO files (path) VALUES (${filePath})`;
|
|
41
|
-
|
|
45
|
+
const rows = yield* sql`SELECT id FROM files WHERE path = ${filePath}`;
|
|
46
|
+
batch?.fileIds.set(filePath, rows[0].id);
|
|
47
|
+
return rows[0].id;
|
|
42
48
|
}).pipe(Effect.annotateLogs("service", "DataStore"), Effect.mapError((e) => new DataStoreError({
|
|
43
49
|
operation: "write",
|
|
44
50
|
table: "files",
|
|
@@ -110,14 +116,19 @@ const DataStoreLive = Layer.effect(DataStore, Effect.gen(function* () {
|
|
|
110
116
|
count: tests.length
|
|
111
117
|
}));
|
|
112
118
|
const ids = [];
|
|
119
|
+
const tagIds = (yield* PersistBatch)?.tagIds ?? /* @__PURE__ */ new Map();
|
|
113
120
|
for (const tc of tests) {
|
|
114
121
|
yield* sql`INSERT INTO test_cases (module_id, suite_id, vitest_id, name, full_name, state, classification, duration, start_time, flaky, slow, retry_count, repeat_count, heap, mode, each, fails, concurrent, shuffle, timeout, skip_note, location_line, location_column, created_turn_id) VALUES (${moduleId}, ${tc.suiteId ?? null}, ${tc.vitestId ?? null}, ${tc.name}, ${tc.fullName}, ${tc.state}, ${tc.classification ?? null}, ${tc.duration ?? null}, ${tc.startTime ?? null}, ${boolToInt(tc.flaky)}, ${boolToInt(tc.slow)}, ${tc.retryCount ?? 0}, ${tc.repeatCount ?? 0}, ${tc.heap ?? null}, ${tc.mode ?? null}, ${boolToInt(tc.each)}, ${boolToInt(tc.fails)}, ${boolToInt(tc.concurrent)}, ${boolToInt(tc.shuffle)}, ${tc.timeout ?? null}, ${tc.skipNote ?? null}, ${tc.locationLine ?? null}, ${tc.locationColumn ?? null}, ${tc.createdTurnId ?? null})`;
|
|
115
122
|
const testCaseId = (yield* sql`SELECT last_insert_rowid() as id`)[0].id;
|
|
116
123
|
ids.push(testCaseId);
|
|
117
124
|
if (tc.tags && tc.tags.length > 0) for (const tag of tc.tags) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
125
|
+
let tagId = tagIds.get(tag);
|
|
126
|
+
if (tagId === void 0) {
|
|
127
|
+
yield* sql`INSERT OR IGNORE INTO tags (name) VALUES (${tag})`;
|
|
128
|
+
tagId = (yield* sql`SELECT id FROM tags WHERE name = ${tag}`)[0]?.id;
|
|
129
|
+
if (tagId !== void 0) tagIds.set(tag, tagId);
|
|
130
|
+
}
|
|
131
|
+
if (tagId !== void 0) yield* sql`INSERT OR IGNORE INTO test_case_tags (test_case_id, tag_id) VALUES (${testCaseId}, ${tagId})`;
|
|
121
132
|
}
|
|
122
133
|
}
|
|
123
134
|
return ids;
|
|
@@ -224,6 +235,11 @@ const DataStoreLive = Layer.effect(DataStore, Effect.gen(function* () {
|
|
|
224
235
|
runId
|
|
225
236
|
}));
|
|
226
237
|
yield* sql`INSERT INTO test_history (run_id, project, module_path, full_name, timestamp, state, duration, flaky, retry_count, error_message) VALUES (${runId}, ${project}, ${modulePath}, ${fullName}, ${timestamp}, ${state}, ${duration}, ${flaky ? 1 : 0}, ${retryCount}, ${errorMessage}) ON CONFLICT(project, module_path, full_name, timestamp) DO UPDATE SET run_id = excluded.run_id, state = excluded.state, duration = excluded.duration, flaky = excluded.flaky, retry_count = excluded.retry_count, error_message = excluded.error_message`;
|
|
238
|
+
const batch = yield* PersistBatch;
|
|
239
|
+
if (batch !== void 0) {
|
|
240
|
+
batch.historyRunIds.add(runId);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
227
243
|
yield* sql`DELETE FROM test_history WHERE id NOT IN (SELECT id FROM test_history WHERE project = ${project} AND module_path = ${modulePath} AND full_name = ${fullName} ORDER BY timestamp DESC LIMIT 10) AND project = ${project} AND module_path = ${modulePath} AND full_name = ${fullName}`;
|
|
228
244
|
}).pipe(Effect.annotateLogs("service", "DataStore"), Effect.mapError((e) => new DataStoreError({
|
|
229
245
|
operation: "write",
|
|
@@ -1279,5 +1295,4 @@ const DataStoreLive = Layer.effect(DataStore, Effect.gen(function* () {
|
|
|
1279
1295
|
};
|
|
1280
1296
|
}));
|
|
1281
1297
|
|
|
1282
|
-
//#endregion
|
|
1283
1298
|
export { DataStoreLive };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { DetailResolver } from "../services/DetailResolver.js";
|
|
2
2
|
import { Effect, Layer } from "effect";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/layers/DetailResolverLive.ts
|
|
5
5
|
/** @public */
|
|
6
6
|
const DetailResolverLive = Layer.succeed(DetailResolver, { resolve: (executor, health, explicit) => Effect.succeed(explicit ?? (executor === "agent" || executor === "ci" ? "verbose" : health.hasFailures ? "verbose" : health.belowTargets ? "standard" : health.hasTargets === false ? "neutral" : "minimal")) });
|
|
7
7
|
|
|
8
|
-
//#endregion
|
|
9
8
|
export { DetailResolverLive };
|
|
@@ -3,7 +3,7 @@ import { DataStoreError, extractSqlReason } from "@vitest-agent/sdk";
|
|
|
3
3
|
import { Effect, Layer } from "effect";
|
|
4
4
|
import { SqlClient } from "effect/sql/SqlClient";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/layers/DiscoveryRegistryLive.ts
|
|
7
7
|
const TABLE = "known_projects";
|
|
8
8
|
const rowToDomain = (row) => ({
|
|
9
9
|
projectKey: row.project_key,
|
|
@@ -66,5 +66,4 @@ const DiscoveryRegistryLive = Layer.effect(DiscoveryRegistry, Effect.gen(functio
|
|
|
66
66
|
};
|
|
67
67
|
}));
|
|
68
68
|
|
|
69
|
-
//#endregion
|
|
70
69
|
export { DiscoveryRegistryLive };
|
|
@@ -2,7 +2,7 @@ import { EnvironmentDetector } from "../services/EnvironmentDetector.js";
|
|
|
2
2
|
import { Effect, Layer, Option } from "effect";
|
|
3
3
|
import { Audience, CurrentRuntimeEnv } from "@effected/env";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/layers/EnvironmentDetectorLive.ts
|
|
6
6
|
/** The engine environment for each CI `@effected/env` names; exhaustive over `CiName`. */
|
|
7
7
|
const CI_ENVIRONMENT = {
|
|
8
8
|
"github-actions": "ci-github",
|
|
@@ -52,5 +52,4 @@ const EnvironmentDetectorLive = (env) => Layer.effect(EnvironmentDetector, Effec
|
|
|
52
52
|
};
|
|
53
53
|
})).pipe(Layer.provide(CurrentRuntimeEnv.layerFrom(env)));
|
|
54
54
|
|
|
55
|
-
//#endregion
|
|
56
55
|
export { EnvironmentDetectorLive, classifyEnvironment };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EnvironmentDetector } from "../services/EnvironmentDetector.js";
|
|
2
2
|
import { Effect, Layer } from "effect";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/layers/EnvironmentDetectorTest.ts
|
|
5
5
|
/** @public */
|
|
6
6
|
const EnvironmentDetectorTest = { layer: (env = "terminal") => Layer.succeed(EnvironmentDetector, {
|
|
7
7
|
detect: () => Effect.succeed(env),
|
|
@@ -9,5 +9,4 @@ const EnvironmentDetectorTest = { layer: (env = "terminal") => Layer.succeed(Env
|
|
|
9
9
|
agentName: Effect.succeed(env === "agent-shell" ? "test-agent" : void 0)
|
|
10
10
|
}) };
|
|
11
11
|
|
|
12
|
-
//#endregion
|
|
13
12
|
export { EnvironmentDetectorTest };
|