# 🏰 dsh-memory-fortress · Memory Fortress for DeepSeek Harness

> **Give your AI cross-session long-term memory, self-evolution, and a local knowledge graph — one package, zero core modifications, install & go.**

**English** | [中文](README.md)

---

## What is this? (30-second intro)

**Memory Fortress** bundles three cooperating capabilities into a single DSH plugin:

| Capability | What it does |
|---|---|
| 🧠 **5-track layered memory** | Long-term memory / user profile / project key-memory / project journal / daily journal — the agent distills conversations into durable memory automatically |
| 📊 **Knowledge graph** | Local SQLite + FTS5 full-text graph of entities, relations, tasks, skills and events |
| 🔄 **Self-evolution** | Turn-end memory review, skill auto-creation with quarantine review, 4-quadrant todos |
| 🌐 **External AI dispatch** | COI: hand tasks to kimi / codex / grok / hermes CLIs with memory injection |
| 💡 **Status pill** | Always-on memory status pill at the conversation input (green/yellow/red/gray) |
| 🛡️ **Data safety** | Before-write snapshots, turn-end entity extraction, snapshot rotation |

**All data stays 100% local** (Markdown + SQLite). No telemetry, no uploads.

---

## Install

```sh
dsh plugin --profile <your-profile> add dsh-memory-fortress
```

Then add `"dsh-memory-fortress"` to the `dsh.profile.bundles` array in the profile's `package.json` and restart DSH.

> **Dependencies**: the only runtime dependency is `better-sqlite3` (prebuilt binaries for Windows / macOS / Linux — no compilation needed).

---

## Components

### 1️⃣ dsh-memory-evolve — memory & self-evolution (core)

- **5-track memory**: `memory` (global facts) / `user` (profile) / `key` (auto-injected project memory, git-branch filtered) / `project` (per-cwd journal) / `daily` (daily log)
- **memory tool**: add / replace / remove / list / archive / expand
- **Turn-end review**: automatic memory review every N turns
- **Skills** (`skill_manage`): create → quarantine → approve → library
- **Todos** (`dtodo`): 4 quadrants, daily todos, overdue reminders
- **COI dispatch**: delegate tasks to external CLI agents
- **Web UI**: memory / skills / todos / prompts management

### 2️⃣ graph-memory — knowledge graph

- `gm_record` / `gm_search` / `gm_stats` / `gm_status`
- better-sqlite3 + FTS5, WAL mode, schema auto-migration
- Turn-end entity extraction hooks
- Data at `~/.dsh/graph-memory/graph-memory.db`

### 3️⃣ memory-status-pill — status pill

- Conversation-input status pill driven by a `ui_state` switch
- Write guards: `off` rejects writes, `readonly` allows reads only
- AUTO-07: turn-end auto entity extraction
- AUTO-09: throttled before-write snapshots (30s), max 20 snapshots

---

## Quick start

After install & restart, just talk to the agent:

```
"Remember this project uses pnpm, not npm"     → writes key-track memory
"How did we fix better-sqlite3 last time?"     → gm_search the graph
"Dispatch this task to kimi"                   → de_coi_dispatch
"What did I finish today?"                     → dtodo list
```

## Configuration

All settings live under **DSH Settings → Memory Evolve**. Advanced (`cordis.patch.yml`):

```yaml
- id: dsh-memory-evolve
  config:
    skillReviewEnabled: true

- id: graph-memory
  config:
    dbPath: ~/.dsh/graph-memory/graph-memory.db

- id: memory-status-pill
  config: {}
```

## Data & privacy

- All local: memories are Markdown files, the graph is a SQLite file
- Locations: `~/.dsh/memories/`, `~/.dsh/graph-memory/`, `~/.dsh/skills/`
- No telemetry; uninstalling never deletes your data

## Requirements

- DeepSeek Harness >= 0.1.1-rc.1
- Node.js >= 20
- A better-sqlite3 supported platform

## License

[MIT](LICENSE) — ownership: lib/graph-memory/, lib/status-pill/ and the packaging layer are original to this project; lib/memory-evolve/ bundles the third-party [dsh-memory-evolve] project (MIT (c) dsh-external, original license preserved). See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
