Repository navigation
Add cmux omo command for oh-my-openagent integration
#2087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
697f4ba
60aca2a
1b43d33
763d7b1
1025196
ca5497e
b2a0bc7
6b42f9f
45a0c37
29135b4
44da195
7d3b53f
2aa7f14
4622d66
1804a31
e5799e5
91deb44
31c3c4d
714fe00
5487d5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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")) { | ||||||||||||||||||||||||||||||||||||||||||||||
| if dispatchSubcommandHelp(command: command, commandArgs: commandArgs) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -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( | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -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] | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(where |
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new 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)@") } | ||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honor version-pinned plugin entries during install checks. Line 9468 already treats Also applies to: 9497-9503, 9511-9518, 9550-9558 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /// 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 = [:] | ||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
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) | ||||||||||||||||||||||||||||||||||||||||||||||
|
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() | ||||||||||||||||||||||||||||||||||||||||||||||
|
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() | ||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The install path pipes both stdout/stderr and then calls 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)") | ||||||||||||||||||||||||||||||||||||||||||||||
|
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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -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 | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.