lingshu-skill 5.45.0 → 5.46.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 +13 -0
- package/README.md +1 -1
- package/SKILL-lite.md +1 -1
- package/SKILL-tiny.md +1 -1
- package/SKILL.md +1 -1
- package/package.json +1 -1
- package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +8 -8
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +13 -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/emotion.py +1669 -1660
- package/scripts/astrbot_plugin_lingshu/engine/scripts/persona.py +13 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/startup_fast.py +22 -2
- package/scripts/emotion.py +1669 -1660
- package/scripts/persona.py +13 -0
- package/scripts/startup_fast.py +22 -2
package/scripts/persona.py
CHANGED
|
@@ -276,6 +276,9 @@ def compile_persona() -> dict:
|
|
|
276
276
|
level="error")
|
|
277
277
|
return _slurp_json(HOME / "persona.json") # 返回盘上完好人格
|
|
278
278
|
atomic_json(HOME / "persona.json", p)
|
|
279
|
+
# SPEED-1 缓存同步失效:compile_persona 直写绕过了 save_persona 的失效点
|
|
280
|
+
global _lp_cache, _lp_cache_mtime, _lp_cache_time
|
|
281
|
+
_lp_cache = None
|
|
279
282
|
return p
|
|
280
283
|
|
|
281
284
|
|
|
@@ -442,6 +445,16 @@ def save_persona_snapshot(p_before: dict, action: str = "update",
|
|
|
442
445
|
with _locked(path):
|
|
443
446
|
with open(path, "a", encoding="utf-8", newline="\n") as f:
|
|
444
447
|
f.write(json.dumps(row, ensure_ascii=False) + "\n")
|
|
448
|
+
# 快照滚修(SPEED 隐藏项修复):每条含完整人格,60+ 条已 216KB;
|
|
449
|
+
# 保留最近 60 条(回滚窗口足够),旧的截掉——文件不再无限膨胀。
|
|
450
|
+
try:
|
|
451
|
+
with open(path, "r", encoding="utf-8") as rf:
|
|
452
|
+
_lines = [ln for ln in rf if ln.strip()]
|
|
453
|
+
if len(_lines) > 60:
|
|
454
|
+
with open(path, "w", encoding="utf-8", newline="\n") as wf:
|
|
455
|
+
wf.writelines(_lines[-60:])
|
|
456
|
+
except OSError:
|
|
457
|
+
pass # 修剪失败不影响主流程
|
|
445
458
|
return version
|
|
446
459
|
except Exception as exc:
|
|
447
460
|
log_event("persona", f"保存 persona 快照失败:{exc}", level="warn")
|
package/scripts/startup_fast.py
CHANGED
|
@@ -15,14 +15,21 @@ import brain(~151ms)+ 冷读盘,实测省 ~150-200ms/次。
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
import json
|
|
18
|
+
import urllib.parse
|
|
18
19
|
import urllib.request
|
|
19
20
|
|
|
20
21
|
_FAST_TIMEOUT = 1.2 # 秒
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
def try_serve_startup(query: str = "", budget_tokens: int | None = None,
|
|
24
|
-
port: int =
|
|
25
|
-
"""尝试从常驻面板拿注入包。成功返回注入文本,任何失败返回 None。
|
|
25
|
+
port: int | None = None) -> str | None:
|
|
26
|
+
"""尝试从常驻面板拿注入包。成功返回注入文本,任何失败返回 None。
|
|
27
|
+
|
|
28
|
+
port 缺省时按序探测:1) 面板配置里记录的实际端口(panel_server 启动时写
|
|
29
|
+
config.json 的 panel_port);2) 默认 18997。探测失败静默回退本进程。
|
|
30
|
+
"""
|
|
31
|
+
if port is None:
|
|
32
|
+
port = _probe_port()
|
|
26
33
|
try:
|
|
27
34
|
qs = f"q={urllib.parse.quote(query or '')}"
|
|
28
35
|
if budget_tokens:
|
|
@@ -36,3 +43,16 @@ def try_serve_startup(query: str = "", budget_tokens: int | None = None,
|
|
|
36
43
|
return packet if isinstance(packet, str) and packet else None
|
|
37
44
|
except Exception:
|
|
38
45
|
return None # 静默回退:面板没开/超时/任何错都不影响主链路
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _probe_port() -> int:
|
|
49
|
+
"""从数据目录 config.json 读面板实际端口;没有就用默认 18997。"""
|
|
50
|
+
try:
|
|
51
|
+
from core import HOME, load_config
|
|
52
|
+
cfg = load_config()
|
|
53
|
+
p = int(cfg.get("panel_port") or 0)
|
|
54
|
+
if p:
|
|
55
|
+
return p
|
|
56
|
+
except Exception:
|
|
57
|
+
pass
|
|
58
|
+
return 18997
|