Skip to main content
Glama

AnchorDex

简体中文 · Changelog: CHANGELOG.md

release CI node dependencies license stars

A pull-based, self-verifying Markdown Memory Vault for AI coding agents — built on Node.js with zero external npm dependencies.

AnchorDex keeps permanent system prompts (AGENTS.md, CLAUDE.md, GEMINI.md) lean by storing durable engineering knowledge as scoped Markdown cards in ~/.memory-vault. Agents retrieve only cards that match the active task, verify file and line anchors against disk before indexing, preserve immutable revision history, and share the same local knowledge store across Antigravity, Claude Code, Codex CLI, Cursor, and DSH.

NOTE

All storage, indexing, search, anchor verification, and atomic file operations run locally on plain Markdown files inside~/.memory-vault (or $MEMORY_VAULT_DIR) without external databases or network services.

Core Mechanisms

1. Compact Index & On-Demand Retrieval

  • 00-System/INDEX.md: Maintains a concise routing table and recent-card summary so agents inspect available topics without pre-loading full notes into every conversation.

  • 00-System/INDEX-full.md & Hash-Isolated Cache: Generates a full metadata catalog alongside a single-file JSON cache (~/.cache/memory-vault/memory-search-cache-<vault-hash>.json), checking per-card statSync metadata so direct file edits invalidate stale cache entries automatically.

2. Applicability Boundaries & Abstention

  • Explicit Scoping (applies_when / not_when): Every active card declares concrete trigger conditions in YAML frontmatter. Cards missing required boundaries are excluded from active auto-recall.

  • Layered Hybrid Search (memory-search.mjs): Scores EN/CJK queries with BM25+IDF weighting while separating strict synonym groups (strict), unidirectional weak associations (weak), and cross-domain generic terms (generic).

  • Abstention-First PreInvocation Hook: Injects 0–3 relevant cards when specificity thresholds are met, and returns {} silently on unrelated prompts to keep context clean.

3. Anchor Verification & Write Guards

  • Disk-Backed Checks (memory-verify.mjs): Verifies referenced local file paths, file:line anchors, numeric counts, and superseded_by links against the filesystem.

  • Write Gate: Writes or corrections with failing anchors return isError: true from MCP and skip updating INDEX.md and the search cache until resolved.

  • Direct-Edit Guards: PostToolUse strips UTF-8 BOMs and stages modified paths without premature indexing; Stop validates staged writes and [git-delta] direct edits across both Git and non-Git vaults before rebuilding indexes.

4. Honest Metadata & Immutable History

  • Strict verified_at Discipline: memory_write records verified_at only when explicitly provided after verification; status: draft omits verified_at automatically.

  • Non-Destructive Revisions (memory_correct): Prepends a dated CORRECTION block above preserved original text, or retires replaced entries via --supersede <new-card> (status: superseded).

  • Bi-Temporal States: Supports approved, draft, pending, archived (searchable and exempt from 30-day environment staleness warnings), superseded, and reverted.

Related MCP server: projectmem

Architecture

User Prompt  ─▶ PreInvocation Hook (autoRecall gate + cache) ─▶ Injects 0–3 scoped cards, or abstains
Agent Turn   ─▶ MCP Server (stdio JSON-RPC 2.0) or CLI fallback resolved from SKILL_DIR
Direct Edit  ─▶ PostToolUse Hook (strip UTF-8 BOM + stage touched path)
Turn End     ─▶ Stop Hook (checks PostToolUse + [git-delta]; rebuilds index & commits baseline on 0 FAIL)
Shared Store ─▶ ~/.memory-vault/ (atomic rename via writeFileAtomic + per-vault SHA-1 cache)

Supported Frameworks

Client

Install Path (install.mjs)

MCP Registration

Vault Alignment

Antigravity

~/.gemini/config/plugins/memory-vault

mcp_config.json + 4 Hooks

MEMORY_VAULT_DIR + plugin-config.json

Claude Code

~/.claude/skills/memory-vault

~/.claude.json (mcpServers.memory_vault)

MEMORY_VAULT_DIR + plugin-config.json

Codex CLI

~/.codex/skills/memory-vault

~/.codex/config.toml ([mcp_servers.memory_vault])

MEMORY_VAULT_DIR + plugin-config.json

Cursor

~/.cursor/skills/memory-vault

~/.cursor/mcp.json (mcpServers.memory_vault)

MEMORY_VAULT_DIR + plugin-config.json

DSH

~/.dsh/skills/memory-vault

Native Skill / CLI tools

plugin-config.json

All card writes, index rebuilds, corrections, and installer config updates use writeFileAtomic() (same-directory temporary file + renameSync with transient lock retry) for safe concurrent access across clients.

Installation

Requires Node.js >= 20 (no npm install needed; Node.js >= 22.15.0 is optional if you want memory_harvest to decompress .zst/.zstd session logs via built-in zlib.zstdDecompressSync).

Auto-Detect Installed Clients

git clone https://github.com/ylx9000/anchordex.git
cd anchordex

# Install only into frameworks already present on this machine
node scripts/install.mjs --target auto

# Read-only status check: vault counts, MCP registration, and path alignment
node scripts/install.mjs --status

Target-Specific & Custom Vault Options

node scripts/install.mjs --target antigravity
node scripts/install.mjs --target claude
node scripts/install.mjs --target codex
node scripts/install.mjs --target cursor
node scripts/install.mjs --target dsh
node scripts/install.mjs --target all

# Point all detected clients to a custom shared vault (syncs plugin-config.json)
node scripts/install.mjs --target auto --vault ~/notes/agent-memory

# Standalone Agent Skill only (no MCP config edits)
node scripts/install.mjs --target skill --skill-dir ~/.agents/skills/memory-vault --no-mcp

# Remove AnchorDex skill bundles and MCP registrations (preserves ~/.memory-vault)
node scripts/install.mjs --uninstall --target auto

Agent Skills CLI (npx skills)

npx skills add ylx9000/anchordex

npx skills add installs the standalone Agent Skill and CLI fallback scripts (initializing ~/.memory-vault/ automatically on first use). Run node scripts/install.mjs --target auto if you also want automatic MCP server registration (Claude Code, Codex CLI, Cursor) and Antigravity lifecycle hooks (PreInvocation, PostToolUse, Stop).

Customization & Session Harvesting

  • 00-System/routes.json (routes.json.example): Pin custom task-to-card routes at the top of INDEX.md.

  • 00-System/synonyms.json (synonyms.json.example): Extend strict alias groups, weak associations, and generic stop-guard terms.

  • memory_harvest (memory-harvest.mjs): Scans recent Claude Code, Codex CLI, Antigravity (transcript_full.jsonl / transcript.jsonl), and DSH logs for user corrections and repeated tool errors.

Verification

npm test            # Isolated E2E suite (MCP, hooks, atomic writes, multi-client install, cold start)
npm run test:eval   # EN/CJK precision, abstention benchmark, and in-place cache invalidation
npm run check       # UTF-8 no-BOM, LF line endings, version parity, and secret scan
npm run status      # Read-only cross-client Vault status report

License

MIT © ylx9000

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Provides long-lived, cross-project technical memory for AI agents via markdown cards stored in git and indexed by SQLite, enabling search, retrieval, and human-reviewed knowledge management.
      5
      1,364 npm
      1
      ISC
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI coding agents to persist project memory across sessions by compiling decisions, progress, and pitfalls into git-linked, evidence-backed entries. It lets clients add, query, inject, scan for stale, check assertions on, and compute ROI of those memories over stdio.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables coding agents to store, search, and retrieve long-term memory as plain Markdown files with a disposable SQLite index, including note management, decision/bug tracking, and codebase symbol lookup via MCP.
      8
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Gives coding agents a persistent memory by searching a local, read-only index of existing markdown and letting them write findings back as notes that the next session can retrieve. It serves ranked, context-sized results over MCP, injects standing conventions at session start, and keeps data on your machine with secret redaction and archive-only deletion.
      MIT