ctxloom-pro 1.2.0 → 1.2.2

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.
@@ -77,7 +77,6 @@ var init_logger = __esm({
77
77
  });
78
78
 
79
79
  // ../../packages/core/src/indexer/embedder.ts
80
- import { pipeline } from "@huggingface/transformers";
81
80
  import fs3 from "fs";
82
81
  import path3 from "path";
83
82
  function collectFiles(dir, results = []) {
@@ -155,8 +154,6 @@ var init_embedder = __esm({
155
154
  });
156
155
 
157
156
  // ../../packages/core/src/db/VectorStore.ts
158
- import lancedb from "@lancedb/lancedb";
159
- import { makeArrowTable } from "@lancedb/lancedb";
160
157
  import path15 from "path";
161
158
  import fs15 from "fs";
162
159
  var init_VectorStore = __esm({
@@ -181,7 +178,6 @@ import fs7 from "fs";
181
178
  import path7 from "path";
182
179
 
183
180
  // ../../packages/core/src/ast/ASTParser.ts
184
- import * as TreeSitter from "web-tree-sitter";
185
181
  import fs2 from "fs";
186
182
  import path2 from "path";
187
183
  import { fileURLToPath } from "url";
@@ -425,6 +421,11 @@ function extractNotebookPythonSource(content) {
425
421
  }
426
422
 
427
423
  // ../../packages/core/src/ast/ASTParser.ts
424
+ var _ts = null;
425
+ async function loadTreeSitter() {
426
+ if (_ts === null) _ts = await import("web-tree-sitter");
427
+ return _ts;
428
+ }
428
429
  var __dirname = path2.dirname(fileURLToPath(import.meta.url));
429
430
  function findWasmDir() {
430
431
  const candidates = [
@@ -480,7 +481,7 @@ var ASTParser = class {
480
481
  getParser(language) {
481
482
  let parser = this.parserCache.get(language);
482
483
  if (parser) return parser;
483
- parser = new TreeSitter.Parser();
484
+ parser = new _ts.Parser();
484
485
  parser.setLanguage(language);
485
486
  this.parserCache.set(language, parser);
486
487
  return parser;
@@ -488,7 +489,8 @@ var ASTParser = class {
488
489
  dartLang = null;
489
490
  grammarLoader = new GrammarLoader();
490
491
  async init() {
491
- await TreeSitter.Parser.init({
492
+ const TS = await loadTreeSitter();
493
+ await TS.Parser.init({
492
494
  locateFile: () => path2.join(WASM_DIR, "tree-sitter.wasm")
493
495
  });
494
496
  const grammarCandidates = [
@@ -510,7 +512,7 @@ var ASTParser = class {
510
512
  if (!grammarPath) {
511
513
  throw new Error("Could not locate tree-sitter-typescript.wasm grammar file");
512
514
  }
513
- this.tsLang = await TreeSitter.Language.load(grammarPath);
515
+ this.tsLang = await _ts.Language.load(grammarPath);
514
516
  }
515
517
  /**
516
518
  * Load Python grammar on demand. Downloads and caches WASM if needed.
@@ -519,7 +521,7 @@ var ASTParser = class {
519
521
  if (this.pyLang) return;
520
522
  try {
521
523
  const wasmPath = await this.grammarLoader.ensureGrammar("python");
522
- this.pyLang = await TreeSitter.Language.load(wasmPath);
524
+ this.pyLang = await _ts.Language.load(wasmPath);
523
525
  } catch (err) {
524
526
  const { logger: logger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
525
527
  logger2.warn("Python grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -532,7 +534,7 @@ var ASTParser = class {
532
534
  if (this.goLang) return;
533
535
  try {
534
536
  const wasmPath = await this.grammarLoader.ensureGrammar("go");
535
- this.goLang = await TreeSitter.Language.load(wasmPath);
537
+ this.goLang = await _ts.Language.load(wasmPath);
536
538
  } catch (err) {
537
539
  const { logger: logger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
538
540
  logger2.warn("Go grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -545,7 +547,7 @@ var ASTParser = class {
545
547
  if (this.rustLang) return;
546
548
  try {
547
549
  const wasmPath = await this.grammarLoader.ensureGrammar("rust");
548
- this.rustLang = await TreeSitter.Language.load(wasmPath);
550
+ this.rustLang = await _ts.Language.load(wasmPath);
549
551
  } catch (err) {
550
552
  const { logger: logger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
551
553
  logger2.warn("Rust grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -558,7 +560,7 @@ var ASTParser = class {
558
560
  if (this.javaLang) return;
559
561
  try {
560
562
  const wasmPath = await this.grammarLoader.ensureGrammar("java");
561
- this.javaLang = await TreeSitter.Language.load(wasmPath);
563
+ this.javaLang = await _ts.Language.load(wasmPath);
562
564
  } catch (err) {
563
565
  const { logger: logger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
564
566
  logger2.warn("Java grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -568,7 +570,7 @@ var ASTParser = class {
568
570
  if (this.csLang) return;
569
571
  try {
570
572
  const wasmPath = await this.grammarLoader.ensureGrammar("csharp");
571
- this.csLang = await TreeSitter.Language.load(wasmPath);
573
+ this.csLang = await _ts.Language.load(wasmPath);
572
574
  } catch (err) {
573
575
  const { logger: logger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
574
576
  logger2.warn("C# grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -578,7 +580,7 @@ var ASTParser = class {
578
580
  if (this.rubyLang) return;
579
581
  try {
580
582
  const wasmPath = await this.grammarLoader.ensureGrammar("ruby");
581
- this.rubyLang = await TreeSitter.Language.load(wasmPath);
583
+ this.rubyLang = await _ts.Language.load(wasmPath);
582
584
  } catch (err) {
583
585
  const { logger: logger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
584
586
  logger2.warn("Ruby grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -588,7 +590,7 @@ var ASTParser = class {
588
590
  if (this.kotlinLang) return;
589
591
  try {
590
592
  const wasmPath = await this.grammarLoader.ensureGrammar("kotlin");
591
- this.kotlinLang = await TreeSitter.Language.load(wasmPath);
593
+ this.kotlinLang = await _ts.Language.load(wasmPath);
592
594
  } catch (err) {
593
595
  const { logger: logger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
594
596
  logger2.warn("Kotlin grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -598,7 +600,7 @@ var ASTParser = class {
598
600
  if (this.swiftLang) return;
599
601
  try {
600
602
  const wasmPath = await this.grammarLoader.ensureGrammar("swift");
601
- this.swiftLang = await TreeSitter.Language.load(wasmPath);
603
+ this.swiftLang = await _ts.Language.load(wasmPath);
602
604
  } catch (err) {
603
605
  const { logger: logger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
604
606
  logger2.warn("Swift grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -608,7 +610,7 @@ var ASTParser = class {
608
610
  if (this.phpLang) return;
609
611
  try {
610
612
  const wasmPath = await this.grammarLoader.ensureGrammar("php");
611
- this.phpLang = await TreeSitter.Language.load(wasmPath);
613
+ this.phpLang = await _ts.Language.load(wasmPath);
612
614
  } catch (err) {
613
615
  const { logger: logger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
614
616
  logger2.warn("PHP grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -618,7 +620,7 @@ var ASTParser = class {
618
620
  if (this.dartLang) return;
619
621
  try {
620
622
  const wasmPath = await this.grammarLoader.ensureGrammar("dart");
621
- this.dartLang = await TreeSitter.Language.load(wasmPath);
623
+ this.dartLang = await _ts.Language.load(wasmPath);
622
624
  } catch (err) {
623
625
  const { logger: logger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
624
626
  logger2.warn("Dart grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -11321,7 +11323,7 @@ function resolveTelemetryLevel() {
11321
11323
  }
11322
11324
  var TELEMETRY_LEVEL = resolveTelemetryLevel();
11323
11325
  var TELEMETRY_DISABLED = TELEMETRY_LEVEL === "off";
11324
- var CTXLOOM_VERSION = "1.2.0".length > 0 ? "1.2.0" : "dev";
11326
+ var CTXLOOM_VERSION = "1.2.2".length > 0 ? "1.2.2" : "dev";
11325
11327
  var POSTHOG_HOST = "https://eu.i.posthog.com";
11326
11328
  var POSTHOG_KEY = process.env["POSTHOG_API_KEY"] ?? (true ? "phc_CiDkmFLcZ2K6uCpcoSUQLmFrnnUvsyXGhSxopX5TVKE6" : "");
11327
11329
  var SENTRY_DSN = process.env["SENTRY_DSN"] ?? (true ? "https://81c94a0f04a8e242dee493ac1e17f733@o4508531702497280.ingest.de.sentry.io/4511256875368528" : "");
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  VectorStore
3
- } from "./chunk-NEHYSE2Y.js";
3
+ } from "./chunk-DVI2RWJR.js";
4
4
  import "./chunk-TYDMSHV7.js";
5
5
  export {
6
6
  VectorStore
7
7
  };
8
- //# sourceMappingURL=VectorStore-HOSUSLV7.js.map
8
+ //# sourceMappingURL=VectorStore-XYLGD37W.js.map
@@ -3,8 +3,6 @@ import {
3
3
  } from "./chunk-TYDMSHV7.js";
4
4
 
5
5
  // packages/core/src/db/VectorStore.ts
6
- import lancedb from "@lancedb/lancedb";
7
- import { makeArrowTable } from "@lancedb/lancedb";
8
6
  import path from "path";
9
7
  import fs from "fs";
10
8
  function sanitizeFilterPath(filePath) {
@@ -24,7 +22,9 @@ var VectorStore = class {
24
22
  if (!fs.existsSync(dir)) {
25
23
  fs.mkdirSync(dir, { recursive: true });
26
24
  }
27
- this.db = await lancedb.connect(this.dbPath);
25
+ const lancedb = await import("@lancedb/lancedb");
26
+ const { makeArrowTable } = lancedb;
27
+ this.db = await lancedb.default.connect(this.dbPath);
28
28
  const existingTables = await this.db.tableNames();
29
29
  if (existingTables.includes("code_embeddings")) {
30
30
  this.table = await this.db.openTable("code_embeddings");
@@ -141,4 +141,4 @@ var VectorStore = class {
141
141
  export {
142
142
  VectorStore
143
143
  };
144
- //# sourceMappingURL=chunk-NEHYSE2Y.js.map
144
+ //# sourceMappingURL=chunk-DVI2RWJR.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  VectorStore
3
- } from "./chunk-NEHYSE2Y.js";
3
+ } from "./chunk-DVI2RWJR.js";
4
4
  import {
5
5
  collectFiles,
6
6
  generateEmbedding
7
- } from "./chunk-VR6PNQYH.js";
7
+ } from "./chunk-NMXQC5CG.js";
8
8
  import {
9
9
  logger
10
10
  } from "./chunk-TYDMSHV7.js";
@@ -14,7 +14,6 @@ import fs6 from "fs";
14
14
  import path6 from "path";
15
15
 
16
16
  // packages/core/src/ast/ASTParser.ts
17
- import * as TreeSitter from "web-tree-sitter";
18
17
  import fs2 from "fs";
19
18
  import path2 from "path";
20
19
  import { fileURLToPath } from "url";
@@ -264,6 +263,11 @@ function extractNotebookLanguage(content) {
264
263
  }
265
264
 
266
265
  // packages/core/src/ast/ASTParser.ts
266
+ var _ts = null;
267
+ async function loadTreeSitter() {
268
+ if (_ts === null) _ts = await import("web-tree-sitter");
269
+ return _ts;
270
+ }
267
271
  var __dirname = path2.dirname(fileURLToPath(import.meta.url));
268
272
  function findWasmDir() {
269
273
  const candidates = [
@@ -319,7 +323,7 @@ var ASTParser = class {
319
323
  getParser(language) {
320
324
  let parser = this.parserCache.get(language);
321
325
  if (parser) return parser;
322
- parser = new TreeSitter.Parser();
326
+ parser = new _ts.Parser();
323
327
  parser.setLanguage(language);
324
328
  this.parserCache.set(language, parser);
325
329
  return parser;
@@ -327,7 +331,8 @@ var ASTParser = class {
327
331
  dartLang = null;
328
332
  grammarLoader = new GrammarLoader();
329
333
  async init() {
330
- await TreeSitter.Parser.init({
334
+ const TS = await loadTreeSitter();
335
+ await TS.Parser.init({
331
336
  locateFile: () => path2.join(WASM_DIR, "tree-sitter.wasm")
332
337
  });
333
338
  const grammarCandidates = [
@@ -349,7 +354,7 @@ var ASTParser = class {
349
354
  if (!grammarPath) {
350
355
  throw new Error("Could not locate tree-sitter-typescript.wasm grammar file");
351
356
  }
352
- this.tsLang = await TreeSitter.Language.load(grammarPath);
357
+ this.tsLang = await _ts.Language.load(grammarPath);
353
358
  }
354
359
  /**
355
360
  * Load Python grammar on demand. Downloads and caches WASM if needed.
@@ -358,7 +363,7 @@ var ASTParser = class {
358
363
  if (this.pyLang) return;
359
364
  try {
360
365
  const wasmPath = await this.grammarLoader.ensureGrammar("python");
361
- this.pyLang = await TreeSitter.Language.load(wasmPath);
366
+ this.pyLang = await _ts.Language.load(wasmPath);
362
367
  } catch (err) {
363
368
  const { logger: logger2 } = await import("./logger-PDXPCKJ6.js");
364
369
  logger2.warn("Python grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -371,7 +376,7 @@ var ASTParser = class {
371
376
  if (this.goLang) return;
372
377
  try {
373
378
  const wasmPath = await this.grammarLoader.ensureGrammar("go");
374
- this.goLang = await TreeSitter.Language.load(wasmPath);
379
+ this.goLang = await _ts.Language.load(wasmPath);
375
380
  } catch (err) {
376
381
  const { logger: logger2 } = await import("./logger-PDXPCKJ6.js");
377
382
  logger2.warn("Go grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -384,7 +389,7 @@ var ASTParser = class {
384
389
  if (this.rustLang) return;
385
390
  try {
386
391
  const wasmPath = await this.grammarLoader.ensureGrammar("rust");
387
- this.rustLang = await TreeSitter.Language.load(wasmPath);
392
+ this.rustLang = await _ts.Language.load(wasmPath);
388
393
  } catch (err) {
389
394
  const { logger: logger2 } = await import("./logger-PDXPCKJ6.js");
390
395
  logger2.warn("Rust grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -397,7 +402,7 @@ var ASTParser = class {
397
402
  if (this.javaLang) return;
398
403
  try {
399
404
  const wasmPath = await this.grammarLoader.ensureGrammar("java");
400
- this.javaLang = await TreeSitter.Language.load(wasmPath);
405
+ this.javaLang = await _ts.Language.load(wasmPath);
401
406
  } catch (err) {
402
407
  const { logger: logger2 } = await import("./logger-PDXPCKJ6.js");
403
408
  logger2.warn("Java grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -407,7 +412,7 @@ var ASTParser = class {
407
412
  if (this.csLang) return;
408
413
  try {
409
414
  const wasmPath = await this.grammarLoader.ensureGrammar("csharp");
410
- this.csLang = await TreeSitter.Language.load(wasmPath);
415
+ this.csLang = await _ts.Language.load(wasmPath);
411
416
  } catch (err) {
412
417
  const { logger: logger2 } = await import("./logger-PDXPCKJ6.js");
413
418
  logger2.warn("C# grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -417,7 +422,7 @@ var ASTParser = class {
417
422
  if (this.rubyLang) return;
418
423
  try {
419
424
  const wasmPath = await this.grammarLoader.ensureGrammar("ruby");
420
- this.rubyLang = await TreeSitter.Language.load(wasmPath);
425
+ this.rubyLang = await _ts.Language.load(wasmPath);
421
426
  } catch (err) {
422
427
  const { logger: logger2 } = await import("./logger-PDXPCKJ6.js");
423
428
  logger2.warn("Ruby grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -427,7 +432,7 @@ var ASTParser = class {
427
432
  if (this.kotlinLang) return;
428
433
  try {
429
434
  const wasmPath = await this.grammarLoader.ensureGrammar("kotlin");
430
- this.kotlinLang = await TreeSitter.Language.load(wasmPath);
435
+ this.kotlinLang = await _ts.Language.load(wasmPath);
431
436
  } catch (err) {
432
437
  const { logger: logger2 } = await import("./logger-PDXPCKJ6.js");
433
438
  logger2.warn("Kotlin grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -437,7 +442,7 @@ var ASTParser = class {
437
442
  if (this.swiftLang) return;
438
443
  try {
439
444
  const wasmPath = await this.grammarLoader.ensureGrammar("swift");
440
- this.swiftLang = await TreeSitter.Language.load(wasmPath);
445
+ this.swiftLang = await _ts.Language.load(wasmPath);
441
446
  } catch (err) {
442
447
  const { logger: logger2 } = await import("./logger-PDXPCKJ6.js");
443
448
  logger2.warn("Swift grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -447,7 +452,7 @@ var ASTParser = class {
447
452
  if (this.phpLang) return;
448
453
  try {
449
454
  const wasmPath = await this.grammarLoader.ensureGrammar("php");
450
- this.phpLang = await TreeSitter.Language.load(wasmPath);
455
+ this.phpLang = await _ts.Language.load(wasmPath);
451
456
  } catch (err) {
452
457
  const { logger: logger2 } = await import("./logger-PDXPCKJ6.js");
453
458
  logger2.warn("PHP grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -457,7 +462,7 @@ var ASTParser = class {
457
462
  if (this.dartLang) return;
458
463
  try {
459
464
  const wasmPath = await this.grammarLoader.ensureGrammar("dart");
460
- this.dartLang = await TreeSitter.Language.load(wasmPath);
465
+ this.dartLang = await _ts.Language.load(wasmPath);
461
466
  } catch (err) {
462
467
  const { logger: logger2 } = await import("./logger-PDXPCKJ6.js");
463
468
  logger2.warn("Dart grammar unavailable", { detail: err instanceof Error ? err.message : String(err) });
@@ -6781,7 +6786,7 @@ function registerFullTextSearchTool(registry, ctx) {
6781
6786
  const { query, mode, case_sensitive, limit, context_lines, project_root } = Schema23.parse(args);
6782
6787
  if (mode === "semantic") {
6783
6788
  try {
6784
- const { generateEmbedding: generateEmbedding2 } = await import("./embedder-MPDEA6P7.js");
6789
+ const { generateEmbedding: generateEmbedding2 } = await import("./embedder-5LMEYY4M.js");
6785
6790
  const store = await ctx.getStore(project_root);
6786
6791
  const embedding = await generateEmbedding2(query);
6787
6792
  const results = await store.search(embedding, limit);
@@ -6818,7 +6823,7 @@ function registerFullTextSearchTool(registry, ctx) {
6818
6823
  let merged = keywordResults.slice(0, limit);
6819
6824
  if (mode === "hybrid") {
6820
6825
  try {
6821
- const { generateEmbedding: generateEmbedding2 } = await import("./embedder-MPDEA6P7.js");
6826
+ const { generateEmbedding: generateEmbedding2 } = await import("./embedder-5LMEYY4M.js");
6822
6827
  const store = await ctx.getStore(project_root);
6823
6828
  const embedding = await generateEmbedding2(query);
6824
6829
  const vectorResults = await store.search(embedding, Math.ceil(limit / 2));
@@ -8850,7 +8855,7 @@ var TELEMETRY_DISABLED = TELEMETRY_LEVEL === "off";
8850
8855
  function getTelemetryLevel() {
8851
8856
  return TELEMETRY_LEVEL;
8852
8857
  }
8853
- var CTXLOOM_VERSION = "1.2.0".length > 0 ? "1.2.0" : "dev";
8858
+ var CTXLOOM_VERSION = "1.2.2".length > 0 ? "1.2.2" : "dev";
8854
8859
  var POSTHOG_HOST = "https://eu.i.posthog.com";
8855
8860
  var POSTHOG_KEY = process.env["POSTHOG_API_KEY"] ?? (true ? "phc_CiDkmFLcZ2K6uCpcoSUQLmFrnnUvsyXGhSxopX5TVKE6" : "");
8856
8861
  var SENTRY_DSN = process.env["SENTRY_DSN"] ?? (true ? "https://81c94a0f04a8e242dee493ac1e17f733@o4508531702497280.ingest.de.sentry.io/4511256875368528" : "");
@@ -9441,4 +9446,4 @@ export {
9441
9446
  FirstTouchTracker,
9442
9447
  EmittedOnceTracker
9443
9448
  };
9444
- //# sourceMappingURL=chunk-4B2S3WJ5.js.map
9449
+ //# sourceMappingURL=chunk-GLBKLUJ4.js.map
@@ -3,7 +3,6 @@ import {
3
3
  } from "./chunk-TYDMSHV7.js";
4
4
 
5
5
  // packages/core/src/indexer/embedder.ts
6
- import { pipeline } from "@huggingface/transformers";
7
6
  import fs from "fs";
8
7
  import path from "path";
9
8
  var EMBEDDING_DIMENSION = 384;
@@ -13,6 +12,7 @@ var MIN_MODEL_BYTES = 80 * 1024 * 1024;
13
12
  var embedder = null;
14
13
  var embedderInitInFlight = null;
15
14
  async function loadEmbedder() {
15
+ const { pipeline } = await import("@huggingface/transformers");
16
16
  return await pipeline("feature-extraction", MODEL_ID, {
17
17
  dtype: "fp32"
18
18
  });
@@ -158,7 +158,7 @@ function collectFiles(dir, results = []) {
158
158
  return results;
159
159
  }
160
160
  async function indexDirectory(rootDir, onProgress) {
161
- const { VectorStore } = await import("./VectorStore-HOSUSLV7.js");
161
+ const { VectorStore } = await import("./VectorStore-XYLGD37W.js");
162
162
  const store = new VectorStore(path.join(rootDir, ".ctxloom", "vectors.lancedb"));
163
163
  await store.init();
164
164
  const files = collectFiles(rootDir);
@@ -211,4 +211,4 @@ export {
211
211
  collectFiles,
212
212
  indexDirectory
213
213
  };
214
- //# sourceMappingURL=chunk-VR6PNQYH.js.map
214
+ //# sourceMappingURL=chunk-NMXQC5CG.js.map
@@ -3,7 +3,7 @@ import {
3
3
  collectFiles,
4
4
  generateEmbedding,
5
5
  indexDirectory
6
- } from "./chunk-VR6PNQYH.js";
6
+ } from "./chunk-NMXQC5CG.js";
7
7
  import "./chunk-TYDMSHV7.js";
8
8
  export {
9
9
  EMBEDDING_DIMENSION,
@@ -11,4 +11,4 @@ export {
11
11
  generateEmbedding,
12
12
  indexDirectory
13
13
  };
14
- //# sourceMappingURL=embedder-MPDEA6P7.js.map
14
+ //# sourceMappingURL=embedder-5LMEYY4M.js.map
package/dist/index.js CHANGED
@@ -47,14 +47,14 @@ import {
47
47
  validateDefaultRoot,
48
48
  wrapWithIndexingEnvelope,
49
49
  writeCODEOWNERS
50
- } from "./chunk-4B2S3WJ5.js";
50
+ } from "./chunk-GLBKLUJ4.js";
51
51
  import {
52
52
  VectorStore
53
- } from "./chunk-NEHYSE2Y.js";
53
+ } from "./chunk-DVI2RWJR.js";
54
54
  import {
55
55
  generateEmbedding,
56
56
  indexDirectory
57
- } from "./chunk-VR6PNQYH.js";
57
+ } from "./chunk-NMXQC5CG.js";
58
58
  import {
59
59
  logger
60
60
  } from "./chunk-TYDMSHV7.js";
@@ -547,6 +547,91 @@ async function startServer(opts = {}) {
547
547
  }
548
548
  }
549
549
 
550
+ // src/setup/install-pr-bot.ts
551
+ import fs2 from "fs";
552
+ import path2 from "path";
553
+ import { execFileSync } from "child_process";
554
+ var WORKFLOW_RELATIVE_PATH = ".github/workflows/ctxloom-review.yml";
555
+ function isGitRepo(cwd) {
556
+ try {
557
+ execFileSync("git", ["rev-parse", "--is-inside-work-tree"], {
558
+ cwd,
559
+ stdio: "ignore"
560
+ });
561
+ return true;
562
+ } catch {
563
+ return false;
564
+ }
565
+ }
566
+ function detectDefaultBranch(cwd) {
567
+ try {
568
+ const out = execFileSync(
569
+ "git",
570
+ ["symbolic-ref", "--short", "refs/remotes/origin/HEAD"],
571
+ { cwd, encoding: "utf8" }
572
+ ).trim();
573
+ if (out) return out.replace(/^origin\//, "");
574
+ } catch {
575
+ }
576
+ try {
577
+ const out = execFileSync("git", ["symbolic-ref", "--short", "HEAD"], {
578
+ cwd,
579
+ encoding: "utf8"
580
+ }).trim();
581
+ if (out) return out;
582
+ } catch {
583
+ }
584
+ return "main";
585
+ }
586
+ function renderWorkflow(ref, defaultBranch) {
587
+ return `# ctxloom PR review \u2014 risk-scored summary + inline notes on every PR.
588
+ # Runs entirely inside this repo's CI; no hosted service, no LLM calls.
589
+ # Default branch for this repo: ${defaultBranch}
590
+ # Docs: https://github.com/kodiii/ctxloom/blob/main/apps/pr-bot/README.md
591
+
592
+ name: ctxloom review
593
+
594
+ on:
595
+ pull_request:
596
+ types: [opened, synchronize, reopened]
597
+
598
+ permissions:
599
+ contents: read
600
+ pull-requests: write
601
+ checks: write
602
+
603
+ jobs:
604
+ review:
605
+ runs-on: ubuntu-latest
606
+ steps:
607
+ - uses: actions/checkout@v4
608
+ with:
609
+ fetch-depth: 0 # required: pr-bot reads git history for co-change overlay
610
+
611
+ - uses: kodiii/ctxloom/apps/pr-bot@${ref}
612
+ `;
613
+ }
614
+ function installPrBotWorkflow(opts = {}) {
615
+ const cwd = opts.cwd ?? process.cwd();
616
+ const force = opts.force ?? false;
617
+ const ref = opts.ref ?? "v1";
618
+ if (!isGitRepo(cwd)) {
619
+ return {
620
+ status: "aborted-not-git",
621
+ reason: `${cwd} is not inside a git repository. GitHub Actions only fire in repos with a remote, so this command needs one.`
622
+ };
623
+ }
624
+ const target = path2.resolve(cwd, WORKFLOW_RELATIVE_PATH);
625
+ if (fs2.existsSync(target) && !force) {
626
+ return { status: "skipped-exists", path: target };
627
+ }
628
+ const defaultBranch = detectDefaultBranch(cwd);
629
+ const contents = renderWorkflow(ref, defaultBranch);
630
+ fs2.mkdirSync(path2.dirname(target), { recursive: true });
631
+ fs2.writeFileSync(target, contents, { mode: 420 });
632
+ return { status: "installed", path: target, defaultBranch };
633
+ }
634
+
550
635
  // src/setup/setup-wizard.ts
551
636
  import { createInterface } from "readline";
552
637
  var C = {
@@ -698,8 +783,45 @@ async function runSetupWizard(options) {
698
783
  console.log(` ${C.red}${failCount} tool${failCount > 1 ? "s" : ""} failed \u2014 see errors above.${C.reset}`);
699
784
  }
700
785
  console.log("");
786
+ if (!options?.nonInteractive) {
787
+ await offerPrBotInstall();
788
+ }
701
789
  printNextSteps();
702
790
  }
791
+ async function offerPrBotInstall() {
792
+ console.log(` ${C.bold}GitHub PR review${C.reset}`);
793
+ console.log(
794
+ ` ${C.dim}Optionally drop .github/workflows/ctxloom-review.yml into${C.reset}`
795
+ );
796
+ console.log(
797
+ ` ${C.dim}this repo so every PR gets an automated risk-scored review.${C.reset}`
798
+ );
799
+ console.log("");
800
+ const answer = await ask(` Install the PR-review workflow here? [y/N]: `);
801
+ if (answer.toLowerCase() !== "y" && answer.toLowerCase() !== "yes") {
802
+ console.log(` ${ICON_SKIP} Skipped. Run ${C.cyan}ctxloom install-pr-bot${C.reset} later if you change your mind.`);
803
+ console.log("");
804
+ return;
805
+ }
806
+ const result = installPrBotWorkflow();
807
+ console.log("");
808
+ switch (result.status) {
809
+ case "installed":
810
+ console.log(` ${ICON_SUCCESS} Created ${C.cyan}${result.path}${C.reset}`);
811
+ console.log(` ${C.dim}Default branch: ${result.defaultBranch}${C.reset}`);
812
+ console.log(` ${C.dim}Commit + push it, then the next PR will trigger the bot.${C.reset}`);
813
+ break;
814
+ case "skipped-exists":
815
+ console.log(` ${ICON_SKIP} A workflow already exists at ${result.path}.`);
816
+ console.log(` ${C.dim}Pass --force to ${C.cyan}ctxloom install-pr-bot${C.reset}${C.dim} to overwrite.${C.reset}`);
817
+ break;
818
+ case "aborted-not-git":
819
+ console.log(` ${ICON_FAIL} ${result.reason}`);
820
+ console.log(` ${C.dim}Run ${C.cyan}git init${C.reset}${C.dim} (and connect a remote) first, then ${C.cyan}ctxloom install-pr-bot${C.reset}${C.dim}.${C.reset}`);
821
+ break;
822
+ }
823
+ console.log("");
824
+ }
703
825
  function printNextSteps() {
704
826
  console.log(` ${C.bold}Next steps:${C.reset}`);
705
827
  console.log("");
@@ -713,16 +835,16 @@ function printNextSteps() {
713
835
  }
714
836
 
715
837
  // src/setup/init.ts
716
- import fs2 from "fs";
717
- import path2 from "path";
838
+ import fs3 from "fs";
839
+ import path3 from "path";
718
840
  function runInit(cwd = process.cwd()) {
719
- const root = path2.resolve(cwd);
720
- const stat = fs2.statSync(root);
841
+ const root = path3.resolve(cwd);
842
+ const stat = fs3.statSync(root);
721
843
  if (!stat.isDirectory()) {
722
844
  throw new Error(`ctxloom init: ${root} is not a directory`);
723
845
  }
724
846
  const warnings = [];
725
- if (!fs2.existsSync(path2.join(root, ".git"))) {
847
+ if (!fs3.existsSync(path3.join(root, ".git"))) {
726
848
  warnings.push(
727
849
  "No .git directory found here. ctxloom init still works, but most graph features (git coupling, risk overlay, churn) require git history."
728
850
  );
@@ -739,14 +861,14 @@ function buildCtxloomEntry(projectRoot) {
739
861
  };
740
862
  }
741
863
  function writeMcpJson(projectRoot) {
742
- const mcpPath = path2.join(projectRoot, ".mcp.json");
864
+ const mcpPath = path3.join(projectRoot, ".mcp.json");
743
865
  const entry = buildCtxloomEntry(projectRoot);
744
- if (!fs2.existsSync(mcpPath)) {
866
+ if (!fs3.existsSync(mcpPath)) {
745
867
  const payload = { mcpServers: { ctxloom: entry } };
746
- fs2.writeFileSync(mcpPath, JSON.stringify(payload, null, 2) + "\n", "utf-8");
868
+ fs3.writeFileSync(mcpPath, JSON.stringify(payload, null, 2) + "\n", "utf-8");
747
869
  return { path: mcpPath, created: true, merged: false, alreadyCorrect: false };
748
870
  }
749
- const raw = fs2.readFileSync(mcpPath, "utf-8");
871
+ const raw = fs3.readFileSync(mcpPath, "utf-8");
750
872
  let parsed2;
751
873
  try {
752
874
  parsed2 = JSON.parse(raw);
@@ -765,18 +887,18 @@ function writeMcpJson(projectRoot) {
765
887
  return { path: mcpPath, created: false, merged: false, alreadyCorrect: true };
766
888
  }
767
889
  servers["ctxloom"] = entry;
768
- fs2.writeFileSync(mcpPath, JSON.stringify(parsed2, null, 2) + "\n", "utf-8");
890
+ fs3.writeFileSync(mcpPath, JSON.stringify(parsed2, null, 2) + "\n", "utf-8");
769
891
  return { path: mcpPath, created: false, merged: true, alreadyCorrect: false };
770
892
  }
771
893
  var GITIGNORE_BANNER = "# ctxloom local index (machine-specific, do not commit)";
772
894
  var GITIGNORE_PATTERN = ".ctxloom/";
773
895
  function appendGitignore(projectRoot) {
774
- const gitignorePath = path2.join(projectRoot, ".gitignore");
775
- if (!fs2.existsSync(gitignorePath)) {
896
+ const gitignorePath = path3.join(projectRoot, ".gitignore");
897
+ if (!fs3.existsSync(gitignorePath)) {
776
898
  const content = `${GITIGNORE_BANNER}
777
899
  ${GITIGNORE_PATTERN}
778
900
  `;
779
- fs2.writeFileSync(gitignorePath, content, "utf-8");
901
+ fs3.writeFileSync(gitignorePath, content, "utf-8");
780
902
  return {
781
903
  path: gitignorePath,
782
904
  created: true,
@@ -784,7 +906,7 @@ ${GITIGNORE_PATTERN}
784
906
  alreadyPresent: false
785
907
  };
786
908
  }
787
- const raw = fs2.readFileSync(gitignorePath, "utf-8");
909
+ const raw = fs3.readFileSync(gitignorePath, "utf-8");
788
910
  const alreadyPresent = raw.split("\n").some((line) => {
789
911
  const trimmed = line.trim();
790
912
  if (trimmed.startsWith("#") || trimmed.startsWith("!")) return false;
@@ -803,7 +925,7 @@ ${GITIGNORE_PATTERN}
803
925
  ${GITIGNORE_BANNER}
804
926
  ${GITIGNORE_PATTERN}
805
927
  `;
806
- fs2.appendFileSync(gitignorePath, addition, "utf-8");
928
+ fs3.appendFileSync(gitignorePath, addition, "utf-8");
807
929
  return {
808
930
  path: gitignorePath,
809
931
  created: false,
@@ -883,7 +1005,7 @@ ${body}
883
1005
  import { execSync } from "child_process";
884
1006
  import * as readline from "readline";
885
1007
  import os from "os";
886
- import path3 from "path";
1008
+ import path4 from "path";
887
1009
  try {
888
1010
  const proc = process;
889
1011
  if (typeof proc.getrlimit === "function" && typeof proc.setrlimit === "function") {
@@ -894,7 +1016,7 @@ try {
894
1016
  } catch {
895
1017
  }
896
1018
  var args = process.argv.slice(2);
897
- var ctxloomVersion = "1.2.0".length > 0 ? "1.2.0" : "dev";
1019
+ var ctxloomVersion = "1.2.2".length > 0 ? "1.2.2" : "dev";
898
1020
  if (args.includes("--version") || args.includes("-v")) {
899
1021
  process.stdout.write(`ctxloom ${ctxloomVersion}
900
1022
  `);
@@ -967,7 +1089,7 @@ async function checkLicense() {
967
1089
  if (command !== void 0 && LICENSE_GATE_BYPASS_COMMANDS.has(command)) return;
968
1090
  const ciKey = process.env["CTXLOOM_LICENSE_KEY"];
969
1091
  if (ciKey) {
970
- const { ApiClient } = await import("./src-CNHVHDBT.js");
1092
+ const { ApiClient } = await import("./src-UOVM4664.js");
971
1093
  const client = new ApiClient(process.env["CTXLOOM_API_BASE"]);
972
1094
  try {
973
1095
  const result = await client.validate(ciKey, "ci-ephemeral");
@@ -1280,6 +1402,36 @@ async function main() {
1280
1402
  await runSetupWizard();
1281
1403
  break;
1282
1404
  }
1405
+ case "install-pr-bot": {
1406
+ const force = hasFlag("--force") || hasFlag("-f");
1407
+ const ref = getFlagValue("--ref") ?? "v1";
1408
+ const result = installPrBotWorkflow({ force, ref });
1409
+ if (result.status === "aborted-not-git") {
1410
+ process.stdout.write(error(result.reason));
1411
+ process.exit(1);
1412
+ }
1413
+ if (result.status === "skipped-exists") {
1414
+ process.stdout.write(
1415
+ warn(
1416
+ `Workflow already present at ${result.path}. Pass --force to overwrite.`
1417
+ )
1418
+ );
1419
+ break;
1420
+ }
1421
+ process.stdout.write(success(`Created ${result.path}`));
1422
+ process.stdout.write(` ${style.dim(`Default branch: ${result.defaultBranch}`)}
1423
+ `);
1424
+ process.stdout.write(` ${style.dim(`Pinned to: kodiii/ctxloom/apps/pr-bot@${ref}`)}
1425
+
1426
+ `);
1427
+ process.stdout.write(
1428
+ nextStep(
1429
+ "Commit and push the workflow",
1430
+ 'git add .github/workflows/ctxloom-review.yml && git commit -m "ci: enable ctxloom pr-bot" && git push'
1431
+ )
1432
+ );
1433
+ break;
1434
+ }
1283
1435
  case "init": {
1284
1436
  process.stdout.write(header("Init"));
1285
1437
  const initRoot = process.cwd();
@@ -1327,7 +1479,7 @@ async function main() {
1327
1479
  registerArgs.splice(aliasIdx, 2);
1328
1480
  }
1329
1481
  const repoPath = registerArgs[0] ?? ".";
1330
- const absPath = path3.resolve(repoPath);
1482
+ const absPath = path4.resolve(repoPath);
1331
1483
  try {
1332
1484
  const stat = await import("fs").then((m) => m.statSync(absPath));
1333
1485
  if (!stat.isDirectory()) {
@@ -1339,15 +1491,15 @@ async function main() {
1339
1491
  process.exit(1);
1340
1492
  }
1341
1493
  if (alias !== void 0) {
1342
- const { validateAlias } = await import("./src-CNHVHDBT.js");
1494
+ const { validateAlias } = await import("./src-UOVM4664.js");
1343
1495
  const v = validateAlias(alias);
1344
1496
  if (!v.ok) {
1345
1497
  console.error(`[ctxloom] Invalid alias: ${v.reason}`);
1346
1498
  process.exit(1);
1347
1499
  }
1348
1500
  }
1349
- const dbPath = path3.join(absPath, ".ctxloom", "vectors.lancedb");
1350
- const registryPath = path3.join(os.homedir(), ".ctxloom", "repos.json");
1501
+ const dbPath = path4.join(absPath, ".ctxloom", "vectors.lancedb");
1502
+ const registryPath = path4.join(os.homedir(), ".ctxloom", "repos.json");
1351
1503
  const reg = new RepoRegistry(registryPath);
1352
1504
  try {
1353
1505
  reg.register(absPath, dbPath, alias !== void 0 ? { alias } : {});
@@ -1367,7 +1519,7 @@ async function main() {
1367
1519
  break;
1368
1520
  }
1369
1521
  case "repos": {
1370
- const registryPath = path3.join(os.homedir(), ".ctxloom", "repos.json");
1522
+ const registryPath = path4.join(os.homedir(), ".ctxloom", "repos.json");
1371
1523
  const reg = new RepoRegistry(registryPath);
1372
1524
  const repos = reg.list();
1373
1525
  if (repos.length === 0) {
@@ -1424,7 +1576,7 @@ async function main() {
1424
1576
  }
1425
1577
  case "review-suggest": {
1426
1578
  const root = process.cwd();
1427
- const ctxloomDir = path3.join(root, ".ctxloom");
1579
+ const ctxloomDir = path4.join(root, ".ctxloom");
1428
1580
  const max = parseInt(getFlagValue("--max=") ?? "3", 10);
1429
1581
  if (isNaN(max) || max <= 0) {
1430
1582
  console.error("[ctxloom] --max must be a positive integer.");
@@ -1458,7 +1610,7 @@ async function main() {
1458
1610
  const allFiles = store.ownership.allNodes();
1459
1611
  const ruleMap = /* @__PURE__ */ new Map();
1460
1612
  for (const file of allFiles) {
1461
- const dir = path3.dirname(file);
1613
+ const dir = path4.dirname(file);
1462
1614
  const stats = store.ownership.statsFor(file);
1463
1615
  if (!stats) continue;
1464
1616
  const topOwners = stats.owners.filter((o) => o.share >= minShare).slice(0, 2);
@@ -1472,7 +1624,7 @@ async function main() {
1472
1624
  }
1473
1625
  }
1474
1626
  const rules = Array.from(ruleMap.entries()).map(([pattern, handles]) => ({ pattern, handles: Array.from(handles) })).sort((a, b) => a.pattern.localeCompare(b.pattern));
1475
- const codeownersPath = path3.join(root, ".github", "CODEOWNERS");
1627
+ const codeownersPath = path4.join(root, ".github", "CODEOWNERS");
1476
1628
  const content = await generateCODEOWNERS(codeownersPath, rules);
1477
1629
  if (writeFlag) {
1478
1630
  await writeCODEOWNERS(codeownersPath, content);
@@ -1528,7 +1680,7 @@ Suggested reviewers for ${files.length} file(s):`);
1528
1680
  }
1529
1681
  case "authors-sync": {
1530
1682
  const root = process.cwd();
1531
- const ctxloomDir = path3.join(root, ".ctxloom");
1683
+ const ctxloomDir = path4.join(root, ".ctxloom");
1532
1684
  const token = process.env.GITHUB_TOKEN;
1533
1685
  if (!token) {
1534
1686
  console.error("[ctxloom] GITHUB_TOKEN env var required for authors-sync.");
@@ -1583,7 +1735,7 @@ Suggested reviewers for ${files.length} file(s):`);
1583
1735
  process.stderr.write("[ctxloom] --limit must be a non-negative integer (0 for unlimited)\n");
1584
1736
  process.exit(2);
1585
1737
  }
1586
- const { loadRulesConfig, RulesChecker, formatText, formatJson, RulesConfigError } = await import("./src-CNHVHDBT.js");
1738
+ const { loadRulesConfig, RulesChecker, formatText, formatJson, RulesConfigError } = await import("./src-UOVM4664.js");
1587
1739
  let config;
1588
1740
  try {
1589
1741
  config = await loadRulesConfig(root);
@@ -1607,7 +1759,7 @@ Suggested reviewers for ${files.length} file(s):`);
1607
1759
  }
1608
1760
  let graph;
1609
1761
  if (useSnapshot) {
1610
- const { DependencyGraph: DG } = await import("./src-CNHVHDBT.js");
1762
+ const { DependencyGraph: DG } = await import("./src-UOVM4664.js");
1611
1763
  graph = new DG();
1612
1764
  const loaded = await graph.loadSnapshotOnly(root);
1613
1765
  if (!loaded) {
@@ -1616,7 +1768,7 @@ Suggested reviewers for ${files.length} file(s):`);
1616
1768
  }
1617
1769
  } else {
1618
1770
  process.stderr.write("[ctxloom] Building dependency graph...\n");
1619
- const { ASTParser: ASTParser2, DependencyGraph: DependencyGraph2 } = await import("./src-CNHVHDBT.js");
1771
+ const { ASTParser: ASTParser2, DependencyGraph: DependencyGraph2 } = await import("./src-UOVM4664.js");
1620
1772
  let parser;
1621
1773
  try {
1622
1774
  parser = new ASTParser2();
@@ -1659,6 +1811,8 @@ Usage:
1659
1811
  ctxloom init Scaffold .mcp.json + .gitignore for this project
1660
1812
  ctxloom index Index the current directory and build dependency graph
1661
1813
  ctxloom setup Detect and configure MCP-compatible AI tools (global)
1814
+ ctxloom install-pr-bot Drop .github/workflows/ctxloom-review.yml into this repo
1815
+ (use --force to overwrite, --ref <tag> to pin a version)
1662
1816
  ctxloom grammars Show grammar cache status
1663
1817
  ctxloom grammars --download Pre-download all language grammars
1664
1818
  ctxloom register [path] Register a repo for cross-repo search (defaults to cwd)
@@ -101,16 +101,16 @@ import {
101
101
  validateDefaultRoot,
102
102
  wrapWithIndexingEnvelope,
103
103
  writeCODEOWNERS
104
- } from "./chunk-4B2S3WJ5.js";
104
+ } from "./chunk-GLBKLUJ4.js";
105
105
  import {
106
106
  VectorStore
107
- } from "./chunk-NEHYSE2Y.js";
107
+ } from "./chunk-DVI2RWJR.js";
108
108
  import {
109
109
  EMBEDDING_DIMENSION,
110
110
  collectFiles,
111
111
  generateEmbedding,
112
112
  indexDirectory
113
- } from "./chunk-VR6PNQYH.js";
113
+ } from "./chunk-NMXQC5CG.js";
114
114
  import {
115
115
  logger
116
116
  } from "./chunk-TYDMSHV7.js";
@@ -224,4 +224,4 @@ export {
224
224
  wrapWithIndexingEnvelope,
225
225
  writeCODEOWNERS
226
226
  };
227
- //# sourceMappingURL=src-CNHVHDBT.js.map
227
+ //# sourceMappingURL=src-UOVM4664.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  VectorStore
3
- } from "../chunk-NEHYSE2Y.js";
3
+ } from "../chunk-DVI2RWJR.js";
4
4
  import {
5
5
  generateEmbedding
6
- } from "../chunk-VR6PNQYH.js";
6
+ } from "../chunk-NMXQC5CG.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.2.0",
3
+ "version": "1.2.2",
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",