๐Ÿง  Cognitive Brain

> **่ทจไผš่ฏ่ฎฐๅฟ†ไธŽ่ฎค็Ÿฅ็ณป็ปŸ v5.0** | Cross-Session Memory & Cognition System

3,891 stars

Best use case

๐Ÿง  Cognitive Brain is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

> **่ทจไผš่ฏ่ฎฐๅฟ†ไธŽ่ฎค็Ÿฅ็ณป็ปŸ v5.0** | Cross-Session Memory & Cognition System

Teams using ๐Ÿง  Cognitive Brain should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/cognitive-brain/SKILL.md --create-dirs "https://raw.githubusercontent.com/openclaw/skills/main/skills/aboutyao/cognitive-brain/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/cognitive-brain/SKILL.md inside your project
  3. Restart your AI agent โ€” it will auto-discover the skill

How ๐Ÿง  Cognitive Brain Compares

Feature / Agent๐Ÿง  Cognitive BrainStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

> **่ทจไผš่ฏ่ฎฐๅฟ†ไธŽ่ฎค็Ÿฅ็ณป็ปŸ v5.0** | Cross-Session Memory & Cognition System

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# ๐Ÿง  Cognitive Brain

> **่ทจไผš่ฏ่ฎฐๅฟ†ไธŽ่ฎค็Ÿฅ็ณป็ปŸ v5.0** | Cross-Session Memory & Cognition System
> 
> ่ฎฉ AI ๆ‹ฅๆœ‰ๅƒไบบ็ฑปไธ€ๆ ท็š„่ฎฐๅฟ†ใ€ๆ€่€ƒๅ’Œ้ข„ๆต‹่ƒฝๅŠ›

**Version: 7.0.1** | **License: MIT**

---

## โœจ ๅŠŸ่ƒฝ็‰นๆ€ง | Features

| ๅŠŸ่ƒฝ | Feature | ๆ่ฟฐ |
|------|---------|------|
| ๐Ÿ”„ ๅฎžๆ—ถๅ…ฑไบซ | Real-time Sharing | ่ทจไผš่ฏๆฏซ็ง’็บง่ฎฐๅฟ†ๅŒๆญฅ |
| ๐Ÿง  ๅ››ๅฑ‚่ฎฐๅฟ† | Four-Layer Memory | ๆ„Ÿๅฎ˜/ๅทฅไฝœ/ๆƒ…ๆ™ฏ/่ฏญไน‰่ฎฐๅฟ†ๆžถๆž„ |
| ๐Ÿ’ญ ่‡ช็”ฑๆ€่€ƒ | Free Thinking | ้žไปปๅŠก้ฉฑๅŠจ็š„ๆ„่ฏ†ๆตๆ€่€ƒ |
| ๐Ÿ”ฎ ๆ™บ่ƒฝ้ข„ๆต‹ | Prediction | ้ข„ๆต‹็”จๆˆท้œ€ๆฑ‚๏ผŒ้ข„ๅŠ ่ฝฝ่ฎฐๅฟ† |
| ๐Ÿ“Š ๅฏ่ง†ๅŒ– | Visualization | ็Ÿฅ่ฏ†ๅ›พ่ฐฑใ€ๆ—ถ้—ด็บฟใ€ๆ‘˜่ฆ |
| ๐Ÿ”— ่”ๆƒณ็ฝ‘็ปœ | Association Network | ๆฆ‚ๅฟตๅ…ณ่”๏ผŒๆฟ€ๆดปๆ‰ฉๆ•ฃ็ฎ—ๆณ• |
| ๐Ÿ—๏ธ ๅˆ†ๅฑ‚ๆžถๆž„ | Layered Architecture | Domain/Repository/Service ๅˆ†ๅฑ‚่ฎพ่ฎก |
| ๐Ÿ”’ ไบ‹ๅŠกๅฎ‰ๅ…จ | Transaction Safety | UnitOfWork ็กฎไฟๆ•ฐๆฎไธ€่‡ดๆ€ง |
| ๐Ÿ“š ๅฎŒๆ•ดๆ–‡ๆกฃ | Documentation | API ๆ–‡ๆกฃ + ๆžถๆž„ๆ–‡ๆกฃ |
| โœ… ๆต‹่ฏ•่ฆ†็›– | Test Coverage | ่‡ชๅŠจๅŒ–ๆต‹่ฏ•ๅฅ—ไปถ |

