Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

Merge branch 'main' into release/2.7

AkitaOnRails1e0aba29376b
diff --cc CHANGELOG.md
index fd80ef94,d69da59a..fb1f9aab
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -7,137 -7,94 +7,224 @@@ and this project adheres to [Semantic V
## [Unreleased]
+### Added
+- `memory_write_page` accepts `expected_page_id` (write only if that is still
+ the page's latest version) or `create_only` (write only if the page does not
+ exist), and `memory_delete_page` accepts `expected_page_id`. A precondition
+ that no longer holds fails with `reason: "precondition_failed"` and the
+ current version, and changes nothing. `memory_read_page` returns the version
+ as `page_id` and `/api/v1` pages as `id`. This is the compare-and-write the
+ team-wiki sync needed (#986).
+- The `ai-memory-wikisync` companion gained CI and post-merge integration
+ (#986, slice 5): `sync --check` writes nothing and exits 0 in sync, 3 on
+ drift and 4 on conflicts or refusals (a clone without sync state compares
+ the repository with the server directly), and `install-hook` /
+ `uninstall-hook` manage a marked git `post-merge` block that runs `sync`
+ after each merge — a dry-run report unless `--on-merge apply`, never with
+ `--prefer`, and never with a stored token. The cookbook has a GitHub
+ Actions recipe. (#986)
+- The `ai-memory-wikisync` companion now propagates deletes with
+ `sync --propagate-deletes` (#986, slice 4): a file deleted in the repository
+ deletes its server page through `memory_delete_page`, and a page deleted on
+ the server deletes its file, when the other side is unchanged since the last
+ sync. A delete against an edit is a conflict that `--prefer` resolves, more
+ than `--max-deletes` (default 10) refuses the run, and a pinned page is
+ deleted only with `--prefer repo`. Every sync write and delete now carries
+ the page version it was planned against, so a page changed during the run is
+ reported and left alone while the rest apply, and `sync --apply` refuses a
+ server older than 2.7. Without the flag deletes are still only reported.
+ (#986)
+- `ai-memory doctor` now reports three silent capture failures: an unreachable
+ server (reported instead of aborting the check), a hook spool that is full and
+ evicting undelivered events, and installed ai-memory Codex hooks that Codex
+ skips because they are untrusted or changed since they were trusted (asked
+ of Codex itself through `codex app-server`). `ai-memory status` no longer says
+ queued events will be delivered once the spool has started evicting them.
+- Added two-way sync to the `ai-memory-wikisync` companion (#986, slice 3):
+ `sync` imports repository edits and new pages through the public
+ `memory_write_page` MCP tool and exports server edits, comparing each
+ page with the last sync. A page changed on both sides is a conflict until
+ `--prefer repo` or `--prefer server`; deletes are reported, not synced.
+ It is a dry-run without `--apply`, refuses files without frontmatter,
+ refuses to overwrite server pages whose metadata a write would clear, and
+ re-reads each page right before writing it. (#1164)
+- `finalize-session --agent antigravity-cli` now replays the session's typed
+ prompts from `agy`'s `history.jsonl` before its synthetic session-end, so
+ live Antigravity sessions — whose hooks carry no prompt event — get a summary
+ page titled by the first prompt, a handoff with "Started/Last", and prompts
+ that `memory_query` and `memory_recent` can find. Only lines whose
+ conversation and workspace match the session are read; each prompt carries
+ the key `backfill` mints for it, so a repeated `--reopen` stores it once and a
+ prompt typed after the first finalize arrives with the next one. A checkout
+ the capture allowlist does not admit and `--all-owners` runs replay nothing,
+ and a missing `history.jsonl` only warns. (#1160)
+- `ai-memory run` accepts `copilot` (alias `copilot-cli`) and manages GitHub
+ Copilot CLI as a workstream harness: a fresh session gets a generated
+ `--session-id`, a returning one is resumed with `--resume=<id>`, user
+ selectors (`--resume`, `--continue`, `--session-id`, `--connect`) win,
+ utility subcommands pass through, and `--yolo` maps to Copilot's native
+ `--yolo`. Visible messages, tool calls and results, and compaction summaries
+ are imported read-only from `$COPILOT_HOME/session-state/<uuid>/events.jsonl`
+ (system prompts, hidden reasoning, hook output, and telemetry are excluded),
+ and the existing SessionStart hook delivers the workstream context. The
+ first managed launch auto-wires Copilot's hooks and MCP, and `doctor` now
+ counts its local sessions. Verified against Copilot CLI 1.0.92. (#1040)
+- GitHub Copilot CLI is now a first-class routing target:
+ `install-skills --agent copilot-cli` (and `install-instructions
+ --skills-agent copilot-cli`) writes the managed Agent Skills to the
+ repository's `.github/skills` or, globally, to `$COPILOT_HOME/skills`
+ (default `~/.copilot/skills`); `memory_install_self_routing` returns
+ `copilot_cli` filename and skill-root hints; the routing snippet, the
+ routing-install skill, and the MCP instructions name Copilot CLI with
+ `AGENTS.md`; and `uninstall` sweeps both Copilot roots, removing only
+ marker-bearing ai-memory skills. (#1040)
+- Added `ai-memory recover` and a bounded local recovery journal for server
+ outages. Offline managed launches now record only uniquely correlated native
+ session locators; recovery quarantines overlapping spool entries before exact
+ `/hook/batch` transcript replay, journals harnesses without transcript export
+ as spool-only without calling their exporter, retains bounded recovery dedup
+ keys with their sessions,
+ fails closed on terminal drops, and lets only the original owner finish an
+ expired unsuperseded managed run through exact idempotent replay. Backfill
+ and recovery replay now use reserved `recovery_*` idempotency keys, so
+ re-running `backfill --force` over sessions imported by ai-memory ≤2.6.0 (or
+ plain-backfilling a recovery-replayed session) can duplicate those older
+ observations. (#1125)
+- Added `AI_MEMORY_LLM_COMPAT_DISABLE_THINKING` for the `openai-compat`
+ provider (opt-in, off by default, ignored by every other provider): when
+ set, every chat request carries
+ `chat_template_kwargs: {"enable_thinking": false}`, so thinking-capable
+ local engines (vLLM / SGLang serving Qwen3-class models) spend the output
+ budget on the structured payload instead of a reasoning pass. (#1130)
+- Added the `cursor` LLM provider. Consolidation calls the logged-in Cursor
+ Agent CLI (`agent --print --mode ask`) so a Cursor subscription can drive
+ summaries without an API key. The default model is `cursor-grok-4.6-high`
+ ("Grok 4.6"). `AI_MEMORY_CURSOR_AGENT` overrides the binary. The provider never passes
+ `--yolo` or `--force`, because the prompt is captured session text. (#1127)
+- Added `applies_to` and `enforced_by` arguments to `memory_write_page`, and
+ `--applies-to` / `--enforced-by` to `ai-memory write-page`, for profile
+ entries. Both fields were documented as profile-entry frontmatter, but no
+ tool could set them, so scoping an entry to a stack or keeping it out of the
+ digest meant editing the wiki file by hand, and the next tool rewrite of the
+ entry dropped the value. A tag the profile cannot detect in any project
+ (`typscript`) is refused instead of silently hiding the entry, and both
+ arguments are refused on any page the digest does not read: one outside
+ `profile/`, or a `profile/` path in an ordinary project. (#1178)
+
+- Added the server version to the footer of every signed-in `/web` page (the
+ public login and change-password pages leave it out), on the right
+ side opposite "ai-memory · read-only", so you can tell which build a browser
+ tab is talking to without running `ai-memory status`. (#1171)
+
+- Added `install-mcp --client dsh` for the DeepSeek Harness (aliases
+ `deepseek-harness` and `deepseek_harness`). DSH keeps its MCP client in
+ a Cordis profile patch rather than a fixed config file, so the command prints a
+ ready-to-merge `- insert:` fragment for `@deepseek-ai/dsh-mcp-client` and
+ refuses `--apply`. (#1193)
+
+### Changed
+- 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
+ unedited files of an earlier export in place. (#1164)
+
### Fixed
+- Fixed SessionEnd consolidation repeating the same expensive prompt on the
+ durable queue when the structured LLM response fails deterministically: a
+ truncated or empty response, malformed JSON, or an unexpected response
+ shape now ends the queue on the first attempt, keeping the heuristic page
+ the hook already wrote; pre-send connection and capacity (`503`) failures
+ retain the bounded backoff. (#1131)
+- Fixed structured LLM responses stopped at the output budget
+ (`finish_reason = "length"`) or returned without usable content: they now
+ fail with redacted terminal errors, without copying the response. (#1130)
+ - Fixed a purged session coming back. `purge-session` leaves a tombstone so a
+ late event cannot recreate the session, but live hook ingest creates its
+ session row on a path that never checked it, so the next event for a purged
+ session brought back the session and a new observation. Hook ingest now
+ refuses it, and the delivery is acknowledged as `dropped_invalid` instead of
+ failing and being retried from the client's spool. (#1194)
+ - Fixed `purge-session` leaving the user's own sentences behind in the
+ cross-project profile's evidence: the profile harvests preference-shaped
+ sentences from prompts into candidate rows keyed to the session, and the
+ purge removed the session but not those rows, so a later pass could still
+ converge a purged sentence into a profile page. The purge now deletes the
+ session's prompt candidates in the same transaction. (#1195)
+ - Fixed `move-project` leaving rows on the old workspace. Pending
+ cross-project messages (addressed to the project and sent by it), entities,
+ page feedback, session purge tombstones and the profile evidence were not
+ re-stamped with the project's other tables, so the moved project lost its
+ pending mail, its entity retrieval and open feedback findings, and a purged
+ session could be recreated. They now move in the same transaction. (#1196)
+ - Fixed a Codex, Pi, OMP or Grok session going missing once its store held more
+ than 2,000 transcripts. Looking a session up by id read the first 2,000 files
+ in directory-walk order, so the rest came back as not found: `ai-memory run`
+ dropped the linked session and started a fresh one, and a transcript import
+ failed. The lookup now reads the transcript that names the session id first,
+ then the newest. (#1189)
+ - Fixed Crush sub-agent sessions being listed as sessions of their own:
+ `backfill`, `doctor` and the automatic session pick of `ai-memory run` read
+ the Crush `sessions` table without skipping rows that have a parent, so a
+ sub-agent session could be imported as a separate session or chosen for the
+ resume. The listing now skips them, as session discovery already did.
+ (#1190)
+ - Fixed rules titled in a script without ASCII letters (Cyrillic, CJK, Arabic
+ and others) overwriting each other: multi-page consolidation named every such
+ rule page `_rules/rule.md`, so only the last survived in the live rules list.
+ Each rule now gets a `_rules/rule-<hash>.md` name derived from its title. Rule
+ titles in Latin scripts are named as before. A restated non-Latin title
+ (case, spacing or punctuation aside) updates its own page. An existing
+ `_rules/rule.md` is left in place; delete it once its rule is restated.
+ (#1191)
+ - Fixed auto-improve accepting a proposal whose confidence is outside 0 to 1:
+ a model that answered in percent (`85`) cleared the confidence floor and was
+ staged, shown to the reviewer as 8500% and ranked first when sorting by
+ confidence. Such a value is now rejected as `confidence_out_of_range` and
+ recorded with the other rejected candidates. (#1192)
+ - Fixed the curl hook installer (`ai-memory-install-hooks`) installing event
+ scripts that could not run. Every script sources the shared `_lib.sh` helper
+ from its own directory or the one above it, but the installer fetched only
+ the per-agent scripts, so the helper was never written and each script
+ stopped at the line that sources it. The installer now also extracts
+ `_lib.sh` from the verified archive into the install root, beside the agent
+ directories, and refuses to continue when the archive does not contain it.
+ (#1184)
+ - Fixed the curl hook installer (`ai-memory-install-hooks`) disagreeing with
+ the hook bundles about which scripts an agent has. `--agent antigravity-cli`
+ always failed: it asked for the seven default event scripts, the Antigravity
+ bundle ships four, and the install stopped at the first missing one.
+ `--agent claude-code` and `--agent grok` never installed `subagent-start.sh`
+ and `subagent-stop.sh`, which their hook config points at, so `install-hooks`
+ warned that both were missing. The installer now installs the scripts each
+ bundle ships, and a test checks every script-based agent against the
+ repository bundles. (#1185)
+ - Fixed Kiro CLI tool calls being stored with no title or content: Kiro's
+ `PreToolUse` and `PostToolUse` hooks carry `tool_name` and `tool_input`
+ (plus `tool_response` after the call), and the capture policy already read
+ them, but Kiro was missing from the tool-capture mapping, so every Kiro tool
+ observation reached the store with a generic title and an empty body. They
+ now get the same tool-family title and output summary as Claude Code's.
+ (#1187)
+ - Fixed the generated OpenCode, OpenCode 2, OMP, Pi and OpenClaw integrations
+ losing hook events when the server is saturated. They treated every 4xx as a
+ permanent rejection, so a `429` (or a `408` or `425`) was dropped instead of
+ spooled, and their spool drain deleted each queued entry it met on such a
+ response. Both now keep `408`, `425`, `429` and every `5xx` for a later
+ drain, as the shell, PowerShell and native hooks already do. Re-run
+ `install-hooks --apply` for the agent to regenerate its plugin. (#1188)
+ - Fixed Claude Code's Windows `PowerShell` tool being classified as an
+ unknown tool, so its output never reached the session record and
+ `[capture] ignore_paths` never checked its command. It is now a shell tool
+ like `Bash`, in the native hook, the server, and the generated TypeScript
+ integrations, and the shell argument reader also follows PowerShell's
+ `-Param:value` binding (`Get-Content -Path:docs\adr\x.md`). (#1186)
+ - Fixed Zero's `sessionEnd` never delivering spooled events even with
+ network allowed in Zero's sandbox. Zero kills a hook's detached children
+ when the hook exits, which took the background drainer down with it. For
+ Zero, `session-end` now drains in-process within a fixed 10-second budget
+ (hard stop at 20 seconds, inside Zero's 30-second hook timeout); events
+ that cannot be delivered stay spooled. Other agents keep the detached
+ drainer. (#1172)
- Fixed generated TypeScript integrations (OpenCode, OpenCode 2, OMP,
Pi, OpenClaw) flashing a console window on Windows.
`discoverRemoteIdentity` spawned `git config --get remote.<name>.url`