wicked-brain 0.4.5 → 0.4.7

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.
package/README.md CHANGED
@@ -159,10 +159,33 @@ Brains can link to other brains. A personal research brain can reference a team
159
159
 
160
160
  When you search, wicked-brain dispatches parallel search agents across all accessible brains and merges the results. Access control is filesystem permissions — if you can read the directory, you can search it.
161
161
 
162
- ## What's on Disk
162
+ ## Per-Project Brains
163
+
164
+ **Each project gets its own brain.** `wicked-brain:init` creates a brain under
165
+ `~/.wicked-brain/projects/{project-name}/` by default, where `{project-name}`
166
+ is the basename of your current working directory. This keeps unrelated
167
+ codebases, clients, and research domains from crowding a single index — and
168
+ makes federated search across projects meaningful.
163
169
 
164
170
  ```
165
171
  ~/.wicked-brain/
172
+ projects/
173
+ my-app/ # one brain per project
174
+ client-site/
175
+ personal-research/
176
+ ```
177
+
178
+ Multiple agents can work on different projects simultaneously without stepping
179
+ on each other. A supervising "meta-brain" can watch `~/.wicked-brain/projects/*`
180
+ and federate queries across all of them via `brain.json` links.
181
+
182
+ If you really want one brain for everything, you can pass a custom path to
183
+ `wicked-brain:init` — but you'll fight the index as it grows.
184
+
185
+ ## What's on Disk
186
+
187
+ ```
188
+ ~/.wicked-brain/projects/{project-name}/
166
189
  brain.json # Identity and brain links
167
190
  raw/ # Your source files
168
191
  chunks/
@@ -171,6 +194,7 @@ When you search, wicked-brain dispatches parallel search agents across all acces
171
194
  wiki/ # Synthesized articles with [[backlinks]]
172
195
  _meta/
173
196
  log.jsonl # Append-only event log
197
+ config.json # Server port, source path
174
198
  .brain.db # SQLite search index (auto-managed)
175
199
  ```
176
200
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wicked-brain",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "type": "module",
5
5
  "description": "Digital brain as skills for AI coding CLIs — no vector DB, no embeddings, no infrastructure",
6
6
  "keywords": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wicked-brain-server",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "type": "module",
5
5
  "description": "SQLite FTS5 search server for wicked-brain digital knowledge bases",
6
6
  "keywords": [
@@ -18,9 +18,34 @@ Commands in this skill work on macOS, Linux, and Windows. When a command has
18
18
  platform differences, alternatives are shown. Your native tools (Read, Write,
19
19
  Grep, Glob) work everywhere — prefer them over shell commands when possible.
20
20
 
21
+ ## Per-project brains (important)
22
+
23
+ **Each project gets its own brain under `~/.wicked-brain/projects/{project-name}/`.**
24
+ Do NOT initialize a single monolithic brain at `~/.wicked-brain/` — that overwhelms
25
+ the index, mixes unrelated content across clients/codebases, and makes federated
26
+ search useless.
27
+
28
+ The structure is:
29
+ ```
30
+ ~/.wicked-brain/ # parent directory (not a brain)
31
+ projects/
32
+ my-app/ # one brain per project
33
+ brain.json
34
+ chunks/
35
+ _meta/
36
+ client-site/ # another project's brain
37
+ brain.json
38
+ ...
39
+ ```
40
+
41
+ Project name defaults to the basename of the current working directory
42
+ (lowercase, hyphens for spaces). A supervising "meta-brain" agent can watch
43
+ `~/.wicked-brain/projects/*` and federate across all of them via
44
+ `brain.json` links.
45
+
21
46
  For the brain path default:
22
- - macOS/Linux: ~/.wicked-brain
23
- - Windows: %USERPROFILE%\.wicked-brain
47
+ - macOS/Linux: `~/.wicked-brain/projects/{project_name}`
48
+ - Windows: `%USERPROFILE%\.wicked-brain\projects\{project_name}`
24
49
 
25
50
  ## When to use
26
51
 
@@ -31,12 +56,18 @@ For the brain path default:
31
56
 
32
57
  ### Step 1: Ask the user
33
58
 
34
- Ask these questions (provide defaults):
59
+ Compute the default project name from the current working directory basename
60
+ (lowercase, replace non-alphanumerics with hyphens). Then ask:
61
+
62
+ 1. "What should this project's brain be called?" — Default: `{cwd_basename}`
63
+ 2. "Where should it live?" — Default:
64
+ - macOS/Linux: `~/.wicked-brain/projects/{project_name}`
65
+ - Windows: `%USERPROFILE%\.wicked-brain\projects\{project_name}`
35
66
 
36
- 1. "Where should your brain live?"
37
- - Default (macOS/Linux): `~/.wicked-brain`
38
- - Default (Windows): `%USERPROFILE%\.wicked-brain`
39
- 2. "What should this brain be called?" Default: directory name
67
+ If the user supplies a path that is exactly `~/.wicked-brain` (the parent
68
+ directory, not a project subdirectory), push back: explain the per-project
69
+ convention and suggest `~/.wicked-brain/projects/{project_name}` instead.
70
+ Only accept the flat path if the user explicitly insists.
40
71
 
41
72
  ### Step 2: Check for existing brain
42
73
 
@@ -43,6 +43,71 @@ whether the language server process is running and review its stderr logs.
43
43
  Read `_meta/config.json` for brain path and server port.
44
44
  If it doesn't exist, trigger wicked-brain:init.
45
45
 
46
+ ## Prerequisites — Source Path
47
+
48
+ **LSP operates on the source project, not the brain directory.** The server must know where the ingested project lives to initialize language servers correctly. Without this, LSP calls will fail with "No Project" errors or return empty results.
49
+
50
+ ### Check if source_path is configured
51
+
52
+ Read `{brain_path}/_meta/config.json`. Look for a `source_path` key:
53
+
54
+ ```json
55
+ {
56
+ "brain_path": "/Users/me/.wicked-brain",
57
+ "server_port": 4243,
58
+ "source_path": "/Users/me/Projects/my-project"
59
+ }
60
+ ```
61
+
62
+ If `source_path` is **present** — LSP is configured. Proceed with calls.
63
+
64
+ If `source_path` is **missing** — LSP will fail. Fix it before continuing.
65
+
66
+ ### Fix: set source_path
67
+
68
+ **Option A** — Re-ingest the project directory (recommended, sets source_path automatically):
69
+ ```
70
+ wicked-brain:ingest source=/path/to/project
71
+ ```
72
+
73
+ **Option B** — Write it manually to `_meta/config.json`, then restart the server:
74
+ ```bash
75
+ # Read current config, add source_path, write back
76
+ python3 -c "
77
+ import json
78
+ path = '{brain_path}/_meta/config.json'
79
+ with open(path) as f: cfg = json.load(f)
80
+ cfg['source_path'] = '/absolute/path/to/project'
81
+ with open(path, 'w') as f: json.dump(cfg, f, indent=2)
82
+ print('source_path set')
83
+ " 2>/dev/null || python -c "
84
+ import json
85
+ path = '{brain_path}/_meta/config.json'
86
+ with open(path) as f: cfg = json.load(f)
87
+ cfg['source_path'] = '/absolute/path/to/project'
88
+ with open(path, 'w') as f: json.dump(cfg, f, indent=2)
89
+ print('source_path set')
90
+ "
91
+ # Then restart the server with --source:
92
+ npx wicked-brain-server --brain {brain_path} --port {port} --source /absolute/path/to/project &
93
+ ```
94
+
95
+ **Option C** — Restart server with `--source` flag (does not persist to config):
96
+ ```bash
97
+ npx wicked-brain-server --brain {brain_path} --port {port} --source /absolute/path/to/project &
98
+ ```
99
+
100
+ Wait 2 seconds after restarting, then verify with `lsp-health`.
101
+
102
+ ### Diagnosing "No Project" / empty results
103
+
104
+ Symptoms that indicate missing or wrong `source_path`:
105
+ - `lsp-workspace-symbols` returns `{"symbols":[]}` for any query
106
+ - `lsp-health` shows `{"typescript":{"status":"error","message":"No Project"}}` or similar
107
+ - Any LSP call returns an error about workspace or project not found
108
+
109
+ Check `source_path` in config. If it points at the brain directory (e.g., `~/.wicked-brain/...`) instead of the source project, that is wrong — the brain dir has no `tsconfig.json` or language config. Set it to the project root and restart.
110
+
46
111
  ## When to Use
47
112
 
48
113
  | You want to... | Action | Example |
@@ -130,7 +195,7 @@ If installation fails, report to the user:
130
195
  | `language_server_crashed` | The server crashed 3 times. Report to user, suggest checking the language server logs. |
131
196
  | `unsupported_language` | No known language server for this file extension. |
132
197
  | `lsp_timeout` | The language server took too long. May be initializing a large project. Retry once. |
133
- | `file_outside_workspace` | The file isn't in a registered project. Use `wicked-brain:onboard` to register the project first. |
198
+ | `file_outside_workspace` | The file isn't under `source_path`. Check `_meta/config.json` `source_path` must be the project root that contains the file. Set it and restart the server with `--source`. |
134
199
 
135
200
  ### Step 5: Use results
136
201