---

## ๐Ÿš€ ๅฟซ้€Ÿๅผ€ๅง‹ | Quick Start

### ไธ€้”ฎๅฎ‰่ฃ… | Quick Install

```bash
# ๆ–นๅผ1: ClawHub ๅฎ‰่ฃ…๏ผˆๆŽจ่๏ผ‰
clawhub install cognitive-brain
cd ~/.openclaw/workspace/skills/cognitive-brain
npm run setup:auto    # ้žไบคไบ’ๆจกๅผ๏ผŒ่‡ชๅŠจๅฎ‰่ฃ…ๆ‰€ๆœ‰ไพ่ต–

# ๆ–นๅผ2: ๆ‰‹ๅŠจๅฎ‰่ฃ…
cd ~/.openclaw/workspace/skills/cognitive-brain
npm install
npm run setup         # ไบคไบ’ๅผ้…็ฝฎ
```

### ๅฎ‰่ฃ…ๆจกๅผ | Install Modes

| ๅ‘ฝไปค | ่ฏดๆ˜Ž |
|------|------|
| `npm run check` | ๆฃ€ๆŸฅ็ณป็ปŸไพ่ต–๏ผˆPostgreSQL, Redis, pgvector๏ผ‰ |
| `npm run setup` | ไบคไบ’ๅผๅฎ‰่ฃ…๏ผŒไผšๆ็คบ่พ“ๅ…ฅๆ•ฐๆฎๅบ“้…็ฝฎ |
| `npm run setup:auto` | ่‡ชๅŠจๅฎ‰่ฃ…๏ผŒไฝฟ็”จ้ป˜่ฎค้…็ฝฎ๏ผŒ่‡ชๅŠจๅฎ‰่ฃ…็ผบๅคฑไพ่ต– |
| `npm run setup:resume` | ไปŽๆ–ญ็‚นๆขๅคๅฎ‰่ฃ…๏ผˆๅฎ‰่ฃ…ๅคฑ่ดฅๅŽไฝฟ็”จ๏ผ‰ |
| `npm run health` | ๅฅๅบทๆฃ€ๆŸฅ |
| `npm run reset` | ้‡็ฝฎๆ•ฐๆฎๅบ“๏ผˆๆธ…็ฉบ่ฎฐๅฟ†๏ผŒไฟ็•™่กจ็ป“ๆž„๏ผ‰ |
| `npm run uninstall` | ๅธ่ฝฝ๏ผˆๆธ…็†ๆ•ฐๆฎๅบ“ใ€hooksใ€้…็ฝฎๆ–‡ไปถ๏ผ‰ |

### ๅฎ‰่ฃ…็‰นๆ€ง | Install Features

| ็‰นๆ€ง | ่ฏดๆ˜Ž |
|------|------|
| ๐Ÿ”„ ๆ–ญ็‚นๆขๅค | ๅฎ‰่ฃ…ๅคฑ่ดฅๅŽ่ฟ่กŒ `npm run setup:resume` ็ปง็ปญ |
| ๐Ÿ“‹ ๅฎ‰่ฃ…ๆ—ฅๅฟ— | ่ฎฐๅฝ•ๅˆฐ `install.log`๏ผŒไพฟไบŽๆŽ’ๆŸฅ้—ฎ้ข˜ |
| ๐Ÿ” ๅทฒๅฎ‰่ฃ…ๆฃ€ๆต‹ | ่‡ชๅŠจๆฃ€ๆต‹ๆ˜ฏๅฆๅทฒๅฎ‰่ฃ…๏ผŒ้ฟๅ…้‡ๅค |
| โšก ไธ€้”ฎๅฎ‰่ฃ… | `installCommand` ่‡ชๅŠจๆ‰ง่กŒๅฎŒๆ•ดๅฎ‰่ฃ…ๆต็จ‹ |

