Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

System-Wide Local AI Text Injector

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.

Current Status

  • 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.

Features

  • Menu bar app with 4 actions:
    • Fix Grammar & Spelling
    • Make Professional
    • Build Prompt
    • Draft 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

Requirements

  • macOS
  • Python 3.11+
  • Ollama installed and running
  • A local model pulled (example):
ollama pull llama3.2:1b

Quick Start

python3 -m venv .venv
source .venv/bin/activate
pip install -e .
python main.py

Alternative run command:

local-ai-text-injector

Permissions (macOS)

Grant 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.

Model Selection

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:3b

Selection priority:

  1. OLLAMA_MODEL
  2. OLLAMA_MODEL_FILE
  3. ./model.txt
  4. project model.txt
  5. fallback llama3.2:1b

Note:

  • If OLLAMA_MODEL is set, model.txt changes are ignored.
  • Model selection is re-read each time you click an action.

Environment Variables

  • OLLAMA_BASE_URL default: http://localhost:11434
  • OLLAMA_MODEL optional override (highest priority)
  • OLLAMA_MODEL_FILE optional custom model file path
  • OLLAMA_TIMEOUT_SECONDS default: 45
  • CLIPBOARD_RESTORE_DELAY_SECONDS default: 1.25
  • TERMINAL_DEBUG_LOG default: true

Typical Usage

  1. Select text in any app.
  2. Press Cmd + C.
  3. Click the menu bar icon ✍️.
  4. Choose an action.
  5. Wait for success notification.
  6. Result is pasted into the previous app.

Project Structure

  • main.py entrypoint
  • src/text_injector/menu_app.py menu bar UI and action wiring
  • src/text_injector/workflow.py orchestration logic
  • src/text_injector/actions.py action prompts and prompt builders
  • src/text_injector/ollama_client.py Ollama API client
  • src/text_injector/clipboard.py clipboard snapshot/read/write/restore
  • src/text_injector/injector.py focus and paste automation
  • src/text_injector/settings.py env/file config resolution
  • model.txt quick model-switch file

Limitations (V1)

  • 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

Troubleshooting

  • No paste happened:
    • Check Accessibility/Input Monitoring permissions.
  • Model didn’t switch:
    • Confirm terminal log lines Model: and Model Source:.
    • Run unset OLLAMA_MODEL if you want model.txt to control model.
  • Output quality is poor:
    • Try a larger model (llama3.2:3b, qwen2.5:3b, etc.).
  • App seems unchanged after edits:
    • Restart process with Ctrl + C then python main.py.

License

Add your preferred license before public release.

About

Lightweight macOS menu bar app that transforms copied text with a local Ollama model and pastes it back into the previous app.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages