ctxloom-pro 1.7.8 → 1.7.10

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  EMBEDDING_DIMENSION,
3
3
  EMBEDDING_MODEL_ID
4
- } from "./chunk-R32CUQAL.js";
4
+ } from "./chunk-XJJHX227.js";
5
5
  import {
6
6
  logger
7
7
  } from "./chunk-TYDMSHV7.js";
@@ -12,6 +12,11 @@ import fs from "fs";
12
12
  function sanitizeFilterPath(filePath) {
13
13
  return filePath.replace(/[^a-zA-Z0-9/._\- ]/g, "_");
14
14
  }
15
+ var VECTOR_RECOVERY_CMD = "ctxloom vectors-cleanup && ctxloom index";
16
+ function isCorruptionError(err) {
17
+ const msg = err instanceof Error ? err.message : String(err);
18
+ return /not found/i.test(msg) && /\.lance|\.arrow|_deletions|_versions|\/data\//.test(msg);
19
+ }
15
20
  var VectorStore = class {
16
21
  dbPath;
17
22
  db = null;
@@ -198,8 +203,7 @@ var VectorStore = class {
198
203
  throw new Error(
199
204
  `Embedding-model mismatch: vector index at ${this.dbPath} was built with "${existing.model}" (${existing.dim}-dim) but the active model is "${active.model}" (${active.dim}-dim). Re-index required:
200
205
 
201
- ctxloom vectors-cleanup --reset
202
- ctxloom index
206
+ ${VECTOR_RECOVERY_CMD}
203
207
 
204
208
  Or revert CTXLOOM_EMBEDDING_MODEL to "${existing.model}" to keep the existing index.`
205
209
  );
@@ -351,6 +355,11 @@ Or revert CTXLOOM_EMBEDDING_MODEL to "${existing.model}" to keep the existing in
351
355
  }
352
356
  return null;
353
357
  } catch (err) {
358
+ if (isCorruptionError(err)) {
359
+ throw new Error(
360
+ `VectorStore corrupt at ${this.dbPath}: manifest references a missing fragment (${err instanceof Error ? err.message : String(err)}). Recover with: ${VECTOR_RECOVERY_CMD}`
361
+ );
362
+ }
354
363
  logger.warn("VectorStore.findEmbeddingByPath failed", {
355
364
  detail: err instanceof Error ? err.message : String(err),
356
365
  filePath
@@ -372,6 +381,11 @@ Or revert CTXLOOM_EMBEDDING_MODEL to "${existing.model}" to keep the existing in
372
381
  score: Number(r._distance ?? 0)
373
382
  }));
374
383
  } catch (err) {
384
+ if (isCorruptionError(err)) {
385
+ throw new Error(
386
+ `VectorStore corrupt at ${this.dbPath}: manifest references a missing fragment (${err instanceof Error ? err.message : String(err)}). Recover with: ${VECTOR_RECOVERY_CMD}`
387
+ );
388
+ }
375
389
  logger.warn("Search failed, attempting to create index", { detail: String(err) });
376
390
  try {
377
391
  await this.table.createIndex("vector");
@@ -381,7 +395,12 @@ Or revert CTXLOOM_EMBEDDING_MODEL to "${existing.model}" to keep the existing in
381
395
  content: String(r.content ?? ""),
382
396
  score: Number(r._distance ?? 0)
383
397
  }));
384
- } catch {
398
+ } catch (retryErr) {
399
+ if (isCorruptionError(retryErr)) {
400
+ throw new Error(
401
+ `VectorStore corrupt at ${this.dbPath}: manifest references a missing fragment (${retryErr instanceof Error ? retryErr.message : String(retryErr)}). Recover with: ${VECTOR_RECOVERY_CMD}`
402
+ );
403
+ }
385
404
  return [];
386
405
  }
387
406
  }
@@ -412,9 +431,22 @@ Or revert CTXLOOM_EMBEDDING_MODEL to "${existing.model}" to keep the existing in
412
431
  return 0;
413
432
  }
414
433
  }
434
+ /**
435
+ * Liveness probe for ctx_status. Performs an actual 1-row READ (not a
436
+ * metadata `count()`, which reads the intact manifest and returns a
437
+ * stale count on a corrupt store). Throws the underlying lance error
438
+ * if a referenced fragment is missing — callers use isCorruptionError()
439
+ * to classify. Resolves silently on a healthy store (including an
440
+ * empty one, which simply yields zero rows). Cheap: a single-row scan.
441
+ */
442
+ async probe() {
443
+ if (!this.table) throw new Error("VectorStore not initialized. Call init() first.");
444
+ await this.table.query().limit(1).toArray();
445
+ }
415
446
  };
