@ctxo/cli 0.7.0-alpha.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -10,13 +10,14 @@ import {
10
10
  SymbolGraph,
11
11
  createLogger,
12
12
  detectWorkspace,
13
- loadCoChangeMap
14
- } from "./chunk-O3L56NY6.js";
13
+ loadCoChangeMap,
14
+ loadConfig,
15
+ statsEnabled
16
+ } from "./chunk-4M4V5V36.js";
15
17
  import {
16
18
  DetailLevelSchema,
17
19
  JsonIndexReader
18
- } from "./chunk-I4TUA7CD.js";
19
- import "./chunk-7OCVIDC7.js";
20
+ } from "./chunk-WXA2JJLH.js";
20
21
 
21
22
  // src/index.ts
22
23
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -642,6 +643,7 @@ function handleGetChangeIntelligence(storage, git, masking, staleness, ctxoRoot
642
643
  const indices = indexReader.readAll();
643
644
  const fileIndex = indices.find((i) => i.file === filePath);
644
645
  const complexityEntries = fileIndex?.complexity ?? [];
646
+ const indexMissingWarning = !fileIndex ? `JSON index for ${filePath} not found on disk \u2014 complexity falls back to 0. Run "ctxo index" to resync.` : void 0;
645
647
  let cyclomatic = complexityEntries.find((c) => c.symbolId === symbolId)?.cyclomatic;
646
648
  if (cyclomatic === void 0) {
647
649
  const symbolName = symbolId.split("::")[1] ?? "";
@@ -658,6 +660,9 @@ function handleGetChangeIntelligence(storage, git, masking, staleness, ctxoRoot
658
660
  const warning = staleness.check(storage.listIndexedFiles());
659
661
  if (warning) content.push({ type: "text", text: `\u26A0\uFE0F ${warning.message}` });
660
662
  }
663
+ if (indexMissingWarning) {
664
+ content.push({ type: "text", text: `\u26A0\uFE0F ${indexMissingWarning}` });
665
+ }
661
666
  content.push({ type: "text", text: payload });
662
667
  return { content };
663
668
  } catch (err) {
@@ -712,7 +717,6 @@ var BlastRadiusCalculator = class {
712
717
  }
713
718
  for (const [nodeId, info] of bestByNode) {
714
719
  visited.add(nodeId);
715
- if (!graph.hasNode(nodeId)) continue;
716
720
  const depth = current.depth + 1;
717
721
  const riskScore = 1 / Math.pow(depth, 0.7);
718
722
  let confidence = info.confidence;
@@ -955,7 +959,7 @@ var ContextAssembler = class {
955
959
  }
956
960
  }
957
961
  for (const entry of blastResult.impactedSymbols) {
958
- const node = graph.getNode(entry.symbolId);
962
+ const node = graph.getNode(entry.symbolId) ?? synthesizeNodeFromId(entry.symbolId);
959
963
  if (!node) continue;
960
964
  const existing = candidateMap.get(entry.symbolId);
961
965
  if (existing) {
@@ -1088,6 +1092,22 @@ var ContextAssembler = class {
1088
1092
  return (node.endLine - node.startLine + 1) * 10;
1089
1093
  }
1090
1094
  };
1095
+ var VALID_SYMBOL_KINDS = /* @__PURE__ */ new Set([
1096
+ "function",
1097
+ "class",
1098
+ "interface",
1099
+ "method",
1100
+ "variable",
1101
+ "type"
1102
+ ]);
1103
+ function synthesizeNodeFromId(symbolId) {
1104
+ const parts = symbolId.split("::");
1105
+ if (parts.length !== 3) return void 0;
1106
+ const [file, name, kindRaw] = parts;
1107
+ if (!file || !name || !kindRaw) return void 0;
1108
+ const kind = VALID_SYMBOL_KINDS.has(kindRaw) ? kindRaw : "variable";
1109
+ return { symbolId, name, kind, startLine: 0, endLine: 0 };
1110
+ }
1091
1111
 
1092
1112
  // src/adapters/mcp/get-context-for-task.ts
1093
1113
  var TaskTypeSchema = z7.enum(["fix", "extend", "refactor", "understand"]);
@@ -2459,16 +2479,7 @@ function loadMaskingConfig(ctxoRoot) {
2459
2479
  return new MaskingPipeline();
2460
2480
  }
2461
2481
  function readStatsEnabled(ctxoRoot) {
2462
- const configPath = join2(ctxoRoot, "config.yaml");
2463
- if (!existsSync2(configPath)) return true;
2464
- try {
2465
- const raw = readFileSync2(configPath, "utf-8");
2466
- const match = raw.match(/stats:\s*\n\s*enabled:\s*(true|false)/);
2467
- if (match) return match[1] !== "false";
2468
- return true;
2469
- } catch {
2470
- return true;
2471
- }
2482
+ return statsEnabled(loadConfig(ctxoRoot).config);
2472
2483
  }
2473
2484
  var PKG_VERSION = (() => {
2474
2485
  try {
@@ -2484,7 +2495,7 @@ async function main() {
2484
2495
  const args = process.argv.slice(2);
2485
2496
  const httpPortStr = process.env.CTXO_HTTP_PORT || (args.includes("--http") ? args[args.indexOf("--port") + 1] || "3001" : null);
2486
2497
  if (!httpPortStr && args.length > 0) {
2487
- const { CliRouter } = await import("./cli-router-RA4EBMVV.js");
2498
+ const { CliRouter } = await import("./cli-router-T3VZZJD6.js");
2488
2499
  const router = new CliRouter(process.cwd());
2489
2500
  await router.route(args);
2490
2501
  return;
@@ -2498,7 +2509,7 @@ async function main() {
2498
2509
  const git = new SimpleGitAdapter(process.cwd());
2499
2510
  const recorder = readStatsEnabled(ctxoRoot) ? new SessionRecorderAdapter(storage.getDb(), () => storage.persist()) : null;
2500
2511
  const server = new McpServer({ name: "ctxo", version: PKG_VERSION });
2501
- const { StalenessDetector } = await import("./staleness-detector-HJH52U5W.js");
2512
+ const { StalenessDetector } = await import("./staleness-detector-4HJYBQ7Z.js");
2502
2513
  const staleness = new StalenessDetector(process.cwd(), ctxoRoot);
2503
2514
  registerTools(server, storage, masking, git, staleness, recorder, ctxoRoot);
2504
2515
  if (httpPortStr) {