Skip to content

#1 Persistent memory for AI coding agents based on real-world benchmarks

fix: plugin auto-wires MCP + sandbox-safe skills (#139) (#141)

Rohit Ghumaref72c7a54fc6b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e1799b9a..62161967 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,28 @@ All notable changes to agentmemory will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [0.8.9] — 2026-04-14
+
+Two UX fixes for the Claude Code plugin install path, both reported in [#139](https://github.com/rohitg00/agentmemory/issues/139) by [@stefanfaur](https://github.com/stefanfaur).
+
+### Fixed
+
+- **Claude Code plugin now auto-wires the `@agentmemory/mcp` stdio server** ([#139](https://github.com/rohitg00/agentmemory/issues/139)) — the plugin previously only shipped hooks and skills, and the README told Claude Code users to wire up the MCP server manually. A new `plugin/.mcp.json` declares the MCP server so `/plugin install agentmemory@agentmemory` auto-starts it when the plugin is enabled. No extra config step.
+- **Skills no longer fail under Claude Code's sandbox with "Contains expansion"** ([#139](https://github.com/rohitg00/agentmemory/issues/139)) — the `recall` and `session-history` skills used pre-execution bash with `$(...)` / `${VAR:-default}` shell expansion, which Claude Code's sandbox rejects by pattern match. All four plugin skills (`recall`, `remember`, `forget`, `session-history`) are now rewritten as pure prompts that tell Claude to use the MCP tools directly. No bash, no sandbox issues, no shell escaping — and the skills run faster because they no longer fork a curl subprocess on every invocation.
+
+### Added
+
+- **Standalone MCP shim now implements `memory_smart_search` and `memory_governance_delete`** — the `@agentmemory/mcp` stdio server only exposed 5 tools (`memory_save`, `memory_recall`, `memory_sessions`, `memory_export`, `memory_audit`), so the rewritten plugin skills would have failed at runtime referencing tools the standalone didn't know about. Now ships 7 tools. `memory_smart_search` falls back to the same substring filter as `memory_recall` since the standalone shim doesn't have BM25/vector/graph without the full engine. `memory_governance_delete` takes `memoryIds` as an array or comma-separated string and returns `{deleted, requested, reason}`.
+- **`memory_save` accepts `concepts`/`files` as arrays or comma-separated strings** — the old standalone only accepted CSV strings, which would silently drop array inputs. New `normalizeList()` helper handles both.
+- **`memory_sessions` honours a `limit` arg** (default 20) — previously returned every session.
+- **8 regression tests** in `test/mcp-standalone.test.ts` covering array/CSV inputs for `memory_save`, `memory_smart_search` substring fallback, `memory_sessions` limit, `memory_governance_delete` happy path + unknown-id skip + validation. Full suite: 715 passing.
+
+### Changed
+
+- **README Claude Code install snippet** — now explicitly notes that `/plugin install agentmemory` registers hooks + skills AND auto-wires the MCP server via `.mcp.json`, with no extra step.
+
+[0.8.9]: https://github.com/rohitg00/agentmemory/compare/v0.8.8...v0.8.9
+
## [0.8.8] — 2026-04-14
**Behavior change**: per-observation LLM compression is now opt-in. If you were relying on LLM-generated summaries (the old default), set `AGENTMEMORY_AUTO_COMPRESS=true` in `~/.agentmemory/.env` and restart.
diff --git a/README.md b/README.md
index 05797da0..a315d6d1 100644
--- a/README.md
+++ b/README.md
@@ -295,7 +295,7 @@ Open `http://localhost:3113` to watch the memory build live.
### Claude Code (one block, paste it)
```
-Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` to register all 12 hooks, 4 skills, and 43 MCP tools. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
+Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 43 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
```
<details>
diff --git a/package-lock.json b/package-lock.json
index 3c15c03c..bfc0400b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@agentmemory/agentmemory",
- "version": "0.8.8",
+ "version": "0.8.9",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@agentmemory/agentmemory",
- "version": "0.8.8",
+ "version": "0.8.9",
"license": "Apache-2.0",
"dependencies": {
"@anthropic-ai/claude-agent-sdk": "^0.2.56",
diff --git a/package.json b/package.json
index 551a0596..ad78ca46 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@agentmemory/agentmemory",
- "version": "0.8.8",
+ "version": "0.8.9",
"description": "Persistent memory for AI coding agents, powered by iii-engine's three primitives",
"type": "module",
"main": "dist/index.mjs",
diff --git a/packages/mcp/package.json b/packages/mcp/package.json
index fd6b6159..1133b77c 100644
--- a/packages/mcp/package.json
+++ b/packages/mcp/package.json
@@ -1,6 +1,6 @@
{
"name": "@agentmemory/mcp",
- "version": "0.8.8",
+ "version": "0.8.9",
"description": "Standalone MCP server for agentmemory — thin shim that re-exposes @agentmemory/agentmemory's MCP entrypoint",
"type": "module",
"bin": {
@@ -28,7 +28,7 @@
"homepage": "https://github.com/rohitg00/agentmemory#readme",
"bugs": "https://github.com/rohitg00/agentmemory/issues",
"dependencies": {
- "@agentmemory/agentmemory": "~0.8.8"
+ "@agentmemory/agentmemory": "~0.8.9"
},
"publishConfig": {
"access": "public",
diff --git a/plugin/.claude-plugin/plugin.json b/plugin/.claude-plugin/plugin.json
index 7a5e4241..20984771 100644
--- a/plugin/.claude-plugin/plugin.json
+++ b/plugin/.claude-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "agentmemory",
- "version": "0.8.8",
+ "version": "0.8.9",
"description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions. 12 hooks, 43 MCP tools, 4 skills, real-time viewer.",
"author": {
"name": "Rohit Ghumare",
diff --git a/plugin/.mcp.json b/plugin/.mcp.json
new file mode 100644
index 00000000..12702a2a
--- /dev/null
+++ b/plugin/.mcp.json
@@ -0,0 +1,8 @@
+{
+ "mcpServers": {
+ "agentmemory": {
+ "command": "npx",
+ "args": ["-y", "@agentmemory/mcp"]
+ }
+ }
+}
diff --git a/plugin/skills/forget/SKILL.md b/plugin/skills/forget/SKILL.md
index 945d502d..067d564c 100644
--- a/plugin/skills/forget/SKILL.md
+++ b/plugin/skills/forget/SKILL.md
@@ -10,23 +10,17 @@ The user wants to remove data from agentmemory: $ARGUMENTS
**IMPORTANT**: This is a destructive operation. Always confirm with the user before deleting.
Steps:
-1. First, search for matching observations:
- ```bash
- curl -s -H "Content-Type: application/json" \
- -H "Authorization: Bearer ${AGENTMEMORY_SECRET:-}" \
- -X POST "http://${AGENTMEMORY_URL:-localhost:3111}/agentmemory/search" \
- -d '{"query": "<SEARCH_TERM>", "limit": 20}'
- ```
-2. Show the user what was found and ask for confirmation
-3. If confirmed, delete via:
- ```bash
- curl -s -H "Content-Type: application/json" \
- -H "Authorization: Bearer ${AGENTMEMORY_SECRET:-}" \
- -X POST "http://${AGENTMEMORY_URL:-localhost:3111}/agentmemory/forget" \
- -d '{"sessionId": "<ID>"}' # or {"observationIds": ["id1", "id2"]}
- ```
+1. First search for matching observations with the `memory_smart_search` MCP tool (provided by the agentmemory server this plugin wires up via `.mcp.json`). Use the user's input as the `query` with `limit: 20`.
+2. Show the user what was found — session IDs, observation IDs, titles — and ask for explicit confirmation before deleting.
+3. Once confirmed, call `memory_governance_delete` with:
+ - `memoryIds: [<id>, ...]` — an array (or comma-separated string) of the memory IDs returned by the search in step 1
+ - `reason: "<short reason>"` — optional, defaults to `"plugin skill request"`
-4. Confirm deletion to the user
+ If the user wants to drop an entire session's observations, collect every memory ID in that session from the search results and pass them all via `memoryIds`. The standalone MCP doesn't accept a bare `sessionId` argument — it deletes by memory ID only.
+4. Confirm the deletion count back to the user.
-Never delete without explicit user confirmation.
+**Never delete without explicit user confirmation.** If the MCP tools aren't available, the stdio MCP shim didn't start — tell the user to:
+1. Run `/plugin list` in Claude Code and confirm `agentmemory` shows as enabled.
+2. Restart Claude Code (the plugin's `.mcp.json` is only read on startup).
+3. Check `/mcp` to see whether the `agentmemory` MCP server is connected.
diff --git a/plugin/skills/recall/SKILL.md b/plugin/skills/recall/SKILL.md
index 3d5824d9..113b3c04 100644
--- a/plugin/skills/recall/SKILL.md
+++ b/plugin/skills/recall/SKILL.md
@@ -5,14 +5,17 @@ argument-hint: "[search query]"
user-invocable: true
---
-Search agentmemory for observations matching: $ARGUMENTS
+The user wants to recall past context about: $ARGUMENTS
-!`QUERY=$(echo "$ARGUMENTS" | sed 's/\\/\\\\/g; s/"/\\"/g') && curl -s -H "Content-Type: application/json" -H "Authorization: Bearer ${AGENTMEMORY_SECRET:-}" -X POST http://${AGENTMEMORY_URL:-localhost:3111}/agentmemory/search -d "{\"query\": \"${QUERY}\", \"limit\": 10}" 2>/dev/null || echo '{"results":[]}'`
+Use the `memory_smart_search` MCP tool (provided by the agentmemory server that this plugin wires up automatically via `.mcp.json`) with the user's query as the `query` argument and `limit: 10`. The tool runs hybrid BM25 + vector + graph-expanded search over captured observations and returns ranked results.
-Present the search results to the user in a readable format:
+Present the returned results to the user in a readable format:
- Group by session
-- Show observation type, title, and narrative
+- For each observation show its type, title, and narrative
- Highlight the most important observations (importance >= 7)
-- If no results found, suggest alternative search terms
+- If no results come back, suggest 2-3 alternative search terms the user could try
-Do NOT make up or hallucinate results. Only present what was returned from the search.
+**Do NOT make up or hallucinate observations.** Only present what the MCP tool actually returned. If `memory_smart_search` isn't available, the stdio MCP shim didn't start — tell the user to:
+1. Run `/plugin list` in Claude Code and confirm `agentmemory` shows as enabled.
+2. Restart Claude Code (the plugin's `.mcp.json` is only read on startup).
+3. Check `/mcp` to see whether the `agentmemory` MCP server is connected.
diff --git a/plugin/skills/remember/SKILL.md b/plugin/skills/remember/SKILL.md
index d00bf960..aa85103e 100644
--- a/plugin/skills/remember/SKILL.md
+++ b/plugin/skills/remember/SKILL.md
@@ -7,19 +7,19 @@ user-invocable: true
The user wants to save this to long-term memory: $ARGUMENTS
-To save this, make a POST request using the Bash tool:
-
-```bash
-curl -s -H "Content-Type: application/json" \
- -H "Authorization: Bearer ${AGENTMEMORY_SECRET:-}" \
- -X POST "http://${AGENTMEMORY_URL:-localhost:3111}/agentmemory/remember" \
- -d '{"content": "<ESCAPED_CONTENT>", "concepts": [<CONCEPTS>], "files": [<FILES>]}'
-```
+Use the `memory_save` MCP tool (provided by the agentmemory server that this plugin wires up automatically via `.mcp.json`) to persist it.
Steps:
-1. Analyze what the user wants to remember
-2. Extract key concepts (2-5 searchable terms)
-3. Extract relevant file paths if any
-4. Make the API call with the properly escaped content
-5. Confirm to the user that the memory was saved
-6. Show what concepts were tagged for future recall
+1. Analyze what the user wants to remember — pull out the core insight, decision, or fact.
+2. Extract 2-5 searchable `concepts` (lowercased keyword phrases) that capture what the memory is about. Prefer specific terms over generic ones (`"jwt-refresh-rotation"` beats `"auth"`).
+3. Extract any relevant `files` — absolute or repo-relative paths the memory references.
+4. Call `memory_save` with the fields:
+ - `content` — the full text to remember (preserve the user's phrasing as much as possible)
+ - `concepts` — the extracted concept list
+ - `files` — the extracted file list (empty array if none apply)
+5. Confirm to the user that the memory was saved and show the concepts you tagged so they know what terms will retrieve it later.
+
+If `memory_save` isn't available, the stdio MCP shim didn't start — tell the user to:
+1. Run `/plugin list` in Claude Code and confirm `agentmemory` shows as enabled.
+2. Restart Claude Code (the plugin's `.mcp.json` is only read on startup).
+3. Check `/mcp` to see whether the `agentmemory` MCP server is connected.
diff --git a/plugin/skills/session-history/SKILL.md b/plugin/skills/session-history/SKILL.md
index 59ff54ab..c33a1fe5 100644
--- a/plugin/skills/session-history/SKILL.md
+++ b/plugin/skills/session-history/SKILL.md
@@ -4,14 +4,15 @@ description: Show what happened in recent past sessions on this project. Use whe
user-invocable: true
---
-Fetch recent session history from agentmemory:
+Fetch recent session history using the `memory_sessions` MCP tool (provided by the agentmemory server that this plugin wires up automatically via `.mcp.json`). Pass `limit: 20` to get a meaningful window.
-!`curl -s -H "Authorization: Bearer ${AGENTMEMORY_SECRET:-}" "http://${AGENTMEMORY_URL:-localhost:3111}/agentmemory/sessions" 2>/dev/null || echo '{"sessions":[]}'`
+Present the returned sessions in reverse chronological order:
+- Show the session ID (first 8 chars), project, start time, and status
+- For each session with observations, show the key highlights (type + title)
+- Note the total observation count per session
+- If a session summary exists, surface the title and the key decisions
-Present the sessions in reverse chronological order:
-- Show session ID (first 8 chars), project, start time, status
-- For each session with observations, show the key highlights
-- Note total observation count per session
-- If summaries exist, show the session title and key decisions
-
-Format as a clean timeline. Do NOT make up sessions -- only show what was returned.
+Format as a clean timeline. **Do NOT make up sessions** — only show what the MCP tool actually returned. If `memory_sessions` isn't available, the stdio MCP shim didn't start — tell the user to:
+1. Run `/plugin list` in Claude Code and confirm `agentmemory` shows as enabled.
+2. Restart Claude Code (the plugin's `.mcp.json` is only read on startup).
+3. Check `/mcp` to see whether the `agentmemory` MCP server is connected.
diff --git a/src/functions/export-import.ts b/src/functions/export-import.ts
index 76b597e8..44d051bb 100644
--- a/src/functions/export-import.ts
+++ b/src/functions/export-import.ts
@@ -175,7 +175,7 @@ export function registerExportImportFunction(sdk: ISdk, kv: StateKV): void {
const strategy = data.strategy || "merge";
const importData = data.exportData;
- const supportedVersions = new Set(["0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.7.0", "0.7.2", "0.7.3", "0.7.4", "0.7.5", "0.7.6", "0.7.7", "0.7.9", "0.8.0", "0.8.1", "0.8.2", "0.8.3", "0.8.4", "0.8.5", "0.8.6", "0.8.7", "0.8.8"]);
+ const supportedVersions = new Set(["0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.7.0", "0.7.2", "0.7.3", "0.7.4", "0.7.5", "0.7.6", "0.7.7", "0.7.9", "0.8.0", "0.8.1", "0.8.2", "0.8.3", "0.8.4", "0.8.5", "0.8.6", "0.8.7", "0.8.8", "0.8.9"]);
if (!supportedVersions.has(importData.version)) {
return {
success: false,
diff --git a/src/mcp/standalone.ts b/src/mcp/standalone.ts
index 2cdaf707..612200a7 100644
--- a/src/mcp/standalone.ts
+++ b/src/mcp/standalone.ts
@@ -10,9 +10,11 @@ import { generateId } from "../state/schema.js";
const IMPLEMENTED_TOOLS = new Set([
"memory_save",
"memory_recall",
+ "memory_smart_search",
"memory_sessions",
"memory_export",
"memory_audit",
+ "memory_governance_delete",
]);
const SERVER_INFO = {
@@ -23,6 +25,40 @@ const SERVER_INFO = {
const kv = new InMemoryKV(getStandalonePersistPath());
+// Accept arrays, comma-separated strings, or a single string and always
+// return a trimmed, non-empty string array. Plugin skills (#139) tell
+// Claude to pass arrays; older clients may still pass CSV strings.
+function normalizeList(value: unknown): string[] {
+ if (!value) return [];
+ if (Array.isArray(value)) {
+ return value
+ .map((v) => (typeof v === "string" ? v.trim() : ""))
+ .filter((v) => v.length > 0);
+ }
+ if (typeof value === "string") {
+ return value
+ .split(",")
+ .map((s) => s.trim())
+ .filter((s) => s.length > 0);
+ }
+ return [];
+}
+
+// Parse a user-supplied limit argument, clamping to a sane range so an
+// adversarial or buggy caller can't request a million memories or pass
+// a negative / NaN / Infinity value that breaks .slice().
+const DEFAULT_LIMIT = 10;
+const MAX_LIMIT = 100;
+function parseLimit(raw: unknown, fallback = DEFAULT_LIMIT): number {
+ // Only accept explicit numbers or numeric strings. Reject booleans,
+ // objects, arrays, null, undefined — they shouldn't silently coerce
+ // (e.g. `Number(true) === 1` would sneak a limit of 1 through).
+ if (typeof raw !== "number" && typeof raw !== "string") return fallback;
+ const n = Number(raw);
+ if (!Number.isFinite(n) || n <= 0) return fallback;
+ return Math.min(Math.floor(n), MAX_LIMIT);
+}
+
export async function handleToolCall(
toolName: string,
args: Record<string, unknown>,
@@ -30,8 +66,11 @@ export async function handleToolCall(
): Promise<{ content: Array<{ type: string; text: string }> }> {
switch (toolName) {
case "memory_save": {
- const content = args.content as string;
- if (!content?.trim()) throw new Error("content is required");
+ const rawContent = args.content;
+ if (typeof rawContent !== "string" || !rawContent.trim()) {
+ throw new Error("content is required");
+ }
+ const content = rawContent;
const id = generateId("mem");
const isoNow = new Date().toISOString();
await kvInstance.set("mem:memories", id, {
@@ -39,12 +78,8 @@ export async function handleToolCall(
type: (args.type as string) || "fact",
title: content.slice(0, 80),
content,
- concepts: args.concepts
- ? (args.concepts as string).split(",").map((c) => c.trim())
- : [],
- files: args.files
- ? (args.files as string).split(",").map((f) => f.trim())
- : [],
+ concepts: normalizeList(args.concepts),
+ files: normalizeList(args.files),
createdAt: isoNow,
updatedAt: isoNow,
strength: 7,
@@ -58,13 +93,41 @@ export async function handleToolCall(
};
}
- case "memory_recall": {
- const query = (args.query as string)?.toLowerCase() || "";
- const limit = (args.limit as number) || 10;
- const all = await kvInstance.list<Record<string, unknown>>("mem:memories");
+ case "memory_recall":
+ case "memory_smart_search": {
+ // memory_smart_search would normally run hybrid BM25+vector+graph
+ // in the engine-backed path, but the standalone shim (#139) only
+ // has the in-memory KV store, so we fall back to a substring
+ // filter. The tool name is kept so plugin skills that say "use
+ // memory_smart_search" still work.
+ //
+ // Empty/missing query is rejected — the forget skill uses this
+ // as its confirmation step before a destructive delete, and an
+ // empty query would match every memory in the store, surfacing
+ // unrelated IDs for deletion.
+ const rawQuery = args.query;
+ if (typeof rawQuery !== "string" || !rawQuery.trim()) {
+ throw new Error("query is required");
+ }
+ const query = rawQuery.trim().toLowerCase();
+ const limit = parseLimit(args.limit);
+ const all =
+ await kvInstance.list<Record<string, unknown>>("mem:memories");
const results = all
.filter((m) => {
- const text = `${m.title} ${m.content}`.toLowerCase();
+ // Search title/content AND files/concepts/sessionIds so the
+ // forget skill can find memories by file path or session
+ // ID, not just by narrative text.
+ const text = [
+ typeof m["title"] === "string" ? m["title"] : "",
+ typeof m["content"] === "string" ? m["content"] : "",
+ Array.isArray(m["files"]) ? m["files"].join(" ") : "",
+ Array.isArray(m["concepts"]) ? m["concepts"].join(" ") : "",
+ Array.isArray(m["sessionIds"]) ? m["sessionIds"].join(" ") : "",
+ typeof m["id"] === "string" ? m["id"] : "",
+ ]
+ .join(" ")
+ .toLowerCase();
return text.includes(query);
})
.slice(0, limit);
@@ -74,10 +137,52 @@ export async function handleToolCall(
}
case "memory_sessions": {
- const sessions = await kvInstance.list("mem:sessions");
+ const sessions =
+ await kvInstance.list<Record<string, unknown>>("mem:sessions");
+ const limit = parseLimit(args.limit, 20);
+ return {
+ content: [
+ {
+ type: "text",
+ text: JSON.stringify(
+ { sessions: sessions.slice(0, limit) },
+ null,
+ 2,
+ ),
+ },
+ ],
+ };
+ }
+
+ case "memory_governance_delete": {
+ // Deletes memories by id. Accepts either a memoryIds array or a
+ // comma-separated memoryIds string (same normalization pattern as
+ // concepts/files) so plugin skills and legacy clients both work.
+ // Unknown ids are silently skipped — the response reports how many
+ // were actually removed so the caller can tell the user.
+ const ids = normalizeList(args.memoryIds);
+ if (ids.length === 0) {
+ throw new Error("memoryIds is required");
+ }
+ let deleted = 0;
+ for (const id of ids) {
+ const existing = await kvInstance.get("mem:memories", id);
+ if (existing) {
+ await kvInstance.delete("mem:memories", id);
+ deleted++;
+ }
+ }
+ kvInstance.persist();
return {
content: [
- { type: "text", text: JSON.stringify({ sessions }, null, 2) },
+ {
+ type: "text",
+ text: JSON.stringify({
+ deleted,
+ requested: ids.length,
+ reason: (args.reason as string) || "plugin skill request",
+ }),
+ },
],
};
}
@@ -101,7 +206,7 @@ export async function handleToolCall(
case "memory_audit": {
const entries = await kvInstance.list("mem:audit");
- const limit = (args.limit as number) || 50;
+ const limit = parseLimit(args.limit, 50);
return {
content: [
{
diff --git a/src/types.ts b/src/types.ts
index d568ad0f..4756f4c0 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -252,7 +252,7 @@ export interface ExportPagination {
}
export interface ExportData {
- version: "0.3.0" | "0.4.0" | "0.5.0" | "0.6.0" | "0.6.1" | "0.7.0" | "0.7.2" | "0.7.3" | "0.7.4" | "0.7.5" | "0.7.6" | "0.7.9" | "0.8.0" | "0.8.1" | "0.8.2" | "0.8.3" | "0.8.4" | "0.8.5" | "0.8.6" | "0.8.7" | "0.8.8";
+ version: "0.3.0" | "0.4.0" | "0.5.0" | "0.6.0" | "0.6.1" | "0.7.0" | "0.7.2" | "0.7.3" | "0.7.4" | "0.7.5" | "0.7.6" | "0.7.9" | "0.8.0" | "0.8.1" | "0.8.2" | "0.8.3" | "0.8.4" | "0.8.5" | "0.8.6" | "0.8.7" | "0.8.8" | "0.8.9";
exportedAt: string;
sessions: Session[];
observations: Record<string, CompressedObservation[]>;
diff --git a/src/version.ts b/src/version.ts
index 5700e195..a1bcfe4f 100644
--- a/src/version.ts
+++ b/src/version.ts
@@ -1 +1 @@
-export const VERSION: "0.3.0" | "0.4.0" | "0.5.0" | "0.6.0" | "0.6.1" | "0.7.0" | "0.7.2" | "0.7.3" | "0.7.4" | "0.7.5" | "0.7.6" | "0.8.1" | "0.8.2" | "0.8.3" | "0.8.4" | "0.8.5" | "0.8.6" | "0.8.7" | "0.8.8" = "0.8.8";
+export const VERSION: "0.3.0" | "0.4.0" | "0.5.0" | "0.6.0" | "0.6.1" | "0.7.0" | "0.7.2" | "0.7.3" | "0.7.4" | "0.7.5" | "0.7.6" | "0.8.1" | "0.8.2" | "0.8.3" | "0.8.4" | "0.8.5" | "0.8.6" | "0.8.7" | "0.8.8" | "0.8.9" = "0.8.9";
diff --git a/test/export-import.test.ts b/test/export-import.test.ts
index 7c523973..7a5f1f16 100644
--- a/test/export-import.test.ts
+++ b/test/export-import.test.ts
@@ -118,7 +118,7 @@ describe("Export/Import Functions", () => {
it("export produces valid ExportData structure", async () => {
const result = (await sdk.trigger("mem::export", {})) as ExportData;
- expect(result.version).toBe("0.8.8");
+ expect(result.version).toBe("0.8.9");
expect(result.exportedAt).toBeDefined();
expect(result.sessions.length).toBe(1);
expect(result.sessions[0].id).toBe("ses_1");
diff --git a/test/mcp-standalone.test.ts b/test/mcp-standalone.test.ts
index 2f2421c5..f534fca4 100644
--- a/test/mcp-standalone.test.ts
+++ b/test/mcp-standalone.test.ts
@@ -155,6 +155,16 @@ describe("handleToolCall", () => {
).rejects.toThrow("content is required");
});
+ it("memory_save rejects non-string content safely (no runtime TypeError)", async () => {
+ const kv = new InMemoryKV();
+ // These would have crashed on .trim() before the type-guard fix.
+ for (const bogus of [42, {}, [], null, undefined, true]) {
+ await expect(
+ handleToolCall("memory_save", { content: bogus }, kv),
+ ).rejects.toThrow("content is required");
+ }
+ });
+
it("memory_recall returns matching memories", async () => {
const kv = new InMemoryKV();
await handleToolCall("memory_save", { content: "TypeScript is great" }, kv);
@@ -168,4 +178,232 @@ describe("handleToolCall", () => {
expect(memories).toHaveLength(1);
expect(memories[0].content).toBe("TypeScript is great");
});
+
+ it("memory_save accepts concepts/files as arrays (plugin skill format, #139)", async () => {
+ const kv = new InMemoryKV();
+ const result = await handleToolCall(
+ "memory_save",
+ {
+ content: "Use HMAC for API auth",
+ concepts: ["hmac", "api-auth", "security"],
+ files: ["src/auth.ts", "src/middleware.ts"],
+ },
+ kv,
+ );
+ const saved = JSON.parse(result.content[0].text);
+ const mem = await kv.get<{ concepts: string[]; files: string[] }>(
+ "mem:memories",
+ saved.saved,
+ );
+ expect(mem?.concepts).toEqual(["hmac", "api-auth", "security"]);
+ expect(mem?.files).toEqual(["src/auth.ts", "src/middleware.ts"]);
+ });
+
+ it("memory_save still accepts concepts/files as comma-separated strings (legacy)", async () => {
+ const kv = new InMemoryKV();
+ const result = await handleToolCall(
+ "memory_save",
+ {
+ content: "JWT refresh rotation",
+ concepts: "jwt, refresh, rotation",
+ files: "src/auth.ts",
+ },
+ kv,
+ );
+ const saved = JSON.parse(result.content[0].text);
+ const mem = await kv.get<{ concepts: string[]; files: string[] }>(
+ "mem:memories",
+ saved.saved,
+ );
+ expect(mem?.concepts).toEqual(["jwt", "refresh", "rotation"]);
+ expect(mem?.files).toEqual(["src/auth.ts"]);
+ });
+
+ it("memory_smart_search falls back to substring match in the standalone shim (#139)", async () => {
+ const kv = new InMemoryKV();
+ await handleToolCall(
+ "memory_save",
+ { content: "Use bcrypt for password hashing" },
+ kv,
+ );
+ await handleToolCall(
+ "memory_save",
+ { content: "Use argon2id for new projects" },
+ kv,
+ );
+ const result = await handleToolCall(
+ "memory_smart_search",
+ { query: "bcrypt", limit: 5 },
+ kv,
+ );
+ const memories = JSON.parse(result.content[0].text);
+ expect(memories).toHaveLength(1);
+ expect(memories[0].content).toBe("Use bcrypt for password hashing");
+ });
+
+ it("memory_smart_search rejects empty query to prevent match-all in forget flow (#139)", async () => {
+ const kv = new InMemoryKV();
+ await handleToolCall("memory_save", { content: "anything" }, kv);
+ await expect(
+ handleToolCall("memory_smart_search", {}, kv),
+ ).rejects.toThrow("query is required");
+ await expect(
+ handleToolCall("memory_smart_search", { query: "" }, kv),
+ ).rejects.toThrow("query is required");
+ await expect(
+ handleToolCall("memory_smart_search", { query: " " }, kv),
+ ).rejects.toThrow("query is required");
+ });
+
+ it("memory_smart_search searches files and concepts, not just title/content (#139)", async () => {
+ const kv = new InMemoryKV();
+ await handleToolCall(
+ "memory_save",
+ {
+ content: "generic note",
+ concepts: ["oauth", "token-rotation"],
+ files: ["src/auth/refresh.ts"],
+ },
+ kv,
+ );
+ await handleToolCall("memory_save", { content: "unrelated" }, kv);
+
+ // Find by file path
+ const byFile = JSON.parse(
+ (
+ await handleToolCall(
+ "memory_smart_search",
+ { query: "src/auth/refresh.ts" },
+ kv,
+ )
+ ).content[0].text,
+ );
+ expect(byFile).toHaveLength(1);
+ expect(byFile[0].files).toContain("src/auth/refresh.ts");
+
+ // Find by concept
+ const byConcept = JSON.parse(
+ (
+ await handleToolCall(
+ "memory_smart_search",
+ { query: "token-rotation" },
+ kv,
+ )
+ ).content[0].text,
+ );
+ expect(byConcept).toHaveLength(1);
+ });
+
+ it("memory_sessions honours the limit arg (#139)", async () => {
+ const kv = new InMemoryKV();
+ for (let i = 0; i < 5; i++) {
+ await kv.set("mem:sessions", `ses_${i}`, {
+ id: `ses_${i}`,
+ project: "demo",
+ });
+ }
+ const result = await handleToolCall(
+ "memory_sessions",
+ { limit: 2 },
+ kv,
+ );
+ const parsed = JSON.parse(result.content[0].text);
+ expect(parsed.sessions).toHaveLength(2);
+ });
+
+ it("parseLimit clamps bad/malicious limit values to a safe range", async () => {
+ const kv = new InMemoryKV();
+ for (let i = 0; i < 150; i++) {
+ await handleToolCall("memory_save", { content: `mem ${i}` }, kv);
+ }
+
+ // Negative / NaN / Infinity / string / object — all should fall back
+ // to the default (10) for memory_smart_search.
+ for (const bogus of [-1, NaN, Infinity, "abc", {}, true]) {
+ const r = await handleToolCall(
+ "memory_smart_search",
+ { query: "mem", limit: bogus },
+ kv,
+ );
+ expect(JSON.parse(r.content[0].text)).toHaveLength(10);
+ }
+
+ // An absurdly large limit gets clamped to MAX_LIMIT (100).
+ const huge = await handleToolCall(
+ "memory_smart_search",
+ { query: "mem", limit: 99999 },
+ kv,
+ );
+ expect(JSON.parse(huge.content[0].text)).toHaveLength(100);
+ });
+
+ it("memory_governance_delete removes memories by id array (#139)", async () => {
+ const kv = new InMemoryKV();
+ const a = JSON.parse(
+ (await handleToolCall("memory_save", { content: "one" }, kv)).content[0]
+ .text,
+ );
+ const b = JSON.parse(
+ (await handleToolCall("memory_save", { content: "two" }, kv)).content[0]
+ .text,
+ );
+ const c = JSON.parse(
+ (await handleToolCall("memory_save", { content: "three" }, kv)).content[0]
+ .text,
+ );
+ const result = await handleToolCall(
+ "memory_governance_delete",
+ { memoryIds: [a.saved, c.saved] },
+ kv,
+ );
+ const parsed = JSON.parse(result.content[0].text);
+ expect(parsed.deleted).toBe(2);
+ expect(parsed.requested).toBe(2);
+
+ const remaining = await kv.list<Record<string, unknown>>("mem:memories");
+ expect(remaining).toHaveLength(1);
+ expect((remaining[0] as { id: string }).id).toBe(b.saved);
+ });
+
+ it("memory_governance_delete accepts CSV-string memoryIds too", async () => {
+ const kv = new InMemoryKV();
+ const saved = JSON.parse(
+ (await handleToolCall("memory_save", { content: "x" }, kv)).content[0]
+ .text,
+ );
+ const result = await handleToolCall(
+ "memory_governance_delete",
+ { memoryIds: saved.saved, reason: "test csv" },
+ kv,
+ );
+ const parsed = JSON.parse(result.content[0].text);
+ expect(parsed.deleted).toBe(1);
+ expect(parsed.reason).toBe("test csv");
+ });
+
+ it("memory_governance_delete throws when memoryIds is missing or empty", async () => {
+ const kv = new InMemoryKV();
+ await expect(
+ handleToolCall("memory_governance_delete", {}, kv),
+ ).rejects.toThrow("memoryIds is required");
+ await expect(
+ handleToolCall("memory_governance_delete", { memoryIds: [] }, kv),
+ ).rejects.toThrow("memoryIds is required");
+ });
+
+ it("memory_governance_delete silently skips unknown ids", async () => {
+ const kv = new InMemoryKV();
+ const saved = JSON.parse(
+ (await handleToolCall("memory_save", { content: "real" }, kv)).content[0]
+ .text,
+ );
+ const result = await handleToolCall(
+ "memory_governance_delete",
+ { memoryIds: [saved.saved, "mem_does_not_exist"] },
+ kv,
+ );
+ const parsed = JSON.parse(result.content[0].text);
+ expect(parsed.deleted).toBe(1);
+ expect(parsed.requested).toBe(2);
+ });
});