ruvector 0.2.22 → 0.2.23
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/README.md +2 -2
- package/package.json +9 -5
- package/dist/analysis/complexity.d.ts +0 -52
- package/dist/analysis/complexity.d.ts.map +0 -1
- package/dist/analysis/complexity.js +0 -146
- package/dist/analysis/index.d.ts +0 -15
- package/dist/analysis/index.d.ts.map +0 -1
- package/dist/analysis/index.js +0 -38
- package/dist/analysis/patterns.d.ts +0 -71
- package/dist/analysis/patterns.d.ts.map +0 -1
- package/dist/analysis/patterns.js +0 -243
- package/dist/analysis/security.d.ts +0 -51
- package/dist/analysis/security.d.ts.map +0 -1
- package/dist/analysis/security.js +0 -139
- package/dist/core/adaptive-embedder.d.ts +0 -156
- package/dist/core/adaptive-embedder.d.ts.map +0 -1
- package/dist/core/adaptive-embedder.js +0 -838
- package/dist/core/agentdb-fast.d.ts +0 -149
- package/dist/core/agentdb-fast.d.ts.map +0 -1
- package/dist/core/agentdb-fast.js +0 -301
- package/dist/core/ast-parser.d.ts +0 -108
- package/dist/core/ast-parser.d.ts.map +0 -1
- package/dist/core/ast-parser.js +0 -602
- package/dist/core/attention-fallbacks.d.ts +0 -321
- package/dist/core/attention-fallbacks.d.ts.map +0 -1
- package/dist/core/attention-fallbacks.js +0 -552
- package/dist/core/cluster-wrapper.d.ts +0 -148
- package/dist/core/cluster-wrapper.d.ts.map +0 -1
- package/dist/core/cluster-wrapper.js +0 -271
- package/dist/core/coverage-router.d.ts +0 -88
- package/dist/core/coverage-router.d.ts.map +0 -1
- package/dist/core/coverage-router.js +0 -315
- package/dist/core/diff-embeddings.d.ts +0 -93
- package/dist/core/diff-embeddings.d.ts.map +0 -1
- package/dist/core/diff-embeddings.js +0 -334
- package/dist/core/gnn-wrapper.d.ts +0 -143
- package/dist/core/gnn-wrapper.d.ts.map +0 -1
- package/dist/core/gnn-wrapper.js +0 -213
- package/dist/core/graph-algorithms.d.ts +0 -83
- package/dist/core/graph-algorithms.d.ts.map +0 -1
- package/dist/core/graph-algorithms.js +0 -514
- package/dist/core/graph-wrapper.d.ts +0 -147
- package/dist/core/graph-wrapper.d.ts.map +0 -1
- package/dist/core/graph-wrapper.js +0 -299
- package/dist/core/index.d.ts +0 -48
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -89
- package/dist/core/intelligence-engine.d.ts +0 -258
- package/dist/core/intelligence-engine.d.ts.map +0 -1
- package/dist/core/intelligence-engine.js +0 -1030
- package/dist/core/learning-engine.d.ts +0 -160
- package/dist/core/learning-engine.d.ts.map +0 -1
- package/dist/core/learning-engine.js +0 -589
- package/dist/core/neural-embeddings.d.ts +0 -393
- package/dist/core/neural-embeddings.d.ts.map +0 -1
- package/dist/core/neural-embeddings.js +0 -1091
- package/dist/core/neural-perf.d.ts +0 -331
- package/dist/core/neural-perf.d.ts.map +0 -1
- package/dist/core/neural-perf.js +0 -704
- package/dist/core/onnx/pkg/package.json +0 -3
- package/dist/core/onnx-embedder.d.ts +0 -105
- package/dist/core/onnx-embedder.d.ts.map +0 -1
- package/dist/core/onnx-embedder.js +0 -410
- package/dist/core/onnx-optimized.d.ts +0 -109
- package/dist/core/onnx-optimized.d.ts.map +0 -1
- package/dist/core/onnx-optimized.js +0 -419
- package/dist/core/parallel-intelligence.d.ts +0 -109
- package/dist/core/parallel-intelligence.d.ts.map +0 -1
- package/dist/core/parallel-intelligence.js +0 -340
- package/dist/core/parallel-workers.d.ts +0 -177
- package/dist/core/parallel-workers.d.ts.map +0 -1
- package/dist/core/parallel-workers.js +0 -671
- package/dist/core/router-wrapper.d.ts +0 -75
- package/dist/core/router-wrapper.d.ts.map +0 -1
- package/dist/core/router-wrapper.js +0 -243
- package/dist/core/rvf-wrapper.d.ts +0 -86
- package/dist/core/rvf-wrapper.d.ts.map +0 -1
- package/dist/core/rvf-wrapper.js +0 -102
- package/dist/core/sona-wrapper.d.ts +0 -226
- package/dist/core/sona-wrapper.d.ts.map +0 -1
- package/dist/core/sona-wrapper.js +0 -282
- package/dist/core/tensor-compress.d.ts +0 -134
- package/dist/core/tensor-compress.d.ts.map +0 -1
- package/dist/core/tensor-compress.js +0 -432
- package/dist/index.d.ts +0 -105
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -221
- package/dist/services/embedding-service.d.ts +0 -136
- package/dist/services/embedding-service.d.ts.map +0 -1
- package/dist/services/embedding-service.js +0 -294
- package/dist/services/index.d.ts +0 -6
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/index.js +0 -26
- package/dist/types.d.ts +0 -145
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/workers/benchmark.d.ts +0 -44
- package/dist/workers/benchmark.d.ts.map +0 -1
- package/dist/workers/benchmark.js +0 -230
- package/dist/workers/index.d.ts +0 -10
- package/dist/workers/index.d.ts.map +0 -1
- package/dist/workers/index.js +0 -25
- package/dist/workers/native-worker.d.ts +0 -76
- package/dist/workers/native-worker.d.ts.map +0 -1
- package/dist/workers/native-worker.js +0 -490
- package/dist/workers/types.d.ts +0 -69
- package/dist/workers/types.d.ts.map +0 -1
- package/dist/workers/types.js +0 -7
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Parallel Intelligence - Worker-based acceleration for IntelligenceEngine
|
|
4
|
-
*
|
|
5
|
-
* Provides parallel processing for:
|
|
6
|
-
* - Q-learning batch updates (3-4x faster)
|
|
7
|
-
* - Multi-file pattern matching
|
|
8
|
-
* - Background memory indexing
|
|
9
|
-
* - Parallel similarity search
|
|
10
|
-
* - Multi-file code analysis
|
|
11
|
-
* - Parallel git commit analysis
|
|
12
|
-
*
|
|
13
|
-
* Uses worker_threads for CPU-bound operations, keeping hooks non-blocking.
|
|
14
|
-
*/
|
|
15
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
-
}
|
|
21
|
-
Object.defineProperty(o, k2, desc);
|
|
22
|
-
}) : (function(o, m, k, k2) {
|
|
23
|
-
if (k2 === undefined) k2 = k;
|
|
24
|
-
o[k2] = m[k];
|
|
25
|
-
}));
|
|
26
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
-
}) : function(o, v) {
|
|
29
|
-
o["default"] = v;
|
|
30
|
-
});
|
|
31
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
-
var ownKeys = function(o) {
|
|
33
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
-
var ar = [];
|
|
35
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
-
return ar;
|
|
37
|
-
};
|
|
38
|
-
return ownKeys(o);
|
|
39
|
-
};
|
|
40
|
-
return function (mod) {
|
|
41
|
-
if (mod && mod.__esModule) return mod;
|
|
42
|
-
var result = {};
|
|
43
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
-
__setModuleDefault(result, mod);
|
|
45
|
-
return result;
|
|
46
|
-
};
|
|
47
|
-
})();
|
|
48
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
-
exports.ParallelIntelligence = void 0;
|
|
50
|
-
exports.getParallelIntelligence = getParallelIntelligence;
|
|
51
|
-
exports.initParallelIntelligence = initParallelIntelligence;
|
|
52
|
-
const worker_threads_1 = require("worker_threads");
|
|
53
|
-
const os = __importStar(require("os"));
|
|
54
|
-
// ============================================================================
|
|
55
|
-
// Worker Pool Manager
|
|
56
|
-
// ============================================================================
|
|
57
|
-
class ParallelIntelligence {
|
|
58
|
-
constructor(config = {}) {
|
|
59
|
-
this.workers = [];
|
|
60
|
-
this.taskQueue = [];
|
|
61
|
-
this.busyWorkers = new Set();
|
|
62
|
-
this.initialized = false;
|
|
63
|
-
const isCLI = process.env.RUVECTOR_CLI === '1';
|
|
64
|
-
const isMCP = process.env.MCP_SERVER === '1';
|
|
65
|
-
this.config = {
|
|
66
|
-
numWorkers: config.numWorkers ?? Math.max(1, os.cpus().length - 1),
|
|
67
|
-
enabled: config.enabled ?? (isMCP || (!isCLI && process.env.RUVECTOR_PARALLEL === '1')),
|
|
68
|
-
batchThreshold: config.batchThreshold ?? 4,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Initialize worker pool
|
|
73
|
-
*/
|
|
74
|
-
async init() {
|
|
75
|
-
if (this.initialized || !this.config.enabled)
|
|
76
|
-
return;
|
|
77
|
-
for (let i = 0; i < this.config.numWorkers; i++) {
|
|
78
|
-
const worker = new worker_threads_1.Worker(__filename, {
|
|
79
|
-
workerData: { workerId: i },
|
|
80
|
-
});
|
|
81
|
-
worker.on('message', (result) => {
|
|
82
|
-
this.busyWorkers.delete(worker);
|
|
83
|
-
this.processQueue();
|
|
84
|
-
});
|
|
85
|
-
worker.on('error', (err) => {
|
|
86
|
-
console.error(`Worker ${i} error:`, err);
|
|
87
|
-
this.busyWorkers.delete(worker);
|
|
88
|
-
});
|
|
89
|
-
this.workers.push(worker);
|
|
90
|
-
}
|
|
91
|
-
this.initialized = true;
|
|
92
|
-
console.error(`ParallelIntelligence: ${this.config.numWorkers} workers ready`);
|
|
93
|
-
}
|
|
94
|
-
processQueue() {
|
|
95
|
-
while (this.taskQueue.length > 0 && this.busyWorkers.size < this.workers.length) {
|
|
96
|
-
const availableWorker = this.workers.find(w => !this.busyWorkers.has(w));
|
|
97
|
-
if (!availableWorker)
|
|
98
|
-
break;
|
|
99
|
-
const task = this.taskQueue.shift();
|
|
100
|
-
this.busyWorkers.add(availableWorker);
|
|
101
|
-
availableWorker.postMessage(task.task);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Execute task in worker pool
|
|
106
|
-
*/
|
|
107
|
-
async executeInWorker(task) {
|
|
108
|
-
if (!this.initialized || !this.config.enabled) {
|
|
109
|
-
throw new Error('ParallelIntelligence not initialized');
|
|
110
|
-
}
|
|
111
|
-
return new Promise((resolve, reject) => {
|
|
112
|
-
const availableWorker = this.workers.find(w => !this.busyWorkers.has(w));
|
|
113
|
-
if (availableWorker) {
|
|
114
|
-
this.busyWorkers.add(availableWorker);
|
|
115
|
-
const handler = (result) => {
|
|
116
|
-
this.busyWorkers.delete(availableWorker);
|
|
117
|
-
availableWorker.off('message', handler);
|
|
118
|
-
if (result.error) {
|
|
119
|
-
reject(new Error(result.error));
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
resolve(result.data);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
availableWorker.on('message', handler);
|
|
126
|
-
availableWorker.postMessage(task);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
this.taskQueue.push({ task, resolve, reject });
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
// =========================================================================
|
|
134
|
-
// Parallel Operations
|
|
135
|
-
// =========================================================================
|
|
136
|
-
/**
|
|
137
|
-
* Batch Q-learning episode recording (3-4x faster)
|
|
138
|
-
*/
|
|
139
|
-
async recordEpisodesBatch(episodes) {
|
|
140
|
-
if (episodes.length < this.config.batchThreshold || !this.config.enabled) {
|
|
141
|
-
// Fall back to sequential
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
// Split into chunks for workers
|
|
145
|
-
const chunkSize = Math.ceil(episodes.length / this.config.numWorkers);
|
|
146
|
-
const chunks = [];
|
|
147
|
-
for (let i = 0; i < episodes.length; i += chunkSize) {
|
|
148
|
-
chunks.push(episodes.slice(i, i + chunkSize));
|
|
149
|
-
}
|
|
150
|
-
await Promise.all(chunks.map(chunk => this.executeInWorker({ type: 'recordEpisodes', episodes: chunk })));
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Multi-file pattern matching (parallel pretrain)
|
|
154
|
-
*/
|
|
155
|
-
async matchPatternsParallel(files) {
|
|
156
|
-
if (files.length < this.config.batchThreshold || !this.config.enabled) {
|
|
157
|
-
return [];
|
|
158
|
-
}
|
|
159
|
-
const chunkSize = Math.ceil(files.length / this.config.numWorkers);
|
|
160
|
-
const chunks = [];
|
|
161
|
-
for (let i = 0; i < files.length; i += chunkSize) {
|
|
162
|
-
chunks.push(files.slice(i, i + chunkSize));
|
|
163
|
-
}
|
|
164
|
-
const results = await Promise.all(chunks.map(chunk => this.executeInWorker({ type: 'matchPatterns', files: chunk })));
|
|
165
|
-
return results.flat();
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Background memory indexing (non-blocking)
|
|
169
|
-
*/
|
|
170
|
-
async indexMemoriesBackground(memories) {
|
|
171
|
-
if (memories.length === 0 || !this.config.enabled)
|
|
172
|
-
return;
|
|
173
|
-
// Fire and forget - non-blocking
|
|
174
|
-
this.executeInWorker({ type: 'indexMemories', memories }).catch(() => { });
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Parallel similarity search with sharding
|
|
178
|
-
*/
|
|
179
|
-
async searchParallel(query, topK = 5) {
|
|
180
|
-
if (!this.config.enabled)
|
|
181
|
-
return [];
|
|
182
|
-
// Each worker searches its shard
|
|
183
|
-
const shardResults = await Promise.all(this.workers.map((_, i) => this.executeInWorker({
|
|
184
|
-
type: 'search',
|
|
185
|
-
query,
|
|
186
|
-
topK,
|
|
187
|
-
shardId: i,
|
|
188
|
-
})));
|
|
189
|
-
// Merge and sort results
|
|
190
|
-
return shardResults
|
|
191
|
-
.flat()
|
|
192
|
-
.sort((a, b) => b.score - a.score)
|
|
193
|
-
.slice(0, topK);
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Multi-file AST analysis for routing
|
|
197
|
-
*/
|
|
198
|
-
async analyzeFilesParallel(files) {
|
|
199
|
-
if (files.length < this.config.batchThreshold || !this.config.enabled) {
|
|
200
|
-
return new Map();
|
|
201
|
-
}
|
|
202
|
-
const chunkSize = Math.ceil(files.length / this.config.numWorkers);
|
|
203
|
-
const chunks = [];
|
|
204
|
-
for (let i = 0; i < files.length; i += chunkSize) {
|
|
205
|
-
chunks.push(files.slice(i, i + chunkSize));
|
|
206
|
-
}
|
|
207
|
-
const results = await Promise.all(chunks.map(chunk => this.executeInWorker({
|
|
208
|
-
type: 'analyzeFiles',
|
|
209
|
-
files: chunk,
|
|
210
|
-
})));
|
|
211
|
-
return new Map(results.flat());
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Parallel git commit analysis for co-edit detection
|
|
215
|
-
*/
|
|
216
|
-
async analyzeCommitsParallel(commits) {
|
|
217
|
-
if (commits.length < this.config.batchThreshold || !this.config.enabled) {
|
|
218
|
-
return [];
|
|
219
|
-
}
|
|
220
|
-
const chunkSize = Math.ceil(commits.length / this.config.numWorkers);
|
|
221
|
-
const chunks = [];
|
|
222
|
-
for (let i = 0; i < commits.length; i += chunkSize) {
|
|
223
|
-
chunks.push(commits.slice(i, i + chunkSize));
|
|
224
|
-
}
|
|
225
|
-
const results = await Promise.all(chunks.map(chunk => this.executeInWorker({ type: 'analyzeCommits', commits: chunk })));
|
|
226
|
-
return results.flat();
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Get worker pool stats
|
|
230
|
-
*/
|
|
231
|
-
getStats() {
|
|
232
|
-
return {
|
|
233
|
-
enabled: this.config.enabled,
|
|
234
|
-
workers: this.workers.length,
|
|
235
|
-
busy: this.busyWorkers.size,
|
|
236
|
-
queued: this.taskQueue.length,
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Shutdown worker pool
|
|
241
|
-
*/
|
|
242
|
-
async shutdown() {
|
|
243
|
-
await Promise.all(this.workers.map(w => w.terminate()));
|
|
244
|
-
this.workers = [];
|
|
245
|
-
this.busyWorkers.clear();
|
|
246
|
-
this.taskQueue = [];
|
|
247
|
-
this.initialized = false;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
exports.ParallelIntelligence = ParallelIntelligence;
|
|
251
|
-
// ============================================================================
|
|
252
|
-
// Worker Thread Code
|
|
253
|
-
// ============================================================================
|
|
254
|
-
if (!worker_threads_1.isMainThread && worker_threads_1.parentPort) {
|
|
255
|
-
// This code runs in worker threads
|
|
256
|
-
const { workerId } = worker_threads_1.workerData;
|
|
257
|
-
worker_threads_1.parentPort.on('message', async (task) => {
|
|
258
|
-
try {
|
|
259
|
-
let result;
|
|
260
|
-
switch (task.type) {
|
|
261
|
-
case 'recordEpisodes':
|
|
262
|
-
// Process episode batch
|
|
263
|
-
result = await processEpisodes(task.episodes);
|
|
264
|
-
break;
|
|
265
|
-
case 'matchPatterns':
|
|
266
|
-
// Match patterns in files
|
|
267
|
-
result = await matchPatterns(task.files);
|
|
268
|
-
break;
|
|
269
|
-
case 'indexMemories':
|
|
270
|
-
// Index memories
|
|
271
|
-
result = await indexMemories(task.memories);
|
|
272
|
-
break;
|
|
273
|
-
case 'search':
|
|
274
|
-
// Search shard
|
|
275
|
-
result = await searchShard(task.query, task.topK, task.shardId);
|
|
276
|
-
break;
|
|
277
|
-
case 'analyzeFiles':
|
|
278
|
-
// Analyze file ASTs
|
|
279
|
-
result = await analyzeFiles(task.files);
|
|
280
|
-
break;
|
|
281
|
-
case 'analyzeCommits':
|
|
282
|
-
// Analyze git commits
|
|
283
|
-
result = await analyzeCommits(task.commits);
|
|
284
|
-
break;
|
|
285
|
-
default:
|
|
286
|
-
throw new Error(`Unknown task type: ${task.type}`);
|
|
287
|
-
}
|
|
288
|
-
worker_threads_1.parentPort.postMessage({ data: result });
|
|
289
|
-
}
|
|
290
|
-
catch (error) {
|
|
291
|
-
worker_threads_1.parentPort.postMessage({ error: error.message });
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
// Worker task implementations
|
|
295
|
-
async function processEpisodes(episodes) {
|
|
296
|
-
// Embed and process episodes
|
|
297
|
-
// In a real implementation, this would use the embedder and update Q-values
|
|
298
|
-
return episodes.length;
|
|
299
|
-
}
|
|
300
|
-
async function matchPatterns(files) {
|
|
301
|
-
// Match patterns in files
|
|
302
|
-
// Would read files and extract patterns
|
|
303
|
-
return files.map(file => ({
|
|
304
|
-
file,
|
|
305
|
-
patterns: [],
|
|
306
|
-
}));
|
|
307
|
-
}
|
|
308
|
-
async function indexMemories(memories) {
|
|
309
|
-
// Index memories in background
|
|
310
|
-
return memories.length;
|
|
311
|
-
}
|
|
312
|
-
async function searchShard(query, topK, shardId) {
|
|
313
|
-
// Search this worker's shard
|
|
314
|
-
return [];
|
|
315
|
-
}
|
|
316
|
-
async function analyzeFiles(files) {
|
|
317
|
-
// Analyze file ASTs
|
|
318
|
-
return files.map(f => [f, { agent: 'coder', confidence: 0.5 }]);
|
|
319
|
-
}
|
|
320
|
-
async function analyzeCommits(commits) {
|
|
321
|
-
// Analyze git commits for co-edit patterns
|
|
322
|
-
return [];
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
// ============================================================================
|
|
326
|
-
// Singleton for easy access
|
|
327
|
-
// ============================================================================
|
|
328
|
-
let instance = null;
|
|
329
|
-
function getParallelIntelligence(config) {
|
|
330
|
-
if (!instance) {
|
|
331
|
-
instance = new ParallelIntelligence(config);
|
|
332
|
-
}
|
|
333
|
-
return instance;
|
|
334
|
-
}
|
|
335
|
-
async function initParallelIntelligence(config) {
|
|
336
|
-
const pi = getParallelIntelligence(config);
|
|
337
|
-
await pi.init();
|
|
338
|
-
return pi;
|
|
339
|
-
}
|
|
340
|
-
exports.default = ParallelIntelligence;
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parallel Workers - Extended worker capabilities for RuVector hooks
|
|
3
|
-
*
|
|
4
|
-
* Provides parallel processing for advanced operations:
|
|
5
|
-
*
|
|
6
|
-
* 1. SPECULATIVE PRE-COMPUTATION
|
|
7
|
-
* - Pre-embed likely next files based on co-edit patterns
|
|
8
|
-
* - Warm model cache before operations
|
|
9
|
-
* - Predictive route caching
|
|
10
|
-
*
|
|
11
|
-
* 2. REAL-TIME CODE ANALYSIS
|
|
12
|
-
* - Multi-file AST parsing with tree-sitter
|
|
13
|
-
* - Cross-file type inference
|
|
14
|
-
* - Live complexity metrics
|
|
15
|
-
* - Dependency graph updates
|
|
16
|
-
*
|
|
17
|
-
* 3. ADVANCED LEARNING
|
|
18
|
-
* - Distributed trajectory replay
|
|
19
|
-
* - Parallel SONA micro-LoRA updates
|
|
20
|
-
* - Background EWC consolidation
|
|
21
|
-
* - Online pattern clustering
|
|
22
|
-
*
|
|
23
|
-
* 4. INTELLIGENT RETRIEVAL
|
|
24
|
-
* - Parallel RAG chunking and retrieval
|
|
25
|
-
* - Sharded similarity search
|
|
26
|
-
* - Context relevance ranking
|
|
27
|
-
* - Semantic deduplication
|
|
28
|
-
*
|
|
29
|
-
* 5. SECURITY & QUALITY
|
|
30
|
-
* - Parallel SAST scanning
|
|
31
|
-
* - Multi-rule linting
|
|
32
|
-
* - Vulnerability detection
|
|
33
|
-
* - Code smell analysis
|
|
34
|
-
*
|
|
35
|
-
* 6. GIT INTELLIGENCE
|
|
36
|
-
* - Parallel blame analysis
|
|
37
|
-
* - Branch comparison
|
|
38
|
-
* - Merge conflict prediction
|
|
39
|
-
* - Code churn metrics
|
|
40
|
-
*/
|
|
41
|
-
import { SecurityFinding } from '../analysis/security';
|
|
42
|
-
export interface WorkerPoolConfig {
|
|
43
|
-
numWorkers?: number;
|
|
44
|
-
enabled?: boolean;
|
|
45
|
-
taskTimeout?: number;
|
|
46
|
-
maxQueueSize?: number;
|
|
47
|
-
}
|
|
48
|
-
export interface SpeculativeEmbedding {
|
|
49
|
-
file: string;
|
|
50
|
-
embedding: number[];
|
|
51
|
-
confidence: number;
|
|
52
|
-
timestamp: number;
|
|
53
|
-
}
|
|
54
|
-
export interface ASTAnalysis {
|
|
55
|
-
file: string;
|
|
56
|
-
language: string;
|
|
57
|
-
complexity: number;
|
|
58
|
-
functions: string[];
|
|
59
|
-
imports: string[];
|
|
60
|
-
exports: string[];
|
|
61
|
-
dependencies: string[];
|
|
62
|
-
}
|
|
63
|
-
export type { SecurityFinding };
|
|
64
|
-
export interface ContextChunk {
|
|
65
|
-
content: string;
|
|
66
|
-
source: string;
|
|
67
|
-
relevance: number;
|
|
68
|
-
embedding?: number[];
|
|
69
|
-
}
|
|
70
|
-
export interface GitBlame {
|
|
71
|
-
file: string;
|
|
72
|
-
lines: Array<{
|
|
73
|
-
line: number;
|
|
74
|
-
author: string;
|
|
75
|
-
date: string;
|
|
76
|
-
commit: string;
|
|
77
|
-
}>;
|
|
78
|
-
}
|
|
79
|
-
export interface CodeChurn {
|
|
80
|
-
file: string;
|
|
81
|
-
additions: number;
|
|
82
|
-
deletions: number;
|
|
83
|
-
commits: number;
|
|
84
|
-
authors: string[];
|
|
85
|
-
lastModified: string;
|
|
86
|
-
}
|
|
87
|
-
export declare class ExtendedWorkerPool {
|
|
88
|
-
private workers;
|
|
89
|
-
private taskQueue;
|
|
90
|
-
private busyWorkers;
|
|
91
|
-
private config;
|
|
92
|
-
private initialized;
|
|
93
|
-
private speculativeCache;
|
|
94
|
-
private astCache;
|
|
95
|
-
constructor(config?: WorkerPoolConfig);
|
|
96
|
-
init(): Promise<void>;
|
|
97
|
-
private getWorkerCode;
|
|
98
|
-
private getWorkerHandlers;
|
|
99
|
-
private handleWorkerResult;
|
|
100
|
-
private processQueue;
|
|
101
|
-
private execute;
|
|
102
|
-
/**
|
|
103
|
-
* Pre-embed files likely to be edited next based on co-edit patterns
|
|
104
|
-
* Hook: session-start, post-edit
|
|
105
|
-
*/
|
|
106
|
-
speculativeEmbed(currentFile: string, coEditGraph: Map<string, string[]>): Promise<SpeculativeEmbedding[]>;
|
|
107
|
-
/**
|
|
108
|
-
* Analyze AST of multiple files in parallel
|
|
109
|
-
* Hook: pre-edit, route
|
|
110
|
-
*/
|
|
111
|
-
analyzeAST(files: string[]): Promise<ASTAnalysis[]>;
|
|
112
|
-
/**
|
|
113
|
-
* Analyze code complexity for multiple files
|
|
114
|
-
* Hook: post-edit, session-end
|
|
115
|
-
*/
|
|
116
|
-
analyzeComplexity(files: string[]): Promise<Array<{
|
|
117
|
-
file: string;
|
|
118
|
-
lines: number;
|
|
119
|
-
nonEmptyLines: number;
|
|
120
|
-
cyclomaticComplexity: number;
|
|
121
|
-
functions: number;
|
|
122
|
-
avgFunctionSize: number;
|
|
123
|
-
}>>;
|
|
124
|
-
/**
|
|
125
|
-
* Build dependency graph from entry points
|
|
126
|
-
* Hook: session-start
|
|
127
|
-
*/
|
|
128
|
-
buildDependencyGraph(entryPoints: string[]): Promise<Record<string, string[]>>;
|
|
129
|
-
/**
|
|
130
|
-
* Scan files for security vulnerabilities
|
|
131
|
-
* Hook: pre-command (before commit), post-edit
|
|
132
|
-
*/
|
|
133
|
-
securityScan(files: string[], rules?: string[]): Promise<SecurityFinding[]>;
|
|
134
|
-
/**
|
|
135
|
-
* Retrieve relevant context chunks in parallel
|
|
136
|
-
* Hook: suggest-context, recall
|
|
137
|
-
*/
|
|
138
|
-
ragRetrieve(query: string, chunks: ContextChunk[], topK?: number): Promise<ContextChunk[]>;
|
|
139
|
-
/**
|
|
140
|
-
* Rank context items by relevance to query
|
|
141
|
-
* Hook: suggest-context
|
|
142
|
-
*/
|
|
143
|
-
rankContext(context: string[], query: string): Promise<Array<{
|
|
144
|
-
index: number;
|
|
145
|
-
content: string;
|
|
146
|
-
relevance: number;
|
|
147
|
-
}>>;
|
|
148
|
-
/**
|
|
149
|
-
* Deduplicate similar items
|
|
150
|
-
* Hook: remember, suggest-context
|
|
151
|
-
*/
|
|
152
|
-
deduplicate(items: string[], threshold?: number): Promise<string[]>;
|
|
153
|
-
/**
|
|
154
|
-
* Get blame information for files in parallel
|
|
155
|
-
* Hook: pre-edit (for context), coedit
|
|
156
|
-
*/
|
|
157
|
-
gitBlame(files: string[]): Promise<GitBlame[]>;
|
|
158
|
-
/**
|
|
159
|
-
* Analyze code churn for files
|
|
160
|
-
* Hook: session-start, route
|
|
161
|
-
*/
|
|
162
|
-
gitChurn(files: string[], since?: string): Promise<CodeChurn[]>;
|
|
163
|
-
getStats(): {
|
|
164
|
-
enabled: boolean;
|
|
165
|
-
workers: number;
|
|
166
|
-
busy: number;
|
|
167
|
-
queued: number;
|
|
168
|
-
speculativeCacheSize: number;
|
|
169
|
-
astCacheSize: number;
|
|
170
|
-
};
|
|
171
|
-
clearCaches(): void;
|
|
172
|
-
shutdown(): Promise<void>;
|
|
173
|
-
}
|
|
174
|
-
export declare function getExtendedWorkerPool(config?: WorkerPoolConfig): ExtendedWorkerPool;
|
|
175
|
-
export declare function initExtendedWorkerPool(config?: WorkerPoolConfig): Promise<ExtendedWorkerPool>;
|
|
176
|
-
export default ExtendedWorkerPool;
|
|
177
|
-
//# sourceMappingURL=parallel-workers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parallel-workers.d.ts","sourceRoot":"","sources":["../../src/core/parallel-workers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAQH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAMvD,MAAM,WAAW,gBAAgB;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,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