diff options
| author | akbash <akbash@herdr.dev> | 2026-08-30 03:03:25 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-30 03:03:25 +0300 |
| commit | 4a3b04f59ba3b7d8a15cea187b23e1e80c343b0c (patch) | |
| tree | e1a38be588e702c39c434092f8b7a7a218e88f7c /src/integration/targets.rs | |
| parent | 3a3792622e59c7f2dc20f9c0236167161e4a5035 (diff) | |
fix: encode antigravity windows hook command (#3352)
refs #3348
Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com>
Diffstat (limited to 'src/integration/targets.rs')
| -rw-r--r-- | src/integration/targets.rs | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/integration/targets.rs b/src/integration/targets.rs index 0150ccaa..0690fc90 100644 --- a/src/integration/targets.rs +++ b/src/integration/targets.rs @@ -8,6 +8,8 @@ use super::claude_settings::{ install as install_claude_settings, uninstall as uninstall_claude_settings, }; use super::command::hook_command; +#[cfg(windows)] +use super::command::powershell_encoded_hook_command; #[cfg(not(windows))] use super::command::shell_single_quote; use super::config_edit::{ @@ -1190,16 +1192,7 @@ pub(crate) fn uninstall_cursor() -> io::Result<CursorUninstallResult> { pub(crate) fn mastracode_hook_command(hook_path: &Path, action: &str) -> String { #[cfg(windows)] { - use base64::Engine; - - let path = hook_path.display().to_string().replace('\'', "''"); - let script = format!("& '{path}' {action}"); - let encoded_script = script - .encode_utf16() - .flat_map(u16::to_le_bytes) - .collect::<Vec<_>>(); - let encoded = base64::engine::general_purpose::STANDARD.encode(encoded_script); - format!("powershell -NoProfile -ExecutionPolicy Bypass -EncodedCommand {encoded}") + powershell_encoded_hook_command(hook_path, action) } #[cfg(not(windows))] { @@ -1349,6 +1342,17 @@ pub(crate) fn install_antigravity_cli() -> io::Result<AntigravityCliInstallPaths }) } +pub(crate) fn antigravity_cli_hook_command(hook_path: &Path, action: &str) -> String { + #[cfg(windows)] + { + powershell_encoded_hook_command(hook_path, action) + } + #[cfg(not(windows))] + { + hook_command(hook_path, Some(action)) + } +} + /// Builds the Herdr-owned `hooks.json` block for Antigravity CLI. /// /// Every event Herdr registers takes a flat handler list; the `matcher`/`hooks` @@ -1358,7 +1362,7 @@ fn antigravity_cli_hook_block(hook_path: &Path) -> Value { for (event, action) in ANTIGRAVITY_CLI_HOOK_EVENTS { let handler = json!({ "type": "command", - "command": hook_command(hook_path, Some(action)), + "command": antigravity_cli_hook_command(hook_path, action), "timeout": ANTIGRAVITY_CLI_HOOK_TIMEOUT_SEC, }); block.insert(event.to_string(), json!([handler])); |
