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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | /** * Phase 8.5 ā Responsive Collective Dashboard š§ * ---------------------------------------------- * Unified display of Integration_Report.json + Responsive Policy context * Supports environment awareness (device/performance/motion/network) * before transition to Phase 9 (Predictive Evolution). * * š§© Layers included: * - Evolution Report Awareness * - Responsive Policy Awareness * - Telemetry Logging * - Dynamic UI density and motion * * CLI + React Dual Mode: Works both as interactive React component and CLI renderer. */ import fs from 'node:fs'; import path from 'node:path'; import chalk from 'chalk'; import boxen from 'boxen'; import React, { useEffect } from 'react'; import { usePolicy } from '../../context/PolicyContext'; import { appendPolicyTelemetry } from '../integration/policy_telemetry'; // ============ Types ============ interface IntegrationReport { timestamp: string; nodes: Array<{ nodeId: string; trust: number }>; metrics: { collectiveStability: number; collaborationIndex: number; metaResonance: number; nextEvolutionDirective: 'Expand' | 'Contract' | 'Freeze' | 'Merge'; }; notes: { interpretation: string; guidance: string; }; } function colorValue(v: number): string { if (v >= 0.7) return chalk.green(`${(v * 100).toFixed(1)}%`); if (v >= 0.4) return chalk.yellow(`${(v * 100).toFixed(1)}%`); return chalk.red(`${(v * 100).toFixed(1)}%`); } function emojiForDirective(dir: string): string { switch (dir) { case 'Expand': return 'š'; case 'Merge': return 'š«±š¼āš«²š½'; case 'Freeze': return 'š§'; case 'Contract': return 'š'; default: return 'ā'; } } // =============================================================== // š§ React Component Mode ā aware of device and motion context // =============================================================== export const CollectiveDashboard: React.FC = () => { const policy = usePolicy(); // š Log telemetry when environment changes useEffect(() => { appendPolicyTelemetry(policy); }, [policy]); const density = policy.device === 'mobile' ? 'compact' : 'spacious'; const motion = policy.motion === 'reduced' ? 'minimal' : 'animated'; const perf = policy.performance === 'low' ? chalk.red('ā ļø Low Performance') : chalk.green('ā Stable'); const infoBox = boxen( ` š± Device: ${policy.device} āļø Performance: ${policy.performance} š Network: ${policy.network} šļø Motion: ${policy.motion} š§© Density: ${density} ${perf} `, { padding: 1, borderColor: 'magenta', borderStyle: 'round', title: 'Responsive Policy' } ); console.log(chalk.cyan('\nš§ Collective Dashboard (Responsive Mode)\n')); console.log(infoBox); // Render static dashboard CLI view showCollectiveDashboard(); return null; }; // =============================================================== // š§© CLI Renderer ā reads Integration_Report.json and displays // =============================================================== export function showCollectiveDashboard(reportPath = './storage/Integration_Report.json') { if (!fs.existsSync(reportPath)) { console.error(chalk.red(`ā ŁŁ ŁŲŖŁ Ų§ŁŲ¹Ų«ŁŲ± Ų¹ŁŁ ${reportPath}`)); process.exit(1); } const json: IntegrationReport = JSON.parse(fs.readFileSync(reportPath, 'utf8')); const { metrics, timestamp, notes } = json; const rows = [ ['𩺠Stability', colorValue(metrics.collectiveStability)], ['š¤ Collaboration', colorValue(metrics.collaborationIndex)], ['š Meta Resonance', colorValue(metrics.metaResonance)], ['ā” Directive', `${emojiForDirective(metrics.nextEvolutionDirective)} ${chalk.bold(metrics.nextEvolutionDirective)}`], ]; const table = 'āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n' + rows.map(([k, v]) => `ā ${chalk.cyanBright(k.padEnd(20))} ā ${v.padEnd(15)} ā`).join('\n') + '\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'; const box = boxen( ` š§ Collective Dashboard āāāāāāāāāāāāāāāāāāāāāāāāāāāā š ${chalk.gray(timestamp)} ${table} š¬ ${chalk.blueBright(notes.interpretation)} š§ ${chalk.yellow(notes.guidance)} `, { padding: 1, margin: 1, borderStyle: 'round', borderColor: 'cyan' } ); console.log(box); } // =============================================================== // CLI Execution Mode // =============================================================== if (process.argv[1]?.includes('collective_dashboard')) { showCollectiveDashboard(); } |