ruvector 0.1.100 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/mcp-server.js CHANGED
@@ -363,7 +363,7 @@ class Intelligence {
363
363
  const server = new Server(
364
364
  {
365
365
  name: 'ruvector',
366
- version: '0.1.58',
366
+ version: '0.2.1',
367
367
  },
368
368
  {
369
369
  capabilities: {
@@ -1269,6 +1269,185 @@ const TOOLS = [
1269
1269
  },
1270
1270
  required: ['query']
1271
1271
  }
1272
+ },
1273
+ // ── Brain Tools (11) ── Shared intelligence via @ruvector/pi-brain ──
1274
+ {
1275
+ name: 'brain_search',
1276
+ description: 'Semantic search across shared brain knowledge',
1277
+ inputSchema: {
1278
+ type: 'object',
1279
+ properties: {
1280
+ query: { type: 'string', description: 'Search query' },
1281
+ category: { type: 'string', description: 'Filter by category (pattern, solution, architecture, convention, security, performance, tooling)' },
1282
+ limit: { type: 'number', description: 'Max results (default 10)' }
1283
+ },
1284
+ required: ['query']
1285
+ }
1286
+ },
1287
+ {
1288
+ name: 'brain_share',
1289
+ description: 'Share a learning or pattern with the collective brain',
1290
+ inputSchema: {
1291
+ type: 'object',
1292
+ properties: {
1293
+ title: { type: 'string', description: 'Title of the knowledge entry' },
1294
+ content: { type: 'string', description: 'Content/description of the knowledge' },
1295
+ category: { type: 'string', description: 'Category (pattern, solution, architecture, convention, security, performance, tooling)' },
1296
+ tags: { type: 'string', description: 'Comma-separated tags' },
1297
+ code_snippet: { type: 'string', description: 'Optional code snippet' }
1298
+ },
1299
+ required: ['title', 'content', 'category']
1300
+ }
1301
+ },
1302
+ {
1303
+ name: 'brain_get',
1304
+ description: 'Retrieve a specific memory by ID with full provenance',
1305
+ inputSchema: {
1306
+ type: 'object',
1307
+ properties: {
1308
+ id: { type: 'string', description: 'Memory ID' }
1309
+ },
1310
+ required: ['id']
1311
+ }
1312
+ },
1313
+ {
1314
+ name: 'brain_vote',
1315
+ description: 'Quality-gate a memory with an up or down vote',
1316
+ inputSchema: {
1317
+ type: 'object',
1318
+ properties: {
1319
+ id: { type: 'string', description: 'Memory ID' },
1320
+ direction: { type: 'string', description: 'Vote direction: up or down' }
1321
+ },
1322
+ required: ['id', 'direction']
1323
+ }
1324
+ },
1325
+ {
1326
+ name: 'brain_list',
1327
+ description: 'List recent shared memories filtered by category or quality',
1328
+ inputSchema: {
1329
+ type: 'object',
1330
+ properties: {
1331
+ category: { type: 'string', description: 'Filter by category' },
1332
+ limit: { type: 'number', description: 'Max results (default 20)' }
1333
+ }
1334
+ }
1335
+ },
1336
+ {
1337
+ name: 'brain_delete',
1338
+ description: 'Delete your own contribution from the shared brain',
1339
+ inputSchema: {
1340
+ type: 'object',
1341
+ properties: {
1342
+ id: { type: 'string', description: 'Memory ID to delete' }
1343
+ },
1344
+ required: ['id']
1345
+ }
1346
+ },
1347
+ {
1348
+ name: 'brain_status',
1349
+ description: 'Get shared brain system health: counts, drift, quality, graph topology',
1350
+ inputSchema: {
1351
+ type: 'object',
1352
+ properties: {}
1353
+ }
1354
+ },
1355
+ {
1356
+ name: 'brain_drift',
1357
+ description: 'Check if shared knowledge has drifted from local state',
1358
+ inputSchema: {
1359
+ type: 'object',
1360
+ properties: {
1361
+ domain: { type: 'string', description: 'Domain to check drift for' }
1362
+ }
1363
+ }
1364
+ },
1365
+ {
1366
+ name: 'brain_partition',
1367
+ description: 'Get knowledge partitioned by mincut topology into clusters',
1368
+ inputSchema: {
1369
+ type: 'object',
1370
+ properties: {
1371
+ domain: { type: 'string', description: 'Domain to partition' },
1372
+ min_cluster_size: { type: 'number', description: 'Minimum cluster size (default 3)' }
1373
+ }
1374
+ }
1375
+ },
1376
+ {
1377
+ name: 'brain_transfer',
1378
+ description: 'Apply learned priors from one knowledge domain to another',
1379
+ inputSchema: {
1380
+ type: 'object',
1381
+ properties: {
1382
+ source_domain: { type: 'string', description: 'Source domain to transfer from' },
1383
+ target_domain: { type: 'string', description: 'Target domain to transfer to' }
1384
+ },
1385
+ required: ['source_domain', 'target_domain']
1386
+ }
1387
+ },
1388
+ {
1389
+ name: 'brain_sync',
1390
+ description: 'Synchronize LoRA weights between local and shared brain',
1391
+ inputSchema: {
1392
+ type: 'object',
1393
+ properties: {
1394
+ direction: { type: 'string', description: 'Sync direction: pull, push, or both (default both)' }
1395
+ }
1396
+ }
1397
+ },
1398
+ // ── Edge Tools (4) ── Distributed compute via @ruvector/edge-net ──
1399
+ {
1400
+ name: 'edge_status',
1401
+ description: 'Get edge compute network status (genesis, relay, nodes, rUv supply)',
1402
+ inputSchema: {
1403
+ type: 'object',
1404
+ properties: {}
1405
+ }
1406
+ },
1407
+ {
1408
+ name: 'edge_join',
1409
+ description: 'Join the edge compute network as a compute node',
1410
+ inputSchema: {
1411
+ type: 'object',
1412
+ properties: {
1413
+ contribution: { type: 'number', description: 'Contribution level 0.0-1.0 (default 0.3)' }
1414
+ }
1415
+ }
1416
+ },
1417
+ {
1418
+ name: 'edge_balance',
1419
+ description: 'Check rUv credit balance for current identity',
1420
+ inputSchema: {
1421
+ type: 'object',
1422
+ properties: {}
1423
+ }
1424
+ },
1425
+ {
1426
+ name: 'edge_tasks',
1427
+ description: 'List available distributed compute tasks on the edge network',
1428
+ inputSchema: {
1429
+ type: 'object',
1430
+ properties: {
1431
+ limit: { type: 'number', description: 'Max tasks to return (default 20)' }
1432
+ }
1433
+ }
1434
+ },
1435
+ // ── Identity Tools (2) ── Pi key management ──
1436
+ {
1437
+ name: 'identity_generate',
1438
+ description: 'Generate a new pi key and derive pseudonym',
1439
+ inputSchema: {
1440
+ type: 'object',
1441
+ properties: {}
1442
+ }
1443
+ },
1444
+ {
1445
+ name: 'identity_show',
1446
+ description: 'Show current pi key pseudonym and derived identities',
1447
+ inputSchema: {
1448
+ type: 'object',
1449
+ properties: {}
1450
+ }
1272
1451
  }
1273
1452
  ];
1274
1453
 
@@ -2963,6 +3142,98 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
2963
3142
  }
