Skip to content

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

Rust

Merge branch 'fix/1186-powershell-mcp'

AkitaOnRailsbddaf8398b6b
diff --cc CHANGELOG.md
index e1bb3a9b,cb5e29ff..d3cdc4ed
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -8,80 -8,12 +8,86 @@@ and this project adheres to [Semantic V
## [Unreleased]
### Fixed
+- 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 generated TypeScript integrations (OpenCode, OpenCode 2, OMP,
Pi, OpenClaw) flashing a console window on Windows.
`discoverRemoteIdentity` spawned `git config --get remote.<name>.url`
diff --cc crates/ai-memory-hooks/src/payload.rs
index cbf518df,7aa6362b..43c4162f
--- a/crates/ai-memory-hooks/src/payload.rs
+++ b/crates/ai-memory-hooks/src/payload.rs
@@@ -2856,71 -2855,48 +2856,113 @@@ mod tests
assert!(pre.body_excerpt.is_some_and(|body| !body.is_empty()));
}
+ /// Kiro CLI's tool hooks carry `tool_name` and `tool_input`, and its
+ /// `PostToolUse` adds `tool_response`: a plain string on the v3 engine
+ /// (live capture, Kiro CLI 2.16.2) and an object with a `success` flag on
+ /// v2. The capture policy already read this shape, but Kiro was absent from
+ /// `closed_tool_agent`, so its tool observations were stored with no title
+ /// or body, the failure mode Grok had in #931.
+ #[test]
+ fn kiro_cli_tool_events_keep_their_family_title_and_output() {
+ let v3 = HookEnvelope::from_query_and_body(
+ HookQuery {
+ event: "post-tool-use".into(),
+ agent: Some("kiro-cli".into()),
+ ..Default::default()
+ },
+ serde_json::json!({
+ "hook_event_name": "PostToolUse",
+ "session_id": "kiro-v3-session",
+ "cwd": "/workspace/project",
+ "tool_name": "read_file",
+ "tool_input": {"path": "/workspace/project/sample.txt"},
+ "tool_response": "MARKER_KIRO_V3_OUTPUT",
+ }),
+ );
+ assert_eq!(v3.agent, AgentKind::KiroCli);
+ assert_eq!(v3.title_hint.as_deref(), Some("tool file"));
+ let body = v3.body_excerpt.expect("kiro v3 post-tool body");
+ assert!(body.contains("MARKER_KIRO_V3_OUTPUT"), "{body:?}");
+
+ let v2 = HookEnvelope::from_query_and_body(
+ HookQuery {
+ event: "post-tool-use".into(),
+ agent: Some("kiro-cli".into()),
+ ..Default::default()
+ },
+ serde_json::json!({
+ "session_id": "kiro-v2-session",
+ "cwd": "/workspace/project",
+ "tool_name": "fs_read",
+ "tool_input": {"operations": [{"mode": "Line", "path": "src/lib.rs"}]},
+ "tool_response": {"success": true, "result": ["MARKER_KIRO_V2_OUTPUT"]},
+ }),
+ );
+ assert_eq!(v2.title_hint.as_deref(), Some("tool file"));
+ let body = v2.body_excerpt.expect("kiro v2 post-tool body");
+ assert!(body.contains("outcome: success"), "{body:?}");
+ assert!(body.contains("MARKER_KIRO_V2_OUTPUT"), "{body:?}");
+
+ let pre = HookEnvelope::from_query_and_body(
+ HookQuery {
+ event: "pre-tool-use".into(),
+ agent: Some("kiro-cli".into()),
+ ..Default::default()
+ },
+ serde_json::json!({
+ "hook_event_name": "PreToolUse",
+ "session_id": "kiro-v3-session",
+ "cwd": "/workspace/project",
+ "tool_name": "read_file",
+ "tool_input": {"path": "/workspace/project/sample.txt"},
+ }),
+ );
+ assert_eq!(pre.title_hint.as_deref(), Some("tool file"));
+ assert!(pre.body_excerpt.is_some_and(|body| !body.is_empty()));
+ }
+
+ /// Claude Code's Windows `PowerShell` tool shares Bash's payload shape but
+ /// fell through to the unknown family, so its output was never stored
+ /// (#1186). The PreToolUse body still never carries the command.
+ #[test]
+ fn claude_code_powershell_tool_keeps_its_family_title_and_output() {
+ let post = HookEnvelope::from_query_and_body(
+ HookQuery {
+ event: "post-tool-use".into(),
+ agent: Some("claude-code".into()),
+ ..Default::default()
+ },
+ serde_json::json!({
+ "session_id": "s",
+ "tool_name": "PowerShell",
+ "tool_input": {"command": "Get-ChildItem SENTINEL_COMMAND", "description": "list"},
+ "tool_response": {"stdout": "MARKER_POWERSHELL_1186", "stderr": ""},
+ "tool_use_id": "toolu_1186",
+ }),
+ );
+ assert_eq!(post.title_hint.as_deref(), Some("tool non-file"));
+ let body = post.body_excerpt.expect("powershell post-tool body");
+ assert!(body.contains("tool_family: non-file"), "{body:?}");
+ assert!(body.contains("MARKER_POWERSHELL_1186"), "{body:?}");
+
+ let pre = HookEnvelope::from_query_and_body(
+ HookQuery {
+ event: "pre-tool-use".into(),
+ agent: Some("claude-code".into()),
+ ..Default::default()
+ },
+ serde_json::json!({
+ "session_id": "s",
+ "tool_name": "PowerShell",
+ "tool_input": {"command": "Get-ChildItem SENTINEL_COMMAND"},
+ "tool_use_id": "toolu_1186",
+ }),
+ );
+ assert_eq!(pre.title_hint.as_deref(), Some("tool non-file"));
+ let body = pre.body_excerpt.expect("powershell pre-tool body");
+ assert!(!body.contains("SENTINEL_COMMAND"), "{body:?}");
+ }
+
/// Grok Build CLI posts a `PostToolUse` with Claude Code's snake_case
/// aliases (`tool_name` / `tool_input` / `tool_use_id`). It was absent from
/// both `closed_tool_agent` and the `tool_observation_metadata` match, so