Skip to content

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

Closed
log0u7 wants to merge 2 commits into
anomalyco:devfrom
log0u7:fix/opencode-pollution
Closed

log0u7 wants to merge 2 commits into
anomalyco:devfrom
log0u7:fix/opencode-pollution

Conversation

@log0u7

@log0u7 log0u7 commented Aug 29, 2026

Copy link
Copy Markdown

Auto-closed by the compliance bot after a body edit broke the template section header (renamed ### Issue for this PR to ### Issues for this PR). Reopening was refused by the API (422).

Superseded by #49502 (same branch fix/opencode-pollution, same commits).

…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.

Per-directory dependency installs used to write package manifest, lockfile
and node_modules directly into config directories (~/.config/opencode and
every project .opencode), violating the XDG base directory spec (anomalyco#27786)
and polluting project trees.

Installs now target a per-directory store under
~/.local/share/opencode/deps/<hash>/, and config dirs only get a
node_modules symlink pointing there so bare imports from local plugins
keep resolving through parent-directory traversal. Installs fall back to
the config dir when symlinks are unavailable (e.g. unprivileged Windows)
or when a real node_modules directory already exists there.

Also documents plans_directory, OPENCODE_DISABLE_PLUGIN_DEPS and the new
install location in the website docs.

Refs anomalyco#46189, closes anomalyco#27786
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Sep 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@log0u7

log0u7 commented Sep 16, 2026

Copy link
Copy Markdown
Author

Friendly ping for review - this is open since Aug 29 with green CI and still merges cleanly against current dev (no drift on the touched files).

Since the last update, this PR now also closes #27786: per-directory dependency installs land in a store under ~/.local/share/opencode/deps/<hash>/ (XDG data dir), config directories keep only a node_modules symlink so bare imports from local plugins keep resolving, existing real node_modules dirs are left untouched, and unprivileged environments (e.g. Windows without symlink rights) fall back to the previous in-place install. Docs added for plans_directory, OPENCODE_DISABLE_PLUGIN_DEPS and the new install location (packages/web/src/content/docs/config.mdx).

Happy to split the relocation into its own PR if that helps review.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 17, 2026
@github-actions github-actions Bot closed this Sep 17, 2026
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant