nexo-brain 1.7.0 → 2.1.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 (261) hide show
  1. package/README.md +160 -60
  2. package/bin/nexo-brain.js +680 -381
  3. package/package.json +18 -3
  4. package/scripts/migrate-to-unified.sh +813 -0
  5. package/scripts/migrate-v1.7-to-v1.8.py +214 -0
  6. package/scripts/pre-commit-check.sh +1 -1
  7. package/src/__pycache__/auto_update.cpython-310.pyc +0 -0
  8. package/src/__pycache__/hnsw_index.cpython-310.pyc +0 -0
  9. package/src/__pycache__/hnsw_index.cpython-314.pyc +0 -0
  10. package/src/__pycache__/kg_populate.cpython-310.pyc +0 -0
  11. package/src/__pycache__/knowledge_graph.cpython-310.pyc +0 -0
  12. package/src/__pycache__/plugin_loader.cpython-310.pyc +0 -0
  13. package/src/__pycache__/tools_coordination.cpython-310.pyc +0 -0
  14. package/src/__pycache__/tools_credentials.cpython-310.pyc +0 -0
  15. package/src/__pycache__/tools_learnings.cpython-310.pyc +0 -0
  16. package/src/__pycache__/tools_menu.cpython-310.pyc +0 -0
  17. package/src/__pycache__/tools_reminders.cpython-310.pyc +0 -0
  18. package/src/__pycache__/tools_reminders_crud.cpython-310.pyc +0 -0
  19. package/src/__pycache__/tools_sessions.cpython-310.pyc +0 -0
  20. package/src/__pycache__/tools_task_history.cpython-310.pyc +0 -0
  21. package/src/auto_close_sessions.py +1 -1
  22. package/src/auto_update.py +634 -0
  23. package/src/cognitive/__pycache__/__init__.cpython-310.pyc +0 -0
  24. package/src/cognitive/__pycache__/__init__.cpython-312.pyc +0 -0
  25. package/src/cognitive/__pycache__/__init__.cpython-314.pyc +0 -0
  26. package/src/cognitive/__pycache__/_core.cpython-310.pyc +0 -0
  27. package/src/cognitive/__pycache__/_core.cpython-312.pyc +0 -0
  28. package/src/cognitive/__pycache__/_core.cpython-314.pyc +0 -0
  29. package/src/cognitive/__pycache__/_decay.cpython-310.pyc +0 -0
  30. package/src/cognitive/__pycache__/_decay.cpython-312.pyc +0 -0
  31. package/src/cognitive/__pycache__/_decay.cpython-314.pyc +0 -0
  32. package/src/cognitive/__pycache__/_ingest.cpython-310.pyc +0 -0
  33. package/src/cognitive/__pycache__/_ingest.cpython-312.pyc +0 -0
  34. package/src/cognitive/__pycache__/_ingest.cpython-314.pyc +0 -0
  35. package/src/cognitive/__pycache__/_memory.cpython-310.pyc +0 -0
  36. package/src/cognitive/__pycache__/_memory.cpython-312.pyc +0 -0
  37. package/src/cognitive/__pycache__/_memory.cpython-314.pyc +0 -0
  38. package/src/cognitive/__pycache__/_search.cpython-310.pyc +0 -0
  39. package/src/cognitive/__pycache__/_search.cpython-312.pyc +0 -0
  40. package/src/cognitive/__pycache__/_search.cpython-314.pyc +0 -0
  41. package/src/cognitive/__pycache__/_trust.cpython-310.pyc +0 -0
  42. package/src/cognitive/__pycache__/_trust.cpython-312.pyc +0 -0
  43. package/src/cognitive/__pycache__/_trust.cpython-314.pyc +0 -0
  44. package/src/cognitive/_core.py +7 -3
  45. package/src/cognitive/_decay.py +1 -1
  46. package/src/cognitive/_search.py +1 -0
  47. package/src/cognitive/_trust.py +3 -3
  48. package/src/crons/manifest.json +106 -0
  49. package/src/crons/sync.py +217 -0
  50. package/src/dashboard/__pycache__/__init__.cpython-310.pyc +0 -0
  51. package/src/dashboard/__pycache__/app.cpython-310.pyc +0 -0
  52. package/src/dashboard/app.py +24 -4
  53. package/src/dashboard/templates/dashboard.html +3 -2
  54. package/src/db/__pycache__/__init__.cpython-310.pyc +0 -0
  55. package/src/db/__pycache__/__init__.cpython-312.pyc +0 -0
  56. package/src/db/__pycache__/__init__.cpython-314.pyc +0 -0
  57. package/src/db/__pycache__/_core.cpython-310.pyc +0 -0
  58. package/src/db/__pycache__/_core.cpython-312.pyc +0 -0
  59. package/src/db/__pycache__/_core.cpython-314.pyc +0 -0
  60. package/src/db/__pycache__/_credentials.cpython-310.pyc +0 -0
  61. package/src/db/__pycache__/_credentials.cpython-312.pyc +0 -0
  62. package/src/db/__pycache__/_credentials.cpython-314.pyc +0 -0
  63. package/src/db/__pycache__/_entities.cpython-310.pyc +0 -0
  64. package/src/db/__pycache__/_entities.cpython-312.pyc +0 -0
  65. package/src/db/__pycache__/_entities.cpython-314.pyc +0 -0
  66. package/src/db/__pycache__/_episodic.cpython-310.pyc +0 -0
  67. package/src/db/__pycache__/_episodic.cpython-312.pyc +0 -0
  68. package/src/db/__pycache__/_episodic.cpython-314.pyc +0 -0
  69. package/src/db/__pycache__/_evolution.cpython-310.pyc +0 -0
  70. package/src/db/__pycache__/_evolution.cpython-312.pyc +0 -0
  71. package/src/db/__pycache__/_evolution.cpython-314.pyc +0 -0
  72. package/src/db/__pycache__/_fts.cpython-310.pyc +0 -0
  73. package/src/db/__pycache__/_fts.cpython-312.pyc +0 -0
  74. package/src/db/__pycache__/_fts.cpython-314.pyc +0 -0
  75. package/src/db/__pycache__/_learnings.cpython-310.pyc +0 -0
  76. package/src/db/__pycache__/_learnings.cpython-312.pyc +0 -0
  77. package/src/db/__pycache__/_learnings.cpython-314.pyc +0 -0
  78. package/src/db/__pycache__/_reminders.cpython-310.pyc +0 -0
  79. package/src/db/__pycache__/_reminders.cpython-312.pyc +0 -0
  80. package/src/db/__pycache__/_reminders.cpython-314.pyc +0 -0
  81. package/src/db/__pycache__/_schema.cpython-310.pyc +0 -0
  82. package/src/db/__pycache__/_schema.cpython-312.pyc +0 -0
  83. package/src/db/__pycache__/_schema.cpython-314.pyc +0 -0
  84. package/src/db/__pycache__/_sessions.cpython-310.pyc +0 -0
  85. package/src/db/__pycache__/_sessions.cpython-312.pyc +0 -0
  86. package/src/db/__pycache__/_sessions.cpython-314.pyc +0 -0
  87. package/src/db/__pycache__/_tasks.cpython-310.pyc +0 -0
  88. package/src/db/__pycache__/_tasks.cpython-312.pyc +0 -0
  89. package/src/db/__pycache__/_tasks.cpython-314.pyc +0 -0
  90. package/src/db/_core.py +5 -1
  91. package/src/db/_episodic.py +2 -4
  92. package/src/db/_reminders.py +45 -6
  93. package/src/db/_schema.py +31 -0
  94. package/src/evolution_cycle.py +33 -11
  95. package/src/hooks/auto_capture.py +1 -1
  96. package/src/hooks/capture-tool-logs.sh +76 -0
  97. package/src/hooks/inbox-hook.sh +2 -1
  98. package/src/hooks/post-compact.sh +2 -1
  99. package/src/hooks/pre-compact.sh +104 -2
  100. package/src/hooks/session-start.sh +6 -2
  101. package/src/hooks/session-stop.sh +4 -2
  102. package/src/kg_populate.py +4 -1
  103. package/src/migrate_embeddings.py +4 -1
  104. package/src/plugin_loader.py +100 -34
  105. package/src/plugins/__pycache__/__init__.cpython-310.pyc +0 -0
  106. package/src/plugins/__pycache__/adaptive_mode.cpython-310.pyc +0 -0
  107. package/src/plugins/__pycache__/adaptive_mode.cpython-314.pyc +0 -0
  108. package/src/plugins/__pycache__/agents.cpython-310.pyc +0 -0
  109. package/src/plugins/__pycache__/artifact_registry.cpython-310.pyc +0 -0
  110. package/src/plugins/__pycache__/backup.cpython-310.pyc +0 -0
  111. package/src/plugins/__pycache__/cognitive_memory.cpython-310.pyc +0 -0
  112. package/src/plugins/__pycache__/core_rules.cpython-310.pyc +0 -0
  113. package/src/plugins/__pycache__/cortex.cpython-310.pyc +0 -0
  114. package/src/plugins/__pycache__/entities.cpython-310.pyc +0 -0
  115. package/src/plugins/__pycache__/episodic_memory.cpython-310.pyc +0 -0
  116. package/src/plugins/__pycache__/evolution.cpython-310.pyc +0 -0
  117. package/src/plugins/__pycache__/guard.cpython-310.pyc +0 -0
  118. package/src/plugins/__pycache__/knowledge_graph_tools.cpython-310.pyc +0 -0
  119. package/src/plugins/__pycache__/preferences.cpython-310.pyc +0 -0
  120. package/src/plugins/__pycache__/update.cpython-310.pyc +0 -0
  121. package/src/plugins/agents.py +2 -2
  122. package/src/plugins/backup.py +5 -4
  123. package/src/plugins/core_rules.py +37 -16
  124. package/src/plugins/episodic_memory.py +14 -5
  125. package/src/plugins/evolution.py +6 -2
  126. package/src/plugins/guard.py +20 -11
  127. package/src/plugins/update.py +256 -0
  128. package/src/requirements.txt +12 -0
  129. package/src/scripts/check-context.py +8 -3
  130. package/src/scripts/deep-sleep/__pycache__/extract.cpython-314.pyc +0 -0
  131. package/src/scripts/deep-sleep/apply_findings.py +514 -169
  132. package/src/scripts/deep-sleep/collect.py +480 -0
  133. package/src/scripts/deep-sleep/extract-prompt.md +233 -0
  134. package/src/scripts/deep-sleep/extract.py +249 -0
  135. package/src/scripts/deep-sleep/synthesize-prompt.md +168 -0
  136. package/src/scripts/deep-sleep/synthesize.py +191 -0
  137. package/src/scripts/nexo-auto-update.py +4 -211
  138. package/src/scripts/nexo-backup.sh +5 -13
  139. package/src/scripts/nexo-brain-activation.sh +26 -26
  140. package/src/scripts/nexo-catchup.py +36 -25
  141. package/src/scripts/nexo-cognitive-decay.py +7 -3
  142. package/src/scripts/nexo-daily-self-audit.py +44 -15
  143. package/src/scripts/nexo-deep-sleep.sh +31 -16
  144. package/src/scripts/nexo-evolution-run.py +21 -11
  145. package/src/scripts/nexo-followup-hygiene.py +6 -4
  146. package/src/scripts/nexo-github-monitor.py +12 -8
  147. package/src/scripts/nexo-immune.py +6 -4
  148. package/src/scripts/nexo-inbox-hook.sh +2 -1
  149. package/src/scripts/nexo-install.py +4 -225
  150. package/src/scripts/nexo-learning-housekeep.py +7 -3
  151. package/src/scripts/nexo-learning-validator.py +1 -22
  152. package/src/scripts/nexo-migrate.py +9 -3
  153. package/src/scripts/nexo-postmortem-consolidator.py +17 -10
  154. package/src/scripts/nexo-pre-commit.py +3 -1
  155. package/src/scripts/nexo-prevent-sleep.sh +29 -0
  156. package/src/scripts/nexo-proactive-dashboard.py +5 -4
  157. package/src/scripts/nexo-runtime-preflight.py +59 -55
  158. package/src/scripts/nexo-send-email.py +1 -1
  159. package/src/scripts/nexo-send-reply.py +3 -1
  160. package/src/scripts/nexo-sleep.py +13 -9
  161. package/src/scripts/nexo-snapshot-restore.sh +2 -1
  162. package/src/scripts/nexo-synthesis.py +11 -7
  163. package/src/scripts/nexo-tcc-approve.sh +79 -0
  164. package/src/scripts/nexo-update.sh +161 -0
  165. package/src/scripts/nexo-watchdog-smoke.py +18 -13
  166. package/src/scripts/nexo-watchdog.sh +22 -13
  167. package/src/server.py +77 -28
  168. package/src/storage_router.py +6 -2
  169. package/src/tools_learnings.py +6 -6
  170. package/src/tools_menu.py +1 -1
  171. package/src/tools_reminders_crud.py +10 -8
  172. package/src/tools_sessions.py +76 -4
  173. package/templates/CLAUDE.md.template +14 -80
  174. package/templates/launchagents/README.md +7 -7
  175. package/templates/launchagents/com.nexo.auto-close-sessions.plist +5 -1
  176. package/templates/launchagents/com.nexo.catchup.plist +4 -0
  177. package/templates/launchagents/com.nexo.cognitive-decay.plist +7 -0
  178. package/templates/launchagents/com.nexo.dashboard.plist +5 -1
  179. package/templates/launchagents/com.nexo.deep-sleep.plist +4 -0
  180. package/templates/launchagents/com.nexo.evolution.plist +4 -0
  181. package/templates/launchagents/com.nexo.followup-hygiene.plist +4 -0
  182. package/templates/launchagents/com.nexo.github-monitor.plist +3 -1
  183. package/templates/launchagents/com.nexo.immune.plist +4 -0
  184. package/templates/launchagents/com.nexo.postmortem.plist +4 -0
  185. package/templates/launchagents/com.nexo.self-audit.plist +4 -0
  186. package/templates/launchagents/com.nexo.synthesis.plist +4 -0
  187. package/templates/launchagents/com.nexo.watchdog.plist +4 -0
  188. package/templates/openclaw.json +1 -1
  189. package/tests/conftest.py +2 -2
  190. package/tests/test_cognitive.py +7 -6
  191. package/tests/test_migrations.py +26 -0
  192. package/src/__pycache__/auto_close_sessions.cpython-314.pyc +0 -0
  193. package/src/__pycache__/claim_graph.cpython-314.pyc +0 -0
  194. package/src/__pycache__/evolution_cycle.cpython-314.pyc +0 -0
  195. package/src/__pycache__/kg_populate.cpython-314.pyc +0 -0
  196. package/src/__pycache__/knowledge_graph.cpython-314.pyc +0 -0
  197. package/src/__pycache__/maintenance.cpython-314.pyc +0 -0
  198. package/src/__pycache__/migrate_embeddings.cpython-314.pyc +0 -0
  199. package/src/__pycache__/plugin_loader.cpython-314.pyc +0 -0
  200. package/src/__pycache__/server.cpython-314.pyc +0 -0
  201. package/src/__pycache__/storage_router.cpython-314.pyc +0 -0
  202. package/src/__pycache__/tools_coordination.cpython-314.pyc +0 -0
  203. package/src/__pycache__/tools_credentials.cpython-314.pyc +0 -0
  204. package/src/__pycache__/tools_learnings.cpython-314.pyc +0 -0
  205. package/src/__pycache__/tools_menu.cpython-314.pyc +0 -0
  206. package/src/__pycache__/tools_reminders.cpython-314.pyc +0 -0
  207. package/src/__pycache__/tools_reminders_crud.cpython-314.pyc +0 -0
  208. package/src/__pycache__/tools_sessions.cpython-314.pyc +0 -0
  209. package/src/__pycache__/tools_task_history.cpython-314.pyc +0 -0
  210. package/src/dashboard/__pycache__/__init__.cpython-314.pyc +0 -0
  211. package/src/dashboard/__pycache__/app.cpython-314.pyc +0 -0
  212. package/src/hooks/__pycache__/auto_capture.cpython-314.pyc +0 -0
  213. package/src/plugins/__pycache__/__init__.cpython-314.pyc +0 -0
  214. package/src/plugins/__pycache__/agents.cpython-314.pyc +0 -0
  215. package/src/plugins/__pycache__/artifact_registry.cpython-314.pyc +0 -0
  216. package/src/plugins/__pycache__/backup.cpython-314.pyc +0 -0
  217. package/src/plugins/__pycache__/cognitive_memory.cpython-314.pyc +0 -0
  218. package/src/plugins/__pycache__/core_rules.cpython-314.pyc +0 -0
  219. package/src/plugins/__pycache__/cortex.cpython-314.pyc +0 -0
  220. package/src/plugins/__pycache__/entities.cpython-314.pyc +0 -0
  221. package/src/plugins/__pycache__/episodic_memory.cpython-314.pyc +0 -0
  222. package/src/plugins/__pycache__/evolution.cpython-314.pyc +0 -0
  223. package/src/plugins/__pycache__/guard.cpython-314.pyc +0 -0
  224. package/src/plugins/__pycache__/knowledge_graph_tools.cpython-314.pyc +0 -0
  225. package/src/plugins/__pycache__/preferences.cpython-314.pyc +0 -0
  226. package/src/rules/__pycache__/__init__.cpython-314.pyc +0 -0
  227. package/src/rules/__pycache__/migrate.cpython-314.pyc +0 -0
  228. package/src/scripts/__pycache__/check-context.cpython-314.pyc +0 -0
  229. package/src/scripts/__pycache__/nexo-auto-update.cpython-314.pyc +0 -0
  230. package/src/scripts/__pycache__/nexo-catchup.cpython-314.pyc +0 -0
  231. package/src/scripts/__pycache__/nexo-cognitive-decay.cpython-314.pyc +0 -0
  232. package/src/scripts/__pycache__/nexo-daily-self-audit.cpython-314.pyc +0 -0
  233. package/src/scripts/__pycache__/nexo-evolution-run.cpython-314.pyc +0 -0
  234. package/src/scripts/__pycache__/nexo-followup-hygiene.cpython-314.pyc +0 -0
  235. package/src/scripts/__pycache__/nexo-github-monitor.cpython-314.pyc +0 -0
  236. package/src/scripts/__pycache__/nexo-immune.cpython-314.pyc +0 -0
  237. package/src/scripts/__pycache__/nexo-install.cpython-314.pyc +0 -0
  238. package/src/scripts/__pycache__/nexo-learning-housekeep.cpython-314.pyc +0 -0
  239. package/src/scripts/__pycache__/nexo-learning-validator.cpython-314.pyc +0 -0
  240. package/src/scripts/__pycache__/nexo-migrate.cpython-314.pyc +0 -0
  241. package/src/scripts/__pycache__/nexo-postmortem-consolidator.cpython-314.pyc +0 -0
  242. package/src/scripts/__pycache__/nexo-pre-commit.cpython-314.pyc +0 -0
  243. package/src/scripts/__pycache__/nexo-proactive-dashboard.cpython-314.pyc +0 -0
  244. package/src/scripts/__pycache__/nexo-reflection.cpython-314.pyc +0 -0
  245. package/src/scripts/__pycache__/nexo-runtime-preflight.cpython-314.pyc +0 -0
  246. package/src/scripts/__pycache__/nexo-send-email.cpython-314.pyc +0 -0
  247. package/src/scripts/__pycache__/nexo-send-reply.cpython-314.pyc +0 -0
  248. package/src/scripts/__pycache__/nexo-sleep.cpython-314.pyc +0 -0
  249. package/src/scripts/__pycache__/nexo-synthesis.cpython-314.pyc +0 -0
  250. package/src/scripts/__pycache__/nexo-watchdog-smoke.cpython-314.pyc +0 -0
  251. package/src/scripts/deep-sleep/__pycache__/analyze_session.cpython-314.pyc +0 -0
  252. package/src/scripts/deep-sleep/__pycache__/apply_findings.cpython-314.pyc +0 -0
  253. package/src/scripts/deep-sleep/__pycache__/collect_transcripts.cpython-314.pyc +0 -0
  254. package/src/scripts/deep-sleep/analyze_session.py +0 -217
  255. package/src/scripts/deep-sleep/collect_transcripts.py +0 -145
  256. package/src/scripts/deep-sleep/prompt.md +0 -109
  257. package/tests/__pycache__/__init__.cpython-314.pyc +0 -0
  258. package/tests/__pycache__/conftest.cpython-314-pytest-9.0.2.pyc +0 -0
  259. package/tests/__pycache__/test_cognitive.cpython-314-pytest-9.0.2.pyc +0 -0
  260. package/tests/__pycache__/test_knowledge_graph.cpython-314-pytest-9.0.2.pyc +0 -0
  261. package/tests/__pycache__/test_migrations.cpython-314-pytest-9.0.2.pyc +0 -0
