Where to Find the Core Components of the OfficeCLI Codebase

The core components of the OfficeCLI codebase are organized into four primary directories: src/officecli/ for the CLI server and entry points, sdk/node/ for the programmatic JavaScript SDK, npm/ for the distribution wrapper, and src/officecli/Resources/ for the client-side preview viewer.

The iOfficeAI/OfficeCLI repository separates its architecture into distinct modules that handle command-line execution, programmatic SDK access, and live-preview rendering. Understanding where to find the core components of the OfficeCLI codebase helps developers navigate the server bootstrap logic, integrate the Node SDK, and customize the browser-based viewer.

CLI Entry Point and Command Handling

The command-line interface and server bootstrap logic reside in the src/officecli/ directory. This folder contains the executable scripts that initialize the application and manage real-time communication channels.

The primary files include:

When you execute the officecli command, the runtime invokes src/officecli/index.js to bootstrap the server and establish the SSE endpoints that stream document updates to the browser.

Node SDK and TypeScript Definitions

For developers integrating OfficeCLI programmatically, the Node SDK is located in sdk/node/. This module exposes a public API that allows external applications to control the CLI without spawning shell processes.

Key files in this directory:

The SDK entry point exports a class-based interface that handles server lifecycle management:

// Using the Node SDK (imported from sdk/node)
import { OfficeCLI } from "officecli";

const cli = new OfficeCLI();
await cli.start();                     // launches the local server
await cli.open("my-document.docx");    // opens a doc for live preview

NPM Distribution Wrapper

The npm/ directory contains the distribution logic that makes OfficeCLI installable via the npm registry. This wrapper handles platform-specific binary downloads and exposes the CLI as a JavaScript-based binary.

Critical files include:

When you run npm install officecli, the install-binary.js script detects your operating system and architecture, then downloads the appropriate native binary to your local node_modules directory.

Client-Side Viewer Resources

The live-preview viewer resources are stored in src/officecli/Resources/. These scripts execute in the browser context to handle real-time document updates, UI overlays, and viewer interactions.

The resource files include:

The client-side code establishes an EventSource connection to receive server updates:

// Client-side: how the preview page receives updates
(function () {
  const es = new EventSource("/events");   // watch-sse-core.js creates this
  es.addEventListener("update", e => {
    const msg = JSON.parse(e.data);
    // …DOM patching logic lives in watch-sse-core.js
  });
})();

Summary

Frequently Asked Questions

Where is the main server entry point located in the OfficeCLI codebase?

The main server entry point is src/officecli/index.js, which parses command-line arguments, initializes the HTTP server, and sets up the SSE endpoints required for live preview functionality.

How do I programmatically control OfficeCLI from my Node.js application?

Import the SDK from sdk/node/index.js, which exports the OfficeCLI class. This allows you to start the server and open documents using await cli.start() and await cli.open("filename.docx") without spawning shell commands.

Where can I find the TypeScript definitions for the OfficeCLI SDK?

The TypeScript definitions are located at sdk/node/index.d.ts in the repository root, providing type safety and IntelliSense support for the OfficeCLI class and its methods.

Which file handles the live preview updates in the browser?

src/officecli/Resources/watch-sse-core.js contains the core logic for browser-side updates, establishing the EventSource connection to /events and applying DOM patches, pagination adjustments, and scroll management as the document changes on the server.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →