Fix Windows connectivity & lifecycle bridges for Antigravity, OpenCode, and Codex
Problem / Motivation
On Windows installations, connecting Antigravity (agy) and OpenCode (opencode) fails to establish a working two-way bridge with Munder Difflin due to schema mismatches and missing configuration declarations:
-
Antigravity (agy) Stop hook never fires:
- In
src/main/hive.ts (installAgyHooks), PreInvocation, PostInvocation, and Stop hooks are written with a nested { hooks: [{ type: 'command', command: ..., timeout: 0 }] } wrapper.
- Per the Antigravity CLI lifecycle specification,
PreInvocation, PostInvocation, and Stop must be a flat array of handler objects: [{ type: "command", command: "...", timeout: 30 }]. Only PreToolUse and PostToolUse use the { matcher, hooks } grouping.
- Because
Stop is nested, Antigravity's hook loader fails to parse and execute Stop. As a result, Munder Difflin never receives the idle notification and never drains the agent's inbox, causing the agent to appear stuck.
- In addition,
timeout: 0 causes immediate timeouts if invoked.
- On Windows,
agy is frequently installed as %LOCALAPPDATA%\agy\bin\agy.exe or %USERPROFILE%\.local\bin\antigravity.cmd, which are not currently searched by winCandidates in pty.ts and shellEnv.ts.
-
OpenCode (opencode) bridge plugin is never loaded:
- In
src/main/hive.ts (installOpenCodePlugin), hive-bridge.js is written to <agentDir>/.opencode/plugins/, but opencode.json is generated with only { "theme": "system" }.
- OpenCode does not auto-scan plugin folders without an explicit declaration in
opencode.json under "plugin": ["./plugins/hive-bridge.js"] (verified via opencode debug config). Without this entry, the plugin is completely ignored.
- In
src/main/index.ts (spawnAgentCore), dynamic serialization of OPENCODE_CONFIG_CONTENT does not inject the plugin array, overriding any local opencode.json.
- In
OPENCODE_PLUGIN, session tracking is missing: extracting sessionID on session.idle and session.created is needed for session registration and cost tracking.
- OpenCode's auto mode in
agentProvider.ts lacked --auto and --dangerously-skip-permissions flags, leaving auto mode ineffective.
-
Auto Mode posture for non-Claude providers:
- In
src/main/index.ts (around line 2746), argsWithAutoModeFlag is only executed under if (opts.hive && claudeProvider). Non-Claude providers spawned by the main process (or restored agents) do not receive their auto-mode flags.
Proposed Solution
-
src/main/hive.ts:
- Update
installAgyHooks:
const tool = (event: string) => ({
matcher: '*',
hooks: [{ type: 'command', command: this.nodeRunUnquoted(shim, event), timeout: 30 }]
});
const plain = (event: string) => ({
type: 'command',
command: this.nodeRunUnquoted(shim, event),
timeout: 30
});
- Also target
~/.gemini/antigravity/hooks.json in addition to config and antigravity-cli.
- Update
installOpenCodePlugin to explicitly register plugin: [fileUrl, './plugins/hive-bridge.js'] in opencode.json.
- Update
OPENCODE_PLUGIN to extract session_id from input.sessionID || input.event.sessionID and handle session.created / session.start.
-
src/main/index.ts:
- In
spawnAgentCore, inject oc.plugin into OPENCODE_CONFIG_CONTENT when OPENCODE_CONFIG_DIR is present.
- Run
argsWithAutoModeFlag in the non-Claude hive spawn branch so all providers receive their auto-mode bypass posture.
- Expand
tools:status resolution to check aliases (agy / antigravity).
-
src/main/pty.ts & src/main/shellEnv.ts:
- Add candidate Windows paths for
agy.exe, antigravity.cmd, and codex.cmd in winCandidates.
-
src/shared/agentProvider.ts:
- Set OpenCode
autoModeFlag: '--dangerously-skip-permissions --auto', autoFlag: '--dangerously-skip-permissions --auto', and resumeFlag: '-s'.
- Add duplicate protection in
buildSpawnCommand.
Operating System
Windows 11 (tested on Windows 10/11 x64)
Fix Windows connectivity & lifecycle bridges for Antigravity, OpenCode, and Codex
Problem / Motivation
On Windows installations, connecting Antigravity (
agy) and OpenCode (opencode) fails to establish a working two-way bridge with Munder Difflin due to schema mismatches and missing configuration declarations:Antigravity (
agy) Stop hook never fires:src/main/hive.ts(installAgyHooks),PreInvocation,PostInvocation, andStophooks are written with a nested{ hooks: [{ type: 'command', command: ..., timeout: 0 }] }wrapper.PreInvocation,PostInvocation, andStopmust be a flat array of handler objects:[{ type: "command", command: "...", timeout: 30 }]. OnlyPreToolUseandPostToolUseuse the{ matcher, hooks }grouping.Stopis nested, Antigravity's hook loader fails to parse and executeStop. As a result, Munder Difflin never receives the idle notification and never drains the agent's inbox, causing the agent to appear stuck.timeout: 0causes immediate timeouts if invoked.agyis frequently installed as%LOCALAPPDATA%\agy\bin\agy.exeor%USERPROFILE%\.local\bin\antigravity.cmd, which are not currently searched bywinCandidatesinpty.tsandshellEnv.ts.OpenCode (
opencode) bridge plugin is never loaded:src/main/hive.ts(installOpenCodePlugin),hive-bridge.jsis written to<agentDir>/.opencode/plugins/, butopencode.jsonis generated with only{ "theme": "system" }.opencode.jsonunder"plugin": ["./plugins/hive-bridge.js"](verified viaopencode debug config). Without this entry, the plugin is completely ignored.src/main/index.ts(spawnAgentCore), dynamic serialization ofOPENCODE_CONFIG_CONTENTdoes not inject thepluginarray, overriding any localopencode.json.OPENCODE_PLUGIN, session tracking is missing: extractingsessionIDonsession.idleandsession.createdis needed for session registration and cost tracking.agentProvider.tslacked--autoand--dangerously-skip-permissionsflags, leaving auto mode ineffective.Auto Mode posture for non-Claude providers:
src/main/index.ts(around line 2746),argsWithAutoModeFlagis only executed underif (opts.hive && claudeProvider). Non-Claude providers spawned by the main process (or restored agents) do not receive their auto-mode flags.Proposed Solution
src/main/hive.ts:installAgyHooks:~/.gemini/antigravity/hooks.jsonin addition toconfigandantigravity-cli.installOpenCodePluginto explicitly registerplugin: [fileUrl, './plugins/hive-bridge.js']inopencode.json.OPENCODE_PLUGINto extractsession_idfrominput.sessionID || input.event.sessionIDand handlesession.created/session.start.src/main/index.ts:spawnAgentCore, injectoc.pluginintoOPENCODE_CONFIG_CONTENTwhenOPENCODE_CONFIG_DIRis present.argsWithAutoModeFlagin the non-Claude hive spawn branch so all providers receive their auto-mode bypass posture.tools:statusresolution to check aliases (agy/antigravity).src/main/pty.ts&src/main/shellEnv.ts:agy.exe,antigravity.cmd, andcodex.cmdinwinCandidates.src/shared/agentProvider.ts:autoModeFlag: '--dangerously-skip-permissions --auto',autoFlag: '--dangerously-skip-permissions --auto', andresumeFlag: '-s'.buildSpawnCommand.Operating System
Windows 11 (tested on Windows 10/11 x64)