### ็ณป็ปŸ่ฆๆฑ‚ | Requirements

| ไพ่ต– | ็‰ˆๆœฌ | ๅฎ‰่ฃ…ๅ‘ฝไปค (Ubuntu) |
|------|------|-------------------|
| Node.js | >= 18 | `apt install nodejs npm` |
| PostgreSQL | >= 14 | `apt install postgresql` |
| Redis | >= 6 | `apt install redis-server` |
| pgvector | - | `apt install postgresql-16-pgvector` |

> ๐Ÿ’ก `npm run setup:auto` ไผš่‡ชๅŠจๅฎ‰่ฃ…่ฟ™ไบ›ไพ่ต–๏ผˆ้œ€่ฆ root ๆƒ้™๏ผ‰

### ๅŸบ็ก€ไฝฟ็”จ | Basic Usage

```javascript
const { CognitiveBrain } = require('./src/index.js');
const brain = new CognitiveBrain();

// ๅญ˜ๅ‚จ่ฎฐๅฟ†
const memory = await brain.encode('็”จๆˆท็š„้กน็›ฎๅซ Alpha', {
  type: 'conversation',
  importance: 0.8
});

// ๆฃ€็ดข่ฎฐๅฟ†
const memories = await brain.recall('้กน็›ฎ');

// ่Žทๅ–็ปŸ่ฎก
const stats = await brain.stats();
```

### CLI ๅทฅๅ…ท

```bash
# ็ผ–็ ่ฎฐๅฟ†
node scripts/core/encode.cjs "ๅ†…ๅฎน" -t conversation -i 0.8

# ๆฃ€็ดข่ฎฐๅฟ†
node scripts/core/recall.cjs --query "ๅ…ณ้”ฎ่ฏ" --limit 5

# ๅฅๅบทๆฃ€ๆŸฅ
node scripts/tools/health_check.cjs

# ่ฟ่กŒๆต‹่ฏ•
./tests/run.sh
```

---

## ๐Ÿ—๏ธ ๆžถๆž„ๆฆ‚่งˆ | Architecture

### v5.0 ๅˆ†ๅฑ‚ๆžถๆž„

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      API / CLI ๅฑ‚                           โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚
โ”‚  โ”‚  REST API  โ”‚  โ”‚   CLI      โ”‚  โ”‚   Hook     โ”‚            โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   Service ๅฑ‚                                โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚
โ”‚  โ”‚   Memory   โ”‚  โ”‚   Concept  โ”‚  โ”‚ Associationโ”‚            โ”‚
โ”‚  โ”‚   Service  โ”‚  โ”‚   Service  โ”‚  โ”‚   Service  โ”‚            โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                Repository ๅฑ‚                                โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚
โ”‚  โ”‚   Memory   โ”‚  โ”‚   Concept  โ”‚  โ”‚ Associationโ”‚            โ”‚
โ”‚  โ”‚ Repository โ”‚  โ”‚ Repository โ”‚  โ”‚ Repository โ”‚            โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
โ”‚                      UnitOfWork (ไบ‹ๅŠก)                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  Domain ๅฑ‚                                  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚
โ”‚  โ”‚   Memory   โ”‚  โ”‚   Concept  โ”‚  โ”‚ Associationโ”‚            โ”‚
โ”‚  โ”‚   Entity   โ”‚  โ”‚   Entity   โ”‚  โ”‚   Entity   โ”‚            โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              ๆŒไน…ๅฑ‚ | Persistence                           โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚
โ”‚  โ”‚  PostgreSQLโ”‚  โ”‚   Redis    โ”‚  โ”‚   Files    โ”‚            โ”‚
โ”‚  โ”‚  (ไธปๅญ˜ๅ‚จ)   โ”‚  โ”‚  (็ผ“ๅญ˜)     โ”‚  โ”‚  (้…็ฝฎ/ๆ—ฅๅฟ—)โ”‚            โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

