bluera-knowledge 0.31.0 → 0.33.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.
Files changed (70) hide show
  1. package/.claude-plugin/plugin.json +23 -0
  2. package/.mcp.json +13 -0
  3. package/CHANGELOG.md +42 -0
  4. package/NOTICE +47 -0
  5. package/README.md +2 -2
  6. package/bun.lock +1978 -0
  7. package/dist/{chunk-B335UOU7.js → chunk-3TB7TDVF.js} +24 -3
  8. package/dist/chunk-3TB7TDVF.js.map +1 -0
  9. package/dist/{chunk-KCI4U6FH.js → chunk-KDZDLJUY.js} +2 -2
  10. package/dist/{chunk-AEXFPA57.js → chunk-YDTTD53Y.js} +158 -26
  11. package/dist/chunk-YDTTD53Y.js.map +1 -0
  12. package/dist/index.js +3 -3
  13. package/dist/mcp/bootstrap.js +10 -0
  14. package/dist/mcp/bootstrap.js.map +1 -1
  15. package/dist/mcp/server.d.ts +5 -3
  16. package/dist/mcp/server.js +2 -2
  17. package/dist/workers/background-worker-cli.js +2 -2
  18. package/hooks/check-ready.sh +109 -0
  19. package/hooks/hooks.json +97 -0
  20. package/hooks/job-status-hook.sh +51 -0
  21. package/hooks/posttooluse-bk-reminder.py +126 -0
  22. package/hooks/posttooluse-web-research.py +209 -0
  23. package/hooks/posttooluse-websearch-bk.py +158 -0
  24. package/hooks/pretooluse-bk-suggest.py +296 -0
  25. package/hooks/skill-activation.py +221 -0
  26. package/hooks/skill-rules.json +131 -0
  27. package/package.json +9 -2
  28. package/scripts/CLAUDE.md +65 -0
  29. package/scripts/auto-setup.sh +65 -0
  30. package/scripts/bench-regression.sh +345 -0
  31. package/scripts/dev.sh +16 -0
  32. package/scripts/doctor.sh +103 -0
  33. package/scripts/download-models.ts +188 -0
  34. package/scripts/export-web-store.ts +142 -0
  35. package/scripts/lib/mock-server.sh +70 -0
  36. package/scripts/mcp-wrapper.sh +91 -0
  37. package/scripts/setup.sh +224 -0
  38. package/scripts/statusline-module.sh +29 -0
  39. package/scripts/test-mcp-dev.js +260 -0
  40. package/scripts/validate-local.sh +412 -0
  41. package/scripts/validate-npm-release.sh +406 -0
  42. package/skills/add-folder/SKILL.md +48 -0
  43. package/skills/add-repo/SKILL.md +50 -0
  44. package/skills/advanced-workflows/SKILL.md +273 -0
  45. package/skills/cancel/SKILL.md +63 -0
  46. package/skills/check-status/SKILL.md +130 -0
  47. package/skills/crawl/SKILL.md +61 -0
  48. package/skills/doctor/SKILL.md +27 -0
  49. package/skills/eval/SKILL.md +222 -0
  50. package/skills/health/SKILL.md +72 -0
  51. package/skills/index/SKILL.md +48 -0
  52. package/skills/knowledge-search/SKILL.md +110 -0
  53. package/skills/remove-store/SKILL.md +52 -0
  54. package/skills/search/SKILL.md +80 -0
  55. package/skills/search/search.sh +63 -0
  56. package/skills/search-optimization/SKILL.md +199 -0
  57. package/skills/search-optimization/references/mistakes.md +21 -0
  58. package/skills/search-optimization/references/strategies.md +80 -0
  59. package/skills/skill-activation/SKILL.md +131 -0
  60. package/skills/statusline/SKILL.md +19 -0
  61. package/skills/store-lifecycle/SKILL.md +470 -0
  62. package/skills/stores/SKILL.md +54 -0
  63. package/skills/suggest/SKILL.md +118 -0
  64. package/skills/sync/SKILL.md +96 -0
  65. package/skills/test-plugin/SKILL.md +547 -0
  66. package/skills/uninstall/SKILL.md +65 -0
  67. package/skills/when-to-query/SKILL.md +160 -0
  68. package/dist/chunk-AEXFPA57.js.map +0 -1
  69. package/dist/chunk-B335UOU7.js.map +0 -1
  70. /package/dist/{chunk-KCI4U6FH.js.map → chunk-KDZDLJUY.js.map} +0 -0
@@ -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
+ ```
@@ -0,0 +1,131 @@
1
+ ---
2
+ description: Toggle skill auto-activation on/off or configure individual skills
3
+ argument-hint: "[on|off|status|config]"
4
+ allowed-tools: ["Read", "Write", "AskUserQuestion"]
5
+ ---
6
+
7
+ # Skill Activation Configuration
8
+
9
+ Manage the bluera-knowledge skill auto-activation system.
10
+
11
+ ## Configuration File
12
+
13
+ Location: `.bluera/bluera-knowledge/skill-activation.json` (per-repo, in project root)
14
+
15
+ Default configuration (created if missing):
16
+ ```json
17
+ {
18
+ "enabled": true,
19
+ "threshold": 1,
20
+ "skills": {
21
+ "knowledge-search": true,
22
+ "when-to-query": true,
23
+ "search-optimization": true,
24
+ "advanced-workflows": true,
25
+ "store-lifecycle": true
26
+ }
27
+ }
28
+ ```
29
+
30
+ ## Steps
31
+
32
+ ### 1. Parse Arguments
33
+
34
+ Extract the subcommand from $ARGUMENTS:
35
+ - Empty or "status": Show current status
36
+ - "on": Enable skill activation
37
+ - "off": Disable skill activation
38
+ - "config": Interactive skill configuration
39
+
40
+ ### 2. Read Current Configuration
41
+
42
+ Read `.bluera/bluera-knowledge/skill-activation.json`
43
+
44
+ If the file doesn't exist, use the default configuration shown above.
45
+
46
+ ### 3. Execute Subcommand
47
+
48
+ **For "status" or empty arguments:**
49
+
50
+ Display the current configuration:
51
+
52
+ ```
53
+ ## Skill Activation Status
54
+
55
+ **Status**: [Enabled/Disabled]
56
+ **Threshold**: [threshold value]
57
+
58
+ ### Individual Skills
59
+ | Skill | Status |
60
+ |-------|--------|
61
+ | knowledge-search | enabled/disabled |
62
+ | when-to-query | enabled/disabled |
63
+ | search-optimization | enabled/disabled |
64
+ | advanced-workflows | enabled/disabled |
65
+ | store-lifecycle | enabled/disabled |
66
+
67
+ Use `/bluera-knowledge:skill-activation config` to toggle individual skills.
68
+ ```
69
+
70
+ **For "on":**
71
+
72
+ 1. Read configuration (or use defaults)
73
+ 2. Set `enabled: true`
74
+ 3. Ensure directory exists: `.bluera/bluera-knowledge/`
75
+ 4. Write updated configuration
76
+ 5. Confirm: "Skill activation **enabled**. Skills will be suggested based on your prompts."
77
+
78
+ **For "off":**
79
+
80
+ 1. Read configuration (or use defaults)
81
+ 2. Set `enabled: false`
82
+ 3. Write updated configuration
83
+ 4. Confirm: "Skill activation **disabled**. No skill suggestions will appear."
84
+
85
+ **For "config":**
86
+
87
+ 1. Read current configuration
88
+ 2. Use AskUserQuestion to let user toggle skills:
89
+
90
+ ```json
91
+ {
92
+ "questions": [{
93
+ "question": "Which skills should auto-activate when relevant patterns are detected?",
94
+ "header": "Skills",
95
+ "multiSelect": true,
96
+ "options": [
97
+ {
98
+ "label": "knowledge-search",
99
+ "description": "Suggests when to query BK for library questions"
100
+ },
101
+ {
102
+ "label": "when-to-query",
103
+ "description": "Guides BK vs Grep/Read decisions"
104
+ },
105
+ {
106
+ "label": "search-optimization",
107
+ "description": "Tips for optimizing search parameters"
108
+ },
109
+ {
110
+ "label": "advanced-workflows",
111
+ "description": "Multi-tool orchestration patterns"
112
+ },
113
+ {
114
+ "label": "store-lifecycle",
115
+ "description": "Managing knowledge stores"
116
+ }
117
+ ]
118
+ }]
119
+ }
120
+ ```
121
+
122
+ 3. Update skills based on selection (selected = enabled, unselected = disabled)
123
+ 4. Write updated configuration
124
+ 5. Show updated status table
125
+
126
+ ## Notes
127
+
128
+ - Configuration is per-repo (stored in project's `.bluera/bluera-knowledge/` directory)
129
+ - The configuration directory is created automatically if it doesn't exist
130
+ - Changes take effect immediately on the next prompt
131
+ - When disabled globally, no skills are suggested regardless of individual settings
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: statusline
3
+ description: Install or update the bluera-knowledge statusline module
4
+ allowed-tools: [Read, Edit, Write, Bash]
5
+ ---
6
+
7
+ Install the bluera-knowledge statusline module into the user's Claude Code statusline.
8
+
9
+ ## Steps
10
+
11
+ 1. Locate the plugin root by finding `scripts/statusline-module.sh` relative to this command file
12
+ 2. Read `scripts/statusline-module.sh` from the plugin directory to get the latest module content
13
+ 3. Read `~/.claude/statusline.sh` (or `$CLAUDE_CONFIG_DIR/statusline.sh`)
14
+ 4. If the file doesn't exist, tell the user to first set up a statusline with `/bluera-base:claude-code-statusline`
15
+ 5. Look for existing boundary comments `# --- bluera-knowledge ---` / `# --- end bluera-knowledge ---`
16
+ 6. If found: replace everything between the boundary comments (exclusive) with the module content (the function and call site from `statusline-module.sh`, excluding the shebang and header comments)
17
+ 7. If not found: insert the full boundary-commented section before the final output `printf` statements, and ensure `$BK_STATUS` is referenced in the `PLUGIN_SEG` variable
18
+ 8. Ensure the call site passes `"$PROJECT_DIR"` to `get_bk_status`
19
+ 9. Show the user the updated section and confirm success