Generated banner for mempal
Generated logo for mempal

mempal

Memory framework

First committed by ZhangHanDong

Published in ZhangHanDong/mempal. Publisher page

284 GitHub stars

What it is

AI Agent Memory
— the description by ZhangHanDong

AutoGineer overview, from the brain’s own files

Mempal is a project memory system designed for coding agents, implemented as a single binary. It enables agents to store, search, and retrieve decision context across sessions. The system utilizes a hybrid search approach combining BM25 keyword matching and vector semantic search, alongside a knowledge graph for tracking entity relationships. It includes a self-describing protocol that allows agents to understand how to interact with the memory system without manual system prompt configuration. Mempal supports cross-project tunnels, multilingual embedding, and collaborative agent workflows through inbox-based handoffs.

How it works

Memory model: Hybrid

AutoGineer overview, from the brain’s own files

Mempal stores data in a SQLite database located at ~/.mempal/palace.db. It ingests project information by chunking and embedding content, which is then searchable via CLI or MCP tools. The system uses a memory protocol to guide agent behavior, such as verifying facts before ingestion and citing sources. It supports collaborative agent interactions by allowing agents to push messages to a per-project inbox, which are then processed via hooks during user prompt submission. The knowledge graph tracks triples with temporal validity, and the system provides tools for fact-checking and context assembly.

Folders
FolderRoleFiles
.claudeagent-config2
.githubagent-config3
docsdocs129
hookshooks2
srcsource-code30
teststests31
benchmarksfolder1
booksfolder41
cratesfolder71
specsfolder131

The agent writes

Requirements

Runtimes: Rust

Databases: SQLite

Works with: Claude Code, OpenAI Codex, GitHub Copilot, Cursor, Kiro, OpenCode, Amp, Cline, JetBrains Junie, Devin (ex-Windsurf)

Set it up

  1. This brain runs code automatically: 2 hooks (claude-code). Review .claude/settings.json before opening the folder in Claude Code. No step below turns a hook on for you.

    • .claude/settings.json: if echo "$TOOL_INPUT" | grep -q 'git commit'; then echo 'MEMPAL REMINDER: You just committed code. Call mempal_ingest to save the decision context (what was built, why, what was considered). Rule 4: SAVE AFTER DECISIONS.'; fi
    • .claude/settings.json: bash .claude/hooks/user-prompt-submit.sh
  2. Not scanned by AutoGineerThe author’s MCP configuration (.mcp.json) also starts it in a way AutoGineer does not offer. Read that file: AutoGineer did not scan that path; what it runs is listed under “This brain runs”. https://github.com/ZhangHanDong/mempal/blob/9ed705d78321daf5878e9579777b1a471e97c6f1/.mcp.json
  3. Not scanned by AutoGineerThe author’s README also describes installing it with cargo. Read its install section: AutoGineer did not scan that path. https://github.com/ZhangHanDong/mempal/blob/9ed705d78321daf5878e9579777b1a471e97c6f1/README.md#quick-start
  4. First committed by ZhangHanDong. Published in ZhangHanDong/mempal. Licence: MIT License.

Usage

AutoGineer overview, from the brain’s own files

  • Initialize project memory for a directory
  • Ingest project files into a specific wing
  • Perform hybrid search for past decisions
  • Fact-check assertions against the knowledge graph
  • Collaborate between agents using inbox pushes
  • Manage knowledge lifecycle and anchor publication
“mempal search "auth decision clerk"”
Returns past decisions related to authentication and Clerk, including source citations.
“mempal fact-check path/to/file”
Identifies potential contradictions like similar name conflicts or stale facts against the knowledge graph.

Documentation by ZhangHanDong

mempal

Image: Crates.io Image: Downloads Image: docs.rs Image: CI Image: Release Image: License: MIT

Project memory for coding agents. Single binary, cargo install mempal, find past decisions with citations in seconds.

Latest release: v0.9.1 (2026-08-19).

What It Does

Agent writes code → commits → mempal saves the decision context
Next session (any agent) → mempal search → finds the decision with source citation
  • Hybrid search: BM25 keyword matching + vector semantic search, merged via Reciprocal Rank Fusion

  • Knowledge graph: subject-predicate-object triples with temporal validity (valid_from/valid_to)

  • Cross-project tunnels: automatic discovery when the same room appears in multiple wings

  • Self-describing protocol: MEMORY_PROTOCOL embedded in MCP ServerInfo teaches any agent how to use mempal — no system prompt configuration required

  • Multilingual: model2vec-rs (BGE-M3 distilled) as default embedder, zero native dependencies

  • Single file: everything lives in ~/.mempal/palace.db (SQLite + sqlite-vec)

Quick Start

cargo install mempal --version 0.9.1 --locked

mempal init ~/code/myapp
mempal ingest ~/code/myapp --wing myapp
mempal search "auth decision clerk"
mempal wake-up

With REST support:

cargo install mempal --version 0.9.1 --locked --features rest

From a source checkout:

cargo install --path . --locked

Configuration

Config at ~/.mempal/config.toml (optional, defaults work without it):

db_path = "~/.mempal/palace.db"

[embed]
backend = "model2vec"                          # default, zero native deps
# model = "minishlab/potion-multilingual-128M" # default multilingual model (1024d)

Other backends:

# Local ONNX (requires --features onnx)
[embed]
backend = "onnx"

# External API
[embed]
backend = "api"
api_endpoint = "http://localhost:11434/api/embeddings"
api_model = "nomic-embed-text"
dimensions = 768  # optional; defaults to 384 when omitted

Commands

CommandPurpose
mempal init <DIR> [--dry-run]Infer wing/rooms from project tree
mempal ingest <DIR> --wing <W> [--dry-run]Chunk, embed, and store
mempal search <QUERY> [--wing W] [--room R] [--json]Hybrid search (BM25 + vector + RRF)
mempal wake-up [--format aaak]Context refresh, sorted by importance
mempal compress <TEXT>AAAK format output
mempal delete <DRAWER_ID>Soft-delete a drawer
mempal purge [--before TIMESTAMP]Permanently remove soft-deleted drawers
mempal kg add <S> <P> <O>Add a knowledge graph triple
mempal kg query [--subject S] [--predicate P]Query triples
mempal kg timeline <ENTITY>Chronological view of an entity
mempal kg statsKnowledge graph statistics
mempal tunnelsCross-wing room links
mempal taxonomy list / editManage routing keywords
mempal reindexRe-embed all drawers after model change
mempal statusDB stats, schema version, scopes
mempal serve [--mcp]MCP server (+ REST with feature)
mempal cowork-install-hooks [--global-codex]Install UserPromptSubmit hooks for Claude Code (+ optional Codex merge)
mempal cowork-drain --target <claude|codex>Drain inbox messages (for hook use; exits 0 on any failure)
mempal cowork-status --cwd <PATH>Read-only view of both inboxes at <PATH>
mempal fact-check [PATH|-] [--wing W] [--room R] [--now <UNIX_SECS>]Offline contradiction check against KG triples + known entities
mempal bench longmemeval <FILE>LongMemEval retrieval benchmark
Project ignore rules

