bluera-knowledge 0.13.0 → 0.13.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.
@@ -0,0 +1,12 @@
1
+ # Code Quality Rules
2
+
3
+ ## Fail Early and Fast
4
+
5
+ Our code is expected to *work* as-designed:
6
+ - Use `throw` when state is unexpected or for any error condition
7
+ - Use 100% strict typing; no `any` no `as`, unless completely unavoidable and considered best practice
8
+
9
+ ## Never
10
+
11
+ - Write "fallback code" or "graceful degradation" code or implement "defaults" *unless* it's part of the specification
12
+ - Leave commented code, nor reference outdated/deprecated implementations
@@ -0,0 +1,5 @@
1
+ # Git Rules
2
+
3
+ ## Never
4
+
5
+ - Use `--no-verify` on Git commits; this anti-pattern completely circumvents the code protections we have in place
@@ -0,0 +1,7 @@
1
+ # Versioning Rules
2
+
3
+ ## Always
4
+
5
+ - Use the `bun run version:*` commands after changes
6
+ - Without this, the changes would not be detected by Claude Code
7
+ - Push to main after version bump - releases happen automatically (no manual tagging needed)
package/CLAUDE.md CHANGED
@@ -101,18 +101,10 @@ Note: Version scripts run full quality checks BEFORE bumping to prevent broken r
101
101
  1. Run `bun run build` (or `bun run precommit` which includes build)
102
102
  2. Commit both source AND dist/ changes together
103
103
 
104
- ## ALWAYS
104
+ ## Project Rules
105
105
 
106
- * use the `bun run version:*` commands after changes
107
- * without this, the changes would not be detected by Claude Code
108
- * push to main after version bump - releases happen automatically (no manual tagging needed)
109
- * fail early and fast
110
- * our code is expected to *work* as-designed
111
- * use "throw" when state is unexpected or for any error condition
112
- * use 100% strict typing; no "any" no "as", unless completely unavoidable and considerd best practice
106
+ Modular rules are in `.claude/rules/` and auto-load:
113
107
 
114
- ## NEVER
115
-
116
- * use `--no-verify` on Git commits; this anti-pattern completely circumvents the code protections we have in place
117
- * write "fallback code" or "graceful degradation" code or implement "defaults" *unless* it's part of the specification
118
- * leave commented code, nor reference outdated/deprecated implementations
108
+ - `code-quality.md` - Fail early/fast, strict typing, no fallback code
109
+ - `git.md` - No --no-verify on commits
110
+ - `versioning.md` - Use version:* commands, push to main for releases
package/README.md CHANGED
@@ -1180,6 +1180,14 @@ pip install crawl4ai
1180
1180
  playwright install chromium
