wicked-brain 0.1.0
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/LICENSE +21 -0
- package/README.md +208 -0
- package/install.mjs +64 -0
- package/package.json +53 -0
- package/server/bin/wicked-brain-server.mjs +95 -0
- package/server/lib/file-watcher.mjs +159 -0
- package/server/lib/sqlite-search.mjs +260 -0
- package/server/lib/wikilinks.mjs +19 -0
- package/server/package.json +38 -0
- package/skills/wicked-brain-batch/SKILL.md +112 -0
- package/skills/wicked-brain-compile/SKILL.md +124 -0
- package/skills/wicked-brain-enhance/SKILL.md +103 -0
- package/skills/wicked-brain-ingest/SKILL.md +331 -0
- package/skills/wicked-brain-init/SKILL.md +110 -0
- package/skills/wicked-brain-lint/SKILL.md +93 -0
- package/skills/wicked-brain-query/SKILL.md +85 -0
- package/skills/wicked-brain-read/SKILL.md +73 -0
- package/skills/wicked-brain-search/SKILL.md +126 -0
- package/skills/wicked-brain-server/SKILL.md +72 -0
- package/skills/wicked-brain-status/SKILL.md +77 -0
- package/skills/wicked-brain-update/SKILL.md +110 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wicked-brain:search
|
|
3
|
+
description: |
|
|
4
|
+
Search the digital brain for relevant content. Dispatches parallel search
|
|
5
|
+
subagents across local and linked brains. Returns results at depth 0 with
|
|
6
|
+
deeper hints.
|
|
7
|
+
|
|
8
|
+
Use when: "search brain for", "find in brain", "brain search", or when
|
|
9
|
+
looking for specific content across the knowledge base.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# wicked-brain:search
|
|
13
|
+
|
|
14
|
+
You search the digital brain by dispatching parallel subagents — one per brain
|
|
15
|
+
in the network (local + parents + links).
|
|
16
|
+
|
|
17
|
+
## Cross-Platform Notes
|
|
18
|
+
|
|
19
|
+
Commands in this skill work on macOS, Linux, and Windows. When a command has
|
|
20
|
+
platform differences, alternatives are shown. Your native tools (Read, Write,
|
|
21
|
+
Grep, Glob) work everywhere — prefer them over shell commands when possible.
|
|
22
|
+
|
|
23
|
+
For the brain path default:
|
|
24
|
+
- macOS/Linux: ~/.wicked-brain
|
|
25
|
+
- Windows: %USERPROFILE%\.wicked-brain
|
|
26
|
+
|
|
27
|
+
## Config
|
|
28
|
+
|
|
29
|
+
Read `_meta/config.json` for brain path and server port.
|
|
30
|
+
If it doesn't exist, trigger wicked-brain:init.
|
|
31
|
+
|
|
32
|
+
## Parameters
|
|
33
|
+
|
|
34
|
+
- **query** (required): what to search for
|
|
35
|
+
- **limit** (default: 10): max results per brain
|
|
36
|
+
- **depth** (default: 0): result detail level
|
|
37
|
+
|
|
38
|
+
## Process
|
|
39
|
+
|
|
40
|
+
### Step 1: Discover brains to search
|
|
41
|
+
|
|
42
|
+
Use the Read tool on `{brain_path}/brain.json` to get parents and links.
|
|
43
|
+
For each parent/link, check if it's accessible by reading `{brain_path}/{relative_path}/brain.json`.
|
|
44
|
+
|
|
45
|
+
Build a list of accessible brains with their absolute paths.
|
|
46
|
+
|
|
47
|
+
### Step 2: Ensure server is running
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
curl -s -f -X POST http://localhost:{port}/api \
|
|
51
|
+
-H "Content-Type: application/json" \
|
|
52
|
+
-d '{"action":"health","params":{}}'
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
If connection refused, trigger wicked-brain:server auto-start pattern.
|
|
56
|
+
|
|
57
|
+
### Step 3: Dispatch search subagents in parallel
|
|
58
|
+
|
|
59
|
+
Launch one subagent per accessible brain **in the same message** (parallel dispatch).
|
|
60
|
+
|
|
61
|
+
Each search subagent receives these instructions:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
You are a search agent for the "{brain_id}" brain at {brain_path}.
|
|
65
|
+
|
|
66
|
+
Search for: "{query}"
|
|
67
|
+
|
|
68
|
+
## Step 1: Server search (FTS5)
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
curl -s -X POST http://localhost:{port}/api \
|
|
72
|
+
-H "Content-Type: application/json" \
|
|
73
|
+
-d '{"action":"search","params":{"query":"{query}","limit":{limit}}}'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Parse the JSON response to get results.
|
|
77
|
+
|
|
78
|
+
## Step 2: File search (catches what FTS might miss)
|
|
79
|
+
|
|
80
|
+
Search for exact phrases or patterns that FTS tokenization might split.
|
|
81
|
+
Use your Grep tool (preferred) or shell fallback:
|
|
82
|
+
- macOS/Linux: `grep -rl "{query}" {brain_path}/chunks/ {brain_path}/wiki/ 2>/dev/null | head -20`
|
|
83
|
+
- Windows: `findstr /s /m "{query}" {brain_path}\chunks\*.md {brain_path}\wiki\*.md 2>nul`
|
|
84
|
+
|
|
85
|
+
## Step 3: Merge and return
|
|
86
|
+
|
|
87
|
+
Combine FTS results and grep matches. Deduplicate by path.
|
|
88
|
+
For each result, read the first line of the file to get the title/summary.
|
|
89
|
+
|
|
90
|
+
Return in this format:
|
|
91
|
+
BRAIN: {brain_id}
|
|
92
|
+
RESULTS:
|
|
93
|
+
- {path} | score: {score} | {one-line summary}
|
|
94
|
+
- {path} | score: {score} | {one-line summary}
|
|
95
|
+
TOTAL: {count}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Step 4: Merge results from all subagents
|
|
99
|
+
|
|
100
|
+
After all subagents return:
|
|
101
|
+
1. Collect all results
|
|
102
|
+
2. Deduplicate by path (keep higher score)
|
|
103
|
+
3. Sort by score descending
|
|
104
|
+
4. Tag each result with its brain origin
|
|
105
|
+
|
|
106
|
+
### Step 5: Return at requested depth
|
|
107
|
+
|
|
108
|
+
**Depth 0 (default):**
|
|
109
|
+
```
|
|
110
|
+
Found {N} matches across {M} brains (showing top {limit}):
|
|
111
|
+
|
|
112
|
+
1. {path} [{brain}] ({score})
|
|
113
|
+
{one-line summary}
|
|
114
|
+
|
|
115
|
+
2. {path} [{brain}] ({score})
|
|
116
|
+
{one-line summary}
|
|
117
|
+
|
|
118
|
+
...
|
|
119
|
+
|
|
120
|
+
Unreachable brains: {list, if any}
|
|
121
|
+
|
|
122
|
+
To read any result: wicked-brain:read {path} --depth 2
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Depth 1:** For each result, also include frontmatter + first paragraph.
|
|
126
|
+
**Depth 2:** For each result, include full content (use sparingly — high token cost).
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wicked-brain:server
|
|
3
|
+
description: |
|
|
4
|
+
Manages the wicked-brain background server. Auto-triggered when any brain skill
|
|
5
|
+
gets a connection error. Starts the server, checks health, and reports status.
|
|
6
|
+
Users should never need to invoke this directly.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# wicked-brain:server
|
|
10
|
+
|
|
11
|
+
You manage the wicked-brain background server. This skill is triggered automatically
|
|
12
|
+
when another brain skill cannot reach the server.
|
|
13
|
+
|
|
14
|
+
## Cross-Platform Notes
|
|
15
|
+
|
|
16
|
+
Commands in this skill work on macOS, Linux, and Windows. When a command has
|
|
17
|
+
platform differences, alternatives are shown. Your native tools (Read, Write,
|
|
18
|
+
Grep, Glob) work everywhere — prefer them over shell commands when possible.
|
|
19
|
+
|
|
20
|
+
For the brain path default:
|
|
21
|
+
- macOS/Linux: ~/.wicked-brain
|
|
22
|
+
- Windows: %USERPROFILE%\.wicked-brain
|
|
23
|
+
|
|
24
|
+
## When to use
|
|
25
|
+
|
|
26
|
+
- When a brain skill reports "connection refused" or similar error from curl
|
|
27
|
+
- When asked to check or restart the brain server
|
|
28
|
+
|
|
29
|
+
## Server check and start
|
|
30
|
+
|
|
31
|
+
1. Read the file at `{brain_path}/_meta/config.json` to get the port and brain path.
|
|
32
|
+
|
|
33
|
+
2. Try a health check:
|
|
34
|
+
```bash
|
|
35
|
+
curl -s -f -X POST http://localhost:{port}/api \
|
|
36
|
+
-H "Content-Type: application/json" \
|
|
37
|
+
-d '{"action":"health","params":{}}'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
3. If the health check succeeds, the server is running. Report the status.
|
|
41
|
+
|
|
42
|
+
4. If connection refused:
|
|
43
|
+
a. Read the file at `{brain_path}/_meta/server.pid` to get the PID.
|
|
44
|
+
|
|
45
|
+
b. Check if the process is running:
|
|
46
|
+
- macOS/Linux: `kill -0 {pid} 2>/dev/null`
|
|
47
|
+
- Windows: `tasklist /FI "PID eq {pid}" 2>nul | findstr {pid}`
|
|
48
|
+
- Or use Python: `python3 -c "import os; os.kill({pid}, 0)" 2>/dev/null || python -c "import os; os.kill({pid}, 0)"`
|
|
49
|
+
|
|
50
|
+
c. If the process is dead or no PID file, start the server:
|
|
51
|
+
```bash
|
|
52
|
+
npx wicked-brain-server --brain {brain_path} --port {port} &
|
|
53
|
+
```
|
|
54
|
+
On Windows (PowerShell): `Start-Process npx -ArgumentList "wicked-brain-server","--brain","{brain_path}","--port","{port}" -NoNewWindow`
|
|
55
|
+
|
|
56
|
+
d. Wait 2 seconds, then retry the health check.
|
|
57
|
+
e. If still failing, tell the user:
|
|
58
|
+
"The brain server couldn't start automatically. Please run:
|
|
59
|
+
`npx wicked-brain-server --brain {brain_path} --port {port}`"
|
|
60
|
+
|
|
61
|
+
## API pattern for other skills
|
|
62
|
+
|
|
63
|
+
All skills that need the server should use this curl pattern:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
curl -s -X POST http://localhost:{port}/api \
|
|
67
|
+
-H "Content-Type: application/json" \
|
|
68
|
+
-d '{"action":"{action}","params":{params_json}}'
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`curl` works on macOS, Linux, and Windows 10+ (ships by default). If curl fails
|
|
72
|
+
with connection refused, trigger this wicked-brain:server skill.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wicked-brain:status
|
|
3
|
+
description: |
|
|
4
|
+
Show brain health, stats, and orientation with progressive loading.
|
|
5
|
+
Depth 0: summary. Depth 1: + topic distribution. Depth 2: full orientation.
|
|
6
|
+
|
|
7
|
+
Use when: "brain status", "what's in my brain", "brain health", or when
|
|
8
|
+
orienting at the start of a session.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# wicked-brain:status
|
|
12
|
+
|
|
13
|
+
You report the brain's current state using progressive loading.
|
|
14
|
+
|
|
15
|
+
## Cross-Platform Notes
|
|
16
|
+
|
|
17
|
+
Commands in this skill work on macOS, Linux, and Windows. When a command has
|
|
18
|
+
platform differences, alternatives are shown. Your native tools (Read, Write,
|
|
19
|
+
Grep, Glob) work everywhere — prefer them over shell commands when possible.
|
|
20
|
+
|
|
21
|
+
For the brain path default:
|
|
22
|
+
- macOS/Linux: ~/.wicked-brain
|
|
23
|
+
- Windows: %USERPROFILE%\.wicked-brain
|
|
24
|
+
|
|
25
|
+
## Config
|
|
26
|
+
|
|
27
|
+
Read `_meta/config.json` for brain path and server port.
|
|
28
|
+
If it doesn't exist, trigger wicked-brain:init.
|
|
29
|
+
|
|
30
|
+
## Parameters
|
|
31
|
+
|
|
32
|
+
- **depth** (default: 0): how much to return
|
|
33
|
+
|
|
34
|
+
## Process
|
|
35
|
+
|
|
36
|
+
### Step 1: Read brain.json
|
|
37
|
+
|
|
38
|
+
Use the Read tool on `{brain_path}/brain.json` to get id, name, parents, links.
|
|
39
|
+
|
|
40
|
+
### Step 2: Get server stats
|
|
41
|
+
|
|
42
|
+
Ensure the server is running (use the wicked-brain:server auto-start pattern):
|
|
43
|
+
```bash
|
|
44
|
+
curl -s -X POST http://localhost:{port}/api \
|
|
45
|
+
-H "Content-Type: application/json" \
|
|
46
|
+
-d '{"action":"stats","params":{}}'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
If connection refused, start the server (see wicked-brain:server skill), then retry.
|
|
50
|
+
|
|
51
|
+
### Step 3: Return at requested depth
|
|
52
|
+
|
|
53
|
+
**Depth 0:**
|
|
54
|
+
```
|
|
55
|
+
Brain: {name} ({id})
|
|
56
|
+
Chunks: {total_chunks} | Wiki articles: {total_wiki_articles}
|
|
57
|
+
Last indexed: {last_indexed}
|
|
58
|
+
Linked brains: {list of parents and links with accessible/inaccessible status}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Check parent/link accessibility by using the Read tool on
|
|
62
|
+
`{brain_path}/{relative_link_path}/brain.json`. Shell fallback:
|
|
63
|
+
- macOS/Linux: `cat {brain_path}/{relative_link_path}/brain.json 2>/dev/null`
|
|
64
|
+
- Windows: `Get-Content "{brain_path}\{relative_link_path}\brain.json" 2>nul`
|
|
65
|
+
|
|
66
|
+
**Depth 1:**
|
|
67
|
+
Depth 0 plus:
|
|
68
|
+
- Use the Read tool on `_meta/log.jsonl` (last 50 lines) to identify topic distribution from recent tag events.
|
|
69
|
+
Shell fallback: `tail -50 {brain_path}/_meta/log.jsonl` (macOS/Linux) or `Get-Content "{brain_path}\_meta\log.jsonl" -Tail 50` (Windows PowerShell)
|
|
70
|
+
- List the top 10 most common tags
|
|
71
|
+
- Flag any staleness warnings (sources modified after last ingest)
|
|
72
|
+
|
|
73
|
+
**Depth 2:**
|
|
74
|
+
Depth 1 plus:
|
|
75
|
+
- Read `_meta/log.jsonl` fully for recent activity (last 7 days)
|
|
76
|
+
- List coverage gaps (chunks with no wiki article referencing them)
|
|
77
|
+
- Full linked brain details
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wicked-brain:update
|
|
3
|
+
description: |
|
|
4
|
+
Check for and install wicked-brain updates. Compares installed version against
|
|
5
|
+
npm registry, updates skills across all detected CLIs, and updates the server.
|
|
6
|
+
|
|
7
|
+
Use when: "update wicked-brain", "check for brain updates", "wicked-brain:update",
|
|
8
|
+
or periodically to stay current.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# wicked-brain:update
|
|
12
|
+
|
|
13
|
+
You check for and install updates to the wicked-brain skills and server.
|
|
14
|
+
|
|
15
|
+
## Cross-Platform Notes
|
|
16
|
+
|
|
17
|
+
Commands in this skill work on macOS, Linux, and Windows. When a command has
|
|
18
|
+
platform differences, alternatives are shown. Your native tools (Read, Write,
|
|
19
|
+
Grep, Glob) work everywhere — prefer them over shell commands when possible.
|
|
20
|
+
|
|
21
|
+
For the brain path default:
|
|
22
|
+
- macOS/Linux: ~/.wicked-brain
|
|
23
|
+
- Windows: %USERPROFILE%\.wicked-brain
|
|
24
|
+
|
|
25
|
+
## When to use
|
|
26
|
+
|
|
27
|
+
- User asks to update or check for updates
|
|
28
|
+
- Periodically (suggest checking monthly)
|
|
29
|
+
- After encountering unexpected behavior that might be fixed in a newer version
|
|
30
|
+
|
|
31
|
+
## Process
|
|
32
|
+
|
|
33
|
+
### Step 1: Check current version
|
|
34
|
+
|
|
35
|
+
Read the installed server version:
|
|
36
|
+
```bash
|
|
37
|
+
wicked-brain-server --version 2>/dev/null || npx wicked-brain-server --version 2>/dev/null || echo "not installed"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
If that doesn't work, check the package directly:
|
|
41
|
+
```bash
|
|
42
|
+
npm list -g wicked-brain-server --json 2>/dev/null | grep version
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Step 2: Check latest version on npm
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm view wicked-brain version 2>/dev/null
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Step 3: Compare versions
|
|
52
|
+
|
|
53
|
+
If the installed version matches the latest, report:
|
|
54
|
+
"wicked-brain is up to date (v{version})."
|
|
55
|
+
|
|
56
|
+
If an update is available, ask the user:
|
|
57
|
+
"wicked-brain v{new} is available (you have v{current}). Update now?"
|
|
58
|
+
|
|
59
|
+
### Step 4: Update (if user approves)
|
|
60
|
+
|
|
61
|
+
#### Update everything (skills + server)
|
|
62
|
+
|
|
63
|
+
The server is bundled in the main package — one command updates both:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npx wicked-brain@latest
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
This re-runs the installer with the latest version, updating all skills across detected CLIs. The server binary updates automatically since it's part of the same package.
|
|
70
|
+
|
|
71
|
+
### Step 5: Restart server if running
|
|
72
|
+
|
|
73
|
+
Check if a brain server is running and restart it to pick up changes.
|
|
74
|
+
|
|
75
|
+
Find running server PIDs by searching for `server.pid` files under `_meta/` directories
|
|
76
|
+
in the home directory. Use your Glob tool if available.
|
|
77
|
+
|
|
78
|
+
On macOS/Linux:
|
|
79
|
+
```bash
|
|
80
|
+
find ~ -name "server.pid" -path "*/_meta/*" 2>/dev/null
|
|
81
|
+
```
|
|
82
|
+
On Windows (PowerShell):
|
|
83
|
+
```powershell
|
|
84
|
+
Get-ChildItem -Recurse -Filter "server.pid" -Path $env:USERPROFILE -ErrorAction SilentlyContinue | Where-Object { $_.DirectoryName -match "_meta" }
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
For each pid file found:
|
|
88
|
+
1. Read the file to get the PID.
|
|
89
|
+
2. Check if the process is alive:
|
|
90
|
+
- macOS/Linux: `kill -0 {pid} 2>/dev/null`
|
|
91
|
+
- Windows: `tasklist /FI "PID eq {pid}" 2>nul | findstr {pid}`
|
|
92
|
+
- Or Python: `python3 -c "import os; os.kill({pid}, 0)" 2>/dev/null || python -c "import os; os.kill({pid}, 0)"`
|
|
93
|
+
3. If alive, stop it:
|
|
94
|
+
- macOS/Linux: `kill {pid}`
|
|
95
|
+
- Windows: `Stop-Process -Id {pid}`
|
|
96
|
+
4. Read `{brain_dir}/_meta/config.json` to get the port.
|
|
97
|
+
5. Restart: `npx wicked-brain-server --brain "{brain_dir}" --port {port}`
|
|
98
|
+
On Windows: `Start-Process npx -ArgumentList "wicked-brain-server","--brain","{brain_dir}","--port","{port}" -NoNewWindow`
|
|
99
|
+
|
|
100
|
+
### Step 6: Report
|
|
101
|
+
|
|
102
|
+
Tell the user what was updated:
|
|
103
|
+
- Server: v{old} -> v{new}
|
|
104
|
+
- Skills: updated in {N} CLIs
|
|
105
|
+
- Running servers: {N} restarted
|
|
106
|
+
|
|
107
|
+
## Version check without updating
|
|
108
|
+
|
|
109
|
+
If the user just wants to check (not update), stop after Step 3 and report
|
|
110
|
+
the current vs. available version.
|