bluera-knowledge 0.13.0 → 0.13.2

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 (34) hide show
  1. package/.claude/rules/code-quality.md +12 -0
  2. package/.claude/rules/git.md +5 -0
  3. package/.claude/rules/versioning.md +7 -0
  4. package/.claude-plugin/plugin.json +2 -15
  5. package/.mcp.json +11 -0
  6. package/CHANGELOG.md +7 -0
  7. package/CLAUDE.md +5 -13
  8. package/CONTRIBUTING.md +307 -0
  9. package/README.md +58 -1167
  10. package/commands/crawl.md +2 -1
  11. package/commands/test-plugin.md +197 -72
  12. package/docs/claude-code-best-practices.md +458 -0
  13. package/docs/cli.md +170 -0
  14. package/docs/commands.md +392 -0
  15. package/docs/crawler-architecture.md +89 -0
  16. package/docs/mcp-integration.md +130 -0
  17. package/docs/token-efficiency.md +91 -0
  18. package/eslint.config.js +1 -1
  19. package/hooks/check-dependencies.sh +18 -1
  20. package/hooks/hooks.json +2 -2
  21. package/hooks/posttooluse-bk-reminder.py +30 -2
  22. package/package.json +1 -1
  23. package/scripts/test-mcp-dev.js +260 -0
  24. package/src/mcp/plugin-mcp-config.test.ts +26 -19
  25. package/tests/integration/cli-consistency.test.ts +3 -2
  26. package/docs/plans/2024-12-17-ai-search-quality-implementation.md +0 -752
  27. package/docs/plans/2024-12-17-ai-search-quality-testing-design.md +0 -201
  28. package/docs/plans/2025-12-16-bluera-knowledge-cli.md +0 -2951
  29. package/docs/plans/2025-12-16-phase2-features.md +0 -1518
  30. package/docs/plans/2025-12-17-hil-implementation.md +0 -926
  31. package/docs/plans/2025-12-17-hil-quality-testing.md +0 -224
  32. package/docs/plans/2025-12-17-search-quality-phase1-implementation.md +0 -1416
  33. package/docs/plans/2025-12-17-search-quality-testing-v2-design.md +0 -212
  34. package/docs/plans/2025-12-28-ai-agent-optimization.md +0 -1630
package/README.md CHANGED
@@ -35,28 +35,19 @@ All searchable in milliseconds, no rate limits, fully offline.
35
35
 