### ่ฎพ่ฎกๅŽŸๅˆ™

1. **ๅ•ไธ€่Œ่ดฃ**: ๆฏไธชๆจกๅ—ๅชๅšไธ€ไปถไบ‹
2. **ไพ่ต–ๆณจๅ…ฅ**: ้€š่ฟ‡ๅ‚ๆ•ฐไผ ๅ…ฅไพ่ต–๏ผŒไธ็›ดๆŽฅๅˆ›ๅปบ
3. **ๆŽฅๅฃ้š”็ฆป**: ๆธ…ๆ™ฐ็š„ๆจกๅ—่พน็•Œ
4. **ไบ‹ๅŠกๅฎ‰ๅ…จ**: ๅคš่กจๆ“ไฝœๅŽŸๅญๆ€งไฟ่ฏ

---

## ๐Ÿง  ๅ››ๅฑ‚่ฎฐๅฟ†ๆจกๅž‹ | Four-Layer Memory

| ๅฑ‚็บง | Layer | Duration | Purpose | Description |
|------|-------|---------|---------|-------------|
| ๆ„Ÿๅฎ˜่ฎฐๅฟ† | Sensory | Milliseconds | Buffer | Transient sensory buffer for immediate perception |
| ๅทฅไฝœ่ฎฐๅฟ† | Working | Minutes~Hours | Active Processing | Active processing workspace for current tasks |
| ๆƒ…ๆ™ฏ่ฎฐๅฟ† | Episodic | Long-term | Experiences | Personal experiences and events with context |
| ่ฏญไน‰่ฎฐๅฟ† | Semantic | Long-term | Knowledge | Facts, concepts, and structured knowledge |

---

## ๐Ÿ“š ๆ ธๅฟƒ API

### CognitiveBrain

ไธปๅ…ฅๅฃ็ฑป๏ผŒๆไพ›็ปŸไธ€็š„ๆ“ไฝœๆŽฅๅฃใ€‚

```javascript
const { CognitiveBrain } = require('./src/index.js');
const brain = new CognitiveBrain();

// ็ผ–็ ่ฎฐๅฟ†
const memory = await brain.encode(content, {
  type: 'conversation',
  importance: 0.8,
  sourceChannel: 'qq'
});

// ๆฃ€็ดข่ฎฐๅฟ†
const memories = await brain.recall('ๅ…ณ้”ฎ่ฏ', { limit: 10 });

// ไบ‹ๅŠกๆ“ไฝœ
await brain.transaction(async (uow) => {
  // ๅคš่กจๅŽŸๅญๆ“ไฝœ
});

// ่Žทๅ–็ปŸ่ฎก
const stats = await brain.stats();
```

### ๅฎžไฝ“ๆจกๅž‹

#### Memory (่ฎฐๅฟ†)
```javascript
{
  id: 'uuid',
  content: '่ฎฐๅฟ†ๅ†…ๅฎน',
  type: 'episodic',
  importance: 0.5,
  sourceChannel: 'qq',
  role: 'user',
  entities: ['ๅ…ณ้”ฎ่ฏ'],
  emotions: { valence: 0, arousal: 0 },
  createdAt: Date,
  updatedAt: Date
}
```

#### Concept (ๆฆ‚ๅฟต)
```javascript
{
  id: 'uuid',
  name: 'ๆฆ‚ๅฟตๅ็งฐ',
  type: 'general',
  importance: 0.5,
  activation: 0.0,
  accessCount: 0
}
```

