opencode-codebase-index 0.18.0 → 0.18.1
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/dist/index.cjs +85 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +84 -83
- 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.win32-x64-msvc.node +0 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -13120,11 +13120,12 @@ function getConfigPaths(projectRoot, host, options) {
|
|
|
13120
13120
|
].map((configPath) => pathNormalize(configPath));
|
|
13121
13121
|
}
|
|
13122
13122
|
|
|
13123
|
-
//
|
|
13124
|
-
var
|
|
13125
|
-
|
|
13126
|
-
|
|
13127
|
-
|
|
13123
|
+
// node_modules/@opencode-ai/plugin/dist/tool.js
|
|
13124
|
+
var import_zod = require("zod");
|
|
13125
|
+
function tool(input) {
|
|
13126
|
+
return input;
|
|
13127
|
+
}
|
|
13128
|
+
tool.schema = import_zod.z;
|
|
13128
13129
|
|
|
13129
13130
|
// src/tools/format-pr-impact.ts
|
|
13130
13131
|
function formatPrImpact(result) {
|
|
@@ -13178,16 +13179,16 @@ function formatPrImpact(result) {
|
|
|
13178
13179
|
}
|
|
13179
13180
|
|
|
13180
13181
|
// src/tools/pr-impact.ts
|
|
13181
|
-
var
|
|
13182
|
-
var pr_impact =
|
|
13182
|
+
var z2 = tool.schema;
|
|
13183
|
+
var pr_impact = tool({
|
|
13183
13184
|
description: "Analyze the impact of a pull request or branch by examining changed files, affected symbols, transitive callers, communities touched, hub nodes, and risk level. Use to understand blast radius before merging.",
|
|
13184
13185
|
args: {
|
|
13185
|
-
pr:
|
|
13186
|
-
branch:
|
|
13187
|
-
maxDepth:
|
|
13188
|
-
hubThreshold:
|
|
13189
|
-
checkConflicts:
|
|
13190
|
-
direction:
|
|
13186
|
+
pr: z2.number().optional().describe("Pull request number to analyze"),
|
|
13187
|
+
branch: z2.string().optional().describe("Branch name to analyze (defaults to current branch)"),
|
|
13188
|
+
maxDepth: z2.number().optional().default(5).describe("Maximum traversal depth for transitive callers (default: 5)"),
|
|
13189
|
+
hubThreshold: z2.number().optional().default(10).describe("Minimum caller count to flag a symbol as a hub node (default: 10)"),
|
|
13190
|
+
checkConflicts: z2.boolean().optional().default(false).describe("Check for conflicting open PRs touching the same communities (default: false)"),
|
|
13191
|
+
direction: z2.enum(["callers", "callees", "both"]).optional().default("both").describe("Call-graph traversal direction: 'callers' for upstream, 'callees' for downstream, 'both' for union (default: both)")
|
|
13191
13192
|
},
|
|
13192
13193
|
async execute(args, context) {
|
|
13193
13194
|
const indexer = getIndexerForProject2(context?.worktree);
|
|
@@ -14164,7 +14165,7 @@ function transformForVisualization(symbols, edges, options = {}) {
|
|
|
14164
14165
|
}
|
|
14165
14166
|
|
|
14166
14167
|
// src/tools/index.ts
|
|
14167
|
-
var
|
|
14168
|
+
var z3 = tool.schema;
|
|
14168
14169
|
var DEFAULT_HOST = "opencode";
|
|
14169
14170
|
var CHUNK_TYPE_VALUES = [
|
|
14170
14171
|
"function",
|
|
@@ -14186,34 +14187,34 @@ function initializeTools2(projectRoot, config) {
|
|
|
14186
14187
|
function getIndexerForProject2(directory) {
|
|
14187
14188
|
return getIndexerForProject(directory, DEFAULT_HOST);
|
|
14188
14189
|
}
|
|
14189
|
-
var codebase_context =
|
|
14190
|
+
var codebase_context = tool({
|
|
14190
14191
|
description: "PREFERRED FIRST TOOL for repository questions. Returns a deduplicated, file-diverse evidence pack within tokenBudget. Provide from and to for dependency paths, symbol for definitions, or only query for conceptual discovery.",
|
|
14191
14192
|
args: {
|
|
14192
|
-
query:
|
|
14193
|
-
from:
|
|
14194
|
-
to:
|
|
14195
|
-
symbol:
|
|
14196
|
-
limit:
|
|
14197
|
-
maxDepth:
|
|
14198
|
-
fileType:
|
|
14199
|
-
directory:
|
|
14200
|
-
tokenBudget:
|
|
14193
|
+
query: z3.string().describe("The repository question or behavior to locate"),
|
|
14194
|
+
from: z3.string().nullable().optional().describe("Source symbol for a dependency path"),
|
|
14195
|
+
to: z3.string().nullable().optional().describe("Target symbol for a dependency path"),
|
|
14196
|
+
symbol: z3.string().nullable().optional().describe("Exact symbol for authoritative definition lookup"),
|
|
14197
|
+
limit: z3.number().int().min(MIN_CONTEXT_RESULT_LIMIT).max(MAX_CONTEXT_RESULT_LIMIT).nullable().optional().default(10).describe(`Maximum number of results (${MIN_CONTEXT_RESULT_LIMIT}-${MAX_CONTEXT_RESULT_LIMIT})`),
|
|
14198
|
+
maxDepth: z3.number().int().min(MIN_CONTEXT_PATH_DEPTH).max(MAX_CONTEXT_PATH_DEPTH).nullable().optional().default(10).describe(`Maximum call-path traversal depth (${MIN_CONTEXT_PATH_DEPTH}-${MAX_CONTEXT_PATH_DEPTH})`),
|
|
14199
|
+
fileType: z3.string().nullable().optional().describe("Filter by file extension"),
|
|
14200
|
+
directory: z3.string().nullable().optional().describe("Filter by directory path"),
|
|
14201
|
+
tokenBudget: z3.number().int().min(MIN_CONTEXT_PACK_TOKEN_BUDGET).max(MAX_CONTEXT_PACK_TOKEN_BUDGET).nullable().optional().default(DEFAULT_CONTEXT_PACK_TOKEN_BUDGET).describe(`Maximum response tokens (${MIN_CONTEXT_PACK_TOKEN_BUDGET}-${MAX_CONTEXT_PACK_TOKEN_BUDGET})`)
|
|
14201
14202
|
},
|
|
14202
14203
|
async execute(args, context) {
|
|
14203
14204
|
return (await resolveCodebaseContext(context?.worktree, DEFAULT_HOST, args)).text;
|
|
14204
14205
|
}
|
|
14205
14206
|
});
|
|
14206
|
-
var codebase_peek =
|
|
14207
|
+
var codebase_peek = tool({
|
|
14207
14208
|
description: "Quick lookup of code locations by meaning. Returns only metadata (file, line, name, type) WITHOUT code content. Use this first to find WHERE code is, then use Read tool to examine specific files. Saves tokens by not returning full code blocks. Best for: discovery, navigation, finding multiple related locations.",
|
|
14208
14209
|
args: {
|
|
14209
|
-
query:
|
|
14210
|
-
limit:
|
|
14211
|
-
fileType:
|
|
14212
|
-
directory:
|
|
14213
|
-
chunkType:
|
|
14214
|
-
blameAuthor:
|
|
14215
|
-
blameSha:
|
|
14216
|
-
blameSince:
|
|
14210
|
+
query: z3.string().describe("Natural language description of what code you're looking for."),
|
|
14211
|
+
limit: z3.number().optional().default(10).describe("Maximum number of results to return"),
|
|
14212
|
+
fileType: z3.string().optional().describe("Filter by file extension (e.g., 'ts', 'py', 'rs')"),
|
|
14213
|
+
directory: z3.string().optional().describe("Filter by directory path (e.g., 'src/utils', 'lib')"),
|
|
14214
|
+
chunkType: z3.enum(CHUNK_TYPE_VALUES).optional().describe("Filter by code chunk type"),
|
|
14215
|
+
blameAuthor: z3.string().optional().describe("Filter by git blame author name or email"),
|
|
14216
|
+
blameSha: z3.string().optional().describe("Filter by git blame commit SHA or prefix"),
|
|
14217
|
+
blameSince: z3.string().optional().describe("Filter to chunks last changed on or after this date (e.g., 2025-01-01)")
|
|
14217
14218
|
},
|
|
14218
14219
|
async execute(args, context) {
|
|
14219
14220
|
const results = await searchCodebase(context?.worktree, DEFAULT_HOST, args.query, {
|
|
@@ -14229,12 +14230,12 @@ var codebase_peek = (0, import_plugin2.tool)({
|
|
|
14229
14230
|
return formatCodebasePeek(results);
|
|
14230
14231
|
}
|
|
14231
14232
|
});
|
|
14232
|
-
var index_codebase =
|
|
14233
|
+
var index_codebase = tool({
|
|
14233
14234
|
description: "Index the codebase for semantic search. Creates vector embeddings of code chunks. Incremental - only re-indexes changed files (~50ms when nothing changed). Run before first codebase_search.",
|
|
14234
14235
|
args: {
|
|
14235
|
-
force:
|
|
14236
|
-
estimateOnly:
|
|
14237
|
-
verbose:
|
|
14236
|
+
force: z3.boolean().optional().default(false).describe("Force reindex even if already indexed"),
|
|
14237
|
+
estimateOnly: z3.boolean().optional().default(false).describe("Only show cost estimate without indexing"),
|
|
14238
|
+
verbose: z3.boolean().optional().default(false).describe("Show detailed info about skipped files and parsing failures")
|
|
14238
14239
|
},
|
|
14239
14240
|
async execute(args, context) {
|
|
14240
14241
|
const result = await runIndexCodebase(context?.worktree, DEFAULT_HOST, args, (title, metadata) => {
|
|
@@ -14245,14 +14246,14 @@ var index_codebase = (0, import_plugin2.tool)({
|
|
|
14245
14246
|
return formatIndexStats(result.stats, args.verbose ?? false);
|
|
14246
14247
|
}
|
|
14247
14248
|
});
|
|
14248
|
-
var index_status =
|
|
14249
|
+
var index_status = tool({
|
|
14249
14250
|
description: "Check the status of the codebase index. Shows whether the codebase is indexed, how many chunks are stored, and the embedding provider being used.",
|
|
14250
14251
|
args: {},
|
|
14251
14252
|
async execute(_args, context) {
|
|
14252
14253
|
return formatStatus(await getIndexStatus(context?.worktree, DEFAULT_HOST));
|
|
14253
14254
|
}
|
|
14254
14255
|
});
|
|
14255
|
-
var index_health_check =
|
|
14256
|
+
var index_health_check = tool({
|
|
14256
14257
|
description: "Check index health and remove stale entries from deleted files. Run this to clean up the index after files have been deleted.",
|
|
14257
14258
|
args: {},
|
|
14258
14259
|
async execute(_args, context) {
|
|
@@ -14261,33 +14262,33 @@ var index_health_check = (0, import_plugin2.tool)({
|
|
|
14261
14262
|
return formatHealthCheck(result.health);
|
|
14262
14263
|
}
|
|
14263
14264
|
});
|
|
14264
|
-
var index_metrics =
|
|
14265
|
+
var index_metrics = tool({
|
|
14265
14266
|
description: "Get metrics and performance statistics for the codebase index. Shows indexing stats, search timings, cache hit rates, and API usage. Requires debug.enabled=true and debug.metrics=true in config.",
|
|
14266
14267
|
args: {},
|
|
14267
14268
|
async execute(_args, context) {
|
|
14268
14269
|
return (await getIndexMetrics(context?.worktree, DEFAULT_HOST)).text;
|
|
14269
14270
|
}
|
|
14270
14271
|
});
|
|
14271
|
-
var index_logs =
|
|
14272
|
+
var index_logs = tool({
|
|
14272
14273
|
description: "Get recent debug logs from the codebase indexer. Shows timestamped log entries with level and category. Requires debug.enabled=true in config.",
|
|
14273
14274
|
args: {
|
|
14274
|
-
limit:
|
|
14275
|
-
category:
|
|
14276
|
-
level:
|
|
14275
|
+
limit: z3.number().optional().default(20).describe("Maximum number of log entries to return"),
|
|
14276
|
+
category: z3.enum(["search", "embedding", "cache", "gc", "branch", "general"]).optional().describe("Filter by log category"),
|
|
14277
|
+
level: z3.enum(["error", "warn", "info", "debug"]).optional().describe("Filter by minimum log level")
|
|
14277
14278
|
},
|
|
14278
14279
|
async execute(args, context) {
|
|
14279
14280
|
return (await getIndexLogs(context?.worktree, DEFAULT_HOST, args)).text;
|
|
14280
14281
|
}
|
|
14281
14282
|
});
|
|
14282
|
-
var find_similar =
|
|
14283
|
+
var find_similar = tool({
|
|
14283
14284
|
description: "Find code similar to a given snippet. Use for duplicate detection, pattern discovery, or refactoring prep. Paste code and find semantically similar implementations elsewhere in the codebase.",
|
|
14284
14285
|
args: {
|
|
14285
|
-
code:
|
|
14286
|
-
limit:
|
|
14287
|
-
fileType:
|
|
14288
|
-
directory:
|
|
14289
|
-
chunkType:
|
|
14290
|
-
excludeFile:
|
|
14286
|
+
code: z3.string().describe("The code snippet to find similar code for"),
|
|
14287
|
+
limit: z3.number().optional().default(10).describe("Maximum number of results to return"),
|
|
14288
|
+
fileType: z3.string().optional().describe("Filter by file extension (e.g., 'ts', 'py', 'rs')"),
|
|
14289
|
+
directory: z3.string().optional().describe("Filter by directory path (e.g., 'src/utils', 'lib')"),
|
|
14290
|
+
chunkType: z3.enum(CHUNK_TYPE_VALUES).optional().describe("Filter by code chunk type"),
|
|
14291
|
+
excludeFile: z3.string().optional().describe("Exclude results from this file path (useful when searching for duplicates of code from a specific file)")
|
|
14291
14292
|
},
|
|
14292
14293
|
async execute(args, context) {
|
|
14293
14294
|
const results = await findSimilarCode(context?.worktree, DEFAULT_HOST, args.code, {
|
|
@@ -14303,18 +14304,18 @@ var find_similar = (0, import_plugin2.tool)({
|
|
|
14303
14304
|
return formatSearchResults(results);
|
|
14304
14305
|
}
|
|
14305
14306
|
});
|
|
14306
|
-
var codebase_search =
|
|
14307
|
+
var codebase_search = tool({
|
|
14307
14308
|
description: "Search codebase by MEANING, not keywords. Returns full code content. Use when you need to see actual implementation. For just finding WHERE code is (saves ~90% tokens), use codebase_peek instead. For known identifiers like 'validateToken', use grep - it's faster.",
|
|
14308
14309
|
args: {
|
|
14309
|
-
query:
|
|
14310
|
-
limit:
|
|
14311
|
-
fileType:
|
|
14312
|
-
directory:
|
|
14313
|
-
chunkType:
|
|
14314
|
-
contextLines:
|
|
14315
|
-
blameAuthor:
|
|
14316
|
-
blameSha:
|
|
14317
|
-
blameSince:
|
|
14310
|
+
query: z3.string().describe("Natural language description of what code you're looking for. Describe behavior, not syntax."),
|
|
14311
|
+
limit: z3.number().optional().default(5).describe("Maximum number of results to return"),
|
|
14312
|
+
fileType: z3.string().optional().describe("Filter by file extension (e.g., 'ts', 'py', 'rs')"),
|
|
14313
|
+
directory: z3.string().optional().describe("Filter by directory path (e.g., 'src/utils', 'lib')"),
|
|
14314
|
+
chunkType: z3.enum(CHUNK_TYPE_VALUES).optional().describe("Filter by code chunk type"),
|
|
14315
|
+
contextLines: z3.number().optional().describe("Number of extra lines to include before/after each match (default: 0)"),
|
|
14316
|
+
blameAuthor: z3.string().optional().describe("Filter by git blame author name or email"),
|
|
14317
|
+
blameSha: z3.string().optional().describe("Filter by git blame commit SHA or prefix"),
|
|
14318
|
+
blameSince: z3.string().optional().describe("Filter to chunks last changed on or after this date (e.g., 2025-01-01)")
|
|
14318
14319
|
},
|
|
14319
14320
|
async execute(args, context) {
|
|
14320
14321
|
const results = await searchCodebase(context?.worktree, DEFAULT_HOST, args.query, {
|
|
@@ -14333,13 +14334,13 @@ var codebase_search = (0, import_plugin2.tool)({
|
|
|
14333
14334
|
return formatSearchResults(results, "score");
|
|
14334
14335
|
}
|
|
14335
14336
|
});
|
|
14336
|
-
var implementation_lookup =
|
|
14337
|
+
var implementation_lookup = tool({
|
|
14337
14338
|
description: "Jump to symbol definition. Find WHERE something is defined. Returns the authoritative source location(s) for a function, class, method, type, or variable. Prefers real implementation files over tests, docs, examples, and fixtures. Use when you need the definition site, not all usages.",
|
|
14338
14339
|
args: {
|
|
14339
|
-
query:
|
|
14340
|
-
limit:
|
|
14341
|
-
fileType:
|
|
14342
|
-
directory:
|
|
14340
|
+
query: z3.string().describe("Symbol name or natural language description (e.g., 'validateToken', 'where is the payment handler defined')"),
|
|
14341
|
+
limit: z3.number().optional().default(5).describe("Maximum number of results"),
|
|
14342
|
+
fileType: z3.string().optional().describe("Filter by file extension (e.g., 'ts', 'py')"),
|
|
14343
|
+
directory: z3.string().optional().describe("Filter by directory path (e.g., 'src/utils')")
|
|
14343
14344
|
},
|
|
14344
14345
|
async execute(args, context) {
|
|
14345
14346
|
const results = await implementationLookup(context?.worktree, DEFAULT_HOST, args.query, {
|
|
@@ -14350,13 +14351,13 @@ var implementation_lookup = (0, import_plugin2.tool)({
|
|
|
14350
14351
|
return formatDefinitionLookup(results, args.query);
|
|
14351
14352
|
}
|
|
14352
14353
|
});
|
|
14353
|
-
var call_graph =
|
|
14354
|
+
var call_graph = tool({
|
|
14354
14355
|
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.",
|
|
14355
14356
|
args: {
|
|
14356
|
-
name:
|
|
14357
|
-
direction:
|
|
14358
|
-
symbolId:
|
|
14359
|
-
relationshipType:
|
|
14357
|
+
name: z3.string().describe("Function or method name to query"),
|
|
14358
|
+
direction: z3.enum(["callers", "callees"]).default("callers").describe("Direction: 'callers' finds who calls this function, 'callees' finds what this function calls"),
|
|
14359
|
+
symbolId: z3.string().optional().describe("Symbol ID (required for 'callees' direction, returned by previous call_graph queries)"),
|
|
14360
|
+
relationshipType: z3.enum(RELATIONSHIP_TYPE_VALUES).optional().describe("Filter by relationship type. Omit to show all.")
|
|
14360
14361
|
},
|
|
14361
14362
|
async execute(args, context) {
|
|
14362
14363
|
if (args.direction === "callees") {
|
|
@@ -14370,49 +14371,49 @@ var call_graph = (0, import_plugin2.tool)({
|
|
|
14370
14371
|
return formatCallGraphCallers(args.name, callers, args.relationshipType);
|
|
14371
14372
|
}
|
|
14372
14373
|
});
|
|
14373
|
-
var call_graph_path =
|
|
14374
|
+
var call_graph_path = tool({
|
|
14374
14375
|
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.",
|
|
14375
14376
|
args: {
|
|
14376
|
-
from:
|
|
14377
|
-
to:
|
|
14378
|
-
maxDepth:
|
|
14377
|
+
from: z3.string().describe("Source function/method name (starting point)"),
|
|
14378
|
+
to: z3.string().describe("Target function/method name (destination)"),
|
|
14379
|
+
maxDepth: z3.number().optional().default(10).describe("Maximum traversal depth (default: 10)")
|
|
14379
14380
|
},
|
|
14380
14381
|
async execute(args, context) {
|
|
14381
14382
|
const path24 = await getCallGraphPath(context?.worktree, DEFAULT_HOST, args.from, args.to, args.maxDepth);
|
|
14382
14383
|
return formatCallGraphPath(args.from, args.to, path24);
|
|
14383
14384
|
}
|
|
14384
14385
|
});
|
|
14385
|
-
var add_knowledge_base =
|
|
14386
|
+
var add_knowledge_base = tool({
|
|
14386
14387
|
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).",
|
|
14387
14388
|
args: {
|
|
14388
|
-
path:
|
|
14389
|
+
path: z3.string().describe("Path to the folder to add as a knowledge base (absolute or relative to the project root)")
|
|
14389
14390
|
},
|
|
14390
14391
|
async execute(args, context) {
|
|
14391
14392
|
return addKnowledgeBase(context?.worktree, DEFAULT_HOST, args.path);
|
|
14392
14393
|
}
|
|
14393
14394
|
});
|
|
14394
|
-
var list_knowledge_bases =
|
|
14395
|
+
var list_knowledge_bases = tool({
|
|
14395
14396
|
description: "List all configured knowledge base folders that are indexed alongside the main project.",
|
|
14396
14397
|
args: {},
|
|
14397
14398
|
async execute(_args, context) {
|
|
14398
14399
|
return listKnowledgeBases(context?.worktree, DEFAULT_HOST);
|
|
14399
14400
|
}
|
|
14400
14401
|
});
|
|
14401
|
-
var remove_knowledge_base =
|
|
14402
|
+
var remove_knowledge_base = tool({
|
|
14402
14403
|
description: "Remove a knowledge base folder from the semantic search index.",
|
|
14403
14404
|
args: {
|
|
14404
|
-
path:
|
|
14405
|
+
path: z3.string().describe("Path of the knowledge base to remove (must match the configured path exactly)")
|
|
14405
14406
|
},
|
|
14406
14407
|
async execute(args, context) {
|
|
14407
14408
|
return removeKnowledgeBase(context?.worktree, DEFAULT_HOST, args.path.trim());
|
|
14408
14409
|
}
|
|
14409
14410
|
});
|
|
14410
|
-
var index_visualize =
|
|
14411
|
+
var index_visualize = tool({
|
|
14411
14412
|
description: "Generate an interactive HTML visualization of recent code movement and the call graph. Starts with temporal onboarding context from Git history, then supports module, symbol, hotspot, and cycle drill-down.",
|
|
14412
14413
|
args: {
|
|
14413
|
-
directory:
|
|
14414
|
-
maxNodes:
|
|
14415
|
-
includeOrphans:
|
|
14414
|
+
directory: z3.string().optional().describe("Filter to symbols in this directory (e.g., 'src/services')"),
|
|
14415
|
+
maxNodes: z3.number().optional().default(5e3).describe("Maximum nodes to include (default 5000)"),
|
|
14416
|
+
includeOrphans: z3.boolean().optional().default(false).describe("Include symbols with no call relationships")
|
|
14416
14417
|
},
|
|
14417
14418
|
async execute(args, context) {
|
|
14418
14419
|
const projectRoot = context?.worktree ?? process.cwd();
|