lingshu-skill 5.24.0 → 5.25.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 +44 -0
- package/README.md +1 -1
- package/SKILL-lite.md +1 -1
- package/SKILL-tiny.md +1 -1
- package/SKILL.md +2 -1
- package/docs//345/256/241/346/240/270/346/224/271/350/277/233/345/276/205/345/212/236.md +12 -0
- package/package.json +1 -1
- package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +14 -13
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +44 -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 +2 -1
- package/scripts/astrbot_plugin_lingshu/engine/scripts/cli.py +43 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/core.py +74 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/coverage_report.py +167 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/mem_dialogue.py +221 -219
- package/scripts/astrbot_plugin_lingshu/engine/scripts/memory.py +10 -3
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panels.py +470 -460
- package/scripts/astrbot_plugin_lingshu/engine/scripts/release.py +14 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/safety.py +29 -1
- package/scripts/astrbot_plugin_lingshu/engine/scripts/safety_net.py +12 -0
- package/scripts/check_version.py +16 -0
- package/scripts/cli.py +43 -0
- package/scripts/core.py +74 -0
- package/scripts/coverage_report.py +167 -0
- package/scripts/mem_dialogue.py +221 -219
- package/scripts/memory.py +10 -3
- package/scripts/panels.py +470 -460
- package/scripts/release.py +14 -0
- package/scripts/safety.py +29 -1
- package/scripts/safety_net.py +12 -0
package/scripts/release.py
CHANGED
|
@@ -121,6 +121,20 @@ def do_bump(new_ver: str, title: str) -> int:
|
|
|
121
121
|
print(f"[release] {rel} 没找到版本标记 {o!r},拒绝继续", file=sys.stderr)
|
|
122
122
|
return 1
|
|
123
123
|
p.write_bytes(b.replace(o, n, 1))
|
|
124
|
+
# 1b) SKILL-lite / SKILL-tiny 的 version 跟着走。
|
|
125
|
+
# 它们不触发"必须升版"(裁剪文档,正文可能长期不动),但头部的 version 若十年不动,
|
|
126
|
+
# 会让人误判"这份文档对得上引擎"。用字节级正则改,保 BOM 与原换行。
|
|
127
|
+
for rel in ("SKILL-lite.md", "SKILL-tiny.md"):
|
|
128
|
+
lp = ROOT / rel
|
|
129
|
+
if not lp.is_file():
|
|
130
|
+
continue
|
|
131
|
+
b = lp.read_bytes()
|
|
132
|
+
nb, cnt = re.subn(rb"^version:\s*[\d.]+",
|
|
133
|
+
f"version: {new_ver}".encode(), b, count=1, flags=re.M)
|
|
134
|
+
if cnt:
|
|
135
|
+
lp.write_bytes(nb)
|
|
136
|
+
print(f"[release] {rel} version → {new_ver}")
|
|
137
|
+
|
|
124
138
|
# CHANGELOG 首节改写为新版本(占位,正文留空由维护者补)
|
|
125
139
|
cl = ROOT / "CHANGELOG.md"
|
|
126
140
|
t = cl.read_text(encoding="utf-8")
|
package/scripts/safety.py
CHANGED
|
@@ -324,10 +324,33 @@ def is_interactive() -> bool:
|
|
|
324
324
|
return False
|
|
325
325
|
|
|
326
326
|
|
|
327
|
+
def require_token(action: str, given: str, expected: str, *, hint: str = "") -> None:
|
|
328
|
+
"""破坏性操作的一次性确认码校验(与 confirm_destructive 同属 safety 的一套原语)。
|
|
329
|
+
|
|
330
|
+
为什么不并进 y/N:这类操作要能被**程序 / AI 调用时强制显式写下指纹**,
|
|
331
|
+
而那种场合 stdin 不是终端,交互提示根本不会出现。
|
|
332
|
+
这样说清分工,比"两套逻辑各写各的"更难出错:
|
|
333
|
+
· confirm_destructive —— 有终端时的人机确认(--yes 或 y)
|
|
334
|
+
· require_token —— 任何场合都必须匹配的指纹
|
|
335
|
+
|
|
336
|
+
不匹配抛 ValueError(调用方负责转成退出码)。
|
|
337
|
+
"""
|
|
338
|
+
if not expected:
|
|
339
|
+
raise ValueError(f"[{action}] 缺少确认码基准(内部错误)")
|
|
340
|
+
if not given or str(given) != str(expected):
|
|
341
|
+
msg = (f"[{action}] 需显式确认:确认码不匹配"
|
|
342
|
+
f"(应为目标 id 的前 {len(str(expected))} 位)")
|
|
343
|
+
if hint:
|
|
344
|
+
msg += f"。{hint}"
|
|
345
|
+
raise ValueError(msg)
|
|
346
|
+
|
|
347
|
+
|
|
327
348
|
def confirm_destructive(action: str, impact: str | list[str], *,
|
|
328
349
|
assume_yes: bool = False,
|
|
329
350
|
hint: str = "",
|
|
330
|
-
stream=None
|
|
351
|
+
stream=None,
|
|
352
|
+
token: str = "",
|
|
353
|
+
expect_token: str = "") -> bool:
|
|
331
354
|
"""破坏性操作的统一确认。返回 True=可以继续,False=调用方应中止(或被取消)。
|
|
332
355
|
|
|
333
356
|
参数:
|
|
@@ -343,6 +366,11 @@ def confirm_destructive(action: str, impact: str | list[str], *,
|
|
|
343
366
|
for line in lines:
|
|
344
367
|
print(f" - {line}", file=out)
|
|
345
368
|
|
|
369
|
+
# 指纹校验放在最前:设了 expect_token 就必须匹配,--yes 也绕不过。
|
|
370
|
+
# 这样"确认码"与"影响面提示"是同一处代码,不会出现某个入口忘了校验。
|
|
371
|
+
if expect_token:
|
|
372
|
+
require_token(action, token, expect_token, hint=hint)
|
|
373
|
+
|
|
346
374
|
if assume_yes:
|
|
347
375
|
print(f"[{action}] 已通过 --yes 确认。", file=out)
|
|
348
376
|
if hint:
|
package/scripts/safety_net.py
CHANGED
|
@@ -339,6 +339,13 @@ def guarded_write(reason: str, writer, names=None, allow_shrink=()) -> dict:
|
|
|
339
339
|
report["error"] = f"写入异常已回滚:{err}"
|
|
340
340
|
except Exception as rexc: # noqa: BLE001
|
|
341
341
|
report["error"] = f"写入异常且回滚失败:{err} / {rexc}"
|
|
342
|
+
# 最危险的一档:写入出了问题、回滚也没成功 ⇒ 数据处于脏状态,
|
|
343
|
+
# 却只体现在返回值里。计一次数,让 doctor 的 swallowed 项能看见。
|
|
344
|
+
try:
|
|
345
|
+
import core as _c
|
|
346
|
+
_c.swallow("safety.rollback", rexc, where="safety_net.guarded_write")
|
|
347
|
+
except Exception: # noqa: BLE001
|
|
348
|
+
pass
|
|
342
349
|
return report
|
|
343
350
|
if _verify_enabled():
|
|
344
351
|
v = verify(names, allow_shrink=allow_shrink)
|
|
@@ -352,4 +359,9 @@ def guarded_write(reason: str, writer, names=None, allow_shrink=()) -> dict:
|
|
|
352
359
|
report["ok"] = True # 已回滚,数据一致
|
|
353
360
|
except Exception as rexc: # noqa: BLE001
|
|
354
361
|
report["issues"].append(f"回滚失败:{rexc}")
|
|
362
|
+
try:
|
|
363
|
+
import core as _c
|
|
364
|
+
_c.swallow("safety.rollback", rexc, where="safety_net.guarded_write")
|
|
365
|
+
except Exception: # noqa: BLE001
|
|
366
|
+
pass
|
|
355
367
|
return report
|