36
36
  - [Installation](#-installation)
37
37
  - [Why Bluera Knowledge?](#-why-bluera-knowledge)
38
- - [Token Efficiency](#-token-efficiency)
38
+ - [When to Query BK](#-when-claude-code-should-query-bk)
39
39
  - [Quick Start](#-quick-start)
40
40
  - [Features](#-features)
41
41
  - [How It Works](#-how-it-works)
42
42
  - [User Interface](#-user-interface)
43
43
  - [Background Jobs](#-background-jobs)
44
- - [Commands](#-commands)
45
- - [Crawler Architecture](#-crawler-architecture)
46
44
  - [Use Cases](#-use-cases)
47
- - [Dependencies](#-dependencies)
48
- - [Troubleshooting](#-troubleshooting)
49
- - [MCP Integration](#-mcp-integration)
50
- - [CLI Tool](#️-cli-tool)
51
45
  - [Skills for Claude Code](#-skills-for-claude-code)
52
46
  - [Data Storage](#-data-storage)
53
- - [Development](#-development)
54
- - [Setup](#-setup)
55
- - [Claude Code Settings](#️-claude-code-settings-recommended)
56
- - [Commands / Scripts](#-commands)
57
- - [Releasing](#-releasing)
58
- - [Testing](#-testing-locally)
47
+ - [Troubleshooting](#-troubleshooting)
48
+ - [Dependencies](#-dependencies)
59
49
  - [Technologies](#-technologies)
50
+ - [Documentation](#-documentation)
60
51
  - [Contributing](#-contributing)
61
52
  - [License](#-license)
62
53
 
@@ -163,92 +154,6 @@ BK is cheap (~100ms, no rate limits), authoritative (actual source code), and co
163
154
 
164
155
  ---
165
156
 
166
- ## 💰 Token Efficiency
167
-
168
- Beyond speed and accuracy, Bluera Knowledge can **significantly reduce token consumption** for code-related queries—typically saving 60-75% compared to web search approaches.
169
-
170
- ### 📊 How It Works
171
-
172
- **Without Bluera Knowledge:**
173
- - Web searches return 5-10 results (~500-2,000 tokens each)
174
- - Total per search: **3,000-10,000 tokens**
175
- - Often need multiple searches to find the right answer
176
- - Lower signal-to-noise ratio (blog posts mixed with actual docs)
177
-
178
- **With Bluera Knowledge:**
179
- - Semantic search returns top 10 relevant code chunks (~200-400 tokens each)
180
- - Structured metadata (file paths, imports, purpose)
181
- - Total per search: **1,500-3,000 tokens**
182
- - Higher relevance due to vector search (fewer follow-up queries needed)
183
-
184
- ### 🎯 Real-World Examples
185
-
186
- #### Example 1: Library Implementation Question
187
-
188
- **Question:** "How does Express handle middleware errors?"
189
-
190
- | Approach | Token Cost | Result |
191
- |----------|-----------|--------|
192
- | **Web Search** | ~8,000 tokens<br/>(3 searches: general query → refined query → source code) | Blog posts + Stack Overflow + eventual guess |
193
- | **Bluera Knowledge** | ~2,000 tokens<br/>(1 semantic search) | Actual Express source code, authoritative |
194
- | **Savings** | **75% fewer tokens** ✅ | Higher accuracy |
195
-
196
- #### Example 2: Dependency Exploration
197
-
198
- **Question:** "How does LanceDB's vector search work?"
199
-
200
- | Approach | Token Cost | Result |
201
- |----------|-----------|--------|
202
- | **Web Search** | ~9,500 tokens<br/>(General docs → API docs → fetch specific page) | Documentation, might miss implementation details |
203
- | **Bluera Knowledge** | ~1,500 tokens<br/>(Search returns source + tests + examples) | Source code from Python + Rust implementation |
204
- | **Savings** | **84% fewer tokens** ✅ | Complete picture |
205
-
206
- #### Example 3: Version-Specific Behavior
207
-
208
- **Question:** "What changed in React 18's useEffect cleanup?"
209
-
210
- | Approach | Token Cost | Result |
211
- |----------|-----------|--------|
212
- | **Training Data** | 0 tokens (but might be outdated) | Uncertain if accurate for React 18 |
213
- | **Web Search** | ~5,000 tokens<br/>(Search changelog → blog posts → docs) | Mix of React 17 and 18 info |
214
- | **Bluera Knowledge** | ~2,000 tokens<br/>(Search indexed React 18 source) | Exact React 18 implementation |
215
- | **Savings** | **60% fewer tokens** ✅ | Version-accurate |
216
-
217
- ### ⚖️ When BK Uses More Tokens
218
-
219
- Bluera Knowledge isn't always the most token-efficient choice:
220
-
221
- | Scenario | Best Approach | Why |
222
- |----------|---------------|-----|
223
- | **Simple concept questions**<br/>("What is a JavaScript closure?") | Training data | Claude already knows this (0 tokens) |
224
- | **Current events**<br/>("Latest Next.js 15 release notes") | Web search | BK only has what you've indexed |
225
- | **General advice**<br/>("How to structure a React app?") | Training data | Opinion-based, not code-specific |
226
-
227
- ### 📈 Summary: Token Savings by Query Type
228
-
229
- | Query Type | Typical Token Savings | When to Use BK |
230
- |------------|----------------------|----------------|
231
- | **Library internals** | 60-75% | ✅ Always |
232
- | **Version-specific behavior** | 50-70% | ✅ Always |
233
- | **"How does X work internally?"** | 70-85% | ✅ Always |
234
- | **API usage examples** | 40-60% | ✅ Recommended |
235
- | **General concepts** | -100% (uses more) | ❌ Skip BK |
236
- | **Current events** | -100% (uses more) | ❌ Skip BK |
237
-
238
- ### 💡 Best Practice
239
-
240
- **Default to BK for library questions.** It's cheap, fast, and authoritative:
241
-
242
- | Question Type | Action | Why |
243
- |--------------|--------|-----|
244
- | Library internals, APIs, errors, versions, config | **Query BK first** | Source code is definitive, 60-85% token savings |
245
- | General programming concepts | Skip BK | Training data is sufficient |
246
- | Breaking news, release notes | Web search | BK only has indexed content |
247
-
248
- The plugin's Skills teach Claude Code these patterns automatically. When in doubt about a dependency, query BK—it's faster and more accurate than guessing or web searching.
249
-
250
- ---
251
-
252
157
  ## 🚀 Quick Start
253
158
 
254
159
  ### Using Claude Code Plugin
@@ -487,483 +392,54 @@ Background jobs include significant performance optimizations:
487
392
 
488
393
  ---
489
394
 
490
- ## 📖 Quick Reference
491
-
492
- | Command | Purpose | Arguments |
493
- |---------|---------|-----------|
494
- | 🔬 `/bluera-knowledge:suggest` | Analyze project dependencies | None |
495
- | 📦 `/bluera-knowledge:add-repo` | Clone and index Git repository | `<url> [--name=<name>] [--branch=<branch>]` |
496
- | 📁 `/bluera-knowledge:add-folder` | Index local folder | `<path> --name=<name>` |
497
- | 🔍 `/bluera-knowledge:search` | Search knowledge stores | `"<query>" [--stores=<names>] [--limit=<N>]` |
498
- | 📋 `/bluera-knowledge:stores` | List all stores | None |
499
- | 🔄 `/bluera-knowledge:index` | Re-index a store | `<store-name-or-id>` |
500
- | 🗑️ `/bluera-knowledge:remove-store` | Delete a store and all data | `<store-name-or-id>` |
501
- | 🌐 `/bluera-knowledge:crawl` | Crawl web pages | `<url> <store-name> [--crawl "<instruction>"]` |
502
- | 🔁 `/bluera-knowledge:sync` | Sync stores from definitions config | `[--dry-run] [--prune]` |
503
-
504
- ---
505
-
506
- ## 💻 Commands
395
+ ## 🎯 Use Cases
507
396
 
508
- ### 🔬 `/bluera-knowledge:suggest`
397
+ ### Dependency Source Code
509
398
 
510
- **Analyze your project to suggest libraries worth indexing as knowledge stores**
399
+ Provide AI agents with canonical dependency implementation details:
511
400
 
512
401
  ```bash
513
402
  /bluera-knowledge:suggest
514
- ```
515
-
516
- Scans source files, counts import statements, and suggests the top 5 most-used dependencies with their repository URLs.
517
-
518
- **Supported languages:**
519
- | Language | Manifest File | Registry |
520
- |----------|---------------|----------|
521
- | JavaScript/TypeScript | `package.json` | NPM |
522
- | Python | `requirements.txt`, `pyproject.toml` | PyPI |
523
- | Rust | `Cargo.toml` | crates.io |
524
- | Go | `go.mod` | Go modules |
525
-
526
- <details>
527
- <summary><b>📊 Expected Output</b></summary>
528
-
529
- ```
530
- ## Dependency Analysis
531
-
532
- Scanned 342 source files and found 24 dependencies.
533
-
534
- ### Top Dependencies by Usage
535
-
536
- 1. **react** (156 imports across 87 files)
537
- Repository: https://github.com/facebook/react
538
-
539
- Add with:
540
- /bluera-knowledge:add-repo https://github.com/facebook/react --name=react
541
-
542
- 2. **vitest** (40 imports across 40 files)
543
- Repository: https://github.com/vitest-dev/vitest
544
-
545
- Add with:
546
- /bluera-knowledge:add-repo https://github.com/vitest-dev/vitest --name=vitest
547
-
548
- 3. **lodash** (28 imports across 15 files)
549
- Repository: https://github.com/lodash/lodash
550
-
551
- Add with:
552
- /bluera-knowledge:add-repo https://github.com/lodash/lodash --name=lodash
553
-
554
- ---
555
-
556
- Already indexed: typescript, express
557
- ```
558
- </details>
559
-
560
- ---
561
-
562
- ### 📦 `/bluera-knowledge:add-repo`
563
-
564
- **Clone and index a Git repository**
565
-
566
- ```bash
567
- /bluera-knowledge:add-repo <url> [--name=<name>] [--branch=<branch>]
568
- ```
569
-
570
- **Examples:**
571
- ```bash
572
- /bluera-knowledge:add-repo https://github.com/lodash/lodash
573
- /bluera-knowledge:add-repo https://github.com/facebook/react --branch=main --name=react
574
- ```
575
-
576
- <details>
577
- <summary><b>✅ Expected Output</b></summary>
578
-
579
- ```
580
- ✓ Cloning https://github.com/facebook/react...
581
- ✓ Created store: react (a1b2c3d4...)
582
- Location: ~/.local/share/bluera-knowledge/stores/a1b2c3d4.../
583
-
584
- ✓ Indexing...
585
- ✓ Indexed 1,247 files
403
+ /bluera-knowledge:add-repo https://github.com/expressjs/express
586
404
 
587
- Store is ready for searching!
405
+ # AI agents can now:
406
+ # - Semantic search: "middleware error handling"
407
+ # - Direct access: Grep/Glob through the cloned express repo
588
408
  ```
589
- </details>
590
-
591
- ---
592
-
593
- ### 📁 `/bluera-knowledge:add-folder`
594
409
 
595
- **Index a local folder**
410
+ ### Project Documentation
596
411
 
597
- ```bash
598
- /bluera-knowledge:add-folder <path> --name=<name>
599
- ```
600
-
601
- **📚 Use cases:**
602
- - 📖 Project documentation
603
- - 📏 Coding standards
604
- - 🎨 Design documents
605
- - 🔌 API specifications
606
- - 📚 Reference materials
607
- - 📄 Any other content
412
+ Make project-specific documentation available:
608
413
 
609
- **Examples:**
610
414
  ```bash
611
415
  /bluera-knowledge:add-folder ./docs --name=project-docs
612
- /bluera-knowledge:add-folder ./architecture --name=design-docs
613
- ```
614
-
615
- <details>
616
- <summary><b>✅ Expected Output</b></summary>
617
-
618
- ```
619
- ✓ Adding folder: ~/my-project/docs...
620
- ✓ Created store: project-docs (e5f6g7h8...)
621
- Location: ~/.local/share/bluera-knowledge/stores/e5f6g7h8.../
622
-
623
- ✓ Indexing...
624
- ✓ Indexed 342 files
625
-
626
- Store is ready for searching!
627
- ```
628
- </details>
629
-
630
- ---
631
-
632
- ### 🔍 `/bluera-knowledge:search`
633
-
634
- **Search across indexed knowledge stores**
635
-
636
- ```bash
637
- /bluera-knowledge:search "<query>" [--stores=<names>] [--limit=<number>] [--min-relevance=<0-1>]
638
- ```
639
-
640
- **Options:**
641
- - `--stores=<names>` - Comma-separated store names to search (default: all stores)
642
- - `--limit=<number>` - Maximum results to return (default: 10)
643
- - `--min-relevance=<0-1>` - Minimum raw cosine similarity; returns empty if no results meet threshold
644
- - `--threshold=<0-1>` - Minimum normalized score to include results
645
- - `--mode=<mode>` - Search mode: `hybrid` (default), `vector`, or `fts`
646
- - `--detail=<level>` - Context detail: `minimal` (default), `contextual`, or `full`
647
-
648
- **Examples:**
649
- ```bash
650
- # Search all stores
651
- /bluera-knowledge:search "how to invalidate queries"
652
-
653
- # Search specific store
654
- /bluera-knowledge:search "useState implementation" --stores=react
655
-
656
- # Search multiple stores (comma-separated)
657
- /bluera-knowledge:search "deep clone" --stores=react,lodash
658
-
659
- # Limit results
660
- /bluera-knowledge:search "testing patterns" --limit=5
661
-
662
- # Filter irrelevant results (returns empty if nothing is truly relevant)
663
- /bluera-knowledge:search "kubernetes deployment" --min-relevance=0.4
664
- ```
665
-
666
- <details>
667
- <summary><b>📊 Expected Output</b></summary>
668
-
669
- ```
670
- ## Search Results: "button component" (hybrid search)
671
-
672
- **1. [Score: 0.95] [Vector+FTS]**
673
- Store: react
674
- File: 📄 src/components/Button.tsx
675
- Purpose: → Reusable button component with variants
676
- Top Terms: 🔑 (in this chunk): button, variant, size, color, onClick
677
- Imports: 📦 (in this chunk): React, clsx
678
-
679
- **2. [Score: 0.87] [Vector]**
680
- Store: react
681
- File: 📄 src/hooks/useButton.ts
682
- Purpose: → Custom hook for button state management
683
- Top Terms: 🔑 (in this chunk): hook, state, pressed, disabled
684
- Imports: 📦 (in this chunk): useState, useCallback
685
-
686
- **3. [Score: 0.81] [Vector+FTS]**
687
- Store: react
688
- File: 📄 src/components/IconButton.tsx
689
- Purpose: → Button component with icon support
690
- Top Terms: 🔑 (in this chunk): icon, button, aria-label, accessible
691
-
692
- ---
693
- **Found 3 results in 45ms**
694
-
695
- 💡 **Next Steps:**
696
- - Read file: `Read src/components/Button.tsx`
697
- - Get full code: `mcp__bluera-knowledge__get_full_context("result-id")`
698
- - Refine search: Use keywords above
699
- ```
700
- </details>
701
-
702
- ---
703
-
704
- ### 📋 `/bluera-knowledge:stores`
705
-
706
- **List all indexed knowledge stores**
707
-
708
- ```bash
709
- /bluera-knowledge:stores
710
- ```
711
-
712
- Shows store name, type, ID, and source location in a clean table format.
713
-
714
- <details>
715
- <summary><b>📊 Expected Output</b></summary>
716
-
717
- ```
718
- | Name | Type | ID | Source |
719
- |------|------|----|--------------------|
720
- | react | repo | 459747c7 | https://github.com/facebook/react |
721
- | crawl4ai | repo | b5a72a94 | https://github.com/unclecode/crawl4ai.git |
722
- | project-docs | file | 70f6309b | ~/repos/my-project/docs |
723
- | claude-docs | web | 9cc62018 | https://code.claude.com/docs |
724
-
725
- **Total**: 4 stores
726
- ```
727
- </details>
728
-
729
- ---
730
-
731
- ### 🔄 `/bluera-knowledge:index`
732
-
733
- **Re-index an existing store to update the search index**
734
-
735
- ```bash
736
- /bluera-knowledge:index <store-name-or-id>
737
- ```
738
-
739
- **🔄 When to re-index:**
740
- - The source repository has been updated (for repo stores)
741
- - Files have been added or modified (for file stores)
742
- - Search results seem out of date
743
-
744
- **Example:**
745
- ```bash
746
- /bluera-knowledge:index react
747
- ```
748
-
749
- <details>
750
- <summary><b>✅ Expected Output</b></summary>
751
-
752
- ```
753
- ✓ Indexing store: react...
754
- ✓ Indexed 1,247 documents in 3,421ms
755
-
756
- Store search index is up to date!
757
- ```
758
- </details>
759
-
760
- ---
761
-
762
- ### 🗑️ `/bluera-knowledge:remove-store`
763
-
764
- **Delete a knowledge store and all associated data**
765
-
766
- ```bash
767
- /bluera-knowledge:remove-store <store-name-or-id>
768
- ```
769
-
770
- **🗑️ What gets deleted:**
771
- - Store registry entry
772
- - LanceDB search index (vector embeddings)
773
- - Cloned repository files (for repo stores created from URLs)
774
-
775
- **Example:**
776
- ```bash
777
- /bluera-knowledge:remove-store react
778
- ```
779
-
780
- <details>
781
- <summary><b>✅ Expected Output</b></summary>
782
-
783
- ```
784
- Store "react" deleted successfully.
785
-
786
- Removed:
787
- - Store registry entry
788
- - LanceDB search index
789
- - Cloned repository files
790
- ```
791
- </details>
792
-
793
- ---
794
-
795
- ### 🌐 `/bluera-knowledge:crawl`
796
-
797
- **Crawl web pages with natural language control**
416
+ /bluera-knowledge:add-folder ./architecture --name=architecture
798
417
 
799
- ```bash
800
- /bluera-knowledge:crawl <url> <store-name> [options]
418
+ # AI agents can search across all documentation or access specific files
801
419
  ```
802
420
 
803
- **Options:**
804
- - `--crawl "<instruction>"` - Natural language instruction for which pages to crawl
805
- - `--extract "<instruction>"` - Natural language instruction for what content to extract
806
- - `--simple` - Use simple BFS mode instead of intelligent crawling
807
- - `--max-pages <n>` - Maximum pages to crawl (default: 50)
808
- - `--fast` - Use fast axios-only mode (may fail on JavaScript-heavy sites)
421
+ ### Coding Standards
809
422
 
810
- **⚙️ Requirements:**
811
- - 🐍 Python 3 with `crawl4ai` package installed
812
- - 📦 Web store is auto-created if it doesn't exist
423
+ Provide definitive coding standards and best practices:
813
424
 
814
- **Examples:**
815
425
  ```bash
816
- # Basic crawl
817
- /bluera-knowledge:crawl https://docs.example.com/guide my-docs
818
-
819
- # Intelligent crawl with custom strategy
820
- /bluera-knowledge:crawl https://react.dev react-docs --crawl "all API reference pages"
821
-
822
- # Extract specific content from pages
823
- /bluera-knowledge:crawl https://example.com/pricing pricing --extract "pricing tiers and features"
824
-
825
- # Combine crawl strategy + extraction
826
- /bluera-knowledge:crawl https://docs.python.org python-docs \
827
- --crawl "standard library modules" \
828
- --extract "function signatures and examples"
829
-
830
- # JavaScript-rendered sites work by default (uses headless browser)
831
- /bluera-knowledge:crawl https://nextjs.org/docs nextjs-docs --max-pages 30
832
-
833
- # Fast mode for static HTML sites (axios-only, faster but may miss JS content)
834
- /bluera-knowledge:crawl https://example.com/static static-docs --fast --max-pages 100
835
-
836
- # Simple BFS mode (no AI guidance)
837
- /bluera-knowledge:crawl https://example.com/docs docs --simple --max-pages 100
838
- ```
839
-
840
- The crawler converts pages to markdown and indexes them for semantic search.
841
-
842
- ---
843
-
844
- ### 🔁 `/bluera-knowledge:sync`
845
-
846
- **Sync stores from definitions config (bootstrap on fresh clone)**
426
+ /bluera-knowledge:add-folder ./company-standards --name=standards
427
+ /bluera-knowledge:add-folder ./api-specs --name=api-docs
847
428
 
848
- ```bash
849
- /bluera-knowledge:sync [options]
429
+ # AI agents reference actual company standards, not generic advice
850
430
  ```
851
431
 
852
- **Options:**
853
- - `--dry-run` - Show what would happen without making changes
854
- - `--prune` - Remove stores not in definitions
855
- - `--reindex` - Re-index existing stores after sync
432
+ ### Mixed Sources
856
433
 
857
- **Use cases:**
858
- - **Fresh clone**: Recreate all stores defined by the team
859
- - **Check status**: See which stores exist vs. defined
860
- - **Clean up**: Remove orphan stores not in config
434
+ Combine canonical library code with project-specific patterns:
861
435
 
862
- **Examples:**
863
436
  ```bash
864
- # Preview what would be synced
865
- /bluera-knowledge:sync --dry-run
866
-
867
- # Sync all stores from definitions
868
- /bluera-knowledge:sync
869
-
870
- # Sync and remove orphan stores
871
- /bluera-knowledge:sync --prune
872
- ```
873
-
874
- **How it works:**
875
- 1. Reads store definitions from `.bluera/bluera-knowledge/stores.config.json`
876
- 2. Creates any stores that don't exist locally
877
- 3. Reports orphan stores (local stores not in definitions)
878
- 4. Optionally prunes orphans with `--prune`
879
-
880
- ---
881
-
882
- ## 🕷️ Crawler Architecture
883
-
884
- The crawler defaults to **headless mode** (Playwright) for maximum compatibility with modern JavaScript-rendered sites. Use `--fast` for static HTML sites when speed is critical.
885
-
886
- ### 🎭 Default Mode (Headless - JavaScript-Rendered Sites)
887
-
888
- By default, the crawler uses Playwright via crawl4ai to render JavaScript content:
889
-
890
- ```mermaid
891
- sequenceDiagram
892
- participant User
893
- participant CLI
894
- participant IntelligentCrawler
895
- participant Axios
896
- participant Claude
897
-
898
- User->>CLI: crawl URL --crawl "instruction"
899
- CLI->>IntelligentCrawler: crawl(url, {useHeadless: true})
900
- IntelligentCrawler->>PythonBridge: fetchHeadless(url)
901
- PythonBridge->>crawl4ai: AsyncWebCrawler.arun(url)
902
- crawl4ai->>Playwright: Launch browser & render JS
903
- Playwright-->>crawl4ai: Rendered HTML
904
- crawl4ai-->>PythonBridge: {html, markdown, links}
905
- PythonBridge-->>IntelligentCrawler: Rendered HTML
906
- IntelligentCrawler->>Claude: determineCrawlUrls(html, instruction)
907
- Note over Claude: Natural language instruction<br/>STILL FULLY ACTIVE
908
- Claude-->>IntelligentCrawler: [urls to crawl]
909
- loop For each URL
910
- IntelligentCrawler->>PythonBridge: fetchHeadless(url)
911
- PythonBridge->>crawl4ai: Render JS
912
- crawl4ai-->>PythonBridge: HTML
913
- PythonBridge-->>IntelligentCrawler: HTML
914
- IntelligentCrawler->>IntelligentCrawler: Convert to markdown & index
915
- end
916
- ```
437
+ /bluera-knowledge:add-repo https://github.com/facebook/react --name=react
438
+ /bluera-knowledge:add-folder ./docs/react-patterns --name=react-patterns
917
439
 
918
- ### Fast Mode (Static Sites - `--fast`)
919
-
920
- For static HTML sites, use `--fast` for faster crawling with axios:
921
-
922
- ```mermaid
923
- sequenceDiagram
924
- participant User
925
- participant CLI
926
- participant IntelligentCrawler
927
- participant Axios
928
- participant Claude
929
-
930
- User->>CLI: crawl URL --crawl "instruction" --fast
931
- CLI->>IntelligentCrawler: crawl(url, {useHeadless: false})
932
- IntelligentCrawler->>Axios: fetchHtml(url)
933
- Axios-->>IntelligentCrawler: Static HTML
934
- IntelligentCrawler->>Claude: determineCrawlUrls(html, instruction)
935
- Claude-->>IntelligentCrawler: [urls to crawl]
936
- loop For each URL
937
- IntelligentCrawler->>Axios: fetchHtml(url)
938
- Axios-->>IntelligentCrawler: HTML
939
- IntelligentCrawler->>IntelligentCrawler: Convert to markdown & index
940
- end
440
+ # Search across both dependency source and team patterns
941
441
  ```
942
442
 
943
- ### 🔑 Key Points
944
-
945
- - **🎭 Default to headless** - Maximum compatibility with modern JavaScript-rendered sites (React, Vue, Next.js)
946
- - **⚡ Fast mode available** - Use `--fast` for static HTML sites when speed is critical
947
- - **🧠 Intelligent crawling preserved** - Claude Code CLI analyzes pages and selects URLs in both modes
948
- - **🔄 Automatic fallback** - If headless fetch fails, automatically falls back to axios
949
-
950
- ### 🤖 Intelligent Mode vs Simple Mode
951
-
952
- The crawler operates in two modes depending on Claude Code CLI availability:
953
-
954
- | Mode | Requires Claude CLI | Behavior |
955
- |------|---------------------|----------|
956
- | **Intelligent** | ✅ Yes | Claude analyzes pages and selects URLs based on natural language instructions |
957
- | **Simple (BFS)** | ❌ No | Breadth-first crawl up to max depth (2 levels) |
958
-
959
- **Automatic detection:**
960
- - When Claude Code CLI is available: Full intelligent mode with `--crawl` and `--extract` instructions
961
- - When Claude Code CLI is unavailable: Automatically uses simple BFS mode
962
- - Clear messaging: "Claude CLI not found, using simple crawl mode"
963
-
964
- > [!NOTE]
965
- > Install Claude Code to unlock `--crawl` (AI-guided URL selection) and `--extract` (AI content extraction). Without it, web crawling still works but uses simple BFS mode.
966
-
967
443
  ---
968
444
 
969
445
  ## 🔧 Troubleshooting
@@ -986,6 +462,18 @@ If the plugin isn't listed, install it:
986
462
  ```
987
463
  </details>
988
464
 
465
+ <details>
466
+ <summary><b>🔌 MCP server shows as "failed" in /plugin</b></summary>
467
+
468
+ If the MCP server shows as failed after installation:
469
+
470
+ 1. **Restart Claude Code** - MCP servers require a restart to initialize
471
+ 2. **Check status:** Run `/mcp` to see connection status
472
+ 3. **Reinstall:** Try `/plugin uninstall bluera-knowledge` then `/plugin install bluera-knowledge@bluera`
473
+
474
+ If the issue persists, check that Claude Code is v2.0.65 or later (earlier versions had MCP loading bugs).
475
+ </details>
476
+
989
477
  <details>
990
478
  <summary><b>🌐 Web crawling fails</b></summary>
991
479
 
@@ -1045,121 +533,6 @@ Simple mode still crawls effectively—it just doesn't use AI to select which pa
1045
533
 
1046
534
  ---
1047
535
 
1048
- ## 🎯 Use Cases
1049
-
1050
- ### 📦 Dependency Source Code
1051
-
1052
- Provide AI agents with canonical dependency implementation details:
1053
-
1054
- ```bash
1055
- /bluera-knowledge:suggest
1056
- /bluera-knowledge:add-repo https://github.com/expressjs/express
1057
-
1058
- # AI agents can now:
1059
- # - Semantic search: "middleware error handling"
1060
- # - Direct access: Grep/Glob through the cloned express repo
1061
- ```
1062
-
1063
- ### 📚 Project Documentation
1064
-
1065
- Make project-specific documentation available:
1066
-
1067
- ```bash
1068
- /bluera-knowledge:add-folder ./docs --name=project-docs
1069
- /bluera-knowledge:add-folder ./architecture --name=architecture
1070
-
1071
- # AI agents can search across all documentation or access specific files
1072
- ```
1073
-
1074
- ### 📏 Coding Standards
1075
-
1076
- Provide definitive coding standards and best practices:
1077
-
1078
- ```bash
1079
- /bluera-knowledge:add-folder ./company-standards --name=standards
1080
- /bluera-knowledge:add-folder ./api-specs --name=api-docs
1081
-
1082
- # AI agents reference actual company standards, not generic advice
1083
- ```
1084
-
1085
- ### 🔀 Mixed Sources
1086
-
1087
- Combine canonical library code with project-specific patterns:
1088
-
1089
- ```bash
1090
- /bluera-knowledge:add-repo https://github.com/facebook/react --name=react
1091
- /bluera-knowledge:add-folder ./docs/react-patterns --name=react-patterns
1092
-
1093
- # Search across both dependency source and team patterns
1094
- ```
1095
-
1096
- ---
1097
-
1098
- ## 💭 What Claude Code Says About Bluera Knowledge
1099
-
1100
- > ### *As an AI coding assistant, here's what I've discovered using this plugin*
1101
- >
1102
- > ---
1103
- >
1104
- > #### ⚡ The Immediate Impact
1105
- >
1106
- > **The difference is immediate.** When a user asks "how does React's useEffect cleanup work?", I can search the actual React source code indexed locally instead of relying on my training data or making web requests. The results include the real implementation, related functions, and usage patterns—all in ~100ms.
1107
- >
1108
- > **Code graph analysis changes the game.** The plugin doesn't just index files—it builds a relationship graph showing which functions call what, import dependencies, and class hierarchies. When I search for a function, I see how many places call it and what it calls. This context makes my suggestions dramatically more accurate.
1109
- >
1110
- > ---
1111
- >
1112
- > #### 🔀 Multi-Modal Search Power
1113
- >
1114
- > I can combine three search approaches in a single workflow:
1115
- >
1116
- > | Mode | Use Case | Example |
1117
- > |------|----------|---------|
1118
- > | 🧠 **Semantic** | Conceptual queries | "authentication flow with JWT validation" |
1119
- > | 📂 **Direct Access** | Pattern matching | Grep for specific identifiers in cloned repos |
1120
- > | 📝 **Full-Text** | Exact matches | Find precise function names or imports |
1121
- >
1122
- > This flexibility means I can start broad (semantic) and narrow down (exact file access) seamlessly.
1123
- >
1124
- > ---
1125
- >
1126
- > #### 🕷️ Intelligent Crawling
1127
- >
1128
- > **The `--crawl` instruction isn't marketing**—it actually uses Claude Code CLI to analyze each page and intelligently select which links to follow. I can tell it "crawl all API reference pages but skip blog posts" and it understands the intent.
1129
- >
1130
- > For JavaScript-rendered sites (Next.js, React docs), the default headless mode renders pages with Playwright while I still control the crawl strategy with natural language. Use `--fast` when you need speed on static sites.
1131
- >
1132
- > ---
1133
- >
1134
- > #### ✨ What Makes It Valuable
1135
- >
1136
- > | Benefit | Impact |
1137
- > |---------|--------|
1138
- > | ✅ **No guessing** | I read actual source code, not blog interpretations |
1139
- > | 🔌 **Offline first** | Works without internet, zero rate limits |
1140
- > | 🎯 **Project-specific** | Index your team's standards, not generic advice |
1141
- > | ⚡ **Speed** | Sub-100ms searches vs 2-5 second web lookups |
1142
- > | 📚 **Completeness** | Tests, implementation details, edge cases—all indexed |
1143
- >
1144
- > ---
1145
- >
1146
- > #### 🌟 When It Shines Most
1147
- >
1148
- > 1. **Deep library questions** - "how does this internal method handle edge cases?"
1149
- > 2. **Version-specific answers** - your indexed version is what you're actually using
1150
- > 3. **Private codebases** - your docs, your standards, your patterns
1151
- > 4. **Complex workflows** - combining semantic search + direct file access + code graph
1152
- >
1153
- > ---
1154
- >
1155
- > The plugin essentially gives me a **photographic memory** of your dependencies and documentation.
1156
- >
1157
- > Instead of *"I think based on training data"*, I can say *"I searched the indexed React v18.2.0 source and found this in `ReactFiberWorkLoop.js:1247`"*.
1158
- >
1159
- > **That's the difference between helpful and authoritative.**
1160
-
1161
- ---
1162
-
1163
536
  ## 🔧 Dependencies
1164
537
 
1165
538
  The plugin automatically checks for and attempts to install Python dependencies on first use:
@@ -1180,261 +553,22 @@ pip install crawl4ai
1180
553
  playwright install chromium
1181
554
  ```
1182
555
 
1183
- > [!NOTE]
1184
- > 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
-
1186
- **Update Plugin:**
1187
- ```bash
1188
- /plugin update bluera-knowledge
1189
- ```
1190
-
1191
- ---
1192
-
1193
- ## 🔌 MCP Integration
1194
-
1195
- The plugin includes a Model Context Protocol server that exposes search tools. This is configured inline in `.claude-plugin/plugin.json`:
1196
-
1197
- > [!IMPORTANT]
1198
- > **Commands vs MCP Tools**: You interact with the plugin using `/bluera-knowledge:` slash commands. Behind the scenes, these commands instruct Claude Code to use MCP tools (`mcp__bluera-knowledge__*`) which handle the actual operations. Commands provide the user interface, while MCP tools are the backend that AI agents use to access your knowledge stores.
1199
-
1200
- ```json
1201
- {
1202
- "mcpServers": {
1203
- "bluera-knowledge": {
1204
- "command": "node",
1205
- "args": ["${CLAUDE_PLUGIN_ROOT}/dist/mcp/server.js"],
1206
- "env": {
1207
- "PROJECT_ROOT": "${PWD}",
1208
- "DATA_DIR": ".bluera/bluera-knowledge/data",
1209
- "CONFIG_PATH": ".bluera/bluera-knowledge/config.json"
1210
- }
1211
- }
1212
- }
1213
- }
1214
- ```
1215
-
1216
- ### 🎯 Context Efficiency Strategy
1217
-
1218
- **Why only 3 MCP tools?**
1219
-
1220
- Every MCP tool exposed requires its full schema to be sent to Claude with each tool invocation. More tools = more tokens consumed before Claude can even respond.
1221
-
1222
- **Design decision:** Consolidate from 10+ tools down to 3:
1223
-
1224
- | Approach | Tool Count | Context Cost | Trade-off |
1225
- |----------|------------|--------------|-----------|
1226
- | Individual tools | 10+ | ~800+ tokens | Simple calls, high overhead |
1227
- | **Consolidated (current)** | 3 | ~300 tokens | Minimal overhead, slightly longer commands |
1228
-
1229
- **How it works:**
1230
-
1231
- 1. **Native tools for common workflow** - `search` and `get_full_context` are the operations Claude uses most often, so they get dedicated tools with full schemas
1232
-
1233
- 2. **Meta-tool for management** - The `execute` tool consolidates 8 store/job management commands into a single tool. Commands are discovered on-demand via `execute("commands")` or `execute("help", {command: "store:create"})`
1234
-
1235
- 3. **Lazy documentation** - Command help isn't pre-sent with tool listings; it's discoverable when needed
1236
-
1237
- **Result:** ~60% reduction in context overhead for MCP tool listings, without sacrificing functionality.
1238
-
1239
- > [!TIP]
1240
- > This pattern—consolidating infrequent operations into a meta-tool while keeping high-frequency operations native—is a general strategy for MCP context efficiency.
1241
-
1242
- ### 🛠️ Available MCP Tools
1243
-
1244
- The plugin exposes 3 MCP tools optimized for minimal context overhead:
1245
-
1246
- #### `search`
1247
- 🔍 Semantic vector search across all indexed stores or a specific subset. Returns structured code units with relevance ranking.
1248
-
1249
- **Parameters:**
1250
- - `query` - Search query (natural language, patterns, or type signatures)
1251
- - `intent` - Search intent: find-pattern, find-implementation, find-usage, find-definition, find-documentation
1252
- - `mode` - Search mode: hybrid (default), vector, or fts
1253
- - `detail` - Context level: minimal, contextual, or full
1254
- - `limit` - Maximum results (default: 10)
1255
- - `stores` - Array of specific store IDs to search (optional, searches all stores if not specified)
1256
- - `threshold` - Minimum normalized score (0-1) for filtering results
1257
- - `minRelevance` - Minimum raw cosine similarity (0-1) for filtering results
1258
-
1259
- #### `get_full_context`
1260
- 📖 Retrieve complete code and context for a specific search result by ID.
1261
-
1262
- **Parameters:**
1263
- - `resultId` - The result ID from a previous search
1264
-
1265
- #### `execute`
1266
- ⚡ Meta-tool for store and job management. Consolidates 8 operations into one tool with subcommands.
1267
-
1268
- **Parameters:**
1269
- - `command` - Command to execute (see below)
1270
- - `args` - Command-specific arguments (optional)
1271
-
1272
- **Available commands:**
1273
- | Command | Args | Description |
1274
- |---------|------|-------------|
1275
- | `stores` | `type?` | List all knowledge stores |
1276
- | `store:info` | `store` | Get detailed store information including file path |
1277
- | `store:create` | `name`, `type`, `source`, `branch?`, `description?` | Create a new store |
1278
- | `store:index` | `store` | Re-index an existing store |
1279
- | `store:delete` | `store` | Delete a store and all data |
1280
- | `stores:sync` | `dryRun?`, `prune?`, `reindex?` | Sync stores from definitions config |
1281
- | `jobs` | `activeOnly?`, `status?` | List background jobs |
1282
- | `job:status` | `jobId` | Check specific job status |
1283
- | `job:cancel` | `jobId` | Cancel a running job |
1284
- | `help` | `command?` | Show help for commands |
1285
- | `commands` | - | List all available commands |
1286
-
1287
- ---
1288
-
1289
- ## 🖥️ CLI Tool
1290
-
1291
- While Bluera Knowledge works seamlessly as a Claude Code plugin, it's also available as a standalone CLI tool for use outside Claude Code.
1292
-
1293
- > [!NOTE]
1294
- > When using CLI without Claude Code installed, web crawling uses simple BFS mode. Install Claude Code to unlock `--crawl` (AI-guided URL selection) and `--extract` (AI content extraction) instructions.
1295
-
1296
- ### Installation
1297
-
1298
- Install globally via npm:
1299
-
1300
- ```bash
1301
- npm install -g bluera-knowledge
1302
- ```
1303
-
1304
- Or use in a project:
1305
-
1306
- ```bash
1307
- npm install --save-dev bluera-knowledge
1308
- ```
1309
-
1310
- ### Usage
1311
-
1312
- #### Create a Store
1313
-
1314
- ```bash
1315
- # Add a Git repository
1316
- bluera-knowledge store create react --type repo --source https://github.com/facebook/react
1317
-
1318
- # Add a Git repository with specific branch
1319
- bluera-knowledge store create react-canary --type repo --source https://github.com/facebook/react --branch canary
1320
-
1321
- # Add a local folder
1322
- bluera-knowledge store create my-docs --type file --source ./docs
1323
-
1324
- # Add a web crawl
1325
- bluera-knowledge store create fastapi-docs --type web --source https://fastapi.tiangolo.com
1326
- ```
1327
-
1328
- **Create Options:**
1329
- - `-t, --type <type>` - Store type: `file`, `repo`, or `web` (required)
1330
- - `-s, --source <path>` - Local path or URL (required)
1331
- - `-b, --branch <branch>` - Git branch to clone (repo stores only)
1332
- - `-d, --description <desc>` - Optional store description
1333
- - `--tags <tags>` - Comma-separated tags for filtering
1334
-
1335
- #### Index a Store
1336
-
1337
- ```bash
1338
- # Re-index a store (only changed files)
1339
- bluera-knowledge index react
1340
-
1341
- # Force re-index all files (ignores cache)
1342
- bluera-knowledge index react --force
1343
-
1344
- # Watch for changes and auto-reindex
1345
- bluera-knowledge index watch react
1346
- bluera-knowledge index watch react --debounce 2000 # Custom debounce (default: 1000ms)
1347
- ```
1348
-
1349
- **Index Options:**
1350
- - `-f, --force` - Re-index all files (ignore incremental cache)
1351
-
1352
- **Watch Options:**
1353
- - `--debounce <ms>` - Debounce delay for file changes (default: 1000ms)
1354
-
1355
- #### Search
1356
-
1357
- ```bash
1358
- # Search across all stores
1359
- bluera-knowledge search "how does useEffect work"
1360
-
1361
- # Search specific stores
1362
- bluera-knowledge search "routing" --stores react,vue
1363
-
1364
- # Get more results with full content
1365
- bluera-knowledge search "middleware" --limit 20 --include-content
1366
-
1367
- # Filter irrelevant results (returns empty if nothing is truly relevant)
1368
- bluera-knowledge search "kubernetes deployment" --min-relevance 0.4
1369
-
1370
- # Get JSON output with confidence and raw scores
1371
- bluera-knowledge search "express middleware" --format json
1372
- ```
1373
-
1374
- **Search Options:**
1375
- - `-s, --stores <stores>` - Comma-separated store names/IDs
1376
- - `-m, --mode <mode>` - `hybrid` (default), `vector`, or `fts`
1377
- - `-n, --limit <count>` - Max results (default: 10)
1378
- - `-t, --threshold <score>` - Min normalized score (0-1)
1379
- - `--min-relevance <score>` - Min raw cosine similarity (0-1)
1380
- - `--include-content` - Show full content in results
1381
- - `--detail <level>` - `minimal`, `contextual`, or `full`
1382
-
1383
- #### List Stores
1384
-
1385
- ```bash
1386
- bluera-knowledge store list
1387
- bluera-knowledge store list --type repo # Filter by type
1388
- ```
556
+ **Disable auto-install (security-conscious environments):**
1389
557
 
1390
- #### Store Info
558
+ Set the `BK_SKIP_AUTO_INSTALL` environment variable to disable automatic pip package installation:
1391
559
 
1392
560
  ```bash
1393
- bluera-knowledge store info react
561
+ export BK_SKIP_AUTO_INSTALL=1
1394
562
  ```
1395
563
 
1396
- #### Delete a Store
1397
-
1398
- ```bash
1399
- # Interactive deletion (prompts for confirmation in TTY mode)
1400
- bluera-knowledge store delete old-store
1401
-
1402
- # Force delete without confirmation
1403
- bluera-knowledge store delete old-store --force
1404
- bluera-knowledge store delete old-store -y
1405
- ```
1406
-
1407
- **Delete Options:**
1408
- - `-f, --force` - Delete without confirmation prompt
1409
- - `-y, --yes` - Alias for `--force`
1410
-
1411
- ### Global Options
564
+ > [!NOTE]
565
+ > 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.
1412
566
 
567
+ **Update Plugin:**
1413
568
  ```bash
1414
- --config <path> # Custom config file
1415
- --data-dir <path> # Custom data directory
1416
- --project-root <path> # Project root for store definitions (required for sync)
1417
- --format <format> # Output format: json | table | plain
1418
- --quiet # Suppress non-essential output
1419
- --verbose # Enable verbose logging
569
+ /plugin update bluera-knowledge
1420
570
  ```
1421
571
 
1422
- ### When to Use CLI vs Plugin
1423
-
1424
- **Use CLI when:**
1425
- - Using an editor other than Claude Code (VSCode, Cursor, etc.)
1426
- - Integrating into CI/CD pipelines
1427
- - Scripting or automation
1428
- - Pre-indexing dependencies for teams
1429
-
1430
- **Use Plugin when:**
1431
- - Working within Claude Code
1432
- - Want slash commands (`/bluera-knowledge:search`)
1433
- - Need Claude to automatically query your knowledge base
1434
- - Want Skills to guide optimal usage
1435
-
1436
- Both interfaces use the same underlying services, so you can switch between them seamlessly.
1437
-
1438
572
  ---
1439
573
 
1440
574
  ## 🎓 Skills for Claude Code
@@ -1560,257 +694,6 @@ This ensures:
1560
694
 
1561
695
  ---
1562
696
 
1563
- ## 🛠️ Development
1564
-
1565
- ### 🚀 Setup
1566
-
1567
- ```bash
1568
- git clone https://github.com/blueraai/bluera-knowledge.git
1569
- cd bluera-knowledge
1570
- bun install
1571
- bun run build
1572
- bun test
1573
- ```
1574
-
1575
- > **Note:** This project uses [Bun](https://bun.sh) for development. Install it via `curl -fsSL https://bun.sh/install | bash`
1576
-
1577
- ### ⚙️ Claude Code Settings (Recommended)
1578
-
1579
- For the best development experience with Claude Code, copy the example settings file:
1580
-
1581
- ```bash
1582
- cp .claude/settings.local.json.example .claude/settings.local.json
1583
- ```
1584
-
1585
- **This provides:**
1586
- - ✅ **Smart validation** - Automatically runs lint/typecheck after editing code (file-type aware)
1587
- - ✅ **No permission prompts** - Pre-approves common commands (lint, typecheck, precommit)
1588
- - ✅ **Desktop notifications** - macOS notifications when Claude needs your input
1589
- - ✅ **Plugin auto-enabled** - Automatically enables the bluera-knowledge plugin
1590
- - ✅ **Faster workflow** - Catch issues immediately without manual validation
1591
-
1592
- The validation is intelligent - it only runs checks for TypeScript/JavaScript files, skipping docs/config to save time.
1593
-
1594
- > **Note:** The `.claude/settings.local.json` file is gitignored (local to your machine). The example file is checked in for reference.
1595
-
1596
- ### 🐕 Dogfooding
1597
-
1598
- Develop this plugin while using it with Claude Code:
1599
-
1600
- ```bash
1601
- claude --plugin-dir /path/to/bluera-knowledge
1602
- ```
1603
-
1604
- This loads the plugin directly from source. Changes take effect on Claude Code restart (no reinstall needed).
1605
-
1606
- | What to test | Approach |
1607
- |--------------|----------|
1608
- | **Commands** (`/search`, `/add-repo`) | `--plugin-dir` (changes need restart) |
1609
- | **Hooks** (job status, dependencies) | `--plugin-dir` (changes need restart) |
1610
- | **MCP tools** (compiled) | `--plugin-dir` (run `bun run build` first) |
1611
- | **MCP tools** (live TypeScript) | `~/.claude.json` dev server (see below) |
1612
-
1613
- ### 🔌 MCP Server Development
1614
-
1615
- **Production mode** (`mcp.plugin.json`):
1616
- - Uses `${CLAUDE_PLUGIN_ROOT}/dist/mcp/server.js` (compiled)
1617
- - Distributed with plugin, no extra setup needed
1618
-
1619
- **Development mode** (live TypeScript):
1620
-
1621
- For instant feedback when editing MCP server code, add a dev server to `~/.claude.json`:
1622
-
1623
- ```json
1624
- {
1625
- "mcpServers": {
1626
- "bluera-knowledge-dev": {
1627
- "command": "npx",
1628
- "args": ["tsx", "/path/to/bluera-knowledge/src/mcp/server.ts"],
1629
- "env": {
1630
- "PWD": "${PWD}",
1631
- "DATA_DIR": "${PWD}/.bluera/bluera-knowledge/data",
1632
- "CONFIG_PATH": "${PWD}/.bluera/bluera-knowledge/config.json"
1633
- }
1634
- }
1635
- }
1636
- }
1637
- ```
1638
-
1639
- This creates a separate `bluera-knowledge-dev` MCP server that runs source TypeScript directly via `tsx` - no rebuild needed for MCP changes
1640
-
1641
- ### 📜 Commands
1642
-
1643
- | Command | Description | When to Use |
1644
- |---------|-------------|-------------|
1645
- | `bun run build` | 🏗️ Compile TypeScript to dist/ | Before testing CLI, after code changes |
1646
- | `bun run dev` | 👀 Watch mode compilation | During active development |
1647
- | `bun start` | ▶️ Run the CLI | Execute CLI commands directly |
1648
- | `bun test` | 🧪 Run tests in watch mode | During TDD/active development |
1649
- | `bun run test:run` | ✅ Run tests once | Quick verification |
1650
- | `bun run test:coverage` | 📊 Run tests with coverage | Before committing, CI checks |
1651
- | `bun run lint` | 🔍 Run ESLint (quiet by default) | Check code style issues |
1652
- | `bun run typecheck` | 🔒 Run TypeScript type checking (quiet by default) | Verify type safety |
1653
- | `bun run precommit` | ✨ Smart validation (file-type aware) | Runs only relevant checks based on changed files |
1654
- | `bun run prepush` | 📊 Smart coverage (skips for docs/config) | Runs coverage only when src/tests changed |
1655
- | `bun run lint:verbose` | 📢 ESLint (full output) | Debugging lint issues |
1656
- | `bun run typecheck:verbose` | 📢 Type check (full output) | Debugging type errors |
1657
- | `bun run test:changed:verbose` | 📢 Test changed files (full output) | Debugging test failures |
1658
- | `bun run test:coverage:verbose` | 📢 Coverage (full output) | Reviewing detailed coverage |
1659
- | `bun run build:verbose` | 📢 Build (full output) | Debugging build issues |
1660
- | `bun run gh:status` | 📋 List recent GitHub Actions runs | Monitor CI/CD status |
1661
- | `bun run gh:watch` | 👁️ Watch latest workflow (quiet, shows result + failures) | Wait for CI completion |
1662
- | `bun run gh:watch:verbose` | 📢 Watch with live status updates | Debugging CI issues |
1663
- | `bun run gh:releases` | 🏷️ List recent GitHub releases | Check release history |
1664
-
1665
- ### 🔄 Automatic Build & Dist Commit
1666
-
1667
- The `dist/` directory **must be committed** because Claude Code plugins are installed by copying files—there's no build step during installation.
1668
-
1669
- **Good news: This is fully automatic!**
1670
-
1671
- 1. **On every commit**, the pre-commit hook intelligently validates based on file types
1672
- 2. **If source/config changed**, it runs build and automatically stages `dist/` via `git add dist/`
1673
- 3. **You never need to manually build or stage dist** — just commit your source changes
1674
-
1675
- **For live rebuilding during development:**
1676
-
1677
- ```bash
1678
- bun run dev # Watches for changes and rebuilds instantly
1679
- ```
1680
-
1681
- This is useful when testing CLI commands locally, but not required for committing — the hook handles everything.
1682
-
1683
- | `bun run version:patch` | 🔢 Run quality checks, then bump patch version (0.0.x) | Bug fixes, minor updates |
1684
- | `bun run version:minor` | 🔢 Run quality checks, then bump minor version (0.x.0) | New features, backwards compatible |
1685
- | `bun run version:major` | 🔢 Run quality checks, then bump major version (x.0.0) | Breaking changes |
1686
-
1687
- ### 🚀 Releasing
1688
-
1689
- ```bash
1690
- # Bump version, commit, tag, and push (triggers GitHub Actions release)
1691
- bun run release:patch # Bug fixes (0.0.x)
1692
- bun run release:minor # New features (0.x.0)
1693
- bun run release:major # Breaking changes (x.0.0)
1694
- ```
1695
-
1696
- **Workflow (Fully Automated):**
1697
-
1698
- 1. Make changes and commit
1699
- 2. Bump version: `bun run version:patch` (runs quality checks first, then updates package.json, plugin.json, README, CHANGELOG)
1700
- 3. Commit version bump: `git commit -am "chore: bump version to X.Y.Z"`
1701
- 4. Push to main: `git push`
1702
- 5. **GitHub Actions automatically:**
1703
- - ✅ Runs CI (lint, typecheck, tests, build)
1704
- - ✅ Creates release tag when CI passes
1705
- - ✅ Creates GitHub release
1706
- - ✅ Updates marketplace
1707
-
1708
- Note: The version command runs full quality checks (format, lint, deadcode, typecheck, coverage, build) BEFORE bumping to catch issues early.
1709
-
1710
- > 💡 **That's it!** No manual tagging needed. Just push to `main` and the release happens automatically when CI passes.
1711
-
1712
- ### 🔍 Post-Release Validation
1713
-
1714
- After a release, validate the npm package works correctly:
1715
-
1716
- ```bash
1717
- bun run validate:npm
1718
- ```
1719
-
1720
- This script:
1721
- - Installs the latest `bluera-knowledge` from npm globally
1722
- - Exercises all CLI commands (stores, add-folder, search, index, delete)
1723
- - Writes detailed logs to `logs/validation/npm-validation-*.log`
1724
- - Returns exit code 0 on success, 1 on failure
1725
-
1726
- Use this to catch any packaging or runtime issues after npm publish.
1727
-
1728
- ### 🧪 Plugin Self-Test
1729
-
1730
- Test all plugin functionality from within Claude Code:
1731
-
1732
- ```
1733
- /test-plugin
1734
- ```
1735
-
1736
- This command runs 13 tests covering:
1737
- - **MCP Tools**: execute (help, stores, create, info, index), search, get_full_context
1738
- - **Slash Commands**: /stores, /search, /suggest
1739
- - **Cleanup**: Store deletion, artifact removal, verification
1740
-
1741
- The test creates temporary content, exercises all features, and cleans up automatically. Use this to verify the plugin is working correctly after installation or updates.
1742
-
1743
- ### 🧪 Testing Locally
1744
-
1745
- **Option 1: Development MCP Server (Recommended)**
1746
-
1747
- Use the local development MCP server (see "MCP Server" section above) which runs your source code directly via `tsx`:
1748
-
1749
- 1. Set up dev MCP server in `~/.claude.json` (see MCP Server section)
1750
- 2. Test your changes - MCP server updates automatically as you edit code
1751
-
1752
- **Option 2: Test Plugin from Working Directory**
1753
-
1754
- Load the plugin directly from your development directory:
1755
-
1756
- ```bash
1757
- cd /path/to/bluera-knowledge
1758
- claude --plugin-dir .
1759
- ```
1760
-
1761
- The MCP config in `plugin.json` is only loaded when the directory is loaded as a plugin (via `--plugin-dir` or marketplace install), so there's no conflict with project-level MCP config.
1762
-
1763
- **Option 3: CLI Tool Testing**
1764
-
1765
- ```bash
1766
- # Build and link
1767
- cd /path/to/bluera-knowledge
1768
- bun run build
1769
- bun link
1770
-
1771
- # Now 'bluera-knowledge' command is available globally
1772
- cd ~/your-project
1773
- bluera-knowledge search "test query" my-store
1774
- ```
1775
-
1776
- **For testing as an installed plugin:**
1777
- This requires publishing a new version to the marketplace.
1778
-
1779
- ### 📂 Project Structure
1780
-
1781
- ```
1782
- .claude-plugin/
1783
- └── plugin.json # Plugin metadata (references mcp.plugin.json)
1784
-
1785
- mcp.plugin.json # MCP server configuration (plugin-scoped)
1786
- commands/ # Slash commands (auto-discovered)
1787
- skills/ # Agent Skills (auto-discovered)
1788
- ├── knowledge-search/ # How to access dependency sources
1789
- │ └── SKILL.md
1790
- ├── when-to-query/ # When to query BK vs project files
1791
- │ └── SKILL.md
1792
- ├── advanced-workflows/ # Multi-tool orchestration patterns
1793
- │ └── SKILL.md
1794
- ├── search-optimization/ # Search parameter optimization
1795
- │ └── SKILL.md
1796
- └── store-lifecycle/ # Store management best practices
1797
- └── SKILL.md
1798
- dist/ # Built MCP server (committed for distribution)
1799
-
1800
- src/
1801
- ├── analysis/ # Dependency analysis & URL resolution
1802
- ├── crawl/ # Web crawling with Python bridge
1803
- ├── services/ # Index, store, and search services
1804
- ├── mcp/ # MCP server source
1805
- └── cli/ # CLI entry point
1806
-
1807
- tests/
1808
- ├── integration/ # Integration tests
1809
- └── fixtures/ # Test infrastructure
1810
- ```
1811
-
1812
- ---
1813
-
1814
697
  ## 🔬 Technologies
1815
698
 
1816
699
  - **🔌 Claude Code Plugin System** with MCP server
@@ -1824,14 +707,22 @@ tests/
1824
707
 
1825
708
  ---
1826
709
 
1827
- ## 🤝 Contributing
710
+ ## 📚 Documentation
711
+
712
+ | Document | Description |
713
+ |----------|-------------|
714
+ | [CLI Reference](docs/cli.md) | Complete CLI commands, options, and usage examples |
715
+ | [MCP Integration](docs/mcp-integration.md) | MCP server configuration and tool documentation |
716
+ | [Commands Reference](docs/commands.md) | All slash commands with parameters and examples |
717
+ | [Crawler Architecture](docs/crawler-architecture.md) | How the intelligent web crawler works |
718
+ | [Token Efficiency](docs/token-efficiency.md) | How BK reduces token consumption vs web search |
719
+ | [CONTRIBUTING](CONTRIBUTING.md) | Development setup, testing, and release process |
1828
720
 
1829
- Contributions welcome! Please:
721
+ ---
722
+
723
+ ## 🤝 Contributing
1830
724
 
1831
- 1. 🍴 Fork the repository
1832
- 2. 🌿 Create a feature branch
1833
- 3. ✅ Add tests
1834
- 4. 📬 Submit a pull request
725
+ Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, testing, and release process.
1835
726
 
1836
727
  ---
1837
728