@claude-flow/cli 3.10.14 → 3.10.16

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.
@@ -52,6 +52,13 @@ export declare const hooksCodemod: MCPTool;
52
52
  export declare const hooksWorkerCancel: MCPTool;
53
53
  export declare const hooksTeammateIdle: MCPTool;
54
54
  export declare const hooksTaskCompleted: MCPTool;
55
+ /**
56
+ * Unified learning-stats aggregator MCP tool (#2245 → ADR-075).
57
+ *
58
+ * One honest call across the four historical stat sources — every sub-view
59
+ * names its store and a `consistency` block flags relationships that drift.
60
+ */
61
+ export declare const hooksIntelligenceUnifiedStats: MCPTool;
55
62
  export declare const hooksTools: MCPTool[];
56
63
  export default hooksTools;
57
64
  //# sourceMappingURL=hooks-tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks-tools.d.ts","sourceRoot":"","sources":["../../../src/mcp-tools/hooks-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,YAAY,CAAC;AAiBzD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASzD;AAwqBD,eAAO,MAAM,YAAY,EAAE,OAwC1B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,OA+C3B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,OA6C7B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,OAuD9B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,OAgLxB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,OAoE1B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,OA8CvB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,OA2F1B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,OAuK3B,CAAC;AAGF,eAAO,MAAM,YAAY,EAAE,OA4E1B,CAAC;AAGF,eAAO,MAAM,aAAa,EAA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AM,iBAAiB,EAAE,OAkI/B,CAAC;AAGF,eAAO,MAAM,sBAAsB,EAAE,OAmEpC,CAAC;AAGF,eAAO,MAAM,oBAAoB,EAAE,OAyDlC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,OAmEjC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,OAgMhC,CAAC;AAGF,eAAO,MAAM,iBAAiB,EAAE,OA4E/B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,OAwGhC,CAAC;AAGF,eAAO,MAAM,sBAAsB,EAAE,OAgNpC,CAAC;AAGF,eAAO,MAAM,sBAAsB,EAAE,OAiGpC,CAAC;AAGF,eAAO,MAAM,0BAA0B,EAAE,OA8MxC,CAAC;AAgQF,eAAO,MAAM,eAAe,EAAE,OA8C7B,CAAC;AAGF,eAAO,MAAM,mBAAmB,EAAE,OAwIjC,CAAC;AAGF,eAAO,MAAM,iBAAiB,EAAE,OAuD/B,CAAC;AAGF,eAAO,MAAM,iBAAiB,EAAE,OAkE/B,CAAC;AAiBF,eAAO,MAAM,eAAe,EAAE,OA4C7B,CAAC;AAGF,eAAO,MAAM,iBAAiB,EAAE,OAgC/B,CAAC;AAGF,eAAO,MAAM,eAAe,EAAE,OAuB7B,CAAC;AAeF,eAAO,MAAM,YAAY,EAAE,OAmI1B,CAAC;AAqBF,eAAO,MAAM,iBAAiB,EAAE,OA0C/B,CAAC;AAOF,eAAO,MAAM,iBAAiB,EAAE,OAwB/B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,OAoFhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,EAAE,OAc3C,CAAC;AAGF,eAAO,MAAM,UAAU,EAAE,OAAO,EA6C/B,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -673,17 +673,41 @@ export const hooksPostEdit = {
673
673
  catch {
674
674
  // Bridge not available — continue with basic response
675
675
  }
676
+ // #2245 Round B — also feed the trajectory pipeline so globalStats
677
+ // (and the unified-stats aggregator in ADR-075) reflects the activity.
678
+ // Synthesises a one-step trajectory from the edit outcome.
679
+ let learningPath = 'recorded-only';
680
+ let trajectoriesDelta = 0;
681
+ try {
682
+ const intel = await import('../memory/intelligence.js');
683
+ const before = intel.getIntelligenceStats().trajectoriesRecorded;
684
+ await intel.recordTrajectory([{
685
+ type: 'action',
686
+ content: `Edit ${filePath}${agent ? ` by ${agent}` : ''}: ${success ? 'success' : 'failure'}`,
687
+ metadata: { hook: 'post-edit', filePath, agent, success },
688
+ timestamp: Date.now(),
689
+ }], success ? 'success' : 'failure');
690
+ trajectoriesDelta = intel.getIntelligenceStats().trajectoriesRecorded - before;
691
+ if (trajectoriesDelta > 0)
692
+ learningPath = 'trajectory-pipeline';
693
+ }
694
+ catch { /* intelligence module not yet initialised — keep recorded-only */ }
676
695
  return {
677
696
  recorded: true,
678
697
  filePath,
679
698
  success,
680
699
  timestamp: new Date().toISOString(),
681
700
  learningUpdate: success ? 'pattern_reinforced' : 'pattern_adjusted',
701
+ learningPath, // ADR-074 / ADR-075 — honest path naming
702
+ trajectoriesDelta,
682
703
  feedback: feedbackResult ? {
683
704
  recorded: feedbackResult.success,
684
705
  controller: feedbackResult.controller,
685
706
  updates: feedbackResult.updated,
686
707
  } : { recorded: false, controller: 'unavailable', updates: 0 },
708
+ note: learningPath === 'trajectory-pipeline'
709
+ ? `Edit outcome fed to the SONA + EWC++ trajectory pipeline (trajectoriesRecorded +${trajectoriesDelta}).`
710
+ : 'Edit outcome stored via memory-bridge only; the trajectory pipeline was not reachable in this process.',
687
711
  };
688
712
  },
689
713
  };
@@ -782,6 +806,24 @@ export const hooksPostCommand = {
782
806
  }
783
807
  catch { /* non-critical */ }
784
808
  }
