Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

command watch

zmworm edited this page Apr 10, 2026 · 42 revisions

watch / unwatch

Live HTML preview server that auto-refreshes when the document changes.

watch

officecli watch <file> [--port N]

Starts an HTTP server that serves a live HTML preview of an Office document. The preview automatically refreshes whenever the document is modified via any OfficeCLI command (set, add, remove, move, raw-set). Supports .pptx, .docx, and .xlsx files.

Arguments

Name Type Required Default Description
file FileInfo Yes - Office document path (.pptx, .docx, .xlsx)

Options

Name Type Required Default Description
--port int No 18080 HTTP port for the preview server

Behavior

  • Opens http://localhost:{port} in the default browser automatically.
  • Monitors the document file and re-renders HTML on every modification.
  • Any set, add, remove, move, or raw-set command on the same file triggers an incremental refresh.
  • Auto-scroll: The preview automatically scrolls to the changed element after each update.
  • Word block-level diff: Word watch uses server-side block diff with incremental SSE patches (replace/add/remove/style). Only changed blocks are sent, with fallback to full refresh when >60% blocks change. Supports version numbering with gap detection for disconnect recovery.
  • Press Ctrl+C to stop the server, or use unwatch from another terminal.
  • Works with both direct mode and resident mode.
  • Idle timeout: Automatically shuts down after 5 minutes of inactivity (no connected clients and no file changes). Override with OFFICECLI_WATCH_IDLE_SECONDS environment variable (mirrors OFFICECLI_RESIDENT_IDLE_SECONDS).

Examples

# Start live preview on default port
officecli watch slides.pptx
# Word document preview
officecli watch report.docx
# Excel spreadsheet preview
officecli watch data.xlsx
# Start on a custom port
officecli watch slides.pptx --port 3000
# In another terminal, make changes — preview auto-refreshes
officecli set slides.pptx /slide[1]/shape[1] --prop text="Updated!"
officecli add slides.pptx /slide[1] --type shape --prop text="New shape"

unwatch

officecli unwatch <file>

Stops the watch preview server for the specified document from another terminal.

Examples

officecli unwatch slides.pptx

Interactive Selection

The watch preview supports interactive element selection for collaborative workflows with AI agents:

Click selection:

  • Click any element to select it
  • Shift/Ctrl/Cmd+click to toggle element in/out of selection

Rubber-band selection:

  • Drag from empty space to draw a selection box
  • Any element intersecting the box is selected
  • Shift+drag adds to current selection
  • Esc cancels mid-drag

CLI integration:

# Query currently-selected elements
officecli get slides.pptx selected --json
# Apply properties to all selected elements
officecli set slides.pptx selected --prop bold=true --prop color=FF0000
# Mark selected elements for review
officecli mark slides.pptx selected --prop color=yellow --prop note="Review"

Supports PowerPoint (shapes, pictures, tables, charts, connectors, groups) and Word (top-level paragraphs, tables).

Marks (Review Annotations)

Attach live annotations to elements via the mark command. Marks render as highlights with tooltips in the browser preview and sync across all connected clients via SSE.

officecli mark report.docx /p[3] --prop find="TODO" --prop color=yellow --prop tofix="Add details"
officecli get-marks report.docx --json
officecli unmark report.docx --path /p[3]

Notes

  • Available for .pptx, .docx, and .xlsx files.
  • PowerPoint: Slide navigation UI, connector arrowheads, custom geometry, 3D effects, gradients, 3D models (Three.js), zoom objects. Equations via KaTeX.
  • Word: Full formatting with style inheritance, tables (floating, conditional formatting, theme borders), images (anchored, crop), drop caps, multi-column sections, footnotes/endnotes (numbering format), TOC, charts (SVG), equations (KaTeX), run borders/shading, CJK support, headers/footers, page layout from OOXML.
  • Excel: Cell formatting, merged cells, frozen panes, hidden rows/cols, embedded charts (SVG), sheet tabs, RTL/i18n support, formula evaluation. Row-level incremental diff — only changed rows are sent via SSE, with fallback to full refresh for structural changes.

See Also


Based on OfficeCLI v1.0.42

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /