@jamesaphoenix/tx-test-utils 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/dist/database/index.d.ts +8 -0
  2. package/dist/database/index.d.ts.map +1 -0
  3. package/dist/database/index.js +7 -0
  4. package/dist/database/index.js.map +1 -0
  5. package/dist/database/test-database.d.ts +101 -0
  6. package/dist/database/test-database.d.ts.map +1 -0
  7. package/dist/database/test-database.js +130 -0
  8. package/dist/database/test-database.js.map +1 -0
  9. package/dist/factories/anchor.factory.d.ts +117 -0
  10. package/dist/factories/anchor.factory.d.ts.map +1 -0
  11. package/dist/factories/anchor.factory.js +201 -0
  12. package/dist/factories/anchor.factory.js.map +1 -0
  13. package/dist/factories/candidate.factory.d.ts +151 -0
  14. package/dist/factories/candidate.factory.d.ts.map +1 -0
  15. package/dist/factories/candidate.factory.js +194 -0
  16. package/dist/factories/candidate.factory.js.map +1 -0
  17. package/dist/factories/edge.factory.d.ts +119 -0
  18. package/dist/factories/edge.factory.d.ts.map +1 -0
  19. package/dist/factories/edge.factory.js +191 -0
  20. package/dist/factories/edge.factory.js.map +1 -0
  21. package/dist/factories/factories.test.d.ts +8 -0
  22. package/dist/factories/factories.test.d.ts.map +1 -0
  23. package/dist/factories/factories.test.js +419 -0
  24. package/dist/factories/factories.test.js.map +1 -0
  25. package/dist/factories/index.d.ts +15 -0
  26. package/dist/factories/index.d.ts.map +1 -0
  27. package/dist/factories/index.js +21 -0
  28. package/dist/factories/index.js.map +1 -0
  29. package/dist/factories/learning.factory.d.ts +107 -0
  30. package/dist/factories/learning.factory.d.ts.map +1 -0
  31. package/dist/factories/learning.factory.js +150 -0
  32. package/dist/factories/learning.factory.js.map +1 -0
  33. package/dist/factories/task.factory.d.ts +106 -0
  34. package/dist/factories/task.factory.d.ts.map +1 -0
  35. package/dist/factories/task.factory.js +151 -0
  36. package/dist/factories/task.factory.js.map +1 -0
  37. package/dist/fixtures/index.d.ts +36 -0
  38. package/dist/fixtures/index.d.ts.map +1 -0
  39. package/dist/fixtures/index.js +47 -0
  40. package/dist/fixtures/index.js.map +1 -0
  41. package/dist/helpers/effect.d.ts +186 -0
  42. package/dist/helpers/effect.d.ts.map +1 -0
  43. package/dist/helpers/effect.js +298 -0
  44. package/dist/helpers/effect.js.map +1 -0
  45. package/dist/helpers/effect.test.d.ts +7 -0
  46. package/dist/helpers/effect.test.d.ts.map +1 -0
  47. package/dist/helpers/effect.test.js +271 -0
  48. package/dist/helpers/effect.test.js.map +1 -0
  49. package/dist/helpers/index.d.ts +7 -0
  50. package/dist/helpers/index.d.ts.map +1 -0
  51. package/dist/helpers/index.js +11 -0
  52. package/dist/helpers/index.js.map +1 -0
  53. package/dist/index.d.ts +26 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +52 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/llm-cache/cache.d.ts +152 -0
  58. package/dist/llm-cache/cache.d.ts.map +1 -0
  59. package/dist/llm-cache/cache.js +199 -0
  60. package/dist/llm-cache/cache.js.map +1 -0
  61. package/dist/llm-cache/cache.test.d.ts +7 -0
  62. package/dist/llm-cache/cache.test.d.ts.map +1 -0
  63. package/dist/llm-cache/cache.test.js +310 -0
  64. package/dist/llm-cache/cache.test.js.map +1 -0
  65. package/dist/llm-cache/cli.d.ts +113 -0
  66. package/dist/llm-cache/cli.d.ts.map +1 -0
  67. package/dist/llm-cache/cli.js +248 -0
  68. package/dist/llm-cache/cli.js.map +1 -0
  69. package/dist/llm-cache/index.d.ts +31 -0
  70. package/dist/llm-cache/index.d.ts.map +1 -0
  71. package/dist/llm-cache/index.js +31 -0
  72. package/dist/llm-cache/index.js.map +1 -0
  73. package/dist/mocks/anthropic.mock.d.ts +173 -0
  74. package/dist/mocks/anthropic.mock.d.ts.map +1 -0
  75. package/dist/mocks/anthropic.mock.js +125 -0
  76. package/dist/mocks/anthropic.mock.js.map +1 -0
  77. package/dist/mocks/ast-grep.mock.d.ts +216 -0
  78. package/dist/mocks/ast-grep.mock.d.ts.map +1 -0
  79. package/dist/mocks/ast-grep.mock.js +164 -0
  80. package/dist/mocks/ast-grep.mock.js.map +1 -0
  81. package/dist/mocks/file-system.mock.d.ts +181 -0
  82. package/dist/mocks/file-system.mock.d.ts.map +1 -0
  83. package/dist/mocks/file-system.mock.js +280 -0
  84. package/dist/mocks/file-system.mock.js.map +1 -0
  85. package/dist/mocks/index.d.ts +10 -0
  86. package/dist/mocks/index.d.ts.map +1 -0
  87. package/dist/mocks/index.js +16 -0
  88. package/dist/mocks/index.js.map +1 -0
  89. package/dist/mocks/mocks.test.d.ts +10 -0
  90. package/dist/mocks/mocks.test.d.ts.map +1 -0
  91. package/dist/mocks/mocks.test.js +961 -0
  92. package/dist/mocks/mocks.test.js.map +1 -0
  93. package/dist/mocks/openai.mock.d.ts +205 -0
  94. package/dist/mocks/openai.mock.d.ts.map +1 -0
  95. package/dist/mocks/openai.mock.js +178 -0
  96. package/dist/mocks/openai.mock.js.map +1 -0
  97. package/dist/setup/index.d.ts +7 -0
  98. package/dist/setup/index.d.ts.map +1 -0
  99. package/dist/setup/index.js +9 -0
  100. package/dist/setup/index.js.map +1 -0
  101. package/package.json +80 -0
