lingshu-skill 5.10.0 → 5.14.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 +120 -0
- package/README.md +69 -3
- package/SKILL.md +3 -1
- package/assets/panel.html +133 -7
- package/docs//345/200/237/351/211/264/345/276/205/345/212/236-DSH/346/217/222/344/273/266/347/224/237/346/200/201.md +224 -0
- package/docs//350/277/233/345/261/225/344/270/216/345/276/205/345/212/236.md +26 -1
- package/package.json +1 -1
- package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +12 -12
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +120 -0
- package/scripts/astrbot_plugin_lingshu/engine/README.md +69 -3
- package/scripts/astrbot_plugin_lingshu/engine/SKILL.md +3 -1
- package/scripts/astrbot_plugin_lingshu/engine/assets/panel.html +133 -7
- package/scripts/astrbot_plugin_lingshu/engine/scripts/cli.py +49 -3
- package/scripts/astrbot_plugin_lingshu/engine/scripts/core.py +7 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/emotion.py +75 -1
- package/scripts/astrbot_plugin_lingshu/engine/scripts/growth.py +5055 -4759
- package/scripts/astrbot_plugin_lingshu/engine/scripts/memory.py +305 -16
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_server.py +131 -7
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_settings.py +6 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_update.py +38 -9
- package/scripts/cli.py +49 -3
- package/scripts/core.py +7 -0
- package/scripts/emotion.py +75 -1
- package/scripts/growth.py +5055 -4759
- package/scripts/memory.py +305 -16
- package/scripts/panel_server.py +131 -7
- package/scripts/panel_settings.py +6 -0
- package/scripts/panel_update.py +38 -9
package/scripts/panel_update.py
CHANGED
|
@@ -27,24 +27,51 @@ def enabled() -> bool:
|
|
|
27
27
|
return bool(_cfg().get("auto_update"))
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
def
|
|
31
|
-
"""
|
|
30
|
+
def _normalize(res: dict) -> dict:
|
|
31
|
+
"""把 growth.update_check 的字段名补成调用方好用的别名,**不改原字段**。
|
|
32
|
+
|
|
33
|
+
历史坑:run() 判断的是 `update_available`,而 update_check 返回的是 `outdated`,
|
|
34
|
+
于是自动更新永远走"已是最新"分支——功能等于没接上。
|
|
35
|
+
"""
|
|
36
|
+
if not isinstance(res, dict):
|
|
37
|
+
return res
|
|
38
|
+
if "update_available" not in res:
|
|
39
|
+
res["update_available"] = bool(res.get("outdated"))
|
|
40
|
+
res.setdefault("current", res.get("installed_version"))
|
|
41
|
+
res.setdefault("latest", res.get("source_version") or res.get("version"))
|
|
42
|
+
return res
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def check(force_pull: bool = False, source: str | None = None) -> dict:
|
|
46
|
+
"""查有没有新版本(只读)。`source` 可强制 "npm" / "git"。"""
|
|
32
47
|
import growth
|
|
33
48
|
try:
|
|
34
|
-
|
|
49
|
+
if source:
|
|
50
|
+
# 强制指定源时先把它解析出来(顺带把"能不能拿到"这件事暴露给调用方)
|
|
51
|
+
src, kind = growth.resolve_source("lingshu", force_pull=force_pull,
|
|
52
|
+
prefer=source)
|
|
53
|
+
res = growth.update_check("lingshu", force_pull=force_pull,
|
|
54
|
+
prefer=source)
|
|
55
|
+
if isinstance(res, dict):
|
|
56
|
+
res["source"] = kind
|
|
57
|
+
res["source_kind"] = kind
|
|
58
|
+
res["target_path"] = str(src)
|
|
59
|
+
return _normalize(res)
|
|
60
|
+
return _normalize(growth.update_check("lingshu", force_pull=force_pull,
|
|
61
|
+
prefer=source))
|
|
35
62
|
except Exception as exc: # noqa: BLE001
|
|
36
63
|
core.log_event("update", f"检查更新失败:{exc}", level="warn")
|
|
37
64
|
return {"ok": False, "error": str(exc)}
|
|
38
65
|
|
|
39
66
|
|
|
40
|
-
def run(force: bool = False) -> dict:
|
|
41
|
-
"""
|
|
67
|
+
def run(force: bool = False, source: str | None = None) -> dict:
|
|
68
|
+
"""执行一次自动更新(含更新前备份)。`source` 可强制 "npm" / "git"。"""
|
|
42
69
|
if core.READONLY:
|
|
43
70
|
return {"ok": False, "reason": "记忆库只读,跳过自动更新"}
|
|
44
71
|
if not force and not enabled():
|
|
45
72
|
return {"ok": False, "skipped": True, "reason": "auto_update 未开启"}
|
|
46
73
|
|
|
47
|
-
chk = check(force_pull=True)
|
|
74
|
+
chk = check(force_pull=True, source=source)
|
|
48
75
|
if not chk or not chk.get("update_available"):
|
|
49
76
|
return {"ok": True, "skipped": True,
|
|
50
77
|
"reason": "已是最新", "current": chk.get("current"),
|
|
@@ -67,15 +94,17 @@ def run(force: bool = False) -> dict:
|
|
|
67
94
|
# ② 原子更新
|
|
68
95
|
try:
|
|
69
96
|
import growth
|
|
70
|
-
src, kind = growth.resolve_source("lingshu", force_pull=False
|
|
97
|
+
src, kind = growth.resolve_source("lingshu", force_pull=False,
|
|
98
|
+
prefer=source)
|
|
71
99
|
res = growth.install_skill("lingshu", force=True, from_dir=str(src))
|
|
72
100
|
except Exception as exc: # noqa: BLE001
|
|
73
101
|
core.log_event("update", f"自动更新失败:{exc}", level="error")
|
|
74
102
|
return {"ok": False, "reason": f"更新失败(已回滚):{exc}", "backup": bak}
|
|
75
103
|
|
|
76
|
-
core.log_event("update", f"
|
|
77
|
-
f"
|
|
104
|
+
core.log_event("update", f"自动更新完成(来源 {chk.get('source') or 'auto'}):"
|
|
105
|
+
f"{chk.get('current')} → {chk.get('latest')};更新前备份 {bak}")
|
|
78
106
|
return {"ok": True, "updated": True, "backup": bak,
|
|
107
|
+
"source": chk.get("source") or "auto",
|
|
79
108
|
"from": chk.get("current"), "to": chk.get("latest"),
|
|
80
109
|
"detail": res if isinstance(res, dict) else str(res),
|
|
81
110
|
"at": int(time.time())}
|