微算力 · API 导航与自营网关
API 接入 EN
未登录登录
📄

AI 审阅专用 Word 处理引擎

docx-md · v1.0.1
办公 安全 B 级 作者 yanweiliang323868-del 公开目录收录
1.2k 下载 0 安装 5.3k 收藏 22 浏览

简介

原生 OOXML 解析工具链,实现 Word 文档读取、AI 修订应用与定稿全流程,无需依赖商业库,适合 LLM 驱动的文档审阅场景。

原始描述

Low-level docx format tool for AI document review. Three operations: (1) read docx → output compact Markdown or JSON; (2) apply edits JSON back to docx (trac...

通过你的 Agent 添加

点「快速安装」复制一段指令,粘给你正在用的 Agent(Claude Code、Codex、OpenClaw 等),它会自己完成安装。

或者手动安装

Claude Codeunzip -o skill.zip -d ~/.claude/skills/docx-md/
其它 Agent解压到它自己的 skills 目录,目录名用 docx-md

包里是 SKILL.md 加作者附带的文件,解压后目录名就是技能名。 技能申请的权限由作者决定,装之前请确认它能读什么、能执行什么。

中文使用说明 来自收录源

核心功能

docx-md 是一套低层级 Word 文档处理工具,专为 AI 文档审阅设计。它提供三个核心操作:读取(docx → Markdown/JSON)、修改(应用 AI 返回的修订)、定稿(接受修订并移除批注)。工具直接操作 OOXML 格式(ZIP + XML),不依赖 Microsoft Word 或商业库如 python-docx,确保跨平台可用性与格式兼容性。

显著优势

  • Token 高效:默认输出 Markdown 格式,含 <!-- b:N --> 块索引标记,显著降低 LLM 上下文长度;JSON 模式提供完整结构可选
  • 原生 OOXML 支持:直接解析 word/document.xml 和 word/comments.xml,支持修订痕迹(w:ins/w:del)与批注锚点
  • 完整工作流闭环:读取 → AI 编辑 → 应用修订 → 定稿输出,支持 tracked changes 和 comments 的商业级协作需求
  • 轻量无依赖:除 docx-revisions(定稿阶段可选)外,核心功能纯标准库实现

潜在局限

  • 仅解析 w:body 内容,页眉/页脚、脚注、尾注、图表、复杂表格样式可能丢失或简化
  • Markdown 格式为自定义方言,需配合特定 JSON 编辑格式(blockIndex, originalContent, content, basis)使用
  • 复杂格式(如修订嵌套、跨段落修订、样式继承)的还原精度取决于 OOXML 实现覆盖度
  • 无可视化界面,纯命令行工具,需技术用户操作

适用人群

  • 构建合同审查、法律文书、学术论文 AI 审阅系统的开发者
  • 需在 CI/CD 流程中自动化 Word 文档处理的技术团队
  • 追求 token 效率、希望替代昂贵商业 Office 自动化的场景

常规风险

  • 格式丢失风险:非正文元素(文本框、嵌入式对象、复杂域代码)可能无法保留
  • 修订冲突:并发编辑或复杂修订历史可能导致 apply 阶段推断错误
  • 编码与国际化:OOXML 编码处理需验证多语言文档(CJK、RTL 语言)兼容性
  • 依赖风险:定稿阶段依赖第三方库 docx-revisions,需审计其维护状态

认证状态

⚠️ 本技能未执行实际安全扫描,安全等级为基于架构的预评估。

技能正文


name: docx-md description: | Low-level docx format tool for AI document review. Three operations: (1) read docx → output compact Markdown or JSON; (2) apply edits JSON back to docx (tracked revisions and comments); (3) finalize (accept revisions, remove comments). Markdown output saves tokens vs full JSON. Use when raw .docx read/write is needed. For full contract review workflow, use contract-review-workflow which invokes this tool.

Word DOCX (OOXML) – docx-md

Overview

Three entry points: Read – output compact Markdown (default, token-efficient) or full JSON; Modify – apply AI-returned edits to the docx; Finalize – accept all revisions and remove all comments. Implemented via OOXML (ZIP + XML). No commercial Word libraries required.

Workflow

Goal Action
Get document for AI Read: run read script → Markdown (default) or JSON. Markdown includes <!-- b:N --> blockIndex markers for edit targeting.
Apply AI edits to docx Modify: run apply script with docx + edits JSON → new docx with track changes and comments.
Deliver final version Finalize: run finalize script → new docx with no revisions/comments.

LLM-oriented pipeline

  1. Read – Parse docx; output Markdown (default) or JSON. Markdown uses <!-- b:N --> prefix per block; revisions: {+inserted+} {-deleted-}; comments: [comment: text].
  2. Send the output + task prompt to the model; require the model to output only the edit JSON: blockIndex, originalContent, content, basis .
  3. Modify – Script infers op from blockIndex, originalContent, content, basis; converts to OOXML (w:ins / w:del / comment anchors), then write back to Word.
  4. Finalize – When the user confirms, run finalize to accept all revisions and remove all comments.

See references/llm-pipeline.md for the Markdown format, JSON schema, and edit format.

1. Read

  • Parse word/document.xml (w:body only) and word/comments.xml.
  • Output Markdown (default) or JSON. Markdown is compact and token-efficient.

Script: scripts/read_docx.py

# Default: Markdown output (token-efficient)
python3 skills/docx-md/scripts/read_docx.py document.docx
python3 skills/docx-md/scripts/read_docx.py document.docx -o result.md

# JSON output (full structure)
python3 skills/docx-md/scripts/read_docx.py document.docx -f json -o result.json

Options:

  • -o, --output – Output path (default: stdout)
  • -f, --format – md (default) or json

2. Modify

  • Input: docx path + edit JSON { modifications: [{ blockIndex, originalContent, content, basis }] } (same blockIndex as read output).
  • Flow: Convert JSON to OOXML (w:ins / w:del / comments), then write back to Word.

Script: scripts/apply_edits_docx.py. Use - as edits file to read JSON from stdin.

python3 skills/docx-md/scripts/apply_edits_docx.py document.docx edits.json -o output.docx
python3 skills/docx-md/scripts/apply_edits_docx.py document.docx - -o output.docx  # stdin

Options: --author (default: "Review")

3. Finalize

  • Accept all revisions (flatten to final text), remove all comments. Save as new docx.
  • Uses docx-revisions to accept revisions (preserves encoding), then removes comment markup via regex on raw bytes.

Script: scripts/finalize_docx.py

Requires: pip install docx-revisions (see requirements.txt)

python3 skills/docx-md/scripts/finalize_docx.py input.docx -o output.docx

Resources

scripts/

  • read_docx.py – Read: python3 scripts/read_docx.py document.docx [-o out.md] [-f md|json]
  • apply_edits_docx.py – Modify: python3 scripts/apply_edits_docx.py document.docx edits.json -o output.docx
  • finalize_docx.py – Finalize: python3 scripts/finalize_docx.py input.docx -o output.docx

references/

  • ooxml.md – OOXML layout (document.xml, comments.xml, revisions, comments)
  • llm-pipeline.md – Pipeline: read → Markdown/JSON → model edits → modify; defines Markdown format, JSON shape (blockIndex, originalContent, content, basis)

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

document-processingooxmlwordmarkdownrevision-trackingcli-toolllm-pipeline

同类 Skill