Skip to content

feat: configurable plans directory and opt-out for plugin dependency installs - #46199

Open
log0u7 wants to merge 1 commit into
anomalyco:devfrom
log0u7:fix/opencode-pollution
Open

feat: configurable plans directory and opt-out for plugin dependency installs#46199
log0u7 wants to merge 1 commit into
anomalyco:devfrom
log0u7:fix/opencode-pollution

Conversation

@log0u7

@log0u7 log0u7 commented Aug 29, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #46189

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Opening opencode in a git project and using plan mode creates <project>/.opencode/plans/. On the next start, that directory is picked up as a config directory and gets an automatic @opencode-ai/plugin dependency install, plus generated package manifest, lockfile and .gitignore files. Every project plan mode was used in ends up with its own copy, and ~/.config/opencode gets one too when it is a git repo. There is currently no way to opt out (details and code refs in #46189).

This PR adds two opt-outs, both default-preserving:

  • plans_directory config key (supports ~): plan files are written to the configured directory instead of the worktree/global defaults, e.g. the global data dir, so project trees stay untouched. The plan agent's built-in edit/external_directory allows were extended to the configured directory so plan mode keeps working.
  • OPENCODE_DISABLE_PLUGIN_DEPS=1 env flag: skips the per-directory dependency install and the generated files. Config discovery (agents, commands, plugins) is unaffected.

Default behavior is unchanged when neither is set.

How did you verify your code works?

  • New unit tests for Session.plan(): default paths (git / non-git), plans_directory override (absolute, ~, bare ~, relative), and a config-loader test asserting nothing is written into a config dir when the flag is set
  • Full bun run typecheck: 30/30 turbo tasks pass on bun 1.3.14 (the pinned version)
  • Manual e2e with the fork build in a throwaway git repo: plan file lands in the configured directory, no .opencode directory is created in the project

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…installs

Plan files were hardcoded to <worktree>/.opencode/plans for git projects,
and every discovered .opencode config directory got an automatic
@opencode-ai/plugin dependency install plus generated package manifest,
lockfile and .gitignore files. This pollutes every project plan mode
is used in, with no way to opt out.

- add plans_directory config key to relocate plan files (supports ~)
- add OPENCODE_DISABLE_PLUGIN_DEPS=1 to skip the per-directory
  dependency install and generated files
- extend the plan agent built-in edit/external_directory permissions
  to cover the configured plans directory

Refs anomalyco#46189
@log0u7

log0u7 commented Aug 29, 2026

Copy link
Copy Markdown
Author

For anyone landing here from the issue: ways to keep this clean today, before and after this PR.

On released versions (no PR needed):

  1. Git-wise you are already safe: opencode writes a .gitignore inside .opencode covering node_modules and the generated manifest files, so nothing reaches your commits. The clutter is filesystem-only.
  2. Shared .opencode symlink: make <project>/.opencode a symlink to one shared directory (e.g. ~/.local/share/opencode/workspace). The dependency install happens once, plan files land in a single place, and per-project agents/commands keep working. One caveat: an opencode.json inside the shared directory would apply to every project linked to it. Add .opencode to ~/.config/git/ignore so no repo ever tracks the symlink.
  3. OPENCODE_DISABLE_PROJECT_CONFIG=1 stops the per-project dependency installs, but also disables per-project AGENTS.md and config discovery. Only viable if you keep everything global.
  4. Periodic cleanup of .opencode works, but opencode reinstalls on the next open, so it is a treadmill.

With this PR:

Options 1-4 become unnecessary. Set plans_directory (e.g. ~/.local/share/opencode/plans) and/or OPENCODE_DISABLE_PLUGIN_DEPS=1 in your environment, and project directories stay completely untouched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.opencode/ dirs (plans + node_modules) duplicated in every opened project, no opt-out

1 participant