grepmax 0.26.32 → 0.26.33
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/.claude-plugin/marketplace.json +1 -1
- package/dist/commands/context.js +12 -8
- package/dist/commands/doctor.js +7 -9
- package/dist/commands/droid.js +2 -1
- package/dist/commands/extract.js +8 -11
- package/dist/commands/impact.js +5 -8
- package/dist/commands/mcp.js +38 -41
- package/dist/commands/peek.js +6 -9
- package/dist/commands/search-output.js +10 -11
- package/dist/commands/search-run.js +5 -4
- package/dist/commands/search-skeletons.js +2 -1
- package/dist/commands/search.js +5 -4
- package/dist/commands/serve.js +2 -1
- package/dist/commands/similar.js +7 -6
- package/dist/commands/skeleton.js +17 -22
- package/dist/commands/test-find.js +5 -8
- package/dist/config.js +6 -5
- package/dist/eval-oss.js +4 -3
- package/dist/eval-tokens.js +4 -4
- package/dist/eval.js +2 -5
- package/dist/index.js +4 -3
- package/dist/lib/daemon/daemon.js +36 -29
- package/dist/lib/daemon/graph-handler.js +2 -1
- package/dist/lib/daemon/mlx-server-manager.js +10 -9
- package/dist/lib/daemon/rows-handler.js +11 -13
- package/dist/lib/daemon/search-handler.js +6 -5
- package/dist/lib/daemon/vector-handler.js +2 -1
- package/dist/lib/daemon/watcher-manager.js +4 -2
- package/dist/lib/graph/graph-builder.js +4 -10
- package/dist/lib/graph/graph-traversal.js +0 -0
- package/dist/lib/index/batch-processor.js +13 -12
- package/dist/lib/index/chunker.js +22 -23
- package/dist/lib/index/syncer.js +2 -2
- package/dist/lib/llm/investigate.js +5 -4
- package/dist/lib/llm/review.js +2 -1
- package/dist/lib/llm/tools.js +6 -5
- package/dist/lib/output/agent-search-formatter.js +3 -2
- package/dist/lib/output/compact-results.js +16 -12
- package/dist/lib/search/searcher.js +11 -13
- package/dist/lib/setup/model-loader.js +1 -1
- package/dist/lib/skeleton/body-fields.js +2 -1
- package/dist/lib/skeleton/skeletonizer.js +8 -7
- package/dist/lib/store/vector-db.js +6 -5
- package/dist/lib/utils/formatter.js +5 -4
- package/dist/lib/utils/stale-hint.js +4 -3
- package/dist/lib/utils/store-access.js +2 -1
- package/dist/lib/workers/embeddings/granite.js +2 -1
- package/dist/lib/workers/pool.js +14 -10
- package/package.json +2 -3
- package/plugins/grepmax/.claude-plugin/plugin.json +1 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
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 (((
|
|
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
|
|
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)((
|
|
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
|
-
(
|
|
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
|
-
(
|
|
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
|
-
(
|
|
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)((
|
|
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
|
-
(
|
|
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
|
-
(
|
|
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
|
-
|
|
628
|
-
|
|
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
|
|
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
|
|
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 = ((
|
|
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 = ((
|
|
756
|
+
const suffix = ((_m = firstChild.namedChildren) !== null && _m !== void 0 ? _m : []).find((c) => c.type === "navigation_suffix");
|
|
758
757
|
const methodId = suffix
|
|
759
|
-
? ((
|
|
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 = ((
|
|
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
|
-
? ((
|
|
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 = ((
|
|
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 (
|
|
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((
|
|
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((
|
|
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((
|
|
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((
|
|
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((
|
|
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((
|
|
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((
|
|
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 = (
|
|
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") {
|
package/dist/lib/index/syncer.js
CHANGED
|
@@ -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
|
|
705
|
-
yield
|
|
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
|
|
97
|
+
var _a, _b;
|
|
98
|
+
var _c;
|
|
98
99
|
const { question, projectRoot, verbose = false } = opts;
|
|
99
|
-
const maxRounds = (
|
|
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 (!((
|
|
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 (!((
|
|
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);
|
package/dist/lib/llm/review.js
CHANGED
|
@@ -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
|
|
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
|
package/dist/lib/llm/tools.js
CHANGED
|
@@ -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
|
|
184
|
-
|
|
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)((
|
|
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((
|
|
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 = (
|
|
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
|
|
44
|
-
|
|
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
|
|
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, ((
|
|
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: (
|
|
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
|
|
65
|
+
var _a, _b;
|
|
66
|
+
var _c, _d, _e;
|
|
65
67
|
const maxLen = 140;
|
|
66
|
-
const lines = (
|
|
67
|
-
let preview = (
|
|
68
|
-
if (!preview && ((
|
|
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
|
|
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, ((
|
|
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 ((
|
|
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
|
|
238
|
+
var _a;
|
|
239
|
+
var _b, _c;
|
|
236
240
|
const files = new Set();
|
|
237
241
|
for (const r of results) {
|
|
238
|
-
const p = (_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
|
|
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((
|
|
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 = ((
|
|
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
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
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 ? ["
|
|
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
|
|
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
|
/**
|
|
@@ -374,7 +374,8 @@ class Skeletonizer {
|
|
|
374
374
|
const refs = [];
|
|
375
375
|
const seen = new Set();
|
|
376
376
|
const extract = (n) => {
|
|
377
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j
|
|
377
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
378
|
+
var _k, _l, _m, _o;
|
|
378
379
|
if (n.type === "call_expression" ||
|
|
379
380
|
n.type === "call" ||
|
|
380
381
|
n.type === "function_call") {
|
|
@@ -401,13 +402,13 @@ class Skeletonizer {
|
|
|
401
402
|
else {
|
|
402
403
|
// Swift/Kotlin: call_expression has no "function" field;
|
|
403
404
|
// the callable is a positional child
|
|
404
|
-
const firstChild = ((
|
|
405
|
+
const firstChild = ((_k = n.namedChildren) !== null && _k !== void 0 ? _k : [])[0];
|
|
405
406
|
if (firstChild) {
|
|
406
407
|
let funcName = firstChild.text;
|
|
407
408
|
if (firstChild.type === "navigation_expression") {
|
|
408
|
-
const suffix = ((
|
|
409
|
+
const suffix = ((_l = firstChild.namedChildren) !== null && _l !== void 0 ? _l : []).find((c) => c.type === "navigation_suffix");
|
|
409
410
|
const methodId = suffix
|
|
410
|
-
? ((
|
|
411
|
+
? ((_m = suffix.namedChildren) !== null && _m !== void 0 ? _m : []).find((c) => c.type === "simple_identifier")
|
|
411
412
|
: null;
|
|
412
413
|
if (methodId)
|
|
413
414
|
funcName = methodId.text;
|
|
@@ -423,7 +424,7 @@ class Skeletonizer {
|
|
|
423
424
|
n.type === "invocation_expression" // C#
|
|
424
425
|
) {
|
|
425
426
|
// Java/C# method calls
|
|
426
|
-
const nameNode = ((
|
|
427
|
+
const nameNode = ((_d = n.childForFieldName) === null || _d === void 0 ? void 0 : _d.call(n, "name")) || ((_e = n.childForFieldName) === null || _e === void 0 ? void 0 : _e.call(n, "function"));
|
|
427
428
|
if (nameNode) {
|
|
428
429
|
refs.push(nameNode.text);
|
|
429
430
|
seen.add(nameNode.text);
|
|
@@ -433,7 +434,7 @@ class Skeletonizer {
|
|
|
433
434
|
n.type === "command" || // Ruby
|
|
434
435
|
n.type === "command_call" // Ruby
|
|
435
436
|
) {
|
|
436
|
-
const nameNode = ((
|
|
437
|
+
const nameNode = ((_f = n.childForFieldName) === null || _f === void 0 ? void 0 : _f.call(n, "method")) || ((_g = n.childForFieldName) === null || _g === void 0 ? void 0 : _g.call(n, "name"));
|
|
437
438
|
if (nameNode) {
|
|
438
439
|
refs.push(nameNode.text);
|
|
439
440
|
seen.add(nameNode.text);
|
|
@@ -447,7 +448,7 @@ class Skeletonizer {
|
|
|
447
448
|
c.type === "nested_identifier");
|
|
448
449
|
if (nameChild) {
|
|
449
450
|
const name = nameChild.type === "member_expression"
|
|
450
|
-
? ((_o = (
|
|
451
|
+
? ((_o = (_j = (_h = nameChild.childForFieldName) === null || _h === void 0 ? void 0 : _h.call(nameChild, "property")) === null || _j === void 0 ? void 0 : _j.text) !== null && _o !== void 0 ? _o : nameChild.text)
|
|
451
452
|
: nameChild.text;
|
|
452
453
|
if (name && /^[A-Z]/.test(name) && !seen.has(name)) {
|
|
453
454
|
seen.add(name);
|
|
@@ -315,7 +315,8 @@ class VectorDB {
|
|
|
315
315
|
* defer idle shutdown so we don't tear down LanceDB mid-optimize. */
|
|
316
316
|
/** Bytes held by LanceDB's index + metadata caches (0 before first connect). */
|
|
317
317
|
cacheSizeBytes() {
|
|
318
|
-
var _a
|
|
318
|
+
var _a;
|
|
319
|
+
var _b;
|
|
319
320
|
try {
|
|
320
321
|
return Number((_b = (_a = this.session) === null || _a === void 0 ? void 0 : _a.sizeBytes()) !== null && _b !== void 0 ? _b : 0);
|
|
321
322
|
}
|
|
@@ -574,7 +575,7 @@ class VectorDB {
|
|
|
574
575
|
return result;
|
|
575
576
|
}
|
|
576
577
|
finally {
|
|
577
|
-
yield
|
|
578
|
+
yield temporaryExclusiveLease === null || temporaryExclusiveLease === void 0 ? void 0 : temporaryExclusiveLease.release();
|
|
578
579
|
}
|
|
579
580
|
}));
|
|
580
581
|
}
|
|
@@ -850,8 +851,7 @@ class VectorDB {
|
|
|
850
851
|
rec.defined_symbols = (_g = rec.defined_symbols) !== null && _g !== void 0 ? _g : [];
|
|
851
852
|
rec.referenced_symbols = (_h = rec.referenced_symbols) !== null && _h !== void 0 ? _h : [];
|
|
852
853
|
rec.type_referenced_symbols = (_j = rec.type_referenced_symbols) !== null && _j !== void 0 ? _j : [];
|
|
853
|
-
rec.member_referenced_symbols =
|
|
854
|
-
(_k = rec.member_referenced_symbols) !== null && _k !== void 0 ? _k : [];
|
|
854
|
+
rec.member_referenced_symbols = (_k = rec.member_referenced_symbols) !== null && _k !== void 0 ? _k : [];
|
|
855
855
|
rec.imports = (_l = rec.imports) !== null && _l !== void 0 ? _l : [];
|
|
856
856
|
rec.exports = (_m = rec.exports) !== null && _m !== void 0 ? _m : [];
|
|
857
857
|
rec.role = (_o = rec.role) !== null && _o !== void 0 ? _o : "";
|
|
@@ -936,7 +936,8 @@ class VectorDB {
|
|
|
936
936
|
}
|
|
937
937
|
createVectorIndexUnsafe(rebuild, retries, checkOnly) {
|
|
938
938
|
return __awaiter(this, void 0, void 0, function* () {
|
|
939
|
-
var _a
|
|
939
|
+
var _a;
|
|
940
|
+
var _b;
|
|
940
941
|
const table = yield this.ensureTableUnsafe();
|
|
941
942
|
const rowCount = yield table.countRows();
|
|
942
943
|
if (rowCount < (0, ann_config_1.annMinRows)())
|