#1 Persistent memory for AI coding agents based on real-world benchmarks
TypeScript agentmemoryagentsaiclaudeclaudecodecodexcopilotcursorgenaiharnesshermesmemoryompopenclawopencodepi
add plugin marketplace install support
Rohit Ghumare6df02d3e2022
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.jsonnew file mode 100644index 00000000..1f0f36d3--- /dev/null+++ b/.claude-plugin/marketplace.json@@ -0,0 +1,9 @@+{+ "plugins": [+ {+ "name": "agentmemory",+ "description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions",+ "path": "./plugin"+ }+ ]+}diff --git a/.gitignore b/.gitignoreindex c4de87f7..76c65c5b 100644--- a/.gitignore+++ b/.gitignore@@ -9,3 +9,6 @@ dist/*.log.DS_Store.claude/++plugin/scripts/*.map+plugin/scripts/*.d.mtsdiff --git a/README.md b/README.mdindex 15801e6d..fb70149b 100644--- a/README.md+++ b/README.md@@ -33,6 +33,17 @@ Session 2: "Now add rate limiting"## Quick Start+### 1. Install the Plugin++```bash+/plugin marketplace add rohitg00/agentmemory+/plugin install agentmemory+```++All 5 hooks are registered automatically. No manual config needed.++### 2. Start the Worker+```bashgit clone https://github.com/rohitg00/agentmemory.gitcd agentmemory@@ -44,18 +55,18 @@ docker compose up -dnpm install && npm run build && npm start```-agentmemory connects to iii-engine on `ws://localhost:49134` and exposes its API on port `3111`.--### Verify it works+### 3. Verify```bashcurl http://localhost:3111/agentmemory/health# {"status":"ok","service":"agentmemory","version":"0.1.0"}```-### Connect to Claude Code+That's it. Start a Claude Code session and agentmemory begins capturing. Start another session and it injects context from all previous sessions.++### Manual Hook Setup (alternative)-Add to `~/.claude/settings.json`:+If you prefer not to use the plugin, add hooks directly to `~/.claude/settings.json`:```json{@@ -69,10 +80,6 @@ Add to `~/.claude/settings.json`:}```-Or install as a [Claude Code plugin](#plugin-install) for automatic hook registration.--That's it. Start a Claude Code session and agentmemory begins capturing. Start another session and it injects context from all previous sessions.-## How It Works### Observation Pipeline@@ -219,14 +226,23 @@ Connects to iii-engine's WebSocket stream. Dark theme, timeline layout, session## Plugin Install-Install as a Claude Code plugin for zero-config hook registration:+### From Marketplace (recommended)```bash-# Symlink into Claude Code plugins-ln -s /path/to/agentmemory/plugin ~/.claude/plugins/agentmemory+/plugin marketplace add rohitg00/agentmemory+/plugin install agentmemory```-All 5 hooks are registered automatically via `hooks.json`.+Restart Claude Code. All 5 hooks are registered automatically.++### Plugin Commands++```bash+/plugin install agentmemory # Install+/plugin disable agentmemory # Disable without uninstalling+/plugin enable agentmemory # Re-enable+/plugin uninstall agentmemory # Remove+```## Migrationdiff --git a/plugin/.claude-plugin/plugin.json b/plugin/.claude-plugin/plugin.jsonindex 2f776ae2..f320eb8d 100644--- a/plugin/.claude-plugin/plugin.json+++ b/plugin/.claude-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "agentmemory","version": "0.1.0",- "description": "Persistent memory for AI coding agents powered by iii-engine",+ "description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions","author": "Rohit Ghumare","license": "Apache-2.0","homepage": "https://github.com/rohitg00/agentmemory",diff --git a/plugin/hooks/hooks.json b/plugin/hooks/hooks.jsonindex c3b9a736..a4a080c4 100644--- a/plugin/hooks/hooks.json+++ b/plugin/hooks/hooks.json@@ -3,31 +3,31 @@"SessionStart": [{"type": "command",- "command": "node __PLUGIN_DIR__/../dist/hooks/session-start.js"+ "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/session-start.mjs"}],"UserPromptSubmit": [{"type": "command",- "command": "node __PLUGIN_DIR__/../dist/hooks/prompt-submit.js"+ "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/prompt-submit.mjs"}],"PostToolUse": [{"type": "command",- "command": "node __PLUGIN_DIR__/../dist/hooks/post-tool-use.js"+ "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/post-tool-use.mjs"}],"Stop": [{"type": "command",- "command": "node __PLUGIN_DIR__/../dist/hooks/stop.js"+ "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/stop.mjs"}],"SessionEnd": [{"type": "command",- "command": "node __PLUGIN_DIR__/../dist/hooks/session-end.js"+ "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/session-end.mjs"}]}diff --git a/plugin/scripts/post-tool-use.mjs b/plugin/scripts/post-tool-use.mjsnew file mode 100755index 00000000..889cd644--- /dev/null+++ b/plugin/scripts/post-tool-use.mjs@@ -0,0 +1,47 @@+#!/usr/bin/env node+//#region src/hooks/post-tool-use.ts+const REST_URL = process.env["AGENTMEMORY_URL"] || "http://localhost:3111";+async function main() {+ let input = "";+ for await (const chunk of process.stdin) input += chunk;+ let data;+ try {+ data = JSON.parse(input);+ } catch {+ return;+ }+ const sessionId = data.session_id || "unknown";+ try {+ await fetch(`${REST_URL}/agentmemory/observe`, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ hookType: "post_tool_use",+ sessionId,+ project: data.cwd || process.cwd(),+ cwd: data.cwd || process.cwd(),+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),+ data: {+ tool_name: data.tool_name,+ tool_input: data.tool_input,+ tool_output: truncate(data.tool_output, 8e3)+ }+ }),+ signal: AbortSignal.timeout(3e3)+ });+ } catch {}+}+function truncate(value, max) {+ if (typeof value === "string" && value.length > max) return value.slice(0, max) + "\n[...truncated]";+ if (typeof value === "object" && value !== null) {+ const str = JSON.stringify(value);+ if (str.length > max) return JSON.parse(str.slice(0, max - 1) + "}");+ return value;+ }+ return value;+}+main();++//#endregion+export { };+//# sourceMappingURL=post-tool-use.mjs.map\ No newline at end of filediff --git a/plugin/scripts/prompt-submit.mjs b/plugin/scripts/prompt-submit.mjsnew file mode 100755index 00000000..3b54eed1--- /dev/null+++ b/plugin/scripts/prompt-submit.mjs@@ -0,0 +1,34 @@+#!/usr/bin/env node+//#region src/hooks/prompt-submit.ts+const REST_URL = process.env["AGENTMEMORY_URL"] || "http://localhost:3111";+async function main() {+ let input = "";+ for await (const chunk of process.stdin) input += chunk;+ let data;+ try {+ data = JSON.parse(input);+ } catch {+ return;+ }+ const sessionId = data.session_id || "unknown";+ try {+ await fetch(`${REST_URL}/agentmemory/observe`, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ hookType: "prompt_submit",+ sessionId,+ project: data.cwd || process.cwd(),+ cwd: data.cwd || process.cwd(),+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),+ data: { prompt: data.prompt }+ }),+ signal: AbortSignal.timeout(3e3)+ });+ } catch {}+}+main();++//#endregion+export { };+//# sourceMappingURL=prompt-submit.mjs.map\ No newline at end of filediff --git a/plugin/scripts/session-end.mjs b/plugin/scripts/session-end.mjsnew file mode 100755index 00000000..72ca9da4--- /dev/null+++ b/plugin/scripts/session-end.mjs@@ -0,0 +1,27 @@+#!/usr/bin/env node+//#region src/hooks/session-end.ts+const REST_URL = process.env["AGENTMEMORY_URL"] || "http://localhost:3111";+async function main() {+ let input = "";+ for await (const chunk of process.stdin) input += chunk;+ let data;+ try {+ data = JSON.parse(input);+ } catch {+ return;+ }+ const sessionId = data.session_id || "unknown";+ try {+ await fetch(`${REST_URL}/agentmemory/session/end`, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ sessionId }),+ signal: AbortSignal.timeout(5e3)+ });+ } catch {}+}+main();++//#endregion+export { };+//# sourceMappingURL=session-end.mjs.map\ No newline at end of filediff --git a/plugin/scripts/session-start.mjs b/plugin/scripts/session-start.mjsnew file mode 100755index 00000000..a7ff150f--- /dev/null+++ b/plugin/scripts/session-start.mjs@@ -0,0 +1,36 @@+#!/usr/bin/env node+//#region src/hooks/session-start.ts+const REST_URL = process.env["AGENTMEMORY_URL"] || "http://localhost:3111";+async function main() {+ let input = "";+ for await (const chunk of process.stdin) input += chunk;+ let data;+ try {+ data = JSON.parse(input);+ } catch {+ return;+ }+ const sessionId = data.session_id || `ses_${Date.now().toString(36)}`;+ const project = data.cwd || process.cwd();+ try {+ const res = await fetch(`${REST_URL}/agentmemory/session/start`, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ sessionId,+ project,+ cwd: project+ }),+ signal: AbortSignal.timeout(5e3)+ });+ if (res.ok) {+ const result = await res.json();+ if (result.context) process.stdout.write(result.context);+ }+ } catch {}+}+main();++//#endregion+export { };+//# sourceMappingURL=session-start.mjs.map\ No newline at end of filediff --git a/plugin/scripts/stop.mjs b/plugin/scripts/stop.mjsnew file mode 100755index 00000000..44dbed60--- /dev/null+++ b/plugin/scripts/stop.mjs@@ -0,0 +1,27 @@+#!/usr/bin/env node+//#region src/hooks/stop.ts+const REST_URL = process.env["AGENTMEMORY_URL"] || "http://localhost:3111";+async function main() {+ let input = "";+ for await (const chunk of process.stdin) input += chunk;+ let data;+ try {+ data = JSON.parse(input);+ } catch {+ return;+ }+ const sessionId = data.session_id || "unknown";+ try {+ await fetch(`${REST_URL}/agentmemory/summarize`, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ sessionId }),+ signal: AbortSignal.timeout(3e4)+ });+ } catch {}+}+main();++//#endregion+export { };+//# sourceMappingURL=stop.mjs.map\ No newline at end of filediff --git a/tsdown.config.ts b/tsdown.config.tsindex d8cc9b36..f0295c3c 100644--- a/tsdown.config.ts+++ b/tsdown.config.ts@@ -1,5 +1,13 @@import { defineConfig } from "tsdown";+const hookEntries = [+ "src/hooks/session-start.ts",+ "src/hooks/prompt-submit.ts",+ "src/hooks/post-tool-use.ts",+ "src/hooks/stop.ts",+ "src/hooks/session-end.ts",+];+export default defineConfig([{entry: ["src/index.ts"],@@ -12,17 +20,19 @@ export default defineConfig([banner: { js: "#!/usr/bin/env node" },},{- entry: [- "src/hooks/session-start.ts",- "src/hooks/prompt-submit.ts",- "src/hooks/post-tool-use.ts",- "src/hooks/stop.ts",- "src/hooks/session-end.ts",- ],+ entry: hookEntries,outDir: "dist/hooks",format: ["esm"],clean: false,sourcemap: false,target: "node18",},+ {+ entry: hookEntries,+ outDir: "plugin/scripts",+ format: ["esm"],+ clean: false,+ sourcemap: false,+ target: "node18",+ },]);