agentic-flow 2.0.1-alpha.15 → 2.0.1-alpha.17
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/CHANGELOG.md +62 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/mcp/fastmcp/tools/hooks/intelligence-bridge.d.ts +203 -0
- package/dist/mcp/fastmcp/tools/hooks/intelligence-bridge.d.ts.map +1 -1
- package/dist/mcp/fastmcp/tools/hooks/intelligence-bridge.js +418 -0
- package/dist/mcp/fastmcp/tools/hooks/intelligence-bridge.js.map +1 -1
- package/package.json +2 -2
- package/wasm/reasoningbank/reasoningbank_wasm_bg.js +2 -2
- package/wasm/reasoningbank/reasoningbank_wasm_bg.wasm +0 -0
|
@@ -100,5 +100,208 @@ export declare function forceLearningCycle(): Promise<string>;
|
|
|
100
100
|
* Compute attention-weighted similarity for advanced routing
|
|
101
101
|
*/
|
|
102
102
|
export declare function computeAttentionSimilarity(query: Float32Array, candidates: Float32Array[]): Promise<number[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Queue an episode for batch Q-learning (3-4x faster)
|
|
105
|
+
* Episodes are batched and processed in parallel
|
|
106
|
+
*/
|
|
107
|
+
export declare function queueEpisode(episode: {
|
|
108
|
+
state: string;
|
|
109
|
+
action: string;
|
|
110
|
+
reward: number;
|
|
111
|
+
nextState: string;
|
|
112
|
+
done: boolean;
|
|
113
|
+
}): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Flush queued episodes for batch processing
|
|
116
|
+
* Processes in parallel with worker threads
|
|
117
|
+
*/
|
|
118
|
+
export declare function flushEpisodeBatch(): Promise<{
|
|
119
|
+
processed: number;
|
|
120
|
+
parallelEnabled: boolean;
|
|
121
|
+
}>;
|
|
122
|
+
/**
|
|
123
|
+
* Match patterns in parallel across multiple files
|
|
124
|
+
* Provides 3-4x faster pretrain
|
|
125
|
+
*/
|
|
126
|
+
export declare function matchPatternsParallel(files: Array<{
|
|
127
|
+
path: string;
|
|
128
|
+
content: string;
|
|
129
|
+
}>): Promise<Array<{
|
|
130
|
+
path: string;
|
|
131
|
+
patterns: string[];
|
|
132
|
+
similarity: number;
|
|
133
|
+
}>>;
|
|
134
|
+
/**
|
|
135
|
+
* Index memories in background (non-blocking hooks)
|
|
136
|
+
*/
|
|
137
|
+
export declare function indexMemoriesBackground(memories: Array<{
|
|
138
|
+
id: string;
|
|
139
|
+
text: string;
|
|
140
|
+
metadata?: Record<string, any>;
|
|
141
|
+
}>): Promise<{
|
|
142
|
+
queued: number;
|
|
143
|
+
processing: boolean;
|
|
144
|
+
}>;
|
|
145
|
+
/**
|
|
146
|
+
* Parallel similarity search with sharding
|
|
147
|
+
*/
|
|
148
|
+
export declare function searchParallel(query: string, topK?: number): Promise<Array<{
|
|
149
|
+
id: string;
|
|
150
|
+
text: string;
|
|
151
|
+
similarity: number;
|
|
152
|
+
}>>;
|
|
153
|
+
/**
|
|
154
|
+
* Analyze multiple files in parallel for routing
|
|
155
|
+
*/
|
|
156
|
+
export declare function analyzeFilesParallel(files: Array<{
|
|
157
|
+
path: string;
|
|
158
|
+
content: string;
|
|
159
|
+
}>): Promise<Array<{
|
|
160
|
+
path: string;
|
|
161
|
+
agent: string;
|
|
162
|
+
confidence: number;
|
|
163
|
+
}>>;
|
|
164
|
+
/**
|
|
165
|
+
* Analyze git commits in parallel for co-edit detection
|
|
166
|
+
*/
|
|
167
|
+
export declare function analyzeCommitsParallel(commits: Array<{
|
|
168
|
+
hash: string;
|
|
169
|
+
message: string;
|
|
170
|
+
files: string[];
|
|
171
|
+
}>): Promise<Array<{
|
|
172
|
+
hash: string;
|
|
173
|
+
coEditGroups: string[][];
|
|
174
|
+
patterns: string[];
|
|
175
|
+
}>>;
|
|
176
|
+
/**
|
|
177
|
+
* Get parallel stats
|
|
178
|
+
*/
|
|
179
|
+
export declare function getParallelStats(): Promise<{
|
|
180
|
+
parallelEnabled: boolean;
|
|
181
|
+
parallelWorkers: number;
|
|
182
|
+
parallelBusy: number;
|
|
183
|
+
parallelQueued: number;
|
|
184
|
+
}>;
|
|
185
|
+
/**
|
|
186
|
+
* Speculatively pre-embed files that are likely to be accessed
|
|
187
|
+
* Call in post-edit hook for related files
|
|
188
|
+
*/
|
|
189
|
+
export declare function speculativeEmbed(files: string[]): Promise<{
|
|
190
|
+
queued: number;
|
|
191
|
+
}>;
|
|
192
|
+
/**
|
|
193
|
+
* Analyze AST of multiple files in parallel
|
|
194
|
+
* For pre-edit and route hooks
|
|
195
|
+
*/
|
|
196
|
+
export declare function analyzeAST(files: Array<{
|
|
197
|
+
path: string;
|
|
198
|
+
content: string;
|
|
199
|
+
}>): Promise<Array<{
|
|
200
|
+
path: string;
|
|
201
|
+
functions: string[];
|
|
202
|
+
imports: string[];
|
|
203
|
+
exports: string[];
|
|
204
|
+
}>>;
|
|
205
|
+
/**
|
|
206
|
+
* Analyze code complexity metrics in parallel
|
|
207
|
+
* For session-end hook to track quality
|
|
208
|
+
*/
|
|
209
|
+
export declare function analyzeComplexity(files: string[]): Promise<Array<{
|
|
210
|
+
path: string;
|
|
211
|
+
cyclomatic: number;
|
|
212
|
+
cognitive: number;
|
|
213
|
+
lines: number;
|
|
214
|
+
}>>;
|
|
215
|
+
/**
|
|
216
|
+
* Build dependency graph from import statements
|
|
217
|
+
* For session-start hook context
|
|
218
|
+
*/
|
|
219
|
+
export declare function buildDependencyGraph(files: string[]): Promise<{
|
|
220
|
+
nodes: string[];
|
|
221
|
+
edges: Array<{
|
|
222
|
+
from: string;
|
|
223
|
+
to: string;
|
|
224
|
+
}>;
|
|
225
|
+
}>;
|
|
226
|
+
/**
|
|
227
|
+
* Parallel security scan (SAST)
|
|
228
|
+
* For pre-command hook before commits
|
|
229
|
+
*/
|
|
230
|
+
export declare function securityScan(files: string[]): Promise<Array<{
|
|
231
|
+
path: string;
|
|
232
|
+
severity: string;
|
|
233
|
+
message: string;
|
|
234
|
+
line: number;
|
|
235
|
+
}>>;
|
|
236
|
+
/**
|
|
237
|
+
* RAG retrieval with parallel chunk processing
|
|
238
|
+
* For recall hook
|
|
239
|
+
*/
|
|
240
|
+
export declare function ragRetrieve(query: string, chunks: Array<{
|
|
241
|
+
id: string;
|
|
242
|
+
text: string;
|
|
243
|
+
}>, topK?: number): Promise<Array<{
|
|
244
|
+
id: string;
|
|
245
|
+
text: string;
|
|
246
|
+
score: number;
|
|
247
|
+
}>>;
|
|
248
|
+
/**
|
|
249
|
+
* Rank context by relevance
|
|
250
|
+
* For suggest-context hook
|
|
251
|
+
*/
|
|
252
|
+
export declare function rankContext(query: string, contexts: Array<{
|
|
253
|
+
id: string;
|
|
254
|
+
content: string;
|
|
255
|
+
}>): Promise<Array<{
|
|
256
|
+
id: string;
|
|
257
|
+
relevance: number;
|
|
258
|
+
}>>;
|
|
259
|
+
/**
|
|
260
|
+
* Semantic deduplication
|
|
261
|
+
* For remember hook to avoid storing duplicates
|
|
262
|
+
*/
|
|
263
|
+
export declare function deduplicate(texts: string[], threshold?: number): Promise<{
|
|
264
|
+
unique: string[];
|
|
265
|
+
duplicateGroups: number[][];
|
|
266
|
+
}>;
|
|
267
|
+
/**
|
|
268
|
+
* Parallel git blame analysis
|
|
269
|
+
* For co-edit hook
|
|
270
|
+
*/
|
|
271
|
+
export declare function gitBlame(files: string[]): Promise<Array<{
|
|
272
|
+
path: string;
|
|
273
|
+
authors: Array<{
|
|
274
|
+
name: string;
|
|
275
|
+
lines: number;
|
|
276
|
+
}>;
|
|
277
|
+
}>>;
|
|
278
|
+
/**
|
|
279
|
+
* Code churn metrics for routing decisions
|
|
280
|
+
* For route hook to prioritize high-churn files
|
|
281
|
+
*/
|
|
282
|
+
export declare function gitChurn(patterns: string[], since?: string): Promise<Array<{
|
|
283
|
+
path: string;
|
|
284
|
+
commits: number;
|
|
285
|
+
additions: number;
|
|
286
|
+
deletions: number;
|
|
287
|
+
}>>;
|
|
288
|
+
/**
|
|
289
|
+
* Get attention mechanism for specific use case
|
|
290
|
+
*/
|
|
291
|
+
export declare function getAttentionForUseCase(useCase: 'pattern-matching' | 'agent-routing' | 'code-structure' | 'context-summary' | 'multi-agent'): Promise<{
|
|
292
|
+
type: string;
|
|
293
|
+
instance: any;
|
|
294
|
+
}>;
|
|
295
|
+
/**
|
|
296
|
+
* Parallel attention compute across multiple queries
|
|
297
|
+
*/
|
|
298
|
+
export declare function parallelAttentionCompute(queries: Float32Array[], keys: Float32Array[], values: Float32Array[], type?: 'hyperbolic' | 'flash' | 'moe'): Promise<Float32Array[]>;
|
|
299
|
+
/**
|
|
300
|
+
* Get extended worker pool stats
|
|
301
|
+
*/
|
|
302
|
+
export declare function getExtendedWorkerStats(): Promise<{
|
|
303
|
+
initialized: boolean;
|
|
304
|
+
operations: string[];
|
|
305
|
+
}>;
|
|
103
306
|
export type { AgentRoutingResult, Trajectory, LearningOutcome };
|
|
104
307
|
//# sourceMappingURL=intelligence-bridge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intelligence-bridge.d.ts","sourceRoot":"","sources":["../../../../../src/mcp/fastmcp/tools/hooks/intelligence-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,oBAAoB,EAGpB,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,eAAe,EACrB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAwB,KAAK,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAqB7G;;GAEG;AACH,wBAAgB,QAAQ,IAAI,iBAAiB,CAK5C;AAmBD;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAWrE;AA6CD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IACR,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GACA,OAAO,CA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AAED;;GAEG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC;IACpD,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE;QACf,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC,CAyBD;AAED;;GAEG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAG1D;AAED;;GAEG;AACH,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,YAAY,EACnB,UAAU,EAAE,YAAY,EAAE,GACzB,OAAO,CAAC,MAAM,EAAE,CAAC,CAOnB;AAGD,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"intelligence-bridge.d.ts","sourceRoot":"","sources":["../../../../../src/mcp/fastmcp/tools/hooks/intelligence-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,oBAAoB,EAGpB,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,eAAe,EACrB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAwB,KAAK,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAqB7G;;GAEG;AACH,wBAAgB,QAAQ,IAAI,iBAAiB,CAK5C;AAmBD;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAWrE;AA6CD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IACR,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAA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MnF;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,MAAM,EAAE,EAClB,KAAK,GAAE,MAAsB,GAC5B,OAAO,CAAC,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAMzF;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,kBAAkB,GAAG,eAAe,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,aAAa,GACnG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAA;CAAE,CAAC,CAqB1C;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,YAAY,EAAE,EACvB,IAAI,EAAE,YAAY,EAAE,EACpB,MAAM,EAAE,YAAY,EAAE,EACtB,IAAI,GAAE,YAAY,GAAG,OAAO,GAAG,KAAa,GAC3C,OAAO,CAAC,YAAY,EAAE,CAAC,CAUzB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC;IACtD,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC,CAYD;AAGD,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -293,4 +293,422 @@ export async function computeAttentionSimilarity(query, candidates) {
|
|
|
293
293
|
const result = await intelligence.computeAttentionAsync(query, candidates, candidates);
|
|
294
294
|
return Array.from(result);
|
|
295
295
|
}
|
|
296
|
+
// ============================================================================
|
|
297
|
+
// Parallel Intelligence (ruvector@0.1.62+)
|
|
298
|
+
// ============================================================================
|
|
299
|
+
// Lazy load ruvector for parallel features
|
|
300
|
+
let ruvectorModule = null;
|
|
301
|
+
let parallelEngine = null;
|
|
302
|
+
let episodeQueue = [];
|
|
303
|
+
/**
|
|
304
|
+
* Get the parallel intelligence engine from ruvector
|
|
305
|
+
*/
|
|
306
|
+
async function getParallelEngine() {
|
|
307
|
+
if (parallelEngine)
|
|
308
|
+
return parallelEngine;
|
|
309
|
+
try {
|
|
310
|
+
ruvectorModule = await import('ruvector');
|
|
311
|
+
if (ruvectorModule.IntelligenceEngine) {
|
|
312
|
+
parallelEngine = new ruvectorModule.IntelligenceEngine({ enableOnnx: true });
|
|
313
|
+
console.log('[IntelligenceBridge] Parallel engine initialized (7 workers)');
|
|
314
|
+
}
|
|
315
|
+
return parallelEngine;
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
console.warn('[IntelligenceBridge] Parallel engine not available:', error);
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Queue an episode for batch Q-learning (3-4x faster)
|
|
324
|
+
* Episodes are batched and processed in parallel
|
|
325
|
+
*/
|
|
326
|
+
export async function queueEpisode(episode) {
|
|
327
|
+
const engine = await getParallelEngine();
|
|
328
|
+
if (engine?.queueEpisode) {
|
|
329
|
+
engine.queueEpisode(episode);
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
// Fallback: queue locally
|
|
333
|
+
episodeQueue.push(episode);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Flush queued episodes for batch processing
|
|
338
|
+
* Processes in parallel with worker threads
|
|
339
|
+
*/
|
|
340
|
+
export async function flushEpisodeBatch() {
|
|
341
|
+
const engine = await getParallelEngine();
|
|
342
|
+
if (engine?.flushEpisodeBatch) {
|
|
343
|
+
await engine.flushEpisodeBatch();
|
|
344
|
+
const stats = engine.getStats();
|
|
345
|
+
return {
|
|
346
|
+
processed: stats.totalEpisodes || 0,
|
|
347
|
+
parallelEnabled: stats.parallelEnabled || false,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
// Fallback: process locally
|
|
351
|
+
const processed = episodeQueue.length;
|
|
352
|
+
episodeQueue = [];
|
|
353
|
+
return { processed, parallelEnabled: false };
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Match patterns in parallel across multiple files
|
|
357
|
+
* Provides 3-4x faster pretrain
|
|
358
|
+
*/
|
|
359
|
+
export async function matchPatternsParallel(files) {
|
|
360
|
+
const engine = await getParallelEngine();
|
|
361
|
+
if (engine?.matchPatternsParallel) {
|
|
362
|
+
return engine.matchPatternsParallel(files);
|
|
363
|
+
}
|
|
364
|
+
// Fallback: sequential matching with embeddings
|
|
365
|
+
const service = getEmbeddingServiceInstance();
|
|
366
|
+
const results = [];
|
|
367
|
+
for (const file of files) {
|
|
368
|
+
const embedding = await service.embed(file.content.slice(0, 1000));
|
|
369
|
+
results.push({
|
|
370
|
+
path: file.path,
|
|
371
|
+
patterns: detectPatterns(file.content),
|
|
372
|
+
similarity: 0.5,
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
return results;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Index memories in background (non-blocking hooks)
|
|
379
|
+
*/
|
|
380
|
+
export async function indexMemoriesBackground(memories) {
|
|
381
|
+
const engine = await getParallelEngine();
|
|
382
|
+
if (engine?.indexMemoriesBackground) {
|
|
383
|
+
return engine.indexMemoriesBackground(memories);
|
|
384
|
+
}
|
|
385
|
+
// Fallback: queue for next batch
|
|
386
|
+
const service = getEmbeddingServiceInstance();
|
|
387
|
+
// Non-blocking: just queue, don't await
|
|
388
|
+
Promise.all(memories.map(m => service.embed(m.text))).catch(() => { });
|
|
389
|
+
return { queued: memories.length, processing: true };
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Parallel similarity search with sharding
|
|
393
|
+
*/
|
|
394
|
+
export async function searchParallel(query, topK = 10) {
|
|
395
|
+
const engine = await getParallelEngine();
|
|
396
|
+
if (engine?.searchParallel) {
|
|
397
|
+
return engine.searchParallel(query, topK);
|
|
398
|
+
}
|
|
399
|
+
// Fallback: use EmbeddingService semantic search
|
|
400
|
+
const service = getEmbeddingServiceInstance();
|
|
401
|
+
try {
|
|
402
|
+
const results = await service.semanticSearch(query, topK);
|
|
403
|
+
return results.map(r => ({
|
|
404
|
+
id: String(r.index),
|
|
405
|
+
text: r.text,
|
|
406
|
+
similarity: r.similarity,
|
|
407
|
+
}));
|
|
408
|
+
}
|
|
409
|
+
catch {
|
|
410
|
+
return [];
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Analyze multiple files in parallel for routing
|
|
415
|
+
*/
|
|
416
|
+
export async function analyzeFilesParallel(files) {
|
|
417
|
+
const engine = await getParallelEngine();
|
|
418
|
+
if (engine?.analyzeFilesParallel) {
|
|
419
|
+
return engine.analyzeFilesParallel(files);
|
|
420
|
+
}
|
|
421
|
+
// Fallback: parallel with Promise.all
|
|
422
|
+
const results = await Promise.all(files.map(async (file) => {
|
|
423
|
+
const routing = await routeTaskIntelligent(`analyze ${file.path}`, { file: file.path });
|
|
424
|
+
return {
|
|
425
|
+
path: file.path,
|
|
426
|
+
agent: routing.agent,
|
|
427
|
+
confidence: routing.confidence,
|
|
428
|
+
};
|
|
429
|
+
}));
|
|
430
|
+
return results;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Analyze git commits in parallel for co-edit detection
|
|
434
|
+
*/
|
|
435
|
+
export async function analyzeCommitsParallel(commits) {
|
|
436
|
+
const engine = await getParallelEngine();
|
|
437
|
+
if (engine?.analyzeCommitsParallel) {
|
|
438
|
+
return engine.analyzeCommitsParallel(commits);
|
|
439
|
+
}
|
|
440
|
+
// Fallback: detect co-edit patterns from file groups
|
|
441
|
+
return commits.map(commit => ({
|
|
442
|
+
hash: commit.hash,
|
|
443
|
+
coEditGroups: [commit.files], // Simple: treat all files as one group
|
|
444
|
+
patterns: detectCommitPatterns(commit.message),
|
|
445
|
+
}));
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Get parallel stats
|
|
449
|
+
*/
|
|
450
|
+
export async function getParallelStats() {
|
|
451
|
+
const engine = await getParallelEngine();
|
|
452
|
+
if (engine?.getStats) {
|
|
453
|
+
const stats = engine.getStats();
|
|
454
|
+
return {
|
|
455
|
+
parallelEnabled: stats.parallelEnabled || false,
|
|
456
|
+
parallelWorkers: stats.parallelWorkers || 0,
|
|
457
|
+
parallelBusy: stats.parallelBusy || 0,
|
|
458
|
+
parallelQueued: stats.parallelQueued || 0,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
return {
|
|
462
|
+
parallelEnabled: false,
|
|
463
|
+
parallelWorkers: 0,
|
|
464
|
+
parallelBusy: 0,
|
|
465
|
+
parallelQueued: 0,
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
// Helper: detect patterns in file content
|
|
469
|
+
function detectPatterns(content) {
|
|
470
|
+
const patterns = [];
|
|
471
|
+
if (content.includes('async'))
|
|
472
|
+
patterns.push('async-code');
|
|
473
|
+
if (content.includes('test') || content.includes('describe'))
|
|
474
|
+
patterns.push('test-file');
|
|
475
|
+
if (content.includes('class'))
|
|
476
|
+
patterns.push('oop');
|
|
477
|
+
if (content.includes('import') || content.includes('export'))
|
|
478
|
+
patterns.push('module');
|
|
479
|
+
if (content.includes('interface') || content.includes('type '))
|
|
480
|
+
patterns.push('typescript');
|
|
481
|
+
return patterns;
|
|
482
|
+
}
|
|
483
|
+
// Helper: detect patterns in commit messages
|
|
484
|
+
function detectCommitPatterns(message) {
|
|
485
|
+
const patterns = [];
|
|
486
|
+
const lower = message.toLowerCase();
|
|
487
|
+
if (lower.includes('fix'))
|
|
488
|
+
patterns.push('bugfix');
|
|
489
|
+
if (lower.includes('feat') || lower.includes('add'))
|
|
490
|
+
patterns.push('feature');
|
|
491
|
+
if (lower.includes('refactor'))
|
|
492
|
+
patterns.push('refactor');
|
|
493
|
+
if (lower.includes('test'))
|
|
494
|
+
patterns.push('testing');
|
|
495
|
+
if (lower.includes('doc'))
|
|
496
|
+
patterns.push('documentation');
|
|
497
|
+
return patterns;
|
|
498
|
+
}
|
|
499
|
+
// ============================================================================
|
|
500
|
+
// Extended Worker Pool (ruvector@0.1.63+)
|
|
501
|
+
// ============================================================================
|
|
502
|
+
let extendedWorkerPool = null;
|
|
503
|
+
/**
|
|
504
|
+
* Get the extended worker pool for hook operations
|
|
505
|
+
*/
|
|
506
|
+
async function getExtendedWorkerPool() {
|
|
507
|
+
if (extendedWorkerPool)
|
|
508
|
+
return extendedWorkerPool;
|
|
509
|
+
try {
|
|
510
|
+
if (!ruvectorModule) {
|
|
511
|
+
ruvectorModule = await import('ruvector');
|
|
512
|
+
}
|
|
513
|
+
if (ruvectorModule.ExtendedWorkerPool) {
|
|
514
|
+
extendedWorkerPool = new ruvectorModule.ExtendedWorkerPool();
|
|
515
|
+
await extendedWorkerPool.init?.();
|
|
516
|
+
console.log('[IntelligenceBridge] Extended worker pool initialized');
|
|
517
|
+
}
|
|
518
|
+
return extendedWorkerPool;
|
|
519
|
+
}
|
|
520
|
+
catch (error) {
|
|
521
|
+
return null;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Speculatively pre-embed files that are likely to be accessed
|
|
526
|
+
* Call in post-edit hook for related files
|
|
527
|
+
*/
|
|
528
|
+
export async function speculativeEmbed(files) {
|
|
529
|
+
const pool = await getExtendedWorkerPool();
|
|
530
|
+
if (pool?.speculativeEmbed) {
|
|
531
|
+
return pool.speculativeEmbed(files);
|
|
532
|
+
}
|
|
533
|
+
return { queued: 0 };
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Analyze AST of multiple files in parallel
|
|
537
|
+
* For pre-edit and route hooks
|
|
538
|
+
*/
|
|
539
|
+
export async function analyzeAST(files) {
|
|
540
|
+
const pool = await getExtendedWorkerPool();
|
|
541
|
+
if (pool?.analyzeAST) {
|
|
542
|
+
return pool.analyzeAST(files);
|
|
543
|
+
}
|
|
544
|
+
// Fallback: simple regex-based extraction
|
|
545
|
+
return files.map(f => ({
|
|
546
|
+
path: f.path,
|
|
547
|
+
functions: (f.content.match(/function\s+(\w+)/g) || []).map(m => m.replace('function ', '')),
|
|
548
|
+
imports: (f.content.match(/import\s+.*from\s+['"]([^'"]+)['"]/g) || []),
|
|
549
|
+
exports: (f.content.match(/export\s+(default\s+)?(function|class|const)\s+(\w+)/g) || []),
|
|
550
|
+
}));
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Analyze code complexity metrics in parallel
|
|
554
|
+
* For session-end hook to track quality
|
|
555
|
+
*/
|
|
556
|
+
export async function analyzeComplexity(files) {
|
|
557
|
+
const pool = await getExtendedWorkerPool();
|
|
558
|
+
if (pool?.analyzeComplexity) {
|
|
559
|
+
return pool.analyzeComplexity(files);
|
|
560
|
+
}
|
|
561
|
+
return files.map(f => ({ path: f, cyclomatic: 0, cognitive: 0, lines: 0 }));
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Build dependency graph from import statements
|
|
565
|
+
* For session-start hook context
|
|
566
|
+
*/
|
|
567
|
+
export async function buildDependencyGraph(files) {
|
|
568
|
+
const pool = await getExtendedWorkerPool();
|
|
569
|
+
if (pool?.buildDependencyGraph) {
|
|
570
|
+
return pool.buildDependencyGraph(files);
|
|
571
|
+
}
|
|
572
|
+
return { nodes: files, edges: [] };
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Parallel security scan (SAST)
|
|
576
|
+
* For pre-command hook before commits
|
|
577
|
+
*/
|
|
578
|
+
export async function securityScan(files) {
|
|
579
|
+
const pool = await getExtendedWorkerPool();
|
|
580
|
+
if (pool?.securityScan) {
|
|
581
|
+
return pool.securityScan(files);
|
|
582
|
+
}
|
|
583
|
+
return [];
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* RAG retrieval with parallel chunk processing
|
|
587
|
+
* For recall hook
|
|
588
|
+
*/
|
|
589
|
+
export async function ragRetrieve(query, chunks, topK = 5) {
|
|
590
|
+
const pool = await getExtendedWorkerPool();
|
|
591
|
+
if (pool?.ragRetrieve) {
|
|
592
|
+
return pool.ragRetrieve(query, chunks, topK);
|
|
593
|
+
}
|
|
594
|
+
// Fallback: use embedding service
|
|
595
|
+
const service = getEmbeddingServiceInstance();
|
|
596
|
+
await service.buildCorpus(chunks.map(c => c.text));
|
|
597
|
+
const results = await service.semanticSearch(query, topK);
|
|
598
|
+
return results.map((r, i) => ({
|
|
599
|
+
id: chunks[r.index]?.id || String(r.index),
|
|
600
|
+
text: r.text,
|
|
601
|
+
score: r.similarity,
|
|
602
|
+
}));
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Rank context by relevance
|
|
606
|
+
* For suggest-context hook
|
|
607
|
+
*/
|
|
608
|
+
export async function rankContext(query, contexts) {
|
|
609
|
+
const pool = await getExtendedWorkerPool();
|
|
610
|
+
if (pool?.rankContext) {
|
|
611
|
+
return pool.rankContext(query, contexts);
|
|
612
|
+
}
|
|
613
|
+
// Fallback: use similarity
|
|
614
|
+
const service = getEmbeddingServiceInstance();
|
|
615
|
+
const queryEmb = await service.embed(query);
|
|
616
|
+
const results = [];
|
|
617
|
+
for (const ctx of contexts) {
|
|
618
|
+
const ctxEmb = await service.embed(ctx.content.slice(0, 500));
|
|
619
|
+
const relevance = service.cosineSimilarity(queryEmb, ctxEmb);
|
|
620
|
+
results.push({ id: ctx.id, relevance });
|
|
621
|
+
}
|
|
622
|
+
return results.sort((a, b) => b.relevance - a.relevance);
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Semantic deduplication
|
|
626
|
+
* For remember hook to avoid storing duplicates
|
|
627
|
+
*/
|
|
628
|
+
export async function deduplicate(texts, threshold = 0.9) {
|
|
629
|
+
const pool = await getExtendedWorkerPool();
|
|
630
|
+
if (pool?.deduplicate) {
|
|
631
|
+
return pool.deduplicate(texts, threshold);
|
|
632
|
+
}
|
|
633
|
+
// Fallback: use embedding service
|
|
634
|
+
const service = getEmbeddingServiceInstance();
|
|
635
|
+
const duplicates = await service.findDuplicates(texts, threshold);
|
|
636
|
+
const duplicateIndices = new Set(duplicates.flatMap(d => d.indices.slice(1)));
|
|
637
|
+
const unique = texts.filter((_, i) => !duplicateIndices.has(i));
|
|
638
|
+
return {
|
|
639
|
+
unique,
|
|
640
|
+
duplicateGroups: duplicates.map(d => d.indices),
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Parallel git blame analysis
|
|
645
|
+
* For co-edit hook
|
|
646
|
+
*/
|
|
647
|
+
export async function gitBlame(files) {
|
|
648
|
+
const pool = await getExtendedWorkerPool();
|
|
649
|
+
if (pool?.gitBlame) {
|
|
650
|
+
return pool.gitBlame(files);
|
|
651
|
+
}
|
|
652
|
+
return files.map(f => ({ path: f, authors: [] }));
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Code churn metrics for routing decisions
|
|
656
|
+
* For route hook to prioritize high-churn files
|
|
657
|
+
*/
|
|
658
|
+
export async function gitChurn(patterns, since = '30 days ago') {
|
|
659
|
+
const pool = await getExtendedWorkerPool();
|
|
660
|
+
if (pool?.gitChurn) {
|
|
661
|
+
return pool.gitChurn(patterns, since);
|
|
662
|
+
}
|
|
663
|
+
return [];
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Get attention mechanism for specific use case
|
|
667
|
+
*/
|
|
668
|
+
export async function getAttentionForUseCase(useCase) {
|
|
669
|
+
if (!ruvectorModule) {
|
|
670
|
+
ruvectorModule = await import('ruvector');
|
|
671
|
+
}
|
|
672
|
+
const attentionMap = {
|
|
673
|
+
'pattern-matching': 'MultiHeadAttention',
|
|
674
|
+
'agent-routing': 'MoEAttention',
|
|
675
|
+
'code-structure': 'GraphRoPeAttention',
|
|
676
|
+
'context-summary': 'LocalGlobalAttention',
|
|
677
|
+
'multi-agent': 'MoEAttention',
|
|
678
|
+
};
|
|
679
|
+
const type = attentionMap[useCase] || 'MultiHeadAttention';
|
|
680
|
+
const AttentionClass = ruvectorModule[type];
|
|
681
|
+
if (AttentionClass) {
|
|
682
|
+
return { type, instance: new AttentionClass(384, 4) };
|
|
683
|
+
}
|
|
684
|
+
return { type: 'fallback', instance: null };
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Parallel attention compute across multiple queries
|
|
688
|
+
*/
|
|
689
|
+
export async function parallelAttentionCompute(queries, keys, values, type = 'moe') {
|
|
690
|
+
if (!ruvectorModule) {
|
|
691
|
+
ruvectorModule = await import('ruvector');
|
|
692
|
+
}
|
|
693
|
+
if (ruvectorModule.parallelAttentionCompute) {
|
|
694
|
+
return ruvectorModule.parallelAttentionCompute(queries, keys, values, type);
|
|
695
|
+
}
|
|
696
|
+
return [];
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Get extended worker pool stats
|
|
700
|
+
*/
|
|
701
|
+
export async function getExtendedWorkerStats() {
|
|
702
|
+
const pool = await getExtendedWorkerPool();
|
|
703
|
+
if (pool) {
|
|
704
|
+
return {
|
|
705
|
+
initialized: true,
|
|
706
|
+
operations: [
|
|
707
|
+
'speculativeEmbed', 'analyzeAST', 'analyzeComplexity', 'buildDependencyGraph',
|
|
708
|
+
'securityScan', 'ragRetrieve', 'rankContext', 'deduplicate', 'gitBlame', 'gitChurn'
|
|
709
|
+
],
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
return { initialized: false, operations: [] };
|
|
713
|
+
}
|
|
296
714
|
//# sourceMappingURL=intelligence-bridge.js.map
|