diff --git a/README.md b/README.md index c8556db7a..888c88459 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ The repo is the system of record. GBrain is the retrieval layer. The agent reads The numbers above aren't theoretical. They come from a real deployment documented in [GBRAIN_SKILLPACK.md](docs/GBRAIN_SKILLPACK.md) — a reference architecture for how a production AI agent uses gbrain as its knowledge backbone. -What's in the skillpack: +**Read the skillpack.** It's the most important doc in this repo. It tells your agent HOW to use gbrain, not just what commands exist: - **The brain-agent loop** — the read-write cycle that makes knowledge compound - **Entity detection** — spawn on every message, capture people/companies/original ideas @@ -105,7 +105,7 @@ What's in the skillpack: - **Source attribution** — every fact traceable to where it came from - **Reference cron schedule** — 20+ recurring jobs that keep the brain alive -It's a pattern book, not a tutorial. "Here's what works, here's why." +Without the skillpack, your agent has tools but no playbook. With it, the agent knows when to read, when to write, how to enrich, and how to keep the brain alive autonomously. It's a pattern book, not a tutorial. "Here's what works, here's why." ## How gbrain fits with OpenClaw @@ -225,13 +225,65 @@ GBrain keeps your brain current. After setup, `gbrain sync --watch` polls your g > or anon key. Find it: Project Settings > Database > Connection string > URI tab > > change dropdown to "Session pooler". -### Standalone CLI +### GBrain without OpenClaw + +GBrain works with any AI agent, any MCP client, or no agent at all. Three paths: + +#### Standalone CLI + +Install globally and use gbrain from the terminal: ```bash bun add -g github:garrytan/gbrain +gbrain init --supabase # guided wizard, connects to your Postgres +gbrain import ~/git/brain/ # index your markdown +gbrain query "what do we know about competitive dynamics?" ``` -### As a library +The CLI gives you every operation: page CRUD, search, tags, links, timeline, graph traversal, file management, health checks. Run `gbrain --help` for the full list. + +#### MCP server (Claude Code, Cursor, Windsurf, etc.) + +GBrain exposes 30 MCP tools via stdio. Add this to your MCP client config: + +**Claude Code** (`~/.claude/server.json`): +```json +{ + "mcpServers": { + "gbrain": { + "command": "gbrain", + "args": ["serve"] + } + } +} +``` + +**Cursor** (Settings > MCP Servers): +```json +{ + "gbrain": { + "command": "gbrain", + "args": ["serve"] + } +} +``` + +This gives your agent `get_page`, `put_page`, `search`, `query`, `add_link`, `traverse_graph`, `sync_brain`, `file_upload`, and 22 more tools. All generated from the same operation definitions as the CLI. + +**The tools are not enough.** Your agent also needs the playbook: read [GBRAIN_SKILLPACK.md](docs/GBRAIN_SKILLPACK.md) and paste the relevant sections into your agent's system prompt or project instructions. The skillpack tells the agent WHEN and HOW to use each tool: read before responding, write after learning, detect entities on every message, back-link everything. + +The skill markdown files in `skills/` are standalone instruction sets. Copy them into your agent's context: + +| Skill file | What the agent learns | +|------------|----------------------| +| `skills/ingest/SKILL.md` | How to import meetings, docs, articles | +| `skills/query/SKILL.md` | 3-layer search with synthesis and citations | +| `skills/maintain/SKILL.md` | Periodic health: stale pages, orphans, dead links | +| `skills/enrich/SKILL.md` | Enrich pages from external APIs | +| `skills/briefing/SKILL.md` | Daily briefing with meeting prep | +| `skills/migrate/SKILL.md` | Migrate from Obsidian, Notion, Logseq, etc. | + +#### As a TypeScript library ```bash bun add github:garrytan/gbrain @@ -239,8 +291,28 @@ bun add github:garrytan/gbrain ```typescript import { PostgresEngine } from 'gbrain'; + +const engine = new PostgresEngine(); +await engine.connect({ database_url: process.env.DATABASE_URL }); +await engine.initSchema(); + +// Search +const results = await engine.searchKeyword('startup growth'); + +// Read +const page = await engine.getPage('people/pedro-franceschi'); + +// Write +await engine.putPage('concepts/superlinear-returns', { + type: 'concept', + title: 'Superlinear Returns', + compiled_truth: 'Paul Graham argues that returns in many fields are superlinear...', + timeline: '- 2023-10-01: Published on paulgraham.com', +}); ``` +The `BrainEngine` interface is pluggable. See `docs/ENGINES.md` for how to add backends. + All paths require a Postgres database with pgvector. Supabase Pro ($25/mo) is the recommended zero-ops option. ## Upgrade @@ -297,6 +369,59 @@ gbrain embed --stale Import is idempotent. Re-running it skips unchanged files (compared by SHA-256 content hash). Progress bar shows status. ~30s for text import of 7,000 files, ~10-15 min for embedding. +## File storage and migration + +Brain repos accumulate binary files: images, PDFs, audio recordings, raw API responses. A repo with 3,000 markdown pages might have 2GB of binaries making `git clone` painful. + +GBrain has a three-stage migration lifecycle that moves binaries to cloud storage while preserving every reference: + +``` +Local files in git repo + │ + ▼ gbrain files mirror