@vitest-agent/engine 0.1.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.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -0
  3. package/index.d.ts +2679 -0
  4. package/index.js +63 -0
  5. package/layers/ConfigLive.js +46 -0
  6. package/layers/DataReaderLive.js +1923 -0
  7. package/layers/DataStoreLive.js +1283 -0
  8. package/layers/DetailResolverLive.js +9 -0
  9. package/layers/DiscoveryRegistryLive.js +70 -0
  10. package/layers/EnvironmentDetectorLive.js +36 -0
  11. package/layers/EnvironmentDetectorTest.js +13 -0
  12. package/layers/ExecutorResolverLive.js +9 -0
  13. package/layers/FormatSelectorLive.js +20 -0
  14. package/layers/HistoryTrackerLive.js +49 -0
  15. package/layers/HistoryTrackerTest.js +25 -0
  16. package/layers/LoggerLive.js +70 -0
  17. package/layers/OutputPipelineLive.js +20 -0
  18. package/layers/OutputRendererLive.js +23 -0
  19. package/layers/PathResolutionLive.js +46 -0
  20. package/layers/PerClientSessionMapLive.js +145 -0
  21. package/layers/ProjectDiscoveryLive.js +67 -0
  22. package/layers/ProjectDiscoveryTest.js +12 -0
  23. package/layers/ProjectIdentityLive.js +95 -0
  24. package/layers/RunContextLive.js +82 -0
  25. package/lib/format-triage.js +103 -0
  26. package/lib/format-wrapup.js +67 -0
  27. package/migrations/0001_initial.js +824 -0
  28. package/migrations/0002_test_artifacts.js +30 -0
  29. package/migrations/index.js +27 -0
  30. package/migrations/registry_0001_initial.js +39 -0
  31. package/migrations/session_map_0001_initial.js +38 -0
  32. package/package.json +59 -0
  33. package/platform.js +58 -0
  34. package/programs/end-agent.js +19 -0
  35. package/programs/hook-paths.js +115 -0
  36. package/programs/platform-sidecar.js +37 -0
  37. package/programs/record-session.js +49 -0
  38. package/programs/record-tdd-artifact.js +119 -0
  39. package/programs/record-turn.js +61 -0
  40. package/programs/record-workspace-changes.js +57 -0
  41. package/programs/register-agent.js +85 -0
  42. package/programs/resolve-session-for-recording.js +44 -0
  43. package/programs/session-env.js +85 -0
  44. package/project-dir.js +32 -0
  45. package/services/Config.js +15 -0
  46. package/services/DataReader.js +8 -0
  47. package/services/DataStore.js +15 -0
  48. package/services/DetailResolver.js +8 -0
  49. package/services/DiscoveryRegistry.js +8 -0
  50. package/services/EnvironmentDetector.js +8 -0
  51. package/services/ExecutorResolver.js +8 -0
  52. package/services/FormatSelector.js +8 -0
  53. package/services/HistoryTracker.js +20 -0
  54. package/services/OutputRenderer.js +8 -0
  55. package/services/PerClientSessionMap.js +22 -0
  56. package/services/ProjectDiscovery.js +8 -0
  57. package/services/ProjectIdentity.js +62 -0
  58. package/services/RunContext.js +53 -0
  59. package/services/idempotency.js +58 -0
  60. package/sql/assemblers.js +69 -0
  61. package/testing/layers.js +16 -0
  62. package/testing.d.ts +1101 -0
  63. package/testing.js +243 -0
  64. package/tsdoc-metadata.json +11 -0
  65. package/utils/ensure-migrated.js +47 -0
  66. package/utils/failure-signature.js +34 -0
  67. package/utils/resolve-data-path.js +64 -0
  68. package/utils/resolve-project-key-from-cwd.js +52 -0
  69. package/utils/resolve-workspace-key.js +41 -0
  70. package/version.js +6 -0
