playwright-mimic 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +695 -446
  2. package/dist/agentic/agent.d.ts +106 -0
  3. package/dist/agentic/agent.d.ts.map +1 -0
  4. package/dist/agentic/agent.js +528 -0
  5. package/dist/agentic/agent.js.map +1 -0
  6. package/dist/agentic/index.d.ts +13 -0
  7. package/dist/agentic/index.d.ts.map +1 -0
  8. package/dist/agentic/index.js +12 -0
  9. package/dist/agentic/index.js.map +1 -0
  10. package/dist/agentic/planner.d.ts +41 -0
  11. package/dist/agentic/planner.d.ts.map +1 -0
  12. package/dist/agentic/planner.js +136 -0
  13. package/dist/agentic/planner.js.map +1 -0
  14. package/dist/agentic/react.d.ts +35 -0
  15. package/dist/agentic/react.d.ts.map +1 -0
  16. package/dist/agentic/react.js +170 -0
  17. package/dist/agentic/react.js.map +1 -0
  18. package/dist/agentic/recovery.d.ts +55 -0
  19. package/dist/agentic/recovery.d.ts.map +1 -0
  20. package/dist/agentic/recovery.js +200 -0
  21. package/dist/agentic/recovery.js.map +1 -0
  22. package/dist/agentic/reflection.d.ts +40 -0
  23. package/dist/agentic/reflection.d.ts.map +1 -0
  24. package/dist/agentic/reflection.js +142 -0
  25. package/dist/agentic/reflection.js.map +1 -0
  26. package/dist/agentic/types.d.ts +177 -0
  27. package/dist/agentic/types.d.ts.map +1 -0
  28. package/dist/agentic/types.js +8 -0
  29. package/dist/agentic/types.js.map +1 -0
  30. package/dist/agentic/wait.d.ts +50 -0
  31. package/dist/agentic/wait.d.ts.map +1 -0
  32. package/dist/agentic/wait.js +140 -0
  33. package/dist/agentic/wait.js.map +1 -0
  34. package/dist/agentic-mimic.d.ts +56 -0
  35. package/dist/agentic-mimic.d.ts.map +1 -0
  36. package/dist/agentic-mimic.js +98 -0
  37. package/dist/agentic-mimic.js.map +1 -0
  38. package/dist/index.d.ts +8 -8
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +9 -9
  41. package/dist/index.js.map +1 -1
  42. package/dist/mimic/actionType.d.ts +7 -0
  43. package/dist/mimic/actionType.d.ts.map +1 -0
  44. package/dist/mimic/actionType.js +44 -0
  45. package/dist/mimic/actionType.js.map +1 -0
  46. package/dist/mimic/annotations.d.ts +21 -0
  47. package/dist/mimic/annotations.d.ts.map +1 -0
  48. package/dist/mimic/annotations.js +36 -0
  49. package/dist/mimic/annotations.js.map +1 -0
  50. package/dist/mimic/cli.d.ts +15 -0
  51. package/dist/mimic/cli.d.ts.map +1 -0
  52. package/dist/mimic/cli.js +17 -0
  53. package/dist/mimic/cli.js.map +1 -0
  54. package/dist/mimic/click.d.ts +39 -0
  55. package/dist/mimic/click.d.ts.map +1 -0
  56. package/dist/mimic/click.js +348 -0
  57. package/dist/mimic/click.js.map +1 -0
  58. package/dist/mimic/forms.d.ts +52 -0
  59. package/dist/mimic/forms.d.ts.map +1 -0
  60. package/dist/mimic/forms.js +511 -0
  61. package/dist/mimic/forms.js.map +1 -0
  62. package/dist/mimic/markers.d.ts +133 -0
  63. package/dist/mimic/markers.d.ts.map +1 -0
  64. package/dist/mimic/markers.js +589 -0
  65. package/dist/mimic/markers.js.map +1 -0
  66. package/dist/mimic/navigation.d.ts +19 -0
  67. package/dist/mimic/navigation.d.ts.map +1 -0
  68. package/dist/mimic/navigation.js +136 -0
  69. package/dist/mimic/navigation.js.map +1 -0
  70. package/dist/mimic/playwrightCodeGenerator.d.ts +55 -0
  71. package/dist/mimic/playwrightCodeGenerator.d.ts.map +1 -0
  72. package/dist/mimic/playwrightCodeGenerator.js +270 -0
  73. package/dist/mimic/playwrightCodeGenerator.js.map +1 -0
  74. package/dist/mimic/replay.d.ts +21 -0
  75. package/dist/mimic/replay.d.ts.map +1 -0
  76. package/dist/mimic/replay.js +142 -0
  77. package/dist/mimic/replay.js.map +1 -0
  78. package/dist/mimic/schema/action.d.ts +315 -0
  79. package/dist/mimic/schema/action.d.ts.map +1 -0
  80. package/dist/mimic/schema/action.js +186 -0
  81. package/dist/mimic/schema/action.js.map +1 -0
  82. package/dist/mimic/selector.d.ts +143 -0
  83. package/dist/mimic/selector.d.ts.map +1 -0
  84. package/dist/mimic/selector.js +1515 -0
  85. package/dist/mimic/selector.js.map +1 -0
  86. package/dist/mimic/selectorDescriptor.d.ts +25 -0
  87. package/dist/mimic/selectorDescriptor.d.ts.map +1 -0
  88. package/dist/mimic/selectorDescriptor.js +32 -0
  89. package/dist/mimic/selectorDescriptor.js.map +1 -0
  90. package/dist/mimic/selectorSerialization.d.ts +18 -0
  91. package/dist/mimic/selectorSerialization.d.ts.map +1 -0
  92. package/dist/mimic/selectorSerialization.js +32 -0
  93. package/dist/mimic/selectorSerialization.js.map +1 -0
  94. package/dist/mimic/selectorTypes.d.ts +122 -0
  95. package/dist/mimic/selectorTypes.d.ts.map +1 -0
  96. package/dist/mimic/selectorTypes.js +2 -0
  97. package/dist/mimic/selectorTypes.js.map +1 -0
  98. package/dist/mimic/selectorUtils.d.ts +52 -0
  99. package/dist/mimic/selectorUtils.d.ts.map +1 -0
  100. package/dist/mimic/selectorUtils.js +251 -0
  101. package/dist/mimic/selectorUtils.js.map +1 -0
  102. package/dist/mimic/storage.d.ts +110 -0
  103. package/dist/mimic/storage.d.ts.map +1 -0
  104. package/dist/mimic/storage.js +409 -0
  105. package/dist/mimic/storage.js.map +1 -0
  106. package/dist/mimic/types.d.ts +85 -0
  107. package/dist/mimic/types.d.ts.map +1 -0
  108. package/dist/mimic/types.js +7 -0
  109. package/dist/mimic/types.js.map +1 -0
  110. package/dist/mimic.d.ts +29 -4
  111. package/dist/mimic.d.ts.map +1 -1
  112. package/dist/mimic.js +530 -32
  113. package/dist/mimic.js.map +1 -1
  114. package/dist/mimicry.d.ts +4 -4
  115. package/dist/mimicry.d.ts.map +1 -1
  116. package/dist/mimicry.js +22 -13
  117. package/dist/mimicry.js.map +1 -1
  118. package/package.json +30 -6
@@ -0,0 +1,409 @@
1
+ /**
2
+ * Snapshot Storage Module
3
+ *
4
+ * Handles reading, writing, and managing test execution snapshots.
5
+ * Snapshots store successful test executions as JSON files for fast replay.
6
+ */
7
+ import { createHash } from 'crypto';
8
+ import fs from 'node:fs/promises';
9
+ import { join, dirname, basename } from 'node:path';
10
+ /**
11
+ * Generate a hash from test text to create a unique identifier
12
+ *
13
+ * @param testText - The test text (mimic template string)
14
+ * @returns SHA-256 hash of the test text (first 16 characters for readability)
15
+ */
16
+ export function hashTestText(testText) {
17
+ const hash = createHash('sha256');
18
+ hash.update(testText.trim());
19
+ return hash.digest('hex').substring(0, 16);
20
+ }
21
+ /**
22
+ * Generate a hash from step text to create a unique identifier
23
+ *
24
+ * @param stepText - The step text (Gherkin step)
25
+ * @returns SHA-256 hash of the step text (first 16 characters for readability)
26
+ */
27
+ export function hashStepText(stepText) {
28
+ const hash = createHash('sha256');
29
+ hash.update(stepText.trim());
30
+ return hash.digest('hex').substring(0, 16);
31
+ }
32
+ /**
33
+ * Extract test file name from full file path
34
+ *
35
+ * @param testFilePath - Full path to the test file
36
+ * @returns Test file name without extension (e.g., "buttons-variety" from "buttons-variety.spec.ts")
37
+ */
38
+ export function getTestFileName(testFilePath) {
39
+ const fileName = basename(testFilePath);
40
+ // Remove extension (e.g., "agentic.spec.ts" -> "agentic.spec" -> "agentic")
41
+ const nameWithoutExt = fileName.replace(/\.(spec|test)\.(ts|js|tsx|jsx)$/, '');
42
+ return nameWithoutExt;
43
+ }
44
+ /**
45
+ * Get the mimic directory path for a test file
46
+ *
47
+ * @param testFilePath - Full path to the test file
48
+ * @returns Path to the __mimic__ directory
49
+ */
50
+ export function getMimicDir(testFilePath) {
51
+ const testFileDir = dirname(testFilePath);
52
+ return join(testFileDir, '__mimic__');
53
+ }
54
+ /**
55
+ * Get the mimic file path for a test file
56
+ *
57
+ * @param testFilePath - Full path to the test file
58
+ * @returns Full path to the mimic JSON file (e.g., "__mimic__/agentic.mimic.json")
59
+ */
60
+ export function getMimicFilePath(testFilePath) {
61
+ const mimicDir = getMimicDir(testFilePath);
62
+ const testFileName = getTestFileName(testFilePath);
63
+ return join(mimicDir, `${testFileName}.mimic.json`);
64
+ }
65
+ /**
66
+ * Ensure the __mimic__ directory exists
67
+ *
68
+ * @param testFilePath - Full path to the test file
69
+ * @returns Promise that resolves when directory is created or already exists
70
+ */
71
+ async function ensureMimicDir(testFilePath) {
72
+ const mimicDir = getMimicDir(testFilePath);
73
+ try {
74
+ await fs.mkdir(mimicDir, { recursive: true });
75
+ }
76
+ catch (error) {
77
+ // Directory might already exist, which is fine
78
+ if (error instanceof Error && !error.message.includes('EEXIST')) {
79
+ throw error;
80
+ }
81
+ }
82
+ }
83
+ /**
84
+ * Get the snapshot directory path for a test file (legacy support)
85
+ *
86
+ * @param testFilePath - Directory path of the test file
87
+ * @returns Path to the .mimic-snapshots directory
88
+ * @deprecated Use getMimicDir instead
89
+ */
90
+ export function getSnapshotDir(testFilePath) {
91
+ return join(testFilePath, '.mimic-snapshots');
92
+ }
93
+ /**
94
+ * Get the snapshot file path for a specific test (legacy support)
95
+ *
96
+ * @param testFilePath - Directory path of the test file
97
+ * @param testHash - Hash identifier for the test
98
+ * @returns Full path to the snapshot JSON file
99
+ * @deprecated Use getMimicFilePath instead
100
+ */
101
+ export function getSnapshotPath(testFilePath, testHash) {
102
+ const snapshotDir = getSnapshotDir(testFilePath);
103
+ return join(snapshotDir, `${testHash}.json`);
104
+ }
105
+ /**
106
+ * Read a snapshot from disk
107
+ *
108
+ * @param testFilePath - Full path to the test file
109
+ * @param testHash - Hash identifier for the test
110
+ * @returns Snapshot object if found, null otherwise
111
+ */
112
+ export async function getSnapshot(testFilePath, testHash) {
113
+ if (!testFilePath) {
114
+ return null;
115
+ }
116
+ const mimicFilePath = getMimicFilePath(testFilePath);
117
+ try {
118
+ const content = await fs.readFile(mimicFilePath, 'utf-8');
119
+ const mimicFile = JSON.parse(content);
120
+ // Find the test by testHash
121
+ const snapshot = mimicFile.tests?.find(test => test.testHash === testHash);
122
+ return snapshot || null;
123
+ }
124
+ catch (error) {
125
+ // File doesn't exist or is invalid - return null
126
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
127
+ // Try legacy location for backward compatibility
128
+ return getSnapshotLegacy(testFilePath, testHash);
129
+ }
130
+ // For other errors (parse errors, etc.), log and return null
131
+ console.warn(`Failed to read snapshot at ${mimicFilePath}:`, error);
132
+ return null;
133
+ }
134
+ }
135
+ /**
136
+ * Read a snapshot from legacy location (backward compatibility)
137
+ *
138
+ * @param testFilePath - Full path to the test file
139
+ * @param testHash - Hash identifier for the test
140
+ * @returns Snapshot object if found, null otherwise
141
+ */
142
+ async function getSnapshotLegacy(testFilePath, testHash) {
143
+ const testFileDir = dirname(testFilePath);
144
+ const snapshotPath = getSnapshotPath(testFileDir, testHash);
145
+ try {
146
+ const content = await fs.readFile(snapshotPath, 'utf-8');
147
+ const snapshot = JSON.parse(content);
148
+ return snapshot;
149
+ }
150
+ catch (error) {
151
+ // File doesn't exist or is invalid - return null
152
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
153
+ return null;
154
+ }
155
+ return null;
156
+ }
157
+ }
158
+ /**
159
+ * Save a snapshot to disk
160
+ *
161
+ * Saves all tests from a test file into a single JSON file in __mimic__ directory.
162
+ * Updates existing test entry if testHash already exists, otherwise adds new test.
163
+ *
164
+ * @param testFilePath - Full path to the test file
165
+ * @param snapshot - Snapshot object to save
166
+ * @returns Promise that resolves when snapshot is saved
167
+ */
168
+ export async function saveSnapshot(testFilePath, snapshot) {
169
+ if (!testFilePath) {
170
+ return;
171
+ }
172
+ await ensureMimicDir(testFilePath);
173
+ const mimicFilePath = getMimicFilePath(testFilePath);
174
+ // Read existing file if it exists
175
+ let mimicFile = { tests: [] };
176
+ try {
177
+ const content = await fs.readFile(mimicFilePath, 'utf-8');
178
+ mimicFile = JSON.parse(content);
179
+ // Ensure tests array exists
180
+ if (!mimicFile.tests) {
181
+ mimicFile.tests = [];
182
+ }
183
+ }
184
+ catch (error) {
185
+ // File doesn't exist - start with empty structure
186
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
187
+ mimicFile = { tests: [] };
188
+ }
189
+ else {
190
+ // For other errors, log and start fresh
191
+ console.warn(`Failed to read existing mimic file at ${mimicFilePath}, starting fresh:`, error);
192
+ mimicFile = { tests: [] };
193
+ }
194
+ }
195
+ // Update timestamps in flags
196
+ const now = new Date().toISOString();
197
+ if (!snapshot.flags) {
198
+ snapshot.flags = {
199
+ needsRetry: false,
200
+ hasErrors: false,
201
+ troubleshootingEnabled: false,
202
+ skipSnapshot: false,
203
+ forceRegenerate: false,
204
+ debugMode: false,
205
+ createdAt: now,
206
+ lastPassedAt: now,
207
+ lastFailedAt: null,
208
+ };
209
+ }
210
+ else {
211
+ snapshot.flags.lastPassedAt = now;
212
+ if (!snapshot.flags.createdAt) {
213
+ snapshot.flags.createdAt = now;
214
+ }
215
+ }
216
+ // Find existing test by testHash and update, or add new
217
+ const existingIndex = mimicFile.tests.findIndex(test => test.testHash === snapshot.testHash);
218
+ if (existingIndex >= 0) {
219
+ // Merge with existing test: preserve existing steps that weren't regenerated
220
+ const existingTest = mimicFile.tests[existingIndex];
221
+ // Merge stepsByHash: new steps overwrite old ones, but keep steps that weren't regenerated
222
+ const mergedStepsByHash = {};
223
+ // Start with existing steps (support both formats)
224
+ if (existingTest && existingTest.stepsByHash) {
225
+ Object.assign(mergedStepsByHash, existingTest.stepsByHash);
226
+ }
227
+ else if (existingTest && existingTest.steps) {
228
+ // Convert old format to new format
229
+ for (const step of existingTest.steps) {
230
+ mergedStepsByHash[step.stepHash] = step;
231
+ }
232
+ }
233
+ // Add/overwrite with new steps from snapshot
234
+ if (snapshot.stepsByHash) {
235
+ Object.assign(mergedStepsByHash, snapshot.stepsByHash);
236
+ }
237
+ else if (snapshot.steps) {
238
+ // Convert new snapshot's steps array to stepsByHash if needed
239
+ for (const step of snapshot.steps) {
240
+ mergedStepsByHash[step.stepHash] = step;
241
+ }
242
+ }
243
+ // Build merged steps array from mergedStepsByHash, sorted by stepIndex
244
+ const allMergedSteps = Object.values(mergedStepsByHash);
245
+ allMergedSteps.sort((a, b) => a.stepIndex - b.stepIndex);
246
+ // Update the test with merged data
247
+ mimicFile.tests[existingIndex] = {
248
+ ...snapshot,
249
+ stepsByHash: mergedStepsByHash,
250
+ steps: allMergedSteps, // Maintain backward compatibility with steps array
251
+ };
252
+ }
253
+ else {
254
+ // Add new test - ensure steps array exists even if only stepsByHash is provided
255
+ const finalSnapshot = {
256
+ ...snapshot,
257
+ steps: snapshot.steps || (snapshot.stepsByHash ? Object.values(snapshot.stepsByHash).sort((a, b) => a.stepIndex - b.stepIndex) : []),
258
+ stepsByHash: snapshot.stepsByHash || (snapshot.steps ? (() => {
259
+ const hash = {};
260
+ for (const step of snapshot.steps) {
261
+ hash[step.stepHash] = step;
262
+ }
263
+ return hash;
264
+ })() : {}),
265
+ };
266
+ mimicFile.tests.push(finalSnapshot);
267
+ }
268
+ // Write back to file
269
+ await fs.writeFile(mimicFilePath, JSON.stringify(mimicFile, null, 2), 'utf-8');
270
+ }
271
+ /**
272
+ * Record a test failure timestamp
273
+ *
274
+ * Updates the snapshot's lastFailedAt timestamp and flags if the snapshot exists.
275
+ *
276
+ * @param testFilePath - Full path to the test file
277
+ * @param testHash - Hash identifier for the test
278
+ * @param failedStepIndex - Index of the step that failed (optional)
279
+ * @param failedStepText - Text of the step that failed (optional)
280
+ * @param error - Error message (optional)
281
+ * @returns Promise that resolves when failure is recorded
282
+ */
283
+ export async function recordFailure(testFilePath, testHash, failedStepIndex, failedStepText, error) {
284
+ if (!testFilePath) {
285
+ return;
286
+ }
287
+ const snapshot = await getSnapshot(testFilePath, testHash);
288
+ if (!snapshot) {
289
+ // Create a minimal snapshot just for failure tracking
290
+ const now = new Date().toISOString();
291
+ const failureSnapshot = {
292
+ testHash,
293
+ testText: '',
294
+ steps: [],
295
+ stepsByHash: {},
296
+ flags: {
297
+ needsRetry: true,
298
+ hasErrors: true,
299
+ troubleshootingEnabled: false,
300
+ skipSnapshot: false,
301
+ forceRegenerate: false,
302
+ debugMode: false,
303
+ createdAt: now,
304
+ lastPassedAt: null,
305
+ lastFailedAt: now,
306
+ },
307
+ };
308
+ await saveSnapshot(testFilePath, failureSnapshot);
309
+ return;
310
+ }
311
+ // Update existing snapshot with failure info
312
+ if (!snapshot.flags) {
313
+ const now = new Date().toISOString();
314
+ snapshot.flags = {
315
+ needsRetry: true,
316
+ hasErrors: true,
317
+ troubleshootingEnabled: false,
318
+ skipSnapshot: false,
319
+ forceRegenerate: false,
320
+ debugMode: false,
321
+ createdAt: now,
322
+ lastPassedAt: null,
323
+ lastFailedAt: now,
324
+ };
325
+ }
326
+ else {
327
+ snapshot.flags.lastFailedAt = new Date().toISOString();
328
+ snapshot.flags.needsRetry = true;
329
+ snapshot.flags.hasErrors = true;
330
+ }
331
+ // Store failure details if provided (store in flags for easier access)
332
+ if (failedStepIndex !== undefined || failedStepText || error) {
333
+ snapshot.flags.failureDetails = {
334
+ failedStepIndex,
335
+ failedStepText,
336
+ error,
337
+ };
338
+ }
339
+ await saveSnapshot(testFilePath, snapshot);
340
+ }
341
+ /**
342
+ * Determine if a snapshot should be used for replay
343
+ *
344
+ * A snapshot should be used if:
345
+ * - It exists
346
+ * - lastPassedAt is more recent than lastFailedAt (or lastFailedAt is null)
347
+ * - Flags don't indicate it should be skipped
348
+ *
349
+ * Note: Even in troubleshoot mode, we use snapshots if they've passed.
350
+ * Regeneration will happen only if replay fails.
351
+ *
352
+ * @param testFilePath - Full path to the test file
353
+ * @param testHash - Hash identifier for the test
354
+ * @param troubleshootMode - Whether troubleshoot mode is enabled (unused, kept for compatibility)
355
+ * @param expectedStepCount - Expected number of steps (optional)
356
+ * @returns true if snapshot should be used, false otherwise
357
+ */
358
+ export async function shouldUseSnapshot(testFilePath, testHash, _troubleshootMode = false, expectedStepCount) {
359
+ // Use snapshots even in troubleshoot mode if they've passed
360
+ // Regeneration will happen only if replay fails
361
+ if (!testFilePath) {
362
+ return false;
363
+ }
364
+ const snapshot = await getSnapshot(testFilePath, testHash);
365
+ if (!snapshot) {
366
+ return false;
367
+ }
368
+ // Check if snapshot should be skipped
369
+ if (snapshot.flags?.skipSnapshot) {
370
+ return false;
371
+ }
372
+ // Check if force regenerate is enabled
373
+ if (snapshot.flags?.forceRegenerate) {
374
+ return false;
375
+ }
376
+ // Validate that snapshot has at least as many steps as expected input lines
377
+ if (expectedStepCount !== undefined) {
378
+ // Count unique steps in snapshot
379
+ // Support both new format (stepsByHash) and old format (steps array)
380
+ let snapshotStepCount;
381
+ if (snapshot.stepsByHash) {
382
+ snapshotStepCount = Object.keys(snapshot.stepsByHash).length;
383
+ }
384
+ else if (snapshot.steps) {
385
+ const uniqueStepIndices = new Set(snapshot.steps.map((step) => step.stepIndex));
386
+ snapshotStepCount = uniqueStepIndices.size;
387
+ }
388
+ else {
389
+ snapshotStepCount = 0;
390
+ }
391
+ if (snapshotStepCount < expectedStepCount) {
392
+ // Snapshot is incomplete - don't use it
393
+ return false;
394
+ }
395
+ }
396
+ // If never passed, don't use snapshot
397
+ if (!snapshot.flags?.lastPassedAt) {
398
+ return false;
399
+ }
400
+ // If never failed, use snapshot
401
+ if (!snapshot.flags?.lastFailedAt) {
402
+ return true;
403
+ }
404
+ // Compare timestamps: use snapshot if pass is more recent than failure
405
+ const passTime = new Date(snapshot.flags.lastPassedAt).getTime();
406
+ const failTime = new Date(snapshot.flags.lastFailedAt).getTime();
407
+ return passTime > failTime;
408
+ }
409
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/mimic/storage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGp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ution snapshots.
5
+ */
6
+ import type { NavigationAction } from './schema/action.js';
7
+ import type { ClickActionResult } from './schema/action.js';
8
+ import type { FormActionResult } from './forms.js';
9
+ import type { SelectorDescriptor } from './selectorTypes.js';
10
+ /**
11
+ * Target element information using best selector with mimicId fallback
12
+ */
13
+ export interface MarkerTargetElement {
14
+ /** The best selector descriptor for the element (primary) */
15
+ selector: SelectorDescriptor;
16
+ /** The mimic ID assigned to the element by the markers system (fallback) */
17
+ mimicId: number;
18
+ }
19
+ /**
20
+ * A single step in a test execution snapshot
21
+ */
22
+ export interface SnapshotStep {
23
+ /** Hash of the step text for identification */
24
+ stepHash: string;
25
+ /** Index of the step in the test (0-based) */
26
+ stepIndex: number;
27
+ /** Original step text (Gherkin step) */
28
+ stepText: string;
29
+ /** Type of action (navigation, click, form update) */
30
+ actionKind: 'navigation' | 'click' | 'form update';
31
+ /** Full action details (varies by actionKind) */
32
+ actionDetails: NavigationAction | ClickActionResult | FormActionResult;
33
+ /** Target element information using marker ID (for click and form actions) */
34
+ targetElement?: MarkerTargetElement;
35
+ /** Timestamp when this step was executed */
36
+ executedAt: string;
37
+ }
38
+ /**
39
+ * Flags for test execution metadata and configuration
40
+ */
41
+ export interface SnapshotFlags {
42
+ /** Metadata flags */
43
+ needsRetry: boolean;
44
+ hasErrors: boolean;
45
+ troubleshootingEnabled: boolean;
46
+ /** Configuration flags */
47
+ skipSnapshot: boolean;
48
+ forceRegenerate: boolean;
49
+ debugMode: boolean;
50
+ /** Timestamps */
51
+ createdAt: string;
52
+ lastPassedAt: string | null;
53
+ lastFailedAt: string | null;
54
+ }
55
+ /**
56
+ * Complete snapshot of a test execution
57
+ */
58
+ export interface Snapshot {
59
+ /** Hash identifier for this test */
60
+ testHash: string;
61
+ /** Original test text (mimic template string) */
62
+ testText: string;
63
+ /** Steps indexed by stepHash (command line text hash) for efficient lookup and selective regeneration */
64
+ stepsByHash: Record<string, SnapshotStep>;
65
+ /** Array of executed steps (for backward compatibility and ordered replay) */
66
+ steps: SnapshotStep[];
67
+ /** Flags for troubleshooting and configuration */
68
+ flags: SnapshotFlags;
69
+ }
70
+ /**
71
+ * Result of executing a single step (for snapshot creation)
72
+ */
73
+ export interface StepExecutionResult {
74
+ /** Index of the step in the test (0-based) */
75
+ stepIndex: number;
76
+ /** Original step text (Gherkin step) */
77
+ stepText: string;
78
+ /** Type of action (navigation, click, form update) */
79
+ actionKind: 'navigation' | 'click' | 'form update';
80
+ /** Full action details (varies by actionKind) */
81
+ actionDetails: NavigationAction | ClickActionResult | FormActionResult;
82
+ /** Target element information using marker ID (for click and form actions) */
83
+ targetElement?: MarkerTargetElement;
84
+ }
85
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/mimic/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,6DAA6D;IAC7D,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,UAAU,EAAE,YAAY,GAAG,OAAO,GAAG,aAAa,CAAC;IACnD,iDAAiD;IACjD,aAAa,EAAE,gBAAgB,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;IAC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
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/mimic/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
package/dist/mimic.d.ts CHANGED
@@ -4,23 +4,48 @@
4
4
  import { Page, TestInfo } from '@playwright/test';
5
5
  import type { LanguageModel } from 'ai';
6
6
  export type Mimic = (steps: TemplateStringsArray, ...args: unknown[]) => Promise<void>;
7
+ /**
8
+ * Test context that tracks previous state and actions for better decision-making
9
+ */
10
+ export interface TestContext {
11
+ /** Previous steps that have been executed */
12
+ previousSteps: Array<{
13
+ stepIndex: number;
14
+ stepText: string;
15
+ actionKind: string;
16
+ url?: string;
17
+ pageTitle?: string;
18
+ }>;
19
+ /** Current page state */
20
+ currentState: {
21
+ url: string;
22
+ pageTitle: string;
23
+ };
24
+ /** Total number of steps in the test */
25
+ totalSteps: number;
26
+ /** Current step index */
27
+ currentStepIndex: number;
28
+ }
7
29
  /**
8
30
  * Minimal flow function that takes a Playwright page and input string
9
31
  *
10
32
  * @param page - Playwright Page object
11
33
  * @param input - Input string to process
34
+ * @param testFilePath - Directory path of the test file (for snapshot storage)
35
+ * @param troubleshootMode - Whether troubleshoot mode is enabled
12
36
  * @returns Flow execution result with validated context
13
37
  */
14
- export declare function mimic(input: string, { page, brains, testInfo }: {
38
+ export declare function mimic(input: string, { page, brains, testInfo, testFilePath, troubleshootMode }: {
15
39
  page: Page;
16
40
  brains: LanguageModel;
17
- eyes: LanguageModel;
18
- testInfo?: TestInfo;
41
+ testInfo: TestInfo | undefined;
42
+ testFilePath?: string;
43
+ troubleshootMode?: boolean;
19
44
  }): Promise<void>;
20
45
  export declare const createMimic: (config: {
21
46
  page: Page;
22
47
  brains: LanguageModel;
23
- eyes: LanguageModel;
48
+ eyes?: LanguageModel;
24
49
  testInfo?: TestInfo;
25
50
  }) => (prompt: TemplateStringsArray, ...args: unknown[]) => Promise<void>;
26
51
  //# sourceMappingURL=mimic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mimic.d.ts","sourceRoot":"","sources":["../src/mimic.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAQ,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAQxC,MAAM,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,oBAAoB,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAGvF;;;;;;GAMG;AACH,wBAAsB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE;IACrE,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,iBAwCA;AAeD,eAAO,MAAM,WAAW,GAAI,QAAQ;IAClC,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,MACe,QAAQ,oBAAoB,EAAE,GAAG,MAAM,OAAO,EAAE,kBAI/D,CAAA"}
1
+ {"version":3,"file":"mimic.d.ts","sourceRoot":"","sources":["../src/mimic.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAQ,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAoBxC,MAAM,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,oBAAoB,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEvF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,6CAA6C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