Skip to content
xirothedev edited this page Aug 25, 2026 · 2 revisions

OpenCode Office Plugin

Office document automation for opencode 2: draft lifecycle, version history, locks, comments, format conversion, and template batch generation. Exposes one tool, officecli, plus an edit override that forces binary files through the draft lifecycle.

Quick start

Add to opencode.json (project root or ~/.config/opencode/opencode.json):

{
  "plugins": ["@xirothedev/openoffice-plugin-opencode"]
}

Then ask opencode: "Create a Word document at /tmp/test.docx with a table". The agent calls officecli(action="create") to open a draft, and officecli(action="accept") to write the real file.

Core model

  • Draft — create/edit never touch the real file. Changes live in a draft under the plugin data dir.
  • Accept — the single write path. accept flushes the draft to disk, records a history snapshot, releases the lock.
  • Lock — a per-file claim, not a mutex. Acquired lazily on the first mutating call. A stale lock (default 24h) can be taken over with force-release.
  • History — every accept records a snapshot; revert restores one through a new draft + accept.

Supported formats

Format Read Write Notes
Text / Markdown yes yes native
PDF yes yes write needs pandoc + LaTeX engine
DOCX / XLSX / PPTX yes yes pandoc + docx/exceljs backends
Images (PNG, JPG) yes yes via annotate overlays; no pixel editing

Pages

  • Install — requirements, config, local dev, troubleshooting
  • Usage — every officecli action with parameters
  • Comment Workflow — suggestions, approvals, track changes
  • Configuration — options, env vars, data storage

Sync map (keep wiki aligned with code)

Wiki page Source of truth in repo
Home README.md, docs/DESIGN.md
Install docs/INSTALL.md, docs/TESTING.md
Usage src/plugin/tools/officecli.ts (schemas), README.md
Comment Workflow docs/COMMENT-WORKFLOW.md
Configuration src/core/options.ts, README.md

If an action signature changes in src/plugin/tools/officecli.ts, update the Usage page in the same PR. Domain terms (Draft, Accept, Lock, Orphaned draft, …) are defined in docs/CONTEXT.md.

License: MIT.

Clone this wiki locally