gongwen-skill 2.5.0 → 2.6.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 CHANGED
@@ -4,6 +4,20 @@
4
4
  Licensed under the MIT License. See the LICENSE file for details.
5
5
  -->
6
6
 
7
+ ## v2.6.0 (2026-09-02)
8
+
9
+ ### Added
10
+ - **check-update 判定渠道精简为 PyPI + GitHub 双权威源**:对齐 EasyTier 单权威源 + 加速代理设计,GitCode/AtomGit 不再参与版本判定(零增量镜像),降为 GitHub 不可达时的国内拉取镜像提示;--json 输出新增 mirrors 字段
11
+ - **GitHub 国内访问优化**:并发查询 + 分级超时(PyPI 10s / GitHub 8s 快速降级),GitHub 不可达时提示 GitHub520 hosts 方案与国内镜像地址
12
+ - **发布流程修复(三平台 Release 统一编号)**:ci.yml 新增 release job,tag 推送自动创建 GitHub Release(编号 = tag);RELEASE.md 发布流程新增 GitHub Release 自动创建 + GitCode/AtomGit Release 同步(编号与 tag 统一)
13
+ - **非必要文件不同步原则写入发布流程**:RELEASE.md 明确临时/调试文件(tmp_*、_gw_* 等)不提交、不入库、不同步三仓库
14
+
15
+ ### Changed
16
+ - check-update 头部与末尾文案同步为 PyPI + GitHub 判定;--json 的 channels 字段只含 PyPI/GitHub
17
+ - README / RELEASE.md 文档同步更新(判定渠道、镜像提示、Release 统一编号说明)
18
+
19
+ ### Fixed
20
+ - 历史遗留:v2.0.0~v2.5.0 在 GitHub/GitCode 从未创建 Release 对象(仅 tag),已补建且编号与 tag 统一
7
21
  ## v2.5.0 (2026-09-01)
8
22
 
9
23
  ### Added
package/README.md CHANGED
@@ -45,7 +45,7 @@ Licensed under the MIT License. See the LICENSE file for details.
45
45
  | 🔍 审稿生成 | `review` | 按五角色审稿机制生成审稿意见 |
46
46
  | 🧩 完整审校 | `full-review` | 修订+批注联合命令(句子级差异修订 + 分类批注) |
47
47
  | 🎨 样式学习 | `style-learn` / `style-list` | 上传标准文档学习 Run/段落/页面三级样式(字体/字号/字间距/行距/缩进/页边距),生成命名模板持久化,后续用 `optimize -t 模板名` 套用 |
48
- | 🔄 版本自检 | `check-update` | 多渠道版本自检(GitHub/GitCode/AtomGit 三仓库比对取最新) |
48
+ | 🔄 版本自检 | `check-update` | 版本自检(PyPI + GitHub 双判定渠道,GitCode/AtomGit 作国内镜像提示) |
49
49
  | 🩺 自我诊断 | `doctor` / `repair` | 全面诊断 22 项(Python/依赖/版本一致性/字体/DSH 文件/DSH 技能 frontmatter/代码风格),自动修复常见问题 |
50
50
  | 🕵️ 文档审计 | `audit` | 检查删除线/加粗/AI 声明等痕迹 |
51
51
  | 🤝 会话交接 | `handoff` | 跨会话上下文传递(`--list` / `--latest` / Agent 长任务收尾必写) |
@@ -150,7 +150,7 @@ python -m gongwen footer 红头公文.docx --cc "各单位" --printer "XX办公
150
150
  # 注入页码(Word PAGE 域动态页码)
151
151
  python -m gongwen pagenum 红头公文.docx --alignment right
152
152
 
153
- # 多渠道版本自检
153
+ # 版本自检(PyPI + GitHub 双判定渠道)
154
154
  python -m gongwen check-update
155
155
 
156
156
  # 安装公文标准字体(方正小标宋简体/仿宋_GB2312/楷体_GB2312)
@@ -317,7 +317,7 @@ python -m gongwen rule-list notice
317
317
 
318
318
  Agent 加载 skill 后**必须执行版本追新自检**,确保使用最新版本:
319
319
 
