Repository navigation
feat(acp): support additional workspace directories - #52524
Merged
Merged
Conversation
# Conflicts: # packages/cli/test/acp/wire-fixture.ts
Ichinose-Kazuki
pushed a commit
to Ichinose-Kazuki/opencode
that referenced
this pull request
Oct 7, 2026
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#35457
Why the change
ACP clients can now give a session extra workspace roots with
additionalDirectories, and opencode tools can work in those roots without asking for outside-directory approval each time.Special things to note
opencode.acp.additionalDirectoriesis the source of truth. Rules are derived from it, and a session rule is ACP's only if it exactly equals a rule derived from the stored list. Load, resume and fork replace those rules and keep every other rule and metadata key. Each root is granted under both its written spelling and its real path, because tools compare paths without following symlinks.external_directorydeny inside a granted root is overridden.read,editand shell rules still apply.*or?, because the permission matcher has no escaping. Anything else is rejected with-32602. The ACP SDK (1.2.1) silently drops entries that are not strings and turns a value that is not an array into[]before the agent sees it, which fails toward a smaller scope. Discovery, the Location root, and telling the model about the roots are deferred core work.Change outline
Each lifecycle request maps to a session change through the existing session API:
session/new { cwd, additionalDirectories } + parse → session.create({ location, permissions: rules(dirs), metadata: { [key]: dirs } }) # no field → neither session/load { sessionId, cwd, additionalDirectories } session/resume { sessionId, cwd, additionalDirectories } + parse → getSession → activate(session, dirs) → attach session/fork { sessionId, cwd, additionalDirectories } + parse → fork → activate(forked, dirs) # forks copy rules and metadata, so inherited grants are replaced session/list + SessionInfo.additionalDirectories = metadata[key] initialize + sessionCapabilities.additionalDirectories = {}How a root becomes rules and how
activatereconciles them:ACP rules go first so the session's other rules, including denies, keep precedence for the same paths.
FileAccessasks for<parent dir>/*on any path outside the session directory. Core takes the last rule that matches, and*in a pattern also matches/. So/abs/root/*allows anything under the root, but not/abs/rootx/*or/abs/*.