office
Office documents
MAIN for Office/PDF — every read and handle (create/edit/accept/undo/history/revert/comment/track-change) of
.docx/.doc/.dotx/.dotm/.xlsx/.xls/.xlsm/.xlsb/.xltx/.pptx/.ppt/.potx/.pdf(and images.png/.jpg/.jpeg/.gif/.bmp/.tiff/.webp) MUST go throughofficecli. The plugin's guard blocks the nativeread/edit/writetools for these extensions and errors withuse officecli tool for office/PDF files — office is the main method for read + handle. Do not bypass.
The plugin overrides the builtin edit tool: every edit — text or binary — runs through a draft and needs officecli accept to reach the real file. Two edit surfaces:
officecli(action="edit", filePath, content)— replaces the whole draft with your markdown (for office/PDF, this is the ONLY write surface)edittool (filePath,oldString,newString) — patches the existing draft in place (text files only; blocked for office/PDF/images)
For office/PDF/images, officecli is the ONLY path: read returns markdown, create/edit consume markdown, both sides inside officecli. Never use read/edit/write on *.docx,*.doc,*.dotx,*.xlsx,*.xls,*.xlsm,*.pptx,*.ppt,*.pdf,*.png,*.jpg,*.jpeg,*.gif — guard fails them. For live Word content on the same machine use officecli(action="read", live=true) (prefers Application.Word document whose full name matches filePath, falls back to saved file; local-only).
Draft lifecycle (every task)
Every write runs through a draft: nothing reaches the real file until accept. The lock is claimed lazily on the first mutating action and released on accept/undo.
L1 path (markdown, 80% tasks):
create filePath + contentfor a new file, oredit filePath + contentto open an existing file's draft- Re-
edit,comment,approve,metadata,watermarkfreely while iterating — all mutate the same draft acceptflushes the draft to disk, records a version snapshot, releases the lock