320
- 1. **多渠道远程自检**(首选):`python -m gongwen check-update`——自动查询 GitHub/GitCode/AtomGit 三仓库最新 tag,取最高版本比对本地;任一渠道可达即不遗漏,全部不可达时明确告知"版本自检跳过"
320
+ 1. **远程自检**(首选):`python -m gongwen check-update`——以 **PyPI(发布源)+ GitHub(代码权威源)双判定渠道**并发查询,取最高版本比对本地;任一判定渠道可达即不遗漏,全部不可达时明确告知"版本自检跳过"。GitHub 为海外渠道(国内常超时)采用短超时快速降级;GitHub 不可达时自动提示国内代码镜像(GitCode/AtomGit,与 GitHub 同源 tag)与 GitHub520 hosts 加速方案
321
321
  2. **本地 git tag 对比**(补充):对 skill 安装目录执行 `git -C "<skill安装目录>" describe --tags --abbrev=0`;若安装目录不在 git 管理下,应告知用户"无法执行版本对比,建议手动检查 GitHub 更新"
322
322
  3. **落后则警告**:发现本地版本落后于最新 tag 时,**必须在执行前警告用户**并提示更新(`cd <gongwen-skill目录> && git pull && git fetch --tags`),不得静默使用旧版本
323
323
 
@@ -337,7 +337,7 @@ DSH 采用 **Cordis 模块化微内核架构**:技能体系基于本地文件
337
337
  git clone https://github.com/linhut/gongwen-skill.git
338
338
  cd gongwen-skill
339
339
  pip install -r requirements.txt # 或 pip install gongwen-skill(已上 PyPI)
