apply_edit
Apply precise edits to Word, Excel, or PowerPoint documents at specified locations, with automatic backup and version history. Supports replace, append, prepend, insert, and delete modes.
Instructions
对指定位置应用修改(首次编辑前自动生成 .bak-<时间戳> 备份;同一标注轮次内只有第一次编辑会快照到版本历史,其余编辑复用该版本——一轮多个标注只产生一个版本,版本描述会汇总本轮全部修改)。mode 缺省 replace;引擎错误返回结构化错误。返回 {ok, loc, new_content, version}(version 为 null 表示本轮已快照过、未新增版本;version.desc 表达该快照为'修改前/该轮标注前的状态'——会话场景为'第 N 轮标注前的状态(本轮修改:…)',无会话为'修改前:<编辑摘要>',回退到该版本即恢复为此内容)。修改成功后,该文档的标注窗口会自动重载展示最新内容(无需再手动调用 annotate_document);用户检查后可能继续标注,此时应再次调用 wait_for_annotations 获取下一轮标注。若修改后发现内容异常,可用 list_versions / restore_version 回退到修改前再重新生成。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| loc | Yes | 统一位置描述符(docs/contracts.md §2):docx-paragraph / docx-cell / xlsx-cell / xlsx-range / pptx-shape / pptx-shape-paragraph | |
| mode | No | 编辑模式,缺省 replace | |
| path | Yes | 文档绝对路径 | |
| style | No | 格式样式提示(可选字段;缺省表示保持原样) | |
| session_id | No | (建议)标注会话 ID(wait_for_annotations 返回)。提供后窗口重载精确绑定该会话,且同一轮内的多次编辑会合并为一个版本快照 | |
| new_content | No | 新内容(mode=delete 时忽略,可为空字符串) |