@iderouter/index-mcp 0.2.0-beta.3 → 0.2.0-beta.4
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/package.json +1 -1
- package/src/index.js +51 -4
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -366,12 +366,13 @@ function contextProbeCacheKey(codebasePath) {
|
|
|
366
366
|
return `context:${codebasePath}`;
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
-
function summarizeContextText(text, maxLines =
|
|
369
|
+
function summarizeContextText(text, maxLines = 4) {
|
|
370
370
|
return String(text || "")
|
|
371
371
|
.split("\n")
|
|
372
372
|
.map((line) => line.trim())
|
|
373
373
|
.filter(Boolean)
|
|
374
374
|
.filter((line) => !/^#/.test(line))
|
|
375
|
+
.map((line) => line.replace(/\*\*/g, "").replace(/`/g, ""))
|
|
375
376
|
.slice(0, maxLines)
|
|
376
377
|
.join(" ");
|
|
377
378
|
}
|
|
@@ -6978,11 +6979,57 @@ function summarizeRepoTechStack(results) {
|
|
|
6978
6979
|
return stack;
|
|
6979
6980
|
}
|
|
6980
6981
|
|
|
6982
|
+
function summarizeRepoTechStackFromContext(contextProbe, fallbackStack) {
|
|
6983
|
+
const summary = String(contextProbe?.summary || "").toLowerCase();
|
|
6984
|
+
const merged = new Set(Array.isArray(fallbackStack) ? fallbackStack : []);
|
|
6985
|
+
if (summary.includes("go ")) merged.add("Go backend");
|
|
6986
|
+
if (summary.includes("react") || summary.includes("typescript")) merged.add("TypeScript/React frontend");
|
|
6987
|
+
if (summary.includes("tailwind")) merged.add("Tailwind CSS");
|
|
6988
|
+
if (summary.includes("gin")) merged.add("Gin web framework");
|
|
6989
|
+
if (summary.includes("gorm")) merged.add("GORM");
|
|
6990
|
+
if (summary.includes("redis")) merged.add("Redis");
|
|
6991
|
+
if (summary.includes("sqlite") || summary.includes("mysql") || summary.includes("postgresql")) {
|
|
6992
|
+
merged.add("Multi-database support");
|
|
6993
|
+
}
|
|
6994
|
+
return [...merged];
|
|
6995
|
+
}
|
|
6996
|
+
|
|
6997
|
+
function summarizeEntrypoints(results, limit = 5) {
|
|
6998
|
+
const preferredRoleOrder = ["controller", "router", "service", "relay", "model", "pkg", "frontend", "core"];
|
|
6999
|
+
const bestByRole = new Map();
|
|
7000
|
+
for (const result of results || []) {
|
|
7001
|
+
const role = pathRole(result.relativePath);
|
|
7002
|
+
if (!preferredRoleOrder.includes(role)) continue;
|
|
7003
|
+
const existing = bestByRole.get(role);
|
|
7004
|
+
if (!existing || Number(result.score || 0) > Number(existing.score || 0)) {
|
|
7005
|
+
bestByRole.set(role, result);
|
|
7006
|
+
}
|
|
7007
|
+
}
|
|
7008
|
+
const ordered = [];
|
|
7009
|
+
for (const role of preferredRoleOrder) {
|
|
7010
|
+
const item = bestByRole.get(role);
|
|
7011
|
+
if (item) ordered.push(item);
|
|
7012
|
+
if (ordered.length >= limit) break;
|
|
7013
|
+
}
|
|
7014
|
+
if (ordered.length >= limit) return ordered.slice(0, limit);
|
|
7015
|
+
const seen = new Set(ordered.map((item) => `${item.relativePath}:${item.startLine}:${item.endLine}`));
|
|
7016
|
+
for (const result of results || []) {
|
|
7017
|
+
const key = `${result.relativePath}:${result.startLine}:${result.endLine}`;
|
|
7018
|
+
if (seen.has(key)) continue;
|
|
7019
|
+
if (["docs", "tests", "mcp", "other"].includes(pathRole(result.relativePath))) continue;
|
|
7020
|
+
ordered.push(result);
|
|
7021
|
+
seen.add(key);
|
|
7022
|
+
if (ordered.length >= limit) break;
|
|
7023
|
+
}
|
|
7024
|
+
return ordered;
|
|
7025
|
+
}
|
|
7026
|
+
|
|
6981
7027
|
function repoSummaryLines(codebasePath, state, contextProbe) {
|
|
6982
7028
|
const results = Array.isArray(state?.results) ? state.results : [];
|
|
6983
7029
|
const topResults = results.slice(0, 8);
|
|
6984
7030
|
const domains = summarizeRepoDomains(topResults);
|
|
6985
|
-
const stack = summarizeRepoTechStack(topResults);
|
|
7031
|
+
const stack = summarizeRepoTechStackFromContext(contextProbe, summarizeRepoTechStack(topResults));
|
|
7032
|
+
const entrypoints = summarizeEntrypoints(topResults, 5);
|
|
6986
7033
|
const lines = [
|
|
6987
7034
|
`Fast repository summary for ${codebasePath}:`,
|
|
6988
7035
|
"",
|
|
@@ -7001,10 +7048,10 @@ function repoSummaryLines(codebasePath, state, contextProbe) {
|
|
|
7001
7048
|
lines.push(`- ${path.basename(item.filePath)}: ${item.excerpt || "context file detected"}`);
|
|
7002
7049
|
}
|
|
7003
7050
|
}
|
|
7004
|
-
if (
|
|
7051
|
+
if (entrypoints.length > 0) {
|
|
7005
7052
|
lines.push("");
|
|
7006
7053
|
lines.push("Key entrypoints:");
|
|
7007
|
-
for (const result of
|
|
7054
|
+
for (const result of entrypoints) {
|
|
7008
7055
|
lines.push(`- ${result.relativePath}:${result.startLine}-${result.endLine}`);
|
|
7009
7056
|
}
|
|
7010
7057
|
}
|