@threadbase-sh/scanner 0.14.5 → 0.14.7
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 +21 -8
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +20 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3048,8 +3048,18 @@ var IndexQueue = class {
|
|
|
3048
3048
|
// src/scanner.ts
|
|
3049
3049
|
var BATCH_SIZE2 = 12;
|
|
3050
3050
|
var DEFAULT_CONFIG_PATH = "~/.config/threadbase-scanner";
|
|
3051
|
+
function isTestProcess() {
|
|
3052
|
+
return Boolean(process.env.VITEST) || Boolean(process.env.JEST_WORKER_ID) || process.env.NODE_ENV === "test";
|
|
3053
|
+
}
|
|
3051
3054
|
function defaultDbPath() {
|
|
3052
|
-
|
|
3055
|
+
const override = process.env.TB_SCANNER_DB;
|
|
3056
|
+
if (override) return override;
|
|
3057
|
+
if (isTestProcess()) {
|
|
3058
|
+
throw new Error(
|
|
3059
|
+
"TB_SCANNER_DB must be set under a test runner. Refusing to open the default index at ~/.config/threadbase-scanner/index.db, because test fixtures written there are indistinguishable from real conversations and corrupt every measurement of the index. Point it at a temp directory in your test setup, or pass persistent.dbPath explicitly."
|
|
3060
|
+
);
|
|
3061
|
+
}
|
|
3062
|
+
return join5(homedir2(), ".config", "threadbase-scanner", "index.db");
|
|
3053
3063
|
}
|
|
3054
3064
|
function capForMemory(doc, max) {
|
|
3055
3065
|
const combined = combineSearchContent(doc);
|
|
@@ -3446,7 +3456,8 @@ var ConversationScanner = class {
|
|
|
3446
3456
|
// feeds the conversation's account field; "default" is the single-profile
|
|
3447
3457
|
// fallback, matching refreshFile.
|
|
3448
3458
|
async parseSingleFilePage(filePath, account, options) {
|
|
3449
|
-
const
|
|
3459
|
+
const provider = await this.resolveProviderForFile(filePath, null);
|
|
3460
|
+
const conversation = provider?.name === CODEX_CLI_PROVIDER ? await parseCodexConversation(filePath, account ?? "default") : await parseConversation(filePath, account ?? "default");
|
|
3450
3461
|
if (!conversation) return null;
|
|
3451
3462
|
const { messages } = conversation;
|
|
3452
3463
|
const total = messages.length;
|
|
@@ -3490,7 +3501,7 @@ var ConversationScanner = class {
|
|
|
3490
3501
|
const engine = this.engine();
|
|
3491
3502
|
const previous2 = engine.getByIdOrSession(filePath);
|
|
3492
3503
|
const resolvedAccount2 = account ?? previous2?.account ?? "default";
|
|
3493
|
-
const
|
|
3504
|
+
const provider2 = await this.resolveProviderForFile(filePath, previous2);
|
|
3494
3505
|
const { meta: meta2, change } = await engine.indexFile(
|
|
3495
3506
|
filePath,
|
|
3496
3507
|
resolvedAccount2,
|
|
@@ -3498,7 +3509,7 @@ var ConversationScanner = class {
|
|
|
3498
3509
|
void 0,
|
|
3499
3510
|
readGitBranch,
|
|
3500
3511
|
false,
|
|
3501
|
-
|
|
3512
|
+
provider2
|
|
3502
3513
|
);
|
|
3503
3514
|
const cacheKeys = /* @__PURE__ */ new Set();
|
|
3504
3515
|
for (const m of [previous2, meta2]) {
|
|
@@ -3519,10 +3530,12 @@ var ConversationScanner = class {
|
|
|
3519
3530
|
const resolvedAccount = account ?? previous?.account ?? "default";
|
|
3520
3531
|
let meta = null;
|
|
3521
3532
|
let searchDoc = emptySearchDocument();
|
|
3533
|
+
const onEntry = (entry) => {
|
|
3534
|
+
searchDoc = appendSearchDelta(searchDoc, extractSearchDelta(entry));
|
|
3535
|
+
};
|
|
3536
|
+
const provider = await this.resolveProviderForFile(filePath, previous ?? null);
|
|
3522
3537
|
try {
|
|
3523
|
-
meta = await
|
|
3524
|
-
searchDoc = appendSearchDelta(searchDoc, extractSearchDelta(entry));
|
|
3525
|
-
});
|
|
3538
|
+
meta = provider ? await parseMetaWithProvider(provider, filePath, resolvedAccount, this.lastTier, onEntry) : await parseMeta(filePath, resolvedAccount, this.lastTier, onEntry);
|
|
3526
3539
|
} catch (err) {
|
|
3527
3540
|
log.warn({ filePath, err }, "refreshFile: parseMeta threw");
|
|
3528
3541
|
meta = null;
|