Skip to content

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

Rust

style: cargo fmt (hook_spool batched drain + hook_batch handler)

Djalma Júnioraa61bf1eb281
diff --git a/CHANGELOG.md b/CHANGELOG.md
index eeb9484b..8f43aad9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,6 +24,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
default, receives proposal JSON on stdin, fails closed on command/timeout/JSON
errors or insufficient score delta, and records eval failures as rejected
candidates without running from hook paths.
+- Hook spool drains now use `POST /hook/batch` when the server supports it,
+ grouping compatible queued lifecycle events into bounded batches to amortize
+ remote request latency. Older servers fall back to the existing per-event
+ `POST /hook` path.
### Fixed
- Auto-improvement eval gates now apply timeouts to the full child interaction,
@@ -35,7 +39,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
aliases still prefix-match later events into the same project.
- Updated `git2` to the patched 0.21 line to clear new RustSec unsoundness
advisories in libgit2 bindings.
-<<<<<<< HEAD
- Native Claude Code hooks now capture array-shaped `tool_response` content and
recognize the native `user-prompt-submit` event token, restoring prompt text
and tool output bodies for native installs.
diff --git a/crates/ai-memory-cli/src/commands/hook_spool.rs b/crates/ai-memory-cli/src/commands/hook_spool.rs
index 377091e5..fb50365a 100644
--- a/crates/ai-memory-cli/src/commands/hook_spool.rs
+++ b/crates/ai-memory-cli/src/commands/hook_spool.rs
@@ -269,7 +269,15 @@ pub async fn drain(
}
let payload = batch_payload(&items[idx..end]);
- match post_batch(&client, &base, &payload, bearer.as_deref(), per_event_timeout).await {
+ match post_batch(
+ &client,
+ &base,
+ &payload,
+ bearer.as_deref(),
+ per_event_timeout,
+ )
+ .await
+ {
BatchOutcome::Accepted(k) => {
let k = k.min(end - idx);
for (path, _) in &items[idx..idx + k] {
@@ -774,7 +782,11 @@ mod tests {
let tmp = tempfile::tempdir().unwrap();
let spool = spool_dir(tmp.path());
for i in 0..3 {
- write_spool_entry(&spool, &format!("evt-{i}.json"), format!("http://{addr}/hook?event=e{i}"));
+ write_spool_entry(
+ &spool,
+ &format!("evt-{i}.json"),
+ format!("http://{addr}/hook?event=e{i}"),
+ );
}
let r = drain(
@@ -803,7 +815,11 @@ mod tests {
let tmp = tempfile::tempdir().unwrap();
let spool = spool_dir(tmp.path());
for i in 0..2 {
- write_spool_entry(&spool, &format!("evt-{i}.json"), format!("http://{addr}/hook?event=e{i}"));
+ write_spool_entry(
+ &spool,
+ &format!("evt-{i}.json"),
+ format!("http://{addr}/hook?event=e{i}"),
+ );
}
let r = drain(
diff --git a/crates/ai-memory-hooks/src/router.rs b/crates/ai-memory-hooks/src/router.rs
index cfcb60a3..f9ddc9f3 100644
--- a/crates/ai-memory-hooks/src/router.rs
+++ b/crates/ai-memory-hooks/src/router.rs
@@ -1648,7 +1648,11 @@ mod tests {
.unwrap();
let parent = state
.writer
- .get_or_create_project(ws, String::from("my_app"), Some(String::from("/repo/my_app")))
+ .get_or_create_project(
+ ws,
+ String::from("my_app"),
+ Some(String::from("/repo/my_app")),
+ )
.await
.unwrap();