1181
1181
  ```
1182
1182
 
1183
+ **Disable auto-install (security-conscious environments):**
1184
+
1185
+ Set the `BK_SKIP_AUTO_INSTALL` environment variable to disable automatic pip package installation:
1186
+
1187
+ ```bash
1188
+ export BK_SKIP_AUTO_INSTALL=1
1189
+ ```
1190
+
1183
1191
  > [!NOTE]
1184
1192
  > The plugin will work without crawl4ai/playwright, but web crawling features (`/bluera-knowledge:crawl`) will be unavailable. The default mode uses headless browser for maximum compatibility with JavaScript-rendered sites. Use `--fast` for static sites when speed is critical.
1185
1193
 
package/commands/crawl.md CHANGED
@@ -1,7 +1,8 @@
1
1
  ---
2
2
  description: Crawl web pages with natural language control and add to knowledge store
3
3
  argument-hint: "[url] [store-name] [--crawl instruction] [--extract instruction] [--fast]"
4
- allowed-tools: [Bash(*)]
4
+ allowed-tools: ["Bash(node ${CLAUDE_PLUGIN_ROOT}/dist/index.js crawl:*)"]
5
+ context: fork
5
6
  ---
6
7
 
7
8
  Crawling and indexing: $ARGUMENTS
@@ -1,24 +1,58 @@
1
+ ---
2
+ description: Run comprehensive plugin validation test suite
3
+ argument-hint: "[--dev]"
4
+ context: fork
5
+ ---
6
+
1
7
  # Test Plugin
2
8
 
3
- Comprehensive test of all Bluera Knowledge plugin functionality (MCP tools + slash commands).
9
+ Comprehensive test of all Bluera Knowledge plugin functionality.
10
+
11
+ ## When to Use Each Mode
12
+
13
+ | Scenario | Command | Tests |
14
+ |----------|---------|-------|
15
+ | Claude running with `--plugin-dir .` | `/test-plugin` | 19/19 (full suite) |
16
+ | Plugin installed from marketplace | `/test-plugin` | 19/19 (full suite) |
17
+ | Claude running WITHOUT plugin loaded | `/test-plugin --dev` | 16/19 (no slash cmds) |
18
+ | CI/CD or scripted testing (no Claude) | `--dev` via bash | 16/19 (no slash cmds) |
19
+
20
+ **Modes:**
21
+ - **Default mode**: Uses Claude's MCP tools. Works when plugin is loaded via `--plugin-dir .` or installed from marketplace. Runs all 19 tests including slash commands.
22
+ - **`--dev` mode**: Spawns MCP server directly via `scripts/test-mcp-dev.js`. Works without Claude Code or when plugin isn't loaded. Skips slash command tests (8-10) since they require Claude's skill router.
23
+
24
+ **Recommendation:** If developing with `claude --plugin-dir .`, use default mode (no `--dev` flag) for full test coverage.
4
25
 
5
26
  ## Context
6
27
 
7
28
  !`echo "=== BK Plugin Test ===" && ls -la .bluera/bluera-knowledge/ 2>/dev/null || echo "No BK data dir yet (will be created)"`
8
29
 
30
+ ## Mode Detection
31
+
32
+ Check if `--dev` flag is present in: $ARGUMENTS
33
+
34
+ - If `--dev` is present: Use **Development Mode** (MCP via scripts/test-mcp-dev.js)
35
+ - Otherwise: Use **Production Mode** (MCP via Claude's built-in tools)
36
+
37
+ ---
38
+
9
39
  ## Pre-Test Cleanup
10
40
 
11
41
  First, clean up any leftover artifacts from previous test runs (ignore errors if they don't exist):
12
42
 
13
- 1. Delete test store if exists: Call MCP tool `execute` with `{ command: "store:delete", args: { store: "bk-test-store" } }` - ignore "not found" errors
14
- 2. Remove test content directory:
15
- ```bash
16
- rm -rf .bluera/bluera-knowledge/test-content
17
- ```
43
+ **In `--dev` mode:**
44
+ ```bash
45
+ node scripts/test-mcp-dev.js call execute '{"command":"store:delete","args":{"store":"bk-test-store"}}' 2>/dev/null || true
46
+ rm -rf .bluera/bluera-knowledge/test-content
47
+ ```
48
+
49
+ **In production mode:**
50
+ 1. Call MCP tool `execute` with `{ command: "store:delete", args: { store: "bk-test-store" } }` - ignore errors
51
+ 2. Run: `rm -rf .bluera/bluera-knowledge/test-content`
18
52
 
19
53
  ## Test Content Setup
20
54
 
21
- First, create test content for indexing:
55
+ Create test content for indexing:
22
56
 
23
57
  ```bash
24
58
  mkdir -p .bluera/bluera-knowledge/test-content
@@ -40,136 +74,225 @@ EOF
40
74
 
41
75
  Execute each test in order. Mark each as PASS or FAIL.
42
76
 
