Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

Checkpoint: File edits

rUv6d67fa67ea27
diff --git a/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts
index e833b0331c..d6fa32ed6e 100644
--- a/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts
@@ -1295,39 +1295,80 @@ export const hooksPatternStore: MCPTool = {
export const hooksPatternSearch: MCPTool = {
name: 'hooks/intelligence/pattern-search',
- description: 'Search ReasoningBank using HNSW (150x faster)',
+ description: 'Search patterns using REAL vector search (HNSW when available, brute-force fallback)',
inputSchema: {
type: 'object',
properties: {
query: { type: 'string', description: 'Search query' },
topK: { type: 'number', description: 'Number of results' },
- minConfidence: { type: 'number', description: 'Minimum confidence' },
+ minConfidence: { type: 'number', description: 'Minimum similarity threshold (0-1)' },
+ namespace: { type: 'string', description: 'Namespace to search (default: pattern)' },
},
required: ['query'],
},
handler: async (params: Record<string, unknown>) => {
const query = params.query as string;
const topK = (params.topK as number) || 5;
- const minConfidence = (params.minConfidence as number) || 0.6;
+ const minConfidence = (params.minConfidence as number) || 0.3;
+ const namespace = (params.namespace as string) || 'pattern';
- // Generate mock results based on query
- const results: Array<{ patternId: string; pattern: string; similarity: number; confidence: number; type: string }> = [];
- for (let i = 0; i < topK; i++) {
- results.push({
- patternId: `pattern-${Date.now() - i * 1000}`,
- pattern: `Pattern matching "${query}" #${i + 1}`,
- similarity: 0.95 - (i * 0.08),
- confidence: Math.max(minConfidence, 0.9 - (i * 0.05)),
- type: ['file-edit', 'task-routing', 'command-risk'][i % 3],
- });
+ // Try to use real vector search
+ const searchFn = await getRealSearchFunction();
+
+ if (searchFn) {
+ try {
+ const searchResult = await searchFn({
+ query,
+ namespace,
+ limit: topK,
+ threshold: minConfidence,
+ });
+
+ if (searchResult.success && searchResult.results.length > 0) {
+ return {
+ query,
+ results: searchResult.results.map(r => ({
+ patternId: r.id,
+ pattern: r.content,
+ similarity: r.score,
+ confidence: r.score, // Using similarity as confidence
+ namespace: r.namespace,
+ key: r.key,
+ })),
+ searchTimeMs: searchResult.searchTime,
+ backend: 'real-vector-search',
+ note: 'Results from actual HNSW/SQLite vector search',
+ };
+ }
+
+ // No results found
+ return {
+ query,
+ results: [],
+ searchTimeMs: searchResult.searchTime,
+ backend: 'real-vector-search',
+ note: searchResult.error || 'No matching patterns found. Store patterns first using memory/store with namespace "pattern".',
+ };
+ } catch (error) {
+ // Fall through to empty response with error
+ return {
+ query,
+ results: [],
+ searchTimeMs: 0,
+ backend: 'error',
+ error: String(error),
+ note: 'Vector search failed. Ensure memory database is initialized.',
+ };
+ }
}
+ // No search function available
return {
query,
- results,
- searchTimeMs: 0.12,
- hnswNodesVisited: 45,
- speedup: '150x vs brute-force',
+ results: [],
+ searchTimeMs: 0,
+ backend: 'unavailable',
+ note: 'Real vector search not available. Initialize memory database with: claude-flow memory init',
};
},
};