lingshu-skill 5.32.0 → 5.37.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 (265) hide show
  1. package/CHANGELOG.md +4281 -4173
  2. package/README.md +1584 -1577
  3. package/SKILL-lite.md +59 -59
  4. package/SKILL-tiny.md +38 -38
  5. package/SKILL.md +356 -317
  6. package/assets/panel.html +6753 -5698
  7. package/cordis-plugin/lingshu-cron/plugin.js +1455 -1417
  8. package/cordis-plugin/lingshu-startup/context-fold.js +170 -0
  9. package/cordis-plugin/lingshu-startup/context-pressure.js +16 -0
  10. package/cordis-plugin/lingshu-startup/context-snapshot.js +176 -0
  11. package/cordis-plugin/lingshu-startup/plugin.js +499 -467
  12. package/docs/audit_notes//345/276/205/345/212/236-20261201-/351/235/242/346/235/277/344/270/245/346/237/245/344/270/216/345/256/241/350/256/241.md +162 -0
  13. package/docs/audit_notes//345/276/205/345/212/236-20261202-/351/235/242/346/235/277/344/272/244/344/272/222/344/270/216/346/225/260/346/215/256/345/245/221/347/272/246/345/256/241/350/256/241.md +92 -0
  14. package/docs/audit_notes//345/276/205/345/212/236/346/250/241/346/235/277.md +140 -0
  15. package/docs/commands.md +278 -247
  16. package/docs/mechanics.md +610 -610
  17. package/docs//345/276/205/345/212/236-20261201-/351/235/242/346/235/277/344/270/245/346/237/245/344/270/216/345/256/241/350/256/241.md +162 -0
  18. package/docs//345/276/205/345/212/236-20261202-/351/235/242/346/235/277/344/272/244/344/272/222/344/270/216/346/225/260/346/215/256/345/245/221/347/272/246/345/256/241/350/256/241.md +92 -0
  19. package/package.json +52 -52
  20. package/scripts/_scratch/_tmp_backup_race.py +70 -0
  21. package/scripts/_scratch/_tmp_cleanup_move.py +34 -0
  22. package/scripts/_scratch/_tmp_count_kinds.py +25 -0
  23. package/scripts/_scratch/_tmp_diag_paths.py +48 -0
  24. package/scripts/_scratch/_tmp_facts.py +63 -0
  25. package/scripts/_scratch/_tmp_find_copies.py +31 -0
  26. package/scripts/_scratch/_tmp_find_pin.py +29 -0
  27. package/scripts/_scratch/_tmp_fix_pin.py +36 -0
  28. package/scripts/_scratch/_tmp_fold_fixture.py +55 -0
  29. package/scripts/_scratch/_tmp_fold_test.mjs +81 -0
  30. package/scripts/_scratch/_tmp_inject_secs.py +30 -0
  31. package/scripts/_scratch/_tmp_kb_balance.py +159 -0
  32. package/scripts/_scratch/_tmp_lines.py +15 -0
  33. package/scripts/_scratch/_tmp_market_probe.py +13 -0
  34. package/scripts/_scratch/_tmp_move_partial.py +16 -0
  35. package/scripts/_scratch/_tmp_patch_b3.py +41 -0
  36. package/scripts/_scratch/_tmp_patch_b5.py +62 -0
  37. package/scripts/_scratch/_tmp_patch_crash_excl.py +24 -0
  38. package/scripts/_scratch/_tmp_patch_handoff.py +21 -0
  39. package/scripts/_scratch/_tmp_patch_ps1.py +25 -0
  40. package/scripts/_scratch/_tmp_patch_stat.py +27 -0
  41. package/scripts/_scratch/_tmp_patch_todo.py +25 -0
  42. package/scripts/_scratch/_tmp_patch_todo2.py +64 -0
  43. package/scripts/_scratch/_tmp_probe_session.py +51 -0
  44. package/scripts/_scratch/_tmp_style_probe.py +40 -0
  45. package/scripts/_scratch/_tmp_write_note.py +139 -0
  46. package/scripts/_scratch/_/346/235/245/346/272/220/350/256/260/345/275/225.txt +1 -0
  47. package/scripts/_scratch/asar_compaction/dsh-compaction-basic__lib__index.js +1044 -0
  48. package/scripts/_scratch/asar_compaction/dsh-compaction-tool-result-pruner__lib__index.js +194 -0
  49. package/scripts/_scratch/asar_compaction/dsh-compaction__lib__index.js +175 -0
  50. package/scripts/_scratch/asar_compaction/dsh-compaction__lib__types__tool-pairing.js +97 -0
  51. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__image-offload.js +47 -0
  52. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__index.js +40 -0
  53. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__project-message.js +37 -0
  54. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__brand.js +9 -0
  55. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__checkpoint.js +36 -0
  56. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__types.js +10 -0
  57. package/scripts/_scratch/commit_msg_occ.txt +16 -0
  58. package/scripts/_scratch/commit_msg_struct.txt +16 -0
  59. package/scripts/_scratch/v5.34_changelog.txt +36 -0
  60. package/scripts/_sync_trae_cn.py +102 -34
  61. package/scripts/_tmp_add_s10.py +54 -0
  62. package/scripts/_tmp_add_s11.py +61 -0
  63. package/scripts/_tmp_add_s12.py +66 -0
  64. package/scripts/_tmp_add_s13.py +69 -0
  65. package/scripts/_tmp_add_s14.py +80 -0
  66. package/scripts/_tmp_add_s9.py +68 -0
  67. package/scripts/_tmp_cache_load.py +82 -0
  68. package/scripts/_tmp_clean_market.py +40 -0
  69. package/scripts/_tmp_clean_pruned.py +81 -0
  70. package/scripts/_tmp_cleanup_docs.py +39 -0
  71. package/scripts/_tmp_cmp_ranker.py +17 -0
  72. package/scripts/_tmp_dolater_note.py +35 -0
  73. package/scripts/_tmp_dust_why.py +27 -0
  74. package/scripts/_tmp_explicit_import.py +40 -0
  75. package/scripts/_tmp_extract_compaction.py +35 -0
  76. package/scripts/_tmp_extract_compaction2.py +63 -0
  77. package/scripts/_tmp_extract_compaction3.py +51 -0
  78. package/scripts/_tmp_extract_compaction4.py +54 -0
  79. package/scripts/_tmp_finalize_s14.py +39 -0
  80. package/scripts/_tmp_find_compaction.py +43 -0
  81. package/scripts/_tmp_fix_b4.py +22 -0
  82. package/scripts/_tmp_fix_cli76.py +26 -0
  83. package/scripts/_tmp_fix_docs.py +38 -0
  84. package/scripts/_tmp_fix_docs_b.py +46 -0
  85. package/scripts/_tmp_fix_docs_b2.py +22 -0
  86. package/scripts/_tmp_fix_i3.py +23 -0
  87. package/scripts/_tmp_fix_s10.py +83 -0
  88. package/scripts/_tmp_fix_s11.py +14 -0
  89. package/scripts/_tmp_fix_s9_status.py +19 -0
  90. package/scripts/_tmp_fix_shadow_sim.py +37 -0
  91. package/scripts/_tmp_fix_traits_value.py +41 -0
  92. package/scripts/_tmp_import_idem.py +106 -0
  93. package/scripts/_tmp_log_ack.py +45 -0
  94. package/scripts/_tmp_mark_batch.py +28 -0
  95. package/scripts/_tmp_mark_batch2.py +32 -0
  96. package/scripts/_tmp_mark_dolater.py +26 -0
  97. package/scripts/_tmp_mark_dolater2.py +31 -0
  98. package/scripts/_tmp_move_self.py +16 -0
  99. package/scripts/_tmp_occ_cli.py +22 -0
  100. package/scripts/_tmp_occ_link.py +108 -0
  101. package/scripts/_tmp_optimize_recall.py +54 -0
  102. package/scripts/_tmp_panel_audit.py +26 -0
  103. package/scripts/_tmp_patch_batch3.py +65 -0
  104. package/scripts/_tmp_patch_rrf.py +46 -0
  105. package/scripts/_tmp_patch_s2s3.py +80 -0
  106. package/scripts/_tmp_patch_s4.py +39 -0
  107. package/scripts/_tmp_patch_s7.py +43 -0
  108. package/scripts/_tmp_patch_s8.py +91 -0
  109. package/scripts/_tmp_patch_skill.py +17 -0
  110. package/scripts/_tmp_release_guard.py +57 -0
  111. package/scripts/_tmp_rerank_breaker.py +62 -0
  112. package/scripts/_tmp_s16.py +41 -0
  113. package/scripts/_tmp_scan_asar.py +41 -0
  114. package/scripts/_tmp_scan_asar2.py +37 -0
  115. package/scripts/_tmp_struct_docs.py +49 -0
  116. package/scripts/_tmp_sum_fallback.py +42 -0
  117. package/scripts/_tmp_sweep.py +81 -0
  118. package/scripts/_tmp_sync_check.py +69 -0
  119. package/scripts/_tmp_sync_tail.py +39 -0
  120. package/scripts/_tmp_todo_clean.py +67 -0
  121. package/scripts/_tmp_verify_copy.py +17 -0
  122. package/scripts/_tmp_wire_extras.py +93 -0
  123. package/scripts/_tmp_wire_hsum.py +34 -0
  124. package/scripts/_tmp_wire_occ_b5.py +40 -0
  125. package/scripts/_tmp_wire_ranker.py +13 -0
  126. package/scripts/_tmp_wire_shadow_timeline.py +45 -0
  127. package/scripts/anchor_retention.py +68 -0
  128. package/scripts/app_context.py +1160 -0
  129. package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +38 -22
  130. package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +4281 -4173
  131. package/scripts/astrbot_plugin_lingshu/engine/README.md +1584 -1577
  132. package/scripts/astrbot_plugin_lingshu/engine/SKILL-lite.md +59 -59
  133. package/scripts/astrbot_plugin_lingshu/engine/SKILL-tiny.md +38 -38
  134. package/scripts/astrbot_plugin_lingshu/engine/SKILL.md +356 -317
  135. package/scripts/astrbot_plugin_lingshu/engine/assets/panel.html +6753 -5698
  136. package/scripts/astrbot_plugin_lingshu/engine/docs/commands.md +278 -247
  137. package/scripts/astrbot_plugin_lingshu/engine/docs/mechanics.md +610 -610
  138. package/scripts/astrbot_plugin_lingshu/engine/scripts/_sync_trae_cn.py +102 -34
  139. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s10.py +54 -0
  140. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s11.py +61 -0
  141. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s12.py +66 -0
  142. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s13.py +69 -0
  143. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s14.py +80 -0
  144. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s9.py +68 -0
  145. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cache_load.py +82 -0
  146. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_clean_market.py +40 -0
  147. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_clean_pruned.py +81 -0
  148. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cleanup_docs.py +39 -0
  149. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cmp_ranker.py +17 -0
  150. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_dolater_note.py +35 -0
  151. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_dust_why.py +27 -0
  152. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_explicit_import.py +40 -0
  153. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction.py +35 -0
  154. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction2.py +63 -0
  155. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction3.py +51 -0
  156. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction4.py +54 -0
  157. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_finalize_s14.py +39 -0
  158. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_find_compaction.py +43 -0
  159. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_b4.py +22 -0
  160. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_cli76.py +26 -0
  161. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs.py +38 -0
  162. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs_b.py +46 -0
  163. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs_b2.py +22 -0
  164. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_i3.py +23 -0
  165. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s10.py +83 -0
  166. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s11.py +14 -0
  167. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s9_status.py +19 -0
  168. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_shadow_sim.py +37 -0
  169. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_traits_value.py +41 -0
  170. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_import_idem.py +106 -0
  171. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_log_ack.py +45 -0
  172. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_batch.py +28 -0
  173. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_batch2.py +32 -0
  174. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_dolater.py +26 -0
  175. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_dolater2.py +31 -0
  176. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_move_self.py +16 -0
  177. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_occ_cli.py +22 -0
  178. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_occ_link.py +108 -0
  179. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_optimize_recall.py +54 -0
  180. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_panel_audit.py +26 -0
  181. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_batch3.py +65 -0
  182. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_rrf.py +46 -0
  183. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s2s3.py +80 -0
  184. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s4.py +39 -0
  185. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s7.py +43 -0
  186. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s8.py +91 -0
  187. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_skill.py +17 -0
  188. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_release_guard.py +57 -0
  189. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_rerank_breaker.py +62 -0
  190. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_s16.py +41 -0
  191. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_scan_asar.py +41 -0
  192. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_scan_asar2.py +37 -0
  193. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_struct_docs.py +49 -0
  194. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sum_fallback.py +42 -0
  195. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sweep.py +81 -0
  196. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sync_check.py +69 -0
  197. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sync_tail.py +39 -0
  198. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_todo_clean.py +67 -0
  199. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_verify_copy.py +17 -0
  200. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_extras.py +93 -0
  201. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_hsum.py +34 -0
  202. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_occ_b5.py +40 -0
  203. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_ranker.py +13 -0
  204. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_shadow_timeline.py +45 -0
  205. package/scripts/astrbot_plugin_lingshu/engine/scripts/anchor_retention.py +68 -0
  206. package/scripts/astrbot_plugin_lingshu/engine/scripts/app_context.py +1160 -0
  207. package/scripts/astrbot_plugin_lingshu/engine/scripts/bigfive.py +90 -0
  208. package/scripts/astrbot_plugin_lingshu/engine/scripts/brain.py +1 -1
  209. package/scripts/astrbot_plugin_lingshu/engine/scripts/check_docs.py +191 -0
  210. package/scripts/astrbot_plugin_lingshu/engine/scripts/cli.py +940 -88
  211. package/scripts/astrbot_plugin_lingshu/engine/scripts/core.py +2468 -2406
  212. package/scripts/astrbot_plugin_lingshu/engine/scripts/coverage_report.py +5 -0
  213. package/scripts/astrbot_plugin_lingshu/engine/scripts/delivery.py +112 -0
  214. package/scripts/astrbot_plugin_lingshu/engine/scripts/dream.py +41 -3
  215. package/scripts/astrbot_plugin_lingshu/engine/scripts/emotion.py +202 -23
  216. package/scripts/astrbot_plugin_lingshu/engine/scripts/gap_memory.py +186 -0
  217. package/scripts/astrbot_plugin_lingshu/engine/scripts/growth.py +72 -8
  218. package/scripts/astrbot_plugin_lingshu/engine/scripts/hsum.py +206 -0
  219. package/scripts/astrbot_plugin_lingshu/engine/scripts/mem_score.py +92 -7
  220. package/scripts/astrbot_plugin_lingshu/engine/scripts/memory.py +533 -60
  221. package/scripts/astrbot_plugin_lingshu/engine/scripts/memory_extras.py +200 -0
  222. package/scripts/astrbot_plugin_lingshu/engine/scripts/occ.py +190 -0
  223. package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_server.py +232 -142
  224. package/scripts/astrbot_plugin_lingshu/engine/scripts/persona.py +2498 -2349
  225. package/scripts/astrbot_plugin_lingshu/engine/scripts/prepublish_tests.py +90 -0
  226. package/scripts/astrbot_plugin_lingshu/engine/scripts/release.py +326 -287
  227. package/scripts/astrbot_plugin_lingshu/engine/scripts/rss_ingest.py +181 -0
  228. package/scripts/astrbot_plugin_lingshu/engine/scripts/session_import.py +832 -764
  229. package/scripts/astrbot_plugin_lingshu/engine/scripts/shadow_memory.py +173 -0
  230. package/scripts/astrbot_plugin_lingshu/engine/scripts/style_check.py +220 -0
  231. package/scripts/astrbot_plugin_lingshu/engine/scripts/summarizer.py +343 -252
  232. package/scripts/astrbot_plugin_lingshu/engine/scripts/timeline.py +118 -0
  233. package/scripts/astrbot_plugin_lingshu/engine/scripts/watchdog.py +110 -0
  234. package/scripts/astrbot_plugin_lingshu/engine/scripts/web_research.py +125 -0
  235. package/scripts/bigfive.py +90 -0
  236. package/scripts/brain.py +1 -1
  237. package/scripts/check_docs.py +191 -0
  238. package/scripts/cli.py +940 -88
  239. package/scripts/core.py +2468 -2406
  240. package/scripts/coverage_report.py +5 -0
  241. package/scripts/delivery.py +112 -0
  242. package/scripts/dream.py +41 -3
  243. package/scripts/emotion.py +202 -23
  244. package/scripts/gap_memory.py +186 -0
  245. package/scripts/growth.py +72 -8
  246. package/scripts/hsum.py +206 -0
  247. package/scripts/mem_score.py +92 -7
  248. package/scripts/memory.py +533 -60
  249. package/scripts/memory_extras.py +200 -0
  250. package/scripts/occ.py +190 -0
  251. package/scripts/panel_server.py +232 -142
  252. package/scripts/persona.py +2498 -2349
  253. package/scripts/prepublish_tests.py +90 -0
  254. package/scripts/release.py +326 -287
  255. package/scripts/rss_ingest.py +181 -0
  256. package/scripts/run_tests.py +13 -0
  257. package/scripts/session_import.py +832 -764
  258. package/scripts/shadow_memory.py +173 -0
  259. package/scripts/style_check.py +220 -0
  260. package/scripts/summarizer.py +343 -252
  261. package/scripts/timeline.py +118 -0
  262. package/scripts/update_dsh_copy.ps1 +110 -107
  263. package/scripts/watchdog.py +110 -0
  264. package/scripts/web_research.py +125 -0
  265. package/docs//345/256/241/346/240/270/346/224/271/350/277/233/345/276/205/345/212/236.md +0 -370
