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,57 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:给 release.py publish 加发布前置守卫(可删)。"""
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\release.py")
|
|
6
|
+
d = p.read_text(encoding="utf-8")
|
|
7
|
+
|
|
8
|
+
anchor = "def do_publish(wait_minutes: int) -> int:"
|
|
9
|
+
guard = '''def _publish_preflight() -> int:
|
|
10
|
+
"""发布前置守卫(§4 二-B 流程固化):发布物过期是最隐蔽的事故——
|
|
11
|
+
registry 上能看到新版本号,装下来却是旧代码。
|
|
12
|
+
|
|
13
|
+
两道检查都是只读的(`--check` 不写文件):
|
|
14
|
+
1. engine 副本(发布包里的派生脚本)
|
|
15
|
+
2. 已安装副本(宿主实际加载的那份)
|
|
16
|
+
"""
|
|
17
|
+
checks = (("scripts/sync_engine.py", "engine 副本"),
|
|
18
|
+
("scripts/_sync_trae_cn.py", "已安装副本"))
|
|
19
|
+
for script, label in checks:
|
|
20
|
+
try:
|
|
21
|
+
rc, _ = _run([script, "--check"])
|
|
22
|
+
except Exception as exc: # noqa: BLE001
|
|
23
|
+
print(f"[release] 守卫执行失败({label}):{exc}", file=sys.stderr)
|
|
24
|
+
return 1
|
|
25
|
+
if rc != 0:
|
|
26
|
+
print(f"[release] 发布中止:{label}与源码不一致(差异见上)。"
|
|
27
|
+
"先跑对应同步脚本,再发布。", file=sys.stderr)
|
|
28
|
+
return 1
|
|
29
|
+
print("[release] 前置守卫通过:engine 副本与已安装副本都与源码一致")
|
|
30
|
+
return 0
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
'''
|
|
34
|
+
if "_publish_preflight" not in d:
|
|
35
|
+
d = d.replace(anchor, guard + anchor, 1)
|
|
36
|
+
print("守卫函数已加")
|
|
37
|
+
|
|
38
|
+
old_body = '''def do_publish(wait_minutes: int) -> int:'''
|
|
39
|
+
# 在函数体开头插入调用:找到函数定义后的第一个空行注释或第一行
|
|
40
|
+
idx = d.find(old_body)
|
|
41
|
+
if idx >= 0:
|
|
42
|
+
line_end = d.find("\n", idx) + 1
|
|
43
|
+
# 跳过紧跟的 docstring(如有)
|
|
44
|
+
rest = d[line_end:line_end + 200]
|
|
45
|
+
insert_at = line_end
|
|
46
|
+
if rest.lstrip().startswith('"""'):
|
|
47
|
+
# 找到 docstring 结束
|
|
48
|
+
start_q = d.find('"""', line_end)
|
|
49
|
+
end_q = d.find('"""', start_q + 3)
|
|
50
|
+
insert_at = d.find("\n", end_q) + 1
|
|
51
|
+
call = (" # 发布前置守卫:副本过期就中止(只读检查)\n"
|
|
52
|
+
" if _publish_preflight() != 0:\n"
|
|
53
|
+
" return 1\n")
|
|
54
|
+
if "_publish_preflight()" not in d:
|
|
55
|
+
d = d[:insert_at] + call + d[insert_at:]
|
|
56
|
+
print("守卫调用已插入")
|
|
57
|
+
p.write_text(d, encoding="utf-8")
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:#4 把熔断推广到 reranker(可删)。"""
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
core = Path(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\core.py")
|
|
6
|
+
d = core.read_text(encoding="utf-8")
|
|
7
|
+
|
|
8
|
+
# 1) 配置项(rerank 段里加 fail_cooldown_sec)
|
|
9
|
+
old_cfg = ''' "rerank": {
|
|
10
|
+
"url": "",'''
|
|
11
|
+
new_cfg = ''' "rerank": {
|
|
12
|
+
# 连不上 reranker 时冷却 N 秒不再试:单机跑本地服务,没启动是常态不是异常,
|
|
13
|
+
# 不冷却的话 deep 模式每次召回都要白等满 timeout_sec(默认 3s)。
|
|
14
|
+
"fail_cooldown_sec": 300,
|
|
15
|
+
"url": "",'''
|
|
16
|
+
if '"fail_cooldown_sec": 300,\n "url": ""' not in d:
|
|
17
|
+
d = d.replace(old_cfg, new_cfg, 1)
|
|
18
|
+
print("配置项已加")
|
|
19
|
+
|
|
20
|
+
# 2) 熔断状态 + 早退
|
|
21
|
+
old_head = ''' cfg = _rerank_cfg()
|
|
22
|
+
if not cfg or not docs:
|
|
23
|
+
return None'''
|
|
24
|
+
new_head = ''' cfg = _rerank_cfg()
|
|
25
|
+
if not cfg or not docs:
|
|
26
|
+
return None
|
|
27
|
+
# 熔断(同 embed 的 fail_cooldown_sec 思路):上次失败后冷却期内直接放弃,
|
|
28
|
+
# 不进入网络调用——否则 deep 模式每次召回都白等满 timeout_sec。
|
|
29
|
+
global _rerank_fail_until
|
|
30
|
+
_now = time.time()
|
|
31
|
+
if _now < _rerank_fail_until:
|
|
32
|
+
return None'''
|
|
33
|
+
if "_rerank_fail_until" not in d:
|
|
34
|
+
d = d.replace(old_head, new_head, 1)
|
|
35
|
+
print("早退已加")
|
|
36
|
+
|
|
37
|
+
# 3) 失败时置冷却
|
|
38
|
+
old_err = ''' except Exception as exc:
|
|
39
|
+
log_event("rerank", f"reranker 调用失败,退回加权合并:{exc}", level="warn")
|
|
40
|
+
return None'''
|
|
41
|
+
new_err = ''' except Exception as exc:
|
|
42
|
+
try:
|
|
43
|
+
_cd = float((cfg or {}).get("fail_cooldown_sec") or 300)
|
|
44
|
+
except (TypeError, ValueError):
|
|
45
|
+
_cd = 300.0
|
|
46
|
+
_rerank_fail_until = time.time() + max(0.0, _cd)
|
|
47
|
+
log_event("rerank", f"reranker 调用失败,{int(_cd)} 秒内不再重试,退回加权合并:{exc}",
|
|
48
|
+
level="warn")
|
|
49
|
+
return None'''
|
|
50
|
+
if "_rerank_fail_until = time.time()" not in d:
|
|
51
|
+
d = d.replace(old_err, new_err, 1)
|
|
52
|
+
print("冷却写入已加")
|
|
53
|
+
|
|
54
|
+
# 4) 模块级状态变量(放在 rerank_docs 之前)
|
|
55
|
+
old_def = "def rerank_docs(query: str, docs: list, top_n: int | None = None) -> list | None:"
|
|
56
|
+
new_def = ('_rerank_fail_until: float = 0.0 # 熔断截止时间戳(0 = 未熔断)\n\n\n'
|
|
57
|
+
+ old_def)
|
|
58
|
+
if "_rerank_fail_until: float = 0.0" not in d:
|
|
59
|
+
d = d.replace(old_def, new_def, 1)
|
|
60
|
+
print("状态变量已加")
|
|
61
|
+
|
|
62
|
+
core.write_text(d, encoding="utf-8")
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:记 #55 心跳诊断待办(可删)。"""
|
|
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
|
+
## §15 重启后心跳不再更新(#55,2026-11-30 未定论)
|
|
10
|
+
|
|
11
|
+
### 现象
|
|
12
|
+
|
|
13
|
+
- 用户 19:57 重启 APP 后,`~/.brain-memory/.host-heartbeat.json` 的 `ts` 停在 **19:27**(重启前),
|
|
14
|
+
此后 80+ 分钟未更新;doctor `host-heartbeat` 持续 WARN。
|
|
15
|
+
- 同一时刻 `plugin-loaded` 只报"副本比最近一次会话开始新"(说明 startup 侧确实跑过:注入包正常出现),
|
|
16
|
+
但 **cron 子插件的 `agent/turn-stopping` 心跳没写**。
|
|
17
|
+
|
|
18
|
+
### 已排除
|
|
19
|
+
|
|
20
|
+
- 心跳路径没错(`~/.brain-memory/.host-heartbeat.json` 确实存在,内容是 `{ts,pid,iso}`);
|
|
21
|
+
- 不是磁盘/权限问题(文件可读可写,历史心跳正常);
|
|
22
|
+
- `lingshu.log` 近 3 小时没有任何 cron/plugin 相关错误行(插件不打加载日志)。
|
|
23
|
+
|
|
24
|
+
### 已加探针(下次重启即可定论)
|
|
25
|
+
|
|
26
|
+
`cordis-plugin/lingshu-cron/plugin.js` 的 `apply()` 现在会打一行
|
|
27
|
+
`[lingshu-cron] mounted`。下次重启后:
|
|
28
|
+
- **有这行** → cron 已挂载,问题在 `agent/turn-stopping` 未触发或 `beatHost` 抛错(继续查 handler);
|
|
29
|
+
- **没这行** → cron 子插件没加载(查 profile 插件启用列表 / 重复挂载守卫是否把第二次挂载挡掉)。
|
|
30
|
+
|
|
31
|
+
### 可能原因(待验证,不猜死)
|
|
32
|
+
|
|
33
|
+
1. 根 `index.js` 用**静态 import** 挂 4 个子插件,任一子插件 apply 抛错可能只影响自己;
|
|
34
|
+
2. 重复挂载守卫(v3.23)在"独立包 + 根包"同时启用时可能挡掉第二次挂载;
|
|
35
|
+
3. 本会话的 agent 可能不触发 `agent/turn-stopping`(不同宿主入口)。
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
if "#55,2026-11-30 未定论" not in d:
|
|
39
|
+
d = d.rstrip() + "\n\n" + SEC
|
|
40
|
+
p.write_text(d, encoding="utf-8")
|
|
41
|
+
print("已记 #55")
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:在 app.asar 里找 contextPressure 实现片段(可删)。"""
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
PATH = r"D:\APP\resources\app.asar"
|
|
6
|
+
NEEDLES = [b"contextPressure", b"pressureTokens"]
|
|
7
|
+
|
|
8
|
+
def scan(path, needle, limit=3, ctx=420):
|
|
9
|
+
hits = 0
|
|
10
|
+
overlap = b""
|
|
11
|
+
with open(path, "rb") as f:
|
|
12
|
+
while True:
|
|
13
|
+
chunk = f.read(8 << 20)
|
|
14
|
+
if not chunk:
|
|
15
|
+
break
|
|
16
|
+
buf = overlap + chunk
|
|
17
|
+
start = 0
|
|
18
|
+
while hits < limit:
|
|
19
|
+
i = buf.find(needle, start)
|
|
20
|
+
if i < 0:
|
|
21
|
+
break
|
|
22
|
+
seg = buf[max(0, i - ctx): i + ctx]
|
|
23
|
+
try:
|
|
24
|
+
text = seg.decode("utf-8", "replace")
|
|
25
|
+
except Exception:
|
|
26
|
+
text = str(seg)
|
|
27
|
+
print(f"--- {needle.decode()} @ ~{i} (chunk) ---")
|
|
28
|
+
print(text.replace("\x00", " ")[:900])
|
|
29
|
+
print()
|
|
30
|
+
hits += 1
|
|
31
|
+
start = i + 1
|
|
32
|
+
if hits >= limit:
|
|
33
|
+
return hits
|
|
34
|
+
overlap = buf[-len(needle) - 8:]
|
|
35
|
+
return hits
|
|
36
|
+
|
|
37
|
+
for n in NEEDLES:
|
|
38
|
+
got = scan(PATH, n)
|
|
39
|
+
print(f"[{n.decode()}] 命中 {got} 处")
|
|
40
|
+
if got:
|
|
41
|
+
break
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:扫 asar 里 projectedTokens / 自动压缩 的实现片段(可删)。"""
|
|
3
|
+
import glob
|
|
4
|
+
|
|
5
|
+
PATH = glob.glob("D:/*/resources/app.asar")[0]
|
|
6
|
+
NEEDLES = [b"projectedTokens", b"compactThreshold", b"autoCompact", b"contextWindow"]
|
|
7
|
+
|
|
8
|
+
def scan(needle, limit=2, ctx=700):
|
|
9
|
+
hits = 0
|
|
10
|
+
overlap = b""
|
|
11
|
+
with open(PATH, "rb") as f:
|
|
12
|
+
while True:
|
|
13
|
+
chunk = f.read(8 << 20)
|
|
14
|
+
if not chunk:
|
|
15
|
+
break
|
|
16
|
+
buf = overlap + chunk
|
|
17
|
+
start = 0
|
|
18
|
+
while hits < limit:
|
|
19
|
+
i = buf.find(needle, start)
|
|
20
|
+
if i < 0:
|
|
21
|
+
break
|
|
22
|
+
seg = buf[max(0, i - 120): i + ctx]
|
|
23
|
+
print(f"--- {needle.decode()} ---")
|
|
24
|
+
print(seg.decode("utf-8", "replace").replace("\x00", " ")[:760])
|
|
25
|
+
print()
|
|
26
|
+
hits += 1
|
|
27
|
+
start = i + 1
|
|
28
|
+
if hits >= limit:
|
|
29
|
+
return hits
|
|
30
|
+
overlap = buf[-len(needle) - 8:]
|
|
31
|
+
return hits
|
|
32
|
+
|
|
33
|
+
for n in NEEDLES:
|
|
34
|
+
got = scan(n)
|
|
35
|
+
print(f"[{n.decode()}] 命中 {got}")
|
|
36
|
+
if not got:
|
|
37
|
+
continue
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:更新结构性两项状态(可删)。"""
|
|
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
|
+
d = d.replace(
|
|
10
|
+
"| 拆分 `scripts/` 与 `engine/scripts/` 双份维护 | ⬜ 未做(改动量最大,需单独立项;当前靠 `sync_engine.py` + doctor `engine-sync` 兜着) |",
|
|
11
|
+
"| 拆分 `scripts/` 与 `engine/scripts/` 双份维护 | ✅ **已按方案 B(流程固化)完成**(2026-11-30):\n"
|
|
12
|
+
"① `run_tests.py` 跑测前幂等同步;② `_sync_trae_cn.py` 加 `--check`(只读校验已安装副本);\n"
|
|
13
|
+
"③ `release.py publish` 加**发布前置守卫**(两份副本任一过期就中止发布——发布物过期是最隐蔽的事故);\n"
|
|
14
|
+
"④ doctor `engine-sync` 已是 FAIL 级。**真拆(符号链接/构建时拷)不做**:`engine/` 本就是发布产物且被 gitignore,\n"
|
|
15
|
+
"风险在'忘记同步'而非'合并冲突',流程固化已根治 |")
|
|
16
|
+
d = d.replace(
|
|
17
|
+
"| 三个 4500 行模块继续拆(growth/cli/memory) | ⬜ 未做(同上,属结构性重构,不适合夹在功能里做) |",
|
|
18
|
+
"| 三个 4500 行模块继续拆(growth/cli/memory) | 🟡 **第一步已完成**(2026-11-30):`memory.py` 的\n"
|
|
19
|
+
"`from mem_score import *` 换成**按 `__all__` 显式导入**(13 个名字,含 `_num`/`_cosine_sim` 等私有名),\n"
|
|
20
|
+
"调用面契约(同一对象、`from memory import *` 可用)由测试锁住。剩余:cli 按命令组拆包、\n"
|
|
21
|
+
"memory 按 store/recall/archive 分文件、growth 最后动 |")
|
|
22
|
+
|
|
23
|
+
SEC = """
|
|
24
|
+
### 结构性两项落地记录(2026-11-30,用户要求"弄3")
|
|
25
|
+
|
|
26
|
+
**① 双份维护 → 按方案 B 完成(流程固化,不真拆)**
|
|
27
|
+
|
|
28
|
+
| 环节 | 做法 |
|
|
29
|
+
|---|---|
|
|
30
|
+
| 跑测 | `run_tests.py` 开头幂等跑 `sync_engine.py`(漏同步不再把测试弄红) |
|
|
31
|
+
| 校验 | `sync_engine.py --check` 与 `_sync_trae_cn.py --check` 都可只读判漂移 |
|
|
32
|
+
| 发布 | `release.py publish` 前置守卫:engine 副本 + 已安装副本任一不一致 → **中止发布** |
|
|
33
|
+
| 体检 | doctor `engine-sync` 已是 FAIL 级 |
|
|
34
|
+
|
|
35
|
+
守卫上线即抓到一次真漂移(`release.py` 自己没同步)——说明它不是摆设。
|
|
36
|
+
|
|
37
|
+
**② 三模块拆分 → 只做第一步**
|
|
38
|
+
|
|
39
|
+
`memory.py` 末尾的 `from mem_score import *` 改成按 `__all__` 显式导入。契约(同一对象、
|
|
40
|
+
`from memory import *` 仍可用、不留同名空壳)由 `test_memory_surface_reexport_contract` 锁住;
|
|
41
|
+
该测试原先断言"必须保留星号",已改为断言"显式导入存在且星号已消失"——**契约本意是调用面不变,不是实现方式不变**。
|
|
42
|
+
|
|
43
|
+
其余(cli 拆包、memory 分 store/recall/archive、growth 最后动)仍按 `docs/重构方案-20261130.md` 排期。
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
if "### 结构性两项落地记录" not in d:
|
|
47
|
+
d = d.rstrip() + "\n\n" + SEC
|
|
48
|
+
p.write_text(d, encoding="utf-8")
|
|
49
|
+
print("文档已更新")
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:离线摘要的兜底补段(降低'未提取到'比例)(可删)。"""
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\summarizer.py")
|
|
6
|
+
d = p.read_text(encoding="utf-8")
|
|
7
|
+
|
|
8
|
+
old = """ quotes = pick([u for u in users if _QUOTE.search(u)], 80)[-3:]
|
|
9
|
+
"""
|
|
10
|
+
new = """ quotes = pick([u for u in users if _QUOTE.search(u)], 80)[-3:]
|
|
11
|
+
|
|
12
|
+
# 兜底补段(v5.34 残余风险):离线抽取只认明确信号,实测"未决/约束/原话"经常空着。
|
|
13
|
+
# 空着比缺信息更糟——读摘要的人会以为"这轮确实没有未决"。这里用保守规则兜一层:
|
|
14
|
+
# 只把**已经存在的内容**换个角度呈现,不编造。
|
|
15
|
+
if not pending:
|
|
16
|
+
_rest_u = [u for u in users if _clip(u, 120) not in used]
|
|
17
|
+
if _rest_u:
|
|
18
|
+
pending = [f"- 待确认:{_clip(_rest_u[-1], 120)}"]
|
|
19
|
+
if not constraints:
|
|
20
|
+
_cue = re.compile(r"不要|必须|只能|务必|别|预算|期限|deadline|时间只|最多|最少", re.I)
|
|
21
|
+
_c = [x for x in (users + bots) if _cue.search(x) and _clip(x, 120) not in used]
|
|
22
|
+
if _c:
|
|
23
|
+
constraints = [f"- {_clip(_c[-1], 120)}"]
|
|
24
|
+
if not quotes:
|
|
25
|
+
_rest_q = [u for u in users if _clip(u, 80) not in used]
|
|
26
|
+
if _rest_q:
|
|
27
|
+
quotes = [f"- 「{_clip(_rest_q[-1], 80)}」"]
|
|
28
|
+
"""
|
|
29
|
+
assert old in d
|
|
30
|
+
d = d.replace(old, new, 1)
|
|
31
|
+
|
|
32
|
+
# 空段文案更诚实:不是"未提取到",而是"这轮没有"
|
|
33
|
+
d = d.replace('block("已做", done, "- (未提取到)")',
|
|
34
|
+
'block("已做", done, "- (本轮没有助手产出)")')
|
|
35
|
+
d = d.replace('block("未决", pending, "- (未提取到)")',
|
|
36
|
+
'block("未决", pending, "- (本轮没有明显未决)")')
|
|
37
|
+
d = d.replace('block("约束", constraints, "- (未提取到)")',
|
|
38
|
+
'block("约束", constraints, "- (本轮没有明显约束)")')
|
|
39
|
+
d = d.replace('block("原话引用", quotes, "- (未提取到)")',
|
|
40
|
+
'block("原话引用", quotes, "- (本轮没有引号原话)")')
|
|
41
|
+
p.write_text(d, encoding="utf-8")
|
|
42
|
+
print("兜底补段已加")
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:自检扫描——把当前可发现的问题都列出来(可删)。"""
|
|
3
|
+
import glob
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
import time
|
|
8
|
+
|
|
9
|
+
sys.path.insert(0, r"E:\丁厚同\文档\程序\灵枢-skill\scripts")
|
|
10
|
+
import brain
|
|
11
|
+
import core
|
|
12
|
+
|
|
13
|
+
NOW = time.time()
|
|
14
|
+
issues = []
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def add(cat, sev, text):
|
|
18
|
+
issues.append((cat, sev, text))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# 1) 心跳
|
|
22
|
+
p = Path(core.HOME) / ".host-heartbeat.json"
|
|
23
|
+
if p.is_file():
|
|
24
|
+
try:
|
|
25
|
+
ts = float((brain._num(json.loads(p.read_text(encoding="utf-8")).get("ts"), 0)))
|
|
26
|
+
age = (NOW - ts) / 60
|
|
27
|
+
if age > 10:
|
|
28
|
+
add("心跳", "warn", f"心跳 {age:.0f} 分钟未更新(#55 诊断中)")
|
|
29
|
+
except Exception as e:
|
|
30
|
+
add("心跳", "warn", f"心跳文件不可解析:{e}")
|
|
31
|
+
|
|
32
|
+
# 2) 最近日志的 error/warn(按 kind 聚类)
|
|
33
|
+
LOG = Path(core.HOME) / "lingshu.log"
|
|
34
|
+
if LOG.is_file():
|
|
35
|
+
from collections import Counter
|
|
36
|
+
cut = NOW - 7 * 86400
|
|
37
|
+
c = Counter()
|
|
38
|
+
for ln in LOG.read_text(encoding="utf-8", errors="replace").splitlines():
|
|
39
|
+
ln = ln.strip()
|
|
40
|
+
if not ln:
|
|
41
|
+
continue
|
|
42
|
+
try:
|
|
43
|
+
o = json.loads(ln)
|
|
44
|
+
except Exception:
|
|
45
|
+
continue
|
|
46
|
+
if o.get("kind") == "inject":
|
|
47
|
+
continue
|
|
48
|
+
ts = float(o.get("ts") or 0)
|
|
49
|
+
if ts < cut:
|
|
50
|
+
continue
|
|
51
|
+
if str(o.get("level", "")).lower() in ("error", "warn"):
|
|
52
|
+
c[(o.get("kind"), str(o.get("msg"))[:60])] += 1
|
|
53
|
+
for (kind, msg), n in c.most_common(6):
|
|
54
|
+
sev = "warn" if kind == "cron-task" else "info"
|
|
55
|
+
add("日志", sev, f"{n}x [{kind}] {msg}")
|
|
56
|
+
|
|
57
|
+
# 3) 只读环境下的写入口 / 磁盘
|
|
58
|
+
p2 = Path(core.HOME) / ".safety" / ".pruned"
|
|
59
|
+
if p2.is_dir():
|
|
60
|
+
files = [f for f in p2.rglob("*") if f.is_file()]
|
|
61
|
+
if files:
|
|
62
|
+
sz = sum(f.stat().st_size for f in files) / 1024 / 1024
|
|
63
|
+
if sz > 30:
|
|
64
|
+
add("磁盘", "warn", f"快照 .pruned 又积累 {sz:.1f}MB/{len(files)} 文件(上轮清过)")
|
|
65
|
+
|
|
66
|
+
# 4) 未做的人为检查(pending review)
|
|
67
|
+
try:
|
|
68
|
+
rows = [m for m in brain.load_all() if m.get("review") == "pending"]
|
|
69
|
+
if rows:
|
|
70
|
+
add("审核", "warn", f"待审核记忆 {len(rows)} 条未裁决")
|
|
71
|
+
except Exception:
|
|
72
|
+
pass
|
|
73
|
+
|
|
74
|
+
# 5) 汇总
|
|
75
|
+
cur_cat = None
|
|
76
|
+
for cat, sev, text in issues:
|
|
77
|
+
if cat != cur_cat:
|
|
78
|
+
print(f"\n== {cat} ==")
|
|
79
|
+
cur_cat = cat
|
|
80
|
+
print(f" [{sev}] {text}")
|
|
81
|
+
print(f"\n共发现 {len(issues)} 条")
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:给 _sync_trae_cn 加 --check(只校验副本是否落后,不写文件)(可删)。"""
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\_sync_trae_cn.py")
|
|
6
|
+
d = p.read_text(encoding="utf-8")
|
|
7
|
+
|
|
8
|
+
# 1) 顶部加 argparse
|
|
9
|
+
old_imp = "import json\nimport os\nimport shutil\nimport sys\nfrom pathlib import Path"
|
|
10
|
+
new_imp = "import argparse\nimport json\nimport os\nimport shutil\nimport sys\nfrom pathlib import Path"
|
|
11
|
+
if "import argparse" not in d:
|
|
12
|
+
d = d.replace(old_imp, new_imp, 1)
|
|
13
|
+
print("argparse 已加")
|
|
14
|
+
|
|
15
|
+
# 2) 主循环里区分 check / 同步
|
|
16
|
+
old_loop = "for dst in targets:\n ok = miss = same = 0"
|
|
17
|
+
new_loop = '''_ap = argparse.ArgumentParser(description="把源码交付物同步到已安装副本(--check 只校验)")
|
|
18
|
+
_ap.add_argument("--check", action="store_true", help="只报告副本是否落后,不写文件")
|
|
19
|
+
_args = _ap.parse_args()
|
|
20
|
+
_check_only = bool(_args.check)
|
|
21
|
+
_drift: list = []
|
|
22
|
+
|
|
23
|
+
for dst in targets:
|
|
24
|
+
ok = miss = same = 0'''
|
|
25
|
+
if "_check_only" not in d:
|
|
26
|
+
d = d.replace(old_loop, new_loop, 1)
|
|
27
|
+
print("参数已加")
|
|
28
|
+
|
|
29
|
+
# 3) check 模式下不写,改记 drift
|
|
30
|
+
old_write = """ try:
|
|
31
|
+
_new = s.read_bytes()
|
|
32
|
+
if d.is_file() and d.read_bytes() == _new:
|
|
33
|
+
same += 1
|
|
34
|
+
continue
|
|
35
|
+
_tmp = d.with_name(d.name + ".syncing")
|
|
36
|
+
_tmp.write_bytes(_new)
|
|
37
|
+
os.replace(_tmp, d) # 同卷 rename,原子
|
|
38
|
+
ok += 1"""
|
|
39
|
+
new_write = """ try:
|
|
40
|
+
_new = s.read_bytes()
|
|
41
|
+
if d.is_file() and d.read_bytes() == _new:
|
|
42
|
+
same += 1
|
|
43
|
+
continue
|
|
44
|
+
if _check_only:
|
|
45
|
+
_drift.append(f"{dst.name}:{rel}")
|
|
46
|
+
ok += 1
|
|
47
|
+
continue
|
|
48
|
+
_tmp = d.with_name(d.name + ".syncing")
|
|
49
|
+
_tmp.write_bytes(_new)
|
|
50
|
+
os.replace(_tmp, d) # 同卷 rename,原子
|
|
51
|
+
ok += 1"""
|
|
52
|
+
if "_drift.append" not in d:
|
|
53
|
+
d = d.replace(old_write, new_write, 1)
|
|
54
|
+
print("check 分支已加")
|
|
55
|
+
|
|
56
|
+
# 4) 结尾汇总 + 退出码
|
|
57
|
+
d = d.rstrip() + '''
|
|
58
|
+
|
|
59
|
+
if _check_only:
|
|
60
|
+
if _drift:
|
|
61
|
+
print(f"[check] 副本落后 {len(_drift)} 个文件:", file=sys.stderr)
|
|
62
|
+
for x in _drift[:15]:
|
|
63
|
+
print(f" - {x}", file=sys.stderr)
|
|
64
|
+
print("跑 python scripts/_sync_trae_cn.py 修复。", file=sys.stderr)
|
|
65
|
+
sys.exit(1)
|
|
66
|
+
print("[check] OK:已安装副本与源码一致")
|
|
67
|
+
'''
|
|
68
|
+
p.write_text(d, encoding="utf-8")
|
|
69
|
+
print("退出码已加")
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:修 _sync_trae_cn 尾部顺序(check 块被 sys.exit 短路)(可删)。"""
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
p = Path(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\_sync_trae_cn.py")
|
|
6
|
+
d = p.read_text(encoding="utf-8")
|
|
7
|
+
|
|
8
|
+
# 删掉文件末尾那段死代码
|
|
9
|
+
dead = '''
|
|
10
|
+
if _check_only:
|
|
11
|
+
if _drift:
|
|
12
|
+
print(f"[check] 副本落后 {len(_drift)} 个文件:", file=sys.stderr)
|
|
13
|
+
for x in _drift[:15]:
|
|
14
|
+
print(f" - {x}", file=sys.stderr)
|
|
15
|
+
print("跑 python scripts/_sync_trae_cn.py 修复。", file=sys.stderr)
|
|
16
|
+
sys.exit(1)
|
|
17
|
+
print("[check] OK:已安装副本与源码一致")
|
|
18
|
+
'''
|
|
19
|
+
if dead in d:
|
|
20
|
+
d = d.replace(dead, "\n")
|
|
21
|
+
print("死代码已删")
|
|
22
|
+
|
|
23
|
+
# 在自检的 sys.exit 之前插入 check 汇总,并让退出码合并
|
|
24
|
+
old_exit = "sys.exit(1 if bad else 0)"
|
|
25
|
+
new_exit = '''# --check 汇总(必须在 sys.exit 之前,否则永远是死代码——踩过)
|
|
26
|
+
if _check_only:
|
|
27
|
+
if _drift:
|
|
28
|
+
print(f"[check] 副本落后 {len(_drift)} 个文件:", file=sys.stderr)
|
|
29
|
+
for x in _drift[:15]:
|
|
30
|
+
print(f" - {x}", file=sys.stderr)
|
|
31
|
+
print("跑 python scripts/_sync_trae_cn.py 修复。", file=sys.stderr)
|
|
32
|
+
else:
|
|
33
|
+
print("[check] OK:已安装副本与源码一致")
|
|
34
|
+
|
|
35
|
+
sys.exit(1 if (bad or (_check_only and _drift)) else 0)'''
|
|
36
|
+
if old_exit in d:
|
|
37
|
+
d = d.replace(old_exit, new_exit, 1)
|
|
38
|
+
print("退出码已合并")
|
|
39
|
+
p.write_text(d, encoding="utf-8")
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:清过期标记 + 记 OCC 联动与摘要兜底(可删)。"""
|
|
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
|
+
# 1) 过期标记:RSS / BM25 早已完成
|
|
10
|
+
d = d.replace('- **P2-1 RSS 摄入**(20h)未做。建议收窄为"本地 RSS/Atom 文件或显式 URL 列表 + 默认关闭"。',
|
|
11
|
+
'- ~~**P2-1 RSS 摄入**(20h)未做~~ → ✅ **已完成**(窄口径:本地 feed / URL 列表,'
|
|
12
|
+
'`brain.py rss ingest`,见 commit e71e88c)')
|
|
13
|
+
d = d.replace("| P2-1 RSS 摄入 | ⬜ 未做(20h;建议按\"本地 RSS/Atom 文件或显式 URL 列表 + 默认关闭\"收窄后再立项) |",
|
|
14
|
+
"| P2-1 RSS 摄入 | ✅ **已完成**(窄口径):`rss ingest --file/--url-list`,零依赖、按 link 去重、不内置定时抓取 |")
|
|
15
|
+
d = d.replace("- **#3 BM25 未做**:它改的是 relevance(占五元权重 0.55 的最大项),必须先用",
|
|
16
|
+
"- ~~**#3 BM25 未做**~~ → ✅ **已完成**(`TermSet` + `bm25(k1=1.2,b=0.75)`,bench 无回退)。"
|
|
17
|
+
"原注:它改的是 relevance(五元权重最大项),必须先用")
|
|
18
|
+
|
|
19
|
+
# 2) 残余风险:已兜底
|
|
20
|
+
d = d.replace("- ⬜ **残余风险(没去掉)**:离线抽取式只挑明确信号,`未决/约束/原话引用`经常空着;",
|
|
21
|
+
"- ✅ **残余风险已缓解(2026-11-30)**:`extractive_fallback` 加兜底补段——"
|
|
22
|
+
"未决用最后一条用户消息、原话引用最近一句、约束再扫一遍线索词;"
|
|
23
|
+
"空段文案改为**诚实表述**(\"本轮没有明显约束\"),不再统一写\"未提取到\"。原风险描述:"
|
|
24
|
+
"离线抽取式只挑明确信号,`未决/约束/原话引用`经常空着;")
|
|
25
|
+
|
|
26
|
+
# 3) 状态统计刷新
|
|
27
|
+
def recount(text):
|
|
28
|
+
done = len(re.findall(r"^\|\s*[A-Z]?\d+\s*\|.*✅", text, re.M))
|
|
29
|
+
todo = len(re.findall(r"^\|\s*[A-Z]?\d+\s*\|.*⬜", text, re.M))
|
|
30
|
+
excl = len(re.findall(r"^\|\s*[A-Z]?\d+\s*\|.*🔍", text, re.M))
|
|
31
|
+
return done, todo, excl
|
|
32
|
+
|
|
33
|
+
done, todo, excl = recount(d)
|
|
34
|
+
d = re.sub(r"> \*\*状态统计(编号任务行)\*\*[^\n]*",
|
|
35
|
+
f"> **状态统计(编号任务行)**:✅ {done} 已修 / ⬜ {todo} 待修 / 🔍 {excl} 已排除(含 §7/§8)",
|
|
36
|
+
d, count=1)
|
|
37
|
+
|
|
38
|
+
SEC = """
|
|
39
|
+
### OCC × 七情六欲 联动(2026-11-30)
|
|
40
|
+
|
|
41
|
+
用户要求:OCC 情绪要联动灵枢的七情六欲。已落:
|
|
42
|
+
|
|
43
|
+
| OCC | 七情 | 具体情绪 | 六欲联动 |
|
|
44
|
+
|---|---|---|---|
|
|
45
|
+
| 失望 | 哀 | 失落 | 成就欲 −8、连接欲 −2 |
|
|
46
|
+
| 释然 | 静 | 平静 | 安全欲 +10 |
|
|
47
|
+
| 满意 | 喜 | 满足 | 成就欲 +10 |
|
|
48
|
+
| 感激 | 爱 | 感动 | 连接欲 +12 |
|
|
49
|
+
| 愤怒 | 怒 | 生气 | 连接欲 −6、掌控欲 −3 |
|
|
50
|
+
| 焦虑 | 惧 | 焦虑 | 安全欲 −10 |
|
|
51
|
+
|
|
52
|
+
- `brain.py occ apply "<话>"`:识别 OCC → `emotion_evaluate(polarity, why="OCC:…")` → `desire_nudge(...)`;
|
|
53
|
+
`--dry-run` 只看不改;识别不出时**不动任何状态**(不瞎记情绪)。
|
|
54
|
+
- 注意:`静` 组只有 平静/疲惫/无聊,没有"安心"——映射已改 平静(映射到不存在的情绪会被拒)。
|
|
55
|
+
|
|
56
|
+
### 待办扫描结论(2026-11-30)
|
|
57
|
+
|
|
58
|
+
- 过期标记已清:RSS(早已完成)、BM25(早已完成)、摘要残余风险(本轮兜底)。
|
|
59
|
+
- **仍然没做的只有 3 项**:① 拆分 `scripts/`↔`engine/scripts/` 双份维护;② growth/cli/memory 三模块拆分;
|
|
60
|
+
③ #54 第二步(写 lingshu compaction provider)。三项都是**结构性/需专门时间**,方案在
|
|
61
|
+
`docs/重构方案-20261130.md` 与 §13。
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
if "### OCC × 七情六欲 联动" not in d:
|
|
65
|
+
d = d.rstrip() + "\n\n" + SEC
|
|
66
|
+
p.write_text(d, encoding="utf-8")
|
|
67
|
+
print("文档已清理并追加联动记录")
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""一次性:用 glob 找到副本并跑 startup(可删)。"""
|
|
3
|
+
import glob
|
|
4
|
+
import os
|
|
5
|
+
import subprocess
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
py = r"D:\ServBay\packages\python\current\python.exe"
|
|
9
|
+
hits = glob.glob(os.path.expanduser("~") + r"\.*\profiles\desktop\node_modules\lingshu-skill\scripts\brain.py")
|
|
10
|
+
print("副本:", hits)
|
|
11
|
+
if hits:
|
|
12
|
+
r = subprocess.run([py, hits[0], "startup"], capture_output=True, text=True,
|
|
13
|
+
encoding="utf-8", errors="replace", timeout=60)
|
|
14
|
+
print("exit =", r.returncode, "| 输出字符 =", len(r.stdout))
|
|
15
|
+
print("首行:", (r.stdout or "").splitlines()[0] if r.stdout else "(无)")
|
|
16
|
+
if r.stderr.strip():
|
|
17
|
+
print("stderr:", r.stderr.strip()[:200])
|