claude-bridge-cli 2.0.22 → 2.0.23
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/lib/bridge.js +29 -3
- package/package.json +1 -1
package/lib/bridge.js
CHANGED
|
@@ -427,8 +427,13 @@ function searchSessions(query, limit = 30) {
|
|
|
427
427
|
} catch { return 0; }
|
|
428
428
|
});
|
|
429
429
|
|
|
430
|
+
// Scan far more than the old 200 newest — on a busy machine that cut off
|
|
431
|
+
// sessions only a few days old, so a term you KNEW was there returned
|
|
432
|
+
// nothing. The loop already stops once `limit` results are collected, and
|
|
433
|
+
// the whole-file prefilter below makes a non-matching session cheap.
|
|
430
434
|
const results = [];
|
|
431
|
-
for (const { id, project, filePath } of files.slice(0,
|
|
435
|
+
for (const { id, project, filePath } of files.slice(0, 2000)) {
|
|
436
|
+
if (results.length >= limit) break;
|
|
432
437
|
let stat;
|
|
433
438
|
try { stat = fs.statSync(filePath); } catch { continue; }
|
|
434
439
|
let content;
|
|
@@ -450,9 +455,30 @@ function searchSessions(query, limit = 30) {
|
|
|
450
455
|
let rec;
|
|
451
456
|
try { rec = JSON.parse(line); } catch { continue; }
|
|
452
457
|
const t = rec.type;
|
|
453
|
-
if (t !== "user" && t !== "assistant") continue;
|
|
454
|
-
const msg = rec.message || {};
|
|
455
458
|
const texts = [];
|
|
459
|
+
// Text also lives OUTSIDE message.content: a queued message you typed,
|
|
460
|
+
// the recorded last prompt, compaction summaries, system notes. Parsing
|
|
461
|
+
// only user/assistant records made those unfindable — the old whole-file
|
|
462
|
+
// grep did match them, so skipping them was a regression.
|
|
463
|
+
if (t !== "user" && t !== "assistant") {
|
|
464
|
+
for (const k of ["summary", "lastPrompt", "content", "text"]) {
|
|
465
|
+
if (typeof rec[k] === "string" && rec[k]) texts.push(rec[k]);
|
|
466
|
+
}
|
|
467
|
+
for (const text of texts) {
|
|
468
|
+
const tl = text.toLowerCase();
|
|
469
|
+
let from = tl.indexOf(q);
|
|
470
|
+
if (from < 0) continue;
|
|
471
|
+
while (from >= 0) { matchCount++; from = tl.indexOf(q, from + q.length); }
|
|
472
|
+
if (!snippet) {
|
|
473
|
+
const i = tl.indexOf(q);
|
|
474
|
+
const s = Math.max(0, i - 40), e = Math.min(text.length, i + q.length + 80);
|
|
475
|
+
snippet = (s > 0 ? "…" : "") + text.slice(s, e).replace(/\s+/g, " ").trim()
|
|
476
|
+
+ (e < text.length ? "…" : "");
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
const msg = rec.message || {};
|
|
456
482
|
const c = msg.content;
|
|
457
483
|
if (typeof c === "string") texts.push(c);
|
|
458
484
|
else if (Array.isArray(c)) {
|
package/package.json
CHANGED