feat(grok): add Grok CLI integration#281
Conversation
|
Nice scope control on the draft (dedup of imported Claude/Cursor hooks and PID/session one-to-one matching are exactly the right hard parts to call out). Two asks for when you mark it ready: (1) the suppression of duplicate imported hooks is the riskiest bit — a test that simulates Grok having imported a Claude-compatible hook config and asserts single delivery per lifecycle event would make that reviewable; (2) please note which Grok CLI version you verified against in the PR body (you mention 0.2.106 — keep that updated if you re-test). Will do a full review pass once it's out of draft. |
ec56b36 to
ec791bb
Compare
|
Both requested follow-ups are now in:
I also exercised the production bridge over a Unix socket: 14/14 managed events were delivered exactly once, 42/42 imported duplicates were suppressed, and 6/6 non-Grok/blank-environment regressions were delivered normally. While covering parallel same-CWD sessions, I found that the original greedy assignment could drop a viable session. It now uses deterministic augmenting-path matching, with a regression test for that counterexample. The PR is ready for the full review pass. |
Summary
$GROK_HOME/hooks/codeisland.json.chat_history.jsonl.Background
Grok Build exposes native global hooks under
$GROK_HOME/hooksand stores sessions under$GROK_HOME/sessions. It can also import Claude/Cursor hook configurations, so forwarding every compatible copy produces duplicate lifecycle events. Interactive and one-shot Grok processes can share a working directory, which requires a real one-to-one assignment rather than a simple CWD lookup or greedy match.Verified Grok version
grok 0.2.106 (bde89716f679)Duplicate-delivery policy
GrokHookForwardingPolicyis the production source of truth for all 14 managed events. In a Grok hook runtime (GROK_SESSION_IDorGROK_HOOK_EVENT), only the explicitly managed--source grokinvocation is forwarded; imported untagged, Claude, and Cursor copies are suppressed. Outside Grok, existing sources retain their prior behavior.Scope and limitations
PreToolUseevents, while permission decisions remain in the terminal.slug+hashsession-directory fallback is not included in this PR./newsession may be rejected by the conservative process-start matching window.Verification
swift build -c release --product CodeIsland.swift build -c release --product codeisland-bridge.git diff --check origin/main..HEAD.SessionStart,UserPromptSubmit, andStopwere delivered once each, the current PID won over an older same-CWD process, and the session was removed after process exit.swift test --filter 'GrokHookForwardingPolicyTests|GrokSupportTests'— this machine only has CommandLineTools and cannot importXCTest; CI or a full Xcode installation is required to execute the suite.The release build emits the pre-existing Swift 6 warning for the captured
cachevariable inAppState.refreshClaudeUsageIfStale(); this PR does not introduce that warning.Asset provenance
The static mark geometry follows Wikimedia Commons' “Grok logo used since February 2025”, attributed there to X.AI Corp. Wikimedia classifies the geometry as public domain for copyright purposes and separately identifies it as trademarked. The mark is rendered without animation or geometric modification, consistent with the xAI Brand Guidelines.
“Grok” and its logo are trademarks of xAI. CodeIsland is not affiliated with or endorsed by xAI.