@iderouter/index-mcp 0.2.0-beta.4 → 0.2.0-beta.5

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 +63 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iderouter/index-mcp",
3
- "version": "0.2.0-beta.4",
3
+ "version": "0.2.0-beta.5",
4
4
  "description": "Hybrid local code index MCP powered by IDERouter embeddings.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -6994,8 +6994,64 @@ function summarizeRepoTechStackFromContext(contextProbe, fallbackStack) {
6994
6994
  return [...merged];
6995
6995
  }
6996
6996
 
6997
- function summarizeEntrypoints(results, limit = 5) {
6997
+ function repoSummarySkeletonPaths(index) {
6998
+ const availableFiles = new Set(
6999
+ Array.isArray(index?.files)
7000
+ ? index.files.map((file) => String(file?.relativePath || ""))
7001
+ : Array.isArray(index?.chunks)
7002
+ ? index.chunks.map((chunk) => String(chunk?.relativePath || ""))
7003
+ : [],
7004
+ );
7005
+ const preferred = [
7006
+ "main.go",
7007
+ "router/main.go",
7008
+ "router/api-router.go",
7009
+ "router/web-router.go",
7010
+ "controller/relay.go",
7011
+ "controller/iderouter.go",
7012
+ "service/iderouter_routing.go",
7013
+ "service/channel_select.go",
7014
+ "service/iderouter_agent.go",
7015
+ "model/main.go",
7016
+ "model/channel.go",
7017
+ "relay/compatible_handler.go",
7018
+ "relay/common/relay_info.go",
7019
+ "setting/iderouter_setting/agent.go",
7020
+ "web/default/src/main.tsx",
7021
+ ];
7022
+ return preferred.filter((relativePath) => availableFiles.has(relativePath));
7023
+ }
7024
+
7025
+ function summaryChunkScore(chunk) {
7026
+ const content = String(chunk?.content || "");
7027
+ let score = 0;
7028
+ if (chunk?.granularity !== "coarse") score += 3;
7029
+ if (/\bfunc\s+[A-Za-z0-9_]+/.test(content)) score += 5;
7030
+ if (/\btype\s+[A-Za-z0-9_]+/.test(content)) score += 3;
7031
+ if (/\bpackage\s+[A-Za-z0-9_]+/.test(content)) score += 1;
7032
+ if (/createRoot|ReactDOM|Gin|router|Handle|RunExpr|RelayInfo|Select/.test(content)) score += 2;
7033
+ return score;
7034
+ }
7035
+
7036
+ function selectSummaryChunkForFile(index, relativePath) {
7037
+ const chunks = Array.isArray(index?.chunks)
7038
+ ? index.chunks.filter((chunk) => String(chunk.relativePath || "") === relativePath)
7039
+ : [];
7040
+ if (chunks.length === 0) return null;
7041
+ return chunks
7042
+ .slice()
7043
+ .sort((left, right) => summaryChunkScore(right) - summaryChunkScore(left) || Number(left.startLine || 0) - Number(right.startLine || 0))[0];
7044
+ }
7045
+
7046
+ function summarizeEntrypoints(index, results, limit = 5) {
6998
7047
  const preferredRoleOrder = ["controller", "router", "service", "relay", "model", "pkg", "frontend", "core"];
7048
+ const byPath = new Map((results || []).map((result) => [String(result.relativePath || ""), result]));
7049
+ const skeleton = [];
7050
+ for (const relativePath of repoSummarySkeletonPaths(index)) {
7051
+ const item = byPath.get(relativePath) || selectSummaryChunkForFile(index, relativePath);
7052
+ if (item) skeleton.push(item);
7053
+ if (skeleton.length >= limit) return skeleton.slice(0, limit);
7054
+ }
6999
7055
  const bestByRole = new Map();
7000
7056
  for (const result of results || []) {
7001
7057
  const role = pathRole(result.relativePath);
@@ -7006,8 +7062,13 @@ function summarizeEntrypoints(results, limit = 5) {
7006
7062
  }
7007
7063
  }
7008
7064
  const ordered = [];
7065
+ const seenFile = new Set(skeleton.map((item) => item.relativePath));
7066
+ for (const item of skeleton) {
7067
+ ordered.push(item);
7068
+ }
7009
7069
  for (const role of preferredRoleOrder) {
7010
7070
  const item = bestByRole.get(role);
7071
+ if (item && seenFile.has(item.relativePath)) continue;
7011
7072
  if (item) ordered.push(item);
7012
7073
  if (ordered.length >= limit) break;
7013
7074
  }
@@ -7029,7 +7090,7 @@ function repoSummaryLines(codebasePath, state, contextProbe) {
7029
7090
  const topResults = results.slice(0, 8);
7030
7091
  const domains = summarizeRepoDomains(topResults);
7031
7092
  const stack = summarizeRepoTechStackFromContext(contextProbe, summarizeRepoTechStack(topResults));
7032
- const entrypoints = summarizeEntrypoints(topResults, 5);
7093
+ const entrypoints = summarizeEntrypoints(state?.index, topResults, 5);
7033
7094
  const lines = [
7034
7095
  `Fast repository summary for ${codebasePath}:`,
7035
7096
  "",