@@ -1,145 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Deep Sleep — Step 1: Collect today's session transcripts.
4
- Reads Claude Code .jsonl files, extracts clean conversation text + tool usage.
5
- """
6
- import json
7
- import os
8
- import sys
9
- from datetime import datetime
10
- from pathlib import Path
11
-
12
- NEXO_HOME = Path(os.environ.get("NEXO_HOME", str(Path.home() / ".nexo")))
13
-
14
- MIN_USER_MESSAGES = 3 # Skip trivial sessions
15
-
16
-
17
- def find_sessions_dir() -> Path:
18
- """Find the Claude Code sessions directory dynamically."""
19
- claude_dir = Path.home() / ".claude" / "projects"
20
- if not claude_dir.exists():
21
- return claude_dir
22
-
23
- # Find the project directory (usually named after the home path)
24
- for d in claude_dir.iterdir():
25
- if d.is_dir() and list(d.glob("*.jsonl")):
26
- return d
27
-
28
- # Fallback: look for any .jsonl in the projects dir tree
29
- for jsonl in claude_dir.rglob("*.jsonl"):
30
- return jsonl.parent
31
-
32
- return claude_dir
33
-
34
-
35
- def extract_session(jsonl_path: str) -> dict | None:
36
- """Extract clean transcript from a session JSONL file."""
37
- messages = []
38
- tool_uses = []
39
- user_msg_count = 0
40
-
41
- try:
42
- with open(jsonl_path, "r") as f:
43
- for line in f:
44
- line = line.strip()
45
- if not line:
46
- continue
47
- try:
48
- d = json.loads(line)
49
- except json.JSONDecodeError:
50
- continue
51
-
52
- msg_type = d.get("type")
53
-
54
- # User messages
55
- if msg_type == "user":
56
- content = d.get("message", {}).get("content", "")
57
- if isinstance(content, str) and content.strip():
58
- if content.startswith("<system-reminder>"):
59
- continue
60
- messages.append({
61
- "role": "user",
62
- "text": content[:5000],
63
- "uuid": d.get("uuid", "")
64
- })
65
- user_msg_count += 1
66
-
67
- # Assistant messages
68
- elif msg_type in ("message", "assistant"):
69
- msg = d.get("message", {})
70
- content_blocks = msg.get("content", [])
71
- text_parts = []
72
- for block in content_blocks:
73
- if isinstance(block, dict):
74
- if block.get("type") == "text":
75
- text_parts.append(block.get("text", ""))
76
- elif block.get("type") == "tool_use":
77
- tool_uses.append({
78
- "tool": block.get("name", ""),
79
- "input_keys": list(block.get("input", {}).keys()) if isinstance(block.get("input"), dict) else [],
80
- "file": block.get("input", {}).get("file_path", "") or block.get("input", {}).get("command", "")[:100] if isinstance(block.get("input"), dict) else ""
81
- })
82
- if text_parts:
83
- combined = "\n".join(text_parts)[:5000]
84
- messages.append({
85
- "role": "assistant",
86
- "text": combined
87
- })
88
-
89
- except Exception as e:
90
- print(f"Error reading {jsonl_path}: {e}", file=sys.stderr)
91
- return None
92
-
93
- if user_msg_count < MIN_USER_MESSAGES:
94
- return None
95
-
96
- return {
97
- "session_file": os.path.basename(jsonl_path),
98
- "message_count": len(messages),
99
- "user_message_count": user_msg_count,
100
- "tool_use_count": len(tool_uses),
101
- "messages": messages,
102
- "tool_uses": tool_uses
103
- }
104
-
105
-
106
- def collect_date(target_date: str, sessions_dir: Path) -> list[dict]:
107
- """Collect all sessions modified on a given date."""
108
- sessions = []
109
- for f in sessions_dir.glob("*.jsonl"):
110
- mtime = datetime.fromtimestamp(f.stat().st_mtime)
111
- if mtime.strftime("%Y-%m-%d") == target_date:
112
- session = extract_session(str(f))
113
- if session:
114
- session["modified"] = mtime.isoformat()
115
- sessions.append(session)
116
- sessions.sort(key=lambda s: s["modified"])
117
- return sessions
118
-
119
-
120
- def main():
121
- date_arg = sys.argv[1] if len(sys.argv) > 1 else datetime.now().strftime("%Y-%m-%d")
122
- sessions_dir = find_sessions_dir()
123
-
124
- sessions = collect_date(date_arg, sessions_dir)
125
-
126
- output = {
127
- "date": date_arg,
128
- "sessions_found": len(sessions),
129
- "total_messages": sum(s["message_count"] for s in sessions),
130
- "total_tool_uses": sum(s["tool_use_count"] for s in sessions),
131
- "sessions": sessions
132
- }
133
-
134
- output_dir = NEXO_HOME / "operations" / "deep-sleep"
135
- output_dir.mkdir(parents=True, exist_ok=True)
136
- output_file = output_dir / f"{output['date']}-transcripts.json"
137
- with open(output_file, "w") as f:
138
- json.dump(output, f, indent=2, ensure_ascii=False)
139
-
140
- print(f"Collected {len(sessions)} sessions, {output['total_messages']} messages, {output['total_tool_uses']} tool uses")
141
- print(f"Output: {output_file}")
142
-
143
-
144
- if __name__ == "__main__":
145
- main()
@@ -1,109 +0,0 @@
1
- # Deep Sleep Analyst — Session Transcript Analysis
2
-
3
- You are NEXO's overnight analyst. You read the COMPLETE transcripts of today's sessions between the user and NEXO, and you find what NEXO missed.
4
-
5
- ## Your job
6
-
7
- NEXO captures feedback, learnings, and corrections during sessions — but it misses things. Your job is to find the gaps by reading what ACTUALLY happened (the transcript), not what NEXO thinks happened (the diary).
8
-
9
- ## What you analyze
10
-
11
- ### 1. Uncaptured corrections
12
- The user corrected NEXO but NEXO didn't save a learning or feedback memory.
13
- Signals: frustration tone, repeating the same instruction 2+ times, the user having to explain something twice, explicit corrections ("no", "wrong", "that's not it").
14
-
15
- ### 2. Repeated patterns
16
- The same correction appears multiple times in the day. This is a SYSTEMIC failure — it needs a strong learning with high severity.
17
-
18
- ### 3. Uncaptured ideas
19
- The user mentioned an idea, plan, or intention that nobody formalized. Signals: "we could", "we should", "I want", "I need", future-tense plans without deadlines.
20
-
21
- ### 4. Missed commitments
22
- The user said "I'll look at it tomorrow", "this week", "when I can" — was a followup created? If not, flag it.
23
-
24
- ### 5. Protocol compliance (from tool_uses)
25
- Check if NEXO followed its own protocols:
26
- - `nexo_guard_check` before Edit/Write on production files?
27
- - `nexo_heartbeat` called with meaningful context_hint?
28
- - `nexo_cognitive_trust` called after corrections?
29
- - `nexo_learning_add` called after resolving errors?
30
- - `nexo_followup_complete` called when the user confirmed completion ("done", "fixed", "already handled")?
31
- - `nexo_change_log` called after production code changes?
32
- - Feedback memory saved after corrections?
33
-
34
- ### 6. Quality assessment
35
- - Did NEXO declare work "complete"/"perfect" and the user had to correct after?
36
- - Was NEXO too verbose when the user wanted action?
37
- - Did NEXO delegate to subagents when it should have done the work directly?
38
-
39
- ## Output format
40
-
41
- Return ONLY valid JSON:
42
-
43
- ```json
44
- {
45
- "date": "YYYY-MM-DD",
46
- "sessions_analyzed": 5,
47
- "uncaptured_corrections": [
48
- {
49
- "quote": "User's exact words (max 100 chars)",
50
- "context": "What they were working on",
51
- "what_nexo_should_have_saved": "The learning/feedback content",
52
- "action": "learning_add|feedback_write|preference_set",
53
- "category": "ui|code|process|communication",
54
- "severity": "low|medium|high|critical",
55
- "times_repeated": 1
56
- }
57
- ],
58
- "uncaptured_ideas": [
59
- {
60
- "quote": "User's words",
61
- "idea": "What the idea is",
62
- "action": "reminder_create|followup_create",
63
- "suggested_date": "YYYY-MM-DD or null"
64
- }
65
- ],
66
- "missed_commitments": [
67
- {
68
- "quote": "User's words",
69
- "commitment": "What was promised",
70
- "action": "followup_create",
71
- "due_date": "YYYY-MM-DD"
72
- }
73
- ],
74
- "protocol_compliance": {
75
- "guard_check": {"required": 0, "executed": 0, "rate": 1.0},
76
- "heartbeat_quality": {"total": 0, "with_good_context": 0, "rate": 1.0},
77
- "trust_adjustments": {"corrections_detected": 0, "adjusted": 0, "rate": 1.0},
78
- "learning_capture": {"errors_resolved": 0, "captured": 0, "rate": 1.0},
79
- "change_log": {"production_edits": 0, "logged": 0, "rate": 1.0},
80
- "feedback_capture": {"corrections": 0, "captured": 0, "rate": 1.0},
81
- "overall_compliance": 1.0
82
- },
83
- "protocol_violations": [
84
- {
85
- "protocol": "guard_check|trust_adjustment|feedback_capture|...",
86
- "context": "What happened",
87
- "severity": "low|medium|high|critical"
88
- }
89
- ],
90
- "quality_issues": [
91
- {
92
- "issue": "Description of quality problem",
93
- "example": "Specific instance",
94
- "severity": "low|medium|high"
95
- }
96
- ],
97
- "auto_reinforcements": [
98
- "Specific rule to add or reinforce in CLAUDE.md or guard"
99
- ],
100
- "summary": "2-3 sentence overall assessment of the day"
101
- }
102
- ```
103
-
104
- ## Rules
105
- - Be SPECIFIC. Quote the user's exact words.
106
- - Only flag REAL issues. If NEXO did capture something correctly, don't flag it.
107
- - severity=critical means the user repeated the same correction 3+ times or expressed strong frustration
108
- - For protocol compliance, count ACTUAL tool_use entries in the transcript
109
- - If no issues found in a category, return empty array — don't invent problems