project-brain 0.5.3 → 0.6.1

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 +86 -5
  2. package/package.json +9 -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
 
@@ -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
 
@@ -72,6 +73,59 @@ 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
+ ### Structural (AST graph — exact, no embeddings needed)
88
+
89
+ | Tool | What it does |
90
+ |---|---|
91
+ | `find_symbol` | Exact symbol definition(s) by name: path, line range, kind, signature. Use when you know the name. |
92
+ | `find_callers` | Every symbol that calls the named symbol (who depends on X). |
93
+ | `find_callees` | Every symbol the named symbol calls (what X depends on). |
94
+ | `impact` | Blast radius — all symbols transitively affected if the named symbol changes (reverse call graph, bounded by `maxDepth`). |
95
+
96
+ ### Modules & knowledge
97
+
98
+ | Tool | What it does |
99
+ |---|---|
100
+ | `list_modules` | Browse the indexed structure by module. |
101
+ | `get_module` | Retrieve all chunks for a module. |
102
+ | `add_knowledge` | Persist a note/decision into the brain for future sessions. |
103
+ | `delete_knowledge` | Remove chunks by source (deleted/renamed files). |
104
+ | `check_health` | Embedding service + index status; run if results look empty or stale. |
105
+
106
+ Routing: exact symbol → `find_symbol`; who-calls → `find_callers`; what-it-calls → `find_callees`; "what breaks if I change X" → `impact`; fuzzy/conceptual → `search_context` then `expand_context`. 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`.
107
+
108
+ ## Recipes — get the most out of it
109
+
110
+ You talk to your **AI assistant** in natural language; it picks the right tool. These prompts steer it well:
111
+
112
+ | Goal | Ask your assistant | Tool it uses |
113
+ |---|---|---|
114
+ | **Refactor safely** | "What breaks if I change `parseConfig`?" | `impact` — see the full blast radius before you touch it |
115
+ | **Understand unfamiliar code** | "How does authentication work here?" | `search_context` → `expand_context` |
116
+ | **Find a definition fast** | "Where is `GraphStore` defined?" | `find_symbol` (exact, faster than grep) |
117
+ | **Trace dependencies** | "Who calls `chargeCard`?" / "What does `runSync` call?" | `find_callers` / `find_callees` |
118
+ | **Onboard to a module** | "Summarize the `store` module" | `list_modules` → `get_module` |
119
+ | **Persist a decision** | "Remember that we use RRF for hybrid search" | `add_knowledge` (survives across sessions) |
120
+
121
+ Tips to maximize value:
122
+
123
+ - **Structural tools work without Ollama.** `find_symbol` / `find_callers` / `find_callees` / `impact` query the local SQLite graph — exact-symbol and call-graph answers work even with embeddings unavailable. Only semantic `search_context` needs Ollama.
124
+ - **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.
125
+ - **Prefer `expand_context` over re-reading files.** `search_context` returns a `chunk_id`; expanding it is cheaper than the assistant reading the whole file.
126
+ - **Lead with the exact name when you have it.** "find_symbol X" / "who calls X" is faster and more precise than a semantic search.
127
+ - **Big repos stay cheap.** The walk honors `.gitignore`; generated/minified files (>512 KB or pathological lines) are skipped from structural parsing automatically.
128
+
75
129
  ## Commands
76
130
 
77
131
  ### `setup`
@@ -116,6 +170,15 @@ Check system health: Ollama availability, LanceDB status, and staleness of the i
116
170
  project-brain health
117
171
  ```
118
172
 
173
+ ### `search`
174
+
175
+ 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.
176
+
177
+ ```bash
178
+ project-brain search "how does auth work"
179
+ echo "how does auth work" | project-brain search --stdin
180
+ ```
181
+
119
182
  ### `serve`
120
183
 
121
184
  Start the MCP server. Default mode uses stdio (for local AI tool connections).
@@ -138,8 +201,26 @@ BRAIN_HTTP_TOKEN=your-secret project-brain serve --http [--port 3000]
138
201
  |---|---|---|
139
202
  | `BRAIN_HTTP_PORT` | `3000` | Port for HTTP server mode |
140
203
  | `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 |
204
+ | `BRAIN_DATA_DIR` | `~/.project-brain/data` | LanceDB + structural graph data directory |
205
+ | `BRAIN_EMBED_MODEL` | `qwen3-embedding:0.6b` | Ollama embedding model (registry keys: `qwen3-embedding`, `nomic-text`; or any raw Ollama model name) |
206
+ | `OLLAMA_HOST` | `http://127.0.0.1:11434` | Ollama server URL |
207
+ | `BRAIN_NO_UPDATE_CHECK` | — | Set to `1` to disable the update-available notice |
208
+
209
+ ## Update notifications
210
+
211
+ 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`.
212
+
213
+ ## Troubleshooting
214
+
215
+ | Symptom | Cause / Fix |
216
+ |---|---|
217
+ | `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.) |
218
+ | 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. |
219
+ | Results feel stale | `project-brain reindex` rebuilds from scratch; `project-brain sync` picks up changed files. |
220
+ | 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. |
221
+ | `serve --http` returns `401 unauthorized` | Set `BRAIN_HTTP_TOKEN` and send `Authorization: Bearer <token>`. |
222
+ | `unsupported platform` on launch | No prebuilt binary for your `os-arch`. Build the standalone binary from source (see Install). |
223
+ | Want to see what's wrong | `project-brain health` reports Ollama status, index counts, and staleness. |
143
224
 
144
225
  ## Module Documentation Workflow
145
226
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "project-brain",
3
- "version": "0.5.3",
3
+ "version": "0.6.1",
4
4
  "type": "module",
5
5
  "description": "Local-first MCP server that gives AI tools semantic memory of your codebase.",
6
6
  "author": "jcsoftdev",
@@ -35,20 +35,22 @@
35
35
  "build": "bun build ./src/cli.ts --compile --outfile dist/project-brain"
36
36
  },
37
37
  "dependencies": {
38
- "@modelcontextprotocol/sdk": "^1.29.0",
39
38
  "@lancedb/lancedb": "^0.30.0",
39
+ "@modelcontextprotocol/sdk": "^1.29.0",
40
40
  "ollama": "^0.6.3",
41
+ "web-tree-sitter": "^0.25.10",
41
42
  "zod": "^4.4.3"
42
43
  },
43
44
  "optionalDependencies": {
44
- "project-brain-darwin-arm64": "0.5.3",
45
- "project-brain-linux-x64": "0.5.3",
46
- "project-brain-linux-arm64": "0.5.3",
47
- "project-brain-windows-x64": "0.5.3",
48
- "project-brain-windows-arm64": "0.5.3"
45
+ "project-brain-darwin-arm64": "0.6.1",
46
+ "project-brain-linux-x64": "0.6.1",
47
+ "project-brain-linux-arm64": "0.6.1",
48
+ "project-brain-windows-x64": "0.6.1",
49
+ "project-brain-windows-arm64": "0.6.1"
49
50
  },
50
51
  "devDependencies": {
51
52
  "@types/bun": "latest",
53
+ "tree-sitter-wasms": "0.1.13",
52
54
  "typescript": "^5.5.4"
53
55
  }
54
56
  }