aspectcode 0.3.4 → 0.4.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.
- package/dist/cli.d.ts +1 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -2
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +0 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/diffSummary.d.ts +17 -0
- package/dist/diffSummary.d.ts.map +1 -0
- package/dist/diffSummary.js +49 -0
- package/dist/diffSummary.js.map +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +13 -16
- package/dist/main.js.map +1 -1
- package/dist/optimize.d.ts +6 -3
- package/dist/optimize.d.ts.map +1 -1
- package/dist/optimize.js +85 -102
- package/dist/optimize.js.map +1 -1
- package/dist/pipeline.d.ts +5 -4
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +45 -10
- package/dist/pipeline.js.map +1 -1
- package/dist/summary.d.ts +15 -0
- package/dist/summary.d.ts.map +1 -0
- package/dist/summary.js +51 -0
- package/dist/summary.js.map +1 -0
- package/dist/ui/Dashboard.d.ts +15 -7
- package/dist/ui/Dashboard.d.ts.map +1 -1
- package/dist/ui/Dashboard.js +55 -24
- package/dist/ui/Dashboard.js.map +1 -1
- package/dist/ui/store.d.ts +33 -0
- package/dist/ui/store.d.ts.map +1 -1
- package/dist/ui/store.js +24 -1
- package/dist/ui/store.js.map +1 -1
- package/dist/ui/theme.d.ts +3 -3
- package/dist/ui/theme.js +3 -3
- package/dist/ui/theme.js.map +1 -1
- package/node_modules/@aspectcode/evaluator/dist/diagnosis.d.ts +33 -0
- package/node_modules/@aspectcode/evaluator/dist/diagnosis.d.ts.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/diagnosis.js +172 -0
- package/node_modules/@aspectcode/evaluator/dist/diagnosis.js.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/aider.d.ts +23 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/aider.d.ts.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/aider.js +125 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/aider.js.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/claudeCode.d.ts +17 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/claudeCode.d.ts.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/claudeCode.js +223 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/claudeCode.js.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/cline.d.ts +17 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/cline.d.ts.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/cline.js +179 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/cline.js.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/common.d.ts +39 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/common.d.ts.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/common.js +170 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/common.js.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/export.d.ts +23 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/export.d.ts.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/export.js +98 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/export.js.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/index.d.ts +29 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/index.d.ts.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/index.js +94 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/index.js.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/vscodeDb.d.ts +37 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/vscodeDb.d.ts.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/vscodeDb.js +473 -0
- package/node_modules/@aspectcode/evaluator/dist/harvest/vscodeDb.js.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/index.d.ts +49 -0
- package/node_modules/@aspectcode/evaluator/dist/index.d.ts.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/index.js +75 -0
- package/node_modules/@aspectcode/evaluator/dist/index.js.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/probes.d.ts +38 -0
- package/node_modules/@aspectcode/evaluator/dist/probes.d.ts.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/probes.js +229 -0
- package/node_modules/@aspectcode/evaluator/dist/probes.js.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/runner.d.ts +44 -0
- package/node_modules/@aspectcode/evaluator/dist/runner.d.ts.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/runner.js +186 -0
- package/node_modules/@aspectcode/evaluator/dist/runner.js.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/types.d.ts +176 -0
- package/node_modules/@aspectcode/evaluator/dist/types.d.ts.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/types.js +9 -0
- package/node_modules/@aspectcode/evaluator/dist/types.js.map +1 -0
- package/node_modules/@aspectcode/evaluator/package.json +41 -0
- package/node_modules/@aspectcode/optimizer/dist/agent.d.ts +12 -13
- package/node_modules/@aspectcode/optimizer/dist/agent.d.ts.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/agent.js +52 -110
- package/node_modules/@aspectcode/optimizer/dist/agent.js.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/index.d.ts +3 -3
- package/node_modules/@aspectcode/optimizer/dist/index.d.ts.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/index.js +3 -5
- package/node_modules/@aspectcode/optimizer/dist/index.js.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/prompts.d.ts +8 -21
- package/node_modules/@aspectcode/optimizer/dist/prompts.d.ts.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/prompts.js +36 -94
- package/node_modules/@aspectcode/optimizer/dist/prompts.js.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/providers/anthropic.d.ts.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/providers/anthropic.js +10 -1
- package/node_modules/@aspectcode/optimizer/dist/providers/anthropic.js.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/providers/openai.d.ts.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/providers/openai.js +10 -1
- package/node_modules/@aspectcode/optimizer/dist/providers/openai.js.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/types.d.ts +33 -24
- package/node_modules/@aspectcode/optimizer/dist/types.d.ts.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/types.js.map +1 -1
- package/node_modules/@aspectcode/optimizer/package.json +2 -2
- package/package.json +4 -3
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SQLite-based prompt harvester for VS Code forks (Copilot Chat, Cursor, Windsurf).
|
|
4
|
+
*
|
|
5
|
+
* All three store conversations in `state.vscdb` — a SQLite database with an
|
|
6
|
+
* `ItemTable(key TEXT, value TEXT)` key-value schema. The difference is which
|
|
7
|
+
* keys hold the conversation data and the JSON shape within.
|
|
8
|
+
*
|
|
9
|
+
* `better-sqlite3` is an optional dependency. If unavailable, these
|
|
10
|
+
* harvesters gracefully return empty arrays.
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.harvestCopilotChat = harvestCopilotChat;
|
|
47
|
+
exports.harvestCursor = harvestCursor;
|
|
48
|
+
exports.harvestWindsurf = harvestWindsurf;
|
|
49
|
+
const fs = __importStar(require("fs"));
|
|
50
|
+
const path = __importStar(require("path"));
|
|
51
|
+
const os = __importStar(require("os"));
|
|
52
|
+
const common_1 = require("./common");
|
|
53
|
+
// ── SQLite availability check ───────────────────────────────
|
|
54
|
+
let Database;
|
|
55
|
+
function loadSqlite() {
|
|
56
|
+
if (Database !== undefined)
|
|
57
|
+
return Database !== null;
|
|
58
|
+
try {
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
60
|
+
Database = require('better-sqlite3');
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
Database = null;
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Read a key from a state.vscdb file. Returns undefined if the key
|
|
70
|
+
* doesn't exist or the DB can't be opened.
|
|
71
|
+
*/
|
|
72
|
+
function readVscdbKey(dbPath, key) {
|
|
73
|
+
if (!loadSqlite() || !fs.existsSync(dbPath))
|
|
74
|
+
return undefined;
|
|
75
|
+
let db;
|
|
76
|
+
try {
|
|
77
|
+
db = new Database(dbPath, { readonly: true, fileMustExist: true });
|
|
78
|
+
const row = db.prepare('SELECT value FROM ItemTable WHERE key = ?').get(key);
|
|
79
|
+
return row?.value ?? undefined;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
db?.close();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Read ALL keys matching a pattern from a state.vscdb file.
|
|
90
|
+
*/
|
|
91
|
+
function readVscdbKeysLike(dbPath, pattern) {
|
|
92
|
+
if (!loadSqlite() || !fs.existsSync(dbPath))
|
|
93
|
+
return [];
|
|
94
|
+
let db;
|
|
95
|
+
try {
|
|
96
|
+
db = new Database(dbPath, { readonly: true, fileMustExist: true });
|
|
97
|
+
return db.prepare('SELECT key, value FROM ItemTable WHERE key LIKE ?').all(pattern);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
db?.close();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// ── Copilot Chat ────────────────────────────────────────────
|
|
107
|
+
/**
|
|
108
|
+
* Harvest prompts from GitHub Copilot Chat conversations.
|
|
109
|
+
*/
|
|
110
|
+
async function harvestCopilotChat(root, options) {
|
|
111
|
+
const log = options?.log ?? common_1.noopLogger;
|
|
112
|
+
const max = options?.max ?? common_1.DEFAULT_MAX_PER_SOURCE;
|
|
113
|
+
if (!loadSqlite()) {
|
|
114
|
+
log.debug('copilot-chat: better-sqlite3 not available, skipping');
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
const prompts = [];
|
|
118
|
+
// Strategy 1: Check workspace storage state.vscdb files
|
|
119
|
+
const wsStorageBase = (0, common_1.vscodeWorkspaceStoragePath)();
|
|
120
|
+
if (fs.existsSync(wsStorageBase)) {
|
|
121
|
+
try {
|
|
122
|
+
const workspaces = fs.readdirSync(wsStorageBase);
|
|
123
|
+
for (const ws of workspaces) {
|
|
124
|
+
const dbPath = path.join(wsStorageBase, ws, 'state.vscdb');
|
|
125
|
+
const parsed = parseCopilotFromVscdb(dbPath, root, log);
|
|
126
|
+
prompts.push(...parsed);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
log.debug(`copilot-chat: failed scanning workspace storage: ${err}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Strategy 2: Check older extension-based storage
|
|
134
|
+
const globalStorageDir = path.join(getVscodeDataDir(), 'User', 'globalStorage', 'github.copilot-chat');
|
|
135
|
+
const conversationsFile = path.join(globalStorageDir, 'conversations.json');
|
|
136
|
+
if (fs.existsSync(conversationsFile)) {
|
|
137
|
+
try {
|
|
138
|
+
const content = fs.readFileSync(conversationsFile, 'utf-8');
|
|
139
|
+
const data = JSON.parse(content);
|
|
140
|
+
const parsed = parseCopilotConversationsJson(data, root);
|
|
141
|
+
prompts.push(...parsed);
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
log.debug(`copilot-chat: failed parsing conversations.json: ${err}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
log.debug(`copilot-chat: parsed ${prompts.length} conversation turns`);
|
|
148
|
+
return (0, common_1.filterRecent)(prompts, options?.since, max);
|
|
149
|
+
}
|
|
150
|
+
function parseCopilotFromVscdb(dbPath, root, _log) {
|
|
151
|
+
// Try known keys for chat sessions
|
|
152
|
+
const keyPatterns = ['interactive.sessions', 'chat.workspaceState', '%chat%'];
|
|
153
|
+
const prompts = [];
|
|
154
|
+
for (const pattern of keyPatterns) {
|
|
155
|
+
let rows;
|
|
156
|
+
if (pattern.includes('%')) {
|
|
157
|
+
rows = readVscdbKeysLike(dbPath, pattern);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
const value = readVscdbKey(dbPath, pattern);
|
|
161
|
+
rows = value ? [{ key: pattern, value }] : [];
|
|
162
|
+
}
|
|
163
|
+
for (const row of rows) {
|
|
164
|
+
try {
|
|
165
|
+
const data = JSON.parse(row.value);
|
|
166
|
+
const parsed = parseCopilotSessionData(data, root);
|
|
167
|
+
prompts.push(...parsed);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
// Unparseable value, skip
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return prompts;
|
|
175
|
+
}
|
|
176
|
+
function parseCopilotSessionData(data, root) {
|
|
177
|
+
const prompts = [];
|
|
178
|
+
// Handle array of sessions or single session
|
|
179
|
+
const sessions = Array.isArray(data) ? data : [data];
|
|
180
|
+
for (const session of sessions) {
|
|
181
|
+
const requests = session.requests || session.entries || [];
|
|
182
|
+
for (const req of requests) {
|
|
183
|
+
const userText = req.message || req.text || req.prompt || '';
|
|
184
|
+
const assistantText = req.response?.value || req.response?.text || req.result?.text || '';
|
|
185
|
+
if (!userText || !assistantText)
|
|
186
|
+
continue;
|
|
187
|
+
const fileRefs = [];
|
|
188
|
+
if (Array.isArray(req.references)) {
|
|
189
|
+
for (const ref of req.references) {
|
|
190
|
+
if (ref.uri && typeof ref.uri === 'string') {
|
|
191
|
+
// Extract path from file:// URI
|
|
192
|
+
const filePath = ref.uri.replace(/^file:\/\/\//, '').replace(/\\/g, '/');
|
|
193
|
+
fileRefs.push(filePath);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const allText = userText + '\n' + assistantText;
|
|
198
|
+
prompts.push({
|
|
199
|
+
source: 'copilot-chat',
|
|
200
|
+
timestamp: req.timestamp ? new Date(req.timestamp).toISOString() : undefined,
|
|
201
|
+
userPrompt: userText,
|
|
202
|
+
assistantResponse: assistantText,
|
|
203
|
+
filesReferenced: [...new Set([...(0, common_1.extractFilePaths)(allText, root), ...fileRefs])],
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return prompts;
|
|
208
|
+
}
|
|
209
|
+
function parseCopilotConversationsJson(data, root) {
|
|
210
|
+
// Older format: { sessions: [{ requests: [...] }] } or just an array
|
|
211
|
+
if (data.sessions)
|
|
212
|
+
return parseCopilotSessionData(data.sessions, root);
|
|
213
|
+
if (Array.isArray(data))
|
|
214
|
+
return parseCopilotSessionData(data, root);
|
|
215
|
+
return [];
|
|
216
|
+
}
|
|
217
|
+
// ── Cursor ──────────────────────────────────────────────────
|
|
218
|
+
/**
|
|
219
|
+
* Harvest prompts from Cursor's conversation history.
|
|
220
|
+
*/
|
|
221
|
+
async function harvestCursor(root, options) {
|
|
222
|
+
const log = options?.log ?? common_1.noopLogger;
|
|
223
|
+
const max = options?.max ?? common_1.DEFAULT_MAX_PER_SOURCE;
|
|
224
|
+
if (!loadSqlite()) {
|
|
225
|
+
log.debug('cursor: better-sqlite3 not available, skipping');
|
|
226
|
+
return [];
|
|
227
|
+
}
|
|
228
|
+
const [globalDb, wsStorageBase] = (0, common_1.vscodeForkStoragePaths)('Cursor');
|
|
229
|
+
const prompts = [];
|
|
230
|
+
// Check global state.vscdb
|
|
231
|
+
const globalParsed = parseCursorDb(globalDb, root, log);
|
|
232
|
+
prompts.push(...globalParsed);
|
|
233
|
+
// Check workspace storage state.vscdb files
|
|
234
|
+
if (fs.existsSync(wsStorageBase)) {
|
|
235
|
+
try {
|
|
236
|
+
const workspaces = fs.readdirSync(wsStorageBase);
|
|
237
|
+
for (const ws of workspaces) {
|
|
238
|
+
const dbPath = path.join(wsStorageBase, ws, 'state.vscdb');
|
|
239
|
+
const parsed = parseCursorDb(dbPath, root, log);
|
|
240
|
+
prompts.push(...parsed);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
catch (err) {
|
|
244
|
+
log.debug(`cursor: failed scanning workspace storage: ${err}`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
log.debug(`cursor: parsed ${prompts.length} conversation turns`);
|
|
248
|
+
return (0, common_1.filterRecent)(prompts, options?.since, max);
|
|
249
|
+
}
|
|
250
|
+
function parseCursorDb(dbPath, root, log) {
|
|
251
|
+
const prompts = [];
|
|
252
|
+
// Try known keys for Cursor chat data
|
|
253
|
+
const chatKeys = ['composerData', 'aiChat.panelChats', 'workbench.panel.chat'];
|
|
254
|
+
for (const key of chatKeys) {
|
|
255
|
+
const value = readVscdbKey(dbPath, key);
|
|
256
|
+
if (!value)
|
|
257
|
+
continue;
|
|
258
|
+
try {
|
|
259
|
+
const data = JSON.parse(value);
|
|
260
|
+
if (key === 'composerData') {
|
|
261
|
+
prompts.push(...parseCursorComposer(data, root));
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
prompts.push(...parseCursorPanelChats(data, root));
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch (err) {
|
|
268
|
+
log.debug(`cursor: failed parsing key ${key}: ${err}`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return prompts;
|
|
272
|
+
}
|
|
273
|
+
function parseCursorComposer(data, root) {
|
|
274
|
+
const prompts = [];
|
|
275
|
+
const composers = data.allComposers || data.composers || [];
|
|
276
|
+
for (const composer of composers) {
|
|
277
|
+
const conversation = composer.conversation || [];
|
|
278
|
+
for (let i = 0; i < conversation.length; i++) {
|
|
279
|
+
const msg = conversation[i];
|
|
280
|
+
// type 1 = user, type 2 = assistant
|
|
281
|
+
if (msg.type !== 1)
|
|
282
|
+
continue;
|
|
283
|
+
const next = conversation[i + 1];
|
|
284
|
+
if (!next || next.type !== 2)
|
|
285
|
+
continue;
|
|
286
|
+
const userText = msg.text || '';
|
|
287
|
+
const assistantText = next.text || '';
|
|
288
|
+
if (!userText || !assistantText)
|
|
289
|
+
continue;
|
|
290
|
+
const fileRefs = extractCursorContextFiles(msg.context);
|
|
291
|
+
const allText = userText + '\n' + assistantText;
|
|
292
|
+
prompts.push({
|
|
293
|
+
source: 'cursor',
|
|
294
|
+
userPrompt: userText,
|
|
295
|
+
assistantResponse: assistantText,
|
|
296
|
+
filesReferenced: [...new Set([...(0, common_1.extractFilePaths)(allText, root), ...fileRefs])],
|
|
297
|
+
});
|
|
298
|
+
i++; // Skip the assistant message
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return prompts;
|
|
302
|
+
}
|
|
303
|
+
function parseCursorPanelChats(data, root) {
|
|
304
|
+
const prompts = [];
|
|
305
|
+
const panels = data.panelChats || data.chats || [];
|
|
306
|
+
for (const panel of panels) {
|
|
307
|
+
if (panel.isDeleted)
|
|
308
|
+
continue;
|
|
309
|
+
const messages = panel.messages || [];
|
|
310
|
+
for (let i = 0; i < messages.length; i++) {
|
|
311
|
+
const msg = messages[i];
|
|
312
|
+
if (msg.role !== 'user')
|
|
313
|
+
continue;
|
|
314
|
+
const next = messages[i + 1];
|
|
315
|
+
if (!next || next.role !== 'assistant')
|
|
316
|
+
continue;
|
|
317
|
+
const userText = msg.content || '';
|
|
318
|
+
const assistantText = next.content || '';
|
|
319
|
+
if (!userText || !assistantText)
|
|
320
|
+
continue;
|
|
321
|
+
const fileRefs = extractCursorContextFiles(next.context);
|
|
322
|
+
const timestamp = msg.timestamp
|
|
323
|
+
? new Date(msg.timestamp).toISOString()
|
|
324
|
+
: undefined;
|
|
325
|
+
const allText = userText + '\n' + assistantText;
|
|
326
|
+
prompts.push({
|
|
327
|
+
source: 'cursor',
|
|
328
|
+
timestamp,
|
|
329
|
+
userPrompt: userText,
|
|
330
|
+
assistantResponse: assistantText,
|
|
331
|
+
filesReferenced: [...new Set([...(0, common_1.extractFilePaths)(allText, root), ...fileRefs])],
|
|
332
|
+
});
|
|
333
|
+
i++; // Skip the assistant message
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return prompts;
|
|
337
|
+
}
|
|
338
|
+
function extractCursorContextFiles(context) {
|
|
339
|
+
if (!context)
|
|
340
|
+
return [];
|
|
341
|
+
const files = [];
|
|
342
|
+
if (Array.isArray(context.files)) {
|
|
343
|
+
for (const f of context.files) {
|
|
344
|
+
if (typeof f === 'string')
|
|
345
|
+
files.push(f.replace(/\\/g, '/'));
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if (Array.isArray(context.selections)) {
|
|
349
|
+
for (const s of context.selections) {
|
|
350
|
+
if (s.uri && typeof s.uri === 'string') {
|
|
351
|
+
files.push(s.uri.replace(/^file:\/\/\//, '').replace(/\\/g, '/'));
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return files;
|
|
356
|
+
}
|
|
357
|
+
// ── Windsurf ────────────────────────────────────────────────
|
|
358
|
+
/**
|
|
359
|
+
* Harvest prompts from Windsurf's conversation history.
|
|
360
|
+
*/
|
|
361
|
+
async function harvestWindsurf(root, options) {
|
|
362
|
+
const log = options?.log ?? common_1.noopLogger;
|
|
363
|
+
const max = options?.max ?? common_1.DEFAULT_MAX_PER_SOURCE;
|
|
364
|
+
if (!loadSqlite()) {
|
|
365
|
+
log.debug('windsurf: better-sqlite3 not available, skipping');
|
|
366
|
+
return [];
|
|
367
|
+
}
|
|
368
|
+
const prompts = [];
|
|
369
|
+
// Try both "Windsurf" and "Codeium" (legacy name)
|
|
370
|
+
for (const appName of ['Windsurf', 'Codeium']) {
|
|
371
|
+
const [globalDb, wsStorageBase] = (0, common_1.vscodeForkStoragePaths)(appName);
|
|
372
|
+
// Check global state.vscdb
|
|
373
|
+
const globalParsed = parseWindsurfDb(globalDb, root, log);
|
|
374
|
+
prompts.push(...globalParsed);
|
|
375
|
+
// Check workspace storage
|
|
376
|
+
if (fs.existsSync(wsStorageBase)) {
|
|
377
|
+
try {
|
|
378
|
+
const workspaces = fs.readdirSync(wsStorageBase);
|
|
379
|
+
for (const ws of workspaces) {
|
|
380
|
+
const dbPath = path.join(wsStorageBase, ws, 'state.vscdb');
|
|
381
|
+
const parsed = parseWindsurfDb(dbPath, root, log);
|
|
382
|
+
prompts.push(...parsed);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
catch (err) {
|
|
386
|
+
log.debug(`windsurf: failed scanning ${appName} workspace storage: ${err}`);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
log.debug(`windsurf: parsed ${prompts.length} conversation turns`);
|
|
391
|
+
return (0, common_1.filterRecent)(prompts, options?.since, max);
|
|
392
|
+
}
|
|
393
|
+
function parseWindsurfDb(dbPath, root, log) {
|
|
394
|
+
const prompts = [];
|
|
395
|
+
// Try known keys for Windsurf/Cascade conversations
|
|
396
|
+
const candidates = ['cascadeHistory', 'cascade.conversations'];
|
|
397
|
+
for (const key of candidates) {
|
|
398
|
+
const value = readVscdbKey(dbPath, key);
|
|
399
|
+
if (!value)
|
|
400
|
+
continue;
|
|
401
|
+
try {
|
|
402
|
+
const data = JSON.parse(value);
|
|
403
|
+
prompts.push(...parseWindsurfConversations(data, root));
|
|
404
|
+
}
|
|
405
|
+
catch (err) {
|
|
406
|
+
log.debug(`windsurf: failed parsing key ${key}: ${err}`);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
// Also try LIKE query for cascade-related keys
|
|
410
|
+
const likeRows = readVscdbKeysLike(dbPath, '%cascade%');
|
|
411
|
+
for (const row of likeRows) {
|
|
412
|
+
if (candidates.includes(row.key))
|
|
413
|
+
continue; // Already tried
|
|
414
|
+
try {
|
|
415
|
+
const data = JSON.parse(row.value);
|
|
416
|
+
prompts.push(...parseWindsurfConversations(data, root));
|
|
417
|
+
}
|
|
418
|
+
catch {
|
|
419
|
+
// Skip unparseable
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return prompts;
|
|
423
|
+
}
|
|
424
|
+
function parseWindsurfConversations(data, root) {
|
|
425
|
+
const prompts = [];
|
|
426
|
+
// Try multiple possible structures
|
|
427
|
+
const conversations = data.conversations || data.chats || (Array.isArray(data) ? data : [data]);
|
|
428
|
+
for (const conv of conversations) {
|
|
429
|
+
const messages = conv.messages || conv.turns || [];
|
|
430
|
+
for (let i = 0; i < messages.length; i++) {
|
|
431
|
+
const msg = messages[i];
|
|
432
|
+
if (msg.role !== 'user')
|
|
433
|
+
continue;
|
|
434
|
+
const next = messages[i + 1];
|
|
435
|
+
if (!next || next.role !== 'assistant')
|
|
436
|
+
continue;
|
|
437
|
+
const userText = msg.content || msg.text || '';
|
|
438
|
+
const assistantText = next.content || next.text || '';
|
|
439
|
+
if (!userText || !assistantText)
|
|
440
|
+
continue;
|
|
441
|
+
const allText = userText + '\n' + assistantText;
|
|
442
|
+
const timestamp = msg.timestamp
|
|
443
|
+
? (typeof msg.timestamp === 'number'
|
|
444
|
+
? new Date(msg.timestamp).toISOString()
|
|
445
|
+
: msg.timestamp)
|
|
446
|
+
: undefined;
|
|
447
|
+
prompts.push({
|
|
448
|
+
source: 'windsurf',
|
|
449
|
+
timestamp,
|
|
450
|
+
userPrompt: userText,
|
|
451
|
+
assistantResponse: assistantText,
|
|
452
|
+
filesReferenced: (0, common_1.extractFilePaths)(allText, root),
|
|
453
|
+
});
|
|
454
|
+
i++; // Skip the assistant message
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return prompts;
|
|
458
|
+
}
|
|
459
|
+
// ── Helpers ─────────────────────────────────────────────────
|
|
460
|
+
function getVscodeDataDir() {
|
|
461
|
+
const platform = os.platform();
|
|
462
|
+
const home = os.homedir();
|
|
463
|
+
if (platform === 'win32') {
|
|
464
|
+
return path.join(process.env.APPDATA || path.join(home, 'AppData', 'Roaming'), 'Code');
|
|
465
|
+
}
|
|
466
|
+
else if (platform === 'darwin') {
|
|
467
|
+
return path.join(home, 'Library', 'Application Support', 'Code');
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
return path.join(home, '.config', 'Code');
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
//# sourceMappingURL=vscodeDb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vscodeDb.js","sourceRoot":"","sources":["../../src/harvest/vscodeDb.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEH,gDAgDC;AAiFD,sCAmCC;AA4HD,0CAuCC;AA5YD,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AAEzB,qCAOkB;AAGlB,+DAA+D;AAE/D,IAAI,QAAa,CAAC;AAElB,SAAS,UAAU;IACjB,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,QAAQ,KAAK,IAAI,CAAC;IACrD,IAAI,CAAC;QACH,8DAA8D;QAC9D,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,QAAQ,GAAG,IAAI,CAAC;QAChB,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,YAAY,CAAC,MAAc,EAAE,GAAW;IAC/C,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IAC9D,IAAI,EAAO,CAAC;IACZ,IAAI,CAAC;QACH,EAAE,GAAG,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QACnE,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,2CAA2C,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7E,OAAO,GAAG,EAAE,KAAK,I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AI,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;IACzF,CAAC;SAAM,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,CAAC,CAAC;IACnE,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aspectcode/evaluator — Evidence-based evaluation for AGENTS.md optimization.
|
|
3
|
+
*
|
|
4
|
+
* Replaces arbitrary LLM self-scoring with:
|
|
5
|
+
* 1. Probe-based micro-tests scoped to the knowledge base
|
|
6
|
+
* 2. Prompt history harvesting from AI coding tools
|
|
7
|
+
* 3. Evidence-driven diagnosis and AGENTS.md improvement
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { generateProbes, runProbes, diagnose, harvestPrompts } from '@aspectcode/evaluator';
|
|
12
|
+
*
|
|
13
|
+
* const harvested = await harvestPrompts({ root });
|
|
14
|
+
* const probes = generateProbes({ kb, harvestedPrompts: harvested });
|
|
15
|
+
* const results = await runProbes({ agentsContent, probes, provider });
|
|
16
|
+
* const failures = results.filter(r => !r.passed);
|
|
17
|
+
* if (failures.length > 0) {
|
|
18
|
+
* const diagnosis = await diagnose({ failures, agentsContent, provider });
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export type { Probe, ProbeCategory, ProbeResult, BehaviorResult, Diagnosis, AgentsEdit, HarvestedPrompt, PromptSource, ProbeGeneratorOptions, ProbeRunnerOptions, ProbeEvaluatorOptions, DiagnosisOptions, HarvestOptions, EvaluationResult, LlmProvider, OptLogger, } from './types';
|
|
23
|
+
export { generateProbes } from './probes';
|
|
24
|
+
export { runProbes } from './runner';
|
|
25
|
+
export type { ProbeProgressCallback } from './runner';
|
|
26
|
+
export { diagnose, applyDiagnosisEdits } from './diagnosis';
|
|
27
|
+
export { harvestPrompts, harvestAider, harvestClaudeCode, harvestCline, harvestCopilotChat, harvestCursor, harvestWindsurf, harvestExport, } from './harvest/index';
|
|
28
|
+
import type { EvaluationResult, ProbeRunnerOptions, DiagnosisOptions, ProbeGeneratorOptions } from './types';
|
|
29
|
+
/**
|
|
30
|
+
* Run the full evaluation pipeline: generate probes → run them → diagnose failures.
|
|
31
|
+
*
|
|
32
|
+
* This is a convenience function combining the individual steps.
|
|
33
|
+
* For more control, use the individual functions directly.
|
|
34
|
+
*/
|
|
35
|
+
export declare function evaluate(options: {
|
|
36
|
+
/** Probe generation options. */
|
|
37
|
+
probeOptions: ProbeGeneratorOptions;
|
|
38
|
+
/** Current AGENTS.md content. */
|
|
39
|
+
agentsContent: string;
|
|
40
|
+
/** LLM provider for probe execution and diagnosis. */
|
|
41
|
+
provider: ProbeRunnerOptions['provider'];
|
|
42
|
+
/** File contents for context. */
|
|
43
|
+
fileContents?: ReadonlyMap<string, string>;
|
|
44
|
+
/** Logger. */
|
|
45
|
+
log?: DiagnosisOptions['log'];
|
|
46
|
+
/** Abort signal. */
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
}): Promise<EvaluationResult>;
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,YAAY,EACV,KAAK,EACL,aAAa,EACb,WAAW,EACX,cAAc,EACd,SAAS,EACT,UAAU,EACV,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,SAAS,GACV,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,YAAY,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtD,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAG5D,OAAO,EACL,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,aAAa,GACd,MAAM,iBAAiB,CAAC;AAIzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAK7G;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE;IACtC,gCAAgC;IAChC,YAAY,EAAE,qBAAqB,CAAC;IACpC,iCAAiC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,QAAQ,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;IACzC,iCAAiC;IACjC,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,cAAc;IACd,GAAG,CAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC9B,oBAAoB;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAqC5B"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @aspectcode/evaluator — Evidence-based evaluation for AGENTS.md optimization.
|
|
4
|
+
*
|
|
5
|
+
* Replaces arbitrary LLM self-scoring with:
|
|
6
|
+
* 1. Probe-based micro-tests scoped to the knowledge base
|
|
7
|
+
* 2. Prompt history harvesting from AI coding tools
|
|
8
|
+
* 3. Evidence-driven diagnosis and AGENTS.md improvement
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { generateProbes, runProbes, diagnose, harvestPrompts } from '@aspectcode/evaluator';
|
|
13
|
+
*
|
|
14
|
+
* const harvested = await harvestPrompts({ root });
|
|
15
|
+
* const probes = generateProbes({ kb, harvestedPrompts: harvested });
|
|
16
|
+
* const results = await runProbes({ agentsContent, probes, provider });
|
|
17
|
+
* const failures = results.filter(r => !r.passed);
|
|
18
|
+
* if (failures.length > 0) {
|
|
19
|
+
* const diagnosis = await diagnose({ failures, agentsContent, provider });
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.harvestExport = exports.harvestWindsurf = exports.harvestCursor = exports.harvestCopilotChat = exports.harvestCline = exports.harvestClaudeCode = exports.harvestAider = exports.harvestPrompts = exports.applyDiagnosisEdits = exports.diagnose = exports.runProbes = exports.generateProbes = void 0;
|
|
25
|
+
exports.evaluate = evaluate;
|
|
26
|
+
// ── Probe generation ────────────────────────────────────────
|
|
27
|
+
var probes_1 = require("./probes");
|
|
28
|
+
Object.defineProperty(exports, "generateProbes", { enumerable: true, get: function () { return probes_1.generateProbes; } });
|
|
29
|
+
// ── Probe execution ─────────────────────────────────────────
|
|
30
|
+
var runner_1 = require("./runner");
|
|
31
|
+
Object.defineProperty(exports, "runProbes", { enumerable: true, get: function () { return runner_1.runProbes; } });
|
|
32
|
+
// ── Diagnosis ───────────────────────────────────────────────
|
|
33
|
+
var diagnosis_1 = require("./diagnosis");
|
|
34
|
+
Object.defineProperty(exports, "diagnose", { enumerable: true, get: function () { return diagnosis_1.diagnose; } });
|
|
35
|
+
Object.defineProperty(exports, "applyDiagnosisEdits", { enumerable: true, get: function () { return diagnosis_1.applyDiagnosisEdits; } });
|
|
36
|
+
// ── Prompt harvesting ───────────────────────────────────────
|
|
37
|
+
var index_1 = require("./harvest/index");
|
|
38
|
+
Object.defineProperty(exports, "harvestPrompts", { enumerable: true, get: function () { return index_1.harvestPrompts; } });
|
|
39
|
+
Object.defineProperty(exports, "harvestAider", { enumerable: true, get: function () { return index_1.harvestAider; } });
|
|
40
|
+
Object.defineProperty(exports, "harvestClaudeCode", { enumerable: true, get: function () { return index_1.harvestClaudeCode; } });
|
|
41
|
+
Object.defineProperty(exports, "harvestCline", { enumerable: true, get: function () { return index_1.harvestCline; } });
|
|
42
|
+
Object.defineProperty(exports, "harvestCopilotChat", { enumerable: true, get: function () { return index_1.harvestCopilotChat; } });
|
|
43
|
+
Object.defineProperty(exports, "harvestCursor", { enumerable: true, get: function () { return index_1.harvestCursor; } });
|
|
44
|
+
Object.defineProperty(exports, "harvestWindsurf", { enumerable: true, get: function () { return index_1.harvestWindsurf; } });
|
|
45
|
+
Object.defineProperty(exports, "harvestExport", { enumerable: true, get: function () { return index_1.harvestExport; } });
|
|
46
|
+
const probes_2 = require("./probes");
|
|
47
|
+
const runner_2 = require("./runner");
|
|
48
|
+
const diagnosis_2 = require("./diagnosis");
|
|
49
|
+
/**
|
|
50
|
+
* Run the full evaluation pipeline: generate probes → run them → diagnose failures.
|
|
51
|
+
*
|
|
52
|
+
* This is a convenience function combining the individual steps.
|
|
53
|
+
* For more control, use the individual functions directly.
|
|
54
|
+
*/
|
|
55
|
+
async function evaluate(options) {
|
|
56
|
+
const { probeOptions, agentsContent, provider, fileContents, log, signal } = options;
|
|
57
|
+
// Step 1: Generate probes
|
|
58
|
+
const probes = (0, probes_2.generateProbes)(probeOptions);
|
|
59
|
+
// Step 2: Run probes
|
|
60
|
+
const probeResults = await (0, runner_2.runProbes)(agentsContent, probes, provider, fileContents, log, signal);
|
|
61
|
+
const failures = probeResults.filter((r) => !r.passed);
|
|
62
|
+
// Step 3: Diagnose if there are failures
|
|
63
|
+
let diagnosis;
|
|
64
|
+
if (failures.length > 0) {
|
|
65
|
+
diagnosis = await (0, diagnosis_2.diagnose)(failures, agentsContent, provider, log, signal);
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
probeResults,
|
|
69
|
+
diagnosis,
|
|
70
|
+
passCount: probeResults.length - failures.length,
|
|
71
|
+
failCount: failures.length,
|
|
72
|
+
totalProbes: probeResults.length,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAyDH,4BAkDC;AArFD,+DAA+D;AAC/D,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AAEvB,+DAA+D;AAC/D,mCAAqC;AAA5B,mGAAA,SAAS,OAAA;AAGlB,+DAA+D;AAC/D,yCAA4D;AAAnD,qGAAA,QAAQ,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAEtC,+DAA+D;AAC/D,yCASyB;AARvB,uGAAA,cAAc,OAAA;AACd,qGAAA,YAAY,OAAA;AACZ,0GAAA,iBAAiB,OAAA;AACjB,qGAAA,YAAY,OAAA;AACZ,2GAAA,kBAAkB,OAAA;AAClB,sGAAA,aAAa,OAAA;AACb,wGAAA,eAAe,OAAA;AACf,sGAAA,aAAa,OAAA;AAMf,qCAA0C;AAC1C,qCAAqC;AACrC,2CAAuC;AAEvC;;;;;GAKG;AACI,KAAK,UAAU,QAAQ,CAAC,OAa9B;IACC,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAErF,0BAA0B;IAC1B,MAAM,MAAM,GAAG,IAAA,uBAAc,EAAC,YAAY,CAAC,CAAC;IAE5C,qBAAqB;IACrB,MAAM,YAAY,GAAG,MAAM,IAAA,kBAAS,EAClC,aAAa,EACb,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,GAAG,EACH,MAAM,CACP,CAAC;IAEF,MAAM,QAAQ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