跳到正文
GitHub·· 7 天前AI 评分62

Pretype 发布 macOS 全局 AI 自动补全工具,本地模型离线运行

nikiomori/Pretype

AI 导读

Pretype 发布面向 macOS 的全局 AI 自动补全工具,可在任意文本框给出 Copilot 式建议,补全由本地模型完成、不上传输入内容。它需要辅助功能权限读取焦点文本框,按 Tab 接受一个词、⇧Tab 接受剩余内容,并支持行内拼写修正、表情短代码、行内算术、⌥Tab 改写与 ⌥⇧Tab 回复草稿。

正文

Pretype logo

System-wide AI autocomplete for macOS.
Copilot-style suggestions in every text field — offline, private, and on-device.

Latest release CI License: MIT Platform: macOS 14+ Website

Features · Quick Start · Models · Privacy · FAQ

Download Pretype for macOS (Apple Silicon)

Typing in a text field; gray ghost text appears at the caret and Tab accepts it word by word

Type anywhere → the local model answers → Tab takes a word, ⇧Tab takes the rest.


Important

What it needs, and what leaves your Mac. Pretype needs the Accessibility permission — the same grant a keylogger would ask for — to read the focused text field, catch the accept key, and type suggestions back. Nothing you type is ever uploaded: completions run on a local model, and the app makes only two kinds of network request — model weights from Hugging Face, and a once-a-day version check against the GitHub Releases API that sends nothing about you (off in Settings → General).

Don't take that on faith. The entire input path is three files worth reading: AXText.swift reads the field, KeyTap.swift watches for the accept key, TextInjector.swift types back. Everything the app stores, and how to remove all of it, is in Privacy & permissions.

Why Pretype?

Most autocomplete lives inside a single editor and ships your text to a server. Pretype works in every macOS text field — Mail, Slack, Notes, Safari, VS Code — and never leaves your machine. No account, no subscription, no API key.

It's a free, MIT-licensed alternative to Cotypist — a from-scratch reimplementation of the same idea, not affiliated with it.


