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.js
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 __copyProps = (to, from, except, desc) => {
|
|
13
17
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -4851,6 +4855,8 @@ var BaseEmbeddingProvider = class {
|
|
|
4851
4855
|
this.credentials = credentials;
|
|
4852
4856
|
this.modelInfo = modelInfo;
|
|
4853
4857
|
}
|
|
4858
|
+
credentials;
|
|
4859
|
+
modelInfo;
|
|
4854
4860
|
async embedQuery(query) {
|
|
4855
4861
|
const result = await this.embedBatch([query]);
|
|
4856
4862
|
return {
|
|
@@ -6398,17 +6404,17 @@ var Database = class {
|
|
|
6398
6404
|
if (edges.length === 0) return;
|
|
6399
6405
|
this.inner.upsertCallEdgesBatch(edges);
|
|
6400
6406
|
}
|
|
6401
|
-
getCallers(targetName, branch) {
|
|
6407
|
+
getCallers(targetName, branch, callTypeFilter) {
|
|
6402
6408
|
this.throwIfClosed();
|
|
6403
|
-
return this.inner.getCallers(targetName, branch);
|
|
6409
|
+
return this.inner.getCallers(targetName, branch, callTypeFilter ?? null);
|
|
6404
6410
|
}
|
|
6405
|
-
getCallersWithContext(targetName, branch) {
|
|
6411
|
+
getCallersWithContext(targetName, branch, callTypeFilter) {
|
|
6406
6412
|
this.throwIfClosed();
|
|
6407
|
-
return this.inner.getCallersWithContext(targetName, branch);
|
|
6413
|
+
return this.inner.getCallersWithContext(targetName, branch, callTypeFilter ?? null);
|
|
6408
6414
|
}
|
|
6409
|
-
getCallees(symbolId, branch) {
|
|
6415
|
+
getCallees(symbolId, branch, callTypeFilter) {
|
|
6410
6416
|
this.throwIfClosed();
|
|
6411
|
-
return this.inner.getCallees(symbolId, branch);
|
|
6417
|
+
return this.inner.getCallees(symbolId, branch, callTypeFilter ?? null);
|
|
6412
6418
|
}
|
|
6413
6419
|
deleteCallEdgesByFile(filePath) {
|
|
6414
6420
|
this.throwIfClosed();
|
|
@@ -6418,6 +6424,10 @@ var Database = class {
|
|
|
6418
6424
|
this.throwIfClosed();
|
|
6419
6425
|
this.inner.resolveCallEdge(edgeId, toSymbolId);
|
|
6420
6426
|
}
|
|
6427
|
+
findShortestPath(fromName, toName, branch, maxDepth) {
|
|
6428
|
+
this.throwIfClosed();
|
|
6429
|
+
return this.inner.findShortestPath(fromName, toName, branch, maxDepth ?? null);
|
|
6430
|
+
}
|
|
6421
6431
|
addSymbolsToBranch(branch, symbolIds) {
|
|
6422
6432
|
this.throwIfClosed();
|
|
6423
6433
|
this.inner.addSymbolsToBranch(branch, symbolIds);
|
|
@@ -9045,6 +9055,7 @@ var Indexer = class {
|
|
|
9045
9055
|
targetName: site.calleeName,
|
|
9046
9056
|
toSymbolId: void 0,
|
|
9047
9057
|
callType: site.callType,
|
|
9058
|
+
confidence: site.confidence,
|
|
9048
9059
|
line: site.line,
|
|
9049
9060
|
col: site.column,
|
|
9050
9061
|
isResolved: false
|
|
@@ -10164,12 +10175,12 @@ var Indexer = class {
|
|
|
10164
10175
|
})
|
|
10165
10176
|
);
|
|
10166
10177
|
}
|
|
10167
|
-
async getCallers(targetName) {
|
|
10178
|
+
async getCallers(targetName, callTypeFilter) {
|
|
10168
10179
|
const { database } = await this.ensureInitialized();
|
|
10169
10180
|
const seen = /* @__PURE__ */ new Set();
|
|
10170
10181
|
const results = [];
|
|
10171
10182
|
for (const branchKey of this.getBranchCatalogKeys()) {
|
|
10172
|
-
for (const edge of database.getCallersWithContext(targetName, branchKey)) {
|
|
10183
|
+
for (const edge of database.getCallersWithContext(targetName, branchKey, callTypeFilter)) {
|
|
10173
10184
|
if (!seen.has(edge.id)) {
|
|
10174
10185
|
seen.add(edge.id);
|
|
10175
10186
|
results.push(edge);
|
|
@@ -10178,12 +10189,12 @@ var Indexer = class {
|
|
|
10178
10189
|
}
|
|
10179
10190
|
return results;
|
|
10180
10191
|
}
|
|
10181
|
-
async getCallees(symbolId) {
|
|
10192
|
+
async getCallees(symbolId, callTypeFilter) {
|
|
10182
10193
|
const { database } = await this.ensureInitialized();
|
|
10183
10194
|
const seen = /* @__PURE__ */ new Set();
|
|
10184
10195
|
const results = [];
|
|
10185
10196
|
for (const branchKey of this.getBranchCatalogKeys()) {
|
|
10186
|
-
for (const edge of database.getCallees(symbolId, branchKey)) {
|
|
10197
|
+
for (const edge of database.getCallees(symbolId, branchKey, callTypeFilter)) {
|
|
10187
10198
|
if (!seen.has(edge.id)) {
|
|
10188
10199
|
seen.add(edge.id);
|
|
10189
10200
|
results.push(edge);
|
|
@@ -10192,6 +10203,17 @@ var Indexer = class {
|
|
|
10192
10203
|
}
|
|
10193
10204
|
return results;
|
|
10194
10205
|
}
|
|
10206
|
+
async findCallPath(fromName, toName, maxDepth) {
|
|
10207
|
+
const { database } = await this.ensureInitialized();
|
|
10208
|
+
let shortest = [];
|
|
10209
|
+
for (const branchKey of this.getBranchCatalogKeys()) {
|
|
10210
|
+
const path18 = database.findShortestPath(fromName, toName, branchKey, maxDepth);
|
|
10211
|
+
if (path18.length > 0 && (shortest.length === 0 || path18.length < shortest.length)) {
|
|
10212
|
+
shortest = path18;
|
|
10213
|
+
}
|
|
10214
|
+
}
|
|
10215
|
+
return shortest;
|
|
10216
|
+
}
|
|
10195
10217
|
async close() {
|
|
10196
10218
|
await this.database?.close();
|
|
10197
10219
|
this.database = null;
|
|
@@ -10735,11 +10757,12 @@ var implementation_lookup = tool({
|
|
|
10735
10757
|
}
|
|
10736
10758
|
});
|
|
10737
10759
|
var call_graph = tool({
|
|
10738
|
-
description: "Query the call graph to find callers or callees of a function/method. Use to understand code flow and dependencies between functions.",
|
|
10760
|
+
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.",
|
|
10739
10761
|
args: {
|
|
10740
10762
|
name: z.string().describe("Function or method name to query"),
|
|
10741
10763
|
direction: z.enum(["callers", "callees"]).default("callers").describe("Direction: 'callers' finds who calls this function, 'callees' finds what this function calls"),
|
|
10742
|
-
symbolId: z.string().optional().describe("Symbol ID (required for 'callees' direction, returned by previous call_graph queries)")
|
|
10764
|
+
symbolId: z.string().optional().describe("Symbol ID (required for 'callees' direction, returned by previous call_graph queries)"),
|
|
10765
|
+
relationshipType: z.enum(["Call", "MethodCall", "Constructor", "Import", "Inherits", "Implements"]).optional().describe("Filter by relationship type. Omit to show all.")
|
|
10743
10766
|
},
|
|
10744
10767
|
async execute(args, context) {
|
|
10745
10768
|
const indexer = getIndexerForProject(context?.worktree);
|
|
@@ -10747,25 +10770,49 @@ var call_graph = tool({
|
|
|
10747
10770
|
if (!args.symbolId) {
|
|
10748
10771
|
return "Error: 'symbolId' is required when direction is 'callees'. First use direction='callers' to find the symbol ID.";
|
|
10749
10772
|
}
|
|
10750
|
-
const callees = await indexer.getCallees(args.symbolId);
|
|
10773
|
+
const callees = await indexer.getCallees(args.symbolId, args.relationshipType);
|
|
10751
10774
|
if (callees.length === 0) {
|
|
10752
|
-
return `No callees found for symbol ${args.symbolId}. The function may not call any other tracked functions.`;
|
|
10775
|
+
return `No callees found for symbol ${args.symbolId}${args.relationshipType ? ` with type ${args.relationshipType}` : ""}. The function may not call any other tracked functions.`;
|
|
10753
10776
|
}
|
|
10754
|
-
const formatted2 = callees.map(
|
|
10755
|
-
|
|
10756
|
-
|
|
10777
|
+
const formatted2 = callees.map((e, i) => {
|
|
10778
|
+
const conf = e.confidence !== "Direct" ? ` [${e.confidence.toLowerCase()}]` : "";
|
|
10779
|
+
return `[${i + 1}] \u2192 ${e.targetName} (${e.callType})${conf} at line ${e.line}${e.isResolved ? ` [resolved: ${e.toSymbolId}]` : " [unresolved]"}`;
|
|
10780
|
+
});
|
|
10757
10781
|
return formatted2.join("\n");
|
|
10758
10782
|
}
|
|
10759
|
-
const callers = await indexer.getCallers(args.name);
|
|
10783
|
+
const callers = await indexer.getCallers(args.name, args.relationshipType);
|
|
10760
10784
|
if (callers.length === 0) {
|
|
10761
|
-
return `No callers found for "${args.name}". It may not be called by any tracked function, or the index needs updating.`;
|
|
10785
|
+
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.`;
|
|
10762
10786
|
}
|
|
10763
|
-
const formatted = callers.map(
|
|
10764
|
-
|
|
10765
|
-
|
|
10787
|
+
const formatted = callers.map((e, i) => {
|
|
10788
|
+
const conf = e.confidence !== "Direct" ? ` [${e.confidence.toLowerCase()}]` : "";
|
|
10789
|
+
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]"}`;
|
|
10790
|
+
});
|
|
10766
10791
|
return formatted.join("\n");
|
|
10767
10792
|
}
|
|
10768
10793
|
});
|
|
10794
|
+
var call_graph_path = tool({
|
|
10795
|
+
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.",
|
|
10796
|
+
args: {
|
|
10797
|
+
from: z.string().describe("Source function/method name (starting point)"),
|
|
10798
|
+
to: z.string().describe("Target function/method name (destination)"),
|
|
10799
|
+
maxDepth: z.number().optional().default(10).describe("Maximum traversal depth (default: 10)")
|
|
10800
|
+
},
|
|
10801
|
+
async execute(args, context) {
|
|
10802
|
+
const indexer = getIndexerForProject(context?.worktree);
|
|
10803
|
+
const path18 = await indexer.findCallPath(args.from, args.to, args.maxDepth);
|
|
10804
|
+
if (path18.length === 0) {
|
|
10805
|
+
return `No path found between "${args.from}" and "${args.to}". They may be in disconnected components, or the call graph index needs updating.`;
|
|
10806
|
+
}
|
|
10807
|
+
const formatted = path18.map((hop, i) => {
|
|
10808
|
+
const prefix = i === 0 ? "[start]" : `--${hop.callType}-->`;
|
|
10809
|
+
const location = hop.filePath ? ` (${hop.filePath}:${hop.line})` : "";
|
|
10810
|
+
return `${prefix} ${hop.symbolName}${location}`;
|
|
10811
|
+
});
|
|
10812
|
+
return `Path (${path18.length} hops):
|
|
10813
|
+
${formatted.join("\n")}`;
|
|
10814
|
+
}
|
|
10815
|
+
});
|
|
10769
10816
|
var add_knowledge_base = tool({
|
|
10770
10817
|
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).",
|
|
10771
10818
|
args: {
|
|
@@ -11197,6 +11244,8 @@ var RoutingHintController = class {
|
|
|
11197
11244
|
this.getStatus = getStatus;
|
|
11198
11245
|
this.maxSessions = maxSessions;
|
|
11199
11246
|
}
|
|
11247
|
+
getStatus;
|
|
11248
|
+
maxSessions;
|
|
11200
11249
|
sessionState = /* @__PURE__ */ new Map();
|
|
11201
11250
|
observeUserMessage(sessionID, parts) {
|
|
11202
11251
|
const assessment = assessRoutingIntent(extractUserText(parts));
|
|
@@ -11324,6 +11373,7 @@ var plugin = async ({ directory, worktree }) => {
|
|
|
11324
11373
|
index_logs,
|
|
11325
11374
|
find_similar,
|
|
11326
11375
|
call_graph,
|
|
11376
|
+
call_graph_path,
|
|
11327
11377
|
implementation_lookup,
|
|
11328
11378
|
add_knowledge_base,
|
|
11329
11379
|
list_knowledge_bases,
|