@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/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.14.
|
|
8
|
+
var version = "0.14.7";
|
|
9
9
|
|
|
10
10
|
// src/logger.ts
|
|
11
11
|
import pino from "pino";
|
|
@@ -3029,8 +3029,18 @@ var IndexQueue = class {
|
|
|
3029
3029
|
// src/scanner.ts
|
|
3030
3030
|
var BATCH_SIZE2 = 12;
|
|
3031
3031
|
var DEFAULT_CONFIG_PATH = "~/.config/threadbase-scanner";
|
|
3032
|
+
function isTestProcess() {
|
|
3033
|
+
return Boolean(process.env.VITEST) || Boolean(process.env.JEST_WORKER_ID) || process.env.NODE_ENV === "test";
|
|
3034
|
+
}
|
|
3032
3035
|
function defaultDbPath() {
|
|
3033
|
-
|
|
3036
|
+
const override = process.env.TB_SCANNER_DB;
|
|
3037
|
+
if (override) return override;
|
|
3038
|
+
if (isTestProcess()) {
|
|
3039
|
+
throw new Error(
|
|
3040
|
+
"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."
|
|
3041
|
+
);
|
|
3042
|
+
}
|
|
3043
|
+
return join5(homedir2(), ".config", "threadbase-scanner", "index.db");
|
|
3034
3044
|
}
|
|
3035
3045
|
function capForMemory(doc, max) {
|
|
3036
3046
|
const combined = combineSearchContent(doc);
|
|
@@ -3427,7 +3437,8 @@ var ConversationScanner = class {
|
|
|
3427
3437
|
// feeds the conversation's account field; "default" is the single-profile
|
|
3428
3438
|
// fallback, matching refreshFile.
|
|
3429
3439
|
async parseSingleFilePage(filePath, account, options) {
|
|
3430
|
-
const
|
|
3440
|
+
const provider = await this.resolveProviderForFile(filePath, null);
|
|
3441
|
+
const conversation = provider?.name === CODEX_CLI_PROVIDER ? await parseCodexConversation(filePath, account ?? "default") : await parseConversation(filePath, account ?? "default");
|
|
3431
3442
|
if (!conversation) return null;
|
|
3432
3443
|
const { messages } = conversation;
|
|
3433
3444
|
const total = messages.length;
|
|
@@ -3471,7 +3482,7 @@ var ConversationScanner = class {
|
|
|
3471
3482
|
const engine = this.engine();
|
|
3472
3483
|
const previous2 = engine.getByIdOrSession(filePath);
|
|
3473
3484
|
const resolvedAccount2 = account ?? previous2?.account ?? "default";
|
|
3474
|
-
const
|
|
3485
|
+
const provider2 = await this.resolveProviderForFile(filePath, previous2);
|
|
3475
3486
|
const { meta: meta2, change } = await engine.indexFile(
|
|
3476
3487
|
filePath,
|
|
3477
3488
|
resolvedAccount2,
|
|
@@ -3479,7 +3490,7 @@ var ConversationScanner = class {
|
|
|
3479
3490
|
void 0,
|
|
3480
3491
|
readGitBranch,
|
|
3481
3492
|
false,
|
|
3482
|
-
|
|
3493
|
+
provider2
|
|
3483
3494
|
);
|
|
3484
3495
|
const cacheKeys = /* @__PURE__ */ new Set();
|
|
3485
3496
|
for (const m of [previous2, meta2]) {
|
|
@@ -3500,10 +3511,12 @@ var ConversationScanner = class {
|
|
|
3500
3511
|
const resolvedAccount = account ?? previous?.account ?? "default";
|
|
3501
3512
|
let meta = null;
|
|
3502
3513
|
let searchDoc = emptySearchDocument();
|
|
3514
|
+
const onEntry = (entry) => {
|
|
3515
|
+
searchDoc = appendSearchDelta(searchDoc, extractSearchDelta(entry));
|
|
3516
|
+
};
|
|
3517
|
+
const provider = await this.resolveProviderForFile(filePath, previous ?? null);
|
|
3503
3518
|
try {
|
|
3504
|
-
meta = await
|
|
3505
|
-
searchDoc = appendSearchDelta(searchDoc, extractSearchDelta(entry));
|
|
3506
|
-
});
|
|
3519
|
+
meta = provider ? await parseMetaWithProvider(provider, filePath, resolvedAccount, this.lastTier, onEntry) : await parseMeta(filePath, resolvedAccount, this.lastTier, onEntry);
|
|
3507
3520
|
} catch (err) {
|
|
3508
3521
|
log.warn({ filePath, err }, "refreshFile: parseMeta threw");
|
|
3509
3522
|
meta = null;
|