bluera-knowledge 0.16.5 → 0.17.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.
@@ -1,408 +0,0 @@
1
- ---
2
- description: Run comprehensive plugin validation test suite
3
- argument-hint: "[--dev]"
4
- context: fork
5
- ---
6
-
7
- # Test Plugin
8
-
9
- Comprehensive test of all Bluera Knowledge plugin functionality covering the **full API surface**.
10
-
11
- ## API Coverage
12
-
13
- | Category | Tests |
14
- |----------|-------|
15
- | MCP execute commands | help, commands, stores, store:create, store:info, store:index, store:delete, jobs, job:status, job:cancel |
16
- | MCP tools | search, get_full_context |
17
- | Slash commands | stores, search, suggest, check-status, skill-activation, index, add-folder |
18
- | Web crawling | crawl (start job, verify status, cancel) |
19
- | Hooks | PostToolUse, UserPromptSubmit, SessionStart |
20
-
21
- ## When to Use Each Mode
22
-
23
- | Scenario | Command | Tests |
24
- |----------|---------|-------|
25
- | Claude running with `--plugin-dir .` | `/test-plugin` | 30/30 (full suite) |
26
- | Plugin installed from marketplace | `/test-plugin` | 30/30 (full suite) |
27
- | Claude running WITHOUT plugin loaded | `/test-plugin --dev` | 24/30 (no slash cmds) |
28
-
29
- **Modes:**
30
- - **Default mode**: Uses Claude's MCP tools. Runs all 30 tests including slash commands.
31
- - **`--dev` mode**: Spawns MCP server directly. Skips slash command tests since they require Claude's skill router.
32
-
33
- ## Context
34
-
35
- !`echo "=== BK Plugin Test ===" && ls -la .bluera/bluera-knowledge/ 2>/dev/null || echo "No BK data dir yet (will be created)"`
36
-
37
- ## Mode Detection
38
-
39
- Check if `--dev` flag is present in: $ARGUMENTS
40
-
41
- - If `--dev` is present: Use **Development Mode**
42
- - Otherwise: Use **Production Mode**
43
-
44
- ---
45
-
46
- ## Pre-Test Cleanup
47
-
48
- Clean up any leftover artifacts from previous test runs (ignore errors):
49
-
50
- **In `--dev` mode:**
51
- ```bash
52
- node scripts/test-mcp-dev.js call execute '{"command":"store:delete","args":{"store":"bk-test-store"}}' 2>/dev/null || true
53
- node scripts/test-mcp-dev.js call execute '{"command":"store:delete","args":{"store":"bk-crawl-test"}}' 2>/dev/null || true
54
- rm -rf .bluera/bluera-knowledge/test-content
55
- ```
56
-
57
- **In production mode:**
58
- 1. Call MCP `execute` with `{ command: "store:delete", args: { store: "bk-test-store" } }` - ignore errors
59
- 2. Call MCP `execute` with `{ command: "store:delete", args: { store: "bk-crawl-test" } }` - ignore errors
60
- 3. Run: `rm -rf .bluera/bluera-knowledge/test-content`
61
-
62
- ## Test Content Setup
63
-
64
- Create test content for indexing:
65
-
66
- ```bash
67
- mkdir -p .bluera/bluera-knowledge/test-content
68
- cat > .bluera/bluera-knowledge/test-content/test-file.md << 'EOF'
69
- # BK Plugin Test File
70
-
71
- This file contains unique test content for validating the Bluera Knowledge plugin.
72
-
73
- ## Test Function
74
-
75
- The `validateBKPlugin` function performs comprehensive testing of all plugin features.
76
- It checks MCP connectivity, store operations, search functionality, and cleanup.
77
-
78
- Keywords: bluera-knowledge-test, plugin-validation, mcp-test
79
- EOF
80
- ```
81
-
82
- ---
83
-
84
- # PRODUCTION MODE (default)
85
-
86
- Use this section if `--dev` flag is NOT present.
87
-
88
- ## Part 1: MCP Execute Commands
89
-
90
- 1. **help**: Call `execute` with `{ command: "help" }`
91
- - PASS if response contains "Available commands"
92
-
93
- 2. **commands**: Call `execute` with `{ command: "commands" }`
94
- - PASS if response contains array of commands with "stores" and "store:create"
95
-
96
- 3. **stores**: Call `execute` with `{ command: "stores" }`
97
- - PASS if no error (may return empty array)
98
-
99
- 4. **store:create**: Call `execute` with:
100
- ```json
101
- { "command": "store:create", "args": { "name": "bk-test-store", "type": "file", "source": ".bluera/bluera-knowledge/test-content" } }
102
- ```
103
- - PASS if response indicates success and contains store id
104
-
105
- 5. **store:info**: Call `execute` with:
106
- ```json
107
- { "command": "store:info", "args": { "store": "bk-test-store" } }
108
- ```
109
- - PASS if response contains store name and type
110
-
111
- 6. **store:index**: Call `execute` with:
112
- ```json
113
- { "command": "store:index", "args": { "store": "bk-test-store" } }
114
- ```
115
- - PASS if response indicates indexing started (job created)
116
-
117
- 7. **jobs**: Call `execute` with `{ command: "jobs" }`
118
- - PASS if response contains jobs array (may be empty if indexing completed)
119
-
120
- 8. **job:status** (if job from step 6 available): Call `execute` with:
121
- ```json
122
- { "command": "job:status", "args": { "jobId": "<job-id-from-step-6>" } }
123
- ```
124
- - PASS if response contains job status (pending, running, or completed)
125
- - SKIP if no job id available (indexing was synchronous)
126
-
127
- ## Part 2: MCP Search Tools
128
-
129
- 9. **search**: Call MCP tool `search` with:
130
- ```json
131
- { "query": "validateBKPlugin", "stores": ["bk-test-store"] }
132
- ```
133
- - PASS if results array is non-empty
134
-
135
- 10. **get_full_context**: Call MCP tool `get_full_context` with resultId from step 9
136
- - PASS if response contains code or documentation content
137
-
138
- ## Part 3: Slash Commands
139
-
140
- 11. **/stores**: Run `/bluera-knowledge:stores`
141
- - PASS if bk-test-store is listed
142
-
143
- 12. **/search**: Run `/bluera-knowledge:search "bluera-knowledge-test"`
144
- - PASS if results are shown
145
-
146
- 13. **/suggest**: Run `/bluera-knowledge:suggest`
147
- - PASS if no error thrown
148
-
149
- 14. **/check-status**: Run `/bluera-knowledge:check-status`
150
- - PASS if shows job status (may show "no active jobs")
151
-
152
- 15. **/skill-activation**: Run `/bluera-knowledge:skill-activation`
153
- - PASS if shows activation configuration or prompts for setup
154
-
155
- 16. **/index**: Run `/bluera-knowledge:index bk-test-store`
156
- - PASS if indexing completes or starts successfully
157
-
158
- ## Part 4: Web Crawl Testing
159
-
160
- 17. **Create crawl store**: Call `execute` with:
161
- ```json
162
- { "command": "store:create", "args": { "name": "bk-crawl-test", "type": "web", "source": "https://httpbin.org/html", "options": { "maxPages": 1 } } }
163
- ```
164
- - PASS if store creation initiates and returns job id
165
-
166
- 18. **Verify crawl job**: Call `execute` with `{ command: "jobs" }`
167
- - PASS if bk-crawl-test job appears in list (or completed)
168
-
169
- 19. **job:cancel** (if crawl still running): Call `execute` with:
170
- ```json
171
- { "command": "job:cancel", "args": { "jobId": "<crawl-job-id>" } }
172
- ```
173
- - PASS if job cancelled or already completed
174
- - SKIP if job already completed
175
-
176
- 20. **Delete crawl store**: Call `execute` with:
177
- ```json
178
- { "command": "store:delete", "args": { "store": "bk-crawl-test" } }
179
- ```
180
- - PASS if deletion succeeds
181
-
182
- ## Part 5: Hook Tests
183
-
184
- 21. **Hook Registration**:
185
- ```bash
186
- cat hooks/hooks.json | jq -e '.hooks.PostToolUse and .hooks.UserPromptSubmit and .hooks.SessionStart'
187
- ```
188
- - PASS if returns `true`
189
-
190
- 22. **PostToolUse Hook - Library Detection**:
191
- ```bash
192
- echo '{"tool_name": "Read", "tool_input": {"file_path": "/project/node_modules/express/index.js"}}' | python3 hooks/posttooluse-bk-reminder.py
193
- ```
194
- - PASS if output contains "BLUERA-KNOWLEDGE REMINDER"
195
-
196
- 23. **PostToolUse Hook - Non-Library**:
197
- ```bash
198
- echo '{"tool_name": "Read", "tool_input": {"file_path": "/project/src/index.ts"}}' | python3 hooks/posttooluse-bk-reminder.py
199
- ```
200
- - PASS if output is empty
201
-
202
- 24. **Skill Activation Hook - Matching**:
203
- ```bash
204
- export CLAUDE_PLUGIN_ROOT="$(pwd)" && echo '{"prompt": "why does the express package throw this error?"}' | python3 hooks/skill-activation.py
205
- ```
206
- - PASS if output contains "MANDATORY EVALUATION"
207
-
208
- 25. **Skill Activation Hook - Excluded**:
209
- ```bash
210
- export CLAUDE_PLUGIN_ROOT="$(pwd)" && echo '{"prompt": "/bluera-knowledge:search express"}' | python3 hooks/skill-activation.py
211
- ```
212
- - PASS if output is empty
213
-
214
- 26. **Skill Rules File**:
215
- ```bash
216
- jq -e '(.skills | length) > 0 and (.globalExclusions | length) > 0' hooks/skill-rules.json
217
- ```
218
- - PASS if returns `true`
219
-
220
- ## Part 6: Cleanup
221
-
222
- 27. **Delete test store**: Call `execute` with:
223
- ```json
224
- { "command": "store:delete", "args": { "store": "bk-test-store" } }
225
- ```
226
- - PASS if deletion succeeds
227
-
228
- 28. **Remove test content**:
229
- ```bash
230
- rm -rf .bluera/bluera-knowledge/test-content
231
- ```
232
- - PASS if command succeeds
233
-
234
- 29. **Verify store cleanup**: Call `execute` with `{ command: "stores" }`
235
- - PASS if bk-test-store is NOT in the list
236
-
237
- 30. **Verify no test artifacts**:
238
- ```bash
239
- test ! -d .bluera/bluera-knowledge/test-content && echo "clean"
240
- ```
241
- - PASS if outputs "clean"
242
-
243
- ---
244
-
245
- # DEVELOPMENT MODE (`--dev`)
246
-
247
- Use this section if `--dev` flag is present. Uses `scripts/test-mcp-dev.js`.
248
-
249
- ### Part 1: MCP Commands (via dev script)
250
-
251
- 1. **help**:
252
- ```bash
253
- node scripts/test-mcp-dev.js call execute '{"command":"help"}'
254
- ```
255
- - PASS if contains "Available commands"
256
-
257
- 2. **commands**:
258
- ```bash
259
- node scripts/test-mcp-dev.js call execute '{"command":"commands"}'
260
- ```
261
- - PASS if contains commands array
262
-
263
- 3. **stores**:
264
- ```bash
265
- node scripts/test-mcp-dev.js call execute '{"command":"stores"}'
266
- ```
267
- - PASS if no error
268
-
269
- 4. **store:create**:
270
- ```bash
271
- node scripts/test-mcp-dev.js call execute '{"command":"store:create","args":{"name":"bk-test-store","type":"file","source":".bluera/bluera-knowledge/test-content"}}'
272
- ```
273
- - PASS if success
274
-
275
- 5. **store:info**:
276
- ```bash
277
- node scripts/test-mcp-dev.js call execute '{"command":"store:info","args":{"store":"bk-test-store"}}'
278
- ```
279
- - PASS if contains store details
280
-
281
- 6. **store:index**:
282
- ```bash
283
- node scripts/test-mcp-dev.js call execute '{"command":"store:index","args":{"store":"bk-test-store"}}'
284
- ```
285
- - PASS if indexing starts
286
-
287
- 7. **jobs**:
288
- ```bash
289
- node scripts/test-mcp-dev.js call execute '{"command":"jobs"}'
290
- ```
291
- - PASS if returns jobs array
292
-
293
- 8. **job:status** (if job available):
294
- ```bash
295
- node scripts/test-mcp-dev.js call execute '{"command":"job:status","args":{"jobId":"<job-id>"}}'
296
- ```
297
- - PASS if returns status
298
-
299
- ### Part 2: Search (via dev script)
300
-
301
- 9-10. **Search + Get Full Context**:
302
- ```bash
303
- node scripts/test-mcp-dev.js session << 'EOF'
304
- search {"query":"validateBKPlugin","stores":["bk-test-store"]}
305
- get_full_context {"resultId":"$LAST_ID"}
306
- EOF
307
- ```
308
- - PASS if search returns results and context contains content
309
-
310
- ### Part 3: Slash Commands (SKIPPED in --dev mode)
311
-
312
- Tests 11-16 are skipped - slash commands require Claude's skill router.
313
-
314
- ### Part 4: Web Crawl (via dev script)
315
-
316
- 17. **Create crawl store**:
317
- ```bash
318
- node scripts/test-mcp-dev.js call execute '{"command":"store:create","args":{"name":"bk-crawl-test","type":"web","source":"https://httpbin.org/html","options":{"maxPages":1}}}'
319
- ```
320
- - PASS if returns job id
321
-
322
- 18. **Verify crawl job**:
323
- ```bash
324
- node scripts/test-mcp-dev.js call execute '{"command":"jobs"}'
325
- ```
326
- - PASS if job appears
327
-
328
- 19. **job:cancel** (if running):
329
- ```bash
330
- node scripts/test-mcp-dev.js call execute '{"command":"job:cancel","args":{"jobId":"<crawl-job-id>"}}'
331
- ```
332
- - PASS if cancelled or completed
333
-
334
- 20. **Delete crawl store**:
335
- ```bash
336
- node scripts/test-mcp-dev.js call execute '{"command":"store:delete","args":{"store":"bk-crawl-test"}}'
337
- ```
338
- - PASS if deleted
339
-
340
- ### Part 5: Hook Tests (same as production)
341
-
342
- [Tests 21-26 - same bash commands as production mode]
343
-
344
- ### Part 6: Cleanup (via dev script)
345
-
346
- 27-30: Same cleanup steps using dev script for MCP calls.
347
-
348
- ---
349
-
350
- ## Output Format
351
-
352
- ### Production mode (30 tests):
353
-
354
- | # | Test | Status |
355
- |---|------|--------|
356
- | 1 | MCP help | ? |
357
- | 2 | MCP commands | ? |
358
- | 3 | MCP stores | ? |
359
- | 4 | MCP store:create | ? |
360
- | 5 | MCP store:info | ? |
361
- | 6 | MCP store:index | ? |
362
- | 7 | MCP jobs | ? |
363
- | 8 | MCP job:status | ? |
364
- | 9 | MCP search | ? |
365
- | 10 | MCP get_full_context | ? |
366
- | 11 | /stores | ? |
367
- | 12 | /search | ? |
368
- | 13 | /suggest | ? |
369
- | 14 | /check-status | ? |
370
- | 15 | /skill-activation | ? |
371
- | 16 | /index | ? |
372
- | 17 | Crawl store create | ? |
373
- | 18 | Crawl job verify | ? |
374
- | 19 | Crawl job:cancel | ? |
375
- | 20 | Crawl store delete | ? |
376
- | 21 | Hook registration | ? |
377
- | 22 | PostToolUse - library | ? |
378
- | 23 | PostToolUse - non-library | ? |
379
- | 24 | Skill activation - match | ? |
380
- | 25 | Skill activation - exclude | ? |
381
- | 26 | Skill rules file | ? |
382
- | 27 | Delete test store | ? |
383
- | 28 | Remove test content | ? |
384
- | 29 | Verify store cleanup | ? |
385
- | 30 | Verify no artifacts | ? |
386
-
387
- **Result: X/30 tests passed**
388
-
389
- ### Development mode (24 tests):
390
-
391
- Same table but tests 11-16 show "SKIPPED (--dev mode)"
392
-
393
- **Result: X/24 tests passed (6 skipped)**
394
-
395
- ---
396
-
397
- ## Error Recovery
398
-
399
- If tests fail partway through, clean up manually:
400
-
401
- ```bash
402
- # Delete test stores
403
- node scripts/test-mcp-dev.js call execute '{"command":"store:delete","args":{"store":"bk-test-store"}}' 2>/dev/null || true
404
- node scripts/test-mcp-dev.js call execute '{"command":"store:delete","args":{"store":"bk-crawl-test"}}' 2>/dev/null || true
405
-
406
- # Remove test content
407
- rm -rf .bluera/bluera-knowledge/test-content
408
- ```
@@ -1,65 +0,0 @@
1
- ---
2
- description: Remove Bluera Knowledge data from this project
3
- allowed-tools: ["mcp__bluera-knowledge__execute"]
4
- ---
5
-
6
- # Uninstall Bluera Knowledge
7
-
8
- Remove Bluera Knowledge data from this project.
9
-
10
- ## Steps
11
-
12
- 1. Use mcp__bluera-knowledge__execute tool with command "uninstall":
13
- - Optional args.global: true to also remove global data
14
- - Optional args.keepDefinitions: false to also remove stores.config.json
15
-
16
- 2. Display the result showing what was deleted and cleanup instructions.
17
-
18
- ## Options
19
-
20
- | Flag | Description |
21
- |------|-------------|
22
- | `global` | Also delete global data (~/.local/share/bluera-knowledge/) |
23
- | `keepDefinitions` | Keep stores.config.json for team sharing (default: true) |
24
-
25
- ## Examples
26
-
27
- **Clean project data (preserves stores.config.json):**
28
- ```
29
- /bluera-knowledge:uninstall
30
- ```
31
-
32
- **Full cleanup including store definitions:**
33
- ```
34
- Use uninstall with keepDefinitions: false
35
- ```
36
-
37
- **Full cleanup including global data:**
38
- ```
39
- Use uninstall with global: true
40
- ```
41
-
42
- ## What Gets Deleted
43
-
44
- **Project data** (`.bluera/bluera-knowledge/`):
45
- - `data/` - Vector indices, cloned repos, stores.json
46
- - `config.json` - Plugin configuration
47
- - `stores.config.json` - Only if keepDefinitions: false
48
-
49
- **Global data** (with --global flag):
50
- - `~/.local/share/bluera-knowledge/` - Job history, skill settings
51
-
52
- ## What Is NOT Deleted
53
-
54
- - **Plugin cache** - Managed by Claude Code, instructions provided
55
- - **Python venv** - Inside plugin cache, cleaned when cache is cleared
56
-
57
- ## Testing Fresh Plugin Installs
58
-
59
- After running uninstall, to test a completely fresh plugin install:
60
-
61
- 1. Exit Claude Code
62
- 2. Clear plugin cache: `rm -rf ~/.claude/plugins/cache/bluera-knowledge-*`
63
- 3. Restart Claude Code and reinstall the plugin
64
-
65
- _Clearing the plugin cache removes everything: plugin code, Python venv, and all dependencies._
@@ -1,145 +0,0 @@
1
- #!/bin/bash
2
- # Bluera Knowledge Plugin - Dependency Checker
3
- # Automatically checks and installs dependencies for the plugin
4
- #
5
- # Environment variables:
6
- # BK_SKIP_AUTO_INSTALL=1 - Skip automatic installation of crawl4ai
7
- # Set this if you prefer to manage Python packages manually
8
- #
9
- # What this script auto-installs (if missing):
10
- # - Node.js dependencies (via bun or npm, from package.json)
11
- # - Python virtual environment with crawl4ai (isolated from system Python)
12
- # - Playwright Chromium browser (via playwright CLI, for headless crawling)
13
-
14
- set -e
15
-
16
- # Get the plugin root directory
17
- PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$(dirname "$(dirname "$0")")}"
18
-
19
- # Venv location within plugin (isolated from system Python)
20
- VENV_DIR="$PLUGIN_ROOT/.venv"
21
- VENV_PYTHON="$VENV_DIR/bin/python3"
22
- VENV_PIP="$VENV_DIR/bin/pip"
23
-
24
- # Colors for output
25
- RED='\033[0;31m'
26
- GREEN='\033[0;32m'
27
- YELLOW='\033[1;33m'
28
- NC='\033[0m' # No Color
29
-
30
- # =====================
31
- # Helper Functions
32
- # =====================
33
-
34
- # Install Playwright browser using specified python
35
- # Args: $1 = python path to use
36
- install_playwright_browser() {
37
- local PYTHON_CMD="${1:-python3}"
38
-
39
- # Check if Playwright Chromium is already installed by testing if browser can be launched
40
- if "$PYTHON_CMD" -c "from playwright.sync_api import sync_playwright; p = sync_playwright().start(); b = p.chromium.launch(); b.close(); p.stop()" 2>/dev/null; then
41
- echo -e "${GREEN}[bluera-knowledge] Playwright Chromium ready ✓${NC}"
42
- return 0
43
- fi
44
-
45
- echo -e "${YELLOW}[bluera-knowledge] Installing Playwright browser (one-time setup)...${NC}"
46
- if "$PYTHON_CMD" -m playwright install chromium 2>/dev/null; then
47
- echo -e "${GREEN}[bluera-knowledge] Playwright Chromium installed ✓${NC}"
48
- return 0
49
- else
50
- echo -e "${YELLOW}[bluera-knowledge] Playwright browser install failed.${NC}"
51
- echo -e "${YELLOW}Manual fix: $PYTHON_CMD -m playwright install chromium${NC}"
52
- return 1
53
- fi
54
- }
55
-
56
- # =====================
57
- # Node.js Dependencies
58
- # =====================
59
-
60
- # Check if node_modules exists
61
- if [ ! -d "$PLUGIN_ROOT/node_modules" ]; then
62
- echo -e "${YELLOW}[bluera-knowledge] Installing Node.js dependencies...${NC}"
63
-
64
- # Try bun first (faster), fall back to npm
65
- if command -v bun &> /dev/null; then
66
- (cd "$PLUGIN_ROOT" && bun install --frozen-lockfile 2>/dev/null) && \
67
- echo -e "${GREEN}[bluera-knowledge] Node.js dependencies installed ✓${NC}" || \
68
- echo -e "${RED}[bluera-knowledge] Failed to install Node.js dependencies${NC}"
69
- elif command -v npm &> /dev/null; then
70
- (cd "$PLUGIN_ROOT" && npm ci --silent 2>/dev/null) && \
71
- echo -e "${GREEN}[bluera-knowledge] Node.js dependencies installed ✓${NC}" || \
72
- echo -e "${RED}[bluera-knowledge] Failed to install Node.js dependencies${NC}"
73
- else
74
- echo -e "${RED}[bluera-knowledge] Neither bun nor npm found. Please install Node.js dependencies manually.${NC}"
75
- fi
76
- fi
77
-
78
- # =====================
79
- # Python Dependencies (using venv)
80
- # =====================
81
-
82
- # Check if Python3 is installed
83
- if ! command -v python3 &> /dev/null; then
84
- echo -e "${RED}[bluera-knowledge] Python3 is not installed${NC}"
85
- echo -e "${YELLOW}Web crawling features require Python 3.x${NC}"
86
- echo -e "${YELLOW}Install Python3: https://www.python.org/downloads/${NC}"
87
- exit 0 # Don't block the session, just warn
88
- fi
89
-
90
- # Check Python version (require 3.8+)
91
- python_version=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
92
-
93
- if ! python3 -c "import sys; exit(0 if sys.version_info >= (3, 8) else 1)"; then
94
- echo -e "${YELLOW}[bluera-knowledge] Python ${python_version} detected. Python 3.8+ recommended for crawl4ai${NC}"
95
- fi
96
-
97
- # Check if venv exists and has crawl4ai installed
98
- if [ -f "$VENV_PYTHON" ] && "$VENV_PYTHON" -c "import crawl4ai" 2>/dev/null; then
99
- crawl4ai_version=$("$VENV_PYTHON" -c "import crawl4ai; print(crawl4ai.__version__)" 2>/dev/null || echo "unknown")
100
- echo -e "${GREEN}[bluera-knowledge] crawl4ai ${crawl4ai_version} ready (venv) ✓${NC}"
101
- # Ensure Playwright browser is installed for headless crawling
102
- install_playwright_browser "$VENV_PYTHON"
103
- exit 0
104
- fi
105
-
106
- # Check if auto-install is disabled
107
- if [ "${BK_SKIP_AUTO_INSTALL:-}" = "1" ]; then
108
- echo -e "${YELLOW}[bluera-knowledge] Auto-install disabled (BK_SKIP_AUTO_INSTALL=1)${NC}"
109
- echo -e "${YELLOW}To enable web crawling, create venv manually:${NC}"
110
- echo -e " ${GREEN}python3 -m venv $VENV_DIR${NC}"
111
- echo -e " ${GREEN}$VENV_PIP install crawl4ai${NC}"
112
- echo -e " ${GREEN}$VENV_PYTHON -m playwright install chromium${NC}"
113
- exit 0
114
- fi
115
-
116
- # Create venv if it doesn't exist
117
- if [ ! -d "$VENV_DIR" ]; then
118
- echo -e "${YELLOW}[bluera-knowledge] Creating Python virtual environment...${NC}"
119
- if python3 -m venv "$VENV_DIR" 2>/dev/null; then
120
- echo -e "${GREEN}[bluera-knowledge] Virtual environment created ✓${NC}"
121
- else
122
- echo -e "${RED}[bluera-knowledge] Failed to create virtual environment${NC}"
123
- echo -e "${YELLOW}Manual fix: python3 -m venv $VENV_DIR${NC}"
124
- exit 0
125
- fi
126
- fi
127
-
128
- # Install crawl4ai into venv
129
- echo -e "${YELLOW}[bluera-knowledge] Installing crawl4ai into virtual environment...${NC}"
130
- echo -e "${YELLOW}(Set BK_SKIP_AUTO_INSTALL=1 to disable auto-install)${NC}"
131
-
132
- if "$VENV_PIP" install --quiet crawl4ai 2>/dev/null; then
133
- crawl4ai_version=$("$VENV_PYTHON" -c "import crawl4ai; print(crawl4ai.__version__)" 2>/dev/null || echo "installed")
134
- echo -e "${GREEN}[bluera-knowledge] crawl4ai ${crawl4ai_version} installed (venv) ✓${NC}"
135
- # Install Playwright browser for headless crawling
136
- install_playwright_browser "$VENV_PYTHON"
137
- else
138
- echo -e "${RED}[bluera-knowledge] Failed to install crawl4ai${NC}"
139
- echo -e "${YELLOW}Manual fix:${NC}"
140
- echo -e " ${GREEN}$VENV_PIP install crawl4ai${NC}"
141
- echo -e " ${GREEN}$VENV_PYTHON -m playwright install chromium${NC}"
142
- fi
143
-
144
- # Always exit 0 to not block the session
145
- exit 0