opencode-readseek 0.11.1 → 0.11.3
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/index.js +14 -28
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -39,7 +39,6 @@ var PARAM_DESCRIPTIONS = {
|
|
|
39
39
|
projectSearchPath: "File or directory to search; defaults to the project directory",
|
|
40
40
|
searchPath: "File or directory to search; defaults to the current directory",
|
|
41
41
|
language: "Language override when auto-detection is ambiguous",
|
|
42
|
-
languageOverride: "Language override",
|
|
43
42
|
languageSymbol: "Language override for symbol replacement",
|
|
44
43
|
pattern: "AST pattern (ast-grep style), such as console.log($$$ARGS)",
|
|
45
44
|
patternContext: "Surrounding code context for sub-statement patterns",
|
|
@@ -56,14 +55,10 @@ var PARAM_DESCRIPTIONS = {
|
|
|
56
55
|
end: "Last line to include",
|
|
57
56
|
limit: "Maximum number of lines to include",
|
|
58
57
|
depth: "Maximum structural depth for structure output; defaults to 1 in agent tools",
|
|
59
|
-
offset: "One-based starting line",
|
|
60
|
-
readLimit: "Maximum lines to return",
|
|
61
|
-
symbolRead: "Symbol name to read",
|
|
62
|
-
bundle: "Include related symbols from the same file; requires symbol",
|
|
63
58
|
level: "Explicit inference level: low (default), medium, or high",
|
|
64
59
|
include: "Additional caption tasks: text and/or objects",
|
|
65
60
|
kind: "Restrict structure to this node kind",
|
|
66
|
-
outline: "
|
|
61
|
+
outline: "Show outline of document hierarchy or source symbols",
|
|
67
62
|
noAnchors: "Omit source line anchors",
|
|
68
63
|
text: "Literal native text query; adapter find_text also supports regex via pattern",
|
|
69
64
|
edits: "Use set_line, replace_lines, insert_after, replace_symbol, or replace",
|
|
@@ -119,11 +114,14 @@ var TOOL_DESCRIPTIONS = {
|
|
|
119
114
|
rename_symbol: "Rename a symbol at a line or hash cursor with binding-aware edits and stale-plan protection.",
|
|
120
115
|
write_file: "Create or replace a complete text file and return `LINE:HASH` anchors. Use `edit_text` for small changes."
|
|
121
116
|
};
|
|
117
|
+
function rewriteBacktickedToolNames(text, aliases = {}) {
|
|
118
|
+
return TOOL_NAMES.reduce((rewritten, toolName) => rewritten.replaceAll(`\`${toolName}\``, `\`${aliases[toolName] ?? toolName}\``), text);
|
|
119
|
+
}
|
|
122
120
|
function renderToolDescription(name, aliases = {}) {
|
|
123
121
|
const desc = TOOL_DESCRIPTIONS[name];
|
|
124
122
|
if (!desc)
|
|
125
123
|
throw new Error(`Missing TOOL_DESCRIPTIONS for ${name}`);
|
|
126
|
-
return
|
|
124
|
+
return rewriteBacktickedToolNames(desc, aliases);
|
|
127
125
|
}
|
|
128
126
|
var gitScopeSchema = {
|
|
129
127
|
gitScope: {
|
|
@@ -212,7 +210,7 @@ var TOOL_CONTRACTS = [
|
|
|
212
210
|
tool("show_metadata", "Show metadata", { ...path, ...lang, ...stdin }, ["path"]),
|
|
213
211
|
tool("show_assets", "Show assets", { ...path, at: string(PARAM_DESCRIPTIONS.assetAt), ...stdin }, ["path"]),
|
|
214
212
|
tool("check_syntax", "Check syntax", { ...path, ...lang, ...stdin }, ["path"]),
|
|
215
|
-
tool("check_rules", "Check rules", {
|
|
213
|
+
tool("check_rules", "Check rules", { path: string(PARAM_DESCRIPTIONS.searchPath), ...gitScopeSchema, rules: string(PARAM_DESCRIPTIONS.rules) }, ["rules"]),
|
|
216
214
|
tool("generate_caption", "Generate caption", { ...path, ...at, ...stdin, ...level, include: { type: "array", items: { type: "string", enum: ["text", "objects"] }, minItems: 1, uniqueItems: true, description: PARAM_DESCRIPTIONS.include } }, ["path"]),
|
|
217
215
|
tool("detect_objects", "Detect objects", { ...path, ...at, ...stdin, ...level }, ["path"]),
|
|
218
216
|
tool("recognize_text", "Recognize text", { ...path, ...at, ...stdin, ...level }, ["path"]),
|
|
@@ -236,12 +234,12 @@ var PREFERENCE_LEADS = {
|
|
|
236
234
|
show_content: "Preferred for reading source with anchors.",
|
|
237
235
|
edit_text: "Preferred for editing existing text files with fresh LINE:HASH anchors.",
|
|
238
236
|
write_file: "Preferred for creating or replacing a complete text file; returns LINE:HASH anchors.",
|
|
239
|
-
find_text: "Preferred text/regex
|
|
240
|
-
find_nodes: "Preferred for AST or structural code
|
|
237
|
+
find_text: "Preferred text/regex search; returns edit-ready LINE:HASH anchors.",
|
|
238
|
+
find_nodes: "Preferred for AST or structural code search with ast-grep-style patterns.",
|
|
241
239
|
find_definitions: "Preferred for go-to-definition or declaration lookup by name.",
|
|
242
240
|
find_references: "Preferred for finding identifier-name matches or binding-specific references before rename_symbol or delete.",
|
|
243
241
|
rename_symbol: "Preferred for renaming a symbol with binding-aware, verified edits.",
|
|
244
|
-
show_assets: "Preferred for
|
|
242
|
+
show_assets: "Preferred for materializing selected document assets with usable cached paths."
|
|
245
243
|
};
|
|
246
244
|
var FALLBACK_TEMPLATES = {
|
|
247
245
|
read: "Prefer `show_content` with fresh LINE:HASH anchors.",
|
|
@@ -253,9 +251,6 @@ var FALLBACK_TEMPLATES = {
|
|
|
253
251
|
function resolveToolName(name, aliases = {}) {
|
|
254
252
|
return aliases[name] ?? name;
|
|
255
253
|
}
|
|
256
|
-
function rewriteBacktickedToolNames(text, aliases = {}) {
|
|
257
|
-
return TOOL_NAMES.reduce((rewritten, toolName) => rewritten.replaceAll(`\`${toolName}\``, `\`${resolveToolName(toolName, aliases)}\``), text);
|
|
258
|
-
}
|
|
259
254
|
function renderPreferredToolDescription(name, aliases = {}) {
|
|
260
255
|
return rewriteBacktickedToolNames(PREFERENCE_LEADS[name] ?? `Preferred for ${name.replaceAll("_", " ")} with ReadSeek.`, aliases);
|
|
261
256
|
}
|
|
@@ -276,15 +271,6 @@ function renderToolRoutingPolicy(options = {}) {
|
|
|
276
271
|
const find_references = resolveToolName("find_references", aliases);
|
|
277
272
|
const rename_symbol = resolveToolName("rename_symbol", aliases);
|
|
278
273
|
const show_assets = resolveToolName("show_assets", aliases);
|
|
279
|
-
if (options.style === "server") {
|
|
280
|
-
return [
|
|
281
|
-
"Structural code navigation, document inspection, and hash-verified edits with readseek.",
|
|
282
|
-
"For structural questions, prefer these tools to text Grep/Bash: targeted definitions, references, and AST patterns; shallow show_structure views; check_syntax diagnostics and show_content cursor context; and document inspection.",
|
|
283
|
-
`Use ${edit_text} for LINE:HASH-anchored mutations (preview with apply=false; apply defaults to true and re-checks plan_hash).`,
|
|
284
|
-
"Paths resolve against CLAUDE_PROJECT_DIR. Native Read/Grep/Edit hooks provide passive context;",
|
|
285
|
-
"call MCP tools for active navigation, document questions, or anchored edits."
|
|
286
|
-
].join(" ");
|
|
287
|
-
}
|
|
288
274
|
const title = options.title ?? "ReadSeek tool policy:";
|
|
289
275
|
const bullets = [];
|
|
290
276
|
if (options.preferOverBuiltIns) {
|
|
@@ -1044,10 +1030,10 @@ function text(value) {
|
|
|
1044
1030
|
function count(value) {
|
|
1045
1031
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : undefined;
|
|
1046
1032
|
}
|
|
1047
|
-
function safe(value) {
|
|
1033
|
+
function safe(value, preserveTabs = false) {
|
|
1048
1034
|
return value.replace(/[\x00-\x09\x0b-\x1f\x7f-\x9f]/g, (char) => {
|
|
1049
1035
|
if (char === "\t")
|
|
1050
|
-
return "\\t";
|
|
1036
|
+
return preserveTabs ? char : "\\t";
|
|
1051
1037
|
if (char === "\r")
|
|
1052
1038
|
return "\\r";
|
|
1053
1039
|
return `\\x${char.charCodeAt(0).toString(16).padStart(2, "0")}`;
|
|
@@ -1207,7 +1193,7 @@ ${assetList(assets)}`);
|
|
|
1207
1193
|
const lang = text(metadata.language || content.language);
|
|
1208
1194
|
if (lang)
|
|
1209
1195
|
summary.push(inline(lang));
|
|
1210
|
-
const rows = lines.map((line) => `${line.line}${options.noAnchors ? "" : `:${text(line.hash)}`} | ${safe(text(line.text)
|
|
1196
|
+
const rows = lines.map((line) => `${line.line}${options.noAnchors ? "" : `:${text(line.hash)}`} | ${safe(text(line.text), true)}`);
|
|
1211
1197
|
const identifier = record(cursor.identifier);
|
|
1212
1198
|
if (count(cursor.line) !== undefined)
|
|
1213
1199
|
result.metadata.line = cursor.line;
|
|
@@ -2405,7 +2391,7 @@ function initialTitle(kind, args) {
|
|
|
2405
2391
|
case "find_definitions":
|
|
2406
2392
|
return `Find definition ${args.name}`;
|
|
2407
2393
|
case "find_references":
|
|
2408
|
-
return `Find references to ${args.name}`;
|
|
2394
|
+
return `Find references to ${args.name ?? args.at}`;
|
|
2409
2395
|
case "rename_symbol":
|
|
2410
2396
|
return `Rename ${args.path}:${args.at} to ${args.to}`;
|
|
2411
2397
|
case "edit_text":
|
|
@@ -2964,7 +2950,7 @@ var ReadSeekPlugin = async (_input, options) => {
|
|
|
2964
2950
|
if (!input.tool.startsWith("readseek_"))
|
|
2965
2951
|
return;
|
|
2966
2952
|
try {
|
|
2967
|
-
const result = JSON.parse(output.output);
|
|
2953
|
+
const result = output.metadata.readseek ?? JSON.parse(output.output);
|
|
2968
2954
|
if (input.tool === "readseek_rename_symbol") {
|
|
2969
2955
|
anchors.planRename(input.sessionID, result);
|
|
2970
2956
|
if (record2(result).applied === true) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-readseek",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"description": "OpenCode plugin for anchored file operations and structural code navigation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"node": ">=20.0.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@jarkkojs/readseek": "^0.11.
|
|
37
|
-
"@jarkkojs/readseek-api": "^0.11.
|
|
36
|
+
"@jarkkojs/readseek": "^0.11.3",
|
|
37
|
+
"@jarkkojs/readseek-api": "^0.11.3",
|
|
38
38
|
"@opencode-ai/plugin": "^1.18.18"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|