@iderouter/index-mcp 0.2.0-beta.1 → 0.2.0-beta.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +35 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iderouter/index-mcp",
3
- "version": "0.2.0-beta.1",
3
+ "version": "0.2.0-beta.2",
4
4
  "description": "Hybrid local code index MCP powered by IDERouter embeddings.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -1063,6 +1063,7 @@ function buildIndexMetaPayload(fullIndex) {
1063
1063
  updatedAt: fullIndex.updatedAt,
1064
1064
  embeddingModel: fullIndex.embeddingModel,
1065
1065
  embeddingModelsUsed: fullIndex.embeddingModelsUsed,
1066
+ strategySource: fullIndex.strategySource || "",
1066
1067
  complete: fullIndex.complete,
1067
1068
  indexStage: fullIndex.indexStage,
1068
1069
  coarseReady: fullIndex.coarseReady,
@@ -3262,6 +3263,7 @@ async function saveIndex(codebasePath, files, chunks, options = {}) {
3262
3263
  .filter((chunk) => chunk.granularity !== "coarse" && Array.isArray(chunk.vector) && chunk.vector.length > 0)
3263
3264
  .map((chunk) => chunkVectorModel(chunk, options.embeddingModel || DEFAULT_EMBEDDING_MODEL)),
3264
3265
  ),
3266
+ strategySource: options.strategySource || lastStrategySource || "local_fallback",
3265
3267
  complete: options.complete !== false,
3266
3268
  indexStage: options.indexStage || (options.complete === false ? "fine_partial" : "fine"),
3267
3269
  coarseReady: Boolean(options.coarseReady),
@@ -3638,6 +3640,16 @@ function formatIndexDiagnostics(diagnostics) {
3638
3640
  ].join(", ");
3639
3641
  }
3640
3642
 
3643
+ function effectiveStrategySource(...sources) {
3644
+ for (const source of sources) {
3645
+ const value = String(source || "").trim();
3646
+ if (!value) continue;
3647
+ if (value === "local_fallback") continue;
3648
+ return value;
3649
+ }
3650
+ return "local_fallback";
3651
+ }
3652
+
3641
3653
  async function indexCodebase(args, precomputedFiles) {
3642
3654
  const codebasePath = normalizePath(args.path);
3643
3655
  const job = args.__jobId ? indexJobs.get(args.__jobId) : null;
@@ -6324,7 +6336,11 @@ async function exactAnchorSearch(codebasePath, args, indexedKeys) {
6324
6336
  ? args.extensionFilter.map((ext) => (ext.startsWith(".") ? ext : `.${ext}`))
6325
6337
  : [],
6326
6338
  );
6327
- const files = await collectFiles(codebasePath, args.customExtensions, args.ignorePatterns);
6339
+ const existingIndex = args.__searchIndex || null;
6340
+ const prepared = existingIndex
6341
+ ? await prepareFilesFast(codebasePath, existingIndex, args.customExtensions, args.ignorePatterns)
6342
+ : null;
6343
+ const files = prepared?.files || await collectFiles(codebasePath, args.customExtensions, args.ignorePatterns);
6328
6344
  const prioritizedFiles = files
6329
6345
  .map((file) => ({
6330
6346
  file,
@@ -6718,7 +6734,10 @@ async function collectSearchState(codebasePath, args, query, limit) {
6718
6734
  const index = refresh.index;
6719
6735
  const indexEmbeddingModel = index.embeddingModel || DEFAULT_EMBEDDING_MODEL;
6720
6736
  const anchorVariants = anchorIdentifierVariants(query);
6721
- const skipQueryEmbedding = usingPartialIndex && anchorVariants.length > 0;
6737
+ const activeJobRunning = isActiveJobStatus(job?.status);
6738
+ const skipQueryEmbedding =
6739
+ (usingPartialIndex && anchorVariants.length > 0) ||
6740
+ ((usingPartialIndex || activeJobRunning) && !isImplementationLocatorQuery(query) && !isRemoveDisabledFieldsQuery(query));
6722
6741
  const queryVectors = new Map();
6723
6742
  const indexedVectorModels = mergeStringSets(
6724
6743
  index.chunks
@@ -6772,7 +6791,7 @@ async function collectSearchState(codebasePath, args, query, limit) {
6772
6791
  .filter((chunk) => chunk.score > 0 && querySpecificChunkAllowed(query, chunk));
6773
6792
 
6774
6793
  const indexedKeys = new Set(indexedResults.map((chunk) => `${chunk.relativePath}:${chunk.startLine}:${chunk.endLine}`));
6775
- const anchorResults = (await exactAnchorSearch(codebasePath, args, indexedKeys))
6794
+ const anchorResults = (await exactAnchorSearch(codebasePath, { ...args, __searchIndex: index }, indexedKeys))
6776
6795
  .filter((chunk) => querySpecificChunkAllowed(query, chunk));
6777
6796
  let results = await expandResultSnippetsToBoundaries(codebasePath, query, diversifyResults(
6778
6797
  query,
@@ -7601,6 +7620,19 @@ async function getIndexingStatus(args) {
7601
7620
  job = await ensureDeferredCloudState(codebasePath, currentIndex, job, args);
7602
7621
  const resumed = await maybeResumeOrphanedIndexJob(codebasePath, args, currentIndex, job);
7603
7622
  if (resumed?.job) job = resumed.job;
7623
+ const resolvedStrategySource = effectiveStrategySource(
7624
+ lastStrategySource,
7625
+ currentIndex?.strategySource,
7626
+ job?.strategySource,
7627
+ currentIndex?.diagnostics?.strategySource,
7628
+ job?.diagnostics?.strategySource,
7629
+ );
7630
+ if (job?.diagnostics) {
7631
+ job.diagnostics = {
7632
+ ...job.diagnostics,
7633
+ strategySource: effectiveStrategySource(job.diagnostics.strategySource, resolvedStrategySource),
7634
+ };
7635
+ }
7604
7636
  const cloudSuffix = cloudStatusSuffix(job);
7605
7637
  const diagnosticsSuffix = job?.diagnostics ? ` Diagnostics: ${formatIndexDiagnostics(job.diagnostics)}.` : "";
7606
7638
  const readinessSuffix = job ? ` Readiness: ${summarizeReadiness(job)}.` : "";