All files / lib/awareness/collective/analysis ai-summary.ts

37.03% Statements 10/27
20% Branches 1/5
100% Functions 1/1
37.03% Lines 10/27

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 351x   1x 3x 3x                               3x 3x 3x 3x   3x 3x                
import { getPinnedInsights } from '@/lib/evolution/history.pins';
 
export function generateAISummary() {
  const pins = getPinnedInsights();
  if (!pins.length) return 'No pinned insights available for analysis.';
 
  const total = pins.length;
  const reformCount = pins.filter((p) => p.trend === 'Reform').length;
  const integrateCount = pins.filter((p) => p.trend === 'Integrate').length;
  const resetCount = pins.filter((p) => p.trend === 'Reset').length;
 
  const avgConfidence = pins.reduce((sum, p) => sum + (p.confidence || 0), 0) / total;
 
  const dominantTrend =
    reformCount >= integrateCount && reformCount >= resetCount
      ? 'Reform'
      : integrateCount >= resetCount
      ? 'Integrate'
      : 'Reset';
 
  let summary = `🧠 **AI Predictive Summary**
Total Insights: ${total}
Average Confidence: ${(avgConfidence * 100).toFixed(1)}%
Dominant Trend: ${dominantTrend}`;
 
  if (dominantTrend === 'Reform')
    summary += `\n→ The system exhibits adaptive restructuring patterns. Stability maintained with moderate confidence.`;
  if (dominantTrend === 'Integrate')
    summary += `\n→ Integration signals are increasing — potential system unification detected.`;
  if (dominantTrend === 'Reset')
    summary += `\n→ System reset phase indicators present. Evaluate consistency and recovery cycle.`;
 
  return summary;
}