gongwen-skill 1.12.73 → 2.0.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/.dsh/skills/gongwen-skill/SKILL.md +1 -1
- package/.dsh/skills/gongwen-skill.md +1 -1
- package/CHANGELOG.md +25 -0
- package/README.md +8 -8
- package/SKILL.md +1 -1
- package/cordis.patch.yml +1 -1
- package/dsh/client.js +1 -1
- package/dsh/index.js +23 -2
- package/engine/core/rules/manager.py +1 -1
- package/engine/live_edit.py +1 -1
- package/etc/dsh-config-defaults.json +1 -1
- package/gongwen/__init__.py +2 -2
- package/gongwen/_legacy.py +21 -21
- package/gongwen/cli/content_cmds.py +11 -11
- package/gongwen/cli/doctor_cmds.py +2 -2
- package/gongwen/cli/helpers.py +1 -1
- package/gongwen/cli/misc_cmds.py +4 -4
- package/gongwen/cli/review_cmds.py +12 -12
- package/package.json +3 -6
- package/prompts/usage-prompts.md +1 -1
- package/pyproject.toml +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: gongwen-skill
|
|
3
|
-
description:
|
|
3
|
+
description: 公文全流程处理工具。支持 .docx 公文按 GB/T 9704 国家标准做格式检查(check)、自动修复(optimize)、行内内容修订(optimize-content,红色标注+删除线+修改说明)、模板生成(template)、样式学习(style-learn,从标准文档学习排版样式生成自定义模板)、Markdown 转公文(md2docx),以及版头/版记/页码注入。覆盖通知/请示/报告/函/会议纪要等 24 类公文。完全自包含,克隆即用,无需数据库或后端服务。
|
|
4
4
|
whenToUse: 当用户需要处理中文公文(.docx格式)时,包括格式检查、自动修复、内容润色、模板生成、样式学习(从标准文档学习排版样式生成自定义模板)、Markdown转公文、版头版记注入等场景。适用于通知/请示/报告/函/会议纪要/新闻稿/讲话稿等24种公文类型。
|
|
5
5
|
user-invocable: true
|
|
6
6
|
metadata:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: gongwen-skill
|
|
3
|
-
description:
|
|
3
|
+
description: 公文全流程处理工具。支持 .docx 公文按 GB/T 9704 国家标准做格式检查(check)、自动修复(optimize)、行内内容修订(optimize-content,红色标注+删除线+修改说明)、模板生成(template)、样式学习(style-learn,从标准文档学习排版样式生成自定义模板)、Markdown 转公文(md2docx),以及版头/版记/页码注入。覆盖通知/请示/报告/函/会议纪要等 24 类公文。完全自包含,克隆即用,无需数据库或后端服务。
|
|
4
4
|
whenToUse: 当用户需要处理中文公文(.docx格式)时,包括格式检查、自动修复、内容润色、模板生成、样式学习(从标准文档学习排版样式生成自定义模板)、Markdown转公文、版头版记注入等场景。适用于通知/请示/报告/函/会议纪要/新闻稿/讲话稿等24种公文类型。
|
|
5
5
|
user-invocable: true
|
|
6
6
|
metadata:
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
## v2.0.0 (2026-08-20)
|
|
2
|
+
|
|
3
|
+
### Major
|
|
4
|
+
- **大版本重置**:从 1.12.x 序列重置为 **2.0.0**,清理历史版本号膨胀
|
|
5
|
+
|
|
6
|
+
### Architecture
|
|
7
|
+
- Migrate all legacy `from core.xxx` imports to `from engine.core.xxx` for proper Python packaging (files: `_legacy.py`, `content_cmds.py`, `review_cmds.py`, `helpers.py`, `misc_cmds.py`, `live_edit.py`)
|
|
8
|
+
- Remove unused `_ENGINE_DIR` import side-effect pattern in `_legacy.py`; use explicit `import gongwen._bootstrap` instead
|
|
9
|
+
|
|
10
|
+
### Performance
|
|
11
|
+
- Reduce verbose logging: change `_dedup_extend` rollup messages from `logger.info` to `logger.debug`, eliminating 50+ lines of noisy "同键覆盖" logs per command
|
|
12
|
+
|
|
13
|
+
## v1.12.74 (2026-08-20)
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- DSH 插件规范严格遵守官方文档(https://dsh.hicyou.com/zh/docs/user-guide/plugins)
|
|
17
|
+
- `dsh` 字段仅保留 `dsh.bundle.patch`,移除不合规的 `dsh.client` 声明
|
|
18
|
+
- `exports` 新增 `"./cordis.patch.yml"` 导出,使 bundle patch 文件可通过模块解析访问(与官方 `dsh-base` 一致)
|
|
19
|
+
- `dsh.bundle` 声明保持 `./cordis.patch.yml`,`cordis.patch.yml` 已列入 npm 包 files 白名单
|
|
20
|
+
- DSH skill 自动激活:`dsh/index.js` 的 `apply(ctx)` 中调用 `ctx.skills.register()`,插件安装并加载后自动注册 `gongwen-skill` 到 DSH 技能目录,AI 无需手动导入即可自动发现并触发使用;`resourceBase` 指向项目根目录,支持按路径加载规则/模板等资源
|
|
21
|
+
- SKILL.md 标准 Anthropic Agent Skills 格式(YAML frontmatter:name/description/whenToUse/user-invocable),跨平台兼容 WorkBuddy、Thelagnet、Claude Code、AtomCode 等
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
- 修复 DSH 插件被识别为"没有 dsh.bundle 声明/不是合法 bundle"的问题:补齐 `exports["./cordis.patch.yml"]` 并移除合同外字段 `dsh.client`
|
|
25
|
+
|
|
1
26
|
## v1.12.73 (2026-08-19)
|
|
2
27
|
|
|
3
28
|
### Added
|
package/README.md
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
Licensed under the MIT License. See the LICENSE file for details.
|
|
4
4
|
-->
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# 公文全流程处理工具
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
9
|
-
<img src="./logo/2026-08-19_11-17-43.png" alt="
|
|
9
|
+
<img src="./logo/2026-08-19_11-17-43.png" alt="公文全流程处理工具" width="760">
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
> 中文公文全流程处理工具——基于 **GB/T 9704《党政机关公文格式》** 国家标准,支持 **格式检查与修复、内容优化(Word 原生修订+批注/差异对比版)、模板生成、Markdown 转公文、版头版记页码注入、事实核验、风格增强** 等完整能力。原生支持 **DeepSeek Harness (DSH)** 技能系统,打包为可被 AI Agent 直接调用的 Skill,完全自包含,克隆即用。
|
|
13
13
|
|
|
14
14
|
[](https://github.com/linhut/gongwen-skill/actions)
|
|
15
|
-
[](https://pypi.org/project/gongwen-skill/)
|
|
16
16
|
[](./LICENSE)
|
|
17
17
|

|
|
18
18
|

|
|
@@ -336,7 +336,7 @@ DSH 采用 **Cordis 模块化微内核架构**:技能体系基于本地文件
|
|
|
336
336
|
git clone https://github.com/linhut/gongwen-skill.git
|
|
337
337
|
cd gongwen-skill
|
|
338
338
|
pip install -r requirements.txt # 或 pip install gongwen-skill(已上 PyPI)
|
|
339
|
-
python -m gongwen --version # 检验:gongwen-skill
|
|
339
|
+
python -m gongwen --version # 检验:gongwen-skill v2.0.0
|
|
340
340
|
```
|
|
341
341
|
|
|
342
342
|
### 方式一:作为 DSH Skill 注册(基于本地文件系统)
|
|
@@ -392,7 +392,7 @@ pnpm add -w gongwen-skill
|
|
|
392
392
|
"dependencies": {
|
|
393
393
|
"@deepseek-ai/dsh-base": "...",
|
|
394
394
|
"@deepseek-ai/dsh-web-app": "...",
|
|
395
|
-
"gongwen-skill": "^
|
|
395
|
+
"gongwen-skill": "^2.0.0"
|
|
396
396
|
},
|
|
397
397
|
"dsh": {
|
|
398
398
|
"profile": {
|
|
@@ -447,9 +447,9 @@ dsh --profile web
|
|
|
447
447
|
| CLI 独立可执行(`python -m gongwen <命令>`) | ✅ |
|
|
448
448
|
| PyPI 上架(`pip install gongwen-skill`) | ✅ |
|
|
449
449
|
| 零外部运行时依赖(仅 python-docx/pydantic/pyyaml) | ✅ |
|
|
450
|
-
| DSH 配置化排版参数(页边距/行距/字体/默认模板版本) | ✅
|
|
450
|
+
| DSH 配置化排版参数(页边距/行距/字体/默认模板版本) | ✅ v2.0.0+ |
|
|
451
451
|
|
|
452
|
-
### DSH 插件配置化(
|
|
452
|
+
### DSH 插件配置化(v2.0.0+)
|
|
453
453
|
|
|
454
454
|
DSH 插件支持通过配置文件管理排版参数,Agent 调用时自动注入,纯 CLI 用户不受影响。
|
|
455
455
|
|
|
@@ -573,7 +573,7 @@ pip install -r requirements.txt
|
|
|
573
573
|
用户:帮我优化这份会议通知的第二章节措辞
|
|
574
574
|
|
|
575
575
|
Agent:📋 合规自检报告
|
|
576
|
-
Skill 版本:
|
|
576
|
+
Skill 版本: v2.0.0(多渠道自检已确认最新)
|
|
577
577
|
路径判定: B(内容优化)
|
|
578
578
|
依据: 用户指定了已有文档,且要求"优化措辞"
|
|
579
579
|
命令调用: 1. python -m gongwen optimize-content 会议通知.docx --changes changes.json --apply --paragraphs "5-8"
|
package/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: gongwen-skill
|
|
3
|
-
description:
|
|
3
|
+
description: 公文全流程处理工具。支持 .docx 公文按 GB/T 9704 国家标准做格式检查(check)、自动修复(optimize)、行内内容修订(optimize-content,红色标注+删除线+修改说明)、模板生成(template)、样式学习(style-learn,从标准文档学习排版样式生成自定义模板)、Markdown 转公文(md2docx),以及版头/版记/页码注入。覆盖通知/请示/报告/函/会议纪要等 24 类公文。完全自包含,克隆即用,无需数据库或后端服务。
|
|
4
4
|
whenToUse: 当用户需要处理中文公文(.docx格式)时,包括格式检查、自动修复、内容润色、模板生成、样式学习(从标准文档学习排版样式生成自定义模板)、Markdown转公文、版头版记注入等场景。适用于通知/请示/报告/函/会议纪要/新闻稿/讲话稿等24种公文类型。
|
|
5
5
|
user-invocable: true
|
|
6
6
|
metadata:
|
package/cordis.patch.yml
CHANGED
package/dsh/client.js
CHANGED
package/dsh/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// 公文全流程处理工具 - DSH plugin bridge (gongwen-skill, v2.0.0+)
|
|
2
2
|
// (c) 2026 Jose AI (https://www.linhut.cn) MIT License
|
|
3
3
|
//
|
|
4
4
|
// 分层架构:
|
|
@@ -28,7 +28,7 @@ const CONFIG_FILE = join(APP_DATA_DIR, "dsh-config.json");
|
|
|
28
28
|
const DEFAULTS_FILE = join(resolve(__dirname, ".."), "etc", "dsh-config-defaults.json");
|
|
29
29
|
|
|
30
30
|
// AI 工作指引
|
|
31
|
-
const GONGWEN_GUIDANCE =
|
|
31
|
+
const GONGWEN_GUIDANCE = `本机已安装公文全流程处理工具插件(gongwen-skill)。能力:.docx 公文全流程——列出公文类型(list-types)、解析文档(parse)、格式检查(check)、自动修复(optimize)、内容修订对比版(optimize-content)、模板生成(template)、样式学习(style-learn/style-list,从标准文档学习排版样式)、全面诊断(doctor,21 项自检)、自动修复(repair)、Markdown 转公文(md2docx)、JSON 模型生成(generate)、版头/版记/页码注入(header/footer/pagenum)、首句加粗(bold-first)、一键格式修复(fix-common)、桌签生成(table-signs)、审稿流转单(review)、完整审校(full-review)、文档审计(audit)、规则管理(rule-export/import/list)、版本自检(check-update)、会话交接(handoff)、字体管理(font)。覆盖通知/请示/报告/函/会议纪要等 24 类公文。完全自包含,克隆即用,无需数据库或后端服务。用户提到「公文 / 红头文件 / 版式 / 排版 / 格式检查 / 公文模板 / 样式学习 / 自定义模板 / 党政机关公文」时即指本插件。DSH 插件支持配置化排版参数(页边距/行距/字体等),配置文件位于 ~/.gongwen-skill/dsh-config.json,可通过 config 命令或 DSH 系统设置→插件配置管理。`;
|
|
32
32
|
|
|
33
33
|
// Web API 路由前缀
|
|
34
34
|
const API_PREFIX = "/plugins/gongwen-skill/api";
|
|
@@ -454,6 +454,27 @@ export function apply(ctx) {
|
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
+
// 4. 注册 runtime skill(自动激活,使 AI 可在安装后自动发现并使用)
|
|
458
|
+
if (ctx?.skills?.register) {
|
|
459
|
+
try {
|
|
460
|
+
const skillPath = join(resolve(__dirname, ".."), "SKILL.md");
|
|
461
|
+
if (existsSync(skillPath)) {
|
|
462
|
+
const skillContent = readFileSync(skillPath, "utf-8");
|
|
463
|
+
const skillD = ctx.skills.register({
|
|
464
|
+
name: "gongwen-skill",
|
|
465
|
+
description: "中文公文全流程处理:格式检查/自动修复/content润色/模板生成/样式学习/Markdown转公文/版头版记注入",
|
|
466
|
+
content: skillContent,
|
|
467
|
+
resourceBase: { kind: "directory", path: resolve(__dirname, "..") },
|
|
468
|
+
invocation: { modelInvocable: true, userInvocable: true },
|
|
469
|
+
});
|
|
470
|
+
if (skillD) disposers.push(skillD);
|
|
471
|
+
if (ctx?.logger) ctx.logger.info("gongwen-skill: runtime skill registered");
|
|
472
|
+
}
|
|
473
|
+
} catch (e) {
|
|
474
|
+
if (ctx?.logger) ctx.logger.warn(`gongwen-skill: runtime skill registration skipped: ${e.message}`);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
457
478
|
if (ctx?.logger) {
|
|
458
479
|
ctx.logger.info(`gongwen-skill plugin loaded (projectRoot=${projectRoot})`);
|
|
459
480
|
}
|
|
@@ -130,7 +130,7 @@ def _dedup_extend(base_list: list, new_items: list, dedup_key) -> None:
|
|
|
130
130
|
if k is not None and k in existing_keys:
|
|
131
131
|
# P2-23 修复:同 field/键去重覆盖属于隐式依赖(如 speech.yaml 覆盖 _common.yaml),
|
|
132
132
|
# 覆盖发生时记录日志,避免静默覆盖导致规则丢失难以排查
|
|
133
|
-
logger.
|
|
133
|
+
logger.debug(f"_dedup_extend: 同键覆盖 {k}(新规则覆盖基础规则)")
|
|
134
134
|
# Replace existing item with same key
|
|
135
135
|
for i, existing in enumerate(base_list):
|
|
136
136
|
if dedup_key(existing) == k:
|
package/engine/live_edit.py
CHANGED
|
@@ -28,7 +28,7 @@ from datetime import datetime
|
|
|
28
28
|
from pathlib import Path
|
|
29
29
|
from typing import List
|
|
30
30
|
|
|
31
|
-
# ARCH-03 修复:engine/ 自身就是搜索路径根,模块内 from core... import 已生效
|
|
31
|
+
# ARCH-03 修复:engine/ 自身就是搜索路径根,模块内 from engine.core... import 已生效
|
|
32
32
|
# 不再需要 sys.path.insert(engine/ 已通过 _bootstrap 或 __init__.py 正确注册)
|
|
33
33
|
|
|
34
34
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_comment": "gongwen-skill
|
|
2
|
+
"_comment": "公文全流程处理工具(gongwen-skill)DSH 插件默认配置。复制到 ~/.gongwen-skill/dsh-config.json 后修改生效。",
|
|
3
3
|
"_doc": "此文件是默认模板,不要直接修改。运行 `python -m gongwen config --init` 可创建用户配置。",
|
|
4
4
|
"default_doc_type": "notice",
|
|
5
5
|
"page_setup": {
|
package/gongwen/__init__.py
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
# (c) 2026 Jose AI (https://www.linhut.cn)
|
|
5
5
|
# Licensed under the MIT License. See the LICENSE file for details.
|
|
6
6
|
#
|
|
7
|
-
# gongwen-skill Python package
|
|
7
|
+
# 公文全流程处理工具 - gongwen-skill Python package
|
|
8
8
|
|
|
9
|
-
__version__ = "
|
|
9
|
+
__version__ = "2.0.0"
|
|
10
10
|
|
|
11
11
|
# Re-export everything from the legacy module for backward compatibility
|
|
12
12
|
# This allows: from gongwen import main, cmd_check, etc.
|
package/gongwen/_legacy.py
CHANGED
|
@@ -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__ = "
|
|
48
|
+
__version__ = "2.0.0"
|
|
49
49
|
# 版本号应与 gongwen/__init__.py 保持一致,每次发版同步更新
|
|
50
50
|
"""
|
|
51
51
|
中文公文全流程处理工具 —— 基于 GB/T 9704《党政机关公文格式》国家标准。
|
|
@@ -98,7 +98,7 @@ _logger = logging.getLogger(__name__)
|
|
|
98
98
|
|
|
99
99
|
# ARCH-03 修复:通过 _bootstrap 统一管理 engine/ 路径和编码设置
|
|
100
100
|
# 消除各入口点重复的 sys.path.insert hack
|
|
101
|
-
|
|
101
|
+
import gongwen._bootstrap # noqa: F401, E402 # 触发编码设置和路径引导
|
|
102
102
|
|
|
103
103
|
# 阶梯2:从 cli.helpers 导入提取的辅助函数(逐步消除单文件膨胀)
|
|
104
104
|
|
|
@@ -125,7 +125,7 @@ from gongwen._bootstrap import _ENGINE_DIR # noqa: F401, E402
|
|
|
125
125
|
|
|
126
126
|
def cmd_list_types(args):
|
|
127
127
|
"""列出所有支持的公文类型。"""
|
|
128
|
-
from core.rules.loader import list_available_types
|
|
128
|
+
from engine.core.rules.loader import list_available_types
|
|
129
129
|
types = list_available_types()
|
|
130
130
|
if args.json:
|
|
131
131
|
print(json.dumps(types, ensure_ascii=False, indent=2))
|
|
@@ -137,7 +137,7 @@ def cmd_list_types(args):
|
|
|
137
137
|
def cmd_template(args):
|
|
138
138
|
"""生成标准公文模板。"""
|
|
139
139
|
from datetime import date as _dt
|
|
140
|
-
from core.document.generator import generate_docx
|
|
140
|
+
from engine.core.document.generator import generate_docx
|
|
141
141
|
from template_builder import create_template_document
|
|
142
142
|
|
|
143
143
|
doc_type = args.type
|
|
@@ -155,7 +155,7 @@ def cmd_template(args):
|
|
|
155
155
|
|
|
156
156
|
def cmd_parse(args):
|
|
157
157
|
"""解析文档为结构化 JSON。"""
|
|
158
|
-
from core.document.parser import parse_docx
|
|
158
|
+
from engine.core.document.parser import parse_docx
|
|
159
159
|
|
|
160
160
|
model = parse_docx(args.input)
|
|
161
161
|
data = model.model_dump()
|
|
@@ -169,8 +169,8 @@ def cmd_parse(args):
|
|
|
169
169
|
|
|
170
170
|
def cmd_check(args):
|
|
171
171
|
"""检查文档格式(只读)。"""
|
|
172
|
-
from core.document.parser import parse_docx
|
|
173
|
-
from core.rules.engine import RuleEngine
|
|
172
|
+
from engine.core.document.parser import parse_docx
|
|
173
|
+
from engine.core.rules.engine import RuleEngine
|
|
174
174
|
|
|
175
175
|
engine = RuleEngine()
|
|
176
176
|
overrides = _parse_config_overrides(getattr(args, "config_overrides", ""))
|
|
@@ -206,9 +206,9 @@ def cmd_optimize(args):
|
|
|
206
206
|
默认预览模式:检测类型 → 检查问题 → 列出摘要 → 提示下一步。
|
|
207
207
|
加 --apply 才真正执行修复并生成文件。
|
|
208
208
|
"""
|
|
209
|
-
from core.document.parser import parse_docx
|
|
210
|
-
from core.document.generator import generate_docx
|
|
211
|
-
from core.rules.engine import RuleEngine
|
|
209
|
+
from engine.core.document.parser import parse_docx
|
|
210
|
+
from engine.core.document.generator import generate_docx
|
|
211
|
+
from engine.core.rules.engine import RuleEngine
|
|
212
212
|
|
|
213
213
|
engine = RuleEngine()
|
|
214
214
|
# 应用 DSH 配置覆盖到规则引擎
|
|
@@ -260,7 +260,7 @@ def cmd_optimize(args):
|
|
|
260
260
|
selected = args.selected_rules.split(",") if args.selected_rules else None
|
|
261
261
|
_, fixed = engine.check_and_fix(model, doc_type, selected)
|
|
262
262
|
# 清理路径 B 遗留的修改说明段落和删除线标记(确保干净成品)
|
|
263
|
-
from core.document.modifier import clean_path_b_markers, bold_first_sentence_of_body
|
|
263
|
+
from engine.core.document.modifier import clean_path_b_markers, bold_first_sentence_of_body
|
|
264
264
|
cleaned = clean_path_b_markers(fixed)
|
|
265
265
|
# B-03(方案八):optimize 增加首句加粗能力——修复后补齐缺失的首句加粗,
|
|
266
266
|
# 与 fix-common 行为对齐(speech 文种跳过:整段加粗为朗读件规范)
|
|
@@ -269,8 +269,8 @@ def cmd_optimize(args):
|
|
|
269
269
|
n_bold = bold_first_sentence_of_body(fixed)
|
|
270
270
|
# 改动9:按 blank_line_rules 配置主动插入必要空行(省筹委会规范:标题前后/落款前/附件后)
|
|
271
271
|
try:
|
|
272
|
-
from core.document.modifier import _insert_blank_lines
|
|
273
|
-
from core.rules.manager import load_rules_merged as _lrm
|
|
272
|
+
from engine.core.document.modifier import _insert_blank_lines
|
|
273
|
+
from engine.core.rules.manager import load_rules_merged as _lrm
|
|
274
274
|
n_blank = _insert_blank_lines(fixed, _lrm(doc_type))
|
|
275
275
|
except Exception:
|
|
276
276
|
n_blank = 0
|
|
@@ -302,8 +302,8 @@ def cmd_optimize(args):
|
|
|
302
302
|
|
|
303
303
|
def cmd_generate(args):
|
|
304
304
|
"""从 DocumentModel JSON 生成 .docx。"""
|
|
305
|
-
from core.document.models import DocumentModel
|
|
306
|
-
from core.document.generator import generate_docx
|
|
305
|
+
from engine.core.document.models import DocumentModel
|
|
306
|
+
from engine.core.document.generator import generate_docx
|
|
307
307
|
|
|
308
308
|
data = json.loads(Path(args.input).read_text(encoding="utf-8"))
|
|
309
309
|
model = DocumentModel(**data)
|
|
@@ -329,12 +329,12 @@ def cmd_md2docx(args):
|
|
|
329
329
|
- doc_type: 公文类型(默认 notice)
|
|
330
330
|
"""
|
|
331
331
|
from datetime import date as _dt
|
|
332
|
-
from core.document.generator import generate_docx
|
|
333
|
-
from core.document.models import (
|
|
332
|
+
from engine.core.document.generator import generate_docx
|
|
333
|
+
from engine.core.document.models import (
|
|
334
334
|
DocumentModel, DocumentMetadata, PageSetup,
|
|
335
335
|
Paragraph, ParagraphFormat, Run, RunFormat,
|
|
336
336
|
)
|
|
337
|
-
from core.document.modifier import convert_markdown
|
|
337
|
+
from engine.core.document.modifier import convert_markdown
|
|
338
338
|
|
|
339
339
|
# 解析参数
|
|
340
340
|
doc_type = args.doc_type or "notice"
|
|
@@ -519,7 +519,7 @@ def cmd_md2docx(args):
|
|
|
519
519
|
|
|
520
520
|
# 生成 docx(P1: --no-ai-declaration 跳过 AI 声明段)
|
|
521
521
|
# AI 生成内容通病修复:去除句前空格 + 统一文字颜色为黑色(md2docx 不走规则引擎,手动调用)
|
|
522
|
-
from core.document.modifier import remove_extra_spaces, unify_text_color
|
|
522
|
+
from engine.core.document.modifier import remove_extra_spaces, unify_text_color
|
|
523
523
|
remove_extra_spaces(model)
|
|
524
524
|
unify_text_color(model)
|
|
525
525
|
if args.output:
|
|
@@ -654,11 +654,11 @@ FONTS_DOWNLOAD_BASE = "https://raw.githubusercontent.com/linhut/document-ai-assi
|
|
|
654
654
|
def main():
|
|
655
655
|
parser = argparse.ArgumentParser(
|
|
656
656
|
prog="gongwen",
|
|
657
|
-
description="
|
|
657
|
+
description="公文全流程处理工具(GB/T 9704)—— 格式检查/内容优化/模板生成/版式注入 (c) 2026 Jose AI https://www.linhut.cn",
|
|
658
658
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
659
659
|
epilog=__doc__,
|
|
660
660
|
)
|
|
661
|
-
parser.add_argument("--version", action="version", version=f"
|
|
661
|
+
parser.add_argument("--version", action="version", version=f"公文全流程处理工具 v{__version__}",
|
|
662
662
|
help="显示版本号并退出")
|
|
663
663
|
sub = parser.add_subparsers(dest="command", help="子命令")
|
|
664
664
|
|
|
@@ -76,7 +76,7 @@ def cmd_optimize_content(args):
|
|
|
76
76
|
Path(args.input), getattr(args, 'doc_type', None))
|
|
77
77
|
content_rules: dict = {}
|
|
78
78
|
try:
|
|
79
|
-
from core.rules.manager import load_rules_merged
|
|
79
|
+
from engine.core.rules.manager import load_rules_merged
|
|
80
80
|
rules = load_rules_merged(doc_type)
|
|
81
81
|
content_rules = _extract_content_rules(rules)
|
|
82
82
|
if getattr(args, 'show_rules', False):
|
|
@@ -336,7 +336,7 @@ def cmd_optimize_content(args):
|
|
|
336
336
|
try:
|
|
337
337
|
from auto_optimizer import style_enhance_changes, llm_configured
|
|
338
338
|
if llm_configured():
|
|
339
|
-
from core.document.parser import parse_docx
|
|
339
|
+
from engine.core.document.parser import parse_docx
|
|
340
340
|
_se_model = parse_docx(str(args.input))
|
|
341
341
|
_se_paras = [p.text for p in _se_model.paragraphs if p.text and p.text.strip()]
|
|
342
342
|
style_changes = style_enhance_changes(_se_paras, style_prompt, changes)
|
|
@@ -353,8 +353,8 @@ def cmd_optimize_content(args):
|
|
|
353
353
|
|
|
354
354
|
# --comment-mode:Word 原生批注模式(可审阅→接受/拒绝)
|
|
355
355
|
if getattr(args, 'comment_mode', False):
|
|
356
|
-
from core.document.annotator import GongwenAnnotator, CommentSuggestion
|
|
357
|
-
from core.document.reviewer_comments import resolve_role
|
|
356
|
+
from engine.core.document.annotator import GongwenAnnotator, CommentSuggestion
|
|
357
|
+
from engine.core.document.reviewer_comments import resolve_role
|
|
358
358
|
|
|
359
359
|
# P1 修复:comment_mode 路径共用 resolve_role(category 优先,角色真正区分)
|
|
360
360
|
suggestions = []
|
|
@@ -382,7 +382,7 @@ def cmd_optimize_content(args):
|
|
|
382
382
|
|
|
383
383
|
# --tracked-change:Word 原生修订标记模式(审阅面板逐条接受/拒绝)
|
|
384
384
|
if getattr(args, 'tracked_change', False):
|
|
385
|
-
from core.document.tracked_changes import inject_tracked_changes
|
|
385
|
+
from engine.core.document.tracked_changes import inject_tracked_changes
|
|
386
386
|
tc_changes = [{
|
|
387
387
|
"para_index": c.get("paragraph_index", 0),
|
|
388
388
|
"original_text": c.get("original_text", ""),
|
|
@@ -398,9 +398,9 @@ def cmd_optimize_content(args):
|
|
|
398
398
|
# --mode tracked:Word 原生修订(del/ins)+ 批注(修改说明)统一模式
|
|
399
399
|
mode = getattr(args, 'mode', 'tracked')
|
|
400
400
|
if mode == 'tracked':
|
|
401
|
-
from core.document.tracked_annotator import inject_tracked_with_comments
|
|
402
|
-
from core.document.annotator import CommentSuggestion
|
|
403
|
-
from core.document.reviewer_comments import REVIEWER_MAP, resolve_role, get_author
|
|
401
|
+
from engine.core.document.tracked_annotator import inject_tracked_with_comments
|
|
402
|
+
from engine.core.document.annotator import CommentSuggestion
|
|
403
|
+
from engine.core.document.reviewer_comments import REVIEWER_MAP, resolve_role, get_author
|
|
404
404
|
|
|
405
405
|
# F1 + D3 修复:修订作者 = skill 英文名 + "-修订"(与 skill 英文标识统一,保留中文后缀便于中文 Word 用户理解)
|
|
406
406
|
REVISION_AUTHOR = "GongWen-Skill修订"
|
|
@@ -486,7 +486,7 @@ def cmd_optimize_content(args):
|
|
|
486
486
|
# P2-7 修复:顶层已导入 json,删除冗余 import json as _json
|
|
487
487
|
# 实体提取(不做互联网核验,交 Agent)
|
|
488
488
|
from fact_check import extract_entities_hybrid
|
|
489
|
-
from core.document.parser import parse_docx as _fc_parse
|
|
489
|
+
from engine.core.document.parser import parse_docx as _fc_parse
|
|
490
490
|
_fc_model = _fc_parse(str(args.input))
|
|
491
491
|
_fc_paras = [p.text for p in _fc_model.paragraphs]
|
|
492
492
|
_entities = extract_entities_hybrid(_fc_paras)
|
|
@@ -632,7 +632,7 @@ def cmd_optimize_content(args):
|
|
|
632
632
|
# R2 修复:按实体名在段落文本中的偏移精确锚定(而非 offset=0 锚定段落起始)
|
|
633
633
|
fc_para_texts: dict[int, str] = {}
|
|
634
634
|
try:
|
|
635
|
-
from core.document.parser import parse_docx
|
|
635
|
+
from engine.core.document.parser import parse_docx
|
|
636
636
|
_m = parse_docx(str(args.input))
|
|
637
637
|
fc_para_texts = {i: p.text for i, p in enumerate(_m.paragraphs)}
|
|
638
638
|
except Exception as e:
|
|
@@ -675,7 +675,7 @@ def cmd_optimize_content(args):
|
|
|
675
675
|
if _m is None:
|
|
676
676
|
# P3-21 修复:移除无效的 '_m = None' 赋值(_m 已确定为 None,赋值无意义)
|
|
677
677
|
try:
|
|
678
|
-
from core.document.parser import parse_docx
|
|
678
|
+
from engine.core.document.parser import parse_docx
|
|
679
679
|
_m = parse_docx(str(args.input))
|
|
680
680
|
except Exception as e:
|
|
681
681
|
_logger.warning(f"文档结构解析失败: {e}")
|
|
@@ -446,7 +446,7 @@ def cmd_doctor(args):
|
|
|
446
446
|
return 0 if report["summary"]["failed"] == 0 else 1
|
|
447
447
|
|
|
448
448
|
s = report["summary"]
|
|
449
|
-
print(f"🔍
|
|
449
|
+
print(f"🔍 公文全流程处理工具 健康诊断")
|
|
450
450
|
print(f" 项目根目录: {report['project_root']}")
|
|
451
451
|
print(f" 诊断时间: {report['timestamp']}")
|
|
452
452
|
print(f" 耗时: {report['elapsed_seconds']}s")
|
|
@@ -478,7 +478,7 @@ def cmd_repair(args):
|
|
|
478
478
|
"""修复常见问题:自动修复 + 提示修复。"""
|
|
479
479
|
import subprocess as _sp
|
|
480
480
|
|
|
481
|
-
print(f"
|
|
481
|
+
print(f"公文全流程处理工具 修复工具")
|
|
482
482
|
print(f"{'-' * 60}")
|
|
483
483
|
|
|
484
484
|
fixes = 0
|
package/gongwen/cli/helpers.py
CHANGED
|
@@ -113,7 +113,7 @@ def parse_config_overrides(raw: str) -> dict | None:
|
|
|
113
113
|
|
|
114
114
|
def load_rules_with_overrides(doc_type: str, overrides_raw: str) -> dict:
|
|
115
115
|
"""加载合并规则并应用 DSH 配置覆盖(优先级最高)。"""
|
|
116
|
-
from core.rules.manager import load_rules_merged, apply_config_overrides
|
|
116
|
+
from engine.core.rules.manager import load_rules_merged, apply_config_overrides
|
|
117
117
|
rules = load_rules_merged(doc_type)
|
|
118
118
|
overrides = parse_config_overrides(overrides_raw)
|
|
119
119
|
if overrides:
|
package/gongwen/cli/misc_cmds.py
CHANGED
|
@@ -15,7 +15,7 @@ _logger = logging.getLogger(__name__)
|
|
|
15
15
|
|
|
16
16
|
def cmd_rule_export(args):
|
|
17
17
|
"""导出某类型的合并规则为 YAML。"""
|
|
18
|
-
from core.rules.manager import load_rules_merged
|
|
18
|
+
from engine.core.rules.manager import load_rules_merged
|
|
19
19
|
import yaml
|
|
20
20
|
|
|
21
21
|
rules = load_rules_merged(args.type)
|
|
@@ -29,7 +29,7 @@ def cmd_rule_export(args):
|
|
|
29
29
|
|
|
30
30
|
def cmd_rule_list(args):
|
|
31
31
|
"""列出三层规则。"""
|
|
32
|
-
from core.rules.manager import list_rule_files
|
|
32
|
+
from engine.core.rules.manager import list_rule_files
|
|
33
33
|
files = list_rule_files(args.source)
|
|
34
34
|
if args.json:
|
|
35
35
|
print(json.dumps(files, ensure_ascii=False, indent=2))
|
|
@@ -40,7 +40,7 @@ def cmd_rule_list(args):
|
|
|
40
40
|
|
|
41
41
|
def cmd_rule_import(args):
|
|
42
42
|
"""导入/保存自定义规则 YAML。"""
|
|
43
|
-
from core.rules.manager import save_rule, validate_rule
|
|
43
|
+
from engine.core.rules.manager import save_rule, validate_rule
|
|
44
44
|
import yaml
|
|
45
45
|
|
|
46
46
|
key = args.key
|
|
@@ -117,7 +117,7 @@ def cmd_table_signs(args):
|
|
|
117
117
|
|
|
118
118
|
def cmd_audit(args):
|
|
119
119
|
"""审计文档处理链:检查文档格式合规性、删除线问题、bold-first 影响。"""
|
|
120
|
-
from core.document.parser import parse_docx
|
|
120
|
+
from engine.core.document.parser import parse_docx
|
|
121
121
|
from pathlib import Path
|
|
122
122
|
|
|
123
123
|
model = parse_docx(args.input)
|
|
@@ -24,11 +24,11 @@ _logger = logging.getLogger(__name__)
|
|
|
24
24
|
|
|
25
25
|
def cmd_full_review(args):
|
|
26
26
|
"""完整审校流程:格式修复(路径A)→ 内容优化(路径B)→ 批注输出。"""
|
|
27
|
-
from core.document.parser import parse_docx
|
|
28
|
-
from core.document.generator import generate_docx
|
|
29
|
-
from core.rules.engine import RuleEngine
|
|
27
|
+
from engine.core.document.parser import parse_docx
|
|
28
|
+
from engine.core.document.generator import generate_docx
|
|
29
|
+
from engine.core.rules.engine import RuleEngine
|
|
30
30
|
from optimizer import load_changes_from_json
|
|
31
|
-
from core.document.annotator import GongwenAnnotator, CommentSuggestion
|
|
31
|
+
from engine.core.document.annotator import GongwenAnnotator, CommentSuggestion
|
|
32
32
|
|
|
33
33
|
input_path = Path(args.input)
|
|
34
34
|
# P1-1 修复:统一传 None
|
|
@@ -78,9 +78,9 @@ def cmd_full_review(args):
|
|
|
78
78
|
def cmd_bold_first(args):
|
|
79
79
|
"""正文段落首句加粗(符合公文规范)。"""
|
|
80
80
|
import shutil
|
|
81
|
-
from core.document.parser import parse_docx
|
|
82
|
-
from core.document.generator import generate_docx
|
|
83
|
-
from core.document.modifier import bold_first_sentence_of_body
|
|
81
|
+
from engine.core.document.parser import parse_docx
|
|
82
|
+
from engine.core.document.generator import generate_docx
|
|
83
|
+
from engine.core.document.modifier import bold_first_sentence_of_body
|
|
84
84
|
|
|
85
85
|
input_path = Path(args.input)
|
|
86
86
|
out = Path(args.output) if args.output else input_path.with_stem(input_path.stem + "_加粗首句")
|
|
@@ -140,14 +140,14 @@ def cmd_fix_common(args):
|
|
|
140
140
|
"""
|
|
141
141
|
import time
|
|
142
142
|
import copy as _copy
|
|
143
|
-
from core.document.parser import parse_docx
|
|
144
|
-
from core.document.generator import generate_docx
|
|
145
|
-
from core.document.modifier import (
|
|
143
|
+
from engine.core.document.parser import parse_docx
|
|
144
|
+
from engine.core.document.generator import generate_docx
|
|
145
|
+
from engine.core.document.modifier import (
|
|
146
146
|
clean_path_b_markers, split_numbered_paragraphs,
|
|
147
147
|
bold_first_sentence_of_body, fix_bold_range,
|
|
148
148
|
)
|
|
149
|
-
from core.rules.manager import load_rules_merged
|
|
150
|
-
from core.rules.fixer import apply_fixes
|
|
149
|
+
from engine.core.rules.manager import load_rules_merged
|
|
150
|
+
from engine.core.rules.fixer import apply_fixes
|
|
151
151
|
|
|
152
152
|
t0 = time.time()
|
|
153
153
|
input_path = Path(args.input)
|
package/package.json
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gongwen-skill",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "公文全流程处理工具 - GB/T 9704 格式检查/修复/内容优化/模板生成/版式注入",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dsh/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./dsh/index.js",
|
|
9
9
|
"./dsh": "./dsh/index.js",
|
|
10
10
|
"./client": "./dsh/client.js",
|
|
11
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
11
12
|
"./package.json": "./package.json"
|
|
12
13
|
},
|
|
13
14
|
"dsh": {
|
|
14
15
|
"bundle": {
|
|
15
16
|
"patch": "./cordis.patch.yml"
|
|
16
|
-
},
|
|
17
|
-
"client": {
|
|
18
|
-
"inject": [],
|
|
19
|
-
"platform": "web"
|
|
20
17
|
}
|
|
21
18
|
},
|
|
22
19
|
"keywords": [
|
package/prompts/usage-prompts.md
CHANGED
package/pyproject.toml
CHANGED
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "gongwen-skill"
|
|
7
|
-
version = "
|
|
8
|
-
description = "
|
|
7
|
+
version = "2.0.0"
|
|
8
|
+
description = "公文全流程处理工具 - GB/T 9704 格式检查/修复/内容优化/模板生成/版式注入"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "MIT"}
|
|
11
11
|
requires-python = ">=3.10"
|