grepmax 0.26.32 → 0.26.34

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.
Files changed (54) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/bin.js +109 -0
  3. package/dist/commands/context.js +12 -8
  4. package/dist/commands/doctor.js +7 -9
  5. package/dist/commands/droid.js +2 -1
  6. package/dist/commands/extract.js +8 -11
  7. package/dist/commands/impact.js +5 -8
  8. package/dist/commands/mcp.js +38 -41
  9. package/dist/commands/peek.js +6 -9
  10. package/dist/commands/search-output.js +10 -11
  11. package/dist/commands/search-run.js +5 -4
  12. package/dist/commands/search-skeletons.js +2 -1
  13. package/dist/commands/search.js +5 -4
  14. package/dist/commands/serve.js +2 -1
  15. package/dist/commands/similar.js +7 -6
  16. package/dist/commands/skeleton.js +17 -22
  17. package/dist/commands/test-find.js +5 -8
  18. package/dist/commands/watch.js +9 -0
  19. package/dist/config.js +19 -9
  20. package/dist/eval-oss.js +4 -3
  21. package/dist/eval-tokens.js +4 -4
  22. package/dist/eval.js +2 -5
  23. package/dist/index.js +4 -3
  24. package/dist/lib/daemon/daemon.js +36 -29
  25. package/dist/lib/daemon/graph-handler.js +2 -1
  26. package/dist/lib/daemon/mlx-server-manager.js +10 -9
  27. package/dist/lib/daemon/rows-handler.js +11 -13
  28. package/dist/lib/daemon/search-handler.js +6 -5
  29. package/dist/lib/daemon/vector-handler.js +2 -1
  30. package/dist/lib/daemon/watcher-manager.js +4 -2
  31. package/dist/lib/graph/graph-builder.js +4 -10
  32. package/dist/lib/graph/graph-traversal.js +0 -0
  33. package/dist/lib/index/batch-processor.js +13 -12
  34. package/dist/lib/index/chunker.js +22 -23
  35. package/dist/lib/index/syncer.js +2 -2
  36. package/dist/lib/llm/investigate.js +5 -4
  37. package/dist/lib/llm/review.js +2 -1
  38. package/dist/lib/llm/tools.js +6 -5
  39. package/dist/lib/output/agent-search-formatter.js +3 -2
  40. package/dist/lib/output/compact-results.js +16 -12
  41. package/dist/lib/search/searcher.js +11 -13
  42. package/dist/lib/setup/model-loader.js +1 -1
  43. package/dist/lib/skeleton/body-fields.js +2 -1
  44. package/dist/lib/skeleton/skeletonizer.js +8 -7
  45. package/dist/lib/store/vector-db.js +6 -5
  46. package/dist/lib/utils/autostart.js +6 -0
  47. package/dist/lib/utils/formatter.js +5 -4
  48. package/dist/lib/utils/stale-hint.js +4 -3
  49. package/dist/lib/utils/store-access.js +2 -1
  50. package/dist/lib/utils/stores.js +124 -0
  51. package/dist/lib/workers/embeddings/granite.js +2 -1
  52. package/dist/lib/workers/pool.js +14 -10
  53. package/package.json +5 -6
  54. package/plugins/grepmax/.claude-plugin/plugin.json +1 -1
@@ -54,13 +54,14 @@ const project_registry_1 = require("../utils/project-registry");
54
54
  */
