opencode-codebase-index 0.10.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/dist/cli.cjs +72 -23
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +72 -23
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +73 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +73 -23
- 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") {
|
|
@@ -2499,6 +2503,8 @@ var BaseEmbeddingProvider = class {
|
|
|
2499
2503
|
this.credentials = credentials;
|
|
2500
2504
|
this.modelInfo = modelInfo;
|
|
2501
2505
|
}
|
|
2506
|
+
credentials;
|
|
2507
|
+
modelInfo;
|
|
2502
2508
|
async embedQuery(query) {
|
|
2503
2509
|
const result = await this.embedBatch([query]);
|
|
2504
2510
|
return {
|
|
@@ -4238,17 +4244,17 @@ var Database = class {
|
|
|
4238
4244
|
if (edges.length === 0) return;
|
|
4239
4245
|
this.inner.upsertCallEdgesBatch(edges);
|
|
4240
4246
|
}
|
|
4241
|
-
getCallers(targetName, branch) {
|
|
4247
|
+
getCallers(targetName, branch, callTypeFilter) {
|
|
4242
4248
|
this.throwIfClosed();
|
|
4243
|
-
return this.inner.getCallers(targetName, branch);
|
|
4249
|
+
return this.inner.getCallers(targetName, branch, callTypeFilter ?? null);
|
|
4244
4250
|
}
|
|
4245
|
-
getCallersWithContext(targetName, branch) {
|
|
4251
|
+
getCallersWithContext(targetName, branch, callTypeFilter) {
|
|
4246
4252
|
this.throwIfClosed();
|
|
4247
|
-
return this.inner.getCallersWithContext(targetName, branch);
|
|
4253
|
+
return this.inner.getCallersWithContext(targetName, branch, callTypeFilter ?? null);
|
|
4248
4254
|
}
|
|
4249
|
-
getCallees(symbolId, branch) {
|
|
4255
|
+
getCallees(symbolId, branch, callTypeFilter) {
|
|
4250
4256
|
this.throwIfClosed();
|
|
4251
|
-
return this.inner.getCallees(symbolId, branch);
|
|
4257
|
+
return this.inner.getCallees(symbolId, branch, callTypeFilter ?? null);
|
|
4252
4258
|
}
|
|
4253
4259
|
deleteCallEdgesByFile(filePath) {
|
|
4254
4260
|
this.throwIfClosed();
|
|
@@ -4258,6 +4264,10 @@ var Database = class {
|
|
|
4258
4264
|
this.throwIfClosed();
|
|
4259
4265
|
this.inner.resolveCallEdge(edgeId, toSymbolId);
|
|
4260
4266
|
}
|
|
4267
|
+
findShortestPath(fromName, toName, branch, maxDepth) {
|
|
4268
|
+
this.throwIfClosed();
|
|
4269
|
+
return this.inner.findShortestPath(fromName, toName, branch, maxDepth ?? null);
|
|
4270
|
+
}
|
|
4261
4271
|
addSymbolsToBranch(branch, symbolIds) {
|
|
4262
4272
|
this.throwIfClosed();
|
|
4263
4273
|
this.inner.addSymbolsToBranch(branch, symbolIds);
|
|
@@ -7056,6 +7066,7 @@ var Indexer = class {
|
|
|
7056
7066
|
targetName: site.calleeName,
|
|
7057
7067
|
toSymbolId: void 0,
|
|
7058
7068
|
callType: site.callType,
|
|
7069
|
+
confidence: site.confidence,
|
|
7059
7070
|
line: site.line,
|
|
7060
7071
|
col: site.column,
|
|
7061
7072
|
isResolved: false
|
|
@@ -8175,12 +8186,12 @@ var Indexer = class {
|
|
|
8175
8186
|
})
|
|
8176
8187
|
);
|
|
8177
8188
|
}
|
|
8178
|
-
async getCallers(targetName) {
|
|
8189
|
+
async getCallers(targetName, callTypeFilter) {
|
|
8179
8190
|
const { database } = await this.ensureInitialized();
|
|
8180
8191
|
const seen = /* @__PURE__ */ new Set();
|
|
8181
8192
|
const results = [];
|
|
8182
8193
|
for (const branchKey of this.getBranchCatalogKeys()) {
|
|
8183
|
-
for (const edge of database.getCallersWithContext(targetName, branchKey)) {
|
|
8194
|
+
for (const edge of database.getCallersWithContext(targetName, branchKey, callTypeFilter)) {
|
|
8184
8195
|
if (!seen.has(edge.id)) {
|
|
8185
8196
|
seen.add(edge.id);
|
|
8186
8197
|
results.push(edge);
|
|
@@ -8189,12 +8200,12 @@ var Indexer = class {
|
|
|
8189
8200
|
}
|
|
8190
8201
|
return results;
|
|
8191
8202
|
}
|
|
8192
|
-
async getCallees(symbolId) {
|
|
8203
|
+
async getCallees(symbolId, callTypeFilter) {
|
|
8193
8204
|
const { database } = await this.ensureInitialized();
|
|
8194
8205
|
const seen = /* @__PURE__ */ new Set();
|
|
8195
8206
|
const results = [];
|
|
8196
8207
|
for (const branchKey of this.getBranchCatalogKeys()) {
|
|
8197
|
-
for (const edge of database.getCallees(symbolId, branchKey)) {
|
|
8208
|
+
for (const edge of database.getCallees(symbolId, branchKey, callTypeFilter)) {
|
|
8198
8209
|
if (!seen.has(edge.id)) {
|
|
8199
8210
|
seen.add(edge.id);
|
|
8200
8211
|
results.push(edge);
|
|
@@ -8203,6 +8214,17 @@ var Indexer = class {
|
|
|
8203
8214
|
}
|
|
8204
8215
|
return results;
|
|
8205
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
|
+
}
|
|
8206
8228
|
async close() {
|
|
8207
8229
|
await this.database?.close();
|
|
8208
8230
|
this.database = null;
|
|
@@ -9978,11 +10000,12 @@ ${formatted.join("\n\n")}` }] };
|
|
|
9978
10000
|
);
|
|
9979
10001
|
server.tool(
|
|
9980
10002
|
"call_graph",
|
|
9981
|
-
"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.",
|
|
9982
10004
|
{
|
|
9983
10005
|
name: z2.string().describe("Function or method name to query"),
|
|
9984
10006
|
direction: z2.enum(["callers", "callees"]).default("callers").describe("Direction: 'callers' finds who calls this function, 'callees' finds what this function calls"),
|
|
9985
|
-
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.")
|
|
9986
10009
|
},
|
|
9987
10010
|
async (args) => {
|
|
9988
10011
|
await runtime.ensureInitialized();
|
|
@@ -9991,26 +10014,52 @@ ${formatted.join("\n\n")}` }] };
|
|
|
9991
10014
|
if (!args.symbolId) {
|
|
9992
10015
|
return { content: [{ type: "text", text: "Error: 'symbolId' is required when direction is 'callees'." }] };
|
|
9993
10016
|
}
|
|
9994
|
-
const callees = await indexer.getCallees(args.symbolId);
|
|
10017
|
+
const callees = await indexer.getCallees(args.symbolId, args.relationshipType);
|
|
9995
10018
|
if (callees.length === 0) {
|
|
9996
|
-
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}` : ""}.` }] };
|
|
9997
10020
|
}
|
|
9998
|
-
const formatted2 = callees.map(
|
|
9999
|
-
|
|
10000
|
-
|
|
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
|
+
});
|
|
10001
10025
|
return { content: [{ type: "text", text: `Callees (${callees.length}):
|
|
10002
10026
|
|
|
10003
10027
|
${formatted2.join("\n")}` }] };
|
|
10004
10028
|
}
|
|
10005
|
-
const callers = await indexer.getCallers(args.name);
|
|
10029
|
+
const callers = await indexer.getCallers(args.name, args.relationshipType);
|
|
10006
10030
|
if (callers.length === 0) {
|
|
10007
|
-
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}` : ""}.` }] };
|
|
10008
10032
|
}
|
|
10009
|
-
const formatted = callers.map(
|
|
10010
|
-
|
|
10011
|
-
|
|
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
|
+
});
|
|
10012
10037
|
return { content: [{ type: "text", text: `"${args.name}" is called by ${callers.length} function(s):
|
|
10013
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):
|
|
10014
10063
|
${formatted.join("\n")}` }] };
|
|
10015
10064
|
}
|
|
10016
10065
|
);
|