project-brain 0.6.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +102 -8
  2. package/package.json +8 -7
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Local-first MCP server that gives AI tools semantic memory of your codebase.
4
4
 
5
- project-brain indexes your project files into a local LanceDB vector store using Ollama embeddings. Once indexed, AI assistants connected via MCP can search your codebase semantically, track module documentation, and maintain knowledge that persists across sessions.
5
+ project-brain indexes your project files into a local LanceDB vector store using Ollama embeddings, and builds a SQLite **structural graph** (symbols + call edges) with a WASM tree-sitter parser. Once indexed, AI assistants connected via MCP can search your codebase **semantically** (by meaning) AND **structurally** (exact symbols, callers/callees, change blast-radius), track module documentation, and maintain knowledge that persists across sessions.
6
6
 
7
7
  ## Quick Start
8
8
 
@@ -10,7 +10,7 @@ project-brain indexes your project files into a local LanceDB vector store using
10
10
  # 1. Install globally
11
11
  bun install -g project-brain
12
12
 
13
- # 2. One-time: register in your AI tools (Claude, Codex, Cursor, Gemini)
13
+ # 2. One-time: register in your AI tools (Claude, Codex, Cursor, Gemini, Windsurf, Zed, VS Code)
14
14
  project-brain setup
15
15
 
16
16
  # 3. Per-project: initialize, index, and install git hook
@@ -28,8 +28,9 @@ After `init`, the following run **automatically** without any extra steps:
28
28
 
29
29
  ## Prerequisites
30
30
 