#### Association (ๅ…ณ่”)
```javascript
{
  id: 'uuid',
  fromId: 'ๆฆ‚ๅฟตA-ID',
  toId: 'ๆฆ‚ๅฟตB-ID',
  type: 'related',
  weight: 0.5
}
```

---

## ๐Ÿ”’ ไบ‹ๅŠก็ฎก็†

ไฝฟ็”จ UnitOfWork ๆจกๅผ็กฎไฟๆ•ฐๆฎไธ€่‡ดๆ€ง๏ผš

```javascript
const { UnitOfWork } = require('./src/repositories/UnitOfWork.js');
const { MemoryRepository } = require('./src/repositories/MemoryRepository.js');

// ่‡ชๅŠจไบ‹ๅŠก
await UnitOfWork.withTransaction(pool, async (uow) => {
  const memRepo = new MemoryRepository(uow.getQueryClient());
  const conceptRepo = new ConceptRepository(uow.getQueryClient());
  
  await memRepo.create(memory);
  await conceptRepo.create(concept);
  // ่‡ชๅŠจ commit ๆˆ– rollback
});
```

---

## ๐Ÿงช ๆต‹่ฏ•

```bash
# ่ฟ่กŒๆ‰€ๆœ‰ๆต‹่ฏ•
./tests/run.sh

# ่ฟ่กŒ็‰นๅฎšๆต‹่ฏ•
node tests/v5.test.cjs
node tests/db.test.cjs
node tests/memory.test.cjs

# ๅฅๅบทๆฃ€ๆŸฅ
node scripts/tools/health_check.cjs
```

---

## ๐Ÿ“– ๆ–‡ๆกฃ

- [API ๆ–‡ๆกฃ](./docs/README.md) - ๅฎŒๆ•ด API ๅ‚่€ƒ
- [ๆžถๆž„ๆ–‡ๆกฃ](./docs/ARCHITECTURE.md) - ๆžถๆž„่ฎพ่ฎก่ฏดๆ˜Ž

---

## ๐Ÿ”„ ๅ…ฑไบซๅทฅไฝœๅŒบ | Shared Workspace

### ๆ ธๅฟƒ่กจ | Core Tables

| ่กจๅ | ็”จ้€” | ่ฏดๆ˜Ž |
|------|------|------|
| `episodes` | ๆƒ…ๆ™ฏ่ฎฐๅฟ† | ๅญ˜ๅ‚จๅฏน่ฏๅ’Œไบ‹ไปถ |
| `concepts` | ๆฆ‚ๅฟต่Š‚็‚น | ๆๅ–็š„ๅฎžไฝ“ๅ’Œๅ…ณ้”ฎ่ฏ |
| `associations` | ๆฆ‚ๅฟตๅ…ณ่” | ๆฆ‚ๅฟต้—ด็š„ๅ…ณ็ณป |
| `system_memory` | ็ณป็ปŸ้…็ฝฎ | ๅ…จๅฑ€่ฎพ็ฝฎๅ’Œ็Šถๆ€ |

### Hook ้›†ๆˆ

่‡ชๅŠจ้›†ๆˆๅˆฐ OpenClaw ๆถˆๆฏๆต็จ‹๏ผš

```
็”จๆˆทๆถˆๆฏ โ†’ Hook(cognitive-recall) โ†’ ๆฃ€็ดข่ฎฐๅฟ† โ†’ ๆณจๅ…ฅไธŠไธ‹ๆ–‡ โ†’ AIๅ›žๅค โ†’ ็ผ–็ ่ฎฐๅฟ†
```

---

## ๐Ÿ”ง ้…็ฝฎ

```json
{
  "version": "5.3.25",
  "storage": {
    "primary": {
      "type": "postgresql",
      "host": "localhost",
      "port": 5432,
      "database": "cognitive_brain"
    },
    "cache": {
      "type": "redis",
      "host": "localhost",
      "port": 6379
    }
  }
}
```

---

## ๐Ÿ“ˆ ็‰ˆๆœฌๅކๅฒ

