← 返回 Skills 市场
hanselxie

用于为Word文档开启并调整修订模式,添加、删除批注等功能

作者 HanselXie · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
242
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install docx-trackchanges-and-comments
功能描述
Word文档 (.docx) 处理,支持修订模式(Track Changes)和批注操作。使用场景:(1) 修订模式 - 添加插入/删除修订、红字标注;(2) 批注操作 - 添加、删除、查看批注;(3) 文档内容修改。当用户要求"修订"、"track changes"、"批注"、"红字修订"、"添加评论"、"添加...
使用说明 (SKILL.md)

Word 文档处理 (修订模式 + 批注)

概述

Word 文档基于 OOXML 标准,内部结构为 ZIP 包,主要 XML 文件:

  • word/document.xml - 文档正文内容
  • word/comments.xml - 批注内容存储
  • word/settings.xml - 文档设置(包含修订模式开关)

快速开始

使用脚本添加修订/批注

手动操作流程

  1. 解压文档:unzip -o document.docx -d docx_temp
  2. 编辑 XML 文件
  3. 重新打包:cd docx_temp && zip -r ../output.docx . && cd .. && rm -rf docx_temp

功能一:修订模式 (Track Changes)

启用修订模式

word/settings.xml 中添加:

\x3Cw:trackChanges>true\x3C/w:trackChanges>

添加插入修订

from scripts.track_changes import add_insertion
add_insertion(doc, "要插入的新内容", author="何大拿")

XML 原理:使用 \x3Cw:ins> 标签包裹插入内容(绿色下划线)

添加删除修订

from scripts.track_changes import add_deletion
add_deletion(doc, "要删除的原文", author="何大拿")

XML 原理:使用 \x3Cw:del> 标签包裹删除内容(红色删除线)


功能二:批注操作

批注结构

批注涉及两个文件:

  1. word/comments.xml - 存储批注内容
  2. word/document.xml - 存储批注引用位置

快速查看批注

cd /path/to/inbound
unzip -o document.docx -d docx_temp
cat docx_temp/word/comments.xml

添加批注(XML 级别)

Step 1: 解压文档

cd /Users/hansel/.openclaw/media/inbound
unzip -o document.docx -d docx_temp

Step 2: 编辑 XML

需要修改两个文件:

2.1 修改 comments.xml

找到下一个可用的 comment ID:

grep -o 'w:id="[0-9]*"' docx_temp/word/comments.xml | sed 's/w:id="//;s/"//' | sort -n | tail -1

假设下一个 ID 是 1,添加新批注:

\x3Cw:comment w:id="1" w:author="你的名字" w:date="2026-03-17T14:00:00Z" w:initials="XX">
  \x3Cw:p w:rsidRDefault="00C227CD">
    \x3Cw:r>\x3Cw:t>批注内容\x3C/w:t>\x3C/w:r>
  \x3C/w:p>
\x3C/w:comment>

XML 实体转义:&&\x3C<>>

2.2 修改 document.xml

在需要添加批注的文本位置添加标记:

\x3C!-- 批注开始标记 -->
\x3Cw:commentRangeStart w:id="1"/>

\x3C!-- 被批注的文本 -->
\x3Cw:r>\x3Cw:t>这里是正文内容\x3C/w:t>\x3C/w:r>

\x3C!-- 批注结束标记 -->
\x3Cw:commentRangeEnd w:id="1"/>

\x3C!-- 批注引用标记(显示为上标数字) -->
\x3Cw:r>
  \x3Cw:rPr>
    \x3Cw:rStyle w:val="CommentReference"/>
  \x3C/w:rPr>
  \x3Cw:commentReference w:id="1"/>
\x3C/w:r>

⚠️ 重要

  • \x3Cw:commentRangeStart>\x3Cw:commentRangeEnd>\x3Cw:p>同级兄弟元素
  • \x3Cw:commentReference> 需要包裹在 \x3Cw:r>

Step 3: 重新打包

cd docx_temp && zip -r ../output.docx . && cd ..
rm -rf docx_temp

删除批注

  1. comments.xml 中删除对应的 \x3Cw:comment> 元素
  2. document.xml 中删除三处标记:
    • \x3Cw:commentRangeStart w:id="X"/>
    • \x3Cw:commentRangeEnd w:id="X"/>
    • 包含 \x3Cw:commentReference w:id="X"/> 的整个 \x3Cw:r> 元素
  3. 重新打包

接受批注(将批注内容合并到正文)

  1. document.xml 中删除三处批注标记
  2. 保留 comments.xml 中的批注内容(可选)
  3. 重新打包

批注 XML 详解

comments.xml 结构

\x3C?xml version="1.0" encoding="UTF-8" standalone="yes"?>
\x3Cw:comments xmlns:w="...">
  \x3Cw:comment w:id="0" w:author="作者名" w:date="2026-01-01T12:00:00Z" w:initials="XX">
    \x3Cw:p w:rsidRDefault="00C227CD">
      \x3Cw:r>\x3Cw:rPr>\x3Cw:rStyle w:val="ae"/>\x3C/w:rPr>\x3Cw:annotationRef/>\x3C/w:r>
      \x3Cw:r>\x3Cw:t>批注内容\x3C/w:t>\x3C/w:r>
    \x3C/w:p>
  \x3C/w:comment>
\x3C/w:comments>

document.xml 中的批注引用

\x3Cw:p>
  \x3Cw:commentRangeStart w:id="0"/>
  \x3Cw:r>\x3Cw:t>被批注的文本\x3C/w:t>\x3C/w:r>
  \x3Cw:commentRangeEnd w:id="0"/>
  \x3Cw:r>
    \x3Cw:rPr>
      \x3Cw:rStyle w:val="CommentReference"/>
    \x3C/w:rPr>
    \x3Cw:commentReference w:id="0"/>
  \x3C/w:r>
\x3C/w:p>

注意事项

  • 作者名称:建议使用英文或拼音
  • 日期格式:ISO 8601 格式,如 2026-03-17T14:00:00Z
  • ID 唯一性:每个批注的 ID 必须唯一,且在两个 XML 文件中保持一致
  • initials:作者名缩写,2个字符为宜
安全使用建议
This skill appears to implement what it claims (editing .docx to add track-changes and comments), but consider the following before installing or running it: - Dependency: The script imports python-docx (module name 'docx') but the skill provides no install instructions. Ensure the runtime has python-docx installed or be prepared to install it in a controlled environment. - Local file access: The instructions include operations on local paths (example: /Users/hansel/.openclaw/media/inbound). Running the skill will read and write .docx files on the host where the agent runs — only run it on files you trust and in an environment where reading those files is appropriate. - Back up originals: The script copies input to output and edits the copy, but direct XML edits can corrupt documents. Keep backups of originals before batch processing. - Verify authorship/date fields: The code uses a fixed ISO timestamp in created elements; if author/date accuracy matters, review or modify the script to set them appropriately. - Run in sandbox: Because the skill will perform filesystem operations, run it first in a sandbox or test environment with non-sensitive documents to confirm behavior. If you want to proceed, ask the skill owner to (a) declare or provide an install step for python-docx, (b) remove or clarify the hard-coded example path to avoid confusion, and (c) confirm there are no hidden network endpoints (none are present in the code provided).
功能分析
Type: OpenClaw Skill Name: docx-trackchanges-and-comments Version: 1.0.0 The skill bundle provides legitimate functionality for processing Word documents (.docx) to support track changes and comments. The Python script `scripts/track_changes.py` uses the `python-docx` library to manipulate OOXML elements, and the `SKILL.md` file provides technical instructions for the agent to perform manual XML edits using standard utilities like `unzip`, `grep`, and `zip`. While `SKILL.md` contains a hardcoded local path (`/Users/hansel/`), it appears to be a documentation artifact rather than a malicious directive, and no evidence of data exfiltration or unauthorized execution was found.
能力评估
Purpose & Capability
The name/description match the actual implementation: the provided Python script manipulates OOXML (docx) to add insert/delete revisions and inline comment text. No unrelated services or credentials are requested, and the SKILL.md documents the same XML files and operations the script performs.
Instruction Scope
Most instructions stay on-topic (unzipping docx, editing XML, repackaging). However, SKILL.md includes a hard-coded/example local path (/Users/hansel/.openclaw/media/inbound) and shell commands that operate on local files; this implies the agent will access files on the host filesystem where the agent runs. The manual procedure also suggests reading and writing arbitrary docx files in those locations, which is expected for a file-editing skill but worth noting for privacy.
Install Mechanism
This is an instruction-only skill with no install spec, but the script imports 'docx' (python-docx). The skill does not declare or install this dependency, so it may fail at runtime or require the platform to already provide python-docx. Lack of declared dependencies is a packaging hygiene issue (not necessarily malicious) and may hide the need for network installs when users try to run it.
Credentials
The skill requests no environment variables or credentials (good). However, SKILL.md's example uses a specific user path (the agent's inbound media directory) which suggests the skill expects to read files from the agent's environment. That is proportionate to the stated purpose (processing uploaded .docx files) but you should be aware it will read and write local files the agent can access.
Persistence & Privilege
No 'always: true' or other privileged flags. The skill does not attempt to modify other skills or system-wide configuration; it operates on files it is given. Autonomous invocation is allowed by default but not combined with other high-risk indicators here.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install docx-trackchanges-and-comments
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /docx-trackchanges-and-comments 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of the docx-trackchanges-and-comments skill. - Enables editing Word (.docx) files with support for track changes (insertions, deletions, redline edits) and comment (annotation) operations. - Allows enabling/disabling revision mode, and adding/removing/viewing comments directly by editing relevant OOXML files. - Includes detailed instructions for XML-level manipulation and manual document unpacking/repacking.
元数据
Slug docx-trackchanges-and-comments
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

用于为Word文档开启并调整修订模式,添加、删除批注等功能 是什么?

Word文档 (.docx) 处理,支持修订模式(Track Changes)和批注操作。使用场景:(1) 修订模式 - 添加插入/删除修订、红字标注;(2) 批注操作 - 添加、删除、查看批注;(3) 文档内容修改。当用户要求"修订"、"track changes"、"批注"、"红字修订"、"添加评论"、"添加... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 242 次。

如何安装 用于为Word文档开启并调整修订模式,添加、删除批注等功能?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install docx-trackchanges-and-comments」即可一键安装,无需额外配置。

用于为Word文档开启并调整修订模式,添加、删除批注等功能 是免费的吗?

是的,用于为Word文档开启并调整修订模式,添加、删除批注等功能 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

用于为Word文档开启并调整修订模式,添加、删除批注等功能 支持哪些平台?

用于为Word文档开启并调整修订模式,添加、删除批注等功能 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 用于为Word文档开启并调整修订模式,添加、删除批注等功能?

由 HanselXie(@hanselxie)开发并维护,当前版本 v1.0.0。

💬 留言讨论