Skip to main content
Glama
README.md
# AIMemory

[![CI](https://github.com/MiaoBiao/AI-Memory/actions/workflows/ci.yml/badge.svg)](https://github.com/MiaoBiao/AI-Memory/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](./LICENSE)
[![MiaoBiao/AI-Memory MCP server](https://glama.ai/mcp/servers/MiaoBiao/AI-Memory/badges/score.svg)](https://glama.ai/mcp/servers/MiaoBiao/AI-Memory)

**Zero-Cloud, Git-Native Shared Long-Term Memory + Local MCP Server for Every AI Coding Harness.**

[简体中文](./README.zh-CN.md) | [AI Harness Integration Guide](./docs/harnesses.md)

Switch freely between **Antigravity, Codex, Claude Code, Gemini CLI, GitHub Copilot, Cursor, OpenCode / DeepSeek Harness, and Windsurf** — across multiple devices and parallel module conversations — without losing your engineering rules, project architecture, or hard-won pitfalls.

---

## Why AIMemory?

```mermaid
flowchart LR
    A1["Antigravity"] --> GW["Unified Entrypoint<br/>(Idempotent Marker / Local stdio MCP)"]
    A2["Codex"] --> GW
    A3["Claude Code"] --> GW
    A4["Gemini CLI / Copilot / Cursor"] --> GW
    A5["OpenCode / DeepSeek Harness"] --> GW
    GW --> MEM["Your Private Git Memory Repo<br/>(Markdown, Zero Vendor Lock-In)"]
    MEM --> L1["RULES.md + profile.md<br/>(Global Principles)"]
    MEM --> L2["projects/&lt;app&gt;/overview.md<br/>(Architecture + Related-Module Graph)"]
    MEM --> L3["projects/&lt;app&gt;/modules/*.md<br/>(Per-Module Isolation)"]
```

| Dimension | AIMemory (Git + Markdown + Local MCP) | Cloud / Heavy Vector Memory Engines |
| :--- | :--- | :--- |
| **Determinism** | **100% deterministic** core rules & module loading | Probabilistic top-K vector recall (may miss critical rules) |
| **Privacy & Compliance** | 100% local + your own Private Git repo; built-in secret blocker | Often requires uploading project context to third-party SaaS |
| **Extra Token Cost** | **$0** — zero background LLM extraction, zero Ollama/GPU needed | Consumes extra LLM/embedding tokens on every ingest |
| **Audit & Rollback** | Native `git diff`, pre-commit secret scan, instant rollback | Opaque vector/graph store |
| **Parallel Conversations** | 3-layer isolation (`profile` → `overview` → `modules/<m>.md`) + file locks | Shared mutable store prone to cross-module noise |

---

## Architecture: Code & Data Strictly Separated

- **This repo (`AIMemory`, Public)**: Contains only the reusable **template** (`template/`), **cross-platform setup/sync scripts** (`scripts/`), the **TypeScript local stdio MCP server** (`mcp-server/`), and a standard **Agent Skill** (`skills/ai-memory/SKILL.md`).
- **Your private memory repo (Private, e.g. `~/AI-MEMORY` or `D:\AI-MEMORY`)**: Stores your actual preferences, project overviews, and module memories. Mount it dynamically via `--root <path>`.

---

## Quick Start (1 Command)

### 1. Initialize Your Private Memory Repo & Connect Harnesses

Pass `-Init` (`--init`) to automatically copy `template/` into a fresh **private** Git repository, connect your AI harnesses idempotently (preserving existing rules via `<!-- BEGIN/END: ai-memory -->`), and `-PrintMcp` (`--print-mcp`) to print exact MCP config snippets with your real local paths:

```powershell
# Windows PowerShell: preview first (no files touched)
.\scripts\setup.ps1 -Init -MemoryRoot D:\AI-MEMORY -AutoDetect -PrintMcp -DryRun

# Apply and print exact MCP configs
.\scripts\setup.ps1 -Init -MemoryRoot D:\AI-MEMORY -Targets antigravity,codex,claude,copilot,opencode -PrintMcp
```

macOS / Linux:

```bash
chmod +x scripts/setup.sh scripts/sync.sh
./scripts/setup.sh --init --memory-root ~/AI-MEMORY --auto-detect --print-mcp --dry-run
./scripts/setup.sh --init --memory-root ~/AI-MEMORY --targets antigravity,codex,claude,opencode --print-mcp
```

### 2. Enable the Optional Local MCP Server (Zero Native Dependencies)

```bash
cd mcp-server
npm install
npm run build
npm test
```

Point any MCP-capable harness to:

```text
node /path/to/AIMemory/mcp-server/dist/src/index.js --root /path/to/your-private-memory
```

See [docs/harnesses.md](./docs/harnesses.md) for copy-paste configs for **Antigravity, Codex, Claude Code, Gemini CLI, GitHub Copilot, Cursor, OpenCode/DeepSeek, Windsurf, and Cline**.

---

## MCP Tools (6) & Prompts (5) Included

| Tool | Purpose |
| :--- | :--- |
| `get_core_context(project?)` | Load `RULES.md`, `profile.md`, and optionally `projects/<project>/overview.md` |
| `list_memory_index(project?)` | Return all projects, module index, `Last Verified` dates, and related-module edges |
| `get_module_memory(project, module, include_related?)` | Load a module by filename or display name and auto-load related modules from `overview.md` |
| `search_memory(query, project?, limit?, include_archive?)` | Bilingual (CJK + English) BM25 weighted search across all memory files (< 5 ms, zero external deps) |
| `save_memory(...)` | Safe writer with **secret redline blocking**, **cross-process file locking**, **UTF-8/LF normalization**, and automatic `Last Verified` date stamping |
| `get_workflow_guide(action, project?, module?)` | **Zero-path trigger for old/new chats**: returns self-contained rules, templates, and context for `bootstrap_module`, `consolidate_project`, `takeover_module`, `new_module`, or `distill_memory` |

> Also ships with 5 **MCP Prompts** (`bootstrap-module`, `consolidate-project`, `takeover-module`, `new-module`, `distill-memory`), exposed as `/` slash commands in clients that support MCP Prompts.

---

## Daily Workflow: Short Commands

Once connected, use concise triggers in any supported harness:

- **Take over an existing module**: `接手 <project>/<module>:<task>` or `takeover <project>/<module>: <task>`
- **Build a new module**: `新模块 <project>/<new-module>:<task>` or `new-module <project>/<new-module>: <task>`
- **Distill & save memory**: `沉淀` / `记记忆` or `distill` / `remember`

Then review and sync your private memory repo across devices safely:

```powershell
.\scripts\sync.ps1 -MemoryRoot D:\AI-MEMORY
# Order: git status -> git diff -> secret scan -> git commit -> git pull --rebase -> git push
```

---

## Bootstrapping an Existing Project (One-Line Cold Start)

Detailed cold-start instructions live in on-demand `guides/bootstrap.md` (zero extra context cost in daily chats). Use one line depending on your setup:

| Setup | Step 1: Extract a module from an existing chat | Step 2: Consolidate `overview.md`, edges & `profile.md` |
| :--- | :--- | :--- |
| **MCP enabled (with `/` Prompts)** | Type `/` → `bootstrap-module` (`project`, `module`) | Type `/` → `consolidate-project` (`project`) |
| **MCP enabled (any client / old chats)** | `Use ai-memory to bootstrap <project>/<module>` | `Use ai-memory to consolidate <project>` |
| **Pure Markdown (new chat)** | `bootstrap <project>/<module>` | `consolidate <project>` |
| **Pure Markdown (old chat before setup)** | `Follow D:\AI-MEMORY\RULES.md: bootstrap <project>/<module>` | `Follow D:\AI-MEMORY\RULES.md: consolidate <project>` |

---

## License

[MIT](./LICENSE)

TDQS

A3.7/5.0

Scored across 6 tools

Disambiguation4/5

Most tools target clearly distinct operations: read core context, list index, read a module, search, save, and get workflow guide. The main ambiguity is between get_core_context (reads RULES.md/profile/overview) and get_workflow_guide (returns self-contained rules, templates, and context), which both deliver rules/context and could be confused by an agent. Descriptions do help differentiate their intended triggers, but the boundary is not fully crisp.

Naming Consistency5/5

All six tools follow a consistent verb_noun snake_case pattern: get_core_context, get_module_memory, get_workflow_guide, list_memory_index, search_memory, save_memory. Verbs (get/list/search/save) are used predictably and no conventions are mixed.

Tool Count5/5

Six tools is well-scoped for a local memory repository server, covering read, list, search, write, and workflow guidance without bloat. Each tool has a distinct role and none feels redundant or trivial.

Completeness3/5

Read/list/search/write (create+update) are covered via get_core_context, list_memory_index, get_module_memory, search_memory, and save_memory. However, there is no delete or remove-memory operation, and save_memory explicitly does not handle git commit/push, leaving lifecycle gaps an agent must work around manually. These notable missing operations prevent a higher completeness score.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues