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,82 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:给 load_all 增加进程内缓存(可删)。"""
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) 顶部加模块级缓存变量
9
- old_defs = "DUST_ARCHIVE_KEEP_DEFAULT = 200"
10
- new_defs = '''DUST_ARCHIVE_KEEP_DEFAULT = 200
11
- _load_cache = None # 进程内记忆缓存
12
- _load_cache_ts = 0 # 缓存的时间戳
13
- _load_cache_files = {} # 记录各层文件的 mtime'''
14
- if "_load_cache = None" not in d:
15
- d = d.replace(old_defs, new_defs, 1)
16
- print("缓存变量已加")
17
-
18
- # 2) 重写 load_all 加入缓存逻辑
19
- old_load = """def load_all() -> list:
20
- \"\"\"三层热层合并;缺 id 的 dict 记录**补一个稳定 id**,而不是丢弃。
21
-
22
- 为什么不丢:`_locked_save_all` 专门保留 `no_id`、`dream.py:182` 也明确承诺
23
- \"这些记录会原样保留在库,不会被 save_all 丢掉\"。但早期版本在这里直接略过
24
- 它们 → 任何一次 `save_all(load_all())` 就把它们永远抹掉
25
- (审计 memory.py:686,承诺与实际相反)。
26
-
27
- 现在按内容哈希补 id:同一条记录重复 load 得到同一个 id(幂等),于是它能
28
- 安全穿过 read-modify-write 而不蒸发,也不会每次 load 都长出重复副本。
29
- 仍然跳过非 dict 的记录(无法附加字段,也读不出 id)。
30
- \"\"\"
31
- raw = (read_jsonl(HOME / "hippocampus.jsonl")
32
- + read_jsonl(HOME / "cortex.jsonl")
33
- + read_jsonl(HOME / "dust.jsonl"))
34
- good, fixed, bad = [], 0, 0
35
- for r in raw:
36
- if not isinstance(r, dict):
37
- bad += 1
38
- continue
39
- if not r.get("id"):
40
- text = str(r.get("text") or "")
41
- r["id"] = "m_" + hashlib.sha1(text.encode("utf-8", "replace")).hexdigest()[:12]
42
- fixed += 1
43
- good.append(r)
44
- return good"""
45
-
46
- new_load = """def load_all() -> list:
47
- \"\"\"三层热层合并;缺 id 的 dict 记录**补一个稳定 id**,并带进程内缓存(2026-11-30)。\"\"\"
48
- global _load_cache, _load_cache_ts, _load_cache_files
49
- # 检查各层文件 mtime,任一变动则失效。
50
- _names = (\"hippocampus.jsonl\", \"cortex.jsonl\", \"dust.jsonl\")
51
- try:
52
- _cur_mtimes = {n: (HOME / n).stat().st_mtime for n in _names if (HOME / n).exists()}
53
- except OSError:
54
- _cur_mtimes = {}
55
-
56
- if _load_cache is not None and _cur_mtimes == _load_cache_files:
57
- return [dict(m) for m in _load_cache] # 返回副本防外部修改污染缓存
58
-
59
- raw = []
60
- for n in _names:
61
- raw.extend(read_jsonl(HOME / n))
62
-
63
- good = []
64
- for r in raw:
65
- if not isinstance(r, dict):
66
- continue
67
- if not r.get(\"id\"):
68
- text = str(r.get(\"text\") or \"\")
69
- r[\"id\"] = \"m_\" + hashlib.sha1(text.encode(\"utf-8\", \"replace\")).hexdigest()[:12]
70
- good.append(r)
71
-
72
- _load_cache = good
73
- _load_cache_files = _cur_mtimes
74
- _load_cache_ts = time.time()
75
- return [dict(m) for m in good]"""
76
-
77
- if old_load in d:
78
- d = d.replace(old_load, new_load, 1)
79
- p.write_text(d, encoding="utf-8")
80
- print("load_all 已缓存")
81
- else:
82
- print("load_all 锚点未找到")
@@ -1,40 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:清理插件市场 journal 里 lingshu 的陈旧记录(§0.2 的修法)。
3
-
4
- 按用户规矩:先备份到「垃圾桶」,再改原文件(这里改的是**行**,不是删文件)。
5
- """
6
- import glob
7
- import os
8
- import shutil
9
- import time
10
- from pathlib import Path
11
-
12
- home = os.path.expanduser("~")
13
- trash = Path(r"E:\丁厚同\文档\程序\灵枢-skill\垃圾桶")
14
- trash.mkdir(parents=True, exist_ok=True)
15
- stamp = time.strftime("%Y%m%d_%H%M%S")
16
-
17
- pat = os.path.join(home, ".*", "profiles", "desktop", ".*market", "*compatibility*.journal")
18
- files = glob.glob(pat)
19
- print("journal 数:", len(files))
20
- total_removed = 0
21
- for f in files:
22
- p = Path(f)
23
- lines = p.read_text(encoding="utf-8", errors="replace").splitlines()
24
- keep = [l for l in lines if "lingshu" not in l]
25
- removed = len(lines) - len(keep)
26
- if removed == 0:
27
- print(f" {p.name}: 没有 lingshu 行,跳过")
28
- continue
29
- bak = trash / f"{p.name}.{stamp}.bak"
30
- shutil.copy2(p, bak)
31
- p.write_text("\n".join(keep) + ("\n" if keep else ""), encoding="utf-8")
32
- total_removed += removed
33
- print(f" {p.name}: 删 {removed} 行(原 {len(lines)} → {len(keep)});备份 {bak.name}")
34
-
35
- note = trash / "_来源记录.txt"
36
- with note.open("a", encoding="utf-8") as f:
37
- f.write(f"[{stamp}] 插件市场 journal 清理 lingshu 行 {total_removed} 条 | 来源: "
38
- f"{os.path.join(home, '.*', 'profiles', 'desktop', '.*market')} | "
39
- "原因: 市场显示旧版本,§0.2 修法(清缓存触发重查)\n")
40
- print("合计删除行:", total_removed)
@@ -1,81 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:把 .pruned 隔离区搬到仓库垃圾桶(只移不删 + 留来源记录)。
3
-
4
- 规矩:任何"清理"都不物理删除——移到 `灵枢-skill/垃圾桶/<时间戳>_<来源>/`,
5
- 并在该目录写 `来源记录.md`(原路径、文件数、总大小、为什么移)。
6
- """
7
- from __future__ import annotations
8
-
9
- import shutil
10
- import sys
11
- import time
12
- from pathlib import Path
13
-
14
- sys.path.insert(0, r"E:\丁厚同\文档\程序\灵枢-skill\scripts")
15
- import core
16
-
17
- REPO = Path(r"E:\丁厚同\文档\程序\灵枢-skill")
18
- TRASH = REPO / "垃圾桶"
19
- STAMP = time.strftime("%Y%m%d_%H%M%S")
20
-
21
- candidates = []
22
- # 1) 安全快照隔离区
23
- candidates.append((Path(core.HOME) / ".safety" / ".pruned", "安全快照-pruned"))
24
- # 2) 备份产物的隔离区(可能在 HOME/backups/.pruned,也可能在跨卷备份根)
25
- for base in (Path(core.HOME), Path("D:/brain-memory-backups"), Path("E:/brain-memory-backups")):
26
- p = base / "backups" / ".pruned"
27
- if p.is_dir() and p not in [c[0] for c in candidates]:
28
- candidates.append((p, "备份-pruned"))
29
- p2 = base / ".pruned"
30
- if p2.is_dir() and p2 not in [c[0] for c in candidates]:
31
- candidates.append((p2, "备份产物-pruned"))
32
-
33
- moved_total = 0
34
- size_total = 0
35
- report = []
36
- for src, label in candidates:
37
- if not src.is_dir():
38
- continue
39
- files = [f for f in src.rglob("*") if f.is_file()]
40
- if not files:
41
- continue
42
- size = sum(f.stat().st_size for f in files)
43
- dst = TRASH / f"{STAMP}_{label}"
44
- dst.mkdir(parents=True, exist_ok=True)
45
- n = 0
46
- for f in files:
47
- rel = f.relative_to(src)
48
- target = dst / rel
49
- target.parent.mkdir(parents=True, exist_ok=True)
50
- try:
51
- shutil.move(str(f), str(target))
52
- n += 1
53
- except OSError as e:
54
- print(f" 跳过 {f}: {e}")
55
- # 清掉空目录
56
- for d in sorted([d for d in src.rglob("*") if d.is_dir()], reverse=True):
57
- try:
58
- d.rmdir()
59
- except OSError:
60
- pass
61
- moved_total += n
62
- size_total += size
63
- report.append((label, str(src), n, size, str(dst)))
64
-
65
- TRASH.mkdir(exist_ok=True)
66
- if report:
67
- rec = TRASH / f"{STAMP}_来源记录.md"
68
- lines = [f"# 清理记录 {STAMP}", "",
69
- "按「只移不删」规矩:以下文件从隔离区移到垃圾桶,可随时搬回。", "",
70
- "| 来源 | 原路径 | 文件数 | 大小 | 去向 |", "|---|---|---|---|---|"]
71
- for label, src, n, size, dst in report:
72
- lines.append(f"| {label} | `{src}` | {n} | {size/1024/1024:.1f}MB | `{dst}` |")
73
- lines.append("")
74
- lines.append("为什么移:doctor `disk-usage` 报快照 `.pruned` 超 30MB 阈值;")
75
- lines.append("这些是写盘失败时被隔离的半成品 zip / 旧快照,确认无用后清理,原始数据不受影响。")
76
- rec.write_text("\n".join(lines) + "\n", encoding="utf-8")
77
- print(f"来源记录:{rec}")
78
-
79
- print(f"共移动 {moved_total} 个文件 / {size_total/1024/1024:.1f}MB → {TRASH}")
80
- for label, src, n, size, dst in report:
81
- print(f" {label}: {n} 个 / {size/1024/1024:.1f}MB")
@@ -1,39 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:按用户要求,将已完成的待办文档移入垃圾桶(只移不删)。"""
3
- import shutil
4
- import time
5
- from pathlib import Path
6
-
7
- REPO = Path(r"E:\丁厚同\文档\程序\灵枢-skill")
8
- TRASH = REPO / "垃圾桶"
9
- STAMP = time.strftime("%Y%m%d_%H%M%S")
10
-
11
- # 待办文档及其相关阶段性方案
12
- targets = [
13
- REPO / "docs" / "审核改进待办.md",
14
- REPO / "docs" / "重构方案-20261130.md"
15
- ]
16
-
17
- moved = []
18
- for p in targets:
19
- if p.exists():
20
- dst_dir = TRASH / f"{STAMP}_待办清理"
21
- dst_dir.mkdir(parents=True, exist_ok=True)
22
- dst_path = dst_dir / p.name
23
- try:
24
- shutil.move(str(p), str(dst_path))
25
- moved.append((str(p), str(dst_path)))
26
- except Exception as e:
27
- print(f"移动失败 {p.name}: {e}")
28
-
29
- if moved:
30
- rec = TRASH / f"{STAMP}_清理记录.md"
31
- lines = [f"# 文档清理记录 {STAMP}", "",
32
- "所有待办事项已确认为 ✅ 已完成,按用户要求移入垃圾桶。", "",
33
- "| 原路径 | 去向 |", "|---|---|"]
34
- for src, dst in moved:
35
- lines.append(f"| `{src}` | `{dst}` |")
36
- rec.write_text("\n".join(lines) + "\n", encoding="utf-8")
37
- print(f"已清理 {len(moved)} 份文档,记录见:{rec}")
38
- else:
39
- print("未发现待清理文档。")
@@ -1,17 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:对比 position vs textrank 的"已做"段(可删)。"""
3
- import sys
4
-
5
- sys.path.insert(0, r"E:\丁厚同\文档\程序\灵枢-skill\scripts")
6
- import summarizer as s
7
-
8
- turns = [
9
- {"role": "user", "text": "帮我查下发布流程"},
10
- {"role": "assistant", "text": "发布前要跑测试、生成产物、核对版本。"},
11
- {"role": "assistant", "text": "预算只有 3 天,所以这周必须发出去。"},
12
- {"role": "assistant", "text": "另外记得备份。"},
13
- ]
14
- for mode in ("position", "textrank"):
15
- txt = s.extractive_fallback(turns, 400, ranker=mode)
16
- done = [ln for ln in txt.splitlines() if ln.startswith("- ")][:3]
17
- print(f"{mode:<9}", done)
@@ -1,35 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:do-later 落地记录(可删)。"""
3
- import time
4
- from pathlib import Path
5
-
6
- p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\docs\审核改进待办.md")
7
- d = p.read_text(encoding="utf-8")
8
-
9
- SEC = """
10
- ### do-later 落地记录(2026-11-30)
11
-
12
- do-later 表原来只有成本列、没有状态列,容易误以为"都没做"。实际状态:
13
-
14
- | 项 | 状态 |
15
- |---|---|
16
- | RRF 倒数排名融合 | ✅ `config rrf_fusion=true`(名次融合替代 max 抢占) |
17
- | MMR 最大边际相关 | ✅ `config mmr_diversity=true`(λ=`mmr_lambda` 默认 0.75) |
18
- | ACT-R base-level activation | ✅ 频次入打分(`mem_score.actr_base_level`,小额加成 ≤0.08) |
19
- | 优先级重放 | ✅ `replay_recent` 做相似去重 + 每类上限 + 回填 |
20
- | TextRank / LexRank | ✅ `summary.ranker=textrank`(TextRank 选句替代"最后 3 条") |
21
- | persona drift 向量散度 | ✅ diff 带 `magnitude`,stability 按幅度扣分(+1 与 +30 不再同分) |
22
- | 熔断推广到 rerank | ✅ `rerank.fail_cooldown_sec=300`,失败后不再每次白等 3s |
23
- | 幂等键 | ✅ `session_import_idempotent`(**默认关**,按"源文件+会话+行"哈希去重) |
24
- | **增量分层摘要** | ⬜ **未做**(L 级,方案在 `docs/重构方案-20261130.md` 第一节) |
25
- | **Big Five 数值化** | ⬜ **未做**(M):需要先定 traits→5 维的映射表,属产品决策 |
26
- | **OCC 结构情绪** | ⬜ **未做**(M):需要先定 OCC 22 类里用哪几类、怎么触发,属产品决策 |
27
-
28
- > 后两条不是"技术做不了",是**要先定语义**(映射表 / 分类表)。定下来我半天能落。
29
- """
30
-
31
- if "### do-later 落地记录" in d:
32
- print("已存在")
33
- else:
34
- p.write_text(d.rstrip() + "\n\n" + SEC, encoding="utf-8")
35
- print("已追加 do-later 落地记录")
@@ -1,27 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:淡忘区里为什么这么多"不可归档"(可删)。"""
3
- import collections
4
- import sys
5
-
6
- sys.path.insert(0, r"E:\丁厚同\文档\程序\灵枢-skill\scripts")
7
- import brain
8
-
9
- recs = brain.load_all()
10
- dust = [m for m in recs if m.get("layer") == "dust"]
11
- print("dust 总数 =", len(dust))
12
- c = collections.Counter()
13
- for m in dust:
14
- if m.get("pinned"):
15
- c["pinned"] += 1
16
- elif m.get("verbatim"):
17
- c["verbatim"] += 1
18
- elif m.get("kind") == "identity":
19
- c["identity"] += 1
20
- elif m.get("review") == "pending":
21
- c["pending"] += 1
22
- elif not m.get("id"):
23
- c["no-id"] += 1
24
- else:
25
- c["可归档"] += 1
26
- print("分类:", dict(c))
27
- print("kind 分布:", dict(collections.Counter(m.get("kind") for m in dust).most_common(6)))
@@ -1,40 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:把 memory.py 的 star import 换成显式 import(重构方案 三-1)(可删)。"""
3
- import ast
4
- from pathlib import Path
5
-
6
- ROOT = Path(r"E:\丁厚同\文档\程序\灵枢-skill")
7
- mem = ROOT / "scripts" / "memory.py"
8
- src = mem.read_text(encoding="utf-8")
9
-
10
- # mem_score 的公开名字
11
- import sys
12
- sys.path.insert(0, str(ROOT / "scripts"))
13
- import mem_score
14
-
15
- public = sorted(n for n in dir(mem_score) if not n.startswith("_"))
16
- tree = ast.parse(src)
17
- used = {n.id for n in ast.walk(tree) if isinstance(n, ast.Name)}
18
- used |= {n.attr for n in ast.walk(tree) if isinstance(n, ast.Attribute)}
19
- need = [n for n in public if n in used]
20
-
21
- old = "from mem_score import * # noqa: E402,F401,F403"
22
- if old not in src:
23
- print("星号 import 已不存在")
24
- raise SystemExit(0)
25
-
26
- lines = []
27
- cur = "from mem_score import ("
28
- for i, n in enumerate(need):
29
- piece = n + ", "
30
- if len(cur) + len(piece) > 96:
31
- lines.append(cur.rstrip())
32
- cur = " "
33
- cur += piece
34
- lines.append(cur.rstrip().rstrip(",") + ") # noqa: E402,F401")
35
- replacement = "\n".join(lines)
36
-
37
- src2 = src.replace(old, replacement, 1)
38
- mem.write_text(src2, encoding="utf-8")
39
- print(f"显式 import {len(need)} 个名字(原星号覆盖 {len(public)} 个)")
40
- print(replacement[:200] + ("…" if len(replacement) > 200 else ""))
@@ -1,35 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:从 asar 按索引抽 compaction 相关源码(可删)。"""
3
- import glob
4
- import json
5
- import re
6
-
7
- PATH = glob.glob("D:/*/resources/app.asar")[0]
8
-
9
- with open(PATH, "rb") as f:
10
- f.seek(0)
11
- head = f.read(3 << 20) # 索引在头部区域
12
-
13
- text = head.decode("utf-8", "replace")
14
- # 该 asar 的索引是 JSON(可能在 header 里),先定位以 { 开头的 JSON 段
15
- start = text.find('{"files"')
16
- if start < 0:
17
- # 有的打包器把 header 放在别处,暴力找 "compaction.ts" 附近的 JSON
18
- i = text.find('"compaction.ts"')
19
- start = text.rfind("{", 0, i - 2000) if i > 0 else -1
20
-
21
- targets = {}
22
- for name in ("compaction.ts", "trajectory-compaction-definition.ts"):
23
- m = re.search(r'"' + re.escape(name) + r'":\{"size":(\d+),"offset":"(\d+)"', text)
24
- if m:
25
- targets[name] = (int(m.group(1)), int(m.group(2)))
26
-
27
- print("定位:", targets)
28
-
29
- with open(PATH, "rb") as f:
30
- for name, (size, off) in targets.items():
31
- f.seek(off)
32
- body = f.read(size)
33
- print("=" * 20, name, f"({size} 字节)")
34
- print(body.decode("utf-8", "replace")[:3000])
35
- print()
@@ -1,63 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:正规解析 asar 头,抽出 dsh-compaction* 包源码(可删)。
3
-
4
- asar 布局:uint32(4) + uint32(headerSize) + JSON header + 数据区。
5
- header.files 是树,节点有 {files:{...}} 或 {size, offset}。
6
- """
7
- import glob
8
- import json
9
- import struct
10
- import sys
11
-
12
- PATH = glob.glob("D:/*/resources/app.asar")[0]
13
- OUT = r"E:\丁厚同\文档\程序\灵枢-skill\scripts\_scratch\asar_compaction"
14
- import os
15
- os.makedirs(OUT, exist_ok=True)
16
-
17
- with open(PATH, "rb") as f:
18
- head = f.read(16)
19
- _a, hsize = struct.unpack("<II", head[:8])
20
- header = f.read(hsize)
21
- base = 8 + hsize
22
- meta, _end = json.JSONDecoder().raw_decode(header.decode("utf-8", "replace"))
23
-
24
- files = meta.get("files", {})
25
-
26
-
27
- def walk(node, prefix=""):
28
- for name, sub in (node or {}).items():
29
- path = f"{prefix}/{name}" if prefix else name
30
- if "files" in sub:
31
- yield from walk(sub["files"], path)
32
- else:
33
- yield path, sub
34
-
35
-
36
- targets = []
37
- for path, sub in walk(files):
38
- low = path.lower()
39
- if "compaction" not in low:
40
- continue
41
- if not (low.endswith(".js") or low.endswith(".mjs") or low.endswith(".cjs")):
42
- continue
43
- targets.append((path, sub.get("size", 0), sub.get("offset")))
44
-
45
- print(f"命中 {len(targets)} 个压缩相关 JS 文件:")
46
- for p, s, o in targets[:40]:
47
- print(f" {s:>7} {p}")
48
-
49
- # 抽前若干个(按大小升序,先看小文件了解接口)
50
- targets.sort(key=lambda x: x[1])
51
- with open(PATH, "rb") as f:
52
- for p, s, o in targets[:6]:
53
- if o is None or s > 400_000:
54
- continue
55
- f.seek(base + int(o))
56
- body = f.read(int(s))
57
- safe = p.replace("/", "__")
58
- dst = os.path.join(OUT, safe)
59
- with open(dst, "wb") as w:
60
- w.write(body)
61
- print(f"\n===== {p} ({s} 字节) → {dst} =====")
62
- txt = body.decode("utf-8", "replace")
63
- print(txt[:1600])
@@ -1,51 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:按名字精确抽 compaction 主实现(可删)。"""
3
- import glob
4
- import json
5
- import os
6
- import struct
7
-
8
- PATH = glob.glob("D:/*/resources/app.asar")[0]
9
- OUT = r"E:\丁厚同\文档\程序\灵枢-skill\scripts\_scratch\asar_compaction"
10
- os.makedirs(OUT, exist_ok=True)
11
-
12
- WANT = (
13
- "dsh-compaction/lib/index.js",
14
- "dsh-compaction-tool-result-pruner/lib/index.js",
15
- "dsh-compaction/lib/types/tool-pairing.js",
16
- )
17
-
18
- with open(PATH, "rb") as f:
19
- _a, hsize = struct.unpack("<II", f.read(8))
20
- meta, _ = json.JSONDecoder().raw_decode(f.read(hsize).decode("utf-8", "replace"))
21
- base = 8 + hsize
22
-
23
-
24
- def walk(node, prefix=""):
25
- for name, sub in (node or {}).items():
26
- path = f"{prefix}/{name}" if prefix else name
27
- if "files" in sub:
28
- yield from walk(sub["files"], path)
29
- else:
30
- yield path, sub
31
-
32
-
33
- found = {}
34
- for path, sub in walk(meta.get("files", {})):
35
- for w in WANT:
36
- if path.endswith(w):
37
- found[w] = (sub.get("size", 0), sub.get("offset"))
38
-
39
- with open(PATH, "rb") as f:
40
- for w in WANT:
41
- if w not in found:
42
- print(f"缺失: {w}")
43
- continue
44
- size, off = found[w]
45
- f.seek(base + int(off))
46
- body = f.read(int(size))
47
- dst = os.path.join(OUT, w.replace("/", "__"))
48
- with open(dst, "wb") as o:
49
- o.write(body)
50
- print(f"\n===== {w} ({size}B) =====")
51
- print(body.decode("utf-8", "replace")[:5200])
@@ -1,54 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:复用已验证的 asar 解析,抽 compaction 主实现(可删)。"""
3
- import glob
4
- import json
5
- import os
6
- import struct
7
-
8
- PATH = glob.glob("D:/*/resources/app.asar")[0]
9
- OUT = r"E:\丁厚同\文档\程序\灵枢-skill\scripts\_scratch\asar_compaction"
10
- os.makedirs(OUT, exist_ok=True)
11
-
12
- WANT = (
13
- "dsh-compaction/lib/index.js",
14
- "dsh-compaction-tool-result-pruner/lib/index.js",
15
- "dsh-compaction/lib/types/tool-pairing.js",
16
- "dsh-compaction-basic/lib/index.js",
17
- )
18
-
19
- with open(PATH, "rb") as f:
20
- head = f.read(16)
21
- _a, hsize = struct.unpack("<II", head[:8])
22
- header = f.read(hsize)
23
- base = 8 + hsize
24
- meta, _end = json.JSONDecoder().raw_decode(header.decode("utf-8", "replace"))
25
-
26
-
27
- def walk(node, prefix=""):
28
- for name, sub in (node or {}).items():
29
- path = f"{prefix}/{name}" if prefix else name
30
- if "files" in sub:
31
- yield from walk(sub["files"], path)
32
- else:
33
- yield path, sub
34
-
35
-
36
- found = {}
37
- for path, sub in walk(meta.get("files", {})):
38
- for w in WANT:
39
- if path.endswith(w):
40
- found.setdefault(w, (sub.get("size", 0), sub.get("offset")))
41
-
42
- with open(PATH, "rb") as f:
43
- for w in WANT:
44
- if w not in found:
45
- print(f"缺失: {w}")
46
- continue
47
- size, off = found[w]
48
- f.seek(base + int(off))
49
- body = f.read(int(size))
50
- dst = os.path.join(OUT, w.replace("/", "__"))
51
- with open(dst, "wb") as o:
52
- o.write(body)
53
- print(f"\n===== {w} ({size}B) =====")
54
- print(body.decode("utf-8", "replace")[:4600])
@@ -1,39 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:§14 标为已落地 + README CLI 数(可删)。"""
3
- from pathlib import Path
4
-
5
- ROOT = Path(r"E:\丁厚同\文档\程序\灵枢-skill")
6
-
7
- rp = ROOT / "README.md"
8
- d = rp.read_text(encoding="utf-8")
9
- n = d.count("82 个 CLI 命令")
10
- rp.write_text(d.replace("82 个 CLI 命令", "84 个 CLI 命令"), encoding="utf-8")
11
- print("README CLI 82→84 x", n)
12
-
13
- p = ROOT / "docs" / "审核改进待办.md"
14
- d = p.read_text(encoding="utf-8")
15
-
16
- d = d.replace("| **Big Five 数值化** | ⬜ **未做**(M):需要先定 traits→5 维的映射表,属产品决策 |",
17
- "| **Big Five 数值化** | ✅ 已做:`brain.py bigfive [--save]`——固定 5 维按关键词归并,"
18
- "未映射计分不计(`{value,why,evidence}` 嵌套结构已正确处理) |", 1)
19
- d = d.replace("| **OCC 结构情绪** | ⬜ **未做**(M):需要先定 OCC 22 类里用哪几类、怎么触发,属产品决策 |",
20
- "| **OCC 结构情绪** | ✅ 已做(**6 类 + 预期违背拆正负两向**):`brain.py occ label|violation`,"
21
- "失望=负向 / 释然=正向 |", 1)
22
-
23
- SEC = """
24
- ### 14.3 决定与落地(2026-11-30)
25
-
26
- 用户拍板:**OCC 先上 6 类,「预期违背」拆正负两向**;Big Five 按 14.1 候选表落地。
27
-
28
- - `scripts/occ.py`:6 类规则(失望/释然/满意/感激/愤怒/焦虑),每类要求"事件线索 + 方向线索"
29
- 同时命中才算,避免单词误报;`expected_violation()` 单独给出 violated + direction。
30
- 实测六句各命中一类,且"答应却没做到"=负向、"担心却没事"=正向。
31
- - `scripts/bigfive.py`:5 维归并(未映射 traits **不计分**,不瞎归),`--save` 写入
32
- `persona.json.big_five`;顺带修了 traits 嵌套结构 `{value,why,evidence}` 被当裸数字读成 0 的 bug
33
- (`persona_drift` 的 magnitude 同样受益,原来对嵌套结构只能记 0.5 当量)。
34
- """
35
-
36
- if "### 14.3 决定与落地" not in d:
37
- d = d.rstrip() + "\n\n" + SEC
38
- p.write_text(d, encoding="utf-8")
39
- print("§14.3 已补")
@@ -1,43 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:在 app.asar 里找 compaction 的真实实现/接口(跳过索引条目)(可删)。"""
3
- import glob
4
-
5
- PATH = glob.glob("D:/*/resources/app.asar")[0]
6
- NEEDLES = [b"compaction", b"compactS", b"autoCompact", b"requestContext()"]
7
-
8
-
9
- def scan(needle, limit=6, ctx=520):
10
- hits = 0
11
- overlap = b""
12
- with open(PATH, "rb") as f:
13
- while True:
14
- chunk = f.read(8 << 20)
15
- if not chunk:
16
- break
17
- buf = overlap + chunk
18
- start = 0
19
- while hits < limit:
20
- i = buf.find(needle, start)
21
- if i < 0:
22
- break
23
- seg = buf[max(0, i - 200): i + ctx]
24
- text = seg.decode("utf-8", "replace")
25
- start = i + 1
26
- # 跳过 asar 的文件索引(这类片段里有 integrity/offset 元数据)
27
- if '"integrity"' in text or '"blockSize"' in text:
28
- continue
29
- if "sourceMappingURL" in text and len(text) < 300:
30
- continue
31
- print(f"--- {needle.decode()} ---")
32
- print(text.replace("\x00", " ").strip()[:900])
33
- print()
34
- hits += 1
35
- if hits >= limit:
36
- return hits
37
- overlap = buf[-len(needle) - 16:]
38
- return hits
39
-
40
-
41
- for n in NEEDLES:
42
- got = scan(n)
43
- print(f"[{n.decode()}] 有效命中 {got}\n")