lingshu-skill 3.83.0 → 3.85.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 +22 -0
- package/README.md +1 -1
- package/SKILL.md +1 -1
- package/docs//345/217/221/345/270/203/350/207/252/345/212/250/345/214/226.md +54 -0
- package/package.json +1 -1
- package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +4 -3
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +22 -0
- package/scripts/astrbot_plugin_lingshu/engine/README.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/SKILL.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/scripts/release.py +227 -0
- package/scripts/release.py +227 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## v3.85(2026-11-22)
|
|
4
|
+
|
|
5
|
+
> 主题:**修 v3.84 发版自动化的 staged 轮询 bug**——publish 用 SKILL.md 的 X.Y 与 registry 的 X.Y.0 比较,永远匹配不上,导致发布成功后脚本空转 20 分钟;本次改从 package.json 读 X.Y.0。
|
|
6
|
+
|
|
7
|
+
- **`release.py do_publish` 版本格式修复**:`ver` 改为读 `package.json` 的 `X.Y.0`(原来读 SKILL.md 的 `X.Y`),与 npm registry `latest` 格式一致——staged 轮询能正确匹配并退出,不再空转到超时。
|
|
8
|
+
- 实测:v3.84.0 通过 release.py publish 成功发布、registry 可见;但脚本因上述 bug 卡在轮询(已终止进程、确认包已上线),本次修复后轮询匹配验证通过。
|
|
9
|
+
|
|
10
|
+
验证:release.py 编译通过;`do_publish` 读到 ver=3.84.0 与 registry latest=3.84.0 匹配。六项检查 + 行为基线 + 全量测试全过。
|
|
11
|
+
|
|
12
|
+
## v3.84(2026-11-22)
|
|
13
|
+
|
|
14
|
+
> 主题:**npm 发版自动化**——把台账第四节发布流程串成一条命令,守住"版本必须升、检查必须全绿"门禁。
|
|
15
|
+
|
|
16
|
+
- **`scripts/release.py`**(新):
|
|
17
|
+
- `status` —— 本地 SKILL/package 版本 / npm 线上 latest / 是否可发;
|
|
18
|
+
- `bump <X.Y> [标题]` —— 拒绝非 X.Y 或版本不升;自动改四处版本(SKILL/package X.Y.0/README/CHANGELOG 首节)+ 按依赖序重生成 sync_engine→checksums→manifest + 跑六项检查/行为基线/全量测试,全绿才成功;
|
|
19
|
+
- `publish [--wait 分钟]` —— 全套验证 + npm whoami + 版本大于线上防 E409 + npm publish + 轮询 registry 到可见(绕本机缓存,覆盖 npm staged 窗口 ~17 分钟,默认等 20 分钟)。
|
|
20
|
+
- **不做** git 提交/tag/push(用户决定);新文件未 git add 时 manifest 门禁照旧拦(脚本不替你决定入库范围)。
|
|
21
|
+
- **`docs/发布自动化.md`**(新):三条命令用法 + 典型发版流程(先 bump 再一起提交,最后 publish)。
|
|
22
|
+
|
|
23
|
+
验证:release.py 编译通过;status 正确显示本地 3.83 / 线上 3.83.0 / 不可发;bump 正确拒绝非升版与未 git add 文件;副本上测了 bump 升版改四处 + 各检查全跑到(副本的 2 处失败是测试环境差异:未 add 新文件 / 临时目录冲突,正式仓库 56/56)。
|
|
24
|
+
|
|
3
25
|
## v3.83(2026-11-22)
|
|
4
26
|
|
|
5
27
|
> 主题:**P5 #21 借鉴清单其余三项落地**——L7 意图层 / 群规 / agentId 维度。仅 Letta core-memory 可编辑暂不做(幻觉固化风险,现有双门限已够)。
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> 名字取自《黄帝内经》:**算力给思考,人格给灵魂,记忆给生命。**
|
|
4
4
|
|
|
5
|
-
> 当前版本 **v3.
|
|
5
|
+
> 当前版本 **v3.85**(变更见 [CHANGELOG.md](CHANGELOG.md))
|
|
6
6
|
|
|
7
7
|
> 🔁 **双仓库镜像**:GitHub(主)与 Gitee(镜像)保持同步——[gitee.com/htmcwy_0/lingshu-skill](https://gitee.com/htmcwy_0/lingshu-skill)。灵枢的更新检查会探测两边最新提交,**谁更新就自动从谁拉取**;任一边不可达(Gitee 匿名风控 / GitHub 限额)时走另一边兜底。
|
|
8
8
|
|
package/SKILL.md
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# 发版自动化(release.py)
|
|
2
|
+
|
|
3
|
+
把台账第四节的发布流程串成命令,**守住"版本必须升、检查必须全绿"的门禁**,不再靠人肉记步骤。
|
|
4
|
+
|
|
5
|
+
## 三条命令
|
|
6
|
+
|
|
7
|
+
```powershell
|
|
8
|
+
$py = "D:\ServBay\packages\python\current\python.exe"
|
|
9
|
+
cd E:\丁厚同\文档\程序\灵枢-skill
|
|
10
|
+
|
|
11
|
+
# 看现状:本地版本 / 线上 latest / 是否可发
|
|
12
|
+
& $py scripts\release.py status
|
|
13
|
+
|
|
14
|
+
# 1)升版本(X.Y):自动改四处版本 + CHANGELOG 首节 + 重生成派生文件 + 全套验证
|
|
15
|
+
& $py scripts\release.py bump 3.84 "一句话主题"
|
|
16
|
+
|
|
17
|
+
# 2)发布:校验版本一致+检查全绿 → npm publish → 轮询 registry 到可见
|
|
18
|
+
& $py scripts\release.py publish
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 各命令细节
|
|
22
|
+
|
|
23
|
+
- **bump `<X.Y>` `[标题]`**:
|
|
24
|
+
- 拒绝非 X.Y 格式、拒绝新版本 ≤ 当前版本;
|
|
25
|
+
- 改 `SKILL.md` / `package.json`(X.Y.0) / `README.md` / `CHANGELOG.md` 首节;
|
|
26
|
+
- 按依赖序重生成 `sync_engine` → `make_checksums` → `make_manifest`;
|
|
27
|
+
- 跑六项检查 + 行为基线 + 全量测试,**全绿才成功**(任一红即退出码 1)。
|
|
28
|
+
- 不做 git 提交/tag/push。
|
|
29
|
+
- **publish `[--wait 分钟]`**:
|
|
30
|
+
- 先跑全套验证;`npm whoami` 确认登录;确认本地版本 > 线上 latest(防 E409 重发);
|
|
31
|
+
- `npm publish` 后轮询 registry(绕本机 npm 缓存)直到 `latest` == 本地版本——**npm staged 窗口最多 ~17 分钟**,脚本默认等 20 分钟。
|
|
32
|
+
- **status**:打印本地/线上版本与"是否可发"。
|
|
33
|
+
|
|
34
|
+
## 两条铁律(脚本替你守)
|
|
35
|
+
|
|
36
|
+
1. **新文件必须先 `git add`**:`manifest --check` 会拒绝未入库的发布范围内文件(如新脚本自己)。先 `git add` 新文件再 bump,脚本不替你决定哪些文件入库。
|
|
37
|
+
2. **tag/push 不做**:按用户决定,脚本不含 git 提交/tag/push;发版后如需提交,仍按"一个版本一个提交"手工做(提交时排除 `tests/test_*.py` 本地测试文件)。
|
|
38
|
+
|
|
39
|
+
## 典型发版流程(建议顺序)
|
|
40
|
+
|
|
41
|
+
```powershell
|
|
42
|
+
# 1) 改完功能代码(先别提交版本文件)
|
|
43
|
+
# 2) 升版本 + 重生成 + 全套验证(bump 会改 SKILL/package/README/CHANGELOG/manifest)
|
|
44
|
+
& $py scripts\release.py bump 3.84 "主题"
|
|
45
|
+
# 3) 全绿后,把功能代码 + 版本文件一起提交(一个版本一个提交)
|
|
46
|
+
git add -A
|
|
47
|
+
git commit -m "feat: v3.84 主题"
|
|
48
|
+
# 4) 发布到 npm(等 staged 可见)
|
|
49
|
+
& $py scripts\release.py publish
|
|
50
|
+
# 5) 同步 DSH 副本 + 重启插件(脚本不做)
|
|
51
|
+
powershell -ExecutionPolicy Bypass -File scripts\update_dsh_copy.ps1 -Profile desktop
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
> tag/push 按用户决定不做;提交时排除 `tests/test_*.py` 本地测试文件。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lingshu-skill",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.85.0",
|
|
4
4
|
"description": "Brain-inspired persistent memory, persona and growth system for AI coding agents. Local-only, zero-dependency Python. Requires Python 3.10+.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"PATCH_NOTES.md": "9296e524f743f358fd11115598398a754cfd69534526dde9c8ad85f14a418f89",
|
|
3
3
|
"README.md": "3d634d743b085eebd2cbb5dd3a00edfa728ed23947e20cc29e7c3b29087ec043",
|
|
4
|
-
"engine/CHANGELOG.md": "
|
|
5
|
-
"engine/README.md": "
|
|
4
|
+
"engine/CHANGELOG.md": "eabfaf6ed04a85195fe77edccb35f70b149bb94f6673021cd857320946a877a2",
|
|
5
|
+
"engine/README.md": "93b9338cc82659f25c4673fe2d3d119f361e86b261e990612087247c8ca0ca6e",
|
|
6
6
|
"engine/SKILL-lite.md": "04b87789232a0f7537c861c857888b4a0e947bcf92a461cbad5328af05361c58",
|
|
7
7
|
"engine/SKILL-tiny.md": "74e1955cc5bf4ec0ca28d52030f799f039283de27a52345a33ce783d6ee0c608",
|
|
8
|
-
"engine/SKILL.md": "
|
|
8
|
+
"engine/SKILL.md": "b5700e9473be44907fa1bc45139ab5ba38f747b76f002f14931b5ca33c6eb6a7",
|
|
9
9
|
"engine/assets/panel.html": "8b368f16f0c1447413456a16cb4666daa4df08983bd30d627af04ad2a0fbda26",
|
|
10
10
|
"engine/docs/commands.md": "15f57adbeeca393fe001831853d5b9a5dfb237ac666711fa5662000eb22b2c59",
|
|
11
11
|
"engine/docs/mechanics.md": "e8a6602a434ed5b78cac64a98884f65a6888eb48daa7a1c0be1f6c3984041b34",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"engine/scripts/panel_server.py": "51c735de0d78d8cc9d3aae5bee4ca1e66a551f200cab37f327bf9c2666abd297",
|
|
43
43
|
"engine/scripts/panels.py": "87dfce47693340af7c9bc6010a593256331e32c2e8504a0ac0745cf2ef992fd6",
|
|
44
44
|
"engine/scripts/persona.py": "fb748d2fb7b176d9dd0d7394de69ba4560da7f4205f62256477d3a69dcbdf0f5",
|
|
45
|
+
"engine/scripts/release.py": "b8a1d313b4c1dd4b9eaa493600954d49a19f78ba23e821bced5e329deba269ed",
|
|
45
46
|
"engine/scripts/retriever.py": "85a35f8f660767cff1c068e722b51e3b5623c4dffe4822527eee96f9220240d3",
|
|
46
47
|
"engine/scripts/safety.py": "7586d8d4a627eec67a4891b758665289a33e07a45fd27d526d45c70d1178cd53",
|
|
47
48
|
"engine/scripts/session_import.py": "31c68069800e6ca8c91aad7869e7e174adc0b1e027ac0a4f7361a2c3a5363b3f",
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## v3.85(2026-11-22)
|
|
4
|
+
|
|
5
|
+
> 主题:**修 v3.84 发版自动化的 staged 轮询 bug**——publish 用 SKILL.md 的 X.Y 与 registry 的 X.Y.0 比较,永远匹配不上,导致发布成功后脚本空转 20 分钟;本次改从 package.json 读 X.Y.0。
|
|
6
|
+
|
|
7
|
+
- **`release.py do_publish` 版本格式修复**:`ver` 改为读 `package.json` 的 `X.Y.0`(原来读 SKILL.md 的 `X.Y`),与 npm registry `latest` 格式一致——staged 轮询能正确匹配并退出,不再空转到超时。
|
|
8
|
+
- 实测:v3.84.0 通过 release.py publish 成功发布、registry 可见;但脚本因上述 bug 卡在轮询(已终止进程、确认包已上线),本次修复后轮询匹配验证通过。
|
|
9
|
+
|
|
10
|
+
验证:release.py 编译通过;`do_publish` 读到 ver=3.84.0 与 registry latest=3.84.0 匹配。六项检查 + 行为基线 + 全量测试全过。
|
|
11
|
+
|
|
12
|
+
## v3.84(2026-11-22)
|
|
13
|
+
|
|
14
|
+
> 主题:**npm 发版自动化**——把台账第四节发布流程串成一条命令,守住"版本必须升、检查必须全绿"门禁。
|
|
15
|
+
|
|
16
|
+
- **`scripts/release.py`**(新):
|
|
17
|
+
- `status` —— 本地 SKILL/package 版本 / npm 线上 latest / 是否可发;
|
|
18
|
+
- `bump <X.Y> [标题]` —— 拒绝非 X.Y 或版本不升;自动改四处版本(SKILL/package X.Y.0/README/CHANGELOG 首节)+ 按依赖序重生成 sync_engine→checksums→manifest + 跑六项检查/行为基线/全量测试,全绿才成功;
|
|
19
|
+
- `publish [--wait 分钟]` —— 全套验证 + npm whoami + 版本大于线上防 E409 + npm publish + 轮询 registry 到可见(绕本机缓存,覆盖 npm staged 窗口 ~17 分钟,默认等 20 分钟)。
|
|
20
|
+
- **不做** git 提交/tag/push(用户决定);新文件未 git add 时 manifest 门禁照旧拦(脚本不替你决定入库范围)。
|
|
21
|
+
- **`docs/发布自动化.md`**(新):三条命令用法 + 典型发版流程(先 bump 再一起提交,最后 publish)。
|
|
22
|
+
|
|
23
|
+
验证:release.py 编译通过;status 正确显示本地 3.83 / 线上 3.83.0 / 不可发;bump 正确拒绝非升版与未 git add 文件;副本上测了 bump 升版改四处 + 各检查全跑到(副本的 2 处失败是测试环境差异:未 add 新文件 / 临时目录冲突,正式仓库 56/56)。
|
|
24
|
+
|
|
3
25
|
## v3.83(2026-11-22)
|
|
4
26
|
|
|
5
27
|
> 主题:**P5 #21 借鉴清单其余三项落地**——L7 意图层 / 群规 / agentId 维度。仅 Letta core-memory 可编辑暂不做(幻觉固化风险,现有双门限已够)。
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> 名字取自《黄帝内经》:**算力给思考,人格给灵魂,记忆给生命。**
|
|
4
4
|
|
|
5
|
-
> 当前版本 **v3.
|
|
5
|
+
> 当前版本 **v3.85**(变更见 [CHANGELOG.md](CHANGELOG.md))
|
|
6
6
|
|
|
7
7
|
> 🔁 **双仓库镜像**:GitHub(主)与 Gitee(镜像)保持同步——[gitee.com/htmcwy_0/lingshu-skill](https://gitee.com/htmcwy_0/lingshu-skill)。灵枢的更新检查会探测两边最新提交,**谁更新就自动从谁拉取**;任一边不可达(Gitee 匿名风控 / GitHub 限额)时走另一边兜底。
|
|
8
8
|
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""灵枢发版自动化(把台账第四节的发布流程串成一条命令)。
|
|
4
|
+
|
|
5
|
+
子命令
|
|
6
|
+
------
|
|
7
|
+
python scripts/release.py bump <X.Y> ["小节标题"]
|
|
8
|
+
1) 校验新版本 > 当前版本;
|
|
9
|
+
2) 改四处版本:SKILL.md / package.json(X.Y.0) / README.md / CHANGELOG 首节占位;
|
|
10
|
+
3) 按依赖序重生成:sync_engine → make_checksums → make_manifest;
|
|
11
|
+
4) 跑六项检查 + 行为基线 + 全量测试,全绿才成功。
|
|
12
|
+
不做 git 提交/tag/push(用户明确不做 tag/push,提交仍按"一个版本一个提交"手工或另配)。
|
|
13
|
+
注意:若有新代码文件(如本脚本自己)尚未 git add,manifest --check 会拒绝——
|
|
14
|
+
这是既有门禁,先 git add 新文件再 bump,脚本不替你决定哪些文件入库。
|
|
15
|
+
|
|
16
|
+
python scripts/release.py publish
|
|
17
|
+
1) 校验版本四处一致(check_version)+ 六项检查全绿;
|
|
18
|
+
2) npm whoami 确认登录;
|
|
19
|
+
3) 确认包版本比线上大(避免 E409 重复发);
|
|
20
|
+
4) npm publish;
|
|
21
|
+
5) 轮询 registry 直到 latest==本地版本(npm staged 窗口最多 ~17 分钟)。
|
|
22
|
+
不构建 tgz、不打 tag、不推 git。
|
|
23
|
+
|
|
24
|
+
python scripts/release.py status
|
|
25
|
+
打印当前版本 / 线上 latest / 是否可发。
|
|
26
|
+
"""
|
|
27
|
+
from __future__ import annotations
|
|
28
|
+
|
|
29
|
+
import argparse
|
|
30
|
+
import json
|
|
31
|
+
import re
|
|
32
|
+
import shutil
|
|
33
|
+
import subprocess
|
|
34
|
+
import sys
|
|
35
|
+
import time
|
|
36
|
+
import urllib.request
|
|
37
|
+
from pathlib import Path
|
|
38
|
+
|
|
39
|
+
ROOT = Path(__file__).resolve().parent.parent
|
|
40
|
+
PY = sys.executable
|
|
41
|
+
REGISTRY = "https://registry.npmjs.org"
|
|
42
|
+
PKG_NAME = "lingshu-skill"
|
|
43
|
+
|
|
44
|
+
CHECKS = [
|
|
45
|
+
("manifest", ["scripts/make_manifest.py", "--check"]),
|
|
46
|
+
("sync", ["scripts/sync_engine.py", "--check"]),
|
|
47
|
+
("panel", ["scripts/panel_build.py", "--check"]),
|
|
48
|
+
("checksums", ["scripts/astrbot_plugin_lingshu/make_checksums.py", "--check"]),
|
|
49
|
+
("version", ["scripts/check_version.py"]),
|
|
50
|
+
("pressure", ["scripts/check_pressure_sync.py"]),
|
|
51
|
+
]
|
|
52
|
+
GENERATE = [
|
|
53
|
+
["scripts/sync_engine.py"],
|
|
54
|
+
["scripts/astrbot_plugin_lingshu/make_checksums.py"],
|
|
55
|
+
["scripts/make_manifest.py"],
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _run(args: list, *, capture: bool = False) -> tuple[int, str]:
|
|
60
|
+
cmd = [PY] + args
|
|
61
|
+
r = subprocess.run(cmd, cwd=ROOT, capture_output=True, text=True,
|
|
62
|
+
encoding="utf-8", errors="replace")
|
|
63
|
+
out = (r.stdout + r.stderr) if capture else ""
|
|
64
|
+
if not capture:
|
|
65
|
+
# 直接透传,用户能看见进度
|
|
66
|
+
print(r.stdout, end="")
|
|
67
|
+
if r.stderr:
|
|
68
|
+
print(r.stderr, end="", file=sys.stderr)
|
|
69
|
+
return r.returncode, out
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def cur_version() -> str:
|
|
73
|
+
t = (ROOT / "SKILL.md").read_text(encoding="utf-8-sig")
|
|
74
|
+
m = re.search(r"^version:\s*([\d.]+)", t, re.M)
|
|
75
|
+
return m.group(1) if m else ""
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _ver_tuple(v: str) -> tuple:
|
|
79
|
+
return tuple(int(x) for x in re.findall(r"\d+", v))
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def registry_latest(timeout: int = 15) -> str | None:
|
|
83
|
+
try:
|
|
84
|
+
with urllib.request.urlopen(f"{REGISTRY}/{PKG_NAME}", timeout=timeout) as r:
|
|
85
|
+
d = json.load(r)
|
|
86
|
+
return str(d.get("dist-tags", {}).get("latest", "")) or None
|
|
87
|
+
except Exception:
|
|
88
|
+
return None
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def do_bump(new_ver: str, title: str) -> int:
|
|
92
|
+
new_ver = new_ver.strip().lstrip("v")
|
|
93
|
+
if not re.fullmatch(r"\d+\.\d+", new_ver):
|
|
94
|
+
print(f"[release] 版本格式应为 X.Y,收到 {new_ver!r}", file=sys.stderr)
|
|
95
|
+
return 1
|
|
96
|
+
old = cur_version()
|
|
97
|
+
if _ver_tuple(new_ver) <= _ver_tuple(old):
|
|
98
|
+
print(f"[release] 新版本 {new_ver} 必须大于当前 {old}", file=sys.stderr)
|
|
99
|
+
return 1
|
|
100
|
+
|
|
101
|
+
# 1) 改四处版本(bytes,保 BOM/换行原样)
|
|
102
|
+
edits = [
|
|
103
|
+
("SKILL.md", f"version: {old}".encode(), f"version: {new_ver}".encode()),
|
|
104
|
+
("package.json", f'"version": "{old}.0"'.encode(), f'"version": "{new_ver}.0"'.encode()),
|
|
105
|
+
("README.md", f"**v{old}**".encode(), f"**v{new_ver}**".encode()),
|
|
106
|
+
]
|
|
107
|
+
for rel, o, n in edits:
|
|
108
|
+
p = ROOT / rel
|
|
109
|
+
b = p.read_bytes()
|
|
110
|
+
if o not in b:
|
|
111
|
+
print(f"[release] {rel} 没找到版本标记 {o!r},拒绝继续", file=sys.stderr)
|
|
112
|
+
return 1
|
|
113
|
+
p.write_bytes(b.replace(o, n, 1))
|
|
114
|
+
# CHANGELOG 首节改写为新版本(占位,正文留空由维护者补)
|
|
115
|
+
cl = ROOT / "CHANGELOG.md"
|
|
116
|
+
t = cl.read_text(encoding="utf-8")
|
|
117
|
+
first = re.search(r"^## v[\d.]+([^)]*)", t, re.M)
|
|
118
|
+
if not first:
|
|
119
|
+
print("[release] CHANGELOG.md 找不到首节标题,拒绝继续", file=sys.stderr)
|
|
120
|
+
return 1
|
|
121
|
+
today = time.strftime("%Y-%m-%d")
|
|
122
|
+
t = t[:first.start()] + f"## v{new_ver}({today})" + t[first.end():]
|
|
123
|
+
cl.write_text(t, encoding="utf-8", newline="")
|
|
124
|
+
|
|
125
|
+
# 2) 重生成派生文件
|
|
126
|
+
print(f"[release] 版本 {old} → {new_ver};重生成派生文件...")
|
|
127
|
+
for gen in GENERATE:
|
|
128
|
+
code, _ = _run(gen)
|
|
129
|
+
if code != 0:
|
|
130
|
+
print(f"[release] 生成失败:{gen}", file=sys.stderr)
|
|
131
|
+
return 1
|
|
132
|
+
|
|
133
|
+
# 3) 验证
|
|
134
|
+
return do_verify()
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def do_verify() -> int:
|
|
138
|
+
bad = []
|
|
139
|
+
for name, args in CHECKS:
|
|
140
|
+
code, _ = _run(args)
|
|
141
|
+
print(f" {name}: {'OK' if code == 0 else 'FAIL'}")
|
|
142
|
+
if code != 0:
|
|
143
|
+
bad.append(name)
|
|
144
|
+
print("[release] 行为基线...")
|
|
145
|
+
code, _ = _run(["scripts/behavior_baseline.py", "check"])
|
|
146
|
+
print(f" baseline: {'OK' if code == 0 else 'FAIL'}")
|
|
147
|
+
if code != 0:
|
|
148
|
+
bad.append("baseline")
|
|
149
|
+
print("[release] 全量测试...")
|
|
150
|
+
code, _ = _run(["scripts/run_tests.py"])
|
|
151
|
+
print(f" tests: {'OK' if code == 0 else 'FAIL'}")
|
|
152
|
+
if code != 0:
|
|
153
|
+
bad.append("tests")
|
|
154
|
+
if bad:
|
|
155
|
+
print(f"[release] 验证失败:{', '.join(bad)}", file=sys.stderr)
|
|
156
|
+
return 1
|
|
157
|
+
print("[release] 全部验证通过 ✔")
|
|
158
|
+
return 0
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def do_publish(wait_minutes: int) -> int:
|
|
162
|
+
# npm 版本是 X.Y.0(package.json),registry 的 latest 也是 X.Y.0——
|
|
163
|
+
# 必须用这个格式比较;用 SKILL.md 的 X.Y 会永远匹配不上 staged 轮询目标。
|
|
164
|
+
ver = json.loads((ROOT / "package.json").read_text(encoding="utf-8-sig"))["version"]
|
|
165
|
+
if do_verify() != 0:
|
|
166
|
+
return 1
|
|
167
|
+
npm = shutil.which("npm") or shutil.which("npm.cmd")
|
|
168
|
+
if not npm:
|
|
169
|
+
print("[release] 找不到 npm 命令", file=sys.stderr)
|
|
170
|
+
return 1
|
|
171
|
+
who = subprocess.run([npm, "whoami"], cwd=ROOT, capture_output=True, text=True,
|
|
172
|
+
encoding="utf-8", errors="replace").stdout.strip()
|
|
173
|
+
if not who:
|
|
174
|
+
print("[release] npm 未登录(npm whoami 无输出)", file=sys.stderr)
|
|
175
|
+
return 1
|
|
176
|
+
online = registry_latest()
|
|
177
|
+
if online and _ver_tuple(online) >= _ver_tuple(ver):
|
|
178
|
+
print(f"[release] 线上 latest={online} >= 本地 {ver},无需重复发布", file=sys.stderr)
|
|
179
|
+
return 1
|
|
180
|
+
print(f"[release] npm 发布 {PKG_NAME}@{ver}(登录用户 {who};线上 {online or '无'})...")
|
|
181
|
+
r = subprocess.run([npm, "publish"], cwd=ROOT)
|
|
182
|
+
if r.returncode != 0:
|
|
183
|
+
print("[release] npm publish 失败", file=sys.stderr)
|
|
184
|
+
return 1
|
|
185
|
+
# staged 窗口轮询
|
|
186
|
+
deadline = time.time() + wait_minutes * 60
|
|
187
|
+
while time.time() < deadline:
|
|
188
|
+
latest = registry_latest()
|
|
189
|
+
if latest == ver:
|
|
190
|
+
print(f"[release] 已可见:{PKG_NAME}@{latest}(latest)✔")
|
|
191
|
+
return 0
|
|
192
|
+
print(f" staged 窗口:latest={latest},等待可见(目标 {ver})...")
|
|
193
|
+
time.sleep(20)
|
|
194
|
+
print(f"[release] 超时({wait_minutes} 分钟)仍不可见,请手动查 registry", file=sys.stderr)
|
|
195
|
+
return 1
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def do_status() -> int:
|
|
199
|
+
ver = cur_version()
|
|
200
|
+
online = registry_latest()
|
|
201
|
+
pkg = json.loads((ROOT / "package.json").read_text(encoding="utf-8-sig"))["version"]
|
|
202
|
+
print(f" 本地 SKILL: {ver} package.json: {pkg}")
|
|
203
|
+
print(f" 线上 latest: {online or '查询失败'}")
|
|
204
|
+
if online:
|
|
205
|
+
print(" 可发布:" , "是" if _ver_tuple(ver) > _ver_tuple(online) else "否(线上已 >= 本地)")
|
|
206
|
+
return 0
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def main() -> int:
|
|
210
|
+
ap = argparse.ArgumentParser(description="灵枢发版自动化")
|
|
211
|
+
sub = ap.add_subparsers(dest="action", required=True)
|
|
212
|
+
p_bump = sub.add_parser("bump", help="升版本+重生成+验证")
|
|
213
|
+
p_bump.add_argument("version", help="新版本 X.Y")
|
|
214
|
+
p_bump.add_argument("title", nargs="?", default="", help="CHANGELOG 小节标题(可选)")
|
|
215
|
+
p_pub = sub.add_parser("publish", help="校验后 npm publish 并等 staged 可见")
|
|
216
|
+
p_pub.add_argument("--wait", type=int, default=20, help="staged 可见轮询最长分钟数(默认20)")
|
|
217
|
+
sub.add_parser("status", help="查看本地/线上版本")
|
|
218
|
+
args = ap.parse_args()
|
|
219
|
+
if args.action == "bump":
|
|
220
|
+
return do_bump(args.version, args.title)
|
|
221
|
+
if args.action == "publish":
|
|
222
|
+
return do_publish(getattr(args, "wait", 20))
|
|
223
|
+
return do_status()
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
if __name__ == "__main__":
|
|
227
|
+
sys.exit(main())
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""灵枢发版自动化(把台账第四节的发布流程串成一条命令)。
|
|
4
|
+
|
|
5
|
+
子命令
|
|
6
|
+
------
|
|
7
|
+
python scripts/release.py bump <X.Y> ["小节标题"]
|
|
8
|
+
1) 校验新版本 > 当前版本;
|
|
9
|
+
2) 改四处版本:SKILL.md / package.json(X.Y.0) / README.md / CHANGELOG 首节占位;
|
|
10
|
+
3) 按依赖序重生成:sync_engine → make_checksums → make_manifest;
|
|
11
|
+
4) 跑六项检查 + 行为基线 + 全量测试,全绿才成功。
|
|
12
|
+
不做 git 提交/tag/push(用户明确不做 tag/push,提交仍按"一个版本一个提交"手工或另配)。
|
|
13
|
+
注意:若有新代码文件(如本脚本自己)尚未 git add,manifest --check 会拒绝——
|
|
14
|
+
这是既有门禁,先 git add 新文件再 bump,脚本不替你决定哪些文件入库。
|
|
15
|
+
|
|
16
|
+
python scripts/release.py publish
|
|
17
|
+
1) 校验版本四处一致(check_version)+ 六项检查全绿;
|
|
18
|
+
2) npm whoami 确认登录;
|
|
19
|
+
3) 确认包版本比线上大(避免 E409 重复发);
|
|
20
|
+
4) npm publish;
|
|
21
|
+
5) 轮询 registry 直到 latest==本地版本(npm staged 窗口最多 ~17 分钟)。
|
|
22
|
+
不构建 tgz、不打 tag、不推 git。
|
|
23
|
+
|
|
24
|
+
python scripts/release.py status
|
|
25
|
+
打印当前版本 / 线上 latest / 是否可发。
|
|
26
|
+
"""
|
|
27
|
+
from __future__ import annotations
|
|
28
|
+
|
|
29
|
+
import argparse
|
|
30
|
+
import json
|
|
31
|
+
import re
|
|
32
|
+
import shutil
|
|
33
|
+
import subprocess
|
|
34
|
+
import sys
|
|
35
|
+
import time
|
|
36
|
+
import urllib.request
|
|
37
|
+
from pathlib import Path
|
|
38
|
+
|
|
39
|
+
ROOT = Path(__file__).resolve().parent.parent
|
|
40
|
+
PY = sys.executable
|
|
41
|
+
REGISTRY = "https://registry.npmjs.org"
|
|
42
|
+
PKG_NAME = "lingshu-skill"
|
|
43
|
+
|
|
44
|
+
CHECKS = [
|
|
45
|
+
("manifest", ["scripts/make_manifest.py", "--check"]),
|
|
46
|
+
("sync", ["scripts/sync_engine.py", "--check"]),
|
|
47
|
+
("panel", ["scripts/panel_build.py", "--check"]),
|
|
48
|
+
("checksums", ["scripts/astrbot_plugin_lingshu/make_checksums.py", "--check"]),
|
|
49
|
+
("version", ["scripts/check_version.py"]),
|
|
50
|
+
("pressure", ["scripts/check_pressure_sync.py"]),
|
|
51
|
+
]
|
|
52
|
+
GENERATE = [
|
|
53
|
+
["scripts/sync_engine.py"],
|
|
54
|
+
["scripts/astrbot_plugin_lingshu/make_checksums.py"],
|
|
55
|
+
["scripts/make_manifest.py"],
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _run(args: list, *, capture: bool = False) -> tuple[int, str]:
|
|
60
|
+
cmd = [PY] + args
|
|
61
|
+
r = subprocess.run(cmd, cwd=ROOT, capture_output=True, text=True,
|
|
62
|
+
encoding="utf-8", errors="replace")
|
|
63
|
+
out = (r.stdout + r.stderr) if capture else ""
|
|
64
|
+
if not capture:
|
|
65
|
+
# 直接透传,用户能看见进度
|
|
66
|
+
print(r.stdout, end="")
|
|
67
|
+
if r.stderr:
|
|
68
|
+
print(r.stderr, end="", file=sys.stderr)
|
|
69
|
+
return r.returncode, out
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def cur_version() -> str:
|
|
73
|
+
t = (ROOT / "SKILL.md").read_text(encoding="utf-8-sig")
|
|
74
|
+
m = re.search(r"^version:\s*([\d.]+)", t, re.M)
|
|
75
|
+
return m.group(1) if m else ""
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _ver_tuple(v: str) -> tuple:
|
|
79
|
+
return tuple(int(x) for x in re.findall(r"\d+", v))
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def registry_latest(timeout: int = 15) -> str | None:
|
|
83
|
+
try:
|
|
84
|
+
with urllib.request.urlopen(f"{REGISTRY}/{PKG_NAME}", timeout=timeout) as r:
|
|
85
|
+
d = json.load(r)
|
|
86
|
+
return str(d.get("dist-tags", {}).get("latest", "")) or None
|
|
87
|
+
except Exception:
|
|
88
|
+
return None
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def do_bump(new_ver: str, title: str) -> int:
|
|
92
|
+
new_ver = new_ver.strip().lstrip("v")
|
|
93
|
+
if not re.fullmatch(r"\d+\.\d+", new_ver):
|
|
94
|
+
print(f"[release] 版本格式应为 X.Y,收到 {new_ver!r}", file=sys.stderr)
|
|
95
|
+
return 1
|
|
96
|
+
old = cur_version()
|
|
97
|
+
if _ver_tuple(new_ver) <= _ver_tuple(old):
|
|
98
|
+
print(f"[release] 新版本 {new_ver} 必须大于当前 {old}", file=sys.stderr)
|
|
99
|
+
return 1
|
|
100
|
+
|
|
101
|
+
# 1) 改四处版本(bytes,保 BOM/换行原样)
|
|
102
|
+
edits = [
|
|
103
|
+
("SKILL.md", f"version: {old}".encode(), f"version: {new_ver}".encode()),
|
|
104
|
+
("package.json", f'"version": "{old}.0"'.encode(), f'"version": "{new_ver}.0"'.encode()),
|
|
105
|
+
("README.md", f"**v{old}**".encode(), f"**v{new_ver}**".encode()),
|
|
106
|
+
]
|
|
107
|
+
for rel, o, n in edits:
|
|
108
|
+
p = ROOT / rel
|
|
109
|
+
b = p.read_bytes()
|
|
110
|
+
if o not in b:
|
|
111
|
+
print(f"[release] {rel} 没找到版本标记 {o!r},拒绝继续", file=sys.stderr)
|
|
112
|
+
return 1
|
|
113
|
+
p.write_bytes(b.replace(o, n, 1))
|
|
114
|
+
# CHANGELOG 首节改写为新版本(占位,正文留空由维护者补)
|
|
115
|
+
cl = ROOT / "CHANGELOG.md"
|
|
116
|
+
t = cl.read_text(encoding="utf-8")
|
|
117
|
+
first = re.search(r"^## v[\d.]+([^)]*)", t, re.M)
|
|
118
|
+
if not first:
|
|
119
|
+
print("[release] CHANGELOG.md 找不到首节标题,拒绝继续", file=sys.stderr)
|
|
120
|
+
return 1
|
|
121
|
+
today = time.strftime("%Y-%m-%d")
|
|
122
|
+
t = t[:first.start()] + f"## v{new_ver}({today})" + t[first.end():]
|
|
123
|
+
cl.write_text(t, encoding="utf-8", newline="")
|
|
124
|
+
|
|
125
|
+
# 2) 重生成派生文件
|
|
126
|
+
print(f"[release] 版本 {old} → {new_ver};重生成派生文件...")
|
|
127
|
+
for gen in GENERATE:
|
|
128
|
+
code, _ = _run(gen)
|
|
129
|
+
if code != 0:
|
|
130
|
+
print(f"[release] 生成失败:{gen}", file=sys.stderr)
|
|
131
|
+
return 1
|
|
132
|
+
|
|
133
|
+
# 3) 验证
|
|
134
|
+
return do_verify()
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def do_verify() -> int:
|
|
138
|
+
bad = []
|
|
139
|
+
for name, args in CHECKS:
|
|
140
|
+
code, _ = _run(args)
|
|
141
|
+
print(f" {name}: {'OK' if code == 0 else 'FAIL'}")
|
|
142
|
+
if code != 0:
|
|
143
|
+
bad.append(name)
|
|
144
|
+
print("[release] 行为基线...")
|
|
145
|
+
code, _ = _run(["scripts/behavior_baseline.py", "check"])
|
|
146
|
+
print(f" baseline: {'OK' if code == 0 else 'FAIL'}")
|
|
147
|
+
if code != 0:
|
|
148
|
+
bad.append("baseline")
|
|
149
|
+
print("[release] 全量测试...")
|
|
150
|
+
code, _ = _run(["scripts/run_tests.py"])
|
|
151
|
+
print(f" tests: {'OK' if code == 0 else 'FAIL'}")
|
|
152
|
+
if code != 0:
|
|
153
|
+
bad.append("tests")
|
|
154
|
+
if bad:
|
|
155
|
+
print(f"[release] 验证失败:{', '.join(bad)}", file=sys.stderr)
|
|
156
|
+
return 1
|
|
157
|
+
print("[release] 全部验证通过 ✔")
|
|
158
|
+
return 0
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def do_publish(wait_minutes: int) -> int:
|
|
162
|
+
# npm 版本是 X.Y.0(package.json),registry 的 latest 也是 X.Y.0——
|
|
163
|
+
# 必须用这个格式比较;用 SKILL.md 的 X.Y 会永远匹配不上 staged 轮询目标。
|
|
164
|
+
ver = json.loads((ROOT / "package.json").read_text(encoding="utf-8-sig"))["version"]
|
|
165
|
+
if do_verify() != 0:
|
|
166
|
+
return 1
|
|
167
|
+
npm = shutil.which("npm") or shutil.which("npm.cmd")
|
|
168
|
+
if not npm:
|
|
169
|
+
print("[release] 找不到 npm 命令", file=sys.stderr)
|
|
170
|
+
return 1
|
|
171
|
+
who = subprocess.run([npm, "whoami"], cwd=ROOT, capture_output=True, text=True,
|
|
172
|
+
encoding="utf-8", errors="replace").stdout.strip()
|
|
173
|
+
if not who:
|
|
174
|
+
print("[release] npm 未登录(npm whoami 无输出)", file=sys.stderr)
|
|
175
|
+
return 1
|
|
176
|
+
online = registry_latest()
|
|
177
|
+
if online and _ver_tuple(online) >= _ver_tuple(ver):
|
|
178
|
+
print(f"[release] 线上 latest={online} >= 本地 {ver},无需重复发布", file=sys.stderr)
|
|
179
|
+
return 1
|
|
180
|
+
print(f"[release] npm 发布 {PKG_NAME}@{ver}(登录用户 {who};线上 {online or '无'})...")
|
|
181
|
+
r = subprocess.run([npm, "publish"], cwd=ROOT)
|
|
182
|
+
if r.returncode != 0:
|
|
183
|
+
print("[release] npm publish 失败", file=sys.stderr)
|
|
184
|
+
return 1
|
|
185
|
+
# staged 窗口轮询
|
|
186
|
+
deadline = time.time() + wait_minutes * 60
|
|
187
|
+
while time.time() < deadline:
|
|
188
|
+
latest = registry_latest()
|
|
189
|
+
if latest == ver:
|
|
190
|
+
print(f"[release] 已可见:{PKG_NAME}@{latest}(latest)✔")
|
|
191
|
+
return 0
|
|
192
|
+
print(f" staged 窗口:latest={latest},等待可见(目标 {ver})...")
|
|
193
|
+
time.sleep(20)
|
|
194
|
+
print(f"[release] 超时({wait_minutes} 分钟)仍不可见,请手动查 registry", file=sys.stderr)
|
|
195
|
+
return 1
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def do_status() -> int:
|
|
199
|
+
ver = cur_version()
|
|
200
|
+
online = registry_latest()
|
|
201
|
+
pkg = json.loads((ROOT / "package.json").read_text(encoding="utf-8-sig"))["version"]
|
|
202
|
+
print(f" 本地 SKILL: {ver} package.json: {pkg}")
|
|
203
|
+
print(f" 线上 latest: {online or '查询失败'}")
|
|
204
|
+
if online:
|
|
205
|
+
print(" 可发布:" , "是" if _ver_tuple(ver) > _ver_tuple(online) else "否(线上已 >= 本地)")
|
|
206
|
+
return 0
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def main() -> int:
|
|
210
|
+
ap = argparse.ArgumentParser(description="灵枢发版自动化")
|
|
211
|
+
sub = ap.add_subparsers(dest="action", required=True)
|
|
212
|
+
p_bump = sub.add_parser("bump", help="升版本+重生成+验证")
|
|
213
|
+
p_bump.add_argument("version", help="新版本 X.Y")
|
|
214
|
+
p_bump.add_argument("title", nargs="?", default="", help="CHANGELOG 小节标题(可选)")
|
|
215
|
+
p_pub = sub.add_parser("publish", help="校验后 npm publish 并等 staged 可见")
|
|
216
|
+
p_pub.add_argument("--wait", type=int, default=20, help="staged 可见轮询最长分钟数(默认20)")
|
|
217
|
+
sub.add_parser("status", help="查看本地/线上版本")
|
|
218
|
+
args = ap.parse_args()
|
|
219
|
+
if args.action == "bump":
|
|
220
|
+
return do_bump(args.version, args.title)
|
|
221
|
+
if args.action == "publish":
|
|
222
|
+
return do_publish(getattr(args, "wait", 20))
|
|
223
|
+
return do_status()
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
if __name__ == "__main__":
|
|
227
|
+
sys.exit(main())
|