How it works

How AI reads and edits your open HWP documents, what stays on your Mac, and what leaves your device.

Documents are opened and edited locally on your Mac. When you send an AI request, the built-in local hub sends only the required context directly to the AI provider you connected.

Architecture

AI never touches files on disk directly. Instead, it calls structured tools over MCP (Model Context Protocol) through the local hub, which forwards them to the editor’s built-in HeemangEngine to read or update the document safely.

  • HeemangEngine (WASM): Handles everything about the document locally — parsing, line breaking, pagination, tables, equations, rendering, and saving.
  • Local agent hub: A background process bound strictly to loopback (127.0.0.1). External machines can’t reach it, and each launch requires a freshly generated random token.
  • MCP tools: The sole channel through which AI interacts with a document. It can only call explicit tools such as reading paragraphs, changing formatting, or editing tables. Claude and Codex connect directly via local HTTP MCP (/mcp-http).
  • Original file safety: AI edits only modify the open document in memory. The file on disk stays untouched until you explicitly Save (⌘S).

How the agent edits documents

When you send a prompt, the AI typically works through four steps:

  1. Read the document

    Each prompt includes a structural summary of the active document (live_document) and its current revision number. When needed, the agent fetches specific pages, table geometry, attached PDFs, or web page captures.

  2. Apply batched edits atomically

    When changing multiple paragraphs or styles, the agent groups up to 32 operations into a single apply_edits batch. If any step fails, the entire batch rolls back so the document is never left half-edited.

  3. Check layout

    After editing, the engine immediately returns the updated paragraphs, page-count changes, and layout warnings such as tables overflowing page margins. When visual confirmation helps, the agent renders a cropped image (render: "crop") to inspect and refine the layout.

  4. Stage for review or apply directly

    In Agent mode, edits accumulate as a live preview on the page until you Accept or Reject them. In Full access mode, each tool call applies immediately and adds an Undo step.

Why concurrent edits never collide (revisions)

Every change to a document increments its revision number. Because the engine verifies this number before applying writes, the AI can’t accidentally overwrite an edit you just made.

  • When reading the document, the AI receives the current revision and sends it back as expectedRevision on every write call.
  • If you typed something or switched documents in the meantime, the engine rejects the stale write with REVISION_MISMATCH, prompting the AI to re-read and retry cleanly.
  • Saving (⌘S) doesn’t change document content, so the revision number stays the same.
  • When multiple subagents edit different paragraphs in parallel, HamaEditor automatically shifts paragraph offsets as earlier edits land so their changes merge cleanly.

Data storage & transfer

Here is exactly what stays on your computer, what goes to your AI provider, and what goes to HamaEditor’s servers.

Data type Stored on your Mac Sent to your AI provider Sent to HamaEditor servers
Open HWP/HWPX documents, embedded versions, imported legacy archives, chat history, resource files, templates, skills, AGENTS.md Yes (stored locally on your Mac) Only the document sections and references read for your prompt Never
AI auth tokens, API keys, built-in browser passwords and secrets Yes (OS secure storage such as macOS Keychain) AI credentials are used only to authenticate with that provider (browser passwords are never exposed to AI) Never
Account info (email, optional nickname & profile picture, registered device ID, app version, OS) Cached locally Never Yes (sign-in, 5-device limit, update checks)
Crash reports & usage statistics N/A Never Only if you opt in (off by default; never includes document contents)