lingshu-skill 5.60.0 → 5.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/README.md +1 -1
- package/SKILL-lite.md +1 -1
- package/SKILL-tiny.md +1 -1
- package/SKILL.md +1 -1
- package/manifest.json +461 -0
- package/package.json +8 -2
- package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +10 -10
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +29 -0
- package/scripts/astrbot_plugin_lingshu/engine/README.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/SKILL-lite.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/SKILL-tiny.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/SKILL.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/scripts/core.py +58 -39
- package/scripts/astrbot_plugin_lingshu/engine/scripts/growth.py +3 -4
- package/scripts/astrbot_plugin_lingshu/engine/scripts/make_dsh_tgz.py +20 -3
- package/scripts/astrbot_plugin_lingshu/engine/scripts/memory.py +11 -2
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_build.py +13 -0
- package/scripts/core.py +58 -39
- package/scripts/growth.py +3 -4
- package/scripts/make_dsh_tgz.py +20 -3
- package/scripts/make_manifest.py +15 -10
- package/scripts/make_plugin_zip.py +7 -3
- package/scripts/memory.py +11 -2
- package/scripts/panel_build.py +13 -0
- package/scripts/_ci_env_probe.py +0 -81
- package/scripts/_panel_smoke_v299.py +0 -27
- package/scripts/_scratch/_tmp_backup_race.py +0 -70
- package/scripts/_scratch/_tmp_cleanup_move.py +0 -34
- package/scripts/_scratch/_tmp_count_kinds.py +0 -25
- package/scripts/_scratch/_tmp_diag_paths.py +0 -48
- package/scripts/_scratch/_tmp_facts.py +0 -63
- package/scripts/_scratch/_tmp_find_copies.py +0 -31
- package/scripts/_scratch/_tmp_find_pin.py +0 -29
- package/scripts/_scratch/_tmp_fix_pin.py +0 -36
- package/scripts/_scratch/_tmp_fold_fixture.py +0 -55
- package/scripts/_scratch/_tmp_fold_test.mjs +0 -81
- package/scripts/_scratch/_tmp_inject_secs.py +0 -30
- package/scripts/_scratch/_tmp_kb_balance.py +0 -159
- package/scripts/_scratch/_tmp_lines.py +0 -15
- package/scripts/_scratch/_tmp_market_probe.py +0 -13
- package/scripts/_scratch/_tmp_move_partial.py +0 -16
- package/scripts/_scratch/_tmp_patch_b3.py +0 -41
- package/scripts/_scratch/_tmp_patch_b5.py +0 -62
- package/scripts/_scratch/_tmp_patch_crash_excl.py +0 -24
- package/scripts/_scratch/_tmp_patch_handoff.py +0 -21
- package/scripts/_scratch/_tmp_patch_ps1.py +0 -25
- package/scripts/_scratch/_tmp_patch_stat.py +0 -27
- package/scripts/_scratch/_tmp_patch_todo.py +0 -25
- package/scripts/_scratch/_tmp_patch_todo2.py +0 -64
- package/scripts/_scratch/_tmp_probe_session.py +0 -51
- package/scripts/_scratch/_tmp_style_probe.py +0 -40
- package/scripts/_scratch/_tmp_write_note.py +0 -139
- package/scripts/_scratch/_/346/235/245/346/272/220/350/256/260/345/275/225.txt +0 -1
- package/scripts/_scratch/asar_compaction/dsh-compaction-basic__lib__index.js +0 -1044
- package/scripts/_scratch/asar_compaction/dsh-compaction-tool-result-pruner__lib__index.js +0 -194
- package/scripts/_scratch/asar_compaction/dsh-compaction__lib__index.js +0 -175
- package/scripts/_scratch/asar_compaction/dsh-compaction__lib__types__tool-pairing.js +0 -97
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__image-offload.js +0 -47
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__index.js +0 -40
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__project-message.js +0 -37
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__brand.js +0 -9
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__checkpoint.js +0 -36
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__types.js +0 -10
- package/scripts/_scratch/commit_msg_occ.txt +0 -16
- package/scripts/_scratch/commit_msg_struct.txt +0 -16
- package/scripts/_scratch/v5.34_changelog.txt +0 -36
- package/scripts/_smoke_v299.py +0 -31
- package/scripts/_sync_trae_cn.py +0 -102
- package/scripts/_tmp_add_s10.py +0 -54
- package/scripts/_tmp_add_s11.py +0 -61
- package/scripts/_tmp_add_s12.py +0 -66
- package/scripts/_tmp_add_s13.py +0 -69
- package/scripts/_tmp_add_s14.py +0 -80
- package/scripts/_tmp_add_s9.py +0 -68
- package/scripts/_tmp_cache_load.py +0 -82
- package/scripts/_tmp_clean_market.py +0 -40
- package/scripts/_tmp_clean_pruned.py +0 -81
- package/scripts/_tmp_cleanup_docs.py +0 -39
- package/scripts/_tmp_cmp_ranker.py +0 -17
- package/scripts/_tmp_dolater_note.py +0 -35
- package/scripts/_tmp_dust_why.py +0 -27
- package/scripts/_tmp_explicit_import.py +0 -40
- package/scripts/_tmp_extract_compaction.py +0 -35
- package/scripts/_tmp_extract_compaction2.py +0 -63
- package/scripts/_tmp_extract_compaction3.py +0 -51
- package/scripts/_tmp_extract_compaction4.py +0 -54
- package/scripts/_tmp_finalize_s14.py +0 -39
- package/scripts/_tmp_find_compaction.py +0 -43
- package/scripts/_tmp_fix_b4.py +0 -22
- package/scripts/_tmp_fix_cli76.py +0 -26
- package/scripts/_tmp_fix_docs.py +0 -38
- package/scripts/_tmp_fix_docs_b.py +0 -46
- package/scripts/_tmp_fix_docs_b2.py +0 -22
- package/scripts/_tmp_fix_i3.py +0 -23
- package/scripts/_tmp_fix_s10.py +0 -83
- package/scripts/_tmp_fix_s11.py +0 -14
- package/scripts/_tmp_fix_s9_status.py +0 -19
- package/scripts/_tmp_fix_shadow_sim.py +0 -37
- package/scripts/_tmp_fix_traits_value.py +0 -41
- package/scripts/_tmp_import_idem.py +0 -106
- package/scripts/_tmp_log_ack.py +0 -45
- package/scripts/_tmp_mark_batch.py +0 -28
- package/scripts/_tmp_mark_batch2.py +0 -32
- package/scripts/_tmp_mark_dolater.py +0 -26
- package/scripts/_tmp_mark_dolater2.py +0 -31
- package/scripts/_tmp_move_self.py +0 -16
- package/scripts/_tmp_occ_cli.py +0 -22
- package/scripts/_tmp_occ_link.py +0 -108
- package/scripts/_tmp_optimize_recall.py +0 -54
- package/scripts/_tmp_panel_audit.py +0 -26
- package/scripts/_tmp_patch_batch3.py +0 -65
- package/scripts/_tmp_patch_rrf.py +0 -46
- package/scripts/_tmp_patch_s2s3.py +0 -80
- package/scripts/_tmp_patch_s4.py +0 -39
- package/scripts/_tmp_patch_s7.py +0 -43
- package/scripts/_tmp_patch_s8.py +0 -91
- package/scripts/_tmp_patch_skill.py +0 -17
- package/scripts/_tmp_release_guard.py +0 -57
- package/scripts/_tmp_rerank_breaker.py +0 -62
- package/scripts/_tmp_s16.py +0 -41
- package/scripts/_tmp_scan_asar.py +0 -41
- package/scripts/_tmp_scan_asar2.py +0 -37
- package/scripts/_tmp_speed_survey.py +0 -49
- package/scripts/_tmp_struct_docs.py +0 -49
- package/scripts/_tmp_sum_fallback.py +0 -42
- package/scripts/_tmp_sweep.py +0 -81
- package/scripts/_tmp_sync_check.py +0 -69
- package/scripts/_tmp_sync_tail.py +0 -39
- package/scripts/_tmp_todo_clean.py +0 -67
- package/scripts/_tmp_verify_copy.py +0 -17
- package/scripts/_tmp_wire_extras.py +0 -93
- package/scripts/_tmp_wire_hsum.py +0 -34
- package/scripts/_tmp_wire_occ_b5.py +0 -40
- package/scripts/_tmp_wire_ranker.py +0 -13
- package/scripts/_tmp_wire_shadow_timeline.py +0 -45
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_ci_env_probe.py +0 -81
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_panel_smoke_v299.py +0 -27
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_smoke_v299.py +0 -31
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_sync_trae_cn.py +0 -102
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s10.py +0 -54
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s11.py +0 -61
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s12.py +0 -66
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s13.py +0 -69
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s14.py +0 -80
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s9.py +0 -68
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cache_load.py +0 -82
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_clean_market.py +0 -40
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_clean_pruned.py +0 -81
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cleanup_docs.py +0 -39
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cmp_ranker.py +0 -17
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_dolater_note.py +0 -35
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_dust_why.py +0 -27
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_explicit_import.py +0 -40
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction.py +0 -35
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction2.py +0 -63
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction3.py +0 -51
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction4.py +0 -54
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_finalize_s14.py +0 -39
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_find_compaction.py +0 -43
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_b4.py +0 -22
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_cli76.py +0 -26
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs.py +0 -38
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs_b.py +0 -46
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs_b2.py +0 -22
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_i3.py +0 -23
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s10.py +0 -83
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s11.py +0 -14
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s9_status.py +0 -19
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_shadow_sim.py +0 -37
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_traits_value.py +0 -41
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_import_idem.py +0 -106
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_log_ack.py +0 -45
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_batch.py +0 -28
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_batch2.py +0 -32
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_dolater.py +0 -26
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_dolater2.py +0 -31
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_move_self.py +0 -16
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_occ_cli.py +0 -22
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_occ_link.py +0 -108
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_optimize_recall.py +0 -54
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_panel_audit.py +0 -26
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_batch3.py +0 -65
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_rrf.py +0 -46
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s2s3.py +0 -80
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s4.py +0 -39
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s7.py +0 -43
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s8.py +0 -91
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_skill.py +0 -17
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_release_guard.py +0 -57
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_rerank_breaker.py +0 -62
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_s16.py +0 -41
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_scan_asar.py +0 -41
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_scan_asar2.py +0 -37
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_speed_survey.py +0 -49
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_struct_docs.py +0 -49
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sum_fallback.py +0 -42
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sweep.py +0 -81
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sync_check.py +0 -69
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sync_tail.py +0 -39
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_todo_clean.py +0 -67
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_verify_copy.py +0 -17
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_extras.py +0 -93
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_hsum.py +0 -34
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_occ_b5.py +0 -40
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_ranker.py +0 -13
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_shadow_timeline.py +0 -45
|
@@ -1,46 +0,0 @@
|
|
|
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 记录")
|
|
@@ -1,80 +0,0 @@
|
|
|
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)
|
|
@@ -1,39 +0,0 @@
|
|
|
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")
|
|
@@ -1,43 +0,0 @@
|
|
|
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)")
|
|
@@ -1,91 +0,0 @@
|
|
|
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")
|
|
@@ -1,17 +0,0 @@
|
|
|
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("没找到锚点,未改动")
|
|
@@ -1,57 +0,0 @@
|
|
|
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")
|
|
@@ -1,62 +0,0 @@
|
|
|
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")
|
|
@@ -1,41 +0,0 @@
|
|
|
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")
|
|
@@ -1,41 +0,0 @@
|
|
|
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
|
|
@@ -1,37 +0,0 @@
|
|
|
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
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""调研:对话慢的根因剖析与同类项目加速方案(2026-12-03)
|
|
3
|
-
|
|
4
|
-
## 一、实测数据(本机,650 条记忆)
|
|
5
|
-
|
|
6
|
-
| 阶段 | 耗时 | 占比 |
|
|
7
|
-
|---|---|---|
|
|
8
|
-
| startup 全程(冷,杀软扫描) | 4922 ms | 偶发 |
|
|
9
|
-
| startup 全程(热态) | ~420 ms | 每次对话 |
|
|
10
|
-
| ├ 纯 Python 解释器 | 25 ms | 6% |
|
|
11
|
-
| ├ import brain(7 模块装配) | 151 ms | 36% |
|
|
12
|
-
| ├ build_injection(含 recall) | 304 ms | 72% |
|
|
13
|
-
│ ├ ├ recall(含 dense/embed 调用) | 168 ms | |
|
|
14
|
-
│ ├ ├ mood_now ×5 | 29 ms | |
|
|
15
|
-
│ ├ ├ affection_state ×7 | 28 ms | |
|
|
16
|
-
│ └ └ load_all ×9 | 33 ms | |
|
|
17
|
-
| overview 全量(面板首屏) | 176 ms | |
|
|
18
|
-
| overview light(30s 轮询) | 74 ms | |
|
|
19
|
-
|
|
20
|
-
## 二、慢的三��根因
|
|
21
|
-
|
|
22
|
-
1. **进程冷启动 4.9s(偶发但刺眼)**:每次对话 startup 都是独立 Python 进程,
|
|
23
|
-
首跑要过 Windows Defender 实时扫描 700+ 个 .pyc/.py 文件。
|
|
24
|
-
2. **build_injection 内部重复计算**:load_persona 被调 24 次、mood_now 5 次、
|
|
25
|
-
affection_state 7 次——模块间无共享缓存,每次都重读盘+重算 EMA。
|
|
26
|
-
3. **recall 的 dense 调用**:auto 模式下长查询会走 embedding HTTP 调用,
|
|
27
|
-
Ollama 冷启动一次就是 100ms+。
|
|
28
|
-
|
|
29
|
-
## 三、同类项目的加速方案
|
|
30
|
-
|
|
31
|
-
| 项目 | 方案 | 可借鉴点 |
|
|
32
|
-
|---|---|---|
|
|
33
|
-
| letta (MemGPT) | 常驻内存进程,所有记忆操作 RPC 化 | 灵枢已有 `serve` 长驻模式——startup 走 HTTP 即可跳过 151ms 导入 |
|
|
34
|
-
| mem0 | 进程内 LRU + 向量缓存 | 模块级 memoize:persona/mood/affection 加 TTL 缓存 |
|
|
35
|
-
| cognee | 管道级懒加载,按需 import | build_injection 分段懒执行:非必需段(技能库/快照)延后 |
|
|
36
|
-
| zep | 会话事实增量更新,不做全量重算 | mood/affection 已是增量 EMA——问题在跨模块重复调用 |
|
|
37
|
-
| Open WebUI | 前端 sessionStorage + 骨架屏 | 面板已有 light 轮询(74ms),无瓶颈 |
|
|
38
|
-
|
|
39
|
-
## 四、落地建议(按性价比排序)
|
|
40
|
-
|
|
41
|
-
1. **模块级 TTL 微缓存**(收益 ~60ms/次):persona.py 加 `_persona_cache`
|
|
42
|
-
(TTL 2s,写路径主动失效);emotion.mood_now / affection_state 同理。
|
|
43
|
-
build_injection 内 24 次 load_persona → 1 次读盘 + 23 次命中缓存。
|
|
44
|
-
2. **常驻 serve 模式**(收益 ~150ms/次 + 消灭 4.9s 冷启动):startup 插件
|
|
45
|
-
优先打 `http://127.0.0.1:18997/api/inject`,失败再回退本进程跑。
|
|
46
|
-
3. **dense 调用预算**(收益 ~100ms/次,长查询时):embed 失败冷却已有;
|
|
47
|
-
加"连续 3 次 dense 命中数 < 2 则自动降级 fast 一段时间"的自适应跳过。
|
|
48
|
-
"""
|
|
49
|
-
print(__doc__)
|