claude-brain 0.3.5 → 0.3.6
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 +3 -1
- package/VERSION +1 -1
- package/assets/CLAUDE.md +24 -296
- package/package.json +1 -1
- package/src/cli/bin.ts +8 -0
- package/src/cli/commands/install-mcp.ts +35 -16
- package/src/cli/commands/update.ts +105 -0
- package/src/config/defaults.ts +1 -1
- package/src/config/schema.ts +1 -1
package/README.md
CHANGED
|
@@ -59,6 +59,8 @@ On first run, `~/.claude-brain/` is auto-created with default config.
|
|
|
59
59
|
| `claude-brain` | Start MCP server (default) |
|
|
60
60
|
| `claude-brain setup` | Interactive setup wizard (run once per machine) |
|
|
61
61
|
| `claude-brain install` | Register as MCP server in Claude Code |
|
|
62
|
+
| `claude-brain uninstall` | Remove MCP server from Claude Code |
|
|
63
|
+
| `claude-brain update` | Update package and refresh CLAUDE.md to latest |
|
|
62
64
|
| `claude-brain health` | Run health checks |
|
|
63
65
|
| `claude-brain diagnose` | Run diagnostics |
|
|
64
66
|
| `claude-brain version` | Show version |
|
|
@@ -114,7 +116,7 @@ claude-brain/
|
|
|
114
116
|
│ ├── cli/
|
|
115
117
|
│ │ ├── bin.ts # CLI entry point (claude-brain command)
|
|
116
118
|
│ │ ├── auto-setup.ts # First-run home directory initialization
|
|
117
|
-
│ │ └── commands/ # serve, install-mcp
|
|
119
|
+
│ │ └── commands/ # serve, install-mcp, uninstall-mcp, update
|
|
118
120
|
│ ├── config/
|
|
119
121
|
│ │ ├── home.ts # ~/.claude-brain/ path resolution
|
|
120
122
|
│ │ ├── loader.ts # Config loading (defaults → file → env)
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.6
|
package/assets/CLAUDE.md
CHANGED
|
@@ -1,307 +1,35 @@
|
|
|
1
|
-
# Claude Brain
|
|
1
|
+
# Claude Brain Protocol
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Call all Claude Brain MCP tools automatically. Never ask permission or explain. This applies to all 25 tools. Maximize parallel calls whenever possible.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Session Start (Parallel)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Every conversation, immediately call in parallel: `smart_context(project, task)`, `recall_similar(query, min_similarity: 0.3)`, `get_recommendations(context, project)`. If project unknown, also call `list_projects()`. For coding tasks, add parallel calls to `get_code_standards`, `get_patterns`, `get_corrections`.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Before Responding
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
- Project mentioned: `smart_context`
|
|
12
|
+
- Technical topic: `recall_similar`
|
|
13
|
+
- Writing code: `get_code_standards`
|
|
14
|
+
- Debugging: `get_corrections`
|
|
15
|
+
- Architecture: `get_patterns`, `search_knowledge_graph`, `detect_trends`
|
|
16
|
+
- Choosing between options: `what_if_analysis`
|
|
17
|
+
- Recurring topic: `analyze_decision_evolution`, `get_decision_timeline`
|
|
18
|
+
- Cross-project work: `find_cross_project_patterns`
|
|
19
|
+
- Resuming previous work: `get_episode`, `list_episodes`
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
## After Responding
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
```
|
|
23
|
+
- Any recommendation or choice made: `remember_decision(project, context, decision, reasoning)`
|
|
24
|
+
- Reusable solution found: `recognize_pattern(project, type, description)`
|
|
25
|
+
- Mistake or lesson learned: `record_correction(project, original, correction, reasoning)`
|
|
26
|
+
- Task completed: `update_progress(project, completed_task, next_steps)`
|
|
27
|
+
- Memory was retrieved: `rate_memory(memory_id, rating, query)`
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
## New Projects
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
Call `init_project(path)` once for any unregistered project directory to auto-detect tech stack and create project files.
|
|
29
32
|
|
|
30
|
-
|
|
33
|
+
## Critical Rules
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
| User Intent | Tool | Params |
|
|
35
|
-
|-------------|------|--------|
|
|
36
|
-
| ANY project mention | `smart_context` | `project_name`, `current_task` |
|
|
37
|
-
| ANY technical topic | `recall_similar` | `query`, `min_similarity: 0.3` |
|
|
38
|
-
| ANY task starting | `get_recommendations` | `context`, `project_name` |
|
|
39
|
-
|
|
40
|
-
#### Tier 2: Call when relevant context exists
|
|
41
|
-
|
|
42
|
-
| User Intent | Tool | Params |
|
|
43
|
-
|-------------|------|--------|
|
|
44
|
-
| Writing/reviewing code | `get_code_standards` | `project_name`, `language` |
|
|
45
|
-
| Debugging/troubleshooting | `get_corrections` | `project_name`, `query` |
|
|
46
|
-
| Designing/architecting | `get_patterns` | `project_name`, `pattern_type` |
|
|
47
|
-
| Choosing between options | `what_if_analysis` | `scenario`, `project_name` |
|
|
48
|
-
| Understanding relationships | `search_knowledge_graph` | `query`, `node_type`, `max_depth` |
|
|
49
|
-
|
|
50
|
-
#### Tier 3: Call proactively for deeper intelligence
|
|
51
|
-
|
|
52
|
-
| User Intent | Tool | Params |
|
|
53
|
-
|-------------|------|--------|
|
|
54
|
-
| Revisiting a topic | `analyze_decision_evolution` | `topic`, `project_name` |
|
|
55
|
-
| Working on established project | `detect_trends` | `project_name`, `period_days` |
|
|
56
|
-
| Decision with history | `get_decision_timeline` | `query`, `project_name` |
|
|
57
|
-
| Multi-project work | `find_cross_project_patterns` | `min_projects` |
|
|
58
|
-
| Session continuity | `list_episodes` | `project_name`, `status`, `limit` |
|
|
59
|
-
| Resuming past work | `get_episode` | `episode_id` or `project_name` |
|
|
60
|
-
|
|
61
|
-
### WRITE Operations (Call AFTER Responding)
|
|
62
|
-
|
|
63
|
-
| Your Response Contains | Tool | Required Params |
|
|
64
|
-
|------------------------|------|-----------------|
|
|
65
|
-
| ANY recommendation, choice, or suggestion | `remember_decision` | `project_name`, `context`, `decision`, `reasoning` |
|
|
66
|
-
| Reusable solution or approach | `recognize_pattern` | `project_name`, `pattern_type`, `description` |
|
|
67
|
-
| Mistake discovered / lesson learned | `record_correction` | `project_name`, `original`, `correction`, `reasoning` |
|
|
68
|
-
| Task completed or milestone reached | `update_progress` | `project_name`, `completed_task`, `next_steps` |
|
|
69
|
-
| Memory was useful (rating 4-5) or not (1-2) | `rate_memory` | `memory_id`, `rating`, `query` |
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## Proactive Intelligence Rules
|
|
74
|
-
|
|
75
|
-
### Rule 1: Always Get Recommendations Before Major Work
|
|
76
|
-
Before implementing any feature, fixing any bug, or making any architectural choice:
|
|
77
|
-
```
|
|
78
|
-
get_recommendations(context: "what you're about to do", project_name)
|
|
79
|
-
```
|
|
80
|
-
This pulls from patterns, corrections, AND past decisions to give you the best starting point.
|
|
81
|
-
|
|
82
|
-
### Rule 2: Always Check Decision Evolution for Recurring Topics
|
|
83
|
-
If the user asks about something they've worked on before (databases, auth, state management, etc.):
|
|
84
|
-
```
|
|
85
|
-
analyze_decision_evolution(topic: "the topic", project_name)
|
|
86
|
-
```
|
|
87
|
-
This shows if past decisions were stable, evolving, or volatile — and the current direction.
|
|
88
|
-
|
|
89
|
-
### Rule 3: Run What-If When Choosing Between Alternatives
|
|
90
|
-
When the user is deciding between options (library A vs B, approach X vs Y):
|
|
91
|
-
```
|
|
92
|
-
what_if_analysis(scenario: "What if we switch from X to Y?", project_name)
|
|
93
|
-
```
|
|
94
|
-
This uses the knowledge graph to trace impact chains.
|
|
95
|
-
|
|
96
|
-
### Rule 4: Check Cross-Project Patterns When Starting New Features
|
|
97
|
-
When implementing something that other projects might have solved:
|
|
98
|
-
```
|
|
99
|
-
find_cross_project_patterns(min_projects: 1)
|
|
100
|
-
```
|
|
101
|
-
This discovers shared solutions across all registered projects.
|
|
102
|
-
|
|
103
|
-
### Rule 5: Check Trends Periodically
|
|
104
|
-
When working on architecture or technology choices:
|
|
105
|
-
```
|
|
106
|
-
detect_trends(project_name, period_days: 90)
|
|
107
|
-
```
|
|
108
|
-
This shows what technologies are emerging, stable, or declining in the project.
|
|
109
|
-
|
|
110
|
-
### Rule 6: Use Knowledge Graph for Technology Relationships
|
|
111
|
-
When discussing technology choices, dependencies, or architecture:
|
|
112
|
-
```
|
|
113
|
-
search_knowledge_graph(query: "technology or concept", node_type: "technology")
|
|
114
|
-
```
|
|
115
|
-
This reveals connections between technologies, decisions, and concepts.
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
## Decision Tree: Complete
|
|
120
|
-
|
|
121
|
-
```
|
|
122
|
-
User message received
|
|
123
|
-
│
|
|
124
|
-
├─► Mentions project name?
|
|
125
|
-
│ └─► YES: smart_context(project, task) [PARALLEL with below]
|
|
126
|
-
│
|
|
127
|
-
├─► Technical question or task?
|
|
128
|
-
│ ├─► YES: recall_similar(query) [PARALLEL with above]
|
|
129
|
-
│ └─► YES: get_recommendations(context) [PARALLEL with above]
|
|
130
|
-
│
|
|
131
|
-
├─► Writing/reviewing code?
|
|
132
|
-
│ └─► YES: get_code_standards(project, language)
|
|
133
|
-
│
|
|
134
|
-
├─► Debugging something?
|
|
135
|
-
│ └─► YES: get_corrections(project, query)
|
|
136
|
-
│
|
|
137
|
-
├─► Designing architecture?
|
|
138
|
-
│ ├─► YES: get_patterns(project, "solution")
|
|
139
|
-
│ ├─► YES: search_knowledge_graph(query, "technology")
|
|
140
|
-
│ └─► YES: detect_trends(project)
|
|
141
|
-
│
|
|
142
|
-
├─► Choosing between options?
|
|
143
|
-
│ └─► YES: what_if_analysis(scenario)
|
|
144
|
-
│
|
|
145
|
-
├─► Topic discussed before?
|
|
146
|
-
│ └─► YES: analyze_decision_evolution(topic)
|
|
147
|
-
│ + get_decision_timeline(query)
|
|
148
|
-
│
|
|
149
|
-
├─► Working across projects?
|
|
150
|
-
│ └─► YES: find_cross_project_patterns()
|
|
151
|
-
│
|
|
152
|
-
├─► Resuming previous work?
|
|
153
|
-
│ └─► YES: get_episode(project) + list_episodes(project)
|
|
154
|
-
│
|
|
155
|
-
└─► New project encountered?
|
|
156
|
-
└─► YES: init_project(project_path)
|
|
157
|
-
|
|
158
|
-
After your response:
|
|
159
|
-
│
|
|
160
|
-
├─► Made ANY recommendation or choice?
|
|
161
|
-
│ └─► YES: remember_decision(...)
|
|
162
|
-
│
|
|
163
|
-
├─► Found reusable solution?
|
|
164
|
-
│ └─► YES: recognize_pattern(...)
|
|
165
|
-
│
|
|
166
|
-
├─► Learned from mistake?
|
|
167
|
-
│ └─► YES: record_correction(...)
|
|
168
|
-
│
|
|
169
|
-
├─► Completed work?
|
|
170
|
-
│ └─► YES: update_progress(...)
|
|
171
|
-
│
|
|
172
|
-
└─► Memory was retrieved?
|
|
173
|
-
└─► YES: rate_memory(memory_id, rating, query)
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
---
|
|
177
|
-
|
|
178
|
-
## Tool Reference (All 25 Tools)
|
|
179
|
-
|
|
180
|
-
### Context Retrieval (5)
|
|
181
|
-
- **`smart_context`** - Primary tool. Gets project + auto-recalls relevant memories
|
|
182
|
-
- **`recall_similar`** - Semantic search across all memory. Use `min_similarity: 0.3`
|
|
183
|
-
- **`get_patterns`** - Types: `solution`, `anti-pattern`, `best-practice`, `common-issue`
|
|
184
|
-
- **`get_corrections`** - Past mistakes relevant to current task
|
|
185
|
-
- **`get_code_standards`** - Project coding conventions
|
|
186
|
-
|
|
187
|
-
### Memory Storage (5)
|
|
188
|
-
- **`remember_decision`** - Store decisions with: context, decision, reasoning, tags
|
|
189
|
-
- **`recognize_pattern`** - Store reusable solutions/anti-patterns with confidence
|
|
190
|
-
- **`record_correction`** - Store mistakes: original, correction, reasoning
|
|
191
|
-
- **`update_progress`** - Track: completed_task, next_steps
|
|
192
|
-
- **`rate_memory`** - Rate retrieved memories 1-5 stars for adaptive learning
|
|
193
|
-
|
|
194
|
-
### Knowledge Graph & Episodic Memory (3)
|
|
195
|
-
- **`search_knowledge_graph`** - Search connected nodes/edges by query, node type, or start node
|
|
196
|
-
- **`get_episode`** - Get episode by ID or active episode for a project
|
|
197
|
-
- **`list_episodes`** - List recent episodes, filter by project or status
|
|
198
|
-
|
|
199
|
-
### Advanced Intelligence (6)
|
|
200
|
-
- **`get_decision_timeline`** - Chronological timeline with temporal queries ("last month", "since January")
|
|
201
|
-
- **`analyze_decision_evolution`** - Track how decisions on a topic changed (stable/evolving/volatile)
|
|
202
|
-
- **`detect_trends`** - Detect emerging, stable, declining technology/pattern trends
|
|
203
|
-
- **`what_if_analysis`** - Counterfactual: "What if we switched from X to Y?"
|
|
204
|
-
- **`get_recommendations`** - Context-aware recommendations from patterns + corrections + decisions
|
|
205
|
-
- **`find_cross_project_patterns`** - Discover shared patterns across all projects
|
|
206
|
-
|
|
207
|
-
### Project Management (3)
|
|
208
|
-
- **`list_projects`** - See available projects (status_filter: active/archived/all)
|
|
209
|
-
- **`init_project`** - Initialize from existing codebase (auto-detects tech stack)
|
|
210
|
-
- **`create_project`** - New project from scratch
|
|
211
|
-
|
|
212
|
-
### System (3)
|
|
213
|
-
- **`auto_remember`** - Auto-detect decisions in text (>70% confidence auto-saved)
|
|
214
|
-
- **`get_phase12_status`** - System health and automation stats
|
|
215
|
-
- **`get_project_context`** - Raw project context without smart recall
|
|
216
|
-
|
|
217
|
-
---
|
|
218
|
-
|
|
219
|
-
## Parallel Call Patterns
|
|
220
|
-
|
|
221
|
-
**Session Start (3 parallel calls):**
|
|
222
|
-
```
|
|
223
|
-
smart_context("project", "task")
|
|
224
|
-
recall_similar("task description", min_similarity: 0.3)
|
|
225
|
-
get_recommendations("task description", "project")
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
**Before Coding (3 parallel calls):**
|
|
229
|
-
```
|
|
230
|
-
get_code_standards("project", "typescript")
|
|
231
|
-
get_patterns("project", query: "feature area")
|
|
232
|
-
get_corrections("project", query: "feature area")
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
**Architecture Discussion (3 parallel calls):**
|
|
236
|
-
```
|
|
237
|
-
search_knowledge_graph("technology", node_type: "technology")
|
|
238
|
-
detect_trends("project")
|
|
239
|
-
analyze_decision_evolution("topic", "project")
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
**Choosing Between Options (2 parallel calls):**
|
|
243
|
-
```
|
|
244
|
-
what_if_analysis("What if we use X instead of Y?", "project")
|
|
245
|
-
find_cross_project_patterns(min_projects: 1)
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
**After Task Completion (2-3 parallel calls):**
|
|
249
|
-
```
|
|
250
|
-
remember_decision(...)
|
|
251
|
-
update_progress(...)
|
|
252
|
-
recognize_pattern(...) // if reusable
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
---
|
|
256
|
-
|
|
257
|
-
## Save Decision Triggers
|
|
258
|
-
|
|
259
|
-
**ALWAYS call `remember_decision` when your response contains:**
|
|
260
|
-
- "I recommend..." / "We should use..." / "The best approach is..."
|
|
261
|
-
- "Let's use X because..." / "Don't use X" / "Avoid X"
|
|
262
|
-
- "Always do X" / "Never do Y"
|
|
263
|
-
- Any architecture/library/framework/tool choice
|
|
264
|
-
- Any coding standard or convention established
|
|
265
|
-
- Any debugging insight or root cause identified
|
|
266
|
-
- Any performance optimization chosen
|
|
267
|
-
- Any security or deployment decision
|
|
268
|
-
|
|
269
|
-
---
|
|
270
|
-
|
|
271
|
-
## New Project Auto-Detection
|
|
272
|
-
|
|
273
|
-
When you encounter a project directory that is NOT yet registered in Claude Brain:
|
|
274
|
-
1. Call `init_project(project_path)` to auto-detect tech stack and create project files
|
|
275
|
-
2. This only needs to happen ONCE per project — it analyzes package.json, config files, etc.
|
|
276
|
-
3. After init, all subsequent sessions automatically have full project context
|
|
277
|
-
|
|
278
|
-
---
|
|
279
|
-
|
|
280
|
-
## Anti-Patterns (What NOT to Do)
|
|
281
|
-
|
|
282
|
-
1. **Never answer technical questions without first calling `recall_similar`**
|
|
283
|
-
2. **Never make recommendations without saving via `remember_decision`**
|
|
284
|
-
3. **Never start project work without `smart_context`**
|
|
285
|
-
4. **Never ask permission to call Claude Brain tools — just call them**
|
|
286
|
-
5. **Never skip `get_recommendations` before major implementation work**
|
|
287
|
-
6. **Never ignore Phase 15 tools — they provide the deepest intelligence**
|
|
288
|
-
7. **Never forget to `rate_memory` when a recall was particularly useful or useless**
|
|
289
|
-
8. **Never work on a new project without calling `init_project` first**
|
|
290
|
-
|
|
291
|
-
---
|
|
292
|
-
|
|
293
|
-
## System Notes
|
|
294
|
-
|
|
295
|
-
- **25 MCP Tools**: Full coverage across context, memory, knowledge graph, and advanced intelligence
|
|
296
|
-
- **Duplicate Prevention**: Decisions with >90% similarity auto-deduplicated
|
|
297
|
-
- **Knowledge Graph**: Auto-populates when decisions are stored — extracts entities and relationships
|
|
298
|
-
- **Episodic Memory**: Tracks sessions with automatic detection and summarization
|
|
299
|
-
- **Memory Consolidation**: Importance scoring, automatic merging, low-importance archival
|
|
300
|
-
- **Hybrid Retrieval**: BM25 + semantic fusion with cross-encoder reranking
|
|
301
|
-
- **Temporal Intelligence**: Timelines, evolution tracking, trend detection with natural language dates
|
|
302
|
-
- **Multi-Hop Reasoning**: Chain retrieval with query refinement and what-if analysis
|
|
303
|
-
- **Predictive Intelligence**: Context-aware recommendations from all stored knowledge
|
|
304
|
-
- **Cross-Project Intelligence**: Pattern discovery, affinity, and knowledge transfer
|
|
305
|
-
- **Semantic Caching**: LRU cache for fast repeated queries
|
|
306
|
-
- **Embedding**: all-MiniLM-L6-v2 (384d), SHA-256 cached
|
|
307
|
-
- **Input Validation**: Zod schemas validate all inputs
|
|
35
|
+
Never answer technical questions without `recall_similar` first. Never recommend without saving via `remember_decision`. Never start project work without `smart_context`. Always call `get_recommendations` before major implementation work. Always call `rate_memory` when memories are retrieved.
|
package/package.json
CHANGED
package/src/cli/bin.ts
CHANGED
|
@@ -30,6 +30,7 @@ function printHelp() {
|
|
|
30
30
|
['setup', 'Run interactive setup wizard'],
|
|
31
31
|
['install', 'Register as MCP server in Claude Code'],
|
|
32
32
|
['uninstall', 'Remove MCP server from Claude Code'],
|
|
33
|
+
['update', 'Update package and refresh CLAUDE.md'],
|
|
33
34
|
['health', 'Run health checks'],
|
|
34
35
|
['diagnose', 'Run diagnostics'],
|
|
35
36
|
['version', 'Show version'],
|
|
@@ -56,6 +57,7 @@ function printHelp() {
|
|
|
56
57
|
` ${dimText('claude-brain')} ${dimText('Start MCP server')}`,
|
|
57
58
|
` ${dimText('claude-brain setup')} ${dimText('Configure Claude Brain')}`,
|
|
58
59
|
` ${dimText('claude-brain install')} ${dimText('Register with Claude Code')}`,
|
|
60
|
+
` ${dimText('claude-brain update')} ${dimText('Update to latest version')}`,
|
|
59
61
|
` ${dimText('claude-brain health')} ${dimText('Check system health')}`,
|
|
60
62
|
'',
|
|
61
63
|
theme.bold('Environment:'),
|
|
@@ -94,6 +96,12 @@ async function main() {
|
|
|
94
96
|
break
|
|
95
97
|
}
|
|
96
98
|
|
|
99
|
+
case 'update': {
|
|
100
|
+
const { runUpdate } = await import('./commands/update')
|
|
101
|
+
await runUpdate()
|
|
102
|
+
break
|
|
103
|
+
}
|
|
104
|
+
|
|
97
105
|
case 'health': {
|
|
98
106
|
const { runHealthCheck } = await import('@/health')
|
|
99
107
|
await runHealthCheck()
|
|
@@ -14,6 +14,15 @@ function isGloballyInstalled(): boolean {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
function isMcpAlreadyConfigured(): boolean {
|
|
18
|
+
try {
|
|
19
|
+
const result = execSync('claude mcp list', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] })
|
|
20
|
+
return result.includes('claude-brain')
|
|
21
|
+
} catch {
|
|
22
|
+
return false
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
17
26
|
export async function runInstall() {
|
|
18
27
|
console.log()
|
|
19
28
|
console.log(renderLogo())
|
|
@@ -27,23 +36,33 @@ export async function runInstall() {
|
|
|
27
36
|
console.log(successText('claude-brain is globally installed'))
|
|
28
37
|
console.log()
|
|
29
38
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
if (isMcpAlreadyConfigured()) {
|
|
40
|
+
console.log(box(successText('Already MCP configured. Claude Brain is registered as an MCP server.'), 'Success'))
|
|
41
|
+
} else {
|
|
42
|
+
try {
|
|
43
|
+
await withSpinner('Registering with Claude Code', async () => {
|
|
44
|
+
execSync('claude mcp add claude-brain -- claude-brain serve', {
|
|
45
|
+
encoding: 'utf-8',
|
|
46
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
47
|
+
})
|
|
35
48
|
})
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
console.log()
|
|
50
|
+
console.log(box(successText('Claude Brain registered as MCP server in Claude Code.'), 'Success'))
|
|
51
|
+
} catch (err) {
|
|
52
|
+
const errorMsg = err instanceof Error ? err.message : String(err)
|
|
53
|
+
if (errorMsg.includes('already') || errorMsg.includes('exists')) {
|
|
54
|
+
console.log()
|
|
55
|
+
console.log(box(successText('Already MCP configured. Claude Brain is registered as an MCP server.'), 'Success'))
|
|
56
|
+
} else {
|
|
57
|
+
console.log()
|
|
58
|
+
console.log(box([
|
|
59
|
+
errorText('Failed to register automatically.'),
|
|
60
|
+
'',
|
|
61
|
+
dimText('Run manually:'),
|
|
62
|
+
` ${theme.bold('claude mcp add claude-brain -- claude-brain serve')}`,
|
|
63
|
+
].join('\n'), 'Error'))
|
|
64
|
+
}
|
|
65
|
+
}
|
|
47
66
|
}
|
|
48
67
|
} else {
|
|
49
68
|
console.log(warningText('claude-brain is not globally installed'))
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process'
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
3
|
+
import fs from 'fs/promises'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
import os from 'os'
|
|
6
|
+
import { fileURLToPath } from 'url'
|
|
7
|
+
import {
|
|
8
|
+
renderLogo, theme, heading, successText, warningText, dimText,
|
|
9
|
+
box, withSpinner,
|
|
10
|
+
} from '@/cli/ui/index.js'
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
13
|
+
const __dirname = path.dirname(__filename)
|
|
14
|
+
const PACKAGE_ROOT = path.resolve(__dirname, '..', '..', '..')
|
|
15
|
+
|
|
16
|
+
function getInstalledVersion(): string {
|
|
17
|
+
try {
|
|
18
|
+
const pkg = JSON.parse(readFileSync(path.join(PACKAGE_ROOT, 'package.json'), 'utf-8'))
|
|
19
|
+
return pkg.version || 'unknown'
|
|
20
|
+
} catch {
|
|
21
|
+
return 'unknown'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getLatestVersion(): string | null {
|
|
26
|
+
try {
|
|
27
|
+
const result = execSync('npm view claude-brain version', {
|
|
28
|
+
encoding: 'utf-8',
|
|
29
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
30
|
+
})
|
|
31
|
+
return result.trim()
|
|
32
|
+
} catch {
|
|
33
|
+
return null
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function runUpdate() {
|
|
38
|
+
console.log()
|
|
39
|
+
console.log(renderLogo())
|
|
40
|
+
console.log()
|
|
41
|
+
console.log(heading('Update Claude Brain'))
|
|
42
|
+
console.log()
|
|
43
|
+
|
|
44
|
+
const currentVersion = getInstalledVersion()
|
|
45
|
+
console.log(` ${theme.bold('Installed:')} ${dimText('v' + currentVersion)}`)
|
|
46
|
+
|
|
47
|
+
const latestVersion = await withSpinner('Checking for updates', () => getLatestVersion())
|
|
48
|
+
|
|
49
|
+
if (latestVersion) {
|
|
50
|
+
console.log(` ${theme.bold('Latest:')} ${dimText('v' + latestVersion)}`)
|
|
51
|
+
}
|
|
52
|
+
console.log()
|
|
53
|
+
|
|
54
|
+
// Step 1: Update package if newer version available
|
|
55
|
+
if (latestVersion && latestVersion !== currentVersion) {
|
|
56
|
+
try {
|
|
57
|
+
await withSpinner(`Updating claude-brain to v${latestVersion}`, () => {
|
|
58
|
+
execSync('bun update -g claude-brain', {
|
|
59
|
+
encoding: 'utf-8',
|
|
60
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
console.log(successText(` Updated to v${latestVersion}`))
|
|
64
|
+
} catch {
|
|
65
|
+
console.log(warningText(' Package update failed. Try manually: bun update -g claude-brain'))
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
console.log(successText(' Package is up to date'))
|
|
69
|
+
}
|
|
70
|
+
console.log()
|
|
71
|
+
|
|
72
|
+
// Step 2: Update CLAUDE.md
|
|
73
|
+
const sourcePath = path.join(PACKAGE_ROOT, 'assets', 'CLAUDE.md')
|
|
74
|
+
const destPath = path.join(os.homedir(), 'CLAUDE.md')
|
|
75
|
+
|
|
76
|
+
if (!existsSync(sourcePath)) {
|
|
77
|
+
console.log(warningText(' CLAUDE.md asset not found in package, skipping'))
|
|
78
|
+
} else if (!existsSync(destPath)) {
|
|
79
|
+
await withSpinner('Installing CLAUDE.md', async () => {
|
|
80
|
+
await fs.copyFile(sourcePath, destPath)
|
|
81
|
+
})
|
|
82
|
+
console.log(successText(' CLAUDE.md installed to ~/CLAUDE.md'))
|
|
83
|
+
} else {
|
|
84
|
+
const sourceContent = readFileSync(sourcePath, 'utf-8')
|
|
85
|
+
const destContent = readFileSync(destPath, 'utf-8')
|
|
86
|
+
|
|
87
|
+
if (sourceContent === destContent) {
|
|
88
|
+
console.log(successText(' CLAUDE.md is already up to date'))
|
|
89
|
+
} else {
|
|
90
|
+
await withSpinner('Updating CLAUDE.md', async () => {
|
|
91
|
+
await fs.copyFile(sourcePath, destPath)
|
|
92
|
+
})
|
|
93
|
+
console.log(successText(' CLAUDE.md updated to latest version'))
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
console.log()
|
|
98
|
+
console.log(box([
|
|
99
|
+
heading('Update complete!'),
|
|
100
|
+
'',
|
|
101
|
+
dimText('Run health check to verify:'),
|
|
102
|
+
` ${theme.bold('claude-brain health')}`,
|
|
103
|
+
].join('\n'), 'Done'))
|
|
104
|
+
console.log()
|
|
105
|
+
}
|
package/src/config/defaults.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { PartialConfig } from './schema'
|
|
|
3
3
|
/** Default configuration values for Claude Brain */
|
|
4
4
|
export const defaultConfig: PartialConfig = {
|
|
5
5
|
serverName: 'claude-brain',
|
|
6
|
-
serverVersion: '0.3.
|
|
6
|
+
serverVersion: '0.3.6',
|
|
7
7
|
logLevel: 'info',
|
|
8
8
|
logFilePath: './logs/claude-brain.log',
|
|
9
9
|
dbPath: './data/memory.db',
|
package/src/config/schema.ts
CHANGED
|
@@ -196,7 +196,7 @@ export const ConfigSchema = z.object({
|
|
|
196
196
|
serverName: z.string().default('claude-brain'),
|
|
197
197
|
|
|
198
198
|
/** Server version in semver format */
|
|
199
|
-
serverVersion: z.string().regex(/^\d+\.\d+\.\d+$/, 'Version must be semver format').default('0.3.
|
|
199
|
+
serverVersion: z.string().regex(/^\d+\.\d+\.\d+$/, 'Version must be semver format').default('0.3.6'),
|
|
200
200
|
|
|
201
201
|
/** Logging level */
|
|
202
202
|
logLevel: LogLevelSchema.default('info'),
|