feat(docx): support cross-document paragraph cloning with source formatting
Problem
officecli add <file> <parent> --from <path> can clone a paragraph only within the same DOCX file. When an agent needs to assemble a new document from existing Word documents, the available paragraph-level dump/batch path does not carry sibling document resources such as styles, numbering, and theme definitions. As a result, copying a paragraph into a new DOCX cannot reliably match Word's Keep Source Formatting behavior.
Proposed interface
Add an explicit source-document option, or an equivalent cross-document clone operation:
officecli add target.docx /body `
--from-file source.docx `
--from "/body/p[12]" `
--after "/body/p[3]"The source document should remain read-only.
Expected behavior
For a copied Word paragraph:
- preserve paragraph properties and all child runs/direct character formatting;
- import or remap referenced custom styles and numbering definitions;
- preserve theme-dependent appearance where required;
- copy and remap media and hyperlink relationships used by the paragraph;
- remap colliding bookmark, comment, footnote, endnote, drawing, and relationship IDs;
- reuse identical target definitions where safe and handle conflicting definitions deterministically;
- produce a DOCX that passes
officecli validateand opens correctly in Microsoft Word.
Motivation
This is useful for contract assembly, compliance-review summaries, report compilation, and other workflows that collect selected source paragraphs into a new Word document. Today agents can find the paragraph and clone it inside its original document, but cannot transfer it to a new document with source formatting intact.
A paragraph-first implementation would already cover the primary use case; support for tables and other block elements could follow separately.
Source: iOfficeAI/OfficeCLI