lingshu-skill 5.53.0 → 5.55.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 +55 -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 +5 -1
- package/package.json +1 -1
- package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +10 -10
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +55 -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 +5 -1
- package/scripts/astrbot_plugin_lingshu/engine/scripts/cli.py +175 -42
- package/scripts/astrbot_plugin_lingshu/engine/scripts/emotion.py +13 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/memory.py +6587 -6583
- package/scripts/astrbot_plugin_lingshu/engine/scripts/persona.py +25 -0
- package/scripts/cli.py +175 -42
- package/scripts/emotion.py +13 -0
- package/scripts/memory.py +6587 -6583
- package/scripts/persona.py +25 -0
package/scripts/persona.py
CHANGED
|
@@ -333,6 +333,24 @@ def load_persona() -> dict:
|
|
|
333
333
|
else:
|
|
334
334
|
# 只读且档案缺失:给一份内存默认值,不影响读取已有记忆
|
|
335
335
|
p = compile_persona() if not READONLY else default_persona()
|
|
336
|
+
# PERSONA-AUTOHEAL(v5.54):读到空态(无名字无特质)时自动从 lastgood 回滚。
|
|
337
|
+
# 这是最后一道网——即使某条未预见的路径把盘写空,人格也不会真的丢。
|
|
338
|
+
try:
|
|
339
|
+
_empty_now = (not str(((p.get("identity") or {}).get("名字") or "")).strip()
|
|
340
|
+
and not (p.get("traits") or {}))
|
|
341
|
+
_lg = HOME / "persona.lastgood.json"
|
|
342
|
+
if _empty_now and _lg.exists():
|
|
343
|
+
_good = _slurp_json(_lg)
|
|
344
|
+
if isinstance(_good, dict) and str(((_good.get("identity") or {}).get("名字") or "")).strip():
|
|
345
|
+
if isinstance(p.get("state"), dict) and isinstance(_good.get("state"), dict):
|
|
346
|
+
_merged = dict(_good["state"])
|
|
347
|
+
_merged.update({kk: vv for kk, vv in p["state"].items() if vv is not None})
|
|
348
|
+
_good["state"] = _merged
|
|
349
|
+
p = _good
|
|
350
|
+
log_event("persona", "检测到人格空态,已自动从 persona.lastgood.json 回滚", level="warn")
|
|
351
|
+
except Exception:
|
|
352
|
+
pass
|
|
353
|
+
|
|
336
354
|
changed = False
|
|
337
355
|
if "onboarding" not in p:
|
|
338
356
|
p["onboarding"] = default_onboarding()
|
|
@@ -400,6 +418,13 @@ def save_persona(p: dict) -> None:
|
|
|
400
418
|
pass # 守卫自身绝不阻塞正常保存
|
|
401
419
|
with _locked(HOME / "persona.json"):
|
|
402
420
|
atomic_json(HOME / "persona.json", p)
|
|
421
|
+
# PERSONA-AUTOHEAL(v5.54):每次成功保存"有名字"的人格,同步留一份 lastgood。
|
|
422
|
+
# 这样无论哪条路径把人格写空,load_persona 都能自动回滚——不再依赖人工恢复。
|
|
423
|
+
try:
|
|
424
|
+
if str(((p.get("identity") or {}).get("名字") or "")).strip():
|
|
425
|
+
atomic_json(HOME / "persona.lastgood.json", p)
|
|
426
|
+
except Exception:
|
|
427
|
+
pass
|
|
403
428
|
|
|
404
429
|
|
|
405
430
|
def _snapshot_path() -> Path:
|