Skip to content

[FEATURE]: Make bash arity dictionary (BashArity) configurable #46250

Closed as duplicate

Description

@7emotions
  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Context: The permission system's "always allow" whitelist pattern is computed by BashArity.prefix(tokens) (packages/opencode/src/permission/arity.ts), using a hardcoded ARITY dictionary keyed by known command prefixes (e.g. git: 2, gh: 3, npm: 2). When a command starts with an unknown wrapper/alias, the lookup fails and prefix() falls back to the first token only.

Concrete problem: For users who wrap shell commands (e.g. the rtk CLI rewrites git push --force origin main into rtk git push --force origin main), the permission request for the rewritten command produces an over-broad "always" whitelist:

  • BashArity.prefix(["rtk","git","push","--force","origin","main"]) → falls back to ["rtk"] → "rtk *"
  • Clicking Allow always on that request whitelists every rtk ... command, silently defeating per-command permission rules. For example a future rtk gh pr review --comment 123 — which the user's "rtk gh pr review*": "ask" rule was meant to gate — becomes auto-approved, because the approved rtk * rule is matched after the config ruleset via findLast in packages/opencode/src/permission/index.ts.

Request: Make the arity dictionary configurable so users can teach prefix() about wrapper commands/aliases:

  1. A config knob to extend/override the built-in ARITY map, e.g. "rtk git": 3, "rtk gh": 4, so prefix() yields rtk git push * / rtk gh pr review *; or
  2. A smarter prefix() that skips unknown leading tokens and resolves arity from the first known command, producing the same scoped patterns without config.

Relevant files: packages/opencode/src/permission/arity.ts, packages/opencode/src/tool/shell.ts (line ~409: scan.always.add(BashArity.prefix(tokens).join(" ") + " *")), packages/opencode/src/permission/index.ts (evaluate/findLast + approved rules).

Environment: opencode-ai 1.18.25, Linux

Activity

  1. github-actions commented on Aug 30, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Your request for a configurable arity dictionary (option 1) or smarter prefix resolution (option 2) overlaps significantly with both of those. It may be worth commenting on #35882 or re-opening #29311 with your expanded proposal rather than filing separately.

  2. 7emotions commented on Aug 30, 2026

    @7emotions
    Author

    Consolidating into #35882, which covers the root cause (permission rules matching rewritten commands after hooks). I've posted the arity-specific proposal there. Closing as duplicate.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions