lingshu-skill 5.61.0 → 5.63.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 +30 -0
- package/README.md +1 -1
- package/SKILL-lite.md +1 -1
- package/SKILL-tiny.md +1 -1
- package/SKILL.md +1 -1
- package/assets/panel.html +2 -2
- package/manifest.json +461 -0
- package/package.json +8 -2
- package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +11 -11
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +30 -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/assets/panel.html +2 -2
- 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/panel_build.py +13 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_server.py +30 -10
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panels.py +1 -0
- 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/panel_build.py +13 -0
- package/scripts/panel_server.py +30 -10
- package/scripts/panels.py +1 -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,70 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""一次性并发压力测试(可删):在**临时**工作区里搭同结构,边修剪边连跑备份。
|
|
3
|
-
|
|
4
|
-
根因场景:safety_net 每次 save_all 后把旧快照**移入** .safety/.pruned/,
|
|
5
|
-
备份 rglob 已列出那些文件 → 写包时文件消失 → 整包失败。
|
|
6
|
-
用临时目录模拟同结构,不碰真实数据。
|
|
7
|
-
"""
|
|
8
|
-
import concurrent.futures
|
|
9
|
-
import os
|
|
10
|
-
import shutil
|
|
11
|
-
import sys
|
|
12
|
-
import tempfile
|
|
13
|
-
import time
|
|
14
|
-
from pathlib import Path
|
|
15
|
-
|
|
16
|
-
sys.path.insert(0, r"E:\丁厚同\文档\程序\灵枢-skill\scripts")
|
|
17
|
-
|
|
18
|
-
home = Path(tempfile.mkdtemp(prefix="ls-bk-race-"))
|
|
19
|
-
(home / "cortex.jsonl").write_text('{"id":"m1"}\n', encoding="utf-8")
|
|
20
|
-
(home / "persona.json").write_text('{"name":"砚"}', encoding="utf-8")
|
|
21
|
-
safety = home / ".safety"
|
|
22
|
-
for i in range(26):
|
|
23
|
-
d = safety / f"2026110{i}-000000_save_all"
|
|
24
|
-
d.mkdir(parents=True, exist_ok=True)
|
|
25
|
-
(d / "cortex.jsonl").write_text(f"snap{i}\n", encoding="utf-8")
|
|
26
|
-
|
|
27
|
-
os.environ["BRAIN_MEMORY_HOME"] = str(home)
|
|
28
|
-
out = home / "_race_out"
|
|
29
|
-
|
|
30
|
-
import brain # noqa: E402
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def prune_loop():
|
|
34
|
-
"""模拟 safety_net 修剪:反复把最旧快照移入 .pruned(只移不删)。"""
|
|
35
|
-
end = time.time() + 20
|
|
36
|
-
moved = 0
|
|
37
|
-
while time.time() < end:
|
|
38
|
-
cands = sorted([p for p in safety.glob("2026*_save_all*") if p.is_dir()],
|
|
39
|
-
key=lambda p: p.stat().st_mtime)
|
|
40
|
-
if cands:
|
|
41
|
-
dst = safety / ".pruned"
|
|
42
|
-
dst.mkdir(parents=True, exist_ok=True)
|
|
43
|
-
try:
|
|
44
|
-
shutil.move(str(cands[0]), str(dst / f"{cands[0].name}.raced"))
|
|
45
|
-
moved += 1
|
|
46
|
-
except OSError:
|
|
47
|
-
pass
|
|
48
|
-
time.sleep(0.02)
|
|
49
|
-
return moved
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def run_backup():
|
|
53
|
-
t0 = time.time()
|
|
54
|
-
rc = brain.cmd_backup(str(out), keep=0, assume_yes=True)
|
|
55
|
-
return rc, round(time.time() - t0, 2)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
with concurrent.futures.ThreadPoolExecutor(max_workers=3) as ex:
|
|
59
|
-
fut_prune = ex.submit(prune_loop)
|
|
60
|
-
outs = [f.result() for f in [ex.submit(run_backup) for _ in range(6)]]
|
|
61
|
-
moved = fut_prune.result()
|
|
62
|
-
|
|
63
|
-
zips = sorted(out.glob("*.zip"))
|
|
64
|
-
print(f"并发移动快照次数 = {moved}")
|
|
65
|
-
print(f"备份结果(rc, 秒): {outs}")
|
|
66
|
-
print(f"产出 zip = {len(zips)}")
|
|
67
|
-
ok = all(rc == 0 for rc, _ in outs) and len(zips) == len(outs)
|
|
68
|
-
print("RESULT:", "PASS" if ok else "FAIL")
|
|
69
|
-
shutil.rmtree(home, ignore_errors=True)
|
|
70
|
-
sys.exit(0 if ok else 1)
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""一次性:把仓库里的 _tmp_* 一次性脚本挪进 scripts/_scratch/(§7 #38,可删)。
|
|
3
|
-
|
|
4
|
-
按用户规矩:**只移不删**,并记录来源与时间。
|
|
5
|
-
"""
|
|
6
|
-
import shutil
|
|
7
|
-
import time
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
|
|
10
|
-
ROOT = Path(r"E:\丁厚同\文档\程序\灵枢-skill")
|
|
11
|
-
SCRATCH = ROOT / "scripts" / "_scratch"
|
|
12
|
-
SCRATCH.mkdir(parents=True, exist_ok=True)
|
|
13
|
-
|
|
14
|
-
targets = sorted(ROOT.glob("_tmp_*.py")) + sorted(ROOT.glob("_tmp_*.mjs")) \
|
|
15
|
-
+ sorted((ROOT / "scripts").glob("_tmp_*.py")) + sorted((ROOT / "scripts").glob("_tmp_*.mjs"))
|
|
16
|
-
moved = 0
|
|
17
|
-
_self = Path(__file__).resolve()
|
|
18
|
-
for p in targets:
|
|
19
|
-
if not p.is_file():
|
|
20
|
-
continue
|
|
21
|
-
if p.resolve() == _self: # 自己正在被解释器占用,别动
|
|
22
|
-
continue
|
|
23
|
-
dst = SCRATCH / p.name
|
|
24
|
-
if dst.exists():
|
|
25
|
-
dst = SCRATCH / f"{p.stem}.{int(time.time())}{p.suffix}"
|
|
26
|
-
shutil.move(str(p), str(dst))
|
|
27
|
-
moved += 1
|
|
28
|
-
print("moved:", p.name, "->", dst.relative_to(ROOT))
|
|
29
|
-
|
|
30
|
-
note = SCRATCH / "_来源记录.txt"
|
|
31
|
-
with note.open("a", encoding="utf-8") as f:
|
|
32
|
-
f.write(f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] 从仓库根/scripts 迁入 {moved} 个 _tmp_* 一次性脚本"
|
|
33
|
-
"(§7 #38:清理探针堆积;只移不删,确认无用后可整目录删除)\n")
|
|
34
|
-
print(f"共移动 {moved} 个到 {SCRATCH}")
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""一次性:列出 lingshu.log 里 inject/warn 的不同消息(可删)。"""
|
|
3
|
-
import collections
|
|
4
|
-
import json
|
|
5
|
-
import os
|
|
6
|
-
import re
|
|
7
|
-
|
|
8
|
-
p = os.path.expanduser(r"~\.brain-memory\lingshu.log")
|
|
9
|
-
c = collections.Counter()
|
|
10
|
-
for ln in open(p, encoding="utf-8", errors="replace"):
|
|
11
|
-
ln = ln.strip()
|
|
12
|
-
if not ln:
|
|
13
|
-
continue
|
|
14
|
-
try:
|
|
15
|
-
o = json.loads(ln)
|
|
16
|
-
except Exception:
|
|
17
|
-
continue
|
|
18
|
-
if o.get("kind") != "inject" or str(o.get("level")).lower() != "warn":
|
|
19
|
-
continue
|
|
20
|
-
msg = str(o.get("msg") or "")
|
|
21
|
-
# 把数字抹平,便于聚合
|
|
22
|
-
key = re.sub(r"-?\d+", "N", msg)[:110]
|
|
23
|
-
c[key] += 1
|
|
24
|
-
for k, v in c.most_common():
|
|
25
|
-
print(f"{v:>3}x {k}")
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""临时诊断 3:验证 APP 会话目录名编码 + 直接构造路径可达性(可删)。"""
|
|
3
|
-
import os
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
|
|
6
|
-
SESS_ROOT = r"C:\Users\Administrator\.app\sessions"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def encode(part: str) -> str:
|
|
10
|
-
out = []
|
|
11
|
-
for ch in part:
|
|
12
|
-
if ch.isascii() and (ch.isalnum() or ch in "._-"):
|
|
13
|
-
out.append(ch)
|
|
14
|
-
elif ch.isascii():
|
|
15
|
-
out.append("-")
|
|
16
|
-
else:
|
|
17
|
-
out.append("~%04X" % ord(ch))
|
|
18
|
-
return "".join(out)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def session_dir_name(path: str) -> str:
|
|
22
|
-
p = Path(path)
|
|
23
|
-
parts = [p.drive.rstrip(":")] + list(p.parts[1:])
|
|
24
|
-
return "--" + "-".join(encode(x) for x in parts if x) + "--"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
for cwd in (r"E:\丁厚同\文档\程序", r"E:\丁厚同\文档\程序\灵枢-skill"):
|
|
28
|
-
name = session_dir_name(cwd)
|
|
29
|
-
full = os.path.join(SESS_ROOT, name)
|
|
30
|
-
print("cwd:", cwd)
|
|
31
|
-
print(" encoded:", name)
|
|
32
|
-
print(" isdir:", os.path.isdir(full))
|
|
33
|
-
if os.path.isdir(full):
|
|
34
|
-
try:
|
|
35
|
-
subs = sorted(os.listdir(full))
|
|
36
|
-
print(" sessions:", len(subs), subs[:3])
|
|
37
|
-
for sid in subs[:2]:
|
|
38
|
-
f = os.path.join(full, sid, "session.v4.jsonl.zstd")
|
|
39
|
-
print(" file exists:", os.path.isfile(f), f[-70:])
|
|
40
|
-
except Exception as e:
|
|
41
|
-
print(" listdir 失败:", type(e).__name__, e)
|
|
42
|
-
print()
|
|
43
|
-
|
|
44
|
-
# 已知正确名对照
|
|
45
|
-
known = "--E-~4E01~539A~540C-~6587~6863-~7A0B~5E8F--"
|
|
46
|
-
print("known :", known)
|
|
47
|
-
print("computed:", session_dir_name(r"E:\丁厚同\文档\程序"))
|
|
48
|
-
print("match:", known == session_dir_name(r"E:\丁厚同\文档\程序"))
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""一次性:为"待办补充缺点"取证(可删)。"""
|
|
3
|
-
import glob
|
|
4
|
-
import json
|
|
5
|
-
import os
|
|
6
|
-
import zipfile
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
|
|
9
|
-
HOME = Path(os.path.expanduser("~"))
|
|
10
|
-
BM = HOME / ".brain-memory"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def du(p: Path) -> tuple:
|
|
14
|
-
if not p.exists():
|
|
15
|
-
return (0, 0)
|
|
16
|
-
n = s = 0
|
|
17
|
-
for root, _dirs, files in os.walk(p):
|
|
18
|
-
for f in files:
|
|
19
|
-
try:
|
|
20
|
-
s += (Path(root) / f).stat().st_size
|
|
21
|
-
n += 1
|
|
22
|
-
except OSError:
|
|
23
|
-
pass
|
|
24
|
-
return (n, s)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def mb(b: int) -> str:
|
|
28
|
-
return f"{b / 1024 / 1024:.1f}MB"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
print("== 磁盘占用 ==")
|
|
32
|
-
for name in (".safety", ".safety/.pruned", "backups", "sources"):
|
|
33
|
-
n, s = du(BM / name)
|
|
34
|
-
print(f" {name:<20} {n:>5} 文件 {mb(s):>8}")
|
|
35
|
-
|
|
36
|
-
print("\n== HOME 里的诊断残留 ==")
|
|
37
|
-
crashes = sorted(BM.glob("crash-*.log"))
|
|
38
|
-
print(f" crash-*.log: {len(crashes)} 个,合计 {mb(sum(p.stat().st_size for p in crashes))}")
|
|
39
|
-
for p in crashes[:3]:
|
|
40
|
-
print(" ", p.name, f"{p.stat().st_size // 1024}KB")
|
|
41
|
-
|
|
42
|
-
print("\n== 备份包是否含 crash 日志 / .safety ==")
|
|
43
|
-
zs = sorted(glob.glob(str(BM / "backups" / "*.zip")), key=os.path.getmtime)
|
|
44
|
-
cand = sorted(glob.glob(r"D:\brain-memory-backups\*.zip"), key=os.path.getmtime)
|
|
45
|
-
z = (cand or zs)[-1] if (cand or zs) else None
|
|
46
|
-
if z:
|
|
47
|
-
names = zipfile.ZipFile(z).namelist()
|
|
48
|
-
print(f" 包: {os.path.basename(z)}({len(names)} 条目)")
|
|
49
|
-
print(" 含 crash-*.log:", sum(1 for n in names if n.startswith("crash-")))
|
|
50
|
-
print(" 含 .safety:", sum(1 for n in names if ".safety" in n))
|
|
51
|
-
|
|
52
|
-
print("\n== 仓库里的临时脚本(未入库) ==")
|
|
53
|
-
tmp = sorted(glob.glob(r"E:\丁厚同\文档\程序\灵枢-skill\scripts\_tmp_*.py"))
|
|
54
|
-
tmp += sorted(glob.glob(r"E:\丁厚同\文档\程序\灵枢-skill\_tmp_*.mjs"))
|
|
55
|
-
print(f" 共 {len(tmp)} 个")
|
|
56
|
-
for p in tmp[:12]:
|
|
57
|
-
print(" ", os.path.basename(p))
|
|
58
|
-
|
|
59
|
-
print("\n== 未跟踪测试文件数 ==")
|
|
60
|
-
import subprocess
|
|
61
|
-
r = subprocess.run(["git", "status", "--porcelain", "tests/"],
|
|
62
|
-
cwd=r"E:\丁厚同\文档\程序\灵枢-skill", capture_output=True, text=True)
|
|
63
|
-
print(" ", len([l for l in r.stdout.splitlines() if l.strip()]), "条改动/未跟踪")
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""一次性:用 Python 视角列出所有已安装的 lingshu brain.py/cli.py 副本及其修复状态。"""
|
|
3
|
-
import os
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
|
|
6
|
-
HOME = Path(os.path.expanduser("~"))
|
|
7
|
-
MARK = "_EXCLUDE_DIR_PARTS"
|
|
8
|
-
|
|
9
|
-
cands = [
|
|
10
|
-
HOME / ".app" / "skills" / "lingshu" / "scripts" / "cli.py",
|
|
11
|
-
HOME / ".trae-cn" / "skills" / "lingshu" / "scripts" / "cli.py",
|
|
12
|
-
HOME / ".app" / "profiles" / "desktop" / "node_modules" / "lingshu-skill" / "scripts" / "cli.py",
|
|
13
|
-
]
|
|
14
|
-
print("== 候选路径 ==")
|
|
15
|
-
for p in cands:
|
|
16
|
-
ok = p.is_file()
|
|
17
|
-
fix = (MARK in p.read_text(encoding="utf-8", errors="replace")) if ok else None
|
|
18
|
-
print(f" exists={ok!s:<5} fix={fix!s:<5} {p}")
|
|
19
|
-
|
|
20
|
-
print("\n== 全盘搜 node_modules/lingshu-skill/scripts/cli.py(限深) ==")
|
|
21
|
-
base = HOME
|
|
22
|
-
depth_limit = 7
|
|
23
|
-
for root, dirs, files in os.walk(base):
|
|
24
|
-
depth = len(Path(root).relative_to(base).parts)
|
|
25
|
-
if depth >= depth_limit:
|
|
26
|
-
dirs[:] = []
|
|
27
|
-
continue
|
|
28
|
-
if Path(root).name == "scripts" and "cli.py" in files and "lingshu" in str(Path(root).parent):
|
|
29
|
-
p = Path(root) / "cli.py"
|
|
30
|
-
fix = MARK in p.read_text(encoding="utf-8", errors="replace")
|
|
31
|
-
print(f" fix={fix!s:<5} mtime={p.stat().st_mtime_ns} {p}")
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""一次性:按 doctor 的办法定位 APP profile,并打印目录名码位 + 依赖声明(可删)。"""
|
|
3
|
-
import json
|
|
4
|
-
import os
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
|
|
7
|
-
home = Path(os.path.expanduser("~"))
|
|
8
|
-
found = None
|
|
9
|
-
for name in os.listdir(home):
|
|
10
|
-
cand = home / name / "profiles" / "desktop"
|
|
11
|
-
try:
|
|
12
|
-
if (cand / "package.json").is_file():
|
|
13
|
-
found = cand
|
|
14
|
-
print("命中目录名:", name, "| chars=", ",".join(str(ord(c)) for c in name))
|
|
15
|
-
break
|
|
16
|
-
except OSError:
|
|
17
|
-
continue
|
|
18
|
-
if not found:
|
|
19
|
-
print("没找到")
|
|
20
|
-
raise SystemExit(1)
|
|
21
|
-
|
|
22
|
-
d = json.loads((found / "package.json").read_text(encoding="utf-8-sig"))
|
|
23
|
-
spec = str(((d.get("dependencies") or {}).get("lingshu-skill")) or "")
|
|
24
|
-
inst = found / "node_modules" / "lingshu-skill" / "package.json"
|
|
25
|
-
ver = ""
|
|
26
|
-
if inst.is_file():
|
|
27
|
-
ver = json.loads(inst.read_text(encoding="utf-8-sig")).get("version", "")
|
|
28
|
-
print("profile:", found)
|
|
29
|
-
print("声明 spec =", repr(spec), "| node_modules 实际版本 =", ver)
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""一次性:把 profile 里 lingshu-skill 的依赖声明从 ^5.33.0 改成 ^5.34.0(可删)。
|
|
3
|
-
|
|
4
|
-
只改声明,不跑 pnpm install——npm 上还没发布 5.34,install 会 404。
|
|
5
|
-
真正升级应在 `release.py publish` 之后再做。
|
|
6
|
-
"""
|
|
7
|
-
import os
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
|
|
10
|
-
home = Path(os.path.expanduser("~"))
|
|
11
|
-
prof = None
|
|
12
|
-
for name in os.listdir(home):
|
|
13
|
-
cand = home / name / "profiles" / "desktop"
|
|
14
|
-
try:
|
|
15
|
-
if (cand / "package.json").is_file():
|
|
16
|
-
prof = cand
|
|
17
|
-
break
|
|
18
|
-
except OSError:
|
|
19
|
-
continue
|
|
20
|
-
if prof is None:
|
|
21
|
-
print("没找到 profile")
|
|
22
|
-
raise SystemExit(1)
|
|
23
|
-
|
|
24
|
-
p = prof / "package.json"
|
|
25
|
-
raw = p.read_text(encoding="utf-8-sig")
|
|
26
|
-
old = '"lingshu-skill": "^5.33.0"'
|
|
27
|
-
new = '"lingshu-skill": "^5.34.0"'
|
|
28
|
-
if old not in raw:
|
|
29
|
-
print("没匹配到旧声明;当前包含 lingshu-skill 的行:")
|
|
30
|
-
for ln in raw.splitlines():
|
|
31
|
-
if "lingshu-skill" in ln:
|
|
32
|
-
print(" ", ln.strip())
|
|
33
|
-
raise SystemExit(2)
|
|
34
|
-
p.write_text(raw.replace(old, new, 1), encoding="utf-8")
|
|
35
|
-
print("已更新:", p)
|
|
36
|
-
print("新声明:", new)
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""一次性:导出**保真**的决策消息(保留 tool-call 段)+ 真实折叠(可删)。
|
|
3
|
-
|
|
4
|
-
注意:把 text 段截到 200 字只为缩小夹具;**结构(段类型/配对)必须原样保留**,
|
|
5
|
-
否则「悬挂工具结果」这类检查会全是假阳性。
|
|
6
|
-
"""
|
|
7
|
-
import json
|
|
8
|
-
import sys
|
|
9
|
-
from pathlib import Path
|
|
10
|
-
|
|
11
|
-
sys.path.insert(0, r"E:\丁厚同\文档\程序\灵枢-skill\scripts")
|
|
12
|
-
import app_context
|
|
13
|
-
|
|
14
|
-
p = app_context.find_session()
|
|
15
|
-
ev = app_context.read_events(p)
|
|
16
|
-
|
|
17
|
-
# 直接按事件原样取消息体(_msg_of 已处理两种形态),按 id 去重
|
|
18
|
-
seen = set()
|
|
19
|
-
host_msgs = []
|
|
20
|
-
for e in ev:
|
|
21
|
-
m = app_context._msg_of(e)
|
|
22
|
-
if not isinstance(m, dict):
|
|
23
|
-
continue
|
|
24
|
-
mid = m.get("id")
|
|
25
|
-
if mid and mid in seen:
|
|
26
|
-
continue
|
|
27
|
-
if mid:
|
|
28
|
-
seen.add(mid)
|
|
29
|
-
if m.get("role") == "system":
|
|
30
|
-
continue
|
|
31
|
-
parts = []
|
|
32
|
-
for x in (m.get("content") or []):
|
|
33
|
-
if not isinstance(x, dict):
|
|
34
|
-
continue
|
|
35
|
-
if x.get("type") == "text":
|
|
36
|
-
parts.append({"type": "text", "text": str(x.get("text") or "")[:200]})
|
|
37
|
-
elif x.get("type") == "tool-call":
|
|
38
|
-
parts.append(x) # 原样保留,含 id
|
|
39
|
-
elif x.get("type") == "reasoning":
|
|
40
|
-
parts.append({"type": "reasoning", "text": "…"})
|
|
41
|
-
item = {"id": mid, "role": m.get("role"), "content": parts}
|
|
42
|
-
if m.get("toolCallId"):
|
|
43
|
-
item["toolCallId"] = m.get("toolCallId")
|
|
44
|
-
host_msgs.append(item)
|
|
45
|
-
|
|
46
|
-
doc = app_context.load_folds()
|
|
47
|
-
active = [f for f in doc["folds"] if not f.get("restored")]
|
|
48
|
-
out = Path(sys.argv[1])
|
|
49
|
-
out.write_text(json.dumps({"folds": active, "messages": host_msgs}, ensure_ascii=False),
|
|
50
|
-
encoding="utf-8")
|
|
51
|
-
print("fold_id:", active[-1]["id"], "fold_msgs:", len(active[-1]["message_ids"]))
|
|
52
|
-
print("host_messages:", len(host_msgs),
|
|
53
|
-
"| with tool-call:", sum(1 for m in host_msgs if any(p.get("type") == "tool-call" for p in m["content"])),
|
|
54
|
-
"| tool results:", sum(1 for m in host_msgs if m.get("toolCallId")))
|
|
55
|
-
print("fixture ->", out)
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// 一次性:验证 context-fold.js 的 applyFolds(可删)
|
|
2
|
-
import { readFileSync, mkdirSync, writeFileSync, rmSync } from 'node:fs'
|
|
3
|
-
import { join } from 'node:path'
|
|
4
|
-
import { tmpdir } from 'node:os'
|
|
5
|
-
import { applyFolds } from './cordis-plugin/lingshu-startup/context-fold.js'
|
|
6
|
-
|
|
7
|
-
const fx = JSON.parse(readFileSync(process.argv[2], 'utf8'))
|
|
8
|
-
|
|
9
|
-
const home = join(tmpdir(), 'ls-fold-test-' + Date.now())
|
|
10
|
-
mkdirSync(home, { recursive: true })
|
|
11
|
-
// 必须设环境变量:模块的 memoryHome() 每次调用都读 BRAIN_MEMORY_HOME,
|
|
12
|
-
// 不设就会去读真实的 ~/.brain-memory/context-folds.json,测试全部失真。
|
|
13
|
-
process.env.BRAIN_MEMORY_HOME = home
|
|
14
|
-
|
|
15
|
-
function writeLedger(doc) {
|
|
16
|
-
writeFileSync(join(home, 'context-folds.json'), JSON.stringify(doc, null, 2), 'utf8')
|
|
17
|
-
}
|
|
18
|
-
function mkDecision(messages) {
|
|
19
|
-
return { kind: 'enter', messages: messages.map((m) => JSON.parse(JSON.stringify(m))) }
|
|
20
|
-
}
|
|
21
|
-
function countOrphans(messages) {
|
|
22
|
-
const produced = new Set()
|
|
23
|
-
for (const m of messages) {
|
|
24
|
-
for (const p of (m.content || [])) {
|
|
25
|
-
if (p && p.type === 'tool-call' && p.id) produced.add(String(p.id))
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return messages.filter((m) => m.toolCallId && !produced.has(String(m.toolCallId))).length
|
|
29
|
-
}
|
|
30
|
-
function foldCount(messages) {
|
|
31
|
-
return messages.filter((m) => String(m.id || '').startsWith('fold-')).length
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
let fail = 0
|
|
35
|
-
|
|
36
|
-
// ---- 场景 A:真实账本,整轮折叠 ----
|
|
37
|
-
writeLedger({ version: 1, folds: fx.folds })
|
|
38
|
-
const dA = mkDecision(fx.messages)
|
|
39
|
-
const rA = applyFolds(dA, 1600)
|
|
40
|
-
const orphanA = countOrphans(dA.messages)
|
|
41
|
-
console.log('A 真实账本:', JSON.stringify({
|
|
42
|
-
ok: rA.ok, changed: rA.changed, folded: rA.folded,
|
|
43
|
-
before: fx.messages.length, after: dA.messages.length,
|
|
44
|
-
inserted: foldCount(dA.messages), orphan: orphanA,
|
|
45
|
-
}))
|
|
46
|
-
if (orphanA !== 0) { console.error('FAIL A: 悬挂工具结果'); fail++ }
|
|
47
|
-
if (!rA.changed) { console.error('FAIL A: 没折叠'); fail++ }
|
|
48
|
-
if (foldCount(dA.messages) !== fx.folds.length) { console.error('FAIL A: 插入条数不符'); fail++ }
|
|
49
|
-
|
|
50
|
-
// ---- 场景 B:对抗——把一个工具结果从折叠里抠掉(模拟不完整折叠)----
|
|
51
|
-
const f0 = fx.folds[0]
|
|
52
|
-
const toolMsg = fx.messages.find((m) => m.role === 'tool' && f0.message_ids.includes(m.id))
|
|
53
|
-
let rB = null, orphanB = null, changedB = null
|
|
54
|
-
if (toolMsg) {
|
|
55
|
-
const tampered = { ...f0, message_ids: f0.message_ids.filter((x) => x !== toolMsg.id) }
|
|
56
|
-
writeLedger({ version: 1, folds: [tampered] })
|
|
57
|
-
const dB = mkDecision(fx.messages)
|
|
58
|
-
rB = applyFolds(dB, 1600)
|
|
59
|
-
orphanB = countOrphans(dB.messages)
|
|
60
|
-
changedB = rB.changed
|
|
61
|
-
console.log('B 抠掉工具结果后:', JSON.stringify({
|
|
62
|
-
ok: rB.ok, changed: rB.changed, folded: rB.folded, reason: rB.reason,
|
|
63
|
-
after: dB.messages.length, orphan: orphanB,
|
|
64
|
-
}))
|
|
65
|
-
if (orphanB !== 0) { console.error('FAIL B: 悬挂工具结果(防护没拦住)'); fail++ }
|
|
66
|
-
if (changedB === true) { console.error('FAIL B: 不完整折叠被应用了'); fail++ }
|
|
67
|
-
} else {
|
|
68
|
-
console.log('B 跳过:该折叠里没有 tool 消息')
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// ---- 场景 C:无账本 → 原样返回 ----
|
|
72
|
-
writeLedger({ version: 1, folds: [] })
|
|
73
|
-
const dC = mkDecision(fx.messages)
|
|
74
|
-
const rC = applyFolds(dC, 1600)
|
|
75
|
-
console.log('C 空账本:', JSON.stringify({ ok: rC.ok, changed: rC.changed,
|
|
76
|
-
before: fx.messages.length, after: dC.messages.length }))
|
|
77
|
-
if (rC.changed) { console.error('FAIL C: 空账本也改了'); fail++ }
|
|
78
|
-
|
|
79
|
-
rmSync(home, { recursive: true, force: true })
|
|
80
|
-
console.log(fail === 0 ? 'PASS' : `FAILED(${fail})`)
|
|
81
|
-
process.exit(fail === 0 ? 0 : 1)
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""一次性诊断:注入包里每段到底装了什么(可删)。"""
|
|
3
|
-
import sys
|
|
4
|
-
from collections import Counter
|
|
5
|
-
|
|
6
|
-
sys.path.insert(0, r"E:\丁厚同\文档\程序\灵枢-skill\scripts")
|
|
7
|
-
import brain # noqa: E402
|
|
8
|
-
|
|
9
|
-
rep = {}
|
|
10
|
-
res = brain.build_injection("", 1400, rep)
|
|
11
|
-
print("总字符:", len(res))
|
|
12
|
-
secs = rep.get("sections") or []
|
|
13
|
-
for s in secs:
|
|
14
|
-
print(f" {s['name']:<14} chars={s['chars']:<6} tokens={s['tokens']}")
|
|
15
|
-
|
|
16
|
-
print("\n== 各段内容样本(前 3 行) ==")
|
|
17
|
-
# 用带段名的原因:build_injection 内部 out 已恒为 _SectionList,但外部拿不到,
|
|
18
|
-
# 所以这里退一步:直接看注入文本里每个二级标题归属哪一段。
|
|
19
|
-
lines = res.splitlines()
|
|
20
|
-
cur = None
|
|
21
|
-
buckets = {}
|
|
22
|
-
for ln in lines:
|
|
23
|
-
if ln.startswith("## ") or ln.startswith("\n## "):
|
|
24
|
-
cur = ln.strip("# ").strip()
|
|
25
|
-
buckets.setdefault(cur or "<头部>", []).append(ln)
|
|
26
|
-
for k, v in sorted(buckets.items(), key=lambda x: -sum(len(i) for i in x[1]))[:8]:
|
|
27
|
-
size = sum(len(i) for i in v)
|
|
28
|
-
print(f"\n--- {k} ({size} 字符, {len(v)} 行) ---")
|
|
29
|
-
for ln in v[:3]:
|
|
30
|
-
print(" ", ln[:100])
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
# 把「金额不显示」的因果与修复步骤写进灵枢知识库
|
|
2
|
-
# 用 Python 直调 growth/memory API:argparse 传多行中文容易踩编码坑。
|
|
3
|
-
import sys
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
|
|
6
|
-
ROOT = Path(r"E:\丁厚同\文档\程序\灵枢-skill")
|
|
7
|
-
sys.path.insert(0, str(ROOT / "scripts"))
|
|
8
|
-
|
|
9
|
-
import brain # noqa: E402,F401 入口合并
|
|
10
|
-
import growth # noqa: E402
|
|
11
|
-
import memory as _mem # noqa: E402
|
|
12
|
-
|
|
13
|
-
TITLE = "APP 左侧金额不显示:accounts.js 被插件安装还原(一键修复 + 复发规律)"
|
|
14
|
-
|
|
15
|
-
BODY = """\
|
|
16
|
-
## 症状
|
|
17
|
-
|
|
18
|
-
DSH(APP)左侧「DeepSeek Usage」卡片的金额空了 / 不显示 / 一直转圈。
|
|
19
|
-
|
|
20
|
-
## 根因(一句话)
|
|
21
|
-
|
|
22
|
-
`node_modules` 里的 `@dougen/dsh-deepseek-usage/lib/accounts.js` 被**还原成原版**,
|
|
23
|
-
`laneai` / `laneai1` 两个余额能力丢失,插件就不知道去哪查余额。
|
|
24
|
-
|
|
25
|
-
触发条件很明确:**任何一次插件安装或更新**。今天就是装了 `dsh-thinking-proxy` 之后金额没的。
|
|
26
|
-
这是规律不是偶发——`node_modules` 里的改动永远会被包管理器覆盖。
|
|
27
|
-
|
|
28
|
-
## 三秒判据(先看这行,别乱猜)
|
|
29
|
-
|
|
30
|
-
文件:`C:\\Users\\Administrator\\.dsh\\profiles\\desktop\\node_modules\\@dougen\\dsh-deepseek-usage\\lib\\accounts.js`
|
|
31
|
-
|
|
32
|
-
| 大小 | 含义 |
|
|
33
|
-
|---|---|
|
|
34
|
-
| **40746** 字节 | 原版,**已损坏**,金额必空 |
|
|
35
|
-
| **43859** 字节 | 已打补丁,正常 |
|
|
36
|
-
|
|
37
|
-
再补三条文本判据(都应为 True):含 `laneai`、含 `parseLaneaiBalance`、含 `case 'laneai'`。
|
|
38
|
-
|
|
39
|
-
## 修复(两步,缺一不可)
|
|
40
|
-
|
|
41
|
-
**第 1 步:补代码**
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
python E:\\丁厚同\\文档\\程序\\app-plugins\\laneai-balance\\fix_balance.py
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
或双击桌面 `修复余额显示.cmd`。脚本会先把原文件备份进灵枢垃圾桶
|
|
48
|
-
(`灵枢-skill\\垃圾桶\\accounts.js.<时间戳>.fix-balance.bak`),再打补丁、跑 node 语法检查。
|
|
49
|
-
|
|
50
|
-
只读检查用 `fix_balance.py --check`(输出「缺失/正常」,不改文件)。
|
|
51
|
-
|
|
52
|
-
**第 2 步:让运行时重新加载模块**
|
|
53
|
-
|
|
54
|
-
补完文件**不会自动生效**——已加载的 ESM 模块不会重读磁盘。必须二选一:
|
|
55
|
-
|
|
56
|
-
- 用 `plugin_manager set_plugin` 把 `include:deepseek-usage` 关一次再开一次(推荐,不用重启);
|
|
57
|
-
- 或在 APP 里把插件关掉再打开 / 重启 APP。
|
|
58
|
-
|
|
59
|
-
只做第 1 步不做第 2 步,你会以为没修好。
|
|
60
|
-
|
|
61
|
-
## 验证(唯一可信的证据)
|
|
62
|
-
|
|
63
|
-
```
|
|
64
|
-
GET http://127.0.0.1:<DSH端口>/api/deepseek-usage
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
正常应返回类似:
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
{"ok":true,
|
|
71
|
-
"provider":{"id":"laneai1","kind":"balance","via":"exact"},
|
|
72
|
-
"balance":{"isAvailable":true,"total":8.486908,"currency":"CNY"},
|
|
73
|
-
"errors":[]}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
- `balance.total` 有数字 = 真的好了;
|
|
77
|
-
- `errors` 非空 = 还没好,看里面写的原因;
|
|
78
|
-
- 侧栏卡片读的就是这个接口,接口对有数就说明卡片会显示。
|
|
79
|
-
|
|
80
|
-
`GET /api/deepseek-usage/accounts` 可看能力表:`aliasable` 里应同时有 `laneai1` 与 `laneai`。
|
|
81
|
-
|
|
82
|
-
## 配置侧的另一半(别忽略)
|
|
83
|
-
|
|
84
|
-
`C:\\Users\\Administrator\\.dsh\\profiles\\desktop\\cordis.patch.yml` 里 `deepseek-usage`
|
|
85
|
-
**必须只有 1 个条目**,`providerAliases` 应有 5 条映射
|
|
86
|
-
(`laneai1-vision` / `laneai1` / `laneai-vision` / `laneai` → `capability: laneai1`;
|
|
87
|
-
`deepseek-vision` → `capability: deepseek-official`)。
|
|
88
|
-
|
|
89
|
-
插件**设置页会追加**一个空 `providerAliases: []` 而不是更新,一旦用那个页面编辑映射,
|
|
90
|
-
映射就会被清空、卡片照样是空的。**不要用设置页改映射**,直接改 `cordis.patch.yml`。
|
|
91
|
-
|
|
92
|
-
## 踩过的两个坑
|
|
93
|
-
|
|
94
|
-
1. **判据别只看"有没有 laneai"**:补丁前 40746 字节里也可能出现 `laneai` 字样(注释里),
|
|
95
|
-
所以要同时看 `parseLaneaiBalance` 函数与 `case 'laneai'` 分支。
|
|
96
|
-
2. **测解析函数要传已解析的对象**,不能传 JSON 字符串:
|
|
97
|
-
`parseLaneaiBalance(JSON.stringify({...}))` 会返回 `code:"shape"`(因为字符串不是 object),
|
|
98
|
-
让人误以为解析器坏了。它要的字段是 `hard_limit_usd`(缺失时退 `soft_limit_usd`),
|
|
99
|
-
数字和数字字符串都接受。
|
|
100
|
-
|
|
101
|
-
## 为什么不能一劳永逸
|
|
102
|
-
|
|
103
|
-
`laneai` 不是官方能力,是本地补丁加进 `accounts.js` 的。只要包管理还会覆盖 `node_modules`,
|
|
104
|
-
补丁就会被冲掉。所以这件事的正确心态是:**每次装/更新插件后,顺手确认一次金额**;
|
|
105
|
-
不是"修好了就没事了"。
|
|
106
|
-
"""
|
|
107
|
-
|
|
108
|
-
POINTS = [
|
|
109
|
-
"症状:APP 左侧 DeepSeek Usage 卡片金额空了/不显示",
|
|
110
|
-
"根因:node_modules/@dougen/dsh-deepseek-usage/lib/accounts.js 被插件安装或更新还原成原版",
|
|
111
|
-
"三秒判据:accounts.js 40746 字节=原版已坏;43859 字节=已补丁正常",
|
|
112
|
-
"修复第1步:跑 app-plugins/laneai-balance/fix_balance.py(或桌面 修复余额显示.cmd)",
|
|
113
|
-
"修复第2步:必须把 include:deepseek-usage 关一次再开一次,否则模块不重载、看着像没修好",
|
|
114
|
-
"验证:GET /api/deepseek-usage,看 balance.total 有数字、errors 为空",
|
|
115
|
-
"配置侧:cordis.patch.yml 里 deepseek-usage 只能有 1 个条目;不要用插件设置页改映射(会追加空数组清掉)",
|
|
116
|
-
"复发规律:每次装/更新任何插件后都要顺手确认金额,补丁不是一劳永逸",
|
|
117
|
-
]
|
|
118
|
-
|
|
119
|
-
TAGS = ["DSH", "插件", "金额", "余额", "deepseek-usage", "laneai", "已修复", "复发"]
|
|
120
|
-
|
|
121
|
-
MEM_TEXT = (
|
|
122
|
-
"APP 左侧金额不显示(DSH / @dougen/dsh-deepseek-usage)已修好并留了排查手册:"
|
|
123
|
-
"根因是 node_modules 里的 accounts.js 被任何一次插件安装/更新还原成原版(40746 字节),"
|
|
124
|
-
"laneai/laneai1 余额能力丢失。判据:40746=坏、43859=好。修复两步:①跑 "
|
|
125
|
-
"E:\\丁厚同\\文档\\程序\\app-plugins\\laneai-balance\\fix_balance.py;"
|
|
126
|
-
"②必须把 include:deepseek-usage 关一次再开一次(模块不会自动重载)。"
|
|
127
|
-
"验证 GET /api/deepseek-usage 看 balance.total。不要再犯的坑:判据别只看有没有 laneai 字样,"
|
|
128
|
-
"要看 parseLaneaiBalance 与 case 'laneai';测试解析函数要传对象不是 JSON 字符串。"
|
|
129
|
-
"详细手册见知识库「APP 左侧金额不显示」。"
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
def main() -> int:
|
|
134
|
-
try:
|
|
135
|
-
dup = [k for k in growth.list_knowledge() if k.get("title") == TITLE]
|
|
136
|
-
except Exception:
|
|
137
|
-
dup = []
|
|
138
|
-
if dup:
|
|
139
|
-
print(f"[skip] 已有同标题知识 id={dup[0].get('id')},不重复写入")
|
|
140
|
-
else:
|
|
141
|
-
rec, how = growth.add_knowledge(
|
|
142
|
-
TITLE, BODY, "故障排查",
|
|
143
|
-
points=POINTS, tags=TAGS,
|
|
144
|
-
entities=["dsh-deepseek-usage", "laneai", "fix_balance.py"],
|
|
145
|
-
source="user", # 人工写入 → 直接 confirmed,不进待审
|
|
146
|
-
)
|
|
147
|
-
print(f"[knowledge] {how} id={rec.get('id')} status={rec.get('status')}")
|
|
148
|
-
|
|
149
|
-
mrec, mhow = _mem.remember(
|
|
150
|
-
MEM_TEXT, "fact", 8,
|
|
151
|
-
["DSH", "金额", "余额", "已修复"],
|
|
152
|
-
["dsh-deepseek-usage", "laneai"], "user",
|
|
153
|
-
)
|
|
154
|
-
print(f"[memory] {mhow} id={mrec.get('id')} imp={mrec.get('importance')}")
|
|
155
|
-
return 0
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if __name__ == "__main__":
|
|
159
|
-
sys.exit(main())
|