lingshu-skill 5.62.0 → 5.64.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 +30 -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 +2 -2
- package/manifest.json +20 -20
- package/package.json +1 -1
- package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +9 -9
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +30 -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 +2 -2
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_server.py +30 -10
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_update.py +9 -1
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panels.py +1 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/release.py +64 -23
- package/scripts/check_version.py +337 -312
- package/scripts/panel_server.py +30 -10
- package/scripts/panel_update.py +9 -1
- package/scripts/panels.py +1 -0
- package/scripts/release.py +64 -23
package/scripts/panel_server.py
CHANGED
|
@@ -1148,10 +1148,12 @@ class Handler(BaseHTTPRequestHandler):
|
|
|
1148
1148
|
"stage": st, "health": st.get("health")})
|
|
1149
1149
|
return
|
|
1150
1150
|
if path == "/api/doctor/summary":
|
|
1151
|
-
# OPS-02: 运行 doctor 并返回按级别分类的摘要(P0/P1 判据)
|
|
1151
|
+
# OPS-02 & LS-082 (v5.63): 运行 doctor 并返回按级别分类的摘要(P0/P1 判据)
|
|
1152
|
+
# 修复 NameError: name 'SCRIPTS' is not defined —— SCRIPTS 未在该函数或全局定义
|
|
1152
1153
|
try:
|
|
1153
1154
|
import subprocess, sys as _sys
|
|
1154
|
-
|
|
1155
|
+
scripts_dir = Path(__file__).resolve().parent
|
|
1156
|
+
proc = subprocess.run([_sys.executable, str(scripts_dir / "brain.py"), "doctor", "--json"],
|
|
1155
1157
|
capture_output=True, text=True, encoding="utf-8", timeout=30)
|
|
1156
1158
|
data = json.loads(proc.stdout) if proc.stdout else {}
|
|
1157
1159
|
except Exception as exc:
|
|
@@ -1199,10 +1201,10 @@ class Handler(BaseHTTPRequestHandler):
|
|
|
1199
1201
|
self._json({"items": panel_settings.all_items()})
|
|
1200
1202
|
return
|
|
1201
1203
|
if path == "/api/extensions/ollama/status":
|
|
1202
|
-
# Ollama
|
|
1203
|
-
#
|
|
1204
|
-
#
|
|
1205
|
-
|
|
1204
|
+
# Ollama 扩展状态:只读返回安装/服务/模型/配置 + 进度
|
|
1205
|
+
# LS-079 (v5.63): 消除 GET 请求的写副作用!
|
|
1206
|
+
# 旧代码在 GET 中调用 _ollama_auto_probe_async(),后台会自动下载模型并写 config.json,
|
|
1207
|
+
# 违反 HTTP GET 无副作用的规范。自动探测接管改由 POST /api/extensions/ollama/probe 显式触发。
|
|
1206
1208
|
self._json(ollama_status())
|
|
1207
1209
|
return
|
|
1208
1210
|
if path == "/api/panels/market":
|
|
@@ -1490,10 +1492,21 @@ def _api_persona_update(self, path, data):
|
|
|
1490
1492
|
|
|
1491
1493
|
|
|
1492
1494
|
def _api_data_backup(self, path, data):
|
|
1493
|
-
"""
|
|
1495
|
+
"""立即备份。保留 keep=0 的不修剪语义(LS-073)。"""
|
|
1494
1496
|
import panel_data
|
|
1497
|
+
# LS-073 (v5.63): 保留手动备份 keep=0 的不修剪语义!
|
|
1498
|
+
# 旧代码 _to_int(data.get("keep"), 20) or 20 会把显式的 0 当作假值再次兜底成 20,
|
|
1499
|
+
# 破坏了 panel_data.make_backup(keep=0) "不修剪" 的明确语义。
|
|
1500
|
+
raw_k = data.get("keep")
|
|
1501
|
+
if raw_k is not None:
|
|
1502
|
+
try:
|
|
1503
|
+
keep_val = int(raw_k)
|
|
1504
|
+
except (ValueError, TypeError):
|
|
1505
|
+
keep_val = 20
|
|
1506
|
+
else:
|
|
1507
|
+
keep_val = 20
|
|
1495
1508
|
try:
|
|
1496
|
-
r = panel_data.make_backup(keep=
|
|
1509
|
+
r = panel_data.make_backup(keep=keep_val)
|
|
1497
1510
|
except PermissionError as exc:
|
|
1498
1511
|
self._json({"error": str(exc)}, 403)
|
|
1499
1512
|
return
|
|
@@ -1845,6 +1858,10 @@ def _api_daily(self, path, data):
|
|
|
1845
1858
|
|
|
1846
1859
|
|
|
1847
1860
|
def _api_skill_self_review(self, path, data):
|
|
1861
|
+
# LS-078 (v5.63): 只读模式下禁止通过 self-review 写入历史!
|
|
1862
|
+
if brain.READONLY:
|
|
1863
|
+
self._json({"error": "数据目录当前只读,无法执行 self-review 写历史"}, 403)
|
|
1864
|
+
return
|
|
1848
1865
|
# P2-4:自审也记一笔(成长阶段要用"self-review 次数")
|
|
1849
1866
|
try:
|
|
1850
1867
|
growth.record_doctor_run(0, 0, 0, kind="self-review")
|
|
@@ -2165,9 +2182,12 @@ def _api_skill(self, path, data):
|
|
|
2165
2182
|
except KeyError as exc:
|
|
2166
2183
|
self._json({"error": f"{_src_pref} 下载源不可用:{exc}"}, 502)
|
|
2167
2184
|
return
|
|
2185
|
+
# LS-086 & LS-087 (v5.63): 统一风险确认字段(兼容 accept_risk、accepted_risk 与 yes)
|
|
2186
|
+
# 并统一技能安装结果包装字段:返回 {"ok": True, "result": res, "skill": res} 双键对齐前端契约
|
|
2187
|
+
risk_ok = bool(data.get("accept_risk") or data.get("accepted_risk") or data.get("yes"))
|
|
2168
2188
|
res = growth.install_skill(_name, force=bool(data.get("force")), from_dir=_from,
|
|
2169
|
-
accept_risk=
|
|
2170
|
-
self._json({"ok": True, "skill": res, "workspace": workspace()})
|
|
2189
|
+
accept_risk=risk_ok)
|
|
2190
|
+
self._json({"ok": True, "result": res, "skill": res, "workspace": workspace()})
|
|
2171
2191
|
elif act == "uninstall":
|
|
2172
2192
|
res = growth.uninstall_skill(data.get("name", ""), managed_only=True)
|
|
2173
2193
|
self._json({"ok": True, "skill": res, "workspace": workspace()})
|
package/scripts/panel_update.py
CHANGED
|
@@ -72,7 +72,15 @@ def run(force: bool = False, source: str | None = None) -> dict:
|
|
|
72
72
|
return {"ok": False, "skipped": True, "reason": "auto_update 未开启"}
|
|
73
73
|
|
|
74
74
|
chk = check(force_pull=True, source=source)
|
|
75
|
-
|
|
75
|
+
# LS-133(v5.64):检查失败绝不能报告"已是最新"!
|
|
76
|
+
# 旧逻辑 `if not chk or not chk.get("update_available")` 把【检查失败】(ok=False)
|
|
77
|
+
# 与【确实已是最新】混为一谈,返回 {"ok": True, "skipped": True, "reason": "已是最新"}
|
|
78
|
+
# —— 调用方(面板/监控)看到 ok=True 会误以为更新系统健康运行。
|
|
79
|
+
# 现在区分:检查失败 → 返回 {"ok": False, "error": ...},绝不伪装成成功。
|
|
80
|
+
if not chk or not chk.get("ok", True):
|
|
81
|
+
return {"ok": False, "error": chk.get("error") or "检查更新失败",
|
|
82
|
+
"current": chk.get("current"), "latest": chk.get("latest")}
|
|
83
|
+
if not chk.get("update_available"):
|
|
76
84
|
return {"ok": True, "skipped": True,
|
|
77
85
|
"reason": "已是最新", "current": chk.get("current"),
|
|
78
86
|
"latest": chk.get("latest")}
|
package/scripts/panels.py
CHANGED
package/scripts/release.py
CHANGED
|
@@ -56,10 +56,11 @@ GENERATE = [
|
|
|
56
56
|
]
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
def _run(args: list, *, capture: bool = False) -> tuple[int, str]:
|
|
59
|
+
def _run(args: list, *, capture: bool = False, timeout: int = 120) -> tuple[int, str]:
|
|
60
60
|
cmd = [PY] + args
|
|
61
|
+
# LS-127(v5.64):发布相关子进程必须设置超时,防止挂起进程卡死整条发布链
|
|
61
62
|
r = subprocess.run(cmd, cwd=ROOT, capture_output=True, text=True,
|
|
62
|
-
encoding="utf-8", errors="replace")
|
|
63
|
+
encoding="utf-8", errors="replace", timeout=timeout)
|
|
63
64
|
out = (r.stdout + r.stderr) if capture else ""
|
|
64
65
|
if not capture:
|
|
65
66
|
# 直接透传,用户能看见进度
|
|
@@ -80,12 +81,16 @@ def _ver_tuple(v: str) -> tuple:
|
|
|
80
81
|
|
|
81
82
|
|
|
82
83
|
def registry_latest(timeout: int = 15) -> str | None:
|
|
84
|
+
# LS-126(v5.64):区分"线上无版本"与"网络/解析故障"!
|
|
85
|
+
# 网络失败绝不能静默返回 None(调用方会误以为"已发布成功"),而是抛出明确异常
|
|
86
|
+
# 让调用方 fail-closed 停止发布流程。
|
|
83
87
|
try:
|
|
84
88
|
with urllib.request.urlopen(f"{REGISTRY}/{PKG_NAME}", timeout=timeout) as r:
|
|
85
89
|
d = json.load(r)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
except Exception as exc:
|
|
91
|
+
raise RuntimeError(
|
|
92
|
+
f"registry 查询失败(无法确认线上状态,发布流程必须中止):{exc}") from exc
|
|
93
|
+
return str(d.get("dist-tags", {}).get("latest", "")) or None
|
|
89
94
|
|
|
90
95
|
|
|
91
96
|
def do_bump(new_ver: str, title: str) -> int:
|
|
@@ -109,33 +114,58 @@ def do_bump(new_ver: str, title: str) -> int:
|
|
|
109
114
|
return 1
|
|
110
115
|
|
|
111
116
|
# 1) 改四处版本(bytes,保 BOM/换行原样)
|
|
117
|
+
# LS-124 / LS-125(v5.64):增加预校验与事务回滚!
|
|
118
|
+
# 旧实现直接原地改文件,若中途失败(磁盘满/权限/CHANGELOG 结构异常)会留下
|
|
119
|
+
# 部分文件已改部分未改的混合状态。现在先备份原内容,任何一步失败立即逆序回滚。
|
|
112
120
|
edits = [
|
|
113
121
|
("SKILL.md", f"version: {old}".encode(), f"version: {new_ver}".encode()),
|
|
114
122
|
("package.json", f'"version": "{old}.0"'.encode(), f'"version": "{new_ver}.0"'.encode()),
|
|
115
123
|
("README.md", f"**v{old}**".encode(), f"**v{new_ver}**".encode()),
|
|
116
124
|
]
|
|
125
|
+
# 预校验:所有替换锚点必须存在,任何一项不匹配都提前拒绝,绝不半途改坏
|
|
126
|
+
_pre = {}
|
|
117
127
|
for rel, o, n in edits:
|
|
118
128
|
p = ROOT / rel
|
|
119
129
|
b = p.read_bytes()
|
|
120
130
|
if o not in b:
|
|
121
131
|
print(f"[release] {rel} 没找到版本标记 {o!r},拒绝继续", file=sys.stderr)
|
|
122
132
|
return 1
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
_pre[rel] = b
|
|
134
|
+
applied: list = []
|
|
135
|
+
try:
|
|
136
|
+
for rel, o, n in edits:
|
|
137
|
+
p = ROOT / rel
|
|
138
|
+
b = _pre[rel]
|
|
139
|
+
nb = b.replace(o, n, 1)
|
|
140
|
+
p.write_bytes(nb)
|
|
141
|
+
applied.append((p, b))
|
|
142
|
+
# 1b) SKILL-lite / SKILL-tiny 的 version 跟着走。
|
|
143
|
+
# 它们不触发"必须升版"(裁剪文档,正文可能长期不动),但头部的 version 若十年不动,
|
|
144
|
+
# 会让人误判"这份文档对得上引擎"。用字节级正则改,保 BOM 与原换行。
|
|
145
|
+
for rel in ("SKILL-lite.md", "SKILL-tiny.md"):
|
|
146
|
+
lp = ROOT / rel
|
|
147
|
+
if not lp.is_file():
|
|
148
|
+
continue
|
|
149
|
+
b = lp.read_bytes()
|
|
150
|
+
nb, cnt = re.subn(rb"^version:\s*[\d.]+",
|
|
151
|
+
f"version: {new_ver}".encode(), b, count=1, flags=re.M)
|
|
152
|
+
if cnt:
|
|
153
|
+
lp.write_bytes(nb)
|
|
154
|
+
applied.append((lp, b))
|
|
155
|
+
print(f"[release] {rel} version → {new_ver}")
|
|
156
|
+
except BaseException as bump_err:
|
|
157
|
+
# LS-125:回滚已应用的版本文件,绝不留下半改状态
|
|
158
|
+
for p, old_b in reversed(applied):
|
|
159
|
+
try:
|
|
160
|
+
p.write_bytes(old_b)
|
|
161
|
+
except Exception:
|
|
162
|
+
pass
|
|
163
|
+
print(f"[release] 版本文件写入失败,已回滚:{bump_err}", file=sys.stderr)
|
|
164
|
+
return 1
|
|
165
|
+
|
|
166
|
+
# 1c) CHANGELOG **新增**版本段而非改写旧段(LS-124)
|
|
167
|
+
# 旧实现直接改写首个 `## vX.Y(date)` 标题,导致旧版本发布记录被永久覆盖丢失。
|
|
168
|
+
# 现在保留旧标题并在其前插入新版本占位段,维护历史完整性。
|
|
139
169
|
cl = ROOT / "CHANGELOG.md"
|
|
140
170
|
t = cl.read_text(encoding="utf-8")
|
|
141
171
|
first = re.search(r"^## v[\d.]+([^)]*)", t, re.M)
|
|
@@ -143,8 +173,19 @@ def do_bump(new_ver: str, title: str) -> int:
|
|
|
143
173
|
print("[release] CHANGELOG.md 找不到首节标题,拒绝继续", file=sys.stderr)
|
|
144
174
|
return 1
|
|
145
175
|
today = time.strftime("%Y-%m-%d")
|
|
146
|
-
|
|
147
|
-
|
|
176
|
+
cl_old = t
|
|
177
|
+
t = t[:first.start()] + f"## v{new_ver}({today})\n\n(占位:正文由维护者补齐)\n\n" + t[first.start():]
|
|
178
|
+
try:
|
|
179
|
+
cl.write_text(t, encoding="utf-8", newline="")
|
|
180
|
+
applied.append((cl, cl_old.encode("utf-8")))
|
|
181
|
+
except BaseException as cl_err:
|
|
182
|
+
for p, old_b in reversed(applied):
|
|
183
|
+
try:
|
|
184
|
+
p.write_bytes(old_b)
|
|
185
|
+
except Exception:
|
|
186
|
+
pass
|
|
187
|
+
print(f"[release] CHANGELOG 写入失败,已回滚版本文件:{cl_err}", file=sys.stderr)
|
|
188
|
+
return 1
|
|
148
189
|
|
|
149
190
|
# 2) 重生成派生文件
|
|
150
191
|
print(f"[release] 版本 {old} → {new_ver};重生成派生文件...")
|