416
447
 
417
448
  export {
449
+ isCorruptionError,
418
450
  VectorStore
419
451
  };
420
- //# sourceMappingURL=chunk-Z3NQHCWG.js.map
452
+ //# sourceMappingURL=chunk-UWQKNIZO.js.map
@@ -253,7 +253,7 @@ var INDEX_SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([
253
253
  ".ipynb"
254
254
  ]);
255
255
  async function indexDirectory(rootDir, onProgress) {
256
- const { VectorStore } = await import("./VectorStore-IHNQ3NOD.js");
256
+ const { VectorStore } = await import("./VectorStore-ZA4EEL6C.js");
257
257
  const store = new VectorStore(path.join(rootDir, ".ctxloom", "vectors.lancedb"));
258
258
  await store.init();
259
259
  let indexed = 0;
@@ -366,4 +366,4 @@ export {
366
366
  EMBEDDING_MODEL_ID,
367
367
  getActiveEmbeddingModel
368
368
  };
369
- //# sourceMappingURL=chunk-R32CUQAL.js.map
369
+ //# sourceMappingURL=chunk-XJJHX227.js.map
@@ -10,7 +10,7 @@ import {
10
10
  indexDirectory,
11
11
  isIgnoredDir,
12
12
  resolveEmbeddingModel
13
- } from "./chunk-R32CUQAL.js";
13
+ } from "./chunk-XJJHX227.js";
14
14
  import "./chunk-TYDMSHV7.js";
15
15
  export {
16
16
  EMBEDDING_DIMENSION,
@@ -25,4 +25,4 @@ export {
25
25
  isIgnoredDir,
26
26
  resolveEmbeddingModel
27
27
  };
28
- //# sourceMappingURL=embedder-E2GDBGOH.js.map
28
+ //# sourceMappingURL=embedder-WQMRK5T7.js.map
package/dist/index.js CHANGED
@@ -47,19 +47,19 @@ import {
47
47
  validateDefaultRoot,
48
48
  wrapWithIndexingEnvelope,
49
49
  writeCODEOWNERS
50
- } from "./chunk-7WLMI4AD.js";
50
+ } from "./chunk-J3NVYR6J.js";
51
51
  import {
52
52
  addCtxloomToConfig,
53
53
  detectInstalledClients
54
54
  } from "./chunk-YHLMQVBV.js";
55
55
  import {
56
56
  VectorStore
57
- } from "./chunk-Z3NQHCWG.js";
57
+ } from "./chunk-UWQKNIZO.js";
58
58
  import {
59
59
  collectFiles,
60
60
  generateEmbedding,
61
61
  indexDirectory
62
- } from "./chunk-R32CUQAL.js";
62
+ } from "./chunk-XJJHX227.js";
63
63
  import "./chunk-5I6CJITG.js";
64
64
  import {
65
65
  logger
@@ -151,13 +151,41 @@ async function initSkeletonizer(state) {
151
151
  }
152
152
  return state.skeletonizerPromise;
153
153
  }
154
+ async function initOverlay(state, withGit2, gitWindowDays2) {
155
+ if (!withGit2) return null;
156
+ if (!state.overlayPromise) {
157
+ state.overlayPromise = (async () => {
158
+ try {
159
+ const overlay = new GitOverlayStore(state.projectRoot, { windowDays: gitWindowDays2 });
160
+ const loaded = await overlay.loadSnapshot();
161
+ if (!loaded) {
162
+ await overlay.rebuild();
163
+ await overlay.saveSnapshot();
164
+ } else {
165
+ await overlay.refresh();
166
+ await overlay.saveSnapshot();
167
+ }
168
+ state.overlay = overlay;
169
+ return overlay;
170
+ } catch (err) {
171
+ logger.warn("Git overlay init failed", {
172
+ root: state.projectRoot,
173
+ detail: err instanceof Error ? err.message : String(err)
174
+ });
175
+ state.overlayPromise = null;
176
+ return null;
177
+ }
178
+ })();
179
+ }
180
+ return state.overlayPromise;
181
+ }
154
182
  function classifyResolutionSource(arg, env) {
155
183
  if (arg !== void 0) {
156
184
  return /[/\\~]|^[A-Za-z]:/.test(arg) ? "arg-path" : "alias";
157
185
  }
158
186
  return env ? "env" : "cwd";
159
187
  }