### v7.0.1 (2026-03-21)
- ๐Ÿ”ง **่ฎฐๅฟ†็ณป็ปŸ้‡ๆž„** - ไฟฎๅค Hook ่งฆๅ‘้—ฎ้ข˜๏ผŒๆ”น็”จ Cron ๆ–นๆกˆ
- โœจ **่ฎฐๅฟ†่ฏปๅ–** - `agent:bootstrap` Hook ๅณๆ—ถๆณจๅ…ฅ่ฎฐๅฟ†
- โœจ **่ฎฐๅฟ†ๅ†™ๅ…ฅ** - Cron ๆฏ 1 ๅˆ†้’Ÿๆ‰ซๆไผš่ฏๆ–‡ไปถ
- ๐Ÿ—‘๏ธ **ๆธ…็†ๆ— ็”จ่„šๆœฌ** - ๅˆ ้™ค 20+ ไธๅธธ็”จ่„šๆœฌ
- ๐Ÿ“ **ๆ–‡ๆกฃๆ›ดๆ–ฐ** - ็ฎ€ๅŒ–ๆžถๆž„่ฏดๆ˜Ž

### v5.3.32 (2026-03-21)
- ๐Ÿ› **ไฟฎๅค็ฑปๅž‹้ชŒ่ฏ** - `type: 'conversation'` ๆ”นไธบๆœ‰ๆ•ˆ็ฑปๅž‹ `'episodic'`
- ๐Ÿ› **ไฟฎๅค Embedding ่ทฏๅพ„** - embed.py ่ทฏๅพ„้”™่ฏฏๅฏผ่‡ด embedding ็”Ÿๆˆๅคฑ่ดฅ

### v5.3.22 (2026-03-20)
- ๅ‘ๅธƒ็‰ˆๆœฌๆ›ดๆ–ฐ

### v5.3.11 (2026-03-18)
- ๐Ÿงช **ๆต‹่ฏ•่ฆ†็›–็އๆๅ‡** - ๆ–ฐๅขž Repository/Service/API ๆต‹่ฏ• (7ไธชๆต‹่ฏ•ๆ–‡ไปถ)
- ๐Ÿงน **ไบ‹ไปถ็›‘ๅฌๅ™จๆธ…็†** - ไผ˜้›…ๅ…ณ้—ญๆ—ถๆธ…็†ๆ‰€ๆœ‰็›‘ๅฌๅ™จ๏ผŒ้˜ฒๆญขๅ†…ๅญ˜ๆณ„ๆผ
- ๐Ÿ’“ **WebSocket ๅฟƒ่ทณ** - 30็ง’ ping/pong ๆฃ€ๆต‹๏ผŒ120็ง’ๆ— ๅ“ๅบ”่‡ชๅŠจๆ–ญๅผ€
- โšก **N+1 ๆŸฅ่ฏขไผ˜ๅŒ–** - ๆ‰น้‡ๆ’ๅ…ฅไปŽ O(N) ไผ˜ๅŒ–ไธบ O(1)
- ๐Ÿ”’ **API ้€Ÿ็އ้™ๅˆถ** - 100 req/min ้™ๆตไฟๆŠค

### v5.3.7 (2026-03-18)
- ๐Ÿ—‘๏ธ **ๅˆ ้™ค้‡ๅคๆ–‡ๆกฃ** - ๅˆ ้™ค README.md๏ผŒ็ปŸไธ€ๆ–‡ๆกฃๅ…ฅๅฃ
- ๐Ÿ”ง **็ปŸไธ€ไปฃ็ ่ง„่Œƒ** - ไฟฎๅค 80+ ๆ–‡ไปถ็ผบๅฐ‘ๆข่กŒ็ฌฆ
- ๐Ÿ”ง **็ปŸไธ€ Logger** - Winston logger ๆ›ฟไปฃ console.log
- ๐Ÿ”’ **ไบ‹ๅŠกๅฎ‰ๅ…จ** - ้š”็ฆป็บงๅˆซ + ๆญป้”้‡่ฏ• + ็†”ๆ–ญๅ™จ
- โš™๏ธ **้…็ฝฎๅขžๅผบ** - ่ฟžๆŽฅๆฑ ๅฏ้…็ฝฎ + ๆ—ฅๅฟ—้…็ฝฎ

