---
name: persistent-memory
description: "Persistent memory and context management across sessions. Self-hosted on user's VPS (mixpresso.top). Uses PocketBase + Qdrant for storage and semantic search. Use when user says: remember this, save this for later, what did we do last time, recall our conventions, save credential, what do you know about X, or starts a new session on an existing project."
---

# Persistent Memory — Self-Hosted Brain

All memory is stored on the user's self-hosted VPS. No 3rd party services. No Pastebin. No GitHub Gist. No rate limits. No token expiry.

**Backend:** PocketBase (structured storage) + Qdrant (semantic vector search)

---

## Architecture: 12 Collections

### Always Loaded (every session):
- **identity** — WHO the user is (personality, preferences, rules, background)
- **secrets_vault** — ALL credentials, passwords, API keys, server info

### Life Areas (ongoing, no end date):
- **area_tech** — Technology, servers, tools, infrastructure
- **area_business** — Work, business ideas, revenue, clients
- **area_people** — Relationships, contacts, people mentioned
- **area_personal** — Health, lifestyle, interests, hobbies

### Per-Project (isolated per chat):
- **projects** — Per-chat/project memory (context, state, conventions)

### Knowledge Base (searchable on demand):
- **facts** — Learned facts and knowledge
- **episodes** — Session summaries and history
- **decisions** — Key decisions and reasoning
- **ideas** — Brainstorms, plans, future ideas
- **archive** — Completed/abandoned items

---

## Auto-Setup (MUST RUN FIRST in Every New Sandbox)

BEFORE doing ANYTHING with memory, ALWAYS run this bootstrap command first. This downloads the latest scripts from the user's server and ensures everything is up to date:

```bash
python3 -c "import sys; sys.path.insert(0,'/home/ubuntu/skills/persistent-memory/scripts'); from brain_client import BOOTSTRAP_URL; import subprocess; subprocess.run(['bash','-c',f'curl -s http://{BOOTSTRAP_URL}/install.sh | bash'])"
```

This single command:
1. Downloads the latest brain_client.py, manage_memory.py, brain.py, brain_learn.py
2. Downloads the latest SKILL.md files
3. Removes any old Pastebin/Gist scripts if they exist
4. Verifies server connection

After bootstrap, verify connection:

```python
import sys
sys.path.insert(0, str(__import__('pathlib').Path.home() / "skills/persistent-memory/scripts"))
from brain_client import status
s = status()
assert s['pocketbase'] == 'healthy' and s['mem0'] == 'healthy'
```

No tokens. No config files. No API keys. Just HTTP to the user's own server.

---

## Core Isolation Rule

Each project has its own record in the `projects` collection, identified by `chat_id`. Loading memory for one project NEVER loads another project's context. If the user switches topics mid-session, ask: "Should I load a different project's memory, or are we staying in [current project]?"

---

## Starting a New Project (First Session)

Say "initialize memory for [project-name]" and Manus will:

```bash
python3 manage_memory.py save [project-id] [project-name] purpose "[description]"
```

Then ask setup questions:
1. What is this project about?
2. What tech stack are you using?
3. What conventions should I always follow?
4. What is the current state?
5. Any important decisions already made?

Save each answer to the appropriate field.

---

## Returning to an Existing Project

Say "load my memory for [project-name]" and Manus will:

```bash
python3 manage_memory.py load [project-id]
```

This pulls the full project record from PocketBase. No local files needed. Works from any sandbox, any session.

---

## Saving During a Session

Say "save this to memory: [note]" or "remember this":

```bash
python3 manage_memory.py save [project-id] [project-name] current_state "[note]"
```

For credentials:
```bash
python3 manage_memory.py save-secret [name] [value] [category] [service] [notes]
```

For decisions:
```bash
python3 manage_memory.py save-decision "[decision] | [reasoning]"
```

---

## Auto-Nudge (Runs Automatically)

After significant conversation exchanges, run:

```bash
python3 manage_memory.py nudge [project-id] [project-name] "[conversation excerpt]"
```

This automatically extracts and saves:
- Passwords, API keys, IPs → secrets_vault
- Decisions → decisions collection
- Preferences → identity collection
- People mentioned → area_people

---

## Semantic Search

Say "what do you know about [topic]":

```bash
python3 manage_memory.py search "[query]"
python3 manage_memory.py search "[query]" [collection]  # search specific collection
```

Returns results ranked by semantic relevance across all collections.

---

## Session End

Say "compress and save this session":

```bash
python3 manage_memory.py save-episode [project-id] [project-name] "[summary of what happened]"
```

---

## All Commands Reference

**Project memory:**
```bash
python3 manage_memory.py save <chat_id> <chat_name> <field> <content>
python3 manage_memory.py save-full <chat_id> <chat_name> <json_file>
python3 manage_memory.py load <chat_id>
```

**Identity / Brain:**
```bash
python3 manage_memory.py save-brain <section> <content>
python3 manage_memory.py load-brain
```

**Secrets:**
```bash
python3 manage_memory.py save-secret <name> <value> [category] [service] [notes]
python3 manage_memory.py load-secrets
```

**Life areas:**
```bash
python3 manage_memory.py save-area <tech|business|people|personal> <topic> <content>
```

**Knowledge:**
```bash
python3 manage_memory.py save-fact <category> <fact>
python3 manage_memory.py save-decision <decision> | <reasoning>
python3 manage_memory.py save-idea <category> <title> | <description>
python3 manage_memory.py save-episode <chat_id> <chat_name> <summary>
```

**Search and status:**
```bash
python3 manage_memory.py search <query> [collection]
python3 manage_memory.py status
python3 manage_memory.py nudge <chat_id> <chat_name> <content>
```

---

## Trigger Words

| User says | Action |
|---|---|
| "remember this" / "save memory" / "save this" | Save to current project |
| "save to brain" / "update my profile" | Save to identity |
| "remember this password" / "save credential" | Save to secrets_vault |
| "save decision" | Save to decisions |
| "save idea" | Save to ideas |
| "save fact" | Save to facts |
| "load my memory for X" | Load project X |
| "load brain" / "who am I to you" | Load identity |
| "load secrets" / "what are my credentials" | Load vault |
| "what do you know about X" | Semantic search all |
| "status" / "brain status" | Show connection + record counts |

---

## Best Practices

- Name projects clearly (e.g., `screenconnect-setup`, `skills-chat`, `business-ideas`)
- Run auto-nudge after conversations with important info
- Use semantic search when you can't remember which collection something is in
- Everything persists on the server — no local files needed, no backup commands needed
- Server is portable: all data in /data/ on VPS, can tar and move to any new server
