bluera-knowledge 0.16.6 → 0.17.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/CHANGELOG.md +19 -0
- package/dist/{chunk-OMC3RAZT.js → chunk-RAXRD23K.js} +2 -2
- package/dist/{chunk-WYZQUKUD.js → chunk-VKTVMW45.js} +28 -18
- package/dist/chunk-VKTVMW45.js.map +1 -0
- package/dist/{chunk-3EQRQOXD.js → chunk-ZGEQCLOZ.js} +2 -2
- package/dist/index.js +3 -3
- package/dist/mcp/bootstrap.js +19 -2
- package/dist/mcp/bootstrap.js.map +1 -1
- package/dist/mcp/server.d.ts +1 -0
- package/dist/mcp/server.js +2 -2
- package/dist/workers/background-worker-cli.js +2 -2
- package/package.json +1 -5
- package/.claude-plugin/plugin.json +0 -9
- package/commands/add-folder.md +0 -48
- package/commands/add-repo.md +0 -50
- package/commands/cancel.md +0 -63
- package/commands/check-status.md +0 -78
- package/commands/crawl.md +0 -54
- package/commands/index.md +0 -48
- package/commands/remove-store.md +0 -52
- package/commands/search.md +0 -86
- package/commands/search.sh +0 -63
- package/commands/skill-activation.md +0 -130
- package/commands/stores.md +0 -54
- package/commands/suggest.md +0 -82
- package/commands/sync.md +0 -96
- package/commands/test-plugin.md +0 -408
- package/commands/uninstall.md +0 -65
- package/dist/chunk-WYZQUKUD.js.map +0 -1
- package/hooks/check-dependencies.sh +0 -145
- package/hooks/format-search-results.py +0 -132
- package/hooks/hooks.json +0 -54
- package/hooks/job-status-hook.sh +0 -51
- package/hooks/posttooluse-bk-reminder.py +0 -166
- package/hooks/skill-activation.py +0 -194
- package/hooks/skill-rules.json +0 -122
- package/skills/advanced-workflows/SKILL.md +0 -273
- package/skills/knowledge-search/SKILL.md +0 -110
- package/skills/search-optimization/SKILL.md +0 -396
- package/skills/store-lifecycle/SKILL.md +0 -470
- package/skills/when-to-query/SKILL.md +0 -160
- /package/dist/{chunk-OMC3RAZT.js.map → chunk-RAXRD23K.js.map} +0 -0
- /package/dist/{chunk-3EQRQOXD.js.map → chunk-ZGEQCLOZ.js.map} +0 -0
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
Skill activation hook for bluera-knowledge plugin.
|
|
4
|
-
Matches user prompts against skill rules and injects activation reminders.
|
|
5
|
-
|
|
6
|
-
Runs on UserPromptSubmit to detect users who would benefit from learning
|
|
7
|
-
about BK skills, while excluding users who already know BK terminology.
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
import json
|
|
11
|
-
import os
|
|
12
|
-
import re
|
|
13
|
-
import sys
|
|
14
|
-
from pathlib import Path
|
|
15
|
-
from typing import Any
|
|
16
|
-
|
|
17
|
-
CONFIG_DIR = Path.home() / ".local" / "share" / "bluera-knowledge"
|
|
18
|
-
CONFIG_FILE = CONFIG_DIR / "skill-activation.json"
|
|
19
|
-
DEFAULT_CONFIG: dict[str, Any] = {
|
|
20
|
-
"enabled": True,
|
|
21
|
-
"threshold": 1,
|
|
22
|
-
"skills": {
|
|
23
|
-
"knowledge-search": True,
|
|
24
|
-
"when-to-query": True,
|
|
25
|
-
"search-optimization": True,
|
|
26
|
-
"advanced-workflows": True,
|
|
27
|
-
"store-lifecycle": True,
|
|
28
|
-
},
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def load_config() -> dict[str, Any]:
|
|
33
|
-
"""Load skill activation configuration."""
|
|
34
|
-
if not CONFIG_FILE.exists():
|
|
35
|
-
return DEFAULT_CONFIG.copy()
|
|
36
|
-
try:
|
|
37
|
-
with open(CONFIG_FILE, encoding="utf-8") as f:
|
|
38
|
-
return json.load(f)
|
|
39
|
-
except (json.JSONDecodeError, IOError):
|
|
40
|
-
return DEFAULT_CONFIG.copy()
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def load_rules(plugin_root: Path) -> dict[str, Any]:
|
|
44
|
-
"""Load skill rules from plugin hooks directory."""
|
|
45
|
-
rules_path = plugin_root / "hooks" / "skill-rules.json"
|
|
46
|
-
if not rules_path.exists():
|
|
47
|
-
return {"skills": [], "threshold": 1, "globalExclusions": []}
|
|
48
|
-
with open(rules_path, encoding="utf-8") as f:
|
|
49
|
-
return json.load(f)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def matches_condition(prompt: str, condition: dict[str, Any]) -> bool:
|
|
53
|
-
"""Check if prompt matches a single condition (keyword or regex)."""
|
|
54
|
-
prompt_lower = prompt.lower()
|
|
55
|
-
if "keyword" in condition:
|
|
56
|
-
return condition["keyword"].lower() in prompt_lower
|
|
57
|
-
if "regex" in condition:
|
|
58
|
-
return bool(re.search(condition["regex"], prompt, flags=re.IGNORECASE))
|
|
59
|
-
return False
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def check_exclusions(
|
|
63
|
-
prompt: str, exclusions: list[dict[str, Any]]
|
|
64
|
-
) -> bool:
|
|
65
|
-
"""Check if any exclusion pattern matches. Returns True if excluded."""
|
|
66
|
-
for exc in exclusions:
|
|
67
|
-
if matches_condition(prompt, exc):
|
|
68
|
-
return True
|
|
69
|
-
return False
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
def score_skill(
|
|
73
|
-
prompt: str, skill: dict[str, Any]
|
|
74
|
-
) -> tuple[int, list[str]]:
|
|
75
|
-
"""Score a skill against the user prompt. Returns (score, reasons)."""
|
|
76
|
-
reasons: list[str] = []
|
|
77
|
-
score = 0
|
|
78
|
-
|
|
79
|
-
# Check skill-specific exclusions first
|
|
80
|
-
if check_exclusions(prompt, skill.get("exclusions", [])):
|
|
81
|
-
return 0, []
|
|
82
|
-
|
|
83
|
-
for trigger in skill.get("triggers", []):
|
|
84
|
-
if matches_condition(prompt, trigger):
|
|
85
|
-
weight = trigger.get("weight", 1)
|
|
86
|
-
score += weight
|
|
87
|
-
if "keyword" in trigger:
|
|
88
|
-
reasons.append(f'keyword "{trigger["keyword"]}"')
|
|
89
|
-
elif "regex" in trigger:
|
|
90
|
-
reasons.append(f'pattern match')
|
|
91
|
-
|
|
92
|
-
return score, reasons
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
def generate_reminder(
|
|
96
|
-
matches: list[tuple[str, int, list[str], str]]
|
|
97
|
-
) -> str:
|
|
98
|
-
"""Generate assertive skill activation reminder using forced evaluation pattern."""
|
|
99
|
-
lines = [
|
|
100
|
-
"BLUERA-KNOWLEDGE SKILL ACTIVATION - MANDATORY EVALUATION",
|
|
101
|
-
"",
|
|
102
|
-
"CRITICAL: Complete these steps IN ORDER before answering:",
|
|
103
|
-
"",
|
|
104
|
-
"STEP 1 - EVALUATE each skill (YES/NO with one-line reason):",
|
|
105
|
-
]
|
|
106
|
-
|
|
107
|
-
for name, score, reasons, description in matches:
|
|
108
|
-
lines.append(f" • [{name}] - {description}")
|
|
109
|
-
lines.append(f" Triggered by: {', '.join(reasons[:2])}")
|
|
110
|
-
|
|
111
|
-
lines.append("")
|
|
112
|
-
lines.append("STEP 2 - ACTIVATE: For each YES, invoke Skill(skill='bluera-knowledge:<name>') NOW")
|
|
113
|
-
lines.append("")
|
|
114
|
-
lines.append("STEP 3 - RESPOND: Only after activation, answer the user's question")
|
|
115
|
-
lines.append("")
|
|
116
|
-
lines.append("WARNING: This evaluation is WORTHLESS if you skip activation.")
|
|
117
|
-
lines.append("Skills provide indexed library knowledge - faster than grepping node_modules.")
|
|
118
|
-
|
|
119
|
-
return "\n".join(lines)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
def main() -> int:
|
|
123
|
-
# Load configuration
|
|
124
|
-
config = load_config()
|
|
125
|
-
|
|
126
|
-
# Check if skill activation is enabled
|
|
127
|
-
if not config.get("enabled", True):
|
|
128
|
-
return 0
|
|
129
|
-
|
|
130
|
-
# Get plugin root from environment
|
|
131
|
-
plugin_root_env = os.environ.get("CLAUDE_PLUGIN_ROOT", "")
|
|
132
|
-
if not plugin_root_env:
|
|
133
|
-
return 0
|
|
134
|
-
plugin_root = Path(plugin_root_env)
|
|
135
|
-
|
|
136
|
-
# Read hook input from stdin
|
|
137
|
-
try:
|
|
138
|
-
stdin_data = sys.stdin.read()
|
|
139
|
-
if not stdin_data.strip():
|
|
140
|
-
return 0
|
|
141
|
-
hook_input = json.loads(stdin_data)
|
|
142
|
-
except json.JSONDecodeError:
|
|
143
|
-
return 0
|
|
144
|
-
|
|
145
|
-
prompt = hook_input.get("prompt", "")
|
|
146
|
-
if not prompt.strip():
|
|
147
|
-
return 0
|
|
148
|
-
|
|
149
|
-
# Load rules
|
|
150
|
-
rules = load_rules(plugin_root)
|
|
151
|
-
|
|
152
|
-
# Check global exclusions first
|
|
153
|
-
if check_exclusions(prompt, rules.get("globalExclusions", [])):
|
|
154
|
-
return 0
|
|
155
|
-
|
|
156
|
-
threshold = config.get("threshold", rules.get("threshold", 1))
|
|
157
|
-
enabled_skills = config.get("skills", {})
|
|
158
|
-
|
|
159
|
-
# Score each skill
|
|
160
|
-
matches: list[tuple[str, int, list[str], str]] = []
|
|
161
|
-
|
|
162
|
-
for skill in rules.get("skills", []):
|
|
163
|
-
name = skill["name"]
|
|
164
|
-
|
|
165
|
-
# Skip disabled skills
|
|
166
|
-
if not enabled_skills.get(name, True):
|
|
167
|
-
continue
|
|
168
|
-
|
|
169
|
-
score, reasons = score_skill(prompt, skill)
|
|
170
|
-
if score >= threshold:
|
|
171
|
-
matches.append((name, score, reasons, skill.get("description", "")))
|
|
172
|
-
|
|
173
|
-
# No matches - silent exit
|
|
174
|
-
if not matches:
|
|
175
|
-
return 0
|
|
176
|
-
|
|
177
|
-
# Sort by score (highest first)
|
|
178
|
-
matches.sort(key=lambda t: t[1], reverse=True)
|
|
179
|
-
|
|
180
|
-
# Generate and output the reminder using proper JSON format
|
|
181
|
-
reminder = generate_reminder(matches)
|
|
182
|
-
output = {
|
|
183
|
-
"hookSpecificOutput": {
|
|
184
|
-
"hookEventName": "UserPromptSubmit",
|
|
185
|
-
"additionalContext": reminder,
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
print(json.dumps(output))
|
|
189
|
-
|
|
190
|
-
return 0
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if __name__ == "__main__":
|
|
194
|
-
raise SystemExit(main())
|
package/hooks/skill-rules.json
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"description": "bluera-knowledge skill activation rules - technology-agnostic patterns for development scenarios",
|
|
3
|
-
"version": 2,
|
|
4
|
-
"globalExclusions": [
|
|
5
|
-
{ "keyword": "bluera-knowledge" },
|
|
6
|
-
{ "keyword": "bluera knowledge" },
|
|
7
|
-
{ "keyword": "/bluera-knowledge:" },
|
|
8
|
-
{ "regex": "mcp__.*bluera" }
|
|
9
|
-
],
|
|
10
|
-
"threshold": 2,
|
|
11
|
-
"skills": [
|
|
12
|
-
{
|
|
13
|
-
"name": "knowledge-search",
|
|
14
|
-
"description": "How to query Bluera Knowledge for library/dependency questions",
|
|
15
|
-
"triggers": [
|
|
16
|
-
{ "regex": "the\\s+\\w+(-\\w+)*\\s+(package|library|module|framework|dependency)", "weight": 3 },
|
|
17
|
-
{ "regex": "\\w+(-\\w+)*\\s+(package|library|module)\\s+(is|does|keeps|isn't|won't|doesn't)", "weight": 3 },
|
|
18
|
-
{ "regex": "\\w+(-\\w+)*\\s+(documentation|docs)\\b", "weight": 2 },
|
|
19
|
-
{ "regex": "error\\s+(from|in|with)\\s+(the\\s+)?\\w+(-\\w+)*\\s+(package|library|module)", "weight": 3 },
|
|
20
|
-
{ "regex": "(package|library|dependency|module)\\s+(is\\s+)?(throwing|throws|error|failing)", "weight": 3 },
|
|
21
|
-
{ "regex": "how\\s+does\\s+(the\\s+)?\\w+(-\\w+)*\\s+(package|library|module|framework)\\s+(handle|work|process)", "weight": 3 },
|
|
22
|
-
{ "regex": "what\\s+does\\s+(the\\s+)?\\w+(-\\w+)*\\s+(package|library)\\s+(do|return|accept)", "weight": 3 },
|
|
23
|
-
{ "regex": "why\\s+does\\s+(the\\s+)?\\w+(-\\w+)*\\s+(package|library|module)", "weight": 3 },
|
|
24
|
-
{ "regex": "(configure|config|settings)\\s+(for\\s+)?(the\\s+)?\\w+(-\\w+)*\\s+(package|library)", "weight": 3 },
|
|
25
|
-
{ "regex": "(upgraded?|updated?)\\s+(the\\s+)?\\w+(-\\w+)*\\s+(package|library|dependency)", "weight": 2 },
|
|
26
|
-
{ "regex": "integrate\\s+(the\\s+)?\\w+(-\\w+)*\\s+(package|library)", "weight": 2 },
|
|
27
|
-
{ "regex": "dependency\\s+(is|keeps|isn't|won't|error|issue|problem)", "weight": 2 },
|
|
28
|
-
{ "regex": "third[- ]party\\s+(library|package|code)", "weight": 2 }
|
|
29
|
-
],
|
|
30
|
-
"exclusions": [
|
|
31
|
-
{ "keyword": "my code" },
|
|
32
|
-
{ "keyword": "our code" },
|
|
33
|
-
{ "keyword": "this function" },
|
|
34
|
-
{ "keyword": "this file" },
|
|
35
|
-
{ "keyword": "this component" },
|
|
36
|
-
{ "keyword": "this class" },
|
|
37
|
-
{ "keyword": "this project" },
|
|
38
|
-
{ "keyword": "I wrote" },
|
|
39
|
-
{ "keyword": "we wrote" },
|
|
40
|
-
{ "keyword": "my implementation" },
|
|
41
|
-
{ "keyword": "store" },
|
|
42
|
-
{ "keyword": "index" }
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"name": "when-to-query",
|
|
47
|
-
"description": "Decision guide for Bluera Knowledge vs Grep/Read",
|
|
48
|
-
"triggers": [
|
|
49
|
-
{ "keyword": "should i grep", "weight": 2 },
|
|
50
|
-
{ "keyword": "where should i look", "weight": 2 },
|
|
51
|
-
{ "keyword": "grep or search", "weight": 2 },
|
|
52
|
-
{ "keyword": "search or grep", "weight": 2 },
|
|
53
|
-
{ "regex": "where\\s+(should|do)\\s+i\\s+(find|look)\\s+.*(library|package|dependency)", "weight": 3 },
|
|
54
|
-
{ "regex": "is\\s+there\\s+a\\s+better\\s+way\\s+to\\s+(search|find)", "weight": 2 },
|
|
55
|
-
{ "regex": "should\\s+i\\s+(use\\s+)?grep\\s+(for|to)", "weight": 2 },
|
|
56
|
-
{ "regex": "how\\s+(do|should)\\s+i\\s+find.*(in|from)\\s+(a\\s+)?(library|package|dependency)", "weight": 3 }
|
|
57
|
-
],
|
|
58
|
-
"exclusions": [
|
|
59
|
-
{ "keyword": "store" },
|
|
60
|
-
{ "keyword": "index" }
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"name": "search-optimization",
|
|
65
|
-
"description": "Optimizing search parameters and token usage",
|
|
66
|
-
"triggers": [
|
|
67
|
-
{ "keyword": "too many results", "weight": 2 },
|
|
68
|
-
{ "keyword": "too few results", "weight": 2 },
|
|
69
|
-
{ "keyword": "limit results", "weight": 2 },
|
|
70
|
-
{ "keyword": "reduce tokens", "weight": 2 },
|
|
71
|
-
{ "keyword": "token usage", "weight": 2 },
|
|
72
|
-
{ "keyword": "optimize search", "weight": 2 },
|
|
73
|
-
{ "keyword": "detail level", "weight": 2 },
|
|
74
|
-
{ "regex": "\\b(minimal|contextual|full)\\s+detail", "weight": 2 },
|
|
75
|
-
{ "regex": "\\b(vector|fts|hybrid)\\s+(search|mode)", "weight": 2 },
|
|
76
|
-
{ "regex": "narrow\\s+(down\\s+)?(the\\s+)?results", "weight": 2 },
|
|
77
|
-
{ "regex": "search\\s+(is\\s+)?(returning|giving)\\s+(too\\s+)?(many|few)", "weight": 2 }
|
|
78
|
-
],
|
|
79
|
-
"exclusions": [
|
|
80
|
-
{ "regex": "--?(limit|detail|mode|threshold)\\s*=" }
|
|
81
|
-
]
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"name": "advanced-workflows",
|
|
85
|
-
"description": "Multi-tool orchestration patterns",
|
|
86
|
-
"triggers": [
|
|
87
|
-
{ "keyword": "multi-step", "weight": 2 },
|
|
88
|
-
{ "keyword": "orchestration", "weight": 2 },
|
|
89
|
-
{ "keyword": "job monitoring", "weight": 2 },
|
|
90
|
-
{ "keyword": "background job", "weight": 2 },
|
|
91
|
-
{ "keyword": "combine tools", "weight": 2 },
|
|
92
|
-
{ "keyword": "chain operations", "weight": 2 },
|
|
93
|
-
{ "regex": "chain.*searches", "weight": 2 },
|
|
94
|
-
{ "regex": "multiple.*searches", "weight": 2 },
|
|
95
|
-
{ "regex": "search.*then\\s+(summarize|extract|filter)", "weight": 2 },
|
|
96
|
-
{ "regex": "for\\s+each\\s+(search\\s+)?(result|match)", "weight": 2 }
|
|
97
|
-
],
|
|
98
|
-
"exclusions": []
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
"name": "store-lifecycle",
|
|
102
|
-
"description": "Managing knowledge stores",
|
|
103
|
-
"triggers": [
|
|
104
|
-
{ "keyword": "add store", "weight": 2 },
|
|
105
|
-
{ "keyword": "create store", "weight": 2 },
|
|
106
|
-
{ "keyword": "delete store", "weight": 2 },
|
|
107
|
-
{ "keyword": "remove store", "weight": 2 },
|
|
108
|
-
{ "keyword": "index store", "weight": 2 },
|
|
109
|
-
{ "keyword": "re-index", "weight": 2 },
|
|
110
|
-
{ "keyword": "reindex", "weight": 2 },
|
|
111
|
-
{ "keyword": "knowledge store", "weight": 2 },
|
|
112
|
-
{ "regex": "add\\s+(a\\s+)?(repo|repository|folder|directory)\\s+(to|for)\\s+(knowledge|indexing|search)", "weight": 3 },
|
|
113
|
-
{ "regex": "index\\s+(a|the|my)\\s+(repo|repository|folder|directory|library|package)", "weight": 2 },
|
|
114
|
-
{ "regex": "set\\s+up.*(knowledge|search)\\s*(store|index)", "weight": 2 },
|
|
115
|
-
{ "regex": "(backup|snapshot|archive).*(knowledge|search)\\s*(store|index)", "weight": 2 }
|
|
116
|
-
],
|
|
117
|
-
"exclusions": [
|
|
118
|
-
{ "regex": "/bluera-knowledge:(add-repo|add-folder|remove-store|index)" }
|
|
119
|
-
]
|
|
120
|
-
}
|
|
121
|
-
]
|
|
122
|
-
}
|
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: advanced-workflows
|
|
3
|
-
description: Multi-tool orchestration patterns for complex Bluera Knowledge operations. Teaches progressive library exploration, adding libraries with job monitoring, handling large result sets, multi-store searches, and error recovery workflows.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Advanced Bluera Knowledge Workflows
|
|
7
|
-
|
|
8
|
-
Master complex multi-tool operations that combine multiple MCP tools for efficient knowledge retrieval and management.
|
|
9
|
-
|
|
10
|
-
## Progressive Library Exploration
|
|
11
|
-
|
|
12
|
-
When exploring a new library or codebase, use this pattern for efficient discovery:
|
|
13
|
-
|
|
14
|
-
### Workflow: Find Relevant Code in Unknown Library
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
1. list_stores()
|
|
18
|
-
→ See what's indexed, identify target store
|
|
19
|
-
|
|
20
|
-
2. get_store_info(store)
|
|
21
|
-
→ Get metadata: file paths, size, indexed files
|
|
22
|
-
→ Understand scope before searching
|
|
23
|
-
|
|
24
|
-
3. search(query, detail='minimal', stores=[target])
|
|
25
|
-
→ Get high-level summaries of relevant code
|
|
26
|
-
→ Review relevance scores (>0.7 = good match)
|
|
27
|
-
|
|
28
|
-
4. get_full_context(result_ids[top_3])
|
|
29
|
-
→ Deep dive on most relevant results only
|
|
30
|
-
→ Get complete code with full context
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Example:**
|
|
34
|
-
|
|
35
|
-
User: "How does Vue's computed properties work?"
|
|
36
|
-
|
|
37
|
-
```
|
|
38
|
-
list_stores()
|
|
39
|
-
→ Found: vue, react, pydantic
|
|
40
|
-
|
|
41
|
-
get_store_info('vue')
|
|
42
|
-
→ Path: .bluera/bluera-knowledge/repos/vue/
|
|
43
|
-
→ Files: 2,847 indexed
|
|
44
|
-
|
|
45
|
-
search("computed properties", intent='find-implementation', detail='minimal', stores=['vue'])
|
|
46
|
-
→ Result 1: packages/reactivity/src/computed.ts (score: 0.92)
|
|
47
|
-
→ Result 2: packages/reactivity/__tests__/computed.spec.ts (score: 0.85)
|
|
48
|
-
→ Result 3: packages/runtime-core/src/apiComputed.ts (score: 0.78)
|
|
49
|
-
|
|
50
|
-
get_full_context(['result_1_id', 'result_2_id'])
|
|
51
|
-
→ Full code for ComputedRefImpl class
|
|
52
|
-
→ Complete API implementation
|
|
53
|
-
|
|
54
|
-
Now explain with authoritative source code.
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Adding New Library with Job Monitoring
|
|
58
|
-
|
|
59
|
-
When adding large libraries, monitor indexing progress to know when search is ready:
|
|
60
|
-
|
|
61
|
-
### Workflow: Add Library and Wait for Index
|
|
62
|
-
|
|
63
|
-
```
|
|
64
|
-
1. create_store(url_or_path, name)
|
|
65
|
-
→ Returns: job_id
|
|
66
|
-
→ Background indexing starts
|
|
67
|
-
|
|
68
|
-
2. check_job_status(job_id)
|
|
69
|
-
→ Poll every 10-30 seconds
|
|
70
|
-
→ Status: 'pending' | 'running' | 'completed' | 'failed'
|
|
71
|
-
→ Progress: percentage, current file
|
|
72
|
-
|
|
73
|
-
3. When status='completed':
|
|
74
|
-
list_stores()
|
|
75
|
-
→ Verify store appears in list
|
|
76
|
-
|
|
77
|
-
4. search(query, stores=[new_store], limit=5)
|
|
78
|
-
→ Test search works
|
|
79
|
-
→ Verify indexing quality
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
**Example:**
|
|
83
|
-
|
|
84
|
-
```
|
|
85
|
-
create_store('https://github.com/fastapi/fastapi', 'fastapi')
|
|
86
|
-
→ job_id: 'job_abc123'
|
|
87
|
-
→ Status: Indexing started in background
|
|
88
|
-
|
|
89
|
-
# Poll for completion (typically 30-120 seconds for medium repos)
|
|
90
|
-
check_job_status('job_abc123')
|
|
91
|
-
→ Status: running
|
|
92
|
-
→ Progress: 45% (processing src/fastapi/routing.py)
|
|
93
|
-
|
|
94
|
-
# ... wait 30 seconds ...
|
|
95
|
-
|
|
96
|
-
check_job_status('job_abc123')
|
|
97
|
-
→ Status: completed
|
|
98
|
-
→ Indexed: 487 files, 125k lines
|
|
99
|
-
|
|
100
|
-
# Verify and test
|
|
101
|
-
list_stores()
|
|
102
|
-
→ fastapi: 487 files, vector + FTS indexed
|
|
103
|
-
|
|
104
|
-
search("dependency injection", stores=['fastapi'], limit=3)
|
|
105
|
-
→ Returns relevant FastAPI DI patterns
|
|
106
|
-
→ Store is ready for use!
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
## Handling Large Result Sets
|
|
110
|
-
|
|
111
|
-
When initial search returns many results, use progressive detail to avoid context overload:
|
|
112
|
-
|
|
113
|
-
### Workflow: Progressive Detail Strategy
|
|
114
|
-
|
|
115
|
-
```
|
|
116
|
-
1. search(query, detail='minimal', limit=20)
|
|
117
|
-
→ Get summaries only (~100 tokens/result)
|
|
118
|
-
→ Review all 20 summaries quickly
|
|
119
|
-
|
|
120
|
-
2. Filter by relevance score:
|
|
121
|
-
- Score > 0.8: Excellent match
|
|
122
|
-
- Score 0.6-0.8: Good match
|
|
123
|
-
- Score < 0.6: Possibly irrelevant
|
|
124
|
-
|
|
125
|
-
3. For top 3-5 results (score > 0.7):
|
|
126
|
-
get_full_context(selected_ids)
|
|
127
|
-
→ Fetch complete code only for relevant items
|
|
128
|
-
→ Saves ~80% context vs fetching all upfront
|
|
129
|
-
|
|
130
|
-
4. If nothing relevant:
|
|
131
|
-
search(refined_query, detail='contextual', limit=10)
|
|
132
|
-
→ Try different query with more context
|
|
133
|
-
→ Or broaden/narrow the search
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
**Example:**
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
# Initial broad search
|
|
140
|
-
search("authentication middleware", detail='minimal', limit=20)
|
|
141
|
-
→ 20 results, scores ranging 0.45-0.92
|
|
142
|
-
→ Total context: ~2k tokens (minimal)
|
|
143
|
-
|
|
144
|
-
# Filter by score
|
|
145
|
-
Top results (>0.7):
|
|
146
|
-
- Result 3: auth/jwt.ts (score: 0.92)
|
|
147
|
-
- Result 7: middleware/authenticate.ts (score: 0.85)
|
|
148
|
-
- Result 12: auth/session.ts (score: 0.74)
|
|
149
|
-
|
|
150
|
-
# Get full code for top 3 only
|
|
151
|
-
get_full_context(['result_3', 'result_7', 'result_12'])
|
|
152
|
-
→ Complete implementations for relevant files only
|
|
153
|
-
→ Context: ~3k tokens (vs ~15k if we fetched all 20)
|
|
154
|
-
|
|
155
|
-
# Found what we needed! If not, would refine query and retry.
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
## Multi-Store Search with Ranking
|
|
159
|
-
|
|
160
|
-
When searching across multiple stores, use ranking to prioritize results:
|
|
161
|
-
|
|
162
|
-
### Workflow: Cross-Library Search
|
|
163
|
-
|
|
164
|
-
```
|
|
165
|
-
1. search(query, limit=10)
|
|
166
|
-
→ Searches ALL stores
|
|
167
|
-
→ Returns mixed results ranked by relevance
|
|
168
|
-
|
|
169
|
-
2. Review store distribution:
|
|
170
|
-
- If dominated by one store: might narrow to specific stores
|
|
171
|
-
- If balanced: good cross-library perspective
|
|
172
|
-
|
|
173
|
-
3. For specific library focus:
|
|
174
|
-
search(query, stores=['lib1', 'lib2'], limit=15)
|
|
175
|
-
→ Search only relevant libraries
|
|
176
|
-
→ Get more results from target libraries
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
**Example:**
|
|
180
|
-
|
|
181
|
-
User: "How do different frameworks handle routing?"
|
|
182
|
-
|
|
183
|
-
```
|
|
184
|
-
# Search all indexed frameworks
|
|
185
|
-
search("routing implementation", intent='find-implementation', limit=15)
|
|
186
|
-
→ Result mix:
|
|
187
|
-
- express (score: 0.91)
|
|
188
|
-
- fastapi (score: 0.89)
|
|
189
|
-
- hono (score: 0.87)
|
|
190
|
-
- vue-router (score: 0.82)
|
|
191
|
-
- ...
|
|
192
|
-
|
|
193
|
-
# All stores represented, good comparative view!
|
|
194
|
-
|
|
195
|
-
# If user wants deeper FastAPI focus:
|
|
196
|
-
search("routing implementation", stores=['fastapi', 'starlette'], limit=20)
|
|
197
|
-
→ More FastAPI/Starlette-specific results
|
|
198
|
-
→ Deeper exploration of Python framework routing
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
## Error Recovery
|
|
202
|
-
|
|
203
|
-
When operations fail, use these recovery patterns:
|
|
204
|
-
|
|
205
|
-
### Workflow: Handle Indexing Failures
|
|
206
|
-
|
|
207
|
-
```
|
|
208
|
-
1. create_store() fails or job_status shows 'failed'
|
|
209
|
-
→ Check error message
|
|
210
|
-
→ Common issues:
|
|
211
|
-
- Git auth required (private repo)
|
|
212
|
-
- Invalid URL/path
|
|
213
|
-
- Disk space
|
|
214
|
-
- Network timeout
|
|
215
|
-
|
|
216
|
-
2. Recovery actions:
|
|
217
|
-
- Auth issue: Provide credentials or use HTTPS
|
|
218
|
-
- Invalid path: Verify URL/path exists
|
|
219
|
-
- Disk space: delete_store() unused stores
|
|
220
|
-
- Network: Retry with smaller repo or use --shallow
|
|
221
|
-
|
|
222
|
-
3. Verify recovery:
|
|
223
|
-
list_stores() → Check store appeared
|
|
224
|
-
search(test_query, stores=[new_store]) → Verify searchable
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
**Example:**
|
|
228
|
-
|
|
229
|
-
```
|
|
230
|
-
create_store('https://github.com/private/repo', 'my-repo')
|
|
231
|
-
→ job_id: 'job_xyz'
|
|
232
|
-
|
|
233
|
-
check_job_status('job_xyz')
|
|
234
|
-
→ Status: failed
|
|
235
|
-
→ Error: "Authentication required for private repository"
|
|
236
|
-
|
|
237
|
-
# Recovery: Use authenticated URL or SSH
|
|
238
|
-
create_store('git@github.com:private/repo.git', 'my-repo')
|
|
239
|
-
→ job_id: 'job_xyz2'
|
|
240
|
-
|
|
241
|
-
check_job_status('job_xyz2')
|
|
242
|
-
→ Status: completed
|
|
243
|
-
→ Success!
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
## Combining Workflows
|
|
247
|
-
|
|
248
|
-
Real-world usage often combines these patterns:
|
|
249
|
-
|
|
250
|
-
```
|
|
251
|
-
User: "I need to understand how Express and Hono handle middleware differently"
|
|
252
|
-
|
|
253
|
-
1. list_stores() → check if both indexed
|
|
254
|
-
2. If not: create_store() for missing framework(s)
|
|
255
|
-
3. check_job_status() → wait for indexing
|
|
256
|
-
4. search("middleware implementation", stores=['express', 'hono'], detail='minimal')
|
|
257
|
-
5. Review summaries, identify key files
|
|
258
|
-
6. get_full_context() for 2-3 most relevant from each framework
|
|
259
|
-
7. Compare implementations with full context
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
This multi-step workflow is efficient, targeted, and conserves context.
|
|
263
|
-
|
|
264
|
-
## Best Practices
|
|
265
|
-
|
|
266
|
-
1. **Always start with detail='minimal'** - Get summaries first, full context selectively
|
|
267
|
-
2. **Monitor background jobs** - Don't search newly added stores until indexing completes
|
|
268
|
-
3. **Use intent parameter** - Helps ranking ('find-implementation' vs 'find-pattern' vs 'find-usage')
|
|
269
|
-
4. **Filter by stores when known** - Faster, more focused results
|
|
270
|
-
5. **Check relevance scores** - >0.7 is usually a strong match, <0.5 might be noise
|
|
271
|
-
6. **Progressive refinement** - Broad search → filter → narrow → full context
|
|
272
|
-
|
|
273
|
-
These workflows reduce token usage, minimize tool calls, and get you to the right answer faster.
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: knowledge-search
|
|
3
|
-
description: Teaches how to use Bluera Knowledge for accessing library sources and reference material. Explains two approaches - vector search via MCP/slash commands for discovery, or direct Grep/Read access to cloned repos for precision. Shows when to use each method and example workflows for querying library internals.
|
|
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.
|