save_docx
Save edited document content back to .docx format. Supports DFM or markdown input with automatic format merging and optional Word track changes for review.
Instructions
將編輯後的內容存回 .docx 檔案。
支援兩種模式:
DFM 模式(預設):傳入 dfm_content(.dfm 格式全文)
MD 模式(from_md=True):從磁碟讀取 content.md + format.yaml
回寫流程:
解析 DFM/MD → 提取修改
載入原始 IR
合併修改(格式合併策略)
重建 .docx
安全機制:若內容萎縮 > 50%,預設拒絕輸出(疑似資料遺失)。 使用 force=True 強制輸出。
若 track_changes=True,會將 DFM 中的文字修改以真正 Word Track
Changes (w:del/w:ins) 寫回,供使用者在 Word 中逐項審查。
Args: doc_id: 文件 ID dfm_content: 編輯後的 DFM 全文(from_md=True 時可省略) output_path: 輸出路徑(預設為 data/{doc_id}/output.docx) from_md: 若為 True,從磁碟讀取 content.md + format.yaml 而非使用 dfm_content force: 若為 True,即使偵測到嚴重內容萎縮仍強制輸出 track_changes: 若為 True,以 Word Track Changes 寫入文字 diff revision_author: 產生追蹤修訂時使用的作者名稱
Returns: 儲存結果
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | ||
| dfm_content | No | ||
| output_path | No | ||
| from_md | No | ||
| force | No | ||
| track_changes | No | ||
| revision_author | No | Asset-Aware MCP | |
| ctx | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |