Skip to content

Fix Windows connectivity & lifecycle bridges for Antigravity, OpenCode, and Codex #475

Description

@adhimiw

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:

  1. 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.
  2. 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.
  3. 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

  1. 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.
  2. 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).
  3. src/main/pty.ts & src/main/shellEnv.ts:

    • Add candidate Windows paths for agy.exe, antigravity.cmd, and codex.cmd in winCandidates.
  4. 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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions