wicked-brain 0.1.2 → 0.3.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.
- package/install.mjs +57 -8
- package/package.json +1 -1
- package/server/bin/wicked-brain-server.mjs +54 -7
- package/server/lib/file-watcher.mjs +102 -5
- package/server/lib/lsp-client.mjs +278 -0
- package/server/lib/lsp-helpers.mjs +133 -0
- package/server/lib/lsp-manager.mjs +164 -0
- package/server/lib/lsp-protocol.mjs +123 -0
- package/server/lib/lsp-servers.mjs +290 -0
- package/server/lib/sqlite-search.mjs +216 -10
- package/server/lib/wikilinks.mjs +20 -4
- package/server/package.json +1 -1
- package/skills/wicked-brain-agent/SKILL.md +52 -0
- package/skills/wicked-brain-agent/agents/consolidate.md +138 -0
- package/skills/wicked-brain-agent/agents/context.md +88 -0
- package/skills/wicked-brain-agent/agents/onboard.md +88 -0
- package/skills/wicked-brain-agent/agents/session-teardown.md +84 -0
- package/skills/wicked-brain-agent/hooks/claude-hooks.json +12 -0
- package/skills/wicked-brain-agent/hooks/copilot-hooks.json +10 -0
- package/skills/wicked-brain-agent/hooks/gemini-hooks.json +12 -0
- package/skills/wicked-brain-agent/platform/antigravity/wicked-brain-consolidate.md +103 -0
- package/skills/wicked-brain-agent/platform/antigravity/wicked-brain-context.md +67 -0
- package/skills/wicked-brain-agent/platform/antigravity/wicked-brain-onboard.md +74 -0
- package/skills/wicked-brain-agent/platform/antigravity/wicked-brain-session-teardown.md +72 -0
- package/skills/wicked-brain-agent/platform/claude/wicked-brain-consolidate.md +106 -0
- package/skills/wicked-brain-agent/platform/claude/wicked-brain-context.md +70 -0
- package/skills/wicked-brain-agent/platform/claude/wicked-brain-onboard.md +77 -0
- package/skills/wicked-brain-agent/platform/claude/wicked-brain-session-teardown.md +75 -0
- package/skills/wicked-brain-agent/platform/codex/wicked-brain-consolidate.toml +104 -0
- package/skills/wicked-brain-agent/platform/codex/wicked-brain-context.toml +68 -0
- package/skills/wicked-brain-agent/platform/codex/wicked-brain-onboard.toml +75 -0
- package/skills/wicked-brain-agent/platform/codex/wicked-brain-session-teardown.toml +73 -0
- package/skills/wicked-brain-agent/platform/copilot/wicked-brain-consolidate.agent.md +105 -0
- package/skills/wicked-brain-agent/platform/copilot/wicked-brain-context.agent.md +69 -0
- package/skills/wicked-brain-agent/platform/copilot/wicked-brain-onboard.agent.md +76 -0
- package/skills/wicked-brain-agent/platform/copilot/wicked-brain-session-teardown.agent.md +74 -0
- package/skills/wicked-brain-agent/platform/cursor/wicked-brain-consolidate.md +104 -0
- package/skills/wicked-brain-agent/platform/cursor/wicked-brain-context.md +68 -0
- package/skills/wicked-brain-agent/platform/cursor/wicked-brain-onboard.md +75 -0
- package/skills/wicked-brain-agent/platform/cursor/wicked-brain-session-teardown.md +73 -0
- package/skills/wicked-brain-agent/platform/gemini/wicked-brain-consolidate.md +107 -0
- package/skills/wicked-brain-agent/platform/gemini/wicked-brain-context.md +71 -0
- package/skills/wicked-brain-agent/platform/gemini/wicked-brain-onboard.md +78 -0
- package/skills/wicked-brain-agent/platform/gemini/wicked-brain-session-teardown.md +76 -0
- package/skills/wicked-brain-agent/platform/kiro/wicked-brain-consolidate.json +17 -0
- package/skills/wicked-brain-agent/platform/kiro/wicked-brain-context.json +16 -0
- package/skills/wicked-brain-agent/platform/kiro/wicked-brain-onboard.json +17 -0
- package/skills/wicked-brain-agent/platform/kiro/wicked-brain-session-teardown.json +17 -0
- package/skills/wicked-brain-compile/SKILL.md +8 -0
- package/skills/wicked-brain-configure/SKILL.md +99 -0
- package/skills/wicked-brain-enhance/SKILL.md +19 -0
- package/skills/wicked-brain-ingest/SKILL.md +68 -5
- package/skills/wicked-brain-lint/SKILL.md +14 -0
- package/skills/wicked-brain-lsp/SKILL.md +172 -0
- package/skills/wicked-brain-memory/SKILL.md +144 -0
- package/skills/wicked-brain-query/SKILL.md +78 -1
- package/skills/wicked-brain-retag/SKILL.md +79 -0
- package/skills/wicked-brain-search/SKILL.md +3 -11
- package/skills/wicked-brain-status/SKILL.md +7 -0
- package/skills/wicked-brain-update/SKILL.md +20 -1
|
@@ -31,13 +31,70 @@ Server: http://localhost:{port}/api
|
|
|
31
31
|
|
|
32
32
|
Question: "{question}"
|
|
33
33
|
|
|
34
|
+
## Step 0: Decompose query
|
|
35
|
+
|
|
36
|
+
Before searching, extract 3-5 keyword search terms from the question.
|
|
37
|
+
These should be noun phrases, named entities, and technical terms — not
|
|
38
|
+
full sentences or common words.
|
|
39
|
+
|
|
40
|
+
Example:
|
|
41
|
+
Question: "What was the reasoning behind choosing PostgreSQL over SQLite?"
|
|
42
|
+
Key terms: ["PostgreSQL", "SQLite", "database decision", "API layer"]
|
|
43
|
+
|
|
44
|
+
### Check learned synonyms first
|
|
45
|
+
|
|
46
|
+
Before generating synonyms, check if `{brain_path}/_meta/synonyms.json` exists.
|
|
47
|
+
If it does, read it. Format:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"testing": ["unit-test", "integration-test", "test-coverage"],
|
|
52
|
+
"auth": ["authentication", "jwt", "session"],
|
|
53
|
+
"bootcamp": ["pod-exercises", "hands-on-lab"]
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
For each key term, look it up in the synonym map. Use learned synonyms first,
|
|
58
|
+
then supplement with LLM-generated synonyms for terms not in the map.
|
|
59
|
+
Learned synonyms are more reliable — they come from actual brain usage.
|
|
60
|
+
|
|
61
|
+
### LLM synonym expansion
|
|
62
|
+
|
|
63
|
+
For terms not covered by the learned synonym map, generate 1-2 synonyms or related terms:
|
|
64
|
+
- "auth" → also search "authentication", "credentials"
|
|
65
|
+
- "DB" → also search "database", "datastore"
|
|
66
|
+
- "K8s" → also search "kubernetes", "container-orchestration"
|
|
67
|
+
|
|
68
|
+
Run searches for both the original key terms AND the expanded terms.
|
|
69
|
+
Deduplicate results before proceeding to Step 1.
|
|
70
|
+
|
|
71
|
+
Example:
|
|
72
|
+
Question: "How does our auth system handle sessions?"
|
|
73
|
+
Key terms: ["auth", "sessions"]
|
|
74
|
+
Expanded: ["authentication", "credentials", "session-management", "tokens"]
|
|
75
|
+
Search queries: ["auth", "sessions", "authentication", "credentials", "session-management", "tokens"]
|
|
76
|
+
|
|
77
|
+
Use the key terms for FTS search queries (Step 1).
|
|
78
|
+
Use the full original question for synthesis context (Step 4).
|
|
79
|
+
Run multiple searches if key terms suggest different angles.
|
|
80
|
+
|
|
34
81
|
## Step 1: Search
|
|
35
82
|
|
|
36
83
|
Search the brain for relevant content:
|
|
37
84
|
```bash
|
|
38
85
|
curl -s -X POST http://localhost:{port}/api \
|
|
39
86
|
-H "Content-Type: application/json" \
|
|
40
|
-
-d '{"action":"search","params":{"query":"{
|
|
87
|
+
-d '{"action":"search","params":{"query":"{term}","limit":10,"session_id":"{session_id}"}}'
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Pass a session_id with every search call. This enables access tracking for
|
|
91
|
+
consolidation. Use a consistent session_id for the entire conversation.
|
|
92
|
+
|
|
93
|
+
If the question implies recency ("recently", "this week", "latest"), add a `since` parameter to the search with an ISO 8601 timestamp. For example, for "this week" use the date 7 days ago:
|
|
94
|
+
```bash
|
|
95
|
+
curl -s -X POST http://localhost:{port}/api \
|
|
96
|
+
-H "Content-Type: application/json" \
|
|
97
|
+
-d '{"action":"search","params":{"query":"{term}","limit":10,"session_id":"{session_id}","since":"{iso8601_date}"}}'
|
|
41
98
|
```
|
|
42
99
|
|
|
43
100
|
Also search with grep for exact phrases:
|
|
@@ -45,6 +102,18 @@ Also search with grep for exact phrases:
|
|
|
45
102
|
grep -rl "{key_terms}" {brain_path}/chunks/ {brain_path}/wiki/ 2>/dev/null | head -10
|
|
46
103
|
```
|
|
47
104
|
|
|
105
|
+
### Log synonym effectiveness
|
|
106
|
+
|
|
107
|
+
For each synonym-expanded search term, log whether it produced results:
|
|
108
|
+
|
|
109
|
+
If the expansion returned results that the user accessed (appeared in final answer):
|
|
110
|
+
Append to `{brain_path}/_meta/log.jsonl`:
|
|
111
|
+
{"ts":"{ISO}","op":"synonym_hit","original":"{original term}","expansion":"{expanded term}","results_found":{count},"author":"agent:query"}
|
|
112
|
+
|
|
113
|
+
If the expansion returned 0 results:
|
|
114
|
+
Append to `{brain_path}/_meta/log.jsonl`:
|
|
115
|
+
{"ts":"{ISO}","op":"synonym_miss","original":"{original term}","expansion":"{expanded term}","results_found":0,"author":"agent:query"}
|
|
116
|
+
|
|
48
117
|
## Step 2: Progressive read
|
|
49
118
|
|
|
50
119
|
Read the top 3-5 results at depth 1 first (just frontmatter + summary).
|
|
@@ -82,4 +151,12 @@ Answer the question directly, then list sources:
|
|
|
82
151
|
Sources:
|
|
83
152
|
- {path}: {one-line description of what it contributed}
|
|
84
153
|
- {path}: {one-line description}
|
|
154
|
+
|
|
155
|
+
## Step 5: Log search effectiveness
|
|
156
|
+
|
|
157
|
+
If evidence was insufficient to answer the question fully, append a
|
|
158
|
+
search-miss event to the brain's log:
|
|
159
|
+
|
|
160
|
+
Append this line to {brain_path}/_meta/log.jsonl:
|
|
161
|
+
{"ts":"{ISO}","op":"search_miss","query":"{original question}","key_terms":[{extracted terms}],"results_found":{count},"author":"agent:query"}
|
|
85
162
|
```
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wicked-brain:retag
|
|
3
|
+
description: |
|
|
4
|
+
Backfill synonym-expanded tags on chunks and memories that have fewer than
|
|
5
|
+
5 tags. Run periodically or as part of consolidation.
|
|
6
|
+
|
|
7
|
+
Use when: "retag the brain", "expand tags", "backfill synonyms",
|
|
8
|
+
"brain retag", "improve tagging".
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# wicked-brain:retag
|
|
12
|
+
|
|
13
|
+
Scan chunks and memories with thin tagging and expand their `contains:` with synonyms and related terms.
|
|
14
|
+
|
|
15
|
+
## Cross-Platform Notes
|
|
16
|
+
|
|
17
|
+
- Uses Glob tool for file discovery (not shell `find`)
|
|
18
|
+
- Uses Read tool for frontmatter parsing (not shell `head`)
|
|
19
|
+
- Uses Edit tool for frontmatter updates (not shell `sed`)
|
|
20
|
+
- No shell commands required — fully agent-native
|
|
21
|
+
|
|
22
|
+
## Config
|
|
23
|
+
|
|
24
|
+
Read `_meta/config.json` for brain path and server port.
|
|
25
|
+
If it doesn't exist, trigger wicked-brain:init.
|
|
26
|
+
|
|
27
|
+
## Parameters
|
|
28
|
+
|
|
29
|
+
- **dry_run** (optional, default false): if true, report what would change without writing
|
|
30
|
+
- **min_tags** (optional, default 5): threshold — only retag docs with fewer tags than this
|
|
31
|
+
|
|
32
|
+
## Process
|
|
33
|
+
|
|
34
|
+
### Step 1: Find under-tagged documents
|
|
35
|
+
|
|
36
|
+
Use Glob to find all markdown files:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
{brain_path}/chunks/**/*.md
|
|
40
|
+
{brain_path}/memory/**/*.md
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Step 2: Read frontmatter at depth 0
|
|
44
|
+
|
|
45
|
+
For each file, read the YAML frontmatter between `---` lines. Parse the `contains:` array. Filter to files with fewer than {min_tags} tags.
|
|
46
|
+
|
|
47
|
+
### Step 3: Expand tags
|
|
48
|
+
|
|
49
|
+
For each under-tagged document, read at depth 1 (first ~10 lines of content after frontmatter). Generate expanded tags:
|
|
50
|
+
|
|
51
|
+
#### Check learned synonyms
|
|
52
|
+
|
|
53
|
+
Before LLM expansion, check if `{brain_path}/_meta/synonyms.json` exists.
|
|
54
|
+
For each existing tag, look it up in the synonym map. Learned expansions take
|
|
55
|
+
priority over LLM-generated ones. Supplement with LLM expansions for tags
|
|
56
|
+
not in the map.
|
|
57
|
+
|
|
58
|
+
- For each existing tag, add 1-3 synonyms or related terms
|
|
59
|
+
- Extract additional keywords from the content summary
|
|
60
|
+
- Apply the same expansion rules as wicked-brain:memory store:
|
|
61
|
+
- Abbreviations: JWT → "json-web-token"
|
|
62
|
+
- Synonyms: "auth" → "authentication"
|
|
63
|
+
- Related concepts: "JWT" → "tokens", "session", "security"
|
|
64
|
+
- Domain hierarchy: "PostgreSQL" → "database", "RDBMS"
|
|
65
|
+
- Deduplicate and cap at 15 tags total
|
|
66
|
+
|
|
67
|
+
### Step 4: Update or report
|
|
68
|
+
|
|
69
|
+
If **dry_run**: report the file path, current tag count, and proposed new tags.
|
|
70
|
+
|
|
71
|
+
If not dry_run: update the `contains:` field in the YAML frontmatter in-place using the Edit tool. The server's file watcher will detect the change and re-index.
|
|
72
|
+
|
|
73
|
+
### Step 5: Summary
|
|
74
|
+
|
|
75
|
+
Report:
|
|
76
|
+
- Total files scanned
|
|
77
|
+
- Files under threshold
|
|
78
|
+
- Files updated (or would-be-updated in dry run)
|
|
79
|
+
- Sample of expanded tags for verification
|
|
@@ -75,16 +75,8 @@ curl -s -X POST http://localhost:{port}/api \
|
|
|
75
75
|
|
|
76
76
|
Parse the JSON response to get results.
|
|
77
77
|
|
|
78
|
-
## Step 2:
|
|
78
|
+
## Step 2: Return results
|
|
79
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
80
|
For each result, read the first line of the file to get the title/summary.
|
|
89
81
|
|
|
90
82
|
Return in this format:
|
|
@@ -95,7 +87,7 @@ RESULTS:
|
|
|
95
87
|
TOTAL: {count}
|
|
96
88
|
```
|
|
97
89
|
|
|
98
|
-
### Step
|
|
90
|
+
### Step 3: Merge results from all subagents
|
|
99
91
|
|
|
100
92
|
After all subagents return:
|
|
101
93
|
1. Collect all results
|
|
@@ -103,7 +95,7 @@ After all subagents return:
|
|
|
103
95
|
3. Sort by score descending
|
|
104
96
|
4. Tag each result with its brain origin
|
|
105
97
|
|
|
106
|
-
### Step
|
|
98
|
+
### Step 4: Return at requested depth
|
|
107
99
|
|
|
108
100
|
**Depth 0 (default):**
|
|
109
101
|
```
|
|
@@ -67,6 +67,13 @@ Check parent/link accessibility by using the Read tool on
|
|
|
67
67
|
Depth 0 plus:
|
|
68
68
|
- Use the Read tool on `_meta/log.jsonl` (last 50 lines) to identify topic distribution from recent tag events.
|
|
69
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
|
+
- Show topic distribution for the last 7 days by searching with a `since` filter:
|
|
71
|
+
```bash
|
|
72
|
+
curl -s -X POST http://localhost:{port}/api \
|
|
73
|
+
-H "Content-Type: application/json" \
|
|
74
|
+
-d '{"action":"search","params":{"query":"*","limit":100,"since":"{iso8601_7_days_ago}"}}'
|
|
75
|
+
```
|
|
76
|
+
Group results by path prefix (e.g., `chunks/extracted/`, `wiki/`) to show recent activity distribution.
|
|
70
77
|
- List the top 10 most common tags
|
|
71
78
|
- Flag any staleness warnings (sources modified after last ingest)
|
|
72
79
|
|
|
@@ -70,6 +70,10 @@ This re-runs the installer with the latest version, updating all skills across d
|
|
|
70
70
|
|
|
71
71
|
### Step 5: Restart server if running
|
|
72
72
|
|
|
73
|
+
**IMPORTANT:** After updating, any running brain server must be restarted to pick up
|
|
74
|
+
new server code (schema migrations, new actions, updated search scoring). Failing to
|
|
75
|
+
restart means the old code serves requests even though skills expect new features.
|
|
76
|
+
|
|
73
77
|
Check if a brain server is running and restart it to pick up changes.
|
|
74
78
|
|
|
75
79
|
Find running server PIDs by searching for `server.pid` files under `_meta/` directories
|
|
@@ -97,12 +101,27 @@ For each pid file found:
|
|
|
97
101
|
5. Restart: `npx wicked-brain-server --brain "{brain_dir}" --port {port}`
|
|
98
102
|
On Windows: `Start-Process npx -ArgumentList "wicked-brain-server","--brain","{brain_dir}","--port","{port}" -NoNewWindow`
|
|
99
103
|
|
|
100
|
-
### Step 6:
|
|
104
|
+
### Step 6: Verify migration
|
|
105
|
+
|
|
106
|
+
After server restart, verify the server started successfully and migrations ran:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
curl -s -X POST http://localhost:{port}/api \
|
|
110
|
+
-H "Content-Type: application/json" \
|
|
111
|
+
-d '{"action":"health"}'
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
If health check fails, check server logs for migration errors. The server runs
|
|
115
|
+
numbered schema migrations on startup — each new version may add tables or columns
|
|
116
|
+
to the SQLite database. Migrations are automatic and idempotent.
|
|
117
|
+
|
|
118
|
+
### Step 7: Report
|
|
101
119
|
|
|
102
120
|
Tell the user what was updated:
|
|
103
121
|
- Server: v{old} -> v{new}
|
|
104
122
|
- Skills: updated in {N} CLIs
|
|
105
123
|
- Running servers: {N} restarted
|
|
124
|
+
- Schema: migrated to version {N} (check via health endpoint)
|
|
106
125
|
|
|
107
126
|
## Version check without updating
|
|
108
127
|
|