Skip to content

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

Rust

Default port: 7777 -> 49374 (0xC0DE)

AkitaOnRails2fccf8091fc6
diff --git a/README.md b/README.md
index b7a838ef..9d37a7fa 100644
--- a/README.md
+++ b/README.md
@@ -95,7 +95,7 @@ claude mcp add ai-memory -- ./target/release/ai-memory serve --transport stdio
Or with HTTP transport for `mcp-inspector` / curl / a remote Claude Code:
```bash
-./target/release/ai-memory serve --transport http --bind 127.0.0.1:7777
+./target/release/ai-memory serve --transport http --bind 127.0.0.1:49374
```
### Local: Docker Compose
@@ -103,7 +103,7 @@ Or with HTTP transport for `mcp-inspector` / curl / a remote Claude Code:
```bash
docker compose -f docker/docker-compose.yml up -d --build
# State lives in the `ai-memory-data` named volume.
-# Attach Claude Code at http://localhost:7777/mcp
+# Attach Claude Code at http://localhost:49374/mcp
```
### Full CLI subcommand list
diff --git a/crates/ai-memory-cli/src/cli.rs b/crates/ai-memory-cli/src/cli.rs
index 0f4364b5..808cf8ed 100644
--- a/crates/ai-memory-cli/src/cli.rs
+++ b/crates/ai-memory-cli/src/cli.rs
@@ -227,7 +227,7 @@ pub struct InstallHooksArgs {
#[arg(long)]
pub hooks_dir: Option<PathBuf>,
/// Server URL the hooks will POST to.
- #[arg(long, default_value = "http://127.0.0.1:7777")]
+ #[arg(long, default_value = "http://127.0.0.1:49374")]
pub server_url: String,
}
diff --git a/crates/ai-memory-cli/src/config.rs b/crates/ai-memory-cli/src/config.rs
index 66b7b273..10ce5d17 100644
--- a/crates/ai-memory-cli/src/config.rs
+++ b/crates/ai-memory-cli/src/config.rs
@@ -37,7 +37,7 @@ impl Default for Config {
fn default() -> Self {
Self {
data_dir: default_data_dir(),
- bind: "127.0.0.1:7777".into(),
+ bind: "127.0.0.1:49374".into(),
log_level: "info".into(),
decay: ai_memory_store::DecayParams::default(),
}
@@ -112,7 +112,7 @@ mod tests {
fn defaults_have_canonical_endings() {
let cfg = Config::default();
assert!(cfg.data_dir.ends_with("ai-memory"));
- assert_eq!(cfg.bind, "127.0.0.1:7777");
+ assert_eq!(cfg.bind, "127.0.0.1:49374");
assert_eq!(cfg.log_level, "info");
}
diff --git a/crates/ai-memory-cli/templates/config.default.toml b/crates/ai-memory-cli/templates/config.default.toml
index bfa0f123..3d7f8392 100644
--- a/crates/ai-memory-cli/templates/config.default.toml
+++ b/crates/ai-memory-cli/templates/config.default.toml
@@ -1,13 +1,13 @@
# ai-memory configuration.
#
# All values can also be overridden via environment variables prefixed
-# `AI_MEMORY_` (e.g. `AI_MEMORY_BIND=0.0.0.0:7777`).
+# `AI_MEMORY_` (e.g. `AI_MEMORY_BIND=0.0.0.0:49374`).
#
# `data_dir` is intentionally absent here: it's set by `--data-dir`
# or `AI_MEMORY_DATA_DIR`, and the config file lives inside it.
# HTTP bind address used by `ai-memory serve`.
-bind = "127.0.0.1:7777"
+bind = "127.0.0.1:49374"
# Default tracing filter (overridable by RUST_LOG).
log_level = "info"
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 1b45c4cf..63a140c7 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -3,7 +3,7 @@
# Run from this directory:
# docker compose up -d
# Attach Claude Code (or any MCP HTTP client) at
-# http://localhost:7777/mcp
+# http://localhost:49374/mcp
# State persists in the `ai-memory-data` volume; move it between hosts
# by stopping the container, `docker volume export` (or rsync the
# mountpoint), and importing on the target.
@@ -20,9 +20,9 @@ services:
volumes:
- ai-memory-data:/data
ports:
- # Bind to loopback by default; flip to 0.0.0.0:7777 when serving
+ # Bind to loopback by default; flip to 0.0.0.0:49374 when serving
# the homelab LAN. Keep behind a reverse proxy if you do.
- - "127.0.0.1:7777:7777"
+ - "127.0.0.1:49374:49374"
environment:
- RUST_LOG=ai_memory=info,ai_memory_store=info,ai_memory_wiki=info,ai_memory_mcp=info,tracing_appender=warn
healthcheck:
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 2e8cf219..f914ec03 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -227,7 +227,7 @@ Lives at `<data_dir>/config.toml`. All values overridable by env vars
prefixed `AI_MEMORY_*`.
```toml
-bind = "127.0.0.1:7777"
+bind = "127.0.0.1:49374"
log_level = "info"
[decay] # M8 retention params
diff --git a/docs/design-decisions.md b/docs/design-decisions.md
index 7603306f..c7de3f4c 100644
--- a/docs/design-decisions.md
+++ b/docs/design-decisions.md
@@ -12,7 +12,7 @@ A self-contained Rust binary that:
2. Captures the agent's session **automatically** — no `write_note` ceremony — via hook scripts that the agent CLIs invoke (Claude Code lifecycle hooks, Codex hooks, OpenCode equivalents). Optional transcript-tail fallback for agents without hook APIs.
3. Maintains a **Karpathy-style wiki**: incrementally-compiled markdown pages with cross-links, supersession, an `index.md` and a `log.md`.
4. Serves retrieval via the MCP `tools/list` to coding agents: a handful of *narrow* tools, not 50.
-5. Ships a **Docker image** (`docker run -v ai-memory-data:/data -p 7777:7777 ai-memory`) so it can move between desktop and homelab.
+5. Ships a **Docker image** (`docker run -v ai-memory-data:/data -p 49374:49374 ai-memory`) so it can move between desktop and homelab.
6. Is *self-healing*: schema migrations on startup, vector-index dim/provider check, write-ahead durability, periodic integrity audit, single-writer queue to avoid `database is locked`.
## 2. Hard requirements (extracted from the prompt)
diff --git a/hooks/claude-code/post-tool-use.sh b/hooks/claude-code/post-tool-use.sh
index 53bf5643..526151dc 100755
--- a/hooks/claude-code/post-tool-use.sh
+++ b/hooks/claude-code/post-tool-use.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# Claude Code PostToolUse hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=post-tool-use&agent=claude-code" \
-H "Content-Type: application/json" \
diff --git a/hooks/claude-code/pre-compact.sh b/hooks/claude-code/pre-compact.sh
index 9696ea33..49d862b5 100755
--- a/hooks/claude-code/pre-compact.sh
+++ b/hooks/claude-code/pre-compact.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# Claude Code PreCompact hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=pre-compact&agent=claude-code" \
-H "Content-Type: application/json" \
diff --git a/hooks/claude-code/pre-tool-use.sh b/hooks/claude-code/pre-tool-use.sh
index 7b97351d..4e451e44 100755
--- a/hooks/claude-code/pre-tool-use.sh
+++ b/hooks/claude-code/pre-tool-use.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# Claude Code PreToolUse hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=pre-tool-use&agent=claude-code" \
-H "Content-Type: application/json" \
diff --git a/hooks/claude-code/session-end.sh b/hooks/claude-code/session-end.sh
index 3f79811d..ced6eb99 100755
--- a/hooks/claude-code/session-end.sh
+++ b/hooks/claude-code/session-end.sh
@@ -2,7 +2,7 @@
# Claude Code SessionEnd hook (final).
# We give the session-end hook a longer timeout because the server
# synthesises a wiki page from the observation log here.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 2.0 \
-X POST "$SERVER/hook?event=session-end&agent=claude-code" \
-H "Content-Type: application/json" \
diff --git a/hooks/claude-code/session-start.sh b/hooks/claude-code/session-start.sh
index e47618dc..18637f8f 100755
--- a/hooks/claude-code/session-start.sh
+++ b/hooks/claude-code/session-start.sh
@@ -2,7 +2,7 @@
# Claude Code SessionStart hook.
# Reads the event JSON from stdin and forwards it to a running
# ai-memory server. Fire-and-forget: never blocks the agent.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=session-start&agent=claude-code" \
-H "Content-Type: application/json" \
diff --git a/hooks/claude-code/stop.sh b/hooks/claude-code/stop.sh
index ad6ef60d..a0b0fdd2 100755
--- a/hooks/claude-code/stop.sh
+++ b/hooks/claude-code/stop.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# Claude Code Stop hook (agent finished one turn).
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=stop&agent=claude-code" \
-H "Content-Type: application/json" \
diff --git a/hooks/claude-code/user-prompt-submit.sh b/hooks/claude-code/user-prompt-submit.sh
index f958bf6d..6bf8a027 100755
--- a/hooks/claude-code/user-prompt-submit.sh
+++ b/hooks/claude-code/user-prompt-submit.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# Claude Code UserPromptSubmit hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=user-prompt&agent=claude-code" \
-H "Content-Type: application/json" \
diff --git a/hooks/codex/post-tool-use.sh b/hooks/codex/post-tool-use.sh
index 88006c98..91bc71d5 100755
--- a/hooks/codex/post-tool-use.sh
+++ b/hooks/codex/post-tool-use.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# codex post-tool-use hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=post-tool-use&agent=codex" \
-H "Content-Type: application/json" \
diff --git a/hooks/codex/pre-compact.sh b/hooks/codex/pre-compact.sh
index 3ccda804..b4fe103d 100755
--- a/hooks/codex/pre-compact.sh
+++ b/hooks/codex/pre-compact.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# codex pre-compact hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=pre-compact&agent=codex" \
-H "Content-Type: application/json" \
diff --git a/hooks/codex/pre-tool-use.sh b/hooks/codex/pre-tool-use.sh
index a7087b5d..32abe9dc 100755
--- a/hooks/codex/pre-tool-use.sh
+++ b/hooks/codex/pre-tool-use.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# codex pre-tool-use hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=pre-tool-use&agent=codex" \
-H "Content-Type: application/json" \
diff --git a/hooks/codex/session-end.sh b/hooks/codex/session-end.sh
index 1f805c80..66516797 100755
--- a/hooks/codex/session-end.sh
+++ b/hooks/codex/session-end.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# codex session-end hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 2.0 \
-X POST "$SERVER/hook?event=session-end&agent=codex" \
-H "Content-Type: application/json" \
diff --git a/hooks/codex/session-start.sh b/hooks/codex/session-start.sh
index 2873c4c3..20dc51a3 100755
--- a/hooks/codex/session-start.sh
+++ b/hooks/codex/session-start.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# codex session-start hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=session-start&agent=codex" \
-H "Content-Type: application/json" \
diff --git a/hooks/codex/stop.sh b/hooks/codex/stop.sh
index e85ca8de..cde7ba0a 100755
--- a/hooks/codex/stop.sh
+++ b/hooks/codex/stop.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# codex stop hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=stop&agent=codex" \
-H "Content-Type: application/json" \
diff --git a/hooks/codex/user-prompt-submit.sh b/hooks/codex/user-prompt-submit.sh
index bda90a9a..8e7021a6 100755
--- a/hooks/codex/user-prompt-submit.sh
+++ b/hooks/codex/user-prompt-submit.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# codex user-prompt-submit hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=user-prompt&agent=codex" \
-H "Content-Type: application/json" \
diff --git a/hooks/opencode/post-tool-use.sh b/hooks/opencode/post-tool-use.sh
index 6dfec34f..49e1f6ea 100755
--- a/hooks/opencode/post-tool-use.sh
+++ b/hooks/opencode/post-tool-use.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# opencode post-tool-use hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=post-tool-use&agent=open-code" \
-H "Content-Type: application/json" \
diff --git a/hooks/opencode/pre-compact.sh b/hooks/opencode/pre-compact.sh
index 664ea9e3..e5837ac5 100755
--- a/hooks/opencode/pre-compact.sh
+++ b/hooks/opencode/pre-compact.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# opencode pre-compact hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=pre-compact&agent=open-code" \
-H "Content-Type: application/json" \
diff --git a/hooks/opencode/pre-tool-use.sh b/hooks/opencode/pre-tool-use.sh
index 0270f7c0..2fe04074 100755
--- a/hooks/opencode/pre-tool-use.sh
+++ b/hooks/opencode/pre-tool-use.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# opencode pre-tool-use hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=pre-tool-use&agent=open-code" \
-H "Content-Type: application/json" \
diff --git a/hooks/opencode/session-end.sh b/hooks/opencode/session-end.sh
index 0138ccee..73551e65 100755
--- a/hooks/opencode/session-end.sh
+++ b/hooks/opencode/session-end.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# opencode session-end hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 2.0 \
-X POST "$SERVER/hook?event=session-end&agent=open-code" \
-H "Content-Type: application/json" \
diff --git a/hooks/opencode/session-start.sh b/hooks/opencode/session-start.sh
index 3a635031..f2ef5eaa 100755
--- a/hooks/opencode/session-start.sh
+++ b/hooks/opencode/session-start.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# opencode session-start hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=session-start&agent=open-code" \
-H "Content-Type: application/json" \
diff --git a/hooks/opencode/stop.sh b/hooks/opencode/stop.sh
index 7efc1c9b..e9102234 100755
--- a/hooks/opencode/stop.sh
+++ b/hooks/opencode/stop.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# opencode stop hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=stop&agent=open-code" \
-H "Content-Type: application/json" \
diff --git a/hooks/opencode/user-prompt-submit.sh b/hooks/opencode/user-prompt-submit.sh
index 0277da2e..a72df1e7 100755
--- a/hooks/opencode/user-prompt-submit.sh
+++ b/hooks/opencode/user-prompt-submit.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# opencode user-prompt-submit hook.
-SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:7777}"
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
curl -s --max-time 0.5 \
-X POST "$SERVER/hook?event=user-prompt&agent=open-code" \
-H "Content-Type: application/json" \