Features

  • Any text field — native AppKit/SwiftUI apps, Electron apps (VS Code, Slack, Claude Desktop), and web views.
  • Ghost text at the caret — baseline-matched and sized to the field's own font, or a floating panel if you prefer that.
  • Tab to accept — one word at a time, ⇧Tab for the rest, or just keep typing to reject. The part one Tab will take renders a step brighter. Switchable to ⌘Space, ⌥Space or ⌃Space in Settings.
  • Inline typo fixes — a correction pill above the misspelled word, Tab to apply. Uses the macOS spell-checker in whichever language it detects from the surrounding text.
  • Emoji shortcodes — type :shrug: and 🤷 is offered in the same pill, Tab to take it. A handful of Gemoji nicknames plus every Unicode character name macOS already knows, so :rocket: and :thinking_face: work without shipping a table.
  • Inline arithmetic — end a sum with = (12*7=, (1+2)*3 =) and the result is offered in the same pill.
  • Rewrites (⌥Tab) and reply drafts (⌥⇧Tab) — select clumsy text and the local model fixes grammar, typos and phrasing in place, keeping your tone; with nothing selected it fixes the word you just typed. Add ⇧ (or double-tap a modifier) and it drafts your next message from the conversation on screen instead. Both are measured per model — the strongest sibling restores 69% of noisy lines byte-exactly and drafts a usable reply 97% of the time — and Choosing a model has the table. On some models this needs a separate instruct sibling, downloaded once on first use (≈2.2 GB on MiniCPM5, up to ≈5 GB on a base-style Gemma; the menu bar shows preparing…).
  • Talk instead of typing (macOS 26+, off by default) — hold ⌥, say the sentence, let go: it is typed into the field you're already in. For anything longer than a sentence there's a hands-free chord (⌃⌥D) — press once to start, once to stop, nothing to hold, so you can scroll, click and think mid-paragraph without losing the capture. It also starts recording on the keypress itself instead of half a second later, because nothing else on the system means that chord. A hands-free capture that goes quiet for a few seconds types what it has and stops on its own, so a forgotten chord is never an open microphone. Transcribed by the system's own on-device speech models, so nothing is downloaded from us and no audio is written to disk or sent anywhere. Apple's newer speech model covers 30 locales (English, German, Spanish, French, Italian, Japanese, Korean, Portuguese, Cantonese, Chinese); everything else — Russian included — uses the model behind macOS's own dictation key, which is rougher and writes no punctuation. For those languages you can opt into Parakeet (NVIDIA's open 0.6B speech model, run on the Neural Engine; a one-time ~470 MB download): on Russian it made half the word errors of the system model (6.6% vs 12.6% WER on FLEURS) and writes its own punctuation. Either way the tidy-up pass is there too: the transcript goes through the same minimal-edit fix ⌥Tab uses, restoring the punctuation and capitalization speech doesn't carry — which on the models that need a separate instruct sibling means the same one-time download ⌥Tab would trigger (dictations don't wait for it — they land as heard while the fetch runs in the background, and the tidy-up starts once it's done). Language follows your keyboard layout, so switching layout switches dictation language. Names and terms already in the field are handed to the recognizer as hints, so it spells them the way the page does. With voice commands switched on (Settings → Dictation), dictating while text is selected is an instruction for it instead — "make it shorter", "more formal", "translate to English" — previewed like a ⌥Tab fix. Switch focus mid-capture and the transcript lands on the clipboard instead of being lost.
  • Fast — 49–145 ms warm completions across the local models, by prefilling only the newly typed tokens and reusing the KV cache.
  • Knows where it is — adapts per app and per website (Gmail and Slack in the same browser can sound different, or one can be switched off from the menu), stays out of terminals and password managers, and stops reading entirely while macOS reports secure input. Pause on Battery in the menu stops completions while unplugged. Where you almost never take its suggestions it goes quiet by itself, and says so in the menu with the numbers and a one-click Resume. Optional on-screen OCR pulls in surrounding context.
  • Sounds like you — one persona plus per-app style instructions, learned from a local journal you can clear or switch off at any time. Per-app styles are shared by the community: one click adds the ones for the apps on your Mac, and one text file (or the share button in Settings) adds yours for everyone.

Quick Start

Homebrew (recommended)

brew install nikiomori/tap/pretype

Apple Silicon only (M1 or newer) — MLX does not run on Intel Macs. Then continue from step 3.