mempal init <DIR> and directory-mode mempal ingest <DIR> use the target project's ignore rules by default. They respect .gitignore, .git/info/exclude, global Git excludes, and a root-level .mempalignore. Built artifacts that should never become project memory can be listed in .mempalignore without changing the project's Git behavior.

Use --ignore-file <PATH> to add one or more extra ignore files for a run. Use --no-gitignore or --no-mempalignore to disable either default source. Explicit file ingest remains explicit: mempal ingest path/to/file --wing <W> still ingests that file even if the project ignore rules would skip it during directory traversal.

MCP Server (10 tools)

mempal serve --mcp exposes these tools via Model Context Protocol:

ToolPurpose
mempal_statusState + protocol + AAAK spec (teaches agent on first call)
mempal_searchHybrid search with tunnel hints, citations, and AAAK-derived structured signals
mempal_ingestStore memories with optional importance (0-5) and dry_run; reports lock_wait_ms when concurrent ingest was observed
mempal_deleteSoft-delete with audit trail
mempal_taxonomyList or edit routing keywords
mempal_kgKnowledge graph: add/query/invalidate/timeline/stats
mempal_tunnelsCross-wing room discovery
mempal_peek_partnerRead partner agent's live session (Claude ↔ Codex), pure read, never writes
mempal_session_peekRead an explicit Claude/Codex local session by concrete tool + cwd, including same-tool cross-project reads
mempal_cowork_pushSend a short handoff message to partner agent's inbox (at-next-submit delivery)
mempal_fact_checkOffline contradiction detection vs KG triples + known entities (similar-name, relation mismatch, stale facts)

The server embeds MEMORY_PROTOCOL (11 behavioral rules) in the MCP initialize.instructions field. Any MCP client learns the workflow automatically.

Memory Protocol

mempal teaches agents these rules through self-description:

  1. FIRST-TIME SETUP — call mempal_status to discover wings before filtering

  2. WAKE UP — different clients have different pre-load mechanisms

  3. VERIFY BEFORE ASSERTING — search before stating project facts

  4. QUERY WHEN UNCERTAIN — search on "why did we...", "last time we..." 3a. TRANSLATE TO ENGLISH — translate non-English queries before searching

  5. SAVE AFTER DECISIONS — persist rationale, not just outcomes

  6. CITE EVERYTHING — reference drawer_id and source_file 5a. KEEP A DIARY — record behavioral observations in wing="agent-diary"

  7. PARTNER AWARENESS — use mempal_peek_partner for live partner-agent session, mempal_session_peek for explicit same-tool/cross-project local sessions, and mempal search only for crystallized drawers

  8. DECISION CAPTURE — mempal_ingest is for firm decisions only; include partner input when peek informed the call

  9. COWORK PUSH — use mempal_cowork_push as the SEND primitive in the SEND/READ/PERSIST triad; at-next-submit delivery, not real-time

  10. VERIFY BEFORE INGEST — call mempal_fact_check before persisting a decision that asserts entity relationships; it catches similar-name typos, relation mismatches against the KG, and stale facts with expired valid_to

Agent Cowork (P6 peek + P8 push)

Two coding agents (Claude Code and Codex) can collaborate on the same repo through a per-project inbox + hook-driven injection channel, on top of mempal_peek_partner (read live partner session), mempal_session_peek (read an explicit local session by concrete tool + cwd), and mempal_cowork_push (send ephemeral handoff).

Install hooks once per repo (run at the repo root):

mempal cowork-install-hooks --global-codex

This writes:

  • .claude/hooks/user-prompt-submit.sh + merges a registration entry into .claude/settings.json so Claude Code fires the hook on every user prompt.

  • ~/.codex/hooks.json UserPromptSubmit entry so Codex fires the same drain on every user prompt.

The --global-codex part is optional. The re-run is idempotent and self-heals stale/wrong drain entries — re-installing after a mempal upgrade is always safe.

Delivery is at-next-UserPromptSubmit, not real-time: a push from Claude to Codex becomes visible only when the Codex user submits their next prompt, at which point the hook drains the inbox and prepends the message as additionalContext on that turn.

Check inbox state at any time without draining:

mempal cowork-status --cwd "$PWD"
Known limitations
  • Codex feature flag dependency: Codex's hooks runtime is gated behind the codex_hooks feature flag (currently "under development" in shipped codex-cli). If the flag is off, Codex silently ignores ~/.codex/hooks.json. install-hooks detects this and prints a warning with the activation command: codex features enable codex_hooks.

  • Two Claude-side artifacts: Claude Code does not auto-discover hook scripts by filename. Both .claude/hooks/user-prompt-submit.sh and the matching entry in .claude/settings.json are required. install-hooks writes both; do not remove either by hand.

  • TUI restart needed after config changes on the Codex side: Codex reads config.toml + hooks.json at process startup only. After enabling the feature flag or running install-hooks, fully quit and relaunch the Codex TUI before expecting hooks to fire.

  • MCP server re-spawn: Claude Code spawns the mempal MCP server at client startup. After upgrading the mempal binary (cargo install ...), restart Claude Code so the MCP server respawns and exposes newly added tools like mempal_cowork_push or mempal_fact_check.

  • Bidirectional scope: mempal_cowork_push currently requires an MCP client identifying itself as claude-code or codex (or their aliases). Generic MCP clients cannot push because caller identity is required to fill the from field and enforce self-push rejection. This is by design for the Claude ↔ Codex pair.

Concurrent Ingest Safety (P9-B)

Two agents writing to the same source simultaneously used to be a TOCTOU race: both would pass the dedup check, both would insert, producing duplicate drawers or mismatched vectors. Since 0.4.0, mempal_ingest and ingest_file_with_options acquire a per-source advisory lock before entering the dedup + insert critical section.

  • Lock files live at ~/.mempal/locks/<16-hex>.lock, created lazily, released on guard drop.

  • 5 s timeout, 50 ms retry + jitter; LockError::Timeout surfaces as an ingest error.

  • Every non-dry-run response carries lock_wait_ms: Option<u64> so agents can detect contention.

  • Dry-run does not acquire the lock (no writes, no race).

  • Unix only in 0.4.0. On Windows the lock path is a no-op fallback; LockFileEx support is tracked for a follow-up.

Offline Fact Checking (P9-A)

mempal_fact_check — and its CLI counterpart mempal fact-check — compare a text blob against the existing KG triples + the entity registry derived from recent drawers. It flags three issue classes, all deterministic and zero-LLM:

IssueTrigger
SimilarNameConflictText mentions a name within Levenshtein distance ≤ 2 of a known entity, and the names are not equal.
RelationContradictionText asserts a predicate (e.g. brother_of) that's in the incompatibility dictionary against an existing KG triple with the same (subject, object) endpoints.
StaleFactText asserts a triple whose KG row has valid_to < now (Unix seconds).