@@ -0,0 +1,271 @@
1
+ /**
2
+ * Effect test helpers unit tests.
3
+ *
4
+ * Tests the Effect runners and assertions for correct behavior.
5
+ */
6
+ import { describe, it, expect } from "vitest";
7
+ import { Effect, Layer, Context, Data } from "effect";
8
+ import { runEffect, runEffectFail, runEffectEither, expectEffectSuccess, expectEffectFailure, mergeLayers, createTestContext } from "./effect.js";
9
+ import { Either } from "effect";
10
+ // =============================================================================
11
+ // Test Error Types
12
+ // =============================================================================
13
+ class TestError extends Data.TaggedError("TestError") {
14
+ }
15
+ class TestServiceTag extends Context.Tag("TestService")() {
16
+ }
17
+ const TestServiceLive = Layer.succeed(TestServiceTag, {
18
+ getValue: () => Effect.succeed(42),
19
+ getValueOrFail: (shouldFail) => shouldFail
20
+ ? Effect.fail(new TestError({ message: "Test failure" }))
21
+ : Effect.succeed(42)
22
+ });
23
+ // =============================================================================
24
+ // runEffect Tests
25
+ // =============================================================================
26
+ describe("runEffect", () => {
27
+ it("returns the value for a successful Effect", async () => {
28
+ const result = await runEffect(Effect.succeed(42));
29
+ expect(result).toBe(42);
30
+ });
31
+ it("works with complex values", async () => {
32
+ const obj = { name: "test", value: 123 };
33
+ const result = await runEffect(Effect.succeed(obj));
34
+ expect(result).toEqual(obj);
35
+ });
36
+ it("throws an error for a failed Effect", async () => {
37
+ const effect = Effect.fail(new TestError({ message: "oops" }));
38
+ await expect(runEffect(effect)).rejects.toThrow("Effect failed:");
39
+ });
40
+ it("supports Layer injection", async () => {
41
+ const effect = Effect.gen(function* () {
42
+ const service = yield* TestServiceTag;
43
+ return yield* service.getValue();
44
+ });
45
+ const result = await runEffect(effect, TestServiceLive);
46
+ expect(result).toBe(42);
47
+ });
48
+ it("throws when Effect times out", async () => {
49
+ const slowEffect = Effect.gen(function* () {
50
+ yield* Effect.sleep(1000);
51
+ return 42;
52
+ });
53
+ await expect(runEffect(slowEffect, undefined, { timeout: 50 })).rejects.toThrow("Effect failed:");
54
+ });
55
+ });
56
+ // =============================================================================
57
+ // runEffectFail Tests
58
+ // =============================================================================
59
+ describe("runEffectFail", () => {
60
+ it("returns the cause for a failed Effect", async () => {
61
+ const effect = Effect.fail(new TestError({ message: "expected failure" }));
62
+ const cause = await runEffectFail(effect);
63
+ expect(cause).toBeDefined();
64
+ });
65
+ it("throws when Effect succeeds unexpectedly", async () => {
66
+ const effect = Effect.succeed(42);
67
+ await expect(runEffectFail(effect)).rejects.toThrow("Expected Effect to fail, but it succeeded");
68
+ });
69
+ it("supports Layer injection for failure cases", async () => {
70
+ const effect = Effect.gen(function* () {
71
+ const service = yield* TestServiceTag;
72
+ return yield* service.getValueOrFail(true);
73
+ });
74
+ const cause = await runEffectFail(effect, TestServiceLive);
75
+ expect(cause).toBeDefined();
76
+ });
77
+ });
78
+ // =============================================================================
79
+ // runEffectEither Tests
80
+ // =============================================================================
81
+ describe("runEffectEither", () => {
82
+ it("returns Right for successful Effect", async () => {
83
+ const result = await runEffectEither(Effect.succeed(42));
84
+ expect(Either.isRight(result)).toBe(true);
85
+ if (Either.isRight(result)) {
86
+ expect(result.right).toBe(42);
87
+ }
88
+ });
89
+ it("returns Left for failed Effect", async () => {
90
+ const effect = Effect.fail(new TestError({ message: "expected" }));
91
+ const result = await runEffectEither(effect);
92
+ expect(Either.isLeft(result)).toBe(true);
93
+ if (Either.isLeft(result)) {
94
+ expect(result.left._tag).toBe("TestError");
95
+ }
96
+ });
97
+ it("never throws for typed failures", async () => {
98
+ const effect = Effect.fail(new TestError({ message: "test" }));
99
+ // Should not throw
100
+ const result = await runEffectEither(effect);
101
+ expect(Either.isLeft(result)).toBe(true);
102
+ });
103
+ it("supports Layer injection", async () => {
104
+ const effect = Effect.gen(function* () {
105
+ const service = yield* TestServiceTag;
106
+ return yield* service.getValue();
107
+ });
108
+ const result = await runEffectEither(effect, TestServiceLive);
109
+ expect(Either.isRight(result)).toBe(true);
110
+ if (Either.isRight(result)) {
111
+ expect(result.right).toBe(42);
112
+ }
113
+ });
114
+ });
115
+ // =============================================================================
116
+ // expectEffectSuccess Tests
117
+ // =============================================================================
118
+ describe("expectEffectSuccess", () => {
119
+ it("returns the value for successful Effect", async () => {
120
+ const result = await expectEffectSuccess(Effect.succeed(42));
121
+ expect(result).toBe(42);
122
+ });
123
+ it("supports validation callback", async () => {
124
+ let validated = false;
125
+ const result = await expectEffectSuccess(Effect.succeed({ id: 1, name: "test" }), undefined, (value) => {
126
+ expect(value.id).toBe(1);
127
+ expect(value.name).toBe("test");
128
+ validated = true;
129
+ });
130
+ expect(result.id).toBe(1);
131
+ expect(validated).toBe(true);
132
+ });
133
+ it("throws when Effect fails", async () => {
134
+ const effect = Effect.fail(new TestError({ message: "fail" }));
135
+ await expect(expectEffectSuccess(effect)).rejects.toThrow("Effect failed:");
136
+ });
137
+ it("supports async validation", async () => {
138
+ let validated = false;
139
+ await expectEffectSuccess(Effect.succeed(42), undefined, async (value) => {
140
+ await Promise.resolve();
141
+ expect(value).toBe(42);
142
+ validated = true;
143
+ });
144
+ expect(validated).toBe(true);
145
+ });
146
+ });
147
+ // =============================================================================
148
+ // expectEffectFailure Tests
149
+ // =============================================================================
150
+ describe("expectEffectFailure", () => {
151
+ it("returns the error for failed Effect", async () => {
152
+ const effect = Effect.fail(new TestError({ message: "expected" }));
153
+ const error = await expectEffectFailure(effect);
154
+ expect(error._tag).toBe("TestError");
155
+ expect(error.message).toBe("expected");
156
+ });
157
+ it("supports validation callback", async () => {
158
+ const effect = Effect.fail(new TestError({ message: "check me" }));
159
+ const error = await expectEffectFailure(effect, undefined, (err) => {
160
+ expect(err._tag).toBe("TestError");
161
+ expect(err.message).toBe("check me");
162
+ });
163
+ expect(error.message).toBe("check me");
164
+ });
165
+ it("throws when Effect succeeds", async () => {
166
+ const effect = Effect.succeed(42);
167
+ await expect(expectEffectFailure(effect)).rejects.toThrow("Expected Effect to fail, but it succeeded");
168
+ });
169
+ it("supports Layer injection", async () => {
170
+ const effect = Effect.gen(function* () {
171
+ const service = yield* TestServiceTag;
172
+ return yield* service.getValueOrFail(true);
173
+ });
174
+ const error = await expectEffectFailure(effect, TestServiceLive, (err) => {
175
+ expect(err._tag).toBe("TestError");
176
+ });
177
+ expect(error._tag).toBe("TestError");
178
+ });
179
+ });
180
+ // =============================================================================
181
+ // mergeLayers Tests
182
+ // =============================================================================
183
+ describe("mergeLayers", () => {
184
+ class ServiceATag extends Context.Tag("ServiceA")() {
185
+ }
186
+ class ServiceBTag extends Context.Tag("ServiceB")() {
187
+ }
188
+ const ServiceALive = Layer.succeed(ServiceATag, { a: 1 });
189
+ const ServiceBLive = Layer.succeed(ServiceBTag, { b: "hello" });
190
+ it("returns empty layer when no layers provided", () => {
191
+ const merged = mergeLayers();
192
+ expect(merged).toBeDefined();
193
+ });
194
+ it("returns the layer when single layer provided", () => {
195
+ const merged = mergeLayers(ServiceALive);
196
+ expect(merged).toBeDefined();
197
+ });
198
+ it("merges multiple layers", async () => {
199
+ const merged = mergeLayers(ServiceALive, ServiceBLive);
200
+ const effect = Effect.gen(function* () {
201
+ const a = yield* ServiceATag;
202
+ const b = yield* ServiceBTag;
203
+ return { a: a.a, b: b.b };
204
+ });
205
+ const result = await runEffect(effect, merged);
206
+ expect(result).toEqual({ a: 1, b: "hello" });
207
+ });
208
+ });
209
+ // =============================================================================
210
+ // createTestContext Tests
211
+ // =============================================================================
212
+ describe("createTestContext", () => {
213
+ it("creates a context with runEffect method", async () => {
214
+ const ctx = createTestContext(() => TestServiceLive);
215
+ const effect = Effect.gen(function* () {
216
+ const service = yield* TestServiceTag;
217
+ return yield* service.getValue();
218
+ });
219
+ const result = await ctx.runEffect(effect);
220
+ expect(result).toBe(42);
221
+ });
222
+ it("reuses the layer across multiple calls", async () => {
223
+ let layerCreationCount = 0;
224
+ const ctx = createTestContext(() => {
225
+ layerCreationCount++;
226
+ return TestServiceLive;
227
+ });
228
+ const effect = Effect.gen(function* () {
229
+ const service = yield* TestServiceTag;
230
+ return yield* service.getValue();
231
+ });
232
+ await ctx.runEffect(effect);
233
+ await ctx.runEffect(effect);
234
+ await ctx.runEffect(effect);
235
+ expect(layerCreationCount).toBe(1);
236
+ });
237
+ it("supports runEffectFail", async () => {
238
+ const ctx = createTestContext(() => TestServiceLive);
239
+ const effect = Effect.gen(function* () {
240
+ const service = yield* TestServiceTag;
241
+ return yield* service.getValueOrFail(true);
242
+ });
243
+ const cause = await ctx.runEffectFail(effect);
244
+ expect(cause).toBeDefined();
245
+ });
246
+ it("supports runEffectEither", async () => {
247
+ const ctx = createTestContext(() => TestServiceLive);
248
+ const effect = Effect.gen(function* () {
249
+ const service = yield* TestServiceTag;
250
+ return yield* service.getValue();
251
+ });
252
+ const result = await ctx.runEffectEither(effect);
253
+ expect(Either.isRight(result)).toBe(true);
254
+ });
255
+ it("reset forces layer recreation", async () => {
256
+ let layerCreationCount = 0;
257
+ const ctx = createTestContext(() => {
258
+ layerCreationCount++;
259
+ return TestServiceLive;
260
+ });
261
+ const effect = Effect.gen(function* () {
262
+ const service = yield* TestServiceTag;
263
+ return yield* service.getValue();
264
+ });
265
+ await ctx.runEffect(effect);
266
+ ctx.reset();
267
+ await ctx.runEffect(effect);
268
+ expect(layerCreationCount).toBe(2);
269
+ });
270
+ });
271
+ //# sourceMappingURL=effect.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effect.test.js","sourceRoot":"","sources":["../../src/helpers/effect.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACrD,OAAO,EACL,SAAS,EACT,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EAClB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF,MAAM,SAAU,SAAQ,IAAI,CAAC,WAAW,CAAC,WAAW,CAElD;CAAG;AAWL,MAAM,cAAe,SAAQ,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAGpD;CAAG;AAEN,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CACnC,cAAc,EACd;IACE,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAClC,cAAc,EAAE,CAAC,UAAU,EAAE,EAAE,CAC7B,UAAU;QACR,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;QACzD,CAAC,CAAC,MAAM,CAAC,OAAO,C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CAAC,GAAG,EAAE;YACjC,kBAAkB,EAAE,CAAA;YACpB,OAAO,eAAe,CAAA;QACxB,CAAC,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YACjC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,cAAc,CAAA;YACrC,OAAO,KAAK,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAA;QAClC,CAAC,CAAC,CAAA;QAEF,MAAM,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAC3B,GAAG,CAAC,KAAK,EAAE,CAAA;QACX,MAAM,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAE3B,MAAM,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Test helper utilities.
3
+ *
4
+ * @module @tx/test-utils/helpers
5
+ */
6
+ export { runEffect, runEffectFail, runEffectEither, expectEffectSuccess, expectEffectFailure, mergeLayers, createTestContext, type RunEffectOptions, type EffectResult } from "./effect.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,SAAS,EACT,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,aAAa,CAAA"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Test helper utilities.
3
+ *
4
+ * @module @tx/test-utils/helpers
5
+ */
6
+ // Effect test helpers
7
+ export { runEffect, runEffectFail, runEffectEither, expectEffectSuccess, expectEffectFailure, mergeLayers, createTestContext } from "./effect.js";
8
+ // TODO: Implement temp file helpers
9
+ // export { createTempDir, writeTestTypeScriptFile, createTestSourceFiles } from './temp-files.js'
10
+ // export type { TempDir } from './temp-files.js'
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sBAAsB;AACtB,OAAO,EACL,SAAS,EACT,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EAGlB,MAAM,aAAa,CAAA;AAEpB,oCAAoC;AACpC,kGAAkG;AAClG,iDAAiD"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @tx/test-utils - Test utilities, factories, fixtures, and helpers
3
+ *
4
+ * This package centralizes all test utilities across the tx monorepo.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import {
9
+ * createTestDatabase,
10
+ * createTestLearning,
11
+ * fixtureId,
12
+ * runEffect
13
+ * } from '@tx/test-utils'
14
+ * ```
15
+ *
16
+ * @module @tx/test-utils
17
+ */
18
+ export { fixtureId, namespacedFixtureId, sequentialFixtureIds, contentFixtureId } from "./fixtures/index.js";
19
+ export { createTestDatabase, TestDatabaseService, TestDatabaseLive, createTestDatabaseLayer } from "./database/index.js";
20
+ export type { TestDatabase } from "./database/index.js";
21
+ export { TaskFactory, createTestTask, createTestTasks, type CreateTaskOptions, LearningFactory, createTestLearning, createTestLearnings, type CreateLearningOptions, EdgeFactory, createTestEdge, createEdgeBetweenLearnings, type CreateEdgeOptions, AnchorFactory, createTestAnchor, type CreateAnchorOptions, CandidateFactory, createTestCandidate, type CreateCandidateOptions, type LearningCandidate, type CandidateConfidence, type CandidateStatus } from "./factories/index.js";
22
+ export { hashInput, cachedLLMCall, withLLMCache, configureLLMCache, getCacheConfig, resetCacheConfig, getCacheStats, clearCache, formatCacheStats, getCacheEntry, listCacheEntries } from "./llm-cache/index.js";
23
+ export type { CacheEntry, CachedLLMCallOptions, WithLLMCacheOptions, CacheStats, ClearCacheOptions } from "./llm-cache/index.js";
24
+ export { runEffect, runEffectFail, runEffectEither, expectEffectSuccess, expectEffectFailure, mergeLayers, createTestContext, type RunEffectOptions, type EffectResult } from "./helpers/index.js";
25
+ export { createMockAnthropic, createMockAnthropicForExtraction, type MockMessage, type MockAnthropicCall, type MockAnthropicResponse, type MockAnthropicConfig, type MockAnthropicResult, createMockOpenAI, createMockOpenAIForExtraction, createMockOpenAIForExtractionRaw, type MockOpenAIMessage, type MockOpenAIChatCall, type MockOpenAIChatResponse, type MockOpenAIConfig, type MockOpenAIResult } from "./mocks/index.js";
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,qBAAqB,CAAA;AAG5B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAGvD,OAAO,EAEL,WAAW,EACX,cAAc,EACd,eAAe,EACf,KAAK,iBAAiB,EAEtB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,qBAAqB,EAE1B,WAAW,EACX,cAAc,EACd,0BAA0B,EAC1B,KAAK,iBAAiB,EAEtB,aAAa,EACb,gBAAgB,EAChB,KAAK,mBAAmB,EAExB,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAEL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAEhB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EACjB,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EACV,UAAU,EACV,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,iBAAiB,EAClB,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EACL,SAAS,EACT,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAA;AAO3B,OAAO,EACL,mBAAmB,EACnB,gCAAgC,EAChC,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,gBAAgB,EAChB,6BAA6B,EAC7B,gCAAgC,EAChC,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @tx/test-utils - Test utilities, factories, fixtures, and helpers
3
+ *
4
+ * This package centralizes all test utilities across the tx monorepo.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import {
9
+ * createTestDatabase,
10
+ * createTestLearning,
11
+ * fixtureId,
12
+ * runEffect
13
+ * } from '@tx/test-utils'
14
+ * ```
15
+ *
16
+ * @module @tx/test-utils
17
+ */
18
+ // Fixtures - SHA256-based deterministic IDs
19
+ export { fixtureId, namespacedFixtureId, sequentialFixtureIds, contentFixtureId } from "./fixtures/index.js";
20
+ // Database helpers
21
+ export { createTestDatabase, TestDatabaseService, TestDatabaseLive, createTestDatabaseLayer } from "./database/index.js";
22
+ // Factories
23
+ export {
24
+ // Task
25
+ TaskFactory, createTestTask, createTestTasks,
26
+ // Learning
27
+ LearningFactory, createTestLearning, createTestLearnings,
28
+ // Edge
29
+ EdgeFactory, createTestEdge, createEdgeBetweenLearnings,
30
+ // Anchor
31
+ AnchorFactory, createTestAnchor,
32
+ // Candidate
33
+ CandidateFactory, createTestCandidate } from "./factories/index.js";
34
+ // LLM Cache - SHA256-based response caching
35
+ export {
36
+ // Core functions
37
+ hashInput, cachedLLMCall, withLLMCache, configureLLMCache, getCacheConfig, resetCacheConfig,
38
+ // CLI utilities
39
+ getCacheStats, clearCache, formatCacheStats, getCacheEntry, listCacheEntries } from "./llm-cache/index.js";
40
+ // Effect Helpers
41
+ export { runEffect, runEffectFail, runEffectEither, expectEffectSuccess, expectEffectFailure, mergeLayers, createTestContext } from "./helpers/index.js";
42
+ // Temp Files (to be implemented)
43
+ // export { createTempDir, writeTestTypeScriptFile, createTestSourceFiles } from './helpers/index.js'
44
+ // export type { TempDir } from './helpers/index.js'
45
+ // Mocks
46
+ export { createMockAnthropic, createMockAnthropicForExtraction, createMockOpenAI, createMockOpenAIForExtraction, createMockOpenAIForExtractionRaw } from "./mocks/index.js";
47
+ // TODO: Implement remaining mocks (tx-b28e5324)
48
+ // export { MockAstGrepService } from './mocks/index.js'
49
+ // export { MockFileSystem } from './mocks/index.js'
50
+ // Setup (to be implemented)
51
+ // export { default as vitestSetup } from './setup/index.js'
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,4CAA4C;AAC5C,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,qBAAqB,CAAA;AAE5B,mBAAmB;AACnB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,qBAAqB,CAAA;AAG5B,YAAY;AACZ,OAAO;AACL,OAAO;AACP,WAAW,EACX,cAAc,EACd,eAAe;AAEf,WAAW;AACX,eAAe,EACf,kBAAkB,EAClB,mBAAmB;AAEnB,OAAO;AACP,WAAW,EACX,cAAc,EACd,0BAA0B;AAE1B,SAAS;AACT,aAAa,EACb,gBAAgB;AAEhB,YAAY;AACZ,gBAAgB,EAChB,mBAAmB,EAKpB,MAAM,sBAAsB,CAAA;AAE7B,4CAA4C;AAC5C,OAAO;AACL,iBAAiB;AACjB,SAAS,EACT,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,gBAAgB;AAChB,gBAAgB;AAChB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EACjB,MAAM,sBAAsB,CAAA;AAS7B,iBAAiB;AACjB,OAAO,EACL,SAAS,EACT,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EAGlB,MAAM,oBAAoB,CAAA;AAE3B,iCAAiC;AACjC,qGAAqG;AACrG,oDAAoD;AAEpD,QAAQ;AACR,OAAO,EACL,mBAAmB,EACnB,gCAAgC,EAMhC,gBAAgB,EAChB,6BAA6B,EAC7B,gCAAgC,EAMjC,MAAM,kBAAkB,CAAA;AACzB,gDAAgD;AAChD,wDAAwD;AACxD,oDAAoD;AAEpD,4BAA4B;AAC5B,4DAA4D"}
@@ -0,0 +1,152 @@
1
+ /**
2
+ * LLM response caching with SHA256 keys.
3
+ *
4
+ * Caches expensive LLM API calls by hashing inputs with SHA256.
5
+ * Supports version-based cache invalidation and various bypass modes.
6
+ *
7
+ * @module @tx/test-utils/llm-cache/cache
8
+ */
9
+ /**
10
+ * Global cache configuration.
11
+ */
12
+ interface LLMCacheConfig {
13
+ /** Directory for cache files. Default: test/fixtures/llm-cache */
14
+ cacheDir: string;
15
+ /** Enable console logging. Default: true in non-CI environments */
16
+ logging: boolean;
17
+ }
18
+ /**
19
+ * Configure LLM cache settings.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * configureLLMCache({
24
+ * cacheDir: 'custom/cache/path',
25
+ * logging: false
26
+ * })
27
+ * ```
28
+ */
29
+ export declare const configureLLMCache: (options: Partial<LLMCacheConfig>) => void;
30
+ /**
31
+ * Get current cache configuration.
32
+ */
33
+ export declare const getCacheConfig: () => Readonly<LLMCacheConfig>;
34
+ /**
35
+ * Reset cache configuration to defaults.
36
+ */
37
+ export declare const resetCacheConfig: () => void;
38
+ /**
39
+ * Cache entry stored in JSON files.
40
+ */
41
+ export interface CacheEntry<T> {
42
+ /** SHA256 hash of input (also the filename) */
43
+ inputHash: string;
44
+ /** Truncated input for human readability */
45
+ input: string;
46
+ /** Cached response data */
47
+ response: T;
48
+ /** Model identifier (for debugging) */
49
+ model: string;
50
+ /** ISO timestamp when cached */
51
+ cachedAt: string;
52
+ /** Version for cache invalidation */
53
+ version: number;
54
+ }
55
+ /**
56
+ * Options for cachedLLMCall.
57
+ */
58
+ export interface CachedLLMCallOptions {
59
+ /** Cache version - mismatch triggers cache miss */
60
+ version?: number;
61
+ /** Force refresh even if cached */
62
+ forceRefresh?: boolean;
63
+ }
64
+ /**
65
+ * Options for withLLMCache wrapper.
66
+ */
67
+ export interface WithLLMCacheOptions<TInput> {
68
+ /** Model identifier for cache metadata */
69
+ model: string;
70
+ /** Custom serializer for input (default: JSON.stringify) */
71
+ serialize?: (input: TInput) => string;
72
+ /** Cache version for invalidation */
73
+ version?: number;
74
+ }
75
+ /**
76
+ * Compute SHA256 hash of input string for cache key.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * const hash = hashInput("What is the capital of France?")
81
+ * // -> "a1b2c3d4e5f6..." (64 hex chars)
82
+ * ```
83
+ */
84
+ export declare const hashInput: (input: string) => string;
85
+ /**
86
+ * Get cached LLM response or execute and cache.
87
+ *
88
+ * Features:
89
+ * - TX_NO_LLM_CACHE=1 env var bypasses cache entirely
90
+ * - forceRefresh option forces fresh call even if cached
91
+ * - version option enables cache invalidation on version mismatch
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * const result = await cachedLLMCall(
96
+ * "What is the capital of France?",
97
+ * "claude-sonnet-4",
98
+ * async () => {
99
+ * const response = await anthropic.messages.create({...})
100
+ * return response.content[0].text
101
+ * },
102
+ * { version: 2 }
103
+ * )
104
+ * ```
105
+ */
106
+ export declare const cachedLLMCall: <T>(input: string, model: string, call: () => Promise<T>, options?: CachedLLMCallOptions) => Promise<T>;
107
+ /**
108
+ * Wrap an async function to use LLM caching.
109
+ *
110
+ * Creates a cached version of any async function. The input is serialized
111
+ * and hashed to create a cache key.
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * // Wrap an extraction function
116
+ * const cachedExtract = withLLMCache(
117
+ * async (transcript: string) => {
118
+ * const response = await anthropic.messages.create({
119
+ * model: "claude-sonnet-4-20250514",
120
+ * messages: [{ role: "user", content: extractPrompt(transcript) }]
121
+ * })
122
+ * return JSON.parse(response.content[0].text)
123
+ * },
124
+ * { model: "claude-sonnet-4", version: 1 }
125
+ * )
126
+ *
127
+ * // Use it - results are cached
128
+ * const result1 = await cachedExtract("some transcript")
129
+ * const result2 = await cachedExtract("some transcript") // cache hit!
130
+ * ```
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * // With custom serializer for complex input
135
+ * interface ComplexInput {
136
+ * transcript: string
137
+ * metadata: { source: string }
138
+ * }
139
+ *
140
+ * const cachedProcess = withLLMCache(
141
+ * async (input: ComplexInput) => processInput(input),
142
+ * {
143
+ * model: "claude-sonnet-4",
144
+ * serialize: (input) => `${input.metadata.source}::${input.transcript}`,
145
+ * version: 2
146
+ * }
147
+ * )
148
+ * ```
149
+ */
150
+ export declare const withLLMCache: <TInput, TOutput>(fn: (input: TInput) => Promise<TOutput>, options: WithLLMCacheOptions<TInput>) => ((input: TInput) => Promise<TOutput>);
151
+ export {};
152
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/llm-cache/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH;;GAEG;AACH,UAAU,cA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