@timmeck/brain 1.8.5 → 2.0.0

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.
Files changed (221) hide show
  1. package/.dockerignore +11 -0
  2. package/Dockerfile +21 -0
  3. package/README.md +19 -0
  4. package/assets/brain-avatar-256.png +0 -0
  5. package/assets/brain-avatar-512.png +0 -0
  6. package/assets/brain-avatar.png +0 -0
  7. package/brain.log +1164 -0
  8. package/{src/cli/commands/dashboard.ts → dashboard.html} +688 -807
  9. package/dist/api/server.d.ts +4 -18
  10. package/dist/api/server.js +4 -173
  11. package/dist/api/server.js.map +1 -1
  12. package/dist/brain.d.ts +6 -0
  13. package/dist/brain.js +56 -4
  14. package/dist/brain.js.map +1 -1
  15. package/dist/cli/colors.d.ts +4 -25
  16. package/dist/cli/colors.js +3 -89
  17. package/dist/cli/colors.js.map +1 -1
  18. package/dist/cli/commands/peers.d.ts +2 -0
  19. package/dist/cli/commands/peers.js +38 -0
  20. package/dist/cli/commands/peers.js.map +1 -0
  21. package/dist/cli/commands/start.js +54 -17
  22. package/dist/cli/commands/start.js.map +1 -1
  23. package/dist/db/connection.d.ts +1 -2
  24. package/dist/db/connection.js +1 -18
  25. package/dist/db/connection.js.map +1 -1
  26. package/dist/index.js +3 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/ipc/__tests__/protocol.test.d.ts +1 -0
  29. package/dist/ipc/__tests__/protocol.test.js +117 -0
  30. package/dist/ipc/__tests__/protocol.test.js.map +1 -0
  31. package/dist/ipc/client.d.ts +1 -16
  32. package/dist/ipc/client.js +1 -100
  33. package/dist/ipc/client.js.map +1 -1
  34. package/dist/ipc/protocol.d.ts +1 -8
  35. package/dist/ipc/protocol.js +1 -28
  36. package/dist/ipc/protocol.js.map +1 -1
  37. package/dist/ipc/router.js +8 -0
  38. package/dist/ipc/router.js.map +1 -1
  39. package/dist/ipc/server.d.ts +1 -22
  40. package/dist/ipc/server.js +1 -163
  41. package/dist/ipc/server.js.map +1 -1
  42. package/dist/mcp/http-server.d.ts +1 -7
  43. package/dist/mcp/http-server.js +6 -117
  44. package/dist/mcp/http-server.js.map +1 -1
  45. package/dist/mcp/server.js +5 -61
  46. package/dist/mcp/server.js.map +1 -1
  47. package/dist/signals/__tests__/fingerprint.test.d.ts +1 -0
  48. package/dist/signals/__tests__/fingerprint.test.js +118 -0
  49. package/dist/signals/__tests__/fingerprint.test.js.map +1 -0
  50. package/dist/types/ipc.types.d.ts +1 -11
  51. package/dist/utils/__tests__/hash.test.d.ts +1 -0
  52. package/dist/utils/__tests__/hash.test.js +32 -0
  53. package/dist/utils/__tests__/hash.test.js.map +1 -0
  54. package/dist/utils/__tests__/paths.test.d.ts +1 -0
  55. package/dist/utils/__tests__/paths.test.js +75 -0
  56. package/dist/utils/__tests__/paths.test.js.map +1 -0
  57. package/dist/utils/events.d.ts +4 -8
  58. package/dist/utils/events.js +2 -14
  59. package/dist/utils/events.js.map +1 -1
  60. package/dist/utils/hash.d.ts +1 -1
  61. package/dist/utils/hash.js +1 -4
  62. package/dist/utils/hash.js.map +1 -1
  63. package/dist/utils/logger.d.ts +3 -2
  64. package/dist/utils/logger.js +8 -35
  65. package/dist/utils/logger.js.map +1 -1
  66. package/dist/utils/paths.d.ts +2 -1
  67. package/dist/utils/paths.js +4 -13
  68. package/dist/utils/paths.js.map +1 -1
  69. package/gen_avatar.py +142 -0
  70. package/package.json +2 -1
  71. package/BRAIN_PLAN.md +0 -3324
  72. package/src/api/server.ts +0 -395
  73. package/src/brain.ts +0 -266
  74. package/src/cli/colors.ts +0 -116
  75. package/src/cli/commands/config.ts +0 -169
  76. package/src/cli/commands/doctor.ts +0 -124
  77. package/src/cli/commands/explain.ts +0 -83
  78. package/src/cli/commands/export.ts +0 -31
  79. package/src/cli/commands/import.ts +0 -199
  80. package/src/cli/commands/insights.ts +0 -65
  81. package/src/cli/commands/learn.ts +0 -24
  82. package/src/cli/commands/modules.ts +0 -53
  83. package/src/cli/commands/network.ts +0 -67
  84. package/src/cli/commands/projects.ts +0 -42
  85. package/src/cli/commands/query.ts +0 -120
  86. package/src/cli/commands/start.ts +0 -62
  87. package/src/cli/commands/status.ts +0 -75
  88. package/src/cli/commands/stop.ts +0 -34
  89. package/src/cli/ipc-helper.ts +0 -22
  90. package/src/cli/update-check.ts +0 -63
  91. package/src/code/analyzer.ts +0 -117
  92. package/src/code/fingerprint.ts +0 -87
  93. package/src/code/matcher.ts +0 -129
  94. package/src/code/parsers/generic.ts +0 -29
  95. package/src/code/parsers/python.ts +0 -54
  96. package/src/code/parsers/typescript.ts +0 -65
  97. package/src/code/registry.ts +0 -60
  98. package/src/code/scorer.ts +0 -120
  99. package/src/config.ts +0 -135
  100. package/src/dashboard/server.ts +0 -142
  101. package/src/db/connection.ts +0 -22
  102. package/src/db/migrations/001_core_schema.ts +0 -120
  103. package/src/db/migrations/002_learning_schema.ts +0 -38
  104. package/src/db/migrations/003_code_schema.ts +0 -53
  105. package/src/db/migrations/004_synapses_schema.ts +0 -57
  106. package/src/db/migrations/005_fts_indexes.ts +0 -78
  107. package/src/db/migrations/006_synapses_phase3.ts +0 -17
  108. package/src/db/migrations/007_feedback.ts +0 -13
  109. package/src/db/migrations/008_git_integration.ts +0 -38
  110. package/src/db/migrations/009_embeddings.ts +0 -8
  111. package/src/db/migrations/index.ts +0 -70
  112. package/src/db/repositories/antipattern.repository.ts +0 -66
  113. package/src/db/repositories/code-module.repository.ts +0 -142
  114. package/src/db/repositories/error.repository.ts +0 -189
  115. package/src/db/repositories/insight.repository.ts +0 -99
  116. package/src/db/repositories/notification.repository.ts +0 -66
  117. package/src/db/repositories/project.repository.ts +0 -93
  118. package/src/db/repositories/rule.repository.ts +0 -108
  119. package/src/db/repositories/solution.repository.ts +0 -154
  120. package/src/db/repositories/synapse.repository.ts +0 -163
  121. package/src/db/repositories/terminal.repository.ts +0 -101
  122. package/src/embeddings/engine.ts +0 -238
  123. package/src/hooks/post-tool-use.ts +0 -92
  124. package/src/hooks/post-write.ts +0 -129
  125. package/src/index.ts +0 -63
  126. package/src/ipc/client.ts +0 -118
  127. package/src/ipc/protocol.ts +0 -35
  128. package/src/ipc/router.ts +0 -133
  129. package/src/ipc/server.ts +0 -176
  130. package/src/learning/confidence-scorer.ts +0 -80
  131. package/src/learning/decay.ts +0 -46
  132. package/src/learning/learning-engine.ts +0 -170
  133. package/src/learning/pattern-extractor.ts +0 -90
  134. package/src/learning/rule-generator.ts +0 -74
  135. package/src/main.rs:10:5 +0 -0
  136. package/src/matching/error-matcher.ts +0 -166
  137. package/src/matching/fingerprint.ts +0 -34
  138. package/src/matching/similarity.ts +0 -61
  139. package/src/matching/tfidf.ts +0 -74
  140. package/src/matching/tokenizer.ts +0 -41
  141. package/src/mcp/auto-detect.ts +0 -93
  142. package/src/mcp/http-server.ts +0 -140
  143. package/src/mcp/server.ts +0 -73
  144. package/src/mcp/tools.ts +0 -328
  145. package/src/parsing/error-parser.ts +0 -28
  146. package/src/parsing/parsers/compiler.ts +0 -93
  147. package/src/parsing/parsers/generic.ts +0 -28
  148. package/src/parsing/parsers/go.ts +0 -97
  149. package/src/parsing/parsers/node.ts +0 -69
  150. package/src/parsing/parsers/python.ts +0 -62
  151. package/src/parsing/parsers/rust.ts +0 -50
  152. package/src/parsing/parsers/shell.ts +0 -42
  153. package/src/parsing/types.ts +0 -47
  154. package/src/research/gap-analyzer.ts +0 -135
  155. package/src/research/insight-generator.ts +0 -123
  156. package/src/research/research-engine.ts +0 -116
  157. package/src/research/synergy-detector.ts +0 -126
  158. package/src/research/template-extractor.ts +0 -130
  159. package/src/research/trend-analyzer.ts +0 -127
  160. package/src/services/analytics.service.ts +0 -226
  161. package/src/services/code.service.ts +0 -271
  162. package/src/services/error.service.ts +0 -266
  163. package/src/services/git.service.ts +0 -132
  164. package/src/services/notification.service.ts +0 -41
  165. package/src/services/prevention.service.ts +0 -159
  166. package/src/services/research.service.ts +0 -98
  167. package/src/services/solution.service.ts +0 -174
  168. package/src/services/synapse.service.ts +0 -59
  169. package/src/services/terminal.service.ts +0 -81
  170. package/src/synapses/activation.ts +0 -80
  171. package/src/synapses/decay.ts +0 -38
  172. package/src/synapses/hebbian.ts +0 -69
  173. package/src/synapses/pathfinder.ts +0 -81
  174. package/src/synapses/synapse-manager.ts +0 -113
  175. package/src/types/code.types.ts +0 -52
  176. package/src/types/config.types.ts +0 -103
  177. package/src/types/error.types.ts +0 -67
  178. package/src/types/ipc.types.ts +0 -8
  179. package/src/types/mcp.types.ts +0 -53
  180. package/src/types/research.types.ts +0 -28
  181. package/src/types/solution.types.ts +0 -30
  182. package/src/types/synapse.types.ts +0 -50
  183. package/src/utils/events.ts +0 -45
  184. package/src/utils/hash.ts +0 -5
  185. package/src/utils/logger.ts +0 -48
  186. package/src/utils/paths.ts +0 -19
  187. package/tests/e2e/test_code_intelligence.py +0 -1015
  188. package/tests/e2e/test_error_memory.py +0 -451
  189. package/tests/e2e/test_full_integration.py +0 -534
  190. package/tests/fixtures/code-modules/modules.ts +0 -83
  191. package/tests/fixtures/errors/go.ts +0 -9
  192. package/tests/fixtures/errors/node.ts +0 -24
  193. package/tests/fixtures/errors/python.ts +0 -21
  194. package/tests/fixtures/errors/rust.ts +0 -25
  195. package/tests/fixtures/errors/shell.ts +0 -15
  196. package/tests/fixtures/solutions/solutions.ts +0 -27
  197. package/tests/helpers/setup-db.ts +0 -52
  198. package/tests/integration/code-flow.test.ts +0 -86
  199. package/tests/integration/error-flow.test.ts +0 -83
  200. package/tests/integration/ipc-flow.test.ts +0 -166
  201. package/tests/integration/learning-cycle.test.ts +0 -82
  202. package/tests/integration/synapse-flow.test.ts +0 -117
  203. package/tests/unit/code/analyzer.test.ts +0 -58
  204. package/tests/unit/code/fingerprint.test.ts +0 -51
  205. package/tests/unit/code/scorer.test.ts +0 -55
  206. package/tests/unit/learning/confidence-scorer.test.ts +0 -60
  207. package/tests/unit/learning/decay.test.ts +0 -45
  208. package/tests/unit/learning/pattern-extractor.test.ts +0 -50
  209. package/tests/unit/matching/error-matcher.test.ts +0 -69
  210. package/tests/unit/matching/fingerprint.test.ts +0 -47
  211. package/tests/unit/matching/similarity.test.ts +0 -65
  212. package/tests/unit/matching/tfidf.test.ts +0 -71
  213. package/tests/unit/matching/tokenizer.test.ts +0 -83
  214. package/tests/unit/parsing/parsers.test.ts +0 -113
  215. package/tests/unit/research/gap-analyzer.test.ts +0 -45
  216. package/tests/unit/research/trend-analyzer.test.ts +0 -45
  217. package/tests/unit/synapses/activation.test.ts +0 -80
  218. package/tests/unit/synapses/decay.test.ts +0 -27
  219. package/tests/unit/synapses/hebbian.test.ts +0 -96
  220. package/tests/unit/synapses/pathfinder.test.ts +0 -72
  221. package/tsconfig.json +0 -18
