lingshu-skill 5.33.0 → 5.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4281 -4227
- package/README.md +1584 -1577
- package/SKILL-lite.md +59 -59
- package/SKILL-tiny.md +38 -38
- package/SKILL.md +356 -331
- package/assets/panel.html +6753 -5698
- package/cordis-plugin/lingshu-cron/plugin.js +1455 -1417
- package/cordis-plugin/lingshu-startup/context-fold.js +170 -0
- package/cordis-plugin/lingshu-startup/context-pressure.js +16 -0
- package/cordis-plugin/lingshu-startup/context-snapshot.js +176 -0
- package/cordis-plugin/lingshu-startup/plugin.js +499 -467
- package/docs/audit_notes//345/276/205/345/212/236-20261201-/351/235/242/346/235/277/344/270/245/346/237/245/344/270/216/345/256/241/350/256/241.md +162 -0
- package/docs/audit_notes//345/276/205/345/212/236-20261202-/351/235/242/346/235/277/344/272/244/344/272/222/344/270/216/346/225/260/346/215/256/345/245/221/347/272/246/345/256/241/350/256/241.md +92 -0
- package/docs/audit_notes//345/276/205/345/212/236/346/250/241/346/235/277.md +140 -0
- package/docs/commands.md +278 -247
- package/docs/mechanics.md +610 -610
- package/docs//345/276/205/345/212/236-20261201-/351/235/242/346/235/277/344/270/245/346/237/245/344/270/216/345/256/241/350/256/241.md +162 -0
- package/docs//345/276/205/345/212/236-20261202-/351/235/242/346/235/277/344/272/244/344/272/222/344/270/216/346/225/260/346/215/256/345/245/221/347/272/246/345/256/241/350/256/241.md +92 -0
- package/package.json +52 -52
- package/scripts/_scratch/_tmp_backup_race.py +70 -0
- package/scripts/_scratch/_tmp_cleanup_move.py +34 -0
- package/scripts/_scratch/_tmp_count_kinds.py +25 -0
- package/scripts/_scratch/_tmp_diag_paths.py +48 -0
- package/scripts/_scratch/_tmp_facts.py +63 -0
- package/scripts/_scratch/_tmp_find_copies.py +31 -0
- package/scripts/_scratch/_tmp_find_pin.py +29 -0
- package/scripts/_scratch/_tmp_fix_pin.py +36 -0
- package/scripts/_scratch/_tmp_fold_fixture.py +55 -0
- package/scripts/_scratch/_tmp_fold_test.mjs +81 -0
- package/scripts/_scratch/_tmp_inject_secs.py +30 -0
- package/scripts/_scratch/_tmp_kb_balance.py +159 -0
- package/scripts/_scratch/_tmp_lines.py +15 -0
- package/scripts/_scratch/_tmp_market_probe.py +13 -0
- package/scripts/_scratch/_tmp_move_partial.py +16 -0
- package/scripts/_scratch/_tmp_patch_b3.py +41 -0
- package/scripts/_scratch/_tmp_patch_b5.py +62 -0
- package/scripts/_scratch/_tmp_patch_crash_excl.py +24 -0
- package/scripts/_scratch/_tmp_patch_handoff.py +21 -0
- package/scripts/_scratch/_tmp_patch_ps1.py +25 -0
- package/scripts/_scratch/_tmp_patch_stat.py +27 -0
- package/scripts/_scratch/_tmp_patch_todo.py +25 -0
- package/scripts/_scratch/_tmp_patch_todo2.py +64 -0
- package/scripts/_scratch/_tmp_probe_session.py +51 -0
- package/scripts/_scratch/_tmp_style_probe.py +40 -0
- package/scripts/_scratch/_tmp_write_note.py +139 -0
- package/scripts/_scratch/_/346/235/245/346/272/220/350/256/260/345/275/225.txt +1 -0
- package/scripts/_scratch/asar_compaction/dsh-compaction-basic__lib__index.js +1044 -0
- package/scripts/_scratch/asar_compaction/dsh-compaction-tool-result-pruner__lib__index.js +194 -0
- package/scripts/_scratch/asar_compaction/dsh-compaction__lib__index.js +175 -0
- package/scripts/_scratch/asar_compaction/dsh-compaction__lib__types__tool-pairing.js +97 -0
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__image-offload.js +47 -0
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__index.js +40 -0
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__project-message.js +37 -0
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__brand.js +9 -0
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__checkpoint.js +36 -0
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__types.js +10 -0
- package/scripts/_scratch/commit_msg_occ.txt +16 -0
- package/scripts/_scratch/commit_msg_struct.txt +16 -0
- package/scripts/_scratch/v5.34_changelog.txt +36 -0
- package/scripts/_sync_trae_cn.py +102 -34
- package/scripts/_tmp_add_s10.py +54 -0
- package/scripts/_tmp_add_s11.py +61 -0
- package/scripts/_tmp_add_s12.py +66 -0
- package/scripts/_tmp_add_s13.py +69 -0
- package/scripts/_tmp_add_s14.py +80 -0
- package/scripts/_tmp_add_s9.py +68 -0
- package/scripts/_tmp_cache_load.py +82 -0
- package/scripts/_tmp_clean_market.py +40 -0
- package/scripts/_tmp_clean_pruned.py +81 -0
- package/scripts/_tmp_cleanup_docs.py +39 -0
- package/scripts/_tmp_cmp_ranker.py +17 -0
- package/scripts/_tmp_dolater_note.py +35 -0
- package/scripts/_tmp_dust_why.py +27 -0
- package/scripts/_tmp_explicit_import.py +40 -0
- package/scripts/_tmp_extract_compaction.py +35 -0
- package/scripts/_tmp_extract_compaction2.py +63 -0
- package/scripts/_tmp_extract_compaction3.py +51 -0
- package/scripts/_tmp_extract_compaction4.py +54 -0
- package/scripts/_tmp_finalize_s14.py +39 -0
- package/scripts/_tmp_find_compaction.py +43 -0
- package/scripts/_tmp_fix_b4.py +22 -0
- package/scripts/_tmp_fix_cli76.py +26 -0
- package/scripts/_tmp_fix_docs.py +38 -0
- package/scripts/_tmp_fix_docs_b.py +46 -0
- package/scripts/_tmp_fix_docs_b2.py +22 -0
- package/scripts/_tmp_fix_i3.py +23 -0
- package/scripts/_tmp_fix_s10.py +83 -0
- package/scripts/_tmp_fix_s11.py +14 -0
- package/scripts/_tmp_fix_s9_status.py +19 -0
- package/scripts/_tmp_fix_shadow_sim.py +37 -0
- package/scripts/_tmp_fix_traits_value.py +41 -0
- package/scripts/_tmp_import_idem.py +106 -0
- package/scripts/_tmp_log_ack.py +45 -0
- package/scripts/_tmp_mark_batch.py +28 -0
- package/scripts/_tmp_mark_batch2.py +32 -0
- package/scripts/_tmp_mark_dolater.py +26 -0
- package/scripts/_tmp_mark_dolater2.py +31 -0
- package/scripts/_tmp_move_self.py +16 -0
- package/scripts/_tmp_occ_cli.py +22 -0
- package/scripts/_tmp_occ_link.py +108 -0
- package/scripts/_tmp_optimize_recall.py +54 -0
- package/scripts/_tmp_panel_audit.py +26 -0
- package/scripts/_tmp_patch_batch3.py +65 -0
- package/scripts/_tmp_patch_rrf.py +46 -0
- package/scripts/_tmp_patch_s2s3.py +80 -0
- package/scripts/_tmp_patch_s4.py +39 -0
- package/scripts/_tmp_patch_s7.py +43 -0
- package/scripts/_tmp_patch_s8.py +91 -0
- package/scripts/_tmp_patch_skill.py +17 -0
- package/scripts/_tmp_release_guard.py +57 -0
- package/scripts/_tmp_rerank_breaker.py +62 -0
- package/scripts/_tmp_s16.py +41 -0
- package/scripts/_tmp_scan_asar.py +41 -0
- package/scripts/_tmp_scan_asar2.py +37 -0
- package/scripts/_tmp_struct_docs.py +49 -0
- package/scripts/_tmp_sum_fallback.py +42 -0
- package/scripts/_tmp_sweep.py +81 -0
- package/scripts/_tmp_sync_check.py +69 -0
- package/scripts/_tmp_sync_tail.py +39 -0
- package/scripts/_tmp_todo_clean.py +67 -0
- package/scripts/_tmp_verify_copy.py +17 -0
- package/scripts/_tmp_wire_extras.py +93 -0
- package/scripts/_tmp_wire_hsum.py +34 -0
- package/scripts/_tmp_wire_occ_b5.py +40 -0
- package/scripts/_tmp_wire_ranker.py +13 -0
- package/scripts/_tmp_wire_shadow_timeline.py +45 -0
- package/scripts/anchor_retention.py +68 -0
- package/scripts/app_context.py +1160 -0
- package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +38 -22
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +4281 -4227
- package/scripts/astrbot_plugin_lingshu/engine/README.md +1584 -1577
- package/scripts/astrbot_plugin_lingshu/engine/SKILL-lite.md +59 -59
- package/scripts/astrbot_plugin_lingshu/engine/SKILL-tiny.md +38 -38
- package/scripts/astrbot_plugin_lingshu/engine/SKILL.md +356 -331
- package/scripts/astrbot_plugin_lingshu/engine/assets/panel.html +6753 -5698
- package/scripts/astrbot_plugin_lingshu/engine/docs/commands.md +278 -247
- package/scripts/astrbot_plugin_lingshu/engine/docs/mechanics.md +610 -610
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_sync_trae_cn.py +102 -34
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s10.py +54 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s11.py +61 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s12.py +66 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s13.py +69 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s14.py +80 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s9.py +68 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cache_load.py +82 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_clean_market.py +40 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_clean_pruned.py +81 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cleanup_docs.py +39 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cmp_ranker.py +17 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_dolater_note.py +35 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_dust_why.py +27 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_explicit_import.py +40 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction.py +35 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction2.py +63 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction3.py +51 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction4.py +54 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_finalize_s14.py +39 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_find_compaction.py +43 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_b4.py +22 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_cli76.py +26 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs.py +38 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs_b.py +46 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs_b2.py +22 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_i3.py +23 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s10.py +83 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s11.py +14 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s9_status.py +19 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_shadow_sim.py +37 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_traits_value.py +41 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_import_idem.py +106 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_log_ack.py +45 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_batch.py +28 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_batch2.py +32 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_dolater.py +26 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_dolater2.py +31 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_move_self.py +16 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_occ_cli.py +22 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_occ_link.py +108 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_optimize_recall.py +54 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_panel_audit.py +26 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_batch3.py +65 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_rrf.py +46 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s2s3.py +80 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s4.py +39 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s7.py +43 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s8.py +91 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_skill.py +17 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_release_guard.py +57 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_rerank_breaker.py +62 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_s16.py +41 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_scan_asar.py +41 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_scan_asar2.py +37 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_struct_docs.py +49 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sum_fallback.py +42 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sweep.py +81 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sync_check.py +69 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sync_tail.py +39 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_todo_clean.py +67 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_verify_copy.py +17 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_extras.py +93 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_hsum.py +34 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_occ_b5.py +40 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_ranker.py +13 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_shadow_timeline.py +45 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/anchor_retention.py +68 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/app_context.py +1160 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/bigfive.py +90 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/brain.py +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/scripts/check_docs.py +191 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/cli.py +921 -86
- package/scripts/astrbot_plugin_lingshu/engine/scripts/core.py +2468 -2406
- package/scripts/astrbot_plugin_lingshu/engine/scripts/coverage_report.py +5 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/delivery.py +112 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/dream.py +41 -3
- package/scripts/astrbot_plugin_lingshu/engine/scripts/emotion.py +202 -23
- package/scripts/astrbot_plugin_lingshu/engine/scripts/gap_memory.py +186 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/growth.py +72 -8
- package/scripts/astrbot_plugin_lingshu/engine/scripts/hsum.py +206 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/mem_score.py +92 -7
- package/scripts/astrbot_plugin_lingshu/engine/scripts/memory.py +530 -60
- package/scripts/astrbot_plugin_lingshu/engine/scripts/memory_extras.py +200 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/occ.py +190 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_server.py +232 -142
- package/scripts/astrbot_plugin_lingshu/engine/scripts/persona.py +2498 -2349
- package/scripts/astrbot_plugin_lingshu/engine/scripts/prepublish_tests.py +90 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/release.py +326 -287
- package/scripts/astrbot_plugin_lingshu/engine/scripts/rss_ingest.py +181 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/session_import.py +832 -764
- package/scripts/astrbot_plugin_lingshu/engine/scripts/shadow_memory.py +173 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/style_check.py +220 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/summarizer.py +343 -252
- package/scripts/astrbot_plugin_lingshu/engine/scripts/timeline.py +118 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/watchdog.py +110 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/web_research.py +125 -0
- package/scripts/bigfive.py +90 -0
- package/scripts/brain.py +1 -1
- package/scripts/check_docs.py +191 -0
- package/scripts/cli.py +921 -86
- package/scripts/core.py +2468 -2406
- package/scripts/coverage_report.py +5 -0
- package/scripts/delivery.py +112 -0
- package/scripts/dream.py +41 -3
- package/scripts/emotion.py +202 -23
- package/scripts/gap_memory.py +186 -0
- package/scripts/growth.py +72 -8
- package/scripts/hsum.py +206 -0
- package/scripts/mem_score.py +92 -7
- package/scripts/memory.py +530 -60
- package/scripts/memory_extras.py +200 -0
- package/scripts/occ.py +190 -0
- package/scripts/panel_server.py +232 -142
- package/scripts/persona.py +2498 -2349
- package/scripts/prepublish_tests.py +90 -0
- package/scripts/release.py +326 -287
- package/scripts/rss_ingest.py +181 -0
- package/scripts/run_tests.py +13 -0
- package/scripts/session_import.py +832 -764
- package/scripts/shadow_memory.py +173 -0
- package/scripts/style_check.py +220 -0
- package/scripts/summarizer.py +343 -252
- package/scripts/timeline.py +118 -0
- package/scripts/update_dsh_copy.ps1 +110 -107
- package/scripts/watchdog.py +110 -0
- package/scripts/web_research.py +125 -0
- package/docs//344/272/244/346/216/245/347/254/224/350/256/260-20261128.md +0 -128
- package/docs//345/256/241/346/240/270/346/224/271/350/277/233/345/276/205/345/212/236.md +0 -408
|
@@ -0,0 +1,16 @@
|
|
|
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_*")])
|
|
@@ -0,0 +1,22 @@
|
|
|
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 子命令已加")
|
|
@@ -0,0 +1,108 @@
|
|
|
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("已存在")
|
|
@@ -0,0 +1,54 @@
|
|
|
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("未找到目标代码,可能已变动")
|
|
@@ -0,0 +1,26 @@
|
|
|
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)
|
|
@@ -0,0 +1,65 @@
|
|
|
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")
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:标记 §2 do-later 的 RRF/MMR(默认关)(可删)。"""
|
|
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
|
+
def mark(prefix, new):
|
|
10
|
+
for i, ln in enumerate(lines):
|
|
11
|
+
if ln.startswith(prefix):
|
|
12
|
+
lines[i] = new
|
|
13
|
+
return True
|
|
14
|
+
return False
|
|
15
|
+
|
|
16
|
+
ok1 = mark("| RRF 倒数排名融合 | S |",
|
|
17
|
+
"| RRF 倒数排名融合 | S · ✅ **已实现(opt-in,默认关)** | 配了 embed 后两路分数量纲不可比"
|
|
18
|
+
"(cosine 0.7~0.9 vs 词法 0.1~0.4),原来 `max()` 让向量单方面压过词法。"
|
|
19
|
+
"现在 `config rrf_fusion=true` 时改用名次融合(k=60),只看名次不看绝对分;"
|
|
20
|
+
"**默认关**:实测直接默认开会让 8 条既有排序断言失败(属调优,不该静默改变召回秩序) |")
|
|
21
|
+
ok2 = mark("| MMR 最大边际相关 | S |",
|
|
22
|
+
"| MMR 最大边际相关 | S · ✅ **已实现(opt-in,默认关)** | 侧抑制只砍 jaccard≥0.85;"
|
|
23
|
+
"0.6~0.85 的「同一件事换个说法」仍会占满注入预算。现在 `config mmr_diversity=true` 时"
|
|
24
|
+
"对已选结果做 MMR 重排(λ=`mmr_lambda` 默认 0.75)。**默认关**:同上,属调优 |")
|
|
25
|
+
p.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
|
26
|
+
print("RRF:", ok1, "| MMR:", ok2)
|
|
27
|
+
|
|
28
|
+
SEC = """
|
|
29
|
+
### §2 do-later:RRF / MMR(2026-11-29,opt-in)
|
|
30
|
+
|
|
31
|
+
- **RRF(`config rrf_fusion`)**:有向量分时把 `rel = max(词法, 向量)` 换成名次融合
|
|
32
|
+
`1/(60+rank_lex) + 1/(60+rank_dense)` 归一化。解决"精确关键词命中被语义近邻淹没"。
|
|
33
|
+
- **MMR(`config mmr_diversity`,`mmr_lambda` 默认 0.75)**:对已选结果做最大边际相关重排,
|
|
34
|
+
把 0.6~0.85 的"换说法"压下去,让注入预算容纳更多不同信息。
|
|
35
|
+
- **两者都默认关闭**:实测把它们默认打开会让 **8 条既有排序/注入断言**变红
|
|
36
|
+
(behavior_baseline、context_ab_wiring、context_stats、inject_lazy、p14、p18、p25、p26)。
|
|
37
|
+
这说明它们改的是**召回秩序**,属于调优项,必须 opt-in + 用 bench/抽样对照后再开。
|
|
38
|
+
- 打开后 smoke 通过(`recall` 正常返回、无异常),配置改回后一切照旧。
|
|
39
|
+
|
|
40
|
+
**怎么验证值不值得开**:`config set rrf_fusion true` 后跑 `bench.py --quick --check`,
|
|
41
|
+
再抽 3~5 个真实查询比对 `recall --json` 的命中顺序;不满意就 `config unset`。
|
|
42
|
+
"""
|
|
43
|
+
if "### §2 do-later:RRF / MMR" not in p.read_text(encoding="utf-8"):
|
|
44
|
+
d = p.read_text(encoding="utf-8").rstrip() + "\n" + SEC
|
|
45
|
+
p.write_text(d, encoding="utf-8")
|
|
46
|
+
print("已追加 RRF/MMR 记录")
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:更新待办里 §2/§3/§7 的状态(可删)。"""
|
|
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
|
+
# §2 do-now:表格里三行的"成本"列追加状态
|
|
10
|
+
d = d.replace("| **1** | **信息保留率度量**(硬锚保留率) | S |",
|
|
11
|
+
"| **1** | **信息保留率度量**(硬锚保留率) | S · ✅ **已做(2026-11-29)** |", 1)
|
|
12
|
+
d = d.replace("| **2** | **稳定性按 retrievability 缩放**(FSRS 式) | S |",
|
|
13
|
+
"| **2** | **稳定性按 retrievability 缩放**(FSRS 式) | S · ✅ **已做(2026-11-29)** |", 1)
|
|
14
|
+
d = d.replace("| **3** | **BM25 词频 + 长度归一** | M |",
|
|
15
|
+
"| **3** | **BM25 词频 + 长度归一** | M · ⬜ **待做(需 bench 前后对比)** |", 1)
|
|
16
|
+
|
|
17
|
+
SEC = """
|
|
18
|
+
### §2 落地记录(2026-11-29)
|
|
19
|
+
|
|
20
|
+
- **#1 信息保留率**:新增 `scripts/anchor_retention.py`(数字/版本/路径/日期/否定词/引号实体
|
|
21
|
+
六个类别的硬锚),暴露 `brain.py retention "<源>" "<新>"`;**并接进 `dream` 的
|
|
22
|
+
`_verify_pairs`**——每次合并都带 `anchor_retention`(rate + 分类明细 + 丢掉的锚),
|
|
23
|
+
于是"压缩后丢了什么"从"只能人看 3 组"变成可量化数字。`tests/test_anchor_retention.py` 5 条。
|
|
24
|
+
- **#2 稳定性按 retrievability 缩放**:`memory.recall` 的巩固倍率改为
|
|
25
|
+
`mult = base × (1 + g·(1-R))`(g:首次 0.60 / 反复 0.35 / 顺带 0.15;上限 4.0),
|
|
26
|
+
常量在 `core.py`。**间隔效应回来了**:刚见过的只拿基础倍率,久别重逢的加成最大。
|
|
27
|
+
全套测试 103/103 未受影响(原有用例不依赖具体 stability 值)。
|
|
28
|
+
- **#3 BM25 未做**:它改的是 relevance(占五元权重 0.55 的最大项),必须先用
|
|
29
|
+
`bench.py --quick --save` 存基线、改完再 `--check` 用数字说话;本轮已把
|
|
30
|
+
`check_docs`/`retention` 两个工具补齐,下轮单独做这一条更稳妥。
|
|
31
|
+
|
|
32
|
+
### §3 文档审查落地记录(2026-11-29)
|
|
33
|
+
|
|
34
|
+
- **C 先做**:新增 `scripts/check_docs.py`——从代码现算(情绪名 48 / doctor 项 / 面板页签 16 /
|
|
35
|
+
设置项 39·组 7 / CLI 命令数)并与 `SKILL.md`·`README.md` 里抓到的数字比对,不一致非零退出;
|
|
36
|
+
顺带校验"文档里写的 `brain.py <cmd>` 是否真实存在"(对隐藏命令如 `skill` 会真跑 `--help` 验证)。
|
|
37
|
+
**它一上线就抓出 6 处不一致**,正好证明这类错是手写导致的。
|
|
38
|
+
- **A 已修**:doctor 17→**23**(README 的 13 也改)、页签 15→**16**、设置 29→**39**(组 6→7)、
|
|
39
|
+
CLI 75→**73**、`brain.py panel`→**`serve`**。
|
|
40
|
+
- **B 已核实并修 6 条**:`lessons` 无子命令(只有 `--bad/--confidence/--evidence`)、
|
|
41
|
+
`topic` 实为 `list|touch|feedback|drop|status`、`session-summary` 是开关式、
|
|
42
|
+
`startup` 也接受 `--budget/--minimal`(拒绝的是位置参数,不写了)、
|
|
43
|
+
备份修剪已改「移入 `.pruned/`」、`skill install` 补 `--yes`。
|
|
44
|
+
**未改**:`docs/panel-api.md:26` 的"没有云端后端"表述——那是产品口径,需你拍板后再统一。
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
if "### §2 落地记录" not in d:
|
|
48
|
+
d = d.rstrip() + "\n" + SEC
|
|
49
|
+
print("已追加 §2/§3 落地记录")
|
|
50
|
+
|
|
51
|
+
# §7 #37 标已修
|
|
52
|
+
for i, ln in enumerate(d.splitlines()):
|
|
53
|
+
if ln.startswith("| 37 |"):
|
|
54
|
+
new = ("| 37 | `cli.py` doctor `log-anomalies` | 我把 `kind=inject` 整类排除后,"
|
|
55
|
+
"**注入包超预算就再没有任何体检项覆盖了**(`context-stats` 只是命令,doctor 不跑它)"
|
|
56
|
+
"——这是上一轮修噪音时留下的新窟窿 "
|
|
57
|
+
"| ✅ **已修**(2026-11-29):doctor 新增 `inject-budget`——真跑一次装配,"
|
|
58
|
+
"按账单口径比 token 与预算(同时看插件默认 1400 与 config `budget_tokens`,取最差那个);"
|
|
59
|
+
"超了给超量与字符数,并指向 `context-stats`/`inject`。实测 PASS(1040/1400) |")
|
|
60
|
+
d = d.replace(ln, new, 1)
|
|
61
|
+
print("§7 #37 已标已修")
|
|
62
|
+
break
|
|
63
|
+
|
|
64
|
+
p.write_text(d, encoding="utf-8")
|
|
65
|
+
|
|
66
|
+
counts = {"done": 0, "todo": 0, "excl": 0}
|
|
67
|
+
for ln in d.splitlines():
|
|
68
|
+
if not re.match(r"^\|\s*[A-Z]?\d+\s*\|", ln):
|
|
69
|
+
continue
|
|
70
|
+
if "✅" in ln:
|
|
71
|
+
counts["done"] += 1
|
|
72
|
+
elif "⬜" in ln:
|
|
73
|
+
counts["todo"] += 1
|
|
74
|
+
elif "🔍" in ln:
|
|
75
|
+
counts["excl"] += 1
|
|
76
|
+
stat = (f"> **状态统计(编号任务行)**:✅ {counts['done']} 已修 / "
|
|
77
|
+
f"⬜ {counts['todo']} 待修 / 🔍 {counts['excl']} 已排除(含 §7/§8)")
|
|
78
|
+
d2 = re.sub(r"> \*\*状态统计(编号任务行)\*\*[^\n]*", stat, d, count=1)
|
|
79
|
+
p.write_text(d2, encoding="utf-8")
|
|
80
|
+
print(stat)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:更新 README 页签数 + 待办 §4 状态(可删)。"""
|
|
3
|
+
import re
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
ROOT = Path(r"E:\丁厚同\文档\程序\灵枢-skill")
|
|
7
|
+
|
|
8
|
+
rd = (ROOT / "README.md").read_text(encoding="utf-8")
|
|
9
|
+
n1 = rd.count("**16 个页签**")
|
|
10
|
+
rd = rd.replace("**16 个页签**", "**17 个页签**")
|
|
11
|
+
n2 = rd.count("面板有 16 个页签")
|
|
12
|
+
rd = rd.replace("面板有 16 个页签", "面板有 17 个页签")
|
|
13
|
+
(ROOT / "README.md").write_text(rd, encoding="utf-8")
|
|
14
|
+
print(f"README: 页签 16→17({n1} + {n2} 处)")
|
|
15
|
+
|
|
16
|
+
p = ROOT / "docs" / "审核改进待办.md"
|
|
17
|
+
d = p.read_text(encoding="utf-8")
|
|
18
|
+
|
|
19
|
+
SEC = """
|
|
20
|
+
### §4 落地记录(2026-11-29)
|
|
21
|
+
|
|
22
|
+
| 项 | 结论 |
|
|
23
|
+
|---|---|
|
|
24
|
+
| `coverage_report.py` 的 `inject` 步骤 | ✅ **文档过期,代码本来就是对的**(用的是 `mem.build_injection`,实测能跑通)。顺手修了真问题:报告中把 `_tmp_*`/`_smoke_*`/`_sync_*` 这类**下划线开头的运维脚本**算成 0% 覆盖,把"最低覆盖 10 项"刷满噪音——现在跳过下划线开头的文件 |
|
|
25
|
+
| `bench.py --quick --check` 接发布流程 | ✅ 已接:`release.py publish --deep`(默认不跑,219s 太重;失败即中止发布) |
|
|
26
|
+
| 体检历史页签 | ✅ 已做:新增 `data-tab="dochealth"` + `view-dochealth` + `panel_src/js/dochealth.js`(独立监听导航点击,**不改 core.js 的 switchTab**,少一处回归面)。渲染 `/api/doctor-history`:按天 PASS/WARN/FAIL + 三色占比条 + 成长阶段。已在 `blocks.json` 注册并补 `<!--@@BLOCK:9@@-->` 占位(**构建只认占位符,漏了会被静默丢弃**——这次踩到了) |
|
|
27
|
+
| P2-1 RSS 摄入 | ⬜ 未做(20h;建议按"本地 RSS/Atom 文件或显式 URL 列表 + 默认关闭"收窄后再立项) |
|
|
28
|
+
| 拆分 `scripts/` 与 `engine/scripts/` 双份维护 | ⬜ 未做(改动量最大,需单独立项;当前靠 `sync_engine.py` + doctor `engine-sync` 兜着) |
|
|
29
|
+
| 三个 4500 行模块继续拆(growth/cli/memory) | ⬜ 未做(同上,属结构性重构,不适合夹在功能里做) |
|
|
30
|
+
|
|
31
|
+
**面板页签数因此变成 17**(新增"体检历史"),`check_docs.py` 当场就把 README 的 16 抓出来了——
|
|
32
|
+
这次是它第二次证明自己有用。
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
if "### §4 落地记录" not in d:
|
|
36
|
+
i = d.find("## §5")
|
|
37
|
+
d = d[:i] + SEC + "\n" + d[i:] if i > 0 else d.rstrip() + "\n" + SEC
|
|
38
|
+
print("已插入 §4 落地记录")
|
|
39
|
+
p.write_text(d, encoding="utf-8")
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:更新 §7 里 35/38/39/41/42 的状态(可删)。"""
|
|
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
|
+
NEW = {
|
|
9
|
+
"| 35 |": ("| 35 | `~/.brain-memory/.safety/` | 回滚快照**只增不减**:`.safety` 共 27.7MB / 300 文件,"
|
|
10
|
+
"其中 `.pruned` 19.7MB / 220 文件。用户规矩是「只移不删」,所以**不能自动清**,"
|
|
11
|
+
"但至少该有容量告警 | ✅ **已修**(2026-11-29):doctor 新增 `disk-usage`——"
|
|
12
|
+
"报快照/快照`.pruned`/备份`.pruned` 的占用与文件数;阈值 `快照>50MB`、"
|
|
13
|
+
"`快照.pruned>30MB`、`备份.pruned>100MB` 才 WARN,并在信息里写清「不会自动清,"
|
|
14
|
+
"确认无用可手动清空」。实测当前 PASS(27.7MB / 19.7MB / 30.6MB) |"),
|
|
15
|
+
"| 38 |": ("| 38 | 仓库 `scripts/` | 积了 **18 个 `_tmp_*` 一次性脚本**(探针/补丁)。"
|
|
16
|
+
"虽已 gitignore、不入交付,但会污染 grep 与 IDE 搜索 | ✅ **已修**(2026-11-29):"
|
|
17
|
+
"全部**移入** `scripts/_scratch/`(只移不删,带 `_来源记录.txt`),"
|
|
18
|
+
"并把该目录加进 `.gitignore`;实测迁入 25 个 |"),
|
|
19
|
+
"| 39 |": ("| 39 | `tests/` | `git status` 显示 **58 条改动/未跟踪**。"
|
|
20
|
+
"\"只提交已跟踪测试\"全靠手工 `git reset`,容易漏(漏了就把本地测试推上去) "
|
|
21
|
+
"| ✅ **已修**(2026-11-29):新增 `scripts/prepublish_tests.py`——"
|
|
22
|
+
"以 `git ls-tree -r HEAD --name-only tests/` 为准求差集,干跑列出会被误提交的测试,"
|
|
23
|
+
"`--apply` 才执行 `git reset`。实测 HEAD 跟踪 45 个、当前暂存 0 个 |"),
|
|
24
|
+
"| 41 |": ("| 41 | `scripts/app_context.py` | `context` 每次**全量解压**会话文件"
|
|
25
|
+
"(旧会话可达 11MB),`sessions`/`analyze` 在大会话上偏慢 | 🔍 **已实测排除**(2026-11-29):"
|
|
26
|
+
"在本机最大会话上实测 `context status` **0.30 秒**、`context sessions` **0.13 秒**——"
|
|
27
|
+
"zstd 解压足够快,加缓存只会增加失效逻辑和磁盘残留。**决定不做**,"
|
|
28
|
+
"等真的出现秒级卡顿再回来看 |"),
|
|
29
|
+
"| 42 |": ("| 42 | `cli.py:_PLUGIN_VERIFY_FILES` | B2 的核对清单是**硬编码 7 个文件**;"
|
|
30
|
+
"以后新增脚本不会被覆盖到,等于留了个盲区 | ✅ **已修**(2026-11-29):"
|
|
31
|
+
"改为 `_plugin_verify_files()` 从 `manifest.json` **自动取**"
|
|
32
|
+
"(`scripts/*.py` + `cordis-plugin/**/*.js`),读不到 manifest 才回退硬编码元组;"
|
|
33
|
+
"核对范围从 7 个文件扩到 manifest 全量 |"),
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
hit = 0
|
|
37
|
+
for i, ln in enumerate(lines):
|
|
38
|
+
for prefix, new in NEW.items():
|
|
39
|
+
if ln.startswith(prefix):
|
|
40
|
+
lines[i] = new
|
|
41
|
+
hit += 1
|
|
42
|
+
p.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
|
43
|
+
print("已更新行数:", hit, "(应为 5)")
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:追加 §8(面板审计/版本徽章/淡忘自动归档),并更新统计(可删)。"""
|
|
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
|
+
## §8 面板真实性 / 版本徽章 / 淡忘区自动归档(2026-11-29)
|
|
11
|
+
|
|
12
|
+
### 8.1 面板显示是真实的吗——审计结论
|
|
13
|
+
|
|
14
|
+
逐项与 CLI 对账(同一时刻取数):
|
|
15
|
+
|
|
16
|
+
| 面板字段 | 面板值 | CLI 真值 | 结论 |
|
|
17
|
+
|---|---|---|---|
|
|
18
|
+
| `layer_counts` | hippo 73 / cortex 59 / dust 283 / archive 0 | `brain.stats()` 完全一致 | ✅ 真实 |
|
|
19
|
+
| `water.pct` | 0.59 | `_water_level()` 0.59 | ✅ 真实 |
|
|
20
|
+
| `stats` | 与 `brain.stats()` 逐字段相等 | — | ✅ 真实 |
|
|
21
|
+
| `source.version` | 5.34 | 仓库 SKILL.md | ✅ 真实(后端本来就有,只是前端没显示) |
|
|
22
|
+
|
|
23
|
+
**两个"看起来不真实"的点,其实是别的原因**:
|
|
24
|
+
1. **记忆列表最多 80 条**(`overview()` 里 `ordered[:80]`)——所以"计数 283、列表里没那么多"
|
|
25
|
+
不是造假,是**有意的截断**。已在文档记明;如需全量请用面板搜索/`context`。
|
|
26
|
+
2. 前端里有 6 处 `v5.12` 字样,全是**代码注释**(`<!-- v5.12 … -->`),不是显示内容。
|
|
27
|
+
|
|
28
|
+
### 8.2 版本徽章(用户要求)
|
|
29
|
+
|
|
30
|
+
页头常驻版本号:`panel_src/index.html` 加 `#panel-ver`,`panel_src/js/core.js` 在
|
|
31
|
+
`renderOverview()` 里用 **`ov.source.version`** 填(后端读仓库真实版本),
|
|
32
|
+
`panel_src/styles/base.css` 加 `.brand .ver` 样式。**不写死**——写死的版本号迟早和
|
|
33
|
+
真实代码对不上(前端那几个 v5.12 注释就是活证据)。悬停显示 `script_dir`。
|
|
34
|
+
|
|
35
|
+
### 8.3 淡忘区自动归档(用户要求:做梦时自动归档)
|
|
36
|
+
|
|
37
|
+
**先纠正一个误报**:`diagnose` 一直喊「淡忘区 283 条已超过活跃层总和」,但实测
|
|
38
|
+
**283 条里 255 条是 `verbatim` 封存原文**(用户明确要保真),本来就不该折也不该归档;
|
|
39
|
+
真正可回收只有 **28 条**。已把口径改成「可回收量 vs 活跃层」,并在信息里带出受保护条数。
|
|
40
|
+
|
|
41
|
+
**为什么以前自动不了**:`_is_archivable()` 只认 `hippo/cortex`,**淡忘区永远不会被常规
|
|
42
|
+
归档选中**,所以 `archive run` 干跑是 0 条。
|
|
43
|
+
|
|
44
|
+
**新做法(可逆、守规矩)**:
|
|
45
|
+
- `memory.dust_archive(keep=config.dust_archive_keep|200)`:只把**超出 keep 的最旧那部分**
|
|
46
|
+
移进 archive 层(先写 `archive.jsonl` 再摘热层,顺序上防丢);
|
|
47
|
+
不碰 `pinned / verbatim / identity / 待审`;keep 之内或池子空了就 no-op。
|
|
48
|
+
- 入口:`brain.py archive dust [--keep N] [--dry-run]`;
|
|
49
|
+
**`dream --auto` 结束后顺带跑一次**(用户要的"做梦自动化");
|
|
50
|
+
另外 cron 每日任务 `dustarchive` 兜底(即使做梦不触发也能清)。
|
|
51
|
+
- 实测:**dust 283 → 255,archive 0 → 28**;`archive restore <id>` 可回热。
|
|
52
|
+
- 回归:`tests/test_dust_archive.py` 4 条(只动非保护项 / keep 内 no-op /
|
|
53
|
+
干跑不写盘 / 全受保护时返回 0)。
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
if "## §8 面板真实性" in d:
|
|
57
|
+
print("§8 已存在,跳过")
|
|
58
|
+
else:
|
|
59
|
+
d = d.rstrip() + "\n" + SEC
|
|
60
|
+
print("已追加 §8")
|
|
61
|
+
|
|
62
|
+
counts = {"done": 0, "todo": 0, "excl": 0}
|
|
63
|
+
for ln in d.splitlines():
|
|
64
|
+
if not re.match(r"^\|\s*[A-Z]?\d+\s*\|", ln):
|
|
65
|
+
continue
|
|
66
|
+
if "✅" in ln:
|
|
67
|
+
counts["done"] += 1
|
|
68
|
+
elif "⬜" in ln:
|
|
69
|
+
counts["todo"] += 1
|
|
70
|
+
elif "🔍" in ln:
|
|
71
|
+
counts["excl"] += 1
|
|
72
|
+
stat = (f"> **状态统计(编号任务行)**:✅ {counts['done']} 已修 / "
|
|
73
|
+
f"⬜ {counts['todo']} 待修 / 🔍 {counts['excl']} 已排除(含 §7/§8)")
|
|
74
|
+
d = re.sub(r"> \*\*状态统计(编号任务行)\*\*[^\n]*", stat, d, count=1)
|
|
75
|
+
p.write_text(d, encoding="utf-8")
|
|
76
|
+
print(stat)
|
|
77
|
+
|
|
78
|
+
# SKILL.md 补一条 draft 命令
|
|
79
|
+
sk = Path(r"E:\丁厚同\文档\程序\灵枢-skill\SKILL.md")
|
|
80
|
+
sd = sk.read_text(encoding="utf-8")
|
|
81
|
+
if "archive dust" not in sd:
|
|
82
|
+
old = "python scripts/brain.py archive show|search|restore|run"
|
|
83
|
+
new = ("python scripts/brain.py archive show|search|restore|run|dust # dust=淡忘区超量自动归档"
|
|
84
|
+
"(dream --auto 也会顺带跑)")
|
|
85
|
+
if old in sd:
|
|
86
|
+
sk.write_text(sd.replace(old, new, 1), encoding="utf-8")
|
|
87
|
+
print("SKILL.md 已补 archive dust")
|
|
88
|
+
else:
|
|
89
|
+
print("SKILL.md 未找到 archive 行,跳过")
|
|
90
|
+
else:
|
|
91
|
+
print("SKILL.md 已有 archive dust")
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:给 SKILL.md 的命令表补 archive dust(可删)。"""
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\SKILL.md")
|
|
6
|
+
d = p.read_text(encoding="utf-8")
|
|
7
|
+
anchor = "python scripts/brain.py memory show|boost|freeze|unfreeze|integrity|shape-audit|diagnose"
|
|
8
|
+
line = ("python scripts/brain.py archive show|search|restore|run|dust "
|
|
9
|
+
"# dust=淡忘区超量自动归档(dream --auto 也会顺带跑)")
|
|
10
|
+
if "archive show|search|restore|run|dust" in d:
|
|
11
|
+
print("已存在,跳过")
|
|
12
|
+
elif anchor in d:
|
|
13
|
+
d = d.replace(anchor, anchor + "\n" + line, 1)
|
|
14
|
+
p.write_text(d, encoding="utf-8")
|
|
15
|
+
print("已插入 archive dust 行")
|
|
16
|
+
else:
|
|
17
|
+
print("没找到锚点,未改动")
|