lingshu-skill 5.61.0 → 5.62.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 (203) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +1 -1
  3. package/SKILL-lite.md +1 -1
  4. package/SKILL-tiny.md +1 -1
  5. package/SKILL.md +1 -1
  6. package/manifest.json +461 -0
  7. package/package.json +8 -2
  8. package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +8 -8
  9. package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +14 -0
  10. package/scripts/astrbot_plugin_lingshu/engine/README.md +1 -1
  11. package/scripts/astrbot_plugin_lingshu/engine/SKILL-lite.md +1 -1
  12. package/scripts/astrbot_plugin_lingshu/engine/SKILL-tiny.md +1 -1
  13. package/scripts/astrbot_plugin_lingshu/engine/SKILL.md +1 -1
  14. package/scripts/astrbot_plugin_lingshu/engine/scripts/growth.py +3 -4
  15. package/scripts/astrbot_plugin_lingshu/engine/scripts/make_dsh_tgz.py +20 -3
  16. package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_build.py +13 -0
  17. package/scripts/growth.py +3 -4
  18. package/scripts/make_dsh_tgz.py +20 -3
  19. package/scripts/make_manifest.py +15 -10
  20. package/scripts/make_plugin_zip.py +7 -3
  21. package/scripts/panel_build.py +13 -0
  22. package/scripts/_ci_env_probe.py +0 -81
  23. package/scripts/_panel_smoke_v299.py +0 -27
  24. package/scripts/_scratch/_tmp_backup_race.py +0 -70
  25. package/scripts/_scratch/_tmp_cleanup_move.py +0 -34
  26. package/scripts/_scratch/_tmp_count_kinds.py +0 -25
  27. package/scripts/_scratch/_tmp_diag_paths.py +0 -48
  28. package/scripts/_scratch/_tmp_facts.py +0 -63
  29. package/scripts/_scratch/_tmp_find_copies.py +0 -31
  30. package/scripts/_scratch/_tmp_find_pin.py +0 -29
  31. package/scripts/_scratch/_tmp_fix_pin.py +0 -36
  32. package/scripts/_scratch/_tmp_fold_fixture.py +0 -55
  33. package/scripts/_scratch/_tmp_fold_test.mjs +0 -81
  34. package/scripts/_scratch/_tmp_inject_secs.py +0 -30
  35. package/scripts/_scratch/_tmp_kb_balance.py +0 -159
  36. package/scripts/_scratch/_tmp_lines.py +0 -15
  37. package/scripts/_scratch/_tmp_market_probe.py +0 -13
  38. package/scripts/_scratch/_tmp_move_partial.py +0 -16
  39. package/scripts/_scratch/_tmp_patch_b3.py +0 -41
  40. package/scripts/_scratch/_tmp_patch_b5.py +0 -62
  41. package/scripts/_scratch/_tmp_patch_crash_excl.py +0 -24
  42. package/scripts/_scratch/_tmp_patch_handoff.py +0 -21
  43. package/scripts/_scratch/_tmp_patch_ps1.py +0 -25
  44. package/scripts/_scratch/_tmp_patch_stat.py +0 -27
  45. package/scripts/_scratch/_tmp_patch_todo.py +0 -25
  46. package/scripts/_scratch/_tmp_patch_todo2.py +0 -64
  47. package/scripts/_scratch/_tmp_probe_session.py +0 -51
  48. package/scripts/_scratch/_tmp_style_probe.py +0 -40
  49. package/scripts/_scratch/_tmp_write_note.py +0 -139
  50. package/scripts/_scratch/_/346/235/245/346/272/220/350/256/260/345/275/225.txt +0 -1
  51. package/scripts/_scratch/asar_compaction/dsh-compaction-basic__lib__index.js +0 -1044
  52. package/scripts/_scratch/asar_compaction/dsh-compaction-tool-result-pruner__lib__index.js +0 -194
  53. package/scripts/_scratch/asar_compaction/dsh-compaction__lib__index.js +0 -175
  54. package/scripts/_scratch/asar_compaction/dsh-compaction__lib__types__tool-pairing.js +0 -97
  55. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__image-offload.js +0 -47
  56. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__index.js +0 -40
  57. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__project-message.js +0 -37
  58. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__brand.js +0 -9
  59. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__checkpoint.js +0 -36
  60. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__types.js +0 -10
  61. package/scripts/_scratch/commit_msg_occ.txt +0 -16
  62. package/scripts/_scratch/commit_msg_struct.txt +0 -16
  63. package/scripts/_scratch/v5.34_changelog.txt +0 -36
  64. package/scripts/_smoke_v299.py +0 -31
  65. package/scripts/_sync_trae_cn.py +0 -102
  66. package/scripts/_tmp_add_s10.py +0 -54
  67. package/scripts/_tmp_add_s11.py +0 -61
  68. package/scripts/_tmp_add_s12.py +0 -66
  69. package/scripts/_tmp_add_s13.py +0 -69
  70. package/scripts/_tmp_add_s14.py +0 -80
  71. package/scripts/_tmp_add_s9.py +0 -68
  72. package/scripts/_tmp_cache_load.py +0 -82
  73. package/scripts/_tmp_clean_market.py +0 -40
  74. package/scripts/_tmp_clean_pruned.py +0 -81
  75. package/scripts/_tmp_cleanup_docs.py +0 -39
  76. package/scripts/_tmp_cmp_ranker.py +0 -17
  77. package/scripts/_tmp_dolater_note.py +0 -35
  78. package/scripts/_tmp_dust_why.py +0 -27
  79. package/scripts/_tmp_explicit_import.py +0 -40
  80. package/scripts/_tmp_extract_compaction.py +0 -35
  81. package/scripts/_tmp_extract_compaction2.py +0 -63
  82. package/scripts/_tmp_extract_compaction3.py +0 -51
  83. package/scripts/_tmp_extract_compaction4.py +0 -54
  84. package/scripts/_tmp_finalize_s14.py +0 -39
  85. package/scripts/_tmp_find_compaction.py +0 -43
  86. package/scripts/_tmp_fix_b4.py +0 -22
  87. package/scripts/_tmp_fix_cli76.py +0 -26
  88. package/scripts/_tmp_fix_docs.py +0 -38
  89. package/scripts/_tmp_fix_docs_b.py +0 -46
  90. package/scripts/_tmp_fix_docs_b2.py +0 -22
  91. package/scripts/_tmp_fix_i3.py +0 -23
  92. package/scripts/_tmp_fix_s10.py +0 -83
  93. package/scripts/_tmp_fix_s11.py +0 -14
  94. package/scripts/_tmp_fix_s9_status.py +0 -19
  95. package/scripts/_tmp_fix_shadow_sim.py +0 -37
  96. package/scripts/_tmp_fix_traits_value.py +0 -41
  97. package/scripts/_tmp_import_idem.py +0 -106
  98. package/scripts/_tmp_log_ack.py +0 -45
  99. package/scripts/_tmp_mark_batch.py +0 -28
  100. package/scripts/_tmp_mark_batch2.py +0 -32
  101. package/scripts/_tmp_mark_dolater.py +0 -26
  102. package/scripts/_tmp_mark_dolater2.py +0 -31
  103. package/scripts/_tmp_move_self.py +0 -16
  104. package/scripts/_tmp_occ_cli.py +0 -22
  105. package/scripts/_tmp_occ_link.py +0 -108
  106. package/scripts/_tmp_optimize_recall.py +0 -54
  107. package/scripts/_tmp_panel_audit.py +0 -26
  108. package/scripts/_tmp_patch_batch3.py +0 -65
  109. package/scripts/_tmp_patch_rrf.py +0 -46
  110. package/scripts/_tmp_patch_s2s3.py +0 -80
  111. package/scripts/_tmp_patch_s4.py +0 -39
  112. package/scripts/_tmp_patch_s7.py +0 -43
  113. package/scripts/_tmp_patch_s8.py +0 -91
  114. package/scripts/_tmp_patch_skill.py +0 -17
  115. package/scripts/_tmp_release_guard.py +0 -57
  116. package/scripts/_tmp_rerank_breaker.py +0 -62
  117. package/scripts/_tmp_s16.py +0 -41
  118. package/scripts/_tmp_scan_asar.py +0 -41
  119. package/scripts/_tmp_scan_asar2.py +0 -37
  120. package/scripts/_tmp_speed_survey.py +0 -49
  121. package/scripts/_tmp_struct_docs.py +0 -49
  122. package/scripts/_tmp_sum_fallback.py +0 -42
  123. package/scripts/_tmp_sweep.py +0 -81
  124. package/scripts/_tmp_sync_check.py +0 -69
  125. package/scripts/_tmp_sync_tail.py +0 -39
  126. package/scripts/_tmp_todo_clean.py +0 -67
  127. package/scripts/_tmp_verify_copy.py +0 -17
  128. package/scripts/_tmp_wire_extras.py +0 -93
  129. package/scripts/_tmp_wire_hsum.py +0 -34
  130. package/scripts/_tmp_wire_occ_b5.py +0 -40
  131. package/scripts/_tmp_wire_ranker.py +0 -13
  132. package/scripts/_tmp_wire_shadow_timeline.py +0 -45
  133. package/scripts/astrbot_plugin_lingshu/engine/scripts/_ci_env_probe.py +0 -81
  134. package/scripts/astrbot_plugin_lingshu/engine/scripts/_panel_smoke_v299.py +0 -27
  135. package/scripts/astrbot_plugin_lingshu/engine/scripts/_smoke_v299.py +0 -31
  136. package/scripts/astrbot_plugin_lingshu/engine/scripts/_sync_trae_cn.py +0 -102
  137. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s10.py +0 -54
  138. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s11.py +0 -61
  139. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s12.py +0 -66
  140. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s13.py +0 -69
  141. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s14.py +0 -80
  142. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s9.py +0 -68
  143. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cache_load.py +0 -82
  144. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_clean_market.py +0 -40
  145. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_clean_pruned.py +0 -81
  146. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cleanup_docs.py +0 -39
  147. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cmp_ranker.py +0 -17
  148. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_dolater_note.py +0 -35
  149. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_dust_why.py +0 -27
  150. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_explicit_import.py +0 -40
  151. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction.py +0 -35
  152. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction2.py +0 -63
  153. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction3.py +0 -51
  154. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction4.py +0 -54
  155. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_finalize_s14.py +0 -39
  156. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_find_compaction.py +0 -43
  157. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_b4.py +0 -22
  158. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_cli76.py +0 -26
  159. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs.py +0 -38
  160. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs_b.py +0 -46
  161. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs_b2.py +0 -22
  162. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_i3.py +0 -23
  163. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s10.py +0 -83
  164. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s11.py +0 -14
  165. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s9_status.py +0 -19
  166. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_shadow_sim.py +0 -37
  167. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_traits_value.py +0 -41
  168. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_import_idem.py +0 -106
  169. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_log_ack.py +0 -45
  170. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_batch.py +0 -28
  171. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_batch2.py +0 -32
  172. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_dolater.py +0 -26
  173. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_dolater2.py +0 -31
  174. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_move_self.py +0 -16
  175. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_occ_cli.py +0 -22
  176. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_occ_link.py +0 -108
  177. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_optimize_recall.py +0 -54
  178. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_panel_audit.py +0 -26
  179. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_batch3.py +0 -65
  180. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_rrf.py +0 -46
  181. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s2s3.py +0 -80
  182. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s4.py +0 -39
  183. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s7.py +0 -43
  184. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s8.py +0 -91
  185. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_skill.py +0 -17
  186. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_release_guard.py +0 -57
  187. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_rerank_breaker.py +0 -62
  188. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_s16.py +0 -41
  189. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_scan_asar.py +0 -41
  190. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_scan_asar2.py +0 -37
  191. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_speed_survey.py +0 -49
  192. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_struct_docs.py +0 -49
  193. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sum_fallback.py +0 -42
  194. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sweep.py +0 -81
  195. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sync_check.py +0 -69
  196. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sync_tail.py +0 -39
  197. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_todo_clean.py +0 -67
  198. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_verify_copy.py +0 -17
  199. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_extras.py +0 -93
  200. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_hsum.py +0 -34
  201. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_occ_b5.py +0 -40
  202. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_ranker.py +0 -13
  203. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_shadow_timeline.py +0 -45