Extracted triples today cover three narrow patterns: "X is Y's ROLE", "X works at / for Y", and "X is [the|a|an] ROLE of Y". Unknown sentence shapes are silently ignored, so the tool errs toward under-reporting rather than false positives.

Protocol Rule 11 guides agents to run this before ingesting a decision that asserts entity relationships. See specs/p9-fact-checker.spec.md for the full contract.

Search Architecture

query → BM25 (FTS5)     → ranked by keyword match
      → Vector (sqlite-vec) → ranked by semantic similarity
      → RRF Fusion (k=60)   → merged ranking
      → Wing/Room filter     → scoped results
      → Tunnel hints         → cross-project references

Knowledge Graph

mempal kg add "Kai" "recommends" "Clerk"
mempal kg add "Clerk" "replaced" "Auth0" --source-drawer drawer_xxx
mempal kg timeline "Kai"
mempal kg stats

Triples support temporal validity — relationships can be invalidated when they expire.

Agent Diary

Cross-session behavioral learning — agents record observations, lessons, and patterns:

# Search diary entries
mempal search "lesson" --wing agent-diary
mempal search "pattern" --wing agent-diary --room claude

Diary entries use the existing mempal_ingest tool with wing="agent-diary" and room=agent-name. MEMORY_PROTOCOL Rule 5a teaches agents to write diary entries. Integrates with Claude Code's auto-dream for automatic memory consolidation.

Ingest Formats (5)

FormatAuto-detected by
Claude Code JSONLtype + message fields
ChatGPT JSONArray or mapping tree
Codex CLI JSONLsession_meta + event_msg entries
Slack DM JSONtype: "message" + user + text
Plain textFallback

AAAK Compression

Output-only format readable by any LLM without decoding:

mempal compress "Kai recommended Clerk over Auth0 based on pricing and DX"
# V1|manual|compress|1744156800|cli
# 0:KAI+CLK+AUT|kai_clerk_auth0|"Kai recommended Clerk over Auth0..."|★★★★|determ|DECISION

Chinese text uses jieba-rs POS tagging for proper word segmentation.

Architecture

CrateResponsibility
mempalInstallable CLI package, REST entrypoint, and legacy facade paths
mempal-embedPublic Embedder / EmbedderFactory traits, API embedder, model2vec and ONNX implementations
mempal-search-corePublic FTS5 query escaping and RRF rank-fusion primitives
mempal-agent-memoryPublic agent-memory domain types and anchor helpers
mempal-mcp-protocolPublic self-describing MEMORY_PROTOCOL text
mempal-store-sqlitePublic SQLite storage layer: schema, migrations, Database, FTS5, sqlite-vec, KG, tunnels, cards, adoption tables
mempal-runtimePublic runtime workflows: ingest, search orchestration, context, brief, knowledge, factcheck, projects, cowork, doctor, AAAK
mempal-mcp-serverPublic MCP server adapter and tool wiring for the runtime

Key design choices:

  • model2vec-rs default embedder — zero native deps, multilingual (BGE-M3 distilled)

  • ort (ONNX) available behind onnx feature flag for max quality

  • FTS5 for BM25 keyword search — synced via SQLite triggers

  • Soft-delete with audit trail — mempal delete + mempal purge

  • Importance ranking — drawers have 0-5 importance, wake-up sorts by importance

  • Semantic dedup — ingest warns (doesn't block) when similar content exists

  • Public workspace crates — reusable libraries are maintained in this repo and published as versioned crates while cargo install mempal remains the CLI path. P114 keeps the split coarse: storage, runtime, and MCP server are separate crates, but feature families such as knowledge, cowork, and context remain in mempal-runtime.

Development

cargo test --workspace
cargo test --workspace --all-features
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo fmt --all --check

After changing the embedding model or dimensions, re-embed existing drawers:

mempal reindex

Docs

Book: MemPalace — Reforging Memory in Rust

mempal 的设计分析和完整技术叙事,收录在《MemPalace: AI 记忆的第一性原理》Part 10(第 26-30 章):

章节内容
第 26 章为什么用 Rust 重铸 — 触发点、重写判断、语言选择
第 27 章保留了什么、改变了什么 — 5 维度对比 + 架构图
第 28 章自描述协议 — MEMORY_PROTOCOL、7 条规则、agent 生命周期
第 29 章多 Agent 协作 — Claude↔Codex 接力、反模式发现、agent 日记
第 30 章诚实的差距 — benchmark 数据、6 个 gap

docs/usage.md

mempal Usage Guide

This guide is for the repository as it exists today: local CLI workflows, MCP usage, AAAK output, the optional REST server, and the native LongMemEval harness.

mempal is a local memory system for coding agents. It stores raw text in SQLite, builds embeddings for retrieval, and always returns citations such as drawer_id and source_file.

Mental Model

Before using the CLI, keep four nouns straight:

  • wing: the top-level scope, usually one project or knowledge domain

  • room: a sub-scope inside a wing, usually inferred from directory names or edited by taxonomy

  • drawer: one stored memory item or chunk

  • source_file: where the drawer came from; for directory ingest, stored relative to the ingest root

mempal is raw-first:

  • original text lives in the drawers table

  • vectors live in drawer_vectors

  • AAAK is output-only and does not replace stored raw text

Install

Install the latest released CLI from crates.io:

cargo install mempal --version 0.9.1 --locked

Install with REST support:

cargo install mempal --version 0.9.1 --locked --features rest

For development without installation:

cargo run -- --help
cargo run --features rest -- serve --help

Source checkouts are Cargo workspaces. The root package is still mempal and still owns the installable CLI binary, while reusable public crates live under crates/:

  • mempal-embed: embedding traits and implementations

  • mempal-search-core: FTS5 query escaping and RRF rank fusion

  • mempal-agent-memory: memory domain types and anchor helpers

  • mempal-mcp-protocol: self-describing MCP protocol text

  • mempal-store-sqlite: SQLite schema, migrations, Database, FTS5, sqlite-vec, KG, tunnels, cards, and adoption tables

  • mempal-runtime: ingest, search orchestration, context, brief, knowledge, factcheck, projects, cowork, doctor, and AAAK workflows

  • mempal-mcp-server: MCP server adapter and tool wiring

The split is intentionally coarse. The root mempal package remains the installable CLI/REST facade, and feature families such as knowledge, cowork, context, and factcheck stay grouped under mempal-runtime instead of becoming separate crates.

Configuration

Config file path:

~/.mempal/config.toml

Default config:

db_path = "~/.mempal/palace.db"

[embed]
backend = "model2vec"
# model = "minishlab/potion-multilingual-128M" # default multilingual model

Use local ONNX instead of the default model2vec backend:

db_path = "~/.mempal/palace.db"

[embed]
backend = "onnx"

Use an external embedding API instead of local embeddings:

db_path = "~/.mempal/palace.db"

[embed]
backend = "api"
api_endpoint = "http://localhost:11434/api/embeddings"
api_model = "nomic-embed-text"
dimensions = 768  # optional; defaults to 384 when omitted

Notes:

  • model2vec is the default backend.

  • The default local model is minishlab/potion-multilingual-128M.

  • First use of model2vec or onnx may download model assets.

  • If config.toml is missing, mempal still works with defaults.

  • The benchmark and search commands use whatever embedder backend is configured here.

Command Cheat Sheet

Use this when you already know the concepts and just need the right command quickly.

CommandPurpose
mempal init <DIR> [--dry-run] [--ignore-file PATH]infer a wing and seed initial taxonomy rooms from a project tree
mempal ingest --wing <WING> <DIR> [--dry-run] [--ignore-file PATH]chunk, embed, and store a project tree
mempal search <QUERY> [--wing W] [--room R] [--json]hybrid search (BM25 + vector + RRF) with tunnel hints
mempal context <QUERY> [--format json] [--include-evidence] [--dao-tian-limit N]assemble mind-model runtime context (dao_tian -> dao_ren -> shu -> qi); default dao_tian budget is 1
mempal field-taxonomy [--format json]inspect read-only recommended field values for typed memory
mempal knowledge distill --statement ... --content ... --tier dao_ren --supporting-ref <ID>create candidate knowledge from evidence refs
mempal knowledge policy [--format json]inspect read-only Stage-1 promotion policy thresholds
mempal knowledge gate <ID> [--format json]evaluate whether knowledge satisfies promotion gate policy without mutating it
mempal knowledge promote <ID> --status promoted --verification-ref <ID> --reason ...promote bootstrap knowledge into active runtime use
mempal knowledge demote <ID> --status demoted --evidence-ref <ID> --reason ... --reason-type contradicteddemote or retire contradicted / obsolete bootstrap knowledge
mempal wake-up [--format aaak]L0/L1 refresh sorted by importance; not a typed mind-model context pack
mempal compress <TEXT>format arbitrary text as AAAK
mempal kg add <S> <P> <O> [--source-drawer ID]add a knowledge graph triple
mempal kg query [--subject S] [--predicate P] [--object O]query triples
mempal kg timeline <ENTITY>chronological view of an entity's relationships
mempal kg statsknowledge graph statistics
mempal tunnelsdiscover rooms shared across multiple wings
mempal taxonomy listinspect current routing keywords
mempal taxonomy edit <WING> <ROOM> --keywords ...tune routing behavior
mempal reindexre-embed all drawers after model/backend change
mempal statusschema version, drawer counts, triples, deleted drawers, scopes
mempal delete <DRAWER_ID>soft-delete one drawer
mempal purge [--before ...]permanently remove soft-deleted drawers
mempal serve --mcprun the MCP server over stdio
mempal bench longmemeval <DATA_FILE>run the native LongMemEval retrieval benchmark

First 5 Minutes

This is the shortest realistic flow for a new project.

1. Inspect the inferred taxonomy

Preview which wing and room names mempal will infer:

mempal init ~/code/myapp --dry-run

Typical output:

dry_run=true
wing: myapp
rooms:
- auth
- deploy
- docs

Write those taxonomy entries:

mempal init ~/code/myapp

By default, init and directory-mode ingest respect the target project's .gitignore, .git/info/exclude, global Git excludes, and a root-level .mempalignore. Add generated files, build outputs, or caches that should stay out of project memory to .mempalignore.

For one-off runs, pass --ignore-file <PATH> more than once to add custom ignore files. Use --no-gitignore or --no-mempalignore when you need to disable one of the default sources. Mempal still hard-skips .git/, target/, and node_modules/ during project traversal. Explicit file ingest bypasses traversal ignore rules.

2. Preview ingest before writing
mempal ingest ~/code/myapp --wing myapp --dry-run

Typical output:

dry_run=true files=12 chunks=34 skipped=2

This reads, normalizes, chunks, and counts, but does not write drawers or vectors.

3. Ingest the project
mempal ingest ~/code/myapp --wing myapp

Optional explicit format selector:

mempal ingest ~/code/myapp --wing myapp --format convos

Every ingest appends a JSONL audit record to:

~/.mempal/audit.jsonl
Bootstrap Knowledge Lifecycle

P18 adds the explicit Stage-1 distillation entry point: create candidate knowledge from existing evidence drawers.

mempal knowledge distill \
  --statement "Prefer evidence before asserting project facts" \
  --content "When answering project-specific questions, cite source-backed memory before making claims." \
  --tier dao_ren \
  --supporting-ref drawer_evidence

Distill always creates status=candidate and currently only allows tier=dao_ren or tier=qi. dao_tian and shu are intentionally excluded from candidate distill because the current P12 status policy does not allow candidate states for those tiers. Use promote only after review.

P17 adds manual lifecycle commands for Stage-1 knowledge drawers. P19 hardens those commands so lifecycle refs must be existing evidence drawers, not arbitrary ids or other knowledge drawers:

P18 adds deterministic CLI distill. P22 exposes the same operation to MCP agents as mempal_knowledge_distill: create candidate dao_ren / qi knowledge from existing evidence refs without LLM summarization or auto-promotion. P23 exposes the lifecycle mutation side as mempal_knowledge_promote and mempal_knowledge_demote: MCP promotion is gate-enforced, and demotion requires counterexample evidence.

Equivalent MCP distill request:

{
  "statement": "Prefer evidence first",
  "content": "Use cited evidence before asserting project facts.",
  "tier": "dao_ren",
  "supporting_refs": ["drawer_evidence"]
}

P20 adds a read-only promotion gate report. P27 exposes the current Stage-1 policy table directly:

mempal knowledge policy --format json

Use gate before promote to check the minimum deterministic policy against a specific drawer without changing status, refs, vectors, schema, or the audit log. P21 exposes the same drawer-specific gate to MCP agents as mempal_knowledge_gate, while P27 exposes the policy table as mempal_knowledge_policy.

mempal knowledge gate drawer_knowledge --format json

P24 adds explicit anchor publication. This is separate from tier/status promotion: it only moves an already active knowledge drawer outward across anchor scope, without rewriting content or vectors.

mempal knowledge publish-anchor drawer_knowledge \
  --to repo \
  --reason "stable across this repository"

Supported publication chain is worktree -> repo -> global. Publishing to global requires domain=global and an explicit --target-anchor-id global://.... P25 exposes the same metadata-only operation to MCP agents as mempal_knowledge_publish_anchor.

For dao_tian -> canonical, provide a reviewer for the advisory gate:

mempal knowledge gate drawer_dao_tian \
  --target-status canonical \
  --reviewer human \
  --format json

Equivalent MCP request:

{
  "drawer_id": "drawer_dao_tian",
  "target_status": "canonical",
  "reviewer": "human"
}
mempal knowledge promote drawer_knowledge \
  --status promoted \
  --verification-ref drawer_evidence \
  --reason "validated across repeated runs" \
  --reviewer "human"
mempal knowledge demote drawer_knowledge \
  --status demoted \
  --evidence-ref drawer_counterexample \
  --reason "new evidence contradicts this heuristic" \
  --reason-type contradicted

Lifecycle commands only update existing memory_kind=knowledge drawers. They validate that --verification-ref / --evidence-ref values start with drawer_, exist, and point to memory_kind=evidence. They do not change content, re-embed vectors, bump schema, or add Phase-2 knowledge_cards. Successful distill and lifecycle changes append JSONL audit entries.

Phase-2 knowledge card tables exist in schema v8, but user-facing card runtime APIs are not implemented yet. drawers remain the active evidence/citation root, while knowledge_cards, knowledge_evidence_links, and knowledge_events are reserved for the Phase-2 runtime.

mempal search "auth decision clerk"

Structured JSON output:

mempal search "auth decision clerk" --json

Restrict to a wing:

mempal search "database decision" --wing myapp

Restrict to a wing and room:

mempal search "token refresh bug" --wing myapp --room auth
5. Generate a context refresh
mempal wake-up

Compact AAAK-formatted refresh:

mempal wake-up --format aaak

Use mempal context when the agent needs typed operating guidance such as dao_tian -> dao_ren -> shu -> qi. wake-up may show selected knowledge statements, but it keeps the L0/L1 refresh shape and does not assemble typed tier sections or apply dao_tian_limit.

Core Workflows

What a search result includes:

  • drawer_id

  • content

  • wing

  • room

  • source_file

  • similarity

  • route

route explains whether the query used explicit filters or taxonomy routing.

source_file is stored relative to the ingest root, so citations stay stable whether the project was ingested via an absolute or relative path.

If you care about deterministic scope, pass --wing and optionally --room explicitly instead of relying on routing.

Field Taxonomy

field is a mind-model metadata dimension used by typed memory search and context assembly. It is separate from wing/room routing taxonomy. P28 exposes a read-only recommended field list:

mempal field-taxonomy
mempal field-taxonomy --format json

The field taxonomy is guidance only. Custom fields remain valid for ingest, distill, search, and context when the recommended Stage-1 fields are too coarse.

Wake-Up and AAAK

wake-up emits a short memory summary for agent context refresh:

mempal wake-up

AAAK output:

mempal wake-up --format aaak
mempal compress "Kai recommended Clerk over Auth0 based on pricing and DX"

Example AAAK output:

V1|manual|compress|1744156800|cli
0:KAI+CLK+AUT|kai_clerk_auth0|"Kai recommended Clerk over Auth0 based on pricing and DX"|★★★★|determ|DECISION

AAAK is an output formatter only:

  • it does not affect how drawers are stored

  • it is not required for ingest or search

  • benchmark --mode aaak means "index AAAK-formatted retrieval text", not "change the storage layer"

Chinese Text

AAAK supports Chinese and mixed Chinese-English text:

mempal compress "张三推荐Clerk替换Auth0,因为价格更优"

Chinese entities and topics are extracted with jieba-rs POS tagging. People, places, organizations, and content words are turned into entity/topic fields before AAAK formatting.

This section is about AAAK output formatting, not retrieval quality. Chinese AAAK support is currently stronger than Chinese search quality.

For the full format specification, see docs/aaak-dialect.md.

Taxonomy

List taxonomy entries:

mempal taxonomy list

Edit or add taxonomy keywords:

mempal taxonomy edit myapp auth --keywords "auth,login,clerk"

Use taxonomy when:

  • you want routing to pick the right room more reliably

  • your repo directory layout is not enough

  • you want search behavior to reflect domain language instead of folder names

Status

Show storage stats:

mempal status

The command reports:

  • schema_version

  • drawer_count

  • deleted_drawers when soft-deleted content exists

  • taxonomy_entries

  • DB file size

  • per-wing and per-room counts

Schema version is backed by SQLite PRAGMA user_version. On open, mempal applies bundled forward migrations needed to bring an older local database up to the current binary's schema.

Agent Diary

mempal supports cross-session behavioral learning through a diary convention. Agents (or humans) record observations, lessons, and patterns that future sessions can learn from.

The diary uses existing tools — no special commands needed:

# Write a diary entry (via MCP or by asking your AI agent)
# Convention: wing="agent-diary", room=agent-name
# Prefix content with OBSERVATION:, LESSON:, or PATTERN:

# Search diary entries
mempal search "lesson" --wing agent-diary
mempal search "pattern infrastructure" --wing agent-diary --room claude

# Search all entries for a specific agent
mempal search "observation" --wing agent-diary --room codex

Example diary entry (written by AI agent via MCP mempal_ingest):

{
  "content": "LESSON: always check repo docs before writing infrastructure code",
  "wing": "agent-diary",
  "room": "claude",
  "importance": 4
}

Content prefixes:

PrefixUse for
OBSERVATION:Factual behavioral observations
LESSON:Actionable takeaways from mistakes or successes
PATTERN:Recurring behavioral patterns across sessions

MEMORY_PROTOCOL Rule 5a tells AI agents to write diary entries after sessions. Human users can also write diary entries — use room to identify the author (e.g., room="alex").

Delete and Purge

These are destructive operations. Use them carefully.

Soft-delete one drawer:

mempal delete drawer_myapp_auth_1234abcd

Current behavior:

  • looks up the drawer first

  • soft-deletes it

  • prints a short summary of what was deleted

  • writes an audit log entry

  • does not permanently remove it yet

Permanent removal:

mempal purge

Purge only drawers soft-deleted before an ISO timestamp:

mempal purge --before 2026-04-10T00:00:00Z

Important:

  • delete is reversible only until purge runs

  • status will tell you when deleted drawers are waiting to be purged

Common Recipes

Index a repo and search one subsystem
mempal init ~/code/myapp
mempal ingest ~/code/myapp --wing myapp
mempal search "token refresh bug" --wing myapp --room auth
Preview a large ingest before committing disk and compute
mempal init ~/code/monorepo --dry-run
mempal ingest ~/code/monorepo --wing monorepo --dry-run
Tune routing when search keeps landing in the wrong room
mempal taxonomy list
mempal taxonomy edit myapp deploy --keywords "render,railway,postgres,migration"
mempal search "postgres migration" --wing myapp
Refresh an AI agent before continuing work
mempal wake-up
mempal wake-up --format aaak
Run a fast benchmark sample instead of the full dataset
mempal bench longmemeval /path/to/longmemeval_s_cleaned.json \
  --limit 20 \
  --out benchmarks/results_longmemeval_20.jsonl

MCP Server

Run stdio MCP explicitly:

mempal serve --mcp

If mempal was built without the rest feature, plain mempal serve behaves the same way.

The MCP server exposes nineteen tools:

  • mempal_status — state + protocol + AAAK spec

  • mempal_search — hybrid search (BM25 + vector + RRF) with tunnel hints and AAAK-derived structured signals (entities / topics / flags / emotions / importance_stars)

  • mempal_context — mind-model runtime context pack (dao_tian -> dao_ren -> shu -> qi, evidence opt-in, dao_tian_limit default 1); guides workflow / skill / tool choice but never executes skills

  • mempal_field_taxonomy — read-only recommended field values for typed evidence / knowledge; guidance only, custom fields remain valid

  • mempal_knowledge_distill — create candidate dao_ren / qi knowledge from existing evidence refs; deterministic and never auto-promotes

  • mempal_knowledge_policy — read-only Stage-1 promotion policy table for dao_tian, dao_ren, shu, and qi

  • mempal_knowledge_gate — read-only promotion readiness check for knowledge drawers; returns the same deterministic gate report as mempal knowledge gate --format json

  • mempal_knowledge_promote — gate-enforced lifecycle promotion with supplied verification refs

  • mempal_knowledge_demote — demote or retire knowledge with counterexample evidence refs

  • mempal_knowledge_publish_anchor — metadata-only outward anchor publication for active knowledge

  • mempal_ingest — store memories with optional importance (0-5) and dry_run

  • mempal_delete — soft-delete with audit

  • mempal_taxonomy — list or edit routing keywords

  • mempal_kg — knowledge graph: add/query/invalidate/timeline/stats

  • mempal_tunnels — cross-wing room discovery

  • mempal_peek_partner — read the partner coding agent's live session (Claude ↔ Codex); pure read, never writes to mempal

  • mempal_session_peek — read an explicit local Claude/Codex session by concrete tool + cwd; use for same-tool or cross-project session reads

  • mempal_cowork_push — send a short handoff message (≤ 8 KB) to the partner agent's inbox; delivered at the partner's next UserPromptSubmit via a drain hook

  • mempal_fact_check — offline contradiction detection against KG triples and known entities

The server also embeds MEMORY_PROTOCOL (behavioral rules) in the MCP initialize.instructions field so any MCP client learns the workflow on connect — zero configuration. The protocol treats wake-up as an L0/L1 refresh surface, mempal_context as typed guidance for choosing an approach, workflow, skill, or tool, mempal_field_taxonomy as guidance for choosing typed-memory field values, and trigger_hints as bias metadata only. These hints never override system, user, repo, or client-native skill rules.

Example request shapes:

{
  "query": "auth decision clerk",
  "wing": "myapp",
  "room": "auth",
  "top_k": 5
}
{
  "content": "decided to use Clerk for auth",
  "wing": "myapp",
  "room": "auth",
  "source": "/repo/README.md",
  "dry_run": false
}

Preview an ingest without writing (returns the predicted drawer_id):

{
  "content": "decided to use Clerk for auth",
  "wing": "myapp",
  "dry_run": true
}

Soft-delete a drawer:

{
  "drawer_id": "drawer_myapp_auth_1234abcd"
}
{
  "action": "edit",
  "wing": "myapp",
  "room": "auth",
  "keywords": ["auth", "login", "clerk"]
}

mempal_status also returns the self-describing memory protocol and a dynamically generated AAAK spec so AI clients can learn the tool without a hardcoded prompt.

Agent Cowork (peek + push)

Two coding agents running on the same repo — typically Claude Code and Codex — can collaborate through two primitives:

  • mempal_peek_partner (P6) — read the partner's live session file without storing anything in mempal. Use for "what is partner currently doing" questions.

  • mempal_session_peek (P112) — read an explicit local session by concrete tool + cwd. Use for same-tool or cross-project inspection such as Codex reading another Codex project's transcript.

  • mempal_cowork_push (P8) — send a short handoff (≤ 8 KB) to the partner's inbox. The partner sees it prepended to their next user prompt via a UserPromptSubmit hook. Use for "make sure partner notices X" status updates that are too transient for an ingest drawer.

Install hooks

Hooks land the pushed message into the partner's next prompt automatically. Install once per repo (run at the repo root):

mempal cowork-install-hooks --global-codex

This writes two Claude-side artifacts (both required — Claude Code does not auto-discover bare hook scripts):

  • .claude/hooks/user-prompt-submit.sh — the drain script

  • an entry in .claude/settings.json under hooks.UserPromptSubmit registering the script

and merges the equivalent entry into ~/.codex/hooks.json (top-level hooks.UserPromptSubmit with {type:"command", command:"mempal cowork-drain --target codex --format codex-hook-json --cwd-source stdin-json"}).

Re-running is idempotent and self-heals stale/wrong drain entries from prior mempal versions, preserving any unrelated hooks already in those files.

Check current state
mempal cowork-status --cwd "$PWD"

Lists both inbox targets (claude and codex) for the given cwd along with message counts, byte sizes, and a preview. Read-only — does not drain.

Known limitations
  • Codex codex_hooks feature flag: Codex's hooks runtime is gated behind the codex_hooks feature flag ("under development" in current shipped codex-cli). If the flag is off, Codex silently ignores ~/.codex/hooks.json. install-hooks detects this and prints an activation prompt (codex features enable codex_hooks).

  • TUI restart required on Codex side: Codex caches config.toml + hooks.json at TUI startup only. After changing the feature flag or running install-hooks, fully quit and relaunch Codex before new hooks take effect.

  • MCP server re-spawn required in Claude Code: Claude Code spawns the mempal MCP server at client startup. After upgrading the mempal binary, restart Claude Code so the MCP server respawns with the new tool list (notably mempal_cowork_push).

  • Claude ↔ Codex scope: mempal_cowork_push requires the MCP client to identify itself as claude-code or codex (or their recognized aliases). Generic MCP clients cannot push because caller identity is required to fill the message from field and enforce self-push rejection. This is by design for the Claude ↔ Codex pair.

  • At-next-submit, not real-time: a push is visible on the partner's next user prompt turn — never mid-turn. Codex's TUI will not re-render to inject a message on an external trigger.

REST Server

Build with --features rest to enable REST:

mempal serve

With REST enabled:

  • MCP still runs over stdio

  • REST listens on 127.0.0.1:3080

  • CORS only allows localhost origins

Endpoints:

  • GET /api/status

  • GET /api/search?q=...&wing=...&room=...&top_k=...

  • POST /api/ingest

  • GET /api/taxonomy

Examples:

curl 'http://127.0.0.1:3080/api/status'
curl 'http://127.0.0.1:3080/api/search?q=clerk&wing=myapp'
curl -X POST 'http://127.0.0.1:3080/api/ingest' \
  -H 'content-type: application/json' \
  -d '{"content":"decided to use Clerk","wing":"myapp","room":"auth"}'
curl 'http://127.0.0.1:3080/api/taxonomy'

Benchmark LongMemEval

mempal includes a native LongMemEval harness. It reuses the dataset shape and retrieval metrics documented in mempalace, while indexing and searching through mempal itself.

Default session-granularity raw benchmark:

mempal bench longmemeval /path/to/longmemeval_s_cleaned.json

Other modes:

mempal bench longmemeval /path/to/longmemeval_s_cleaned.json --mode aaak
mempal bench longmemeval /path/to/longmemeval_s_cleaned.json --mode rooms

Turn granularity and results log:

mempal bench longmemeval /path/to/longmemeval_s_cleaned.json \
  --granularity turn \
  --out benchmarks/results_longmemeval.jsonl

Supported options:

  • --mode raw|aaak|rooms

  • --granularity session|turn

  • --limit N

  • --skip N

  • --top-k N

  • --out path/to/results.jsonl

What the benchmark does:

  • loads the cleaned LongMemEval JSON

  • builds a temporary benchmark DB per question

  • indexes retrieval text using the configured embedder

  • runs retrieval and reports Recall@k and NDCG@k

What it does not do:

  • it does not generate final answers with an LLM

  • it is not the same as the official answer-generation evaluation pipeline

  • raw mode does not automatically mean zero API cost if your embedder backend is configured as api

For the current local benchmark snapshot in this repository, see benchmarks/longmemeval_s_summary.md. That summary now separates the older 384d baseline from the newer model2vec 256d run.

mempal works best when AI agents save decision context after every commit — not just the code diff, but why the change was made, what was considered, and what's left to do. This is MEMORY_PROTOCOL Rule 4 (SAVE AFTER DECISIONS).

The problem: agents forget. The solution: a Claude Code hook that reminds the agent after every git commit.

Setup for Claude Code

Create .claude/settings.json in your project root:

{
  "hooks": {
    "afterToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "if echo \"$TOOL_INPUT\" | grep -q 'git commit'; then echo 'MEMPAL REMINDER: You just committed code. Call mempal_ingest to save the decision context (what was built, why, what was considered). Rule 4: SAVE AFTER DECISIONS.'; fi"
          }
        ]
      }
    ]
  }
}

After this, every time the agent runs git commit, it sees a reminder to save the decision to mempal. The agent still decides what to save — the hook just ensures it doesn't forget.

What makes a good decision record

Bad (just restating the diff):

Added CI workflow

Good (captures context a future agent needs):

Added CI with default + all-features matrix. Deliberately omitted rustfmt
because formatting drift exists in 2 test files — cleanup is a separate
commit. Follow-up: cargo fmt --all then add fmt check step. This completes
priority #1 from drawer_mempal_default_a295458d.

The difference: a future agent reading the good version knows what was omitted, why, and what to do next. The bad version tells them nothing they can't learn from git log.

For other AI tools
  • Codex: Configure in ~/.codex/instructions.md — add "After every commit, call mempal_ingest with decision context"

  • Cursor: Add to .cursorrules — same instruction

  • Any MCP client: The MEMORY_PROTOCOL in mempal_status already contains Rule 4; the hook is a reinforcement for clients that sometimes skip it

Auto-Dream Integration

Claude Code's auto-dream feature consolidates session memory while you're away — like REM sleep for AI. mempal integrates with this process to ensure project decisions survive across sessions.

How it works

When auto-dream runs (automatically between sessions or manually via "dream"):

  1. Claude reviews recent session transcripts

  2. Extracts key decisions and knowledge

  3. With mempal: verifies facts via mempal_search, saves consolidated insights via mempal_ingest with importance >= 3, and records a dream diary entry

