Skip to content

sanathks/rewrite

Repository files navigation

Rewrite

Rewrite

A lightweight macOS menu bar app for system-wide grammar correction, text rewriting, and voice-to-text, powered by local LLMs via Ollama or LM Studio and on-device speech recognition via Moonshine.

Select text in any app, hit a keyboard shortcut, and get instant results. Hold a shortcut to dictate with your voice. All processing happens locally. No data leaves your machine.

Install

Download

Latest Release: 1.3.0

Platform Download
macOS (Apple Silicon) Rewrite-apple-silicon.dmg
macOS (Intel) Rewrite-intel.dmg
  1. Download the DMG for your Mac
  2. Open the DMG and drag Rewrite.app to your Applications folder
  3. On first launch, right-click the app and select Open (macOS blocks unsigned apps by default)
  4. Grant Accessibility permissions when prompted

Build from Source

Requirements

  • macOS 13+
  • Swift toolchain (Xcode or Command Line Tools)
  • CMake (for building the Moonshine C++ core)
  • Git

Clone and Build

git clone --recursive https://github.com/sanathks/rewrite.git
cd rewrite

If you already cloned without --recursive, initialize the submodule:

git submodule update --init --depth 1

Build the app:

chmod +x Scripts/build.sh Scripts/install.sh
./Scripts/build.sh

This will:

  1. Build the Moonshine C++ core and create the XCFramework (first time only)
  2. Compile the Swift app in release mode
  3. Create build/Rewrite.app and build/Rewrite.dmg

To build for a specific architecture:

./Scripts/build.sh arm64    # Apple Silicon only
./Scripts/build.sh x86_64   # Intel only

Install

./Scripts/install.sh

This copies Rewrite.app to ~/Applications and registers it with Launch Services.

Or simply open the DMG from build/Rewrite.dmg and drag to Applications.

Updating the Moonshine Submodule

To pull the latest Moonshine changes:

git submodule update --remote vendor/moonshine

Then rebuild the XCFramework by removing the old one and running the build:

rm -rf vendor/moonshine/swift/Moonshine.xcframework
./Scripts/build.sh

Prerequisites

  • Ollama or LM Studio installed and running
  • For Ollama, pull a model (default: gemma3):
    ollama pull gemma3
  • For LM Studio, load a model and start the local server (default port: 1234)

Usage

Text Rewriting

  1. Launch Rewrite -- an icon appears in the menu bar
  2. Select text in any app (browser, Slack, Notes, TextEdit, etc.)
  3. Press Ctrl+Shift+G to silently fix grammar (text is replaced in-place, no popup)
  4. Press Ctrl+Shift+T to open the rewrite popup with mode selection
  5. Click Replace to swap the original text, or Copy to copy to clipboard

Press Esc to dismiss the popup.

Voice Input (Speech-to-Text)

  1. Download a speech model from Settings (Tiny, Small, or Medium)
  2. Grant microphone permission when prompted
  3. Hold Ctrl+Option+S and speak
  4. Release the keys to stop recording
  5. The transcribed text is inserted at your cursor

When Auto Grammar Fix is enabled (default), transcribed text is automatically corrected by the LLM before insertion. Toggle this off in Settings to insert raw transcription.

You can select which microphone to use from the Settings dropdown.

Speech Models

Rewrite uses Moonshine for on-device speech recognition. Three streaming models are available:

Model Size Accuracy Latency (MacBook Pro)
Tiny ~35 MB Good ~34ms
Small ~130 MB Better ~73ms
Medium ~300 MB Best ~107ms

All models run entirely on-device with no internet required.

Rewrite Modes

The rewrite popup runs your default mode immediately and shows mode pills to switch between:

Rewrite Popup

  • Fix Grammar -- fixes grammar, spelling, and punctuation errors without changing tone or wording
  • Clarity -- simplifies text for maximum readability
  • My Tone -- rewrites to match your personal tone description
  • Humanize -- makes AI-generated text sound natural

Click Replace to swap the original text in-place, or Copy to copy the result to clipboard.

Modes are fully configurable. Add, remove, or edit modes and their prompts via Configure... in settings.

Configuration

Click the menu bar icon to access settings:

Settings

  • Server URL -- default: http://localhost:11434 (Ollama) or http://localhost:1234 (LM Studio)
  • Model -- auto-detected from your LLM server
  • Rewrite Modes -- click Configure to edit mode names and prompts
  • Shortcuts -- click to rebind the grammar, rewrite, and voice input hotkeys
  • Default Mode -- choose which mode the Quick Fix shortcut uses
  • Voice Input -- select speech model, microphone, and toggle auto grammar fix
  • Launch at Login -- start Rewrite automatically when you log in

Settings persist across app restarts.

How It Works

Rewrite uses the macOS Accessibility API to read and write text in any app. When you trigger a shortcut:

  1. Reads the selected text via accessibility
  2. Sends it to your local LLM server with a tailored prompt
  3. For Quick Fix: silently replaces the text in-place using the default mode
  4. For rewrite: shows a popup near your selection with mode options and the result
  5. On "Replace", writes the corrected text back into the source app via accessibility

For voice input:

  1. Captures audio from your selected microphone
  2. Transcribes speech on-device using the Moonshine streaming model
  3. Optionally runs the transcription through the LLM for grammar correction
  4. Inserts the result at your cursor position

Project Structure

rewrite/
  Sources/Rewrite/       # Swift source code
  Resources/             # Info.plist, icons
  Scripts/
    build.sh             # Build app bundle and DMG
    build-moonshine.sh   # Build Moonshine C++ core + XCFramework
    install.sh           # Install to ~/Applications
  vendor/moonshine/      # Moonshine submodule (speech recognition)
  Package.swift          # Swift Package Manager manifest

License

MIT