@@ -37,7 +37,9 @@ _WRITE_ENDPOINTS = {
37
37
  "/api/persona/self", "/api/persona/rollback", "/api/persona/changes-viewed",
38
38
  "/api/persona/suggest",
39
39
  "/api/persona/snapshots/rollback", # 自动快照按 version 回滚(persona_snapshots.jsonl)
40
- "/api/memory", "/api/memory/review", "/api/knowledge", "/api/knowledge/review",
40
+ "/api/persona/snapshots/create",
41
+ "/api/persona/self-model",
42
+ "/api/memory", "/api/memory/review", "/api/knowledge",
41
43
  "/api/note", "/api/skill",
42
44
  "/api/skill/self-review", "/api/skill/dsh-repair",
43
45
  "/api/skill/dsh-force-update",
@@ -47,6 +49,8 @@ _WRITE_ENDPOINTS = {
47
49
  "/api/mind/weigh", "/api/diagnostics/fix-links", "/api/seed",
48
50
  "/api/forget", "/api/daily", "/api/dream/instruction", "/api/logs",
49
51
  "/api/memory/dust",
52
+ "/api/dream/verify/done",
53
+ "/api/conflicts/resolve",
50
54
  "/api/memory/purge",
51
55
  "/api/memory/boost",
52
56
  "/api/memory/rebuild-embeds",
@@ -118,6 +122,8 @@ def memory_view(m: dict) -> dict:
118
122
  out["retention"] = round(brain.retention(m), 3)
119
123
  out["display"] = brain.display_text(m)
120
124
  out["created_text"] = brain.fmt_time(m.get("created", 0))
125
+ la = m.get("last_access")
126
+ out["last_access_text"] = brain.fmt_time(la) if la and la > 0 else ""
121
127
  return out
122
128
 
123
129
 
@@ -147,7 +153,7 @@ def _repo_version() -> str:
147
153
  return ""
148
154
 
149
155
 
150
- def overview() -> dict:
156
+ def overview(light: bool = False) -> dict:
151
157
  # 逐条 try/except 降级:单条坏记忆/坏文件不能让整个 overview 500(面板全页挂掉)
152
158
  def _safe(label: str, fn, default):
153
159
  try:
@@ -156,14 +162,36 @@ def overview() -> dict:
156
162
  brain.log_event("panel", f"overview {label} 降级:{exc}", level="warn")
157
163
  return default
158
164
 
165
+ st = _safe("stats", brain.stats, {}) or {}
166
+ try:
167
+ _stage = growth.stage_state()
168
+ except Exception: # noqa: BLE001
169
+ _stage = None
170
+
171
+ # ARCH-02: light=True 轻量轮询模式(仅 2.7 KB,比全量 140 KB 省流 98%)
172
+ # 供面板 30s 周期轮询实时心境、水位、健康度、心智与模式,跳过整库扫描与历史重算
173
+ if light:
174
+ return {
175
+ "light": True,
176
+ "stage": _stage,
177
+ "stats": st,
178
+ "mind": _safe("mind", brain.mind_state, {}),
179
+ "mood": _safe("mood", brain.mood_now, {}),
180
+ "water": _safe("water", brain._water_level, None),
181
+ "health_score": _safe("health_score", _health_score, 100),
182
+ "inner_voice": _safe("inner_voice", brain.inner_voice, ""),
183
+ "saturation": _safe("saturation", brain.saturation_report, {}),
184
+ "affection": _safe("affection", brain.affection_state, {}),
185
+ "readonly": bool(brain.READONLY),
186
+ "mode": _safe("mode", lambda: str(brain.load_config().get("mode", "auto") or "auto").lower(), "auto"),
187
+ "log_summary": _safe("log_summary", _log_summary, {"warn": 0, "error": 0}),
188
+ "home": str(brain.HOME),
189
+ }
190
+
159
191
  records = brain.load_all() + brain.load_archive()
160
- ordered = sorted(records, key=lambda m: _created_key(m), reverse=True)
161
- memories = []
162
- for m in ordered[:80]:
163
- try:
164
- memories.append(memory_view(m))
165
- except Exception as exc:
166
- brain.log_event("panel", f"overview 跳过坏记忆 {m.get('id')}: {exc}", level="warn")
192
+ # P3-10: 使用 min-heap / 局部堆选取代全局 O(n log n) 排序,极大降低超大记忆库全量切页耗时
193
+ import heapq
194
+ memories = [memory_view(m) for m in heapq.nlargest(80, records, key=lambda m: _created_key(m))]
167
195
  dreams = []
168
196
  ddir = brain.HOME / "dreams"
169
197
  if ddir.exists():
@@ -198,7 +226,7 @@ def overview() -> dict:
198
226
  "desire_defs": _safe("desire_defs", lambda: brain.DESIRES, {}),
199
227
  "rationality": _safe("rationality", brain.rationality, {}),
200
228
  "emotion_cfg": _safe("emotion_cfg", brain.emotion_cfg, {}),
201
- "daily_state": _safe("daily_state", brain._daily_state, {}),
229
+ "daily_state": _safe("daily_state", lambda: brain._daily_state(), {}),
202
230
  "last_self_review": load_config_last_review(),
203
231
  "onboarding": _safe("onboarding", brain.onboarding_state, {}),
204
232
  "readonly": bool(brain.READONLY),
@@ -209,6 +237,10 @@ def overview() -> dict:
209
237
  "emotion_alerts": _safe("emotion_alerts", lambda: brain.emotion_checks_recent(10), []),
210
238
  "dream_draft": _safe("dream_draft", brain.load_dream_draft, None),
211
239
  "mode_detail": _safe("mode_detail", lambda: brain.resolve_mode_detail(""), {}),
240
+ "saturation": _safe("saturation", brain.saturation_report, {}),
241
+ "affection": _safe("affection", brain.affection_state, {}),
242
+ # v5.36 自我认知四桶:面板人格页展示与编辑(此前只有 CLI 能改)
243
+ "self_model": _safe("self_model", brain.self_model_get, {}),
212
244
  "log_summary": _safe("log_summary", _log_summary, {"warn": 0, "error": 0}),
213
245
  # #24 当前写入者:锁文件里记的 pid/主机,多机共享记忆库时能看见另一台
214
246
  "writers": _safe("writers", brain.lock_writers, []),
@@ -227,8 +259,8 @@ def overview() -> dict:
227
259
  # 纯模板 + 词表,不调 LLM;无情绪记录返回空字符串,前端据此隐藏。
228
260
  "inner_voice": _safe("inner_voice", brain.inner_voice, ""),
229
261
  # 情绪时间线(v5.12 新增):最近 50 条自动生成的情绪事件(genesis=True),
230
- # 面板 emotion 页签底部的心情流水用。
231
- "emotion_timeline": _safe("emotion_timeline", brain.emotion_timeline, []),
262
+ # 面板 emotion 页签底部的心情流水用(延迟 getattr 避免特定导入时序产生 AttributeError)。
263
+ "emotion_timeline": _safe("emotion_timeline", lambda: getattr(brain, "emotion_timeline", lambda: [])(), []),
232
264
  # 体检历史(v5.12 新增):最近 30 天的 doctor 跑次,按天聚合。
233
265
  # 面板"体检历史"页签的折线图用(按天统计 PASS/WARN/FAIL 分布)。
234
266
  "doctor_history": _safe("doctor_history", _doctor_history, []),
@@ -289,31 +321,13 @@ def _doctor_history(days: int = 30) -> list:
289
321
  return out
290
322
 
291
323
 
292
- def _health_score() -> int:
293
-
294
- """灵枢健康度:0-100。**委托给 growth.health_score(),不在这里另算一套。**
295
-
296
-
297
-
298
- 原来这里有自己的公式(100 - fails*10 - warns*3 - fbcnt),而 growth.health_score
299
-
300
- 用的是 100 - fail*10 - warn*3 - failures_7d//5 → 面板 footer 与 stage/doctor 对
301
-
302
- 同一份数据给出两个不同分数,被吞异常越多差得越大。同一指标只能有一个口径。
303
-
304
-
305
-
306
- 历史记录字段名也一并由 growth 侧统一(pass/warn/fail),它自己会取最近一次体检。
307
-
308
- """
309
-
324
+ def _health_score() -> dict:
325
+ """灵枢健康度详细结构:委托给 growth.health_score(),包含分数、新鲜度、上次体检日期。"""
310
326
  try:
311
-
312
327
  import growth as _growth
313
-
314
- return int(_growth.health_score().get("score", 100))
315
-
328
+ return _growth.health_score()
316
329
  except Exception:
330
+ return {"score": None, "stale": True, "never_checked": True}
317
331
 
318
332
  return 100
319
333
 
@@ -825,7 +839,9 @@ class Handler(BaseHTTPRequestHandler):
825
839
  self._json({"error": "forbidden"}, 403)
826
840
  return
827
841
  if path == "/api/overview":
828
- self._json(overview())
842
+ qs = parse_qs(url.query)
843
+ light = (qs.get("light") or ["0"])[0] in ("1", "true", "yes")
844
+ self._json(overview(light=light))
829
845
  return
830
846
  if path == "/api/insights":
831
847
  # v3.36 运行洞察:一次聚合上下文账单 / 原文库 / 收尾 / 鉴权 / 嵌入。
@@ -1007,6 +1023,17 @@ class Handler(BaseHTTPRequestHandler):
1007
1023
  limit = _int_param(url, "limit", 50, 1, 200)
1008
1024
  self._json(brain.list_persona_snapshots(limit=limit))
1009
1025
  return
1026
+ if path == "/api/persona/snapshots/diff":
1027
+ ver = _int_param(url, "version", 0, 1, 100000)
1028
+ if not ver:
1029
+ self._json({"error": "缺少或非法的 version 参数"}, 400)
1030
+ return
1031
+ snap = brain.get_persona_snapshot(ver)
1032
+ if not snap:
1033
+ self._json({"error": f"找不到快照 v{ver}"}, 404)
1034
+ return
1035
+ self._json(snap)
1036
+ return
1010
1037
  if path == "/api/persona/changes":
1011
1038
  # 人格变更时间线(v3.01「先生效后告知」流):未读 AI 改动 + 全量 history + 漂移度
1012
1039
  days = _int_param(url, "days", 7, 1, 90)
@@ -1038,6 +1065,27 @@ class Handler(BaseHTTPRequestHandler):
1038
1065
  self._json({"items": hist, "count": len(hist),
1039
1066
  "stage": st, "health": st.get("health")})
1040
1067
  return
1068
+ if path == "/api/doctor/summary":
1069
+ # OPS-02: 运行 doctor 并返回按级别分类的摘要(P0/P1 判据)
1070
+ try:
1071
+ import subprocess, sys as _sys
1072
+ proc = subprocess.run([_sys.executable, str(SCRIPTS / "brain.py"), "doctor", "--json"],
1073
+ capture_output=True, text=True, encoding="utf-8", timeout=30)
1074
+ data = json.loads(proc.stdout) if proc.stdout else {}
1075
+ except Exception as exc:
1076
+ self._json({"error": f"执行体检失败:{exc}"}, 500)
1077
+ return
1078
+ checks = data.get("checks", [])
1079
+ p0 = [c for c in checks if c.get("status") == "FAIL" and c.get("name") in ("write-permission", "persona-schema", "corrupt-file", "hash-chain")]
1080
+ p1 = [c for c in checks if c.get("status") == "FAIL" and c not in p0]
1081
+ warns = [c for c in checks if c.get("status") == "WARN"]
1082
+ passes = [c for c in checks if c.get("status") == "PASS"]
1083
+ self._json({
1084
+ "ok": data.get("ok", False),
1085
+ "counts": {"p0": len(p0), "p1": len(p1), "warn": len(warns), "pass": len(passes), "total": len(checks)},
1086
+ "p0": p0, "p1": p1, "warns": warns, "checks": checks,
1087
+ })
1088
+ return
1041
1089
  if path == "/api/logs":
1042
1090
  limit = _int_param(url, "limit", 200, 1, 2000)
1043
1091
  level = (parse_qs(url.query).get("level") or [""])[0] or None
@@ -1139,7 +1187,11 @@ class Handler(BaseHTTPRequestHandler):
1139
1187
  pass # 非 UTF-8 HTML:原样下发,面板作者自己修
1140
1188
  self._send(200, body, ctype)
1141
1189
  return
1142
- self._json({"error": "not found"}, 404)
1190
+ # P2-4 & P2-5: 未知路由自解释报错;如果该路径存在于 POST 路由中,明确提示 Method Not Allowed
1191
+ if path in _POST_ROUTES:
1192
+ self._json({"error": f"接口 {path} 仅支持 POST 请求,不支持 GET", "method_not_allowed": True}, 405)
1193
+ return
1194
+ self._json({"error": f"接口未找到: GET {path}", "path": path}, 404)
1143
1195
 
1144
1196
  def do_POST(self):
1145
1197
  _touch_activity()
@@ -1153,21 +1205,17 @@ class Handler(BaseHTTPRequestHandler):
1153
1205
  data = self._body()
1154
1206
  if data is None:
1155
1207
  return
1156
- # 只读门控:写接口在数据目录不可写时直接 403(展示/预览接口放行)
1157
- # 自愈合(v3.76 收紧):面板是长驻进程,启动那一下探测失败可能只是杀软/
1158
- # 索引器短暂占用——**自动降级**的只读可在写请求到来时复探自愈,不用重启。
1159
- # 但**用户显式强制只读**(--ro / BRAIN_MEMORY_READONLY=1,READONLY_FORCED=True)
1160
- # 绝不能被自愈:那等于静默违反用户的只读承诺(原来这里不区分,强制只读也
1161
- # 被摘掉)。强制只读时连复探都不做——探针本身会往 HOME 写文件。
1208
+ # P3-11: 启动与运行期保障:只读门控表与 POST 注册表严格双向对齐,非只读白名单一律受只读门控保护
1209
+ is_write = (path in _WRITE_ENDPOINTS) or (path not in ("/api/shutdown", "/api/extensions/ollama/status"))
1162
1210
  if (brain.READONLY and not brain.READONLY_FORCED
1163
- and path in _WRITE_ENDPOINTS and not _readonly_allowed(path, data)):
1211
+ and is_write and not _readonly_allowed(path, data)):
1164
1212
  try:
1165
1213
  if brain._home_writable(max_attempts=3):
1166
1214
  brain.READONLY = False
1167
1215
  brain._sync_state()
1168
1216
  except Exception:
1169
1217
  pass
1170
- if brain.READONLY and path in _WRITE_ENDPOINTS and not _readonly_allowed(path, data):
1218
+ if brain.READONLY and is_write and not _readonly_allowed(path, data):
1171
1219
  self.close_connection = True
1172
1220
  self._json({"error": "readonly", "message": "数据目录当前只读,写操作已被禁用。"}, 403)
1173
1221
  return
@@ -1470,6 +1518,49 @@ def _api_persona_state(self, path, data):
1470
1518
 
1471
1519
 
1472
1520
 
1521
+ def _api_persona_self_model(self, path, data):
1522
+ """自我认知四桶增删(v5.36 面板化)。act: add / remove。
1523
+
1524
+ kind 必须是 strengths/limitations/uncertainties/autobiography 之一;
1525
+ add 走 persona.self_model_add(带去重、写 history、自动快照),
1526
+ remove 按文本精确匹配删除对应条目。
1527
+ """
1528
+ act = str(data.get("action") or "add").strip()
1529
+ kind = str(data.get("kind") or "").strip().lower()
1530
+ text = str(data.get("text") or "").strip()
1531
+ if act == "add":
1532
+ if not text:
1533
+ self._json({"ok": False, "error": "缺少 text"}, 400)
1534
+ return
1535
+ try:
1536
+ r = brain.self_model_add(kind, text)
1537
+ except (ValueError, KeyError) as exc:
1538
+ self._json({"ok": False, "error": str(exc)}, 400)
1539
+ return
1540
+ self._json({"ok": True, "added": True, "self_model": brain.self_model_get()})
1541
+ return
1542
+ if act == "remove":
1543
+ if not text:
1544
+ self._json({"ok": False, "error": "缺少 text"}, 400)
1545
+ return
1546
+ p = brain.load_persona()
1547
+ sm = p.get("self_model") or {}
1548
+ bucket = sm.get(kind)
1549
+ if not isinstance(bucket, list):
1550
+ self._json({"ok": False, "error": f"未知桶:{kind}"}, 400)
1551
+ return
1552
+ before = len(bucket)
1553
+ sm[kind] = [x for x in bucket
1554
+ if str(x.get("text") if isinstance(x, dict) else x, "").strip() != text]
1555
+ if len(sm[kind]) == before:
1556
+ self._json({"ok": False, "error": "没找到要删的条目"}, 404)
1557
+ return
1558
+ brain.save_persona(p)
1559
+ self._json({"ok": True, "removed": True, "self_model": brain.self_model_get()})
1560
+ return
1561
+ self._json({"ok": False, "error": f"未知 action: {act}(add/remove)"}, 400)
1562
+
1563
+
1473
1564
  def _api_persona_edit(self, path, data):
1474
1565
  # 类型防御:dict 字段传字符串、list 字段传对象都会在 edit_persona 里 500,
1475
1566
  # 这里先校验给 400;字符串的 likes 等按逗号拆开(容错前端/脚本的手填输入)
@@ -1510,6 +1601,17 @@ def _api_persona_edit(self, path, data):
1510
1601
  self._json({"ok": True, "persona": p, "onboarding": brain.onboarding_state()})
1511
1602
 
1512
1603
 
1604
+ def _api_persona_snapshot_create(self, path, data):
1605
+ """手动给人格拍一张快照(persona_snapshots.jsonl)。"""
1606
+ if brain.READONLY:
1607
+ self._json({"error": "当前只读,无法拍快照"}, 403)
1608
+ return
1609
+ label = str(data.get("label") or "手动快照").strip()
1610
+ p = brain.load_persona()
1611
+ ver = brain.save_persona_snapshot(p, action="snapshot", source="手动", why=label)
1612
+ brain.log_event("panel", f"手动拍摄人格快照 v{ver}({label})")
1613
+ self._json({"ok": True, "version": ver, "label": label, "snapshots": brain.list_persona_snapshots(50)})
1614
+
1513
1615
 
1514
1616
  def _api_persona_mind(self, path, data):
1515
1617
  if data.get("mode") == "tune":
@@ -1753,6 +1855,30 @@ def _api_dream_draft(self, path, data):
1753
1855
  self._json({"ok": True, "draft": brain.load_dream_draft()})
1754
1856
 
1755
1857
 
1858
+ def _api_dream_verify_done(self, path, data):
1859
+ """标记梦抽检样本已复核(FEAT-01)。"""
1860
+ if brain.READONLY:
1861
+ self._json({"error": "当前只读,无法完成复核"}, 403)
1862
+ return
1863
+ res = brain.mark_verify_reviewed()
1864
+ brain.log_event("panel", "梦抽检样本标记为已复核")
1865
+ self._json({"ok": True, "verify_sample": res})
1866
+
1867
+
1868
+
1869
+ def _api_conflict_resolve(self, path, data):
1870
+ """一键裁决冲突(FEAT-04):winner 取代 loser。"""
1871
+ winner = str(data.get("winner") or "").strip()
1872
+ loser = str(data.get("loser") or "").strip()
1873
+ if not winner or not loser:
1874
+ self._json({"error": "缺少 winner 或 loser 参数"}, 400)
1875
+ return
1876
+ try:
1877
+ res = brain.resolve_conflict_pair(winner, loser)
1878
+ self._json(res)
1879
+ except Exception as exc:
1880
+ self._json({"error": str(exc)}, 400)
1881
+
1756
1882
 
1757
1883
  def _api_memory_edit(self, path, data):
1758
1884
  mid = data.get("id")
@@ -1802,9 +1928,21 @@ def _api_diag_fix_links(self, path, data):
1802
1928
 
1803
1929
 
1804
1930
  def _api_memory_dust(self, path, data):
1805
- # 淡忘可逆通道:fold 折叠(原文收起)/ unfold 解压还原 / revive 彻底复活
1931
+ # 淡忘可逆通道:fold 折叠(原文收起)/ unfold 解压还原 / revive 彻底复活 / fold-all 一键批量折叠释放
1806
1932
  act = data.get("action", "fold")
1807
1933
  mid = data.get("id", "")
1934
+ if act == "fold-all":
1935
+ # IDEA-05: 一键批量折叠淡忘区未折叠记录
1936
+ dust_rows = [m for m in brain.load_all() if m.get("layer") == "dust" and not m.get("folded")]
1937
+ folded_cnt = 0
1938
+ for m in dust_rows:
1939
+ try:
1940
+ brain.fold(m["id"])
1941
+ folded_cnt += 1
1942
+ except Exception:
1943
+ pass
1944
+ self._json({"ok": True, "action": "fold-all", "folded_count": folded_cnt})
1945
+ return
1808
1946
  if act == "fold":
1809
1947
  m = brain.fold(mid)
1810
1948
  elif act == "unfold":
@@ -1813,7 +1951,7 @@ def _api_memory_dust(self, path, data):
1813
1951
  layer = data.get("layer") or "cortex"
1814
1952
  m = brain.revive(mid, layer=layer)
1815
1953
  else:
1816
- self._json({"error": "action 只能是 fold / unfold / revive"}, 400)
1954
+ self._json({"error": "action 只能是 fold / unfold / revive / fold-all"}, 400)
1817
1955
  return
1818
1956
  self._json({"ok": True, "action": act, "memory": memory_view(m)})
1819
1957
 
@@ -1920,78 +2058,47 @@ def _api_skill(self, path, data):
1920
2058
  res = growth.edit_skill(data.get("name", ""), data.get("body"),
1921
2059
  data.get("append"), data.get("description"))
1922
2060
  self._json({"ok": True, "skill": res, "workspace": workspace()})
2061
+ elif act == "enable":
2062
+ res = growth.set_skill_enabled(data.get("name", ""), True)
2063
+ self._json({"ok": True, "result": res, "workspace": workspace()})
2064
+ elif act == "disable":
2065
+ res = growth.set_skill_enabled(data.get("name", ""), False)
2066
+ self._json({"ok": True, "result": res, "workspace": workspace()})
1923
2067
  elif act == "install":
1924
- # 面板安装忽略前端传的 from_dir:本地 CLI 才能指外部目录,防远程乱指。
1925
- # 但允许传**下载源枚举**(npm/git):目录由服务端自己 resolve,客户端拿不到路径控制权。
1926
2068
  _name = data.get("name", "")
1927
2069
  _src_pref = str(data.get("source") or "").strip().lower()
1928
2070
  _from = None
1929
2071
  if _src_pref in ("npm", "git") and _name:
1930
2072
  try:
1931
- _dir, _kind = growth.resolve_source(_name, force_pull=True,
1932
- prefer=_src_pref)
2073
+ _dir, _kind = growth.resolve_source(_name, force_pull=True, prefer=_src_pref)
1933
2074
  _from = str(_dir)
1934
2075
  except KeyError as exc:
1935
2076
  self._json({"error": f"{_src_pref} 下载源不可用:{exc}"}, 502)
1936
2077
  return
1937
- res = growth.install_skill(_name,
1938
- bool(data.get("force")),
1939
- _from,
1940
- accept_risk=bool(data.get("yes")))
1941
- if isinstance(res, dict):
1942
- res.setdefault("source", _src_pref or "auto")
1943
- # 面板触发的更新/安装要留痕(特别是本体 lingshu):事后能查谁在何时更新到什么状态
1944
- brain.log_event("panel", f"安装/更新技能 {_name} "
1945
- f"(源={_src_pref or 'auto'}, force={bool(data.get('force'))}) "
1946
- f"→ {res.get('state')}")
1947
- self._json({"ok": True, "result": res, "workspace": workspace()})
1948
- return
2078
+ res = growth.install_skill(_name, force=bool(data.get("force")), from_dir=_from,
2079
+ accept_risk=bool(data.get("accept_risk")))
2080
+ self._json({"ok": True, "skill": res, "workspace": workspace()})
1949
2081
  elif act == "uninstall":
1950
- # 会删全局技能目录里的东西,记一笔日志,事后能查是谁在面板上删的;
1951
- # managed_only 只允许卸载灵枢装过的技能,防止误删用户其他全局插件
1952
2082
  res = growth.uninstall_skill(data.get("name", ""), managed_only=True)
1953
- brain.log_event("panel", f"卸载技能 {data.get('name', '')} → {res.get('state')}")
1954
- self._json({"ok": True, "result": res,
1955
- "workspace": workspace()})
1956
- elif act == "delete":
1957
- ok = growth.remove_skill(data.get("name", ""))
1958
- brain.log_event("panel", f"删除自建技能 {data.get('name', '')} → {ok}")
1959
- self._json({"ok": ok, "workspace": workspace()})
1960
- elif act == "check":
1961
- self._json({"ok": True, "checks": growth.check_skill(data.get("name"))})
1962
- elif act == "show":
1963
- self._json({"ok": True, "skill": growth.read_skill(data.get("name", ""))})
1964
- elif act == "list":
1965
- self._json({"ok": True, "skills": growth.list_skills(), "workspace": workspace()})
1966
- elif act == "roots":
1967
- self._json({"ok": True, "roots": growth.skill_roots(),
1968
- "workspace": workspace()})
2083
+ self._json({"ok": True, "skill": res, "workspace": workspace()})
2084
+ elif act == "use":
2085
+ res = growth.locate_skill(data.get("name", ""), data.get("root"))
2086
+ self._json({"ok": True, "skill": res})
2087
+ elif act == "borrow":
2088
+ sk = growth.locate_skill(data.get("name", ""), data.get("root"))
2089
+ res = growth.create_skill(sk["name"], sk["meta"].get("description", ""), sk["body"])
2090
+ self._json({"ok": True, "skill": res, "workspace": workspace()})
1969
2091
  elif act == "root_add":
1970
2092
  res = growth.add_skill_root(data.get("path", ""))
1971
2093
  self._json({"ok": True, "result": res, "workspace": workspace()})
1972
- elif act == "root_rm":
2094
+ elif act == "root_remove":
1973
2095
  res = growth.remove_skill_root(data.get("path", ""))
1974
2096
  self._json({"ok": True, "result": res, "workspace": workspace()})
1975
2097
  elif act == "scan":
1976
- rows = growth.scan_skills(data.get("root") or None)
1977
- self._json({"ok": True, "skills": rows, "workspace": workspace()})
1978
- elif act == "use":
1979
- # 只读取正文给前端预览(不自动全局化),便于面板里看外部技能内容
1980
- res = growth.use_skill(data.get("name", ""),
1981
- int(data.get("chars") or 6000),
1982
- root=data.get("root") or None)
1983
- self._json({"ok": True, "skill": res})
1984
- elif act == "borrow":
1985
- res = growth.borrow_skill(data.get("name", ""),
1986
- data.get("as_name", ""),
1987
- data.get("note", ""),
1988
- bool(data.get("force")),
1989
- root=data.get("root") or None)
1990
- self._json({"ok": True, "skill": res, "workspace": workspace()})
2098
+ res = growth.scan_skills()
2099
+ self._json({"ok": True, "skills": res, "workspace": workspace()})
1991
2100
  else:
1992
- self._json({"error": "未知操作"}, 400)
1993
-
1994
-
2101
+ self._json({"error": f"未知 action: {act}"}, 400)
1995
2102
 
1996
2103
  def _api_skill_dsh_repair(self, path, data):
1997
2104
  """修复 DSH 里残缺的 lingshu-skill 副本(空壳目录 + 被移除的声明)。"""
@@ -2005,61 +2112,40 @@ def _api_skill_dsh_repair(self, path, data):
2005
2112
 
2006
2113
 
2007
2114
  def _kill_lingshu_children() -> list:
2008
- """杀掉占用灵枢文件的 python 后台子进程(命令行含 brain.py / lingshu)。
2115
+ """杀掉占用灵枢文件的 python 后台子进程(AUD-01 规范收敛)。
2009
2116
 
2010
2117
  DSH 运行时 pnpm 无法 rename 被占用的目录,强制更新前先停掉这些子进程。
2011
- 排除面板自身进程;单条失败不影响其余,异常静默记日志。
2118
+ 排除面板自身进程;严格限定命令行包含 brain.py,淘汰过时的 wmic,
2119
+ 采用 PowerShell CIM 作为标准跨平台 Windows 路径。单条失败不影响其余。
2012
2120
  返回 [{pid, cmd}](cmd 为截断摘要)。
2013
2121
  """
2014
2122
  me = os.getpid()
2015
2123
  procs = [] # (pid, cmdline)
2016
2124
  try:
2017
- p = subprocess.run(
2018
- ["wmic", "process", "where",
2019
- "name='python.exe' and commandline like '%brain.py%'",
2020
- "get", "processid,commandline", "/format:list"],
2021
- capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=30)
2022
- cur = {}
2023
- for line in (p.stdout or "").splitlines():
2024
- line = line.strip()
2025
- if "=" in line:
2026
- k, _, v = line.partition("=")
2027
- cur[k.strip().lower()] = v.strip()
2028
- elif not line and cur:
2029
- procs.append((int(cur.get("processid", "0") or 0),
2030
- cur.get("commandline", "")))
2031
- cur = {}
2032
- if cur:
2033
- procs.append((int(cur.get("processid", "0") or 0),
2034
- cur.get("commandline", "")))
2035
- except Exception as e:
2036
- brain.log_event("panel", f"wmic 枚举灵枢子进程失败,改用 PowerShell:{e}", level="warn")
2037
- procs = []
2038
- try:
2039
- ps = ("Get-CimInstance Win32_Process -Filter \"Name='python.exe'\" | "
2040
- "Where-Object {$_.CommandLine -like '*brain.py*'} | "
2041
- "Select-Object ProcessId,CommandLine | ConvertTo-Json")
2042
- p = subprocess.run(["powershell", "-NoProfile", "-Command", ps],
2043
- capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=60)
2044
- out = (p.stdout or "").strip()
2045
- if out:
2046
- items = json.loads(out)
2047
- if isinstance(items, dict):
2048
- items = [items]
2049
- for it in items:
2050
- try:
2051
- procs.append((int(it.get("ProcessId") or 0),
2052
- str(it.get("CommandLine") or "")))
2053
- except (TypeError, ValueError):
2054
- continue
2055
- except Exception as e2:
2056
- brain.log_event("panel", f"PowerShell 枚举灵枢子进程也失败:{e2}", level="warn")
2125
+ ps = ("Get-CimInstance Win32_Process -Filter \"Name='python.exe'\" | "
2126
+ "Where-Object {$_.CommandLine -like '*brain.py*'} | "
2127
+ "Select-Object ProcessId,CommandLine | ConvertTo-Json")
2128
+ p = subprocess.run(["powershell", "-NoProfile", "-Command", ps],
2129
+ capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=60)
2130
+ out = (p.stdout or "").strip()
2131
+ if out:
2132
+ items = json.loads(out)
2133
+ if isinstance(items, dict):
2134
+ items = [items]
2135
+ for it in items:
2136
+ try:
2137
+ procs.append((int(it.get("ProcessId") or 0),
2138
+ str(it.get("CommandLine") or "")))
2139
+ except (TypeError, ValueError):
2140
+ continue
2141
+ except Exception as e2:
2142
+ brain.log_event("panel", f"PowerShell 枚举灵枢子进程失败:{e2}", level="warn")
2057
2143
  killed = []
2058
2144
  for pid, cmd in procs:
2059
2145
  if not pid or pid == me:
2060
2146
  continue
2061
2147
  low = (cmd or "").lower()
2062
- if "brain.py" not in low and "lingshu" not in low:
2148
+ if "brain.py" not in low:
2063
2149
  continue
2064
2150
  try:
2065
2151
  r = subprocess.run(["taskkill", "/PID", str(pid), "/F", "/T"],
@@ -3058,6 +3144,8 @@ _POST_ROUTES = {
3058
3144
  "/api/persona/self": _api_persona_self,
3059
3145
  "/api/persona/rollback": _api_persona_rollback,
3060
3146
  "/api/persona/snapshots/rollback": _api_persona_snapshot_rollback,
3147
+ "/api/persona/snapshots/create": _api_persona_snapshot_create,
3148
+ "/api/persona/self-model": _api_persona_self_model,
3061
3149
  "/api/mind/weigh": _api_mind_weigh,
3062
3150
  "/api/emotion": _api_emotion,
3063
3151
  # 关联 / 整理 / 模式
@@ -3065,12 +3153,14 @@ _POST_ROUTES = {
3065
3153
  "/api/daily": _api_daily,
3066
3154
  "/api/evolve": _api_evolve,
3067
3155
  "/api/mode": _api_mode,
3156
+ "/api/conflicts/resolve": _api_conflict_resolve,
3068
3157
  # 做梦
3069
3158
  "/api/dream": _api_dream,
3070
3159
  "/api/dream/auto": _api_dream_auto,
3071
3160
  "/api/dream/instruction": _api_dream_instruction,
3072
3161
  "/api/dream/apply": _api_dream_apply,
3073
3162
  "/api/dream/draft": _api_dream_draft,
3163
+ "/api/dream/verify/done": _api_dream_verify_done,
3074
3164
  # 记忆管理 / 知识 / 笔记
3075
3165
  "/api/memory": _api_memory_edit,
3076
3166
  "/api/forget": _api_forget,