nexo-brain 5.3.26 → 5.3.27

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 (211) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/package.json +1 -1
  3. package/src/server.py +3 -0
  4. package/src/tools_sessions.py +6 -1
  5. package/src/dashboard/static/favicon 2.svg +0 -32
  6. package/src/dashboard/static/nexo-logo 2.png +0 -0
  7. package/src/dashboard/static/nexo-logo 2.svg +0 -40
  8. package/src/dashboard/static/style 2.css +0 -2458
  9. package/src/dashboard/templates/adaptive 2.html +0 -118
  10. package/src/dashboard/templates/artifacts 2.html +0 -133
  11. package/src/dashboard/templates/backups 2.html +0 -136
  12. package/src/dashboard/templates/base 2.html +0 -417
  13. package/src/dashboard/templates/calendar 2.html +0 -591
  14. package/src/dashboard/templates/chat 2.html +0 -356
  15. package/src/dashboard/templates/claims 2.html +0 -259
  16. package/src/dashboard/templates/cortex 2.html +0 -321
  17. package/src/dashboard/templates/credentials 2.html +0 -128
  18. package/src/dashboard/templates/crons 2.html +0 -370
  19. package/src/dashboard/templates/dashboard 2.html +0 -494
  20. package/src/dashboard/templates/dreams 2.html +0 -252
  21. package/src/dashboard/templates/email 2.html +0 -160
  22. package/src/dashboard/templates/evolution 2.html +0 -189
  23. package/src/dashboard/templates/feed 2.html +0 -249
  24. package/src/dashboard/templates/followup_health 2.html +0 -170
  25. package/src/dashboard/templates/graph 2.html +0 -201
  26. package/src/dashboard/templates/guard 2.html +0 -259
  27. package/src/dashboard/templates/inbox 2.html +0 -251
  28. package/src/dashboard/templates/memory 2.html +0 -420
  29. package/src/dashboard/templates/operations 2.html +0 -608
  30. package/src/dashboard/templates/plugins 2.html +0 -185
  31. package/src/dashboard/templates/protocol 2.html +0 -199
  32. package/src/dashboard/templates/rules 2.html +0 -246
  33. package/src/dashboard/templates/sentiment 2.html +0 -247
  34. package/src/dashboard/templates/sessions 2.html +0 -218
  35. package/src/dashboard/templates/skills 2.html +0 -329
  36. package/src/dashboard/templates/somatic 2.html +0 -73
  37. package/src/dashboard/templates/triggers 2.html +0 -133
  38. package/src/dashboard/templates/trust 2.html +0 -360
  39. package/src/db/__init__ 2.py +0 -259
  40. package/src/db/_core 2.py +0 -437
  41. package/src/db/_credentials 2.py +0 -124
  42. package/src/db/_episodic 2.py +0 -762
  43. package/src/db/_evolution 2.py +0 -54
  44. package/src/db/_fts 2.py +0 -406
  45. package/src/db/_goal_profiles 2.py +0 -376
  46. package/src/db/_hot_context 2.py +0 -660
  47. package/src/db/_outcomes 2.py +0 -800
  48. package/src/db/_personal_scripts 2.py +0 -582
  49. package/src/db/_sessions 2.py +0 -330
  50. package/src/db/_tasks 2.py +0 -91
  51. package/src/db/_watchers 2.py +0 -173
  52. package/src/doctor/formatters 2.py +0 -52
  53. package/src/doctor/models 2.py +0 -69
  54. package/src/doctor/planes 2.py +0 -87
  55. package/src/doctor/providers/__init__ 2.py +0 -1
  56. package/src/doctor/providers/deep 2.py +0 -367
  57. package/src/evolution_cycle 2.py +0 -519
  58. package/src/hooks/auto_capture 2.py +0 -208
  59. package/src/hooks/caffeinate-guard 2.sh +0 -8
  60. package/src/hooks/capture-session 2.sh +0 -21
  61. package/src/hooks/capture-tool-logs 2.sh +0 -158
  62. package/src/hooks/daily-briefing-check 2.sh +0 -33
  63. package/src/hooks/heartbeat-enforcement 2.py +0 -90
  64. package/src/hooks/heartbeat-posttool 2.sh +0 -18
  65. package/src/hooks/inbox-hook 2.sh +0 -76
  66. package/src/hooks/post-compact 2.sh +0 -152
  67. package/src/hooks/pre-compact 2.sh +0 -169
  68. package/src/hooks/protocol-guardrail 2.sh +0 -10
  69. package/src/hooks/protocol-pretool-guardrail 2.sh +0 -9
  70. package/src/hooks/session-stop 2.sh +0 -52
  71. package/src/kg_populate 2.py +0 -292
  72. package/src/maintenance 2.py +0 -53
  73. package/src/memory_backends 2.py +0 -71
  74. package/src/migrate_embeddings 2.py +0 -124
  75. package/src/nexo_sdk 2.py +0 -103
  76. package/src/observability 2.py +0 -199
  77. package/src/plugin_loader 2.py +0 -217
  78. package/src/plugins/__init__ 2.py +0 -0
  79. package/src/plugins/artifact_registry 2.py +0 -450
  80. package/src/plugins/backup 2.py +0 -127
  81. package/src/plugins/claims_tools 2.py +0 -119
  82. package/src/plugins/cognitive_memory 2.py +0 -609
  83. package/src/plugins/core_rules 2.py +0 -252
  84. package/src/plugins/cortex 2.py +0 -1155
  85. package/src/plugins/entities 2.py +0 -67
  86. package/src/plugins/episodic_memory 2.py +0 -560
  87. package/src/plugins/evolution 2.py +0 -167
  88. package/src/plugins/goal_engine 2.py +0 -142
  89. package/src/plugins/guard 2.py +0 -862
  90. package/src/plugins/impact 2.py +0 -29
  91. package/src/plugins/knowledge_graph_tools 2.py +0 -137
  92. package/src/plugins/media_memory_tools 2.py +0 -98
  93. package/src/plugins/memory_export 2.py +0 -196
  94. package/src/plugins/outcomes 2.py +0 -130
  95. package/src/plugins/personal_scripts 2.py +0 -117
  96. package/src/plugins/preferences 2.py +0 -47
  97. package/src/plugins/protocol 2.py +0 -1449
  98. package/src/plugins/simple_api 2.py +0 -106
  99. package/src/plugins/skills 2.py +0 -341
  100. package/src/plugins/state_watchers 2.py +0 -79
  101. package/src/plugins/update 2.py +0 -986
  102. package/src/plugins/user_state_tools 2.py +0 -43
  103. package/src/plugins/workflow 2.py +0 -588
  104. package/src/protocol_settings 2.py +0 -59
  105. package/src/public_contribution 2.py +0 -466
  106. package/src/public_evolution_queue 2.py +0 -241
  107. package/src/requirements 2.txt +0 -14
  108. package/src/retroactive_learnings 2.py +0 -373
  109. package/src/rules/__init__ 2.py +0 -0
  110. package/src/rules/core-rules 2.json +0 -331
  111. package/src/rules/migrate 2.py +0 -207
  112. package/src/runtime_power 2.py +0 -874
  113. package/src/script_registry 2.py +0 -1559
  114. package/src/scripts/check-context 2.py +0 -272
  115. package/src/scripts/deep-sleep/apply_findings 2.py +0 -2327
  116. package/src/scripts/deep-sleep/collect 2.py +0 -928
  117. package/src/scripts/deep-sleep/extract 2.py +0 -330
  118. package/src/scripts/deep-sleep/extract-prompt 2.md +0 -285
  119. package/src/scripts/deep-sleep/synthesize 2.py +0 -312
  120. package/src/scripts/deep-sleep/synthesize-prompt 2.md +0 -336
  121. package/src/scripts/nexo-agent-run 2.py +0 -75
  122. package/src/scripts/nexo-auto-update 2.py +0 -6
  123. package/src/scripts/nexo-backup 2.sh +0 -25
  124. package/src/scripts/nexo-brain-activation 2.sh +0 -140
  125. package/src/scripts/nexo-catchup 2.py +0 -300
  126. package/src/scripts/nexo-cognitive-decay 2.py +0 -257
  127. package/src/scripts/nexo-cortex-cycle 2.py +0 -293
  128. package/src/scripts/nexo-cron-wrapper 2.sh +0 -53
  129. package/src/scripts/nexo-daily-self-audit 2.py +0 -2161
  130. package/src/scripts/nexo-dashboard 2.sh +0 -29
  131. package/src/scripts/nexo-deep-sleep 2.sh +0 -86
  132. package/src/scripts/nexo-evolution-run 2.py +0 -1664
  133. package/src/scripts/nexo-followup-hygiene 2.py +0 -139
  134. package/src/scripts/nexo-hook-record 2.py +0 -42
  135. package/src/scripts/nexo-immune 2.py +0 -936
  136. package/src/scripts/nexo-impact-scorer 2.py +0 -117
  137. package/src/scripts/nexo-inbox-hook 2.sh +0 -74
  138. package/src/scripts/nexo-install 2.py +0 -6
  139. package/src/scripts/nexo-learning-housekeep 2.py +0 -401
  140. package/src/scripts/nexo-learning-validator 2.py +0 -266
  141. package/src/scripts/nexo-migrate 2.py +0 -260
  142. package/src/scripts/nexo-outcome-checker 2.py +0 -127
  143. package/src/scripts/nexo-postmortem-consolidator 2.py +0 -456
  144. package/src/scripts/nexo-pre-commit 2.py +0 -120
  145. package/src/scripts/nexo-prevent-sleep 2.sh +0 -35
  146. package/src/scripts/nexo-proactive-dashboard 2.py +0 -354
  147. package/src/scripts/nexo-reflection 2.py +0 -256
  148. package/src/scripts/nexo-runtime-preflight 2.py +0 -274
  149. package/src/scripts/nexo-sleep 2.py +0 -631
  150. package/src/scripts/nexo-snapshot-restore 2.sh +0 -35
  151. package/src/scripts/nexo-sync-clients 2.py +0 -16
  152. package/src/scripts/nexo-synthesis 2.py +0 -475
  153. package/src/scripts/nexo-tcc-approve 2.sh +0 -79
  154. package/src/scripts/nexo-update 2.sh +0 -306
  155. package/src/scripts/nexo-watchdog 2.sh +0 -1207
  156. package/src/scripts/nexo-watchdog-smoke 2.py +0 -119
  157. package/src/scripts/rehydrate_learnings_from_archive 2.py +0 -245
  158. package/src/server 2.py +0 -1296
  159. package/src/skills/run-nexo-audit-phase/guide 2.md +0 -43
  160. package/src/skills/run-nexo-audit-phase/skill 2.json +0 -59
  161. package/src/skills/run-nexo-core-fix-cycle/guide 2.md +0 -17
  162. package/src/skills/run-nexo-core-fix-cycle/script 2.py +0 -276
  163. package/src/skills/run-nexo-core-fix-cycle/skill 2.json +0 -58
  164. package/src/skills/run-release-final-audit/guide 2.md +0 -16
  165. package/src/skills/run-release-final-audit/script 2.py +0 -259
  166. package/src/skills/run-release-final-audit/skill 2.json +0 -77
  167. package/src/skills/run-runtime-doctor/guide 2.md +0 -12
  168. package/src/skills/run-runtime-doctor/script 2.py +0 -21
  169. package/src/skills/run-runtime-doctor/skill 2.json +0 -25
  170. package/src/skills_runtime 2.py +0 -932
  171. package/src/state_watchers_runtime 2.py +0 -475
  172. package/src/storage_router 2.py +0 -32
  173. package/src/system_catalog 2.py +0 -786
  174. package/src/tools_coordination 2.py +0 -103
  175. package/src/tools_credentials 2.py +0 -68
  176. package/src/tools_drive 2.py +0 -487
  177. package/src/tools_hot_context 2.py +0 -163
  178. package/src/tools_learnings 2.py +0 -612
  179. package/src/tools_menu 2.py +0 -229
  180. package/src/tools_reminders 2.py +0 -88
  181. package/src/tools_reminders_crud 2.py +0 -363
  182. package/src/tools_sessions 2.py +0 -1054
  183. package/src/tools_system_catalog 2.py +0 -19
  184. package/src/tools_task_history 2.py +0 -57
  185. package/src/tools_transcripts 2.py +0 -98
  186. package/src/transcript_utils 2.py +0 -412
  187. package/src/user_context 2.py +0 -46
  188. package/src/user_data_portability 2.py +0 -328
  189. package/src/user_state_model 2.py +0 -170
  190. package/templates/CLAUDE.md 2.template +0 -108
  191. package/templates/CODEX.AGENTS.md 2.template +0 -66
  192. package/templates/launchagents/README 2.md +0 -132
  193. package/templates/launchagents/com.nexo.auto-close-sessions 2.plist +0 -39
  194. package/templates/launchagents/com.nexo.catchup 2.plist +0 -39
  195. package/templates/launchagents/com.nexo.cognitive-decay 2.plist +0 -40
  196. package/templates/launchagents/com.nexo.dashboard 2.plist +0 -43
  197. package/templates/launchagents/com.nexo.deep-sleep 2.plist +0 -43
  198. package/templates/launchagents/com.nexo.evolution 2.plist +0 -44
  199. package/templates/launchagents/com.nexo.followup-hygiene 2.plist +0 -45
  200. package/templates/launchagents/com.nexo.immune 2.plist +0 -41
  201. package/templates/launchagents/com.nexo.postmortem 2.plist +0 -45
  202. package/templates/launchagents/com.nexo.self-audit 2.plist +0 -47
  203. package/templates/launchagents/com.nexo.synthesis 2.plist +0 -45
  204. package/templates/launchagents/com.nexo.watchdog 2.plist +0 -37
  205. package/templates/nexo_helper 2.py +0 -301
  206. package/templates/openclaw 2.json +0 -13
  207. package/templates/plugin-template 2.py +0 -40
  208. package/templates/script-template 2.py +0 -59
  209. package/templates/script-template 2.sh +0 -13
  210. package/templates/skill-script-template 2.py +0 -48
  211. package/templates/skill-template 2.md +0 -33
