Problem
insert_image_from_path 在 append 模式(不帶任何 anchor)只建立 relationship 與 word/media/ 二進位檔,不把 <w:drawing> 寫進 body。save_document 照當下的 body 序列化,於是那張圖在輸出檔裡根本不存在——但關係與媒體檔都在,所以檔案帶著一份永遠不會顯示的酬載。
被積壓的 append 圖片會在之後某個會重建 body 的操作(帶 anchor 的插入、insert_equation…)發生時一起 materialize。也就是說:一張 append 的圖能不能存活,取決於你之後碰巧做了什麼。
最自然的用法——「把圖附在最後然後存檔」——必然遺失最後那張。
最小重現(che-word-mcp 4.0.7)
base.docx = macdoc convert 產的 3 段落文件(drawing=0)
| # |
操作序列 |
存檔後 <w:drawing> |
rels image |
判讀 |
| 1 |
insert_image ×2(append)→ save |
0 |
2 |
兩張全遺失 |
| 2 |
接著 insert_paragraph(append)→ save |
0 |
2 |
文字有寫入,圖仍遺失 |
| 3 |
再 save 到新路徑 |
0 |
2 |
與存檔路徑無關 |
| 4 |
insert_image(帶 after_text)→ save |
3 |
3 |
積壓的 2 張一起 materialize |
| 5 |
insert_image(append)+ insert_equation(append)→ save |
4 |
4 |
insert_equation 也會 flush |
| 6 |
insert_image(append)→ 立刻 save |
4 |
5 |
最後一張遺失,rels/media 與 body 不一致 |
第 6 列是本 issue 的核心:rels=5 / media=5 但 body=4。
Type
bug
Expected
insert_image_from_path 回報成功後,save_document 寫出的檔案裡該圖片應有對應的 <w:drawing>;rels / media / body drawing 三者數量一致。
Actual
append 模式插入的圖片在 body 缺席,除非之後恰好有其他操作重建 body。輸出檔的 rels 與 media 數量大於 body 的 <w:drawing> 數量。
Impact
這個失敗是靜默的,而且三個看起來像驗證的管道都偵測不到:
insert_image_from_path 的回傳值 —— 回報 Inserted image 'x.png' with id 'rIdN',成功
list_images —— 回報全部圖片都在(它列的是 relationship/media,不是 body 引用)
save_document —— 回報成功
唯一抓得到的方法是打開輸出檔數 document.xml 的 <w:drawing>。
實際踩到的情境:用 MCP 組一份要交出去的 Word 文件,插 7 張圖,全部回報成功,list_images 回報 7 張。轉成 PDF 目視才發現其中 4 張根本沒出現。若沒有目視那一步,交出去的就是一份少了 4 張圖的檔案。
建議
- 修正 append 路徑,讓
<w:drawing> 在插入當下就進 body(與 anchored 路徑一致)
- 若短期難修,至少讓
save_document 在序列化後比對 rels/media/body drawing 三者數量,不一致就 報錯而非回報成功
list_images 應區分「有 relationship」與「body 有引用」,或直接以 body drawing 為準
環境
- che-word-mcp 4.0.7
- macOS 27.0
Current Status
Phase: planning
Last updated: 2026-09-01 by idd-implement (Stage 1)
Key Decisions
- Root cause:ooxml-swift
appendParagraph op 快路徑的 payload 投影無 drawing 詞彙(RunPayload OpLog/Operation.swift:366),磁碟開啟文件的 append 圖片段落 <w:drawing> 被靜默丟棄;typed view 保有 → 後續 typed-dirty 操作才 materialize
- Complexity = Plan(硬閘:shared abstraction
appendParagraph;risk-sensitive data-loss + 跨 repo 釋出鏈);Conflict Class = C_shared_module_coord
- Fix 方向:白名單「payload 可表示」才走快路徑,否則 fallback typed-dirty;defense-in-depth save 計數一致性檢查
Scope Changes
- list_images 語意旁支 → PsychQuant/che-word-mcp(sister issue,見 diagnosis comment)
Blocking
Commits
Problem
insert_image_from_path在 append 模式(不帶任何 anchor)只建立 relationship 與word/media/二進位檔,不把<w:drawing>寫進 body。save_document照當下的 body 序列化,於是那張圖在輸出檔裡根本不存在——但關係與媒體檔都在,所以檔案帶著一份永遠不會顯示的酬載。被積壓的 append 圖片會在之後某個會重建 body 的操作(帶 anchor 的插入、
insert_equation…)發生時一起 materialize。也就是說:一張 append 的圖能不能存活,取決於你之後碰巧做了什麼。最自然的用法——「把圖附在最後然後存檔」——必然遺失最後那張。
最小重現(che-word-mcp 4.0.7)
<w:drawing>relsimageinsert_image ×2(append)→saveinsert_paragraph(append)→savesave到新路徑insert_image(帶after_text)→saveinsert_image(append)+insert_equation(append)→saveinsert_equation也會 flushinsert_image(append)→ 立刻save第 6 列是本 issue 的核心:
rels=5 / media=5但body=4。Type
bug
Expected
insert_image_from_path回報成功後,save_document寫出的檔案裡該圖片應有對應的<w:drawing>;rels/media/ body drawing 三者數量一致。Actual
append 模式插入的圖片在 body 缺席,除非之後恰好有其他操作重建 body。輸出檔的
rels與media數量大於 body 的<w:drawing>數量。Impact
這個失敗是靜默的,而且三個看起來像驗證的管道都偵測不到:
insert_image_from_path的回傳值 —— 回報Inserted image 'x.png' with id 'rIdN',成功list_images—— 回報全部圖片都在(它列的是 relationship/media,不是 body 引用)save_document—— 回報成功唯一抓得到的方法是打開輸出檔數
document.xml的<w:drawing>。實際踩到的情境:用 MCP 組一份要交出去的 Word 文件,插 7 張圖,全部回報成功,
list_images回報 7 張。轉成 PDF 目視才發現其中 4 張根本沒出現。若沒有目視那一步,交出去的就是一份少了 4 張圖的檔案。建議
<w:drawing>在插入當下就進 body(與 anchored 路徑一致)save_document在序列化後比對rels/media/body drawing 三者數量,不一致就 報錯而非回報成功list_images應區分「有 relationship」與「body 有引用」,或直接以 body drawing 為準環境
Current Status
Phase: planning
Last updated: 2026-09-01 by idd-implement (Stage 1)
Key Decisions
appendParagraphop 快路徑的 payload 投影無 drawing 詞彙(RunPayloadOpLog/Operation.swift:366),磁碟開啟文件的 append 圖片段落<w:drawing>被靜默丟棄;typed view 保有 → 後續 typed-dirty 操作才 materializeappendParagraph;risk-sensitive data-loss + 跨 repo 釋出鏈);Conflict Class = C_shared_module_coordScope Changes
Blocking
Commits