55
55
  function handleDaemonSearch(deps, payload, signal) {
56
56
  return __awaiter(this, void 0, void 0, function* () {
57
- var _a, _b, _c, _d, _e, _f;
57
+ var _a, _b, _c, _d;
58
+ var _e, _f;
58
59
  const { vectorDb, workerPool } = deps;
59
60
  if (!vectorDb || !workerPool) {
60
61
  return { ok: false, error: "daemon not ready" };
61
62
  }
62
63
  const root = payload.projectRoot;
63
- const roots = (_b = (_a = payload.filters) === null || _a === void 0 ? void 0 : _a.projectRoots) !== null && _b !== void 0 ? _b : [root];
64
+ const roots = (_e = (_a = payload.filters) === null || _a === void 0 ? void 0 : _a.projectRoots) !== null && _e !== void 0 ? _e : [root];
64
65
  for (const candidateRoot of roots) {
65
66
  const project = (0, project_registry_1.getProject)(candidateRoot);
66
67
  if ((project === null || project === void 0 ? void 0 : project.status) === "indexed" &&
@@ -80,7 +81,7 @@ function handleDaemonSearch(deps, payload, signal) {
80
81
  // An indexed project nobody holds a watch lease on is served from its
81
82
  // last-synced vectors — watching is per session now, not a precondition
82
83
  // for reading. Only unknown, never-indexed roots get "not watched".
83
- const status = (_c = (0, project_registry_1.getProject)(root)) === null || _c === void 0 ? void 0 : _c.status;
84
+ const status = (_b = (0, project_registry_1.getProject)(root)) === null || _b === void 0 ? void 0 : _b.status;
84
85
  const indexingNow = deps.indexProgress.has(root) || status === "pending";
85
86
  if (!indexingNow && status !== "indexed") {
86
87
  return {
@@ -112,7 +113,7 @@ function handleDaemonSearch(deps, payload, signal) {
112
113
  return { ok: false, error: "search_failed", hint: msg };
113
114
  }
114
115
  const response = { ok: true, data: result.data };
115
- if ((_d = result.warnings) === null || _d === void 0 ? void 0 : _d.length)
116
+ if ((_c = result.warnings) === null || _c === void 0 ? void 0 : _c.length)
116
117
  response.warnings = result.warnings;
117
118
  // Annotate partial results when the index is still catching up, so an
118
119
  // agent can caveat or retry. Only attached when actually indexing (the
@@ -130,7 +131,7 @@ function handleDaemonSearch(deps, payload, signal) {
130
131
  const seen = new Set();
131
132
  const skeletons = {};
132
133
  for (const chunk of result.data) {
133
- const p = (_e = chunk.path) !== null && _e !== void 0 ? _e : (_f = chunk.metadata) === null || _f === void 0 ? void 0 : _f.path;
134
+ const p = (_f = chunk.path) !== null && _f !== void 0 ? _f : (_d = chunk.metadata) === null || _d === void 0 ? void 0 : _d.path;
134
135
  if (!p || seen.has(p))
135
136
  continue;
136
137
  seen.add(p);
@@ -41,7 +41,8 @@ const read_verbs_1 = require("./read-verbs");
41
41
  const rows_handler_1 = require("./rows-handler");
42
42
  function runSimilar(deps, req) {
43
43
  return __awaiter(this, void 0, void 0, function* () {
44
- var _a, _b;
44
+ var _a;
45
+ var _b;
45
46
  if (!deps.vectorDb)
46
47
  throw new rows_handler_1.ReadVerbError("daemon not ready");
47
48
  (_a = deps.touchActivity) === null || _a === void 0 ? void 0 : _a.call(deps);
@@ -248,7 +248,8 @@ class WatcherManager {
248
248
  });
249
249
  }
250
250
  isRootDegraded(root) {
251
- var _a, _b;
251
+ var _a;
252
+ var _b;
252
253
  return (this.degradedRoots.has(root) ||
253
254
  ((_b = (_a = this.terminalFailures.get(root)) === null || _a === void 0 ? void 0 : _a.size) !== null && _b !== void 0 ? _b : 0) > 0);
254
255
  }
@@ -487,7 +488,8 @@ class WatcherManager {
487
488
  catchupScan(root, processor, signal) {
488
489
  return __awaiter(this, void 0, void 0, function* () {
489
490
  var _a, e_1, _b, _c;
490
- var _d, _e;
491
+ var _d;
492
+ var _e;
491
493
  const { isFileCached } = yield Promise.resolve().then(() => __importStar(require("../utils/cache-check")));
492
494
  const metaCache = this.deps.getMetaCache();
493
495
  const vectorDb = this.deps.getVectorDb();
@@ -192,11 +192,8 @@ class GraphBuilder {
192
192
  // first row when no candidate shares the center's file or family.
193
193
  const selfRow = rows.find((r) => { var _a; return String((_a = r.path) !== null && _a !== void 0 ? _a : "") === centerFile; });
194
194
  const familyRow = centerFamily
195
- ? rows.find((r) => {
196
- var _a;
197
- return (0, languages_1.languageFamilyForPath)(String((_a = r.path) !== null && _a !== void 0 ? _a : "")) ===
198
- centerFamily;
199
- })
195
+ ? rows.find((r) => { var _a; return (0, languages_1.languageFamilyForPath)(String((_a = r.path) !== null && _a !== void 0 ? _a : "")) ===
196
+ centerFamily; })
200
197
  : undefined;
201
198
  calleeNodes.push(this.mapRowToNode(((_a = selfRow !== null && selfRow !== void 0 ? selfRow : familyRow) !== null && _a !== void 0 ? _a : rows[0]), name, "center"));
202
199
  }
@@ -371,11 +368,8 @@ class GraphBuilder {
371
368
  return null;
372
369
  let r = rows[0];
373
370
  if (anchorFamily) {
374
- const match = rows.find((row) => {
375
- var _a;
376
- return (0, languages_1.languageFamilyForPath)(String((_a = row.path) !== null && _a !== void 0 ? _a : "")) ===
377
- anchorFamily;
378
- });
371
+ const match = rows.find((row) => { var _a; return (0, languages_1.languageFamilyForPath)(String((_a = row.path) !== null && _a !== void 0 ? _a : "")) ===
372
+ anchorFamily; });
379
373
  if (match)
380
374
  r = match;
381
375
  }
Binary file
@@ -94,8 +94,7 @@ class ProjectBatchProcessor {
94
94
  this.onTerminalFailure = opts.onTerminalFailure;
95
95
  this.onPathSuccess = opts.onPathSuccess;
96
96
  this.runOperation = opts.runOperation;
97
- this.filePolicy =
98
- (_b = opts.filePolicy) !== null && _b !== void 0 ? _b : new file_policy_1.ProjectFilePolicy(opts.projectRoot);
97
+ this.filePolicy = (_b = opts.filePolicy) !== null && _b !== void 0 ? _b : new file_policy_1.ProjectFilePolicy(opts.projectRoot);
99
98
  this.wtag = `watch:${path.basename(opts.projectRoot)}`;
100
99
  this.concurrency = Math.max(1, Math.floor((_c = opts.concurrency) !== null && _c !== void 0 ? _c : DEFAULT_BATCH_CONCURRENCY));
101
100
  const taskTimeoutMs = (() => {
@@ -232,7 +231,8 @@ class ProjectBatchProcessor {
232
231
  }
233
232
  processBatch(operationSignal) {
234
233
  return __awaiter(this, void 0, void 0, function* () {
235
- var _a, _b, _c, _d, _e, _f;
234
+ var _a, _b, _c, _d;
235
+ var _e, _f;
236
236
  if (this.closed || this.processing || this.pending.size === 0)
237
237
  return;
238
238
  const diskPressure = this.vectorDb.checkDiskPressure();
@@ -244,7 +244,7 @@ class ProjectBatchProcessor {
244
244
  const now = Date.now();
245
245
  let taken = 0;
246
246
  for (const [absPath, event] of this.pending) {
247
- if (((_a = this.retryAt.get(absPath)) !== null && _a !== void 0 ? _a : 0) > now)
247
+ if (((_e = this.retryAt.get(absPath)) !== null && _e !== void 0 ? _e : 0) > now)
248
248
  continue;
249
249
  batch.set(absPath, event);
250
250
  const forceGeneration = this.forcedReprocess.get(absPath);
@@ -291,17 +291,18 @@ class ProjectBatchProcessor {
291
291
  const completed = new Set();
292
292
  const retryFailures = new Set();
293
293
  const requeuePath = (absPath, event, failed) => {
294
- var _a, _b;
294
+ var _a;
295
+ var _b;
295
296
  if (this.pending.has(absPath))
296
297
  return;
297
298
  if (failed) {
298
- const retry = (0, watcher_batch_1.computePathRetry)((_a = this.retryCount.get(absPath)) !== null && _a !== void 0 ? _a : 0, MAX_RETRIES, DEBOUNCE_MS);
299
+ const retry = (0, watcher_batch_1.computePathRetry)((_b = this.retryCount.get(absPath)) !== null && _b !== void 0 ? _b : 0, MAX_RETRIES, DEBOUNCE_MS);
299
300
  if (!retry.retry) {
300
301
  (0, logger_1.log)(this.wtag, `Dropped ${path.basename(absPath)} after ${MAX_RETRIES} retries`);
301
302
  this.retryCount.delete(absPath);
302
303
  this.retryAt.delete(absPath);
303
304
  this.terminalFailures.add(absPath);
304
- (_b = this.onTerminalFailure) === null || _b === void 0 ? void 0 : _b.call(this, absPath);
305
+ (_a = this.onTerminalFailure) === null || _a === void 0 ? void 0 : _a.call(this, absPath);
305
306
  return;
306
307
  }
307
308
  this.retryCount.set(absPath, retry.failures);
@@ -519,7 +520,7 @@ class ProjectBatchProcessor {
519
520
  }
520
521
  const duration = Date.now() - start;
521
522
  if (reindexed > 0) {
522
- (_b = this.onReindex) === null || _b === void 0 ? void 0 : _b.call(this, reindexed, duration);
523
+ (_a = this.onReindex) === null || _a === void 0 ? void 0 : _a.call(this, reindexed, duration);
523
524
  }
524
525
  this.recentBatches.push({ files: batch.size, reindexed });
525
526
  if (this.recentBatches.length > ProjectBatchProcessor.RECENT_BATCH_WINDOW) {
@@ -536,7 +537,7 @@ class ProjectBatchProcessor {
536
537
  this.retryCount.delete(absPath);
537
538
  this.retryAt.delete(absPath);
538
539
  this.terminalFailures.delete(absPath);
539
- (_c = this.onPathSuccess) === null || _c === void 0 ? void 0 : _c.call(this, absPath);
540
+ (_b = this.onPathSuccess) === null || _b === void 0 ? void 0 : _b.call(this, absPath);
540
541
  }
541
542
  // Trigger compaction if fragments are accumulating
542
543
  if (reindexed > 0 && diskPressure !== "critical") {
@@ -593,12 +594,12 @@ class ProjectBatchProcessor {
593
594
  continue;
594
595
  if (this.pending.has(absPath))
595
596
  continue;
596
- const retry = (0, watcher_batch_1.computePathRetry)((_d = this.retryCount.get(absPath)) !== null && _d !== void 0 ? _d : 0, MAX_RETRIES, DEBOUNCE_MS);
597
+ const retry = (0, watcher_batch_1.computePathRetry)((_f = this.retryCount.get(absPath)) !== null && _f !== void 0 ? _f : 0, MAX_RETRIES, DEBOUNCE_MS);
597
598
  if (!retry.retry) {
598
599
  this.retryCount.delete(absPath);
599
600
  this.retryAt.delete(absPath);
600
601
  this.terminalFailures.add(absPath);
601
- (_e = this.onTerminalFailure) === null || _e === void 0 ? void 0 : _e.call(this, absPath);
602
+ (_c = this.onTerminalFailure) === null || _c === void 0 ? void 0 : _c.call(this, absPath);
602
603
  dropped++;
603
604
  droppedPaths.push(absPath);
604
605
  continue;
@@ -644,7 +645,7 @@ class ProjectBatchProcessor {
644
645
  }
645
646
  }
646
647
  if (!this.closed)
647
- (_f = this.onBatchSettled) === null || _f === void 0 ? void 0 : _f.call(this);
648
+ (_d = this.onBatchSettled) === null || _d === void 0 ? void 0 : _d.call(this);
648
649
  }
649
650
  });
650
651
  }
@@ -623,12 +623,9 @@ class TreeSitterChunker {
623
623
  "property_identifier",
624
624
  "field_identifier", // Go
625
625
  ]);
626
- const isLeafId = (n) => {
627
- var _a, _b;
628
- return !!n &&
629
- LEAF_ID_TYPES.has(n.type) &&
630
- ((_b = (_a = n.namedChildren) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0;
631
- };
626
+ const isLeafId = (n) => { var _a; var _b; return !!n &&
627
+ LEAF_ID_TYPES.has(n.type) &&
628
+ ((_b = (_a = n.namedChildren) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0; };
632
629
  const firstNamed = (n) => { var _a, _b; return (_b = ((_a = n.namedChildren) !== null && _a !== void 0 ? _a : [])[0]) !== null && _b !== void 0 ? _b : null; };
633
630
  // Resolve the type name out of an instantiation node (`new Foo`,
634
631
  // `Foo{}`, `new Foo()`), preferring an explicit `type` field and
@@ -693,7 +690,8 @@ class TreeSitterChunker {
693
690
  // in `Literal["x"]`) fall out via the kind + Capitalized gates.
694
691
  const TYPE_NAME_LEAF_TYPES = new Set(["identifier", "name"]);
695
692
  const harvestTypeLeaves = (node) => {
696
- var _a, _b, _c;
693
+ var _a;
694
+ var _b, _c;
697
695
  if (!node)
698
696
  return;
699
697
  if (((_b = (_a = node.namedChildren) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0) {
@@ -708,7 +706,8 @@ class TreeSitterChunker {
708
706
  harvestTypeLeaves(c);
709
707
  };
710
708
  const extractRefs = (n) => {
711
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
709
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
710
+ var _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
712
711
  // Handle JS/TS (call_expression), Python (call), Lua (function_call)
713
712
  if (n.type === "call_expression" ||
714
713
  n.type === "call" ||
@@ -749,14 +748,14 @@ class TreeSitterChunker {
749
748
  else {
750
749
  // Swift/Kotlin: call_expression has no "function" field;
751
750
  // the callable is a positional child
752
- const firstChild = ((_a = n.namedChildren) !== null && _a !== void 0 ? _a : [])[0];
751
+ const firstChild = ((_l = n.namedChildren) !== null && _l !== void 0 ? _l : [])[0];
753
752
  if (firstChild) {
754
753
  let funcName = firstChild.text;
755
754
  let isMemberCall = false;
756
755
  if (firstChild.type === "navigation_expression") {
757
- const suffix = ((_b = firstChild.namedChildren) !== null && _b !== void 0 ? _b : []).find((c) => c.type === "navigation_suffix");
756
+ const suffix = ((_m = firstChild.namedChildren) !== null && _m !== void 0 ? _m : []).find((c) => c.type === "navigation_suffix");
758
757
  const methodId = suffix
759
- ? ((_c = suffix.namedChildren) !== null && _c !== void 0 ? _c : []).find((c) => c.type === "simple_identifier")
758
+ ? ((_o = suffix.namedChildren) !== null && _o !== void 0 ? _o : []).find((c) => c.type === "simple_identifier")
760
759
  : null;
761
760
  if (methodId) {
762
761
  funcName = methodId.text;
@@ -772,13 +771,13 @@ class TreeSitterChunker {
772
771
  // JSX elements: <Component /> or <Component>
773
772
  if (n.type === "jsx_self_closing_element" ||
774
773
  n.type === "jsx_opening_element") {
775
- const nameChild = ((_d = n.namedChildren) !== null && _d !== void 0 ? _d : []).find((c) => c.type === "identifier" ||
774
+ const nameChild = ((_p = n.namedChildren) !== null && _p !== void 0 ? _p : []).find((c) => c.type === "identifier" ||
776
775
  c.type === "member_expression" ||
777
776
  c.type === "nested_identifier");
778
777
  if (nameChild) {
779
778
  // Only capture PascalCase components (skip HTML tags like div, span)
780
779
  const name = nameChild.type === "member_expression"
781
- ? ((_g = (_f = (_e = nameChild.childForFieldName) === null || _e === void 0 ? void 0 : _e.call(nameChild, "property")) === null || _f === void 0 ? void 0 : _f.text) !== null && _g !== void 0 ? _g : nameChild.text)
780
+ ? ((_q = (_b = (_a = nameChild.childForFieldName) === null || _a === void 0 ? void 0 : _a.call(nameChild, "property")) === null || _b === void 0 ? void 0 : _b.text) !== null && _q !== void 0 ? _q : nameChild.text)
782
781
  : nameChild.text;
783
782
  if (name && /^[A-Z]/.test(name)) {
784
783
  referencedSymbols.push(name);
@@ -822,7 +821,7 @@ class TreeSitterChunker {
822
821
  }
823
822
  else if (n.type === "is_pattern_expression") {
824
823
  // C# — `x is BeyondError`: the type sits in a constant_pattern.
825
- const cp = ((_h = n.namedChildren) !== null && _h !== void 0 ? _h : []).find((c) => c.type === "constant_pattern");
824
+ const cp = ((_r = n.namedChildren) !== null && _r !== void 0 ? _r : []).find((c) => c.type === "constant_pattern");
826
825
  const id = cp ? firstNamed(cp) : null;
827
826
  if (isLeafId(id) && id && /^[A-Z]/.test(id.text))
828
827
  addRef(id.text);
@@ -854,7 +853,7 @@ class TreeSitterChunker {
854
853
  // type_identifier and are already covered. Reduce `extends ns.Base`
855
854
  // to `Base`; skip type arguments (Shape 4 handles those).
856
855
  if (n.type === "extends_clause") {
857
- for (const c of (_j = n.namedChildren) !== null && _j !== void 0 ? _j : []) {
856
+ for (const c of (_s = n.namedChildren) !== null && _s !== void 0 ? _s : []) {
858
857
  if (c.type === "type_arguments")
859
858
  continue;
860
859
  const sup = simpleRefName(c);
@@ -876,16 +875,16 @@ class TreeSitterChunker {
876
875
  // `x: Foo`, `-> Bar`, `v: Baz = …`, and `class C(Base)` bases.
877
876
  if (n.type === "typed_parameter" ||
878
877
  n.type === "typed_default_parameter") {
879
- harvestTypeLeaves((_l = (_k = n.childForFieldName) === null || _k === void 0 ? void 0 : _k.call(n, "type")) !== null && _l !== void 0 ? _l : null);
878
+ harvestTypeLeaves((_t = (_c = n.childForFieldName) === null || _c === void 0 ? void 0 : _c.call(n, "type")) !== null && _t !== void 0 ? _t : null);
880
879
  }
881
880
  else if (n.type === "function_definition") {
882
- harvestTypeLeaves((_o = (_m = n.childForFieldName) === null || _m === void 0 ? void 0 : _m.call(n, "return_type")) !== null && _o !== void 0 ? _o : null);
881
+ harvestTypeLeaves((_u = (_d = n.childForFieldName) === null || _d === void 0 ? void 0 : _d.call(n, "return_type")) !== null && _u !== void 0 ? _u : null);
883
882
  }
884
883
  else if (n.type === "assignment") {
885
- harvestTypeLeaves((_q = (_p = n.childForFieldName) === null || _p === void 0 ? void 0 : _p.call(n, "type")) !== null && _q !== void 0 ? _q : null);
884
+ harvestTypeLeaves((_v = (_e = n.childForFieldName) === null || _e === void 0 ? void 0 : _e.call(n, "type")) !== null && _v !== void 0 ? _v : null);
886
885
  }
887
886
  else if (n.type === "class_definition") {
888
- harvestTypeLeaves((_s = (_r = n.childForFieldName) === null || _r === void 0 ? void 0 : _r.call(n, "superclasses")) !== null && _s !== void 0 ? _s : null);
887
+ harvestTypeLeaves((_w = (_f = n.childForFieldName) === null || _f === void 0 ? void 0 : _f.call(n, "superclasses")) !== null && _w !== void 0 ? _w : null);
889
888
  }
890
889
  }
891
890
  else if (lang === "c_sharp") {
@@ -894,10 +893,10 @@ class TreeSitterChunker {
894
893
  if (n.type === "parameter" ||
895
894
  n.type === "property_declaration" ||
896
895
  n.type === "variable_declaration") {
897
- harvestTypeLeaves((_u = (_t = n.childForFieldName) === null || _t === void 0 ? void 0 : _t.call(n, "type")) !== null && _u !== void 0 ? _u : null);
896
+ harvestTypeLeaves((_x = (_g = n.childForFieldName) === null || _g === void 0 ? void 0 : _g.call(n, "type")) !== null && _x !== void 0 ? _x : null);
898
897
  }
899
898
  else if (n.type === "method_declaration") {
900
- harvestTypeLeaves((_w = (_v = n.childForFieldName) === null || _v === void 0 ? void 0 : _v.call(n, "returns")) !== null && _w !== void 0 ? _w : null);
899
+ harvestTypeLeaves((_y = (_h = n.childForFieldName) === null || _h === void 0 ? void 0 : _h.call(n, "returns")) !== null && _y !== void 0 ? _y : null);
901
900
  }
902
901
  else if (n.type === "base_list") {
903
902
  harvestTypeLeaves(n);
@@ -909,11 +908,11 @@ class TreeSitterChunker {
909
908
  // (`return_type`), and the extends / implements clauses.
910
909
  if (n.type === "simple_parameter" ||
911
910
  n.type === "property_declaration") {
912
- harvestTypeLeaves((_y = (_x = n.childForFieldName) === null || _x === void 0 ? void 0 : _x.call(n, "type")) !== null && _y !== void 0 ? _y : null);
911
+ harvestTypeLeaves((_z = (_j = n.childForFieldName) === null || _j === void 0 ? void 0 : _j.call(n, "type")) !== null && _z !== void 0 ? _z : null);
913
912
  }
914
913
  else if (n.type === "function_definition" ||
915
914
  n.type === "method_declaration") {
916
- harvestTypeLeaves((_0 = (_z = n.childForFieldName) === null || _z === void 0 ? void 0 : _z.call(n, "return_type")) !== null && _0 !== void 0 ? _0 : null);
915
+ harvestTypeLeaves((_0 = (_k = n.childForFieldName) === null || _k === void 0 ? void 0 : _k.call(n, "return_type")) !== null && _0 !== void 0 ? _0 : null);
917
916
  }
918
917
  else if (n.type === "base_clause" ||
919
918
  n.type === "class_interface_clause") {
@@ -701,8 +701,8 @@ function initialSync(options) {
701
701
  }
702
702
  // Only close resources we own (not injected by daemon)
703
703
  if (!injected) {
704
- yield (metaCache === null || metaCache === void 0 ? void 0 : metaCache.close());
705
- yield (ownedVectorDb === null || ownedVectorDb === void 0 ? void 0 : ownedVectorDb.close());
704
+ yield metaCache === null || metaCache === void 0 ? void 0 : metaCache.close();
705
+ yield ownedVectorDb === null || ownedVectorDb === void 0 ? void 0 : ownedVectorDb.close();
706
706
  }
707
707
  }
708
708
  });
@@ -94,9 +94,10 @@ function finalizeAnswer(content, modelName) {
94
94
  }
95
95
  function investigate(opts) {
96
96
  return __awaiter(this, void 0, void 0, function* () {
97
- var _a, _b, _c;
97
+ var _a, _b;
98
+ var _c;
98
99
  const { question, projectRoot, verbose = false } = opts;
99
- const maxRounds = (_a = opts.maxRounds) !== null && _a !== void 0 ? _a : prompts_1.MAX_ROUNDS;
100
+ const maxRounds = (_c = opts.maxRounds) !== null && _c !== void 0 ? _c : prompts_1.MAX_ROUNDS;
100
101
  const config = (0, config_1.getLlmConfig)();
101
102
  const modelName = path.basename(config.model, path.extname(config.model));
102
103
  const client = new openai_1.default({
@@ -140,7 +141,7 @@ function investigate(opts) {
140
141
  tool_choice: "auto",
141
142
  temperature: 0,
142
143
  });
143
- if (!((_b = response.choices) === null || _b === void 0 ? void 0 : _b.length)) {
144
+ if (!((_a = response.choices) === null || _a === void 0 ? void 0 : _a.length)) {
144
145
  throw new Error("LLM returned empty response");
145
146
  }
146
147
  const message = response.choices[0].message;
@@ -235,7 +236,7 @@ function investigate(opts) {
235
236
  messages,
236
237
  temperature: 0,
237
238
  });
238
- if (!((_c = response.choices) === null || _c === void 0 ? void 0 : _c.length)) {
239
+ if (!((_b = response.choices) === null || _b === void 0 ? void 0 : _b.length)) {
239
240
  throw new Error("LLM returned empty response");
240
241
  }
241
242
  const answer = finalizeAnswer(response.choices[0].message.content, modelName);
@@ -59,7 +59,8 @@ const report_1 = require("./report");
59
59
  const tools_1 = require("./tools");
60
60
  function reviewCommit(opts) {
61
61
  return __awaiter(this, void 0, void 0, function* () {
62
- var _a, _b, _c, _d;
62
+ var _a, _b, _c;
63
+ var _d;
63
64
  const { commitRef, projectRoot, verbose = false } = opts;
64
65
  const wallStart = Date.now();
65
66
  // 1. Extract diff
@@ -180,15 +180,16 @@ function executeSearch(args, ctx) {
180
180
  if (!resp.data || resp.data.length === 0)
181
181
  return "(no results)";
182
182
  const lines = resp.data.map((r) => {
183
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
184
- const absPath = String((_c = (_b = (_a = r.metadata) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : r.path) !== null && _c !== void 0 ? _c : "");
183
+ var _a, _b;
184
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l;
185
+ const absPath = String((_d = (_c = (_a = r.metadata) === null || _a === void 0 ? void 0 : _a.path) !== null && _c !== void 0 ? _c : r.path) !== null && _d !== void 0 ? _d : "");
185
186
  const rp = rel(absPath, ctx.projectRoot);
186
- const defs = (0, arrow_1.toArr)((_d = r.definedSymbols) !== null && _d !== void 0 ? _d : r.defined_symbols);
187
+ const defs = (0, arrow_1.toArr)((_e = r.definedSymbols) !== null && _e !== void 0 ? _e : r.defined_symbols);
187
188
  const sym = defs[0] || "(anonymous)";
188
- const role = String((_e = r.role) !== null && _e !== void 0 ? _e : "IMPL")
189
+ const role = String((_f = r.role) !== null && _f !== void 0 ? _f : "IMPL")
189
190
  .slice(0, 4)
190
191
  .toUpperCase();
191
- const startLine = (_j = (_h = (_f = r.startLine) !== null && _f !== void 0 ? _f : (_g = r.generated_metadata) === null || _g === void 0 ? void 0 : _g.start_line) !== null && _h !== void 0 ? _h : r.start_line) !== null && _j !== void 0 ? _j : 0;
192
+ const startLine = (_j = (_h = (_g = r.startLine) !== null && _g !== void 0 ? _g : (_b = r.generated_metadata) === null || _b === void 0 ? void 0 : _b.start_line) !== null && _h !== void 0 ? _h : r.start_line) !== null && _j !== void 0 ? _j : 0;
192
193
  const hint = String((_l = (_k = r.text) !== null && _k !== void 0 ? _k : r.content) !== null && _l !== void 0 ? _l : "")
193
194
  .split("\n")[0]
194
195
  .slice(0, 100);
@@ -40,8 +40,9 @@ function chunkPath(chunk) {
40
40
  return String(chunk.path || (metadata === null || metadata === void 0 ? void 0 : metadata.path) || "");
41
41
  }
42
42
  function chunkStartLine(chunk) {
43
- var _a, _b, _c, _d;
44
- return Math.max(1, Number((_d = (_b = (_a = chunk.startLine) !== null && _a !== void 0 ? _a : chunk.start_line) !== null && _b !== void 0 ? _b : (_c = chunk.generated_metadata) === null || _c === void 0 ? void 0 : _c.start_line) !== null && _d !== void 0 ? _d : 0) + 1);
43
+ var _a;
44
+ var _b, _c, _d;
45
+ return Math.max(1, Number((_d = (_c = (_b = chunk.startLine) !== null && _b !== void 0 ? _b : chunk.start_line) !== null && _c !== void 0 ? _c : (_a = chunk.generated_metadata) === null || _a === void 0 ? void 0 : _a.start_line) !== null && _d !== void 0 ? _d : 0) + 1);
45
46
  }
46
47
  function definedSymbols(chunk) {
47
48
  var _a;
@@ -40,7 +40,8 @@ exports.resultCountHeader = resultCountHeader;
40
40
  const path = __importStar(require("node:path"));
41
41
  function toTextResults(data) {
42
42
  return data.map((r) => {
43
- var _a, _b, _c, _d, _e, _f;
43
+ var _a, _b, _c, _d, _e;
44
+ var _f;
44
45
  const rawPath = typeof ((_a = r.metadata) === null || _a === void 0 ? void 0 : _a.path) === "string"
45
46
  ? r.metadata.path
46
47
  : "Unknown path";
@@ -49,23 +50,24 @@ function toTextResults(data) {
49
50
  : 0;
50
51
  const end = typeof ((_c = r.generated_metadata) === null || _c === void 0 ? void 0 : _c.end_line) === "number"
51
52
  ? r.generated_metadata.end_line
52
- : start + Math.max(0, ((_e = (_d = r.generated_metadata) === null || _d === void 0 ? void 0 : _d.num_lines) !== null && _e !== void 0 ? _e : 1) - 1);
53
+ : start + Math.max(0, ((_f = (_d = r.generated_metadata) === null || _d === void 0 ? void 0 : _d.num_lines) !== null && _f !== void 0 ? _f : 1) - 1);
53
54
  return {
54
55
  path: rawPath,
55
56
  score: r.score,
56
57
  content: r.text || "",
57
- chunk_type: (_f = r.generated_metadata) === null || _f === void 0 ? void 0 : _f.type,
58
+ chunk_type: (_e = r.generated_metadata) === null || _e === void 0 ? void 0 : _e.type,
58
59
  start_line: start,
59
60
  end_line: end,
60
61
  };
61
62
  });
62
63
  }
63
64
  function getPreviewText(chunk) {
64
- var _a, _b, _c, _d, _e;
65
+ var _a, _b;
66
+ var _c, _d, _e;
65
67
  const maxLen = 140;
66
- const lines = (_b = (_a = chunk.text) === null || _a === void 0 ? void 0 : _a.split("\n").map((l) => l.trim()).filter(Boolean)) !== null && _b !== void 0 ? _b : [];
67
- let preview = (_c = lines[0]) !== null && _c !== void 0 ? _c : "";
68
- if (!preview && ((_d = chunk.defined_symbols) === null || _d === void 0 ? void 0 : _d.length)) {
68
+ const lines = (_c = (_a = chunk.text) === null || _a === void 0 ? void 0 : _a.split("\n").map((l) => l.trim()).filter(Boolean)) !== null && _c !== void 0 ? _c : [];
69
+ let preview = (_d = lines[0]) !== null && _d !== void 0 ? _d : "";
70
+ if (!preview && ((_b = chunk.defined_symbols) === null || _b === void 0 ? void 0 : _b.length)) {
69
71
  preview = (_e = chunk.defined_symbols[0]) !== null && _e !== void 0 ? _e : "";
70
72
  }
71
73
  if (preview.length > maxLen) {
@@ -75,7 +77,8 @@ function getPreviewText(chunk) {
75
77
  }
76
78
  function toCompactHits(data) {
77
79
  return data.map((chunk) => {
78
- var _a, _b, _c, _d, _e, _f;
80
+ var _a, _b, _c, _d, _e;
81
+ var _f;
79
82
  const rawPath = typeof ((_a = chunk.metadata) === null || _a === void 0 ? void 0 : _a.path) === "string"
80
83
  ? chunk.metadata.path
81
84
  : "Unknown path";
@@ -84,7 +87,7 @@ function toCompactHits(data) {
84
87
  : 0;
85
88
  const end = typeof ((_c = chunk.generated_metadata) === null || _c === void 0 ? void 0 : _c.end_line) === "number"
86
89
  ? chunk.generated_metadata.end_line
87
- : start + Math.max(0, ((_e = (_d = chunk.generated_metadata) === null || _d === void 0 ? void 0 : _d.num_lines) !== null && _e !== void 0 ? _e : 1) - 1);
90
+ : start + Math.max(0, ((_f = (_d = chunk.generated_metadata) === null || _d === void 0 ? void 0 : _d.num_lines) !== null && _f !== void 0 ? _f : 1) - 1);
88
91
  return {
89
92
  path: rawPath,
90
93
  range: `${start + 1}-${end + 1}`,
@@ -97,7 +100,7 @@ function toCompactHits(data) {
97
100
  ? chunk.defined_symbols.slice(0, 3)
98
101
  : typeof chunk.defined_symbols === "string"
99
102
  ? [chunk.defined_symbols]
100
- : typeof ((_f = chunk.defined_symbols) === null || _f === void 0 ? void 0 : _f.toArray) === "function"
103
+ : typeof ((_e = chunk.defined_symbols) === null || _e === void 0 ? void 0 : _e.toArray) === "function"
101
104
  ? chunk.defined_symbols.toArray().slice(0, 3)
102
105
  : [],
103
106
  preview: getPreviewText(chunk),
@@ -232,10 +235,11 @@ function formatCompactTable(hits, projectRoot, query, opts) {
232
235
  return formatCompactPretty(hits, projectRoot, query, termWidth, true);
233
236
  }
234
237
  function resultCountHeader(results, maxCount) {
235
- var _a, _b, _c;
238
+ var _a;
239
+ var _b, _c;
236
240
  const files = new Set();
237
241
  for (const r of results) {
238
- const p = (_c = (_a = r.path) !== null && _a !== void 0 ? _a : (_b = r.metadata) === null || _b === void 0 ? void 0 : _b.path) !== null && _c !== void 0 ? _c : "";
242
+ const p = (_c = (_b = r.path) !== null && _b !== void 0 ? _b : (_a = r.metadata) === null || _a === void 0 ? void 0 : _a.path) !== null && _c !== void 0 ? _c : "";
239
243
  if (p)
240
244
  files.add(p);
241
245
  }
@@ -268,12 +268,13 @@ class Searcher {
268
268
  };
269
269
  }
270
270
  applyStructureBoost(record, score, intent) {
271
- var _a, _b, _c, _d;
271
+ var _a;
272
+ var _b, _c, _d;
272
273
  let adjusted = score;
273
274
  // Item 6: Anchors are recall helpers, not rank contenders
274
275
  if (record.is_anchor) {
275
276
  // Minimal penalty to break ties
276
- const anchorPenalty = Number.parseFloat((_a = process.env.GMAX_ANCHOR_PENALTY) !== null && _a !== void 0 ? _a : "") || 0.99;
277
+ const anchorPenalty = Number.parseFloat((_b = process.env.GMAX_ANCHOR_PENALTY) !== null && _b !== void 0 ? _b : "") || 0.99;
277
278
  adjusted *= anchorPenalty;
278
279
  }
279
280
  else {
@@ -301,7 +302,7 @@ class Searcher {
301
302
  boostFactor *= 1.1;
302
303
  }
303
304
  // --- Complexity/Orchestration Boost (User Requested) ---
304
- const refs = ((_b = record.referenced_symbols) === null || _b === void 0 ? void 0 : _b.length) || 0;
305
+ const refs = ((_a = record.referenced_symbols) === null || _a === void 0 ? void 0 : _a.length) || 0;
305
306
  if (refs > 5) {
306
307
  // Small boost for non-trivial functions
307
308
  boostFactor *= 1.1;
@@ -757,16 +758,13 @@ class Searcher {
757
758
  if (doRerank && rerankCandidates.length > 0) {
758
759
  const scores = yield pool.rerank({
759
760
  query: queryMatrixRaw,
760
- docs: rerankCandidates.map((doc) => {
761
- var _a;
762
- return ({
763
- colbert: (_a = doc.colbert) !== null && _a !== void 0 ? _a : [],
764
- scale: typeof doc.colbert_scale === "number" ? doc.colbert_scale : 1,
765
- token_ids: Array.isArray(doc.doc_token_ids)
766
- ? doc.doc_token_ids
767
- : undefined,
768
- });
769
- }),
761
+ docs: rerankCandidates.map((doc) => { var _a; return ({
762
+ colbert: (_a = doc.colbert) !== null && _a !== void 0 ? _a : [],
763
+ scale: typeof doc.colbert_scale === "number" ? doc.colbert_scale : 1,
764
+ token_ids: Array.isArray(doc.doc_token_ids)
765
+ ? doc.doc_token_ids
766
+ : undefined,
767
+ }); }),
770
768
  colbertDim,
771
769
  }, signal);
772
770
  for (const [idx, doc] of rerankCandidates.entries()) {
@@ -67,7 +67,7 @@ function downloadModels() {
67
67
  const runningTs = path.extname(__filename) === ".ts";
68
68
  const isDev = (runningTs && hasTsWorker) || (hasTsWorker && !hasJsWorker);
69
69
  const workerPath = isDev ? tsWorkerPath : jsWorkerPath;
70
- const execArgv = isDev ? ["-r", "ts-node/register"] : [];
70
+ const execArgv = isDev ? ["--import", require.resolve("tsx")] : [];
71
71
  const worker = new node_worker_threads_1.Worker(workerPath, { execArgv });
72
72
  worker.on("message", (msg) => {
73
73
  if (msg.type === "progress") {
@@ -164,7 +164,8 @@ exports.CONTAINER_TYPES = {
164
164
  * Check if a node type is a container (holds methods).
165
165
  */
166
166
  function isContainerType(langId, nodeType) {
167
- var _a, _b;
167
+ var _a;
168
+ var _b;
168
169
  return (_b = (_a = exports.CONTAINER_TYPES[langId]) === null || _a === void 0 ? void 0 : _a.includes(nodeType)) !== null && _b !== void 0 ? _b : false;
169
170
  }
170
171
  /**