77
+ ---
78
+
79
+ # DEVELOPMENT MODE (`--dev`)
80
+
81
+ Use this section if `--dev` flag is present. Uses `scripts/test-mcp-dev.js` to spawn MCP server directly.
82
+
83
+ ### Part 1: MCP Server Tests (via dev script)
84
+
85
+ 1. **MCP Connection**:
86
+ ```bash
87
+ node scripts/test-mcp-dev.js call execute '{"command":"help"}'
88
+ ```
89
+ - PASS if output contains "Available commands"
90
+
91
+ 2. **List Stores**:
92
+ ```bash
93
+ node scripts/test-mcp-dev.js call execute '{"command":"stores"}'
94
+ ```
95
+ - PASS if no error (may return empty array)
96
+
97
+ 3. **Create Store**:
98
+ ```bash
99
+ node scripts/test-mcp-dev.js call execute '{"command":"store:create","args":{"name":"bk-test-store","type":"file","source":".bluera/bluera-knowledge/test-content"}}'
100
+ ```
101
+ - PASS if response indicates success
102
+
103
+ 4. **Store Info**:
104
+ ```bash
105
+ node scripts/test-mcp-dev.js call execute '{"command":"store:info","args":{"store":"bk-test-store"}}'
106
+ ```
107
+ - PASS if response contains store details
108
+
109
+ 5. **Index Store** (via CLI for reliability):
110
+ ```bash
111
+ node dist/index.js index bk-test-store
112
+ ```
113
+ - PASS if output shows "Indexed X documents"
114
+
115
+ 6-7. **Search + Get Full Context** (session mode to maintain cache):
116
+ ```bash
117
+ node scripts/test-mcp-dev.js session << 'EOF'
118
+ search {"query":"validateBKPlugin","stores":["bk-test-store"]}
119
+ get_full_context {"resultId":"$LAST_ID"}
120
+ EOF
121
+ ```
122
+ - PASS if first result has non-empty results array
123
+ - PASS if second result contains "BK Plugin Test File"
124
+
125
+ ### Part 2: Slash Commands (SKIPPED in --dev mode)
126
+
127
+ Tests 8-10 are skipped in development mode because slash commands require Claude Code to invoke them. The MCP server tests (Part 1) provide equivalent coverage of the underlying functionality.
128
+
129
+ ### Part 3: Hook Tests (same for both modes)
130
+
131
+ [Continue to Part 3 below]
132
+
133
+ ### Part 4: Cleanup (--dev mode)
134
+
135
+ 17. **Delete Store**:
136
+ ```bash
137
+ node scripts/test-mcp-dev.js call execute '{"command":"store:delete","args":{"store":"bk-test-store"}}'
138
+ ```
139
+ - PASS if deletion succeeds
140
+
141
+ 18. **Remove Test Content**:
142
+ ```bash
143
+ rm -rf .bluera/bluera-knowledge/test-content
144
+ ```
145
+ - PASS if command succeeds
146
+
147
+ 19. **Verify Cleanup**:
148
+ ```bash
149
+ node scripts/test-mcp-dev.js call execute '{"command":"stores"}'
150
+ ```
151
+ - PASS if bk-test-store is NOT in the list
152
+
153
+ ---
154
+
155
+ # PRODUCTION MODE (default)
156
+
157
+ Use this section if `--dev` flag is NOT present. Uses Claude's built-in MCP tools.
158
+
43
159
  ### Part 1: MCP Tools
44
160
 
45
161
  1. **MCP Connection**: Call MCP tool `execute` with `{ command: "help" }`
46
- - Expected: Returns list of available commands
47
162
  - PASS if response contains "Available commands"
48
163
 
49
164
  2. **List Stores (MCP)**: Call MCP tool `execute` with `{ command: "stores" }`
50
- - Expected: Returns store list (may be empty initially)
51
165
  - PASS if no error
52
166
 
53
167
  3. **Create Store**: Call MCP tool `execute` with:
54
168
  ```json
55
169
  { "command": "store:create", "args": { "name": "bk-test-store", "type": "file", "source": ".bluera/bluera-knowledge/test-content" } }
56
170
  ```
57
- - Expected: Store created successfully
58
171
  - PASS if response indicates success
59
172
 
60
173
  4. **Store Info**: Call MCP tool `execute` with:
61
174
  ```json
62
175
  { "command": "store:info", "args": { "store": "bk-test-store" } }
63
176
  ```
64
- - Expected: Returns store metadata including name, type, path
65
177
  - PASS if response contains store details
66
178
 
67
- 5. **Index Store**: Run CLI command via Bash (MCP's store:index spawns background jobs that don't complete reliably):
179
+ 5. **Index Store**: Run CLI command via Bash:
68
180
  ```bash
69
181
  node dist/index.js index bk-test-store
70
182
  ```
71
- - Expected: Output shows "Indexed X documents, Y chunks"
72
183
  - PASS if indexing completes successfully
73
184
 
74
185
  6. **Search (MCP)**: Call MCP tool `search` with:
75
186
  ```json
76
187
  { "query": "validateBKPlugin", "stores": ["bk-test-store"] }
77
188
  ```
78
- - Expected: Returns results containing test content
79
- - PASS if results array is non-empty and contains test file
189
+ - PASS if results array is non-empty
80
190
 
81
- 7. **Get Full Context**: If search returned results, call MCP tool `get_full_context` with:
82
- ```json
83
- { "resultId": "<id from search result>" }
84
- ```
85
- - Expected: Returns full file content
191
+ 7. **Get Full Context**: Call MCP tool `get_full_context` with resultId from step 6
86
192
  - PASS if response contains "BK Plugin Test File"
87
193
 
88
194
  ### Part 2: Slash Commands
89
195
 
90
196
  8. **Stores Command**: Run `/bluera-knowledge:stores`
