Problem
getImageOutputDir() in src/plugin/image-saver.ts hardcodes the generated image output directory to ~/.opencode/generated-images/:
function getImageOutputDir(outputDir) {
const resolved = outputDir ?? join(homedir(), '.opencode', 'generated-images');
if (!existsSync(resolved)) mkdirSync(resolved, { recursive: true });
return resolved;
}
There is no way to configure this path — no env var, no config option, no plugin hook on the output side.
Use Case
When using image generation subagents (e.g. task(category="image-generation")), generated images always land in ~/.opencode/generated-images/ regardless of the project context. Users working on specific projects (e.g. e-commerce product shots) need images saved directly to their project directory without manual copying after every generation.
Proposed Solution
Add process.env.OPENCODE_IMAGE_OUTPUT_DIR as a fallback before the hardcoded default:
function getImageOutputDir(outputDir) {
const resolved = outputDir ?? process.env.OPENCODE_IMAGE_OUTPUT_DIR ?? join(homedir(), '.opencode', 'generated-images');
if (!existsSync(resolved)) mkdirSync(resolved, { recursive: true });
return resolved;
}
This is a one-line change that:
- Maintains full backward compatibility (env var unset = same behavior as today)
- Lets users set
OPENCODE_IMAGE_OUTPUT_DIR globally or per-session
- Enables plugins to dynamically redirect output by setting
process.env.OPENCODE_IMAGE_OUTPUT_DIR in the same Node.js process (since the auth plugin and local plugins share the same runtime)
Current Workaround
We patch dist/src/plugin/image-saver.js and dist/index.js (both in node_modules and the Bun cache at ~/.cache/opencode/packages/@cortexkit/opencode-antigravity-auth@latest/) via a post-install script. The patch gets overwritten on every npm install and must be re-applied manually.
Environment
- OpenCode on Windows (Bun runtime)
@cortexkit/opencode-antigravity-auth@latest
- Node 26, Bun standalone binary
Note on Bun Cache
Bun loads the plugin from ~/.cache/opencode/packages/@cortexkit/opencode-antigravity-auth@latest/ rather than the project node_modules/, so patches to node_modules/ alone have no effect — the cache copy must also be patched. A native env var support in the source would eliminate this entirely.
Problem
getImageOutputDir()insrc/plugin/image-saver.tshardcodes the generated image output directory to~/.opencode/generated-images/:There is no way to configure this path — no env var, no config option, no plugin hook on the output side.
Use Case
When using image generation subagents (e.g.
task(category="image-generation")), generated images always land in~/.opencode/generated-images/regardless of the project context. Users working on specific projects (e.g. e-commerce product shots) need images saved directly to their project directory without manual copying after every generation.Proposed Solution
Add
process.env.OPENCODE_IMAGE_OUTPUT_DIRas a fallback before the hardcoded default:This is a one-line change that:
OPENCODE_IMAGE_OUTPUT_DIRglobally or per-sessionprocess.env.OPENCODE_IMAGE_OUTPUT_DIRin the same Node.js process (since the auth plugin and local plugins share the same runtime)Current Workaround
We patch
dist/src/plugin/image-saver.jsanddist/index.js(both innode_modulesand the Bun cache at~/.cache/opencode/packages/@cortexkit/opencode-antigravity-auth@latest/) via a post-install script. The patch gets overwritten on everynpm installand must be re-applied manually.Environment
@cortexkit/opencode-antigravity-auth@latestNote on Bun Cache
Bun loads the plugin from
~/.cache/opencode/packages/@cortexkit/opencode-antigravity-auth@latest/rather than the projectnode_modules/, so patches tonode_modules/alone have no effect — the cache copy must also be patched. A native env var support in the source would eliminate this entirely.