809
+ // #2245 Round B — feed the trajectory pipeline so globalStats reflects
810
+ // command outcomes alongside the AgentDB entry that already gets written.
811
+ let learningPath = 'recorded-only';
812
+ let trajectoriesDelta = 0;
813
+ try {
814
+ const intel = await import('../memory/intelligence.js');
815
+ const before = intel.getIntelligenceStats().trajectoriesRecorded;
816
+ await intel.recordTrajectory([{
817
+ type: 'action',
818
+ content: `Command \`${command.slice(0, 200)}\` exited ${exitCode} (${success ? 'success' : 'failure'})`,
819
+ metadata: { hook: 'post-command', command: command.slice(0, 500), exitCode, success },
820
+ timestamp: Date.now(),
821
+ }], success ? 'success' : 'failure');
822
+ trajectoriesDelta = intel.getIntelligenceStats().trajectoriesRecorded - before;
823
+ if (trajectoriesDelta > 0)
824
+ learningPath = 'trajectory-pipeline';
825
+ }
826
+ catch { /* intelligence module not yet initialised — keep recorded-only */ }
785
827
  return {
786
828
  recorded: _storedIn !== 'none',
787
829
  command,
@@ -789,6 +831,11 @@ export const hooksPostCommand = {
789
831
  success,
790
832
  timestamp: new Date().toISOString(),
791
833
  _storedIn,
834
+ learningPath, // 'trajectory-pipeline' | 'recorded-only'
835
+ trajectoriesDelta,
836
+ note: learningPath === 'trajectory-pipeline'
837
+ ? `Command outcome fed to the SONA + EWC++ trajectory pipeline (trajectoriesRecorded +${trajectoriesDelta}).`
838
+ : `Command outcome stored via ${_storedIn}; the trajectory pipeline was not reachable in this process.`,
792
839
  };
793
840
  },
794
841
  };
@@ -2575,6 +2622,27 @@ export const hooksTrajectoryEnd = {
2575
2622
  }
2576
2623
  }
2577
2624
  }
2625
+ // #2245 Round B — also bump globalStats so the trajectory-end MCP path
2626
+ // shows up in `hooks_intelligence_unified-stats.global.*` (was only
2627
+ // touching sonaCoordinator before — the "MCP trajectory tools feed sona,
2628
+ // not globalStats" gap from ADR-075). Maps the recorded steps to the
2629
+ // intelligence-module TrajectoryStep shape and runs them through the
2630
+ // canonical recordTrajectory() entry point.
2631
+ let globalStatsDelta = 0;
2632
+ if (trajectory && trajectory.steps && trajectory.steps.length > 0) {
2633
+ try {
2634
+ const intel = await import('../memory/intelligence.js');
2635
+ const before = intel.getIntelligenceStats();
2636
+ await intel.recordTrajectory(trajectory.steps.map((s) => ({
2637
+ type: s.type ?? 'action',
2638
+ content: String(s.content ?? `${s.action ?? ''} → ${s.result ?? ''}`).slice(0, 4096),
2639
+ timestamp: Date.now(),
2640
+ })), success ? 'success' : 'failure');
2641
+ const after = intel.getIntelligenceStats();
2642
+ globalStatsDelta = after.trajectoriesRecorded - before.trajectoriesRecorded;
2643
+ }
2644
+ catch { /* intelligence module not loadable — keep sona-only behaviour */ }
2645
+ }
2578
2646
  const learningTimeMs = Date.now() - startTime;
2579
2647
  return {
2580
2648
  trajectoryId,
@@ -2590,6 +2658,7 @@ export const hooksTrajectoryEnd = {
2590
2658
  ewcPenalty: ewcResult.penalty || undefined,
2591
2659
  patternsExtracted: trajectory?.steps.length || 0,
2592
2660
  learningTimeMs,
2661
+ globalStatsTrajectoriesDelta: globalStatsDelta, // Round B: was 0, now reflects
2593
2662
  },
2594
2663
  trajectory: trajectory ? {
2595
2664
  task: trajectory.task,
@@ -4253,8 +4322,30 @@ export const hooksTaskCompleted = {
4253
4322
  };
4254
4323
  },
4255
4324
  };
4325
+ /**
4326
+ * Unified learning-stats aggregator MCP tool (#2245 → ADR-075).
4327
+ *
4328
+ * One honest call across the four historical stat sources — every sub-view
4329
+ * names its store and a `consistency` block flags relationships that drift.
4330
+ */
4331
+ export const hooksIntelligenceUnifiedStats = {
4332
+ name: 'hooks_intelligence_unified-stats',
4333
+ description: 'One honest view across the four learning stat sources: globalStats (`.claude-flow/neural/stats.json`), the in-memory SONA coordinator, memory-bridge AgentDB entries, and the neural-patterns store. Each sub-view names its source path. The `consistency` block notes cross-store drift (e.g. globalStats reports N patterns but neural_patterns is empty). Use this when one dashboard call should show "did learning happen" coherently — vs the four original aggregators which each return only their narrow slice. See ADR-075.',
4334
+ category: 'hooks',
4335
+ inputSchema: {
4336
+ type: 'object',
4337
+ properties: {
4338
+ verbose: { type: 'boolean', description: 'Include extended breakdowns', default: true },
4339
+ },
4340
+ },
4341
+ handler: async (_input) => {
4342
+ const intel = await import('../memory/intelligence.js');
4343
+ return intel.getUnifiedLearningStats();
4344
+ },
4345
+ };
4256
4346
  // Export all hooks tools
4257
4347
  export const hooksTools = [
4348
+ hooksIntelligenceUnifiedStats,
4258
4349
  hooksTeammateIdle,
4259
4350
  hooksTaskCompleted,
4260
4351
  hooksPreEdit,