Skip to content

feat: make openspec-plan agent permissions fully explicit#8

Merged
Octane0411 merged 2 commits intoOctane0411:mainfrom
JAPACX:feat/explicit-agent-permissions
Mar 23, 2026
Merged

feat: make openspec-plan agent permissions fully explicit#8
Octane0411 merged 2 commits intoOctane0411:mainfrom
JAPACX:feat/explicit-agent-permissions

Conversation

@JAPACX
Copy link
Contributor

@JAPACX JAPACX commented Mar 19, 2026

Summary

The openspec-plan agent previously only declared edit permissions, leaving
all other tools (read, bash, glob, grep, etc.) as implicit — relying on
OpenCode's global defaults.

This made the agent's actual capabilities opaque and created a risk of unintended access.

This PR replaces the minimal permission block with a fully explicit declaration
covering every OpenCode permission key relevant to the agent.

Changes

src/config.tsopenSpecAgent.permission

read

  • Allow all file reads
  • Explicitly deny .env files (a spec agent has no need for secrets)

edit

  • Base rule: "*": "deny" — nothing is editable by default
  • Explicit allow only for spec targets: project.md, AGENTS.md,
    openspec/**, specs/**

bash

  • Base rule: "*": "deny" — no arbitrary shell execution
  • Allow read-only filesystem commands: grep, ls, cat, find,
    echo, pwd, which, env, printenv
  • Allow git read-only: git status*, git log*, git diff*, git show*
    (useful for repo context without risk of mutations)

All other tools

Explicitly declared as allow or ask instead of relying on defaults:

  • glob, grep, list, lsp — allow (read-only exploration)
  • todoread, todowrite — allow (internal task tracking)
  • webfetch, websearch, codesearch — allow (doc/reference lookup)
  • task, skill, question — allow (subagents and user interaction)
  • doom_loop, external_directory — ask (safety guards, unchanged)

Why last-match-wins matters here

OpenCode evaluates granular permission rules in order, with the last matching
rule winning
. For edit and bash, the catch-all "*": "deny" is placed
first so that the specific allow rules after it correctly override it.

No functional change for spec files

The set of files the agent can edit is identical to before. This PR only makes
the full permission surface explicit and adds a deny baseline for everything
outside that set.

- Add explicit allow/deny for all OpenCode permission keys
- read: allow all, deny .env files
- edit: deny * base, allow only spec files (project.md, AGENTS.md, openspec/**, specs/**)
- bash: deny * base, allow read-only filesystem and git read commands
- Add explicit allow for glob, grep, list, lsp, todoread, todowrite
- Add explicit allow for webfetch, websearch, codesearch, task, skill, question
- Keep doom_loop and external_directory as ask (safety guards)
@JAPACX
Copy link
Contributor Author

JAPACX commented Mar 19, 2026

The .env deny rules gave a false sense of security since bash tools
(cat, grep) could still access them. Agent is trusted with full read
access to the project.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Octane0411 Octane0411 merged commit f4d0b35 into Octane0411:main Mar 23, 2026
@Octane0411
Copy link
Owner

Thanks for the PR! I added a small commit to remove the .env deny rules — since bash tools like cat/grep can still access them anyway, the deny gave a false sense of security. Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants