Skip to content

https://arxiv.org/abs/2606.28344. The end of web parsing. The beginning of scalable pixel-native search. link: https://pixelrag.ai/

fix(opencode-plugin): default the tile directory inside the project (#157)

Zhifei Li0e22177a7948
diff --git a/plugin/opencode/README.md b/plugin/opencode/README.md
index cd6faa8..1e050c6 100644
--- a/plugin/opencode/README.md
+++ b/plugin/opencode/README.md
@@ -33,7 +33,7 @@ opencode run "screenshot https://news.ycombinator.com and summarize the top stor
The agent calls the `screenshot` tool with a URL (or a local HTML file, PDF, or image),
gets back the tile image paths, and reads them visually. Optional tool args: `output`
-(tile directory, default `/tmp/pixelbrowse`) and `viewportWidth` (default 875; use 1280
+(tile directory, default `.opencode/pixelbrowse` inside the project) and `viewportWidth` (default 875; use 1280
for desktop layouts).
No MCP server, no backend — the plugin just calls `pixelshot` on your machine.
diff --git a/plugin/opencode/index.js b/plugin/opencode/index.js
index 56d833b..4f184aa 100644
--- a/plugin/opencode/index.js
+++ b/plugin/opencode/index.js
@@ -13,7 +13,7 @@ further down. Tiles are rendered at 1568px height for optimal vision-model reada
If text or details are too small to read, crop the region of interest from a tile and
re-read at full resolution. Pillow is always available (it's a pixelshot dependency):
- python3 -c "from PIL import Image; Image.open('<tile>').crop((x1, y1, x2, y2)).save('/tmp/pixelbrowse/crop.png')"
+ python3 -c "from PIL import Image; Image.open('<tile>').crop((x1, y1, x2, y2)).save('<tile>.crop.png')"
Crop to roughly 800x800 or smaller for maximum clarity.`
const INSTALL_HINT =
@@ -55,7 +55,9 @@ export const PixelbrowsePlugin = async ({ $ }) => {
output: tool.schema
.string()
.optional()
- .describe("Output directory for tiles (default /tmp/pixelbrowse)"),
+ .describe(
+ "Output directory for tiles (default .opencode/pixelbrowse inside the project)"
+ ),
viewportWidth: tool.schema
.number()
.optional()
@@ -63,8 +65,12 @@ export const PixelbrowsePlugin = async ({ $ }) => {
"Viewport width in px (default 875, mobile/article width). Use 1280 for desktop layouts."
),
},
- async execute(args) {
- const output = args.output ?? "/tmp/pixelbrowse"
+ async execute(args, context) {
+ // Default inside the project: tiles written outside it trip opencode's
+ // external_directory permission, which auto-rejects under `opencode run`,
+ // so the agent gets tile paths it is not allowed to read.
+ const output =
+ args.output ?? join(context.worktree ?? context.directory, ".opencode", "pixelbrowse")
try {
await $`which pixelshot`.quiet()