lingshu-skill 5.33.0 → 5.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4281 -4227
- package/README.md +1584 -1577
- package/SKILL-lite.md +59 -59
- package/SKILL-tiny.md +38 -38
- package/SKILL.md +356 -331
- package/assets/panel.html +6753 -5698
- package/cordis-plugin/lingshu-cron/plugin.js +1455 -1417
- package/cordis-plugin/lingshu-startup/context-fold.js +170 -0
- package/cordis-plugin/lingshu-startup/context-pressure.js +16 -0
- package/cordis-plugin/lingshu-startup/context-snapshot.js +176 -0
- package/cordis-plugin/lingshu-startup/plugin.js +499 -467
- package/docs/audit_notes//345/276/205/345/212/236-20261201-/351/235/242/346/235/277/344/270/245/346/237/245/344/270/216/345/256/241/350/256/241.md +162 -0
- package/docs/audit_notes//345/276/205/345/212/236-20261202-/351/235/242/346/235/277/344/272/244/344/272/222/344/270/216/346/225/260/346/215/256/345/245/221/347/272/246/345/256/241/350/256/241.md +92 -0
- package/docs/audit_notes//345/276/205/345/212/236/346/250/241/346/235/277.md +140 -0
- package/docs/commands.md +278 -247
- package/docs/mechanics.md +610 -610
- package/docs//345/276/205/345/212/236-20261201-/351/235/242/346/235/277/344/270/245/346/237/245/344/270/216/345/256/241/350/256/241.md +162 -0
- package/docs//345/276/205/345/212/236-20261202-/351/235/242/346/235/277/344/272/244/344/272/222/344/270/216/346/225/260/346/215/256/345/245/221/347/272/246/345/256/241/350/256/241.md +92 -0
- package/package.json +52 -52
- package/scripts/_scratch/_tmp_backup_race.py +70 -0
- package/scripts/_scratch/_tmp_cleanup_move.py +34 -0
- package/scripts/_scratch/_tmp_count_kinds.py +25 -0
- package/scripts/_scratch/_tmp_diag_paths.py +48 -0
- package/scripts/_scratch/_tmp_facts.py +63 -0
- package/scripts/_scratch/_tmp_find_copies.py +31 -0
- package/scripts/_scratch/_tmp_find_pin.py +29 -0
- package/scripts/_scratch/_tmp_fix_pin.py +36 -0
- package/scripts/_scratch/_tmp_fold_fixture.py +55 -0
- package/scripts/_scratch/_tmp_fold_test.mjs +81 -0
- package/scripts/_scratch/_tmp_inject_secs.py +30 -0
- package/scripts/_scratch/_tmp_kb_balance.py +159 -0
- package/scripts/_scratch/_tmp_lines.py +15 -0
- package/scripts/_scratch/_tmp_market_probe.py +13 -0
- package/scripts/_scratch/_tmp_move_partial.py +16 -0
- package/scripts/_scratch/_tmp_patch_b3.py +41 -0
- package/scripts/_scratch/_tmp_patch_b5.py +62 -0
- package/scripts/_scratch/_tmp_patch_crash_excl.py +24 -0
- package/scripts/_scratch/_tmp_patch_handoff.py +21 -0
- package/scripts/_scratch/_tmp_patch_ps1.py +25 -0
- package/scripts/_scratch/_tmp_patch_stat.py +27 -0
- package/scripts/_scratch/_tmp_patch_todo.py +25 -0
- package/scripts/_scratch/_tmp_patch_todo2.py +64 -0
- package/scripts/_scratch/_tmp_probe_session.py +51 -0
- package/scripts/_scratch/_tmp_style_probe.py +40 -0
- package/scripts/_scratch/_tmp_write_note.py +139 -0
- package/scripts/_scratch/_/346/235/245/346/272/220/350/256/260/345/275/225.txt +1 -0
- package/scripts/_scratch/asar_compaction/dsh-compaction-basic__lib__index.js +1044 -0
- package/scripts/_scratch/asar_compaction/dsh-compaction-tool-result-pruner__lib__index.js +194 -0
- package/scripts/_scratch/asar_compaction/dsh-compaction__lib__index.js +175 -0
- package/scripts/_scratch/asar_compaction/dsh-compaction__lib__types__tool-pairing.js +97 -0
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__image-offload.js +47 -0
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__index.js +40 -0
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction-image-offload__lib__types__project-message.js +37 -0
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__brand.js +9 -0
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__checkpoint.js +36 -0
- package/scripts/_scratch/asar_compaction/dsh__node_modules__@deepseek-ai__dsh-compaction__lib__types__types.js +10 -0
- package/scripts/_scratch/commit_msg_occ.txt +16 -0
- package/scripts/_scratch/commit_msg_struct.txt +16 -0
- package/scripts/_scratch/v5.34_changelog.txt +36 -0
- package/scripts/_sync_trae_cn.py +102 -34
- package/scripts/_tmp_add_s10.py +54 -0
- package/scripts/_tmp_add_s11.py +61 -0
- package/scripts/_tmp_add_s12.py +66 -0
- package/scripts/_tmp_add_s13.py +69 -0
- package/scripts/_tmp_add_s14.py +80 -0
- package/scripts/_tmp_add_s9.py +68 -0
- package/scripts/_tmp_cache_load.py +82 -0
- package/scripts/_tmp_clean_market.py +40 -0
- package/scripts/_tmp_clean_pruned.py +81 -0
- package/scripts/_tmp_cleanup_docs.py +39 -0
- package/scripts/_tmp_cmp_ranker.py +17 -0
- package/scripts/_tmp_dolater_note.py +35 -0
- package/scripts/_tmp_dust_why.py +27 -0
- package/scripts/_tmp_explicit_import.py +40 -0
- package/scripts/_tmp_extract_compaction.py +35 -0
- package/scripts/_tmp_extract_compaction2.py +63 -0
- package/scripts/_tmp_extract_compaction3.py +51 -0
- package/scripts/_tmp_extract_compaction4.py +54 -0
- package/scripts/_tmp_finalize_s14.py +39 -0
- package/scripts/_tmp_find_compaction.py +43 -0
- package/scripts/_tmp_fix_b4.py +22 -0
- package/scripts/_tmp_fix_cli76.py +26 -0
- package/scripts/_tmp_fix_docs.py +38 -0
- package/scripts/_tmp_fix_docs_b.py +46 -0
- package/scripts/_tmp_fix_docs_b2.py +22 -0
- package/scripts/_tmp_fix_i3.py +23 -0
- package/scripts/_tmp_fix_s10.py +83 -0
- package/scripts/_tmp_fix_s11.py +14 -0
- package/scripts/_tmp_fix_s9_status.py +19 -0
- package/scripts/_tmp_fix_shadow_sim.py +37 -0
- package/scripts/_tmp_fix_traits_value.py +41 -0
- package/scripts/_tmp_import_idem.py +106 -0
- package/scripts/_tmp_log_ack.py +45 -0
- package/scripts/_tmp_mark_batch.py +28 -0
- package/scripts/_tmp_mark_batch2.py +32 -0
- package/scripts/_tmp_mark_dolater.py +26 -0
- package/scripts/_tmp_mark_dolater2.py +31 -0
- package/scripts/_tmp_move_self.py +16 -0
- package/scripts/_tmp_occ_cli.py +22 -0
- package/scripts/_tmp_occ_link.py +108 -0
- package/scripts/_tmp_optimize_recall.py +54 -0
- package/scripts/_tmp_panel_audit.py +26 -0
- package/scripts/_tmp_patch_batch3.py +65 -0
- package/scripts/_tmp_patch_rrf.py +46 -0
- package/scripts/_tmp_patch_s2s3.py +80 -0
- package/scripts/_tmp_patch_s4.py +39 -0
- package/scripts/_tmp_patch_s7.py +43 -0
- package/scripts/_tmp_patch_s8.py +91 -0
- package/scripts/_tmp_patch_skill.py +17 -0
- package/scripts/_tmp_release_guard.py +57 -0
- package/scripts/_tmp_rerank_breaker.py +62 -0
- package/scripts/_tmp_s16.py +41 -0
- package/scripts/_tmp_scan_asar.py +41 -0
- package/scripts/_tmp_scan_asar2.py +37 -0
- package/scripts/_tmp_struct_docs.py +49 -0
- package/scripts/_tmp_sum_fallback.py +42 -0
- package/scripts/_tmp_sweep.py +81 -0
- package/scripts/_tmp_sync_check.py +69 -0
- package/scripts/_tmp_sync_tail.py +39 -0
- package/scripts/_tmp_todo_clean.py +67 -0
- package/scripts/_tmp_verify_copy.py +17 -0
- package/scripts/_tmp_wire_extras.py +93 -0
- package/scripts/_tmp_wire_hsum.py +34 -0
- package/scripts/_tmp_wire_occ_b5.py +40 -0
- package/scripts/_tmp_wire_ranker.py +13 -0
- package/scripts/_tmp_wire_shadow_timeline.py +45 -0
- package/scripts/anchor_retention.py +68 -0
- package/scripts/app_context.py +1160 -0
- package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +38 -22
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +4281 -4227
- package/scripts/astrbot_plugin_lingshu/engine/README.md +1584 -1577
- package/scripts/astrbot_plugin_lingshu/engine/SKILL-lite.md +59 -59
- package/scripts/astrbot_plugin_lingshu/engine/SKILL-tiny.md +38 -38
- package/scripts/astrbot_plugin_lingshu/engine/SKILL.md +356 -331
- package/scripts/astrbot_plugin_lingshu/engine/assets/panel.html +6753 -5698
- package/scripts/astrbot_plugin_lingshu/engine/docs/commands.md +278 -247
- package/scripts/astrbot_plugin_lingshu/engine/docs/mechanics.md +610 -610
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_sync_trae_cn.py +102 -34
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s10.py +54 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s11.py +61 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s12.py +66 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s13.py +69 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s14.py +80 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_add_s9.py +68 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cache_load.py +82 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_clean_market.py +40 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_clean_pruned.py +81 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cleanup_docs.py +39 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_cmp_ranker.py +17 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_dolater_note.py +35 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_dust_why.py +27 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_explicit_import.py +40 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction.py +35 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction2.py +63 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction3.py +51 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_extract_compaction4.py +54 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_finalize_s14.py +39 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_find_compaction.py +43 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_b4.py +22 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_cli76.py +26 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs.py +38 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs_b.py +46 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_docs_b2.py +22 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_i3.py +23 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s10.py +83 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s11.py +14 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_s9_status.py +19 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_shadow_sim.py +37 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_fix_traits_value.py +41 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_import_idem.py +106 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_log_ack.py +45 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_batch.py +28 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_batch2.py +32 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_dolater.py +26 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_mark_dolater2.py +31 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_move_self.py +16 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_occ_cli.py +22 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_occ_link.py +108 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_optimize_recall.py +54 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_panel_audit.py +26 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_batch3.py +65 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_rrf.py +46 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s2s3.py +80 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s4.py +39 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s7.py +43 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_s8.py +91 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_patch_skill.py +17 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_release_guard.py +57 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_rerank_breaker.py +62 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_s16.py +41 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_scan_asar.py +41 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_scan_asar2.py +37 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_struct_docs.py +49 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sum_fallback.py +42 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sweep.py +81 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sync_check.py +69 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_sync_tail.py +39 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_todo_clean.py +67 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_verify_copy.py +17 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_extras.py +93 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_hsum.py +34 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_occ_b5.py +40 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_ranker.py +13 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/_tmp_wire_shadow_timeline.py +45 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/anchor_retention.py +68 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/app_context.py +1160 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/bigfive.py +90 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/brain.py +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/scripts/check_docs.py +191 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/cli.py +921 -86
- package/scripts/astrbot_plugin_lingshu/engine/scripts/core.py +2468 -2406
- package/scripts/astrbot_plugin_lingshu/engine/scripts/coverage_report.py +5 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/delivery.py +112 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/dream.py +41 -3
- package/scripts/astrbot_plugin_lingshu/engine/scripts/emotion.py +202 -23
- package/scripts/astrbot_plugin_lingshu/engine/scripts/gap_memory.py +186 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/growth.py +72 -8
- package/scripts/astrbot_plugin_lingshu/engine/scripts/hsum.py +206 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/mem_score.py +92 -7
- package/scripts/astrbot_plugin_lingshu/engine/scripts/memory.py +530 -60
- package/scripts/astrbot_plugin_lingshu/engine/scripts/memory_extras.py +200 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/occ.py +190 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_server.py +232 -142
- package/scripts/astrbot_plugin_lingshu/engine/scripts/persona.py +2498 -2349
- package/scripts/astrbot_plugin_lingshu/engine/scripts/prepublish_tests.py +90 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/release.py +326 -287
- package/scripts/astrbot_plugin_lingshu/engine/scripts/rss_ingest.py +181 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/session_import.py +832 -764
- package/scripts/astrbot_plugin_lingshu/engine/scripts/shadow_memory.py +173 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/style_check.py +220 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/summarizer.py +343 -252
- package/scripts/astrbot_plugin_lingshu/engine/scripts/timeline.py +118 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/watchdog.py +110 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/web_research.py +125 -0
- package/scripts/bigfive.py +90 -0
- package/scripts/brain.py +1 -1
- package/scripts/check_docs.py +191 -0
- package/scripts/cli.py +921 -86
- package/scripts/core.py +2468 -2406
- package/scripts/coverage_report.py +5 -0
- package/scripts/delivery.py +112 -0
- package/scripts/dream.py +41 -3
- package/scripts/emotion.py +202 -23
- package/scripts/gap_memory.py +186 -0
- package/scripts/growth.py +72 -8
- package/scripts/hsum.py +206 -0
- package/scripts/mem_score.py +92 -7
- package/scripts/memory.py +530 -60
- package/scripts/memory_extras.py +200 -0
- package/scripts/occ.py +190 -0
- package/scripts/panel_server.py +232 -142
- package/scripts/persona.py +2498 -2349
- package/scripts/prepublish_tests.py +90 -0
- package/scripts/release.py +326 -287
- package/scripts/rss_ingest.py +181 -0
- package/scripts/run_tests.py +13 -0
- package/scripts/session_import.py +832 -764
- package/scripts/shadow_memory.py +173 -0
- package/scripts/style_check.py +220 -0
- package/scripts/summarizer.py +343 -252
- package/scripts/timeline.py +118 -0
- package/scripts/update_dsh_copy.ps1 +110 -107
- package/scripts/watchdog.py +110 -0
- package/scripts/web_research.py +125 -0
- package/docs//344/272/244/346/216/245/347/254/224/350/256/260-20261128.md +0 -128
- package/docs//345/256/241/346/240/270/346/224/271/350/277/233/345/276/205/345/212/236.md +0 -408
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""Big Five 数值化(do-later「M」,§14.1 决定版)。
|
|
4
|
+
|
|
5
|
+
问题:traits 是自由命名(好奇/温和/理智…),**改名或加轴,历史就不可比**;
|
|
6
|
+
drift 散度需要固定维度。
|
|
7
|
+
|
|
8
|
+
做法:固定 5 维,把现有 traits 按关键词归并(未列出的**不计分**,避免瞎归):
|
|
9
|
+
开放性 ← 好奇/求知/探索/创造/审美
|
|
10
|
+
尽责性 ← 严谨/理智/秩序/尽责/条理
|
|
11
|
+
外向性 ← 表达/社交/热烈/主动
|
|
12
|
+
宜人性 ← 温和/共情/包容/体贴
|
|
13
|
+
神经质 ← 敏感/焦虑/波动/脆弱(**低=情绪稳定**)
|
|
14
|
+
|
|
15
|
+
用法:
|
|
16
|
+
brain.py bigfive # 看当前 5 维
|
|
17
|
+
brain.py bigfive --save # 写进 persona.json 的 big_five(供 drift 比较)
|
|
18
|
+
"""
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import brain
|
|
22
|
+
import core
|
|
23
|
+
from core import _num
|
|
24
|
+
|
|
25
|
+
DIMENSIONS = ("开放性", "尽责性", "外向性", "宜人性", "神经质")
|
|
26
|
+
|
|
27
|
+
MAP = {
|
|
28
|
+
"开放性": ("好奇", "求知", "探索", "创造", "审美", "开放", "想象"),
|
|
29
|
+
"尽责性": ("严谨", "理智", "秩序", "尽责", "条理", "自律", "克制"),
|
|
30
|
+
"外向性": ("表达", "社交", "热烈", "主动", "外向", "健谈", "热情"),
|
|
31
|
+
"宜人性": ("温和", "共情", "包容", "体贴", "善意", "耐心", "友好"),
|
|
32
|
+
"神经质": ("敏感", "焦虑", "波动", "脆弱", "易感", "紧张", "情绪化"),
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def compute(persona: dict | None = None) -> dict:
|
|
37
|
+
"""把自由命名的 traits 归并成 5 维(0~100)。未命中任何维度的 trait 不计分。"""
|
|
38
|
+
p = persona if isinstance(persona, dict) else (brain.load_persona() or {})
|
|
39
|
+
traits = p.get("traits") or {}
|
|
40
|
+
acc: dict = {d: [] for d in DIMENSIONS}
|
|
41
|
+
unmapped = []
|
|
42
|
+
for name, val in traits.items():
|
|
43
|
+
key = str(name)
|
|
44
|
+
# traits 是嵌套结构 {value, why, evidence},不是裸数字——直接 _num(dict) 会得 0。
|
|
45
|
+
_raw = val.get("value") if isinstance(val, dict) else val
|
|
46
|
+
v = _num(_raw, 0.0)
|
|
47
|
+
hit = None
|
|
48
|
+
for dim, words in MAP.items():
|
|
49
|
+
if any(w in key for w in words):
|
|
50
|
+
hit = dim
|
|
51
|
+
break
|
|
52
|
+
if hit:
|
|
53
|
+
acc[hit].append(v)
|
|
54
|
+
else:
|
|
55
|
+
unmapped.append(key)
|
|
56
|
+
out = {d: (round(sum(vs) / len(vs), 1) if vs else None) for d, vs in acc.items()}
|
|
57
|
+
out["_unmapped"] = unmapped
|
|
58
|
+
out["_n"] = sum(len(v) for v in acc.values())
|
|
59
|
+
return out
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def save(values: dict | None = None) -> dict:
|
|
63
|
+
vals = values or compute()
|
|
64
|
+
clean = {k: v for k, v in vals.items() if k in DIMENSIONS}
|
|
65
|
+
with core._locked(core.HOME / "persona.json"):
|
|
66
|
+
p = brain.load_persona() or {}
|
|
67
|
+
p["big_five"] = clean
|
|
68
|
+
brain.save_persona(p)
|
|
69
|
+
return clean
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def render(v: dict) -> list:
|
|
73
|
+
lines = []
|
|
74
|
+
for d in DIMENSIONS:
|
|
75
|
+
x = v.get(d)
|
|
76
|
+
lines.append(f" {d:<4} {'—' if x is None else str(x):>5}")
|
|
77
|
+
if v.get("_unmapped"):
|
|
78
|
+
lines.append(f" (未映射的 traits:{'、'.join(v['_unmapped'][:8])}——按决定不计分)")
|
|
79
|
+
return lines
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def run(args) -> int:
|
|
83
|
+
v = compute()
|
|
84
|
+
print("Big Five(由 traits 归并,未映射不计分):")
|
|
85
|
+
for line in render(v):
|
|
86
|
+
print(line)
|
|
87
|
+
if getattr(args, "save", False):
|
|
88
|
+
saved = save(v)
|
|
89
|
+
print("已写入 persona.json 的 big_five:", saved)
|
|
90
|
+
return 0
|
|
@@ -27,7 +27,7 @@ _MODULES = (core, memory, emotion, persona, dream, cli)
|
|
|
27
27
|
# 登记进 _SYNC_TARGETS,让 _sync_state() 把状态同步过去(注意只登记进同步表,
|
|
28
28
|
# 不进 _MODULES:它们的命名空间不该参与双向合并)。
|
|
29
29
|
_EXTRA_SYNC = []
|
|
30
|
-
for _name in ("mem_lesson", "mem_score", "mem_topic", "mem_dialogue"
|
|
30
|
+
for _name in ("mem_lesson", "mem_score", "mem_topic", "mem_dialogue"):
|
|
31
31
|
_m = sys.modules.get(_name)
|
|
32
32
|
if _m is not None:
|
|
33
33
|
_EXTRA_SYNC.append(_m)
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""文档数字自检(§3 C)。
|
|
4
|
+
|
|
5
|
+
为什么要有它:文档里的"45 个情绪名 / 13 项体检 / 15 个页签 / 29 项设置 / 75 个命令"
|
|
6
|
+
全是**手写**的,改代码时没人回去同步,于是反复对不上(实测一次就抓出 5 处)。
|
|
7
|
+
这里从代码**现算**真值,再和文档里抓到的数字比对,不一致就非零退出——接进 CI
|
|
8
|
+
就能防复发(与 check_version.py 同层)。
|
|
9
|
+
|
|
10
|
+
用法:
|
|
11
|
+
python scripts/check_docs.py # 报告差异(不一致 exit 1)
|
|
12
|
+
python scripts/check_docs.py --json
|
|
13
|
+
"""
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import re
|
|
18
|
+
import subprocess
|
|
19
|
+
import sys
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
|
|
22
|
+
ROOT = Path(__file__).resolve().parent.parent
|
|
23
|
+
SCRIPTS = ROOT / "scripts"
|
|
24
|
+
sys.path.insert(0, str(SCRIPTS))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _truth() -> dict:
|
|
28
|
+
"""从代码现算真实数字。任何一项失败就留 None(不猜)。"""
|
|
29
|
+
t: dict = {}
|
|
30
|
+
|
|
31
|
+
# 情绪:名数 + 分组
|
|
32
|
+
try:
|
|
33
|
+
import emotion
|
|
34
|
+
emos = getattr(emotion, "EMOTIONS", {}) or {}
|
|
35
|
+
t["emotions"] = len(emos)
|
|
36
|
+
grp = getattr(emotion, "EMOTION_GROUPS", None)
|
|
37
|
+
if isinstance(grp, dict) and grp:
|
|
38
|
+
t["emotion_groups"] = len(grp)
|
|
39
|
+
except Exception:
|
|
40
|
+
t["emotions"] = None
|
|
41
|
+
|
|
42
|
+
# doctor 项数:直接跑 --json 数(最不容易和实现漂移)
|
|
43
|
+
try:
|
|
44
|
+
r = subprocess.run([sys.executable, str(SCRIPTS / "brain.py"), "doctor", "--json"],
|
|
45
|
+
cwd=ROOT, capture_output=True, text=True,
|
|
46
|
+
encoding="utf-8", errors="replace", timeout=300)
|
|
47
|
+
txt = r.stdout
|
|
48
|
+
i = txt.find("{")
|
|
49
|
+
t["doctor"] = len(json.loads(txt[i:]).get("checks") or [])
|
|
50
|
+
except Exception:
|
|
51
|
+
t["doctor"] = None
|
|
52
|
+
|
|
53
|
+
# 面板页签:从产物里数 data-tab 的唯一名字
|
|
54
|
+
try:
|
|
55
|
+
html = (ROOT / "assets" / "panel.html").read_text(encoding="utf-8", errors="replace")
|
|
56
|
+
names = re.findall(r'data-tab="([^"]+)"', html)
|
|
57
|
+
t["panel_tabs"] = len(set(names))
|
|
58
|
+
except Exception:
|
|
59
|
+
t["panel_tabs"] = None
|
|
60
|
+
|
|
61
|
+
# 设置项/组
|
|
62
|
+
try:
|
|
63
|
+
import panel_settings
|
|
64
|
+
schema = getattr(panel_settings, "CONFIG_SCHEMA", None)
|
|
65
|
+
if isinstance(schema, dict):
|
|
66
|
+
t["settings_groups"] = len(schema)
|
|
67
|
+
n = 0
|
|
68
|
+
for v in schema.values():
|
|
69
|
+
if isinstance(v, dict):
|
|
70
|
+
items = v.get("items") or v.get("fields") or []
|
|
71
|
+
n += len(items)
|
|
72
|
+
if n:
|
|
73
|
+
t["settings_items"] = n
|
|
74
|
+
elif isinstance(schema, list):
|
|
75
|
+
t["settings_items"] = len(schema)
|
|
76
|
+
groups = {(x or {}).get("group") for x in schema if isinstance(x, dict)}
|
|
77
|
+
groups.discard(None)
|
|
78
|
+
if groups:
|
|
79
|
+
t["settings_groups"] = len(groups)
|
|
80
|
+
except Exception:
|
|
81
|
+
pass
|
|
82
|
+
|
|
83
|
+
# CLI 命令数:--help 的 choices
|
|
84
|
+
try:
|
|
85
|
+
r = subprocess.run([sys.executable, str(SCRIPTS / "brain.py"), "--help"],
|
|
86
|
+
cwd=ROOT, capture_output=True, text=True,
|
|
87
|
+
encoding="utf-8", errors="replace", timeout=120)
|
|
88
|
+
m = re.search(r"\{([a-z0-9,\-_]+)\}", r.stdout)
|
|
89
|
+
if m:
|
|
90
|
+
t["cli_commands"] = len(m.group(1).split(","))
|
|
91
|
+
except Exception:
|
|
92
|
+
t["cli_commands"] = None
|
|
93
|
+
return t
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# 文档里的"数字断言": (文档, 正则, 真值键, 说明)
|
|
97
|
+
CLAIMS = [
|
|
98
|
+
("SKILL.md", r"(\d+)\s*个情绪名", "emotions", "情绪名数量"),
|
|
99
|
+
("SKILL.md", r"doctor\s*\[--json\][^\n]*?(\d+)\s*项体检", "doctor", "doctor 体检项数"),
|
|
100
|
+
("SKILL.md", r"(\d+)\s*项体检", "doctor", "doctor 体检项数"),
|
|
101
|
+
("README.md", r"(\d+)\s*项体检", "doctor", "doctor 体检项数"),
|
|
102
|
+
("README.md", r"(\d+)\s*个页签", "panel_tabs", "面板页签数"),
|
|
103
|
+
("README.md", r"设置页\s*(\d+)\s*项", "settings_items", "设置项数"),
|
|
104
|
+
("README.md", r"(\d+)\s*个 CLI 命令", "cli_commands", "CLI 命令数"),
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def main(argv=None) -> int:
|
|
109
|
+
argv = list(sys.argv[1:] if argv is None else argv)
|
|
110
|
+
truth = _truth()
|
|
111
|
+
mismatches = []
|
|
112
|
+
for rel, pat, key, label in CLAIMS:
|
|
113
|
+
p = ROOT / rel
|
|
114
|
+
if not p.is_file():
|
|
115
|
+
continue
|
|
116
|
+
text = p.read_text(encoding="utf-8", errors="replace")
|
|
117
|
+
for m in re.finditer(pat, text):
|
|
118
|
+
claimed = int(m.group(1))
|
|
119
|
+
real = truth.get(key)
|
|
120
|
+
if real is None:
|
|
121
|
+
continue
|
|
122
|
+
if claimed != real:
|
|
123
|
+
line = text[:m.start()].count("\n") + 1
|
|
124
|
+
mismatches.append({"file": rel, "line": line, "label": label,
|
|
125
|
+
"claimed": claimed, "real": real,
|
|
126
|
+
"snippet": text[max(0, m.start() - 30):m.end() + 20].replace("\n", " ")})
|
|
127
|
+
|
|
128
|
+
# 额外:命令名必须真实存在(照做会报错的那类)
|
|
129
|
+
bad_cmds = []
|
|
130
|
+
try:
|
|
131
|
+
r = subprocess.run([sys.executable, str(SCRIPTS / "brain.py"), "--help"],
|
|
132
|
+
cwd=ROOT, capture_output=True, text=True,
|
|
133
|
+
encoding="utf-8", errors="replace", timeout=120)
|
|
134
|
+
m = re.search(r"\{([a-z0-9,\-_]+)\}", r.stdout)
|
|
135
|
+
valid = set(m.group(1).split(",")) if m else set()
|
|
136
|
+
for rel in ("README.md", "SKILL.md"):
|
|
137
|
+
p = ROOT / rel
|
|
138
|
+
if not p.is_file():
|
|
139
|
+
continue
|
|
140
|
+
text = p.read_text(encoding="utf-8", errors="replace")
|
|
141
|
+
for cm in re.finditer(r"brain\.py\s+([a-z][a-z0-9\-]+)", text):
|
|
142
|
+
name = cm.group(1)
|
|
143
|
+
if not valid or name in valid:
|
|
144
|
+
continue
|
|
145
|
+
# 有些命令(如 `skill`)是隐藏的:不进 --help 的 choices 但确实可用。
|
|
146
|
+
# 所以不靠列表下结论,真跑一次 --help 验证(只对少数候选做,代价可忽略)。
|
|
147
|
+
try:
|
|
148
|
+
rr = subprocess.run([sys.executable, str(SCRIPTS / "brain.py"), name, "--help"],
|
|
149
|
+
cwd=ROOT, capture_output=True, text=True,
|
|
150
|
+
encoding="utf-8", errors="replace", timeout=60)
|
|
151
|
+
if rr.returncode == 0 or "invalid choice" not in (rr.stderr or ""):
|
|
152
|
+
continue
|
|
153
|
+
except Exception:
|
|
154
|
+
pass
|
|
155
|
+
line = text[:cm.start()].count("\n") + 1
|
|
156
|
+
bad_cmds.append({"file": rel, "line": line, "command": name})
|
|
157
|
+
except Exception:
|
|
158
|
+
pass
|
|
159
|
+
|
|
160
|
+
if "--json" in argv:
|
|
161
|
+
print(json.dumps({"truth": truth, "mismatches": mismatches,
|
|
162
|
+
"bad_commands": bad_cmds}, ensure_ascii=False, indent=2))
|
|
163
|
+
else:
|
|
164
|
+
print("[check_docs] 代码现算的真值:")
|
|
165
|
+
for k, v in truth.items():
|
|
166
|
+
print(f" {k:<16} = {v}")
|
|
167
|
+
if not mismatches and not bad_cmds:
|
|
168
|
+
print("\n[check_docs] 文档数字与命令名全部对得上 ✔")
|
|
169
|
+
for m in mismatches:
|
|
170
|
+
print(f"\n[不一致] {m['file']}:{m['line']} {m['label']}:文档写 {m['claimed']},实际 {m['real']}")
|
|
171
|
+
print(f" …{m['snippet']}…")
|
|
172
|
+
seen = set()
|
|
173
|
+
for b in bad_cmds:
|
|
174
|
+
key = (b["file"], b["command"])
|
|
175
|
+
if key in seen:
|
|
176
|
+
continue
|
|
177
|
+
seen.add(key)
|
|
178
|
+
print(f"\n[命令不存在] {b['file']}:{b['line']} `brain.py {b['command']}`")
|
|
179
|
+
return 1 if (mismatches or bad_cmds) else 0
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
if __name__ == "__main__":
|
|
183
|
+
for _n in ("stdout", "stderr"):
|
|
184
|
+
_s = getattr(sys, _n, None)
|
|
185
|
+
_f = getattr(_s, "reconfigure", None)
|
|
186
|
+
if callable(_f):
|
|
187
|
+
try:
|
|
188
|
+
_f(encoding="utf-8", errors="replace")
|
|
189
|
+
except (OSError, ValueError, AttributeError):
|
|
190
|
+
pass
|
|
191
|
+
sys.exit(main())
|