160
- function buildContext(defaultRoot, noDefaultMode) {
188
+ function buildContext(defaultRoot, noDefaultMode, gitOpts) {
161
189
  const repoRegistry = new RepoRegistry(repoRegistryPath);
162
190
  function resolveOrDefault(arg) {
163
191
  let state;
@@ -212,6 +240,7 @@ function buildContext(defaultRoot, noDefaultMode) {
212
240
  noDefaultMode,
213
241
  registry: repoRegistry,
214
242
  stateManager,
243
+ getOverlay: (root) => initOverlay(resolveOrDefault(root), gitOpts.withGit, gitOpts.gitWindowDays),
215
244
  getStore: async (root) => {
216
245
  const state = resolveOrDefault(root);
217
246
  const store = await initStore(state);
@@ -254,7 +283,7 @@ function buildContext(defaultRoot, noDefaultMode) {
254
283
  };
255
284
  return { ctx, resolveOrDefault };
256
285
  }
257
- function createServer() {
286
+ function createServer(gitOpts = { withGit: true, gitWindowDays: 365 }) {
258
287
  const server = new Server({ name: "ctxloom", version: "1.0.0" }, { capabilities: { tools: {} } });
259
288
  const candidateDefault = PROJECT_ROOT;
260
289
  const isValidDefault = validateDefaultRoot(candidateDefault);
@@ -266,7 +295,7 @@ function createServer() {
266
295
  }
267
296
  const defaultRoot = isValidDefault ? candidateDefault : null;
268
297
  if (defaultRoot) stateManager.pin(defaultRoot);
269
- const { ctx, resolveOrDefault } = buildContext(defaultRoot, !isValidDefault);
298
+ const { ctx, resolveOrDefault } = buildContext(defaultRoot, !isValidDefault, gitOpts);
270
299
  const registry = createToolRegistry(ctx);
271
300
  server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: registry.list() }));
272
301
  server.setRequestHandler(CallToolRequestSchema, async ({ params: { name, arguments: args2 } }) => {
@@ -410,7 +439,7 @@ function createServer() {
410
439
  async function startServer(opts = {}) {
411
440
  const withGit2 = opts.withGit ?? true;
412
441
  const gitWindowDays2 = opts.gitWindowDays ?? 365;
413
- const { server, ctx } = createServer();
442
+ const { server, ctx } = createServer({ withGit: withGit2, gitWindowDays: gitWindowDays2 });
414
443
  const transport = new StdioServerTransport();
415
444
  await server.connect(transport);
416
445
  logger.info("MCP Server started on Stdio transport");
@@ -1068,7 +1097,7 @@ try {
1068
1097
  } catch {
1069
1098
  }
1070
1099
  var args = process.argv.slice(2);
1071
- var ctxloomVersion = "1.7.8".length > 0 ? "1.7.8" : "dev";
1100
+ var ctxloomVersion = "1.7.10".length > 0 ? "1.7.10" : "dev";
1072
1101
  if (args.includes("--version") || args.includes("-v")) {
1073
1102
  process.stdout.write(`ctxloom ${ctxloomVersion}
1074
1103
  `);
@@ -1163,7 +1192,7 @@ async function checkLicense() {
1163
1192
  if (command !== void 0 && LICENSE_GATE_BYPASS_COMMANDS.has(command)) return;
1164
1193
  const ciKey = process.env["CTXLOOM_LICENSE_KEY"];
1165
1194
  if (ciKey) {
1166
- const { ApiClient } = await import("./src-C5NS2JAW.js");
1195
+ const { ApiClient } = await import("./src-7ETGK3MB.js");
1167
1196
  const client = new ApiClient(process.env["CTXLOOM_API_BASE"]);
1168
1197
  try {
1169
1198
  const result = await client.validate(ciKey, "ci-ephemeral");
@@ -1556,7 +1585,7 @@ async function main() {
1556
1585
  }
1557
1586
  if (!skipHarness) {
1558
1587
  process.stdout.write("\n");
1559
- const { installHarness } = await import("./src-C5NS2JAW.js");
1588
+ const { installHarness } = await import("./src-7ETGK3MB.js");
1560
1589
  const h = installHarness({ cwd: initRoot, dryRun, force, extraHosts });
1561
1590
  const harnessFiles = [
1562
1591
  h.claudeMd,
@@ -1619,7 +1648,7 @@ async function main() {
1619
1648
  process.exit(1);
1620
1649
  }
1621
1650
  if (alias !== void 0) {
1622
- const { validateAlias } = await import("./src-C5NS2JAW.js");
1651
+ const { validateAlias } = await import("./src-7ETGK3MB.js");
1623
1652
  const v = validateAlias(alias);
1624
1653
  if (!v.ok) {
1625
1654
  console.error(`[ctxloom] Invalid alias: ${v.reason}`);
@@ -1978,7 +2007,7 @@ Suggested reviewers for ${files.length} file(s):`);
1978
2007
  process.stderr.write("[ctxloom] --limit must be a non-negative integer (0 for unlimited)\n");
1979
2008
  process.exit(2);
1980
2009
  }
1981
- const { loadRulesConfig, RulesChecker, formatText, formatJson, RulesConfigError } = await import("./src-C5NS2JAW.js");
2010
+ const { loadRulesConfig, RulesChecker, formatText, formatJson, RulesConfigError } = await import("./src-7ETGK3MB.js");
1982
2011
  let config;
1983
2012
  try {
1984
2013
  config = await loadRulesConfig(root);
@@ -2002,7 +2031,7 @@ Suggested reviewers for ${files.length} file(s):`);
2002
2031
  }
2003
2032
  let graph;
2004
2033
  if (useSnapshot) {
2005
- const { DependencyGraph: DG } = await import("./src-C5NS2JAW.js");
2034
+ const { DependencyGraph: DG } = await import("./src-7ETGK3MB.js");
2006
2035
  graph = new DG();
2007
2036
  const loaded = await graph.loadSnapshotOnly(root);
2008
2037
  if (!loaded) {
@@ -2011,7 +2040,7 @@ Suggested reviewers for ${files.length} file(s):`);
2011
2040
  }
2012
2041
  } else {
2013
2042
  process.stderr.write("[ctxloom] Building dependency graph...\n");
2014
- const { ASTParser: ASTParser2, DependencyGraph: DependencyGraph2 } = await import("./src-C5NS2JAW.js");
2043
+ const { ASTParser: ASTParser2, DependencyGraph: DependencyGraph2 } = await import("./src-7ETGK3MB.js");
2015
2044
  let parser;
2016
2045
  try {
2017
2046
  parser = new ASTParser2();
@@ -132,10 +132,11 @@ import {
132
132
  wrapBlock,
133
133
  wrapWithIndexingEnvelope,
134
134
  writeCODEOWNERS
135
- } from "./chunk-7WLMI4AD.js";
135
+ } from "./chunk-J3NVYR6J.js";
136
136
  import {
137
- VectorStore
138
- } from "./chunk-Z3NQHCWG.js";
137
+ VectorStore,
138
+ isCorruptionError
139
+ } from "./chunk-UWQKNIZO.js";
139
140
  import {
140
141
  EMBEDDING_DIMENSION,
141
142
  INDEXER_IGNORED_DIRS,
@@ -143,7 +144,7 @@ import {
143
144
  generateEmbedding,
144
145
  indexDirectory,
145
146
  isIgnoredDir
146
- } from "./chunk-R32CUQAL.js";
147
+ } from "./chunk-XJJHX227.js";
147
148
  import {
148
149
  filenameForDate,
149
150
  readEvents,
@@ -259,6 +260,7 @@ export {
259
260
  inspectVectorsDb,
260
261
  installHarness,
261
262
  isActive,
263
+ isCorruptionError,
262
264
  isIgnoredDir,
263
265
  isSiloed,
264
266
  learnSuggestionsFromTelemetry,
@@ -304,4 +306,4 @@ export {
304
306
  wrapWithIndexingEnvelope,
305
307
  writeCODEOWNERS
306
308
  };
307
- //# sourceMappingURL=src-C5NS2JAW.js.map
309
+ //# sourceMappingURL=src-7ETGK3MB.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  VectorStore
3
- } from "../chunk-Z3NQHCWG.js";
3
+ } from "../chunk-UWQKNIZO.js";
4
4
  import {
5
5
  generateEmbedding
6
- } from "../chunk-R32CUQAL.js";
6
+ } from "../chunk-XJJHX227.js";
7
7
  import "../chunk-TYDMSHV7.js";
8
8
 
9
9
  // packages/core/src/workers/indexerWorker.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ctxloom-pro",
3
- "version": "1.7.8",
3
+ "version": "1.7.10",
4
4
  "description": "ctxloom — The Universal Code Context Engine. A local-first MCP server providing intelligent code context via hybrid Vector + AST + Graph search with Skeletonization (92% token reduction).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,9 +0,0 @@
1
- import {
2
- VectorStore
3
- } from "./chunk-Z3NQHCWG.js";
4
- import "./chunk-R32CUQAL.js";
5
- import "./chunk-TYDMSHV7.js";
6
- export {
7
- VectorStore
8
- };
9
- //# sourceMappingURL=VectorStore-IHNQ3NOD.js.map