Download the app

  1. Apple Silicon only (M1 or newer). Grab Pretype.app.zip from Releases, unzip, and move Pretype.app to /Applications.
  2. Open it. Releases are signed with a Developer ID and notarized by Apple, so it launches like any other downloaded app. Coming from 2.4.0 or earlier (ad-hoc signed)? macOS asks for Accessibility once more after this update, because the signature changed; later updates keep the grant.
  3. Launch it and grant Accessibility when prompted. If you grant it after launching, restart the app.
  4. On first launch Pretype downloads one model from Hugging Face (≈1.6–6.8 GB, sized to your Mac's memory — the strongest tier that stays within about a quarter of it; the menu-bar icon shows progress). Any other model is one click in Settings → Model; Choosing a model has the eval numbers behind the default.
  5. Pretype lives in the menu bar — no Dock icon, no main window. Click the icon for status, Diagnostics, and Settings… (⌘,).

Build from source

Note

Requires full Xcode 26.4 or newer — the MLX packages need Swift 6.3, the Apple Intelligence engine imports the FoundationModels framework, which is absent from Xcode 16.x, and the MLX engine needs the Metal compiler. Command Line Tools alone are not enough. The prebuilt app above needs none of this.

xcodebuild -downloadComponent MetalToolchain      # once

git clone https://github.com/nikiomori/Pretype.git && cd Pretype
./Scripts/make-app.sh                             # builds build/Pretype.app
open build/Pretype.app

Dev loop, headless harnesses and the SwiftPM/Metal caveat live in the Contributing Guide.


In Action

A misspelled word gets a correction pill above it; Tab applies the fix in place

Inline typo fix. Tab applies it, Esc dismisses.

A messy line is selected, Option-Tab sends it to the local model, and the rewrite replaces it in place

Rewrite (⌥Tab). ⏎ takes the rewrite, Esc keeps your original.

Two presentation modes side by side: inline ghost text on the line, and a floating capsule panel above it

Two presentation modes. Inline ghost text stays pixel-accurate even in Electron apps.

Settings window with a glass sidebar and a Live Impact inspector showing measured accuracy, speed, memory and compute

Settings show their cost. Hover any option and the accuracy / speed / memory / compute meters preview the change before you commit it.

Personalization tab with a persona field and per-app style instructions for Mail, Messages and Notes

Your voice, per app. Formal prose in Mail, short replies in Messages.


How It Works

flowchart LR
    App["Focused App<br/>Any text field"] -->|AX API Text| FocusTracker
    FocusTracker -->|Prompt| MLX["MLX Engine<br/>Local LLM"]
    MLX -->|Suggestion| Window[Suggestion Overlay]
    Window -->|Ghost Text| App
    App -->|Keystrokes| EventTap
    EventTap -->|Tab Caught| Injector[Text Injector]
    Injector -->|Simulated Keys| App

Loading

  1. FocusTracker follows the focused text element via AXObserver and reads the text around the caret on each keystroke.
  2. The CompletionEngine — a local MLX model, debounced and cancellable — returns a short continuation, or stays silent.
  3. SuggestionWindow draws the ghost text, size- and baseline-matched to the caret.
  4. A CGEventTap catches the accept key. If you take the suggestion, TextInjector types it into the active app as synthetic key events.

Documentation

Rendered at pretype.app/docs, written in docs/.

Architecture Engines, the model catalog, quantization tiers, the KV cache, and how the app decides to stay quiet
Choosing a model The eval behind the defaults, what each tier costs in RAM and latency, and how to pick for your languages
Privacy & permissions Every permission and why it's needed, what's stored on disk, and how to uninstall completely
Troubleshooting & FAQ Reading Diagnostics, the common failure modes, and the questions that keep coming up
Fine-tuning Training a small base model on your own writing, end to end on your Mac

Requirements

  • OS — macOS 14+ (macOS 26+ for the Apple Intelligence engine)
  • Hardware — Apple Silicon (M1 or newer). Intel Macs can't run MLX at all.
  • Memory — 8 GB is enough; the default is sized to about a quarter of your Mac's memory (≈1.1 GB resident on 8 GB Macs up to ≈6.8 GB from 32 GB), and the catalog goes down to ≈1 GB. Big-RAM Macs can pick Gemma 4 E4B 8-bit, a ≈6 GB download.
  • Storage — ≈1.6–6.8 GB for the default model (sized to your Mac); 1–8.6 GB depending on what you pick. Using ⌥Tab can add a one-time instruct sibling (≈2.2 GB on MiniCPM5, up to ≈5 GB on a base-style Gemma; none on Qwen3.5 or Bonsai, which correct with themselves, or on a Gemma in its recommended Instruct style)
  • To build — full Xcode 26.4+ (Swift 6.3, macOS 26 SDK + Metal toolchain). Not needed for the prebuilt app.

Contributing

Pretype is young and moving fast — bug reports, ideas and pull requests are all welcome.

If Pretype is useful to you, a ⭐ helps others find it.

Acknowledgements

MLX and mlx-swift-lm — Apple's on-device ML stack · MiniCPM and Qwen — the default models · Gemma — the heavy-duty option · swift-transformers — tokenizers and hub client · Cotypist — the original inspiration.

License

MIT — free for personal and commercial use. Bundled libraries and downloadable model weights carry their own licenses; see THIRD_PARTY_NOTICES.md.

来源:GitHub · github.com