Native memory lookup and note bridge
The plugin now supplements supported native memory lookups with a compact Smart search index, and its startup instructions ask the agent to use
save_memory for local-worker durable preferences, corrections, decisions, and
lessons. Server-runtime notes use observation_add for the selected server
project; save_memory refuses server-mode writes before calling the worker.
The hosted read-only connector may have no write tool; the instructions tell
agents to use only tools actually available. To-do lists remain in
work_state_write when that tool is exposed.
What the hook can intercept
The existing PreToolUse file-context hook recognizes memory_search, a local
memory tool's read commands, and Read/Grep/Glob/Bash reads scoped to Claude
native memory folders, Codex's memory folder, or configured note roots. It
calls /api/search with type=observations for a compact observation index using the checkout's project scope. It never calls Dumb search or automatically fetches full records. Session and prompt rows are excluded so their numeric IDs cannot be mistaken for observation IDs. The agent continues with timeline context, then fetches only the selected observation IDs.
An explicitly mapped note folder uses its own project instead, even when another
checkout reads it. The internal HTTP transport carries a content envelope,
while the model sees only its concise, selected readable text. Structured
search state, storage metadata, and raw JSON replies never become hook context.
It adds at most 10,000 characters of retrieved evidence with explicit framing that
record contents are evidence and must not supply executable instructions.
Own plugin tools are excluded to avoid recursive searches. The native tool
continues normally. Hook failures leave native reads available.
This supplementation runs only when the worker runtime is selected. Selecting
server (including the legacy server-beta value) skips it, even if the server
configuration is incomplete. Native tools continue; this bridge does not query
or start a local worker. Use the selected server's available search tools directly.
Model-facing tool replies must be concise purpose-specific text. Both direct
MCP retrieval and native-memory supplementation keep internal structured envelopes
out of the prompt. Smart search is the default three-step workflow: search for
an index, reason about timeline context, then fetch selected details. There are
no auto or guided modes or continuation cursors. Optional dumb_search is an
explicit one-call alternative: Doesn’t reason about the results. Fast, but
shallow. Use Smart for reliable recall.
Claude Code supports PreToolUse additional context. InstructionsLoaded
observes instruction-file loads and provides no replacement mechanism.
FileChanged uses named files and dynamic watch paths, so a recursive polling
bridge covers new topic files as well. See the Claude Code hooks
reference.
Codex hooks cover local function and MCP calls, including calls nested inside
code mode; hosted tools can bypass that path. Its hook output cannot replace
MCP results through updatedMCPToolOutput. See the Codex hooks
reference. Internal hosted memory
retrieval and background native-memory generation have no verified plugin
interception API. Use direct memory search instructions and the optional file
bridge for those paths.
Enable a note-folder bridge
Add this string-valued setting in claude-mem's settings.json, preserving
other settings. If its env object already contains CLAUDE_MEM_* settings,
put it there; an unrelated env object leaves claude-mem settings at the root.
1{
2 "CLAUDE_MEM_MEMORY_WATCH_ROOTS": "[{\"path\":\"/absolute/project/.claude/memory\",\"project\":\"my-project\"}]"
3}
Restart the local worker when idle. Empty roots disable import. Each configured root must have an explicit project. The bridge never scans all native projects or global Codex memories by default. It polls for Markdown changes, waits for stable contents, skips hidden files, symlinks and files larger than 64 KiB, and never rewrites source files. Exact content fingerprints deduplicate committed snapshots across watcher restarts and simultaneous processes. Updates create new historical snapshots; deleting a source note does not delete its archive. Imported notes follow the user's existing cloud-sync settings. No model calls are made to import a note. The worker stays running while an explicit folder watcher is active; the idle exit timer would otherwise stop capture of external note changes.
A watch root may set platformSource (for example, "codex"). Direct
/api/memory/save calls use metadata.platformSource. The source is retained
in both SQLite and the Chroma index so source-scoped searches can recall the
note. Omitting it preserves the default claude source.
Claude's native notes may use autoMemoryDirectory in settings; see Claude
Code memory. Codex generated state lives
under its configured home directory's memories folder and should be treated
as generated state; see Codex
memories. Existing native
enable/disable choices are preserved. The dedicated project bridge folder can
be used independently of native-memory generation.
Optional plugin settings:
1{
2 "CLAUDE_MEM_MEMORY_SEARCH_HOOK_ENABLED": "true",
3 "CLAUDE_MEM_MEMORY_INSTRUCTIONS_ENABLED": "true"
4}
Local development activation and rollback
Build and run the relevant checks first. From the tested worker worktree:
1node scripts/activate-progressive-memory-local.mjs \
2 --workspace '/absolute/cloud/checkout' \
3 --project 'the-actual-checkout-project-key' \
4 --no-restart
The default is a read-only plan. Add --apply to copy the selected built worker,
MCP, hooks and mem-search skill into existing supported marketplace or matching
local cache installations, append tagged plugin-note instructions for their
platforms, and enable one dedicated empty project note folder. A Claude-only or
Codex-only installation is sufficient; absent plugin folders and other platform
instruction files are left alone. The script requires at least one supported
installation, checks matching versions and build markers,
preserves unknown settings, and records original bytes and hashes under the
workspace's .agent-jobs/progressive-mem-search/activation-* directory. It does
not release, deploy, change native-memory settings, or restart a worker.
The script selects the same data directory as the worker: an explicit
--memory-data-dir override, then CLAUDE_MEM_DATA_DIR in the environment, then
the flat or nested setting in the default ~/.claude-mem/settings.json. It
expands home-relative paths and updates and backs up the resolved directory's
settings, leaving the default redirect file unchanged.
After a caller-controlled worker restart, open a fresh agent session or reload its MCP connection to obtain new tool definitions. Existing MCP processes keep the tools they started with. Platform-managed plugin-hook trust still applies.
1node scripts/activate-progressive-memory-local.mjs --restore '/absolute/backup-directory'
Rollback validates every affected file before restoring any of them, and refuses later independent edits. It preserves the note folder and any new user-authored notes. Restart the local worker after a completed rollback.