31
- - **Bun** ≥ 1.3.14 — required runtime ([install](https://bun.sh))
32
- - **Ollama** (optional, for semantic search) — download from [ollama.com](https://ollama.com). Pull `nomic-embed-text` for embeddings: `ollama pull nomic-embed-text`
31
+ - **Nothing extra to run it.** The registry install ships a self-contained, prebuilt binary per platform (the runtime is bundled in) — you do **not** need Bun or Node installed to use project-brain.
32
+ - **Bun** ≥ 1.3.14 — only needed to build/run **from source** ([install](https://bun.sh)).
33
+ - **Ollama** (optional, only for semantic search) — download from [ollama.com](https://ollama.com). `project-brain init` **auto-pulls** the default embedding model `qwen3-embedding:0.6b` (1024-dim, fast, code-capable). To pre-pull it: `ollama pull qwen3-embedding:0.6b`. If it can't be pulled, project-brain falls back to `nomic-embed-text`. The structural tools work with **no** Ollama at all.
33
34
 
34
35
  ## Install
35
36
 
@@ -60,7 +61,7 @@ Run commands directly from your terminal in any project directory.
60
61
 
61
62
  ### Inside AI tools (slash commands)
62
63
 
63
- Once `project-brain setup` has registered the MCP server in your AI tool, you can invoke commands as slash commands from within Claude Code, Codex, Cursor, or any MCP-compatible AI:
64
+ Once `project-brain setup` has registered the MCP server in your AI tool, you can invoke commands as slash commands from within Claude Code, Codex, Cursor, Windsurf, Zed, VS Code, or any MCP-compatible AI:
64
65
 
65
66
  | Slash command | Equivalent CLI | What it does |
66
67
  |---|---|---|
@@ -72,11 +73,77 @@ Once `project-brain setup` has registered the MCP server in your AI tool, you ca
72
73
 
73
74
  The slash commands are Claude Code skills installed globally at `~/.claude/skills/brain-*/SKILL.md`. They work in any session regardless of the current project.
74
75
 
76
+ ## MCP Tools
77
+
78
+ Once connected over MCP, AI assistants get these tools. The server also injects routing instructions so the assistant picks the right one (semantic vs structural).
79
+
80
+ ### Semantic (meaning-based)
81
+
82
+ | Tool | What it does |
83
+ |---|---|
84
+ | `search_context` | Semantic/conceptual lookup. Returns ranked snippets, each with a `chunk_id`. **Primary** for fuzzy/cross-file questions ("how does X work"). |
85
+ | `expand_context` | Full body of a `chunk_id` from `search_context` — read this instead of re-reading whole files. |
86
+
87
+ ### Lexical (keyword — no embeddings needed)
88
+
89
+ | Tool | What it does |
90
+ |---|---|
91
+ | `search_code` | Exact/keyword full-text search (BM25) over indexed code — identifiers, error strings, exact phrases. Works offline without Ollama. Not regex. |
92
+
93
+ ### Structural (AST graph — exact, no embeddings needed)
94
+
95
+ | Tool | What it does |
96
+ |---|---|
97
+ | `find_symbol` | Exact symbol definition(s) by name: path, line range, kind, signature. Use when you know the name. |
98
+ | `find_callers` | Every symbol that calls the named symbol (who depends on X). |
99
+ | `find_callees` | Every symbol the named symbol calls (what X depends on). |
100
+ | `impact` | Blast radius — all symbols transitively affected if the named symbol changes (reverse call graph, bounded by `maxDepth`). |
101
+ | `trace_path` | Shortest call path between two symbols (how does A reach B) — ordered caller→callee chain. |
102
+ | `repo_map` | Token-budgeted overview of the most important symbols in the codebase, ranked by PageRank over the call graph. Use for repo orientation / where to start reading. |
103
+
104
+ ### Modules & knowledge
105
+
106
+ | Tool | What it does |
107
+ |---|---|
108
+ | `list_modules` | Browse the indexed structure by module. |
109
+ | `get_module` | Retrieve all chunks for a module. |
110
+ | `add_knowledge` | Persist a note/decision into the brain for future sessions. |
111
+ | `delete_knowledge` | Remove chunks by source (deleted/renamed files). |
112
+ | `check_health` | Embedding service + index status; run if results look empty or stale. |
113
+ | `list_projects` | List every indexed project with chunk counts and embedding meta. |
114
+ | `delete_project` | Delete an entire indexed project's vector index + metadata (never touches its `.project-brain/` directory). |
115
+ | `manage_adr` | Create or list Architecture Decision Records. Append-only: supersede by creating a new ADR with `supersedes:<slug>`. |
116
+ | `get_architecture` | One-call project summary: detected tech stack, indexed modules, chunk count, and symbol count. |
117
+ | `sync_project` | Re-index changed files now (incremental, hash-gated). Streams progress via MCP notifications when the client supplies a `progressToken`. Use when results look stale. |
118
+
119
+ Routing: exact symbol → `find_symbol`; who-calls → `find_callers`; what-it-calls → `find_callees`; "what breaks if I change X" → `impact`; "how does A end up calling B" → `trace_path`; fuzzy/conceptual → `search_context` then `expand_context`; exact string/identifier you can type verbatim → `search_code`. The canonical tool list lives in `src/constants.ts` (`TOOL_CATALOG`) and is rendered into both the MCP server instructions and the per-project `CLAUDE.md`.
120
+
121
+ ## Recipes — get the most out of it
122
+
123
+ You talk to your **AI assistant** in natural language; it picks the right tool. These prompts steer it well:
124
+
125
+ | Goal | Ask your assistant | Tool it uses |
126
+ |---|---|---|
127
+ | **Refactor safely** | "What breaks if I change `parseConfig`?" | `impact` — see the full blast radius before you touch it |
128
+ | **Understand unfamiliar code** | "How does authentication work here?" | `search_context` → `expand_context` |
129
+ | **Find a definition fast** | "Where is `GraphStore` defined?" | `find_symbol` (exact, faster than grep) |
130
+ | **Trace dependencies** | "Who calls `chargeCard`?" / "What does `runSync` call?" | `find_callers` / `find_callees` |
131
+ | **Onboard to a module** | "Summarize the `store` module" | `list_modules` → `get_module` |
132
+ | **Persist a decision** | "Remember that we use RRF for hybrid search" | `add_knowledge` (survives across sessions) |
133
+
134
+ Tips to maximize value:
135
+
136
+ - **Structural and lexical tools work without Ollama.** `find_symbol` / `find_callers` / `find_callees` / `impact` / `trace_path` query the local SQLite graph, and `search_code` queries the local FTS index — all work even with embeddings unavailable. Only semantic `search_context` needs Ollama.
137
+ - **Keep the index fresh automatically.** The git hook re-syncs on commit and the file watcher re-indexes on save while `serve` runs — no manual step. Run `project-brain sync` after big external changes.
138
+ - **Prefer `expand_context` over re-reading files.** `search_context` returns a `chunk_id`; expanding it is cheaper than the assistant reading the whole file.
139
+ - **Lead with the exact name when you have it.** "find_symbol X" / "who calls X" is faster and more precise than a semantic search.
140
+ - **Big repos stay cheap.** The walk honors `.gitignore`; generated/minified files (>512 KB or pathological lines) are skipped from structural parsing automatically.
141
+
75
142
  ## Commands
76
143
 
77
144
  ### `setup`
78
145
 
79
- One-time global setup. Detects your environment and registers project-brain with AI tools (Claude, Cursor, Gemini, Codex).
146
+ One-time global setup. Detects your environment and registers project-brain with AI tools (Claude, Cursor, Gemini, Codex, Windsurf, Zed, VS Code).
80
147
 
81
148
  ```bash
82
149
  project-brain setup
@@ -116,6 +183,15 @@ Check system health: Ollama availability, LanceDB status, and staleness of the i
116
183
  project-brain health
117
184
  ```
118
185
 
186
+ ### `search`
187
+
188
+ Search the indexed context and print compact results. Primarily used internally: `init` installs a `UserPromptSubmit` hook (`project-brain search --stdin`) in `.claude/settings.json` that auto-injects relevant context on every prompt, so retrieval is deterministic rather than relying on the AI to call a tool.
189
+
190
+ ```bash
191
+ project-brain search "how does auth work"
192
+ echo "how does auth work" | project-brain search --stdin
193
+ ```
194
+
119
195
  ### `serve`
120
196
 
121
197
  Start the MCP server. Default mode uses stdio (for local AI tool connections).
@@ -138,8 +214,26 @@ BRAIN_HTTP_TOKEN=your-secret project-brain serve --http [--port 3000]
138
214
  |---|---|---|
139
215
  | `BRAIN_HTTP_PORT` | `3000` | Port for HTTP server mode |
140
216
  | `BRAIN_HTTP_TOKEN` | — | **Required** for `serve --http`. Bearer secret. |
141
- | `BRAIN_DATA_DIR` | `~/.project-brain/data` | LanceDB data directory |
142
- | `BRAIN_EMBED_MODEL` | `nomic-embed-text` | Ollama embedding model name |
217
+ | `BRAIN_DATA_DIR` | `~/.project-brain/data` | LanceDB + structural graph data directory |
218
+ | `BRAIN_EMBED_MODEL` | `qwen3-embedding:0.6b` | Ollama embedding model (registry keys: `qwen3-embedding`, `nomic-text`; or any raw Ollama model name) |
219
+ | `OLLAMA_HOST` | `http://127.0.0.1:11434` | Ollama server URL |
220
+ | `BRAIN_NO_UPDATE_CHECK` | — | Set to `1` to disable the update-available notice |
221
+
222
+ ## Update notifications
223
+
224
+ The CLI checks (at most once a day, in the background) whether a newer `project-brain` is published on npm and prints a one-line notice when one is available. It is fail-silent, adds zero latency (the check runs in a detached process; the current command reads only a cached result), and is skipped in CI. Disable it with `BRAIN_NO_UPDATE_CHECK=1`.
225
+
226
+ ## Troubleshooting
227
+
228
+ | Symptom | Cause / Fix |
229
+ |---|---|
230
+ | `Ingested: 0` or empty semantic results | Ollama not running or model not pulled. Start Ollama and `ollama pull qwen3-embedding:0.6b`, then `project-brain reindex`. Run `project-brain health` to confirm. (Structural tools still work without Ollama.) |
231
+ | Structural tools (`find_symbol`/`impact`) return nothing | The graph isn't populated yet — run `project-brain sync` (or `reindex`) once. Structural extraction does **not** need Ollama, so this works even offline. |
232
+ | Results feel stale | `project-brain reindex` rebuilds from scratch; `project-brain sync` picks up changed files. |
233
+ | Changed `BRAIN_EMBED_MODEL` and search broke | A new model usually means a new vector dimension. Run `project-brain reindex` — the table re-embeds and migrates the dimension. |
234
+ | `serve --http` returns `401 unauthorized` | Set `BRAIN_HTTP_TOKEN` and send `Authorization: Bearer <token>`. |
235
+ | `unsupported platform` on launch | No prebuilt binary for your `os-arch`. Build the standalone binary from source (see Install). |
236
+ | Want to see what's wrong | `project-brain health` reports Ollama status, index counts, and staleness. |
143
237
 
144
238
  ## Module Documentation Workflow
145
239
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "project-brain",
3
- "version": "0.6.0",
3
+ "version": "0.8.2",
4
4
  "type": "module",
5
5
  "description": "Local-first MCP server that gives AI tools semantic memory of your codebase.",
6
6
  "author": "jcsoftdev",
@@ -30,9 +30,10 @@
30
30
  "scripts": {
31
31
  "dev": "bun run src/cli.ts",
32
32
  "test": "bun test",
33
+ "typecheck": "tsc --noEmit",
33
34
  "setup": "bun run src/cli.ts setup",
34
35
  "init": "bun run src/cli.ts init",
35
- "build": "bun build ./src/cli.ts --compile --outfile dist/project-brain"
36
+ "build": "bun build ./src/cli.ts ./src/parser/worker.ts --compile --outfile dist/project-brain"
36
37
  },
37
38
  "dependencies": {
38
39
  "@lancedb/lancedb": "^0.30.0",
@@ -42,11 +43,11 @@
42
43
  "zod": "^4.4.3"
43
44
  },
44
45
  "optionalDependencies": {
45
- "project-brain-darwin-arm64": "0.6.0",
46
- "project-brain-linux-x64": "0.6.0",
47
- "project-brain-linux-arm64": "0.6.0",
48
- "project-brain-windows-x64": "0.6.0",
49
- "project-brain-windows-arm64": "0.6.0"
46
+ "project-brain-darwin-arm64": "0.8.2",
47
+ "project-brain-linux-x64": "0.8.2",
48
+ "project-brain-linux-arm64": "0.8.2",
49
+ "project-brain-windows-x64": "0.8.2",
50
+ "project-brain-windows-arm64": "0.8.2"
50
51
  },
51
52
  "devDependencies": {
52
53
  "@types/bun": "latest",