@fabersep/memory 0.1.0 → 0.2.1
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/CHANGELOG.md +34 -0
- package/README.md +65 -198
- package/dist/src/cache-logs.d.ts +47 -0
- package/dist/src/cache-logs.js +433 -0
- package/dist/src/cli.js +417 -75
- package/dist/src/compiler.d.ts +4 -0
- package/dist/src/compiler.js +41 -1
- package/dist/src/doctor.d.ts +23 -0
- package/dist/src/doctor.js +447 -0
- package/dist/src/git.js +1 -1
- package/dist/src/hygiene.d.ts +4 -0
- package/dist/src/hygiene.js +8 -0
- package/dist/src/importer.d.ts +8 -0
- package/dist/src/importer.js +63 -8
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +5 -0
- package/dist/src/init.d.ts +2 -0
- package/dist/src/init.js +43 -4
- package/dist/src/mcp.d.ts +91 -1
- package/dist/src/mcp.js +61 -4
- package/dist/src/metrics.d.ts +72 -0
- package/dist/src/metrics.js +179 -0
- package/dist/src/proposals.js +39 -2
- package/dist/src/stats.d.ts +166 -0
- package/dist/src/stats.js +565 -0
- package/dist/src/sync.d.ts +2 -0
- package/dist/src/sync.js +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/src/types.js +2 -1
- package/dist/src/ui.d.ts +19 -0
- package/dist/src/ui.js +74 -0
- package/dist/src/version.d.ts +2 -0
- package/dist/src/version.js +22 -0
- package/package.json +3 -2
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { getUserHome } from './init.js';
|
|
4
|
+
export const CACHE_TTL_MS = 5 * 60 * 1000; // 5-minute default prompt-cache TTL
|
|
5
|
+
function round1(n) {
|
|
6
|
+
return Math.round(n * 10) / 10;
|
|
7
|
+
}
|
|
8
|
+
function computePct(cacheRead, denom, clamp100 = false) {
|
|
9
|
+
if (denom <= 0)
|
|
10
|
+
return 0;
|
|
11
|
+
const pct = (cacheRead / denom) * 100;
|
|
12
|
+
return round1(clamp100 ? Math.min(100, pct) : pct);
|
|
13
|
+
}
|
|
14
|
+
function walkFiles(rootDir, predicate) {
|
|
15
|
+
const results = [];
|
|
16
|
+
if (!fs.existsSync(rootDir))
|
|
17
|
+
return results;
|
|
18
|
+
const stack = [rootDir];
|
|
19
|
+
while (stack.length > 0) {
|
|
20
|
+
const dir = stack.pop();
|
|
21
|
+
let entries;
|
|
22
|
+
try {
|
|
23
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
for (const entry of entries) {
|
|
29
|
+
const full = path.join(dir, entry.name);
|
|
30
|
+
if (entry.isDirectory()) {
|
|
31
|
+
stack.push(full);
|
|
32
|
+
}
|
|
33
|
+
else if (entry.isFile() && predicate(entry.name, full)) {
|
|
34
|
+
results.push(full);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return results.sort();
|
|
39
|
+
}
|
|
40
|
+
function aggregateSessions(engine, sessions, skippedLines, foundDir, clamp100, unrecognizedFormat = false) {
|
|
41
|
+
let totalSteps = 0;
|
|
42
|
+
let totalFirstSteps = 0;
|
|
43
|
+
let totalWarmSteps = 0;
|
|
44
|
+
let totalIdleExcluded = 0;
|
|
45
|
+
let firstCacheRead = 0;
|
|
46
|
+
let firstDenom = 0;
|
|
47
|
+
let warmCacheRead = 0;
|
|
48
|
+
let warmDenom = 0;
|
|
49
|
+
const modelStats = new Map();
|
|
50
|
+
const getModelBucket = (model) => {
|
|
51
|
+
let bucket = modelStats.get(model);
|
|
52
|
+
if (!bucket) {
|
|
53
|
+
bucket = {
|
|
54
|
+
sessionSet: new Set(),
|
|
55
|
+
steps: 0,
|
|
56
|
+
firstSteps: 0,
|
|
57
|
+
warmSteps: 0,
|
|
58
|
+
idleExcluded: 0,
|
|
59
|
+
firstCacheRead: 0,
|
|
60
|
+
firstDenom: 0,
|
|
61
|
+
warmCacheRead: 0,
|
|
62
|
+
warmDenom: 0,
|
|
63
|
+
};
|
|
64
|
+
modelStats.set(model, bucket);
|
|
65
|
+
}
|
|
66
|
+
return bucket;
|
|
67
|
+
};
|
|
68
|
+
for (let sIdx = 0; sIdx < sessions.length; sIdx++) {
|
|
69
|
+
const sess = sessions[sIdx];
|
|
70
|
+
for (let i = 0; i < sess.steps.length; i++) {
|
|
71
|
+
const step = sess.steps[i];
|
|
72
|
+
const bucket = getModelBucket(step.model);
|
|
73
|
+
bucket.sessionSet.add(sIdx);
|
|
74
|
+
bucket.steps++;
|
|
75
|
+
totalSteps++;
|
|
76
|
+
if (i === 0) {
|
|
77
|
+
totalFirstSteps++;
|
|
78
|
+
firstCacheRead += step.cacheRead;
|
|
79
|
+
firstDenom += step.denom;
|
|
80
|
+
bucket.firstSteps++;
|
|
81
|
+
bucket.firstCacheRead += step.cacheRead;
|
|
82
|
+
bucket.firstDenom += step.denom;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const prev = sess.steps[i - 1];
|
|
86
|
+
const gapMs = step.tsMs - prev.tsMs;
|
|
87
|
+
if (gapMs <= CACHE_TTL_MS) {
|
|
88
|
+
totalWarmSteps++;
|
|
89
|
+
warmCacheRead += step.cacheRead;
|
|
90
|
+
warmDenom += step.denom;
|
|
91
|
+
bucket.warmSteps++;
|
|
92
|
+
bucket.warmCacheRead += step.cacheRead;
|
|
93
|
+
bucket.warmDenom += step.denom;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
totalIdleExcluded++;
|
|
97
|
+
bucket.idleExcluded++;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const byModel = [...modelStats.entries()]
|
|
103
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
104
|
+
.map(([model, b]) => ({
|
|
105
|
+
model,
|
|
106
|
+
sessions: b.sessionSet.size,
|
|
107
|
+
steps: b.steps,
|
|
108
|
+
firstSteps: b.firstSteps,
|
|
109
|
+
warmSteps: b.warmSteps,
|
|
110
|
+
idleGapExcludedSteps: b.idleExcluded,
|
|
111
|
+
firstStepHitPct: computePct(b.firstCacheRead, b.firstDenom, clamp100),
|
|
112
|
+
warmStepHitPct: computePct(b.warmCacheRead, b.warmDenom, clamp100),
|
|
113
|
+
}));
|
|
114
|
+
return {
|
|
115
|
+
engine,
|
|
116
|
+
foundDir,
|
|
117
|
+
...(unrecognizedFormat ? { unrecognizedFormat: true } : {}),
|
|
118
|
+
sessions: sessions.length,
|
|
119
|
+
steps: totalSteps,
|
|
120
|
+
firstSteps: totalFirstSteps,
|
|
121
|
+
warmSteps: totalWarmSteps,
|
|
122
|
+
idleGapExcludedSteps: totalIdleExcluded,
|
|
123
|
+
firstStepHitPct: computePct(firstCacheRead, firstDenom, clamp100),
|
|
124
|
+
warmStepHitPct: computePct(warmCacheRead, warmDenom, clamp100),
|
|
125
|
+
skippedLines,
|
|
126
|
+
byModel,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function parseClaudeCodeLogs(dirs, cutoffMs, changedCompiles) {
|
|
130
|
+
const existingDirs = dirs.filter((d) => fs.existsSync(d));
|
|
131
|
+
if (existingDirs.length === 0) {
|
|
132
|
+
return {
|
|
133
|
+
...aggregateSessions('claude-code', [], 0, false, false),
|
|
134
|
+
correlation: {
|
|
135
|
+
applicable: true,
|
|
136
|
+
eligibleSessions: 0,
|
|
137
|
+
correlatedBreaks: 0,
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
const files = [];
|
|
142
|
+
for (const dir of existingDirs) {
|
|
143
|
+
files.push(...walkFiles(dir, (name) => name.endsWith('.jsonl') &&
|
|
144
|
+
name !== 'transcript.jsonl' &&
|
|
145
|
+
name !== 'transcript_full.jsonl'));
|
|
146
|
+
}
|
|
147
|
+
let skippedLines = 0;
|
|
148
|
+
const sessions = [];
|
|
149
|
+
for (const filePath of files) {
|
|
150
|
+
let raw;
|
|
151
|
+
let fallbackMs;
|
|
152
|
+
try {
|
|
153
|
+
raw = fs.readFileSync(filePath, 'utf8');
|
|
154
|
+
fallbackMs = fs.statSync(filePath).mtimeMs;
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
// Deduplicate by message ID within each session file (keep last occurrence, preserve order)
|
|
160
|
+
const order = [];
|
|
161
|
+
const byMsgId = new Map();
|
|
162
|
+
let anonCounter = 0;
|
|
163
|
+
for (const rawLine of raw.split('\n')) {
|
|
164
|
+
const trimmed = rawLine.trim();
|
|
165
|
+
if (!trimmed)
|
|
166
|
+
continue;
|
|
167
|
+
let rec;
|
|
168
|
+
try {
|
|
169
|
+
rec = JSON.parse(trimmed);
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
skippedLines++;
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (!rec || typeof rec !== 'object') {
|
|
176
|
+
skippedLines++;
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
// Exclude sidechain records
|
|
180
|
+
if (rec.isSidechain === true)
|
|
181
|
+
continue;
|
|
182
|
+
const msg = rec.message && typeof rec.message === 'object'
|
|
183
|
+
? rec.message
|
|
184
|
+
: undefined;
|
|
185
|
+
const usage = msg?.usage && typeof msg.usage === 'object'
|
|
186
|
+
? msg.usage
|
|
187
|
+
: rec.usage && typeof rec.usage === 'object'
|
|
188
|
+
? rec.usage
|
|
189
|
+
: undefined;
|
|
190
|
+
if (!usage)
|
|
191
|
+
continue;
|
|
192
|
+
const hasInput = typeof usage.input_tokens === 'number';
|
|
193
|
+
const hasCacheRead = typeof usage.cache_read_input_tokens === 'number';
|
|
194
|
+
const hasCacheCreate = typeof usage.cache_creation_input_tokens === 'number';
|
|
195
|
+
if (!hasInput && !hasCacheRead && !hasCacheCreate)
|
|
196
|
+
continue;
|
|
197
|
+
const tsStr = typeof rec.timestamp === 'string'
|
|
198
|
+
? rec.timestamp
|
|
199
|
+
: typeof rec.created_at === 'string'
|
|
200
|
+
? rec.created_at
|
|
201
|
+
: undefined;
|
|
202
|
+
const tsMs = tsStr && Number.isFinite(Date.parse(tsStr)) ? Date.parse(tsStr) : fallbackMs;
|
|
203
|
+
if (tsMs < cutoffMs)
|
|
204
|
+
continue;
|
|
205
|
+
const input = typeof usage.input_tokens === 'number' ? usage.input_tokens : 0;
|
|
206
|
+
const cacheRead = typeof usage.cache_read_input_tokens === 'number' ? usage.cache_read_input_tokens : 0;
|
|
207
|
+
const cacheCreate = typeof usage.cache_creation_input_tokens === 'number'
|
|
208
|
+
? usage.cache_creation_input_tokens
|
|
209
|
+
: 0;
|
|
210
|
+
const denom = input + cacheRead + cacheCreate;
|
|
211
|
+
const model = typeof msg?.model === 'string' && msg.model.trim()
|
|
212
|
+
? msg.model.trim()
|
|
213
|
+
: typeof rec.model === 'string' && rec.model.trim()
|
|
214
|
+
? rec.model.trim()
|
|
215
|
+
: 'unknown';
|
|
216
|
+
const rawMsgId = typeof msg?.id === 'string' && msg.id
|
|
217
|
+
? msg.id
|
|
218
|
+
: typeof rec.message_id === 'string' && rec.message_id
|
|
219
|
+
? rec.message_id
|
|
220
|
+
: undefined;
|
|
221
|
+
const key = rawMsgId ? `id:${rawMsgId}` : `anon:${anonCounter++}`;
|
|
222
|
+
if (!byMsgId.has(key)) {
|
|
223
|
+
order.push(key);
|
|
224
|
+
}
|
|
225
|
+
byMsgId.set(key, {
|
|
226
|
+
tsMs,
|
|
227
|
+
model,
|
|
228
|
+
cacheRead,
|
|
229
|
+
denom,
|
|
230
|
+
rawInputTokens: input,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
const steps = order
|
|
234
|
+
.map((k) => byMsgId.get(k))
|
|
235
|
+
.sort((a, b) => a.tsMs - b.tsMs);
|
|
236
|
+
if (steps.length > 0) {
|
|
237
|
+
sessions.push({
|
|
238
|
+
startTsMs: steps[0].tsMs,
|
|
239
|
+
endTsMs: steps[steps.length - 1].tsMs,
|
|
240
|
+
firstTurnCacheRead: steps[0].cacheRead,
|
|
241
|
+
steps,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
sessions.sort((a, b) => a.startTsMs - b.startTsMs);
|
|
246
|
+
// L0 cache-break correlation (FR-04, AC-16a)
|
|
247
|
+
let eligibleSessions = 0;
|
|
248
|
+
let correlatedBreaks = 0;
|
|
249
|
+
if (changedCompiles.length > 0 && sessions.length > 1) {
|
|
250
|
+
const sortedCompiles = [...changedCompiles]
|
|
251
|
+
.map((c) => ({ tsMs: Date.parse(c.ts), l0Tokens: c.l0_tokens }))
|
|
252
|
+
.filter((c) => Number.isFinite(c.tsMs))
|
|
253
|
+
.sort((a, b) => a.tsMs - b.tsMs);
|
|
254
|
+
for (let i = 1; i < sessions.length; i++) {
|
|
255
|
+
const curr = sessions[i];
|
|
256
|
+
// Find the latest changed compile T <= curr.startTsMs that falls between a prior session's end and curr.startTsMs
|
|
257
|
+
let matchedCompile = null;
|
|
258
|
+
let matchedPrior = null;
|
|
259
|
+
for (let pIdx = i - 1; pIdx >= 0; pIdx--) {
|
|
260
|
+
const prior = sessions[pIdx];
|
|
261
|
+
if (curr.startTsMs - prior.endTsMs > CACHE_TTL_MS) {
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
// Look for a compile event with prior.endTsMs <= T <= curr.startTsMs
|
|
265
|
+
for (let cIdx = sortedCompiles.length - 1; cIdx >= 0; cIdx--) {
|
|
266
|
+
const comp = sortedCompiles[cIdx];
|
|
267
|
+
if (comp.tsMs >= prior.endTsMs && comp.tsMs <= curr.startTsMs) {
|
|
268
|
+
matchedCompile = comp;
|
|
269
|
+
matchedPrior = prior;
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (matchedCompile)
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
if (matchedCompile && matchedPrior) {
|
|
277
|
+
eligibleSessions++;
|
|
278
|
+
const drop = matchedPrior.firstTurnCacheRead - curr.firstTurnCacheRead;
|
|
279
|
+
if (drop >= matchedCompile.l0Tokens) {
|
|
280
|
+
correlatedBreaks++;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const report = aggregateSessions('claude-code', sessions, skippedLines, true, false);
|
|
286
|
+
report.correlation = {
|
|
287
|
+
applicable: true,
|
|
288
|
+
eligibleSessions,
|
|
289
|
+
correlatedBreaks,
|
|
290
|
+
};
|
|
291
|
+
return report;
|
|
292
|
+
}
|
|
293
|
+
function parseAntigravityLogs(dirs, cutoffMs) {
|
|
294
|
+
const existingDirs = dirs.filter((d) => fs.existsSync(d));
|
|
295
|
+
if (existingDirs.length === 0) {
|
|
296
|
+
return {
|
|
297
|
+
...aggregateSessions('antigravity', [], 0, false, true),
|
|
298
|
+
correlation: {
|
|
299
|
+
applicable: false,
|
|
300
|
+
note: 'L0 prefix-break correlation applies only to claude-code (Antigravity reads MEMORY.md via a tool call rather than static prompt-prefix injection).',
|
|
301
|
+
eligibleSessions: 0,
|
|
302
|
+
correlatedBreaks: 0,
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
const files = [];
|
|
307
|
+
for (const dir of existingDirs) {
|
|
308
|
+
// Strictly read transcript.jsonl only — never transcript_full.jsonl
|
|
309
|
+
files.push(...walkFiles(dir, (name) => name === 'transcript.jsonl'));
|
|
310
|
+
}
|
|
311
|
+
let skippedLines = 0;
|
|
312
|
+
let plannerRecordsSeen = 0;
|
|
313
|
+
let plannerRecordsWithTokens = 0;
|
|
314
|
+
const sessions = [];
|
|
315
|
+
for (const filePath of files) {
|
|
316
|
+
let raw;
|
|
317
|
+
let fallbackMs;
|
|
318
|
+
try {
|
|
319
|
+
raw = fs.readFileSync(filePath, 'utf8');
|
|
320
|
+
fallbackMs = fs.statSync(filePath).mtimeMs;
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
const steps = [];
|
|
326
|
+
for (const rawLine of raw.split('\n')) {
|
|
327
|
+
const trimmed = rawLine.trim();
|
|
328
|
+
if (!trimmed)
|
|
329
|
+
continue;
|
|
330
|
+
let rec;
|
|
331
|
+
try {
|
|
332
|
+
rec = JSON.parse(trimmed);
|
|
333
|
+
}
|
|
334
|
+
catch {
|
|
335
|
+
skippedLines++;
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
if (!rec || typeof rec !== 'object') {
|
|
339
|
+
skippedLines++;
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (rec.type !== 'PLANNER_RESPONSE')
|
|
343
|
+
continue;
|
|
344
|
+
plannerRecordsSeen++;
|
|
345
|
+
const hasInput = typeof rec.input_tokens === 'number';
|
|
346
|
+
const hasCacheRead = typeof rec.cache_read_tokens === 'number';
|
|
347
|
+
if (!hasInput && !hasCacheRead)
|
|
348
|
+
continue;
|
|
349
|
+
plannerRecordsWithTokens++;
|
|
350
|
+
const tsStr = typeof rec.created_at === 'string'
|
|
351
|
+
? rec.created_at
|
|
352
|
+
: typeof rec.timestamp === 'string'
|
|
353
|
+
? rec.timestamp
|
|
354
|
+
: undefined;
|
|
355
|
+
const tsMs = tsStr && Number.isFinite(Date.parse(tsStr)) ? Date.parse(tsStr) : fallbackMs;
|
|
356
|
+
if (tsMs < cutoffMs)
|
|
357
|
+
continue;
|
|
358
|
+
const input = typeof rec.input_tokens === 'number' ? rec.input_tokens : 0;
|
|
359
|
+
const cacheRead = typeof rec.cache_read_tokens === 'number' ? rec.cache_read_tokens : 0;
|
|
360
|
+
const model = typeof rec.model === 'string' && rec.model.trim() ? rec.model.trim() : 'unknown';
|
|
361
|
+
// Antigravity: when cache_read_tokens <= input_tokens, input_tokens is inclusive;
|
|
362
|
+
// when cache_read_tokens > input_tokens (warm turns where input_tokens logs uncached delta only),
|
|
363
|
+
// total input is input_tokens + cache_read_tokens so warm hit % is accurate rather than clamped to 100%.
|
|
364
|
+
const denom = cacheRead > input ? input + cacheRead : input;
|
|
365
|
+
steps.push({
|
|
366
|
+
tsMs,
|
|
367
|
+
model,
|
|
368
|
+
cacheRead,
|
|
369
|
+
denom,
|
|
370
|
+
rawInputTokens: input,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
steps.sort((a, b) => a.tsMs - b.tsMs);
|
|
374
|
+
if (steps.length > 0) {
|
|
375
|
+
sessions.push({
|
|
376
|
+
startTsMs: steps[0].tsMs,
|
|
377
|
+
endTsMs: steps[steps.length - 1].tsMs,
|
|
378
|
+
firstTurnCacheRead: steps[0].cacheRead,
|
|
379
|
+
steps,
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
const unrecognizedFormat = plannerRecordsSeen > 0 && plannerRecordsWithTokens === 0;
|
|
384
|
+
const report = aggregateSessions('antigravity', sessions, skippedLines, true, true, unrecognizedFormat);
|
|
385
|
+
report.correlation = {
|
|
386
|
+
applicable: false,
|
|
387
|
+
note: 'L0 prefix-break correlation applies only to claude-code (Antigravity reads MEMORY.md via a tool call rather than static prompt-prefix injection).',
|
|
388
|
+
eligibleSessions: 0,
|
|
389
|
+
correlatedBreaks: 0,
|
|
390
|
+
};
|
|
391
|
+
return report;
|
|
392
|
+
}
|
|
393
|
+
export function analyzeCacheLogs(options) {
|
|
394
|
+
const engine = (options.engine || 'all').toLowerCase();
|
|
395
|
+
if (engine === 'cursor' || engine === 'codex') {
|
|
396
|
+
return {
|
|
397
|
+
unsupportedEngine: engine,
|
|
398
|
+
unsupportedMessage: `Engine "${engine}" cache log parsing is not supported in v0.2 (GAP-01: local session log format unverified). Supported engines: claude-code, antigravity, all.`,
|
|
399
|
+
engines: [],
|
|
400
|
+
skippedLines: 0,
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
if (engine !== 'claude-code' && engine !== 'antigravity' && engine !== 'all') {
|
|
404
|
+
return {
|
|
405
|
+
unsupportedEngine: engine,
|
|
406
|
+
unsupportedMessage: `Unsupported engine "${engine}" (GAP-01). Supported engines: claude-code, antigravity, all.`,
|
|
407
|
+
engines: [],
|
|
408
|
+
skippedLines: 0,
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
const nowMs = options.nowMs ?? Date.now();
|
|
412
|
+
const cutoffMs = nowMs - options.days * 24 * 60 * 60 * 1000;
|
|
413
|
+
const userHome = options.userHome || getUserHome();
|
|
414
|
+
const changedCompiles = options.changedCompiles || [];
|
|
415
|
+
const reports = [];
|
|
416
|
+
if (engine === 'claude-code' || engine === 'all') {
|
|
417
|
+
const dirs = options.logDir
|
|
418
|
+
? [options.logDir]
|
|
419
|
+
: [path.join(userHome, '.claude', 'projects')];
|
|
420
|
+
reports.push(parseClaudeCodeLogs(dirs, cutoffMs, changedCompiles));
|
|
421
|
+
}
|
|
422
|
+
if (engine === 'antigravity' || engine === 'all') {
|
|
423
|
+
const dirs = options.logDir
|
|
424
|
+
? [options.logDir]
|
|
425
|
+
: [
|
|
426
|
+
path.join(userHome, '.gemini', 'antigravity', 'brain'),
|
|
427
|
+
path.join(userHome, '.gemini', 'antigravity-cli', 'brain'),
|
|
428
|
+
];
|
|
429
|
+
reports.push(parseAntigravityLogs(dirs, cutoffMs));
|
|
430
|
+
}
|
|
431
|
+
const skippedLines = reports.reduce((sum, r) => sum + r.skippedLines, 0);
|
|
432
|
+
return { engines: reports, skippedLines };
|
|
433
|
+
}
|