91
- - Expected: Shows bk-test-store in output
92
- - PASS if store is listed
197
+ - PASS if bk-test-store is listed
93
198
 
94
199
  9. **Search Command**: Run `/bluera-knowledge:search "bluera-knowledge-test"`
95
- - Expected: Returns results from test store
96
200
  - PASS if results are shown
97
201
 
98
202
  10. **Suggest Command**: Run `/bluera-knowledge:suggest`
99
- - Expected: Runs without error (may show no suggestions if no package.json)
100
203
  - PASS if no error thrown
101
204
 
102
- ### Part 3: Hook Tests
205
+ ### Part 3: Hook Tests (same for both modes)
206
+
207
+ [Continue to Part 3 below]
103
208
 
104
- These tests verify that plugin hooks work correctly by running hook scripts directly with simulated input.
209
+ ### Part 4: Cleanup (production mode)
105
210
 
106
- 11. **Hook Registration**: Verify hooks.json has expected structure
211
+ 17. **Delete Store**: Call MCP tool `execute` with:
212
+ ```json
213
+ { "command": "store:delete", "args": { "store": "bk-test-store" } }
214
+ ```
215
+ - PASS if deletion succeeds
216
+
217
+ 18. **Remove Test Content**:
107
218
  ```bash
108
- cat .claude-plugin/hooks/hooks.json 2>/dev/null || cat hooks/hooks.json | jq -e '.hooks.PostToolUse and .hooks.UserPromptSubmit and .hooks.SessionStart'
219
+ rm -rf .bluera/bluera-knowledge/test-content
109
220
  ```
110
- - Expected: Returns `true` (all hook types registered)
111
- - PASS if command succeeds with truthy output
221
+ - PASS if command succeeds
112
222
 
113
- 12. **PostToolUse Hook - Library Detection**: Run hook with simulated node_modules read
223
+ 19. **Verify Cleanup**: Call MCP tool `execute` with `{ command: "stores" }`
224
+ - PASS if bk-test-store is NOT in the list
225
+
226
+ ---
227
+
228
+ # Part 3: Hook Tests (both modes)
229
+
230
+ These tests verify that plugin hooks work correctly by running hook scripts directly.
231
+
232
+ 11. **Hook Registration**:
233
+ ```bash
234
+ cat hooks/hooks.json | jq -e '.hooks.PostToolUse and .hooks.UserPromptSubmit and .hooks.SessionStart'
235
+ ```
236
+ - PASS if returns `true`
237
+
238
+ 12. **PostToolUse Hook - Library Detection**:
114
239
  ```bash
115
240
  echo '{"tool_name": "Read", "tool_input": {"file_path": "/project/node_modules/express/index.js"}}' | python3 hooks/posttooluse-bk-reminder.py
116
241
  ```
117
- - Expected: JSON output with `hookSpecificOutput.additionalContext` containing "BLUERA-KNOWLEDGE REMINDER"
118
- - PASS if output contains reminder text and library name "express"
242
+ - PASS if output contains "BLUERA-KNOWLEDGE REMINDER" and "express"
119
243
 
120
- 13. **PostToolUse Hook - Non-Library (Silent)**: Run hook with non-dependency path
244
+ 13. **PostToolUse Hook - Non-Library (Silent)**:
121
245
  ```bash
122
246
  echo '{"tool_name": "Read", "tool_input": {"file_path": "/project/src/index.ts"}}' | python3 hooks/posttooluse-bk-reminder.py
123
247
  ```
124
- - Expected: Empty output (no reminder for non-library paths)
125
248
  - PASS if output is empty
126
249
 
127
- 14. **Skill Activation Hook - Matching Prompt**: Run hook with library-related question
250
+ 14. **Skill Activation Hook - Matching Prompt**:
128
251
  ```bash
129
252
  export CLAUDE_PLUGIN_ROOT="$(pwd)" && echo '{"prompt": "why does the express package throw this error?"}' | python3 hooks/skill-activation.py
130
253
  ```
131
- - Expected: JSON output with skill activation reminder for "knowledge-search"
132
- - PASS if output contains "MANDATORY EVALUATION" and "knowledge-search"
254
+ - PASS if output contains "MANDATORY EVALUATION"
133
255
 
134
- 15. **Skill Activation Hook - Excluded Prompt**: Run hook with BK command (excluded)
256
+ 15. **Skill Activation Hook - Excluded Prompt**:
135
257
  ```bash
136
258
  export CLAUDE_PLUGIN_ROOT="$(pwd)" && echo '{"prompt": "/bluera-knowledge:search express"}' | python3 hooks/skill-activation.py
137
259
  ```
