# Write_Away Two quotation marks shaped like pen nibs A Mac writing tool that keeps the other ways you tried to say something. A word, a sentence or a paragraph can hold several versions, and you flip through them in place, in the sentence they have to live in. Text you doubt can be dimmed instead of deleted. Lines that don't belong go to a panel beside the page. It all saves to one Markdown file. The idea is Jason Fried's. He showed it as [Write_On](https://x.com/jasonfried/status/2105403067793584590), called it “alternative control”, and [demonstrated AI alternatives](https://x.com/jasonfried/status/2105427261461758238/video/1). Write_Away is a prototype of the same idea in Zig and AppKit, written without his code. It is not connected with him or with 37signals. ## Install Releases are zips on Codeberg for Apple silicon, built for macOS 13 or later (only tested on macOS 26). Unzip one and move `Write_Away.app` to `/Applications`. The app is not notarized, so macOS refuses it the first time: try to open it, then choose **System Settings → Privacy & Security → Open Anyway**. Each zip's checksum is in the release's `SHA256SUMS`. **Write_Away → About Write_Away** shows the version. ## Build and run Use [mise](https://mise.jdx.dev), which supplies Zig **0.16.0**, and the Xcode Command Line Tools, on Apple silicon. The first build fetches [libpantograph](https://codeberg.org/teepark/libpantograph) at the revision pinned in `build.zig.zon`. ```sh mise trust # once: let mise read this repo's tasks mise run build # zig-out/Write_Away.app open zig-out/Write_Away.app mise run run -- piece.md # open a piece, or start one at that path mise run test # the document model, then the app driven with no window ``` `build:local` and `test:local` use a libpantograph checkout at `../libpantograph` instead. `mise run pin:libpanto` moves the pin. `mise tasks` lists the rest. A normal launch reopens the last file you had open, using its current contents on disk. On the first launch, after **File → New**, or if the file can’t be read, you get an empty **Untitled** draft instead. Opening a file explicitly takes precedence. Unsaved text is not restored. ### Launch from the terminal With `Write_Away.app` in `/Applications`, install the launcher into a directory on your `PATH` (here, `~/.local/bin`): ```sh mkdir -p "$HOME/.local/bin" install -m 755 bin/write_away "$HOME/.local/bin/write_away" write_away # launch or bring the editor forward write_away "my draft.md" # open an existing file ``` ## Using it | Keys | What happens | | --- | --- | | Ctrl+Shift+A | Open alternatives for the word or selection. Pick Word, Sentence, or Paragraph; move between rows to hear and see each version in context. Return adds a row; Escape closes. | | Ctrl+Shift+G, or `??` alone on a panel row | Ask for alternatives without replacing the version on the page. | | ⌘, | Set the inference API style, base URL, model and key. | | ← → ↑ ↓ with the pointer on underlined text | Flip through its versions. Typing gives the arrows back to the caret. | | Delete with the pointer on underlined text | Throw out the version showing. | | Ctrl+] and Ctrl+[ | Flip the group the caret is in, without the pointer. | | Ctrl+/ | Ghost the selection or the word. On ghosted text, revive it. | | Ctrl+Shift+X | Stash the selection, or the paragraph, in Overflow. | | Ctrl+Shift+D | Show or hide Overflow. Drag its left divider to resize it; closing and reopening keeps the width. | | Ctrl+Return | Move Overflow's selection, or its paragraph, to the caret in the page. | | Ctrl+Shift+R, or click the word count | Put the tools away and read. | | ⌘N ⌘O ⌘S ⇧⌘S ⌘Z ⇧⌘Z | New, Open, Save, Save As, Undo, Redo. | Right-click the page for alternatives, AI alternatives, ghost/revive, or Overflow. While the panel is open, the surrounding text dims. A word’s versions have a wavy violet underline; a sentence’s have a pink one. Paragraphs get a bar in the margin. Dots show the active version, and a lower tick marks a return to the version you started on. Flipping a word adjusts a preceding *a/an* where the pronunciation can be guessed. Heading hashes (`#` through `######`) appear while the caret is on that heading so you can edit its level. They hide again when the caret leaves. Matched `**strong**`, `_emphasis_`, `***both***`, `~~strikethrough~~`, and inline code spans render on the page. Move the caret inside a span to see and edit its delimiters. Saving keeps the Markdown source, not a rich-text conversion. `[Links](with/targets)` show as their underlined text. Move the caret inside one to see its brackets and target. Reference links stay as written, and a link isn’t clickable yet. An image alone on its line (`![alt](picture.png)`) shows as the picture, fitted to the column and never enlarged past its own size. Click it, or move the caret onto its line, and the source comes back in its place. Pictures are read from this Mac only: an absolute path, or one relative to the folder the piece is saved in, so an unsaved piece shows none. Nothing is fetched. An image among other text, a remote URL, or a file that can’t be read stays as written. A line starting with `> ` is a quote: a bar stands in for the marker and the text keeps its indent. A line of three or more `-`, `*` or `_` (all the same, spaces between them allowed) is a rule across the column. Unbroken hyphens directly under a line of text are the exception: Markdown would make that line a heading, so they stay as written. Put the caret on a quote or rule to see its source. Nested quotes stay as written. Fenced code blocks (three or more backticks or tildes, with an optional language) sit on a darker panel, and nothing inside one is read as Markdown. The fence lines show while the caret is in the block. A block with no closing fence runs to the end of the piece. YAML frontmatter is shown the same way, with its `---` lines as the fences. It counts only when the first line is `---` and a later line of `---` or `...` closes it; its contents are not parsed. ## The Lab Choose **Lab** in the bottom bar or press **Ctrl+Shift+L** (also in the Write menu); the shortcut leaves read mode if needed. During a review, use **Ctrl+Shift+N** for Next, **Ctrl+Shift+K** for Keep, **Ctrl+Shift+P** for Apply rest, and **Ctrl+Shift+O** for Discard/Original. The in-window chooser has six editing passes and a row of trim strengths. Use the arrow keys to move, Return to choose, or Escape to go back to the draft. A pass can mark weak, long, or convoluted sentences, changes of tone, or filler. Punctuation and typo fixes are proposals until you apply them. **Next** visits the next passage; **Keep** leaves it alone. The four trims aim for about 10%, 20%, 30%, or 50%. They ghost proposed cuts using the same ghosts you can make yourself. **Save** at that point to publish without the ghosted words and still recover them in Write_Away. **Original** revives the pass’s remaining proposals, not your manual ghosts. **Apply rest** removes the remaining cuts from the editor too; Undo brings them back. Editing the draft closes the review, leaving existing ghosts in place. ## Inference (optional) Choose **Write_Away → Inference…**, or configure it on your first `??`. For alternatives, the request sends the target, its paragraph and the variants already tried. Choosing a Lab pass sends the numbered draft text (including ghosted words, not Overflow or unselected alternatives). Ordinary editing and saving make no requests. The app asks for five word alternatives or three longer ones. A robot marker identifies suggestions. Anthropic Messages, OpenAI Chat Completions, OpenAI Responses and Google Interactions are available via libpantograph. Use HTTPS for remote endpoints. The key is **not in Keychain**: it is stored unencrypted in `~/Library/Application Support/Write_Away/inference.json`, mode `0600`. Save an empty key to remove it. The other settings live in the `local.write-away` preferences domain. When upgrading from a differently named build, re-enter your inference settings or copy your existing `inference.json` into this directory with mode `0600`. ## The file ```markdown # A draft The tension is real. ``` Ordinary Markdown renders only the visible draft. Manual and Lab ghosts are removed from the visible bytes and stored in the leading `write_away` comment, along with any alternatives. Overflow has its own leading comment: `&` represents `&` and `-` represents `-` inside its parentheses. These are Write_Away escapes, not Markdown escapes. All hidden text is still readable in the file source. Write_Away preserves the visible bytes exactly after the blank line that separates the comments from the draft. A file with no Overflow, alternatives or ghosts is saved unchanged. YAML frontmatter stays on the first line: the comments go directly after the line that closes it, and the rest of the draft follows their blank line. ```markdown --- title: A draft --- # A draft ``` Files saved earlier with the comments above the frontmatter still open, and move to this layout on the next save. If the closing line is the last thing in the file with no line break after it, or ghosting leaves the published text without frontmatter, the comments go first as before. Files record UTF-8 byte offsets into the restored editor body. While editing, ghosts are attributes on the text itself; Save computes fresh offsets. A fully ghosted alternative stays ghosted when swapped. If a replacement crosses a ghost boundary, revive the ghosted part first: Write_Away won’t guess which words in another version should be hidden. If a file has ghosts and its visible bytes change outside Write_Away (even just a newline), Write_Away opens the original Markdown as-is, with its comments intact, rather than guessing where to put the ghosts. Without ghosts, alternatives can still follow matching text after an outside edit. Legacy Overflow trailers and v1 records are supported. For drafts saved under an earlier app name, change only the identifier on the metadata comment to `write_away` before opening; leave its JSON and the draft text unchanged. ## Not here yet A separate Markdown view, source-stripped public export, sharing/posting, deletion animations, crash recovery, and multiple windows are not implemented. ## Releasing The version is the `.version` in `build.zig.zon`; `mise run version x.y.z` rewrites it and the build copies it into `Info.plist`. In panto, `/workflow:ship` does everything: commits the work, bumps the version, pushes `main`, and releases. By hand, with the work committed, `main` at `@-` and pushed, and nothing in the working copy: ```sh DRY_RUN=1 mise run release # test, build and check the zip, and stop there mise run release # and tag, push the tag, and publish on Codeberg ``` Both need a remote named `codeberg`, and a `CODEBERG_TOKEN` with repository write access in `mise.local.toml` (ignored by version control). A release stays a draft until its zip and checksum are uploaded; if it fails partway, run it again. ## The code - `src/doc.zig` and `src/ghost_io.zig`: variants, recoverable ghosts, and the Markdown format. - `src/markdown.zig`: matches inline formatting and link delimiters in the editor’s UTF-16 text, and tells fences, frontmatter and rules from text a line at a time. - `src/lab.zig` and `src/lab_ui.zig`: map model suggestions to draft passages and present them for review. - `src/main.zig`: the app. The page is an `NSTextView`; two custom text attributes mark groups and ghosts, and everything drawn is derived from them. - `src/ai.zig`: one inference request via libpantograph and local key storage. - `src/objc.zig`: the Objective-C runtime calls that make AppKit reachable from Zig.