@@ -0,0 +1,69 @@
1
+ import { historyKey } from "../services/HistoryTracker.js";
2
+
3
+ //#region src/sql/assemblers.ts
4
+ /**
5
+ * Builds a `CacheManifest` from an array of test_runs aggregation rows.
6
+ *
7
+ * Each row represents the latest run for a project/sub_project pair.
8
+ * The `dbPath` is stored as `cacheDir` so CLI tools can locate the source.
9
+ * @public
10
+ */
11
+ function assembleManifest(rows, dbPath) {
12
+ return {
13
+ updatedAt: rows.reduce((latest, row) => {
14
+ return row.timestamp > latest ? row.timestamp : latest;
15
+ }, (/* @__PURE__ */ new Date(0)).toISOString()),
16
+ cacheDir: dbPath,
17
+ projects: rows.map((row) => {
18
+ const projectName = row.sub_project ? `${row.project}:${row.sub_project}` : row.project;
19
+ const safeProjectName = projectName.replace(/[^a-z0-9@._-]/gi, "_");
20
+ const reportFile = `sql:reports/${safeProjectName}.json`;
21
+ const historyFile = `sql:history/${safeProjectName}.history.json`;
22
+ const lastResult = (() => {
23
+ if (row.reason === "passed" || row.reason === "failed" || row.reason === "interrupted") return row.reason;
24
+ return null;
25
+ })();
26
+ return {
27
+ project: projectName,
28
+ reportFile,
29
+ historyFile,
30
+ lastRun: row.timestamp,
31
+ lastResult
32
+ };
33
+ })
34
+ };
35
+ }
36
+ /**
37
+ * Groups test_history rows by the composite (module_path, full_name) key
38
+ * into a keyed record.
39
+ *
40
+ * Returns `Record<compositeKey, { modulePath, fullName, runs: TestRun[] }>`
41
+ * where `runs` are the accumulated test runs for that test, in the order
42
+ * they appear in `rows`. Two rows sharing `full_name` but differing
43
+ * `module_path` are tracked as distinct entries rather than merged.
44
+ *
45
+ * Only rows with state `"passed"` or `"failed"` are included in runs
46
+ * (matching the `TestRun` schema constraint).
47
+ * @public
48
+ */
49
+ function assembleHistoryRecord(rows) {
50
+ const record = {};
51
+ for (const row of rows) {
52
+ const state = row.state === "passed" || row.state === "failed" ? row.state : null;
53
+ if (state === null) continue;
54
+ const key = historyKey(row.module_path, row.full_name);
55
+ if (!record[key]) record[key] = {
56
+ modulePath: row.module_path,
57
+ fullName: row.full_name,
58
+ runs: []
59
+ };
60
+ record[key].runs.push({
61
+ timestamp: row.timestamp,
62
+ state
63
+ });
64
+ }
65
+ return record;
66
+ }
67
+
68
+ //#endregion
69
+ export { assembleHistoryRecord, assembleManifest };
@@ -0,0 +1,16 @@
1
+ import { DataReaderLive } from "../layers/DataReaderLive.js";
2
+ import { DataStoreLive } from "../layers/DataStoreLive.js";
3
+ import { NodePlatformLayer, makeSqliteStack } from "../platform.js";
4
+ import { Layer } from "effect";
5
+
6
+ //#region src/testing/layers.ts
7
+ /** @public */
8
+ function makeTestLayer(filename) {
9
+ const { SqliteLayer, MigratorLayer } = makeSqliteStack(filename);
10
+ return Layer.mergeAll(DataStoreLive.pipe(Layer.provide(SqliteLayer)), DataReaderLive.pipe(Layer.provide(SqliteLayer)), MigratorLayer, SqliteLayer, NodePlatformLayer);
11
+ }
12
+ /** @public */
13
+ const DataStoreTestLayer = makeTestLayer(":memory:");
14
+
15
+ //#endregion
16
+ export { DataStoreTestLayer, makeTestLayer };