[PR #8859] feat: Permissions dialog #12889

Open
opened 2026-02-16 18:17:46 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8859

State: open
Merged: No


What does this PR do?

Fixes #3261

Happy for feedback/pushback, implemented the way I would I have liked it, but it doesn't mean it fits everyone.

First, fixed small bug in TUI, causing edit-cancel to exit the dialog

Created a "permissions" dialog that shows the permissions from:

  1. session level ("allow always" in the dialog)
  2. project level (in opencode.json)
  3. global level (in ~/.config/opencode/opencode.json)
  4. "default" (hardcoded, agent specific)

1-3 are editable (CRUD) in the dialog. 2-3 show confirmations prompts when writing.
Changes are persisted to the relevant files.
Small hint on how execute perms work with wildcards

Added debug command to show permissions for a quicker feedback loop.

How did you verify your code works?

Tested locally with the following:

$ cat ~/.config/opencode/opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "permission": {
    "read": {
      "*.password": "deny",
      "*.key": "deny",
      "credentials.json": "deny"
    },
    "bash": {
      "dnf *": "deny",
      "yum *": "deny",
      "apt *": "deny"
    },
    "webfetch": "deny",
    "external_directory": {
      "/var/*": "deny",
      "/etc/*": "deny",
      "/sys/*": "deny"
    }
  }
}

$ cat opencode.json 
{
  "$schema": "https://opencode.ai/config.json",
  "permission": {
    "read": {
      "*": "allow",
      "*.secret": "deny",
      ".env*": "ask",
      "node_modules/**": "allow"
    },
    "edit": {
      "*": "allow",
      "package.json": "ask",
      "*.lock": "deny"
    },
    "bash": {
      "ffeff*": "ask",
      "rm *": "deny"
    },
    "glob": "allow",
    "grep": "allow",
    "webfetch": "allow",
    "websearch": "ask",
    "codesearch": "allow",
    "todowrite": "allow",
    "todoread": "allow",
    "question": "allow",
    "external_directory": {
      "/tmp/*": "allow",
      "/home/*": "ask"
    }
  }
}

Screenshots from bun dev:
image
image
image
When editing
image
When editing a non-session permission, after pressing enter
image
image
image

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8859 **State:** open **Merged:** No --- ### What does this PR do? Fixes #3261 Happy for feedback/pushback, implemented the way I would I have liked it, but it doesn't mean it fits everyone. First, fixed small bug in TUI, causing edit-cancel to exit the dialog Created a "permissions" dialog that shows the permissions from: 1. session level ("allow always" in the dialog) 2. project level (in `opencode.json`) 3. global level (in `~/.config/opencode/opencode.json`) 4. "default" (hardcoded, agent specific) 1-3 are editable (CRUD) in the dialog. 2-3 show confirmations prompts when writing. Changes are persisted to the relevant files. Small hint on how execute perms work with wildcards Added debug command to show permissions for a quicker feedback loop. ### How did you verify your code works? Tested locally with the following: ``` $ cat ~/.config/opencode/opencode.json { "$schema": "https://opencode.ai/config.json", "permission": { "read": { "*.password": "deny", "*.key": "deny", "credentials.json": "deny" }, "bash": { "dnf *": "deny", "yum *": "deny", "apt *": "deny" }, "webfetch": "deny", "external_directory": { "/var/*": "deny", "/etc/*": "deny", "/sys/*": "deny" } } } $ cat opencode.json { "$schema": "https://opencode.ai/config.json", "permission": { "read": { "*": "allow", "*.secret": "deny", ".env*": "ask", "node_modules/**": "allow" }, "edit": { "*": "allow", "package.json": "ask", "*.lock": "deny" }, "bash": { "ffeff*": "ask", "rm *": "deny" }, "glob": "allow", "grep": "allow", "webfetch": "allow", "websearch": "ask", "codesearch": "allow", "todowrite": "allow", "todoread": "allow", "question": "allow", "external_directory": { "/tmp/*": "allow", "/home/*": "ask" } } } ``` Screenshots from `bun dev`: <img width="1057" height="621" alt="image" src="https://github.com/user-attachments/assets/a13ed5b8-26dc-45fa-88f6-560745fc63d3" /> <img width="1246" height="940" alt="image" src="https://github.com/user-attachments/assets/c429e489-3efa-400a-b04d-52b1f3cda877" /> <img width="1296" height="975" alt="image" src="https://github.com/user-attachments/assets/304b48d4-68fb-46f9-b258-f3a915926fce" /> When editing <img width="1356" height="909" alt="image" src="https://github.com/user-attachments/assets/b16a3a88-5b6b-4411-983b-323068f3cbec" /> When editing a non-session permission, after pressing enter <img width="1270" height="891" alt="image" src="https://github.com/user-attachments/assets/c357c73e-6139-46ff-821b-1db23fb25572" /> <img width="1282" height="958" alt="image" src="https://github.com/user-attachments/assets/193b4c19-6e0c-45f9-af70-a78c31c72548" /> <img width="1267" height="966" alt="image" src="https://github.com/user-attachments/assets/a2dfe32b-c283-4bdb-8b50-5812efe4a853" />
yindo added the pull-request label 2026-02-16 18:17:46 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12889