138
- - Expected: Empty output (global exclusion matches)
139
260
  - PASS if output is empty
140
261
 
141
- 16. **Skill Rules File**: Verify skill-rules.json structure
262
+ 16. **Skill Rules File**:
142
263
  ```bash
143
264
  jq -e '(.skills | length) > 0 and (.globalExclusions | length) > 0' hooks/skill-rules.json
144
265
  ```
145
- - Expected: Returns `true` (valid structure with skills and exclusions)
146
- - PASS if command succeeds
147
-
148
- ### Part 4: Cleanup
266
+ - PASS if returns `true`
149
267
 
150
- 17. **Delete Store**: Call MCP tool `execute` with:
151
- ```json
152
- { "command": "store:delete", "args": { "store": "bk-test-store" } }
153
- ```
154
- - Expected: Store deleted
155
- - PASS if deletion succeeds
268
+ ---
156
269
 
157
- 18. **Remove Test Content**: Run bash command:
158
- ```bash
159
- rm -rf .bluera/bluera-knowledge/test-content
160
- ```
161
- - Expected: Directory removed
162
- - PASS if command succeeds
270
+ ## Output Format
163
271
 
164
- 19. **Verify Cleanup**: Call MCP tool `execute` with `{ command: "stores" }`
165
- - Expected: bk-test-store is NOT in the list
166
- - PASS if test store is gone
272
+ ### For `--dev` mode (16 tests):
167
273
 
168
- ## Output Format
274
+ | # | Test | Status |
275
+ |---|------|--------|
276
+ | 1 | MCP Connection (help) | ? |
277
+ | 2 | List Stores | ? |
278
+ | 3 | Create Store | ? |
279
+ | 4 | Store Info | ? |
280
+ | 5 | Index Store | ? |
281
+ | 6-7 | Search + Get Full Context | ? |
282
+ | 8-10 | Slash Commands | SKIPPED (--dev mode) |
283
+ | 11 | Hook Registration | ? |
284
+ | 12 | PostToolUse - Library Detection | ? |
285
+ | 13 | PostToolUse - Non-Library | ? |
286
+ | 14 | Skill Activation - Matching | ? |
287
+ | 15 | Skill Activation - Excluded | ? |
288
+ | 16 | Skill Rules File | ? |
289
+ | 17 | Delete Store | ? |
290
+ | 18 | Remove Test Content | ? |
291
+ | 19 | Verify Cleanup | ? |
169
292
 
170
- After running all tests, report results in this format:
293
+ **Result: X/16 tests passed (3 skipped)**
171
294
 
172
- ### Plugin Test Results
295
+ ### For production mode (19 tests):
173
296
 
174
297
  | # | Test | Status |
175
298
  |---|------|--------|
@@ -185,7 +308,7 @@ After running all tests, report results in this format:
185
308
  | 10 | /suggest Command | ? |
186
309
  | 11 | Hook Registration | ? |
187
310
  | 12 | PostToolUse - Library Detection | ? |
188
- | 13 | PostToolUse - Non-Library (Silent) | ? |
311
+ | 13 | PostToolUse - Non-Library | ? |
189
312
  | 14 | Skill Activation - Matching | ? |
190
313
  | 15 | Skill Activation - Excluded | ? |
191
314
  | 16 | Skill Rules File | ? |
@@ -195,16 +318,18 @@ After running all tests, report results in this format:
195
318
 
196
319
  **Result: X/19 tests passed**
197
320
 
321
+ ---
322
+
198
323
  ## Error Recovery
199
324
 
200
325
  If tests fail partway through, clean up manually:
201
326
 
202
- 1. Delete test store (if exists):
203
- ```
204
- execute { command: "store:delete", args: { store: "bk-test-store" } }
205
- ```
327
+ **In --dev mode:**
328
+ ```bash
329
+ node scripts/test-mcp-dev.js call execute '{"command":"store:delete","args":{"store":"bk-test-store"}}' 2>/dev/null || true
330
+ rm -rf .bluera/bluera-knowledge/test-content
331
+ ```
206
332
 
207
- 2. Remove test content directory:
208
- ```bash
209
- rm -rf .bluera/bluera-knowledge/test-content
210
- ```
333
+ **In production mode:**
334
+ 1. Call MCP tool `execute` with `{ command: "store:delete", args: { store: "bk-test-store" } }`
335
+ 2. Run: `rm -rf .bluera/bluera-knowledge/test-content`