### v5.3.20 (2026-03-19)
- โœจ **ๅฎ‰่ฃ…ๆต็จ‹ไผ˜ๅŒ–** - ้žไบคไบ’ๆจกๅผใ€ๆ–ญ็‚นๆขๅคใ€ๅฎ‰่ฃ…ๆ—ฅๅฟ—
- โœจ **Skill.json installCommand** - ๆ”ฏๆŒไธ€้”ฎ่‡ชๅŠจๅฎ‰่ฃ…
- โœจ **ๅธ่ฝฝ่„šๆœฌ** - `npm run uninstall` ๆธ…็†ๆ‰€ๆœ‰็ป„ไปถ
- โœจ **้‡็ฝฎ่„šๆœฌ** - `npm run reset` ๆธ…็ฉบ่ฎฐๅฟ†ๆ•ฐๆฎ
- ๐Ÿ”ง **ไฟฎๅค create_indexes.cjs** - ๆจกๅ—่ทฏๅพ„้”™่ฏฏ
- ๐Ÿ”ง **ไฟฎๅค health_check.cjs** - SQL ่ฏญๆณ•้”™่ฏฏ
- ๐Ÿ“ **ๆ–‡ๆกฃๆ›ดๆ–ฐ** - ๅฎ‰่ฃ…ๆŒ‡ๅ—ใ€ๅ‘ฝไปค่ฏดๆ˜Ž

### v5.0.0 (2026-03-18)
- โœจ ้‡ๆž„ไธบๅˆ†ๅฑ‚ๆžถๆž„ (Domain/Repository/Service)
- โœจ ๆทปๅŠ  UnitOfWork ไบ‹ๅŠก็ฎก็†
- โœจ ๆทปๅŠ ้ข†ๅŸŸๆจกๅž‹้ชŒ่ฏ
- โœจ ๆทปๅŠ ๆต‹่ฏ•ๆก†ๆžถ (13ไธชๆต‹่ฏ•)
- โœจ ๆทปๅŠ ็ปŸไธ€ๆ—ฅๅฟ—ๆจกๅ—
- โœจ ๆทปๅŠ ้…็ฝฎ็ฎก็†ๅ™จ
- โœ… ไฟฎๅค Pool ่ฟžๆŽฅๆณ„ๆผ
- โœ… ไฟฎๅค็ฉบ catch ๅ—
- โœ… ็งป้™คๆ–‡ไปถ fallback๏ผŒๅผบๅˆถๆ•ฐๆฎๅบ“ไผ˜ๅ…ˆ

### v4.1.0 (Previous)
- ๅŸบ็ก€่ฎฐๅฟ†ๅŠŸ่ƒฝ
- ่”ๆƒณ็ฝ‘็ปœ
- ้ข„ๆต‹้ข„ๅŠ ่ฝฝ
- ๅฟƒ่ทณๅๆ€
- ่‡ช็”ฑๆ€่€ƒ

---

## ๐Ÿค ่ดก็Œฎ

1. Fork ไป“ๅบ“
2. ๅˆ›ๅปบๅˆ†ๆ”ฏ (`git checkout -b feature/xxx`)
3. ๆไบคไฟฎๆ”น (`git commit -m 'Add feature'`)
4. ๆŽจ้€ๅˆ†ๆ”ฏ (`git push origin feature/xxx`)
5. ๅˆ›ๅปบ Pull Request

---

## ๐Ÿ“„ ่ฎธๅฏ

MIT License

---

