lingshu-skill 5.33.0 → 5.37.1
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,82 @@
|
|
|
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 锚点未找到")
|
|
@@ -0,0 +1,40 @@
|
|
|
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)
|
|
@@ -0,0 +1,81 @@
|
|
|
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")
|
|
@@ -0,0 +1,39 @@
|
|
|
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("未发现待清理文档。")
|
|
@@ -0,0 +1,17 @@
|
|
|
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)
|
|
@@ -0,0 +1,35 @@
|
|
|
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 落地记录")
|
|
@@ -0,0 +1,27 @@
|
|
|
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)))
|
|
@@ -0,0 +1,40 @@
|
|
|
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 ""))
|
|
@@ -0,0 +1,35 @@
|
|
|
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()
|
|
@@ -0,0 +1,63 @@
|
|
|
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])
|
|
@@ -0,0 +1,51 @@
|
|
|
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])
|
|
@@ -0,0 +1,54 @@
|
|
|
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])
|
|
@@ -0,0 +1,39 @@
|
|
|
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 已补")
|
|
@@ -0,0 +1,43 @@
|
|
|
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")
|