← Back to Plugins
Tools

Zettelkasten Second Memory

cx2002302-lang By cx2002302-lang ⭐ 1 stars 👁 56 views ▲ 0 votes

An OpenClaw plugin that turns AI conversations into a permanent Zettelkasten knowledge base โ€” atomic notes, bi-directional links, knowledge distillation, and intelligent retrieval.

Homepage GitHub

Install

npm install

#

README

<p align="center">
  <img src="docs/assets/zettelkasten-infographic.png" alt="Zettelkasten Second Memory" width="100%">
</p>

# ๐Ÿง  Zettelkasten Second Memory

> **An [OpenClaw](https://github.com/openclaw) plugin** that turns AI conversations into a permanent Zettelkasten knowledge base โ€” atomic notes, bi-directional links, knowledge distillation, and intelligent retrieval.

[English](README.md) ยท [็ฎ€ไฝ“ไธญๆ–‡](README.zh.md)

[![Version](https://img.shields.io/badge/version-v1.0.0--beta.3-blue.svg)](https://github.com/cx2002302-lang/zettelkasten-second-memory/releases)
[![OpenClaw](https://img.shields.io/badge/OpenClaw-2026.4.24-green.svg)](https://github.com/openclaw)
[![MCP Server](https://img.shields.io/badge/MCP-18%20Tools-orange.svg)](src/mcp/server.ts)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Node.js Version](https://img.shields.io/badge/node-%3E%3D22.14.0-blue.svg)](package.json)

---

## ๐Ÿ“Œ Current Version

| Component | Version | Status |
|-----------|---------|--------|
| Plugin | `v1.0.0-beta.3` | Active development |
| Skill | `v1.0.0-beta.2` | Active development |
| OpenClaw | `2026.4.24` | Developed & tested on 2026.4.24; compatible with >= 2026.4.23 |
| Node.js | `>= 22.14.0` | Required (for `node:sqlite`) |

**Latest Release**: [v1.0.0-beta.3](https://github.com/cx2002302-lang/zettelkasten-second-memory/releases/tag/v1.0.0-beta.3) โ€” Wave 3: Knowledge Heatmap & Network Graph

---

## โœจ Core Features

| Feature | Description |
|---------|-------------|
| ๐Ÿ“ **Atomic Notes** | Each note is an independent knowledge unit, supporting `atomic` / `structure` / `source` types |
| ๐Ÿ”— **Bi-directional Links** | 11 semantic link types (supports, refines, extends, contradicts, example-of...) to build a true knowledge graph |
| ๐Ÿ” **Full-text Search** | SQLite FTS5 + LIKE dual engine, supporting Chinese tokenization and fuzzy matching |
| ๐Ÿค– **AI Integration** | Deep MCP integration with OpenClaw, enabling AI agents to automatically capture conversation knowledge |
| ๐Ÿ”„ **Knowledge Distillation** | CEQRC pipeline automatically refines fragmented notes into permanent knowledge |
| ๐Ÿท๏ธ **Tag System** | Flexible tag classification and statistics, supporting tag-cloud analysis |
| ๐Ÿ“ฆ **Markdown Native** | All notes stored as Markdown, your data belongs entirely to you |
| ๐ŸงŸ **Zombie Detection** | Auto-detect stale notes (180+ days, zero backlinks) with `zk_find_zombies` |
| โœจ **Glow Ranking** | Knowledge importance scoring via PageRank + citation + recency decay |
| ๐Ÿ“ฆ **Archive System** | Move cold notes to `archive` folder; auto-archive nightly at 2:00 AM |
| ๐Ÿ“œ **Audit Log** | Full archive/unarchive history with `zk_get_archive_log` |
| ๐Ÿ”Ž **Path Discovery** | Weighted shortest path between any two notes with Chinese explanations |

---

> ๐Ÿ‡จ๐Ÿ‡ณ **Looking for Chinese documentation?** [็‚นๅ‡ป่ฟ™้‡ŒๆŸฅ็œ‹็ฎ€ไฝ“ไธญๆ–‡ไป‹็ป](README.zh.md)

---

## ๐Ÿ“ System Architecture

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    OpenClaw Gateway                      โ”‚
โ”‚                  (MCP Protocol Layer)                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Zettelkasten Plugin                         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚
โ”‚  โ”‚  MCP    โ”‚  โ”‚   CLI    โ”‚  โ”‚  Session    โ”‚            โ”‚
โ”‚  โ”‚ Tools   โ”‚  โ”‚ Commands โ”‚  โ”‚   Hook      โ”‚            โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
โ”‚       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                   โ”‚
โ”‚                         โ”‚                                โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”‚
โ”‚  โ”‚ Service  โ”‚ Repositoryโ”‚  Storage  โ”‚  Core    โ”‚        โ”‚
โ”‚  โ”‚ Layer    โ”‚  Layer    โ”‚  Layer    โ”‚  Types   โ”‚        โ”‚
โ”‚  โ”‚          โ”‚           โ”‚           โ”‚          โ”‚        โ”‚
โ”‚  โ”‚โ€ข Note    โ”‚โ€ข NoteRepo โ”‚โ€ข DB Schemaโ”‚โ€ข Types   โ”‚        โ”‚
โ”‚  โ”‚โ€ข Link    โ”‚โ€ข LinkRepo โ”‚โ€ข FTS5     โ”‚โ€ข Constantsโ”‚       โ”‚
โ”‚  โ”‚โ€ข CEQRC   โ”‚โ€ข TagRepo  โ”‚โ€ข Templatesโ”‚โ€ข Utils   โ”‚        โ”‚
โ”‚  โ”‚โ€ข Distill โ”‚โ€ข ReviewRepoโ”‚          โ”‚          โ”‚        โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ”‚
โ”‚                         โ”‚                                โ”‚
โ”‚                    SQLite + Markdown                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

---

> ๐Ÿ‡จ๐Ÿ‡ณ **Chinese users**: [็‚นๅ‡ป่ฟ™้‡ŒๆŸฅ็œ‹ไธญๆ–‡ไป‹็ป](README.zh.md)

---

## ๐Ÿš€ Quick Start

### Requirements

- **Node.js** >= 22.14.0 (requires built-in `node:sqlite`)
- **OpenClaw** `2026.4.24` (developed & tested on this version; compatible with >= 2026.4.23)

### Installation

```bash
# Clone the repository
git clone https://github.com/YOUR_USERNAME/zettelkasten-second-memory.git
cd zettelkasten-second-memory

# Install dependencies
npm install

# Run tests
npm test
```

### Use as an OpenClaw Plugin

```bash
# 1. Deploy the plugin
bash scripts/deploy.sh

# 2. Configure OpenClaw (edit ~/.openclaw/openclaw.json)
# Ensure plugins.load.paths includes the plugin path

# 3. Restart the Gateway
openclaw gateway restart

# 4. Initialize the database
openclaw zk init

# 5. Health check
openclaw zk doctor
```

### Use as a Standalone Library

```typescript
import { createZettelkasten } from "zettelkasten-second-memory";

// Create a client
const zk = await createZettelkasten("./data/zettelkasten.db", "./data");

// Create a note
const note = await zk.createNote({
  title: "Hello Zettelkasten",
  content: "This is my first atomic note.",
  tags: ["intro", "demo"],
  type: "atomic",
});

// Search
const results = zk.searchNotes("atomic note", 10);
console.log(results);
```

---

## ๐Ÿ› ๏ธ CLI Commands

| Command | Description |
|---------|-------------|
| `openclaw zk init` | Initialize database and directory structure |
| `openclaw zk doctor` | Run health checks |
| `openclaw zk status` | Show system status |
| `openclaw zk new` | Create a new note |
| `openclaw zk list` | List notes |
| `openclaw zk search <query>` | Search notes |
| `openclaw zk show <id>` | View note details |
| `openclaw zk link <from> <to>` | Create a note link |

---

## ๐Ÿงฉ MCP Tools (for AI Agents)

| Tool | Permission | Description |
|------|------------|-------------|
| `zk_search_notes` | Read | Full-text search for notes |
| `zk_get_note` | Read | Get a single note |
| `zk_get_backlinks` | Read | Get reverse links |
| `zk_find_path` | Read | Find paths between notes |
| `zk_create_note` | Write | Create a new note |
| `zk_update_note` | Write | Update a note |
| `zk_create_link` | Write | Create a note link |
| `zk_run_ceqrc` | Write | Run the cognitive pipeline |
| `zk_distill_memory` | Write | Distill session memories |
| `zk_review_note` | Write | Review a note |

---

## ๐Ÿ“ Project Structure

```
zettelkasten-second-memory/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ core/               # Type definitions, constants, utilities
โ”‚   โ”œโ”€โ”€ storage/            # Database schema, FTS5, template manager
โ”‚   โ”œโ”€โ”€ repository/         # Data access layer (notes, links, tags, reviews...)
โ”‚   โ”œโ”€โ”€ service/            # Business logic (CEQRC, distillation, deduplication...)
โ”‚   โ”œโ”€โ”€ integration/        # OpenClaw integration (agent config, scheduler, hooks)
โ”‚   โ”œโ”€โ”€ mcp/                # MCP tool definitions and server
โ”‚   โ”œโ”€โ”€ plugin/             # OpenClaw plugin entry and manifest
โ”‚   โ”œโ”€โ”€ skills/brain/       # AI Skill (prompts, rules, evolution scripts)
โ”‚   โ”œโ”€โ”€ examples/           # Usage examples
โ”‚   โ””โ”€โ”€ index.ts            # Library entry point
โ”œโ”€โ”€ scripts/                # Deployment scripts
โ”œโ”€โ”€ plans/                  # Design documents and architecture diagrams
โ”œโ”€โ”€ docs/                   # Documentation
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ LICENSE
โ””โ”€โ”€ README.md
```

---

## ๐Ÿง  Second Memory Skill (AI Integration)

This project includes a **Brain Skill** that enables AI agents to automatically save conversation knowledge into Zettelkasten:

```bash
# Install the Skill
cp -r src/skills/brain ~/.openclaw/skills/zettelkasten-brain

# Activate the Skill
openclaw config set agents.defaults.skills '["zettelkasten-brain"]'

# Restart the Gateway
openclaw gateway restart
```

Once activated, the AI will automatically:
- ๐Ÿ” Search the knowledge base before answering
- ๐Ÿ“ Recognize and save important information
- ๐Ÿ”— Intelligently establish note associations
- ๐Ÿ“ฆ Archive discussions when sessions end

---

## ๐Ÿ“Š Database Schema

The system uses SQLite. Core tables include:

| Table | Description |
|-------|-------------|
| `zettel_notes` | Main notes table (title, content, status, confidence...) |
| `zettel_links` | Bi-directional links table (11 semantic link types) |
| `zettel_tags` | Tags table |
| `zettel_note_tags` | Note-tag association table |
| `zettel_reviews` | Review records table |
| `zettel_feedback` | Feedback data table |
| `zettel_prompt_versions` | Prompt version table |
| `zettel_meta` | Metadata table |

FTS5 virtual tables provide full-text search capabilities.

---

## ๐Ÿงช Testing

```bash
# Run all tests
npm test

# Watch mode
npm run test:watch
```

Current test coverage:
- Repository layer (CRUD, search, links, tags)
- Service layer (CEQRC, distillation, deduplication, parsing)
- Integration layer (configuration, scheduling)
- MCP Server (tool registration and invocation)

---

## ๐Ÿ“œ License

[MIT](LICENSE) ยฉ Zettelkasten Contributors

---

## ๐Ÿ™ Acknowledgements

- Inspired by [Niklas Luhmann](https://en.wikipedia.org/wiki/Niklas_Luhmann)'s Zettelkasten method
- Built on the [OpenClaw](https://github.com/openclaw) plugin architecture
- Uses SQLite FTS5 for full-text search
tools

Comments

Sign in to leave a comment

Loading comments...