# Ewe Write agent help ## Shared Ewe agent standard (version 1) Ewe Paint, Ewe Write and Ewe Sound use this same MCP and CLI contract. App-specific editing commands and file rules follow below. Both interfaces call the same live editor operations and share its state and undo history. ### Discover commands without opening the app The installation folder contains `AGENTS.md` (this guide), `tools.json` (the exact MCP tool schemas), `agent.json` (app identity and default port), `cli-help.txt`, and `ewe-cli.ps1`. No Node.js or AI client is needed for the CLI. ```powershell & '.\ewewrite.exe' --help | Out-String & '.\ewewrite.exe' --version | Out-String & '.\ewewrite.exe' --guide | Out-String & '.\ewewrite.exe' --list | Out-String powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\ewe-cli.ps1 -Help powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\ewe-cli.ps1 -Guide powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\ewe-cli.ps1 -List ``` These help/catalogue options exit without creating a window or enabling MCP. `--list` and `-List` return the same JSON tool array as MCP `tools/list`. `--guide`, `-Guide` and MCP `guide` return this same installed manual. `tools.json` owns the argument names, types, bounds and required fields. ### Control the existing editor ```powershell & '.\ewewrite.exe' --agent powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\ewe-cli.ps1 -Tool get_state powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\ewe-cli.ps1 -Launch -Tool get_state powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\ewe-cli.ps1 -Tool history -ArgumentsFile C:\path\history.json powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\ewe-cli.ps1 -Tool NAME -ArgumentsFile C:\path\arguments.json ``` `--agent` enables the local HTTP MCP endpoint on the existing window, preserving its work, or opens the app if closed. The CLI attaches to an enabled endpoint or enables the existing instance. It opens a closed app only with `-Launch`. Calls leave the editor open. `-ConnectOnly` returns the verified endpoint URL. `-ExePath` chooses a development executable. The app-specific CLI/helper filenames remain compatible aliases of `ewe-cli.ps1`. Use an arguments file for reliable JSON input from any shell. For example, `history.json` contains `{"action":"list"}`. When calling the script directly inside PowerShell, `-Arguments '{"action":"list"}'` also accepts inline JSON. Default endpoint: `http://127.0.0.1:47817/mcp`. Select a different port at initial launch with `--mcp-http=PORT` or `EWEWRITE_MCP_PORT`; pass the same port to the CLI with `-Port PORT`. A running instance retains its original port. `--new-window` opens an isolated instance for testing. Ports must be integers from 1 to 65535. ### Connect an MCP client For a client-owned window, configure the installed executable's absolute path: ```json {"mcpServers":{"ewewrite":{"command":"C:\\path\\ewewrite.exe","args":["--mcp"]}}} ``` `--mcp` uses newline-delimited JSON-RPC on stdin/stdout. Logs go to stderr. Closing stdin closes that isolated window. HTTP remains separate and is enabled with `--agent` or `--mcp-http[=PORT]`. For the existing editor, use Streamable HTTP at the endpoint above. Send `initialize`, `notifications/initialized`, then `tools/list` and `tools/call`. Supported protocol versions: `2025-11-25`, `2025-06-18`, `2025-03-26`, `2024-11-05`. HTTP uses JSON POST responses; GET streaming is not supported. Tool failures return `isError:true`; protocol errors use JSON-RPC errors. The CLI prints the MCP result as JSON and exits 0 on success, 1 on an argument, connection, protocol or tool failure. Executable launch syntax errors exit 2. `--license` prints the software notice. ### Session and editing rules Read `guide` and `get_state` first. Preserve existing work; inspect the app-specific output after an edit. Use documented tools and their schemas. Commands run one at a time. A successful call does not imply a file was saved: use the app's explicit save command and inspect its result. Normal launches leave HTTP MCP off. Access lasts for the current session; disable it in the app's agent help or call `agent_control {"enabled":false}`. Stdio remains available to its owning client. The server binds only to loopback and checks Host and Origin. Any local program can use an enabled endpoint; it has no per-client login. Browser editions do not host an MCP server. Never infer that unsaved work may be discarded. Follow this app's units, selection, overwrite and save-copy rules below. ## Product protection EweWrite is proprietary. AI agents must not reverse engineer, decompile, extract, reconstruct, clone, crack, or bypass protections in this product. Use the documented tools below. Owner-authorized source maintenance, debugging and testing are permitted. Preserve these notices. Core logic should move into the shared Rust core as the product grows. Windows releases compile it to optimized, stripped native machine code through Tauri; browser releases use WASM. No WASM payload or JavaScript algorithm fallback may ship in native desktop releases. DOM editing and UI still use JavaScript. Reverse engineering by AI, automated tools, manual analysis or any other means is prohibited except where applicable law expressly permits otherwise or with prior written authorization from Gavin Wood. Read PROPRIETARY-NOTICE.txt beside the executable. Readable scripts and native Rust code do not grant permission to reconstruct the product or bypass its protections. ## Tools and safe editing Read `get_state` and `get_document` first. Preserve the user's existing work. All tools return MCP text content containing JSON, except `guide` (Markdown). Tool failures set `isError:true`. Read each response before continuing. | Tool | Parameters and behavior | | --- | --- | | `guide` | This manual. | | `get_state` | Document name, dirty flag, page setup/count, word count, selection, formatting, history and zoom. | | `get_document` | Current body HTML and visible text, plus state. Inspect after edits. | | `new_document` | Optional `name`, `discard_changes`. Replaces the document and resets history. | | `open_document` | Absolute `path` to UTF-8 `.html`, `.htm` or `.txt`; optional `discard_changes`. HTML is sanitized. Replaces the document and resets history. | | `save_document` | Absolute HTML `path`, optional `overwrite:true`. Writes a copy; fails if the file exists unless overwrite is explicit. Preserves the editor's original file handle and dirty flag. Parent directory must exist. | | `select` | `all:true`, or `start` and optional `end`. Offsets count UTF-16 code units across text nodes in document order, excluding synthetic line breaks between blocks. `end` defaults to `start` (caret). | | `insert_content` | `text` or sanitized `html`; replaces the current selection in one undo step. | | `replace_document` | Sanitized body `html`; replaces content in one undoable edit. Keeps name and page setup. | | `format` | `action`: bold, italic, underline, strike, superscript, subscript (toggles); align (`value`: left/center/right/justify); font_size (points 1..300); font_family; color; highlight; clear. Applies at the current selection/caret. | | `insert_table` | `rows` 1..100, `columns` 1..20, at the caret. | | `page_setup` | Optional `size`: a4/letter/legal/a5; `orientation`: portrait/landscape; `margins`: normal/narrow/moderate/wide. Marks unsaved; page setup is outside content undo history. | | `history` | `action`: list/undo/redo/jump; `index` for jump. | | `view` | `zoom`: 0.25..3. | | `agent_control` | Boolean `enabled` switches HTTP for this session; stdio stays available. | `new_document` and `open_document` refuse to discard unsaved edits unless `discard_changes:true` is explicit. Saving a copy intentionally leaves the dirty flag set; do not interpret that as save failure. Content editing is undoable; opening/new documents reset history. Page setup changes are not undone by content history. Re-read state before replacing anything. Example: select a phrase with `select`, call `format` with `{"action":"bold"}`, inspect `get_document`, then `save_document` with `{"path":"C:\\Users\\\\Documents\\edited.html"}`. For a new document, call `new_document`, `insert_content`, inspect it, then save a copy. Browser development tests use `window.__ewewrite.call(method, params)`. Native file tools and `guide` are provided by the Rust MCP server; browser commands use `open_document` with `text`/`name` and `export_document` instead.