Skip to content

OpenCode hook misses .opencode project permissions and can lift deny or ask #4855

Open

Description

@superbiche

RTK 1.1.0 (tag v1.1.0, 753a3b0) and current develop (7e92da0; the file is byte-identical). OpenCode v2.0.26.

What happens. rtk hook opencode reads project permissions only from an ancestor directory's direct opencode.json/opencode.jsonc (src/hooks/permissions_opencode.rs, project_root_with_config / read_first_config). OpenCode v2 also discovers .opencode/opencode.json(c) (packages/core/src/config/discovery.ts). A project-level deny or ask placed there is invisible to the verdict comparison, so the hook rewrites and the native rule no longer matches the rewritten command.

Reproduction (disposable HOME, no config overrides):

  1. $HOME/.config/opencode/opencode.json:
    {"permissions":[{"action":"shell","resource":"*","effect":"allow"}]}
  2. In a project, .opencode/opencode.json:
    {"permissions":[{"action":"shell","resource":"git diff","effect":"deny"}]}
  3. From the project: rtk hook opencode "git diff" → exit 0, {"command":"rtk git diff"} (deny lifted).
  4. Move the same file to ./opencode.json and repeat → exit 0, {} (correct).

Confirmed end to end with the stock execute.before plugin on OpenCode 2.0.26: the raw git diff is denied by OpenCode, the rewritten rtk git diff runs and its output reaches the model. Replacing deny with ask silences the prompt the same way.

Expected. {} in both placements, since the rewrite changes the native verdict (the fail-closed rule from #4195 / #4187).

Proposed fix. Discover .opencode/ directories alongside direct files, preserving OpenCode's order (direct files outermost first, then project directories outermost first, opencode.json before opencode.jsonc per directory). PR follows; it is a focused discovery fix, not a claim of complete discovery parity (profile, agent-file and content sources still need their own qualification).


@superbiche · user · drafted with Claude Fable 5.1, reviewed before posting; the voice and decisions are mine.

Activity

  1. rtk-wshm-sync-bot commented on Oct 30, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 90%

    Summary

    OpenCode hook doesn't discover .opencode/opencode.json(c) project configs, letting a project-level deny/ask rule get silently lifted by the rewrite.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/hooks/permissions_opencode.rs

    Suggested Actions

    1. Extend project_root_with_config/read_first_config in src/hooks/permissions_opencode.rs to check .opencode/ dirs
    2. Preserve OpenCode's discovery order: direct files outermost-first, then .opencode/ dirs outermost-first, json before js…
    3. Cross-check against the fail-closed fix in PR fix(hooks): judge OpenCode against its own permission rules #4349 (fix(hooks): judge OpenCode against its own permission rules)
    4. Author has a PR in progress per the issue — ask for status/link and review when posted

    Triaged automatically by wshm · This is an automated analysis, not a human review.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions