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 edit:

rUv6d6e360f108d
diff --git a/v3/@claude-flow/hooks/src/daemons/index.ts b/v3/@claude-flow/hooks/src/daemons/index.ts
index 9e444dfd37..832186287e 100644
--- a/v3/@claude-flow/hooks/src/daemons/index.ts
+++ b/v3/@claude-flow/hooks/src/daemons/index.ts
@@ -405,12 +405,20 @@ export class SwarmMonitorDaemon {
}
/**
- * Hooks Learning Daemon - consolidates learned patterns
+ * Hooks Learning Daemon - consolidates learned patterns using ReasoningBank
*/
export class HooksLearningDaemon {
private manager: DaemonManager;
private patternsLearned = 0;
private routingAccuracy = 0;
+ private reasoningBank: any = null;
+ private lastConsolidation: Date | null = null;
+ private consolidationStats = {
+ totalRuns: 0,
+ patternsPromoted: 0,
+ patternsPruned: 0,
+ duplicatesRemoved: 0,
+ };
constructor(manager?: DaemonManager) {
this.manager = manager ?? new DaemonManager();
@@ -430,6 +438,15 @@ export class HooksLearningDaemon {
* Start learning consolidation
*/
async start(): Promise<void> {
+ // Lazy load ReasoningBank to avoid circular dependencies
+ try {
+ const { reasoningBank } = await import('../reasoningbank/index.js');
+ this.reasoningBank = reasoningBank;
+ await this.reasoningBank.initialize();
+ } catch (error) {
+ console.warn('[HooksLearningDaemon] ReasoningBank not available:', error);
+ }
+
await this.manager.start('hooks-learning');
}
@@ -441,22 +458,53 @@ export class HooksLearningDaemon {
}
/**
- * Consolidate learned patterns
+ * Consolidate learned patterns using ReasoningBank
*/
private async consolidate(): Promise<void> {
- // In a real implementation, this would:
- // - Prune low-quality trajectories
- // - Merge similar patterns
- // - Optimize HNSW index
+ if (!this.reasoningBank) {
+ return;
+ }
+
+ try {
+ const result = await this.reasoningBank.consolidate();
+
+ // Update stats
+ this.consolidationStats.totalRuns++;
+ this.consolidationStats.patternsPromoted += result.patternsPromoted;
+ this.consolidationStats.patternsPruned += result.patternsPruned;
+ this.consolidationStats.duplicatesRemoved += result.duplicatesRemoved;
+ this.lastConsolidation = new Date();
+
+ // Update pattern count from ReasoningBank stats
+ const stats = this.reasoningBank.getStats();
+ this.patternsLearned = stats.shortTermCount + stats.longTermCount;
+
+ // Emit consolidation event
+ if (result.patternsPromoted > 0 || result.patternsPruned > 0) {
+ console.log(
+ `[HooksLearningDaemon] Consolidated: ${result.patternsPromoted} promoted, ` +
+ `${result.patternsPruned} pruned, ${result.duplicatesRemoved} deduped`
+ );
+ }
+ } catch (error) {
+ console.error('[HooksLearningDaemon] Consolidation failed:', error);
+ }
}
/**
* Get learning stats
*/
- getStats(): { patternsLearned: number; routingAccuracy: number } {
+ getStats(): {
+ patternsLearned: number;
+ routingAccuracy: number;
+ consolidationStats: typeof this.consolidationStats;
+ lastConsolidation: Date | null;
+ } {
return {
patternsLearned: this.patternsLearned,
routingAccuracy: this.routingAccuracy,
+ consolidationStats: { ...this.consolidationStats },
+ lastConsolidation: this.lastConsolidation,
};
}
@@ -473,6 +521,23 @@ export class HooksLearningDaemon {
updateRoutingAccuracy(accuracy: number): void {
this.routingAccuracy = accuracy;
}
+
+ /**
+ * Get ReasoningBank stats (if available)
+ */
+ getReasoningBankStats(): any {
+ if (!this.reasoningBank) {
+ return null;
+ }
+ return this.reasoningBank.getStats();
+ }
+
+ /**
+ * Force immediate consolidation
+ */
+ async forceConsolidate(): Promise<void> {
+ await this.consolidate();
+ }
}
/**