@threadbase-sh/scanner 0.14.6 → 0.15.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.js +25 -15
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +36 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +35 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Command } from "commander";
|
|
|
5
5
|
import pino2 from "pino";
|
|
6
6
|
|
|
7
7
|
// package.json
|
|
8
|
-
var version = "0.
|
|
8
|
+
var version = "0.15.0";
|
|
9
9
|
|
|
10
10
|
// src/logger.ts
|
|
11
11
|
import pino from "pino";
|
|
@@ -1309,6 +1309,16 @@ function extractCodexText(content) {
|
|
|
1309
1309
|
return "";
|
|
1310
1310
|
}).filter(Boolean).map(cleanSystemTags).join(" ");
|
|
1311
1311
|
}
|
|
1312
|
+
function codexEntryToMessage(entry) {
|
|
1313
|
+
const payload = entry.payload;
|
|
1314
|
+
if (!payload || typeof payload !== "object") return null;
|
|
1315
|
+
if (entry.type !== "response_item" || payload.type !== "message") return null;
|
|
1316
|
+
const role = payload.role;
|
|
1317
|
+
if (role !== "user" && role !== "assistant") return null;
|
|
1318
|
+
const text = extractCodexText(payload.content);
|
|
1319
|
+
if (!text) return null;
|
|
1320
|
+
return { role, text, timestamp: asString(entry.timestamp) };
|
|
1321
|
+
}
|
|
1312
1322
|
function reduceCodexEntry(acc, entry, tier) {
|
|
1313
1323
|
const ts = asString(entry.timestamp);
|
|
1314
1324
|
if (ts && (!acc.latestTimestamp || ts > acc.latestTimestamp)) acc.latestTimestamp = ts;
|
|
@@ -1419,14 +1429,11 @@ async function parseCodexConversation(filePath, account) {
|
|
|
1419
1429
|
if (!cwd) cwd = asString(payload.cwd);
|
|
1420
1430
|
continue;
|
|
1421
1431
|
}
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
if (
|
|
1427
|
-
messages.push({ role, text, timestamp: ts });
|
|
1428
|
-
textParts.push(text);
|
|
1429
|
-
if (role === "user") lastUserText = text;
|
|
1432
|
+
const message = codexEntryToMessage(entry);
|
|
1433
|
+
if (!message) continue;
|
|
1434
|
+
messages.push(message);
|
|
1435
|
+
textParts.push(message.text);
|
|
1436
|
+
if (message.role === "user") lastUserText = message.text;
|
|
1430
1437
|
}
|
|
1431
1438
|
} catch (err) {
|
|
1432
1439
|
log.warn({ filePath, err }, "parseCodexConversation: read failed");
|
|
@@ -3437,7 +3444,8 @@ var ConversationScanner = class {
|
|
|
3437
3444
|
// feeds the conversation's account field; "default" is the single-profile
|
|
3438
3445
|
// fallback, matching refreshFile.
|
|
3439
3446
|
async parseSingleFilePage(filePath, account, options) {
|
|
3440
|
-
const
|
|
3447
|
+
const provider = await this.resolveProviderForFile(filePath, null);
|
|
3448
|
+
const conversation = provider?.name === CODEX_CLI_PROVIDER ? await parseCodexConversation(filePath, account ?? "default") : await parseConversation(filePath, account ?? "default");
|
|
3441
3449
|
if (!conversation) return null;
|
|
3442
3450
|
const { messages } = conversation;
|
|
3443
3451
|
const total = messages.length;
|
|
@@ -3481,7 +3489,7 @@ var ConversationScanner = class {
|
|
|
3481
3489
|
const engine = this.engine();
|
|
3482
3490
|
const previous2 = engine.getByIdOrSession(filePath);
|
|
3483
3491
|
const resolvedAccount2 = account ?? previous2?.account ?? "default";
|
|
3484
|
-
const
|
|
3492
|
+
const provider2 = await this.resolveProviderForFile(filePath, previous2);
|
|
3485
3493
|
const { meta: meta2, change } = await engine.indexFile(
|
|
3486
3494
|
filePath,
|
|
3487
3495
|
resolvedAccount2,
|
|
@@ -3489,7 +3497,7 @@ var ConversationScanner = class {
|
|
|
3489
3497
|
void 0,
|
|
3490
3498
|
readGitBranch,
|
|
3491
3499
|
false,
|
|
3492
|
-
|
|
3500
|
+
provider2
|
|
3493
3501
|
);
|
|
3494
3502
|
const cacheKeys = /* @__PURE__ */ new Set();
|
|
3495
3503
|
for (const m of [previous2, meta2]) {
|
|
@@ -3510,10 +3518,12 @@ var ConversationScanner = class {
|
|
|
3510
3518
|
const resolvedAccount = account ?? previous?.account ?? "default";
|
|
3511
3519
|
let meta = null;
|
|
3512
3520
|
let searchDoc = emptySearchDocument();
|
|
3521
|
+
const onEntry = (entry) => {
|
|
3522
|
+
searchDoc = appendSearchDelta(searchDoc, extractSearchDelta(entry));
|
|
3523
|
+
};
|
|
3524
|
+
const provider = await this.resolveProviderForFile(filePath, previous ?? null);
|
|
3513
3525
|
try {
|
|
3514
|
-
meta = await
|
|
3515
|
-
searchDoc = appendSearchDelta(searchDoc, extractSearchDelta(entry));
|
|
3516
|
-
});
|
|
3526
|
+
meta = provider ? await parseMetaWithProvider(provider, filePath, resolvedAccount, this.lastTier, onEntry) : await parseMeta(filePath, resolvedAccount, this.lastTier, onEntry);
|
|
3517
3527
|
} catch (err) {
|
|
3518
3528
|
log.warn({ filePath, err }, "refreshFile: parseMeta threw");
|
|
3519
3529
|
meta = null;
|