@@ -1,807 +1,688 @@
1
- import { Command } from 'commander';
2
- import { withIpc } from '../ipc-helper.js';
3
- import { writeFileSync } from 'fs';
4
- import { resolve } from 'path';
5
- import { c, icons } from '../colors.js';
6
-
7
- export function dashboardCommand(): Command {
8
- return new Command('dashboard')
9
- .description('Generate and open the Brain dashboard with live data')
10
- .option('-o, --output <path>', 'Output HTML file path')
11
- .option('--no-open', 'Generate without opening in browser')
12
- .option('-l, --live', 'Start live dashboard server with SSE updates')
13
- .option('-p, --port <number>', 'Port for live dashboard', '7420')
14
- .action(async (opts) => {
15
- await withIpc(async (client) => {
16
- console.log(`${icons.chart} ${c.info('Fetching data from Brain...')}`);
17
-
18
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
- const summary: any = await client.request('analytics.summary', {});
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- const network: any = await client.request('synapse.stats', {});
22
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
- const networkOverview: any = await client.request('analytics.network', { limit: 90 });
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
- const insights: any = await client.request('research.insights', {
26
- activeOnly: true,
27
- limit: 500,
28
- });
29
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
- const modules: any = await client.request('code.modules', {});
31
-
32
- // Collect language stats
33
- const langStats: Record<string, number> = {};
34
- const projectSet = new Set<string>();
35
- if (Array.isArray(modules)) {
36
- for (const m of modules) {
37
- langStats[m.language] = (langStats[m.language] || 0) + 1;
38
- if (m.projectId) projectSet.add(String(m.projectId));
39
- }
40
- }
41
-
42
- // Categorize insights
43
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
- const insightList = Array.isArray(insights) ? insights : [];
45
- const templates = insightList.filter((i: InsightItem) => i.type === 'template_candidate' || i.title?.includes('Template'));
46
- const suggestions = insightList.filter((i: InsightItem) => i.type === 'suggestion' || i.type === 'project_suggestion');
47
- const trends = insightList.filter((i: InsightItem) => i.type === 'trend' || i.type === 'pattern');
48
- const gaps = insightList.filter((i: InsightItem) => i.type === 'gap');
49
- const warnings = insightList.filter((i: InsightItem) => i.type === 'warning');
50
- const synergies = insightList.filter((i: InsightItem) => i.type === 'synergy' || i.type === 'optimization');
51
-
52
- // Build synapse graph data
53
- const synapseEdges = Array.isArray(networkOverview?.strongestSynapses) ? networkOverview.strongestSynapses : [];
54
-
55
- const data = {
56
- stats: {
57
- modules: summary.modules?.total ?? 0,
58
- synapses: network.totalSynapses ?? 0,
59
- errors: summary.errors?.total ?? 0,
60
- solutions: summary.solutions?.total ?? 0,
61
- rules: summary.rules?.active ?? 0,
62
- insights: insightList.length,
63
- },
64
- langStats,
65
- insights: { templates, suggestions, trends, gaps, warnings, synergies },
66
- synapseEdges,
67
- };
68
-
69
- const html = generateHtml(data);
70
- const outPath = opts.output
71
- ? resolve(opts.output)
72
- : resolve(import.meta.dirname, '../../../dashboard.html');
73
-
74
- // Inject live SSE connection for --live mode
75
- let finalHtml = html;
76
- if (opts.live) {
77
- const apiPort = opts.port || '7777';
78
- const sseScript = `
79
- <script>
80
- (function(){
81
- const evtSource = new EventSource('http://localhost:${apiPort}/api/v1/events');
82
- evtSource.onmessage = function(e) {
83
- try {
84
- const data = JSON.parse(e.data);
85
- if (data.type === 'stats_update') {
86
- document.querySelectorAll('.stat-card').forEach(card => {
87
- const label = card.querySelector('.stat-label')?.textContent?.toLowerCase();
88
- const num = card.querySelector('.stat-number');
89
- if (label && num && data.stats[label] !== undefined) {
90
- num.textContent = Number(data.stats[label]).toLocaleString();
91
- }
92
- });
93
- }
94
- if (data.type === 'event') {
95
- const dot = document.querySelector('.activity-dot');
96
- if (dot) { dot.style.background = '#ff5577'; setTimeout(() => dot.style.background = '', 500); }
97
- }
98
- } catch {}
99
- };
100
- evtSource.onerror = function() { setTimeout(() => location.reload(), 5000); };
101
- })();
102
- </script>`;
103
- finalHtml = html.replace('</body>', sseScript + '</body>');
104
- }
105
-
106
- writeFileSync(outPath, finalHtml, 'utf-8');
107
- console.log(`${icons.ok} ${c.success('Dashboard written to')} ${c.dim(outPath)}`);
108
- if (opts.live) {
109
- console.log(` ${c.info('Live mode:')} Connected to Brain daemon SSE on port ${opts.port || 7777}`);
110
- }
111
- console.log(` ${c.label('Modules:')} ${c.value(data.stats.modules)} ${c.label('Synapses:')} ${c.value(data.stats.synapses)} ${c.label('Insights:')} ${c.value(data.stats.insights)}`);
112
-
113
- if (opts.open !== false) {
114
- const { exec } = await import('child_process');
115
- exec(`start "" "${outPath}"`);
116
- }
117
- });
118
- });
119
- }
120
-
121
- interface InsightItem {
122
- type: string;
123
- title: string;
124
- description?: string;
125
- priority?: string;
126
- }
127
-
128
- interface SynapseEdge {
129
- source: string;
130
- target: string;
131
- type: string;
132
- weight: number;
133
- }
134
-
135
- interface DashboardData {
136
- stats: {
137
- modules: number;
138
- synapses: number;
139
- errors: number;
140
- solutions: number;
141
- rules: number;
142
- insights: number;
143
- };
144
- langStats: Record<string, number>;
145
- insights: {
146
- templates: InsightItem[];
147
- suggestions: InsightItem[];
148
- trends: InsightItem[];
149
- gaps: InsightItem[];
150
- warnings: InsightItem[];
151
- synergies: InsightItem[];
152
- };
153
- synapseEdges: SynapseEdge[];
154
- }
155
-
156
- function esc(s: string): string {
157
- return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
158
- }
159
-
160
- function generateHtml(data: DashboardData): string {
161
- const { stats, langStats, insights, synapseEdges } = data;
162
-
163
- // Build language chart bars
164
- const sortedLangs = Object.entries(langStats).sort((a, b) => b[1] - a[1]);
165
- const maxLang = sortedLangs[0]?.[1] || 1;
166
- const langBars = sortedLangs.slice(0, 12).map(([lang, count]) => {
167
- const pct = Math.round((count / maxLang) * 100);
168
- return `<div class="lang-row"><span class="lang-name">${esc(lang)}</span><div class="lang-bar-bg"><div class="lang-bar" data-width="${pct}"></div></div><span class="lang-count">${count}</span></div>`;
169
- }).join('\n');
170
-
171
- // Build insight cards
172
- function insightCards(items: InsightItem[], color: string): string {
173
- if (!items.length) return '<p class="empty">Keine Insights in dieser Kategorie.</p>';
174
- return items.slice(0, 30).map(i => {
175
- const prio = i.priority ? `<span class="prio prio-${String(i.priority).toLowerCase()}">${esc(String(i.priority))}</span>` : '';
176
- return `<div class="insight-card ${color}"><div class="insight-header">${prio}<strong>${esc(i.title)}</strong></div><p>${esc((i.description || '').slice(0, 200))}</p></div>`;
177
- }).join('\n');
178
- }
179
-
180
- const totalKnowledge = stats.modules + stats.synapses + stats.errors + stats.solutions;
181
- const activityLevel = Math.min(100, Math.round((stats.insights / Math.max(1, totalKnowledge)) * 1000));
182
-
183
- return `<!DOCTYPE html>
184
- <html lang="de">
185
- <head>
186
- <meta charset="UTF-8">
187
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
188
- <title>Brain — Dashboard</title>
189
- <style>
190
- @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');
191
- *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
192
- :root{
193
- --bg:#04060e;--bg2:rgba(10,12,24,.7);--bg3:rgba(20,24,50,.6);--bg4:rgba(30,35,70,.5);
194
- --glass:rgba(15,18,40,.55);--glass-border:rgba(100,120,255,.12);--glass-hover:rgba(100,120,255,.2);
195
- --text:#e8eaf6;--text2:#8b8fb0;--text3:#4a4d6e;
196
- --blue:#5b9cff;--red:#ff5577;--green:#3dffa0;
197
- --purple:#b47aff;--orange:#ffb347;--cyan:#47e5ff;
198
- --accent:linear-gradient(135deg,#b47aff,#5b9cff,#47e5ff);
199
- --radius:16px;--radius-sm:10px;
200
- }
201
- html{scroll-behavior:smooth}
202
- body{font-family:'Inter',system-ui,sans-serif;background:var(--bg);color:var(--text);line-height:1.6;min-height:100vh;overflow-x:hidden}
203
-
204
- /* Neural canvas background */
205
- #neural-bg{position:fixed;top:0;left:0;width:100%;height:100%;z-index:0;pointer-events:none}
206
-
207
- /* Ambient glow orbs */
208
- .orb{position:fixed;border-radius:50%;filter:blur(120px);opacity:.12;pointer-events:none;z-index:0}
209
- .orb-1{width:600px;height:600px;background:var(--purple);top:-200px;left:-100px;animation:orb-float 20s ease-in-out infinite}
210
- .orb-2{width:500px;height:500px;background:var(--blue);bottom:-150px;right:-100px;animation:orb-float 25s ease-in-out infinite reverse}
211
- .orb-3{width:400px;height:400px;background:var(--cyan);top:40%;left:50%;animation:orb-float 18s ease-in-out infinite 5s}
212
- @keyframes orb-float{0%,100%{transform:translate(0,0) scale(1)}33%{transform:translate(60px,-40px) scale(1.1)}66%{transform:translate(-40px,60px) scale(.9)}}
213
-
214
- .container{max-width:1400px;margin:0 auto;padding:0 28px;position:relative;z-index:1}
215
-
216
- /* Reveal animations */
217
- .reveal{opacity:0;transform:translateY(30px);transition:opacity .6s ease,transform .6s ease}
218
- .reveal.visible{opacity:1;transform:translateY(0)}
219
- .reveal-delay-1{transition-delay:.1s}.reveal-delay-2{transition-delay:.2s}
220
- .reveal-delay-3{transition-delay:.3s}.reveal-delay-4{transition-delay:.4s}
221
- .reveal-delay-5{transition-delay:.5s}
222
-
223
- section{margin-bottom:56px}
224
-
225
- /* Header */
226
- header{padding:60px 0 24px;text-align:center;position:relative}
227
- .logo{display:flex;align-items:center;justify-content:center;gap:20px;margin-bottom:12px}
228
- .logo-icon{
229
- width:68px;height:68px;border-radius:18px;
230
- background:linear-gradient(135deg,var(--purple),var(--blue),var(--cyan));
231
- display:flex;align-items:center;justify-content:center;font-size:32px;
232
- box-shadow:0 0 60px rgba(170,102,255,.35),0 0 120px rgba(90,150,255,.15);
233
- animation:icon-breathe 4s ease-in-out infinite;
234
- position:relative;
235
- }
236
- .logo-icon::after{
237
- content:'';position:absolute;inset:-3px;border-radius:20px;
238
- background:linear-gradient(135deg,var(--purple),var(--cyan));
239
- opacity:.4;filter:blur(8px);z-index:-1;animation:icon-breathe 4s ease-in-out infinite reverse;
240
- }
241
- @keyframes icon-breathe{0%,100%{box-shadow:0 0 60px rgba(170,102,255,.35),0 0 120px rgba(90,150,255,.15)}50%{box-shadow:0 0 80px rgba(170,102,255,.5),0 0 160px rgba(90,150,255,.25)}}
242
- .logo h1{font-size:2.8rem;font-weight:900;letter-spacing:-1px;background:linear-gradient(135deg,#fff 0%,var(--blue) 50%,var(--purple) 100%);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}
243
- .tagline{color:var(--text2);font-size:1.05rem;font-weight:300;letter-spacing:.5px}
244
-
245
- /* Activity indicator */
246
- .activity{display:inline-flex;align-items:center;gap:10px;margin-top:16px;padding:8px 20px;border-radius:30px;background:var(--glass);border:1px solid var(--glass-border);backdrop-filter:blur(20px)}
247
- .activity-dot{width:8px;height:8px;border-radius:50%;background:var(--green);box-shadow:0 0 12px var(--green);animation:pulse-dot 2s ease-in-out infinite}
248
- @keyframes pulse-dot{0%,100%{opacity:1;box-shadow:0 0 12px var(--green)}50%{opacity:.5;box-shadow:0 0 20px var(--green)}}
249
- .activity-text{font-size:.8rem;color:var(--text2);font-weight:500}
250
- .activity-bar{width:80px;height:4px;border-radius:2px;background:var(--bg4);overflow:hidden}
251
- .activity-fill{height:100%;border-radius:2px;background:linear-gradient(90deg,var(--green),var(--cyan));transition:width 1.5s ease}
252
-
253
- /* Nav */
254
- nav{display:flex;justify-content:center;gap:8px;flex-wrap:wrap;padding:20px 0;margin-bottom:40px}
255
- nav a{
256
- color:var(--text2);text-decoration:none;padding:8px 18px;border-radius:24px;font-size:.85rem;font-weight:500;
257
- transition:all .3s ease;border:1px solid transparent;backdrop-filter:blur(10px);
258
- }
259
- nav a:hover{color:var(--text);background:var(--glass);border-color:var(--glass-border);transform:translateY(-1px)}
260
- nav a.research{
261
- background:var(--glass);color:var(--cyan);border-color:rgba(71,229,255,.25);font-weight:600;
262
- box-shadow:0 0 20px rgba(71,229,255,.1);animation:nav-glow 3s ease-in-out infinite alternate;
263
- }
264
- @keyframes nav-glow{0%{box-shadow:0 0 20px rgba(71,229,255,.1)}100%{box-shadow:0 0 35px rgba(71,229,255,.2)}}
265
-
266
- /* Stats */
267
- .stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:18px}
268
- .stat-card{
269
- background:var(--glass);border:1px solid var(--glass-border);border-radius:var(--radius);
270
- padding:28px 22px;text-align:center;position:relative;overflow:hidden;
271
- transition:all .35s ease;backdrop-filter:blur(20px);
272
- }
273
- .stat-card:hover{transform:translateY(-4px);border-color:var(--glass-hover);box-shadow:0 20px 60px rgba(0,0,0,.3)}
274
- .stat-card::before{content:'';position:absolute;top:0;left:0;right:0;height:2px}
275
- .stat-card::after{content:'';position:absolute;top:0;left:0;right:0;bottom:0;background:radial-gradient(ellipse at 50% 0%,rgba(255,255,255,.03),transparent 70%);pointer-events:none}
276
- .stat-card.blue::before{background:linear-gradient(90deg,transparent,var(--blue),transparent)}
277
- .stat-card.purple::before{background:linear-gradient(90deg,transparent,var(--purple),transparent)}
278
- .stat-card.red::before{background:linear-gradient(90deg,transparent,var(--red),transparent)}
279
- .stat-card.green::before{background:linear-gradient(90deg,transparent,var(--green),transparent)}
280
- .stat-card.orange::before{background:linear-gradient(90deg,transparent,var(--orange),transparent)}
281
- .stat-card.cyan::before{background:linear-gradient(90deg,transparent,var(--cyan),transparent)}
282
- .stat-number{font-size:2.6rem;font-weight:900;letter-spacing:-2px}
283
- .stat-card.blue .stat-number{color:var(--blue)}.stat-card.purple .stat-number{color:var(--purple)}
284
- .stat-card.red .stat-number{color:var(--red)}.stat-card.green .stat-number{color:var(--green)}
285
- .stat-card.orange .stat-number{color:var(--orange)}.stat-card.cyan .stat-number{color:var(--cyan)}
286
- .stat-label{color:var(--text2);font-size:.82rem;margin-top:6px;font-weight:500;letter-spacing:.3px;text-transform:uppercase}
287
-
288
- /* Section titles */
289
- .section-title{font-size:1.5rem;font-weight:700;margin-bottom:24px;display:flex;align-items:center;gap:12px}
290
- .section-title .icon{font-size:1.2rem;width:38px;height:38px;border-radius:var(--radius-sm);display:flex;align-items:center;justify-content:center;backdrop-filter:blur(10px)}
291
-
292
- /* Language chart */
293
- .lang-chart{max-width:650px}
294
- .lang-row{display:flex;align-items:center;gap:14px;margin-bottom:10px}
295
- .lang-name{width:100px;text-align:right;font-size:.85rem;color:var(--text2);font-weight:500}
296
- .lang-bar-bg{flex:1;height:28px;background:var(--bg3);border-radius:6px;overflow:hidden;border:1px solid var(--glass-border)}
297
- .lang-bar{height:100%;background:var(--accent);border-radius:6px;width:0;transition:width 1.2s cubic-bezier(.22,1,.36,1)}
298
- .lang-count{width:50px;font-size:.85rem;color:var(--text2);font-weight:600}
299
-
300
- /* Insight tabs */
301
- .tab-bar{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:24px}
302
- .tab-btn{
303
- padding:10px 20px;border-radius:24px;border:1px solid var(--glass-border);
304
- background:var(--glass);color:var(--text2);cursor:pointer;font-size:.85rem;font-weight:500;
305
- transition:all .3s ease;backdrop-filter:blur(10px);font-family:inherit;
306
- }
307
- .tab-btn:hover{border-color:var(--glass-hover);color:var(--text);transform:translateY(-1px)}
308
- .tab-btn.active{border-color:rgba(71,229,255,.35);color:var(--cyan);background:rgba(71,229,255,.08);box-shadow:0 0 20px rgba(71,229,255,.1)}
309
- .tab-btn .count{background:var(--bg4);padding:2px 8px;border-radius:12px;font-size:.72rem;margin-left:6px;font-weight:600}
310
- .tab-panel{display:none}.tab-panel.active{display:block}
311
- .insight-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(380px,1fr));gap:14px}
312
- .insight-card{
313
- background:var(--glass);border:1px solid var(--glass-border);border-radius:var(--radius-sm);
314
- padding:18px;border-left:3px solid var(--text3);transition:all .25s ease;backdrop-filter:blur(20px);
315
- }
316
- .insight-card:hover{transform:translateX(6px);border-color:var(--glass-hover);box-shadow:0 8px 30px rgba(0,0,0,.2)}
317
- .insight-card.cyan{border-left-color:var(--cyan)}.insight-card.orange{border-left-color:var(--orange)}
318
- .insight-card.green{border-left-color:var(--green)}.insight-card.red{border-left-color:var(--red)}
319
- .insight-card.purple{border-left-color:var(--purple)}.insight-card.blue{border-left-color:var(--blue)}
320
- .insight-header{display:flex;align-items:center;gap:8px;margin-bottom:8px;flex-wrap:wrap}
321
- .insight-card p{color:var(--text2);font-size:.85rem;line-height:1.5}
322
- .prio{font-size:.68rem;padding:3px 10px;border-radius:12px;text-transform:uppercase;font-weight:700;letter-spacing:.5px}
323
- .prio-critical{background:rgba(255,85,119,.15);color:var(--red);border:1px solid rgba(255,85,119,.25)}
324
- .prio-high{background:rgba(255,179,71,.15);color:var(--orange);border:1px solid rgba(255,179,71,.25)}
325
- .prio-medium{background:rgba(91,156,255,.15);color:var(--blue);border:1px solid rgba(91,156,255,.25)}
326
- .prio-low{background:rgba(139,143,176,.1);color:var(--text2);border:1px solid rgba(139,143,176,.2)}
327
- .empty{color:var(--text3);font-style:italic;padding:24px}
328
-
329
- /* Graph */
330
- .graph-container{position:relative;background:var(--glass);border:1px solid var(--glass-border);border-radius:var(--radius);overflow:hidden;backdrop-filter:blur(20px)}
331
- #synapse-graph{width:100%;height:650px;display:block;cursor:grab}
332
- #synapse-graph:active{cursor:grabbing}
333
- .graph-legend{display:flex;gap:16px;flex-wrap:wrap;padding:12px 20px;border-top:1px solid var(--glass-border);font-size:.8rem;color:var(--text2)}
334
- .legend-dot{display:inline-block;width:10px;height:10px;border-radius:50%;margin-right:6px;vertical-align:middle}
335
- .graph-tooltip{position:absolute;display:none;background:var(--bg2);border:1px solid var(--glass-border);border-radius:8px;padding:8px 14px;font-size:.8rem;color:var(--text);pointer-events:none;z-index:10;backdrop-filter:blur(20px);box-shadow:0 8px 30px rgba(0,0,0,.3)}
336
-
337
- /* Footer */
338
- footer{text-align:center;padding:40px 0;border-top:1px solid var(--glass-border)}
339
- footer p{color:var(--text3);font-size:.8rem}
340
- footer code{background:var(--glass);padding:3px 10px;border-radius:6px;font-size:.78rem;border:1px solid var(--glass-border)}
341
-
342
- /* Responsive */
343
- @media(max-width:600px){.stats-grid{grid-template-columns:1fr 1fr}.insight-grid{grid-template-columns:1fr}.logo h1{font-size:2rem}}
344
- </style>
345
- </head>
346
- <body>
347
-
348
- <canvas id="neural-bg"></canvas>
349
- <div class="orb orb-1"></div>
350
- <div class="orb orb-2"></div>
351
- <div class="orb orb-3"></div>
352
-
353
- <div class="container">
354
- <header class="reveal">
355
- <div class="logo">
356
- <div class="logo-icon">&#129504;</div>
357
- <h1>Brain</h1>
358
- </div>
359
- <p class="tagline">Adaptive Code Intelligence</p>
360
- <div class="activity">
361
- <span class="activity-dot"></span>
362
- <span class="activity-text">Neural Activity</span>
363
- <div class="activity-bar"><div class="activity-fill" style="width:0%" data-target="${activityLevel}"></div></div>
364
- <span class="activity-text" style="color:var(--cyan);font-weight:700">${activityLevel}%</span>
365
- </div>
366
- </header>
367
-
368
- <nav class="reveal reveal-delay-1">
369
- <a href="#stats">Stats</a>
370
- <a href="#languages">Languages</a>
371
- <a href="#network">&#128300; Network</a>
372
- <a href="#research" class="research">&#128161; Research</a>
373
- </nav>
374
-
375
- <section id="stats" class="reveal reveal-delay-2">
376
- <div class="section-title"><div class="icon" style="background:rgba(91,156,255,.1)">&#128202;</div> Neural Status</div>
377
- <div class="stats-grid">
378
- <div class="stat-card blue"><div class="stat-number">${stats.modules.toLocaleString()}</div><div class="stat-label">Modules</div></div>
379
- <div class="stat-card purple"><div class="stat-number">${stats.synapses.toLocaleString()}</div><div class="stat-label">Synapses</div></div>
380
- <div class="stat-card cyan"><div class="stat-number">${stats.insights}</div><div class="stat-label">Insights</div></div>
381
- <div class="stat-card red"><div class="stat-number">${stats.errors}</div><div class="stat-label">Errors</div></div>
382
- <div class="stat-card green"><div class="stat-number">${stats.solutions}</div><div class="stat-label">Solutions</div></div>
383
- <div class="stat-card orange"><div class="stat-number">${stats.rules}</div><div class="stat-label">Rules</div></div>
384
- </div>
385
- </section>
386
-
387
- <section id="languages" class="reveal reveal-delay-3">
388
- <div class="section-title"><div class="icon" style="background:rgba(180,122,255,.1)">&#128187;</div> Languages</div>
389
- <div class="lang-chart">${langBars}</div>
390
- </section>
391
-
392
- <section id="network" class="reveal reveal-delay-4">
393
- <div class="section-title"><div class="icon" style="background:rgba(71,229,255,.1)">&#128300;</div> Synapse Network</div>
394
- <div class="graph-container">
395
- <canvas id="synapse-graph"></canvas>
396
- <div class="graph-legend">
397
- <span><span class="legend-dot" style="background:#ff5577"></span> error</span>
398
- <span><span class="legend-dot" style="background:#3dffa0"></span> solution</span>
399
- <span><span class="legend-dot" style="background:#b47aff"></span> code_module</span>
400
- <span><span class="legend-dot" style="background:#ffb347"></span> project</span>
401
- <span><span class="legend-dot" style="background:#5b9cff"></span> rule</span>
402
- <span style="margin-left:auto;color:var(--text3);font-size:.72rem">edges: co_occurs / solves / uses_module / depends_on</span>
403
- </div>
404
- <div id="graph-tooltip" class="graph-tooltip"></div>
405
- </div>
406
- </section>
407
-
408
- <section id="research" class="reveal reveal-delay-5">
409
- <div class="section-title"><div class="icon" style="background:rgba(71,229,255,.1)">&#128300;</div> Research Insights</div>
410
- <div class="tab-bar">
411
- <button class="tab-btn active" data-tab="templates">&#127912; Templates <span class="count">${insights.templates.length}</span></button>
412
- <button class="tab-btn" data-tab="suggestions">&#128161; Suggestions <span class="count">${insights.suggestions.length}</span></button>
413
- <button class="tab-btn" data-tab="trends">&#128200; Trends <span class="count">${insights.trends.length}</span></button>
414
- <button class="tab-btn" data-tab="gaps">&#9888;&#65039; Gaps <span class="count">${insights.gaps.length}</span></button>
415
- <button class="tab-btn" data-tab="synergies">&#9889; Synergies <span class="count">${insights.synergies.length}</span></button>
416
- <button class="tab-btn" data-tab="warnings">&#128680; Warnings <span class="count">${insights.warnings.length}</span></button>
417
- </div>
418
- <div class="tab-panel active" id="tab-templates"><div class="insight-grid">${insightCards(insights.templates, 'cyan')}</div></div>
419
- <div class="tab-panel" id="tab-suggestions"><div class="insight-grid">${insightCards(insights.suggestions, 'orange')}</div></div>
420
- <div class="tab-panel" id="tab-trends"><div class="insight-grid">${insightCards(insights.trends, 'green')}</div></div>
421
- <div class="tab-panel" id="tab-gaps"><div class="insight-grid">${insightCards(insights.gaps, 'red')}</div></div>
422
- <div class="tab-panel" id="tab-synergies"><div class="insight-grid">${insightCards(insights.synergies, 'purple')}</div></div>
423
- <div class="tab-panel" id="tab-warnings"><div class="insight-grid">${insightCards(insights.warnings, 'red')}</div></div>
424
- </section>
425
-
426
- <footer class="reveal reveal-delay-5">
427
- <p>Brain v1.0 &mdash; <code>brain dashboard</code></p>
428
- </footer>
429
- </div>
430
-
431
- <script>
432
- // --- Neural Network Canvas ---
433
- (function(){
434
- const canvas = document.getElementById('neural-bg');
435
- const ctx = canvas.getContext('2d');
436
- let W, H, nodes = [], mouse = {x:-1000,y:-1000};
437
-
438
- function resize(){
439
- W = canvas.width = window.innerWidth;
440
- H = canvas.height = window.innerHeight;
441
- }
442
- resize();
443
- window.addEventListener('resize', resize);
444
- document.addEventListener('mousemove', e => { mouse.x = e.clientX; mouse.y = e.clientY; });
445
-
446
- const NODE_COUNT = Math.min(80, Math.floor(window.innerWidth / 18));
447
- const CONNECT_DIST = 180;
448
- const MOUSE_DIST = 200;
449
-
450
- for(let i = 0; i < NODE_COUNT; i++){
451
- nodes.push({
452
- x: Math.random() * W,
453
- y: Math.random() * H,
454
- vx: (Math.random() - 0.5) * 0.4,
455
- vy: (Math.random() - 0.5) * 0.4,
456
- r: Math.random() * 2 + 1,
457
- pulse: Math.random() * Math.PI * 2,
458
- });
459
- }
460
-
461
- function draw(){
462
- ctx.clearRect(0, 0, W, H);
463
-
464
- // Draw connections
465
- for(let i = 0; i < nodes.length; i++){
466
- for(let j = i + 1; j < nodes.length; j++){
467
- const dx = nodes[i].x - nodes[j].x;
468
- const dy = nodes[i].y - nodes[j].y;
469
- const dist = Math.sqrt(dx*dx + dy*dy);
470
- if(dist < CONNECT_DIST){
471
- const alpha = (1 - dist / CONNECT_DIST) * 0.15;
472
- ctx.strokeStyle = 'rgba(91,156,255,' + alpha + ')';
473
- ctx.lineWidth = 0.5;
474
- ctx.beginPath();
475
- ctx.moveTo(nodes[i].x, nodes[i].y);
476
- ctx.lineTo(nodes[j].x, nodes[j].y);
477
- ctx.stroke();
478
- }
479
- }
480
-
481
- // Mouse interaction
482
- const mdx = nodes[i].x - mouse.x;
483
- const mdy = nodes[i].y - mouse.y;
484
- const mDist = Math.sqrt(mdx*mdx + mdy*mdy);
485
- if(mDist < MOUSE_DIST){
486
- const alpha = (1 - mDist / MOUSE_DIST) * 0.4;
487
- ctx.strokeStyle = 'rgba(180,122,255,' + alpha + ')';
488
- ctx.lineWidth = 1;
489
- ctx.beginPath();
490
- ctx.moveTo(nodes[i].x, nodes[i].y);
491
- ctx.lineTo(mouse.x, mouse.y);
492
- ctx.stroke();
493
- }
494
- }
495
-
496
- // Draw nodes
497
- const time = Date.now() * 0.001;
498
- for(const n of nodes){
499
- const glow = 0.4 + Math.sin(time * 1.5 + n.pulse) * 0.3;
500
- ctx.fillStyle = 'rgba(91,156,255,' + glow + ')';
501
- ctx.beginPath();
502
- ctx.arc(n.x, n.y, n.r, 0, Math.PI * 2);
503
- ctx.fill();
504
-
505
- n.x += n.vx;
506
- n.y += n.vy;
507
- if(n.x < 0 || n.x > W) n.vx *= -1;
508
- if(n.y < 0 || n.y > H) n.vy *= -1;
509
- }
510
-
511
- requestAnimationFrame(draw);
512
- }
513
- draw();
514
- })();
515
-
516
- // --- Reveal on scroll ---
517
- const observer = new IntersectionObserver(entries => {
518
- entries.forEach(e => { if(e.isIntersecting) e.target.classList.add('visible'); });
519
- }, {threshold: 0.1});
520
- document.querySelectorAll('.reveal').forEach(el => observer.observe(el));
521
-
522
- // --- Tab switching ---
523
- document.querySelectorAll('.tab-btn').forEach(btn => {
524
- btn.addEventListener('click', () => {
525
- document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
526
- document.querySelectorAll('.tab-panel').forEach(p => p.classList.remove('active'));
527
- btn.classList.add('active');
528
- document.getElementById('tab-' + btn.dataset.tab).classList.add('active');
529
- });
530
- });
531
-
532
- // --- Animate stat numbers ---
533
- const numObserver = new IntersectionObserver(entries => {
534
- entries.forEach(e => {
535
- if(!e.isIntersecting) return;
536
- const el = e.target;
537
- if(el.dataset.animated) return;
538
- el.dataset.animated = '1';
539
- const target = parseInt(el.textContent.replace(/\\D/g,''), 10);
540
- if(isNaN(target) || target === 0) return;
541
- const duration = 1200;
542
- const start = performance.now();
543
- function tick(now){
544
- const t = Math.min((now - start) / duration, 1);
545
- const ease = 1 - Math.pow(1 - t, 3);
546
- el.textContent = Math.round(target * ease).toLocaleString();
547
- if(t < 1) requestAnimationFrame(tick);
548
- }
549
- requestAnimationFrame(tick);
550
- });
551
- }, {threshold: 0.5});
552
- document.querySelectorAll('.stat-number').forEach(el => numObserver.observe(el));
553
-
554
- // --- Animate language bars ---
555
- setTimeout(() => {
556
- document.querySelectorAll('.lang-bar').forEach(bar => {
557
- bar.style.width = bar.dataset.width + '%';
558
- });
559
- }, 300);
560
-
561
- // --- Activity bar ---
562
- setTimeout(() => {
563
- document.querySelectorAll('.activity-fill').forEach(el => {
564
- el.style.width = el.dataset.target + '%';
565
- });
566
- }, 500);
567
-
568
- // --- Synapse Force-Directed Graph (Premium) ---
569
- (function(){
570
- const edges = ${JSON.stringify(synapseEdges.map((e: SynapseEdge) => ({ s: e.source, t: e.target, type: e.type, w: e.weight })))};
571
- const canvas = document.getElementById('synapse-graph');
572
- if (!canvas || !edges.length) return;
573
- const ctx = canvas.getContext('2d');
574
- const container = canvas.parentElement;
575
- let W, H, dpr;
576
- let frame = 0;
577
-
578
- const NODE_COLORS = {
579
- error: '#ff5577', solution: '#3dffa0', code_module: '#b47aff',
580
- project: '#ffb347', rule: '#5b9cff', antipattern: '#ff5577'
581
- };
582
- const EDGE_COLORS = {
583
- co_occurs: ['#5b9cff','#47e5ff'], solves: ['#3dffa0','#5bff8a'],
584
- uses_module: ['#b47aff','#7a5cff'], depends_on: ['#ff5577','#ffb347'],
585
- caused_by: ['#ff5577','#ff8866']
586
- };
587
- const DEFAULT_COLOR = '#47e5ff';
588
-
589
- // Build graph nodes & edges
590
- const nodeMap = new Map();
591
- const graphEdges = [];
592
- for (const e of edges) {
593
- if (!nodeMap.has(e.s)) nodeMap.set(e.s, { id: e.s, type: e.s.split(':')[0], x: 0, y: 0, vx: 0, vy: 0, connections: 0 });
594
- if (!nodeMap.has(e.t)) nodeMap.set(e.t, { id: e.t, type: e.t.split(':')[0], x: 0, y: 0, vx: 0, vy: 0, connections: 0 });
595
- nodeMap.get(e.s).connections++;
596
- nodeMap.get(e.t).connections++;
597
- graphEdges.push({ source: nodeMap.get(e.s), target: nodeMap.get(e.t), type: e.type, weight: e.w });
598
- }
599
- const nodes = [...nodeMap.values()];
600
-
601
- function resize() {
602
- dpr = window.devicePixelRatio || 1;
603
- W = container.clientWidth;
604
- H = 650;
605
- canvas.width = W * dpr;
606
- canvas.height = H * dpr;
607
- canvas.style.width = W + 'px';
608
- canvas.style.height = H + 'px';
609
- ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
610
- }
611
- resize();
612
- window.addEventListener('resize', resize);
613
-
614
- // Cluster initial positions by type for better layout
615
- const typeGroups = {};
616
- for (const n of nodes) {
617
- if (!typeGroups[n.type]) typeGroups[n.type] = [];
618
- typeGroups[n.type].push(n);
619
- }
620
- const types = Object.keys(typeGroups);
621
- types.forEach((t, i) => {
622
- const angle = (i / types.length) * Math.PI * 2;
623
- const cx = W/2 + Math.cos(angle) * W * 0.2;
624
- const cy = H/2 + Math.sin(angle) * H * 0.2;
625
- for (const n of typeGroups[t]) {
626
- n.x = cx + (Math.random() - 0.5) * W * 0.25;
627
- n.y = cy + (Math.random() - 0.5) * H * 0.25;
628
- }
629
- });
630
-
631
- // Force simulation
632
- const REPULSION = 4000;
633
- const ATTRACTION = 0.006;
634
- const DAMPING = 0.88;
635
- const CENTER_GRAVITY = 0.0015;
636
- let hovered = null;
637
- let dragging = null;
638
- let dragOff = {x:0,y:0};
639
-
640
- function simulate() {
641
- for (let i = 0; i < nodes.length; i++) {
642
- for (let j = i + 1; j < nodes.length; j++) {
643
- let dx = nodes[i].x - nodes[j].x;
644
- let dy = nodes[i].y - nodes[j].y;
645
- let dist = Math.sqrt(dx*dx + dy*dy) || 1;
646
- let force = REPULSION / (dist * dist);
647
- let fx = (dx / dist) * force;
648
- let fy = (dy / dist) * force;
649
- nodes[i].vx += fx; nodes[i].vy += fy;
650
- nodes[j].vx -= fx; nodes[j].vy -= fy;
651
- }
652
- }
653
- for (const e of graphEdges) {
654
- let dx = e.target.x - e.source.x;
655
- let dy = e.target.y - e.source.y;
656
- let dist = Math.sqrt(dx*dx + dy*dy) || 1;
657
- let force = (dist - 120) * ATTRACTION * e.weight;
658
- let fx = (dx / dist) * force;
659
- let fy = (dy / dist) * force;
660
- e.source.vx += fx; e.source.vy += fy;
661
- e.target.vx -= fx; e.target.vy -= fy;
662
- }
663
- for (const n of nodes) {
664
- n.vx += (W/2 - n.x) * CENTER_GRAVITY;
665
- n.vy += (H/2 - n.y) * CENTER_GRAVITY;
666
- }
667
- for (const n of nodes) {
668
- if (n === dragging) continue;
669
- n.vx *= DAMPING; n.vy *= DAMPING;
670
- n.x += n.vx; n.y += n.vy;
671
- n.x = Math.max(30, Math.min(W - 30, n.x));
672
- n.y = Math.max(30, Math.min(H - 30, n.y));
673
- }
674
- }
675
-
676
- function getNodeRadius(n) {
677
- return Math.min(20, 4 + Math.sqrt(n.connections) * 3.5);
678
- }
679
-
680
- function draw() {
681
- frame++;
682
- ctx.clearRect(0, 0, W, H);
683
-
684
- // Edges with gradient colors per type
685
- for (const e of graphEdges) {
686
- const alpha = 0.1 + e.weight * 0.4;
687
- const colors = EDGE_COLORS[e.type] || ['#5b9cff','#47e5ff'];
688
- const grad = ctx.createLinearGradient(e.source.x, e.source.y, e.target.x, e.target.y);
689
- grad.addColorStop(0, colors[0] + Math.round(Math.min(0.7,alpha)*255).toString(16).padStart(2,'0'));
690
- grad.addColorStop(1, colors[1] + Math.round(Math.min(0.7,alpha)*255).toString(16).padStart(2,'0'));
691
- ctx.strokeStyle = grad;
692
- ctx.lineWidth = 0.5 + e.weight * 2.5;
693
- ctx.beginPath();
694
- ctx.moveTo(e.source.x, e.source.y);
695
- ctx.lineTo(e.target.x, e.target.y);
696
- ctx.stroke();
697
- }
698
-
699
- // Nodes with ambient glow + pulse on hubs
700
- for (const n of nodes) {
701
- const r = getNodeRadius(n);
702
- const color = NODE_COLORS[n.type] || DEFAULT_COLOR;
703
- const isHover = n === hovered || n === dragging;
704
- const isHub = n.connections >= 5;
705
-
706
- // Ambient glow for all nodes
707
- const glowSize = isHover ? 30 : (isHub ? 15 + Math.sin(frame * 0.03 + n.x) * 5 : 8);
708
- ctx.shadowColor = color;
709
- ctx.shadowBlur = glowSize;
710
-
711
- // Outer ring for hubs
712
- if (isHub || isHover) {
713
- const pulseR = r + 3 + (isHub ? Math.sin(frame * 0.04 + n.y) * 2 : 0);
714
- ctx.strokeStyle = color;
715
- ctx.globalAlpha = isHover ? 0.6 : 0.25;
716
- ctx.lineWidth = 1.5;
717
- ctx.beginPath();
718
- ctx.arc(n.x, n.y, pulseR, 0, Math.PI * 2);
719
- ctx.stroke();
720
- }
721
-
722
- // Core node
723
- ctx.globalAlpha = isHover ? 1 : 0.85;
724
- ctx.fillStyle = color;
725
- ctx.beginPath();
726
- ctx.arc(n.x, n.y, r, 0, Math.PI * 2);
727
- ctx.fill();
728
-
729
- // Inner highlight (glossy effect)
730
- ctx.globalAlpha = 0.3;
731
- ctx.fillStyle = '#ffffff';
732
- ctx.beginPath();
733
- ctx.arc(n.x - r * 0.25, n.y - r * 0.25, r * 0.4, 0, Math.PI * 2);
734
- ctx.fill();
735
-
736
- ctx.globalAlpha = 1;
737
- ctx.shadowBlur = 0;
738
-
739
- // Labels
740
- if (isHover || n.connections >= 4) {
741
- const label = n.type === 'project' ? n.id.replace('project:','P') : n.id.split(':')[0];
742
- ctx.fillStyle = '#e8eaf6';
743
- ctx.font = (isHover ? 'bold 12px' : '10px') + ' Inter, system-ui, sans-serif';
744
- ctx.textAlign = 'center';
745
- ctx.globalAlpha = isHover ? 1 : 0.7;
746
- ctx.fillText(isHover ? n.id : label, n.x, n.y - r - 8);
747
- ctx.globalAlpha = 1;
748
- }
749
- }
750
- simulate();
751
- requestAnimationFrame(draw);
752
- }
753
- draw();
754
-
755
- // Interaction
756
- const tooltip = document.getElementById('graph-tooltip');
757
- function getNodeAt(mx, my) {
758
- for (let i = nodes.length - 1; i >= 0; i--) {
759
- const n = nodes[i], r = getNodeRadius(n);
760
- if (Math.hypot(mx - n.x, my - n.y) <= r + 4) return n;
761
- }
762
- return null;
763
- }
764
- function getPos(e) {
765
- const rect = canvas.getBoundingClientRect();
766
- return { x: e.clientX - rect.left, y: e.clientY - rect.top };
767
- }
768
- canvas.addEventListener('mousemove', function(e) {
769
- const p = getPos(e);
770
- if (dragging) {
771
- dragging.x = p.x + dragOff.x;
772
- dragging.y = p.y + dragOff.y;
773
- dragging.vx = 0; dragging.vy = 0;
774
- return;
775
- }
776
- const n = getNodeAt(p.x, p.y);
777
- hovered = n;
778
- canvas.style.cursor = n ? 'pointer' : 'grab';
779
- if (n) {
780
- const conns = graphEdges.filter(e => e.source === n || e.target === n);
781
- const types = {};
782
- conns.forEach(c => { types[c.type] = (types[c.type]||0)+1; });
783
- const typeStr = Object.entries(types).map(([t,c]) => t+': '+c).join(', ');
784
- tooltip.innerHTML = '<strong>' + n.id + '</strong><br>' + conns.length + ' connections<br><span style="color:var(--text3);font-size:.75rem">' + typeStr + '</span>';
785
- tooltip.style.display = 'block';
786
- tooltip.style.left = (p.x + 15) + 'px';
787
- tooltip.style.top = (p.y - 10) + 'px';
788
- } else {
789
- tooltip.style.display = 'none';
790
- }
791
- });
792
- canvas.addEventListener('mousedown', function(e) {
793
- const p = getPos(e);
794
- const n = getNodeAt(p.x, p.y);
795
- if (n) {
796
- dragging = n;
797
- dragOff = { x: n.x - p.x, y: n.y - p.y };
798
- canvas.style.cursor = 'grabbing';
799
- }
800
- });
801
- canvas.addEventListener('mouseup', function() { dragging = null; });
802
- canvas.addEventListener('mouseleave', function() { dragging = null; hovered = null; tooltip.style.display = 'none'; });
803
- })();
804
- </script>
805
- </body>
806
- </html>`;
807
- }
1
+ <!DOCTYPE html>
2
+ <html lang="de">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Brain — Dashboard</title>
7
+ <style>
8
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');
9
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
10
+ :root{
11
+ --bg:#04060e;--bg2:rgba(10,12,24,.7);--bg3:rgba(20,24,50,.6);--bg4:rgba(30,35,70,.5);
12
+ --glass:rgba(15,18,40,.55);--glass-border:rgba(100,120,255,.12);--glass-hover:rgba(100,120,255,.2);
13
+ --text:#e8eaf6;--text2:#8b8fb0;--text3:#4a4d6e;
14
+ --blue:#5b9cff;--red:#ff5577;--green:#3dffa0;
15
+ --purple:#b47aff;--orange:#ffb347;--cyan:#47e5ff;
16
+ --accent:linear-gradient(135deg,#b47aff,#5b9cff,#47e5ff);
17
+ --radius:16px;--radius-sm:10px;
18
+ }
19
+ html{scroll-behavior:smooth}
20
+ body{font-family:'Inter',system-ui,sans-serif;background:var(--bg);color:var(--text);line-height:1.6;min-height:100vh;overflow-x:hidden}
21
+
22
+ /* Neural canvas background */
23
+ #neural-bg{position:fixed;top:0;left:0;width:100%;height:100%;z-index:0;pointer-events:none}
24
+
25
+ /* Ambient glow orbs */
26
+ .orb{position:fixed;border-radius:50%;filter:blur(120px);opacity:.12;pointer-events:none;z-index:0}
27
+ .orb-1{width:600px;height:600px;background:var(--purple);top:-200px;left:-100px;animation:orb-float 20s ease-in-out infinite}
28
+ .orb-2{width:500px;height:500px;background:var(--blue);bottom:-150px;right:-100px;animation:orb-float 25s ease-in-out infinite reverse}
29
+ .orb-3{width:400px;height:400px;background:var(--cyan);top:40%;left:50%;animation:orb-float 18s ease-in-out infinite 5s}
30
+ @keyframes orb-float{0%,100%{transform:translate(0,0) scale(1)}33%{transform:translate(60px,-40px) scale(1.1)}66%{transform:translate(-40px,60px) scale(.9)}}
31
+
32
+ .container{max-width:1400px;margin:0 auto;padding:0 28px;position:relative;z-index:1}
33
+
34
+ /* Reveal animations */
35
+ .reveal{opacity:0;transform:translateY(30px);transition:opacity .6s ease,transform .6s ease}
36
+ .reveal.visible{opacity:1;transform:translateY(0)}
37
+ .reveal-delay-1{transition-delay:.1s}.reveal-delay-2{transition-delay:.2s}
38
+ .reveal-delay-3{transition-delay:.3s}.reveal-delay-4{transition-delay:.4s}
39
+ .reveal-delay-5{transition-delay:.5s}
40
+
41
+ section{margin-bottom:56px}
42
+
43
+ /* Header */
44
+ header{padding:60px 0 24px;text-align:center;position:relative}
45
+ .logo{display:flex;align-items:center;justify-content:center;gap:20px;margin-bottom:12px}
46
+ .logo-icon{
47
+ width:68px;height:68px;border-radius:18px;
48
+ background:linear-gradient(135deg,var(--purple),var(--blue),var(--cyan));
49
+ display:flex;align-items:center;justify-content:center;font-size:32px;
50
+ box-shadow:0 0 60px rgba(170,102,255,.35),0 0 120px rgba(90,150,255,.15);
51
+ animation:icon-breathe 4s ease-in-out infinite;
52
+ position:relative;
53
+ }
54
+ .logo-icon::after{
55
+ content:'';position:absolute;inset:-3px;border-radius:20px;
56
+ background:linear-gradient(135deg,var(--purple),var(--cyan));
57
+ opacity:.4;filter:blur(8px);z-index:-1;animation:icon-breathe 4s ease-in-out infinite reverse;
58
+ }
59
+ @keyframes icon-breathe{0%,100%{box-shadow:0 0 60px rgba(170,102,255,.35),0 0 120px rgba(90,150,255,.15)}50%{box-shadow:0 0 80px rgba(170,102,255,.5),0 0 160px rgba(90,150,255,.25)}}
60
+ .logo h1{font-size:2.8rem;font-weight:900;letter-spacing:-1px;background:linear-gradient(135deg,#fff 0%,var(--blue) 50%,var(--purple) 100%);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}
61
+ .tagline{color:var(--text2);font-size:1.05rem;font-weight:300;letter-spacing:.5px}
62
+
63
+ /* Activity indicator */
64
+ .activity{display:inline-flex;align-items:center;gap:10px;margin-top:16px;padding:8px 20px;border-radius:30px;background:var(--glass);border:1px solid var(--glass-border);backdrop-filter:blur(20px)}
65
+ .activity-dot{width:8px;height:8px;border-radius:50%;background:var(--green);box-shadow:0 0 12px var(--green);animation:pulse-dot 2s ease-in-out infinite}
66
+ @keyframes pulse-dot{0%,100%{opacity:1;box-shadow:0 0 12px var(--green)}50%{opacity:.5;box-shadow:0 0 20px var(--green)}}
67
+ .activity-text{font-size:.8rem;color:var(--text2);font-weight:500}
68
+ .activity-bar{width:80px;height:4px;border-radius:2px;background:var(--bg4);overflow:hidden}
69
+ .activity-fill{height:100%;border-radius:2px;background:linear-gradient(90deg,var(--green),var(--cyan));transition:width 1.5s ease}
70
+
71
+ /* Nav */
72
+ nav{display:flex;justify-content:center;gap:8px;flex-wrap:wrap;padding:20px 0;margin-bottom:40px}
73
+ nav a{
74
+ color:var(--text2);text-decoration:none;padding:8px 18px;border-radius:24px;font-size:.85rem;font-weight:500;
75
+ transition:all .3s ease;border:1px solid transparent;backdrop-filter:blur(10px);
76
+ }
77
+ nav a:hover{color:var(--text);background:var(--glass);border-color:var(--glass-border);transform:translateY(-1px)}
78
+ nav a.research{
79
+ background:var(--glass);color:var(--cyan);border-color:rgba(71,229,255,.25);font-weight:600;
80
+ box-shadow:0 0 20px rgba(71,229,255,.1);animation:nav-glow 3s ease-in-out infinite alternate;
81
+ }
82
+ @keyframes nav-glow{0%{box-shadow:0 0 20px rgba(71,229,255,.1)}100%{box-shadow:0 0 35px rgba(71,229,255,.2)}}
83
+
84
+ /* Stats */
85
+ .stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:18px}
86
+ .stat-card{
87
+ background:var(--glass);border:1px solid var(--glass-border);border-radius:var(--radius);
88
+ padding:28px 22px;text-align:center;position:relative;overflow:hidden;
89
+ transition:all .35s ease;backdrop-filter:blur(20px);
90
+ }
91
+ .stat-card:hover{transform:translateY(-4px);border-color:var(--glass-hover);box-shadow:0 20px 60px rgba(0,0,0,.3)}
92
+ .stat-card::before{content:'';position:absolute;top:0;left:0;right:0;height:2px}
93
+ .stat-card::after{content:'';position:absolute;top:0;left:0;right:0;bottom:0;background:radial-gradient(ellipse at 50% 0%,rgba(255,255,255,.03),transparent 70%);pointer-events:none}
94
+ .stat-card.blue::before{background:linear-gradient(90deg,transparent,var(--blue),transparent)}
95
+ .stat-card.purple::before{background:linear-gradient(90deg,transparent,var(--purple),transparent)}
96
+ .stat-card.red::before{background:linear-gradient(90deg,transparent,var(--red),transparent)}
97
+ .stat-card.green::before{background:linear-gradient(90deg,transparent,var(--green),transparent)}
98
+ .stat-card.orange::before{background:linear-gradient(90deg,transparent,var(--orange),transparent)}
99
+ .stat-card.cyan::before{background:linear-gradient(90deg,transparent,var(--cyan),transparent)}
100
+ .stat-number{font-size:2.6rem;font-weight:900;letter-spacing:-2px}
101
+ .stat-card.blue .stat-number{color:var(--blue)}.stat-card.purple .stat-number{color:var(--purple)}
102
+ .stat-card.red .stat-number{color:var(--red)}.stat-card.green .stat-number{color:var(--green)}
103
+ .stat-card.orange .stat-number{color:var(--orange)}.stat-card.cyan .stat-number{color:var(--cyan)}
104
+ .stat-label{color:var(--text2);font-size:.82rem;margin-top:6px;font-weight:500;letter-spacing:.3px;text-transform:uppercase}
105
+
106
+ /* Section titles */
107
+ .section-title{font-size:1.5rem;font-weight:700;margin-bottom:24px;display:flex;align-items:center;gap:12px}
108
+ .section-title .icon{font-size:1.2rem;width:38px;height:38px;border-radius:var(--radius-sm);display:flex;align-items:center;justify-content:center;backdrop-filter:blur(10px)}
109
+
110
+ /* Language chart */
111
+ .lang-chart{max-width:650px}
112
+ .lang-row{display:flex;align-items:center;gap:14px;margin-bottom:10px}
113
+ .lang-name{width:100px;text-align:right;font-size:.85rem;color:var(--text2);font-weight:500}
114
+ .lang-bar-bg{flex:1;height:28px;background:var(--bg3);border-radius:6px;overflow:hidden;border:1px solid var(--glass-border)}
115
+ .lang-bar{height:100%;background:var(--accent);border-radius:6px;width:0;transition:width 1.2s cubic-bezier(.22,1,.36,1)}
116
+ .lang-count{width:50px;font-size:.85rem;color:var(--text2);font-weight:600}
117
+
118
+ /* Insight tabs */
119
+ .tab-bar{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:24px}
120
+ .tab-btn{
121
+ padding:10px 20px;border-radius:24px;border:1px solid var(--glass-border);
122
+ background:var(--glass);color:var(--text2);cursor:pointer;font-size:.85rem;font-weight:500;
123
+ transition:all .3s ease;backdrop-filter:blur(10px);font-family:inherit;
124
+ }
125
+ .tab-btn:hover{border-color:var(--glass-hover);color:var(--text);transform:translateY(-1px)}
126
+ .tab-btn.active{border-color:rgba(71,229,255,.35);color:var(--cyan);background:rgba(71,229,255,.08);box-shadow:0 0 20px rgba(71,229,255,.1)}
127
+ .tab-btn .count{background:var(--bg4);padding:2px 8px;border-radius:12px;font-size:.72rem;margin-left:6px;font-weight:600}
128
+ .tab-panel{display:none}.tab-panel.active{display:block}
129
+ .insight-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(380px,1fr));gap:14px}
130
+ .insight-card{
131
+ background:var(--glass);border:1px solid var(--glass-border);border-radius:var(--radius-sm);
132
+ padding:18px;border-left:3px solid var(--text3);transition:all .25s ease;backdrop-filter:blur(20px);
133
+ }
134
+ .insight-card:hover{transform:translateX(6px);border-color:var(--glass-hover);box-shadow:0 8px 30px rgba(0,0,0,.2)}
135
+ .insight-card.cyan{border-left-color:var(--cyan)}.insight-card.orange{border-left-color:var(--orange)}
136
+ .insight-card.green{border-left-color:var(--green)}.insight-card.red{border-left-color:var(--red)}
137
+ .insight-card.purple{border-left-color:var(--purple)}.insight-card.blue{border-left-color:var(--blue)}
138
+ .insight-header{display:flex;align-items:center;gap:8px;margin-bottom:8px;flex-wrap:wrap}
139
+ .insight-card p{color:var(--text2);font-size:.85rem;line-height:1.5}
140
+ .prio{font-size:.68rem;padding:3px 10px;border-radius:12px;text-transform:uppercase;font-weight:700;letter-spacing:.5px}
141
+ .prio-critical{background:rgba(255,85,119,.15);color:var(--red);border:1px solid rgba(255,85,119,.25)}
142
+ .prio-high{background:rgba(255,179,71,.15);color:var(--orange);border:1px solid rgba(255,179,71,.25)}
143
+ .prio-medium{background:rgba(91,156,255,.15);color:var(--blue);border:1px solid rgba(91,156,255,.25)}
144
+ .prio-low{background:rgba(139,143,176,.1);color:var(--text2);border:1px solid rgba(139,143,176,.2)}
145
+ .empty{color:var(--text3);font-style:italic;padding:24px}
146
+
147
+ /* Graph */
148
+ .graph-container{position:relative;background:var(--glass);border:1px solid var(--glass-border);border-radius:var(--radius);overflow:hidden;backdrop-filter:blur(20px)}
149
+ #synapse-graph{width:100%;height:650px;display:block;cursor:grab}
150
+ #synapse-graph:active{cursor:grabbing}
151
+ .graph-legend{display:flex;gap:16px;flex-wrap:wrap;padding:12px 20px;border-top:1px solid var(--glass-border);font-size:.8rem;color:var(--text2)}
152
+ .legend-dot{display:inline-block;width:10px;height:10px;border-radius:50%;margin-right:6px;vertical-align:middle}
153
+ .graph-tooltip{position:absolute;display:none;background:var(--bg2);border:1px solid var(--glass-border);border-radius:8px;padding:8px 14px;font-size:.8rem;color:var(--text);pointer-events:none;z-index:10;backdrop-filter:blur(20px);box-shadow:0 8px 30px rgba(0,0,0,.3)}
154
+
155
+ /* Footer */
156
+ footer{text-align:center;padding:40px 0;border-top:1px solid var(--glass-border)}
157
+ footer p{color:var(--text3);font-size:.8rem}
158
+ footer code{background:var(--glass);padding:3px 10px;border-radius:6px;font-size:.78rem;border:1px solid var(--glass-border)}
159
+
160
+ /* Responsive */
161
+ @media(max-width:600px){.stats-grid{grid-template-columns:1fr 1fr}.insight-grid{grid-template-columns:1fr}.logo h1{font-size:2rem}}
162
+ </style>
163
+ </head>
164
+ <body>
165
+
166
+ <canvas id="neural-bg"></canvas>
167
+ <div class="orb orb-1"></div>
168
+ <div class="orb orb-2"></div>
169
+ <div class="orb orb-3"></div>
170
+
171
+ <div class="container">
172
+ <header class="reveal">
173
+ <div class="logo">
174
+ <div class="logo-icon">&#129504;</div>
175
+ <h1>Brain</h1>
176
+ </div>
177
+ <p class="tagline">Adaptive Code Intelligence</p>
178
+ <div class="activity">
179
+ <span class="activity-dot"></span>
180
+ <span class="activity-text">Neural Activity</span>
181
+ <div class="activity-bar"><div class="activity-fill" style="width:0%" data-target="91"></div></div>
182
+ <span class="activity-text" style="color:var(--cyan);font-weight:700">91%</span>
183
+ </div>
184
+ </header>
185
+
186
+ <nav class="reveal reveal-delay-1">
187
+ <a href="#stats">Stats</a>
188
+ <a href="#languages">Languages</a>
189
+ <a href="#network">&#128300; Network</a>
190
+ <a href="#research" class="research">&#128161; Research</a>
191
+ </nav>
192
+
193
+ <section id="stats" class="reveal reveal-delay-2">
194
+ <div class="section-title"><div class="icon" style="background:rgba(91,156,255,.1)">&#128202;</div> Neural Status</div>
195
+ <div class="stats-grid">
196
+ <div class="stat-card blue"><div class="stat-number">18.160</div><div class="stat-label">Modules</div></div>
197
+ <div class="stat-card purple"><div class="stat-number">37.277</div><div class="stat-label">Synapses</div></div>
198
+ <div class="stat-card cyan"><div class="stat-number">5031</div><div class="stat-label">Insights</div></div>
199
+ <div class="stat-card red"><div class="stat-number">0</div><div class="stat-label">Errors</div></div>
200
+ <div class="stat-card green"><div class="stat-number">0</div><div class="stat-label">Solutions</div></div>
201
+ <div class="stat-card orange"><div class="stat-number">0</div><div class="stat-label">Rules</div></div>
202
+ </div>
203
+ </section>
204
+
205
+ <section id="languages" class="reveal reveal-delay-3">
206
+ <div class="section-title"><div class="icon" style="background:rgba(180,122,255,.1)">&#128187;</div> Languages</div>
207
+ <div class="lang-chart"><div class="lang-row"><span class="lang-name">python</span><div class="lang-bar-bg"><div class="lang-bar" data-width="100"></div></div><span class="lang-count">10344</span></div>
208
+ <div class="lang-row"><span class="lang-name">c</span><div class="lang-bar-bg"><div class="lang-bar" data-width="52"></div></div><span class="lang-count">5402</span></div>
209
+ <div class="lang-row"><span class="lang-name">typescript</span><div class="lang-bar-bg"><div class="lang-bar" data-width="18"></div></div><span class="lang-count">1865</span></div>
210
+ <div class="lang-row"><span class="lang-name">javascript</span><div class="lang-bar-bg"><div class="lang-bar" data-width="4"></div></div><span class="lang-count">416</span></div>
211
+ <div class="lang-row"><span class="lang-name">cpp</span><div class="lang-bar-bg"><div class="lang-bar" data-width="1"></div></div><span class="lang-count">107</span></div>
212
+ <div class="lang-row"><span class="lang-name">shell</span><div class="lang-bar-bg"><div class="lang-bar" data-width="0"></div></div><span class="lang-count">20</span></div>
213
+ <div class="lang-row"><span class="lang-name">rust</span><div class="lang-bar-bg"><div class="lang-bar" data-width="0"></div></div><span class="lang-count">6</span></div></div>
214
+ </section>
215
+
216
+ <section id="network" class="reveal reveal-delay-4">
217
+ <div class="section-title"><div class="icon" style="background:rgba(71,229,255,.1)">&#128300;</div> Synapse Network</div>
218
+ <div class="graph-container">
219
+ <canvas id="synapse-graph"></canvas>
220
+ <div class="graph-legend">
221
+ <span><span class="legend-dot" style="background:#ff5577"></span> error</span>
222
+ <span><span class="legend-dot" style="background:#3dffa0"></span> solution</span>
223
+ <span><span class="legend-dot" style="background:#b47aff"></span> code_module</span>
224
+ <span><span class="legend-dot" style="background:#ffb347"></span> project</span>
225
+ <span><span class="legend-dot" style="background:#5b9cff"></span> rule</span>
226
+ <span style="margin-left:auto;color:var(--text3);font-size:.72rem">edges: co_occurs / solves / uses_module / depends_on</span>
227
+ </div>
228
+ <div id="graph-tooltip" class="graph-tooltip"></div>
229
+ </div>
230
+ </section>
231
+
232
+ <section id="research" class="reveal reveal-delay-5">
233
+ <div class="section-title"><div class="icon" style="background:rgba(71,229,255,.1)">&#128300;</div> Research Insights</div>
234
+ <div class="tab-bar">
235
+ <button class="tab-btn active" data-tab="templates">&#127912; Templates <span class="count">5031</span></button>
236
+ <button class="tab-btn" data-tab="suggestions">&#128161; Suggestions <span class="count">5031</span></button>
237
+ <button class="tab-btn" data-tab="trends">&#128200; Trends <span class="count">0</span></button>
238
+ <button class="tab-btn" data-tab="gaps">&#9888;&#65039; Gaps <span class="count">0</span></button>
239
+ <button class="tab-btn" data-tab="synergies">&#9889; Synergies <span class="count">0</span></button>
240
+ <button class="tab-btn" data-tab="warnings">&#128680; Warnings <span class="count">0</span></button>
241
+ </div>
242
+ <div class="tab-panel active" id="tab-templates"><div class="insight-grid"><div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: alert.tsx</strong></div><p>&quot;alert.tsx&quot; exists in 4 projects as adaptations (avg reusability 52%). Generalize into parameterized template.</p></div>
243
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: button.tsx</strong></div><p>&quot;button.tsx&quot; exists in 8 projects as adaptations (avg reusability 71%). Generalize into parameterized template.</p></div>
244
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: config.py</strong></div><p>&quot;config.py&quot; exists in 5 projects as adaptations (avg reusability 74%). Generalize into parameterized template.</p></div>
245
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: footer.tsx</strong></div><p>&quot;footer.tsx&quot; exists in 8 projects as adaptations (avg reusability 78%). Generalize into parameterized template.</p></div>
246
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: index.ts</strong></div><p>&quot;index.ts&quot; exists in 12 projects as adaptations (avg reusability 63%). Generalize into parameterized template.</p></div>
247
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: input.tsx</strong></div><p>&quot;input.tsx&quot; exists in 7 projects as adaptations (avg reusability 64%). Generalize into parameterized template.</p></div>
248
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: layout.tsx</strong></div><p>&quot;layout.tsx&quot; exists in 12 projects as adaptations (avg reusability 77%). Generalize into parameterized template.</p></div>
249
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: main.py</strong></div><p>&quot;main.py&quot; exists in 4 projects as adaptations (avg reusability 81%). Generalize into parameterized template.</p></div>
250
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: page.tsx</strong></div><p>&quot;page.tsx&quot; exists in 12 projects as adaptations (avg reusability 77%). Generalize into parameterized template.</p></div>
251
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: postcss.config.js</strong></div><p>&quot;postcss.config.js&quot; exists in 4 projects as adaptations (avg reusability 53%). Generalize into parameterized template.</p></div>
252
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: route.ts</strong></div><p>&quot;route.ts&quot; exists in 11 projects as adaptations (avg reusability 76%). Generalize into parameterized template.</p></div>
253
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: run.py</strong></div><p>&quot;run.py&quot; exists in 4 projects as adaptations (avg reusability 76%). Generalize into parameterized template.</p></div>
254
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: sidebar.tsx</strong></div><p>&quot;sidebar.tsx&quot; exists in 4 projects as adaptations (avg reusability 81%). Generalize into parameterized template.</p></div>
255
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: tailwind.config.js</strong></div><p>&quot;tailwind.config.js&quot; exists in 4 projects as adaptations (avg reusability 56%). Generalize into parameterized template.</p></div>
256
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: use-debounce.ts</strong></div><p>&quot;use-debounce.ts&quot; exists in 4 projects as adaptations (avg reusability 87%). Generalize into parameterized template.</p></div>
257
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: use-local-storage.ts</strong></div><p>&quot;use-local-storage.ts&quot; exists in 4 projects as adaptations (avg reusability 74%). Generalize into parameterized template.</p></div>
258
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: use-media-query.ts</strong></div><p>&quot;use-media-query.ts&quot; exists in 4 projects as adaptations (avg reusability 81%). Generalize into parameterized template.</p></div>
259
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: auth.ts</strong></div><p>&quot;auth.ts&quot; exists in 7 projects as adaptations (avg reusability 67%). Generalize into parameterized template.</p></div>
260
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: badge.tsx</strong></div><p>&quot;badge.tsx&quot; exists in 5 projects as adaptations (avg reusability 75%). Generalize into parameterized template.</p></div>
261
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: client.ts</strong></div><p>&quot;client.ts&quot; exists in 6 projects as adaptations (avg reusability 69%). Generalize into parameterized template.</p></div>
262
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: db.ts</strong></div><p>&quot;db.ts&quot; exists in 4 projects as adaptations (avg reusability 73%). Generalize into parameterized template.</p></div>
263
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: error.tsx</strong></div><p>&quot;error.tsx&quot; exists in 4 projects as adaptations (avg reusability 71%). Generalize into parameterized template.</p></div>
264
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: not-found.tsx</strong></div><p>&quot;not-found.tsx&quot; exists in 4 projects as adaptations (avg reusability 76%). Generalize into parameterized template.</p></div>
265
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: select.tsx</strong></div><p>&quot;select.tsx&quot; exists in 5 projects as adaptations (avg reusability 54%). Generalize into parameterized template.</p></div>
266
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: textarea.tsx</strong></div><p>&quot;textarea.tsx&quot; exists in 4 projects as adaptations (avg reusability 63%). Generalize into parameterized template.</p></div>
267
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: utils.ts</strong></div><p>&quot;utils.ts&quot; exists in 7 projects as adaptations (avg reusability 75%). Generalize into parameterized template.</p></div>
268
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: middleware.ts</strong></div><p>&quot;middleware.ts&quot; exists in 5 projects as adaptations (avg reusability 78%). Generalize into parameterized template.</p></div>
269
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: providers.tsx</strong></div><p>&quot;providers.tsx&quot; exists in 5 projects as adaptations (avg reusability 80%). Generalize into parameterized template.</p></div>
270
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: progress.tsx</strong></div><p>&quot;progress.tsx&quot; exists in 4 projects as adaptations (avg reusability 52%). Generalize into parameterized template.</p></div>
271
+ <div class="insight-card cyan"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: tailwind.config.ts</strong></div><p>&quot;tailwind.config.ts&quot; exists in 4 projects as adaptations (avg reusability 88%). Generalize into parameterized template.</p></div></div></div>
272
+ <div class="tab-panel" id="tab-suggestions"><div class="insight-grid"><div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: alert.tsx</strong></div><p>&quot;alert.tsx&quot; exists in 4 projects as adaptations (avg reusability 52%). Generalize into parameterized template.</p></div>
273
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: button.tsx</strong></div><p>&quot;button.tsx&quot; exists in 8 projects as adaptations (avg reusability 71%). Generalize into parameterized template.</p></div>
274
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: config.py</strong></div><p>&quot;config.py&quot; exists in 5 projects as adaptations (avg reusability 74%). Generalize into parameterized template.</p></div>
275
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: footer.tsx</strong></div><p>&quot;footer.tsx&quot; exists in 8 projects as adaptations (avg reusability 78%). Generalize into parameterized template.</p></div>
276
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: index.ts</strong></div><p>&quot;index.ts&quot; exists in 12 projects as adaptations (avg reusability 63%). Generalize into parameterized template.</p></div>
277
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: input.tsx</strong></div><p>&quot;input.tsx&quot; exists in 7 projects as adaptations (avg reusability 64%). Generalize into parameterized template.</p></div>
278
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: layout.tsx</strong></div><p>&quot;layout.tsx&quot; exists in 12 projects as adaptations (avg reusability 77%). Generalize into parameterized template.</p></div>
279
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: main.py</strong></div><p>&quot;main.py&quot; exists in 4 projects as adaptations (avg reusability 81%). Generalize into parameterized template.</p></div>
280
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: page.tsx</strong></div><p>&quot;page.tsx&quot; exists in 12 projects as adaptations (avg reusability 77%). Generalize into parameterized template.</p></div>
281
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: postcss.config.js</strong></div><p>&quot;postcss.config.js&quot; exists in 4 projects as adaptations (avg reusability 53%). Generalize into parameterized template.</p></div>
282
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: route.ts</strong></div><p>&quot;route.ts&quot; exists in 11 projects as adaptations (avg reusability 76%). Generalize into parameterized template.</p></div>
283
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: run.py</strong></div><p>&quot;run.py&quot; exists in 4 projects as adaptations (avg reusability 76%). Generalize into parameterized template.</p></div>
284
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: sidebar.tsx</strong></div><p>&quot;sidebar.tsx&quot; exists in 4 projects as adaptations (avg reusability 81%). Generalize into parameterized template.</p></div>
285
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: tailwind.config.js</strong></div><p>&quot;tailwind.config.js&quot; exists in 4 projects as adaptations (avg reusability 56%). Generalize into parameterized template.</p></div>
286
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: use-debounce.ts</strong></div><p>&quot;use-debounce.ts&quot; exists in 4 projects as adaptations (avg reusability 87%). Generalize into parameterized template.</p></div>
287
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: use-local-storage.ts</strong></div><p>&quot;use-local-storage.ts&quot; exists in 4 projects as adaptations (avg reusability 74%). Generalize into parameterized template.</p></div>
288
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: use-media-query.ts</strong></div><p>&quot;use-media-query.ts&quot; exists in 4 projects as adaptations (avg reusability 81%). Generalize into parameterized template.</p></div>
289
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: auth.ts</strong></div><p>&quot;auth.ts&quot; exists in 7 projects as adaptations (avg reusability 67%). Generalize into parameterized template.</p></div>
290
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: badge.tsx</strong></div><p>&quot;badge.tsx&quot; exists in 5 projects as adaptations (avg reusability 75%). Generalize into parameterized template.</p></div>
291
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: client.ts</strong></div><p>&quot;client.ts&quot; exists in 6 projects as adaptations (avg reusability 69%). Generalize into parameterized template.</p></div>
292
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: db.ts</strong></div><p>&quot;db.ts&quot; exists in 4 projects as adaptations (avg reusability 73%). Generalize into parameterized template.</p></div>
293
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: error.tsx</strong></div><p>&quot;error.tsx&quot; exists in 4 projects as adaptations (avg reusability 71%). Generalize into parameterized template.</p></div>
294
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: not-found.tsx</strong></div><p>&quot;not-found.tsx&quot; exists in 4 projects as adaptations (avg reusability 76%). Generalize into parameterized template.</p></div>
295
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: select.tsx</strong></div><p>&quot;select.tsx&quot; exists in 5 projects as adaptations (avg reusability 54%). Generalize into parameterized template.</p></div>
296
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: textarea.tsx</strong></div><p>&quot;textarea.tsx&quot; exists in 4 projects as adaptations (avg reusability 63%). Generalize into parameterized template.</p></div>
297
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: utils.ts</strong></div><p>&quot;utils.ts&quot; exists in 7 projects as adaptations (avg reusability 75%). Generalize into parameterized template.</p></div>
298
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: middleware.ts</strong></div><p>&quot;middleware.ts&quot; exists in 5 projects as adaptations (avg reusability 78%). Generalize into parameterized template.</p></div>
299
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: providers.tsx</strong></div><p>&quot;providers.tsx&quot; exists in 5 projects as adaptations (avg reusability 80%). Generalize into parameterized template.</p></div>
300
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: progress.tsx</strong></div><p>&quot;progress.tsx&quot; exists in 4 projects as adaptations (avg reusability 52%). Generalize into parameterized template.</p></div>
301
+ <div class="insight-card orange"><div class="insight-header"><span class="prio prio-75">75</span><strong>Template candidate: tailwind.config.ts</strong></div><p>&quot;tailwind.config.ts&quot; exists in 4 projects as adaptations (avg reusability 88%). Generalize into parameterized template.</p></div></div></div>
302
+ <div class="tab-panel" id="tab-trends"><div class="insight-grid"><p class="empty">Keine Insights in dieser Kategorie.</p></div></div>
303
+ <div class="tab-panel" id="tab-gaps"><div class="insight-grid"><p class="empty">Keine Insights in dieser Kategorie.</p></div></div>
304
+ <div class="tab-panel" id="tab-synergies"><div class="insight-grid"><p class="empty">Keine Insights in dieser Kategorie.</p></div></div>
305
+ <div class="tab-panel" id="tab-warnings"><div class="insight-grid"><p class="empty">Keine Insights in dieser Kategorie.</p></div></div>
306
+ </section>
307
+
308
+ <footer class="reveal reveal-delay-5">
309
+ <p>Brain v1.0 &mdash; <code>brain dashboard</code></p>
310
+ </footer>
311
+ </div>
312
+
313
+ <script>
314
+ // --- Neural Network Canvas ---
315
+ (function(){
316
+ const canvas = document.getElementById('neural-bg');
317
+ const ctx = canvas.getContext('2d');
318
+ let W, H, nodes = [], mouse = {x:-1000,y:-1000};
319
+
320
+ function resize(){
321
+ W = canvas.width = window.innerWidth;
322
+ H = canvas.height = window.innerHeight;
323
+ }
324
+ resize();
325
+ window.addEventListener('resize', resize);
326
+ document.addEventListener('mousemove', e => { mouse.x = e.clientX; mouse.y = e.clientY; });
327
+
328
+ const NODE_COUNT = Math.min(80, Math.floor(window.innerWidth / 18));
329
+ const CONNECT_DIST = 180;
330
+ const MOUSE_DIST = 200;
331
+
332
+ for(let i = 0; i < NODE_COUNT; i++){
333
+ nodes.push({
334
+ x: Math.random() * W,
335
+ y: Math.random() * H,
336
+ vx: (Math.random() - 0.5) * 0.4,
337
+ vy: (Math.random() - 0.5) * 0.4,
338
+ r: Math.random() * 2 + 1,
339
+ pulse: Math.random() * Math.PI * 2,
340
+ });
341
+ }
342
+
343
+ function draw(){
344
+ ctx.clearRect(0, 0, W, H);
345
+
346
+ // Draw connections
347
+ for(let i = 0; i < nodes.length; i++){
348
+ for(let j = i + 1; j < nodes.length; j++){
349
+ const dx = nodes[i].x - nodes[j].x;
350
+ const dy = nodes[i].y - nodes[j].y;
351
+ const dist = Math.sqrt(dx*dx + dy*dy);
352
+ if(dist < CONNECT_DIST){
353
+ const alpha = (1 - dist / CONNECT_DIST) * 0.15;
354
+ ctx.strokeStyle = 'rgba(91,156,255,' + alpha + ')';
355
+ ctx.lineWidth = 0.5;
356
+ ctx.beginPath();
357
+ ctx.moveTo(nodes[i].x, nodes[i].y);
358
+ ctx.lineTo(nodes[j].x, nodes[j].y);
359
+ ctx.stroke();
360
+ }
361
+ }
362
+
363
+ // Mouse interaction
364
+ const mdx = nodes[i].x - mouse.x;
365
+ const mdy = nodes[i].y - mouse.y;
366
+ const mDist = Math.sqrt(mdx*mdx + mdy*mdy);
367
+ if(mDist < MOUSE_DIST){
368
+ const alpha = (1 - mDist / MOUSE_DIST) * 0.4;
369
+ ctx.strokeStyle = 'rgba(180,122,255,' + alpha + ')';
370
+ ctx.lineWidth = 1;
371
+ ctx.beginPath();
372
+ ctx.moveTo(nodes[i].x, nodes[i].y);
373
+ ctx.lineTo(mouse.x, mouse.y);
374
+ ctx.stroke();
375
+ }
376
+ }
377
+
378
+ // Draw nodes
379
+ const time = Date.now() * 0.001;
380
+ for(const n of nodes){
381
+ const glow = 0.4 + Math.sin(time * 1.5 + n.pulse) * 0.3;
382
+ ctx.fillStyle = 'rgba(91,156,255,' + glow + ')';
383
+ ctx.beginPath();
384
+ ctx.arc(n.x, n.y, n.r, 0, Math.PI * 2);
385
+ ctx.fill();
386
+
387
+ n.x += n.vx;
388
+ n.y += n.vy;
389
+ if(n.x < 0 || n.x > W) n.vx *= -1;
390
+ if(n.y < 0 || n.y > H) n.vy *= -1;
391
+ }
392
+
393
+ requestAnimationFrame(draw);
394
+ }
395
+ draw();
396
+ })();
397
+
398
+ // --- Reveal on scroll ---
399
+ const observer = new IntersectionObserver(entries => {
400
+ entries.forEach(e => { if(e.isIntersecting) e.target.classList.add('visible'); });
401
+ }, {threshold: 0.1});
402
+ document.querySelectorAll('.reveal').forEach(el => observer.observe(el));
403
+
404
+ // --- Tab switching ---
405
+ document.querySelectorAll('.tab-btn').forEach(btn => {
406
+ btn.addEventListener('click', () => {
407
+ document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
408
+ document.querySelectorAll('.tab-panel').forEach(p => p.classList.remove('active'));
409
+ btn.classList.add('active');
410
+ document.getElementById('tab-' + btn.dataset.tab).classList.add('active');
411
+ });
412
+ });
413
+
414
+ // --- Animate stat numbers ---
415
+ const numObserver = new IntersectionObserver(entries => {
416
+ entries.forEach(e => {
417
+ if(!e.isIntersecting) return;
418
+ const el = e.target;
419
+ if(el.dataset.animated) return;
420
+ el.dataset.animated = '1';
421
+ const target = parseInt(el.textContent.replace(/\D/g,''), 10);
422
+ if(isNaN(target) || target === 0) return;
423
+ const duration = 1200;
424
+ const start = performance.now();
425
+ function tick(now){
426
+ const t = Math.min((now - start) / duration, 1);
427
+ const ease = 1 - Math.pow(1 - t, 3);
428
+ el.textContent = Math.round(target * ease).toLocaleString();
429
+ if(t < 1) requestAnimationFrame(tick);
430
+ }
431
+ requestAnimationFrame(tick);
432
+ });
433
+ }, {threshold: 0.5});
434
+ document.querySelectorAll('.stat-number').forEach(el => numObserver.observe(el));
435
+
436
+ // --- Animate language bars ---
437
+ setTimeout(() => {
438
+ document.querySelectorAll('.lang-bar').forEach(bar => {
439
+ bar.style.width = bar.dataset.width + '%';
440
+ });
441
+ }, 300);
442
+
443
+ // --- Activity bar ---
444
+ setTimeout(() => {
445
+ document.querySelectorAll('.activity-fill').forEach(el => {
446
+ el.style.width = el.dataset.target + '%';
447
+ });
448
+ }, 500);
449
+
450
+ // --- Synapse Force-Directed Graph (Premium) ---
451
+ (function(){
452
+ const edges = [{"s":"code_module:16396","t":"project:32","type":"uses_module","w":0.9999999999976071},{"s":"code_module:11809","t":"project:32","type":"uses_module","w":0.9999999997734227},{"s":"code_module:10773","t":"project:32","type":"uses_module","w":0.9999999589029372},{"s":"code_module:10770","t":"project:32","type":"uses_module","w":0.9999998491798466},{"s":"code_module:16403","t":"project:32","type":"uses_module","w":0.9999997110759625},{"s":"code_module:10777","t":"project:32","type":"uses_module","w":0.9999996600893677},{"s":"code_module:10761","t":"project:32","type":"uses_module","w":0.9999925457292852},{"s":"code_module:10764","t":"project:32","type":"uses_module","w":0.9999878619650481},{"s":"code_module:10659","t":"project:32","type":"uses_module","w":0.9999621369230813},{"s":"code_module:11811","t":"project:32","type":"uses_module","w":0.9999621369230813},{"s":"code_module:11906","t":"project:32","type":"uses_module","w":0.9999383463025951},{"s":"code_module:10776","t":"project:32","type":"uses_module","w":0.9999146661627615},{"s":"code_module:10710","t":"project:32","type":"uses_module","w":0.9998818908827148},{"s":"code_module:11808","t":"project:32","type":"uses_module","w":0.9998076790274208},{"s":"code_module:16419","t":"project:32","type":"uses_module","w":0.9997338118026586},{"s":"code_module:16461","t":"project:32","type":"uses_module","w":0.9997338118026586},{"s":"code_module:11806","t":"project:32","type":"uses_module","w":0.9996315734292853},{"s":"code_module:11805","t":"project:32","type":"uses_module","w":0.9994900670301526},{"s":"code_module:11935","t":"project:32","type":"uses_module","w":0.9992942104223566},{"s":"code_module:10772","t":"project:32","type":"uses_module","w":0.9990231286122582},{"s":"code_module:10775","t":"project:32","type":"uses_module","w":0.9988507395438331},{"s":"code_module:399","t":"project:32","type":"uses_module","w":0.9984093280883503},{"s":"code_module:10762","t":"project:32","type":"uses_module","w":0.9974098564434769},{"s":"code_module:11812","t":"project:32","type":"uses_module","w":0.9969527722864434},{"s":"code_module:10657","t":"project:32","type":"uses_module","w":0.995782383787465},{"s":"code_module:399","t":"project:1","type":"uses_module","w":0.9931323163646896},{"s":"code_module:10661","t":"project:32","type":"uses_module","w":0.9931323163646896},{"s":"code_module:10996","t":"project:32","type":"uses_module","w":0.9931323163646896},{"s":"code_module:10995","t":"project:32","type":"uses_module","w":0.9919203721937524},{"s":"code_module:10997","t":"project:32","type":"uses_module","w":0.9919203721937524},{"s":"error:1","t":"project:33","type":"co_occurs","w":0.4472875},{"s":"solution:1","t":"error:1","type":"solves","w":0.34975},{"s":"solution:2","t":"error:2","type":"solves","w":0.34975},{"s":"solution:3","t":"error:3","type":"solves","w":0.34975},{"s":"error:2","t":"project:33","type":"co_occurs","w":0.23500000000000001},{"s":"error:3","t":"project:33","type":"co_occurs","w":0.23500000000000001},{"s":"error:4","t":"project:33","type":"co_occurs","w":0.23500000000000001},{"s":"error:5","t":"project:34","type":"co_occurs","w":0.23500000000000001},{"s":"error:6","t":"project:34","type":"co_occurs","w":0.23500000000000001},{"s":"error:7","t":"project:34","type":"co_occurs","w":0.23500000000000001},{"s":"error:8","t":"project:34","type":"co_occurs","w":0.23500000000000001},{"s":"error:9","t":"project:34","type":"co_occurs","w":0.23500000000000001},{"s":"error:10","t":"project:34","type":"co_occurs","w":0.23500000000000001},{"s":"error:11","t":"project:33","type":"co_occurs","w":0.23500000000000001},{"s":"error:12","t":"project:33","type":"co_occurs","w":0.23500000000000001},{"s":"error:13","t":"project:33","type":"co_occurs","w":0.23500000000000001},{"s":"error:14","t":"project:36","type":"co_occurs","w":0.23500000000000001},{"s":"code_module:1","t":"project:1","type":"co_occurs","w":0.1},{"s":"code_module:2","t":"project:1","type":"co_occurs","w":0.1},{"s":"code_module:3","t":"project:1","type":"co_occurs","w":0.1},{"s":"code_module:4","t":"project:1","type":"co_occurs","w":0.1},{"s":"code_module:5","t":"project:1","type":"co_occurs","w":0.1},{"s":"code_module:6","t":"project:1","type":"co_occurs","w":0.1},{"s":"code_module:7","t":"project:1","type":"co_occurs","w":0.1},{"s":"code_module:8","t":"project:1","type":"co_occurs","w":0.1},{"s":"code_module:9","t":"project:1","type":"co_occurs","w":0.1},{"s":"code_module:10","t":"project:1","type":"co_occurs","w":0.1},{"s":"code_module:11","t":"project:1","type":"co_occurs","w":0.1},{"s":"code_module:12","t":"project:1","type":"co_occurs","w":0.1},{"s":"code_module:13","t":"project:1","type":"co_occurs","w":0.1},{"s":"code_module:14","t":"project:1","type":"co_occurs","w":0.1},{"s":"code_module:15","t":"project:1","type":"co_occurs","w":0.1},{"s":"code_module:16","t":"project:1","type":"co_occurs","w":0.1},{"s":"solution:5","t":"error:5","type":"solves","w":0.1}];
453
+ const canvas = document.getElementById('synapse-graph');
454
+ if (!canvas || !edges.length) return;
455
+ const ctx = canvas.getContext('2d');
456
+ const container = canvas.parentElement;
457
+ let W, H, dpr;
458
+ let frame = 0;
459
+
460
+ const NODE_COLORS = {
461
+ error: '#ff5577', solution: '#3dffa0', code_module: '#b47aff',
462
+ project: '#ffb347', rule: '#5b9cff', antipattern: '#ff5577'
463
+ };
464
+ const EDGE_COLORS = {
465
+ co_occurs: ['#5b9cff','#47e5ff'], solves: ['#3dffa0','#5bff8a'],
466
+ uses_module: ['#b47aff','#7a5cff'], depends_on: ['#ff5577','#ffb347'],
467
+ caused_by: ['#ff5577','#ff8866']
468
+ };
469
+ const DEFAULT_COLOR = '#47e5ff';
470
+
471
+ // Build graph nodes & edges
472
+ const nodeMap = new Map();
473
+ const graphEdges = [];
474
+ for (const e of edges) {
475
+ if (!nodeMap.has(e.s)) nodeMap.set(e.s, { id: e.s, type: e.s.split(':')[0], x: 0, y: 0, vx: 0, vy: 0, connections: 0 });
476
+ if (!nodeMap.has(e.t)) nodeMap.set(e.t, { id: e.t, type: e.t.split(':')[0], x: 0, y: 0, vx: 0, vy: 0, connections: 0 });
477
+ nodeMap.get(e.s).connections++;
478
+ nodeMap.get(e.t).connections++;
479
+ graphEdges.push({ source: nodeMap.get(e.s), target: nodeMap.get(e.t), type: e.type, weight: e.w });
480
+ }
481
+ const nodes = [...nodeMap.values()];
482
+
483
+ function resize() {
484
+ dpr = window.devicePixelRatio || 1;
485
+ W = container.clientWidth;
486
+ H = 650;
487
+ canvas.width = W * dpr;
488
+ canvas.height = H * dpr;
489
+ canvas.style.width = W + 'px';
490
+ canvas.style.height = H + 'px';
491
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
492
+ }
493
+ resize();
494
+ window.addEventListener('resize', resize);
495
+
496
+ // Cluster initial positions by type for better layout
497
+ const typeGroups = {};
498
+ for (const n of nodes) {
499
+ if (!typeGroups[n.type]) typeGroups[n.type] = [];
500
+ typeGroups[n.type].push(n);
501
+ }
502
+ const types = Object.keys(typeGroups);
503
+ types.forEach((t, i) => {
504
+ const angle = (i / types.length) * Math.PI * 2;
505
+ const cx = W/2 + Math.cos(angle) * W * 0.2;
506
+ const cy = H/2 + Math.sin(angle) * H * 0.2;
507
+ for (const n of typeGroups[t]) {
508
+ n.x = cx + (Math.random() - 0.5) * W * 0.25;
509
+ n.y = cy + (Math.random() - 0.5) * H * 0.25;
510
+ }
511
+ });
512
+
513
+ // Force simulation
514
+ const REPULSION = 4000;
515
+ const ATTRACTION = 0.006;
516
+ const DAMPING = 0.88;
517
+ const CENTER_GRAVITY = 0.0015;
518
+ let hovered = null;
519
+ let dragging = null;
520
+ let dragOff = {x:0,y:0};
521
+
522
+ function simulate() {
523
+ for (let i = 0; i < nodes.length; i++) {
524
+ for (let j = i + 1; j < nodes.length; j++) {
525
+ let dx = nodes[i].x - nodes[j].x;
526
+ let dy = nodes[i].y - nodes[j].y;
527
+ let dist = Math.sqrt(dx*dx + dy*dy) || 1;
528
+ let force = REPULSION / (dist * dist);
529
+ let fx = (dx / dist) * force;
530
+ let fy = (dy / dist) * force;
531
+ nodes[i].vx += fx; nodes[i].vy += fy;
532
+ nodes[j].vx -= fx; nodes[j].vy -= fy;
533
+ }
534
+ }
535
+ for (const e of graphEdges) {
536
+ let dx = e.target.x - e.source.x;
537
+ let dy = e.target.y - e.source.y;
538
+ let dist = Math.sqrt(dx*dx + dy*dy) || 1;
539
+ let force = (dist - 120) * ATTRACTION * e.weight;
540
+ let fx = (dx / dist) * force;
541
+ let fy = (dy / dist) * force;
542
+ e.source.vx += fx; e.source.vy += fy;
543
+ e.target.vx -= fx; e.target.vy -= fy;
544
+ }
545
+ for (const n of nodes) {
546
+ n.vx += (W/2 - n.x) * CENTER_GRAVITY;
547
+ n.vy += (H/2 - n.y) * CENTER_GRAVITY;
548
+ }
549
+ for (const n of nodes) {
550
+ if (n === dragging) continue;
551
+ n.vx *= DAMPING; n.vy *= DAMPING;
552
+ n.x += n.vx; n.y += n.vy;
553
+ n.x = Math.max(30, Math.min(W - 30, n.x));
554
+ n.y = Math.max(30, Math.min(H - 30, n.y));
555
+ }
556
+ }
557
+
558
+ function getNodeRadius(n) {
559
+ return Math.min(20, 4 + Math.sqrt(n.connections) * 3.5);
560
+ }
561
+
562
+ function draw() {
563
+ frame++;
564
+ ctx.clearRect(0, 0, W, H);
565
+
566
+ // Edges with gradient colors per type
567
+ for (const e of graphEdges) {
568
+ const alpha = 0.1 + e.weight * 0.4;
569
+ const colors = EDGE_COLORS[e.type] || ['#5b9cff','#47e5ff'];
570
+ const grad = ctx.createLinearGradient(e.source.x, e.source.y, e.target.x, e.target.y);
571
+ grad.addColorStop(0, colors[0] + Math.round(Math.min(0.7,alpha)*255).toString(16).padStart(2,'0'));
572
+ grad.addColorStop(1, colors[1] + Math.round(Math.min(0.7,alpha)*255).toString(16).padStart(2,'0'));
573
+ ctx.strokeStyle = grad;
574
+ ctx.lineWidth = 0.5 + e.weight * 2.5;
575
+ ctx.beginPath();
576
+ ctx.moveTo(e.source.x, e.source.y);
577
+ ctx.lineTo(e.target.x, e.target.y);
578
+ ctx.stroke();
579
+ }
580
+
581
+ // Nodes with ambient glow + pulse on hubs
582
+ for (const n of nodes) {
583
+ const r = getNodeRadius(n);
584
+ const color = NODE_COLORS[n.type] || DEFAULT_COLOR;
585
+ const isHover = n === hovered || n === dragging;
586
+ const isHub = n.connections >= 5;
587
+
588
+ // Ambient glow for all nodes
589
+ const glowSize = isHover ? 30 : (isHub ? 15 + Math.sin(frame * 0.03 + n.x) * 5 : 8);
590
+ ctx.shadowColor = color;
591
+ ctx.shadowBlur = glowSize;
592
+
593
+ // Outer ring for hubs
594
+ if (isHub || isHover) {
595
+ const pulseR = r + 3 + (isHub ? Math.sin(frame * 0.04 + n.y) * 2 : 0);
596
+ ctx.strokeStyle = color;
597
+ ctx.globalAlpha = isHover ? 0.6 : 0.25;
598
+ ctx.lineWidth = 1.5;
599
+ ctx.beginPath();
600
+ ctx.arc(n.x, n.y, pulseR, 0, Math.PI * 2);
601
+ ctx.stroke();
602
+ }
603
+
604
+ // Core node
605
+ ctx.globalAlpha = isHover ? 1 : 0.85;
606
+ ctx.fillStyle = color;
607
+ ctx.beginPath();
608
+ ctx.arc(n.x, n.y, r, 0, Math.PI * 2);
609
+ ctx.fill();
610
+
611
+ // Inner highlight (glossy effect)
612
+ ctx.globalAlpha = 0.3;
613
+ ctx.fillStyle = '#ffffff';
614
+ ctx.beginPath();
615
+ ctx.arc(n.x - r * 0.25, n.y - r * 0.25, r * 0.4, 0, Math.PI * 2);
616
+ ctx.fill();
617
+
618
+ ctx.globalAlpha = 1;
619
+ ctx.shadowBlur = 0;
620
+
621
+ // Labels
622
+ if (isHover || n.connections >= 4) {
623
+ const label = n.type === 'project' ? n.id.replace('project:','P') : n.id.split(':')[0];
624
+ ctx.fillStyle = '#e8eaf6';
625
+ ctx.font = (isHover ? 'bold 12px' : '10px') + ' Inter, system-ui, sans-serif';
626
+ ctx.textAlign = 'center';
627
+ ctx.globalAlpha = isHover ? 1 : 0.7;
628
+ ctx.fillText(isHover ? n.id : label, n.x, n.y - r - 8);
629
+ ctx.globalAlpha = 1;
630
+ }
631
+ }
632
+ simulate();
633
+ requestAnimationFrame(draw);
634
+ }
635
+ draw();
636
+
637
+ // Interaction
638
+ const tooltip = document.getElementById('graph-tooltip');
639
+ function getNodeAt(mx, my) {
640
+ for (let i = nodes.length - 1; i >= 0; i--) {
641
+ const n = nodes[i], r = getNodeRadius(n);
642
+ if (Math.hypot(mx - n.x, my - n.y) <= r + 4) return n;
643
+ }
644
+ return null;
645
+ }
646
+ function getPos(e) {
647
+ const rect = canvas.getBoundingClientRect();
648
+ return { x: e.clientX - rect.left, y: e.clientY - rect.top };
649
+ }
650
+ canvas.addEventListener('mousemove', function(e) {
651
+ const p = getPos(e);
652
+ if (dragging) {
653
+ dragging.x = p.x + dragOff.x;
654
+ dragging.y = p.y + dragOff.y;
655
+ dragging.vx = 0; dragging.vy = 0;
656
+ return;
657
+ }
658
+ const n = getNodeAt(p.x, p.y);
659
+ hovered = n;
660
+ canvas.style.cursor = n ? 'pointer' : 'grab';
661
+ if (n) {
662
+ const conns = graphEdges.filter(e => e.source === n || e.target === n);
663
+ const types = {};
664
+ conns.forEach(c => { types[c.type] = (types[c.type]||0)+1; });
665
+ const typeStr = Object.entries(types).map(([t,c]) => t+': '+c).join(', ');
666
+ tooltip.innerHTML = '<strong>' + n.id + '</strong><br>' + conns.length + ' connections<br><span style="color:var(--text3);font-size:.75rem">' + typeStr + '</span>';
667
+ tooltip.style.display = 'block';
668
+ tooltip.style.left = (p.x + 15) + 'px';
669
+ tooltip.style.top = (p.y - 10) + 'px';
670
+ } else {
671
+ tooltip.style.display = 'none';
672
+ }
673
+ });
674
+ canvas.addEventListener('mousedown', function(e) {
675
+ const p = getPos(e);
676
+ const n = getNodeAt(p.x, p.y);
677
+ if (n) {
678
+ dragging = n;
679
+ dragOff = { x: n.x - p.x, y: n.y - p.y };
680
+ canvas.style.cursor = 'grabbing';
681
+ }
682
+ });
683
+ canvas.addEventListener('mouseup', function() { dragging = null; });
684
+ canvas.addEventListener('mouseleave', function() { dragging = null; hovered = null; tooltip.style.display = 'none'; });
685
+ })();
686
+ </script>
687
+ </body>
688
+ </html>