Setup

Add to your project's CLAUDE.md:

## Auto-Dream Integration

When performing auto-dream or manual dream:
1. Call mempal_search to verify facts being consolidated
2. Save high-value insights to mempal (mempal_ingest, importance >= 3)
3. If MEMORY.md and mempal contradict, trust mempal (has citations)
4. Write dream summary as agent diary (wing="agent-diary", room="claude")
5. Check triples for expired relationships to invalidate
What this gives you

Without mempal, auto-dream consolidates into MEMORY.md files that only Claude Code reads. With mempal, dream insights are stored in palace.db where any MCP-connected agent (Codex, Cursor, etc.) can find them. Dream becomes a cross-agent memory consolidation mechanism, not just a Claude Code internal process.

Identity File

If you use wake-up regularly with AI agents, you can add a user-edited identity file:

mkdir -p ~/.mempal
$EDITOR ~/.mempal/identity.txt

Example:

Role: Rust backend engineer at Acme.
Current focus: auth rewrite, Clerk migration.
Working style: small reversible edits, verify before asserting.

wake-up can include this as part of the agent context refresh.

FAQ

Search results look wrong or too broad
  • Pass --wing explicitly. Global search is convenient, but it broadens retrieval.

  • Pass --room when you already know the subsystem.

  • Inspect taxonomy with mempal taxonomy list and add better keywords with mempal taxonomy edit.

  • Check which embedder backend you are using. Different embedding models shift retrieval behavior.

