PBrain is a lean local knowledge base for people who want durable memory without running a second-brain lab.
It stores structured notes, decisions, patterns, project context, and distilled session signals in SQLite. It is CLI-first, serverless by default, and designed to sit beside an agent or personal workflow without slowing it down.
PBrain is inspired by Garry Tan's GBrain idea: keep a personal source of truth that an agent can query, update, and reason from. The difference is scope. PBrain keeps the useful part and removes the machinery that makes personal knowledge systems heavy: no graph-first architecture, no always-on service, no mandatory vector store, no review queue, no scoring layer.
- Stores structured personal knowledge in a local SQLite database.
- Searches entries with SQLite FTS.
- Captures durable context from chat/session logs through a configured distiller.
- Requires source snippets for distilled entries, so generated memories keep provenance.
- Exports readable markdown pages for inspection or backup.
- Offers an optional local HTTP API for lightweight integrations.
- Provides an optional Hermes plugin bridge with explicit tools only.
- It does not dump raw transcripts into memory.
- It does not store secrets.
- It does not run as a server unless you ask it to.
- It does not create candidate/review queues by default.
- It does not use confidence scores, importance scores, fit scores, or ranking theater.
- It does not require embeddings, a vector database, or MCP.
PBrain has one job: make useful knowledge retrievable later.
The core rules are simple:
- Store structured entries, not raw logs.
- Preserve timestamps and source provenance.
- Fail closed when automatic distillation is not configured.
- Keep native agent memory small. Put broader context in PBrain.
- Prefer boring local tools over complex infrastructure.
PBrain currently uses Python 3.11+ and the standard library at runtime.
git clone https://github.com/<owner>/pbrain.git
cd pbrain
python -m venv .venv
source .venv/bin/activate
pip install -e .For development:
pip install pytest
python -m pytest tests -q
python scripts/smoke.pypbrain health
pbrain write-entry --kind decision --title "Keep it local" --content "PBrain should stay local and CLI-first."
pbrain search "local CLI"
pbrain context --recent 10
pbrain exportBy default, PBrain stores data under its configured home directory. Runtime data is intentionally ignored by git.
PBrain can scan session files into a source ledger, then run a configured distiller to turn useful conversation context into structured entries.
pbrain dream scan --sessions-dir /path/to/sessions
pbrain dream due
pbrain dream run --date YYYY-MM-DD --distiller-command "python scripts/gemini_dream_distiller.py"
pbrain dream status
pbrain dream catchup --dry-runA distiller receives a prompt on stdin and must return JSON like this:
{
"accepted": [
{
"kind": "decision",
"title": "Keep PBrain lean",
"content": "PBrain should stay local, structured, and CLI-first.",
"tags": ["architecture"],
"source_snippet": "PBrain should stay local, structured, and CLI-first."
}
]
}Every item must include an exact source_snippet copied from the transcript. If the distiller is missing, fails, or returns ungrounded output, PBrain writes nothing for that session.
The bundled Gemini distiller is optional. It loads API keys from the environment or a local .env file, never from committed project files.
The API is off by default.
pbrain serve --host 127.0.0.1 --port 8765
pbrain serve --read-onlyEndpoints:
GET /health
GET /context?recent=10
GET /search?q=query
POST /entries
pbrain/
api.py # optional local HTTP API
cli.py # command-line interface
config.py # runtime path/config resolution
dream.py # session scan + distillation pipeline
repository.py # SQLite repository and FTS logic
tools.py # explicit agent/tool bridge schemas
scripts/
smoke.py
install_launchagent.py
gemini_dream_distiller.py
tests/
test_*.py
PBrain is local-first. The database, exports, logs, backups, virtualenvs, and local .env files are ignored by git.
Before publishing or sharing a repo, check what will be committed:
git status --short
git diff --cached --name-only
git diff --cachedDo not commit runtime data from data/, session logs, API keys, personal exports, or local scheduler logs.
MIT. Use it, fork it, simplify it further.