bluera-knowledge 0.30.0 → 0.32.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/.claude-plugin/plugin.json +24 -0
- package/.mcp.json +13 -0
- package/CHANGELOG.md +37 -0
- package/NOTICE +47 -0
- package/README.md +2 -2
- package/bun.lock +1978 -0
- package/commands/add-folder.md +48 -0
- package/commands/add-repo.md +50 -0
- package/commands/cancel.md +63 -0
- package/commands/check-status.md +130 -0
- package/commands/crawl.md +61 -0
- package/commands/doctor.md +27 -0
- package/commands/eval.md +222 -0
- package/commands/health.md +72 -0
- package/commands/index.md +48 -0
- package/commands/remove-store.md +52 -0
- package/commands/search.md +80 -0
- package/commands/search.sh +63 -0
- package/commands/skill-activation.md +131 -0
- package/commands/stores.md +54 -0
- package/commands/suggest.md +118 -0
- package/commands/sync.md +96 -0
- package/commands/test-plugin.md +547 -0
- package/commands/uninstall.md +65 -0
- package/dist/{chunk-B335UOU7.js → chunk-3TB7TDVF.js} +24 -3
- package/dist/chunk-3TB7TDVF.js.map +1 -0
- package/dist/{chunk-KCI4U6FH.js → chunk-KDZDLJUY.js} +2 -2
- package/dist/{chunk-AEXFPA57.js → chunk-YDTTD53Y.js} +158 -26
- package/dist/chunk-YDTTD53Y.js.map +1 -0
- package/dist/index.js +3 -3
- package/dist/mcp/bootstrap.js +10 -0
- package/dist/mcp/bootstrap.js.map +1 -1
- package/dist/mcp/server.d.ts +5 -3
- package/dist/mcp/server.js +2 -2
- package/dist/workers/background-worker-cli.js +2 -2
- package/hooks/check-ready.sh +109 -0
- package/hooks/hooks.json +87 -0
- package/hooks/job-status-hook.sh +51 -0
- package/hooks/posttooluse-bk-reminder.py +126 -0
- package/hooks/posttooluse-web-research.py +209 -0
- package/hooks/pretooluse-bk-suggest.py +296 -0
- package/hooks/skill-activation.py +221 -0
- package/hooks/skill-rules.json +131 -0
- package/package.json +10 -2
- package/scripts/CLAUDE.md +65 -0
- package/scripts/auto-setup.sh +65 -0
- package/scripts/bench-regression.sh +345 -0
- package/scripts/dev.sh +16 -0
- package/scripts/doctor.sh +103 -0
- package/scripts/download-models.ts +188 -0
- package/scripts/export-web-store.ts +142 -0
- package/scripts/lib/mock-server.sh +70 -0
- package/scripts/mcp-wrapper.sh +91 -0
- package/scripts/setup.sh +224 -0
- package/scripts/test-mcp-dev.js +260 -0
- package/scripts/validate-local.sh +412 -0
- package/scripts/validate-npm-release.sh +406 -0
- package/skills/advanced-workflows/SKILL.md +273 -0
- package/skills/knowledge-search/SKILL.md +110 -0
- package/skills/search-optimization/SKILL.md +199 -0
- package/skills/search-optimization/references/mistakes.md +21 -0
- package/skills/search-optimization/references/strategies.md +80 -0
- package/skills/store-lifecycle/SKILL.md +470 -0
- package/skills/when-to-query/SKILL.md +160 -0
- package/dist/chunk-AEXFPA57.js.map +0 -1
- package/dist/chunk-B335UOU7.js.map +0 -1
- /package/dist/{chunk-KCI4U6FH.js.map → chunk-KDZDLJUY.js.map} +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: knowledge-search
|
|
3
|
+
description: Query BK for library internals via vector search or direct Grep/Read
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Using Bluera Knowledge (BK)
|
|
7
|
+
|
|
8
|
+
BK provides access to **definitive library sources** for your project dependencies.
|
|
9
|
+
|
|
10
|
+
## The Rule: Query BK for External Code
|
|
11
|
+
|
|
12
|
+
**Any question about libraries, dependencies, or indexed reference material should query BK.**
|
|
13
|
+
|
|
14
|
+
BK is:
|
|
15
|
+
- **Cheap**: ~100ms response, unlimited queries, no rate limits
|
|
16
|
+
- **Authoritative**: Actual source code, not blog posts or training data
|
|
17
|
+
- **Complete**: Includes tests, examples, internal APIs, configuration
|
|
18
|
+
|
|
19
|
+
## Always Query BK For:
|
|
20
|
+
|
|
21
|
+
**Library implementation:**
|
|
22
|
+
- "How does Express handle middleware errors?"
|
|
23
|
+
- "What does React's useEffect cleanup actually do?"
|
|
24
|
+
- "How is Pydantic validation implemented?"
|
|
25
|
+
|
|
26
|
+
**API signatures and options:**
|
|
27
|
+
- "What parameters does axios.create() accept?"
|
|
28
|
+
- "What options can I pass to hono.use()?"
|
|
29
|
+
- "What's the signature of zod.object()?"
|
|
30
|
+
|
|
31
|
+
**Error handling:**
|
|
32
|
+
- "What errors can this library throw?"
|
|
33
|
+
- "Why might this function return undefined?"
|
|
34
|
+
- "What validation does Zod perform?"
|
|
35
|
+
|
|
36
|
+
**Version-specific behavior:**
|
|
37
|
+
- "What changed in React 18?"
|
|
38
|
+
- "Is this deprecated in Express 5?"
|
|
39
|
+
- "Does my version support this?"
|
|
40
|
+
|
|
41
|
+
**Configuration:**
|
|
42
|
+
- "What config options exist for Vite?"
|
|
43
|
+
- "What are the default values?"
|
|
44
|
+
- "What environment variables does this use?"
|
|
45
|
+
|
|
46
|
+
**Testing:**
|
|
47
|
+
- "How do the library authors test this?"
|
|
48
|
+
- "How should I mock this in tests?"
|
|
49
|
+
- "What edge cases do the tests cover?"
|
|
50
|
+
|
|
51
|
+
**Performance:**
|
|
52
|
+
- "Is this cached internally?"
|
|
53
|
+
- "What's the complexity of this operation?"
|
|
54
|
+
- "Does this run async or sync?"
|
|
55
|
+
|
|
56
|
+
**Security:**
|
|
57
|
+
- "How does this validate input?"
|
|
58
|
+
- "Is this safe against injection?"
|
|
59
|
+
- "How are credentials handled?"
|
|
60
|
+
|
|
61
|
+
**Integration:**
|
|
62
|
+
- "How do I integrate X with Y?"
|
|
63
|
+
- "What's the idiomatic usage pattern?"
|
|
64
|
+
- "How do examples in the library do this?"
|
|
65
|
+
|
|
66
|
+
## Two Ways to Access Library Sources
|
|
67
|
+
|
|
68
|
+
### 1. Vector Search (Discovery)
|
|
69
|
+
Find concepts and patterns across indexed content:
|
|
70
|
+
```
|
|
71
|
+
search("vue reactivity system")
|
|
72
|
+
/bluera-knowledge:search "pydantic custom validators"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 2. Direct File Access (Precision)
|
|
76
|
+
Precise lookups in cloned library source:
|
|
77
|
+
```
|
|
78
|
+
Grep: pattern="defineReactive" path=".bluera/bluera-knowledge/repos/vue/"
|
|
79
|
+
Read: .bluera/bluera-knowledge/repos/pydantic/pydantic/validators.py
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Both are valid! Use vector search for discovery, Grep/Read for specific functions.
|
|
83
|
+
|
|
84
|
+
## DO NOT Query BK For:
|
|
85
|
+
|
|
86
|
+
- **Your project code** → Use Grep/Read directly
|
|
87
|
+
- **General concepts** → Use training data ("What is a closure?")
|
|
88
|
+
- **Breaking news** → Use web search ("Latest React release")
|
|
89
|
+
|
|
90
|
+
## Example Workflow
|
|
91
|
+
|
|
92
|
+
User: "How does Vue's computed properties work internally?"
|
|
93
|
+
|
|
94
|
+
Claude:
|
|
95
|
+
1. Check stores: `list_stores` MCP tool → vue store exists
|
|
96
|
+
2. Vector search: `search("vue computed properties")` → finds computed.ts
|
|
97
|
+
3. Read file: `.bluera/bluera-knowledge/repos/vue/packages/reactivity/src/computed.ts`
|
|
98
|
+
4. Grep for implementation: pattern="class ComputedRefImpl"
|
|
99
|
+
5. Explain with authoritative source code examples
|
|
100
|
+
|
|
101
|
+
## Quick Reference
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
[library] question → Query BK
|
|
105
|
+
[your code] question → Grep/Read directly
|
|
106
|
+
[concept] question → Training data
|
|
107
|
+
[news/updates] question → Web search
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
BK is cheap and fast. Query it liberally for library questions.
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: search-optimization
|
|
3
|
+
description: Optimize BK search with intent, detail level, and store filtering
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Optimizing Bluera Knowledge Search
|
|
7
|
+
|
|
8
|
+
Master the `search()` MCP tool parameters to get better results with less context usage.
|
|
9
|
+
|
|
10
|
+
## Understanding Search Parameters
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
search(
|
|
14
|
+
query: string, // Your search query
|
|
15
|
+
intent?: SearchIntent, // What you're looking for
|
|
16
|
+
detail?: 'minimal' | 'contextual' | 'full', // How much context to return
|
|
17
|
+
limit?: number, // Max results (default: 10)
|
|
18
|
+
stores?: string[] // Which stores to search
|
|
19
|
+
)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Search Intent: Choosing the Right Type
|
|
23
|
+
|
|
24
|
+
The `intent` parameter helps the search engine rank results appropriately for your query type.
|
|
25
|
+
|
|
26
|
+
### Intent Decision Tree
|
|
27
|
+
|
|
28
|
+
**Looking for implementation details? Use `find-implementation`**
|
|
29
|
+
- "How does X work internally?"
|
|
30
|
+
- "Show me the implementation of Y"
|
|
31
|
+
- "What's inside the Z class/function?"
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
search("Vue computed properties implementation", intent='find-implementation')
|
|
35
|
+
→ Prioritizes: actual class/function implementations
|
|
36
|
+
→ Ranks higher: ComputedRefImpl class, createComputed() function
|
|
37
|
+
→ Ranks lower: tests, documentation, examples
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Looking for usage patterns? Use `find-pattern`**
|
|
41
|
+
- "How to use X?"
|
|
42
|
+
- "Examples of Y pattern"
|
|
43
|
+
- "Common ways to implement Z"
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
search("React hooks patterns", intent='find-pattern')
|
|
47
|
+
→ Prioritizes: example code, usage patterns, HOCs
|
|
48
|
+
→ Ranks higher: common patterns like useEffect cleanup
|
|
49
|
+
→ Ranks lower: internal implementation details
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Looking for references? Use `find-usage`**
|
|
53
|
+
- "Where is X used?"
|
|
54
|
+
- "Find all calls to Y"
|
|
55
|
+
- "What depends on Z?"
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
search("useCallback usage", intent='find-usage')
|
|
59
|
+
→ Prioritizes: call sites, import statements
|
|
60
|
+
→ Ranks higher: files importing and using useCallback
|
|
61
|
+
→ Ranks lower: useCallback's own implementation
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Looking for definitions/APIs? Use `find-definition`**
|
|
65
|
+
- "What is the API for X?"
|
|
66
|
+
- "Show me the type definition of Y"
|
|
67
|
+
- "What are the parameters for Z?"
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
search("FastAPI route decorator", intent='find-definition')
|
|
71
|
+
→ Prioritizes: function signatures, type definitions
|
|
72
|
+
→ Ranks higher: @app.get() decorator definition
|
|
73
|
+
→ Ranks lower: examples using the decorator
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Looking for documentation? Use `find-documentation`**
|
|
77
|
+
- "What does the doc say about X?"
|
|
78
|
+
- "Explain Y from the documentation"
|
|
79
|
+
- "API reference for Z"
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
search("Pydantic validators documentation", intent='find-documentation')
|
|
83
|
+
→ Prioritizes: README, docstrings, comments
|
|
84
|
+
→ Ranks higher: markdown docs, inline documentation
|
|
85
|
+
→ Ranks lower: implementation code
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Default (No Intent)
|
|
89
|
+
|
|
90
|
+
If unsure, omit `intent` - the search engine will use hybrid ranking:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
search("authentication middleware")
|
|
94
|
+
→ Returns mixed: implementations, patterns, usage, docs
|
|
95
|
+
→ Balanced ranking across all categories
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Detail Level: Progressive Context Strategy
|
|
99
|
+
|
|
100
|
+
The `detail` parameter controls how much code context is returned **per result**.
|
|
101
|
+
|
|
102
|
+
### Detail Levels Explained
|
|
103
|
+
|
|
104
|
+
| Level | What You Get | Tokens/Result | Use When |
|
|
105
|
+
|-------|--------------|---------------|----------|
|
|
106
|
+
| `minimal` | Summary, file path, relevance | ~100 | Browsing many results |
|
|
107
|
+
| `contextual` | + imports, types, signatures | ~300 | Need interface context |
|
|
108
|
+
| `full` | + complete code, all context | ~800 | Deep dive on specific file |
|
|
109
|
+
|
|
110
|
+
### Progressive Detail Strategy (Recommended)
|
|
111
|
+
|
|
112
|
+
**Step 1: Start Minimal**
|
|
113
|
+
```
|
|
114
|
+
search(query, detail='minimal', limit=20)
|
|
115
|
+
→ Get 20 summaries (~2k tokens total)
|
|
116
|
+
→ Scan quickly for relevance
|
|
117
|
+
→ Identify top 3-5 candidates
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Step 2: Evaluate Scores**
|
|
121
|
+
```
|
|
122
|
+
Review relevance scores:
|
|
123
|
+
- 0.9-1.0: Excellent match (almost certainly relevant)
|
|
124
|
+
- 0.7-0.9: Strong match (very likely relevant)
|
|
125
|
+
- 0.5-0.7: Moderate match (possibly relevant)
|
|
126
|
+
- < 0.5: Weak match (probably not relevant)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Step 3: Selective Deep Dive**
|
|
130
|
+
```
|
|
131
|
+
For top results (score > 0.7):
|
|
132
|
+
get_full_context(result_ids)
|
|
133
|
+
→ Fetch complete code only for relevant items
|
|
134
|
+
|
|
135
|
+
For moderate results (score 0.5-0.7):
|
|
136
|
+
search(refined_query, detail='contextual')
|
|
137
|
+
→ Try different query with more context
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Result Limiting
|
|
141
|
+
|
|
142
|
+
The `limit` parameter caps the number of results returned.
|
|
143
|
+
|
|
144
|
+
### Choosing the Right Limit
|
|
145
|
+
|
|
146
|
+
| Limit | Mode | Use When |
|
|
147
|
+
|-------|------|----------|
|
|
148
|
+
| 20-50 | Discovery | Exploring, not sure what exists |
|
|
149
|
+
| 10-20 | Standard | Specific question, multiple files |
|
|
150
|
+
| 3-5 | Targeted | Know exactly what you need |
|
|
151
|
+
|
|
152
|
+
**Tip**: Large limits work best with `detail='minimal'` to control tokens.
|
|
153
|
+
|
|
154
|
+
## Store Filtering
|
|
155
|
+
|
|
156
|
+
The `stores` parameter restricts search to specific knowledge stores.
|
|
157
|
+
|
|
158
|
+
### When to Filter Stores
|
|
159
|
+
|
|
160
|
+
**✅ Filter when:** You know the library, comparing specific libs, want focused results
|
|
161
|
+
|
|
162
|
+
**❌ Don't filter when:** Discovering where code lives, want cross-library perspective
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
# Check available stores first
|
|
166
|
+
list_stores()
|
|
167
|
+
|
|
168
|
+
# Then filter
|
|
169
|
+
search(query, stores=['fastapi', 'express'])
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Quick Reference
|
|
173
|
+
|
|
174
|
+
### High-Efficiency Defaults
|
|
175
|
+
```
|
|
176
|
+
search(query, detail='minimal', limit=20)
|
|
177
|
+
→ Good for most discovery tasks
|
|
178
|
+
→ Review, then selectively fetch full context
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### High-Precision Defaults
|
|
182
|
+
```
|
|
183
|
+
search(query, intent='find-implementation', detail='full', limit=5, stores=['known-lib'])
|
|
184
|
+
→ When you know exactly what you're looking for
|
|
185
|
+
→ Fastest path to deep answer
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Balanced Defaults
|
|
189
|
+
```
|
|
190
|
+
search(query, detail='contextual', limit=10)
|
|
191
|
+
→ Good middle ground
|
|
192
|
+
→ See interfaces without full implementation
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Deep Dive
|
|
196
|
+
|
|
197
|
+
For advanced strategies and token optimization examples:
|
|
198
|
+
- @references/strategies.md - Combined optimization strategies with token counts
|
|
199
|
+
- @references/mistakes.md - Common mistakes to avoid
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Common Mistakes to Avoid
|
|
2
|
+
|
|
3
|
+
1. **Using detail='full' with limit=50**
|
|
4
|
+
- Result: ~40k tokens consumed
|
|
5
|
+
- Fix: Start with detail='minimal', escalate selectively
|
|
6
|
+
|
|
7
|
+
2. **Not using intent parameter**
|
|
8
|
+
- Result: Mixed ranking, less relevant results
|
|
9
|
+
- Fix: Choose intent based on query type
|
|
10
|
+
|
|
11
|
+
3. **Over-filtering stores too early**
|
|
12
|
+
- Result: Miss better answers in other libraries
|
|
13
|
+
- Fix: Search broadly first, then narrow
|
|
14
|
+
|
|
15
|
+
4. **Setting limit too low (1-2)**
|
|
16
|
+
- Result: Miss relevant alternatives
|
|
17
|
+
- Fix: Use limit=5 minimum, more for discovery
|
|
18
|
+
|
|
19
|
+
5. **Not checking relevance scores**
|
|
20
|
+
- Result: Waste time on low-relevance results
|
|
21
|
+
- Fix: Filter by score > 0.7 before deep dive
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Combined Optimization Strategies
|
|
2
|
+
|
|
3
|
+
### Strategy 1: Efficient Discovery
|
|
4
|
+
```
|
|
5
|
+
Goal: Find something across many files, minimize tokens
|
|
6
|
+
|
|
7
|
+
1. search(query, detail='minimal', limit=30)
|
|
8
|
+
→ Browse summaries (~3k tokens)
|
|
9
|
+
|
|
10
|
+
2. Filter top 5 by score (>0.7)
|
|
11
|
+
|
|
12
|
+
3. get_full_context(top_5_ids)
|
|
13
|
+
→ Deep dive selectively (~4k tokens)
|
|
14
|
+
|
|
15
|
+
Total: ~7k tokens (vs ~24k with detail='full' upfront)
|
|
16
|
+
Savings: ~70% token reduction
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Strategy 2: Precise Targeting
|
|
20
|
+
```
|
|
21
|
+
Goal: Get exactly what you need, fast
|
|
22
|
+
|
|
23
|
+
1. Identify store: list_stores()
|
|
24
|
+
|
|
25
|
+
2. search(precise_query,
|
|
26
|
+
intent='find-implementation',
|
|
27
|
+
detail='full',
|
|
28
|
+
limit=3,
|
|
29
|
+
stores=['target-store'])
|
|
30
|
+
→ Exact match with full code
|
|
31
|
+
|
|
32
|
+
Total: ~2.5k tokens
|
|
33
|
+
Result: Fastest path to answer
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Strategy 3: Comparative Analysis
|
|
37
|
+
```
|
|
38
|
+
Goal: Compare implementations across libraries
|
|
39
|
+
|
|
40
|
+
1. search(query,
|
|
41
|
+
intent='find-implementation',
|
|
42
|
+
detail='minimal',
|
|
43
|
+
limit=20,
|
|
44
|
+
stores=['lib1', 'lib2', 'lib3'])
|
|
45
|
+
→ Get summaries from multiple libraries
|
|
46
|
+
|
|
47
|
+
2. Review distribution:
|
|
48
|
+
- lib1: 8 results
|
|
49
|
+
- lib2: 7 results
|
|
50
|
+
- lib3: 5 results
|
|
51
|
+
|
|
52
|
+
3. get_full_context(top_2_from_each_lib)
|
|
53
|
+
→ Compare implementations
|
|
54
|
+
|
|
55
|
+
Total: ~5k tokens
|
|
56
|
+
Result: Balanced cross-library comparison
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
# Token Usage Examples
|
|
62
|
+
|
|
63
|
+
Real token counts for different strategies:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
# Inefficient approach
|
|
67
|
+
search("auth middleware", detail='full', limit=30)
|
|
68
|
+
→ 30 results × 800 tokens = 24,000 tokens
|
|
69
|
+
→ Most results not even relevant!
|
|
70
|
+
|
|
71
|
+
# Optimized approach
|
|
72
|
+
search("auth middleware", detail='minimal', limit=30)
|
|
73
|
+
→ 30 results × 100 tokens = 3,000 tokens
|
|
74
|
+
→ Identify top 3 (score > 0.8)
|
|
75
|
+
|
|
76
|
+
get_full_context([id1, id2, id3])
|
|
77
|
+
→ 3 results × 800 tokens = 2,400 tokens
|
|
78
|
+
|
|
79
|
+
Total: 5,400 tokens (78% reduction!)
|
|
80
|
+
```
|