Search returns irrelevant results for Chinese (or other non-English) queries

The default embedder is now a multilingual model2vec model, but English queries still retrieve more reliably than Chinese (and other non-English) queries in practice.

For AI agents: MEMORY_PROTOCOL rule 3a tells agents to translate queries to English before calling mempal_search. This is handled automatically by agents that read the protocol.

For CLI users: translate your query to English manually, or use the --wing filter to narrow scope:

# Poor results:
mempal search "它不再是一个高级原型"

# Good results:
mempal search "no longer just an advanced prototype"

This is mostly a retrieval-stack limitation, not a storage limitation:

  • the embedder is multilingual but still stronger on English queries

  • the search path does not currently use a Chinese-specific lexical tokenizer for FTS5

  • AAAK uses jieba-rs, but the search path does not

So the practical guidance is still: translate the query to English first, or narrow scope with --wing / --room.

Why did ingest store relative paths instead of absolute ones?

mempal stores source_file relative to the ingest root on purpose. This keeps citations stable if you ingest the same project through different absolute paths.

Is raw benchmark mode always zero API cost?

No. raw only means raw retrieval text. API cost depends on the embedder backend:

  • local onnx backend: zero external API calls

  • api backend: embedding requests still go to the configured API

Why is --granularity turn so much slower?

Because it expands one session into many more indexed items. On the current LongMemEval s_cleaned runs in this repository, raw + turn was dramatically slower than raw + session while not improving overall retrieval quality enough to justify being the default.

Should I use delete freely because it is soft-delete?

Use it carefully anyway. delete is safer than hard removal, but once mempal purge runs, the data is permanently gone.

Verify Changes

If you modify code or behavior in this repository, the current validation baseline is:

cargo test --workspace
cargo test --workspace --all-features
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo fmt --all --check
453 files · 436 not served here

Advantages

  • Hybrid search combines BM25 and vector semantic search for improved retrieval. evidence: README.md
  • Self-describing protocol allows agents to learn interaction rules automatically. evidence: README.md
  • Per-source advisory locking prevents race conditions during concurrent agent ingestion. evidence: README.md

Limitations

Security

Risk level: Low risk

This brain runs

Hooks (2)

  • .claude/settings.json (PostToolUse): if echo "$TOOL_INPUT" | grep -q 'git commit'; then echo 'MEMPAL REMINDER: You just committed code. Call mempal_ingest to save the decision context (what was built, why, what was considered). Rule 4: SAVE AFTER DECISIONS.'; fi
  • .claude/settings.json (UserPromptSubmit): bash .claude/hooks/user-prompt-submit.sh

MCP servers (1)

  • .mcp.json (mempal): mempal serve --mcp

