diff options
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])); |