2964
3143
  }
2965
3144
 
3145
+ // ── Brain Tool Handlers ──────────────────────────────────────────────
3146
+ case 'brain_search':
3147
+ case 'brain_share':
3148
+ case 'brain_get':
3149
+ case 'brain_vote':
3150
+ case 'brain_list':
3151
+ case 'brain_delete':
3152
+ case 'brain_status':
3153
+ case 'brain_drift':
3154
+ case 'brain_partition':
3155
+ case 'brain_transfer':
3156
+ case 'brain_sync': {
3157
+ try {
3158
+ const { PiBrainClient } = require('@ruvector/pi-brain');
3159
+ const client = new PiBrainClient({
3160
+ url: process.env.BRAIN_URL || 'https://pi.ruv.io',
3161
+ key: process.env.PI
3162
+ });
3163
+ const subCmd = name.replace('brain_', '');
3164
+ let result;
3165
+ switch (subCmd) {
3166
+ case 'search': result = await client.search(args.query, { category: args.category, limit: args.limit || 10 }); break;
3167
+ case 'share': result = await client.share({ title: args.title, content: args.content, category: args.category, tags: args.tags ? args.tags.split(',').map(t => t.trim()) : [], code_snippet: args.code_snippet }); break;
3168
+ case 'get': result = await client.get(args.id); break;
3169
+ case 'vote': result = await client.vote(args.id, args.direction); break;
3170
+ case 'list': result = await client.list({ category: args.category, limit: args.limit || 20 }); break;
3171
+ case 'delete': result = await client.delete(args.id); break;
3172
+ case 'status': result = await client.status(); break;
3173
+ case 'drift': result = await client.drift({ domain: args.domain }); break;
3174
+ case 'partition': result = await client.partition({ domain: args.domain, min_cluster_size: args.min_cluster_size }); break;
3175
+ case 'transfer': result = await client.transfer(args.source_domain, args.target_domain); break;
3176
+ case 'sync': result = await client.sync(args.direction || 'both'); break;
3177
+ }
3178
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...result }, null, 2) }] };
3179
+ } catch (e) {
3180
+ if (e.code === 'MODULE_NOT_FOUND') {
3181
+ return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Brain tools require @ruvector/pi-brain. Install with: npm install @ruvector/pi-brain' }, null, 2) }], isError: true };
3182
+ }
3183
+ return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
3184
+ }
3185
+ }
3186
+
3187
+ // ── Edge Tool Handlers ───────────────────────────────────────────────
3188
+ case 'edge_status':
3189
+ case 'edge_join':
3190
+ case 'edge_balance':
3191
+ case 'edge_tasks': {
3192
+ try {
3193
+ const genesisUrl = process.env.EDGE_GENESIS_URL || 'https://edge-net-genesis-875130704813.us-central1.run.app';
3194
+ const subCmd = name.replace('edge_', '');
3195
+ let endpoint, method = 'GET', body;
3196
+ switch (subCmd) {
3197
+ case 'status': endpoint = '/status'; break;
3198
+ case 'join': endpoint = '/join'; method = 'POST'; body = JSON.stringify({ contribution: args.contribution || 0.3, pi_key: process.env.PI }); break;
3199
+ case 'balance': endpoint = `/balance/${process.env.PI || 'anonymous'}`; break;
3200
+ case 'tasks': endpoint = `/tasks?limit=${args.limit || 20}`; break;
3201
+ }
3202
+ const resp = await fetch(`${genesisUrl}${endpoint}`, {
3203
+ method,
3204
+ headers: { 'Content-Type': 'application/json', ...(process.env.PI ? { 'Authorization': `Bearer ${process.env.PI}` } : {}) },
3205
+ ...(body ? { body } : {})
3206
+ });
3207
+ const data = await resp.json();
3208
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...data }, null, 2) }] };
3209
+ } catch (e) {
3210
+ return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: e.message }, null, 2) }], isError: true };
3211
+ }
3212
+ }
3213
+
3214
+ // ── Identity Tool Handlers ───────────────────────────────────────────
3215
+ case 'identity_generate': {
3216
+ const crypto = require('crypto');
3217
+ const key = crypto.randomBytes(32).toString('hex');
3218
+ const hash = crypto.createHash('shake256', { outputLength: 16 });
3219
+ hash.update(key);
3220
+ const pseudonym = hash.digest('hex');
3221
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, pi_key: key, pseudonym, warning: 'Store this key securely. Set PI env var to use it.' }, null, 2) }] };
3222
+ }
3223
+
3224
+ case 'identity_show': {
3225
+ const piKey = process.env.PI;
3226
+ if (!piKey) {
3227
+ return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'No PI environment variable set. Run identity_generate first.' }, null, 2) }], isError: true };
3228
+ }
3229
+ const crypto = require('crypto');
3230
+ const hash = crypto.createHash('shake256', { outputLength: 16 });
3231
+ hash.update(piKey);
3232
+ const pseudonym = hash.digest('hex');
3233
+ const mcpToken = crypto.createHmac('sha256', piKey).update('mcp').digest('hex').slice(0, 32);
3234
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, pseudonym, mcp_token: mcpToken, key_prefix: piKey.slice(0, 8) + '...' }, null, 2) }] };
3235
+ }
3236
+
2966
3237
  default:
2967
3238
  return {
2968
3239
  content: [{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ruvector",
3
- "version": "0.1.100",
3
+ "version": "0.2.1",
4
4
  "description": "High-performance vector database for Node.js with automatic native/WASM fallback",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "scripts": {
11
11
  "build": "tsc && cp src/core/onnx/pkg/package.json dist/core/onnx/pkg/",
12
12
  "prepublishOnly": "npm run build",
13
- "test": "node test/integration.js"
13
+ "test": "node test/integration.js && node test/cli-commands.js"
14
14
  },
15
15
  "keywords": [
16
16
  "vector",
@@ -41,7 +41,15 @@
41
41
  "continual-learning",
42
42
  "onnx",
43
43
  "semantic-embeddings",
44
- "minilm"
44
+ "minilm",
45
+ "brain",
46
+ "shared-intelligence",
47
+ "mcp",
48
+ "edge-computing",
49
+ "pi-brain",
50
+ "identity",
51
+ "pi-key",
52
+ "distributed-compute"
45
53
  ],
46
54
  "author": "ruv.io Team <info@ruv.io> (https://ruv.io)",
47
55
  "homepage": "https://ruv.io",
@@ -71,7 +79,23 @@
71
79
  "@types/node": "^20.10.5",
72
80
  "typescript": "^5.3.3"
73
81
  },
82
+ "peerDependencies": {
83
+ "@ruvector/pi-brain": ">=0.1.0",
84
+ "@ruvector/ruvllm": ">=2.0.0",
85
+ "@ruvector/router": ">=0.1.0"
86
+ },
87
+ "peerDependenciesMeta": {
88
+ "@ruvector/pi-brain": { "optional": true },
89
+ "@ruvector/ruvllm": { "optional": true },
90
+ "@ruvector/router": { "optional": true }
91
+ },
92
+ "files": [
93
+ "bin/",
94
+ "dist/",
95
+ "README.md",
96
+ "LICENSE"
97
+ ],
74
98
  "engines": {
75
- "node": ">=14.0.0"
99
+ "node": ">=18.0.0"
76
100
  }
77
101
  }
package/HOOKS.md DELETED
@@ -1,221 +0,0 @@
1
- # RuVector Hooks for Claude Code
2
-
3
- Self-learning intelligence hooks that enhance Claude Code with Q-learning, vector memory, and automatic agent routing.
4
-
5
- ## Quick Start
6
-
7
- ```bash
8
- # Full setup: hooks + pretrain + optimized agents
9
- npx ruvector hooks init --pretrain --build-agents quality
10
-
11
- # Or step by step:
12
- npx ruvector hooks init # Setup hooks
13
- npx ruvector hooks pretrain # Analyze repository
14
- npx ruvector hooks build-agents # Generate agent configs
15
- ```
16
-
17
- ## What It Does
18
-
19
- RuVector hooks integrate with Claude Code to provide:
20
-
21
- | Feature | Description |
22
- |---------|-------------|
23
- | **Agent Routing** | Suggests the best agent for each file type based on learned patterns |
24
- | **Co-edit Patterns** | Predicts "likely next files" from git history |
25
- | **Vector Memory** | Semantic recall of project context |
26
- | **Command Analysis** | Risk assessment for bash commands |
27
- | **Self-Learning** | Q-learning improves suggestions over time |
28
-
29
- ## Commands
30
-
31
- ### Initialization
32
-
33
- ```bash
34
- # Full configuration
35
- npx ruvector hooks init
36
-
37
- # With pretrain and agent building
38
- npx ruvector hooks init --pretrain --build-agents security
39
-
40
- # Minimal (basic hooks only)
41
- npx ruvector hooks init --minimal
42
-
43
- # Options
44
- --force # Overwrite existing settings
45
- --minimal # Basic hooks only
46
- --pretrain # Run pretrain after init
47
- --build-agents # Generate optimized agents (quality|speed|security|testing|fullstack)
48
- --no-claude-md # Skip CLAUDE.md creation
49
- --no-permissions # Skip permissions config
50
- --no-env # Skip environment variables
51
- --no-gitignore # Skip .gitignore update
52
- --no-mcp # Skip MCP server config
53
- --no-statusline # Skip status line config
54
- ```
55
-
56
- ### Pretrain
57
-
58
- Analyze your repository to bootstrap intelligence:
59
-
60
- ```bash
61
- npx ruvector hooks pretrain
62
-
63
- # Options
64
- --depth <n> # Git history depth (default: 100)
65
- --verbose # Show detailed progress
66
- --skip-git # Skip git history analysis
67
- --skip-files # Skip file structure analysis
68
- ```
69
-
70
- **What it learns:**
71
- - File type → Agent mapping (`.rs` → rust-developer)
72
- - Co-edit patterns from git history
73
- - Directory → Agent mapping
74
- - Project context memories
75
-
76
- ### Build Agents
77
-
78
- Generate optimized `.claude/agents/` configurations:
79
-
80
- ```bash
81
- npx ruvector hooks build-agents --focus quality
82
-
83
- # Focus modes
84
- --focus quality # Code quality, best practices (default)
85
- --focus speed # Rapid development, prototyping
86
- --focus security # OWASP, input validation, encryption
87
- --focus testing # TDD, comprehensive coverage
88
- --focus fullstack # Balanced frontend/backend/database
89
-
90
- # Options
91
- --output <dir> # Output directory (default: .claude/agents)
92
- --format <fmt> # yaml, json, or md (default: yaml)
93
- --include-prompts # Include system prompts in agent configs
94
- ```
95
-
96
- ### Verification & Diagnostics
97
-
98
- ```bash
99
- # Check if hooks are working
100
- npx ruvector hooks verify
101
-
102
- # Diagnose and fix issues
103
- npx ruvector hooks doctor
104
- npx ruvector hooks doctor --fix
105
- ```
106
-
107
- ### Data Management
108
-
109
- ```bash
110
- # View statistics
111
- npx ruvector hooks stats
112
-
113
- # Export intelligence data
114
- npx ruvector hooks export -o backup.json
115
- npx ruvector hooks export --include-all
116
-
117
- # Import intelligence data
118
- npx ruvector hooks import backup.json
119
- npx ruvector hooks import backup.json --merge
120
- ```
121
-
122
- ### Memory Operations
123
-
124
- ```bash
125
- # Store context in vector memory
126
- npx ruvector hooks remember "API uses JWT auth" -t project
127
-
128
- # Semantic search memory
129
- npx ruvector hooks recall "authentication"
130
-
131
- # Route a task to best agent
132
- npx ruvector hooks route "implement user login"
133
- ```
134
-
135
- ## Hook Events
136
-
137
- | Event | Trigger | RuVector Action |
138
- |-------|---------|-----------------|
139
- | **PreToolUse** | Before Edit/Write/Bash | Agent routing, file analysis, command risk |
140
- | **PostToolUse** | After Edit/Write/Bash | Q-learning update, pattern recording |
141
- | **SessionStart** | Conversation begins | Load intelligence, display stats |
142
- | **Stop** | Conversation ends | Save learning data |
143
- | **UserPromptSubmit** | User sends message | Context suggestions |
144
- | **PreCompact** | Before context compaction | Preserve important context |
145
- | **Notification** | Any notification | Track events for learning |
146
-
147
- ## Generated Files
148
-
149
- After running `hooks init`:
150
-
151
- ```
152
- your-project/
153
- ├── .claude/
154
- │ ├── settings.json # Hooks configuration
155
- │ ├── statusline.sh # Status bar script
156
- │ └── agents/ # Generated agents (with --build-agents)
157
- │ ├── rust-specialist.yaml
158
- │ ├── typescript-specialist.yaml
159
- │ ├── test-architect.yaml
160
- │ └── project-coordinator.yaml
161
- ├── .ruvector/
162
- │ └── intelligence.json # Learning data
163
- ├── CLAUDE.md # Project documentation
164
- └── .gitignore # Updated with .ruvector/
165
- ```
166
-
167
- ## Environment Variables
168
-
169
- | Variable | Default | Description |
170
- |----------|---------|-------------|
171
- | `RUVECTOR_INTELLIGENCE_ENABLED` | `true` | Enable/disable intelligence |
172
- | `RUVECTOR_LEARNING_RATE` | `0.1` | Q-learning rate (0.0-1.0) |
173
- | `RUVECTOR_MEMORY_BACKEND` | `rvlite` | Memory storage backend |
174
- | `INTELLIGENCE_MODE` | `treatment` | A/B testing mode |
175
-
176
- ## Example Output
177
-
178
- ### Agent Routing
179
- ```
180
- 🧠 Intelligence Analysis:
181
- 📁 src/api/routes.ts
182
- 🤖 Recommended: typescript-developer (85% confidence)
183
- → learned from 127 .ts files in repo
184
- 📎 Likely next files:
185
- - src/api/handlers.ts (12 co-edits)
186
- - src/types/api.ts (8 co-edits)
187
- ```
188
-
189
- ### Command Analysis
190
- ```
191
- 🧠 Command Analysis:
192
- 📦 Category: rust
193
- 🏷️ Type: test
194
- ✅ Risk: LOW
195
- ```
196
-
197
- ## Best Practices
198
-
199
- 1. **Run pretrain on existing repos** — Bootstrap intelligence before starting work
200
- 2. **Use focus modes** — Match agent generation to your current task
201
- 3. **Export before major changes** — Backup learning data
202
- 4. **Let it learn** — Intelligence improves with each edit
203
-
204
- ## Troubleshooting
205
-
206
- ```bash
207
- # Check setup
208
- npx ruvector hooks verify
209
-
210
- # Fix common issues
211
- npx ruvector hooks doctor --fix
212
-
213
- # Reset and reinitialize
214
- npx ruvector hooks init --force --pretrain
215
- ```
216
-
217
- ## Links
218
-
219
- - [RuVector GitHub](https://github.com/ruvnet/ruvector)
220
- - [npm Package](https://www.npmjs.com/package/ruvector)
221
- - [Claude Code Documentation](https://docs.anthropic.com/claude-code)