lingshu-skill 5.61.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 +14 -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 +8 -8
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +14 -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/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/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/_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
|
@@ -1688,12 +1688,11 @@ def apply_update(src_dir: Path, dst_dir: Path,
|
|
|
1688
1688
|
+ ", ".join(sorted(_missing)[:8])
|
|
1689
1689
|
+ (f" 等 {len(_missing)} 个" if len(_missing) > 8 else ""))
|
|
1690
1690
|
def _norm_sha(p: Path) -> str:
|
|
1691
|
+
# LS-121(v5.62):二进制文件(png, ico等)不执行文本换行归一化,直接取原始字节 SHA
|
|
1692
|
+
if p.suffix.lower() in {".png", ".ico", ".jpg", ".jpeg", ".webp", ".gif", ".pdf", ".woff", ".woff2", ".ttf"}:
|
|
1693
|
+
return _sha256_file(p)
|
|
1691
1694
|
# 规范形态哈希:与 make_manifest.py 生成侧完全一致——
|
|
1692
1695
|
# CRLF→LF 归一化(autocrlf/git clone 的换行符差异)+ 剥 UTF-8 BOM
|
|
1693
|
-
# (raw 下载/记事本保存可能带 BOM)。字节形态不同但内容没变的文件
|
|
1694
|
-
# 放行,内容真被篡改仍然拦得住。
|
|
1695
|
-
# 注意分块方式:\r 必须暂存到下一块拼回来再 replace——否则恰好在
|
|
1696
|
-
# 64KB 边界被切成 \r|\n 的换行符会漏归一化,大文件哈希对不上。
|
|
1697
1696
|
h = hashlib.sha256()
|
|
1698
1697
|
first = True
|
|
1699
1698
|
tail = b""
|
|
@@ -33,9 +33,26 @@ EXCLUDE_NAMES = {"panel-token.txt", ".env", "LINGSHU_PANEL_TOKEN", "config.json"
|
|
|
33
33
|
|
|
34
34
|
def collect() -> list[Path]:
|
|
35
35
|
"""manifest 发布文件 + engine/ 全目录(都要先 sync 生成)。"""
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
manifest_p = ROOT / "manifest.json"
|
|
37
|
+
if not manifest_p.is_file():
|
|
38
|
+
raise SystemExit("[错误] 找不到 manifest.json,拒绝打包")
|
|
39
|
+
manifest = json.loads(manifest_p.read_text(encoding="utf-8"))
|
|
40
|
+
|
|
41
|
+
# LS-119(v5.62):DSH 打包遇到清单缺文件必须失败非零退出!
|
|
42
|
+
missing = []
|
|
43
|
+
files = []
|
|
44
|
+
for rel in manifest.get("files", {}):
|
|
45
|
+
p = ROOT / rel
|
|
46
|
+
if not p.is_file():
|
|
47
|
+
missing.append(rel)
|
|
48
|
+
else:
|
|
49
|
+
files.append(p)
|
|
50
|
+
if missing:
|
|
51
|
+
raise SystemExit(f"[错误] DSH 打包失败:manifest 中有 {len(missing)} 个文件在本地缺失!\n 缺失示例: {', '.join(missing[:5])}")
|
|
52
|
+
|
|
53
|
+
# LS-120(v5.62):将 manifest.json 本身加入 DSH tgz 的根目录,保证安装后能做完整哈希校验
|
|
54
|
+
files.append(manifest_p)
|
|
55
|
+
|
|
39
56
|
# engine/ 派生副本(打包时生成,不入库)
|
|
40
57
|
engine = ROOT / "scripts" / "astrbot_plugin_lingshu" / "engine"
|
|
41
58
|
if engine.is_dir():
|
|
@@ -82,11 +82,24 @@ def build(src: Path = SRC, out: Path | None = OUT) -> bytes:
|
|
|
82
82
|
"""拼装产物;out=None 时只返回字节、不落盘(--check 用,检查不该改文件)。"""
|
|
83
83
|
shell = (src / "index.html").read_bytes()
|
|
84
84
|
meta = json.loads((src / "blocks.json").read_text(encoding="utf-8"))
|
|
85
|
+
consumed = 0
|
|
85
86
|
for i, blk in enumerate(meta):
|
|
86
87
|
token = f"<!--@@BLOCK:{i}@@-->".encode()
|
|
88
|
+
if token not in shell:
|
|
89
|
+
raise ValueError(f"LS-123 缺失占位符:index.html 中未找到 {token.decode()} 无法嵌入块 {blk['file']}")
|
|
87
90
|
body = (src / blk["file"]).read_bytes()
|
|
88
91
|
close = b"</style>" if blk["kind"] == "style" else b"</script>"
|
|
89
92
|
shell = shell.replace(token, blk["open"].encode() + body + close, 1)
|
|
93
|
+
consumed += 1
|
|
94
|
+
|
|
95
|
+
# LS-123(v5.62):面板构建校验所有占位符和块均被消费!
|
|
96
|
+
# 检查产物中是否仍残留未被替换的 <!--@@BLOCK:*@@--> 占位符
|
|
97
|
+
leftover = re.findall(rb"<!--@@BLOCK:\d+@@-->", shell)
|
|
98
|
+
if leftover:
|
|
99
|
+
raise ValueError(f"LS-123 构建产物中残留未消费的占位符:{[x.decode() for x in leftover]}")
|
|
100
|
+
if consumed != len(meta):
|
|
101
|
+
raise ValueError(f"LS-123 ���消费不全:定义了 {len(meta)} 个块,实际消费 {consumed} 个")
|
|
102
|
+
|
|
90
103
|
if out is not None:
|
|
91
104
|
out.parent.mkdir(parents=True, exist_ok=True)
|
|
92
105
|
out.write_bytes(shell)
|
package/scripts/growth.py
CHANGED
|
@@ -1688,12 +1688,11 @@ def apply_update(src_dir: Path, dst_dir: Path,
|
|
|
1688
1688
|
+ ", ".join(sorted(_missing)[:8])
|
|
1689
1689
|
+ (f" 等 {len(_missing)} 个" if len(_missing) > 8 else ""))
|
|
1690
1690
|
def _norm_sha(p: Path) -> str:
|
|
1691
|
+
# LS-121(v5.62):二进制文件(png, ico等)不执行文本换行归一化,直接取原始字节 SHA
|
|
1692
|
+
if p.suffix.lower() in {".png", ".ico", ".jpg", ".jpeg", ".webp", ".gif", ".pdf", ".woff", ".woff2", ".ttf"}:
|
|
1693
|
+
return _sha256_file(p)
|
|
1691
1694
|
# 规范形态哈希:与 make_manifest.py 生成侧完全一致——
|
|
1692
1695
|
# CRLF→LF 归一化(autocrlf/git clone 的换行符差异)+ 剥 UTF-8 BOM
|
|
1693
|
-
# (raw 下载/记事本保存可能带 BOM)。字节形态不同但内容没变的文件
|
|
1694
|
-
# 放行,内容真被篡改仍然拦得住。
|
|
1695
|
-
# 注意分块方式:\r 必须暂存到下一块拼回来再 replace——否则恰好在
|
|
1696
|
-
# 64KB 边界被切成 \r|\n 的换行符会漏归一化,大文件哈希对不上。
|
|
1697
1696
|
h = hashlib.sha256()
|
|
1698
1697
|
first = True
|
|
1699
1698
|
tail = b""
|
package/scripts/make_dsh_tgz.py
CHANGED
|
@@ -33,9 +33,26 @@ EXCLUDE_NAMES = {"panel-token.txt", ".env", "LINGSHU_PANEL_TOKEN", "config.json"
|
|
|
33
33
|
|
|
34
34
|
def collect() -> list[Path]:
|
|
35
35
|
"""manifest 发布文件 + engine/ 全目录(都要先 sync 生成)。"""
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
manifest_p = ROOT / "manifest.json"
|
|
37
|
+
if not manifest_p.is_file():
|
|
38
|
+
raise SystemExit("[错误] 找不到 manifest.json,拒绝打包")
|
|
39
|
+
manifest = json.loads(manifest_p.read_text(encoding="utf-8"))
|
|
40
|
+
|
|
41
|
+
# LS-119(v5.62):DSH 打包遇到清单缺文件必须失败非零退出!
|
|
42
|
+
missing = []
|
|
43
|
+
files = []
|
|
44
|
+
for rel in manifest.get("files", {}):
|
|
45
|
+
p = ROOT / rel
|
|
46
|
+
if not p.is_file():
|
|
47
|
+
missing.append(rel)
|
|
48
|
+
else:
|
|
49
|
+
files.append(p)
|
|
50
|
+
if missing:
|
|
51
|
+
raise SystemExit(f"[错误] DSH 打包失败:manifest 中有 {len(missing)} 个文件在本地缺失!\n 缺失示例: {', '.join(missing[:5])}")
|
|
52
|
+
|
|
53
|
+
# LS-120(v5.62):将 manifest.json 本身加入 DSH tgz 的根目录,保证安装后能做完整哈希校验
|
|
54
|
+
files.append(manifest_p)
|
|
55
|
+
|
|
39
56
|
# engine/ 派生副本(打包时生成,不入库)
|
|
40
57
|
engine = ROOT / "scripts" / "astrbot_plugin_lingshu" / "engine"
|
|
41
58
|
if engine.is_dir():
|
package/scripts/make_manifest.py
CHANGED
|
@@ -54,19 +54,24 @@ def _excluded(rel: str, name: str) -> bool:
|
|
|
54
54
|
return name.startswith("test_") and name.endswith(".py")
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
# 二进制扩展名白名单(图片、图标、音频等):绝不执行换行符归一化
|
|
58
|
+
BINARY_EXTS = {".png", ".ico", ".jpg", ".jpeg", ".webp", ".gif", ".pdf", ".woff", ".woff2", ".ttf"}
|
|
59
59
|
|
|
60
|
-
manifest 是发布契约——它必须对应"发布内容的规范形态",而不是作者本机的
|
|
61
|
-
磁盘形态。作者机器 core.autocrlf=true + 记事本存盘会把工作区文件写成
|
|
62
|
-
CRLF+带 BOM,逐字节哈希记录的就是这套形态;用户按 raw / zip 拿到的是
|
|
63
|
-
LF+无 BOM,逐字节比对永远失败(v2.52 只修了比对侧,没修生成侧)。
|
|
64
|
-
换行符与 BOM 都不改变内容语义,归一化后哈希才与发布内容对齐;
|
|
65
|
-
真正的内容篡改仍拦得住。
|
|
66
60
|
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
def sha256_file(p: Path) -> tuple[str, int]:
|
|
62
|
+
"""计算文件的 SHA256 与大小。
|
|
63
|
+
LS-121(v5.62):仅对文本文件执行换行符归一化(CRLF→LF + 剥 BOM);
|
|
64
|
+
二进制文件(如 png, ico)按原始字节计算哈希与大小,绝不能当作文本替换字节破坏文件哈希!
|
|
69
65
|
"""
|
|
66
|
+
if p.suffix.lower() in BINARY_EXTS:
|
|
67
|
+
h = hashlib.sha256()
|
|
68
|
+
size = 0
|
|
69
|
+
with open(p, "rb") as f:
|
|
70
|
+
for chunk in iter(lambda: f.read(1 << 16), b""):
|
|
71
|
+
h.update(chunk)
|
|
72
|
+
size += len(chunk)
|
|
73
|
+
return h.hexdigest(), size
|
|
74
|
+
|
|
70
75
|
h = hashlib.sha256()
|
|
71
76
|
size = 0
|
|
72
77
|
first = True
|
|
@@ -25,8 +25,8 @@ sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
|
25
25
|
|
|
26
26
|
REPO = Path(__file__).resolve().parent.parent
|
|
27
27
|
SRC = REPO / "scripts" / "astrbot_plugin_lingshu"
|
|
28
|
-
EXCLUDE_DIRS = {"__pycache__"}
|
|
29
|
-
EXCLUDE_SUFFIX = {".pyc", ".pyo", ".log", ".zip"}
|
|
28
|
+
EXCLUDE_DIRS = {"__pycache__", "_scratch", "垃圾桶", "_ui_probe", "tests"}
|
|
29
|
+
EXCLUDE_SUFFIX = {".pyc", ".pyo", ".log", ".zip", ".tmp"}
|
|
30
30
|
EXCLUDE_NAMES = {"panel-token.txt", ".home", "consent.json",
|
|
31
31
|
"hippocampus.jsonl", "persona.json", "emotions.jsonl"}
|
|
32
32
|
|
|
@@ -36,7 +36,11 @@ def collect() -> list[Path]:
|
|
|
36
36
|
for p in sorted(SRC.rglob("*")):
|
|
37
37
|
if p.is_dir():
|
|
38
38
|
continue
|
|
39
|
-
|
|
39
|
+
rel_parts = p.relative_to(SRC).parts
|
|
40
|
+
if any(part in EXCLUDE_DIRS for part in rel_parts):
|
|
41
|
+
continue
|
|
42
|
+
# LS-118(v5.62):排除开发探针、临时脚本和冒烟代码
|
|
43
|
+
if p.name.startswith(("_tmp", "_ci_env_probe", "_panel_smoke")):
|
|
40
44
|
continue
|
|
41
45
|
if p.suffix.lower() in EXCLUDE_SUFFIX or p.name in EXCLUDE_NAMES:
|
|
42
46
|
continue
|
package/scripts/panel_build.py
CHANGED
|
@@ -82,11 +82,24 @@ def build(src: Path = SRC, out: Path | None = OUT) -> bytes:
|
|
|
82
82
|
"""拼装产物;out=None 时只返回字节、不落盘(--check 用,检查不该改文件)。"""
|
|
83
83
|
shell = (src / "index.html").read_bytes()
|
|
84
84
|
meta = json.loads((src / "blocks.json").read_text(encoding="utf-8"))
|
|
85
|
+
consumed = 0
|
|
85
86
|
for i, blk in enumerate(meta):
|
|
86
87
|
token = f"<!--@@BLOCK:{i}@@-->".encode()
|
|
88
|
+
if token not in shell:
|
|
89
|
+
raise ValueError(f"LS-123 缺失占位符:index.html 中未找到 {token.decode()} 无法嵌入块 {blk['file']}")
|
|
87
90
|
body = (src / blk["file"]).read_bytes()
|
|
88
91
|
close = b"</style>" if blk["kind"] == "style" else b"</script>"
|
|
89
92
|
shell = shell.replace(token, blk["open"].encode() + body + close, 1)
|
|
93
|
+
consumed += 1
|
|
94
|
+
|
|
95
|
+
# LS-123(v5.62):面板构建校验所有占位符和块均被消费!
|
|
96
|
+
# 检查产物中是否仍残留未被替换的 <!--@@BLOCK:*@@--> 占位符
|
|
97
|
+
leftover = re.findall(rb"<!--@@BLOCK:\d+@@-->", shell)
|
|
98
|
+
if leftover:
|
|
99
|
+
raise ValueError(f"LS-123 构建产物中残留未消费的占位符:{[x.decode() for x in leftover]}")
|
|
100
|
+
if consumed != len(meta):
|
|
101
|
+
raise ValueError(f"LS-123 ���消费不全:定义了 {len(meta)} 个块,实际消费 {consumed} 个")
|
|
102
|
+
|
|
90
103
|
if out is not None:
|
|
91
104
|
out.parent.mkdir(parents=True, exist_ok=True)
|
|
92
105
|
out.write_bytes(shell)
|
package/scripts/_ci_env_probe.py
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""CI 诊断探针:只在 sync_engine 失败时被调用,把环境事实打出来。
|
|
3
|
-
|
|
4
|
-
为什么单独成文件:内联在 workflow 的 heredoc 会破坏 YAML 缩进(实测解析失败),
|
|
5
|
-
而这一段逻辑值得留档——它回答的是"为什么在 Windows runner 上失败、Linux 上不".
|
|
6
|
-
"""
|
|
7
|
-
import locale
|
|
8
|
-
import pathlib
|
|
9
|
-
import sys
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def main() -> int:
|
|
13
|
-
root = pathlib.Path(".").resolve()
|
|
14
|
-
print(f" cwd={root}")
|
|
15
|
-
print(f" python={sys.version.split()[0]}")
|
|
16
|
-
print(f" fsencoding={sys.getfilesystemencoding()}")
|
|
17
|
-
print(f" preferred={locale.getpreferredencoding(False)}")
|
|
18
|
-
|
|
19
|
-
print(" --- 关键路径 ---")
|
|
20
|
-
for rel in ("scripts",
|
|
21
|
-
"scripts/astrbot_plugin_lingshu",
|
|
22
|
-
"scripts/astrbot_plugin_lingshu/engine",
|
|
23
|
-
"docs/panel-api.md", "docs/commands.md",
|
|
24
|
-
"docs/mechanics.md", "docs/models.md", "docs/recovery.md",
|
|
25
|
-
"assets/panel.html"):
|
|
26
|
-
p = root / rel
|
|
27
|
-
kind = "-" if not p.exists() else ("dir" if p.is_dir() else f"{p.stat().st_size}B")
|
|
28
|
-
print(f" {rel}: {kind}")
|
|
29
|
-
|
|
30
|
-
# 换行抽样:CI 若在 Windows 上 checkout 成 CRLF,这里能直接看出来
|
|
31
|
-
print(" --- 换行抽样(前 5 个 .md/.py)---")
|
|
32
|
-
shown = 0
|
|
33
|
-
for p in sorted(root.rglob("*")):
|
|
34
|
-
if shown >= 5:
|
|
35
|
-
break
|
|
36
|
-
if p.is_file() and p.suffix.lower() in (".md", ".py") and "node_modules" not in str(p):
|
|
37
|
-
b = p.read_bytes()[:400]
|
|
38
|
-
crlf = b.count(b"\r\n")
|
|
39
|
-
lf = b.count(b"\n") - crlf
|
|
40
|
-
print(f" {p.relative_to(root)}: CRLF={crlf} LF={lf}")
|
|
41
|
-
shown += 1
|
|
42
|
-
|
|
43
|
-
# engine 里是否残留已从根目录删掉的文档
|
|
44
|
-
eng = root / "scripts" / "astrbot_plugin_lingshu" / "engine"
|
|
45
|
-
if eng.is_dir():
|
|
46
|
-
stale = [p.name for p in eng.rglob("*.md")
|
|
47
|
-
if not (root / p.relative_to(eng)).exists()]
|
|
48
|
-
print(f" --- engine 里根目录已无对应项的 .md: {stale[:8] or '无'}")
|
|
49
|
-
return 0
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def _ensure_utf8_stdout() -> None:
|
|
53
|
-
"""把 stdout/stderr 切到 UTF-8,避免 Windows 控制台(cp1252/cp936)编不了中文就崩。
|
|
54
|
-
|
|
55
|
-
CI 的 windows-latest stdout 是 cp1252:脚本一 print 中文就 UnicodeEncodeError
|
|
56
|
-
直接退出(实测 sync_engine.py / make_checksums.py 都因此挂过,Ubuntu 同期正常)。
|
|
57
|
-
这不是业务 bug,是"中文输出 + 非 UTF-8 控制台"的必然结果。
|
|
58
|
-
"""
|
|
59
|
-
for name in ("stdout", "stderr"):
|
|
60
|
-
stream = getattr(sys, name, None)
|
|
61
|
-
fn = getattr(stream, "reconfigure", None)
|
|
62
|
-
if callable(fn):
|
|
63
|
-
try:
|
|
64
|
-
fn(encoding="utf-8", errors="replace")
|
|
65
|
-
continue
|
|
66
|
-
except (OSError, ValueError, AttributeError):
|
|
67
|
-
pass
|
|
68
|
-
try:
|
|
69
|
-
import io
|
|
70
|
-
buf = getattr(stream, "buffer", None)
|
|
71
|
-
if buf is not None:
|
|
72
|
-
setattr(sys, name,
|
|
73
|
-
io.TextIOWrapper(buf, encoding="utf-8", errors="replace",
|
|
74
|
-
line_buffering=True))
|
|
75
|
-
except Exception: # noqa: BLE001
|
|
76
|
-
pass
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if __name__ == "__main__":
|
|
80
|
-
_ensure_utf8_stdout()
|
|
81
|
-
sys.exit(main())
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""验证脚本:后台起 panel_server(临时 HOME),查 /api/extensions/ollama/status,然后关掉。"""
|
|
3
|
-
import os, subprocess, sys, tempfile, time, urllib.request
|
|
4
|
-
|
|
5
|
-
tmp = os.path.join(tempfile.gettempdir(), "lingshu-panel-smoke")
|
|
6
|
-
os.makedirs(tmp, exist_ok=True)
|
|
7
|
-
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
8
|
-
flags = getattr(subprocess, "CREATE_NO_WINDOW", 0)
|
|
9
|
-
proc = subprocess.Popen([sys.executable, os.path.join(root, "scripts", "panel_server.py"),
|
|
10
|
-
"--port", "8791", "--no-browser", "--home", tmp],
|
|
11
|
-
cwd=root, creationflags=flags,
|
|
12
|
-
stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
|
|
13
|
-
time.sleep(6)
|
|
14
|
-
try:
|
|
15
|
-
with urllib.request.urlopen("http://127.0.0.1:8791/api/extensions/ollama/status", timeout=10) as r:
|
|
16
|
-
print("STATUS:", r.read().decode("utf-8"))
|
|
17
|
-
except Exception as exc:
|
|
18
|
-
print("ERR:", exc)
|
|
19
|
-
finally:
|
|
20
|
-
proc.terminate()
|
|
21
|
-
try:
|
|
22
|
-
_, err = proc.communicate(timeout=10)
|
|
23
|
-
if err:
|
|
24
|
-
print("STDERR:", err.decode("utf-8", "replace")[-800:])
|
|
25
|
-
except Exception:
|
|
26
|
-
proc.kill()
|
|
27
|
-
print("PANEL SMOKE DONE")
|
|
@@ -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)
|