Windows JSON-hook command line is not cmd.exe-safe - #956
Open
vecsop wants to merge 1 commit into
Open
Conversation
JSON-hook runners on Windows execute the hooks.json command through cmd.exe. A line that starts with a quoted exe path is looked up as a file whose name includes the quote characters: "C:/Program Files/.../aioncore.exe" is not recognized as an internal or external command Prefix with `call`, normalize slashes to backslashes, and keep the antigravity-hook subcommand. Unix quoting is unchanged. Fixes the leftover of AionUi#4095 after AionCore#887 stripped \\?\ .
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Windows JSON-hook command line is not cmd.exe-safe
Summary
The PreToolUse permission bridge (
aionui-permission-bridge) writes a command line (not a bare path) into<workspace>/.agents/hooks.json. Unix/agy word-splits that string and honours double quotes. On Windows the same string is executed throughcmd.exeby the JSON-hook runner (jsonhook__aionui-permission-bridge_PreToolUse_0_0).A command that starts with a quote is treated as the program name including the quote characters:
(Quote characters included in the reported program name; path uses forward slashes.)
This is the leftover of iOfficeAI/AionUi#4095 after #887 stripped the
\\?\verbatim prefix withdunce::canonicalize. The reporter’s follow-up on #4095 is the same class of failure without\\?\:Root cause
File:
crates/aionui-ai-agent/src/antigravity_hook.rsFunction:
hooks_json_body/ former one-linerAlways produced
"<path>" antigravity-hook. Combined with:cmd.exequote-eating when the JSON-hook runner doescmd /c <command>current_exe()sometimes yielding forward slashes (C:/Program Files/...), which cmd then treats as switches…the quoted path is looked up as a literal filename.
Hook command strings are generated at session start (
factory/antigravity.rs→permission_hook_body) and persisted on the session. After an AionCore/AionUi server restart, live sessions restore that body viasync_permission_hook(crates/aionui-session/src/backend/antigravity/conn.rs) without rebuilding argv. New sessions generate the command and spawn in one flow. This PR does not invent a second generator — if the stored string is cmd-hostile, restore-after-restart is the path that re-applies it to an already-running agent whose JSON-hook runner uses cmd.exe. New sessions after restart working is consistent with backends that do not install this hook (factory/acp.rssetspermission_hook_body: None) or with a freshly spawned process that word-splits the command itself. If a new Windows Claude/agy session still hits jsonhook+cmd, it would fail the same way until this command-line encoding is fixed.Fix
Build the command with an explicit Windows encoding:
/→\callbuiltin so quotes wrap an argument, not argv[0]antigravity-hooksubcommand (bare exe would start the resident backend)Unix encoding is unchanged.
Tests
Assertions on the generated command string (no Electron build):
"/opt/..." antigravity-hook(quoted path, subcommand present)call "C:\Program Files\...\aioncore.exe" antigravity-hook"/or\\?\Reproduce (pre-fix)
C:\Program Files\AionUi\(space in path).aioncore.exepath as an unknown command.