lingshu-skill 5.60.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 (207) hide show
  1. package/CHANGELOG.md +29 -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 +10 -10
  9. package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +29 -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/core.py +58 -39
  15. package/scripts/astrbot_plugin_lingshu/engine/scripts/growth.py +3 -4
  16. package/scripts/astrbot_plugin_lingshu/engine/scripts/make_dsh_tgz.py +20 -3
  17. package/scripts/astrbot_plugin_lingshu/engine/scripts/memory.py +11 -2
  18. package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_build.py +13 -0
  19. package/scripts/core.py +58 -39
  20. package/scripts/growth.py +3 -4
  21. package/scripts/make_dsh_tgz.py +20 -3
  22. package/scripts/make_manifest.py +15 -10
  23. package/scripts/make_plugin_zip.py +7 -3
  24. package/scripts/memory.py +11 -2
  25. package/scripts/panel_build.py +13 -0
  26. package/scripts/_ci_env_probe.py +0 -81
  27. package/scripts/_panel_smoke_v299.py +0 -27
  28. package/scripts/_scratch/_tmp_backup_race.py +0 -70
  29. package/scripts/_scratch/_tmp_cleanup_move.py +0 -34
  30. package/scripts/_scratch/_tmp_count_kinds.py +0 -25
  31. package/scripts/_scratch/_tmp_diag_paths.py +0 -48
  32. package/scripts/_scratch/_tmp_facts.py +0 -63
  33. package/scripts/_scratch/_tmp_find_copies.py +0 -31
  34. package/scripts/_scratch/_tmp_find_pin.py +0 -29
  35. package/scripts/_scratch/_tmp_fix_pin.py +0 -36
  36. package/scripts/_scratch/_tmp_fold_fixture.py +0 -55
  37. package/scripts/_scratch/_tmp_fold_test.mjs +0 -81
  38. package/scripts/_scratch/_tmp_inject_secs.py +0 -30
  39. package/scripts/_scratch/_tmp_kb_balance.py +0 -159
  40. package/scripts/_scratch/_tmp_lines.py +0 -15
  41. package/scripts/_scratch/_tmp_market_probe.py +0 -13
  42. package/scripts/_scratch/_tmp_move_partial.py +0 -16
  43. package/scripts/_scratch/_tmp_patch_b3.py +0 -41
  44. package/scripts/_scratch/_tmp_patch_b5.py +0 -62
  45. package/scripts/_scratch/_tmp_patch_crash_excl.py +0 -24
  46. package/scripts/_scratch/_tmp_patch_handoff.py +0 -21
  47. package/scripts/_scratch/_tmp_patch_ps1.py +0 -25
  48. package/scripts/_scratch/_tmp_patch_stat.py +0 -27
  49. package/scripts/_scratch/_tmp_patch_todo.py +0 -25
  50. package/scripts/_scratch/_tmp_patch_todo2.py +0 -64
  51. package/scripts/_scratch/_tmp_probe_session.py +0 -51
  52. package/scripts/_scratch/_tmp_style_probe.py +0 -40
  53. package/scripts/_scratch/_tmp_write_note.py +0 -139
  54. package/scripts/_scratch/_/346/235/245/346/272/220/350/256/260/345/275/225.txt +0 -1
  55. package/scripts/_scratch/asar_compaction/dsh-compaction-basic__lib__index.js +0 -1044
  56. package/scripts/_scratch/asar_compaction/dsh-compaction-tool-result-pruner__lib__index.js +0 -194
  57. package/scripts/_scratch/asar_compaction/dsh-compaction__lib__index.js +0 -175
  58. package/scripts/_scratch/asar_compaction/dsh-compaction__lib__types__tool-pairing.js +0 -97
  59. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__image-offload.js +0 -47
  60. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__index.js +0 -40
  61. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__project-message.js +0 -37
  62. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__brand.js +0 -9
  63. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__checkpoint.js +0 -36
  64. package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__types.js +0 -10
  65. package/scripts/_scratch/commit_msg_occ.txt +0 -16
  66. package/scripts/_scratch/commit_msg_struct.txt +0 -16
  67. package/scripts/_scratch/v5.34_changelog.txt +0 -36
  68. package/scripts/_smoke_v299.py +0 -31
  69. package/scripts/_sync_trae_cn.py +0 -102
  70. package/scripts/_tmp_add_s10.py +0 -54
  71. package/scripts/_tmp_add_s11.py +0 -61
  72. package/scripts/_tmp_add_s12.py +0 -66
  73. package/scripts/_tmp_add_s13.py +0 -69
  74. package/scripts/_tmp_add_s14.py +0 -80
  75. package/scripts/_tmp_add_s9.py +0 -68
  76. package/scripts/_tmp_cache_load.py +0 -82
  77. package/scripts/_tmp_clean_market.py +0 -40
  78. package/scripts/_tmp_clean_pruned.py +0 -81
  79. package/scripts/_tmp_cleanup_docs.py +0 -39
  80. package/scripts/_tmp_cmp_ranker.py +0 -17
  81. package/scripts/_tmp_dolater_note.py +0 -35
  82. package/scripts/_tmp_dust_why.py +0 -27
  83. package/scripts/_tmp_explicit_import.py +0 -40
  84. package/scripts/_tmp_extract_compaction.py +0 -35
  85. package/scripts/_tmp_extract_compaction2.py +0 -63
  86. package/scripts/_tmp_extract_compaction3.py +0 -51
  87. package/scripts/_tmp_extract_compaction4.py +0 -54
  88. package/scripts/_tmp_finalize_s14.py +0 -39
  89. package/scripts/_tmp_find_compaction.py +0 -43
  90. package/scripts/_tmp_fix_b4.py +0 -22
  91. package/scripts/_tmp_fix_cli76.py +0 -26
  92. package/scripts/_tmp_fix_docs.py +0 -38
  93. package/scripts/_tmp_fix_docs_b.py +0 -46
  94. package/scripts/_tmp_fix_docs_b2.py +0 -22
  95. package/scripts/_tmp_fix_i3.py +0 -23
  96. package/scripts/_tmp_fix_s10.py +0 -83
  97. package/scripts/_tmp_fix_s11.py +0 -14
  98. package/scripts/_tmp_fix_s9_status.py +0 -19
  99. package/scripts/_tmp_fix_shadow_sim.py +0 -37
  100. package/scripts/_tmp_fix_traits_value.py +0 -41
  101. package/scripts/_tmp_import_idem.py +0 -106
  102. package/scripts/_tmp_log_ack.py +0 -45
  103. package/scripts/_tmp_mark_batch.py +0 -28
  104. package/scripts/_tmp_mark_batch2.py +0 -32
  105. package/scripts/_tmp_mark_dolater.py +0 -26
  106. package/scripts/_tmp_mark_dolater2.py +0 -31
  107. package/scripts/_tmp_move_self.py +0 -16
  108. package/scripts/_tmp_occ_cli.py +0 -22
  109. package/scripts/_tmp_occ_link.py +0 -108
  110. package/scripts/_tmp_optimize_recall.py +0 -54
  111. package/scripts/_tmp_panel_audit.py +0 -26
  112. package/scripts/_tmp_patch_batch3.py +0 -65
  113. package/scripts/_tmp_patch_rrf.py +0 -46
  114. package/scripts/_tmp_patch_s2s3.py +0 -80
  115. package/scripts/_tmp_patch_s4.py +0 -39
  116. package/scripts/_tmp_patch_s7.py +0 -43
  117. package/scripts/_tmp_patch_s8.py +0 -91
  118. package/scripts/_tmp_patch_skill.py +0 -17
  119. package/scripts/_tmp_release_guard.py +0 -57
  120. package/scripts/_tmp_rerank_breaker.py +0 -62
  121. package/scripts/_tmp_s16.py +0 -41
  122. package/scripts/_tmp_scan_asar.py +0 -41
  123. package/scripts/_tmp_scan_asar2.py +0 -37
  124. package/scripts/_tmp_speed_survey.py +0 -49
  125. package/scripts/_tmp_struct_docs.py +0 -49
  126. package/scripts/_tmp_sum_fallback.py +0 -42
  127. package/scripts/_tmp_sweep.py +0 -81
  128. package/scripts/_tmp_sync_check.py +0 -69
  129. package/scripts/_tmp_sync_tail.py +0 -39
  130. package/scripts/_tmp_todo_clean.py +0 -67
  131. package/scripts/_tmp_verify_copy.py +0 -17
  132. package/scripts/_tmp_wire_extras.py +0 -93
  133. package/scripts/_tmp_wire_hsum.py +0 -34
  134. package/scripts/_tmp_wire_occ_b5.py +0 -40
  135. package/scripts/_tmp_wire_ranker.py +0 -13
  136. package/scripts/_tmp_wire_shadow_timeline.py +0 -45
  137. package/scripts/astrbot_plugin_lingshu/engine/scripts/_ci_env_probe.py +0 -81
  138. package/scripts/astrbot_plugin_lingshu/engine/scripts/_panel_smoke_v299.py +0 -27
  139. package/scripts/astrbot_plugin_lingshu/engine/scripts/_smoke_v299.py +0 -31
  140. package/scripts/astrbot_plugin_lingshu/engine/scripts/_sync_trae_cn.py +0 -102
  141. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s10.py +0 -54
  142. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s11.py +0 -61
  143. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s12.py +0 -66
  144. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s13.py +0 -69
  145. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s14.py +0 -80
  146. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s9.py +0 -68
  147. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cache_load.py +0 -82
  148. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_clean_market.py +0 -40
  149. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_clean_pruned.py +0 -81
  150. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cleanup_docs.py +0 -39
  151. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cmp_ranker.py +0 -17
  152. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_dolater_note.py +0 -35
  153. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_dust_why.py +0 -27
  154. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_explicit_import.py +0 -40
  155. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction.py +0 -35
  156. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction2.py +0 -63
  157. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction3.py +0 -51
  158. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction4.py +0 -54
  159. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_finalize_s14.py +0 -39
  160. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_find_compaction.py +0 -43
  161. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_b4.py +0 -22
  162. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_cli76.py +0 -26
  163. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs.py +0 -38
  164. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs_b.py +0 -46
  165. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs_b2.py +0 -22
  166. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_i3.py +0 -23
  167. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s10.py +0 -83
  168. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s11.py +0 -14
  169. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s9_status.py +0 -19
  170. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_shadow_sim.py +0 -37
  171. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_traits_value.py +0 -41
  172. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_import_idem.py +0 -106
  173. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_log_ack.py +0 -45
  174. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_batch.py +0 -28
  175. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_batch2.py +0 -32
  176. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_dolater.py +0 -26
  177. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_dolater2.py +0 -31
  178. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_move_self.py +0 -16
  179. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_occ_cli.py +0 -22
  180. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_occ_link.py +0 -108
  181. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_optimize_recall.py +0 -54
  182. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_panel_audit.py +0 -26
  183. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_batch3.py +0 -65
  184. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_rrf.py +0 -46
  185. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s2s3.py +0 -80
  186. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s4.py +0 -39
  187. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s7.py +0 -43
  188. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s8.py +0 -91
  189. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_skill.py +0 -17
  190. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_release_guard.py +0 -57
  191. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_rerank_breaker.py +0 -62
  192. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_s16.py +0 -41
  193. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_scan_asar.py +0 -41
  194. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_scan_asar2.py +0 -37
  195. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_speed_survey.py +0 -49
  196. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_struct_docs.py +0 -49
  197. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sum_fallback.py +0 -42
  198. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sweep.py +0 -81
  199. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sync_check.py +0 -69
  200. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sync_tail.py +0 -39
  201. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_todo_clean.py +0 -67
  202. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_verify_copy.py +0 -17
  203. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_extras.py +0 -93
  204. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_hsum.py +0 -34
  205. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_occ_b5.py +0 -40
  206. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_ranker.py +0 -13
  207. package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_shadow_timeline.py +0 -45