Agent instructions that run or fetch something (22)

  • AGENTS.md: Rust 实现的 coding agent 项目记忆工具。单二进制,`cargo install mempal`,10 秒内带出处找回历史决策。
  • AGENTS.md: | Spec | 状态 | 范围 | |------|------|------| | `specs/p0-core-scaffold.spec.md` | 完成 | workspace 骨架 + SQLite schema | | `specs/p0-embed-trait.spec.md` | 完成 | Embedder trait(model2vec 默认 + ort 可选) | | `specs/p0-ingest.spec.md` | 完成 | 导入管道(格式检测/归一化/分块/存储) | | `specs/p0-search-cli.spec.md` …[+7715 chars]
  • AGENTS.md: `docs/plans/2026-05-26-p98-release-install-doctor.md` — P98 release install doctor(已完成)
  • AGENTS.md: `docs/plans/2026-05-26-p100-guided-maintenance-run.md` — P100 guided maintenance run(已完成)
  • AGENTS.md: `docs/plans/2026-08-18-p117-reindex-atomic-replace.md` — P117 atomic reindex replace + dry-run feasibility report(已完成)
  • AGENTS.md: | 工具 | 作用 | |------|------| | `mempal_status` | 状态 + 协议 + AAAK spec | | `mempal_doctor` | release/install + MCP runtime diagnostics:报告 binary/PATH/schema 兼容性和 required MCP tool/action 能力清单(P99) | | `mempal_search` | 混合检索(BM25 + 向量 + RRF + tunnel hints)+ AAAK 结构化 signals(P7) | | `mempa …[+2688 chars]
  • AGENTS.md: Cargo workspace,root package 仍是 `mempal`,并继续提供 `cargo install mempal` 的 CLI binary。P113/P114 已把可复用边界拆成公开 workspace crates;root crate 现在主要负责 CLI、REST entrypoint、package metadata 和 legacy facade paths。
  • AGENTS.md: **`mempal cowork-install-hooks` 写两件 Claude 侧制品**:`.claude/hooks/user-prompt-submit.sh`(脚本)+ `.claude/settings.json` 下的 `hooks.UserPromptSubmit` 条目(注册)。Claude Code 不按文件名约定自动发现脚本,两件**都必须有**hook 才会 fire。`install-hooks` 已自动处理 + 自愈 stale 条目;请勿手工移除其中任一。
  • AGENTS.md: **Codex 侧依赖 `codex_hooks` feature flag**:shipped `codex-cli ≤ 0.120.0` 该 flag 处于 "under development" 且默认 `false`,此时 Codex runtime 完全忽略 `~/.codex/hooks.json`。`install-hooks` 检测到会打印 warning + 激活命令 `codex features enable codex_hooks`。
  • AGENTS.md: **Codex TUI 进程启动时一次性缓存 config**:改完 `config.toml` 或 `hooks.json`(含 feature flag / install-hooks)后,必须完全退出并重启 Codex TUI;已在跑的进程拿不到新配置。
  • AGENTS.md: **Claude Code 的 MCP server 是 session startup spawn**:`cargo install` 升级 mempal binary 后,Claude Code 还在用旧 MCP server 进程,**不认识新加的工具**(如 `mempal_cowork_push`)。升级后重启 Claude Code,MCP server 会 respawn 到新 binary。
  • CLAUDE.md: Rust 实现的 coding agent 项目记忆工具。单二进制,`cargo install mempal`,10 秒内带出处找回历史决策。
  • CLAUDE.md: | Spec | 状态 | 范围 | |------|------|------| | `specs/p0-core-scaffold.spec.md` | 完成 | workspace 骨架 + SQLite schema | | `specs/p0-embed-trait.spec.md` | 完成 | Embedder trait(model2vec 默认 + ort 可选) | | `specs/p0-ingest.spec.md` | 完成 | 导入管道(格式检测/归一化/分块/存储) | | `specs/p0-search-cli.spec.md` …[+7715 chars]
  • CLAUDE.md: `docs/plans/2026-05-26-p98-release-install-doctor.md` — P98 release install doctor(已完成)
  • CLAUDE.md: `docs/plans/2026-05-26-p100-guided-maintenance-run.md` — P100 guided maintenance run(已完成)
  • CLAUDE.md: `docs/plans/2026-08-18-p117-reindex-atomic-replace.md` — P117 atomic reindex replace + dry-run feasibility report(已完成)
  • CLAUDE.md: | 工具 | 作用 | |------|------| | `mempal_status` | 状态 + 协议 + AAAK spec | | `mempal_doctor` | release/install + MCP runtime diagnostics:报告 binary/PATH/schema 兼容性和 required MCP tool/action 能力清单(P99) | | `mempal_search` | 混合检索(BM25 + 向量 + RRF + tunnel hints)+ AAAK 结构化 signals(P7) | | `mempa …[+2688 chars]
  • CLAUDE.md: Cargo workspace,root package 仍是 `mempal`,并继续提供 `cargo install mempal` 的 CLI binary。P113/P114 已把可复用边界拆成公开 workspace crates;root crate 现在主要负责 CLI、REST entrypoint、package metadata 和 legacy facade paths。
  • CLAUDE.md: **`mempal cowork-install-hooks` 写两件 Claude 侧制品**:`.claude/hooks/user-prompt-submit.sh`(脚本)+ `.claude/settings.json` 下的 `hooks.UserPromptSubmit` 条目(注册)。Claude Code 不按文件名约定自动发现脚本,两件**都必须有**hook 才会 fire。`install-hooks` 已自动处理 + 自愈 stale 条目;请勿手工移除其中任一。
  • CLAUDE.md: **Codex 侧依赖 `codex_hooks` feature flag**:shipped `codex-cli ≤ 0.120.0` 该 flag 处于 "under development" 且默认 `false`,此时 Codex runtime 完全忽略 `~/.codex/hooks.json`。`install-hooks` 检测到会打印 warning + 激活命令 `codex features enable codex_hooks`。
  • CLAUDE.md: **Codex TUI 进程启动时一次性缓存 config**:改完 `config.toml` 或 `hooks.json`(含 feature flag / install-hooks)后,必须完全退出并重启 Codex TUI;已在跑的进程拿不到新配置。
  • CLAUDE.md: **Claude Code 的 MCP server 是 session startup spawn**:`cargo install` 升级 mempal binary 后,Claude Code 还在用旧 MCP server 进程,**不认识新加的工具**(如 `mempal_cowork_push`)。升级后重启 Claude Code,MCP server 会 respawn 到新 binary。
  • Low risk: scripts-present (.claude/hooks/user-prompt-submit.sh)

Attribution and licence

First committed by
GitHub avatar of ZhangHanDongZhangHanDong
Publisher
Alex (Community)
Source
ZhangHanDong/mempal · commit 9ed705d
Licence
MIT License (files served here)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Contributors
ZhangHanDong, LiuZiqi-dual, TigerInYourDream, jolestar, ryushione

AutoGineer is not affiliated with or endorsed by ZhangHanDong.

Install from source

436 of its files are not served here, so there is no ZIP. ZhangHanDong/mempal at 9ed705d