function c --wraps=opencode --description 'opencode (auto-starts tmux for visual subagent panes)'
    set -l port (python -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1", 0)); print(s.getsockname()[1]); s.close()')

    if not set -q TMUX
        tmux new-session opencode --port $port $argv
    else
        opencode --port $port $argv
    end
end