**่ฎฉ AI ๆ‹ฅๆœ‰่ฎฐๅฟ†๏ผŒ่ฎฉๅฏน่ฏๆ›ดๆœ‰ๆธฉๅบฆ** โค๏ธ

Related Skills

superpowers-brainstorming

3891
from openclaw/skills

Use before any creative work - creating features, building components, adding functionality, or modifying behavior - guides through exploration, questioning, design proposal, and spec documentation before any implementation

brainstorming

3891
from openclaw/skills

Facilitates structured ideation sessions for features, products, content, and strategy. Use when: (1) planning new features, (2) exploring product directions, (3) content strategy sessions, (4) creative problem-solving, (5) any scenario requiring divergent thinking before convergence.

bmad-brainstorming-coach

3891
from openclaw/skills

ๆฟ€ๆดป BMad ็ณป็ปŸ็š„ "Brainstorming Coach" ไปฃ็†๏ผˆCarson๏ผ‰๏ผŒ็”จไบŽๅผ•ๅฏผๅˆ›ๆ–ฐๅทฅไฝœๅŠใ€ๅคด่„‘้ฃŽๆšดไผš่ฎฎๅ’Œๅˆ›ๆ„ๆฟ€ๅ‘ใ€‚้€‚็”จไบŽ้œ€่ฆๆ‰“็ ดๅธธ่ง„ๆ€็ปดใ€็”Ÿๆˆๅคง้‡ๅˆ›ๆ„ใ€ๆˆ–่€…่ฟ›่กŒ็ณป็ปŸๆ€งๅˆ›ๆ–ฐๆŽข็ดข็š„ๅœบๆ™ฏใ€‚

super-brain

3891
from openclaw/skills

AI่‡ชๆˆ‘ๅขžๅผบ็ณป็ปŸ - ่ฎฉAI่ทจไผš่ฏ่ฎฐไฝ็”จๆˆทใ€ๆŒ็ปญ่ฟ›ๅŒ–ใ€‚ๅฝ“้œ€่ฆ้•ฟๆœŸ่ฎฐๅฟ†็”จๆˆทๅๅฅฝใ€่ฟฝ่ธชๅฏน่ฏๅކๅฒใ€ๅญฆไน ๆœๅŠกๆŠ€ๅทงใ€ไธปๅŠจๆไพ›ไธชๆ€งๅŒ–ๆœๅŠกๆ—ถไฝฟ็”จๆญคๆŠ€่ƒฝใ€‚

model-brain

3891
from openclaw/skills

Route each incoming message to the right Bankr/OpenClaw model or to a zero-LLM path based on task type, risk, and cost. Use when you need per-message model selection, cost-aware routing, deterministic skill bypasses, or a model recommendation for aaigotchi workflows.

my-brain-is-full-crew

3823
from openclaw/skills

A team of 10 AI agents that manage your Obsidian vault for knowledge, nutrition, and mental wellness using Claude Code

๏ปฟ---

3891
from openclaw/skills

name: article-factory-wechat

Content & Documentation

humanizer

3891
from openclaw/skills

Remove signs of AI-generated writing from text. Use when editing or reviewing text to make it sound more natural and human-written. Based on Wikipedia's comprehensive "Signs of AI writing" guide. Detects and fixes patterns including: inflated symbolism, promotional language, superficial -ing analyses, vague attributions, em dash overuse, rule of three, AI vocabulary words, negative parallelisms, and excessive conjunctive phrases.

Content & Documentation

find-skills

3891
from openclaw/skills

Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.

General Utilities

tavily-search

3891
from openclaw/skills

Use Tavily API for real-time web search and content extraction. Use when: user needs real-time web search results, research, or current information from the web. Requires Tavily API key.

Data & Research

baidu-search

3891
from openclaw/skills

Search the web using Baidu AI Search Engine (BDSE). Use for live information, documentation, or research topics.

Data & Research

agent-autonomy-kit

3891
from openclaw/skills

Stop waiting for prompts. Keep working.

Workflow & Productivity