Repository navigation
Use Claude Code memory store with autoMemoryStorage - #434
Merged
ilovepixelart merged 12 commits intoNov 14, 2026
Merged
Conversation
…slug, and format compat
An entry line ending in a carriage return did not match the entry pattern, so a save appended a duplicate line and a delete left the line behind. Lines are now split on LF or CRLF and the index is rewritten with the line ending it already uses. A title containing a closing bracket is matched by its link target. An index whose first line is blank no longer receives a second `# Memory index` heading: the first non-blank line decides.
Both describe blocks repeated the temp home, the settings writer, the store path helper and the extension wiring. They now use one file-level copy. The per-file HOME restore is dropped: tests/setup.ts rolls process.env back after every test.
With build_notes.md and build-notes.md both indexed, reading build-notes returned the dashed file, saving it overwrote the underscored one, and deleting it removed both. A file such as foo-bar_baz.md could not be reached at all. All three actions now resolve the name once: an exactly named file wins, and a file differing only in dashes and underscores is used when the exact one does not exist. Delete removes that file and its index line only. safeStem is removed: a name is a slug and a match differs from it only by underscores, so a link target with a path separator never matched. A test now pins that an index link pointing out of the store is not followed.
With autoMemoryStorage "claude", a save of a new memory prepended `# Memory index` to an index that has no heading and appended the entry in pi's `- [name](name.md): description` format. Claude Code writes its index without a heading and separates the link from the description with a dash. In the claude store a new entry now uses Claude's separator and no heading is added. In both stores an update keeps the entry's link and whatever separator it already has (a colon or any dash) and replaces only the description. The pi store's format is unchanged. The test fixture now has the shape Claude Code writes: no top heading and dashed file names, with one underscored name kept for the fallback.
stampModified removed every `modified:` line, including the one nested under `metadata:`, and appended a top-level field. A file whose metadata held only `modified` was left with an empty `metadata:` key. An existing field is now replaced in place with its indentation. A file with a `metadata:` block and no timestamp gets it inside that block, where Claude Code writes it; a file without the block gets a top-level field as before. CRLF frontmatter keeps its line ending.
A memory saved by pi into Claude Code's store had no frontmatter unless the content carried its own. Claude Code reads `name` and `description` from it and flags a file without a description as unreliable for recall. In the claude store a save now adds `name` (the memory name) and `description` (the description the save already takes) when the content lacks them, and moves a top-level `type:` under `metadata:`, where Claude keeps it. Fields the content already has are kept. The pi store is unchanged.
claudeProjectSlug returned the dashed path at any length. Claude Code cuts a name longer than 200 characters there and appends a base-36 32-bit hash of the path, so a deep project resolved to a directory Claude never uses. The cap and the hash are ported, and the project path and the resulting store path are normalised to NFC as Claude does. Two environment variables Claude Code reads are honoured: CLAUDE_CODE_REMOTE_MEMORY_DIR replaces the config directory as the root of the store, and CLAUDE_CODE_PROJECT_DIR_NAME replaces the slug when CLAUDE_CONFIG_DIR is set and the value is one plain segment of at most 64 characters that is not a Windows device name. Both are added to the test environment quarantine.
Adds tests for behaviour that had none: a linked worktree resolves to the main checkout's Claude store, CLAUDE_CONFIG_DIR moves both the setting and the store, an unrecognised autoMemoryStorage value keeps the pi store, and a CRLF index is updated and trimmed through the tool with its line ending kept.
The paragraph said the setting is read from any settings scope; project settings count only once the project is approved. It also restated the index format rules. It now names the scopes, points at claudeMemoryDir for the location rules, states what a pi save writes into Claude's store, and lists the known differences from Claude Code. A dash pair in a memory.ts comment is replaced with commas.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an opt-in memory storage mode that reuses the store Claude Code already keeps for each project, so memories do not start over or drift apart when switching between Claude Code and pi.
The Claude store is read and written in place. Project paths use Claude's observed encoding, and the store is keyed on the repository root so subdirectory sessions and worktrees share it.
Existing Claude indexes remain usable: reads and writes recognize underscore file names, preserve link titles and section headings, and replace only the matching entry. Index link targets are accepted as file names only when they are plain path segments, so a repository-supplied index cannot write outside the store.
The default pi store, explicit
autoMemoryDirectoryoverrides, and automatic migration behavior remain unchanged. Switching modes does not move or merge existing memories.Evidence
tests/memory-shared.test.tshad 16 failing tests covering Claude project resolution and compatibility with Claude-written stores.npm run checkpasses, including Biome, strict TypeScript, knip, and the full Vitest suite with coverage.Merge Danger
Door: two-way
Blast Radius: opt-in memory storage selection, plus shared memory read/write/index handling.
The new storage location is inactive unless the user selects
autoMemoryStorage: "claude". The default pi storage path is unchanged. Format-compatibility changes affect memory reads, updates, and deletions in both modes and are covered by the existing and new tests.npm run checkpasses (Biome, strict tsc, Vitest)