@@ -1,249 +0,0 @@
1
- {% extends "base.html" %}
2
-
3
- {% block title %}Activity Feed{% endblock %}
4
- {% block page_title %}Activity Feed{% endblock %}
5
- {% block page_subtitle %}
6
- <span class="text-xs text-slate-500 font-mono ml-2" id="feed-count">-- events</span>
7
- {% endblock %}
8
-
9
- {% block header_actions %}
10
- <button onclick="loadFeed()" class="text-xs text-slate-400 hover:text-slate-200 bg-slate-800/50 border border-slate-700/50 rounded-lg px-3 py-1.5 transition-colors flex items-center gap-1.5">
11
- <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/></svg>
12
- Refresh
13
- </button>
14
- {% endblock %}
15
-
16
- {% block content %}
17
- <!-- Type filter pills -->
18
- <div class="flex items-center gap-2 mb-5 flex-wrap">
19
- <button onclick="setFilter('all')" data-filter="all" class="filter-pill active px-3 py-1.5 rounded-lg text-xs font-medium transition-all duration-200">
20
- All
21
- <span class="ml-1 font-mono text-[10px] opacity-70" id="count-all">0</span>
22
- </button>
23
- <button onclick="setFilter('diary')" data-filter="diary" class="filter-pill px-3 py-1.5 rounded-lg text-xs font-medium transition-all duration-200">
24
- <svg class="w-3 h-3 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"/></svg>
25
- Diary
26
- <span class="ml-1 font-mono text-[10px] opacity-70" id="count-diary">0</span>
27
- </button>
28
- <button onclick="setFilter('change')" data-filter="change" class="filter-pill px-3 py-1.5 rounded-lg text-xs font-medium transition-all duration-200">
29
- <svg class="w-3 h-3 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"/></svg>
30
- Changes
31
- <span class="ml-1 font-mono text-[10px] opacity-70" id="count-change">0</span>
32
- </button>
33
- <button onclick="setFilter('cortex')" data-filter="cortex" class="filter-pill px-3 py-1.5 rounded-lg text-xs font-medium transition-all duration-200">
34
- <svg class="w-3 h-3 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/></svg>
35
- Cortex
36
- <span class="ml-1 font-mono text-[10px] opacity-70" id="count-cortex">0</span>
37
- </button>
38
- <button onclick="setFilter('cron')" data-filter="cron" class="filter-pill px-3 py-1.5 rounded-lg text-xs font-medium transition-all duration-200">
39
- <svg class="w-3 h-3 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
40
- Crons
41
- <span class="ml-1 font-mono text-[10px] opacity-70" id="count-cron">0</span>
42
- </button>
43
- <button onclick="setFilter('decision')" data-filter="decision" class="filter-pill px-3 py-1.5 rounded-lg text-xs font-medium transition-all duration-200">
44
- <svg class="w-3 h-3 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 6l3 1m0 0l-3 9a5.002 5.002 0 006.001 0M6 7l3 9M6 7l6-2m6 2l3-1m-3 1l-3 9a5.002 5.002 0 006.001 0M18 7l3 9m-3-9l-6-2m0-2v2m0 16V5m0 16H9m3 0h3"/></svg>
45
- Decisions
46
- <span class="ml-1 font-mono text-[10px] opacity-70" id="count-decision">0</span>
47
- </button>
48
-
49
- <!-- Live indicator -->
50
- <div class="ml-auto flex items-center gap-2">
51
- <div class="w-1.5 h-1.5 rounded-full bg-emerald-400 glow-dot" style="color: #34d399;"></div>
52
- <span class="text-[10px] text-slate-500 uppercase tracking-wider">Live</span>
53
- </div>
54
- </div>
55
-
56
- <!-- Feed container -->
57
- <div id="feed-list" class="space-y-2">
58
- <!-- Loading skeleton -->
59
- <div id="feed-skeleton" class="space-y-2">
60
- <div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 animate-pulse"><div class="h-4 bg-slate-800 rounded w-3/4"></div><div class="h-3 bg-slate-800/50 rounded w-1/2 mt-3"></div></div>
61
- <div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 animate-pulse"><div class="h-4 bg-slate-800 rounded w-2/3"></div><div class="h-3 bg-slate-800/50 rounded w-1/3 mt-3"></div></div>
62
- <div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 animate-pulse"><div class="h-4 bg-slate-800 rounded w-1/2"></div><div class="h-3 bg-slate-800/50 rounded w-2/5 mt-3"></div></div>
63
- </div>
64
- </div>
65
-
66
- <!-- Empty state -->
67
- <div id="feed-empty" class="hidden text-center py-20">
68
- <svg class="w-12 h-12 mx-auto text-slate-700 mb-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M13 10V3L4 14h7v7l9-11h-7z"/></svg>
69
- <p class="text-sm text-slate-500">No activity events yet</p>
70
- <p class="text-xs text-slate-600 mt-1">Events will appear here as NEXO operates</p>
71
- </div>
72
-
73
- <style>
74
- .filter-pill {
75
- background: rgba(30, 41, 59, 0.5);
76
- border: 1px solid rgba(51, 65, 85, 0.5);
77
- color: #94a3b8;
78
- }
79
- .filter-pill:hover {
80
- background: rgba(51, 65, 85, 0.5);
81
- color: #e2e8f0;
82
- }
83
- .filter-pill.active {
84
- background: rgba(124, 58, 237, 0.15);
85
- border-color: rgba(124, 58, 237, 0.4);
86
- color: #a78bfa;
87
- }
88
-
89
- .event-card {
90
- transition: all 0.2s ease;
91
- }
92
- .event-card:hover {
93
- border-color: rgba(124, 58, 237, 0.3);
94
- box-shadow: 0 0 20px rgba(124, 58, 237, 0.06);
95
- }
96
-
97
- @keyframes slideInFeed {
98
- 0% { opacity: 0; transform: translateY(-12px) scale(0.98); }
99
- 100% { opacity: 1; transform: translateY(0) scale(1); }
100
- }
101
- .event-new {
102
- animation: slideInFeed 0.4s cubic-bezier(0.16, 1, 0.3, 1);
103
- }
104
-
105
- .event-details {
106
- max-height: 0;
107
- overflow: hidden;
108
- transition: max-height 0.3s ease, opacity 0.3s ease;
109
- opacity: 0;
110
- }
111
- .event-details.open {
112
- max-height: 600px;
113
- opacity: 1;
114
- }
115
-
116
- .icon-diary { color: #a78bfa; background: rgba(167, 139, 250, 0.1); }
117
- .icon-change { color: #34d399; background: rgba(52, 211, 153, 0.1); }
118
- .icon-cortex { color: #f472b6; background: rgba(244, 114, 182, 0.1); }
119
- .icon-cron { color: #fbbf24; background: rgba(251, 191, 36, 0.1); }
120
- .icon-decision { color: #60a5fa; background: rgba(96, 165, 250, 0.1); }
121
-
122
- .type-badge-diary { color: #a78bfa; background: rgba(167, 139, 250, 0.1); border: 1px solid rgba(167, 139, 250, 0.2); }
123
- .type-badge-change { color: #34d399; background: rgba(52, 211, 153, 0.1); border: 1px solid rgba(52, 211, 153, 0.2); }
124
- .type-badge-cortex { color: #f472b6; background: rgba(244, 114, 182, 0.1); border: 1px solid rgba(244, 114, 182, 0.2); }
125
- .type-badge-cron { color: #fbbf24; background: rgba(251, 191, 36, 0.1); border: 1px solid rgba(251, 191, 36, 0.2); }
126
- .type-badge-decision { color: #60a5fa; background: rgba(96, 165, 250, 0.1); border: 1px solid rgba(96, 165, 250, 0.2); }
127
- </style>
128
- {% endblock %}
129
-
130
- {% block scripts %}
131
- <script>
132
- const ICONS = {
133
- diary: `<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"/></svg>`,
134
- change: `<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"/></svg>`,
135
- cortex: `<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/></svg>`,
136
- cron: `<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>`,
137
- decision: `<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 6l3 1m0 0l-3 9a5.002 5.002 0 006.001 0M6 7l3 9M6 7l6-2m6 2l3-1m-3 1l-3 9a5.002 5.002 0 006.001 0M18 7l3 9m-3-9l-6-2m0-2v2m0 16V5m0 16H9m3 0h3"/></svg>`
138
- };
139
-
140
- const TYPE_LABELS = { diary: 'Diary', change: 'Change', cortex: 'Cortex', cron: 'Cron', decision: 'Decision' };
141
-
142
- let allEvents = [];
143
- let currentFilter = 'all';
144
- let knownIds = new Set();
145
-
146
- function setFilter(type) {
147
- currentFilter = type;
148
- document.querySelectorAll('.filter-pill').forEach(btn => {
149
- btn.classList.toggle('active', btn.dataset.filter === type);
150
- });
151
- renderEvents();
152
- }
153
-
154
- function renderEvents() {
155
- const list = document.getElementById('feed-list');
156
- const skeleton = document.getElementById('feed-skeleton');
157
- const empty = document.getElementById('feed-empty');
158
- if (skeleton) skeleton.remove();
159
-
160
- const filtered = currentFilter === 'all'
161
- ? allEvents
162
- : allEvents.filter(e => e.type === currentFilter);
163
-
164
- if (filtered.length === 0) {
165
- list.innerHTML = '';
166
- empty.classList.remove('hidden');
167
- return;
168
- }
169
- empty.classList.add('hidden');
170
-
171
- list.innerHTML = filtered.map((ev, i) => {
172
- const icon = ICONS[ev.type] || ICONS.change;
173
- const snippet = escapeHtml((ev.content || '').substring(0, 200));
174
- const full = escapeHtml(ev.content || '');
175
- const isNew = !knownIds.has(ev.id || i);
176
- return `
177
- <div class="event-card bg-slate-900/50 border border-slate-800/50 rounded-xl p-4 cursor-pointer ${isNew ? 'event-new' : ''}"
178
- onclick="toggleDetails(this)" data-event-id="${ev.id || i}">
179
- <div class="flex items-start gap-3">
180
- <div class="w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 icon-${ev.type}">
181
- ${icon}
182
- </div>
183
- <div class="flex-1 min-w-0">
184
- <div class="flex items-center gap-2 mb-1">
185
- <span class="type-badge-${ev.type} text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded">
186
- ${TYPE_LABELS[ev.type] || ev.type}
187
- </span>
188
- ${ev.source ? `<span class="text-[10px] text-slate-600">${escapeHtml(ev.source)}</span>` : ''}
189
- <span class="ml-auto text-[10px] text-slate-500 font-mono flex-shrink-0">${relativeTime(ev.created_at)}</span>
190
- </div>
191
- <p class="text-sm text-slate-300 leading-relaxed line-clamp-2">${snippet}${(ev.content || '').length > 200 ? '...' : ''}</p>
192
- </div>
193
- <svg class="w-4 h-4 text-slate-600 flex-shrink-0 mt-1 transition-transform duration-200 expand-chevron" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/></svg>
194
- </div>
195
- <div class="event-details mt-3 pl-11">
196
- <div class="border-t border-slate-800/50 pt-3">
197
- <pre class="text-xs text-slate-400 font-mono whitespace-pre-wrap leading-relaxed">${full}</pre>
198
- <div class="flex items-center gap-4 mt-3 text-[10px] text-slate-600">
199
- <span>ID: ${escapeHtml(String(ev.id || '--'))}</span>
200
- <span>${ev.created_at ? new Date(ev.created_at).toLocaleString('en-GB') : '--'}</span>
201
- ${ev.session_id ? `<span>Session: ${escapeHtml(ev.session_id)}</span>` : ''}
202
- </div>
203
- </div>
204
- </div>
205
- </div>
206
- `;
207
- }).join('');
208
- }
209
-
210
- function toggleDetails(card) {
211
- const details = card.querySelector('.event-details');
212
- const chevron = card.querySelector('.expand-chevron');
213
- details.classList.toggle('open');
214
- chevron.style.transform = details.classList.contains('open') ? 'rotate(180deg)' : '';
215
- }
216
-
217
- function updateCounts() {
218
- const counts = { all: allEvents.length, diary: 0, change: 0, cortex: 0, cron: 0, decision: 0 };
219
- allEvents.forEach(e => { if (counts[e.type] !== undefined) counts[e.type]++; });
220
- Object.keys(counts).forEach(k => {
221
- const el = document.getElementById('count-' + k);
222
- if (el) el.textContent = counts[k];
223
- });
224
- document.getElementById('feed-count').textContent = `${allEvents.length} events`;
225
- }
226
-
227
- async function loadFeed() {
228
- const data = await fetchJSON('/api/feed');
229
- if (!data || !data.events) return;
230
-
231
- const oldIds = new Set(allEvents.map(e => e.id));
232
- allEvents = data.events;
233
- knownIds = oldIds;
234
- updateCounts();
235
- renderEvents();
236
-
237
- // Mark all as known after render
238
- setTimeout(() => {
239
- allEvents.forEach(e => knownIds.add(e.id));
240
- }, 500);
241
- }
242
-
243
- // Initial load
244
- loadFeed();
245
-
246
- // Auto-refresh every 30s
247
- setInterval(loadFeed, 30000);
248
- </script>
249
- {% endblock %}
@@ -1,170 +0,0 @@
1
- {% extends "base.html" %}
2
-
3
- {% block title %}Followup Health{% endblock %}
4
- {% block page_title %}Followup Health{% endblock %}
5
-
6
- {% block content %}
7
- <div class="space-y-5">
8
- <!-- Stat cards -->
9
- <div class="grid grid-cols-5 gap-4">
10
- <div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-4 card">
11
- <div class="text-xs uppercase tracking-wider text-slate-400 font-medium mb-2">Total</div>
12
- <div class="text-xl font-mono font-semibold text-slate-200" id="fh-total">--</div>
13
- </div>
14
- <div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-4 card">
15
- <div class="text-xs uppercase tracking-wider text-amber-400/70 font-medium mb-2">Pending</div>
16
- <div class="text-xl font-mono font-semibold text-amber-400" id="fh-pending">--</div>
17
- </div>
18
- <div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-4 card">
19
- <div class="text-xs uppercase tracking-wider text-emerald-400/70 font-medium mb-2">Completed</div>
20
- <div class="text-xl font-mono font-semibold text-emerald-400" id="fh-completed">--</div>
21
- </div>
22
- <div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-4 card">
23
- <div class="text-xs uppercase tracking-wider text-red-400/70 font-medium mb-2">Overdue</div>
24
- <div class="text-xl font-mono font-semibold text-red-400" id="fh-overdue">--</div>
25
- </div>
26
- <div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-4 card">
27
- <div class="text-xs uppercase tracking-wider text-violet-400/70 font-medium mb-2">Completion Rate</div>
28
- <div class="text-xl font-mono font-semibold text-violet-400" id="fh-rate">--%</div>
29
- </div>
30
- </div>
31
-
32
- <!-- Charts row -->
33
- <div class="grid grid-cols-2 gap-5">
34
- <!-- Donut chart -->
35
- <div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
36
- <div class="text-xs uppercase tracking-wider text-slate-400 font-medium mb-4">Completion Rate</div>
37
- <div class="flex items-center justify-center" style="min-height: 260px;">
38
- <svg id="donut-svg" viewBox="0 0 200 200" class="w-52 h-52"></svg>
39
- </div>
40
- </div>
41
-
42
- <!-- Age distribution bar chart -->
43
- <div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
44
- <div class="text-xs uppercase tracking-wider text-slate-400 font-medium mb-4">Age Distribution</div>
45
- <div class="space-y-3" id="age-bars" style="min-height: 260px;">
46
- <div class="text-xs text-slate-600 py-12 text-center">loading...</div>
47
- </div>
48
- </div>
49
- </div>
50
-
51
- <!-- Overdue items table -->
52
- <div class="bg-slate-900/50 border border-slate-800/50 rounded-xl p-5 card">
53
- <div class="flex items-center justify-between mb-4">
54
- <div class="text-xs uppercase tracking-wider text-red-400/70 font-medium">Overdue Items</div>
55
- <span class="text-xs font-mono text-slate-500" id="overdue-label">--</span>
56
- </div>
57
- <div class="space-y-2" id="overdue-list">
58
- <div class="text-xs text-slate-600 py-4 text-center">loading...</div>
59
- </div>
60
- </div>
61
- </div>
62
- {% endblock %}
63
-
64
- {% block scripts %}
65
- <script>
66
- function drawDonut(completed, total) {
67
- const svg = document.getElementById('donut-svg');
68
- const cx = 100, cy = 100, r = 70, strokeW = 16;
69
- const pct = total > 0 ? completed / total : 0;
70
- const circumference = 2 * Math.PI * r;
71
- const completedArc = circumference * pct;
72
- const remainingArc = circumference - completedArc;
73
-
74
- // Determine color based on rate
75
- let color = '#EF4444'; // red
76
- if (pct >= 0.8) color = '#10B981'; // emerald
77
- else if (pct >= 0.5) color = '#F59E0B'; // amber
78
-
79
- svg.innerHTML = `
80
- <!-- Background ring -->
81
- <circle cx="${cx}" cy="${cy}" r="${r}" fill="none" stroke="rgba(51,65,85,0.4)" stroke-width="${strokeW}"/>
82
- <!-- Completed arc -->
83
- <circle cx="${cx}" cy="${cy}" r="${r}" fill="none" stroke="${color}" stroke-width="${strokeW}"
84
- stroke-dasharray="${completedArc} ${remainingArc}"
85
- stroke-dashoffset="${circumference / 4}"
86
- stroke-linecap="round"
87
- style="transition: stroke-dasharray 0.8s ease-out;"/>
88
- <!-- Center text -->
89
- <text x="${cx}" y="${cy - 8}" text-anchor="middle" fill="${color}" class="text-2xl font-mono font-bold" style="font-size:28px;font-weight:700">${Math.round(pct * 100)}%</text>
90
- <text x="${cx}" y="${cy + 14}" text-anchor="middle" fill="#64748b" style="font-size:11px">completion</text>
91
- <text x="${cx}" y="${cy + 30}" text-anchor="middle" fill="#475569" style="font-size:10px">${completed}/${total}</text>
92
- `;
93
- }
94
-
95
- function renderAgeBars(buckets) {
96
- const container = document.getElementById('age-bars');
97
- if (!buckets || !Object.keys(buckets).length) {
98
- container.innerHTML = '<div class="text-xs text-slate-600 py-12 text-center">No age data</div>';
99
- return;
100
- }
101
-
102
- const entries = Object.entries(buckets);
103
- const maxVal = Math.max(...entries.map(([, v]) => v), 1);
104
- const barColors = ['bg-emerald-500', 'bg-emerald-400', 'bg-amber-400', 'bg-amber-500', 'bg-red-400', 'bg-red-500'];
105
-
106
- container.innerHTML = entries.map(([label, count], i) => {
107
- const pct = (count / maxVal) * 100;
108
- const color = barColors[Math.min(i, barColors.length - 1)];
109
- return `<div class="flex items-center gap-3">
110
- <span class="w-20 text-xs text-slate-400 text-right">${escapeHtml(label)}</span>
111
- <div class="flex-1 bg-slate-800/50 rounded-full h-5 overflow-hidden">
112
- <div class="${color}/70 h-full rounded-full transition-all duration-500 flex items-center" style="width:${Math.max(2, pct)}%">
113
- ${pct > 15 ? `<span class="text-[10px] font-mono text-white/80 ml-2">${count}</span>` : ''}
114
- </div>
115
- </div>
116
- ${pct <= 15 ? `<span class="text-[10px] font-mono text-slate-500">${count}</span>` : ''}
117
- </div>`;
118
- }).join('');
119
- }
120
-
121
- function renderOverdue(items) {
122
- const container = document.getElementById('overdue-list');
123
- document.getElementById('overdue-label').textContent = (items || []).length + ' items';
124
-
125
- if (!items || !items.length) {
126
- container.innerHTML = '<div class="flex items-center justify-center gap-2 py-8 text-emerald-400"><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/></svg><span class="text-xs">No overdue items</span></div>';
127
- return;
128
- }
129
-
130
- container.innerHTML = items.map(item => {
131
- const daysOverdue = item.days_overdue || 0;
132
- const urgency = daysOverdue > 7 ? 'text-red-400' : daysOverdue > 3 ? 'text-amber-400' : 'text-slate-300';
133
- return `<div class="flex items-start gap-3 py-2.5 px-3 rounded-lg hover:bg-slate-800/20 transition-colors border border-transparent hover:border-red-500/10">
134
- <svg class="w-3.5 h-3.5 text-red-400 mt-0.5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
135
- <div class="flex-1 min-w-0">
136
- <div class="text-xs text-slate-300 leading-relaxed">${escapeHtml(item.description || item.text || '--')}</div>
137
- <div class="flex items-center gap-2 mt-1">
138
- ${item.date ? `<span class="text-[10px] text-slate-500">${escapeHtml(item.date)}</span>` : ''}
139
- <span class="text-[10px] ${urgency} font-mono">${daysOverdue}d overdue</span>
140
- </div>
141
- </div>
142
- </div>`;
143
- }).join('');
144
- }
145
-
146
- async function loadHealth() {
147
- const data = await fetchJSON('/api/followup-health');
148
- if (!data) return;
149
-
150
- const total = data.total || 0;
151
- const completed = data.completed || 0;
152
- const pending = data.pending || 0;
153
- const overdue = data.overdue || 0;
154
- const rate = data.completion_rate != null ? data.completion_rate : (total > 0 ? Math.round((completed / total) * 100) : 0);
155
-
156
- document.getElementById('fh-total').textContent = total;
157
- document.getElementById('fh-pending').textContent = pending;
158
- document.getElementById('fh-completed').textContent = completed;
159
- document.getElementById('fh-overdue').textContent = overdue;
160
- document.getElementById('fh-rate').textContent = rate + '%';
161
-
162
- drawDonut(completed, total);
163
- renderAgeBars(data.age_buckets || {});
164
- renderOverdue(data.overdue_items || []);
165
- }
166
-
167
- loadHealth();
168
- setInterval(loadHealth, 60000);
169
- </script>
170
- {% endblock %}
@@ -1,201 +0,0 @@
1
- {% extends "base.html" %}
2
-
3
- {% block title %}Knowledge Graph{% endblock %}
4
- {% block page_title %}Knowledge Graph{% endblock %}
5
-
6
- {% block head %}
7
- <style>
8
- .node circle { transition: filter 0.15s ease; }
9
- .node:hover circle { filter: drop-shadow(0 0 10px currentColor); }
10
- .link-label { fill: #64748b; font-size: 10px; pointer-events: none; opacity: 0.6; }
11
- </style>
12
- {% endblock %}
13
-
14
- {% block header_actions %}
15
- <input type="number" id="center" placeholder="Node ID"
16
- class="bg-slate-800 border border-slate-700 rounded-lg px-3 py-1 text-xs w-24 text-slate-200 focus:outline-none focus:ring-1 focus:ring-violet-500">
17
- <select id="depth" class="bg-slate-800 border border-slate-700 rounded-lg px-2 py-1 text-xs text-slate-200 focus:outline-none focus:ring-1 focus:ring-violet-500">
18
- <option>1</option><option selected>2</option><option>3</option>
19
- </select>
20
- <button onclick="loadGraph()" class="px-3 py-1 text-xs bg-violet-600 text-white rounded-lg hover:bg-violet-500 transition-colors">Load</button>
21
- <span id="info" class="text-xs text-slate-500 font-mono"></span>
22
- <div class="flex items-center gap-3 ml-2 text-xs text-slate-400">
23
- <span class="flex items-center gap-1"><span class="w-2 h-2 rounded-full bg-violet-500 inline-block"></span>area</span>
24
- <span class="flex items-center gap-1"><span class="w-2 h-2 rounded-full bg-emerald-500 inline-block"></span>file</span>
25
- <span class="flex items-center gap-1"><span class="w-2 h-2 rounded-full bg-blue-500 inline-block"></span>learning</span>
26
- <span class="flex items-center gap-1"><span class="w-2 h-2 rounded-full bg-amber-500 inline-block"></span>decision</span>
27
- <span class="flex items-center gap-1"><span class="w-2 h-2 rounded-full bg-pink-500 inline-block"></span>entity</span>
28
- <span class="flex items-center gap-1"><span class="w-2 h-2 rounded-full bg-slate-500 inline-block"></span>change</span>
29
- <span class="flex items-center gap-1"><span class="w-2 h-2 rounded-full bg-cyan-500 inline-block"></span>memory</span>
30
- </div>
31
- {% endblock %}
32
-
33
- {% block content %}
34
- <div class="flex overflow-hidden" style="height: calc(100vh - 8.5rem);">
35
- <!-- Graph canvas -->
36
- <div id="graph-container" class="flex-1 overflow-hidden">
37
- <svg id="svg" class="w-full h-full"></svg>
38
- </div>
39
-
40
- <!-- Node detail sidebar -->
41
- <div id="sidebar" class="overflow-hidden bg-slate-900 border-l border-slate-800 transition-all duration-300 flex-shrink-0" style="width:0">
42
- <div class="p-5 w-80">
43
- <div class="flex items-center justify-between mb-3">
44
- <h3 id="sb-label" class="text-sm font-display font-semibold text-violet-400 pr-4 leading-tight"></h3>
45
- <button onclick="closeSidebar()" class="text-slate-400 hover:text-white text-lg leading-none flex-shrink-0">&times;</button>
46
- </div>
47
- <div id="sb-meta" class="text-xs text-slate-500 mb-3 font-mono space-y-0.5"></div>
48
- <div class="text-xs font-display font-semibold text-slate-400 uppercase tracking-wide mb-2">Connections</div>
49
- <div id="sb-neighbors" class="space-y-1"></div>
50
- </div>
51
- </div>
52
- </div>
53
- {% endblock %}
54
-
55
- {% block scripts %}
56
- <script src="https://d3js.org/d3.v7.min.js"></script>
57
- <script>
58
- const typeColors = {
59
- area: '#8B5CF6',
60
- file: '#10B981',
61
- learning: '#3B82F6',
62
- decision: '#F59E0B',
63
- entity: '#EC4899',
64
- change: '#64748B',
65
- memory: '#06B6D4'
66
- };
67
-
68
- function nodeColor(type) { return typeColors[type] || '#64748B'; }
69
- function nodeRadius(d) { return d.depth === 0 ? 16 : d.depth === 1 ? 10 : 7; }
70
-
71
- let currentSim = null;
72
-
73
- async function loadGraph() {
74
- const center = document.getElementById('center').value;
75
- const depth = document.getElementById('depth').value;
76
- const url = center ? `/api/graph?center=${center}&depth=${depth}` : '/api/graph';
77
- const data = await fetch(url).then(r => r.json());
78
-
79
- if (!data.nodes || data.nodes.length === 0) {
80
- const hints = (data.hints || []).map(h => `${h.label} (id:${h.id})`).join(', ');
81
- document.getElementById('info').textContent = hints ? `No subgraph found. Top: ${hints}` : 'No graph data found';
82
- if (data.hints && data.hints.length > 0) {
83
- document.getElementById('center').value = data.hints[0].id;
84
- loadGraph();
85
- }
86
- return;
87
- }
88
-
89
- document.getElementById('info').textContent = `${data.nodes.length} nodes · ${data.edges.length} edges`;
90
- renderGraph(data);
91
- }
92
-
93
- function renderGraph(data) {
94
- const svg = d3.select('#svg');
95
- svg.selectAll('*').remove();
96
- const width = svg.node().clientWidth;
97
- const height = svg.node().clientHeight;
98
- const g = svg.append('g');
99
-
100
- svg.call(d3.zoom().scaleExtent([0.1, 8]).on('zoom', e => g.attr('transform', e.transform)));
101
-
102
- if (currentSim) currentSim.stop();
103
- currentSim = d3.forceSimulation(data.nodes)
104
- .force('link', d3.forceLink(data.edges).id(d => d.id).distance(80))
105
- .force('charge', d3.forceManyBody().strength(-300))
106
- .force('center', d3.forceCenter(width / 2, height / 2))
107
- .force('collision', d3.forceCollide().radius(d => nodeRadius(d) + 20));
108
-
109
- const link = g.selectAll('.link').data(data.edges).join('line')
110
- .attr('class', 'link')
111
- .attr('stroke', '#334155')
112
- .attr('stroke-width', d => Math.max(1, (d.weight || 0.5) * 2.5))
113
- .attr('stroke-opacity', d => Math.min(0.6, 0.2 + (d.weight || 0.3) * 0.4));
114
-
115
- const linkLabel = g.selectAll('.link-label').data(data.edges).join('text')
116
- .attr('class', 'link-label')
117
- .text(d => d.relation);
118
-
119
- const node = g.selectAll('.node').data(data.nodes).join('g')
120
- .attr('class', 'node')
121
- .style('cursor', 'pointer')
122
- .on('click', (e, d) => showNodeDetail(d))
123
- .call(d3.drag()
124
- .on('start', (e, d) => { if (!e.active) currentSim.alphaTarget(0.3).restart(); d.fx = d.x; d.fy = d.y; })
125
- .on('drag', (e, d) => { d.fx = e.x; d.fy = e.y; })
126
- .on('end', (e, d) => { if (!e.active) currentSim.alphaTarget(0); d.fx = null; d.fy = null; }));
127
-
128
- node.append('circle')
129
- .attr('r', d => nodeRadius(d))
130
- .attr('fill', d => nodeColor(d.type))
131
- .attr('stroke', d => d.depth === 0 ? '#fff' : nodeColor(d.type))
132
- .attr('stroke-width', d => d.depth === 0 ? 2.5 : 1)
133
- .attr('stroke-opacity', d => d.depth === 0 ? 0.8 : 0.3)
134
- .style('color', d => nodeColor(d.type));
135
-
136
- node.filter(d => d.depth <= 1).append('text')
137
- .attr('dx', d => nodeRadius(d) + 5)
138
- .attr('dy', 4)
139
- .attr('fill', '#94a3b8')
140
- .attr('font-size', d => d.depth === 0 ? '13px' : '11px')
141
- .attr('font-weight', d => d.depth === 0 ? '600' : '400')
142
- .attr('font-family', 'Space Grotesk, system-ui, sans-serif')
143
- .text(d => d.label.length > 40 ? d.label.slice(0, 37) + '...' : d.label);
144
-
145
- node.filter(d => d.depth > 1).append('title')
146
- .text(d => `[${d.type}] ${d.label}`);
147
-
148
- currentSim.on('tick', () => {
149
- link.attr('x1', d => d.source.x).attr('y1', d => d.source.y)
150
- .attr('x2', d => d.target.x).attr('y2', d => d.target.y);
151
- linkLabel.attr('x', d => (d.source.x + d.target.x) / 2)
152
- .attr('y', d => (d.source.y + d.target.y) / 2);
153
- node.attr('transform', d => `translate(${d.x},${d.y})`);
154
- });
155
- }
156
-
157
- async function showNodeDetail(d) {
158
- document.getElementById('sb-label').textContent = d.label;
159
- document.getElementById('sb-meta').innerHTML =
160
- `<div>Type: <span style="color:${nodeColor(d.type)}">${d.type}</span></div>` +
161
- `<div>ID: ${d.id}</div>` +
162
- `<div>Depth: ${d.depth}</div>`;
163
-
164
- document.getElementById('sidebar').style.width = '320px';
165
-
166
- const resp = await fetch(`/api/graph?center=${d.id}&depth=1`);
167
- const data = await resp.json();
168
- const nbDiv = document.getElementById('sb-neighbors');
169
-
170
- if (!data.edges || data.edges.length === 0) {
171
- nbDiv.innerHTML = '<p class="text-sm text-slate-500">No connections found</p>';
172
- return;
173
- }
174
-
175
- const neighbors = data.nodes.filter(n => n.id !== d.id).slice(0, 20);
176
- nbDiv.innerHTML = `<p class="text-xs text-slate-500 mb-2">${data.edges.length} connections</p>` +
177
- neighbors.map(n => {
178
- const label = n.label.length > 45 ? n.label.slice(0, 42) + '...' : n.label;
179
- return `<div class="neighbor-item px-2 py-1.5 rounded-md hover:bg-slate-800 cursor-pointer transition-colors" data-id="${n.id}">
180
- <span class="text-xs font-semibold" style="color:${nodeColor(n.type)}">[${n.type}]</span>
181
- <span class="text-sm text-slate-300 ml-1">${label.replace(/</g, '&lt;')}</span>
182
- <div class="text-xs text-slate-600 mt-0.5">Click to center</div>
183
- </div>`;
184
- }).join('');
185
-
186
- nbDiv.querySelectorAll('.neighbor-item').forEach(el => {
187
- el.addEventListener('click', () => {
188
- document.getElementById('center').value = el.dataset.id;
189
- loadGraph();
190
- });
191
- });
192
- }
193
-
194
- function closeSidebar() {
195
- document.getElementById('sidebar').style.width = '0';
196
- }
197
-
198
- // Auto-load on page open
199
- loadGraph();
200
- </script>
201
- {% endblock %}