跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    adiled

    Dir

    opencode-dir·v1.3.1·其他

    Directory operations for opencode sessions

    GitHub 星标

    29

    近 30 天 +3

    月装机量

    2,129

    近 7 天 518

    综合评分

    56.1

    生态多维模型

    最近提交

    3 天前

    2026-10-01

    快速安装与配置

    opencode.json

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

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-dir@1.3.1"]
    }

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

    Directory operations for opencode sessions. Change directory, move sessions, and grant access to additional directories at runtime.

    In OpenCode, when working across monorepos or multiple repositories, sessions get stuck in the directory they were started in. opencode-dir plugin helps by unlocking multiple directory workflows, with special commands: /cd, /mv, /add-dir, /remove-dir.

    To encrypt certain directories, use /vault init <dir>, and give deliberate access using /vault open <dir>.

    Screenshot 2026-09-07 at 8 05 39 PM

    Setup

    Add to opencode.json and tui.json, and restart OpenCode:

    {
      "plugin": ["opencode-dir"]
    }
    

    Commands

    /cd <path>

    Change the session's working directory. Tools (bash, glob, grep, read, write, edit) will operate in the new directory immediately. Message history is left untouched.

    /mv <path>

    Same as /cd, but also rewrites path.cwd and path.root in all existing assistant messages to point to the new directory. Use when you want the full conversation history to reflect the new location.

    After moving, the session is fully operational in the new directory. System prompt, tools, and permissions are all updated immediately. When you next open opencode from the target directory, the session will appear under that project's session list.

    /add-dir <path>

    Grant tool access to an additional directory without changing the session's working directory. Use when you need to read or write files in a secondary project or monorepo package. Can be called multiple times to add several directories.

    /remove-dir <path>

    Revoke tool access to a directory previously granted via /add-dir. The session working directory is unchanged; only the permission entries for the given path are removed.

    /vault <init|open|close> <path>

    Encrypt a directory using a passphrase or env OPENCODE_DIR_VAULT_PASS. init to set passphrase. init <path> to encrypt. open <path> to create a temporary access for that session. close to revoke access on-demand.

    /vault init
    /vault init ~/secrets
    /vault open ~/secrets
    /vault close ~/secrets
    

    License

    MIT

    同类生态推荐