@@ -1,66 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:写「调研能力阶梯」进文档 §12 + 长期记忆(可删)。"""
3
- import sys
4
-
5
- from pathlib import Path
6
-
7
- ROOT = Path(r"E:\丁厚同\文档\程序\灵枢-skill")
8
- p = ROOT / "docs" / "审核改进待办.md"
9
- d = p.read_text(encoding="utf-8")
10
-
11
- SEC = """
12
- ## §12 调研能力阶梯(2026-11-30 实测)
13
-
14
- 用户要求:**能联网就连网,连不上才本地**;技能优先,技能失败就换方案。
15
-
16
- ### 实测结论
17
-
18
- | 路径 | 状态 | 说明 |
19
- |---|---|---|
20
- | `web_search` 工具 | ❌ 402 余额不足 | 走模型 provider 的搜索端点,欠费即不可用 |
21
- | `web_fetch` 工具 | ✅ 可用 | 抓指定 URL 正文 |
22
- | **普通 HTTP**(`brain.py web search/fetch`) | ✅ **通** | 实测 `api.github.com` 200、`www.bing.com` 200、Bing HTML 能解析出 9 条结果 |
23
- | DuckDuckGo HTML | ❌ 超时 | 该域被墙/超时,别用 |
24
- | `webapp-testing` 技能(Playwright) | 🟡 存在 | 真浏览器自动化,重活才用 |
25
- | `gh-cli` 技能(curl / gh) | ✅ 可用 | GitHub API 类调研 |
26
- | `report-page` 技能 | ✅ 可用 | 调研**成文**(source-backed 报告)用 |
27
- | 本地取证(asar / 源码 / 文档) | ✅ 兜底 | 例:APP 的 `contextPressure` 定义就是从 `app.asar` 里扫出来的 |
28
-
29
- > `app-doc` 技能在技能目录里,但 `skill` 工具调用返回 `unknown skill`(未在当前 profile 注册)——
30
- > 需要查 APP 自身机制时,直接扫 `app.asar` 更可靠(用 glob 定位,因为目录名有字形混淆问题)。
31
-
32
- ### 固定阶梯(按顺序降级)
33
-
34
- 1. `web fetch` 工具 / `web search`(若恢复);
35
- 2. `brain.py web search "<q>"` → `brain.py web fetch <url>`(Bing HTML + urllib,零依赖);
36
- 3. 特定域用专门工具:GitHub → `gh-cli`;要跑页面交互 → `webapp-testing`(Playwright);
37
- 4. 成文交付 → `report-page`;
38
- 5. 都失败 → 本地取证(asar / 源码 / 本地文档),并在结论里**注明"联网失败,结论来自本地"**。
39
-
40
- ### 注意
41
-
42
- - Bing 对灵枢/APP 这类产品名会被当成普通词("APP"→手机 App),**查询要加引号 + 域名限定**,
43
- 例如 `"deepseek harness" site:github.com`;
44
- - 抓取上限 4MB、超时 12s,防拖死;失败返回结构化错误,不抛栈。
45
- """
46
-
47
- if "## §12 调研能力阶梯" in d:
48
- print("§12 已存在")
49
- else:
50
- p.write_text(d.rstrip() + "\n\n" + SEC, encoding="utf-8")
51
- print("已追加 §12")
52
-
53
- sys.path.insert(0, str(ROOT / "scripts"))
54
- import brain # noqa: E402
55
-
56
- res = brain.remember(
57
- "调研阶梯(2026-11-30 实测,用户要求'能联网就连网,连不上才本地'):"
58
- "①web_fetch 工具可用;web_search 工具 402 欠费不可用。"
59
- "②普通 HTTP 通:brain.py web search(Bing HTML 解析)/ web fetch(抽正文),零依赖。"
60
- "③DuckDuckGo HTML 超时不可用。④GitHub 类用 gh-cli 技能;页面交互用 webapp-testing(Playwright);"
61
- "成文用 report-page 技能。⑤全失败才本地取证(app.asar/源码/文档),并在结论注明来源。"
62
- "⑥app-doc 技能在目录里但 skill 工具报 unknown,查 APP 机制直接扫 app.asar(路径有字形混淆,用 glob)。",
63
- kind="preference", importance=0.9, tags=["调研", "联网", "工具阶梯"],
64
- )
65
- mid = res[0].get("id") if isinstance(res, tuple) and res and isinstance(res[0], dict) else res
66
- print("已记入长期记忆:", mid)
@@ -1,69 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:把宿主 compaction API 合同写进 §13(可删)。"""
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
- ## §13 宿主 compaction 的 API 合同(2026-11-30 从 app.asar 源码取证)
10
-
11
- ### 13.1 宿主有哪些包
12
-
13
- ```
14
- @deepseek-ai/dsh-compaction ← 抽象服务(seam)
15
- @deepseek-ai/dsh-compaction-basic ← 通用实现
16
- @deepseek-ai/dsh-compaction-image-offload ← 图片外置
17
- @deepseek-ai/dsh-compaction-tool-result-pruner ← 工具结果裁剪
18
- ```
19
-
20
- ### 13.2 合同(源码事实)
21
-
22
- | 事实 | 原文/签名 |
23
- |---|---|
24
- | 服务标识 | `var CompactionEngine = class extends Service { constructor(ctx){ super(ctx, "compaction") } }`,即 `ctx.compaction` |
25
- | 职责边界 | "Implementations own **trigger policy, retention, and summarization**"——策略/保留/摘要都归 provider |
26
- | 压缩语义 | "A successful run **replaces the selected surface span with one summary node**",并阻止同一会话并发压缩 |
27
- | 摘要如何落地 | 替换成一条**普通用户消息**,其 `source` 用 `compactCheckpointSource(compactionId, sourceCommandId)` 生成 → `{ kind: 'compact-checkpoint', compactionId, sourceCommandId }` |
28
- | 识别 checkpoint | `isCompactCheckpointSource(source)` |
29
- | 安全切点 | `toolPairingBalancedBefore(session, seq)` / `toolPairingBalancedAfter(session, seq)`——**宿主自己就有工具配对平衡判断**("Compaction changes surface positions, so safe cuts are derived from tool-call/result content in current surface order rather than step markers") |
30
- | 会话表面 | `session.surface.nodes`(seq 数组)、`session.surface.replaceGeneration`、`session.eventAt(seq)` |
31
- | 失败类型 | `ManualCompactionError(code, message)`,`code` 含 `busy`(其他自动路径也可能抛) |
32
- | basic 的方法 | `summarize` / `compactIfNeeded` / `compactPressure` / `compactRegion` |
33
-
34
- ### 13.3 结论:#54 分两步走
35
-
36
- **第一步(已做,2026-11-30)——让位,别重复压**
37
-
38
- 宿主压缩的结果是"一条带 `compact-checkpoint` 的用户消息"。我们已经压过一遍的轮次如果被宿主再压,
39
- 就是摘要的摘要(越压越糊)。所以:
40
-
41
- - `cordis-plugin/lingshu-startup/context-fold.js`:请求里出现 `source.kind === 'compact-checkpoint'`
42
- → **本次不折叠**(`reason: 'host-compacted'`,每进程只提示一次);
43
- - `scripts/app_context.py`:消息上标 `is_checkpoint`,`plan_turns` **跳过含 checkpoint 的轮**
44
- (测试 `test_plan_turns_skips_host_checkpoint_turns` 锁住)。
45
-
46
- **第二步(未做)——写一个灵枢 provider,替掉 pre-step 改写**
47
-
48
- 既然宿主提供 `CompactionEngine` 抽象,正确做法是**灵枢实现一个 provider**(`extends CompactionEngine`,
49
- 实现 `compactIfNeeded/compactPressure/compactRegion/summarize`),把我们的
50
- "五段式摘要 + 硬锚保留率(§2#1)+ 水位触发(autofold)"当成策略与摘要器。
51
-
52
- 收益:
53
- - 压缩交给宿主的 surface 机制,**不再和宿主状态机抢**(现在的 pre-step 改写是并行机制);
54
- - 自动获得并发保护、checkpoint 标记、工具配对安全切点;
55
- - `projectedTokens` 会立刻反映(宿主自己的注释就是这么说的)。
56
-
57
- 代价:basic 实现约 50KB,要读懂 surface/事件/回放语义;**必须单独立项**(水位 <40% 时做)。
58
-
59
- ### 13.4 顺带修正一条旧判断
60
-
61
- 我们此前在 `context-fold.js` 里自己实现了"整轮折叠 + 工具配对保护"——现在确认**宿主已有同款**
62
- (`toolPairingBalancedBefore/After`)。短期保留(不动主链路),长期随第二步一起收敛。
63
- """
64
-
65
- if "## §13 宿主 compaction" in d:
66
- print("§13 已存在")
67
- else:
68
- p.write_text(d.rstrip() + "\n\n" + SEC, encoding="utf-8")
69
- print("已追加 §13")
@@ -1,80 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:§14 两级建模候选表 + 标记增量分层摘要完成 + 记教训(可删)。"""
3
- import sys
4
-
5
- from pathlib import Path
6
-
7
- ROOT = Path(r"E:\丁厚同\文档\程序\灵枢-skill")
8
- p = ROOT / "docs" / "审核改进待办.md"
9
- d = p.read_text(encoding="utf-8")
10
-
11
- # 1) 标记增量分层摘要完成
12
- old = "| **增量分层摘要** | ⬜ **未做**(L 级,方案在 `docs/重构方案-20261130.md` 第一节) |"
13
- new = ("| **增量分层摘要** | ✅ 已做:`brain.py hsum build --level 1|2|3`——L1/L2/L3 账本,"
14
- "按 covers 幂等(同覆盖范围只生成一次),保留率 <0.5 拒绝覆盖(宁可旧不可烂) |")
15
- if old in d:
16
- d = d.replace(old, new, 1)
17
- print("已标记增量分层摘要")
18
- else:
19
- print("增量分层摘要行未找到")
20
-
21
- SEC = """
22
- ## §14 需要你拍板的两张语义表(Big Five / OCC)
23
-
24
- 这两项技术上半天能落,但**先要定语义**(我不替你拍)。
25
-
26
- ### 14.1 Big Five 数值化(候选映射)
27
-
28
- 现状问题:traits 是自由命名(好奇/温和/理智…),**改名或加轴,历史就不可比** —— 而 drift 散度需要固定维度。
29
-
30
- 建议固定 5 维,把现有 traits 归并进去(未列出的默认不计分):
31
-
32
- | 维度 | 建议归并的来源 traits | 说明 |
33
- |---|---|---|
34
- | 开放性 Openness | 好奇、求知欲、探索、创造、审美 | 求新求变 |
35
- | 尽责性 Conscientiousness | 严谨、理智、秩序、尽责、条理 | 自控与执行 |
36
- | 外向性 Extraversion | 表达欲、社交、热烈、主动 | 能量朝外 |
37
- | 宜人性 Agreeableness | 温和、共情、包容、体贴 | 对人友善 |
38
- | 神经质 Neuroticism | 敏感、焦虑、情绪波动、脆弱 | **低=情绪稳定**(注意方向) |
39
-
40
- > 需要你确认:① 5 维命名用中文还是中英;② 上表归并是否要增删;③ 未列 traits 是"不计分"还是"按最近维度就近归"。
41
-
42
- ### 14.2 OCC 结构情绪(候选分类)
43
-
44
- 现状问题:**"预期违背"没有独立标签** —— "他答应了"和"他答应了却没做到"落进同一档,而那才是用户真有感受的时刻。
45
-
46
- 建议先只上 6 类(够覆盖日常,别一上来 22 类):
47
-
48
- | 类 | 触发(示例规则) | 对应现有情绪 |
49
- |---|---|---|
50
- | 失望 disappointment | 承诺/期望 + 未达成 | 难过/失落 |
51
- | 释然 relief | 担心的事 + 没发生 | 放松 |
52
- | 满意 satisfaction | 努力 + 达成预期 | 开心 |
53
- | 感激 gratitude | 对方付出 + 超出预期 | 感动 |
54
- | 愤怒 anger | 被损害/被违背 + 归因他人 | 生气 |
55
- | 焦虑 fear | 未来不确定 + 可能损失 | 焦虑 |
56
-
57
- > 需要你确认:① 先上这 6 类还是更多;② "预期违背"是否要拆成正负两向(失望/释然)——
58
- > 我建议拆,否则一个标签同时表示"没做到"和"没出事",会互相污染。
59
- """
60
-
61
- if "## §14 需要你拍板" not in d:
62
- p.write_text(d.rstrip() + "\n\n" + SEC, encoding="utf-8")
63
- print("已追加 §14")
64
- else:
65
- p.write_text(d, encoding="utf-8")
66
- print("§14 已存在")
67
-
68
- sys.path.insert(0, str(ROOT / "scripts"))
69
- import brain # noqa: E402
70
-
71
- res = brain.remember(
72
- "教训(2026-11-30,同一天踩两次):Python 里 `x.get(k) or default` 会把**显式 0 当成假值**吞掉。"
73
- "实例:① rerank 的 fail_cooldown_sec=0(不熔断)被 `or 300` 变成 5 分钟;"
74
- "② hsum 的保留率 0.0(全丢)被 `or 1.0` 变成满保留、闸门失效。"
75
- "规矩:凡是\"0 是合法取值\"的数值配置/度量,一律写 `v = d.get(k); v if v is not None else default`,"
76
- "禁止用 `or` 兜默认值。",
77
- kind="mistake", importance=0.85, tags=["python", "陷阱", "配置"],
78
- )
79
- mid = res[0].get("id") if isinstance(res, tuple) and res and isinstance(res[0], dict) else res
80
- print("教训已记:", mid)
@@ -1,68 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """一次性:把「长时记忆架构」借鉴评估写进待办 §9(可删)。"""
3
- import re
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
- ## §9 长时记忆架构(外部方案)对照评估(2026-11-30)
11
-
12
- > 来源:用户提供的一份「给灵枢的长时记忆架构」提案(四层 + 调度层 + 三库模型 + 演化引擎)。
13
- > 处理方式:**逐条对照灵枢现状**,只把"真缺的"记成新待办,避免重复造轮子。
14
-
15
- ### 9.1 逐条对照
16
-
17
- | 提案要点 | 灵枢现状 | 结论 |
18
- |---|---|---|
19
- | 四层:瞬时 / 短期 / 永久 / 冷归档 | `hippocampus`(短) + `cortex`(长) + `dust`(淡忘) + `archive`(冷档);「瞬时」= `WORKING_FILE` 工作记忆(12h 过期) | ✅ **已有** |
20
- | 向量检索 | `embed`/`dense_scores` + BM25(#3) + RRF(opt-in) + rerank 可插拔 | ✅ **已有**(比提案更全:还有词法/混合) |
21
- | `abstract` 摘要先行:检索拿摘要、命中才拉全文 | 已有 **gist + 指针注入**(一句要点 + 短 id,正文 `memory show`/`deref` 取)——机制完全一致 | ✅ 机制已有;但 gist 是**启发式**,提案要求"模型提炼" → 见 **#43** |
22
- | 记忆限流 3–6 条 / 防上下文爆炸 | 默认 `k=8`、注入 `budget=1400` + **总量兜底按段丢弃**(P0.8) | ✅ **已有**(比硬上限更精细) |
23
- | `protection` 保护标记(禁自动遗忘/修改) | `pinned` / `frozen` / `verbatim` / `kind=identity`,且归档/合并都避开它们 | ✅ **已有** |
24
- | 权重衰减 + 冷归档不删 | `retention()` Ebbinghaus + dust→archive(`archive restore` 可回热)+ `.pruned/` 只移不删 | ✅ **已有** |
25
- | 记忆合并去冗余 | `dream --auto` 合并 + 侧抑制(jaccard≥0.85)+ MMR(opt-in) 处理 0.6–0.85 | ✅ **已有** |
26
- | 冲突检测待审、不程序强改 | `detect-conflicts` + `audit` 的"疑似冲突" + `review confirm/discard` | ✅ **已有** |
27
- | 三级删除(冷归档 / 软删 / 硬删) | `archive`(可回) / `dust`(淡忘) / `purge`(双重确认 + 台账) | ✅ **已有** |
28
- | 人格本体与记忆解耦 | `persona.json` 独立 + 快照/回滚;记忆在 jsonl | ✅ **已有**(但见 #44 的分区差异) |
29
- | 记忆溯源("我怎么变成现在这样") | 每条有 id/`links`/`evidence_ids`;`persona history`、`growth`、`dream` 报告 | 🟡 数据有,**没有一条可读的成长时间线** → 见 **#46** |
30
- | 人格升华:聚类人格碎片→新认知,追加不覆盖 | `dream` 沉淀 + `persona suggest`(从记忆归纳候选特征,需人工 adopt) | 🟡 半有;缺"人格碎片聚类→自主升华"的专线 → 见 **#44** |
31
- | 轻量可落地(Chroma/Milvus/Redis) | 本地 JSON + 可选外部 embed;**零运行时依赖**是硬设计 | ❌ **不采纳**外部向量库/Redis 依赖(与零依赖冲突);现有 `mem_embed`/`fallback_embed` 已够 |
32
-
33
- ### 9.2 真缺的部分(新增待办)
34
-
35
- | # | 项 | 为什么值得做 | 代价/风险 |
36
- |---|---|---|---|
37
- | 43 | **`abstract` 由模型提炼**(写入时生成,检索优先用;命中原记录再拉全文) | 现在 `gist` 是启发式截断,长记忆的"一句话"常常没抓住要点;提案这点对省 token 最直接 | 需 `config.summary` 配模型才有质量;无模型时保持启发式兜底(fail-open)。写路径加一次摘要生成,注意别阻塞 `remember`(异步/可跳) |
38
- | 44 | **人格演化池分区**:把"感悟 / 自我认知 / 成长碎片"单独归档,**默认不注入任务上下文**,只在 `persona self` / 自省 / 演化指令时调取 | 提案的核心价值点:人格自由生长且**不污染业务上下文**。现在人格身份是每轮注入的(这是对的),但"演化碎片"和业务记忆混在一层 | 要新增分区字段/层,并改注入选择逻辑(**注入主链路**,需水位 <50%、单独做、带 `context preview` 式的可见性) |
39
- | 45 | **缓存守卫**:`priorAuto` 每轮查一次并可能注入 prior 块 —— 这会动**前缀缓存** | 提案反复强调"缓存命中率优先、记忆操作后置"。我们现在每轮都可能加一条,和"稳定前缀"目标相冲突 | 需要宿主侧缓存命中信号(`tokenMeter` 只给压力,不给命中率);退一步可做"同会话同 digest 只查一次 + 稳定前缀后置",风险中等 |
40
- | 46 | **成长时间线视图**("我是怎么变成现在这样") | 数据都在(persona history / lesson / dream 沉淀 / stage),但散在多个命令里,没有一条时间线。提案的"记忆溯源"正是这个体验 | 纯读,低风险;CLI + 面板页签各一处 |
41
-
42
- ### 9.3 关于"联网调研用技能"
43
-
44
- - `web_search` 工具走的是模型 provider 的搜索端点,**当前 402 余额不足**,不可用;
45
- - 技能库里可用 **`report-page`**("source-backed report / research note")做**带来源的调研**——
46
- 以后调研类任务优先 `skill use report-page`(必要时 `skill borrow report-page` 变成自己的版本),
47
- 而不是直接调 `web_search`。
48
- """
49
-
50
- if "## §9 长时记忆架构" in d:
51
- print("§9 已存在,跳过")
52
- else:
53
- d = d.rstrip() + "\n\n" + SEC
54
- print("已追加 §9")
55
-
56
- # 统计(把 §9 的 43–46 计入)
57
- counts = {"done": 0, "todo": 0, "excl": 0}
58
- for ln in d.splitlines():
59
- if not re.match(r"^\|\s*[A-Z]?\d+\s*\|", ln):
60
- continue
61
- if "✅" in ln:
62
- counts["done"] += 1
63
- elif "⬜" in ln:
64
- counts["todo"] += 1
65
- elif "🔍" in ln:
66
- counts["excl"] += 1
67
- p.write_text(d, encoding="utf-8")
68
- print("(§9 的 43–46 是表格行但不带状态列,未计入编号统计)")
@@ -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 ""))