> ## Documentation Index
> Fetch the complete documentation index at: https://agent-memory.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Antigravity

> Separate adapters for the IDE and the agy CLI, with native hooks on the CLI side

Antigravity is two products with two configs. The IDE keeps MCP config in its application support directory; the `agy` CLI keeps its own under `~/.gemini/config/`. agentmemory ships one adapter for each; they share nothing.

<Tabs>
  <Tab title="Antigravity IDE">
    ```bash theme={"dark"}
    npx @agentmemory/agentmemory connect antigravity
    ```

    <Steps>
      <Step title="Start agentmemory">
        ```bash theme={"dark"}
        npx @agentmemory/agentmemory
        ```
      </Step>

      <Step title="Run connect">
        The adapter writes `mcp_config.json` in Antigravity's User directory. macOS: `~/Library/Application Support/Antigravity/User/`. Linux: `~/.config/Antigravity/User/`.
      </Step>

      <Step title="Restart Antigravity">
        Restart the IDE so the MCP server loads.
      </Step>

      <Step title="Verify">
        Ask the agent to save a fact with `memory_save`, then search it:

        ```bash theme={"dark"}
        curl -X POST http://localhost:3111/agentmemory/smart-search \
          -H 'Content-Type: application/json' \
          -d '{"query": "the fact you saved"}'
        ```
      </Step>
    </Steps>

    The written entry is the standard block:

    ```json mcp_config.json theme={"dark"}
    {
      "mcpServers": {
        "agentmemory": {
          "command": "npx",
          "args": ["-y", "@agentmemory/mcp"],
          "env": {
            "AGENTMEMORY_URL": "${AGENTMEMORY_URL:-http://localhost:3111}",
            "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET:-}",
            "AGENTMEMORY_TOOLS": "${AGENTMEMORY_TOOLS:-all}"
          }
        }
      }
    }
    ```

    The IDE is MCP-only for capture purposes; `connect` upserts the memory-usage guideline into `~/.gemini/GEMINI.md` (Antigravity does not read AGENTS.md).
  </Tab>

  <Tab title="Antigravity CLI (agy)">
    ```bash theme={"dark"}
    npx @agentmemory/agentmemory connect antigravity-cli --with-hooks
    ```

    Detection keys off `~/.gemini/antigravity-cli/`, which only the CLI creates; `~/.gemini/` alone would also match Gemini CLI. MCP lands in `~/.gemini/config/mcp_config.json` (same standard block as the IDE tab), and `/mcp` inside agy lists configured servers.

    `--with-hooks` merges the bundled manifest into `~/.gemini/config/hooks.json`. Antigravity's hooks file is not the Claude Code envelope; it is a map of named bundles, and the two event shapes inside are load-bearing. Tool events take a `{ matcher, hooks }` wrapper; lifecycle events take a flat handler list:

    ```json ~/.gemini/config/hooks.json theme={"dark"}
    {
      "agentmemory": {
        "enabled": true,
        "PreInvocation": [
          { "type": "command", "command": "node <plugin>/scripts/antigravity-bridge.mjs PreInvocation", "timeout": 10 }
        ],
        "PreToolUse": [
          {
            "matcher": "view_file|view_code_item|read_file|edit_file|replace_file_content|write_to_file|create_file|grep_search|codebase_search|find_by_name|list_dir",
            "hooks": [
              { "type": "command", "command": "node <plugin>/scripts/antigravity-bridge.mjs PreToolUse", "timeout": 10 }
            ]
          }
        ],
        "PostToolUse": [
          {
            "matcher": "",
            "hooks": [
              { "type": "command", "command": "node <plugin>/scripts/antigravity-bridge.mjs PostToolUse", "timeout": 10 }
            ]
          }
        ],
        "Stop": [
          { "type": "command", "command": "node <plugin>/scripts/antigravity-bridge.mjs Stop", "timeout": 10 }
        ]
      }
    }
    ```

    `<plugin>` is resolved at install time to the absolute path of the bundled `plugin/` directory; agy expands no env vars. The merge owns exactly the top-level bundles whose commands point under the bundled `scripts/` directory, so your own named bundles survive re-installs.

    <Warning>
      agy runs hook commands with no shell: it strips no quotes and offers no escaping, so a space anywhere in the plugin path produces hooks that load but never run. The installer refuses to install hooks when the resolved path contains whitespace and says so; reinstall agentmemory under a space-free path to use `--with-hooks`. MCP works either way. Verified against agy 1.0.15.
    </Warning>
  </Tab>
</Tabs>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Wired the wrong Antigravity">
    `connect antigravity` targets the IDE, `connect antigravity-cli` targets agy. They read different files; wiring one does nothing for the other. Run the adapter that matches what you use, or both.
  </Accordion>

  <Accordion title="Hooks file rejected after manual edits">
    Wrapping a lifecycle event (`PreInvocation`, `PostInvocation`, `Stop`) in the `{ matcher, hooks }` form makes agy read the wrapper as a handler and reject the whole file, disabling every other bundle in it. Keep lifecycle events as flat handler lists and let the installer manage the agentmemory bundle.
  </Accordion>
</AccordionGroup>

Adapter sources: `src/cli/connect/antigravity.ts`, `src/cli/connect/antigravity-cli.ts`, merge engine in `src/cli/connect/antigravity-hooks.ts`. Hook manifest: `plugin/hooks/hooks.antigravity.json`.
