From e9b22084e03880f43d1f1daaf5d9f45c717b77c4 Mon Sep 17 00:00:00 2001 From: Enrico Carlesso Date: Fri, 24 Jul 2026 12:05:20 -0700 Subject: feat: add grok cli integration for native session restore (#1807) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add grok cli integration for native session restore tl;dr: adds `herdr integration install grok` (session-identity tier: a SessionStart hook reports the grok session id for native restore; state stays screen-detected via the bundled manifest). Grok merges every ~/.grok/hooks/*.json, so install writes a self-contained hooks/herdr.json registering a SessionStart hook next to hooks/herdr-agent-state.sh, and never touches other hook files. The hook prefers $GROK_SESSION_ID (injected into every grok hook process) and reports through the socket API; herdr:grok is a reserved-native-state source so screen detection stays authoritative. Restore uses `grok --resume `. Additive JSON API change; no protocol bump; the schema artifact is regenerated. refs #1800 * fix: honor GROK_HOME and validate grok hook config in status Review follow-ups: grok_dir now resolves GROK_CONFIG_DIR (herdr test seam) before GROK_HOME (the grok CLI's own config-home override) before ~/.grok, so hook installs land where grok actually looks. Integration status now also validates the herdr-owned hooks/herdr.json next to the hook script — missing, corrupt, or no-longer-referencing configs report the install as outdated instead of masking a hook grok never invokes. refs #1800 * fix: validate the exact grok session hook command in status The config validator matched on a filename substring, so a SessionStart command like `echo herdr-agent-state.sh`, or one invoking the script without the `session` action, still reported the integration as current while grok never delivered a session id. Status now compares against the exact command the installer writes, via a shared builder, and the degradation tests cover both nonfunctional shapes. refs #1800 * fix: require a command-type grok session hook in status validation A config entry carrying the exact generated command under a non-command hook type (e.g. "http") is never executed by grok, so it must not report the integration as current. The validator now also requires type = "command", with a degradation test for the mismatched-type shape. refs #1800 * fix: validate the complete grok hook config refs #1800 --------- Co-authored-by: Ogulcan Celik --- src/integration/actions.rs | 50 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) (limited to 'src/integration/actions.rs') diff --git a/src/integration/actions.rs b/src/integration/actions.rs index 807ceeb6..c00e10b7 100644 --- a/src/integration/actions.rs +++ b/src/integration/actions.rs @@ -3,11 +3,11 @@ use std::io; use super::registry::{integration_target_label, integration_target_supported}; use super::targets::{ install_claude, install_codex, install_copilot, install_cursor, install_devin, install_droid, - install_hermes, install_kilo, install_kimi, install_mastracode, install_omp, install_opencode, - install_pi, install_qodercli, uninstall_claude, uninstall_codex, uninstall_copilot, - uninstall_cursor, uninstall_devin, uninstall_droid, uninstall_hermes, uninstall_kilo, - uninstall_kimi, uninstall_mastracode, uninstall_omp, uninstall_opencode, uninstall_pi, - uninstall_qodercli, + install_grok, install_hermes, install_kilo, install_kimi, install_mastracode, install_omp, + install_opencode, install_pi, install_qodercli, uninstall_claude, uninstall_codex, + uninstall_copilot, uninstall_cursor, uninstall_devin, uninstall_droid, uninstall_grok, + uninstall_hermes, uninstall_kilo, uninstall_kimi, uninstall_mastracode, uninstall_omp, + uninstall_opencode, uninstall_pi, uninstall_qodercli, }; use super::version::{agent_version_requirement, enforce_agent_version}; use super::{KIMI_MIN_VERSION, PI_EXTENSION_INSTALL_NAME}; @@ -204,6 +204,19 @@ fn install_target_inner(target: crate::api::schema::IntegrationTarget) -> io::Re ), ] } + crate::api::schema::IntegrationTarget::Grok => { + let installed = install_grok()?; + vec![ + format!( + "installed grok integration hook to {}", + installed.hook_path.display() + ), + format!( + "registered grok hook config at {}", + installed.config_path.display() + ), + ] + } }; if let Some(warning) = version_warning { @@ -558,6 +571,33 @@ pub(crate) fn uninstall_target( } messages } + crate::api::schema::IntegrationTarget::Grok => { + let result = uninstall_grok()?; + let mut messages = Vec::new(); + if result.removed_hook_file { + messages.push(format!( + "removed grok hook at {}", + result.hook_path.display() + )); + } else { + messages.push(format!( + "no grok hook found at {}", + result.hook_path.display() + )); + } + if result.removed_config_file { + messages.push(format!( + "removed grok hook config at {}", + result.config_path.display() + )); + } else { + messages.push(format!( + "no grok hook config found at {}", + result.config_path.display() + )); + } + messages + } }; crate::logging::integration_action("uninstall", integration_target_label(target), "ok"); -- cgit v1.2.3