Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
Merge adjusted PR #1068 into PR #1070
AkitaOnRailsa47631d9d7a1
diff --cc CHANGELOG.mdindex e02f0a55,8fda8773..5feb24b1--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -15,17 -15,12 +15,17 @@@ and this project adheres to [Semantic Vpayload. Ten events — Claude Code's nine plus `PostToolUseFailure` — withnative commands enforcing capture exclusions; tool output is read from`tool_result.text_result_for_llm` and the outcome from- `tool_result.result_type`. Copilot reads a top-level `additionalContext` on- `SessionStart` rather than Claude Code's envelope, so handoffs are not- injected yet: recover them with `memory_handoff_accept`. The bare+ `tool_result.result_type`. The `SessionStart` hook delivers the prior+ session's handoff through Copilot's top-level `additionalContext` (ported+ from #1069). There is deliberately no `--scope project`. The bare`install-mcp --client copilot` alias keeps meaning VS Code Copilot;- `install-mcp --client copilot-cli` and `ai-memory run copilot` follow- separately. (#1040)+ `ai-memory run copilot` follows separately. (#1040)+- Added `install-mcp --client copilot-cli`, which merges ai-memory's remote+ entry (`type: "http"`, `url`, bearer `headers`, `tools: ["*"]`) into the root+ `mcpServers` map of `$COPILOT_HOME/mcp-config.json` (default+ `~/.copilot/mcp-config.json`), preserving other servers. `install-hooks+ --agent copilot-cli` without `--server-url` now reads the server URL and+ bearer back from that entry, and `uninstall` removes it. (#1040)- Added `install-hooks --agent claude-code --scope project`, which writes thehook configuration to the checkout's gitignored `.claude/settings.local.json`(where Claude Code reads it: the git root, or the launch directory ondiff --cc docs/install.mdindex 4310c583,ce8bb6e5..9e0f6e6c--- a/docs/install.md+++ b/docs/install.md@@@ -1332,14 -1325,18 +1332,18 @@@ rejects `matcher` on `SessionStart`, `Sevents, and omitting it elsewhere means "every invocation". Tool output isread from `tool_result.text_result_for_llm`.- Copilot reads a top-level `additionalContext` from `SessionStart` stdout, not- Claude Code's `hookSpecificOutput` envelope, so the prior session's handoff is- not injected yet; recover it via MCP `memory_handoff_list` then- `memory_handoff_accept` with that `handoff_id`. There is no `--scope project`:- Copilot's repository hook files (`.github/hooks/*.json`) are shared with the- team and loaded by the Copilot cloud agent, so they cannot carry per-machine- script paths. `ai-memory run copilot` is not shipped yet;- `install-mcp --client copilot` remains the VS Code Copilot client.+ The `SessionStart` hook delivers the prior session's handoff: Copilot reads a+ top-level `additionalContext` from `SessionStart` stdout (not Claude Code's+ `hookSpecificOutput` envelope), and the hook prints exactly that, or `{}` when+ nothing is pending.++ `--scope project` is intentionally unsupported for Copilot CLI. Copilot's+ repository hook files (`.github/hooks/*.json`) are versioned, shared with the+ team and loaded by the Copilot cloud agent, while ai-memory's hook entries+ carry this machine's absolute executable and data-dir paths; committing them-would point every teammate at one person's install and server. `install-mcp --client copilot-cli` and `ai-memory run copilot`-are not shipped yet; `install-mcp --client copilot` remains the VS Code-Copilot client.++would point every teammate at one person's install and server.++`ai-memory run copilot` is not shipped yet; `install-mcp --client copilot`++remains the VS Code Copilot client.### Hermes Agent (Nous Research)diff --cc docs/support-matrix.mdindex 78ce3706,1558f66e..7dc3a532--- a/docs/support-matrix.md+++ b/docs/support-matrix.md@@@ -34,7 -34,7 +34,7 @@@| Kimi Code | Supported | MCP config (`url` entry in `~/.kimi-code/mcp.json`) + lifecycle hooks (`[[hooks]]` in `~/.kimi-code/config.toml`, 10 events including subagent start/stop and `PostToolUseFailure` for tool-failure capture); both paths honor `$KIMI_CODE_HOME`. Handoffs inject via `UserPromptSubmit` stdout (Kimi Code discards `SessionStart` hook stdout); `ai-memory run kimi` adds managed workstream resume. || Kiro CLI | Supported | MCP config uses `install-mcp --client kiro-cli` (alias `kiro`) and Kiro's Bedrock-compatible schema flavor. `install-hooks --agent kiro-cli` merges v2 hooks into existing agent configs; the explicit `--agent kiro-cli-v3` target writes the incompatible standalone v3 registration. Both preserve unrelated entries, honor `$KIRO_HOME`, enforce capture exclusions, and inject pending handoffs at session start. Kiro has no true SessionEnd hook; use `ai-memory finalize-session --agent kiro-cli`, with `--session-id <uuid>` for concurrent sessions, unless it is an interactive session launched with `ai-memory run kiro`, which finalizes it automatically when it exits if the run can tie the session to itself (see [`docs/managed-workstreams.md`](managed-workstreams.md)). `ai-memory run kiro` manages v2; add `--v3`, `--mode`, or `--agent-engine v3` for version-safe v3 resume. || Pool | Hooks-only | Poolside Agent CLI (`pool`). Lifecycle-hook capture via `install-hooks --agent pool` (alias `poolside`): Pool reads project-scoped hooks from the repo-root `.poolside/settings.yaml`, so ai-memory stages the scripts and prints a ready-to-paste `hooks:` snippet rather than writing committed project files; native commands enforce capture exclusions. Five Claude-shaped events (`SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `Stop`) and no true session-end — `Stop` is a turn boundary, so run `ai-memory finalize-session --agent pool` after the final turn. `SessionStart` stdout injection is not demonstrated, so capture works but handoff injection does not — recover handoffs via MCP `memory_handoff_list` then `memory_handoff_accept` with that `handoff_id`. No first-party `install-mcp` client and no managed workstream (`ai-memory run pool`) are claimed: Pool's native session-store contract is not demonstrated (see [`docs/managed-harness-contributions.md`](managed-harness-contributions.md)). Verified against Poolside CLI v1.0.16. |- | GitHub Copilot CLI | Supported | MCP config (`install-mcp --client copilot-cli` → `$COPILOT_HOME/mcp-config.json`, root `mcpServers`, `type: "http"`) + lifecycle hooks: `install-hooks --agent copilot-cli` writes `$COPILOT_HOME/hooks/ai-memory.json` (`COPILOT_HOME` defaults to `~/.copilot`). Configured with PascalCase event names, so Copilot sends the VS Code/Claude-compatible payload (`session_id`, `cwd`, `tool_name`, `tool_input`, `tool_result`) and native commands enforce capture exclusions; 10 events, Claude Code's nine plus `PostToolUseFailure`. Entries are flat with no `matcher`, because Copilot rejects it on `SessionStart`/`Stop`/`SessionEnd` and subagent events. Copilot reads a top-level `additionalContext` on `SessionStart` rather than Claude Code's envelope, so capture works but handoff injection does not yet — recover handoffs via MCP `memory_handoff_list` then `memory_handoff_accept` with that `handoff_id`. No `--scope project`: Copilot's repository hook files (`.github/hooks/*.json`) are shared with the team and the cloud agent, so they cannot carry per-machine script paths. `ai-memory run copilot` is a follow-up (#1040). The bare `--client copilot` alias keeps meaning VS Code Copilot. |-| GitHub Copilot CLI | Hooks-only | `install-hooks --agent copilot-cli` writes lifecycle hooks to `$COPILOT_HOME/hooks/ai-memory.json` (default `~/.copilot/hooks/ai-memory.json`). Configured with PascalCase event names, so Copilot sends the VS Code/Claude-compatible payload (`session_id`, `cwd`, `tool_name`, `tool_input`, `tool_result`) and native commands enforce capture exclusions; 10 events, Claude Code's nine plus `PostToolUseFailure`. Entries are flat with no `matcher`, because Copilot rejects it on `SessionStart`/`Stop`/`SessionEnd` and subagent events. The `SessionStart` hook delivers the prior session's handoff through Copilot's top-level `additionalContext`. `--scope project` is intentionally unsupported: Copilot's repository hook files (`.github/hooks/*.json`) are versioned and shared with the team and the cloud agent, so they cannot carry this machine's absolute executable and data-dir paths. `install-mcp --client copilot-cli` and `ai-memory run copilot` are follow-ups (#1040). The bare `--client copilot` alias keeps meaning VS Code Copilot. |++| GitHub Copilot CLI | Supported | MCP config (`install-mcp --client copilot-cli` → `$COPILOT_HOME/mcp-config.json`, root `mcpServers`, `type: "http"`) + lifecycle hooks: `install-hooks --agent copilot-cli` writes `$COPILOT_HOME/hooks/ai-memory.json` (`COPILOT_HOME` defaults to `~/.copilot`). Configured with PascalCase event names, so Copilot sends the VS Code/Claude-compatible payload (`session_id`, `cwd`, `tool_name`, `tool_input`, `tool_result`) and native commands enforce capture exclusions; 10 events, Claude Code's nine plus `PostToolUseFailure`. Entries are flat with no `matcher`, because Copilot rejects it on `SessionStart`/`Stop`/`SessionEnd` and subagent events. The `SessionStart` hook delivers the prior session's handoff through Copilot's top-level `additionalContext`. `--scope project` is intentionally unsupported: Copilot's repository hook files (`.github/hooks/*.json`) are versioned and shared with the team and the cloud agent, so they cannot carry this machine's absolute executable and data-dir paths. `ai-memory run copilot` is a follow-up (#1040). The bare `--client copilot` alias keeps meaning VS Code Copilot. || VS Code Copilot | MCP-only | `.vscode/mcp.json` for Copilot agent mode; no lifecycle hooks (Copilot does not expose them yet). || Zed | MCP-only | Native remote MCP under `context_servers` in Zed's user `settings.json`; no lifecycle hooks or managed-workstream support. || Muse Code | MCP-only | `install-mcp --client muse` merges a native streamable-HTTP entry with bearer `headers` into the snake_case `mcp_servers` map of `~/.config/muse/settings.json`, preserving sibling servers. The writer adds the mandatory `"schema_version": 1` when absent (without it every `muse` command fails at startup) and never rewrites an existing value, and it sets `"mode": "optional"` because Muse's default `required` aborts the whole run when the server is unreachable. Skills need no extra step: Muse reads `~/.agents/skills`, which `install-skills` already writes. Lifecycle capture and managed workstreams are not claimed — Muse documents a hook surface, but the output contract of its `SessionStart` event is not specified. |