Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
docs: clarify Gemini CLI hook support
AkitaOnRailsb1d645afb6fa
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d9fdb2d4..0bb37b42 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -31,6 +31,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Changed- Documented the vector backend policy and the measured criteria requiredbefore adding `sqlite-vec`.+- Clarified Gemini CLI support docs: MCP registration, lifecycle hooks,+ SessionStart handoff injection, and SessionEnd capture are now called out+ consistently across README and install guides.- Docker images now bundle both POSIX and PowerShell hook scripts.### Fixeddiff --git a/README.md b/README.mdindex 6d422402..277898cc 100644--- a/README.md+++ b/README.md@@ -149,8 +149,8 @@ docker run -d --name ai-memory \# 3. Wire your agent CLI in two commands. The wrapper takes care of# mounts + auto-detecting ~/.claude/settings.json. Re-run with-# `--agent codex`, `--agent opencode`, `--agent omp`/`pi`,-# `--client cursor`, `--client pi`/`omp`, etc.+# `--agent codex`, `--agent opencode`, `--agent gemini-cli`,+# `--agent omp`/`pi`, `--client cursor`, `--client gemini-cli`, etc.# for additional agents; full list in docs/install.md.ai-memory install-mcp --client claude-code --applyai-memory install-hooks --agent claude-code --applydiff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex 39e758b7..9cb81cf7 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -7,8 +7,8 @@## Purposeai-memory is a single Rust binary that gives AI coding agents (Claude-Code, OpenAI Codex, OpenCode, OMP, and MCP-capable clients) long-term-memory shared across CLIs.+Code, OpenAI Codex, Cursor, Gemini CLI, OpenCode, OMP, and MCP-capable+clients) long-term memory shared across CLIs.Quit one mid-task; open another in the same directory; continue. Nomanual `write_note` ceremony, no copy-pasting summaries betweensessions.@@ -25,7 +25,8 @@ markdown stays the source of truth.```┌──────────────────────┐│ Claude Code / Codex │- │ / OpenCode / OMP │+ │ Cursor / Gemini CLI │+ │ OpenCode / OMP │└──────────┬───────────┘lifecycle hooks │ stdio(fire-and-forget HTTP) ▼diff --git a/docs/design-decisions.md b/docs/design-decisions.mdindex 516f08d4..8111ad14 100644--- a/docs/design-decisions.md+++ b/docs/design-decisions.md@@ -8,8 +8,8 @@A self-contained Rust binary that:-1. Runs as an **MCP server** (stdio + HTTP/SSE) for coding-agent CLIs (Claude Code, OpenAI Codex, OpenCode, OMP, and MCP-capable clients).-2. Captures the agent's session **automatically** - no `write_note` ceremony - via hook scripts or generated extensions that the agent CLIs invoke (Claude Code lifecycle hooks, Codex hooks, OpenCode/OMP TypeScript integrations). Optional transcript-tail fallback for agents without hook APIs.+1. Runs as an **MCP server** (stdio + HTTP/SSE) for coding-agent CLIs (Claude Code, OpenAI Codex, Cursor, Gemini CLI, OpenCode, OMP, and MCP-capable clients).+2. Captures the agent's session **automatically** - no `write_note` ceremony - via hook scripts or generated extensions that the agent CLIs invoke (Claude Code / Codex / Cursor / Gemini CLI lifecycle hooks, OpenCode/OMP TypeScript integrations). Optional transcript-tail fallback for agents without hook APIs.3. Maintains a **Karpathy-style wiki**: incrementally-compiled markdown pages with cross-links, supersession, an `index.md` and a `log.md`.4. Serves retrieval via the MCP `tools/list` to coding agents: a handful of *narrow* tools, not 50.5. Ships a **Docker image** (`docker run -v ai-memory-data:/data -p 49374:49374 ai-memory`) so it can move between desktop and homelab.diff --git a/docs/install.md b/docs/install.mdindex 4e007b17..bcc64a09 100644--- a/docs/install.md+++ b/docs/install.md@@ -85,9 +85,10 @@ Claude Desktop and OpenClaw are MCP-only today. Claude Code, Codex,OpenCode, OMP, Cursor, and Gemini CLI have lifecycle capture pathsthrough `install-hooks`.-> **Two-step hook install pattern.** Claude Code and Codex use shell-> hook scripts: (1) `docker cp` the bundled scripts to your home dir,-> (2) `docker run --rm install-hooks` to render the config snippet.+> **Two-step hook install pattern.** Claude Code, Codex, Cursor, and+> Gemini CLI use shell/PowerShell hook scripts: (1) `docker cp` the+> bundled scripts to your home dir, (2) `docker run --rm install-hooks`+> to render the config snippet.> OpenCode and OMP are different: they use generated TypeScript> plugin/extension files, so no shell-script extraction is needed for> those clients.@@ -179,7 +180,7 @@ files owned by the user running the command. Prefer it as thedefault; reach for `setup-agent` only when your docker setup isknown not to remap UIDs.-### Cursor, Claude Desktop, Gemini CLI, OpenClaw+### Cursor, Gemini CLI, Claude Desktop, OpenClawSee [**`docs/mcp-install.md`**](mcp-install.md) for the per-client MCPconfig file path and snippet, or one-shot it via:@@ -197,15 +198,20 @@ docker run --rm akitaonrails/ai-memory:latest \install-mcp --client gemini-cli --auth-token "$TOKEN" \--server-url "http://homelab:49374/mcp"+docker run --rm akitaonrails/ai-memory:latest \+ install-hooks --agent gemini-cli --auth-token "$TOKEN" \+ --server-url "http://homelab:49374"+docker run --rm akitaonrails/ai-memory:latest \install-mcp --client openclaw --auth-token "$TOKEN" \--server-url "http://homelab:49374/mcp"```-For MCP-only clients you'll need to nudge the model to call-`memory_query` / `memory_handoff_accept` itself. For clients with-`install-hooks` support, the capture path handles handoff injection at-session start.+Cursor and Gemini CLI support both `install-mcp` and `install-hooks`.+Claude Desktop and OpenClaw are MCP-only here, so you'll need to nudge+the model to call `memory_query` / `memory_handoff_accept` itself. For+clients with `install-hooks` support, the capture path handles handoff+injection at session start.---diff --git a/docs/mcp-install.md b/docs/mcp-install.mdindex e6e8206c..d67977a1 100644--- a/docs/mcp-install.md+++ b/docs/mcp-install.md@@ -17,12 +17,12 @@> --http-stateful` to restore rmcp's session mode.This page documents how to register ai-memory as an MCP server with-the agent CLIs **that are not covered inline in the README**.+agent CLIs beyond the README quick start.-Claude Code, OpenAI Codex, OpenCode, and OMP have automatic capture-integrations (shell hooks for Claude Code / Codex, TypeScript-plugin/extension files for OpenCode / OMP) and are covered in the-[main README](../README.md#configure-your-agent-cli).+Claude Code, OpenAI Codex, Cursor, Gemini CLI, OpenCode, and OMP have+automatic capture integrations (shell/PowerShell hooks for Claude Code /+Codex / Cursor / Gemini CLI, TypeScript plugin/extension files for+OpenCode / OMP) and are covered in the [main README](../README.md#quick-start).Some clients on this page are **MCP-only**: they expose long-termmemory to their LLM via ai-memory's MCP tools (`memory_query`,@@ -41,7 +41,7 @@ asking the LLM to call `memory_handoff_begin` manually before quitting.> **One-shot tip:** every snippet below is also reachable from the> CLI:> ```bash-> ai-memory install-mcp --client cursor # or claude-desktop / gemini-cli / openclaw / pi|omp+> ai-memory install-mcp --client gemini-cli # or cursor / claude-desktop / openclaw / pi|omp> ```---@@ -134,9 +134,23 @@ endpoints. The `timeout` is in milliseconds.}```+**Hooks:**++```bash+ai-memory install-hooks --agent gemini-cli --apply+```++Gemini CLI's lifecycle event names differ from Claude Code's, so use+`install-hooks --agent gemini-cli` rather than copying another agent's+settings. ai-memory maps Gemini's `SessionStart`, `SessionEnd`,+`BeforeTool`, `AfterTool`, and `PreCompress` events to the shared hook+capture path; `SessionStart` also fetches pending handoffs.+**Gotchas:**- Gemini supports stdio too via `command`/`args`, plus SSE via `url`.Only `httpUrl` covers streamable HTTP. Don't mix them in one entry.+- Restart the CLI session after changing `~/.gemini/settings.json` so+ both MCP servers and hooks are reloaded.- Source: <https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md>---@@ -270,8 +284,8 @@ that *starts* the next one - to play nicely with ai-memory:| Side | What's needed | Covered by ||---|---|---|-| **Ending side** | The agent must create a handoff, either through a true session-end hook or by calling `memory_handoff_begin`. | Built-in for Claude Code, Codex, and OMP. OpenCode has no true session-end event, so ask it to call `memory_handoff_begin` before quitting when you need a handoff. |-| **Starting side** | Either (a) the session-start/plugin path injects the handoff via `/handoff`, OR (b) the model proactively calls `memory_handoff_accept` on first turn. | (a) is built-in for Claude Code / Codex / OpenCode / OMP. (b) works for any MCP-capable client if you nudge the model - see [the CLAUDE.md snippet](../README.md#nudging-the-agent-to-use-memory-proactively). |+| **Ending side** | The agent must create a handoff, either through a true session-end hook or by calling `memory_handoff_begin`. | Built-in for Claude Code, Codex, Cursor, Gemini CLI, and OMP. OpenCode has no true session-end event, so ask it to call `memory_handoff_begin` before quitting when you need a handoff. |+| **Starting side** | Either (a) the session-start/plugin path injects the handoff via `/handoff`, OR (b) the model proactively calls `memory_handoff_accept` on first turn. | (a) is built-in for Claude Code / Codex / Cursor / Gemini CLI / OpenCode / OMP. (b) works for any MCP-capable client if you nudge the model - see [the CLAUDE.md snippet](../README.md#nudging-the-agent-to-use-memory-proactively). |So a typical mixed workflow looks like: