Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
Merge remote-tracking branch 'origin/release/2.7' into pr/1226
AkitaOnRails131a74c231d8
diff --cc CHANGELOG.mdindex 497ad56e,606a9132..8040abb3--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -147,8 -243,120 +243,129 @@@ and this project adheres to [Semantic Va Cordis profile patch rather than a fixed config file, so the command prints aready-to-merge `- insert:` fragment for `@deepseek-ai/dsh-mcp-client` andrefuses `--apply`. (#1193)+ - The `ai-memory-importer` companion imports agentmemory data. `agentmemory-vault`+ reads its Obsidian vault export; `agentmemory-export` reads its `ExportData`+ JSON file, from disk only, and needs a mapping file from agentmemory's+ project names (or exact session working directories) to ai-memory+ workspaces and projects. `--apply` refuses to run while any record is+ unmapped. Pages land under `imported/agentmemory/` (`--dest-prefix`), never+ under `sessions/` or another reserved family, and links to pages that were+ not imported become plain text. Every write goes through `memory_write_page`+ with `create_only` or `expected_page_id`, and the importer refuses servers+ older than 2.7. A memory's versions are written oldest first so ai-memory+ keeps the supersession chain, and `forgetAfter` becomes `expires_at`. Each+ page carries a stable UUIDv5 ingest key, so an interrupted import resumes+ without duplicates and a rerun writes nothing. Text is redacted before+ anything is planned or sent. Observations are dropped unless+ `--replay-observations` replays them as `external-import` sessions through+ `/hook/batch`, and records with no ai-memory counterpart are counted in the+ manifest. The cookbook has a "Coming from agentmemory" section.+ - `ai-memory doctor` reports agentmemory configuration left behind after a+ migration: an MCP server entry in any harness config `install-mcp` knows (or+ in a project's `.mcp.json`, `.cursor/mcp.json`, `.gemini/settings.json` or+ `.vscode/mcp.json`), and agentmemory guideline blocks in rules files such as+ `AGENTS.md`, `GEMINI.md`, `.cursor/rules/` and `.kiro/steering/`. It names+ each file and the key or lines, prints the fix, and warns when a block names+ `memory_consolidate`, which ai-memory also has with different arguments. The+ check only reads; it never edits or deletes another tool's files. `doctor+ --json` carries the findings as `agentmemory_residue`.+ - Added `ai-memory auth enable`, which turns on bearer auth for an install+ created without it. It reuses or creates an owner-only token at+ `<data_dir>/auth-tokens/default`, records it in `config.toml`, gives the+ installed hooks the token when they hold no other credential, and+ re-registers every MCP client whose `ai-memory` entry points at this server+ the way `install-mcp` now wires a token-file install. It lists each client+ it changed, each entry for another server it left alone, and anything that+ needs a manual change. Running it again changes nothing, and the token is+ never printed or written into a harness config. Restart the server+ afterwards.+ - Added `ai-memory mcp-bridge --no-session-id`, a plain stdio-to-HTTP MCP+ bridge for any client that runs local commands. It authenticates with the+ token from config (`AI_MEMORY_AUTH_TOKEN`, `[auth] bearer_token`, or the+ file `[auth] bearer_token_file` names), forwards no session identity (the+ client passes `workspace` and `project` like any static MCP client, and an+ inherited `CLAUDE_CODE_SESSION_ID` is ignored), and exits at once with+ `401 Unauthorized` when the server refuses it. Without the flag the bridge+ keeps Claude Code's session forwarding and still refuses to start without+ `CLAUDE_CODE_SESSION_ID`.+ - Added the `[auth] bearer_token_file` config key (env+ `AI_MEMORY_AUTH__BEARER_TOKEN_FILE`): a file holding the root bearer token,+ read once at startup. A relative path resolves against the data dir.+ `AI_MEMORY_AUTH_TOKEN` still takes precedence; setting the key together with+ `[auth] bearer_token` is a startup error, and a server whose configured file+ is missing or empty refuses to start. A token read from the file is never+ written into a harness config: `install-mcp` registers Claude Code through+ the session-aware `ai-memory mcp-bridge`, gives Codex and Prime Agent a+ reference to `$AI_MEMORY_AUTH_TOKEN`, and writes every other client a stdio+ entry for `ai-memory mcp-bridge --no-session-id` in that client's own config+ format (OpenCode, OpenCode 2, Cursor, Claude Desktop, Gemini CLI, OpenClaw,+ OMP, Antigravity CLI, Zero, Devin, Grok, Kimi Code, Kiro CLI, Command Code,+ Copilot CLI, Swival, VS Code, Zed, Muse Code; DeepSeek Harness's printed+ patch too). Only ZCode, whose config keeps HTTP entries only, is refused with+ the manual option. `uninstall` recognises these entries.+ `install-hooks --apply` stores the token in the hook credential files only.+ - `ai-memory status` and `ai-memory doctor` now show the server's auth+ posture, and for an unauthenticated loopback server print+ `auth: none (loopback)` with the fix, `ai-memory auth enable`.++- Added `--project-id` to `purge-project`, `rename-project` and++ `move-project` (and `project_id` to their admin endpoints), as an++ alternative to the project name. A legacy twin row whose name collides with++ another project's `legacy_name` (the empty leftover an older migration++ leaves behind) was refused as ambiguous by name, so it could not be purged++ or renamed. The id is looked up inside the named workspace: sending both or++ neither is a 400, a malformed UUID is a 400, and an id that names no project++ in that workspace is a 404. `list-projects` now prints each project's id so++ an operator can copy it. (#1208, #1226)### Changed+ - Changed scoped `/api/v1/search` (a single `workspace` + `project`, or+ `scopes`) to rank with the same hybrid ranker as `memory_query` instead of+ FTS5 alone, so it returns the same order as `memory_query`, and `rank` is+ now the fused rank. Cross-project search without a scope is unchanged.+ - Documented hand-written MCP recipes for Factory Droid, Warp, Cline, Kilo+ Code, Goose, Qwen Code and OpenHuman in `docs/install.md`, and listed them+ in `docs/support-matrix.md` as `MCP-only (documented)`: each recipe follows+ the client's own documentation at a named version and has not yet been run+ end to end. Aider is not listed because it has no MCP support.+ - Published `docs/benchmarks/longmemeval-s-decomposition-2026-10-12.md`, which+ splits the LongMemEval-S retrieval number into capture cost, ranking quality+ and harness artifacts, and records what the observation stream recovered+ (zero-LLM FTS `hit@5` 0.666 → 0.868 on all 470 questions). The benchmark,+ evals and comparison docs no longer blame the 2 KB excerpt cap for the gap+ (pages holding exactly the captured text score 0.968 against 0.972 for whole+ sessions) and no longer attribute agentmemory's 0.967 to LongMemEval-S: it is+ the grep baseline on agentmemory's in-house corpus, and its LongMemEval-S+ figure is 95.2% from a component harness with the reranker disabled, not+ like-for-like with ai-memory's pipeline numbers. `docs/comparison.md` gains a+ "From agentmemory" migration note.+ - Changed `memory_query` ranking to include the observation stream by+ default, after it raised hit@5 on the retrieval eval for both zero-LLM and+ local-embedding search while staying inside its latency and context-token+ budgets. `explain=true` lists `observation` in+ `streams_active` whenever it runs. To keep the previous ranking, set+ `[retrieval] observation_stream = false` (or+ `AI_MEMORY_RETRIEVAL__OBSERVATION_STREAM=false`); ranking is then identical+ to before.+ - Changed `ai-memory init` on a fresh data dir (no config file and no+ database yet) to create a root bearer token at+ `<data_dir>/auth-tokens/default` and record `[auth] bearer_token_file`, so+ a new install's server requires the token on every route except `/healthz`.+ The hooks, the CLI and `ai-memory mcp-bridge` read it from the data dir;+ client commands of a packaged install, whose config lives outside the data+ dir, find it there too when they read no config file and target a loopback+ server. Existing installs are unchanged and keep running without auth until+ `ai-memory auth enable`; so is an `init` that finds a database or a bearer+ supplied another way. `uninstall` keeps this token, since it is the+ server's credential. The Docker wrapper hands a host command (`install-hooks`,+ `mcp-bridge`, `run`) the token of a server initialized on its volume as an+ owner-only file that `install-hooks` copies from the volume, never on a+ command line. With no human accounts the built-in web UI answers a browser+ with a Basic sign-in prompt instead of redirecting to a login form that+ could not succeed: any username, and the token file's contents as the+ password. `ai-memory setup` prints that URL and the file to read, never the+ token. The macOS menu bar app reads the token from its data dir when none is+ saved in Settings, so an install it initialized turns green without pasting+ anything.- Changed `ai-memory-wikisync` files to carry a small frontmatter (`title`,plus `tags`, `pinned` and a non-default `tier` when set) above the body,so metadata survives a round trip. The first run after upgrading rewrites