#1 Persistent memory for AI coding agents based on real-world benchmarks
TypeScript agentmemoryagentsaiclaudeclaudecodecodexcopilotcursorgenaiharnesshermesmemoryompopenclawopencodepi
fix(claude-bridge): restore memory/ subdir in MEMORY.md path (#1134)
Tassamu Akhsan52d229d51764
diff --git a/src/config.ts b/src/config.tsindex e2b52061..d27c39e4 100644--- a/src/config.ts+++ b/src/config.ts@@ -285,19 +285,20 @@ export function loadClaudeBridgeConfig(): ClaudeBridgeConfig {const lineBudget = safeParseInt(env["CLAUDE_MEMORY_LINE_BUDGET"], 200);let memoryFilePath = "";if (enabled && projectPath) {- // Claude Code stores MEMORY.md at- // ~/.claude/projects/<slug>/MEMORY.md+ // Claude Code stores project memory at+ // ~/.claude/projects/<slug>/memory/MEMORY.md// where <slug> is the project path with `/` and `\` swapped for `-`.// The leading `-` from an absolute POSIX path is preserved (Claude// Code keeps it; stripping it produced a slug Claude never reads).- // There's also no `memory/` subdirectory — the file sits directly- // under the slug dir.+ // The `memory/` subdirectory holds MEMORY.md (the index) plus one+ // per-topic `.md` file per memory (verified against Claude Code 2.x).const safePath = projectPath.replace(/[/\\]/g, "-");memoryFilePath = join(homedir(),".claude","projects",safePath,+ "memory","MEMORY.md",);}diff --git a/test/claude-bridge-path.test.ts b/test/claude-bridge-path.test.tsindex fa3573d3..f9c8f185 100644--- a/test/claude-bridge-path.test.ts+++ b/test/claude-bridge-path.test.ts@@ -4,10 +4,10 @@ import { join } from "node:path";import { loadClaudeBridgeConfig } from "../src/config.js";// bridge path must match Claude Code's slug convention exactly:-// ~/.claude/projects/<slug>/MEMORY.md+// ~/.claude/projects/<slug>/memory/MEMORY.md// where <slug> replaces every / and \ with - and KEEPS any leading -.-// The previous code stripped the leading - and added a /memory/-// subdirectory; the bridge then wrote a file Claude Code never read.+// The memory/ subdirectory holds MEMORY.md (the index) plus per-topic+// .md files — this is where Claude Code 2.x actually reads/writes.describe("loadClaudeBridgeConfig path (#625)", () => {const ORIG_ENV = { ...process.env };beforeEach(() => {@@ -24,16 +24,15 @@ describe("loadClaudeBridgeConfig path (#625)", () => {process.env["CLAUDE_PROJECT_PATH"] = "/home/user/repos/my-project";const cfg = loadClaudeBridgeConfig();expect(cfg.memoryFilePath).toBe(- join(homedir(), ".claude", "projects", "-home-user-repos-my-project", "MEMORY.md"),+ join(homedir(), ".claude", "projects", "-home-user-repos-my-project", "memory", "MEMORY.md"),);});- it("writes MEMORY.md directly under the slug dir, no memory/ subdir", () => {+ it("writes MEMORY.md inside the memory/ subdir under the slug dir", () => {process.env["CLAUDE_MEMORY_BRIDGE"] = "true";process.env["CLAUDE_PROJECT_PATH"] = "/Users/x/agentmemory";const cfg = loadClaudeBridgeConfig();- expect(cfg.memoryFilePath).not.toMatch(/[/\\]memory[/\\]MEMORY\.md$/);- expect(cfg.memoryFilePath).toMatch(/-Users-x-agentmemory[/\\]MEMORY\.md$/);+ expect(cfg.memoryFilePath).toMatch(/-Users-x-agentmemory[/\\]memory[/\\]MEMORY\.md$/);});it("returns empty memoryFilePath when bridge disabled", () => {@@ -53,6 +52,6 @@ describe("loadClaudeBridgeConfig path (#625)", () => {process.env["CLAUDE_MEMORY_BRIDGE"] = "true";process.env["CLAUDE_PROJECT_PATH"] = "C:\\Users\\x\\project";const cfg = loadClaudeBridgeConfig();- expect(cfg.memoryFilePath).toMatch(/C:-Users-x-project[/\\]MEMORY\.md$/);+ expect(cfg.memoryFilePath).toMatch(/C:-Users-x-project[/\\]memory[/\\]MEMORY\.md$/);});});