Native-feeling macOS menu bar utility (Python + rumps) that rewrites copied text using a local Ollama model, then pastes the result back into the previously focused app.
- V1 is working for plain-text workflows.
- Target flow: copy text (
Cmd + C) -> click menu action -> AI rewrite -> auto paste (Cmd + V). - Designed for local model testing and prompt iteration.
- Menu bar app with 4 actions:
Fix Grammar & SpellingMake ProfessionalBuild PromptDraft Reply
- Local Ollama inference via
http://localhost:11434/api/generate - Clipboard snapshot + auto-restore safety
- Re-focus previous app and auto-inject via paste
- Undo last injection
- Terminal debug logs for:
- active model and source
- copied text
- generated prompt
- raw model output
- cleaned output used for paste
- Refusal-recovery retry path for smaller models
- macOS
- Python
3.11+ - Ollama installed and running
- A local model pulled (example):
ollama pull llama3.2:1bpython3 -m venv .venv
source .venv/bin/activate
pip install -e .
python main.pyAlternative run command:
local-ai-text-injectorGrant permissions to the host process running the app (usually Terminal or iTerm):
- Accessibility
- Input Monitoring (if prompted)
Without these, focus switching and paste injection will fail.
You can switch models without code edits.
Option 1: edit model.txt:
llama3.2:1b
Option 2: use environment variable:
export OLLAMA_MODEL=qwen2.5:3bSelection priority:
OLLAMA_MODELOLLAMA_MODEL_FILE./model.txt- project
model.txt - fallback
llama3.2:1b
Note:
- If
OLLAMA_MODELis set,model.txtchanges are ignored. - Model selection is re-read each time you click an action.
OLLAMA_BASE_URLdefault:http://localhost:11434OLLAMA_MODELoptional override (highest priority)OLLAMA_MODEL_FILEoptional custom model file pathOLLAMA_TIMEOUT_SECONDSdefault:45CLIPBOARD_RESTORE_DELAY_SECONDSdefault:1.25TERMINAL_DEBUG_LOGdefault:true
- Select text in any app.
- Press
Cmd + C. - Click the menu bar icon
✍️. - Choose an action.
- Wait for success notification.
- Result is pasted into the previous app.
main.pyentrypointsrc/text_injector/menu_app.pymenu bar UI and action wiringsrc/text_injector/workflow.pyorchestration logicsrc/text_injector/actions.pyaction prompts and prompt builderssrc/text_injector/ollama_client.pyOllama API clientsrc/text_injector/clipboard.pyclipboard snapshot/read/write/restoresrc/text_injector/injector.pyfocus and paste automationsrc/text_injector/settings.pyenv/file config resolutionmodel.txtquick model-switch file
- Plain text only (rich text not preserved)
- Assumes user copied text before action
- UI automation depends on macOS permissions
- Small models may still produce weak rewrites on complex input
- No paste happened:
- Check Accessibility/Input Monitoring permissions.
- Model didn’t switch:
- Confirm terminal log lines
Model:andModel Source:. - Run
unset OLLAMA_MODELif you wantmodel.txtto control model.
- Confirm terminal log lines
- Output quality is poor:
- Try a larger model (
llama3.2:3b,qwen2.5:3b, etc.).
- Try a larger model (
- App seems unchanged after edits:
- Restart process with
Ctrl + Cthenpython main.py.
- Restart process with
Add your preferred license before public release.