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
@@ -64,14 +64,15 @@ exports.similar = new commander_1.Command("similar")
64
64
  .option("--exclude <subpath>", "Exclude a sub-path of the project (repeatable)", (value, prev) => prev ? [...prev, value] : [value])
65
65
  .option("--agent", "Compact output for AI agents", false)
66
66
  .action((target, opts) => __awaiter(void 0, void 0, void 0, function* () {
67
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
67
+ var _a, _b;
68
+ var _c, _d, _e, _f, _g, _h, _j;
68
69
  const limit = Math.min(Math.max(Number.parseInt(opts.maxCount || "5", 10), 1), 25);
69
70
  const threshold = Number.parseFloat(opts.threshold || "0") || 0;
70
71
  try {
71
72
  const root = (0, project_registry_1.resolveRootOrExit)(opts.root);
72
73
  if (root === null)
73
74
  return;
74
- const projectRoot = (_a = (0, project_root_1.findProjectRoot)(root)) !== null && _a !== void 0 ? _a : root;
75
+ const projectRoot = (_c = (0, project_root_1.findProjectRoot)(root)) !== null && _c !== void 0 ? _c : root;
75
76
  (0, stale_hint_1.maybeWarnStaleChunker)(projectRoot, { agent: opts.agent });
76
77
  (0, stale_hint_1.maybeWarnStaleEmbedding)(projectRoot, { agent: opts.agent });
77
78
  const paths = (0, project_root_1.ensureProjectPaths)(projectRoot);
@@ -133,17 +134,17 @@ exports.similar = new commander_1.Command("similar")
133
134
  const rel = (p) => p.startsWith(`${projectRoot}/`) ? p.slice(projectRoot.length + 1) : p;
134
135
  if (opts.agent) {
135
136
  for (const r of filtered.slice(0, limit)) {
136
- const sym = (_c = (_b = r.defined_symbols) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : "";
137
- const line = ((_d = r.start_line) !== null && _d !== void 0 ? _d : 0) + 1;
137
+ const sym = (_d = (_a = r.defined_symbols) === null || _a === void 0 ? void 0 : _a[0]) !== null && _d !== void 0 ? _d : "";
138
+ const line = ((_e = r.start_line) !== null && _e !== void 0 ? _e : 0) + 1;
138
139
  const role = (r.role || "IMPL").slice(0, 4);
139
- const dist = ((_e = r._distance) !== null && _e !== void 0 ? _e : 0).toFixed(3);
140
+ const dist = ((_f = r._distance) !== null && _f !== void 0 ? _f : 0).toFixed(3);
140
141
  console.log(`${rel(r.path)}:${line}\t${sym}\t[${role}]\td=${dist}`);
141
142
  }
142
143
  }
143
144
  else {
144
145
  console.log(`Code similar to ${target}:\n`);
145
146
  for (const r of filtered.slice(0, limit)) {
146
- const sym = (_g = (_f = r.defined_symbols) === null || _f === void 0 ? void 0 : _f[0]) !== null && _g !== void 0 ? _g : "";
147
+ const sym = (_g = (_b = r.defined_symbols) === null || _b === void 0 ? void 0 : _b[0]) !== null && _g !== void 0 ? _g : "";
147
148
  const line = ((_h = r.start_line) !== null && _h !== void 0 ? _h : 0) + 1;
148
149
  const role = r.role || "IMPLEMENTATION";
149
150
  const dist = ((_j = r._distance) !== null && _j !== void 0 ? _j : 0).toFixed(3);
@@ -94,15 +94,12 @@ function syncIndex(projectRoot, lancedbDir) {
94
94
  daemon: () => __awaiter(this, void 0, void 0, function* () {
95
95
  var _a;
96
96
  try {
97
- const done = yield (0, daemon_client_1.sendStreamingCommand)({ cmd: "ensure-project", root: projectRoot }, (msg) => {
98
- var _a, _b, _c;
99
- return onProgress({
100
- processed: Number((_a = msg.processed) !== null && _a !== void 0 ? _a : 0),
101
- total: Number((_b = msg.total) !== null && _b !== void 0 ? _b : 0),
102
- indexed: Number((_c = msg.indexed) !== null && _c !== void 0 ? _c : 0),
103
- filePath: typeof msg.filePath === "string" ? msg.filePath : "",
104
- });
105
- });
97
+ const done = yield (0, daemon_client_1.sendStreamingCommand)({ cmd: "ensure-project", root: projectRoot }, (msg) => { var _a, _b, _c; return onProgress({
98
+ processed: Number((_a = msg.processed) !== null && _a !== void 0 ? _a : 0),
99
+ total: Number((_b = msg.total) !== null && _b !== void 0 ? _b : 0),
100
+ indexed: Number((_c = msg.indexed) !== null && _c !== void 0 ? _c : 0),
101
+ filePath: typeof msg.filePath === "string" ? msg.filePath : "",
102
+ }); });
106
103
  return Object.assign(Object.assign({}, done), { ok: done.ok !== false });
107
104
  }
108
105
  catch (err) {
@@ -156,13 +153,10 @@ function lookupSkeleton(projectRoot, lancedbDir, req) {
156
153
  path: req.path,
157
154
  symbol: req.symbol,
158
155
  }, { timeoutMs: 30000 }),
159
- render: (resp) => {
160
- var _a, _b;
161
- return ({
162
- path: ((_a = resp.path) !== null && _a !== void 0 ? _a : null),
163
- skeleton: ((_b = resp.skeleton) !== null && _b !== void 0 ? _b : null),
164
- });
165
- },
156
+ render: (resp) => { var _a, _b; return ({
157
+ path: ((_a = resp.path) !== null && _a !== void 0 ? _a : null),
158
+ skeleton: ((_b = resp.skeleton) !== null && _b !== void 0 ? _b : null),
159
+ }); },
166
160
  inProcess: () => (0, rows_handler_1.withLocalStore)(lancedbDir, (deps) => (0, rows_handler_1.runSkeleton)(deps, Object.assign({ projectRoot }, req))),
167
161
  fallbackOnUnknownVerb: true,
168
162
  });
@@ -208,11 +202,12 @@ Examples:
208
202
  gmax skeleton "auth logic" Search, skeletonize top matches
209
203
  `)
210
204
  .action((target, options, _cmd) => __awaiter(void 0, void 0, void 0, function* () {
211
- var _a, _b, _c, _d, _e;
205
+ var _a;
206
+ var _b, _c, _d, _e;
212
207
  try {
213
208
  // Initialize
214
209
  yield (0, setup_helpers_1.ensureSetup)();
215
- const projectRoot = (_a = (0, project_root_1.findProjectRoot)(process.cwd())) !== null && _a !== void 0 ? _a : process.cwd();
210
+ const projectRoot = (_b = (0, project_root_1.findProjectRoot)(process.cwd())) !== null && _b !== void 0 ? _b : process.cwd();
216
211
  const paths = (0, project_root_1.ensureProjectPaths)(projectRoot);
217
212
  const lancedbDir = paths.lancedbDir;
218
213
  // Sync if requested
@@ -228,7 +223,7 @@ Examples:
228
223
  // Determine mode based on target. Prefer an existing cwd-relative
229
224
  // match so callers inside a subdirectory (or nested subrepo) can pass
230
225
  // paths relative to where they are.
231
- const resolvedTarget = (_b = (0, path_containment_1.resolveContainedExistingPath)(projectRoot, target)) !== null && _b !== void 0 ? _b : (0, path_containment_1.resolveContainedPath)(projectRoot, target, {
226
+ const resolvedTarget = (_c = (0, path_containment_1.resolveContainedExistingPath)(projectRoot, target)) !== null && _c !== void 0 ? _c : (0, path_containment_1.resolveContainedPath)(projectRoot, target, {
232
227
  verifyExistingTarget: true,
233
228
  });
234
229
  // Directory mode is unsupported. Auto-picking files from a directory
@@ -252,7 +247,7 @@ Examples:
252
247
  .map((t) => t.trim())
253
248
  .filter(Boolean);
254
249
  for (const t of targets) {
255
- const filePath = (_c = (0, path_containment_1.resolveContainedExistingPath)(projectRoot, t)) !== null && _c !== void 0 ? _c : (0, path_containment_1.resolveContainedPath)(projectRoot, t, {
250
+ const filePath = (_d = (0, path_containment_1.resolveContainedExistingPath)(projectRoot, t)) !== null && _d !== void 0 ? _d : (0, path_containment_1.resolveContainedPath)(projectRoot, t, {
256
251
  verifyExistingTarget: true,
257
252
  });
258
253
  if (!fs.existsSync(filePath)) {
@@ -267,7 +262,7 @@ Examples:
267
262
  }
268
263
  if (isFilePath(target)) {
269
264
  // === FILE MODE ===
270
- const filePath = (_d = (0, path_containment_1.resolveContainedExistingPath)(projectRoot, target)) !== null && _d !== void 0 ? _d : (0, path_containment_1.resolveContainedPath)(projectRoot, target, {
265
+ const filePath = (_e = (0, path_containment_1.resolveContainedExistingPath)(projectRoot, target)) !== null && _e !== void 0 ? _e : (0, path_containment_1.resolveContainedPath)(projectRoot, target, {
271
266
  verifyExistingTarget: true,
272
267
  });
273
268
  if (!fs.existsSync(filePath)) {
@@ -335,7 +330,7 @@ Examples:
335
330
  const seenPaths = new Set();
336
331
  const filePaths = [];
337
332
  for (const result of searchData) {
338
- const resultPath = (_e = result.metadata) === null || _e === void 0 ? void 0 : _e.path;
333
+ const resultPath = (_a = result.metadata) === null || _a === void 0 ? void 0 : _a.path;
339
334
  if (resultPath && !seenPaths.has(resultPath)) {
340
335
  seenPaths.add(resultPath);
341
336
  filePaths.push(resultPath);
@@ -87,14 +87,11 @@ exports.testFind = new commander_1.Command("test")
87
87
  projectRoot,
88
88
  scope,
89
89
  payload: { target },
90
- render: (resp) => {
91
- var _a, _b;
92
- return ({
93
- symbols: (_a = resp.symbols) !== null && _a !== void 0 ? _a : [],
94
- resolvedAsFile: resp.resolvedAsFile === true,
95
- symbolFamilies: (_b = resp.symbolFamilies) !== null && _b !== void 0 ? _b : null,
96
- });
97
- },
90
+ render: (resp) => { var _a, _b; return ({
91
+ symbols: (_a = resp.symbols) !== null && _a !== void 0 ? _a : [],
92
+ resolvedAsFile: resp.resolvedAsFile === true,
93
+ symbolFamilies: (_b = resp.symbolFamilies) !== null && _b !== void 0 ? _b : null,
94
+ }); },
98
95
  inProcess: () => (0, graph_handler_1.runGraphResolve)(localDb(), { target, projectRoot }),
99
96
  });
100
97
  if (symbols.length === 0) {
@@ -72,6 +72,15 @@ exports.watch = new commander_1.Command("watch")
72
72
  .option("--no-idle-timeout", "Disable the 30-minute idle shutdown")
73
73
  .action((options) => __awaiter(void 0, void 0, void 0, function* () {
74
74
  var _a, _b;
75
+ // A secondary store (src/bin.ts) never runs a daemon or a watcher: one
76
+ // would hold the external drive open, and its startup sweep of stale
77
+ // daemons judges liveness by its own home's lock and socket, so it takes
78
+ // the primary daemon for dead and shuts it down (seen 2026-09-22).
79
+ if (process.env.GMAX_SECONDARY_STORE === "1") {
80
+ console.error("gmax: this project's index lives on an external drive and runs in-process; it is never watched. Run `gmax index` after changing it.");
81
+ process.exitCode = 2;
82
+ return;
83
+ }
75
84
  // --- Daemon mode ---
76
85
  if (options.daemon) {
77
86
  if (options.path) {
package/dist/config.js CHANGED
@@ -151,11 +151,12 @@ function describeChunkerGap(indexedVersion) {
151
151
  * from the global config) so this module stays free of config I/O.
152
152
  */
153
153
  function describeEmbeddingGap(stored, current) {
154
- var _a, _b, _c, _d, _e, _f, _g, _h;
155
- const fromModel = (_a = stored.modelTier) !== null && _a !== void 0 ? _a : exports.DEFAULT_MODEL_TIER;
156
- const toModel = (_b = current.modelTier) !== null && _b !== void 0 ? _b : exports.DEFAULT_MODEL_TIER;
157
- const fromDim = (_e = (_c = stored.vectorDim) !== null && _c !== void 0 ? _c : (_d = exports.MODEL_TIERS[fromModel]) === null || _d === void 0 ? void 0 : _d.vectorDim) !== null && _e !== void 0 ? _e : exports.CONFIG.VECTOR_DIM;
158
- const toDim = (_h = (_f = current.vectorDim) !== null && _f !== void 0 ? _f : (_g = exports.MODEL_TIERS[toModel]) === null || _g === void 0 ? void 0 : _g.vectorDim) !== null && _h !== void 0 ? _h : exports.CONFIG.VECTOR_DIM;
154
+ var _a, _b;
155
+ var _c, _d, _e, _f, _g, _h;
156
+ const fromModel = (_c = stored.modelTier) !== null && _c !== void 0 ? _c : exports.DEFAULT_MODEL_TIER;
157
+ const toModel = (_d = current.modelTier) !== null && _d !== void 0 ? _d : exports.DEFAULT_MODEL_TIER;
158
+ const fromDim = (_f = (_e = stored.vectorDim) !== null && _e !== void 0 ? _e : (_a = exports.MODEL_TIERS[fromModel]) === null || _a === void 0 ? void 0 : _a.vectorDim) !== null && _f !== void 0 ? _f : exports.CONFIG.VECTOR_DIM;
159
+ const toDim = (_h = (_g = current.vectorDim) !== null && _g !== void 0 ? _g : (_b = exports.MODEL_TIERS[toModel]) === null || _b === void 0 ? void 0 : _b.vectorDim) !== null && _h !== void 0 ? _h : exports.CONFIG.VECTOR_DIM;
159
160
  const dimChanged = fromDim !== toDim;
160
161
  const modelChanged = fromModel !== toModel;
161
162
  if (!dimChanged && !modelChanged)
@@ -217,14 +218,23 @@ exports.MAX_WORKER_MEMORY_MB = (() => {
217
218
  return Math.min(HARD_CEILING, Math.max(2048, Math.floor((os.totalmem() / 1024 / 1024) * 0.5)));
218
219
  })();
219
220
  const HOME = os.homedir();
220
- const GLOBAL_ROOT = path.join(HOME, ".gmax");
221
+ // Models, grammars and the pinned HF cache are shared by every store and always
222
+ // live on the internal disk. GMAX_HOME moves only the data root: a secondary
223
+ // store on an external drive (see src/lib/utils/stores.ts) sets it before this
224
+ // module loads, so a project's index can live on the drive with its files.
225
+ const SHARED_ROOT = path.join(HOME, ".gmax");
226
+ const GLOBAL_ROOT = process.env.GMAX_HOME
227
+ ? path.resolve(process.env.GMAX_HOME)
228
+ : SHARED_ROOT;
221
229
  exports.PATHS = {
222
230
  globalRoot: GLOBAL_ROOT,
223
- models: path.join(GLOBAL_ROOT, "models"),
224
- grammars: path.join(GLOBAL_ROOT, "grammars"),
231
+ sharedRoot: SHARED_ROOT,
232
+ storesFile: path.join(SHARED_ROOT, "stores.json"),
233
+ models: path.join(SHARED_ROOT, "models"),
234
+ grammars: path.join(SHARED_ROOT, "grammars"),
225
235
  // HF cache for the MLX embed server, pinned to internal disk so the server
226
236
  // survives an unmounted external volume behind the user's HF_HOME.
227
- hfDir: path.join(GLOBAL_ROOT, "hf"),
237
+ hfDir: path.join(SHARED_ROOT, "hf"),
228
238
  logsDir: path.join(GLOBAL_ROOT, "logs"),
229
239
  daemonSocket: path.join(GLOBAL_ROOT, "daemon.sock"),
230
240
  daemonPidFile: path.join(GLOBAL_ROOT, "daemon.pid"),
package/dist/eval-oss.js CHANGED
@@ -321,7 +321,8 @@ const DATASETS = {
321
321
  // lodash `merge`) whose answer chunk legitimately doesn't carry the symbol in
322
322
  // `defined_symbols`. end_line falls back to start_line + 200 when missing.
323
323
  function chunkMatches(chunk, expectedFile, expectedLine, expectedSymbol) {
324
- var _a, _b, _c, _d, _e, _f;
324
+ var _a, _b, _c;
325
+ var _d, _e, _f;
325
326
  const path = String(((_a = chunk.metadata) === null || _a === void 0 ? void 0 : _a.path) || "").toLowerCase();
326
327
  if (!path.endsWith(`/${expectedFile.toLowerCase()}`) &&
327
328
  !path.endsWith(expectedFile.toLowerCase())) {
@@ -334,8 +335,8 @@ function chunkMatches(chunk, expectedFile, expectedLine, expectedSymbol) {
334
335
  return true;
335
336
  }
336
337
  // (a) line-range match — chunks are 0-indexed start_line; expected line is 1-indexed
337
- const start = Number((_d = (_c = (_b = chunk.generated_metadata) === null || _b === void 0 ? void 0 : _b.start_line) !== null && _c !== void 0 ? _c : chunk.start_line) !== null && _d !== void 0 ? _d : 0);
338
- const numLines = Number((_f = (_e = chunk.generated_metadata) === null || _e === void 0 ? void 0 : _e.num_lines) !== null && _f !== void 0 ? _f : 0);
338
+ const start = Number((_e = (_d = (_b = chunk.generated_metadata) === null || _b === void 0 ? void 0 : _b.start_line) !== null && _d !== void 0 ? _d : chunk.start_line) !== null && _e !== void 0 ? _e : 0);
339
+ const numLines = Number((_f = (_c = chunk.generated_metadata) === null || _c === void 0 ? void 0 : _c.num_lines) !== null && _f !== void 0 ? _f : 0);
339
340
  const end = numLines > 0 ? start + numLines : start + 200;
340
341
  return expectedLine - 1 >= start && expectedLine - 1 <= end;
341
342
  }
@@ -85,9 +85,10 @@ function aggregate(ratios) {
85
85
  }
86
86
  function run() {
87
87
  return __awaiter(this, void 0, void 0, function* () {
88
- var _a, _b, _c;
88
+ var _a;
89
+ var _b, _c;
89
90
  const root = process.cwd();
90
- const projectRoot = (_a = (0, project_root_1.findProjectRoot)(root)) !== null && _a !== void 0 ? _a : root;
91
+ const projectRoot = (_b = (0, project_root_1.findProjectRoot)(root)) !== null && _b !== void 0 ? _b : root;
91
92
  const paths = (0, project_root_1.ensureProjectPaths)(projectRoot);
92
93
  const vectorDb = new vector_db_1.VectorDB(paths.lancedbDir);
93
94
  const searcher = new searcher_1.Searcher(vectorDb);
@@ -140,8 +141,7 @@ function run() {
140
141
  try {
141
142
  const lines = (0, node_fs_1.readFileSync)(absPath, "utf8").split("\n");
142
143
  symbolTokens = estTokens(lines.slice(start, end + 1).join("\n"));
143
- symbolLabel =
144
- (_c = (_b = top.defined_symbols) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : "";
144
+ symbolLabel = (_c = (_a = top.defined_symbols) === null || _a === void 0 ? void 0 : _a[0]) !== null && _c !== void 0 ? _c : "";
145
145
  }
146
146
  catch (_e) {
147
147
  // Top-hit file unreadable — symbol cost stays 0 (pointer-only).
package/dist/eval.js CHANGED
@@ -435,7 +435,7 @@ exports.cases = [
435
435
  {
436
436
  query: "Where do we download models via a worker thread to avoid ONNX in main thread?",
437
437
  expectedPath: "src/lib/setup/model-loader.ts",
438
- note: "downloadModels spawns worker with ts-node/register when dev.",
438
+ note: "downloadModels spawns worker with the tsx loader when dev.",
439
439
  },
440
440
  {
441
441
  query: "Where do we check areModelsDownloaded before running setup?",
@@ -524,10 +524,7 @@ function evaluateCase(response, evalCase, timeMs) {
524
524
  const path = ((_b = (_a = chunk.metadata) === null || _a === void 0 ? void 0 : _a.path) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || "";
525
525
  return expectedPaths.some((expected) => path.includes(expected));
526
526
  });
527
- const avoidRank = response.data.findIndex((chunk) => {
528
- var _a, _b, _c;
529
- return (_b = (_a = chunk.metadata) === null || _a === void 0 ? void 0 : _a.path) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(((_c = evalCase.avoidPath) === null || _c === void 0 ? void 0 : _c.toLowerCase()) || "_____");
530
- });
527
+ const avoidRank = response.data.findIndex((chunk) => { var _a, _b, _c; return (_b = (_a = chunk.metadata) === null || _a === void 0 ? void 0 : _a.path) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(((_c = evalCase.avoidPath) === null || _c === void 0 ? void 0 : _c.toLowerCase()) || "_____"); });
531
528
  const hitAvoid = evalCase.avoidPath && avoidRank >= 0 && (rank === -1 || avoidRank < rank);
532
529
  const found = rank >= 0 && !hitAvoid;
533
530
  const rr = found ? 1 / (rank + 1) : 0;
package/dist/index.js CHANGED
@@ -96,9 +96,10 @@ if (legacyProjectData) {
96
96
  }
97
97
  // Wire global --store to per-command --root so cross-project queries work
98
98
  commander_1.program.hook("preAction", (_thisCommand, actionCommand) => {
99
- var _a, _b, _c;
100
- const globals = (_b = (_a = actionCommand.optsWithGlobals) === null || _a === void 0 ? void 0 : _a.call(actionCommand)) !== null && _b !== void 0 ? _b : {};
101
- if (globals.store && !((_c = actionCommand.getOptionValue) === null || _c === void 0 ? void 0 : _c.call(actionCommand, "root"))) {
99
+ var _a, _b;
100
+ var _c;
101
+ const globals = (_c = (_a = actionCommand.optsWithGlobals) === null || _a === void 0 ? void 0 : _a.call(actionCommand)) !== null && _c !== void 0 ? _c : {};
102
+ if (globals.store && !((_b = actionCommand.getOptionValue) === null || _b === void 0 ? void 0 : _b.call(actionCommand, "root"))) {
102
103
  try {
103
104
  actionCommand.setOptionValue("root", globals.store);
104
105
  }
@@ -620,7 +620,8 @@ class Daemon {
620
620
  return this.operations.status;
621
621
  }
622
622
  resourceGenerationId() {
623
- var _a, _b;
623
+ var _a;
624
+ var _b;
624
625
  return (_b = (_a = this.resources) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null;
625
626
  }
626
627
  hasUnfinishedRebuild() {
@@ -661,7 +662,8 @@ class Daemon {
661
662
  try {
662
663
  yield this.withProjectLock(root, ac.signal, () => __awaiter(this, void 0, void 0, function* () {
663
664
  return this.runSharedOperation("index-pending", ac.signal, (operationSignal) => __awaiter(this, void 0, void 0, function* () {
664
- var _a, _b, _c, _d;
665
+ var _a, _b;
666
+ var _c, _d;
665
667
  // Bail if shutdown raced ahead of us between iteration and lock
666
668
  // acquisition. Starting now would race the store close below.
667
669
  if (this.shuttingDown)
@@ -683,9 +685,9 @@ class Daemon {
683
685
  vectorDb: this.vectorDb,
684
686
  metaCache: this.metaCache,
685
687
  signal: operationSignal,
686
- generation: (_a = this.activeGeneration) !== null && _a !== void 0 ? _a : undefined,
687
- embedMode: (_b = this.activeConfig) === null || _b === void 0 ? void 0 : _b.embedMode,
688
- workerPool: (_c = this.workerPool) !== null && _c !== void 0 ? _c : undefined,
688
+ generation: (_c = this.activeGeneration) !== null && _c !== void 0 ? _c : undefined,
689
+ embedMode: (_a = this.activeConfig) === null || _a === void 0 ? void 0 : _a.embedMode,
690
+ workerPool: (_d = this.workerPool) !== null && _d !== void 0 ? _d : undefined,
689
691
  onProgress: () => {
690
692
  this.resetActivity();
691
693
  },
@@ -724,7 +726,7 @@ class Daemon {
724
726
  }
725
727
  }
726
728
  finally {
727
- (_d = this.vectorDb) === null || _d === void 0 ? void 0 : _d.resumeMaintenanceLoop();
729
+ (_b = this.vectorDb) === null || _b === void 0 ? void 0 : _b.resumeMaintenanceLoop();
728
730
  if (!this.shuttingDown) {
729
731
  try {
730
732
  yield this.watchProjectWithinOperation(root);
@@ -765,12 +767,13 @@ class Daemon {
765
767
  * on every search to annotate partial-result responses (Phase 6).
766
768
  */
767
769
  indexState(root) {
768
- var _a, _b, _c, _d;
770
+ var _a;
771
+ var _b, _c, _d;
769
772
  const processor = this.processors.get(root);
770
- const batchPending = (_a = processor === null || processor === void 0 ? void 0 : processor.progress.pendingFiles) !== null && _a !== void 0 ? _a : 0;
771
- const processing = (_b = processor === null || processor === void 0 ? void 0 : processor.progress.processing) !== null && _b !== void 0 ? _b : false;
773
+ const batchPending = (_b = processor === null || processor === void 0 ? void 0 : processor.progress.pendingFiles) !== null && _b !== void 0 ? _b : 0;
774
+ const processing = (_c = processor === null || processor === void 0 ? void 0 : processor.progress.processing) !== null && _c !== void 0 ? _c : false;
772
775
  // status === "pending" means the initial full index hasn't completed.
773
- const initialPending = ((_c = (0, project_registry_1.getProject)(root)) === null || _c === void 0 ? void 0 : _c.status) === "pending";
776
+ const initialPending = ((_a = (0, project_registry_1.getProject)(root)) === null || _a === void 0 ? void 0 : _a.status) === "pending";
774
777
  // A full index (--reset / initial) bypasses the batch processor; its
775
778
  // onProgress feeds indexProgress, giving a real remaining count.
776
779
  const fullIdx = this.indexProgress.get(root);
@@ -846,7 +849,8 @@ class Daemon {
846
849
  return this.ready;
847
850
  }
848
851
  getDiskPressure() {
849
- var _a, _b;
852
+ var _a;
853
+ var _b;
850
854
  return (_b = (_a = this.vectorDb) === null || _a === void 0 ? void 0 : _a.diskPressure) !== null && _b !== void 0 ? _b : "unknown";
851
855
  }
852
856
  getMlxStatus() {
@@ -967,7 +971,8 @@ class Daemon {
967
971
  }
968
972
  addProjectLocked(root, conn, signal, previousProject) {
969
973
  return __awaiter(this, void 0, void 0, function* () {
970
- var _a, _b, _c, _d;
974
+ var _a;
975
+ var _b, _c, _d;
971
976
  if (!this.vectorDb || !this.metaCache || !this.activeConfig) {
972
977
  (0, ipc_handler_1.writeDone)(conn, { ok: false, error: "daemon resources not ready" });
973
978
  return;
@@ -996,9 +1001,9 @@ class Daemon {
996
1001
  vectorDb: this.vectorDb,
997
1002
  metaCache: this.metaCache,
998
1003
  signal,
999
- generation: (_a = this.activeGeneration) !== null && _a !== void 0 ? _a : undefined,
1004
+ generation: (_b = this.activeGeneration) !== null && _b !== void 0 ? _b : undefined,
1000
1005
  embedMode: this.activeConfig.embedMode,
1001
- workerPool: (_b = this.workerPool) !== null && _b !== void 0 ? _b : undefined,
1006
+ workerPool: (_c = this.workerPool) !== null && _c !== void 0 ? _c : undefined,
1002
1007
  onProgress: (info) => {
1003
1008
  this.resetActivity();
1004
1009
  const now = Date.now();
@@ -1030,7 +1035,7 @@ class Daemon {
1030
1035
  this.clearPendingIndexRetry(root);
1031
1036
  (0, project_registry_1.stampProjectFullSync)({
1032
1037
  root,
1033
- name: (_c = project === null || project === void 0 ? void 0 : project.name) !== null && _c !== void 0 ? _c : path.basename(root),
1038
+ name: (_d = project === null || project === void 0 ? void 0 : project.name) !== null && _d !== void 0 ? _d : path.basename(root),
1034
1039
  generation: result.generation,
1035
1040
  embedMode: result.embedMode,
1036
1041
  chunkCount,
@@ -1069,7 +1074,7 @@ class Daemon {
1069
1074
  }
1070
1075
  finally {
1071
1076
  stopHeartbeat();
1072
- (_d = this.vectorDb) === null || _d === void 0 ? void 0 : _d.resumeMaintenanceLoop();
1077
+ (_a = this.vectorDb) === null || _a === void 0 ? void 0 : _a.resumeMaintenanceLoop();
1073
1078
  }
1074
1079
  });
1075
1080
  }
@@ -1115,7 +1120,8 @@ class Daemon {
1115
1120
  */
1116
1121
  reindexOneProject(root, opts, signal, onProgress) {
1117
1122
  return __awaiter(this, void 0, void 0, function* () {
1118
- var _a, _b, _c;
1123
+ var _a;
1124
+ var _b, _c;
1119
1125
  if (!this.vectorDb || !this.metaCache) {
1120
1126
  throw new Error("daemon resources not ready");
1121
1127
  }
@@ -1133,8 +1139,8 @@ class Daemon {
1133
1139
  vectorDb: this.vectorDb,
1134
1140
  metaCache: this.metaCache,
1135
1141
  signal,
1136
- generation: (_a = this.activeGeneration) !== null && _a !== void 0 ? _a : undefined,
1137
- embedMode: (_b = this.activeConfig) === null || _b === void 0 ? void 0 : _b.embedMode,
1142
+ generation: (_b = this.activeGeneration) !== null && _b !== void 0 ? _b : undefined,
1143
+ embedMode: (_a = this.activeConfig) === null || _a === void 0 ? void 0 : _a.embedMode,
1138
1144
  workerPool: (_c = this.workerPool) !== null && _c !== void 0 ? _c : undefined,
1139
1145
  onProgress: (info) => {
1140
1146
  this.resetActivity();
@@ -1168,7 +1174,8 @@ class Daemon {
1168
1174
  this.shutdownAbortControllers.add(ac);
1169
1175
  try {
1170
1176
  yield this.withProjectLock(root, ac.signal, () => this.runSharedOperation("index-project", ac.signal, (operationSignal) => __awaiter(this, void 0, void 0, function* () {
1171
- var _a, _b;
1177
+ var _a;
1178
+ var _b;
1172
1179
  if (!this.vectorDb || !this.metaCache) {
1173
1180
  (0, ipc_handler_1.writeDone)(conn, {
1174
1181
  ok: false,
@@ -1203,7 +1210,7 @@ class Daemon {
1203
1210
  chunkCount,
1204
1211
  chunkerVersion: opts.reset
1205
1212
  ? config_1.CONFIG.CHUNKER_VERSION
1206
- : ((_a = project === null || project === void 0 ? void 0 : project.chunkerVersion) !== null && _a !== void 0 ? _a : 1),
1213
+ : ((_b = project === null || project === void 0 ? void 0 : project.chunkerVersion) !== null && _b !== void 0 ? _b : 1),
1207
1214
  expectedFingerprint: result.registryExpectation.embeddingFingerprint,
1208
1215
  expectedRebuildId: result.registryExpectation.rebuildId,
1209
1216
  });
@@ -1226,7 +1233,7 @@ class Daemon {
1226
1233
  }
1227
1234
  finally {
1228
1235
  stopHeartbeat();
1229
- (_b = this.vectorDb) === null || _b === void 0 ? void 0 : _b.resumeMaintenanceLoop();
1236
+ (_a = this.vectorDb) === null || _a === void 0 ? void 0 : _a.resumeMaintenanceLoop();
1230
1237
  }
1231
1238
  })));
1232
1239
  }
@@ -1466,9 +1473,9 @@ class Daemon {
1466
1473
  this.ready = false;
1467
1474
  this.resources = null;
1468
1475
  let recoveryError;
1469
- yield (targetPool === null || targetPool === void 0 ? void 0 : targetPool.destroy({ requireExit: true }).catch((cause) => {
1476
+ yield targetPool === null || targetPool === void 0 ? void 0 : targetPool.destroy({ requireExit: true }).catch((cause) => {
1470
1477
  recoveryError !== null && recoveryError !== void 0 ? recoveryError : (recoveryError = cause);
1471
- }));
1478
+ });
1472
1479
  if (targetDb) {
1473
1480
  yield targetDb
1474
1481
  .close({ releaseLease: false, requireClosed: true })
@@ -1516,7 +1523,7 @@ class Daemon {
1516
1523
  }
1517
1524
  catch (cause) {
1518
1525
  recoveryError = cause;
1519
- yield (restoredPool === null || restoredPool === void 0 ? void 0 : restoredPool.destroy({ requireExit: true }).catch(() => { }));
1526
+ yield restoredPool === null || restoredPool === void 0 ? void 0 : restoredPool.destroy({ requireExit: true }).catch(() => { });
1520
1527
  if (restoredDb) {
1521
1528
  yield restoredDb.close().catch(() => { });
1522
1529
  }
@@ -2018,7 +2025,7 @@ class Daemon {
2018
2025
  yield this.drainOperationsBounded(operationDrain, projectDrain);
2019
2026
  // Stop LLM server if running
2020
2027
  try {
2021
- yield ((_b = this.llmServer) === null || _b === void 0 ? void 0 : _b.stop());
2028
+ yield (_b = this.llmServer) === null || _b === void 0 ? void 0 : _b.stop();
2022
2029
  }
2023
2030
  catch (_j) { }
2024
2031
  // Destroy worker pool to prevent orphaned child processes
@@ -2053,15 +2060,15 @@ class Daemon {
2053
2060
  this.processors.clear();
2054
2061
  // Close shared resources
2055
2062
  try {
2056
- yield ((_c = this.metaCache) === null || _c === void 0 ? void 0 : _c.close());
2063
+ yield (_c = this.metaCache) === null || _c === void 0 ? void 0 : _c.close();
2057
2064
  }
2058
2065
  catch (_m) { }
2059
2066
  if (strictResourceShutdown) {
2060
- yield ((_d = this.vectorDb) === null || _d === void 0 ? void 0 : _d.close({ requireClosed: true }));
2067
+ yield (_d = this.vectorDb) === null || _d === void 0 ? void 0 : _d.close({ requireClosed: true });
2061
2068
  }
2062
2069
  else {
2063
2070
  try {
2064
- yield ((_e = this.vectorDb) === null || _e === void 0 ? void 0 : _e.close());
2071
+ yield (_e = this.vectorDb) === null || _e === void 0 ? void 0 : _e.close();
2065
2072
  }
2066
2073
  catch (_o) { }
2067
2074
  }
@@ -536,7 +536,8 @@ function findFileCycles(deps, prefix, top) {
536
536
  * `top` caps each list; `deadTotal` reports the full pre-cap dead count.
537
537
  */
538
538
  function computeAudit(rows, prefix, top) {
539
- var _a, _b;
539
+ var _a;
540
+ var _b;
540
541
  // First definition of a symbol wins (matches GraphBuilder semantics).
541
542
  const defs = new Map();
542
543
  // Distinct files defining each name — name-based edges can't tell same-name
@@ -72,7 +72,8 @@ class MlxServerManager {
72
72
  return !this.enabled || this.deps.getShuttingDown();
73
73
  }
74
74
  sleep(ms) {
75
- var _a, _b, _c;
75
+ var _a, _b;
76
+ var _c;
76
77
  return ((_c = (_b = (_a = this.deps).sleep) === null || _b === void 0 ? void 0 : _b.call(_a, ms)) !== null && _c !== void 0 ? _c : new Promise((resolve) => setTimeout(resolve, ms)));
77
78
  }
78
79
  probeHealth(port) {
@@ -202,7 +203,8 @@ class MlxServerManager {
202
203
  }
203
204
  ensureInternal(model) {
204
205
  return __awaiter(this, void 0, void 0, function* () {
205
- var _a, _b, _c, _d, _e, _f, _g, _h;
206
+ var _a, _b, _c;
207
+ var _d, _e, _f, _g, _h;
206
208
  this.phase = "probing";
207
209
  const health = yield this.probeHealth(this.port);
208
210
  if (this.shouldStop())
@@ -254,15 +256,15 @@ class MlxServerManager {
254
256
  console.warn("[daemon] MLX embed server not found — falling back to CPU embeddings");
255
257
  return;
256
258
  }
257
- const owner = (_c = (_b = (_a = this.deps).createOwnerToken) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : (0, node_crypto_1.randomUUID)();
258
- const openLog = (_d = this.deps.openLog) !== null && _d !== void 0 ? _d : log_rotate_1.openRotatedLog;
259
- const closeFd = (_e = this.deps.closeFd) !== null && _e !== void 0 ? _e : fs.closeSync;
259
+ const owner = (_d = (_b = (_a = this.deps).createOwnerToken) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _d !== void 0 ? _d : (0, node_crypto_1.randomUUID)();
260
+ const openLog = (_e = this.deps.openLog) !== null && _e !== void 0 ? _e : log_rotate_1.openRotatedLog;
261
+ const closeFd = (_f = this.deps.closeFd) !== null && _f !== void 0 ? _f : fs.closeSync;
260
262
  const logFd = openLog(path.join(config_1.PATHS.logsDir, "mlx-embed-server.log"));
261
263
  const env = Object.assign(Object.assign({}, process.env), { MLX_EMBED_MODEL: model, GMAX_EMBED_OWNER_TOKEN: owner, HF_HOME: (0, mlx_hf_cache_1.resolveMlxHfHome)(model) });
262
264
  this.phase = "starting";
263
265
  let child;
264
266
  try {
265
- child = ((_f = this.deps.spawn) !== null && _f !== void 0 ? _f : node_child_process_1.spawn)("uv", ["run", "python", "server.py"], {
267
+ child = ((_g = this.deps.spawn) !== null && _g !== void 0 ? _g : node_child_process_1.spawn)("uv", ["run", "python", "server.py"], {
266
268
  cwd: serverDir,
267
269
  detached: true,
268
270
  stdio: ["ignore", logFd, logFd],
@@ -338,8 +340,7 @@ class MlxServerManager {
338
340
  child.off("error", onError);
339
341
  child.off("exit", onExit);
340
342
  yield this.terminateOwned(candidate);
341
- this.lastError =
342
- (_h = (_g = startup.error) === null || _g === void 0 ? void 0 : _g.message) !== null && _h !== void 0 ? _h : (this.shouldStop() ? "MLX startup cancelled" : "MLX startup timed out");
343
+ this.lastError = (_h = (_c = startup.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _h !== void 0 ? _h : (this.shouldStop() ? "MLX startup cancelled" : "MLX startup timed out");
343
344
  if (!this.shouldStop()) {
344
345
  this.phase = "failed";
345
346
  console.error(`[daemon] ${this.lastError} — falling back to CPU embeddings`);
@@ -353,7 +354,7 @@ class MlxServerManager {
353
354
  return this.stopFlight;
354
355
  const flight = (() => __awaiter(this, void 0, void 0, function* () {
355
356
  var _a;
356
- yield ((_a = this.ensureFlight) === null || _a === void 0 ? void 0 : _a.catch(() => { }));
357
+ yield (_a = this.ensureFlight) === null || _a === void 0 ? void 0 : _a.catch(() => { });
357
358
  if (this.stable.kind === "owned") {
358
359
  const owned = this.stable;
359
360
  yield this.terminateOwned(owned);
@@ -555,7 +555,8 @@ function handleRowsLocate(deps, payload) {
555
555
  */
556
556
  function runSkeleton(deps, req) {
557
557
  return __awaiter(this, void 0, void 0, function* () {
558
- var _a, _b;
558
+ var _a;
559
+ var _b;
559
560
  if (!deps.vectorDb)
560
561
  throw new ReadVerbError("daemon not ready");
561
562
  (_a = deps.touchActivity) === null || _a === void 0 ? void 0 : _a.call(deps);
@@ -607,18 +608,15 @@ function readRows(opts) {
607
608
  return [];
608
609
  const { sendDaemonCommand } = yield Promise.resolve().then(() => __importStar(require("../utils/daemon-client")));
609
610
  const { withStoreRead } = yield Promise.resolve().then(() => __importStar(require("../utils/store-access")));
610
- return withStoreRead(opts.name, Object.assign({ daemon: () => {
611
- var _a;
612
- return sendDaemonCommand({
613
- cmd: "rows.locate",
614
- projectRoot: opts.projectRoot,
615
- scope: scopeToWire(opts.scope),
616
- select: opts.select,
617
- matches: opts.matches,
618
- limit: opts.limit,
619
- scoped: opts.scoped,
620
- }, { timeoutMs: (_a = opts.timeoutMs) !== null && _a !== void 0 ? _a : 60000 });
621
- }, render: (resp) => { var _a; return ((_a = resp.rows) !== null && _a !== void 0 ? _a : []); }, inProcess: () => withLocalStore(opts.lancedbDir, (deps) => runLocate(deps, {
611
+ return withStoreRead(opts.name, Object.assign({ daemon: () => { var _a; return sendDaemonCommand({
612
+ cmd: "rows.locate",
613
+ projectRoot: opts.projectRoot,
614
+ scope: scopeToWire(opts.scope),
615
+ select: opts.select,
616
+ matches: opts.matches,
617
+ limit: opts.limit,
618
+ scoped: opts.scoped,
619
+ }, { timeoutMs: (_a = opts.timeoutMs) !== null && _a !== void 0 ? _a : 60000 }); }, render: (resp) => { var _a; return ((_a = resp.rows) !== null && _a !== void 0 ? _a : []); }, inProcess: () => withLocalStore(opts.lancedbDir, (deps) => runLocate(deps, {
622
620
  projectRoot: opts.projectRoot,
623
621
  scope: opts.scope,
624
622
  select: opts.select,