@@ -1,93 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:接 abstract/seed/loops 三个命令 + #48 亲和度漂移(flag 门控)(可删)。"""
3
- from pathlib import Path
4
-
5
- cli = Path(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\cli.py")
6
- d = cli.read_text(encoding="utf-8")
7
-
8
- anchor = " # #49 影子记忆:写下记忆时的\"人格底色\",用于检测人格断裂风险(只提醒不阻止)"
9
- block = ''' # #43 abstract:给记忆补模型级摘要(没配模型就不补,不造假)
10
- p_abs = sub.add_parser("abstract", help="给记忆补一行模型摘要(检索/展示优先用它)")
11
- _ab = p_abs.add_subparsers(dest="abstract_action", parser_class=_BrainParser)
12
- _ab_s = _ab.add_parser("stamp-recent", help="给最近 N 天没有摘要的记忆补(需要 config summary)")
13
- _ab_s.add_argument("--limit", type=int, default=30)
14
- _ab_s.add_argument("--days", type=int, default=7)
15
- _ab_s.add_argument("--dry-run", action="store_true")
16
-
17
- # #52 代际种子:把当前人格底色固化一代(不参与日常检索)
18
- p_seed = sub.add_parser("seed", help="代际种子:固化一代人格底色作为演化压力")
19
- _sd = p_seed.add_subparsers(dest="seed_action", parser_class=_BrainParser)
20
- _sd_m = _sd.add_parser("make", help="拍一代种子")
21
- _sd_m.add_argument("--label", default="")
22
- _sd_l = _sd.add_parser("list", help="列出现有种子")
23
- _sd_l.add_argument("--limit", type=int, default=20)
24
-
25
- # #53 时序褶皱:给"同一思维循环"的记忆连边
26
- p_loop = sub.add_parser("loops", help="时序褶皱:把同一思维循环的记忆连成演化线")
27
- _lp = p_loop.add_subparsers(dest="loops_action", parser_class=_BrainParser)
28
- _lp_b = _lp.add_parser("build", help="扫描并连边(mistake/insight/gap)")
29
- _lp_b.add_argument("--min-overlap", type=int, default=4)
30
- _lp_b.add_argument("--limit", type=int, default=60)
31
-
32
- '''
33
- if "p_abs = sub.add_parser" not in d:
34
- d = d.replace(anchor, block + anchor, 1)
35
- print("解析器已加")
36
-
37
- disp_anchor = ' if args.cmd == "shadow":'
38
- disp = ''' if args.cmd == "abstract":
39
- import memory_extras
40
- return memory_extras.run_abstract(args)
41
-
42
- if args.cmd == "seed":
43
- import memory_extras
44
- return memory_extras.run_seed(args)
45
-
46
- if args.cmd == "loops":
47
- import memory_extras
48
- return memory_extras.run_loops(args)
49
-
50
- '''
51
- if 'args.cmd == "abstract"' not in d:
52
- d = d.replace(disp_anchor, disp + disp_anchor, 1)
53
- print("分派已加")
54
-
55
- cli.write_text(d, encoding="utf-8")
56
-
57
- # ---------------- #48 亲和度漂移(flag 门控,默认关) ----------------
58
- mem = Path(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\memory.py")
59
- m = mem.read_text(encoding="utf-8")
60
-
61
- old = """ for m in records:
62
- rel = relevance(q_terms, all_terms[m["id"]], idf, _avgdl) if q_terms else 0.0"""
63
- new = """ # §2 do-later #48(亲和度漂移,opt-in):人格变了,检索排序自然跟着变。
64
- # 近似做法:记忆的 tags/entities 命中当前人格 traits 越多的,给一点亲和加成。
65
- # 默认关闭——它改的是召回秩序,属调优项(和 RRF/MMR 同一理由)。
66
- _aff_on = bool(cfg.get("affinity_drift"))
67
- _ptraits = set()
68
- if _aff_on:
69
- try:
70
- _ptraits = {str(k) for k in ((load_persona() or {}).get("traits") or {})}
71
- except Exception:
72
- _ptraits = set()
73
-
74
- for m in records:
75
- rel = relevance(q_terms, all_terms[m["id"]], idf, _avgdl) if q_terms else 0.0"""
76
- if old in m:
77
- m = m.replace(old, new, 1)
78
- print("亲和度:插桩已加")
79
-
80
- old2 = """ score = w["relevance"] * rel + w["recency"] * rec + w["importance"] * imp"""
81
- new2 = """ score = w["relevance"] * rel + w["recency"] * rec + w["importance"] * imp
82
- if _aff_on and _ptraits:
83
- try:
84
- _hit = {str(t) for t in (m.get("tags") or [])} | {str(e) for e in (m.get("entities") or [])}
85
- _aff = len(_hit & _ptraits) / max(1, len(_ptraits))
86
- if _aff:
87
- score *= (1.0 + 0.15 * _aff) # 最多 +15%,属"轻微偏好",不抢相关性
88
- except Exception:
89
- pass"""
90
- if old2 in m:
91
- m = m.replace(old2, new2, 1)
92
- print("亲和度:打分已加")
93
- mem.write_text(m, encoding="utf-8")
@@ -1,34 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:接 hsum 命令(可删)。"""
3
- from pathlib import Path
4
-
5
- p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\cli.py")
6
- d = p.read_text(encoding="utf-8")
7
-
8
- anchor = " # #43 abstract:给记忆补模型级摘要(没配模型就不补,不造假)"
9
- block = ''' # 增量分层摘要:L1/L2/L3 账本,按 covers 幂等,保留率闸门
10
- p_hsum = sub.add_parser("hsum", help="增量分层摘要:按覆盖范围幂等,不反复重压同一段历史")
11
- _hs = p_hsum.add_subparsers(dest="hsum_action", parser_class=_BrainParser)
12
- _hs_b = _hs.add_parser("build", help="生成一层摘要(已存在的 covers 自动跳过)")
13
- _hs_b.add_argument("--level", type=int, default=1, choices=[1, 2, 3])
14
- _hs_b.add_argument("--max-units", type=int, default=8)
15
- _hs_b.add_argument("--dry-run", action="store_true")
16
- _hs_s = _hs.add_parser("show", help="查看某层最近的摘要")
17
- _hs_s.add_argument("--level", type=int, default=1, choices=[1, 2, 3])
18
-
19
- '''
20
- if "p_hsum = sub.add_parser" not in d:
21
- d = d.replace(anchor, block + anchor, 1)
22
- print("解析器已加")
23
-
24
- disp_anchor = ' if args.cmd == "abstract":'
25
- disp = ''' if args.cmd == "hsum":
26
- import hsum
27
- return hsum.run(args)
28
-
29
- '''
30
- if 'args.cmd == "hsum"' not in d:
31
- d = d.replace(disp_anchor, disp + disp_anchor, 1)
32
- print("分派已加")
33
-
34
- p.write_text(d, encoding="utf-8")
@@ -1,40 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:接 occ / bigfive 两个命令(可删)。"""
3
- from pathlib import Path
4
-
5
- p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\cli.py")
6
- d = p.read_text(encoding="utf-8")
7
-
8
- anchor = " # 增量分层摘要:L1/L2/L3 账本,按 covers 幂等,保留率闸门"
9
- block = ''' # OCC 结构情绪(6 类 + 预期违背拆正负两向)
10
- p_occ = sub.add_parser("occ", help="OCC 结构情绪:认'承诺没做到/担心没发生'这类结构")
11
- _os = p_occ.add_subparsers(dest="occ_action", parser_class=_BrainParser)
12
- _os_l = _os.add_parser("label", help="给一句话打 OCC 标签")
13
- _os_l.add_argument("text")
14
- _os_v = _os.add_parser("violation", help="只看预期违背(负向=失望 / 正向=释然)")
15
- _os_v.add_argument("text")
16
-
17
- # Big Five 数值化(固定 5 维,便于跨时间比较)
18
- p_b5 = sub.add_parser("bigfive", help="Big Five:把自由命名的 traits 归并成固定 5 维")
19
- p_b5.add_argument("--save", action="store_true", help="写进 persona.json 的 big_five")
20
-
21
- '''
22
- if "p_occ = sub.add_parser" not in d:
23
- d = d.replace(anchor, block + anchor, 1)
24
- print("解析器已加")
25
-
26
- disp_anchor = ' if args.cmd == "hsum":'
27
- disp = ''' if args.cmd == "occ":
28
- import occ
29
- return occ.run(args)
30
-
31
- if args.cmd == "bigfive":
32
- import bigfive
33
- return bigfive.run(args)
34
-
35
- '''
36
- if 'args.cmd == "occ"' not in d:
37
- d = d.replace(disp_anchor, disp + disp_anchor, 1)
38
- print("分派已加")
39
-
40
- p.write_text(d, encoding="utf-8")
@@ -1,13 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:把 summarize 里的 extractive_fallback 调用带上 ranker(可删)。"""
3
- from pathlib import Path
4
-
5
- p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\summarizer.py")
6
- d = p.read_text(encoding="utf-8")
7
- old = "text = extractive_fallback(turns, max_chars)"
8
- new = ('text = extractive_fallback(turns, max_chars, '
9
- 'ranker=str(sec.get("ranker") or "position"))')
10
- n = d.count(old)
11
- d = d.replace(old, new)
12
- p.write_text(d, encoding="utf-8")
13
- print("替换", n, "处")
@@ -1,45 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:给 cli 接 shadow / timeline 两个命令(可删)。"""
3
- from pathlib import Path
4
-
5
- p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\cli.py")
6
- d = p.read_text(encoding="utf-8")
7
-
8
- anchor = " # 联网调研(web_search 工具欠费时的备胎;能联网就联网,连不上再本地取证)"
9
- if "p_shadow = sub.add_parser" not in d:
10
- block = ''' # #49 影子记忆:写下记忆时的"人格底色",用于检测人格断裂风险(只提醒不阻止)
11
- p_shadow = sub.add_parser("shadow", help="影子记忆:记录/审计写下记忆时的人格底色")
12
- _sh = p_shadow.add_subparsers(dest="shadow_action", parser_class=_BrainParser)
13
- _sh_s = _sh.add_parser("stamp", help="给一条记忆补影子")
14
- _sh_s.add_argument("id")
15
- _sh_r = _sh.add_parser("stamp-recent", help="给最近 N 天没影子的记忆批量补")
16
- _sh_r.add_argument("--days", type=int, default=1)
17
- _sh_r.add_argument("--limit", type=int, default=50)
18
- _sh_a = _sh.add_parser("audit", help="检测人格断裂风险(相似度低于阈值)")
19
- _sh_a.add_argument("--threshold", type=float, default=0.55)
20
- _sh_a.add_argument("--limit", type=int, default=20)
21
-
22
- # #46 成长时间线:把梦/人格快照/教训/缺口按时间并成一条线
23
- p_tl = sub.add_parser("timeline", help="成长时间线:'我是怎么变成现在这样的'")
24
- p_tl.add_argument("--days", type=int, default=30)
25
- p_tl.add_argument("--limit", type=int, default=40)
26
-
27
- '''
28
- d = d.replace(anchor, block + anchor, 1)
29
- print("解析器已加")
30
-
31
- disp_anchor = ' if args.cmd == "web":'
32
- if 'args.cmd == "shadow"' not in d:
33
- disp = ''' if args.cmd == "shadow":
34
- import shadow_memory
35
- return shadow_memory.run(args)
36
-
37
- if args.cmd == "timeline":
38
- import timeline
39
- return timeline.run(args)
40
-
41
- '''
42
- d = d.replace(disp_anchor, disp + disp_anchor, 1)
43
- print("分派已加")
44
-
45
- p.write_text(d, encoding="utf-8")
@@ -1,81 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """CI 诊断探针:只在 sync_engine 失败时被调用,把环境事实打出来。
3
-
4
- 为什么单独成文件:内联在 workflow 的 heredoc 会破坏 YAML 缩进(实测解析失败),
5
- 而这一段逻辑值得留档——它回答的是"为什么在 Windows runner 上失败、Linux 上不".
6
- """
7
- import locale
8
- import pathlib
9
- import sys
10
-
11
-
12
- def main() -> int:
13
- root = pathlib.Path(".").resolve()
14
- print(f" cwd={root}")
15
- print(f" python={sys.version.split()[0]}")
16
- print(f" fsencoding={sys.getfilesystemencoding()}")
17
- print(f" preferred={locale.getpreferredencoding(False)}")
18
-
19
- print(" --- 关键路径 ---")
20
- for rel in ("scripts",
21
- "scripts/astrbot_plugin_lingshu",
22
- "scripts/astrbot_plugin_lingshu/engine",
23
- "docs/panel-api.md", "docs/commands.md",
24
- "docs/mechanics.md", "docs/models.md", "docs/recovery.md",
25
- "assets/panel.html"):
26
- p = root / rel
27
- kind = "-" if not p.exists() else ("dir" if p.is_dir() else f"{p.stat().st_size}B")
28
- print(f" {rel}: {kind}")
29
-
30
- # 换行抽样:CI 若在 Windows 上 checkout 成 CRLF,这里能直接看出来
31
- print(" --- 换行抽样(前 5 个 .md/.py)---")
32
- shown = 0
33
- for p in sorted(root.rglob("*")):
34
- if shown >= 5:
35
- break
36
- if p.is_file() and p.suffix.lower() in (".md", ".py") and "node_modules" not in str(p):
37
- b = p.read_bytes()[:400]
38
- crlf = b.count(b"\r\n")
39
- lf = b.count(b"\n") - crlf
40
- print(f" {p.relative_to(root)}: CRLF={crlf} LF={lf}")
41
- shown += 1
42
-
43
- # engine 里是否残留已从根目录删掉的文档
44
- eng = root / "scripts" / "astrbot_plugin_lingshu" / "engine"
45
- if eng.is_dir():
46
- stale = [p.name for p in eng.rglob("*.md")
47
- if not (root / p.relative_to(eng)).exists()]
48
- print(f" --- engine 里根目录已无对应项的 .md: {stale[:8] or '无'}")
49
- return 0
50
-
51
-
52
- def _ensure_utf8_stdout() -> None:
53
- """把 stdout/stderr 切到 UTF-8,避免 Windows 控制台(cp1252/cp936)编不了中文就崩。
54
-
55
- CI 的 windows-latest stdout 是 cp1252:脚本一 print 中文就 UnicodeEncodeError
56
- 直接退出(实测 sync_engine.py / make_checksums.py 都因此挂过,Ubuntu 同期正常)。
57
- 这不是业务 bug,是"中文输出 + 非 UTF-8 控制台"的必然结果。
58
- """
59
- for name in ("stdout", "stderr"):
60
- stream = getattr(sys, name, None)
61
- fn = getattr(stream, "reconfigure", None)
62
- if callable(fn):
63
- try:
64
- fn(encoding="utf-8", errors="replace")
65
- continue
66
- except (OSError, ValueError, AttributeError):
67
- pass
68
- try:
69
- import io
70
- buf = getattr(stream, "buffer", None)
71
- if buf is not None:
72
- setattr(sys, name,
73
- io.TextIOWrapper(buf, encoding="utf-8", errors="replace",
74
- line_buffering=True))
75
- except Exception: # noqa: BLE001
76
- pass
77
-
78
-
79
- if __name__ == "__main__":
80
- _ensure_utf8_stdout()
81
- sys.exit(main())
@@ -1,27 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """验证脚本:后台起 panel_server(临时 HOME),查 /api/extensions/ollama/status,然后关掉。"""
3
- import os, subprocess, sys, tempfile, time, urllib.request
4
-
5
- tmp = os.path.join(tempfile.gettempdir(), "lingshu-panel-smoke")
6
- os.makedirs(tmp, exist_ok=True)
7
- root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
8
- flags = getattr(subprocess, "CREATE_NO_WINDOW", 0)
9
- proc = subprocess.Popen([sys.executable, os.path.join(root, "scripts", "panel_server.py"),
10
- "--port", "8791", "--no-browser", "--home", tmp],
11
- cwd=root, creationflags=flags,
12
- stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
13
- time.sleep(6)
14
- try:
15
- with urllib.request.urlopen("http://127.0.0.1:8791/api/extensions/ollama/status", timeout=10) as r:
16
- print("STATUS:", r.read().decode("utf-8"))
17
- except Exception as exc:
18
- print("ERR:", exc)
19
- finally:
20
- proc.terminate()
21
- try:
22
- _, err = proc.communicate(timeout=10)
23
- if err:
24
- print("STDERR:", err.decode("utf-8", "replace")[-800:])
25
- except Exception:
26
- proc.kill()
27
- print("PANEL SMOKE DONE")
@@ -1,31 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """v2.99 冒烟:临时 HOME 下写入记忆 → recall 语义相近查询 → hash 向量自检。"""
3
- import sys, os, tempfile
4
- tmp = tempfile.mkdtemp(prefix="lingshu-smoke-")
5
- os.environ["BRAIN_MEMORY_HOME"] = tmp # 必须在 import 前设好,模块加载即解析 HOME
6
- sys.path.insert(0, r"e:\丁厚同\文档\程序\灵枢-skill\scripts")
7
- import core, memory, brain # brain 负责命名空间合并(compile_persona 等跨模块名)
8
- from pathlib import Path
9
- print("HOME =", core.HOME)
10
- assert str(core.HOME) == tmp or Path(tmp) == Path(os.environ["BRAIN_MEMORY_HOME"])
11
-
12
- # hash 向量自检
13
- import fallback_embed as fe
14
- a = fe.encode("用户喜欢用PostgreSQL存数据")
15
- assert a is not None and len(a) == 256, "encode 失败"
16
- assert abs(fe.cosine(a, a) - 1.0) < 0.01, "自相似度应为 1"
17
- sim_rel = fe.cosine(a, fe.encode("用户偏好把数据存在PostgreSQL里"))
18
- sim_irr = fe.cosine(a, fe.encode("今天天气很好适合出去爬山"))
19
- assert sim_rel > sim_irr, f"语义相近应更高分: {sim_rel} vs {sim_irr}"
20
- print(f"hash 向量: 自相似=1 OK, 相近={sim_rel:.3f} > 无关={sim_irr:.3f} OK")
21
-
22
- # 记忆写入 + recall
23
- memory.remember("我们把项目的数据库迁移到了 PostgreSQL 16,连接串放在 config 里", kind="fact")
24
- memory.remember("用户生日是 3 月 12 日,喜欢巧克力蛋糕", kind="fact")
25
- memory.remember("上周末一起去爬了香山,秋天的红叶很美", kind="episode")
26
- import time; time.sleep(2.5) # 等异步 embedding 回写
27
- hits = memory.recall("项目现在用的什么数据库存数据?", strengthen=False)
28
- texts = [h[0].get("text", "")[:30] for h in hits]
29
- print("recall 命中:", texts[:3])
30
- assert any("PostgreSQL" in t for t in texts), "语义相近查询未命中"
31
- print("SMOKE PASS, home =", tmp)
@@ -1,102 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- """把源码交付物同步到**已安装副本**(一次性运维脚本,可删)。
4
-
5
- ⚠ 2026-11-29 纠偏:本脚本原先只写 `~/.app/profiles/desktop/node_modules/lingshu-skill`,
6
- 而该路径并不存在、宿主根本不用它。doctor 的 `release-drift` 实际检查的两份副本是:
7
- · DSH profile 插件副本(宿主真正加载、cron 也从这里取 `scripts/brain.py`)
8
- · 全局技能目录里的 `lingshu/`
9
- 写错目标的后果是"同步显示成功、运行时还是旧代码"——2026-11-29 备份修复就是这样
10
- 没生效的,跑了 6 天的 cron 备份仍在失败。
11
-
12
- 用法:python scripts/_sync_trae_cn.py
13
- """
14
- import argparse
15
- import json
16
- import os
17
- import shutil
18
- import sys
19
- from pathlib import Path
20
-
21
- SRC = Path(r"e:\丁厚同\文档\程序\灵枢-skill")
22
- # 只同步**确实存在**的副本;不存在的目标跳过(不创建,避免往空路径写)
23
- DST_CANDIDATES = [
24
- Path(r"C:\Users\Administrator\.dsh\profiles\desktop\node_modules\lingshu-skill"),
25
- Path(r"C:\Users\Administrator\.trae-cn\skills\lingshu"),
26
- Path(r"C:\Users\Administrator\.app\skills\lingshu"),
27
- ]
28
-
29
- m = json.loads((SRC / "manifest.json").read_text(encoding="utf-8-sig"))
30
- files = m["files"]
31
-
32
- targets = [d for d in DST_CANDIDATES if (d / "SKILL.md").is_file()]
33
- if not targets:
34
- print("[sync] 没找到任何已安装副本(检查 DST_CANDIDATES 路径)")
35
- sys.exit(1)
36
-
37
- _ap = argparse.ArgumentParser(description="把源码交付物同步到已安装副本(--check 只校验)")
38
- _ap.add_argument("--check", action="store_true", help="只报告副本是否落后,不写文件")
39
- _args = _ap.parse_args()
40
- _check_only = bool(_args.check)
41
- _drift: list = []
42
-
43
- for dst in targets:
44
- ok = miss = same = 0
45
- missing = []
46
- for rel in files:
47
- s = SRC / rel
48
- if not s.is_file():
49
- missing.append(rel)
50
- continue
51
- d = dst / rel
52
- d.parent.mkdir(parents=True, exist_ok=True)
53
- # 原子替换 + 跳过未变化:宿主进程随时可能 spawn 副本里的 python,
54
- # 直接 copy2 覆盖会留下"文件正被读一半"的窗口——2026-11-30 实测出现过
55
- # `startup-no-output`(同步期间插件读到半截 brain.py)。
56
- try:
57
- _new = s.read_bytes()
58
- if d.is_file() and d.read_bytes() == _new:
59
- same += 1
60
- continue
61
- if _check_only:
62
- _drift.append(f"{dst.name}:{rel}")
63
- ok += 1
64
- continue
65
- _tmp = d.with_name(d.name + ".syncing")
66
- _tmp.write_bytes(_new)
67
- os.replace(_tmp, d) # 同卷 rename,原子
68
- ok += 1
69
- except OSError:
70
- # 极端情况下退回普通拷贝(至少别整份失败)
71
- import shutil as _sh
72
- _sh.copy2(s, d)
73
- ok += 1
74
- ver = ""
75
- for line in (dst / "SKILL.md").read_text(encoding="utf-8-sig").splitlines():
76
- if line.startswith("version:"):
77
- ver = line.strip()
78
- break
79
- print(f"[sync] {dst}: updated={ok} unchanged={same} missing={miss} SKILL.md {ver}")
80
-
81
- # 自检:确认关键修复真的落进了副本
82
- MARK = "_EXCLUDE_DIR_PARTS"
83
- print("\n[自检] 各副本是否含备份修复标记:")
84
- bad = 0
85
- for dst in targets:
86
- p = dst / "scripts" / "cli.py"
87
- has = p.is_file() and MARK in p.read_text(encoding="utf-8", errors="replace")
88
- print(f" {dst}: {'OK' if has else '缺失'}")
89
- if not has:
90
- bad += 1
91
- # --check 汇总(必须在 sys.exit 之前,否则永远是死代码——踩过)
92
- if _check_only:
93
- if _drift:
94
- print(f"[check] 副本落后 {len(_drift)} 个文件:", file=sys.stderr)
95
- for x in _drift[:15]:
96
- print(f" - {x}", file=sys.stderr)
97
- print("跑 python scripts/_sync_trae_cn.py 修复。", file=sys.stderr)
98
- else:
99
- print("[check] OK:已安装副本与源码一致")
100
-
101
- sys.exit(1 if (bad or (_check_only and _drift)) else 0)
102
-
@@ -1,54 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:写「为什么 APP 水位不降」的口径说明(可删)。"""
3
- from pathlib import Path
4
-
5
- p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\docs\审核改进待办.md")
6
- d = p.read_text(encoding="utf-8")
7
-
8
- SEC = """
9
- ## §10 为什么"灵枢压了、APP 水位还是那么多"(2026-11-30 查清)
10
-
11
- ### 两个水位是两个口径
12
-
13
- | 口径 | 谁算的 | 算什么 |
14
- |---|---|---|
15
- | **宿主水位**(APP 里显示的那个) | APP 的 `ctx.tokenMeter.contextPressure(session)` | 宿主自己持有的**会话历史**规模 |
16
- | **折叠后水位**(灵枢算的) | `context preview` / `context status` 的 `effective` | 灵枢折叠后**本次请求实际会发出去**的 messages 规模 |
17
-
18
- 实测同一时刻:宿主 **79.9%** / 折叠后 **45.0%**(省 39.7%,折了 7 轮)。
19
-
20
- ### 三条会让人误判"没生效"的原因
21
-
22
- 1. **插件开关默认关**:`contextFold` 为假时,账本里备好的折叠**一条都不会应用**,
23
- 请求原样发出——这是之前水位纹丝不动的**主因**(账本里有 7 条生效中的折叠却没用上)。
24
- 已在 2026-11-30 打开(`config set contextFold true`),**需重载插件/重启 APP 才生效**。
25
- 2. **宿主口径不会因为"我们改了请求"而立刻掉**:它数的是自己的历史。
26
- 灵枢能改的只是"每次请求发出去的那份 messages",改不了宿主手里的历史副本。
27
- 所以正确预期是:**宿主数字降得慢、实际消耗降得快**。
28
- 3. **插件重载前改配置等于没改**——`plugin-loaded` 会诚实报警("副本比最近一次会话开始新")。
29
-
30
- ### 怎么验证真的生效
31
-
32
- 重载插件后,同一次会话里对比:
33
-
34
- ```
35
- brain.py context status # 第一行宿主口径,第二行折叠后口径
36
- brain.py context preview # 折叠收益明细(省多少字符 / 多少轮)
37
- ```
38
-
39
- 若"折叠后"明显低于"宿主",且 `tokenMeter` 的 `pressure_tokens` 增长速度变慢,就是生效了。
40
- 要回退:`brain.py config set contextFold false`(同样需重载)。
41
-
42
- ### 还能怎么让宿主水位真的降
43
-
44
- - 让**宿主自己**压缩/新开会话(灵枢无权改它的历史);
45
- - 继续跑 `context autofold`(cron 每小时)把更多轮折进账本——账本越大,"发出去的"越小;
46
- - 减少灵枢自身注入(`budget`/`style_hint` 默认关、P0.8 总量兜底已在管)。
47
- """
48
-
49
- if "## §10 为什么" in d:
50
- print("§10 已存在")
51
- else:
52
- d = d.rstrip() + "\n\n" + SEC
53
- p.write_text(d, encoding="utf-8")
54
- print("已追加 §10")
@@ -1,61 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:把「反直觉记忆机制」评估写进待办 §11(可删)。"""
3
- from pathlib import Path
4
-
5
- p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\docs\审核改进待办.md")
6
- d = p.read_text(encoding="utf-8")
7
-
8
- SEC = """
9
- ## §11 反直觉记忆机制(外部方案二)评估(2026-11-30)
10
-
11
- > 来源:用户提供的第二份提案,8 条"跳出人类直觉"的记忆机制。
12
- > 处理方式:逐条判断**在灵枢现有结构里能不能落地**,能落的记成待办,落不了的写明卡点。
13
- > 先说结论:**8 条里 4 条现在可落、2 条要前置信号、2 条建议不做**。
14
-
15
- ### 11.1 逐条判定
16
-
17
- | # | 机制 | 灵枢能否落地 | 判定 |
18
- |---|---|---|---|
19
- | 一 | **记忆拥有观测权**:记忆订阅推理流、自带 `trigger_expr`、按侵略系数申请投递 | 🟡 **半可落**。插件只有 `agent/pre-step`(拿到 messages)与 `turn-stopping`,**拿不到"推理草稿/中途分支"**——链式思考不在宿主暴露面里。能做的版本:把触发条件从"关键词"换成**上下文状态特征**(话题类型、是否在推翻旧方案、距上次唤醒轮数)+ `delivery_aggressiveness` 系数 | 前置受限;可做"弱化版" → **#47** |
20
- | 二 | **遗忘 = 灵枢亲和度漂移**,不是记忆降权 | ✅ **可落**。灵枢有人格 traits/drives(0-100)与情绪向量,天然就是"亲和向量";检索分现在是 `relevance×0.55 + recency + importance`,把"亲和投影"作为**乘性因子**接进去即可 | 有价值 → **#48** |
21
- | 三 | **影子记忆**:写每条记忆时留一份"当时的人格底色",日后检测"人格断裂风险" | ✅ **可落**。已有 `persona_snapshots`(整份快照)与 `persona_drift`,缺的是**per-memory 的影子配对**。可写 `shadow` 字段(写入时 persona traits/情绪摘要,不含任务内容) | 有价值、可逆 → **#49** |
22
- | 四 | **寄生钩子**:写记忆时预埋未来触发器(近钩/远钩/循环钩,绑"思维模式指纹") | 🟡 **半可落**。没有"思维模式指纹"这种信号,但可以用**词法/主题指纹**(`terms` + 话题栈 + mistake 复发检测)近似;「循环钩」其实就是"反复踩同一个坑",我们已经能检测 | 近似版可做 → **#50** |
23
- | 五 | **缓存-记忆负反馈**:`aggressiveness = base × 缓存命中率系数` | ❌ **现在做不到**。宿主**不暴露缓存命中率**(`tokenMeter` 只给压力 token/窗口)。可用的代理只有"前缀稳定性"(`inject-drift` 已能做)与水位数,但那不等于命中率 | 阻塞:缺信号。**不做**,只在文档留结论 |
24
- | 六 | **缺口记忆**(gap memory):存"当时卡住的地方 / 为什么没落地 / 未来什么条件可重启" | ✅ **可落且很契合**。现有 `kind` 里有 `intent`(未完成意图)最接近;补 `gap_type / unsolved_branch / reject_reason / latent_potential / maturity` 五个字段,后台按新能力涨 `maturity` | 建议做 → **#51** |
25
- | 七 | **代际遗传种子**:每次人格升华产一代种子,重大重构时释放,作为演化压力 | 🟡 **半可落**。有 `dream` 沉淀与 `persona suggest`,但"种子"需要**显式代际标记**与"重大重构时释放"的触发点(现在没有"重构"这个事件) | 可做最小版 → **#52** |
26
- | 八 | **时序褶皱**:按"主观时间/思维循环"邻接检索,而非物理时间 | 🟡 **半可落**。已有 `links`/`assoc` 图与 `related`,但"同一思维循环"没有被算作一种边 | 可做近似版 → **#53** |
27
-
28
- ### 11.2 新增待办(47–53)
29
-
30
- | # | 项 | 具体做法(贴合现有代码) | 风险/代价 | 状态 |
31
- |---|---|---|---|---|
32
- | 47 | **记忆投递触发(弱化版)** | 记忆加 `trigger` 块:`{topic_kinds, flip_old_plan, min_turns_since_hit, aggressiveness}`;`prior`/注入选择时按这些特征打分,而不是只按查询相似度 | 属**注入主链路**;需水位 <50% 单独做,并用 `context preview` 式可见性验证 | ⬜ 待修 |
33
- | 48 | **亲和度漂移代替衰减** | 检索分乘一个亲和因子:`affinity = cos(persona 向量, 记忆主题向量)` 的归一值;人格变了排序自然变,旧记忆不强删、漂回来能复活 | 需要把 persona traits/情绪做成稳定向量;改打分 → 动召回秩序,必须 opt-in + 前后对照 | ⬜ 待修 |
34
- | 49 | **影子记忆(人格底色配对)** | 写入时附 `shadow: {ts, traits, mood, drives}`(**不含任务正文**);`detect-conflicts` 增加"人格断裂风险"一项:新记忆 vs 目标的影子夹角过大就标记,交灵枢自决 | 只加字段+只读检测,低风险;但会增大存储(每条多一小块) | ⬜ 待修 |
35
- | 50 | **寄生钩子(词法近似)** | 写 mistake/insight 时预埋 `hooks: {near: [...], far: {topic, terms}}`;`prior` 与注入时按"话题命中 + terms 重合"唤醒,而不是关键词匹配 | 近似版准确率有限,别让它变成噪音源;先只对 `mistake` 类开 | ⬜ 待修 |
36
- | 51 | **缺口记忆(gap memory)** | 新增 `kind=gap`:`unsolved_branch / reject_reason / latent_potential / maturity(0~1)`;`dream` 时按"新出现的能力/工具/知识"给 maturity 加成,过阈值浮出 | 与现有 `intent` 语义要划清(intent=要做的事,gap=想不通的路);字段多、要迁移旧数据 | ⬜ 待修 |
37
- | 52 | **代际种子(最小版)** | 每次 `dream` 沉淀后,若人格有实质变化(`persona_drift` 幅度超阈值),生成一条 `kind=seed` 的"演化底色"记忆;**不参与日常检索**,仅在 `persona self`/重大重构时列出 | 容易变噪音;需严格触发条件(否则每条 dream 都产种子) | ⬜ 待修 |
38
- | 53 | **时序褶皱(近似)** | 给 `links` 增加一种边 `same_loop`:同话题 + 同 mistake 指纹的记忆互连;`related` 检索优先走这些边,而不是纯物理时间 | 需要"思维循环"的判定规则,否则边会乱连 | ⬜ 待修 |
39
-
40
- ### 11.3 明确建议不做 / 需前置条件
41
-
42
- | 机制 | 原因 |
43
- |---|---|
44
- | **五、缓存-记忆负反馈** | 宿主不暴露命中率,**没有可用信号**。用"水位"冒充会得到一个错误的反馈环(水位受很多因素影响,不等于缓存命中)。等宿主提供命中率再议;现在能做的最多是"前缀稳定性"(`inject-drift` 已有) |
45
- | **一、完全版"记忆拥有观测权"** | 需要订阅**推理痕迹/草稿/中途分支**,插件 API 只给到 `decision.messages`,拿不到链式思考。做"完全版"等于臆造信号 |
46
- | **七、代际种子(完整版)** | "重大架构/自我重构"目前**没有对应事件**,无法可靠触发;先做最小版(#52) |
47
-
48
- ### 11.4 判据(为什么这么判)
49
-
50
- - 能落地的四条(二/三/六/八)都**只碰读写字段与打分**,不需要新信号、不需要向量库外挂;
51
- - 半可落的三条(一/四/七)缺的都是**信号**(推理草稿、思维指纹、重构事件),
52
- 只能先用"话题/词法/复发"近似——**要写清是近似,别假装有真信号**;
53
- - 建议不做的两条,一条缺信号、一条缺事件,硬做只会产出"看起来玄、实际拍脑袋"的东西。
54
- """
55
-
56
- if "## §11 反直觉记忆机制" in d:
57
- print("§11 已存在,跳过")
58
- else:
59
- d = d.rstrip() + "\n\n" + SEC
60
- p.write_text(d, encoding="utf-8")
61
- print("已追加 §11")