gongwen-skill 2.12.0 → 2.14.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/.claude-plugin/marketplace.json +27 -0
- package/.claude-plugin/plugin.json +25 -0
- package/AGENTS.md +120 -0
- package/CHANGELOG.md +42 -0
- package/README.md +13 -5
- package/SKILL.md +3 -3
- package/cordis.patch.yml +1 -1
- package/dsh/client.js +4 -48
- package/dsh/index.js +10 -76
- package/engine/auto_optimizer.py +1 -1
- package/engine/core/document/models.py +30 -0
- package/engine/core/document/ooxml_parser.py +39 -0
- package/engine/core/document/parser.py +25 -5
- package/engine/core/rules/checker.py +14 -1
- package/engine/live_edit.py +1 -1
- package/etc/dsh-config-defaults.json +1 -1
- package/gongwen/__init__.py +7 -2
- package/gongwen/_legacy.py +63 -10
- package/gongwen/cli/app.py +40 -18
- package/gongwen/cli/content_cmds.py +13 -21
- package/gongwen/cli/doctor_cmds.py +268 -2
- package/gongwen/cli/draft_cmds.py +0 -2
- package/gongwen/cli/font_cmds.py +1 -1
- package/gongwen/cli/misc_cmds.py +5 -5
- package/gongwen/cli/policy_cmds.py +239 -0
- package/gongwen/cli/render_cmds.py +96 -0
- package/gongwen/cli/review_cmds.py +3 -3
- package/gongwen/cli/style_helpers.py +1 -1
- package/gongwen/cli/wizard_cmds.py +16 -7
- package/package.json +6 -4
- package/prompts/usage-prompts.md +1 -1
- package/pyproject.toml +2 -2
- package/rules/official/_common.yaml +10 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gongwen-skill-marketplace",
|
|
3
|
+
"description": "公文全流程处理专家(gongwen-skill)Claude Code 插件市场",
|
|
4
|
+
"owner": {
|
|
5
|
+
"name": "Jose AI"
|
|
6
|
+
},
|
|
7
|
+
"plugins": [
|
|
8
|
+
{
|
|
9
|
+
"name": "gongwen-skill",
|
|
10
|
+
"displayName": "公文全流程处理专家",
|
|
11
|
+
"source": "./",
|
|
12
|
+
"version": "2.12.0",
|
|
13
|
+
"description": "公文全流程处理专家 —— 面向中文公文(.docx)的 GB/T 9704 全流程工具链:格式检查、自动修复、内容优化(Word 原生修订+批注 / 行内差异对比)、模板生成、样式学习、Markdown 转公文、版头版记页码注入,覆盖 25 类法定公文。",
|
|
14
|
+
"category": "productivity",
|
|
15
|
+
"tags": [
|
|
16
|
+
"chinese",
|
|
17
|
+
"document",
|
|
18
|
+
"government",
|
|
19
|
+
"official-document",
|
|
20
|
+
"GB/T 9704",
|
|
21
|
+
"docx",
|
|
22
|
+
"skill",
|
|
23
|
+
"公文"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gongwen-skill",
|
|
3
|
+
"displayName": "公文全流程处理专家",
|
|
4
|
+
"version": "2.12.0",
|
|
5
|
+
"description": "公文全流程处理专家 —— 面向中文公文(.docx)的 GB/T 9704 全流程工具链:格式检查、自动修复、内容优化(Word 原生修订+批注 / 行内差异对比)、模板生成、样式学习、Markdown 转公文、版头版记页码注入,覆盖 25 类法定公文。",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Jose AI",
|
|
8
|
+
"url": "https://www.linhut.cn"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/linhut/gongwen-skill",
|
|
11
|
+
"repository": "https://github.com/linhut/gongwen-skill",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"category": "productivity",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"chinese",
|
|
16
|
+
"document",
|
|
17
|
+
"government",
|
|
18
|
+
"official-document",
|
|
19
|
+
"GB/T 9704",
|
|
20
|
+
"docx",
|
|
21
|
+
"skill",
|
|
22
|
+
"公文",
|
|
23
|
+
"格式检查"
|
|
24
|
+
]
|
|
25
|
+
}
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
AIGC:
|
|
3
|
+
Label: "1"
|
|
4
|
+
ContentProducer: 001191440300708461136T1XGW3
|
|
5
|
+
ProduceID: 594788b2f473f3679080da07b1915493_3948b672adda11f18039525400461939
|
|
6
|
+
ReservedCode1: QQXN7DfjJFomCh/Kvmo5ok38vndecdGMG4kKZFsPf0YzBRkXkoJoUGOxHtU8m2/aike/LgYiydcg6cHyT1NuWO3+Bq2M8XblOH3SdsrfC75KXxL6fOZiMjsMLk7jccu0KbisbuD4uLLjFUcFV/o2lh90oFvPqDf1lK+11KDbXcYRNupGF1SyCJDwukM=
|
|
7
|
+
ContentPropagator: 001191440300708461136T1XGW3
|
|
8
|
+
PropagateID: 594788b2f473f3679080da07b1915493_3948b672adda11f18039525400461939
|
|
9
|
+
ReservedCode2: QQXN7DfjJFomCh/Kvmo5ok38vndecdGMG4kKZFsPf0YzBRkXkoJoUGOxHtU8m2/aike/LgYiydcg6cHyT1NuWO3+Bq2M8XblOH3SdsrfC75KXxL6fOZiMjsMLk7jccu0KbisbuD4uLLjFUcFV/o2lh90oFvPqDf1lK+11KDbXcYRNupGF1SyCJDwukM=
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
<!--
|
|
15
|
+
(c) 2026 Jose AI (https://www.linhut.cn)
|
|
16
|
+
https://github.com/linhut/gongwen-skill
|
|
17
|
+
Licensed under the MIT License. See the LICENSE file for details.
|
|
18
|
+
-->
|
|
19
|
+
|
|
20
|
+
# 公文全流程处理专家(gongwen-skill)
|
|
21
|
+
|
|
22
|
+
> 面向中文公文(`.docx`)的 **GB/T 9704《党政机关公文格式》** 全流程处理工具链,打包为可被 AI Agent 直接调用的 Skill。
|
|
23
|
+
>
|
|
24
|
+
> - **展示名(对外名称)**:公文全流程处理专家
|
|
25
|
+
> - **标识名(机器标识,请勿改动)**:包名 `gongwen-skill`、命令名 `gongwen`、Skill 目录名 `gongwen-skill`
|
|
26
|
+
> - **仓库**:https://github.com/linhut/gongwen-skill | 许可:MIT
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 1. 快速开始
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/linhut/gongwen-skill.git
|
|
34
|
+
cd gongwen-skill
|
|
35
|
+
pip install -r requirements.txt # 需要 Python 3.10+
|
|
36
|
+
python -m gongwen list-types # 验证安装(应列出 25 种公文类型)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
也可直接安装 PyPI 包:`pip install gongwen-skill`。
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 2. Agent 调用约定
|
|
44
|
+
|
|
45
|
+
1. **入口唯一**:所有业务能力统一通过 CLI `python -m gongwen <命令>` 调用,不要自行拼装底层脚本。
|
|
46
|
+
2. **执行前声明**(硬门控,不可跳过):先声明「当前调用环境 / 用户需求判定路径(A 格式修复、B 内容优化、C 生成公文、D 一键修复、E 其他)/ 判定依据」。
|
|
47
|
+
3. **写操作显式授权**:修复与生成类命令默认只预览,需 `--apply` 才落盘;覆盖已有文件前须获得用户确认。
|
|
48
|
+
4. **只读优先**:诊断类命令(`check` / `parse` / `audit` / `rule-list` / `doctor`)不修改用户文档,可放心执行。
|
|
49
|
+
5. **规则与提示词**:格式规则位于 `rules/`(官方 / 单位 / 用户三层 YAML),提示词位于 `prompts/`,可按需读取后再判断。
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 3. 命令速查(29 项)
|
|
54
|
+
|
|
55
|
+
> 本表仅为速查摘要,**完整操作指南以 `SKILL.md` 为准**(命令参数、示例、规则详见 skills 主文件);新增或调整命令时同步更新两处。
|
|
56
|
+
|
|
57
|
+
| 命令 | 说明 |
|
|
58
|
+
|:-----|:-----|
|
|
59
|
+
| `list-types` | 列出 25 种支持的公文类型 |
|
|
60
|
+
| `template` | 按类型生成 GB/T 9704 标准空白模板 |
|
|
61
|
+
| `parse` | `.docx` → 结构化 DocumentModel(JSON) |
|
|
62
|
+
| `check` | 按国标检查格式,分级 P0/P1/P2(只读) |
|
|
63
|
+
| `optimize` | 检查 + 修复 + 生成(默认预览,`--apply` 执行) |
|
|
64
|
+
| `generate` | 从 DocumentModel JSON 生成 `.docx` |
|
|
65
|
+
| `header` | 注入版头:发文机关标志 + 发文字号 + 签发人 + 红色反线 |
|
|
66
|
+
| `footer` | 注入版记:抄送 + 印发机关 + 印发日期 + 分隔线 |
|
|
67
|
+
| `pagenum` | 注入 Word PAGE 域动态页码 |
|
|
68
|
+
| `md2docx` | Markdown 文本转格式化公文 `.docx` |
|
|
69
|
+
| `draft` | Markdown 草稿 → 国标成品 + 验证(四步合一) |
|
|
70
|
+
| `optimize-content` | 内容优化:Word 原生修订+批注,或行内差异对比版 |
|
|
71
|
+
| `bold-first` | 正文段落首句加粗(符合公文规范) |
|
|
72
|
+
| `fix-common` | 一键修复常见格式问题(段落类型 / 编号拆分 / 首句加粗 / 加粗范围) |
|
|
73
|
+
| `handoff` | 查看或写入会话交接文档(跨会话上下文传递) |
|
|
74
|
+
| `rule-export` / `rule-list` / `rule-import` | 三层规则导出 / 列出 / 导入 |
|
|
75
|
+
| `table-signs` | 从名单批量生成会议桌签 |
|
|
76
|
+
| `full-review` | 完整审校:格式修复 → 内容优化 → 批注输出 |
|
|
77
|
+
| `style-learn` / `style-list` | 从标准文档学习排版样式并注册为命名模板 |
|
|
78
|
+
| `check-update` | 版本自检(PyPI 权威判定 + GitHub 备用 + 国内镜像提示) |
|
|
79
|
+
| `audit` | 审计文档处理链:删除线 / 加粗 / AI 声明等合规性 |
|
|
80
|
+
| `review` | 生成公文审稿流转单(五角色 / 三角色模板) |
|
|
81
|
+
| `wizard` | 向导式交互:A/B/C/D/E 路径引导 + 一键执行 |
|
|
82
|
+
| `font` | 公文标准字体管理:安装 / 检查 / 列出内置字体 |
|
|
83
|
+
| `doctor` / `repair` | 全面自我诊断与常见问题修复 |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 4. 目录结构
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
gongwen-skill/
|
|
91
|
+
├── SKILL.md # Skill 主文件(frontmatter + 全量操作指南)
|
|
92
|
+
├── AGENTS.md # 本文件(面向 Codex 等指令型 Agent)
|
|
93
|
+
├── .claude-plugin/ # Claude Code 插件清单(plugin.json / marketplace.json)
|
|
94
|
+
├── dsh/ # DeepSeek Harness 插件(index.js / client.js)
|
|
95
|
+
├── cordis.patch.yml # DSH 插件注册补丁
|
|
96
|
+
├── presets/ # DSH Agent 预设「公文全流程处理专家」
|
|
97
|
+
├── engine/ # 格式引擎(解析 / 检查 / 修复 / 生成)
|
|
98
|
+
├── gongwen/ # CLI(`python -m gongwen`)
|
|
99
|
+
├── rules/ # 三层格式规则(官方 / 单位 / 用户)
|
|
100
|
+
└── prompts/ # 各路径提示词
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 5. 平台适配
|
|
106
|
+
|
|
107
|
+
| 平台 | 接入方式 | 对外名称来源 |
|
|
108
|
+
|:-----|:---------|:-------------|
|
|
109
|
+
| Claude Code | `.claude-plugin/plugin.json`(`displayName`)+ `.claude-plugin/marketplace.json` | `displayName` |
|
|
110
|
+
| Codex 等指令型 Agent | 本文件 `AGENTS.md` | 标题名称 |
|
|
111
|
+
| DeepSeek Harness (DSH) | `dsh/` 插件 + `cordis.patch.yml` + `presets/` 预设 | 预设 `name` |
|
|
112
|
+
| WorkBuddy / 通用 Agent | 读取 `SKILL.md` | frontmatter `description` |
|
|
113
|
+
|
|
114
|
+
> 说明:SKILL.md 的 frontmatter `name` 必须保持 kebab-case(`gongwen-skill`)以符合 Agent Skill 规范,对外展示统一使用中文展示名「公文全流程处理专家」。
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 6. 许可
|
|
119
|
+
|
|
120
|
+
MIT License,详见 [LICENSE](./LICENSE)。
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,48 @@
|
|
|
4
4
|
Licensed under the MIT License. See the LICENSE file for details.
|
|
5
5
|
-->
|
|
6
6
|
|
|
7
|
+
## v2.14.0 (2026-09-26)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- **解析读取可见性(V2.14)**:文本框内容(`w:txbxContent`,公文红头/发文字号常承载于此)与修订追踪摘要(`w:ins`/`w:del`)正式纳入 DocumentModel(`textboxes` / `revisions` 字段),`parse --json` 结构化输出——此前两者在解析层静默丢失(文本框仅挂非 Pydantic 属性、修订因 python-docx 高层 API 不读 `w:ins` 包裹 run 而整体丢失)
|
|
11
|
+
- **文本框内容检查规则 CHK-TBX001**:检测到文本框但内容为空时提示(红头/发文字号可能缺失);无文本框的文档不触发,避免误报
|
|
12
|
+
- **check/optimize 读取可见性提示**:文档含修订(含作者与增删数)或存在空文本框时,非 JSON 路径显式打印提示,不再静默忽略;`optimize --json` 新增 `textboxes` / `revisions` 字段供 Agent 感知解析降级
|
|
13
|
+
- **未知公文类型显式警告**:check/optimize 对 `-t` 拼错类型不再静默回退 common 规则,打印警告并提示 list-types(发布前全功能测试发现)
|
|
14
|
+
- **新增测试**:`tests/test_read_visibility.py`(文本框入模型、修订摘要、JSON 序列化、普通文档默认值、提示输出、CHK-TBX001、reviewers_count 回归等 7 用例,本地)
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- **npm peer 依赖解析失败(P1,GitHub issue #1)**:`@deepseek-ai/dsh-tools` peer 下限由 `>=0.1.0` 修正为 `>=0.1.5-rc.3`。根因:该包在 npm 上仅发布 rc/alpha 预发布版本(latest tag = `0.0.1-rc.1`),而 npm semver 的预发布 tuple 规则使 `>=0.1.0`(无预发布比较器)无法匹配任何版本,导致 pnpm 安装报 `ERR_PNPM_NO_MATCHING_VERSION`;现对齐官方宿主配套版本(`@deepseek-ai/dsh-base ^0.1.5-rc.3` 传递提供的 dsh-tools)
|
|
18
|
+
- **optimize-content tracked 模式 NameError(P1,发布前全功能测试发现)**:`_run_tracked_mode` 打印「审稿角色」时引用从未赋值的 `reviewers_count`(O10 重构遗留),文档已生成但崩溃 rc=1;现从 `args.reviewers` 取值(full 默认 6 / quick 3),rc 恢复 0
|
|
19
|
+
- **SKILL.md 标题与对外展示名统一**:H1 由「公文文档格式化 Skill(GB/T 9704)」改为「公文全流程处理专家(GB/T 9704)」,三副本(根 / `.dsh/skills/gongwen-skill/SKILL.md` / `.dsh/skills/gongwen-skill.md`)已同步
|
|
20
|
+
- **AGENTS.md 尾部重复行清理**:删除重复的「内容由AI生成,仅供参考」一行
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- **README 下载量徽章动态化**:`Downloads-0` 硬编码徽章改为 PyPI 动态下载量徽章(`img.shields.io/pypi/dm/gongwen-skill`)
|
|
24
|
+
|
|
25
|
+
## v2.13.0 (2026-09-11)
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
- **政策联网检索 `policy-search`**:按主题检索国务院政策文件库(gov.cn,t=zhengcelibrary)→ web 引擎兜底;`--json` 结构化输出供 agent 消费(含 `gov_empty` 诊断字段);抓取复用 `fact_check._safe_fetch_url`(SSRF 防护)+ `netcheck` DoH 兜底;wizard 新增 F 路径「政策检索」(只读直接执行,dry-run 支持)
|
|
29
|
+
- **渲染验收 `render`**:docx 转逐页图片供版面可视化检查(分页/表格劈裂/签章区),复用 `engine/docx_to_image` 完整链路(LibreOffice/docx2pdf → pdftoppm/PyMuPDF);`--pages/--dpi/--format/--json`,只读命令
|
|
30
|
+
- **对外展示名承载层**:`.claude-plugin/plugin.json` + `marketplace.json`(`displayName: 公文全流程处理专家`)+ `AGENTS.md`(Codex 等指令型 Agent 说明),并纳入 `package.json` files 与 `MANIFEST.in` 打包声明
|
|
31
|
+
- **`npx skills add linhut/gongwen-skill` 安装渠道**:README 新增方式零一行安装(Claude Code/Codex/Cursor 等通用 harness)
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
- **对外展示名统一为「公文全流程处理专家」**:原称谓「公文全流程处理工具」在全部面向人与模型可见的文案层被替换,覆盖 `SKILL.md`(三副本 frontmatter `description`)、`dsh/index.js`(`GONGWEN_GUIDANCE` 入口描述 / 工具描述 / `export const description` / 文件头注释)、CLI `--version` 与命令帮助描述(`gongwen/cli/app.py`)、`README.md`、`package.json` 与 `pyproject.toml` 的 `description`、`doctor` 诊断标题(`gongwen/cli/doctor_cmds.py`)、`gongwen/_legacy.py` / `gongwen/__init__.py` / `cordis.patch.yml` / `dsh/client.js` / `etc/dsh-config-defaults.json` 中的称谓注释
|
|
35
|
+
- **机器标识与用户文档内容一律不变**:包名 `gongwen-skill`、命令名 `gongwen`、`SKILL.md` frontmatter `name`、DSH 插件 id/name/ns(`cordis.patch.yml`、`dsh/index.js`)、以及所有写入用户 `.docx` 的署名字符串保持原样;`CHANGELOG` 历史条目与 `docs/design/` 历史记录不改
|
|
36
|
+
- **展示名单一事实来源**:`gongwen/__init__.py` 新增 `DISPLAY_NAME` 常量,CLI `description` / `--version` / `doctor` / `repair` 标题统一引用,消除多处硬编码中文名
|
|
37
|
+
- **doctor 新增「展示名一致性」检查**:校验 SKILL.md frontmatter description、`.claude-plugin/` 两个 JSON 的 `displayName`、`package.json` / `pyproject.toml` description、`dsh/index.js` 插件描述共 6 处承载点与 `DISPLAY_NAME` 一致(文件缺失跳过,不误报)
|
|
38
|
+
- **doctor 新增「DSH 宿主版本」「DSH peer 依赖」检查**:探测本机 `@deepseek-ai/dsh` ≥ 0.1.2-rc.1,peer 下限以 `package.json` peerDependencies 为单一来源;无 DSH 宿主时一致跳过避免误报(asar 布局兼容)
|
|
39
|
+
- **CLI 启动提速约 -72%**:`app.py` 顶层重导入惰性化(`review_cmds` 4 命令经 `_lazy_command` 首次调用时导入、`pagenum` 默认值内联),`--version` 926ms→244ms、`--help` 830ms→234ms
|
|
40
|
+
- **架构导入统一**:28 处旧式顶层导入(`from optimizer/config/fact_check` 等)统一为 `from engine.xxx`,消除对 `_bootstrap` sys.path hack 的运行时依赖
|
|
41
|
+
- **DSH 设置面板精简 39→5 字段(P2-31)**:`dsh/client.js` FIELDS 只保留默认类型+页边距,`dsh/index.js` schema 同步;低频排版参数回归 CLI(`config --set` / `--config-overrides`)
|
|
42
|
+
- **DSH 插件移除运行时技能注册(P2-31)**:`dsh/index.js` 取消 `ctx.skills.register`(与文件系统技能 `~/.dsh/skills/gongwen-skill/` 完全重复),技能发现统一走方式一
|
|
43
|
+
- `AGENTS.md` 命令速查表标注「完整操作指南以 SKILL.md 为准」,避免双表维护漂移
|
|
44
|
+
- **`.gitattributes` 统一文本换行**:`*.js/*.py/*.md/*.json/*.yml/*.yaml` 等强制 LF,消除 Windows 检出时的 CRLF 噪音 diff
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
- `tests/test_wizard.py`:PATH_DEFS 断言更新为 A–F 并校验 F 路径映射(policy-search)
|
|
48
|
+
|
|
7
49
|
## v2.12.0 (2026-09-08)
|
|
8
50
|
|
|
9
51
|
### Added
|
package/README.md
CHANGED
|
@@ -4,13 +4,13 @@ https://github.com/linhut/gongwen-skill
|
|
|
4
4
|
Licensed under the MIT License. See the LICENSE file for details.
|
|
5
5
|
-->
|
|
6
6
|
|
|
7
|
-
#
|
|
7
|
+
# 公文全流程处理专家
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
|
-
<img src="./logo/2026-08-19_11-17-43.png" alt="
|
|
10
|
+
<img src="./logo/2026-08-19_11-17-43.png" alt="公文全流程处理专家" width="760">
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
|
-
>
|
|
13
|
+
> 中文公文全流程处理专家——基于 **GB/T 9704《党政机关公文格式》** 国家标准,支持 **格式检查与修复、内容优化(Word 原生修订+批注/差异对比版)、模板生成、Markdown 转公文、版头版记页码注入、事实核验、风格增强** 等完整能力。原生支持 **DeepSeek Harness (DSH)** 技能系统,打包为可被 AI Agent 直接调用的 Skill,完全自包含,克隆即用。
|
|
14
14
|
|
|
15
15
|
[](https://github.com/linhut/gongwen-skill/actions)
|
|
16
16
|
[](https://pypi.org/project/gongwen-skill/)
|
|
@@ -18,7 +18,7 @@ Licensed under the MIT License. See the LICENSE file for details.
|
|
|
18
18
|

|
|
19
19
|

|
|
20
20
|

|
|
21
|
-

|
|
22
22
|
|
|
23
23
|
本 Skill 源自开源桌面项目 [AI 公文智能优化助手](https://github.com/linhut/document-ai-assistant),将其核心格式引擎抽取、剥离桌面端/数据库依赖后独立发行,支持公文的**模板建立、解析、规则检查、自动修复、内容优化、Markdown 转公文**全流程能力。同时原生集成 **DeepSeek Harness (DSH)** 技能系统,支持 DSH Agent 自动发现与加载。
|
|
24
24
|
|
|
@@ -30,7 +30,7 @@ Licensed under the MIT License. See the LICENSE file for details.
|
|
|
30
30
|
|------|------|------|
|
|
31
31
|
| 📋 列类型 | `list-types` | 列出 25 种支持的公文类型(新增主持词 host_speech;含新闻稿/讲话稿) |
|
|
32
32
|
| 🏗️ 模板生成 | `template` | 按类型生成 GB/T 9704 标准空白模板 |
|
|
33
|
-
| 🔍 解析 | `parse` | `.docx` → 结构化 DocumentModel |
|
|
33
|
+
| 🔍 解析 | `parse` | `.docx` → 结构化 DocumentModel(含文本框/修订摘要) |
|
|
34
34
|
| ✅ 格式检查 | `check` | 按国标检查,分级 P0/P1/P2(只读) |
|
|
35
35
|
| 🔧 格式修复 | `optimize` | 自动修复字体/字号/行距/页边距,输出合规文档;`--verify` 单命令闭环自动复查、P0 存在时退出码非 0;`--json` 结构化输出 |
|
|
36
36
|
| ✍️ **内容优化** | **`optimize-content`** | 内容润色:默认 **Word 原生修订+批注**(审阅面板逐条接受/拒绝),可选行内差异对比版;`--precheck` 预检 changes 与原文一致性、`--preset quick/full/review` 参数收敛 |
|
|
@@ -615,6 +615,7 @@ python -m gongwen optimize input.docx -o output.docx --apply \
|
|
|
615
615
|
| 想让 DSH Agent 调用本技能,无需 Web UI | 方式一(Skill 文件系统) |
|
|
616
616
|
| 想让 DSH Web UI 工具面板直接调用 | 方式二(npm 插件 bundle) |
|
|
617
617
|
| 二开插件本身,本地反复编辑 | 方式三(link 模式) |
|
|
618
|
+
| 通用 Agent 一行安装(Claude Code/Codex/Cursor 等) | `npx skills add linhut/gongwen-skill` |
|
|
618
619
|
|
|
619
620
|
## 🤖 通过 Agent 调用
|
|
620
621
|
|
|
@@ -622,6 +623,13 @@ python -m gongwen optimize input.docx -o output.docx --apply \
|
|
|
622
623
|
|
|
623
624
|
### 安装方式
|
|
624
625
|
|
|
626
|
+
**方式零:npx skills add 一行安装(最简)**
|
|
627
|
+
```bash
|
|
628
|
+
# 任意支持 Agent Skills 的 harness(Claude Code / Codex / Cursor 等)均可:
|
|
629
|
+
# skills CLI 会自动把本技能路由到对应 harness 的 skills 目录
|
|
630
|
+
npx skills add linhut/gongwen-skill
|
|
631
|
+
```
|
|
632
|
+
|
|
625
633
|
**方式一:克隆到 Skills 目录(推荐)**
|
|
626
634
|
```bash
|
|
627
635
|
# WorkBuddy / CloudCode
|
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),以及版头/版记/页码注入。覆盖通知/请示/报告/函/会议纪要等 25 类公文。完全自包含,克隆即用,无需数据库或后端服务。
|
|
4
4
|
whenToUse: 当用户需要处理中文公文(.docx格式)时,包括格式检查、自动修复、内容润色、模板生成、样式学习(从标准文档学习排版样式生成自定义模板)、Markdown转公文、版头版记注入等场景。适用于通知/请示/报告/函/会议纪要/新闻稿/讲话稿等25种公文类型。
|
|
5
5
|
user-invocable: true
|
|
6
6
|
metadata:
|
|
@@ -19,7 +19,7 @@ metadata:
|
|
|
19
19
|
Licensed under the MIT License. See the LICENSE file for details.
|
|
20
20
|
-->
|
|
21
21
|
|
|
22
|
-
#
|
|
22
|
+
# 公文全流程处理专家(GB/T 9704)
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
@@ -900,7 +900,7 @@ python -m gongwen fix-common 文件.docx -o 成品.docx
|
|
|
900
900
|
|
|
901
901
|
| 命令 | 用途 | 最小用法 |
|
|
902
902
|
|------|------|---------|
|
|
903
|
-
| `parse` | .docx → 结构化 DocumentModel JSON | `python -m gongwen parse 公文.docx` |
|
|
903
|
+
| `parse` | .docx → 结构化 DocumentModel JSON(含文本框/修订摘要) | `python -m gongwen parse 公文.docx` |
|
|
904
904
|
| `check` | 按国标检查格式(只读,分级 P0/P1/P2) | `python -m gongwen check 公文.docx -t notice` |
|
|
905
905
|
| `audit` | 审计文档:检查删除线/加粗/AI 声明等痕迹 | `python -m gongwen audit 公文.docx` |
|
|
906
906
|
|
package/cordis.patch.yml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# https://github.com/linhut/gongwen-skill
|
|
3
3
|
# Licensed under the MIT License. See the LICENSE file for details.
|
|
4
4
|
|
|
5
|
-
# dsh bundle layer:
|
|
5
|
+
# dsh bundle layer: 公文全流程处理专家 (gongwen-skill, host + client)
|
|
6
6
|
- insert:
|
|
7
7
|
- id: gongwen-skill
|
|
8
8
|
name: gongwen-skill
|
package/dsh/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// 公文全流程处理专家 DSH client — 设置平级菜单「文档样式配置」(gongwen-skill)
|
|
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.
|
|
@@ -61,6 +61,8 @@ window.__ModuleLoader__.load({
|
|
|
61
61
|
|
|
62
62
|
// 扁平字段表:path(嵌套数组)、label、placeholder、type(text|checkbox|select)
|
|
63
63
|
// 与 dsh/index.js 的 settings schema 保持一一对应
|
|
64
|
+
// P2-31 精简:只保留高频 5 字段(默认类型 + 页边距);字体/字号/行距等
|
|
65
|
+
// 低频排版参数走 CLI(config --set / --config-overrides)
|
|
64
66
|
var FIELDS = [
|
|
65
67
|
{ path: ["default_doc_type"], label: "默认公文类型", placeholder: "notice", type: "select" },
|
|
66
68
|
|
|
@@ -68,46 +70,6 @@ window.__ModuleLoader__.load({
|
|
|
68
70
|
{ path: ["page_setup", "margins", "bottom"], label: "下边距", placeholder: "2.8cm", type: "text" },
|
|
69
71
|
{ path: ["page_setup", "margins", "left"], label: "左边距", placeholder: "2.7cm", type: "text" },
|
|
70
72
|
{ path: ["page_setup", "margins", "right"], label: "右边距", placeholder: "2.7cm", type: "text" },
|
|
71
|
-
{ path: ["page_setup", "header_distance"], label: "页眉距", placeholder: "1.5cm", type: "text" },
|
|
72
|
-
{ path: ["page_setup", "footer_distance"], label: "页脚距", placeholder: "2.3cm", type: "text" },
|
|
73
|
-
|
|
74
|
-
{ path: ["body", "font"], label: "正文·字体", placeholder: "仿宋_GB2312", type: "text" },
|
|
75
|
-
{ path: ["body", "font_fallback"], label: "正文·字体回退", placeholder: "FangSong", type: "text" },
|
|
76
|
-
{ path: ["body", "size"], label: "正文·字号", placeholder: "16pt", type: "text" },
|
|
77
|
-
{ path: ["body", "line_spacing"], label: "正文·行距", placeholder: "33pt", type: "text" },
|
|
78
|
-
{ path: ["body", "first_line_indent"], label: "正文·首行缩进", placeholder: "2em", type: "text" },
|
|
79
|
-
{ path: ["body", "align"], label: "正文·对齐", placeholder: "justify", type: "text" },
|
|
80
|
-
|
|
81
|
-
{ path: ["doc_title", "font"], label: "标题·字体", placeholder: "方正小标宋简体", type: "text" },
|
|
82
|
-
{ path: ["doc_title", "font_fallback"], label: "标题·字体回退", placeholder: "SimSun", type: "text" },
|
|
83
|
-
{ path: ["doc_title", "size"], label: "标题·字号", placeholder: "22pt", type: "text" },
|
|
84
|
-
{ path: ["doc_title", "align"], label: "标题·对齐", placeholder: "center", type: "text" },
|
|
85
|
-
{ path: ["doc_title", "bold"], label: "标题·加粗", type: "checkbox" },
|
|
86
|
-
{ path: ["doc_title", "line_spacing"], label: "标题·行距", placeholder: "33pt", type: "text" },
|
|
87
|
-
|
|
88
|
-
{ path: ["heading_1", "font"], label: "一级标题·字体", placeholder: "黑体", type: "text" },
|
|
89
|
-
{ path: ["heading_1", "font_fallback"], label: "一级标题·字体回退", placeholder: "SimHei", type: "text" },
|
|
90
|
-
{ path: ["heading_1", "size"], label: "一级标题·字号", placeholder: "16pt", type: "text" },
|
|
91
|
-
{ path: ["heading_1", "line_spacing"], label: "一级标题·行距", placeholder: "33pt", type: "text" },
|
|
92
|
-
{ path: ["heading_1", "first_line_indent"], label: "一级标题·首行缩进", placeholder: "2em", type: "text" },
|
|
93
|
-
|
|
94
|
-
{ path: ["heading_2", "font"], label: "二级标题·字体", placeholder: "楷体_GB2312", type: "text" },
|
|
95
|
-
{ path: ["heading_2", "font_fallback"], label: "二级标题·字体回退", placeholder: "KaiTi", type: "text" },
|
|
96
|
-
{ path: ["heading_2", "size"], label: "二级标题·字号", placeholder: "16pt", type: "text" },
|
|
97
|
-
{ path: ["heading_2", "line_spacing"], label: "二级标题·行距", placeholder: "33pt", type: "text" },
|
|
98
|
-
{ path: ["heading_2", "first_line_indent"], label: "二级标题·首行缩进", placeholder: "2em", type: "text" },
|
|
99
|
-
|
|
100
|
-
{ path: ["heading_3", "font"], label: "三级标题·字体", placeholder: "仿宋_GB2312", type: "text" },
|
|
101
|
-
{ path: ["heading_3", "font_fallback"], label: "三级标题·字体回退", placeholder: "FangSong", type: "text" },
|
|
102
|
-
{ path: ["heading_3", "size"], label: "三级标题·字号", placeholder: "16pt", type: "text" },
|
|
103
|
-
{ path: ["heading_3", "bold"], label: "三级标题·加粗", type: "checkbox" },
|
|
104
|
-
{ path: ["heading_3", "line_spacing"], label: "三级标题·行距", placeholder: "33pt", type: "text" },
|
|
105
|
-
{ path: ["heading_3", "first_line_indent"], label: "三级标题·首行缩进", placeholder: "2em", type: "text" },
|
|
106
|
-
|
|
107
|
-
{ path: ["signature", "font"], label: "署名·字体", placeholder: "仿宋_GB2312", type: "text" },
|
|
108
|
-
{ path: ["signature", "font_fallback"], label: "署名·字体回退", placeholder: "FangSong", type: "text" },
|
|
109
|
-
{ path: ["signature", "size"], label: "署名·字号", placeholder: "18pt", type: "text" },
|
|
110
|
-
{ path: ["signature", "align"], label: "署名·对齐", placeholder: "center", type: "text" },
|
|
111
73
|
];
|
|
112
74
|
|
|
113
75
|
// 从嵌套 value 中取路径值
|
|
@@ -438,13 +400,7 @@ window.__ModuleLoader__.load({
|
|
|
438
400
|
}, "设置服务不可用(当前部署未挂载 settings provider),排版参数区只读。"),
|
|
439
401
|
|
|
440
402
|
renderGroup("基础设置", FIELDS.slice(0, 1)),
|
|
441
|
-
renderGroup("页面设置", FIELDS.slice(1,
|
|
442
|
-
renderGroup("正文格式", FIELDS.slice(7, 13)),
|
|
443
|
-
renderGroup("公文标题", FIELDS.slice(13, 19)),
|
|
444
|
-
renderGroup("一级标题", FIELDS.slice(19, 24)),
|
|
445
|
-
renderGroup("二级标题", FIELDS.slice(24, 29)),
|
|
446
|
-
renderGroup("三级标题", FIELDS.slice(29, 35)),
|
|
447
|
-
renderGroup("署名格式", FIELDS.slice(35, 39)),
|
|
403
|
+
renderGroup("页面设置", FIELDS.slice(1, 5)),
|
|
448
404
|
|
|
449
405
|
h("div", { style: { display: "flex", gap: "10px", marginTop: "16px", alignItems: "center" } },
|
|
450
406
|
h("button", {
|
package/dsh/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// 公文全流程处理专家 - DSH plugin bridge (gongwen-skill, v2.14.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.
|
|
@@ -11,13 +11,14 @@
|
|
|
11
11
|
// * ctx.systemPrompt.section 注入 AI 工作指引(可选服务,缺失不阻塞)
|
|
12
12
|
// * ctx.settings.register('gongwen-skill') 官方设置命名空间(schemastery schema),
|
|
13
13
|
// scope.watch 回写 ~/.gongwen-skill/dsh-config.json 保持 CLI 兼容
|
|
14
|
-
// * ctx.skills.register 运行时注册 SKILL.md(可选服务)
|
|
15
14
|
// * call() 透传 Python CLI(向后兼容旧调用方)
|
|
16
15
|
//
|
|
16
|
+
// 技能发现走文件系统(~/.dsh/skills/gongwen-skill/,方式一),插件不再
|
|
17
|
+
// 运行时注册 SKILL.md(P2-31:与文件系统技能重复,去掉冗余 API 面)。
|
|
18
|
+
//
|
|
17
19
|
// 官方依据:DeepSeek Harness Bluebook Developer Guide
|
|
18
20
|
// - Host Services & Events:inject 硬依赖 / ctx.get 可选依赖 / ctx.effect 可逆副作用
|
|
19
21
|
// - Registering Tools:defineTool + ctx.tools.register
|
|
20
|
-
// - User Guide · Skills:ctx.skills.register(SkillRegistration)
|
|
21
22
|
// 纯 CLI 用户完全不受影响(不使用 DSH 插件时不会读取 dsh-config.json)
|
|
22
23
|
|
|
23
24
|
import { spawn } from "node:child_process";
|
|
@@ -44,7 +45,7 @@ const SECTION_NAME = "plugin:gongwen-skill";
|
|
|
44
45
|
const SECTION_ORDER = 100;
|
|
45
46
|
|
|
46
47
|
// AI 工作指引(模型可见的能力说明;工具 schema 由 defineTool 自动注入)
|
|
47
|
-
const GONGWEN_GUIDANCE =
|
|
48
|
+
const GONGWEN_GUIDANCE = `本机已安装公文全流程处理专家 插件(gongwen-skill)。能力:.docx 公文全流程——列出公文类型(list-types)、解析文档(parse)、格式检查(check)、自动修复(optimize)、内容修订对比版(optimize-content)、模板生成(template)、样式学习(style-learn/style-list,从标准文档学习排版样式)、全面诊断(doctor)、自动修复(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)。覆盖通知/请示/报告/函/会议纪要等 25 类公文。完全自包含,克隆即用,无需数据库或后端服务。用户提到「公文 / 红头文件 / 版式 / 排版 / 格式检查 / 公文模板 / 样式学习 / 自定义模板 / 党政机关公文」时即指本插件。DSH 插件支持配置化排版参数(页边距/行距/字体等):在系统设置 → 文档样式配置 中调整,写入官方 settings 命名空间并同步到 ~/.gongwen-skill/dsh-config.json。`;
|
|
48
49
|
|
|
49
50
|
// 定位 gongwen CLI 真实安装根目录
|
|
50
51
|
function _resolve_gongwen_root() {
|
|
@@ -249,6 +250,8 @@ function _handle_config(args) {
|
|
|
249
250
|
|
|
250
251
|
// 构建系统设置 Schema(schemastery 官方 API:Schema.object / Schema.string ...)
|
|
251
252
|
function _build_settings_schema() {
|
|
253
|
+
// P2-31 精简:Web 面板只保留高频 5 字段(默认类型 + 页边距);
|
|
254
|
+
// 字体/字号/行距等低频排版参数走 CLI(config --set / --config-overrides)
|
|
252
255
|
return Schema.object({
|
|
253
256
|
default_doc_type: Schema.string().default("notice").description("默认公文类型"),
|
|
254
257
|
page_setup: Schema.object({
|
|
@@ -258,53 +261,7 @@ function _build_settings_schema() {
|
|
|
258
261
|
left: Schema.string().default("2.7cm").description("左边距"),
|
|
259
262
|
right: Schema.string().default("2.7cm").description("右边距"),
|
|
260
263
|
}).description("页边距"),
|
|
261
|
-
header_distance: Schema.string().default("1.5cm").description("页眉距"),
|
|
262
|
-
footer_distance: Schema.string().default("2.3cm").description("页脚距"),
|
|
263
264
|
}).description("页面设置"),
|
|
264
|
-
body: Schema.object({
|
|
265
|
-
font: Schema.string().default("仿宋_GB2312").description("正文字体"),
|
|
266
|
-
font_fallback: Schema.string().default("FangSong").description("字体回退"),
|
|
267
|
-
size: Schema.string().default("16pt").description("正文字号"),
|
|
268
|
-
line_spacing: Schema.string().default("33pt").description("行距"),
|
|
269
|
-
first_line_indent: Schema.string().default("2em").description("首行缩进"),
|
|
270
|
-
align: Schema.string().default("justify").description("对齐方式"),
|
|
271
|
-
}).description("正文格式"),
|
|
272
|
-
doc_title: Schema.object({
|
|
273
|
-
font: Schema.string().default("方正小标宋简体").description("标题字体"),
|
|
274
|
-
font_fallback: Schema.string().default("SimSun").description("字体回退"),
|
|
275
|
-
size: Schema.string().default("22pt").description("标题字号"),
|
|
276
|
-
align: Schema.string().default("center").description("对齐方式"),
|
|
277
|
-
bold: Schema.boolean().default(false).description("是否加粗"),
|
|
278
|
-
line_spacing: Schema.string().default("33pt").description("行距"),
|
|
279
|
-
}).description("公文标题"),
|
|
280
|
-
heading_1: Schema.object({
|
|
281
|
-
font: Schema.string().default("黑体").description("一级标题字体"),
|
|
282
|
-
font_fallback: Schema.string().default("SimHei").description("字体回退"),
|
|
283
|
-
size: Schema.string().default("16pt").description("字号"),
|
|
284
|
-
line_spacing: Schema.string().default("33pt").description("行距"),
|
|
285
|
-
first_line_indent: Schema.string().default("2em").description("首行缩进"),
|
|
286
|
-
}).description("一级标题"),
|
|
287
|
-
heading_2: Schema.object({
|
|
288
|
-
font: Schema.string().default("楷体_GB2312").description("二级标题字体"),
|
|
289
|
-
font_fallback: Schema.string().default("KaiTi").description("字体回退"),
|
|
290
|
-
size: Schema.string().default("16pt").description("字号"),
|
|
291
|
-
line_spacing: Schema.string().default("33pt").description("行距"),
|
|
292
|
-
first_line_indent: Schema.string().default("2em").description("首行缩进"),
|
|
293
|
-
}).description("二级标题"),
|
|
294
|
-
heading_3: Schema.object({
|
|
295
|
-
font: Schema.string().default("仿宋_GB2312").description("三级标题字体"),
|
|
296
|
-
font_fallback: Schema.string().default("FangSong").description("字体回退"),
|
|
297
|
-
size: Schema.string().default("16pt").description("字号"),
|
|
298
|
-
bold: Schema.boolean().default(true).description("是否加粗"),
|
|
299
|
-
line_spacing: Schema.string().default("33pt").description("行距"),
|
|
300
|
-
first_line_indent: Schema.string().default("2em").description("首行缩进"),
|
|
301
|
-
}).description("三级标题"),
|
|
302
|
-
signature: Schema.object({
|
|
303
|
-
font: Schema.string().default("仿宋_GB2312").description("署名字体"),
|
|
304
|
-
font_fallback: Schema.string().default("FangSong").description("字体回退"),
|
|
305
|
-
size: Schema.string().default("18pt").description("署名字号"),
|
|
306
|
-
align: Schema.string().default("center").description("对齐方式"),
|
|
307
|
-
}).description("署名格式"),
|
|
308
265
|
});
|
|
309
266
|
}
|
|
310
267
|
|
|
@@ -484,7 +441,7 @@ function registerGongwenTool(ctx) {
|
|
|
484
441
|
ctx.tools.register(defineTool({
|
|
485
442
|
name: "gongwen",
|
|
486
443
|
description:
|
|
487
|
-
"
|
|
444
|
+
"运行公文全流程处理专家(gongwen-skill)CLI 命令:check(格式检查)、optimize(自动修复)、optimize-content(内容修订对比版)、md2docx(Markdown 转公文)、template(模板生成)、style-learn(样式学习)、list-types(列出公文类型)、doctor(全面诊断)、handoff(会话交接)等。",
|
|
488
445
|
parameters: {
|
|
489
446
|
command: {
|
|
490
447
|
type: "string",
|
|
@@ -529,7 +486,7 @@ function registerGongwenTool(ctx) {
|
|
|
529
486
|
|
|
530
487
|
export const name = "gongwen-skill";
|
|
531
488
|
export const description =
|
|
532
|
-
"
|
|
489
|
+
"公文全流程处理专家(gongwen-skill)—— 中文公文 GB/T 9704 格式检查/修复/内容优化/模板生成/版式注入";
|
|
533
490
|
|
|
534
491
|
// 硬依赖:tools(模型工具注册需要)。systemPrompt / settings / skills 为可选服务,
|
|
535
492
|
// 分别用 ctx.get / ctx.inject 处理,避免在未挂载对应提供方的组合中阻塞插件加载。
|
|
@@ -610,30 +567,7 @@ export function apply(ctx) {
|
|
|
610
567
|
console.error("[gongwen-skill] settings inject failed:", e);
|
|
611
568
|
}
|
|
612
569
|
|
|
613
|
-
// 4.
|
|
614
|
-
const skills = ctx.get("skills");
|
|
615
|
-
if (skills?.register) {
|
|
616
|
-
try {
|
|
617
|
-
const skillPath = join(resolve(__dirname, ".."), "SKILL.md");
|
|
618
|
-
if (existsSync(skillPath)) {
|
|
619
|
-
const skillContent = readFileSync(skillPath, "utf-8");
|
|
620
|
-
const skillD = skills.register({
|
|
621
|
-
name: "gongwen-skill",
|
|
622
|
-
description:
|
|
623
|
-
"中文公文全流程处理:格式检查/自动修复/content润色/模板生成/样式学习/Markdown转公文/版头版记注入",
|
|
624
|
-
content: skillContent,
|
|
625
|
-
resourceBase: { kind: "directory", path: resolve(__dirname, "..") },
|
|
626
|
-
invocation: { modelInvocable: true, userInvocable: true },
|
|
627
|
-
});
|
|
628
|
-
if (typeof skillD === "function") disposers.push(skillD);
|
|
629
|
-
ctx.logger?.info?.("gongwen-skill: runtime skill registered");
|
|
630
|
-
}
|
|
631
|
-
} catch (e) {
|
|
632
|
-
ctx.logger?.warn?.(`gongwen-skill: runtime skill registration skipped: ${e.message}`);
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
// 5. 安装 Agent 预设(presets/ → ~/.dsh/.agent-presets/gongwen-skill/,
|
|
570
|
+
// 4. 安装 Agent 预设(presets/ → ~/.dsh/.agent-presets/gongwen-skill/,
|
|
637
571
|
// 让 DSH 新建会话可选「公文全流程处理专家」;失败不影响插件其余能力)
|
|
638
572
|
ensurePresetInstalled();
|
|
639
573
|
|
package/engine/auto_optimizer.py
CHANGED
|
@@ -314,7 +314,7 @@ def auto_generate_changes(input_path: str, doc_type: str,
|
|
|
314
314
|
if not changes:
|
|
315
315
|
logger.info("LLM 未生成建议(可能未配置或返回空),尝试基于规则的结构建议")
|
|
316
316
|
try:
|
|
317
|
-
from structure_checker import check_structure
|
|
317
|
+
from engine.structure_checker import check_structure
|
|
318
318
|
issues = check_structure(model.paragraphs, content_rules.get("structure", []))
|
|
319
319
|
for issue in issues:
|
|
320
320
|
changes.append({
|
|
@@ -122,6 +122,32 @@ class HeaderFooter(BaseModel):
|
|
|
122
122
|
has_page_number: bool = False # 是否包含页码域
|
|
123
123
|
|
|
124
124
|
|
|
125
|
+
# ---------------------------------------------------------------------------
|
|
126
|
+
# Read-visibility structures(V2.14:读取可见性)
|
|
127
|
+
# 公文红头/发文字号常承载于文本框(<w:txbxContent>),修订(<w:ins>/<w:del>)
|
|
128
|
+
# 是流转中的草稿核心信息——两者此前在解析层静默丢失,现正式纳入模型。
|
|
129
|
+
# ---------------------------------------------------------------------------
|
|
130
|
+
|
|
131
|
+
class TextBox(BaseModel):
|
|
132
|
+
"""文本框内容(红头、发文字号等常承载于文本框)。"""
|
|
133
|
+
index: int = 0
|
|
134
|
+
text: str = ""
|
|
135
|
+
paragraphs: list[str] = Field(default_factory=list)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class RevisionInfo(BaseModel):
|
|
139
|
+
"""文档修订追踪摘要(w:ins 新增 / w:del 删除)。"""
|
|
140
|
+
insert_count: int = 0
|
|
141
|
+
delete_count: int = 0
|
|
142
|
+
authors: list[str] = Field(default_factory=list)
|
|
143
|
+
inserted_snippets: list[str] = Field(default_factory=list) # 新增内容片段(前 5 条)
|
|
144
|
+
deleted_snippets: list[str] = Field(default_factory=list) # 删除内容片段(前 5 条)
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def has_revisions(self) -> bool:
|
|
148
|
+
return self.insert_count > 0 or self.delete_count > 0
|
|
149
|
+
|
|
150
|
+
|
|
125
151
|
# ---------------------------------------------------------------------------
|
|
126
152
|
# Page setup
|
|
127
153
|
# ---------------------------------------------------------------------------
|
|
@@ -170,6 +196,10 @@ class DocumentModel(BaseModel):
|
|
|
170
196
|
headers: list[HeaderFooter] = Field(default_factory=list)
|
|
171
197
|
footers: list[HeaderFooter] = Field(default_factory=list)
|
|
172
198
|
|
|
199
|
+
# V2.14:读取可见性——文本框内容与修订摘要(此前静默丢失)
|
|
200
|
+
textboxes: list[TextBox] = Field(default_factory=list)
|
|
201
|
+
revisions: RevisionInfo = Field(default_factory=RevisionInfo)
|
|
202
|
+
|
|
173
203
|
# Source file info
|
|
174
204
|
filename: Optional[str] = Field(default=None, exclude=True)
|
|
175
205
|
source_path: Optional[str] = Field(default=None, exclude=True)
|