Split external_directory permission into read vs write #3483

Open
opened 2026-02-16 17:40:17 -05:00 by yindo · 10 comments
Owner

Originally created by @charles-cooper on GitHub (Dec 11, 2025).

Originally assigned to: @thdxr on GitHub.

Currently, external_directory is a single permission that controls all file operations (read, write, edit, patch, bash workdir) outside the working directory. This makes it impossible to allow reading external files while blocking writes.

Use case

I want the agent to be able to read reference files, configs, or documentation outside the project directory without prompts, but still block (or prompt for) any writes to external locations. Currently I must choose between:

  • "allow" - permits both reads and writes (too permissive)
  • "ask" - prompts for every read (too noisy)
  • "deny" - blocks all external access (too restrictive)

Proposed solution

Split into two permissions:

{
  "permission": {
    "external_directory_read": "allow",
    "external_directory_write": "ask"
  }
}

Or alternatively, add a mode qualifier:

{
  "permission": {
    "external_directory": {
      "read": "allow",
      "write": "ask"
    }
  }
}

Implementation notes

Looking at the source, this would require:

  1. Update config schema in config/config.ts and agent/agent.ts
  2. Modify permission checks in tool/read.ts, tool/write.ts, tool/edit.ts, tool/patch.ts, tool/bash.ts to use the appropriate permission type
  3. For backwards compatibility, the existing external_directory could be kept as a shorthand that sets both read and write

Note: This issue was drafted with Claude Opus 4.5

Originally created by @charles-cooper on GitHub (Dec 11, 2025). Originally assigned to: @thdxr on GitHub. Currently, `external_directory` is a single permission that controls all file operations (read, write, edit, patch, bash workdir) outside the working directory. This makes it impossible to allow reading external files while blocking writes. ## Use case I want the agent to be able to read reference files, configs, or documentation outside the project directory without prompts, but still block (or prompt for) any writes to external locations. Currently I must choose between: - `"allow"` - permits both reads and writes (too permissive) - `"ask"` - prompts for every read (too noisy) - `"deny"` - blocks all external access (too restrictive) ## Proposed solution Split into two permissions: ```json { "permission": { "external_directory_read": "allow", "external_directory_write": "ask" } } ``` Or alternatively, add a `mode` qualifier: ```json { "permission": { "external_directory": { "read": "allow", "write": "ask" } } } ``` ## Implementation notes Looking at the source, this would require: 1. Update config schema in `config/config.ts` and `agent/agent.ts` 2. Modify permission checks in `tool/read.ts`, `tool/write.ts`, `tool/edit.ts`, `tool/patch.ts`, `tool/bash.ts` to use the appropriate permission type 3. For backwards compatibility, the existing `external_directory` could be kept as a shorthand that sets both read and write --- *Note: This issue was drafted with Claude Opus 4.5*
Author
Owner

@github-actions[bot] commented on GitHub (Dec 11, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #4991: More general external_directory permissions - proposes making external_directory permissions more granular and extensible
  • #4743: Allow /tmp or $TMPDIR folder access option - requests path-specific permission control for external directories

Feel free to ignore if your use case is different from these.

@github-actions[bot] commented on GitHub (Dec 11, 2025): This issue might be a duplicate of existing issues. Please check: - #4991: More general external_directory permissions - proposes making external_directory permissions more granular and extensible - #4743: Allow /tmp or $TMPDIR folder access option - requests path-specific permission control for external directories Feel free to ignore if your use case is different from these.
Author
Owner

@rekram1-node commented on GitHub (Dec 11, 2025):

Yeah we need more granular permissions

@rekram1-node commented on GitHub (Dec 11, 2025): Yeah we need more granular permissions
Author
Owner

@jgordijn commented on GitHub (Dec 18, 2025):

It would be nice if instead of just ask/allow/deny we can configure it even on directory bases:
something like:

"external_directory_read": {
   "~/.config/opencode/skills": "allow",
   "*": "ask"
}
@jgordijn commented on GitHub (Dec 18, 2025): It would be nice if instead of just ask/allow/deny we can configure it even on directory bases: something like: ``` "external_directory_read": { "~/.config/opencode/skills": "allow", "*": "ask" } ```
Author
Owner

@fpdy commented on GitHub (Dec 20, 2025):

made first proposal implementation at #5841

@fpdy commented on GitHub (Dec 20, 2025): made first proposal implementation at #5841
Author
Owner

@jgordijn commented on GitHub (Dec 21, 2025):

I also took a stab at it, so it may have been a waste of my time for this PR. It was a learning experience nonetheless. I leave it to the creators of OpenCode to decide which implementation is better. https://github.com/sst/opencode/pull/5905

Sorry @fpdy don't want to overrule you or anything. Was just playing with the codebase to see if I could do it. Didn't know you were also working on it.

@jgordijn commented on GitHub (Dec 21, 2025): I also took a stab at it, so it may have been a waste of my time for this PR. It was a learning experience nonetheless. I leave it to the creators of OpenCode to decide which implementation is better. https://github.com/sst/opencode/pull/5905 Sorry @fpdy don't want to overrule you or anything. Was just playing with the codebase to see if I could do it. Didn't know you were also working on it.
Author
Owner

@fpdy commented on GitHub (Dec 21, 2025):

@jgordijn Thanks for the kind words, I realize I should’ve said on the issue that I was working on it too — so sorry for the overlap and for making you spend time on it (btw your implementation looks a bit more solid than mine tbh)

@fpdy commented on GitHub (Dec 21, 2025): @jgordijn Thanks for the kind words, I realize I should’ve said on the issue that I was working on it too — so sorry for the overlap and for making you spend time on it (btw your implementation looks a bit more solid than mine tbh)
Author
Owner

@jgordijn commented on GitHub (Dec 21, 2025):

@fpdy you and me both :-). I didn't claim the issue as well. But hey, let's fix more ;-)

@jgordijn commented on GitHub (Dec 21, 2025): @fpdy you and me both :-). I didn't claim the issue as well. But hey, let's fix more ;-)
Author
Owner

@jgordijn commented on GitHub (Dec 29, 2025):

@thdxr Is there anything I/we can do to get this going? Does this stand a chance to get merged in?

@jgordijn commented on GitHub (Dec 29, 2025): @thdxr Is there anything I/we can do to get this going? Does this stand a chance to get merged in?
Author
Owner

@ethaizone commented on GitHub (Jan 21, 2026):

Any updates?

I'm looking forward to this feaure as it's really important for Go developer. In many cases we need AI to read latest code from ~/go/pkg/mod/github.com as Go doesn't install deps in work directory but install in folder inside home directory and in normal case. We need only read permissions.

Now I need to click accept manually everytimes.

@ethaizone commented on GitHub (Jan 21, 2026): Any updates? I'm looking forward to this feaure as it's really important for Go developer. In many cases we need AI to read latest code from `~/go/pkg/mod/github.com` as Go doesn't install deps in work directory but install in folder inside home directory and in normal case. We need only read permissions. Now I need to click accept manually everytimes.
Author
Owner

@Nindaleth commented on GitHub (Feb 4, 2026):

@jgordijn @fpdy I was interested in this too and after reading the current Permissions docs I believe OpenCode can do what you propose. What do you think?

@Nindaleth commented on GitHub (Feb 4, 2026): @jgordijn @fpdy I was interested in this too and after reading the current [Permissions](https://opencode.ai/docs/permissions/#external-directories) docs I believe OpenCode can do what you propose. What do you think?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3483