跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    中文English
    athal7

    Permission Log

    v1.0.0其他
    opencode-permission-log

    opencode plugin that logs permission prompt replies (once/always/reject) to a per-day JSON sidecar file, so static permission config can be tuned from real usage instead of re-approving the same pattern every session.

    GitHub 星标

    0

    月装机量

    28

    近 7 天 6

    综合评分SCORE

    29.0

    生态多维模型

    最近提交

    4 小时前

    2026-08-20

    快速安装与配置

    opencode.json

    写入当前项目的 opencode.json,只对这个仓库生效。

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-permission-log@1.0.0"]
    }

    opencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。

    opencode shows an interactive permission prompt every time a tool call needs your approval, and asks you to reply once, always, or reject. That reply is a real signal about what your checked-in permission config should say — this repo captures that signal (via a plugin) and turns it into actionable audit output (via an Agent Skill), so static permission config can be tuned from real usage instead of re-approving the same pattern every session.

    It contains two independent deliverables:

    • opencode-permission-log — an npm plugin that logs every permission reply to a local JSON sidecar file.
    • permission-audit — an Agent Skill that reads those sidecar files and reports loosening candidates, denials, and friction against your current permission config.

    Plugin: opencode-permission-log

    What it does

    Hooks into opencode's generic event hook and listens for permission.updated (a permission prompt was shown) followed by permission.replied (the human responded). When a reply is once, always, or reject, it appends a small JSON record to a per-day sidecar file under your local opencode storage directory. It never blocks or crashes the permission flow — all file IO is fail-open: any IO error is swallowed and reported to console.error, never thrown back into opencode's event loop.

    Install

    Add it to opencode's plugin list, either globally (all projects) in ~/.config/opencode/opencode.json:

    {
      "plugin": ["opencode-permission-log"]
    }
    

    or scoped to a single project in that project's ./opencode.json. opencode auto-installs npm plugins via Bun at startup — there's no separate npm install step to run yourself.

    Sidecar files

    Entries are written to:

    ~/.local/share/opencode/storage/plugin/opencode-permission-log/<YYYY-MM-DD>.json
    

    one file per UTC day, capped at the 500 most recent entries per day (see DAY_FILE_CAP in src/log-store.ts). Each file is a DayFile:

    interface DayFile {
      version: 1;
      date: string;          // "YYYY-MM-DD" (UTC)
      entries: SidecarEntry[];
    }
    
    interface SidecarEntry {
      timestamp: string;     // ISO 8601
      sessionID: string;
      permission: string;    // e.g. "bash"
      patterns: string[];    // normalized from Permission.pattern
      response: "once" | "always" | "reject";
    }
    

    See src/types.ts for the authoritative definitions.

    Privacy

    Sidecar files are written only to your own local machine, under your own home directory. Nothing is transmitted anywhere by this plugin.

    Skill: permission-audit

    What it does

    Reads the opencode-permission-log sidecar files, merges your global and project opencode.json permission config, and reports:

    • Loosening candidates — patterns you've repeatedly replied always to that the config doesn't yet allow.
    • Denials — patterns you've reject-ed.
    • Friction — patterns you've replied once to repeatedly (3+ times), suggesting the prompt itself is just noise.
    • Policy concerns / Ambiguous — non-builtin (custom tool / MCP) permission keys, flagged separately and never auto-suggested for loosening.

    It is detection-only: it never writes to any opencode.json and never applies a diff. It only prints a report for a human to act on.

    Install

    Copy (or clone) the permission-audit/ directory into the consuming project's skill directory. Per the agentskills.io convention, the directory name must stay permission-audit (it must match the name: in its SKILL.md frontmatter).

    Usage

    node permission-audit/scripts/audit.mjs --project "$PWD"
    

    This is the exact instruction an agent following the skill will run; see permission-audit/SKILL.md for the full workflow (how to parse and present the JSON output).

    The skill has no code dependency on the opencode-permission-log npm package above — audit.mjs is a standalone, zero-dependency Node ESM script that only reads the JSON sidecar files that plugin produces. They are designed to be used together but can be copied into other repos independently of each other.

    Credit

    The Agent Skill format used by permission-audit/SKILL.md was originally developed by Anthropic and released as an open standard. See the agentskills.io specification.

    License

    MIT — see LICENSE.

    Development

    npm install && npm test && npm run build