testdriverai 7.2.3 → 7.2.9
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/.github/workflows/publish.yaml +15 -7
- package/.github/workflows/testdriver.yml +36 -0
- package/agent/index.js +28 -109
- package/bin/testdriverai.js +8 -0
- package/debugger/index.html +37 -0
- package/docs/v7/_drafts/architecture.mdx +1 -26
- package/docs/v7/_drafts/quick-start-test-recording.mdx +0 -1
- package/docs/v7/_drafts/test-recording.mdx +0 -6
- package/docs/v7/api/act.mdx +1 -0
- package/interfaces/cli/commands/init.js +33 -19
- package/interfaces/cli/lib/base.js +24 -0
- package/interfaces/cli.js +8 -1
- package/interfaces/logger.js +8 -3
- package/interfaces/vitest-plugin.mjs +16 -71
- package/lib/sentry.js +343 -0
- package/lib/vitest/hooks.mjs +12 -24
- package/package.json +4 -3
- package/sdk-log-formatter.js +41 -0
- package/sdk.js +167 -56
- package/test/testdriver/act.test.mjs +30 -0
- package/test/testdriver/assert.test.mjs +1 -1
- package/test/testdriver/hover-text.test.mjs +1 -1
- package/test/testdriver/setup/testHelpers.mjs +8 -118
- package/tests/example.test.js +33 -0
- package/tests/login.js +28 -0
- package/vitest.config.js +18 -0
- package/vitest.config.mjs +2 -1
- package/agent/lib/cache.js +0 -142
package/agent/lib/cache.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const crypto = require("crypto");
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Generate a cache key from a prompt
|
|
7
|
-
* Uses a hash to create a safe filename
|
|
8
|
-
*/
|
|
9
|
-
function getCacheKey(prompt) {
|
|
10
|
-
// Normalize the prompt by trimming and converting to lowercase
|
|
11
|
-
const normalized = prompt.trim().toLowerCase();
|
|
12
|
-
|
|
13
|
-
// Create a hash for the filename
|
|
14
|
-
const hash = crypto.createHash("md5").update(normalized).digest("hex");
|
|
15
|
-
|
|
16
|
-
// Also create a sanitized version of the prompt for readability
|
|
17
|
-
const sanitized = normalized
|
|
18
|
-
.replace(/[^a-z0-9\s]/g, "") // Remove special chars
|
|
19
|
-
.replace(/\s+/g, "-") // Replace spaces with hyphens
|
|
20
|
-
.substring(0, 50); // Limit length
|
|
21
|
-
|
|
22
|
-
// Combine sanitized prompt with hash for uniqueness
|
|
23
|
-
return `${sanitized}-${hash}.yaml`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Get the cache directory path
|
|
28
|
-
* Creates it if it doesn't exist
|
|
29
|
-
*/
|
|
30
|
-
function getCacheDir() {
|
|
31
|
-
const cacheDir = path.join(process.cwd(), ".testdriver", ".cache");
|
|
32
|
-
|
|
33
|
-
if (!fs.existsSync(cacheDir)) {
|
|
34
|
-
fs.mkdirSync(cacheDir, { recursive: true });
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return cacheDir;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Get the full path to a cache file
|
|
42
|
-
*/
|
|
43
|
-
function getCachePath(prompt) {
|
|
44
|
-
const cacheDir = getCacheDir();
|
|
45
|
-
const key = getCacheKey(prompt);
|
|
46
|
-
return path.join(cacheDir, key);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Check if a cached response exists for a prompt
|
|
51
|
-
*/
|
|
52
|
-
function hasCache(prompt) {
|
|
53
|
-
const cachePath = getCachePath(prompt);
|
|
54
|
-
return fs.existsSync(cachePath);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Read cached YAML for a prompt
|
|
59
|
-
* Returns null if no cache exists
|
|
60
|
-
*/
|
|
61
|
-
function readCache(prompt) {
|
|
62
|
-
if (!hasCache(prompt)) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
const cachePath = getCachePath(prompt);
|
|
68
|
-
const yaml = fs.readFileSync(cachePath, "utf8");
|
|
69
|
-
return yaml;
|
|
70
|
-
} catch {
|
|
71
|
-
// If there's an error reading the cache, return null
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Write YAML to cache for a prompt
|
|
78
|
-
*/
|
|
79
|
-
function writeCache(prompt, yaml) {
|
|
80
|
-
try {
|
|
81
|
-
const cachePath = getCachePath(prompt);
|
|
82
|
-
fs.writeFileSync(cachePath, yaml, "utf8");
|
|
83
|
-
return cachePath;
|
|
84
|
-
} catch {
|
|
85
|
-
// Silently fail if we can't write to cache
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Clear all cached prompts
|
|
92
|
-
*/
|
|
93
|
-
function clearCache() {
|
|
94
|
-
const cacheDir = getCacheDir();
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
const files = fs.readdirSync(cacheDir);
|
|
98
|
-
|
|
99
|
-
for (const file of files) {
|
|
100
|
-
if (file.endsWith(".yaml")) {
|
|
101
|
-
fs.unlinkSync(path.join(cacheDir, file));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return true;
|
|
106
|
-
} catch {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Get cache statistics
|
|
113
|
-
*/
|
|
114
|
-
function getCacheStats() {
|
|
115
|
-
const cacheDir = getCacheDir();
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
const files = fs.readdirSync(cacheDir);
|
|
119
|
-
const yamlFiles = files.filter((f) => f.endsWith(".yaml"));
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
count: yamlFiles.length,
|
|
123
|
-
files: yamlFiles,
|
|
124
|
-
};
|
|
125
|
-
} catch {
|
|
126
|
-
return {
|
|
127
|
-
count: 0,
|
|
128
|
-
files: [],
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
module.exports = {
|
|
134
|
-
getCacheKey,
|
|
135
|
-
getCacheDir,
|
|
136
|
-
getCachePath,
|
|
137
|
-
hasCache,
|
|
138
|
-
readCache,
|
|
139
|
-
writeCache,
|
|
140
|
-
clearCache,
|
|
141
|
-
getCacheStats,
|
|
142
|
-
};
|