ruvector 0.1.65 → 0.1.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ruvector/intelligence.json +125 -0
- package/README.md +169 -20
- package/bin/cli.js +443 -0
- package/bin/mcp-server.js +337 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +8 -1
- package/dist/core/learning-engine.d.ts +160 -0
- package/dist/core/learning-engine.d.ts.map +1 -0
- package/dist/core/learning-engine.js +589 -0
- package/dist/core/tensor-compress.d.ts +134 -0
- package/dist/core/tensor-compress.d.ts.map +1 -0
- package/dist/core/tensor-compress.js +432 -0
- package/package.json +1 -1
- package/ruvector.db +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
{
|
|
2
|
+
"learning": {
|
|
3
|
+
"qTables": {
|
|
4
|
+
"typescript": {
|
|
5
|
+
"coder": 0.1
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
"qTables2": {
|
|
9
|
+
"typescript": {}
|
|
10
|
+
},
|
|
11
|
+
"criticValues": {},
|
|
12
|
+
"trajectories": [],
|
|
13
|
+
"stats": {
|
|
14
|
+
"q-learning": {
|
|
15
|
+
"algorithm": "q-learning",
|
|
16
|
+
"updates": 0,
|
|
17
|
+
"avgReward": 0,
|
|
18
|
+
"convergenceScore": 0,
|
|
19
|
+
"lastUpdate": 1767193933062
|
|
20
|
+
},
|
|
21
|
+
"sarsa": {
|
|
22
|
+
"algorithm": "sarsa",
|
|
23
|
+
"updates": 0,
|
|
24
|
+
"avgReward": 0,
|
|
25
|
+
"convergenceScore": 0,
|
|
26
|
+
"lastUpdate": 1767193933062
|
|
27
|
+
},
|
|
28
|
+
"double-q": {
|
|
29
|
+
"algorithm": "double-q",
|
|
30
|
+
"updates": 1,
|
|
31
|
+
"avgReward": 1,
|
|
32
|
+
"convergenceScore": 0.5,
|
|
33
|
+
"lastUpdate": 1767193942801
|
|
34
|
+
},
|
|
35
|
+
"actor-critic": {
|
|
36
|
+
"algorithm": "actor-critic",
|
|
37
|
+
"updates": 0,
|
|
38
|
+
"avgReward": 0,
|
|
39
|
+
"convergenceScore": 0,
|
|
40
|
+
"lastUpdate": 1767193933062
|
|
41
|
+
},
|
|
42
|
+
"ppo": {
|
|
43
|
+
"algorithm": "ppo",
|
|
44
|
+
"updates": 0,
|
|
45
|
+
"avgReward": 0,
|
|
46
|
+
"convergenceScore": 0,
|
|
47
|
+
"lastUpdate": 1767193933062
|
|
48
|
+
},
|
|
49
|
+
"decision-transformer": {
|
|
50
|
+
"algorithm": "decision-transformer",
|
|
51
|
+
"updates": 0,
|
|
52
|
+
"avgReward": 0,
|
|
53
|
+
"convergenceScore": 0,
|
|
54
|
+
"lastUpdate": 1767193933062
|
|
55
|
+
},
|
|
56
|
+
"monte-carlo": {
|
|
57
|
+
"algorithm": "monte-carlo",
|
|
58
|
+
"updates": 0,
|
|
59
|
+
"avgReward": 0,
|
|
60
|
+
"convergenceScore": 0,
|
|
61
|
+
"lastUpdate": 1767193933062
|
|
62
|
+
},
|
|
63
|
+
"td-lambda": {
|
|
64
|
+
"algorithm": "td-lambda",
|
|
65
|
+
"updates": 0,
|
|
66
|
+
"avgReward": 0,
|
|
67
|
+
"convergenceScore": 0,
|
|
68
|
+
"lastUpdate": 1767193933062
|
|
69
|
+
},
|
|
70
|
+
"dqn": {
|
|
71
|
+
"algorithm": "dqn",
|
|
72
|
+
"updates": 0,
|
|
73
|
+
"avgReward": 0,
|
|
74
|
+
"convergenceScore": 0,
|
|
75
|
+
"lastUpdate": 1767193933062
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"configs": {
|
|
79
|
+
"agent-routing": {
|
|
80
|
+
"algorithm": "double-q",
|
|
81
|
+
"learningRate": 0.1,
|
|
82
|
+
"discountFactor": 0.95,
|
|
83
|
+
"epsilon": 0.1
|
|
84
|
+
},
|
|
85
|
+
"error-avoidance": {
|
|
86
|
+
"algorithm": "sarsa",
|
|
87
|
+
"learningRate": 0.05,
|
|
88
|
+
"discountFactor": 0.99,
|
|
89
|
+
"epsilon": 0.05
|
|
90
|
+
},
|
|
91
|
+
"confidence-scoring": {
|
|
92
|
+
"algorithm": "actor-critic",
|
|
93
|
+
"learningRate": 0.01,
|
|
94
|
+
"discountFactor": 0.95,
|
|
95
|
+
"epsilon": 0.1,
|
|
96
|
+
"entropyCoef": 0.01
|
|
97
|
+
},
|
|
98
|
+
"trajectory-learning": {
|
|
99
|
+
"algorithm": "decision-transformer",
|
|
100
|
+
"learningRate": 0.001,
|
|
101
|
+
"discountFactor": 0.99,
|
|
102
|
+
"epsilon": 0,
|
|
103
|
+
"sequenceLength": 20
|
|
104
|
+
},
|
|
105
|
+
"context-ranking": {
|
|
106
|
+
"algorithm": "ppo",
|
|
107
|
+
"learningRate": 0.0003,
|
|
108
|
+
"discountFactor": 0.99,
|
|
109
|
+
"epsilon": 0.2,
|
|
110
|
+
"clipRange": 0.2,
|
|
111
|
+
"entropyCoef": 0.01
|
|
112
|
+
},
|
|
113
|
+
"memory-recall": {
|
|
114
|
+
"algorithm": "td-lambda",
|
|
115
|
+
"learningRate": 0.1,
|
|
116
|
+
"discountFactor": 0.9,
|
|
117
|
+
"epsilon": 0.1,
|
|
118
|
+
"lambda": 0.8
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"rewardHistory": [
|
|
122
|
+
1
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
}
|
package/README.md
CHANGED
|
@@ -20,24 +20,59 @@ Built by [rUv](https://ruv.io) with production-grade Rust performance and intell
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
-
## 🧠 Claude Code
|
|
23
|
+
## 🧠 Claude Code Intelligence v2.0
|
|
24
24
|
|
|
25
|
-
**Self-learning intelligence for Claude Code** — RuVector provides optimized hooks
|
|
25
|
+
**Self-learning intelligence for Claude Code** — RuVector provides optimized hooks with ONNX embeddings, AST analysis, and coverage-aware routing.
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
28
|
# One-command setup with pretrain and agent generation
|
|
29
29
|
npx ruvector hooks init --pretrain --build-agents quality
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
- 🎯 **Smart Agent Routing** —
|
|
34
|
-
- 📚 **
|
|
35
|
-
- 🤖 **Agent Builder** — Generates optimized `.claude/agents/` configs
|
|
36
|
-
- 🔗 **Co-edit Patterns** — Learns
|
|
37
|
-
- 💾 **Vector Memory** —
|
|
32
|
+
### Core Features
|
|
33
|
+
- 🎯 **Smart Agent Routing** — Q-learning optimized suggestions with 80%+ accuracy
|
|
34
|
+
- 📚 **9-Phase Pretrain** — AST, diff, coverage, neural, and graph analysis
|
|
35
|
+
- 🤖 **Agent Builder** — Generates optimized `.claude/agents/` configs
|
|
36
|
+
- 🔗 **Co-edit Patterns** — Learns file relationships from git history
|
|
37
|
+
- 💾 **Vector Memory** — HNSW-indexed semantic recall (150x faster)
|
|
38
|
+
|
|
39
|
+
### New in v2.0
|
|
40
|
+
- ⚡ **ONNX WASM Embeddings** — all-MiniLM-L6-v2 (384d) runs locally, no API needed
|
|
41
|
+
- 🌳 **AST Analysis** — Symbol extraction, complexity metrics, import graphs
|
|
42
|
+
- 📊 **Diff Embeddings** — Semantic change classification with risk scoring
|
|
43
|
+
- 🧪 **Coverage Routing** — Test coverage-aware agent selection
|
|
44
|
+
- 🔍 **Graph Algorithms** — MinCut boundaries, Louvain communities, Spectral clustering
|
|
45
|
+
- 🛡️ **Security Scanning** — Parallel vulnerability pattern detection
|
|
46
|
+
- 🎯 **RAG Context** — Semantic retrieval with HNSW indexing
|
|
47
|
+
|
|
48
|
+
### Performance
|
|
49
|
+
| Backend | Read Time | Speedup |
|
|
50
|
+
|---------|-----------|---------|
|
|
51
|
+
| ONNX inference | ~400ms | baseline |
|
|
52
|
+
| HNSW search | ~0.045ms | 8,800x |
|
|
53
|
+
| Memory cache | ~0.01ms | **40,000x** |
|
|
38
54
|
|
|
39
55
|
📖 **[Full Hooks Documentation →](https://github.com/ruvnet/ruvector/blob/main/npm/packages/ruvector/HOOKS.md)**
|
|
40
56
|
|
|
57
|
+
### MCP Server Integration
|
|
58
|
+
|
|
59
|
+
RuVector includes an MCP server for Claude Code with 30+ tools:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Add to Claude Code
|
|
63
|
+
claude mcp add ruvector-mcp -- npx ruvector mcp-server
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Available MCP Tools:**
|
|
67
|
+
- `hooks_route`, `hooks_route_enhanced` — Agent routing with signals
|
|
68
|
+
- `hooks_ast_analyze`, `hooks_ast_complexity` — Code structure analysis
|
|
69
|
+
- `hooks_diff_analyze`, `hooks_diff_classify` — Change classification
|
|
70
|
+
- `hooks_coverage_route`, `hooks_coverage_suggest` — Test-aware routing
|
|
71
|
+
- `hooks_graph_mincut`, `hooks_graph_cluster` — Code boundaries
|
|
72
|
+
- `hooks_security_scan` — Vulnerability detection
|
|
73
|
+
- `hooks_rag_context` — Semantic context retrieval
|
|
74
|
+
- `hooks_attention_info`, `hooks_gnn_info` — Neural capabilities
|
|
75
|
+
|
|
41
76
|
---
|
|
42
77
|
|
|
43
78
|
## 🌟 Why Ruvector?
|
|
@@ -113,6 +148,15 @@ npm install ruvector
|
|
|
113
148
|
- Falls back to WebAssembly if native binaries aren't available
|
|
114
149
|
- No additional setup, Docker, or external services required
|
|
115
150
|
|
|
151
|
+
**Windows Installation (without build tools):**
|
|
152
|
+
```bash
|
|
153
|
+
# Skip native compilation, use WASM fallback
|
|
154
|
+
npm install ruvector --ignore-scripts
|
|
155
|
+
|
|
156
|
+
# The ONNX WASM runtime (7.4MB) works without build tools
|
|
157
|
+
# Memory cache provides 40,000x speedup over inference
|
|
158
|
+
```
|
|
159
|
+
|
|
116
160
|
**Verify installation:**
|
|
117
161
|
```bash
|
|
118
162
|
npx ruvector info
|
|
@@ -617,9 +661,38 @@ npx ruvector attention hyperbolic -a exp-map -v "[0.1,0.2,0.3]"
|
|
|
617
661
|
| **Large-Scale Graphs** | LocalGlobalAttention | Efficient local + global context |
|
|
618
662
|
| **Model Routing/MoE** | MoEAttention | Expert selection and routing |
|
|
619
663
|
|
|
620
|
-
###
|
|
664
|
+
### ⚡ ONNX WASM Embeddings (v2.0)
|
|
621
665
|
|
|
622
|
-
|
|
666
|
+
RuVector includes a pure JavaScript ONNX runtime for local embeddings - no Python, no API calls, no build tools required.
|
|
667
|
+
|
|
668
|
+
```bash
|
|
669
|
+
# Embeddings work out of the box
|
|
670
|
+
npx ruvector hooks remember "important context" -t project
|
|
671
|
+
npx ruvector hooks recall "context query"
|
|
672
|
+
npx ruvector hooks rag-context "how does auth work"
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
**Model**: all-MiniLM-L6-v2 (384 dimensions, 23MB)
|
|
676
|
+
- Downloads automatically on first use
|
|
677
|
+
- Cached in `.ruvector/models/`
|
|
678
|
+
- SIMD-accelerated when available
|
|
679
|
+
|
|
680
|
+
**Performance:**
|
|
681
|
+
| Operation | Time | Notes |
|
|
682
|
+
|-----------|------|-------|
|
|
683
|
+
| Model load | ~2s | First use only |
|
|
684
|
+
| Embedding | ~50ms | Per text chunk |
|
|
685
|
+
| HNSW search | 0.045ms | 150x faster than brute force |
|
|
686
|
+
| Cache hit | 0.01ms | 40,000x faster than inference |
|
|
687
|
+
|
|
688
|
+
**Fallback Chain:**
|
|
689
|
+
1. Native SQLite → best persistence
|
|
690
|
+
2. WASM SQLite → cross-platform
|
|
691
|
+
3. Memory Cache → fastest (no persistence)
|
|
692
|
+
|
|
693
|
+
### 🧠 Self-Learning Hooks v2.0
|
|
694
|
+
|
|
695
|
+
Ruvector includes **self-learning intelligence hooks** for Claude Code integration with ONNX embeddings, AST analysis, and coverage-aware routing.
|
|
623
696
|
|
|
624
697
|
#### Initialize Hooks
|
|
625
698
|
|
|
@@ -628,11 +701,13 @@ Ruvector includes **self-learning intelligence hooks** for Claude Code integrati
|
|
|
628
701
|
npx ruvector hooks init
|
|
629
702
|
|
|
630
703
|
# Options:
|
|
631
|
-
# --force
|
|
632
|
-
# --minimal
|
|
704
|
+
# --force Overwrite existing configuration
|
|
705
|
+
# --minimal Minimal configuration (no optional hooks)
|
|
706
|
+
# --pretrain Initialize + pretrain from git history
|
|
707
|
+
# --build-agents quality Generate optimized agent configs
|
|
633
708
|
```
|
|
634
709
|
|
|
635
|
-
This creates `.claude/settings.json` with pre-configured hooks
|
|
710
|
+
This creates `.claude/settings.json` with pre-configured hooks and `CLAUDE.md` with comprehensive documentation.
|
|
636
711
|
|
|
637
712
|
#### Session Management
|
|
638
713
|
|
|
@@ -720,31 +795,102 @@ npx ruvector hooks swarm-recommend "code-review"
|
|
|
720
795
|
# Output: Recommended agents for code review task
|
|
721
796
|
```
|
|
722
797
|
|
|
798
|
+
#### AST Analysis (v2.0)
|
|
799
|
+
|
|
800
|
+
```bash
|
|
801
|
+
# Analyze file structure, symbols, imports, complexity
|
|
802
|
+
npx ruvector hooks ast-analyze src/index.ts --json
|
|
803
|
+
|
|
804
|
+
# Get complexity metrics for multiple files
|
|
805
|
+
npx ruvector hooks ast-complexity src/*.ts --threshold 15
|
|
806
|
+
# Flags files exceeding cyclomatic complexity threshold
|
|
807
|
+
```
|
|
808
|
+
|
|
809
|
+
#### Diff & Risk Analysis (v2.0)
|
|
810
|
+
|
|
811
|
+
```bash
|
|
812
|
+
# Analyze commit with semantic embeddings and risk scoring
|
|
813
|
+
npx ruvector hooks diff-analyze HEAD
|
|
814
|
+
# Output: risk score, category, affected files
|
|
815
|
+
|
|
816
|
+
# Classify change type (feature, bugfix, refactor, docs, test)
|
|
817
|
+
npx ruvector hooks diff-classify
|
|
818
|
+
|
|
819
|
+
# Find similar past commits via embeddings
|
|
820
|
+
npx ruvector hooks diff-similar -k 5
|
|
821
|
+
|
|
822
|
+
# Git churn analysis (hot spots)
|
|
823
|
+
npx ruvector hooks git-churn --days 30
|
|
824
|
+
```
|
|
825
|
+
|
|
826
|
+
#### Coverage-Aware Routing (v2.0)
|
|
827
|
+
|
|
828
|
+
```bash
|
|
829
|
+
# Get coverage-aware routing for a file
|
|
830
|
+
npx ruvector hooks coverage-route src/api.ts
|
|
831
|
+
# Output: agent weights based on test coverage
|
|
832
|
+
|
|
833
|
+
# Suggest tests for files based on coverage gaps
|
|
834
|
+
npx ruvector hooks coverage-suggest src/*.ts
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
#### Graph Analysis (v2.0)
|
|
838
|
+
|
|
839
|
+
```bash
|
|
840
|
+
# Find optimal code boundaries (MinCut algorithm)
|
|
841
|
+
npx ruvector hooks graph-mincut src/*.ts
|
|
842
|
+
|
|
843
|
+
# Detect code communities (Louvain/Spectral clustering)
|
|
844
|
+
npx ruvector hooks graph-cluster src/*.ts --method louvain
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
#### Security & RAG (v2.0)
|
|
848
|
+
|
|
849
|
+
```bash
|
|
850
|
+
# Parallel security vulnerability scan
|
|
851
|
+
npx ruvector hooks security-scan src/*.ts
|
|
852
|
+
|
|
853
|
+
# RAG-enhanced context retrieval
|
|
854
|
+
npx ruvector hooks rag-context "how does auth work"
|
|
855
|
+
|
|
856
|
+
# Enhanced routing with all signals
|
|
857
|
+
npx ruvector hooks route-enhanced "fix bug" --file src/api.ts
|
|
858
|
+
```
|
|
859
|
+
|
|
723
860
|
#### Hooks Configuration
|
|
724
861
|
|
|
725
862
|
The hooks integrate with Claude Code via `.claude/settings.json`:
|
|
726
863
|
|
|
727
864
|
```json
|
|
728
865
|
{
|
|
866
|
+
"env": {
|
|
867
|
+
"RUVECTOR_INTELLIGENCE_ENABLED": "true",
|
|
868
|
+
"RUVECTOR_LEARNING_RATE": "0.1",
|
|
869
|
+
"RUVECTOR_AST_ENABLED": "true",
|
|
870
|
+
"RUVECTOR_DIFF_EMBEDDINGS": "true",
|
|
871
|
+
"RUVECTOR_COVERAGE_ROUTING": "true",
|
|
872
|
+
"RUVECTOR_GRAPH_ALGORITHMS": "true",
|
|
873
|
+
"RUVECTOR_SECURITY_SCAN": "true"
|
|
874
|
+
},
|
|
729
875
|
"hooks": {
|
|
730
876
|
"PreToolUse": [
|
|
731
877
|
{
|
|
732
878
|
"matcher": "Edit|Write|MultiEdit",
|
|
733
|
-
"hooks": ["ruvector hooks pre-edit \"$TOOL_INPUT_file_path\""]
|
|
879
|
+
"hooks": [{ "type": "command", "command": "npx ruvector hooks pre-edit \"$TOOL_INPUT_file_path\"" }]
|
|
734
880
|
},
|
|
735
881
|
{
|
|
736
882
|
"matcher": "Bash",
|
|
737
|
-
"hooks": ["ruvector hooks pre-command \"$TOOL_INPUT_command\""]
|
|
883
|
+
"hooks": [{ "type": "command", "command": "npx ruvector hooks pre-command \"$TOOL_INPUT_command\"" }]
|
|
738
884
|
}
|
|
739
885
|
],
|
|
740
886
|
"PostToolUse": [
|
|
741
887
|
{
|
|
742
888
|
"matcher": "Edit|Write|MultiEdit",
|
|
743
|
-
"hooks": ["ruvector hooks post-edit \"$TOOL_INPUT_file_path\""]
|
|
889
|
+
"hooks": [{ "type": "command", "command": "npx ruvector hooks post-edit \"$TOOL_INPUT_file_path\"" }]
|
|
744
890
|
}
|
|
745
891
|
],
|
|
746
|
-
"SessionStart": ["ruvector hooks session-start"],
|
|
747
|
-
"Stop": ["ruvector hooks session-end"]
|
|
892
|
+
"SessionStart": [{ "hooks": [{ "type": "command", "command": "npx ruvector hooks session-start" }] }],
|
|
893
|
+
"Stop": [{ "hooks": [{ "type": "command", "command": "npx ruvector hooks session-end" }] }]
|
|
748
894
|
}
|
|
749
895
|
}
|
|
750
896
|
```
|
|
@@ -753,8 +899,11 @@ The hooks integrate with Claude Code via `.claude/settings.json`:
|
|
|
753
899
|
|
|
754
900
|
1. **Pattern Recording**: Every edit and command is recorded with context
|
|
755
901
|
2. **Q-Learning**: Success/failure updates agent routing weights
|
|
756
|
-
3. **
|
|
757
|
-
4. **
|
|
902
|
+
3. **AST Analysis**: Code complexity informs agent selection
|
|
903
|
+
4. **Diff Embeddings**: Change patterns improve risk assessment
|
|
904
|
+
5. **Coverage Routing**: Test coverage guides testing priorities
|
|
905
|
+
6. **Vector Memory**: Decisions and references stored for semantic recall (HNSW indexed)
|
|
906
|
+
7. **Continuous Improvement**: The more you use it, the smarter it gets
|
|
758
907
|
|
|
759
908
|
## 📊 Performance Benchmarks
|
|
760
909
|
|