docx-md
v1.0.1Low-level docx 格式化 工具 for AI document review. Three operations: (1) read docx → 输出 compact Markdown or JSON; (2) 应用ly edits JSON back to docx (追踪ed revisions and comments); (3) finalize (accept revisions, 移除 comments). Markdown 输出 saves 令牌s vs full JSON. Use when raw .docx read/write is needed. For full contract review 工作流, use contract-review-工作流 which invokes this 工具.
运行时依赖
安装命令
点击复制技能文档
Word DOCX (OOXML) – docx-md Overview
Three entry points: Read – 输出 compact Markdown (default, 令牌-efficient) or full JSON; Modify – 应用ly AI-returned edits to the docx; Finalize – accept all revisions and 移除 all comments. Implemented via OOXML (ZIP + XML). No commercial Word libraries required.
工作流 Goal Action 获取 document for AI Read: 运行 read script → Markdown (default) or JSON. Markdown includes block索引 markers for edit tar获取ing. 应用ly AI edits to docx Modify: 运行 应用ly script with docx + edits JSON → new docx with 追踪 changes and comments. Deliver final version Finalize: 运行 finalize script → new docx with no revisions/comments. LLM-oriented 流水线 Read – 解析 docx; 输出 Markdown (default) or JSON. Markdown uses prefix per block; revisions: {+inserted+} {-删除d-}; comments: [comment: text]. 发送 the 输出 + task prompt to the 模型; require the 模型 to 输出 only the edit JSON: block索引, originalContent, content, basis . Modify – Script infers op from block索引, originalContent, content, basis; converts to OOXML (w:ins / w:del / comment anchors), then write back to Word. Finalize – When the user confirms, 运行 finalize to accept all revisions and 移除 all comments.
See references/llm-流水线.md for the Markdown 格式化, JSON 模式, and edit 格式化.
- Read
Script: scripts/read_docx.py
# Default: Markdown 输出 (令牌-efficient) python3 技能s/docx-md/scripts/read_docx.py document.docx python3 技能s/docx-md/scripts/read_docx.py document.docx -o 结果.md
# JSON 输出 (full structure) python3 技能s/docx-md/scripts/read_docx.py document.docx -f json -o 结果.json
Options:
-o, --输出 – 输出 path (default: stdout) -f, --格式化 – md (default) or json
- Modify
Script: scripts/应用ly_edits_docx.py. Use - as edits file to read JSON from stdin.
python3 技能s/docx-md/scripts/应用ly_edits_docx.py document.docx edits.json -o 输出.docx python3 技能s/docx-md/scripts/应用ly_edits_docx.py document.docx - -o 输出.docx # stdin
Options: --author (default: "Review")
- Finalize
Script: scripts/finalize_docx.py
Requires: pip 安装 docx-revisions (see requirements.txt)
python3 技能s/docx-md/scripts/finalize_docx.py 输入.docx -o 输出.docx
Resources scripts/ read_docx.py – Read: python3 scripts/read_docx.py document.docx [-o out.md] [-f md|json] 应用ly_edits_docx.py – Modify: python3 scripts/应用ly_edits_docx.py document.docx edits.json -o 输出.docx finalize_docx.py – Finalize: python3 scripts/finalize_docx.py 输入.docx -o 输出.docx references/ ooxml.md – OOXML layout (document.xml, comments.xml, revisions, comments) llm-流水线.md – 流水线: read → Markdown/JSON → 模型 edits → modify; defines Markdown 格式化, JSON shape (block索引, originalContent, content, basis)