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/index.cjs
CHANGED
|
@@ -7,7 +7,11 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
-
|
|
10
|
+
try {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw mod = 0, e;
|
|
14
|
+
}
|
|
11
15
|
};
|
|
12
16
|
var __export = (target, all) => {
|
|
13
17
|
for (var name in all)
|
|
@@ -4861,6 +4865,8 @@ var BaseEmbeddingProvider = class {
|
|
|
4861
4865
|
this.credentials = credentials;
|
|
4862
4866
|
this.modelInfo = modelInfo;
|
|
4863
4867
|
}
|
|
4868
|
+
credentials;
|
|
4869
|
+
modelInfo;
|
|
4864
4870
|
async embedQuery(query) {
|
|
4865
4871
|
const result = await this.embedBatch([query]);
|
|
4866
4872
|
return {
|
|
@@ -6409,17 +6415,17 @@ var Database = class {
|
|
|
6409
6415
|
if (edges.length === 0) return;
|
|
6410
6416
|
this.inner.upsertCallEdgesBatch(edges);
|
|
6411
6417
|
}
|
|
6412
|
-
getCallers(targetName, branch) {
|
|
6418
|
+
getCallers(targetName, branch, callTypeFilter) {
|
|
6413
6419
|
this.throwIfClosed();
|
|
6414
|
-
return this.inner.getCallers(targetName, branch);
|
|
6420
|
+
return this.inner.getCallers(targetName, branch, callTypeFilter ?? null);
|
|
6415
6421
|
}
|
|
6416
|
-
getCallersWithContext(targetName, branch) {
|
|
6422
|
+
getCallersWithContext(targetName, branch, callTypeFilter) {
|
|
6417
6423
|
this.throwIfClosed();
|
|
6418
|
-
return this.inner.getCallersWithContext(targetName, branch);
|
|
6424
|
+
return this.inner.getCallersWithContext(targetName, branch, callTypeFilter ?? null);
|
|
6419
6425
|
}
|
|
6420
|
-
getCallees(symbolId, branch) {
|
|
6426
|
+
getCallees(symbolId, branch, callTypeFilter) {
|
|
6421
6427
|
this.throwIfClosed();
|
|
6422
|
-
return this.inner.getCallees(symbolId, branch);
|
|
6428
|
+
return this.inner.getCallees(symbolId, branch, callTypeFilter ?? null);
|
|
6423
6429
|
}
|
|
6424
6430
|
deleteCallEdgesByFile(filePath) {
|
|
6425
6431
|
this.throwIfClosed();
|
|
@@ -6429,6 +6435,10 @@ var Database = class {
|
|
|
6429
6435
|
this.throwIfClosed();
|
|
6430
6436
|
this.inner.resolveCallEdge(edgeId, toSymbolId);
|
|
6431
6437
|
}
|
|
6438
|
+
findShortestPath(fromName, toName, branch, maxDepth) {
|
|
6439
|
+
this.throwIfClosed();
|
|
6440
|
+
return this.inner.findShortestPath(fromName, toName, branch, maxDepth ?? null);
|
|
6441
|
+
}
|
|
6432
6442
|
addSymbolsToBranch(branch, symbolIds) {
|
|
6433
6443
|
this.throwIfClosed();
|
|
6434
6444
|
this.inner.addSymbolsToBranch(branch, symbolIds);
|
|
@@ -9056,6 +9066,7 @@ var Indexer = class {
|
|
|
9056
9066
|
targetName: site.calleeName,
|
|
9057
9067
|
toSymbolId: void 0,
|
|
9058
9068
|
callType: site.callType,
|
|
9069
|
+
confidence: site.confidence,
|
|
9059
9070
|
line: site.line,
|
|
9060
9071
|
col: site.column,
|
|
9061
9072
|
isResolved: false
|
|
@@ -10175,12 +10186,12 @@ var Indexer = class {
|
|
|
10175
10186
|
})
|
|
10176
10187
|
);
|
|
10177
10188
|
}
|
|
10178
|
-
async getCallers(targetName) {
|
|
10189
|
+
async getCallers(targetName, callTypeFilter) {
|
|
10179
10190
|
const { database } = await this.ensureInitialized();
|
|
10180
10191
|
const seen = /* @__PURE__ */ new Set();
|
|
10181
10192
|
const results = [];
|
|
10182
10193
|
for (const branchKey of this.getBranchCatalogKeys()) {
|
|
10183
|
-
for (const edge of database.getCallersWithContext(targetName, branchKey)) {
|
|
10194
|
+
for (const edge of database.getCallersWithContext(targetName, branchKey, callTypeFilter)) {
|
|
10184
10195
|
if (!seen.has(edge.id)) {
|
|
10185
10196
|
seen.add(edge.id);
|
|
10186
10197
|
results.push(edge);
|
|
@@ -10189,12 +10200,12 @@ var Indexer = class {
|
|
|
10189
10200
|
}
|
|
10190
10201
|
return results;
|
|
10191
10202
|
}
|
|
10192
|
-
async getCallees(symbolId) {
|
|
10203
|
+
async getCallees(symbolId, callTypeFilter) {
|
|
10193
10204
|
const { database } = await this.ensureInitialized();
|
|
10194
10205
|
const seen = /* @__PURE__ */ new Set();
|
|
10195
10206
|
const results = [];
|
|
10196
10207
|
for (const branchKey of this.getBranchCatalogKeys()) {
|
|
10197
|
-
for (const edge of database.getCallees(symbolId, branchKey)) {
|
|
10208
|
+
for (const edge of database.getCallees(symbolId, branchKey, callTypeFilter)) {
|
|
10198
10209
|
if (!seen.has(edge.id)) {
|
|
10199
10210
|
seen.add(edge.id);
|
|
10200
10211
|
results.push(edge);
|
|
@@ -10203,6 +10214,17 @@ var Indexer = class {
|
|
|
10203
10214
|
}
|
|
10204
10215
|
return results;
|
|
10205
10216
|
}
|
|
10217
|
+
async findCallPath(fromName, toName, maxDepth) {
|
|
10218
|
+
const { database } = await this.ensureInitialized();
|
|
10219
|
+
let shortest = [];
|
|
10220
|
+
for (const branchKey of this.getBranchCatalogKeys()) {
|
|
10221
|
+
const path18 = database.findShortestPath(fromName, toName, branchKey, maxDepth);
|
|
10222
|
+
if (path18.length > 0 && (shortest.length === 0 || path18.length < shortest.length)) {
|
|
10223
|
+
shortest = path18;
|
|
10224
|
+
}
|
|
10225
|
+
}
|
|
10226
|
+
return shortest;
|
|
10227
|
+
}
|
|
10206
10228
|
async close() {
|
|
10207
10229
|
await this.database?.close();
|
|
10208
10230
|
this.database = null;
|
|
@@ -10746,11 +10768,12 @@ var implementation_lookup = (0, import_plugin.tool)({
|
|
|
10746
10768
|
}
|
|
10747
10769
|
});
|
|
10748
10770
|
var call_graph = (0, import_plugin.tool)({
|
|
10749
|
-
description: "Query the call graph to find callers or callees of a function/method. Use to understand code flow and dependencies between functions.",
|
|
10771
|
+
description: "Query the call graph to find callers or callees of a function/method. Use to understand code flow and dependencies between functions. Supports relationship types: Call, MethodCall, Constructor, Import, Inherits, Implements.",
|
|
10750
10772
|
args: {
|
|
10751
10773
|
name: z.string().describe("Function or method name to query"),
|
|
10752
10774
|
direction: z.enum(["callers", "callees"]).default("callers").describe("Direction: 'callers' finds who calls this function, 'callees' finds what this function calls"),
|
|
10753
|
-
symbolId: z.string().optional().describe("Symbol ID (required for 'callees' direction, returned by previous call_graph queries)")
|
|
10775
|
+
symbolId: z.string().optional().describe("Symbol ID (required for 'callees' direction, returned by previous call_graph queries)"),
|
|
10776
|
+
relationshipType: z.enum(["Call", "MethodCall", "Constructor", "Import", "Inherits", "Implements"]).optional().describe("Filter by relationship type. Omit to show all.")
|
|
10754
10777
|
},
|
|
10755
10778
|
async execute(args, context) {
|
|
10756
10779
|
const indexer = getIndexerForProject(context?.worktree);
|
|
@@ -10758,25 +10781,49 @@ var call_graph = (0, import_plugin.tool)({
|
|
|
10758
10781
|
if (!args.symbolId) {
|
|
10759
10782
|
return "Error: 'symbolId' is required when direction is 'callees'. First use direction='callers' to find the symbol ID.";
|
|
10760
10783
|
}
|
|
10761
|
-
const callees = await indexer.getCallees(args.symbolId);
|
|
10784
|
+
const callees = await indexer.getCallees(args.symbolId, args.relationshipType);
|
|
10762
10785
|
if (callees.length === 0) {
|
|
10763
|
-
return `No callees found for symbol ${args.symbolId}. The function may not call any other tracked functions.`;
|
|
10786
|
+
return `No callees found for symbol ${args.symbolId}${args.relationshipType ? ` with type ${args.relationshipType}` : ""}. The function may not call any other tracked functions.`;
|
|
10764
10787
|
}
|
|
10765
|
-
const formatted2 = callees.map(
|
|
10766
|
-
|
|
10767
|
-
|
|
10788
|
+
const formatted2 = callees.map((e, i) => {
|
|
10789
|
+
const conf = e.confidence !== "Direct" ? ` [${e.confidence.toLowerCase()}]` : "";
|
|
10790
|
+
return `[${i + 1}] \u2192 ${e.targetName} (${e.callType})${conf} at line ${e.line}${e.isResolved ? ` [resolved: ${e.toSymbolId}]` : " [unresolved]"}`;
|
|
10791
|
+
});
|
|
10768
10792
|
return formatted2.join("\n");
|
|
10769
10793
|
}
|
|
10770
|
-
const callers = await indexer.getCallers(args.name);
|
|
10794
|
+
const callers = await indexer.getCallers(args.name, args.relationshipType);
|
|
10771
10795
|
if (callers.length === 0) {
|
|
10772
|
-
return `No callers found for "${args.name}". It may not be called by any tracked function, or the index needs updating.`;
|
|
10796
|
+
return `No callers found for "${args.name}"${args.relationshipType ? ` with type ${args.relationshipType}` : ""}. It may not be called by any tracked function, or the index needs updating.`;
|
|
10773
10797
|
}
|
|
10774
|
-
const formatted = callers.map(
|
|
10775
|
-
|
|
10776
|
-
|
|
10798
|
+
const formatted = callers.map((e, i) => {
|
|
10799
|
+
const conf = e.confidence !== "Direct" ? ` [${e.confidence.toLowerCase()}]` : "";
|
|
10800
|
+
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]"}`;
|
|
10801
|
+
});
|
|
10777
10802
|
return formatted.join("\n");
|
|
10778
10803
|
}
|
|
10779
10804
|
});
|
|
10805
|
+
var call_graph_path = (0, import_plugin.tool)({
|
|
10806
|
+
description: "Find the shortest connection path between two symbols in the call graph. Given a source and target function/method name, returns the chain of calls connecting them.",
|
|
10807
|
+
args: {
|
|
10808
|
+
from: z.string().describe("Source function/method name (starting point)"),
|
|
10809
|
+
to: z.string().describe("Target function/method name (destination)"),
|
|
10810
|
+
maxDepth: z.number().optional().default(10).describe("Maximum traversal depth (default: 10)")
|
|
10811
|
+
},
|
|
10812
|
+
async execute(args, context) {
|
|
10813
|
+
const indexer = getIndexerForProject(context?.worktree);
|
|
10814
|
+
const path18 = await indexer.findCallPath(args.from, args.to, args.maxDepth);
|
|
10815
|
+
if (path18.length === 0) {
|
|
10816
|
+
return `No path found between "${args.from}" and "${args.to}". They may be in disconnected components, or the call graph index needs updating.`;
|
|
10817
|
+
}
|
|
10818
|
+
const formatted = path18.map((hop, i) => {
|
|
10819
|
+
const prefix = i === 0 ? "[start]" : `--${hop.callType}-->`;
|
|
10820
|
+
const location = hop.filePath ? ` (${hop.filePath}:${hop.line})` : "";
|
|
10821
|
+
return `${prefix} ${hop.symbolName}${location}`;
|
|
10822
|
+
});
|
|
10823
|
+
return `Path (${path18.length} hops):
|
|
10824
|
+
${formatted.join("\n")}`;
|
|
10825
|
+
}
|
|
10826
|
+
});
|
|
10780
10827
|
var add_knowledge_base = (0, import_plugin.tool)({
|
|
10781
10828
|
description: "Add a folder as a knowledge base to the semantic search index. The folder will be indexed alongside the main project code. Supports absolute paths or relative paths (relative to the project root).",
|
|
10782
10829
|
args: {
|
|
@@ -11208,6 +11255,8 @@ var RoutingHintController = class {
|
|
|
11208
11255
|
this.getStatus = getStatus;
|
|
11209
11256
|
this.maxSessions = maxSessions;
|
|
11210
11257
|
}
|
|
11258
|
+
getStatus;
|
|
11259
|
+
maxSessions;
|
|
11211
11260
|
sessionState = /* @__PURE__ */ new Map();
|
|
11212
11261
|
observeUserMessage(sessionID, parts) {
|
|
11213
11262
|
const assessment = assessRoutingIntent(extractUserText(parts));
|
|
@@ -11336,6 +11385,7 @@ var plugin = async ({ directory, worktree }) => {
|
|
|
11336
11385
|
index_logs,
|
|
11337
11386
|
find_similar,
|
|
11338
11387
|
call_graph,
|
|
11388
|
+
call_graph_path,
|
|
11339
11389
|
implementation_lookup,
|
|
11340
11390
|
add_knowledge_base,
|
|
11341
11391
|
list_knowledge_bases,
|