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

    Fs Ops

    v0.1.1其他
    opencode-fs-ops

    OpenCode plugin that adds permission-gated `mv` and `cp` filesystem tools, encouraging agents to move/copy existing files instead of rewriting them.

    GitHub 星标

    0

    月装机量

    13

    近 7 天 5

    综合评分SCORE

    22.5

    生态多维模型

    最近提交

    2 个月前

    2026-05-23

    快速安装与配置

    opencode.json

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

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-fs-ops@0.1.1"]
    }

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

    OpenCode plugin that adds permission-gated mv and cp tools so the agent can move and copy files instead of rewriting them.

    Why

    When an agent renames a module or duplicates a file, the cheap path is to move/copy first, then edit. Doing it with write instead is expensive (re-emitting the entire file content), loses git rename detection, and increases the chance of the model corrupting code it didn't need to touch.

    Without dedicated tools the agent has to reach for bash (mv, cp, Move-Item, Copy-Item, …) which is gated behind shell permissions and varies per platform. This plugin gives the agent first-class, cross-platform, permission-gated tools so the safe path is also the obvious path.

    Tools

    mv — move or rename

    Moves or renames a file or directory. Uses fs.rename for the fast atomic path and falls back to copy + delete on EXDEV (cross-volume moves). Refuses to clobber an existing destination unless overwrite: true.

    cp — copy

    Copies a file or directory. Recursive when the source is a directory. Refuses to clobber an existing destination unless overwrite: true. Symbolic links are preserved as links (not dereferenced).

    Both tools work identically on Windows, macOS, and Linux (Node ≥20 stdlib only — no shelling out).

    Permissions

    Both tools reuse the edit permission key — the same one that gates the built-in write, edit, and apply_patch tools. That means:

    • An agent that has edit denied also has mv/cp denied.
    • A read-only agent never sees these tools in its toolset.
    • Existing config like "permission": { "edit": "ask" } automatically prompts for mv/cp too.

    When the source or destination escapes the project worktree, the tools additionally request the external_directory permission, mirroring how the built-in tools handle out-of-tree paths.

    Installation

    Add the plugin to your OpenCode config:

    // opencode.json
    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": [
        "opencode-fs-ops@latest"
      ]
    }
    

    For a read-only agent, deny edit and these tools disappear from its toolset along with the built-ins:

    {
      "agent": {
        "researcher": {
          "permission": { "edit": "deny" }
        }
      }
    }
    

    Build

    pnpm install
    pnpm build       # tsc → dist/
    

    License

    MIT