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,41 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:修 traits 嵌套结构({value,why,evidence})的数值提取(可删)。"""
3
- from pathlib import Path
4
-
5
- ROOT = Path(r"E:\丁厚同\文档\程序\灵枢-skill")
6
-
7
- # 1) bigfive:取 .value
8
- p = ROOT / "scripts" / "bigfive.py"
9
- d = p.read_text(encoding="utf-8")
10
- old = """ v = _num(val, 0.0)"""
11
- new = """ # traits 是嵌套结构 {value, why, evidence},不是裸数字——直接 _num(dict) 会得 0。
12
- _raw = val.get("value") if isinstance(val, dict) else val
13
- v = _num(_raw, 0.0)"""
14
- assert old in d
15
- p.write_text(d.replace(old, new, 1), encoding="utf-8")
16
- print("bigfive 已取 value")
17
-
18
- # 2) persona drift:数值型 diff 也要能读嵌套结构,否则 magnitude 永远是 0.5 当量
19
- p2 = ROOT / "scripts" / "persona.py"
20
- d2 = p2.read_text(encoding="utf-8")
21
- old2 = """ try:
22
- if isinstance(b.get(k), (int, float)) and \\
23
- isinstance(c.get(k), (int, float)):
24
- _mag = abs(float(c[k]) - float(b[k])) / 100.0
25
- _d["delta"] = round(float(c[k]) - float(b[k]), 2)
26
- else:
27
- _mag = 0.5"""
28
- new2 = """ def _val(x):
29
- # traits/drives 是 {value, why, evidence};取数值那层
30
- return x.get("value") if isinstance(x, dict) else x
31
-
32
- try:
33
- _bv, _cv = _val(b.get(k)), _val(c.get(k))
34
- if isinstance(_bv, (int, float)) and isinstance(_cv, (int, float)):
35
- _mag = abs(float(_cv) - float(_bv)) / 100.0
36
- _d["delta"] = round(float(_cv) - float(_bv), 2)
37
- else:
38
- _mag = 0.5"""
39
- assert old2 in d2
40
- p2.write_text(d2.replace(old2, new2, 1), encoding="utf-8")
41
- print("persona drift 已取 value")
@@ -1,106 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:#5 给 session_import 加持久化幂等键(可删)。"""
3
- from pathlib import Path
4
-
5
- p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\session_import.py")
6
- d = p.read_text(encoding="utf-8")
7
-
8
- # 1) 辅助函数(放在 import_session_file 之前)
9
- anchor = "def import_session_file(log: SessionLog, *, decoder: Decoder, dry_run: bool = False,"
10
- helpers = '''SEEN_FILE = ".session-import-seen.json"
11
- SEEN_CAP = 50000
12
-
13
-
14
- def _seen_path() -> Path:
15
- return Path(brain.HOME) / SEEN_FILE if "brain" in globals() else Path.home() / SEEN_FILE
16
-
17
-
18
- def load_seen_keys() -> set:
19
- """跨批次/跨运行的导入幂等键(上次入库过的行不再进)。"""
20
- try:
21
- p = _seen_path()
22
- if not p.is_file():
23
- return set()
24
- data = json.loads(p.read_text(encoding="utf-8", errors="replace") or "[]")
25
- return {str(x) for x in (data or []) if x}
26
- except Exception:
27
- return set()
28
-
29
-
30
- def save_seen_keys(keys: set) -> None:
31
- try:
32
- p = _seen_path()
33
- tmp = p.with_name(p.name + ".tmp")
34
- kept = sorted(keys)[-SEEN_CAP:]
35
- tmp.write_text(json.dumps(kept, ensure_ascii=False), encoding="utf-8")
36
- os.replace(tmp, p) # 原子替换,避免写一半被读到
37
- except Exception:
38
- pass
39
-
40
-
41
- def row_key(session_id: str, row: dict) -> str:
42
- """一行的幂等键:会话 + 行内容指纹。行结构变了也不会误判重复。"""
43
- try:
44
- basis = session_id + "|" + json.dumps(row, ensure_ascii=False, sort_keys=True)
45
- except Exception:
46
- basis = session_id + "|" + str(row)[:500]
47
- return hashlib.sha1(basis.encode("utf-8", "replace")).hexdigest()[:20]
48
-
49
-
50
- '''
51
- if "def load_seen_keys" not in d:
52
- d = d.replace(anchor, helpers + anchor, 1)
53
- print("辅助函数已加")
54
-
55
- # 2) 循环里加幂等判断
56
- old_loop = """ row = _event_to_row(event)
57
- if row is None:
58
- continue
59
- parsed += 1
60
- batch.append(row)"""
61
- new_loop = """ row = _event_to_row(event)
62
- if row is None:
63
- continue
64
- # #5 持久化幂等:重跑同一次导出不会重复入库(原来只在单批次内去重)
65
- _k = row_key(session_id, row)
66
- if _k in _seen_keys:
67
- skipped_dup += 1
68
- continue
69
- _pending_keys.add(_k)
70
- parsed += 1
71
- batch.append(row)"""
72
- if "skipped_dup" not in d:
73
- d = d.replace(old_loop, new_loop, 1)
74
- print("幂等判断已加")
75
-
76
- # 3) 初始化变量
77
- old_init = """ parsed = added = skipped = bad_lines = 0
78
- batch: list[dict] = []"""
79
- new_init = """ parsed = added = skipped = bad_lines = 0
80
- skipped_dup = 0
81
- _seen_keys = load_seen_keys()
82
- _pending_keys: set = set()
83
- batch: list[dict] = []"""
84
- if "skipped_dup = 0" not in d:
85
- d = d.replace(old_init, new_init, 1)
86
- print("初始化已加")
87
-
88
- # 4) 结束时保存 + 报告
89
- old_end = """ report["messages"] = parsed
90
- report["bad_lines"] = bad_lines
91
- if not dry_run:
92
- report["added"] = added
93
- report["skipped"] = skipped"""
94
- new_end = """ report["messages"] = parsed
95
- report["bad_lines"] = bad_lines
96
- report["already_imported"] = skipped_dup
97
- if not dry_run:
98
- report["added"] = added
99
- report["skipped"] = skipped
100
- if _pending_keys:
101
- save_seen_keys(_seen_keys | _pending_keys)"""
102
- if "already_imported" not in d:
103
- d = d.replace(old_end, new_end, 1)
104
- print("落盘已加")
105
-
106
- p.write_text(d, encoding="utf-8")
@@ -1,45 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:给 cli 加 logs ack + log-anomalies 窗口下界(可删)。"""
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
- old = """ import time as _t
9
- _cut = _t.time() - 7 * 86400"""
10
- new = """ import time as _t
11
- _cut = _t.time() - 7 * 86400
12
- # 「确认历史噪声」:logs ack 记下时刻后,只统计它之后的条目。
13
- # 为什么需要:修好的旧错误会在 7 天窗口里持续把这项顶成 WARN,
14
- # 而它既不代表现状、又没法"修好",只能显式确认一次。
15
- try:
16
- _ack = float((load_config() or {}).get("log_ack_ts") or 0)
17
- if _ack > 0:
18
- _cut = max(_cut, _ack)
19
- except Exception:
20
- pass"""
21
- if old in d:
22
- d = d.replace(old, new, 1)
23
- print("窗口下界已改")
24
- else:
25
- print("窗口下界:未找到锚点(可能已改过)")
26
-
27
- old2 = """ if args.cmd == "logs":
28
- lvl = None if args.all else args.level"""
29
- new2 = """ if args.cmd == "logs":
30
- if getattr(args, "ack", False):
31
- import time as _t
32
- with _locked(HOME / "config.json"):
33
- _cfg_ack = load_config() or {}
34
- _cfg_ack["log_ack_ts"] = int(_t.time())
35
- atomic_json(HOME / "config.json", _cfg_ack)
36
- print("已确认:doctor 的 log-anomalies 从此只统计这之后的日志。")
37
- return 0
38
- lvl = None if args.all else args.level"""
39
- if old2 in d:
40
- d = d.replace(old2, new2, 1)
41
- print("logs ack 已加")
42
- else:
43
- print("logs ack:未找到锚点")
44
-
45
- p.write_text(d, encoding="utf-8")
@@ -1,28 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:标记 #43/#46/#48/#49/#52/#53 为已做(可删)。"""
3
- import re
4
- from pathlib import Path
5
-
6
- p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\docs\审核改进待办.md")
7
- lines = p.read_text(encoding="utf-8").splitlines()
8
-
9
- MARKS = {
10
- "| 43 |": "✅ 已做:`brain.py abstract stamp-recent`;没配 `config summary` 时**拒绝造假**(返回 reason)",
11
- "| 46 |": "✅ 已做:`brain.py timeline --days 30`(梦/人格快照/教训/缺口并成一条线)",
12
- "| 48 |": "✅ 已做(opt-in):`config affinity_drift=true` 时 tags/entities 命中人格 traits 给 ≤+15% 亲和加成",
13
- "| 49 |": "✅ 已做:`shadow stamp/stamp-recent/audit`;相似度=余弦×逐维相对一致度(纯余弦对小向量不敏感)",
14
- "| 52 |": "✅ 已做(命令驱动):`seed make/list`,kind=seed 不参与日常检索",
15
- "| 53 |": "✅ 已做:`loops build` 连 `same_loop` 边,幂等",
16
- }
17
- hit = 0
18
- for i, ln in enumerate(lines):
19
- for prefix, note in MARKS.items():
20
- if ln.startswith(prefix) and "⬜" in ln:
21
- lines[i] = re.sub(r"⬜[^|]*\|$", note + " |", ln)
22
- hit += 1
23
- p.write_text("\n".join(lines) + "\n", encoding="utf-8")
24
-
25
- d = p.read_text(encoding="utf-8")
26
- done = len(re.findall(r"^\|\s*[A-Z]?\d+\s*\|.*✅", d, re.M))
27
- todo = len(re.findall(r"^\|\s*[A-Z]?\d+\s*\|.*⬜", d, re.M))
28
- print(f"标记 {hit} 行 | ✅{done} / ⬜{todo}")
@@ -1,32 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:标记 #44/#45/#47/#50 已做(可删)。"""
3
- import re
4
- from pathlib import Path
5
-
6
- p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\docs\审核改进待办.md")
7
- lines = p.read_text(encoding="utf-8").splitlines()
8
-
9
- MARKS = {
10
- "| 44 |": ("✅ 已做(默认开):`scripts/delivery.py` 的 `persona_pool`——kind=seed/gap 或 "
11
- "tags 命中 persona/evolve/self 的记忆**默认不进任务上下文**,只在自省类查询放行;"
12
- "配置可关(`persona_pool: false`)"),
13
- "| 45 |": ("✅ 已做(**代理,非真信号**):`priorCooldownSec=300`——同一 digest 的 prior 查询 "
14
- "5 分钟内不重复跑(`graphile`…见 plugin.js)。宿主不暴露命中率,这是最接近的降频代理;"
15
- "真信号要等宿主提供"),
16
- "| 47 |": ("✅ 已做(opt-in):记忆可带 `trigger {topic_kinds, terms, aggressiveness}`,"
17
- "命中当前上下文时最多 +18%(`delivery_trigger: true` 才启用)"),
18
- "| 50 |": ("✅ 已做(opt-in):写 mistake/insight 时预埋 `hooks {near, far}`(词法近似),"
19
- "命中时最多 +15%(`delivery_hooks: true` 才启用)"),
20
- }
21
- hit = 0
22
- for i, ln in enumerate(lines):
23
- for prefix, note in MARKS.items():
24
- if ln.startswith(prefix) and "⬜" in ln:
25
- lines[i] = re.sub(r"⬜[^|]*\|$", note + " |", ln)
26
- hit += 1
27
- p.write_text("\n".join(lines) + "\n", encoding="utf-8")
28
-
29
- d = p.read_text(encoding="utf-8")
30
- done = len(re.findall(r"^\|\s*[A-Z]?\d+\s*\|.*✅", d, re.M))
31
- todo = len(re.findall(r"^\|\s*[A-Z]?\d+\s*\|.*⬜", d, re.M))
32
- print(f"标记 {hit} 行 | ✅{done} / ⬜{todo}")
@@ -1,26 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:标记 ACT-R 与优先级重放为已完成(可删)。"""
3
- from pathlib import Path
4
-
5
- p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\docs\审核改进待办.md")
6
- lines = p.read_text(encoding="utf-8").splitlines()
7
-
8
- ACT_R = ("| ACT-R base-level activation | M · ✅ **已做(2026-11-30)** | "
9
- "`mem_score.actr_base_level()`:B = ln(Σ t_j^-0.5),用 access_count/last_access/created "
10
- "近似均匀间隔,sigmoid 压到 0~1;recall 里作为小幅加成 min(0.08, 0.05·B)——作用是"
11
- "「同样相关同样新鲜时,想过 5 次的略靠前」,不是让高频霸榜。"
12
- "实测 5 次近访 0.666 > 1 次 0.5 > 5 次但 20 天前 0.502 > 从未 0;4 条测试 |")
13
- REPLAY = ("| 优先级重放 | S · ✅ **已做(2026-11-30)** | `replay_recent` 原来纯按时间截断,"
14
- "「昨晚 2 小时全调同一个 bug」会把重放集塞满同质噪音。现在只读地做三道裁剪:"
15
- "①与已选 jaccard≥0.75 跳过;②同 kind 最多占一半;③不足 limit 时按原序回填(条数不缩水) |")
16
-
17
- hit = 0
18
- for i, ln in enumerate(lines):
19
- if ln.startswith("| ACT-R base-level activation |"):
20
- lines[i] = ACT_R
21
- hit += 1
22
- elif ln.startswith("| 优先级重放 |"):
23
- lines[i] = REPLAY
24
- hit += 1
25
- p.write_text("\n".join(lines) + "\n", encoding="utf-8")
26
- print("已更新行数:", hit)
@@ -1,31 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:更新 do-later 状态(TextRank/persona/熔断/幂等 已做)(可删)。"""
3
- import re
4
- from pathlib import Path
5
-
6
- p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\docs\审核改进待办.md")
7
- lines = p.read_text(encoding="utf-8").splitlines()
8
-
9
- MARKS = {
10
- "| TextRank / LexRank |": ("✅ 已做(opt-in):`summary.ranker=textrank` 时用 TextRank 选句替代"
11
- "\"最后 3 条\";位置无关,避免关键句因不在末尾被丢"),
12
- "| persona drift 向量散度 |": ("✅ 已做:diff 带 `magnitude`(数值按 0-100 归一),stability 除处数外"
13
- "再按幅度扣 0~20;返回 `magnitude{total,top3}`"),
14
- "| 熔断推广到 rerank/session-rag |": ("✅ 已做(rerank):`rerank.fail_cooldown_sec=300`,失败后冷却期内"
15
- "不再发起调用——单机没起 reranker 时不再每次白等 3s(实测 0.4ms 早退)"),
16
- "| 幂等键 |": ("✅ 已做(**默认关**):`session_import_idempotent` 开启后按"
17
- "「源文件+会话+行内容」哈希去重,重跑同一次导出不重复入库;"
18
- "默认关因为导入的既有语义是加法(两个文件同内容都该进)"),
19
- }
20
- hit = 0
21
- for i, ln in enumerate(lines):
22
- for prefix, note in MARKS.items():
23
- if ln.startswith(prefix) and "⬜" in ln:
24
- lines[i] = re.sub(r"⬜[^|]*\|$", note + " |", ln)
25
- hit += 1
26
- p.write_text("\n".join(lines) + "\n", encoding="utf-8")
27
-
28
- d = p.read_text(encoding="utf-8")
29
- done = len(re.findall(r"^\|\s*[A-Z]?\d+\s*\|.*✅", d, re.M))
30
- todo = len(re.findall(r"^\|\s*[A-Z]?\d+\s*\|.*⬜", d, re.M))
31
- print(f"更新 {hit} 行 | ✅{done} / ⬜{todo}")
@@ -1,16 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:把仅剩的搬运脚本自己也挪进 _scratch(可删)。"""
3
- import shutil
4
- from pathlib import Path
5
-
6
- ROOT = Path(r"E:\丁厚同\文档\程序\灵枢-skill")
7
- src = ROOT / "scripts" / "_tmp_cleanup_move.py"
8
- scratch = ROOT / "scripts" / "_scratch"
9
- scratch.mkdir(parents=True, exist_ok=True)
10
- if src.is_file():
11
- shutil.move(str(src), str(scratch / src.name))
12
- print("moved:", src.name)
13
- else:
14
- print("已不存在")
15
- print("_scratch 文件数 =", len(list(scratch.iterdir())))
16
- print("scripts 下剩余 _tmp_* =", [p.name for p in (ROOT / "scripts").glob("_tmp_*")])
@@ -1,22 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:给 occ 解析器加 apply 子命令(可删)。"""
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
- old = ''' _os_v = _os.add_parser("violation", help="只看预期违背(负向=失望 / 正向=释然)")
9
- _os_v.add_argument("text")'''
10
- new = ''' _os_v = _os.add_parser("violation", help="只看预期违背(负向=失望 / 正向=释然)")
11
- _os_v.add_argument("text")
12
- _os_a = _os.add_parser("apply", help="识别 OCC 并联动七情六欲(情绪+欲望)")
13
- _os_a.add_argument("text")
14
- _os_a.add_argument("--importance", type=float, default=0.6)
15
- _os_a.add_argument("--dry-run", action="store_true")'''
16
- if 'accept' or "_os_a" not in d:
17
- if "_os_a" not in d:
18
- d = d.replace(old, new, 1)
19
- d = d.replace('p_occ = sub.add_parser("occ", help="OCC 结构情绪:认\'承诺没做到/担心没发生\'这类结构")',
20
- 'p_occ = sub.add_parser("occ", help="OCC 结构情绪:认\'承诺没做到/担心没发生\',可联动七情六欲")', 1)
21
- p.write_text(d, encoding="utf-8")
22
- print("apply 子命令已加")
@@ -1,108 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:给 occ.py 加七情六欲联动(可删)。"""
3
- from pathlib import Path
4
-
5
- p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\occ.py")
6
- d = p.read_text(encoding="utf-8")
7
-
8
- APPEND = '''
9
-
10
- # ---------------------------------------------------------------- 联动七情六欲
11
-
12
- # OCC → 灵枢七情(组 + 具体情绪);polarity 给 emotion_evaluate 用
13
- EMOTION_MAP = {
14
- "失望": ("哀", "失落", "negative"),
15
- "释然": ("静", "安心", "positive"),
16
- "满意": ("喜", "满足", "positive"),
17
- "感激": ("爱", "感动", "positive"),
18
- "愤怒": ("怒", "生气", "negative"),
19
- "焦虑": ("惧", "焦虑", "negative"),
20
- }
21
-
22
- # OCC → 六欲增减(正=满足/上调,负=受挫/下调)
23
- DESIRE_DELTA = {
24
- "失望": {"成就欲": -8.0, "连接欲": -2.0},
25
- "释然": {"安全欲": 10.0},
26
- "满意": {"成就欲": 10.0},
27
- "感激": {"连接欲": 12.0},
28
- "愤怒": {"连接欲": -6.0, "掌控欲": -3.0},
29
- "焦虑": {"安全欲": -10.0},
30
- }
31
-
32
-
33
- def to_emotion(occ_name: str) -> dict:
34
- """OCC 类 → 七情三元组(组/具体情绪/极性)。"""
35
- g = EMOTION_MAP.get(str(occ_name or ""))
36
- if not g:
37
- return {"group": "", "emotion": "", "polarity": ""}
38
- return {"group": g[0], "emotion": g[1], "polarity": g[2]}
39
-
40
-
41
- def to_desires(occ_name: str) -> dict:
42
- """OCC 类 → 六欲增减。"""
43
- return dict(DESIRE_DELTA.get(str(occ_name or ""), {}))
44
-
45
-
46
- def apply_emotion(text: str, importance: float = 0.6, dry_run: bool = False) -> dict:
47
- """识别 OCC 并落到灵枢的情绪/欲望上(这就是"联动")。
48
-
49
- - 情绪:走 `emotion_evaluate(event, polarity, importance, why)`,why 里带 OCC 标签便于追溯;
50
- - 欲望:走 `desire_nudge(changes)` 增减六欲。
51
- dry_run 只算不改。识别不出 OCC 时不动任何状态(不瞎记情绪)。
52
- """
53
- import brain
54
- d = label(text)
55
- occ_name = d.get("occ") or ""
56
- if not occ_name:
57
- return {"ok": False, "reason": "没识别出 OCC 情绪,不改状态", "occ": d}
58
- emo = to_emotion(occ_name)
59
- delta = to_desires(occ_name)
60
- out = {"ok": True, "occ": occ_name, "direction": d.get("direction"),
61
- "emotion": emo, "desires": delta, "dry_run": dry_run}
62
- if dry_run:
63
- return out
64
- try:
65
- out["emotion_result"] = brain.emotion_evaluate(
66
- text, polarity=emo["polarity"], importance=float(importance),
67
- why=f"OCC:{occ_name}")
68
- except Exception as exc: # noqa: BLE001
69
- out["emotion_error"] = str(exc)[:120]
70
- if delta:
71
- try:
72
- out["desire_result"] = brain.desire_nudge(delta)
73
- except Exception as exc: # noqa: BLE001
74
- out["desire_error"] = str(exc)[:120]
75
- return out
76
-
77
-
78
- def render_apply(r: dict) -> list:
79
- if not r.get("ok"):
80
- return [f"跳过:{r.get('reason')}(OCC={r.get('occ', {}).get('occ') or '无'})"]
81
- emo = r.get("emotion") or {}
82
- lines = [f"OCC {r['occ']}({r.get('direction') or '—'})→ 七情「{emo.get('group')}·{emo.get('emotion')}」"]
83
- if r.get("desires"):
84
- lines.append(" 六欲:" + "、".join(f"{k}{v:+.0f}" for k, v in r["desires"].items()))
85
- if r.get("dry_run"):
86
- lines.append(" (干跑,未改动状态)")
87
- for k in ("emotion_error", "desire_error"):
88
- if r.get(k):
89
- lines.append(f" ⚠ {k}: {r[k]}")
90
- return lines
91
- '''
92
-
93
- if "def apply_emotion" not in d:
94
- d = d.rstrip() + APPEND
95
- # run() 里加 apply 动作
96
- old = ''' if action == "violation":'''
97
- new = ''' if action == "apply":
98
- for line in render_apply(apply_emotion(
99
- text, importance=float(getattr(args, "importance", 0.6) or 0.6),
100
- dry_run=bool(getattr(args, "dry_run", False)))):
101
- print(line)
102
- return 0
103
- if action == "violation":'''
104
- d = d.replace(old, new, 1)
105
- p.write_text(d, encoding="utf-8")
106
- print("已加七情六欲联动")
107
- else:
108
- print("已存在")
@@ -1,54 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:优化 recall 联想性能——减少重复 I/O、排序与冗余遍历(可删)。"""
3
- from pathlib import Path
4
-
5
- p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\memory.py")
6
- d = p.read_text(encoding="utf-8")
7
-
8
- # 1) 把 load_assoc 提到循环外(减少 O(n²) 级的 I/O)
9
- # 2) 把 score += 的内层循环换成 dict 查找(从 O(m*n) 降到 O(m))
10
- # 3) 合并重复的 sort
11
-
12
- old = ''' # 显式联想:记忆之间已有的关联边把邻居也带起来("提到 A 就想起 B")
13
- # mode=fast 跳过关联扩散:低延迟模式只认词面直接命中(#27)。
14
- if (not READONLY or _assoc_file().exists()) and eff_mode != "fast":
15
- for r in load_assoc():
16
- if r["src"] in top_ids and r["dst"] not in top_ids:
17
- w = _num(r.get("weight"), 1)
18
- for item in scored[len(top):]:
19
- if item[0]["id"] == r["dst"]:
20
- item[1] += min(0.12, 0.04 * w)
21
- elif r["dst"] in top_ids and r["src"] not in top_ids:
22
- w = _num(r.get("weight"), 1)
23
- for item in scored[len(top):]:
24
- if item[0]["id"] == r["src"]:
25
- item[1] += min(0.12, 0.04 * w)
26
-
27
- scored.sort(key=lambda x: x[1], reverse=True)'''
28
-
29
- new = ''' # 显式联想:记忆之间已有的关联边把邻居也带起来("提到 A 就想起 B")
30
- # mode=fast 跳过关联扩散:低延迟模式只认词面直接命中(#27)。
31
- if (not READONLY or _assoc_file().exists()) and eff_mode != "fast":
32
- # 优化(2026-11-30):load_assoc 提到循环外,且把待加分项索引化
33
- # 避免在 assoc 循环里套 O(n) 的 ID 查找。
34
- _rest_map = {x[0]["id"]: x for x in scored[len(top):]}
35
- for r in load_assoc():
36
- sid, did = r.get("src"), r.get("dst")
37
- target_id = None
38
- if sid in top_ids and did in _rest_map:
39
- target_id = did
40
- elif did in top_ids and sid in _rest_map:
41
- target_id = sid
42
-
43
- if target_id:
44
- w = _num(r.get("weight"), 1)
45
- _rest_map[target_id][1] += min(0.12, 0.04 * w)
46
-
47
- scored.sort(key=lambda x: x[1], reverse=True)'''
48
-
49
- if old in d:
50
- d = d.replace(old, new, 1)
51
- p.write_text(d, encoding="utf-8")
52
- print("recall 联想逻辑已优化")
53
- else:
54
- print("未找到目标代码,可能已变动")
@@ -1,26 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:面板数据真实性对账 + 看 source 块(可删)。"""
3
- import json
4
- import sys
5
-
6
- sys.path.insert(0, r"E:\丁厚同\文档\程序\灵枢-skill\scripts")
7
- import brain
8
- import panel_server
9
-
10
- src = open(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\panel_server.py", encoding="utf-8").read()
11
- i = src.find('"source": {')
12
- print("=== overview 的 source 块 ===")
13
- print(src[i:i + 460])
14
-
15
- ov = panel_server.overview()
16
- print("\n=== 面板 overview 关键字段 vs 真实数据 ===")
17
- st = brain.stats()
18
- print("panel.layer_counts =", ov.get("layer_counts"))
19
- print("brain.stats =", {k: st.get(k) for k in ("hippo", "cortex", "dust", "archive")})
20
- print("panel.source =", ov.get("source"))
21
- wl = brain._water_level()
22
- print("panel.water.pct =", (ov.get("water") or {}).get("pct"),
23
- "| status.water.pct =", wl.get("pct"))
24
- print("panel.memories 条数 =", len(ov.get("memories") or []),
25
- "(注意:overview 只返回最近 80 条,不是全部)")
26
- print("panel.stats 是否等于 brain.stats:", ov.get("stats") == st)
@@ -1,65 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:§2#3 / §4.1 B4 / §4 RSS 状态落地(可删)。"""
3
- import re
4
- from pathlib import Path
5
-
6
- ROOT = Path(r"E:\丁厚同\文档\程序\灵枢-skill")
7
- p = ROOT / "docs" / "审核改进待办.md"
8
- d = p.read_text(encoding="utf-8")
9
-
10
- d = d.replace("| **3** | **BM25 词频 + 长度归一** | M · ⬜ **待做(需 bench 前后对比)** |",
11
- "| **3** | **BM25 词频 + 长度归一** | M · ✅ **已做(2026-11-29,含 bench 前后对比)** |", 1)
12
-
13
- d = d.replace("| ⬜ 待修 |\n\n**明确不借鉴", "| ✅ **已修**(2026-11-29,默认关闭) |\n\n**明确不借鉴", 1)
14
-
15
- SEC = """
16
- ### §2#3 BM25 / §4.1 B4 / §4 RSS 落地(2026-11-29 第三批)
17
-
18
- - **§2#3 BM25 ✅**:`mem_score.terms()` 改返回 `TermSet`(**仍是 set**,`&`/`len()`/jaccard 照旧),
19
- 额外带 `counts` 与 `length`;`relevance()` 有词频就走 `bm25(k1=1.2, b=0.75)`,没有则退回原余弦。
20
- `memory.recall` 传入候选集的平均文档长度。
21
- **bench 前后对比**(`bench --quick`):remember ×0.98、recall ×0.99、inject ×0.87、doctor ×0.99 ——
22
- **无性能回退**;行为上短而精准的命中被抬高、长而啰嗦的被长度归一下压(实测 0.60 vs 0.057)。
23
- `tests/test_bm25_relevance.py` 5 条。
24
- - **§4.1 B4 周期性语气提示 ✅(默认关闭)**:`style_check.hint()` 从近期回复提炼一句
25
- `【语气】…`(平均句长/列表占比 + 具体建议),**6 小时缓存**写 `config.style_hint_cache`;
26
- 注入侧只有 `config style_hint: true` 才追加(`_bill["sec"]="rules"`)。
27
- **默认关闭**——它属于注入主链路改动,水位 >50% 时不该默认生效。实测:默认开关时注入包无该块。
28
- - **§4 P2-1 RSS 摄入 ✅(窄口径)**:新增 `scripts/rss_ingest.py` + `brain.py rss ingest`
29
- (`--file` / `--url-list` / `--limit` / `--dry-run`)。零依赖(`xml.etree`+`urllib`),
30
- 支持 RSS 2.0 与 Atom,按 link 哈希去重(`rss_seen.json`,只留最近 5000 条),坏 XML/断网只跳过。
31
- **不做定时抓取**——想自动化就把它挂到你自己的计划任务里。实测:干跑 0 写入 → 实跑写 2 条 →
32
- 重跑幂等 0 条(测试产生的两条已 `forget` 到淡忘区)。`tests/test_rss_ingest.py` 6 条。
33
- **踩坑记录**:`e.find(summary) or e.find(content)` 在 ElementTree 里是错的——**空元素布尔值为 False**,
34
- 会让一个没有子节点的 `<summary>` 落到 `content` 上(Atom 摘要因此变空);改成显式判 `None`。
35
- """
36
- if "### §2#3 BM25" not in d:
37
- d = d.rstrip() + "\n" + SEC
38
- print("已追加第三批落地记录")
39
- p.write_text(d, encoding="utf-8")
40
-
41
- counts = {"done": 0, "todo": 0, "excl": 0}
42
- for ln in d.splitlines():
43
- if not re.match(r"^\|\s*[A-Z]?\d+\s*\|", ln):
44
- continue
45
- if "✅" in ln:
46
- counts["done"] += 1
47
- elif "⬜" in ln:
48
- counts["todo"] += 1
49
- elif "🔍" in ln:
50
- counts["excl"] += 1
51
- stat = (f"> **状态统计(编号任务行)**:✅ {counts['done']} 已修 / "
52
- f"⬜ {counts['todo']} 待修 / 🔍 {counts['excl']} 已排除(含 §7/§8)")
53
- d2 = re.sub(r"> \*\*状态统计(编号任务行)\*\*[^\n]*", stat, d, count=1)
54
- p.write_text(d2, encoding="utf-8")
55
- print(stat)
56
-
57
- # SKILL.md 命令表补 rss
58
- sk = ROOT / "SKILL.md"
59
- sd = sk.read_text(encoding="utf-8")
60
- anchor = "python scripts/brain.py archive show|search|restore|run|dust"
61
- line = ("python scripts/brain.py rss ingest --file feed.xml [--url-list urls.txt] [--dry-run] "
62
- "# §4:RSS/Atom 摄入(窄口径,不自动跑)")
63
- if "rss ingest" not in sd and anchor in sd:
64
- sk.write_text(sd.replace(anchor, anchor + "\n" + line, 1), encoding="utf-8")
65
- print("SKILL.md 已补 rss ingest")