wicked-brain 0.4.12 → 0.4.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wicked-brain",
3
- "version": "0.4.12",
3
+ "version": "0.4.14",
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.12",
3
+ "version": "0.4.14",
4
4
  "type": "module",
5
5
  "description": "SQLite FTS5 search server for wicked-brain digital knowledge bases",
6
6
  "keywords": [
@@ -80,15 +80,32 @@ this resolution. Never compute `_meta/config.json` against the project's `cwd`.
80
80
 
81
81
  ### Step 1: Ask the user
82
82
 
83
- **Ask in this exact order — do not reverse the questions:**
83
+ **Ask in this exact order — do not reverse the questions.**
84
84
 
85
- First, compute `{cwd_basename}`: take the basename of the current working directory,
86
- lowercase it, and replace any non-alphanumeric characters with hyphens.
85
+ First, compute `{cwd_basename}`:
86
+
87
+ ```bash
88
+ # macOS/Linux
89
+ basename "$PWD"
90
+ # Windows PowerShell
91
+ Split-Path -Leaf (Get-Location)
92
+ ```
93
+
94
+ This gives you the name of **the project the user is currently working in** — the repo or
95
+ directory they are about to index. It has nothing to do with wicked-brain, the skill name,
96
+ or any installed tool. For example:
97
+
98
+ - User is in `/Users/alice/Projects/wicked-bus` → default name is `wicked-bus`
99
+ - User is in `/home/bob/work/my-api` → default name is `my-api`
100
+ - User is in `/Users/mike/Projects/wicked-brain` → default name is `wicked-brain` (only
101
+ correct if they are literally indexing the wicked-brain repo itself)
102
+
103
+ Lowercase the result and replace non-alphanumeric characters with hyphens.
87
104
 
88
105
  Then ask **two questions, in order**:
89
106
 
90
107
  1. **"What should this project's brain be called?"**
91
- - Default: `{cwd_basename}` (the current directory name, not the string "wicked-brain")
108
+ - Default: `{cwd_basename}` computed above from the actual current working directory
92
109
  - Wait for the user's answer (or acceptance of default) before asking question 2.
93
110
 
94
111
  2. **"Where should it live?"**
@@ -103,24 +120,59 @@ directory, not a project subdirectory), push back: explain the per-project
103
120
  convention and suggest `~/.wicked-brain/projects/{project_name}` instead.
104
121
  Only accept the flat path if the user explicitly insists.
105
122
 
106
- ### Step 2: Check for existing brains
123
+ ### The `projects/` infix is mandatory — do not invent alternate layouts
107
124
 
108
- #### 2a: Detect a flat brain at the parent path
125
+ The ONLY valid brain path under the default container is
126
+ `~/.wicked-brain/projects/{name}/`. Common misreadings to avoid:
127
+
128
+ - ❌ `~/.wicked-brain/{name}/` — missing the `projects/` segment. Not valid.
129
+ - ❌ `~/.{name}-brain/` — sibling directory. Not the convention.
130
+ - ❌ `~/.wicked-brain/projects/{name}/projects/{subname}/` — nested brains. Not supported.
109
131
 
110
- If `~/.wicked-brain/brain.json` exists (note: `brain.json` at the flat parent
111
- path, NOT inside a `projects/` subdirectory), this is a legacy flat brain from
112
- before v0.4.7. Stop and tell the user:
132
+ If the user asks "why not `~/.wicked-brain/{name}`?" the answer is: the `projects/`
133
+ segment is a deliberate namespace. The parent `~/.wicked-brain/` is a container
134
+ that may hold other metadata (linked brain indexes, federation config, etc.),
135
+ and every brain lives under `projects/` to keep that clean.
113
136
 
114
- "I found an existing flat brain at `~/.wicked-brain/`. The current layout puts
115
- each project under `~/.wicked-brain/projects/{name}/`. I can migrate the flat
116
- brain with `wicked-brain:migrate` before creating the new one. Migrate now?"
137
+ Do not improvise alternate layouts when you hit an obstacle. If the documented
138
+ path is occupied, invoke the migration flow (Step 2a) — do not pick a sibling
139
+ directory or a nested path.
117
140
 
118
- If yes, invoke `wicked-brain:migrate` with `flat_path=~/.wicked-brain` and
119
- wait for it to complete before continuing.
141
+ ### Step 2: Check for existing brains
142
+
143
+ #### 2a: Detect a flat brain at the parent path
120
144
 
121
- If no, confirm the user wants to keep the flat brain and proceed (accept the
122
- tradeoff: the new project brain will live under `projects/` but the old one
123
- stays at the flat path).
145
+ **Check first, before anything else:** does `~/.wicked-brain/brain.json` exist?
146
+ (That is `brain.json` at the flat parent path, NOT inside `projects/`.) If yes,
147
+ this is a legacy flat brain from before v0.4.7 and you **MUST STOP** the init
148
+ flow and resolve it before continuing.
149
+
150
+ Read `~/.wicked-brain/brain.json` to find the existing brain's name, then tell
151
+ the user exactly this (substituting the real name):
152
+
153
+ > "Heads up — there's already a legacy flat brain at `~/.wicked-brain/` named
154
+ > `{existing_name}`. The current layout puts each project under
155
+ > `~/.wicked-brain/projects/{name}/`, so I can't just create a new brain at the
156
+ > parent path without clobbering it. You have two options:
157
+ >
158
+ > 1. **Migrate** the existing `{existing_name}` brain to
159
+ > `~/.wicked-brain/projects/{existing_name}/` first, then create the new
160
+ > `{project_name}` brain alongside it. Recommended.
161
+ > 2. **Keep** the flat `{existing_name}` brain where it is and create the new
162
+ > brain at `~/.wicked-brain/projects/{project_name}/`. This works but leaves
163
+ > the old brain in a legacy layout.
164
+ >
165
+ > Which do you want?"
166
+
167
+ Do NOT propose any other options. Do NOT suggest a sibling directory like
168
+ `~/.wicked-bus-brain`. Do NOT suggest nesting inside the existing brain. Do NOT
169
+ proceed with overwriting `~/.wicked-brain/brain.json` under any circumstances.
170
+
171
+ If the user picks option 1, invoke `wicked-brain:migrate` with
172
+ `flat_path=~/.wicked-brain` and wait for it to complete before continuing.
173
+
174
+ If the user picks option 2, proceed with the new brain at
175
+ `~/.wicked-brain/projects/{project_name}/` — the flat brain stays untouched.
124
176
 
125
177
  #### 2b: Check target path
126
178