Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
e0ffc64
Add Grok CLI integration
austinywang May 16, 2026
41e1909
Merge remote-tracking branch 'origin/main' into issue-4220-grok-cli-n…
austinywang May 16, 2026
b7a4f24
Address Grok integration review feedback
austinywang May 16, 2026
a93eec0
Clarify Grok notification hook mapping
austinywang May 16, 2026
01f98e2
Handle optional Grok resume selectors
austinywang May 16, 2026
303ac14
Mark optional Grok selectors as value options
austinywang May 16, 2026
6a1732c
Improve Grok notification hook handling
austinywang May 16, 2026
780f9bc
Fix generic notification idle status
austinywang May 16, 2026
238588b
Persist generic notification status
austinywang May 17, 2026
b0293a5
Merge remote-tracking branch 'origin/main' into issue-4220-grok-cli-n…
austinywang May 18, 2026
ea7add3
fix: keep grok notification status neutral when unknown
austinywang May 18, 2026
46cd4f9
Merge origin/main into issue-4220-grok-cli-notifications
austinywang May 18, 2026
62ea3a6
fix: restore grok notification status from persisted state
austinywang May 18, 2026
ddd3cb2
Merge remote-tracking branch 'origin/main' into issue-4220-grok-cli-n…
austinywang May 18, 2026
0970d70
Fix Grok completion hook notifications
lawrencecchen May 18, 2026
ade0515
Suppress Grok internal startup notifications
lawrencecchen May 18, 2026
01f58c5
Add agent hook binding regression tests
lawrencecchen May 18, 2026
69bd674
Fix agent hooks across stale dev sockets
lawrencecchen May 18, 2026
3b4c5e0
test: cover repeated grok completion notifications
austinywang May 18, 2026
f5b5113
fix: keep grok notification delivery on critical path
austinywang May 18, 2026
8a16224
Merge remote-tracking branch 'origin/issue-4220-grok-cli-notification…
austinywang May 18, 2026
840dfe5
fix: address grok hook review feedback
austinywang May 18, 2026
b93b2e0
Merge remote-tracking branch 'origin/main' into issue-4220-grok-cli-n…
austinywang May 18, 2026
d032e06
fix: preserve legacy grok hook metadata
austinywang May 18, 2026
34b1c6d
refactor: share grok completion summary path
austinywang May 18, 2026
25040ea
fix: avoid ghostty startup recursion
austinywang May 19, 2026
cd9026b
Merge branch 'main' of https://github.com/manaflow-ai/cmux into issue…
austinywang May 19, 2026
aa43ef5
Suppress Grok placeholder completion notifications
lawrencecchen May 19, 2026
e6a26ef
fix: address grok hook review feedback
austinywang May 19, 2026
8165562
fix: make grok completion notifications consistent
austinywang May 19, 2026
c307e59
fix: align grok notification session lookup
austinywang May 19, 2026
8c373ad
Merge remote-tracking branch 'origin/main' into issue-4220-grok-cli-n…
austinywang May 19, 2026
1b044df
fix: prune bundled cli legacy hooks
austinywang May 19, 2026
6f69b23
Merge remote-tracking branch 'origin/main' into issue-4220-grok-cli-n…
austinywang May 19, 2026
abc9881
fix: hide stale structured agent sidebar statuses
lawrencecchen May 19, 2026
331223c
fix: publish grok completion notifications
austinywang May 19, 2026
436f7d5
Merge remote-tracking branch 'origin/main' into issue-4220-grok-cli-n…
austinywang May 19, 2026
767bac9
fix: address grok notification review feedback
austinywang May 19, 2026
0641a5d
Merge remote-tracking branch 'origin/main' into issue-4220-grok-cli-n…
austinywang May 19, 2026
9b890ee
fix: harden CLI socket reconnect for autodiscovery
austinywang May 19, 2026
b33f04c
fix: dedupe structured agent sidebar statuses
lawrencecchen May 19, 2026
7b69958
fix: address retry and title review feedback
austinywang May 19, 2026
02a0138
Merge remote-tracking branch 'origin/issue-4220-grok-cli-notification…
austinywang May 19, 2026
2fb56df
Merge branch 'main' of https://github.com/manaflow-ai/cmux into issue…
austinywang May 19, 2026
6fcd42b
Merge remote-tracking branch 'origin/main' into issue-4220-grok-cli-n…
austinywang May 19, 2026
1efe227
Merge remote-tracking branch 'origin/main' into issue-4220-grok-cli-n…
austinywang May 19, 2026
37c5a04
fix: align generic agent idle status
austinywang May 19, 2026
64d0ce1
fix: preserve grok hook timeout
austinywang May 19, 2026
8728dea
fix: isolate grok session notifications
austinywang May 19, 2026
5305dbe
merge: resolve conflicts with main
austinywang May 19, 2026
adacdbf
fix: remove grok hook dead code
austinywang May 19, 2026
8513225
ci: verify zig without minisign dependency
austinywang May 19, 2026
53dc14f
fix: restore grok runtime status on prompt
austinywang May 19, 2026
0d3378a
fix: route grok completions through notification hooks
austinywang May 19, 2026
ec8fb47
fix: compile grok stop notification setting
austinywang May 19, 2026
2a73838
fix: tighten notification waiting classifier
austinywang May 19, 2026
1f5d41f
test: cover concurrent grok stop notifications
austinywang May 19, 2026
072562e
fix: restore grok stop notification dedupe
austinywang May 19, 2026
2f350bd
fix: keep grok completions notification-owned
austinywang May 19, 2026
5204997
test: cover grok stop completion fallback
austinywang May 19, 2026
8559c88
fix: add grok stop completion fallback
austinywang May 19, 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
50 changes: 44 additions & 6 deletions CLI/CMUXCLI+AgentHookDefinitions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ extension CMUXCLI {
let configDir: String // Relative to ~: ".cursor", ".gemini"
let configFile: String // File name: "hooks.json", "settings.json"
let configDirEnvOverride: String? // e.g. "CODEX_HOME" overrides configDir
let configDirEnvOverrideSubpath: String? // e.g. "GROK_HOME" + "hooks"
let createConfigDirIfMissing: Bool // for agents whose hook dir is created lazily
let sessionStoreSuffix: String // e.g. "cursor" -> ~/.cmuxterm/cursor-hook-sessions.json
let disableEnvVar: String // e.g. "CMUX_CURSOR_HOOKS_DISABLED"
let hookMarker: String // Marker in commands: "cmux hooks cursor"
let binaryName: String
let format: HookFormat
let events: [HookEvent]
let aliases: Set<String>
let publishesStopNotification: Bool
/// Feed-hook events. Each entry installs a second hook for
/// `agentEvent` that invokes `cmux hooks feed --source <name>`
/// with a 120s timeout so the socket reply wait doesn't trip the
Expand All @@ -44,34 +47,50 @@ extension CMUXCLI {

/// Resolves the config directory, respecting env override if set.
func resolvedConfigDir() -> String {
if let envKey = configDirEnvOverride,
let envValue = ProcessInfo.processInfo.environment[envKey],
!envValue.isEmpty {
return NSString(string: envValue).expandingTildeInPath
}
let home = ProcessInfo.processInfo.environment["HOME"].flatMap { value -> String? in
let trimmed = value.trimmingCharacters(in: .whitespacesAndNewlines)
return trimmed.isEmpty ? nil : trimmed
} ?? NSHomeDirectory()
if let envKey = configDirEnvOverride,
let rawEnvValue = ProcessInfo.processInfo.environment[envKey] {
let envValue = rawEnvValue.trimmingCharacters(in: .whitespacesAndNewlines)
guard !envValue.isEmpty else {
return URL(fileURLWithPath: home, isDirectory: true)
.appendingPathComponent(configDir, isDirectory: true)
.path
}
var url = URL(fileURLWithPath: NSString(string: envValue).expandingTildeInPath, isDirectory: true)
if let subpath = configDirEnvOverrideSubpath,
!subpath.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
url.appendPathComponent(subpath, isDirectory: true)
}
return url.path
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}
return URL(fileURLWithPath: home, isDirectory: true)
.appendingPathComponent(configDir, isDirectory: true)
.path
}

init(name: String, displayName: String, statusKey: String,
configDir: String, configFile: String, configDirEnvOverride: String? = nil,
configDirEnvOverrideSubpath: String? = nil,
createConfigDirIfMissing: Bool = false,
binaryName: String? = nil,
sessionStoreSuffix: String, disableEnvVar: String, hookMarker: String,
format: HookFormat, events: [HookEvent],
aliases: Set<String> = [],
publishesStopNotification: Bool = true,
feedHookEvents: [String] = [],
postInstallAction: PostInstallAction? = nil) {
self.name = name; self.displayName = displayName; self.statusKey = statusKey
self.configDir = configDir; self.configFile = configFile
self.configDirEnvOverride = configDirEnvOverride
self.configDirEnvOverrideSubpath = configDirEnvOverrideSubpath
self.createConfigDirIfMissing = createConfigDirIfMissing
self.binaryName = binaryName ?? name
self.sessionStoreSuffix = sessionStoreSuffix; self.disableEnvVar = disableEnvVar
self.hookMarker = hookMarker; self.format = format; self.events = events
self.publishesStopNotification = publishesStopNotification
self.aliases = Set(aliases.compactMap { alias in
let normalized = alias.trimmingCharacters(in: .whitespacesAndNewlines).lowercased()
return normalized.isEmpty ? nil : normalized
Expand All @@ -82,13 +101,15 @@ extension CMUXCLI {
}

enum AgentHookAction {
case sessionStart, promptSubmit, stop, sessionEnd, noop
case sessionStart, promptSubmit, stop, notification, sessionEnd, noop
}

static let subcommandActions: [String: AgentHookAction] = [
"session-start": .sessionStart,
"prompt-submit": .promptSubmit,
"stop": .stop,
"notification": .notification,
"notify": .notification,
"agent-response": .stop,
"shell-exec": .promptSubmit,
"shell-done": .noop,
Expand All @@ -111,6 +132,23 @@ extension CMUXCLI {
feedHookEvents: ["PreToolUse", "PermissionRequest"],
postInstallAction: .codexConfigToml
),
AgentHookDef(
name: "grok", displayName: "Grok", statusKey: "grok",
configDir: ".grok/hooks", configFile: "cmux-session.json",
configDirEnvOverride: "GROK_HOME", configDirEnvOverrideSubpath: "hooks",
createConfigDirIfMissing: true,
sessionStoreSuffix: "grok", disableEnvVar: "CMUX_GROK_HOOKS_DISABLED",
hookMarker: "cmux hooks grok", format: .nested(timeoutMs: 5000),
events: [
.init(agentEvent: "SessionStart", cmuxSubcommand: "session-start"),
.init(agentEvent: "UserPromptSubmit", cmuxSubcommand: "prompt-submit"),
.init(agentEvent: "Stop", cmuxSubcommand: "stop"),
.init(agentEvent: "Notification", cmuxSubcommand: "notification"),
.init(agentEvent: "SessionEnd", cmuxSubcommand: "session-end"),
],
publishesStopNotification: false,
feedHookEvents: ["PreToolUse"]
Comment thread
lawrencecchen marked this conversation as resolved.
Resolved
),
Comment thread
austinywang marked this conversation as resolved.
Resolved
Comment thread
austinywang marked this conversation as resolved.
Resolved
AgentHookDef(
name: "opencode", displayName: "OpenCode", statusKey: "opencode",
configDir: ".config/opencode", configFile: "plugins/cmux-session.js", configDirEnvOverride: "OPENCODE_CONFIG_DIR",
Expand Down
Loading
Loading