Skip to content

OpenCode: rtk hook check --agent opencode judges differently from the plugin #4518

Open

Description

@KuSh

rtk hook opencode (what the plugin calls) answers {} in two cases where rtk can't judge the rules, so the command runs as typed:

  • the active agent's markdown file declares permission:/permissions:;
  • a legacy permission key means different rules to OpenCode 1.x and 2.x (shell, sh*, b*).

rtk hook check --agent opencode loads the same rules through check_command_for_agent → load_opencode_rules and applies neither guard, so it can report a rewrite the plugin refuses. Example: a project opencode.json with {"permission":{"bash":{"ls *":"ask"},"shell":"allow"}}. rtk hook opencode ls -la prints {}, but rtk hook check --agent opencode ls -la reports rtk ls -la.

Found while reviewing #4187. Diagnostic only; rewriting is not affected.

A fix passes this row: in that directory, both commands agree, and hook check reports no rewrite.

Activity

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

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 90%

    Summary

    rtk hook check --agent opencode skips the permission-declaration and legacy permission key guards that rtk hook opencode applies, causing divergent judgments on OpenCode config.

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

    📁 Relevant files
    • src/hook/check.rs
    • src/hook/opencode.rs

    Suggested Actions

    1. Port the two guards (permission/permissions declaration check, legacy permission key handling) from the opencode hook…
    2. Add a regression test with the example opencode.json ({"permission":{"bash":{"ls *":"ask"},"shell":"allow"}}) asserting…
    3. Cross-reference feat(hook/opencode): support OpenCode V2, Desktop, and Windows (#3463, #3326) #4187 and OpenCode permission rules: rtk's config loader diverges from OpenCode's config resolution #4422 since both touch OpenCode config/rule loading divergence

    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

    Labels

    area:clibugopencodepriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions