Improve permission request messages; add external directory check for write tool#6714
Open
aspiers wants to merge 2 commits intoanomalyco:devfrom
Open
Improve permission request messages; add external directory check for write tool#6714aspiers wants to merge 2 commits intoanomalyco:devfrom
aspiers wants to merge 2 commits intoanomalyco:devfrom
Conversation
4c80a7e to
d5a655f
Compare
Contributor
Author
|
Turns out that it's still displaying all commands, even ones which are already allowed. Working on a fix. |
Without this patch, permission prompts showed generic messages like `Permission required` without providing specific details about what the user is granting permission for. This is a problem because users need clear, actionable information to make informed decisions about permission requests, especially for security-sensitive operations like bash commands and file access. This patch solves the problem by introducing a centralized `Permission.formatPermissionMessage()` function that generates context-aware messages based on permission type and metadata. The function provides specific details for each permission type (bash commands, file operations, web requests, etc.) and includes relevant paths, patterns, or queries in the message. Key changes: - Add `Permission.formatPermissionMessage()` with type-specific formatting - Update ACP agent to use formatted messages for tool call titles - Update CLI run command to use formatted permission prompts - Update TUI permission display with improved UI - Add metadata to bash, read, skill tools for better messages
Without this patch, the write tool had a TODO comment for checking external directory permissions but the implementation was incomplete. This meant that write operations to paths outside the working directory would proceed without requesting user permission. This is a problem because write operations outside the project directory could be security-sensitive, and users should be informed and able to approve or deny such operations. This patch solves the problem by implementing the external directory permission check using `ctx.ask()` with the `external_directory` permission type, following the same pattern used in other tools like bash. The check includes the parent directory pattern and provides appropriate metadata for permission message formatting. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
d5a655f to
d6f8783
Compare
This was referenced Jan 6, 2026
00637c0 to
71e0ba2
Compare
f1ae801 to
08fa7f7
Compare
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.
Summary
This PR improves permission request messages in opencode to provide users with
clear, actionable information about what they're approving. It also fixes a
security gap where write operations to external directories were not being
checked for permission.
Commit 1:
5b988f9a- feat: improve permission request messages with context-aware formattingProblem
Permission prompts would show full bash commands; however users couldn't see
which specific commands or files were being requested permission. This made it
a lot harder to understand and manage the impact of configured or per-session
allow lists.
Solution
Permission.formatMessage()function that generatescontext-aware messages based on permission type and metadata.
<TextBody>to<PermissionBody>and include more comprehensivedetails in each prompt.
Changes by File
packages/opencode/src/permission/index.tsformatMessage()function with type-specific formattingpackages/opencode/src/cli/cmd/run.tspackages/opencode/src/cli/cmd/tui/routes/session/permission.tsxPermissionBodycomponentpackages/opencode/src/acp/agent.tspackages/opencode/src/tool/bash.tspackages/opencode/src/tool/read.tspackages/opencode/src/tool/skill.tsMessage Example
Before:
After:
(assuming
grepis already allowed)Commit 2:
eeee56a- feat(write): add external directory permission checkProblem
The
writetool had a TODO comment for checking external directory permissionsbut the implementation was incomplete. Write operations to paths outside the
working directory would proceed without requesting user permission.
This is a security concern since writes outside the project directory could be
sensitive.
Solution
Implemented the external directory permission check using
ctx.ask()with theexternal_directorypermission type, following the same pattern used in readand bash tools.
Changes
packages/opencode/src/tool/write.tsTesting