340
- python -m gongwen --version # 检验:gongwen-skill v2.5.0
340
+ python -m gongwen --version # 检验:gongwen-skill v2.6.0
341
341
  ```
342
342
 
343
343
  ### 方式一:作为 DSH Skill 注册(基于本地文件系统)
@@ -393,7 +393,7 @@ pnpm add -w gongwen-skill
393
393
  "dependencies": {
394
394
  "@deepseek-ai/dsh-base": "...",
395
395
  "@deepseek-ai/dsh-web-app": "...",
396
- "gongwen-skill": "^2.5.0"
396
+ "gongwen-skill": "^2.6.0"
397
397
  },
398
398
  "dsh": {
399
399
  "profile": {
@@ -448,9 +448,9 @@ dsh --profile web
448
448
  | CLI 独立可执行(`python -m gongwen <命令>`) | ✅ |
449
449
  | PyPI 上架(`pip install gongwen-skill`) | ✅ |
450
450
  | 零外部运行时依赖(仅 python-docx/pydantic/pyyaml) | ✅ |
451
- | DSH 配置化排版参数(页边距/行距/字体/默认模板版本) | ✅ v2.5.0+ |
451
+ | DSH 配置化排版参数(页边距/行距/字体/默认模板版本) | ✅ v2.6.0+ |
452
452
 
453
- ### DSH 插件配置化(v2.5.0+)
453
+ ### DSH 插件配置化(v2.6.0+)
454
454
 
455
455
  DSH 插件支持通过配置文件管理排版参数,Agent 调用时自动注入,纯 CLI 用户不受影响。
456
456
 
@@ -574,7 +574,7 @@ pip install -r requirements.txt
574
574
  用户:帮我优化这份会议通知的第二章节措辞
575
575
 
576
576
  Agent:📋 合规自检报告
577
- Skill 版本: v2.5.0(多渠道自检已确认最新)
577
+ Skill 版本: v2.6.0(版本自检已确认最新)
578
578
  路径判定: B(内容优化)
579
579
  依据: 用户指定了已有文档,且要求"优化措辞"
580
580
  命令调用: 1. python -m gongwen optimize-content 会议通知.docx --changes changes.json --apply --paragraphs "5-8"
package/dsh/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // 公文全流程处理工具 - DSH plugin bridge (gongwen-skill, v2.5.0+)
1
+ // 公文全流程处理工具 - DSH plugin bridge (gongwen-skill, v2.6.0+)
2
2
  // (c) 2026 Jose AI (https://www.linhut.cn)
3
3
  // https://github.com/linhut/gongwen-skill
4
4
  // Licensed under the MIT License. See the LICENSE file for details.
@@ -7,7 +7,7 @@
7
7
  #
8
8
  # 公文全流程处理工具 - gongwen-skill Python package
9
9
 
10
- __version__ = "2.5.0"
10
+ __version__ = "2.6.0"
11
11
 
12
12
  # Re-export everything from the legacy module for backward compatibility
13
13
  # This allows: from gongwen import main, cmd_check, etc.
@@ -45,7 +45,7 @@ from gongwen.cli.helpers import (
45
45
  parse_config_overrides as _parse_config_overrides,
46
46
  load_rules_with_overrides as _load_rules_with_overrides,
47
47
  )
48
- __version__ = "2.5.0"
48
+ __version__ = "2.6.0"
49
49
  # 版本号应与 gongwen/__init__.py 保持一致,每次发版同步更新
50
50
  """
51
51
  中文公文全流程处理工具 —— 基于 GB/T 9704《党政机关公文格式》国家标准。
@@ -857,7 +857,7 @@ _STYLE_DEVIATION_HINTS = {
857
857
  # _VALID_STYLES 已迁移到 gongwen/cli/style_helpers.py
858
858
 
859
859
 
860
- # 官方镜像仓库(多渠道版本自检用)
860
+ # 官方镜像仓库(GitHub 为 check-update 判定渠道,GitCode/AtomGit 作国内镜像)
861
861
  # PyPI JSON API(无需 git,pip 用户首选渠道)
862
862
  # ---------------------------------------------------------------------------
863
863
  # 字体管理(install/list/check)
@@ -1076,8 +1076,8 @@ def main():
1076
1076
  p = sub.add_parser("style-list", help="列出所有通过 style-learn 学习的自定义样式模板")
1077
1077
  p.set_defaults(func=cmd_style_list)
1078
1078
 
1079
- # ---- 多渠道版本自检(PyPI/GitHub/GitCode/AtomGit 比对取最新) ----
1080
- p = sub.add_parser("check-update", help="多渠道版本自检:查询 PyPI/GitHub/GitCode/AtomGit 四渠道最新版本,取最高版本比对本地")
1079
+ # ---- 版本自检(PyPI + GitHub 双判定渠道,GitCode/AtomGit 作国内镜像) ----
1080
+ p = sub.add_parser("check-update", help="版本自检:PyPI + GitHub 双判定渠道比对本地版本(GitCode/AtomGit 作国内镜像提示)")
1081
1081
  p.add_argument("--json", action="store_true",
1082
1082
  help="输出 JSON 格式结果(便于 Agent 解析)")
1083
1083
  p.set_defaults(func=cmd_check_update)
@@ -38,7 +38,7 @@ TYPE_KEYWORDS = {
38
38
  "讲话稿": "speech", "主持词": "speech", "新闻稿": "news", "简报": "news",
39
39
  }
40
40
 
41
- # 官方镜像仓库(多渠道版本自检用)
41
+ # 官方镜像仓库(GitHub 为 check-update 判定渠道,GitCode/AtomGit 作国内镜像)
42
42
  REPO_MIRRORS = {
43
43
  "GitHub": "https://github.com/linhut/gongwen-skill.git",
44
44
  "GitCode": "https://gitcode.com/linhut/gongwen-skill.git",
@@ -57,11 +57,45 @@ def _latest_tag_from_remote(remote_url: str, timeout: int = 15) -> tuple[bool, s
57
57
  return False, str(e)[:120]
58
58
 
59
59
 
60
+ # 判定渠道(版本从哪来):
61
+ # - PyPI :发布源(pip 用户首选,国内有镜像)
62
+ # - GitHub :代码仓库权威源(git 用户,CI 触发源)
63
+ # GitCode/AtomGit 与 GitHub 是同一份 tag 的镜像(发布时同步 push),
64
+ # 参与版本判定零增量,不列为判定渠道;仅在 GitHub 不可达时作为
65
+ # 国内拉取/加速代理提示(参考 EasyTier「单权威源 + 加速代理」设计)。
66
+ _JUDGMENT_CHANNELS = ("PyPI", "GitHub")
67
+
68
+ # 渠道分级超时(秒):GitHub 为海外渠道,国内常超时,用短超时快速降级;
69
+ # PyPI 有国内镜像 CDN,可用较长超时。
70
+ _CHANNEL_TIMEOUTS = {
71
+ "PyPI": 10,
72
+ "GitHub": 8,
73
+ }
74
+
75
+ # 国内代码镜像(加速代理层,非判定渠道):GitHub 不可达时的 git 拉取替代。
76
+ # 从 REPO_MIRRORS 派生(排除 GitHub),避免 URL 重复维护。
77
+ _GIT_MIRRORS = {k: v for k, v in REPO_MIRRORS.items() if k != "GitHub"}
78
+
79
+
80
+ def _fetch_channel(name: str, url: str | None, timeout: int) -> tuple[str, bool, str]:
81
+ """查询单个渠道,返回 (渠道名, 是否成功, 版本或错误信息)。
82
+
83
+ 在线程池中执行;内部已捕获异常,不会向外抛出。
84
+ """
85
+ if name == "PyPI":
86
+ ok, val = _latest_version_from_pypi(timeout=timeout)
87
+ else:
88
+ ok, val = _latest_tag_from_remote(url, timeout=timeout)
89
+ return name, ok, val
90
+
91
+
60
92
  def cmd_check_update(args):
61
- """多渠道版本自检:查询 PyPI/GitHub/GitCode/AtomGit 四渠道最新版本,取最高版本比对本地。
93
+ """版本自检:以 PyPI + GitHub 双判定渠道取最高版本比对本地。
62
94
 
63
- 渠道优先级:PyPI(pip 用户首选)> GitHub > GitCode > AtomGit
64
- 全部不可达时明确告知并返回退出码 2。
95
+ 判定渠道:PyPI(发布源,pip 用户首选)+ GitHub(代码仓库权威源,CI 触发源)。
96
+ GitCode/AtomGit 与 GitHub 同步同 tag,不参与版本判定(零增量),
97
+ 仅在 GitHub 不可达时作为国内拉取镜像提示(JSON 输出于 mirrors 字段)。
98
+ 全部判定渠道不可达时明确告知并返回退出码 2。
65
99
  支持 --json 输出结构化结果,便于 Agent 解析。
66
100
  """
67
101
  import json as _json
@@ -71,36 +105,40 @@ def cmd_check_update(args):
71
105
  local_ver = __version__
72
106
 
73
107
  if not use_json:
74
- print(f"🔍 版本自检(多渠道,本地 v{local_ver})")
108
+ print(f"🔍 版本自检(PyPI + GitHub 判定,本地 v{local_ver})")
75
109
  print(f"{'─' * 50}")
76
110
 
77
111
  results: dict[str, str] = {}
78
112
  ok_count = 0
79
113
 
80
- # 渠道1:PyPI(无需 git,pip 用户首选)
81
- ok, val = _latest_version_from_pypi()
82
- if ok:
83
- results["PyPI"] = val
84
- ok_count += 1
85
- if not use_json:
86
- print(f" ✅ PyPI 最新: {val}")
87
- else:
88
- results["PyPI"] = ""
89
- if not use_json:
90
- print(f" ⚠️ PyPI 不可达: {val}")
91
-
92
- # 渠道2-4:Git 仓库
93
- for name, url in REPO_MIRRORS.items():
94
- ok, val = _latest_tag_from_remote(url)
95
- if ok:
96
- results[name] = val
97
- ok_count += 1
98
- if not use_json:
99
- print(f" ✅ {name:<8} 最新: {val}")
100
- else:
101
- results[name] = ""
102
- if not use_json:
103
- print(f" ⚠️ {name:<8} 不可达: {val}")
114
+ # 判定渠道并发查询:PyPI(发布源)+ GitHub(代码权威源)。
115
+ # 两渠道并发,总耗时 = 最坏单渠道超时(GitHub 短超时快速降级)。
116
+ from concurrent.futures import ThreadPoolExecutor
117
+ channels = [
118
+ (name, REPO_MIRRORS[name] if name in REPO_MIRRORS else None)
119
+ for name in _JUDGMENT_CHANNELS
120
+ ]
121
+ with ThreadPoolExecutor(max_workers=len(channels)) as pool:
122
+ futures = [pool.submit(_fetch_channel, name, url, _CHANNEL_TIMEOUTS[name])
123
+ for name, url in channels]
124
+ for fut in futures:
125
+ name, ok, val = fut.result()
126
+ if ok:
127
+ results[name] = val
128
+ ok_count += 1
129
+ if not use_json:
130
+ print(f" ✅ {name:<8} 最新: {val}")
131
+ else:
132
+ results[name] = ""
133
+ if not use_json:
134
+ print(f" ⚠️ {name:<8} 不可达: {val}")
135
+
136
+ # GitHub 海外渠道不可达时,给出国内加速指引(EasyTier 式加速代理 + GitHub520 hosts)
137
+ if not use_json and results.get("GitHub", "") == "" and ok_count > 0:
138
+ print(" 💡 国内访问 GitHub 常超时,可用国内代码镜像:")
139
+ for _name, _url in _GIT_MIRRORS.items():
140
+ print(f" - {_name}: {_url}")
141
+ print(" 或参考 GitHub520 hosts 加速方案:https://github.com/521xueweihan/GitHub520")
104
142
 
105
143
  if not use_json:
106
144
  print(f"{'─' * 50}")
@@ -111,18 +149,22 @@ def cmd_check_update(args):
111
149
  print(" ⚠️ 版本自检因无法访问远程而跳过,本地版本可能不是最新")
112
150
  print(" 💡 拉取地址:")
113
151
  print(" - PyPI: pip install --upgrade gongwen-skill")
114
- for name, url in REPO_MIRRORS.items():
152
+ for name in _JUDGMENT_CHANNELS:
153
+ if name == "PyPI":
154
+ continue
155
+ print(f" - {name}: {REPO_MIRRORS[name]}")
156
+ for name, url in _GIT_MIRRORS.items():
115
157
  print(f" - {name}: {url}")
116
158
  return 2
117
159
 
118
- # 取多渠道中的最高版本
160
+ # 取判定渠道中的最高版本
119
161
  valid = [v for v in results.values() if v]
120
162
  latest = max(valid, key=_parse_version)
121
163
 
122
164
  # 判断安装方式(用于给出对应的更新命令)
123
165
  # pip 安装的用户应使用 pip install --upgrade,git clone 的用户应使用 git pull
124
166
  pypi_ok = bool(results.get("PyPI"))
125
- git_ok = any(results.get(name) for name in REPO_MIRRORS)
167
+ git_ok = bool(results.get("GitHub"))
126
168
 
127
169
  has_update = _parse_version(latest) > _parse_version(local_ver)
128
170
 
@@ -136,6 +178,7 @@ def cmd_check_update(args):
136
178
  name: {"reachable": bool(v), "version": v.lstrip("v") if v else None}
137
179
  for name, v in results.items()
138
180
  },
181
+ "mirrors": {name: url for name, url in _GIT_MIRRORS.items()},
139
182
  "reachable_channels": ok_count,
140
183
  "elapsed_seconds": round(time.time() - t0, 1),
141
184
  }
@@ -153,7 +196,10 @@ def cmd_check_update(args):
153
196
  print(f"⏱️ 自检耗时 {time.time() - t0:.1f}s")
154
197
  return 1
155
198
  elif _parse_version(latest) == _parse_version(local_ver):
156
- print(f"✅ 已是最新版本:v{local_ver}(多渠道一致)")
199
+ if ok_count >= 2:
200
+ print(f"✅ 已是最新版本:v{local_ver}(PyPI 与 GitHub 一致)")
201
+ else:
202
+ print(f"✅ 已是最新版本:v{local_ver}(单渠道确认)")
157
203
  else:
158
204
  print(f"ℹ️ 本地版本 v{local_ver} 高于远程 {latest}(本地领先或渠道不同步)")
159
205
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gongwen-skill",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "公文全流程处理工具 - GB/T 9704 格式检查/修复/内容优化/模板生成/版式注入",
5
5
  "type": "module",
6
6
  "main": "dsh/index.js",
@@ -201,7 +201,7 @@ python -m gongwen optimize 文件.docx -o 优化版.docx
201
201
  **Agent 响应**:
202
202
  ```
203
203
  📋 合规自检报告
204
- Skill 版本: v2.5.0
204
+ Skill 版本: v2.6.0
205
205
  路径判定: B(内容优化)
206
206
  依据: 用户提供纯文本+优化要求,无已有文档
207
207
  命令调用: 将原文保存为临时文件后执行 optimize-content --apply --paragraphs "1-3"
package/pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "gongwen-skill"
7
- version = "2.5.0"
7
+ version = "2.6.0"
8
8
  description = "公文全流程处理工具 - GB/T 9704 格式检查/修复/内容优化/模板生成/版式注入"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}