Memex

Logo

The extra-context layer for AI agents — L1 eviction, sticky L2/L3 context pools, context paging, cold-tier compression.

View the Project on GitHub QiuXu-Tech/memex

Claude Code

node packages/memex-claude/bin/cli.mjs init --model claude-sonnet-5-5
# or: --model claude-opus-5-5  (1M context, adaptive thinking)
# or: --project /path/to/project  --root ~/.memex --levels l2,l3

init is idempotent and writes three things in the project:

File What it does
.mcp.json registers memex MCP server (memory_search, memory_open, memory_grep, memory_write, memory_index, memory_restore, memory_compress + memory://catalog)
.claude/settings.json merges SessionStart, UserPromptSubmit, PreCompact, SessionEnd hooks (keeps your existing hooks)
CLAUDE.md appends a model-tailored memory manual in a <!-- memex:start -->…<!-- memex:end --> section

How the hooks behave

Hooks never break a session: failures are logged to stderr and the exit code stays 0.

———- test README ———-

p=pathlib.Path(‘test/README.md’); s=p.read_text() s=s.replace(‘Expected output ends with # 110/110 passed.’, ‘Expected output ends with # 112/112 passed.’).replace(‘110/110 passed’,’112/112 passed’) s=s.replace(“- Operations: backup/verify/restore scripts.”, “- Operations: backup/verify/restore scripts.

———- architecture ———-

p=pathlib.Path(‘docs/architecture.md’); s=p.read_text() s=s.replace(## 11.4 Hot-body rescue (v0.3.0)

Card retrieval legs only see title/summary/useWhen/tags/abstract, so a fact that lives only in a hot body could be invisible when card matches fill the candidate limit (measured 0% hit@5 on a controlled fixture). v0.3.0 adds:

Acceptance: body-only probe hit@1/hit@5 0%/0% → 100%/100%. Natural-language-only body facts (no identifier anchor) still rely on card summaries / memory_grep.

12. Agent-agnostic adapters (v0.2.0)

Manual workflows

Ask Claude to “remember this” (it calls memory_write), or run:

node packages/memex-claude/bin/cli.mjs status
node packages/memex-claude/bin/cli.mjs print-manual --model claude-sonnet-4

The shared core means memory written through Claude Code is visible to the DSH plugin, Codex and any MCP client when they use the same root (default ~/.memex; point DSH at it with MEMEX_HOME).