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

    Tmux

    v0.6.0智能体编排
    @floschl/opencode-tmux

    Minimal OpenCode plugin: auto-spawn tmux panes for subagent sessions

    GitHub 星标

    0

    月装机量

    49

    近 7 天 8

    综合评分SCORE

    25.6

    生态多维模型

    最近提交

    3 个月前

    2026-05-19

    快速安装与配置

    opencode.json

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

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["@floschl/opencode-tmux@0.6.0"]
    }

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

    CI npm version npm downloads License GitHub Stars GitHub Forks Last Commit Bun

    Auto-spawn tmux panes for OpenCode subagent sessions — when OpenCode creates a child session, this plugin splits a new tmux pane and attaches it automatically.

    How It Works

    When OpenCode fires a session.created event for a child session (one with a parentID), the plugin:

    1. Splits a new tmux pane horizontally
    2. Runs opencode attach <serverUrl> --session <id> --dir <dir> in it
    3. Applies your configured layout
    4. Closes the pane when the session goes idle (if autoClose: true)

    Pane lifecycle is driven entirely by OpenCode events — no background polling.

    Requirements

    • tmux ≥ 3.0 installed and in PATH
    • OpenCode must be running inside a tmux session (the plugin is a no-op otherwise)
    • opencode binary must be in PATH (for the attach command in spawned panes)

    Usage

    OpenCode must be started as a server with an explicit port so the plugin knows the serverUrl to pass to opencode attach in spawned panes:

    opencode --port 3000
    

    Without a port, the plugin cannot construct the serverUrl and the opencode attach <serverUrl> --session <id> command in new tmux panes will fail.

    Installation

    bun add @floschl/opencode-tmux
    

    Register the plugin in your opencode.json (global ~/.config/opencode/opencode.json or project-local):

    {
      "plugin": ["@floschl/opencode-tmux"]
    }
    

    Configuration

    Create opencode-tmux.json with the plugin's settings. Keys are flat (no nesting):

    Global (~/.config/opencode/opencode-tmux.json):

    {
      "layout": "main-vertical",
      "mainPaneSize": 60,
      "autoClose": true
    }
    

    Project-local (either path works; <project>/opencode-tmux.json takes precedence):

    • <project>/opencode-tmux.json
    • <project>/.opencode/opencode-tmux.json

    Project-local config overrides global config. Unset keys fall back to defaults.

    Configuration Reference

    All keys go directly in opencode-tmux.json (flat, no nesting).

    Key Type Default Description
    layout string "main-vertical" tmux layout: main-vertical, main-horizontal, tiled, even-horizontal, even-vertical
    mainPaneSize number 60 Main pane size as percentage (10–90). Used with main-vertical / main-horizontal layouts
    autoClose boolean true Close pane automatically when session goes idle

    Event Handling

    Event Action
    session.created (child only) Spawn new tmux pane with opencode attach
    session.statusidle Close pane (if autoClose: true)
    session.statusbusy Re-spawn pane if session is known but pane was closed
    session.deleted Close pane unconditionally

    Debugging

    Set OPENCODE_TMUX_DEBUG=1 to enable verbose stderr logging:

    OPENCODE_TMUX_DEBUG=1 opencode --port 4096
    

    Limitations

    • tmux only — no support for other terminal multiplexers
    • Child sessions only — top-level sessions (no parentID) are ignored
    • Requires OpenCode to be started from within an active tmux session
    • The opencode attach command must be available in the spawned pane's PATH