opencode-readseek 0.7.1 → 0.7.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.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/index.ts +9 -2
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # opencode-readseek
2
2
 
3
+ <img alt="Screenshot of OpenCode running opencode-readseek" src="screenshot.png" width="800">
4
+
3
5
  `opencode-readseek` exposes ReadSeek's hash-anchored text tools and structural
4
6
  code navigation as OpenCode tools.
5
7
 
package/index.ts CHANGED
@@ -11,6 +11,7 @@ import { tool, type Plugin, type PluginOptions, type ToolAttachment, type ToolCo
11
11
  const require = createRequire(import.meta.url);
12
12
  const MAX_OUTPUT_BYTES = 32 * 1024 * 1024;
13
13
  const DEFAULT_READ_LIMIT = 2000;
14
+ const EDIT_RESULT_READ_LIMIT = 40;
14
15
  const MAX_DOCUMENT_OUTPUT_BYTES = 256 * 1024;
15
16
  const MAX_DOCUMENT_OUTPUT_LINES = 2000;
16
17
  const EDITING_POLICY = [
@@ -1296,14 +1297,20 @@ export const ReadSeekPlugin: Plugin = async (_input, options) => {
1296
1297
  context.abort.throwIfAborted();
1297
1298
  await authorizeRead(context, filePath);
1298
1299
  await rejectSymlinkMutation(filePath);
1299
- const edits = input.edits;
1300
+ const edits = input.edits as AnchorEdit[];
1300
1301
  const before = await readFile(filePath, "utf8");
1301
1302
  await verifyAnchors(context, filePath, edits);
1302
1303
  const after = applyAnchorEdits(before, edits);
1303
1304
  await authorizeEdit(context, [filePath], simpleDiff(filePath, before, after), false);
1304
1305
  context.abort.throwIfAborted();
1305
1306
  if (before !== after) await writeText(filePath, { exists: true, content: before }, after);
1306
- return runReadSeek(context, ["read", filePath, "--end", String(DEFAULT_READ_LIMIT)], { cancelable: false });
1307
+ const firstEditedLine = Math.min(...edits.flatMap((edit) => anchorRefs(edit).map((ref) => ref.line)));
1308
+ const previewStart = Math.max(1, firstEditedLine - 3);
1309
+ return runReadSeek(
1310
+ context,
1311
+ ["read", `${filePath}:${previewStart}`, "--end", String(previewStart + EDIT_RESULT_READ_LIMIT - 1)],
1312
+ { cancelable: false },
1313
+ );
1307
1314
  });
1308
1315
  },
1309
1316
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-readseek",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "OpenCode plugin for readseek-backed structural code navigation",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
@@ -30,7 +30,7 @@
30
30
  "node": ">=20.0.0"
31
31
  },
32
32
  "dependencies": {
33
- "@jarkkojs/readseek": "^0.7.1",
33
+ "@jarkkojs/readseek": "^0.7.3",
34
34
  "@opencode-ai/plugin": "^1.17.20"
35
35
  },
36
36
  "devDependencies": {