Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
697f4ba
Add `cmux omo` command for OpenCode + oh-my-openagent integration
lawrencecchen Mar 25, 2026
60aca2a
Auto-install oh-my-opencode plugin when running cmux omo
lawrencecchen Mar 25, 2026
1b43d33
Use shadow config dir to avoid modifying user's opencode setup
lawrencecchen Mar 25, 2026
763d7b1
Add Agent Integrations docs section with Claude Code Teams and oh-my-…
lawrencecchen Mar 25, 2026
1025196
Remove uppercase from sidebar section headers
lawrencecchen Mar 25, 2026
ca5497e
Add more spacing above and below sidebar section headers
lawrencecchen Mar 25, 2026
b2a0bc7
Enable tmux mode in oh-my-opencode config, improve docs
lawrencecchen Mar 25, 2026
6b42f9f
Add terminal-notifier shim to route oh-my-openagent notifications to …
lawrencecchen Mar 25, 2026
45a0c37
Add pane geometry to tmux-compat for oh-my-openagent grid planning
lawrencecchen Mar 25, 2026
29135b4
Add socket tests for tmux-compat pane geometry
lawrencecchen Mar 25, 2026
44da195
Handle tmux -V in shim script directly (no socket needed)
lawrencecchen Mar 25, 2026
7d3b53f
Lower default tmux pane min widths for cmux omo
lawrencecchen Mar 25, 2026
2aa7f14
Merge origin/main into issue-2085-cmux-omo
lawrencecchen Mar 26, 2026
4622d66
Merge remote-tracking branch 'origin/main' into issue-2085-cmux-omo
lawrencecchen Mar 26, 2026
1804a31
Resolve merge conflicts with main (main-vertical layout, focus param)
lawrencecchen Mar 26, 2026
e5799e5
Implement select-layout equalize and resize-pane absolute width
lawrencecchen Mar 26, 2026
91deb44
Fix equalize to use proportional divider positions
lawrencecchen Mar 26, 2026
31c3c4d
Fix select-layout main-vertical to only equalize vertical splits
lawrencecchen Mar 26, 2026
714fe00
Re-equalize agent column after kill-pane
lawrencecchen Mar 26, 2026
5487d5e
Address PR review comments
lawrencecchen Mar 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
274 changes: 274 additions & 0 deletions CLI/cmux.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,7 @@ struct CMUXCLI {
// so help text is available even when cmux is not running.
if command != "__tmux-compat",
command != "claude-teams",
command != "omo",
(commandArgs.contains("--help") || commandArgs.contains("-h")) {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
if dispatchSubcommandHelp(command: command, commandArgs: commandArgs) {
return
Expand Down Expand Up @@ -1463,6 +1464,15 @@ struct CMUXCLI {
return
}

if command == "omo" {
try runOMO(
commandArgs: commandArgs,
socketPath: resolvedSocketPath,
explicitPassword: socketPasswordArg
)
return
}

let client = SocketClient(path: resolvedSocketPath)
if resolvedSocketPath != socketPath {
cliTelemetry.breadcrumb(
Expand Down Expand Up @@ -6073,6 +6083,29 @@ struct CMUXCLI {
cmux claude-teams --continue
cmux claude-teams --model sonnet
""")
case "omo":
return String(localized: "cli.omo.usage", defaultValue: """
Usage: cmux omo [opencode-args...]

Launch OpenCode with oh-my-openagent in a cmux-aware environment.

oh-my-openagent orchestrates multiple AI models as specialized agents in
parallel. This command sets up a tmux shim so agent panes become native
cmux splits with sidebar metadata and notifications.

This command:
- sets a tmux-like environment so oh-my-openagent uses cmux splits
- prepends a private tmux shim to PATH
- forwards all remaining arguments to opencode

The tmux shim translates tmux window/pane commands into cmux workspace
and split operations in the current cmux session.

Examples:
cmux omo
cmux omo --continue
cmux omo --model claude-sonnet-4-6
""")
case "identify":
return """
Usage: cmux identify [--workspace <id|ref|index>] [--surface <id|ref|index>] [--no-caller]
Expand Down Expand Up @@ -9380,6 +9413,246 @@ struct CMUXCLI {
throw CLIError(message: "Failed to launch claude: \(String(cString: strerror(code)))")
}

// MARK: - cmux omo (OpenCode + oh-my-openagent)

private func resolveOpenCodeExecutable(searchPath: String?) -> String? {
let entries = searchPath?.split(separator: ":").map(String.init) ?? []
for entry in entries where !entry.isEmpty {
let candidate = URL(fileURLWithPath: entry, isDirectory: true)
.appendingPathComponent("opencode", isDirectory: false)
.path
guard FileManager.default.isExecutableFile(atPath: candidate) else { continue }
return candidate
}
return nil
Comment on lines +9550 to +9559

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing wrapper-detection guard

resolveClaudeExecutable calls isCmuxClaudeWrapper(at:) to skip any claude binary that is already a cmux shim — preventing an infinite exec loop if a wrapper is installed on the user's system. resolveOpenCodeExecutable has no analogous check. There is currently no cmux-opencode wrapper, so this can't cause an actual loop today, but adding the guard now keeps the two resolvers structurally consistent and future-proofs against an opencode shim being added later.

Suggested change
private func resolveOpenCodeExecutable(searchPath: String?) -> String? {
let entries = searchPath?.split(separator: ":").map(String.init) ?? []
for entry in entries where !entry.isEmpty {
let candidate = URL(fileURLWithPath: entry, isDirectory: true)
.appendingPathComponent("opencode", isDirectory: false)
.path
guard FileManager.default.isExecutableFile(atPath: candidate) else { continue }
return candidate
}
return nil
private func resolveOpenCodeExecutable(searchPath: String?) -> String? {
let entries = searchPath?.split(separator: ":").map(String.init) ?? []
for entry in entries where !entry.isEmpty {
let candidate = URL(fileURLWithPath: entry, isDirectory: true)
.appendingPathComponent("opencode", isDirectory: false)
.path
guard FileManager.default.isExecutableFile(atPath: candidate) else { continue }
guard !isCmuxOpenCodeWrapper(at: candidate) else { continue }
return candidate
}
return nil
}

(where isCmuxOpenCodeWrapper would mirror isCmuxClaudeWrapper with an opencode-specific sentinel string)

}

private func createOMOShimDirectory() throws -> URL {
let homePath = ProcessInfo.processInfo.environment["HOME"] ?? NSHomeDirectory()
let root = URL(fileURLWithPath: homePath, isDirectory: true)
.appendingPathComponent(".cmuxterm", isDirectory: true)
.appendingPathComponent("omo-bin", isDirectory: true)
try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true, attributes: nil)
let tmuxURL = root.appendingPathComponent("tmux", isDirectory: false)
let script = """
#!/usr/bin/env bash
set -euo pipefail
exec "${CMUX_OMO_CMUX_BIN:-cmux}" __tmux-compat "$@"
"""
Comment on lines +9573 to +9581

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Provide tmux pane metric fields for OMO compatibility

The new omo wrapper routes every tmux call through cmux __tmux-compat, but this compat path’s list-panes -F renderer only fills a small context and drops unknown placeholders, while OMO’s tmux session manager requests fields like #{pane_width}, #{pane_height}, #{pane_left}, #{pane_top}, #{pane_active}, and window dimensions to parse pane state. Because those placeholders are stripped, pane-state parsing fails and OMO cannot reliably spawn/track subagent panes, so cmux omo does not deliver the advertised native split workflow.

Useful? React with 👍 / 👎.

let normalizedScript = script.trimmingCharacters(in: .whitespacesAndNewlines)
let existingScript = try? String(contentsOf: tmuxURL, encoding: .utf8)
if existingScript?.trimmingCharacters(in: .whitespacesAndNewlines) != normalizedScript {
try script.write(to: tmuxURL, atomically: false, encoding: .utf8)
}
try FileManager.default.setAttributes([.posixPermissions: 0o755], ofItemAtPath: tmuxURL.path)
return root
}

private static let omoPluginName = "oh-my-opencode"

private func omoOpenCodeConfigURL() -> URL {
let homePath = ProcessInfo.processInfo.environment["HOME"] ?? NSHomeDirectory()
return URL(fileURLWithPath: homePath, isDirectory: true)
.appendingPathComponent(".config", isDirectory: true)
.appendingPathComponent("opencode", isDirectory: true)
}

/// Returns true if `oh-my-opencode` is listed in the opencode.json plugin array.
private func omoPluginIsRegistered(configDir: URL) -> Bool {
let jsonURL = configDir.appendingPathComponent("opencode.json")
guard let data = try? Data(contentsOf: jsonURL),
let obj = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
let plugins = obj["plugin"] as? [String] else {
return false
}
return plugins.contains { $0 == Self.omoPluginName || $0.hasPrefix("\(Self.omoPluginName)@") }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Honor version-pinned plugin entries during install checks.

Line 9468 already treats oh-my-opencode@... as a valid configured plugin, but the bootstrap path only checks for an unversioned node_modules/oh-my-opencode directory and always runs bun add / npm install oh-my-opencode. If a user pins a version in opencode.json, cmux omo can silently drift to a different package than the config asks for.

Also applies to: 9497-9503, 9511-9518, 9550-9558

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CLI/cmux.swift` around lines 9461 - 9468, omoPluginIsRegistered currently
recognizes version-pinned entries in opencode.json but install checks and
bootstrap logic still only look for an unversioned node_modules/oh-my-opencode
and always run installs without the pinned spec; update the install/verification
paths to honor version-pinned plugin strings by (1) parsing the plugin entry
(e.g., "oh-my-opencode@1.2.3") instead of using Self.omoPluginName alone, (2)
checking the installed package version by either looking for
node_modules/<package>/package.json and comparing its "name" and "version" or by
checking node_modules/<package>@<version> if your packaging system supports that
layout, and (3) when invoking installers (bun add / npm install) pass the exact
plugin spec from opencode.json so pinned versions are installed; apply the same
change to the other related checks referenced near the other occurrences of the
bootstrap/install logic.

}

/// Adds `oh-my-opencode` to the opencode.json plugin array, creating the file if needed.
private func omoRegisterPlugin(configDir: URL) throws {
try FileManager.default.createDirectory(at: configDir, withIntermediateDirectories: true, attributes: nil)
let jsonURL = configDir.appendingPathComponent("opencode.json")

var config: [String: Any]
if let data = try? Data(contentsOf: jsonURL),
let existing = try? JSONSerialization.jsonObject(with: data) as? [String: Any] {
config = existing
} else {
config = [:]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Abort when opencode.json cannot be parsed

omoRegisterPlugin silently treats any decode failure as an empty config and then writes opencode.json back, which can erase existing user settings. If ~/.config/opencode/opencode.json is temporarily malformed (or uses syntax JSONSerialization rejects), running cmux omo will overwrite it with only the new plugin array. This is destructive data loss; parse errors should fail fast instead of resetting the config.

Useful? React with 👍 / 👎.

}
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved

var plugins = (config["plugin"] as? [String]) ?? []
let alreadyPresent = plugins.contains {
$0 == Self.omoPluginName || $0.hasPrefix("\(Self.omoPluginName)@")
}
if !alreadyPresent {
plugins.append(Self.omoPluginName)
}
config["plugin"] = plugins

let output = try JSONSerialization.data(withJSONObject: config, options: [.prettyPrinted, .sortedKeys])
try output.write(to: jsonURL, options: .atomic)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

/// Returns true if the oh-my-opencode package exists in node_modules.
private func omoPackageIsInstalled(configDir: URL) -> Bool {
let packageDir = configDir
.appendingPathComponent("node_modules", isDirectory: true)
.appendingPathComponent(Self.omoPluginName, isDirectory: true)
return FileManager.default.fileExists(atPath: packageDir.path)
}

/// Installs the oh-my-opencode npm package in the config directory using bun or npm.
private func omoInstallPackage(configDir: URL) throws {
let process = Process()
process.currentDirectoryURL = configDir

// Prefer bun, fall back to npm
if let bunPath = resolveExecutableInPath("bun") {
process.executableURL = URL(fileURLWithPath: bunPath)
process.arguments = ["add", Self.omoPluginName]
} else if let npmPath = resolveExecutableInPath("npm") {
process.executableURL = URL(fileURLWithPath: npmPath)
process.arguments = ["install", Self.omoPluginName]
} else {
throw CLIError(message: "Neither bun nor npm found in PATH. Install oh-my-opencode manually: bunx oh-my-opencode install")
}

let stdout = Pipe()
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
let stderr = Pipe()
process.standardOutput = stdout
process.standardError = stderr

FileHandle.standardError.write("Installing oh-my-opencode plugin...\n".data(using: .utf8)!)
try process.run()
process.waitUntilExit()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Drain installer pipes before waiting for process exit

The install path pipes both stdout/stderr and then calls waitUntilExit() without consuming either stream first. During noisy bun add/npm install runs, pipe buffers can fill and block the child process on write, which leaves cmux omo hanging indefinitely on first-time setup. Consume the pipes concurrently (or inherit terminal stdio) before waiting.

Useful? React with 👍 / 👎.


if process.terminationStatus != 0 {
let errText = String(data: stderr.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? ""
throw CLIError(message: "Failed to install oh-my-opencode: \(errText)")
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}
}

private func resolveExecutableInPath(_ name: String) -> String? {
let entries = ProcessInfo.processInfo.environment["PATH"]?.split(separator: ":").map(String.init) ?? []
for entry in entries where !entry.isEmpty {
let candidate = URL(fileURLWithPath: entry, isDirectory: true)
.appendingPathComponent(name, isDirectory: false)
.path
if FileManager.default.isExecutableFile(atPath: candidate) {
return candidate
}
}
return nil
}

/// Ensures oh-my-opencode plugin is registered and installed before launching opencode.
private func omoEnsurePlugin() throws {
let configDir = omoOpenCodeConfigURL()
if !omoPluginIsRegistered(configDir: configDir) {
try omoRegisterPlugin(configDir: configDir)
FileHandle.standardError.write("Registered oh-my-opencode plugin in opencode.json\n".data(using: .utf8)!)
}
if !omoPackageIsInstalled(configDir: configDir) {
try omoInstallPackage(configDir: configDir)
FileHandle.standardError.write("oh-my-opencode plugin installed\n".data(using: .utf8)!)
}
}

private func configureOMOEnvironment(
processEnvironment: [String: String],
shimDirectory: URL,
executablePath: String,
socketPath: String,
explicitPassword: String?,
focusedContext: ClaudeTeamsFocusedContext?
) {
let updatedPath = prependPathEntries(
[shimDirectory.path],
to: processEnvironment["PATH"]
)
let fakeTmuxValue: String = {
if let focusedContext {
let windowToken = focusedContext.windowId ?? focusedContext.workspaceId
return "/tmp/cmux-omo/\(focusedContext.workspaceId),\(windowToken),\(focusedContext.paneHandle)"
}
return processEnvironment["TMUX"] ?? "/tmp/cmux-omo/default,0,0"
}()
let fakeTmuxPane = focusedContext.map { "%\($0.paneHandle)" }
?? processEnvironment["TMUX_PANE"]
?? "%1"
let fakeTerm = processEnvironment["CMUX_OMO_TERM"] ?? "screen-256color"

setenv("CMUX_OMO_CMUX_BIN", executablePath, 1)
setenv("PATH", updatedPath, 1)
setenv("TMUX", fakeTmuxValue, 1)
setenv("TMUX_PANE", fakeTmuxPane, 1)
setenv("TERM", fakeTerm, 1)
setenv("CMUX_SOCKET_PATH", socketPath, 1)
setenv("CMUX_SOCKET", socketPath, 1)
if let explicitPassword,
!explicitPassword.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
setenv("CMUX_SOCKET_PASSWORD", explicitPassword, 1)
}
unsetenv("TERM_PROGRAM")
if let focusedContext {
setenv("CMUX_WORKSPACE_ID", focusedContext.workspaceId, 1)
if let surfaceId = focusedContext.surfaceId, !surfaceId.isEmpty {
setenv("CMUX_SURFACE_ID", surfaceId, 1)
}
}
}

private func runOMO(
commandArgs: [String],
socketPath: String,
explicitPassword: String?
) throws {
// Ensure oh-my-opencode plugin is registered and installed
try omoEnsurePlugin()
Comment on lines +9875 to +9876

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Short-circuit --help before running OMO setup

runOMO unconditionally executes omoEnsurePlugin(), so cmux omo --help still performs side effects (shadow-config writes and possible bun/npm install attempts) before help is shown. Because omo is excluded from early subcommand help dispatch, a help-only invocation can unexpectedly mutate user config or fail due missing package managers; help paths should be side-effect free.

Useful? React with 👍 / 👎.


let processEnvironment = ProcessInfo.processInfo.environment
var launcherEnvironment = processEnvironment
launcherEnvironment["CMUX_SOCKET_PATH"] = socketPath
launcherEnvironment["CMUX_SOCKET"] = socketPath
if let explicitPassword,
!explicitPassword.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
launcherEnvironment["CMUX_SOCKET_PASSWORD"] = explicitPassword
}
let shimDirectory = try createOMOShimDirectory()
let executablePath = resolvedExecutableURL()?.path ?? (args.first ?? "cmux")
let focusedContext = claudeTeamsFocusedContext(
processEnvironment: launcherEnvironment,
explicitPassword: explicitPassword
)
let openCodeExecutablePath = resolveOpenCodeExecutable(searchPath: launcherEnvironment["PATH"])
configureOMOEnvironment(
processEnvironment: launcherEnvironment,
shimDirectory: shimDirectory,
executablePath: executablePath,
socketPath: socketPath,
explicitPassword: explicitPassword,
focusedContext: focusedContext
)

let launchPath = openCodeExecutablePath ?? "opencode"
var argv = ([launchPath] + commandArgs).map { strdup($0) }
defer {
for item in argv {
free(item)
}
}
argv.append(nil)

if openCodeExecutablePath != nil {
execv(launchPath, &argv)
} else {
execvp("opencode", &argv)
}
let code = errno
throw CLIError(message: "Failed to launch opencode: \(String(cString: strerror(code)))")
}

private func runClaudeTeamsTmuxCompat(
commandArgs: [String],
client: SocketClient,
Expand Down Expand Up @@ -11361,6 +11634,7 @@ struct CMUXCLI {
feedback [--email <email> --body <text> [--image <path> ...]]
themes [list|set|clear]
claude-teams [claude-args...]
omo [opencode-args...]
ping
version
capabilities
Expand Down
17 changes: 17 additions & 0 deletions Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,23 @@
}
}
},
"cli.omo.usage": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Usage: cmux omo [opencode-args...]\n\nLaunch OpenCode with oh-my-openagent in a cmux-aware environment.\n\noh-my-openagent orchestrates multiple AI models as specialized agents in\nparallel. This command sets up a tmux shim so agent panes become native\ncmux splits with sidebar metadata and notifications.\n\nThis command:\n - sets a tmux-like environment so oh-my-openagent uses cmux splits\n - prepends a private tmux shim to PATH\n - forwards all remaining arguments to opencode\n\nThe tmux shim translates tmux window/pane commands into cmux workspace\nand split operations in the current cmux session.\n\nExamples:\n cmux omo\n cmux omo --continue\n cmux omo --model claude-sonnet-4-6"
}
},
"ja": {
"stringUnit": {
"state": "translated",
"value": "使い方: cmux omo [opencode-args...]\n\ncmux 対応の環境で OpenCode と oh-my-openagent を起動します。\n\noh-my-openagent は複数の AI モデルを専門エージェントとして並列に\nオーケストレーションします。このコマンドは tmux shim を設定し、\nエージェントのペインをネイティブの cmux split に変換します。\n\nこのコマンドは次を行います:\n - oh-my-openagent が cmux の split を使うよう tmux 風の環境を設定\n - 専用の tmux shim を PATH の先頭に追加\n - 残りの引数をそのまま opencode に渡す\n\ntmux shim は、tmux の window/pane コマンドを、現在の cmux セッション内の\nworkspace と split 操作に変換します。\n\n例:\n cmux omo\n cmux omo --continue\n cmux omo --model claude-sonnet-4-6"
}
}
}
},
"applescript.error.disabled": {
"extractionState": "manual",
"localizations": {
Expand Down
Loading