opencode-codebase-index 0.9.0 → 0.11.0
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/README.md +4 -2
- package/dist/cli.cjs +78 -28
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +78 -28
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +244 -113
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +244 -113
- package/dist/index.js.map +1 -1
- package/native/codebase-index-native.darwin-arm64.node +0 -0
- package/native/codebase-index-native.darwin-x64.node +0 -0
- package/native/codebase-index-native.linux-arm64-gnu.node +0 -0
- package/native/codebase-index-native.linux-x64-gnu.node +0 -0
- package/native/codebase-index-native.win32-x64-msvc.node +0 -0
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,11 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
10
|
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
-
|
|
11
|
+
try {
|
|
12
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
throw mod = 0, e;
|
|
15
|
+
}
|
|
12
16
|
};
|
|
13
17
|
var __copyProps = (to, from, except, desc) => {
|
|
14
18
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -794,7 +798,8 @@ function getDefaultSearchConfig() {
|
|
|
794
798
|
rrfK: 60,
|
|
795
799
|
rerankTopN: 20,
|
|
796
800
|
contextLines: 0,
|
|
797
|
-
routingHints: true
|
|
801
|
+
routingHints: true,
|
|
802
|
+
routingHintRole: "system"
|
|
798
803
|
};
|
|
799
804
|
}
|
|
800
805
|
function getDefaultRerankerBaseUrl(provider) {
|
|
@@ -915,7 +920,8 @@ function parseConfig(raw) {
|
|
|
915
920
|
rrfK: typeof rawSearch.rrfK === "number" ? Math.max(1, Math.floor(rawSearch.rrfK)) : defaultSearch.rrfK,
|
|
916
921
|
rerankTopN: typeof rawSearch.rerankTopN === "number" ? Math.min(200, Math.max(0, Math.floor(rawSearch.rerankTopN))) : defaultSearch.rerankTopN,
|
|
917
922
|
contextLines: typeof rawSearch.contextLines === "number" ? Math.min(50, Math.max(0, rawSearch.contextLines)) : defaultSearch.contextLines,
|
|
918
|
-
routingHints: typeof rawSearch.routingHints === "boolean" ? rawSearch.routingHints : defaultSearch.routingHints
|
|
923
|
+
routingHints: typeof rawSearch.routingHints === "boolean" ? rawSearch.routingHints : defaultSearch.routingHints,
|
|
924
|
+
routingHintRole: rawSearch.routingHintRole === "developer" || rawSearch.routingHintRole === "system" ? rawSearch.routingHintRole : defaultSearch.routingHintRole
|
|
919
925
|
};
|
|
920
926
|
const rawDebug = input.debug && typeof input.debug === "object" ? input.debug : {};
|
|
921
927
|
const debug = {
|
|
@@ -2497,6 +2503,8 @@ var BaseEmbeddingProvider = class {
|
|
|
2497
2503
|
this.credentials = credentials;
|
|
2498
2504
|
this.modelInfo = modelInfo;
|
|
2499
2505
|
}
|
|
2506
|
+
credentials;
|
|
2507
|
+
modelInfo;
|
|
2500
2508
|
async embedQuery(query) {
|
|
2501
2509
|
const result = await this.embedBatch([query]);
|
|
2502
2510
|
return {
|
|
@@ -4236,17 +4244,17 @@ var Database = class {
|
|
|
4236
4244
|
if (edges.length === 0) return;
|
|
4237
4245
|
this.inner.upsertCallEdgesBatch(edges);
|
|
4238
4246
|
}
|
|
4239
|
-
getCallers(targetName, branch) {
|
|
4247
|
+
getCallers(targetName, branch, callTypeFilter) {
|
|
4240
4248
|
this.throwIfClosed();
|
|
4241
|
-
return this.inner.getCallers(targetName, branch);
|
|
4249
|
+
return this.inner.getCallers(targetName, branch, callTypeFilter ?? null);
|
|
4242
4250
|
}
|
|
4243
|
-
getCallersWithContext(targetName, branch) {
|
|
4251
|
+
getCallersWithContext(targetName, branch, callTypeFilter) {
|
|
4244
4252
|
this.throwIfClosed();
|
|
4245
|
-
return this.inner.getCallersWithContext(targetName, branch);
|
|
4253
|
+
return this.inner.getCallersWithContext(targetName, branch, callTypeFilter ?? null);
|
|
4246
4254
|
}
|
|
4247
|
-
getCallees(symbolId, branch) {
|
|
4255
|
+
getCallees(symbolId, branch, callTypeFilter) {
|
|
4248
4256
|
this.throwIfClosed();
|
|
4249
|
-
return this.inner.getCallees(symbolId, branch);
|
|
4257
|
+
return this.inner.getCallees(symbolId, branch, callTypeFilter ?? null);
|
|
4250
4258
|
}
|
|
4251
4259
|
deleteCallEdgesByFile(filePath) {
|
|
4252
4260
|
this.throwIfClosed();
|
|
@@ -4256,6 +4264,10 @@ var Database = class {
|
|
|
4256
4264
|
this.throwIfClosed();
|
|
4257
4265
|
this.inner.resolveCallEdge(edgeId, toSymbolId);
|
|
4258
4266
|
}
|
|
4267
|
+
findShortestPath(fromName, toName, branch, maxDepth) {
|
|
4268
|
+
this.throwIfClosed();
|
|
4269
|
+
return this.inner.findShortestPath(fromName, toName, branch, maxDepth ?? null);
|
|
4270
|
+
}
|
|
4259
4271
|
addSymbolsToBranch(branch, symbolIds) {
|
|
4260
4272
|
this.throwIfClosed();
|
|
4261
4273
|
this.inner.addSymbolsToBranch(branch, symbolIds);
|
|
@@ -7054,6 +7066,7 @@ var Indexer = class {
|
|
|
7054
7066
|
targetName: site.calleeName,
|
|
7055
7067
|
toSymbolId: void 0,
|
|
7056
7068
|
callType: site.callType,
|
|
7069
|
+
confidence: site.confidence,
|
|
7057
7070
|
line: site.line,
|
|
7058
7071
|
col: site.column,
|
|
7059
7072
|
isResolved: false
|
|
@@ -8173,12 +8186,12 @@ var Indexer = class {
|
|
|
8173
8186
|
})
|
|
8174
8187
|
);
|
|
8175
8188
|
}
|
|
8176
|
-
async getCallers(targetName) {
|
|
8189
|
+
async getCallers(targetName, callTypeFilter) {
|
|
8177
8190
|
const { database } = await this.ensureInitialized();
|
|
8178
8191
|
const seen = /* @__PURE__ */ new Set();
|
|
8179
8192
|
const results = [];
|
|
8180
8193
|
for (const branchKey of this.getBranchCatalogKeys()) {
|
|
8181
|
-
for (const edge of database.getCallersWithContext(targetName, branchKey)) {
|
|
8194
|
+
for (const edge of database.getCallersWithContext(targetName, branchKey, callTypeFilter)) {
|
|
8182
8195
|
if (!seen.has(edge.id)) {
|
|
8183
8196
|
seen.add(edge.id);
|
|
8184
8197
|
results.push(edge);
|
|
@@ -8187,12 +8200,12 @@ var Indexer = class {
|
|
|
8187
8200
|
}
|
|
8188
8201
|
return results;
|
|
8189
8202
|
}
|
|
8190
|
-
async getCallees(symbolId) {
|
|
8203
|
+
async getCallees(symbolId, callTypeFilter) {
|
|
8191
8204
|
const { database } = await this.ensureInitialized();
|
|
8192
8205
|
const seen = /* @__PURE__ */ new Set();
|
|
8193
8206
|
const results = [];
|
|
8194
8207
|
for (const branchKey of this.getBranchCatalogKeys()) {
|
|
8195
|
-
for (const edge of database.getCallees(symbolId, branchKey)) {
|
|
8208
|
+
for (const edge of database.getCallees(symbolId, branchKey, callTypeFilter)) {
|
|
8196
8209
|
if (!seen.has(edge.id)) {
|
|
8197
8210
|
seen.add(edge.id);
|
|
8198
8211
|
results.push(edge);
|
|
@@ -8201,6 +8214,17 @@ var Indexer = class {
|
|
|
8201
8214
|
}
|
|
8202
8215
|
return results;
|
|
8203
8216
|
}
|
|
8217
|
+
async findCallPath(fromName, toName, maxDepth) {
|
|
8218
|
+
const { database } = await this.ensureInitialized();
|
|
8219
|
+
let shortest = [];
|
|
8220
|
+
for (const branchKey of this.getBranchCatalogKeys()) {
|
|
8221
|
+
const path18 = database.findShortestPath(fromName, toName, branchKey, maxDepth);
|
|
8222
|
+
if (path18.length > 0 && (shortest.length === 0 || path18.length < shortest.length)) {
|
|
8223
|
+
shortest = path18;
|
|
8224
|
+
}
|
|
8225
|
+
}
|
|
8226
|
+
return shortest;
|
|
8227
|
+
}
|
|
8204
8228
|
async close() {
|
|
8205
8229
|
await this.database?.close();
|
|
8206
8230
|
this.database = null;
|
|
@@ -9976,11 +10000,12 @@ ${formatted.join("\n\n")}` }] };
|
|
|
9976
10000
|
);
|
|
9977
10001
|
server.tool(
|
|
9978
10002
|
"call_graph",
|
|
9979
|
-
"Query the call graph to find callers or callees of a function/method. Use to understand code flow and dependencies.",
|
|
10003
|
+
"Query the call graph to find callers or callees of a function/method. Use to understand code flow and dependencies. Supports relationship types: Call, MethodCall, Constructor, Import, Inherits, Implements.",
|
|
9980
10004
|
{
|
|
9981
10005
|
name: z2.string().describe("Function or method name to query"),
|
|
9982
10006
|
direction: z2.enum(["callers", "callees"]).default("callers").describe("Direction: 'callers' finds who calls this function, 'callees' finds what this function calls"),
|
|
9983
|
-
symbolId: z2.string().optional().describe("Symbol ID (required for 'callees' direction)")
|
|
10007
|
+
symbolId: z2.string().optional().describe("Symbol ID (required for 'callees' direction)"),
|
|
10008
|
+
relationshipType: z2.enum(["Call", "MethodCall", "Constructor", "Import", "Inherits", "Implements"]).optional().describe("Filter by relationship type. Omit to show all.")
|
|
9984
10009
|
},
|
|
9985
10010
|
async (args) => {
|
|
9986
10011
|
await runtime.ensureInitialized();
|
|
@@ -9989,26 +10014,52 @@ ${formatted.join("\n\n")}` }] };
|
|
|
9989
10014
|
if (!args.symbolId) {
|
|
9990
10015
|
return { content: [{ type: "text", text: "Error: 'symbolId' is required when direction is 'callees'." }] };
|
|
9991
10016
|
}
|
|
9992
|
-
const callees = await indexer.getCallees(args.symbolId);
|
|
10017
|
+
const callees = await indexer.getCallees(args.symbolId, args.relationshipType);
|
|
9993
10018
|
if (callees.length === 0) {
|
|
9994
|
-
return { content: [{ type: "text", text: `No callees found for symbol ${args.symbolId}.` }] };
|
|
10019
|
+
return { content: [{ type: "text", text: `No callees found for symbol ${args.symbolId}${args.relationshipType ? ` with type ${args.relationshipType}` : ""}.` }] };
|
|
9995
10020
|
}
|
|
9996
|
-
const formatted2 = callees.map(
|
|
9997
|
-
|
|
9998
|
-
|
|
10021
|
+
const formatted2 = callees.map((e, i) => {
|
|
10022
|
+
const conf = e.confidence !== "Direct" ? ` [${e.confidence.toLowerCase()}]` : "";
|
|
10023
|
+
return `[${i + 1}] \u2192 ${e.targetName} (${e.callType})${conf} at line ${e.line}${e.isResolved ? ` [resolved: ${e.toSymbolId}]` : " [unresolved]"}`;
|
|
10024
|
+
});
|
|
9999
10025
|
return { content: [{ type: "text", text: `Callees (${callees.length}):
|
|
10000
10026
|
|
|
10001
10027
|
${formatted2.join("\n")}` }] };
|
|
10002
10028
|
}
|
|
10003
|
-
const callers = await indexer.getCallers(args.name);
|
|
10029
|
+
const callers = await indexer.getCallers(args.name, args.relationshipType);
|
|
10004
10030
|
if (callers.length === 0) {
|
|
10005
|
-
return { content: [{ type: "text", text: `No callers found for "${args.name}".` }] };
|
|
10031
|
+
return { content: [{ type: "text", text: `No callers found for "${args.name}"${args.relationshipType ? ` with type ${args.relationshipType}` : ""}.` }] };
|
|
10006
10032
|
}
|
|
10007
|
-
const formatted = callers.map(
|
|
10008
|
-
|
|
10009
|
-
|
|
10033
|
+
const formatted = callers.map((e, i) => {
|
|
10034
|
+
const conf = e.confidence !== "Direct" ? ` [${e.confidence.toLowerCase()}]` : "";
|
|
10035
|
+
return `[${i + 1}] \u2190 from ${e.fromSymbolName ?? "<unknown>"} in ${e.fromSymbolFilePath ?? "<unknown file>"} [${e.fromSymbolId}] (${e.callType})${conf} at line ${e.line}${e.isResolved ? " [resolved]" : " [unresolved]"}`;
|
|
10036
|
+
});
|
|
10010
10037
|
return { content: [{ type: "text", text: `"${args.name}" is called by ${callers.length} function(s):
|
|
10011
10038
|
|
|
10039
|
+
${formatted.join("\n")}` }] };
|
|
10040
|
+
}
|
|
10041
|
+
);
|
|
10042
|
+
server.tool(
|
|
10043
|
+
"call_graph_path",
|
|
10044
|
+
"Find the shortest connection path between two symbols in the call graph. Returns the chain of calls connecting them.",
|
|
10045
|
+
{
|
|
10046
|
+
from: z2.string().describe("Source function/method name (starting point)"),
|
|
10047
|
+
to: z2.string().describe("Target function/method name (destination)"),
|
|
10048
|
+
maxDepth: z2.number().optional().default(10).describe("Maximum traversal depth (default: 10)")
|
|
10049
|
+
},
|
|
10050
|
+
async (args) => {
|
|
10051
|
+
await runtime.ensureInitialized();
|
|
10052
|
+
const indexer = runtime.getIndexer();
|
|
10053
|
+
const path18 = await indexer.findCallPath(args.from, args.to, args.maxDepth);
|
|
10054
|
+
if (path18.length === 0) {
|
|
10055
|
+
return { content: [{ type: "text", text: `No path found between "${args.from}" and "${args.to}". They may be in disconnected components, or the call graph index needs updating.` }] };
|
|
10056
|
+
}
|
|
10057
|
+
const formatted = path18.map((hop, i) => {
|
|
10058
|
+
const prefix = i === 0 ? "[start]" : `--${hop.callType}-->`;
|
|
10059
|
+
const location = hop.filePath ? ` (${hop.filePath}:${hop.line})` : "";
|
|
10060
|
+
return `${prefix} ${hop.symbolName}${location}`;
|
|
10061
|
+
});
|
|
10062
|
+
return { content: [{ type: "text", text: `Path (${path18.length} hops):
|
|
10012
10063
|
${formatted.join("\n")}` }] };
|
|
10013
10064
|
}
|
|
10014
10065
|
);
|
|
@@ -10087,9 +10138,8 @@ async function main() {
|
|
|
10087
10138
|
process.on("SIGINT", shutdown);
|
|
10088
10139
|
process.on("SIGTERM", shutdown);
|
|
10089
10140
|
}
|
|
10090
|
-
main().catch((
|
|
10091
|
-
|
|
10092
|
-
console.error(`Fatal: ${message}`);
|
|
10141
|
+
main().catch((_error) => {
|
|
10142
|
+
console.error("Fatal: failed to start MCP server (check config and network)");
|
|
10093
10143
|
process.exit(1);
|
|
10094
10144
|
});
|
|
10095
10145
|
//# sourceMappingURL=cli.js.map
|