Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ examples/piper-data/
examples/whisper-data/
examples/ollama/id_ed25519*
scripts/.runtime/
scripts/macos-hotkeys/menubar-icon
*.onnx
*.onnx.json
*.bin
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ I got tired of typing long prompts to LLMs. Speaking is faster, so I built this

**What it does:**

- Voice transcription to clipboard with system-wide hotkeys (Cmd+Shift+R on macOS)
- Voice transcription to clipboard with system-wide hotkeys (Cmd+Shift+1 on macOS)
- Autocorrect any text from your clipboard
- Edit clipboard content with voice commands ("make this more formal")
- Runs locally - no internet required, your audio stays on your machine
Expand Down Expand Up @@ -265,9 +265,9 @@ This script automatically:
- ✅ Installs Homebrew if not present
- ✅ Installs skhd (hotkey daemon) and terminal-notifier
- ✅ Configures these system-wide hotkeys:
- **`Cmd+Shift+R`** - Toggle voice transcription
- **`Cmd+Shift+A`** - Autocorrect clipboard text
- **`Cmd+Shift+V`** - Voice edit clipboard text
- **`Cmd+Shift+1`** - Toggle voice transcription
- **`Cmd+Shift+2`** - Autocorrect clipboard text
- **`Cmd+Shift+\``** - Voice edit clipboard text

> [!NOTE]
> After setup, you may need to grant Accessibility permissions to skhd in System Settings → Privacy & Security → Accessibility
Expand Down
2 changes: 1 addition & 1 deletion agent_cli/agents/voice_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
KEYBOARD MAESTRO INTEGRATION:
To create a hotkey toggle for this script, set up a Keyboard Maestro macro with:

1. Trigger: Hot Key (e.g., Cmd+Shift+A for "Assistant")
1. Trigger: Hot Key (e.g., Cmd+Shift+` for "Voice Edit")

2. If/Then/Else Action:
- Condition: Shell script returns success
Expand Down
6 changes: 3 additions & 3 deletions agent_cli/install/hotkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def install_hotkeys() -> None:

| Hotkey (macOS / Linux) | Action |
|-------------------------|-------------------------------------------------|
| Cmd/Super + Shift + R | Toggle voice transcription (start/stop) |
| Cmd/Super + Shift + A | Autocorrect clipboard text (grammar/spelling) |
| Cmd/Super + Shift + V | Voice edit clipboard text (voice commands) |
| Cmd/Super + Shift + 1 | Toggle voice transcription (start/stop) |
| Cmd/Super + Shift + 2 | Autocorrect clipboard text (grammar/spelling) |
| Cmd/Super + Shift + ` | Voice edit clipboard text (voice commands) |

**macOS** (fully automatic):

Expand Down
4 changes: 2 additions & 2 deletions docs/commands/autocorrect.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Set up a hotkey to run autocorrect on your clipboard:
=== "macOS (skhd)"

```
cmd + shift + a : /path/to/agent-cli autocorrect
cmd + shift - 2 : /path/to/agent-cli autocorrect
```

=== "Linux (Hyprland)"
Expand All @@ -103,5 +103,5 @@ Set up a hotkey to run autocorrect on your clipboard:
### Typical Usage

1. Select and copy text with errors
2. Press your hotkey (e.g., Cmd+Shift+A)
2. Press your hotkey (e.g., Cmd+Shift+2)
3. Paste the corrected text
6 changes: 3 additions & 3 deletions docs/commands/install-hotkeys.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Sets up hotkeys for common workflows:

**macOS:**

- Cmd+Shift+R: Toggle voice transcription
- Cmd+Shift+A: Autocorrect clipboard text
- Cmd+Shift+V: Voice edit clipboard text
- Cmd+Shift+1: Toggle voice transcription
- Cmd+Shift+2: Autocorrect clipboard text
- Cmd+Shift+`: Voice edit clipboard text

**Linux:**

Expand Down
2 changes: 1 addition & 1 deletion docs/commands/transcribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ agent-cli transcribe --toggle
### macOS Hotkey (skhd)

```
cmd + shift + r : /path/to/agent-cli transcribe --toggle --input-device-index 1
cmd + shift - 1 : /path/to/agent-cli transcribe --toggle --input-device-index 1
```

### Transcription Log
Expand Down
4 changes: 2 additions & 2 deletions docs/commands/voice-edit.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ agent-cli voice-edit --stop
### macOS (skhd)

```
# Toggle voice-edit with Cmd+Shift+V
cmd + shift + v : /path/to/agent-cli voice-edit --toggle --input-device-index 1
# Toggle voice-edit with Cmd+Shift+`
cmd + shift - ` : /path/to/agent-cli voice-edit --toggle --input-device-index 1
```

### Linux (Hyprland)
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ For detailed installation instructions, see the platform-specific guides:
Here's a typical workflow for using voice transcription:

1. **Copy some text** you want to respond to (e.g., an email)
2. **Press your hotkey** (Cmd+Shift+R on macOS) to start recording
2. **Press your hotkey** (Cmd+Shift+1 on macOS) to start recording
3. **Speak your response** naturally
4. **Press the hotkey again** to stop recording
5. **Paste** the transcribed text wherever you need it
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ I got tired of typing long prompts to LLMs. Speaking is faster, so I built this

**What it does:**

- Voice transcription to clipboard with system-wide hotkeys (Cmd+Shift+R on macOS)
- Voice transcription to clipboard with system-wide hotkeys (Cmd+Shift+1 on macOS)
- Autocorrect any text from your clipboard
- Edit clipboard content with voice commands ("make this more formal")
- Runs locally - no internet required, your audio stays on your machine
Expand Down
6 changes: 3 additions & 3 deletions docs/system-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ Create or edit `~/.config/skhd/skhdrc`:

```bash
# Transcribe to clipboard (toggle recording)
cmd + shift + r : /path/to/agent-cli transcribe --toggle --input-device-index 1
cmd + shift - 1 : /path/to/agent-cli transcribe --toggle --input-device-index 1

# Autocorrect clipboard
cmd + shift + a : /path/to/agent-cli autocorrect
cmd + shift - 2 : /path/to/agent-cli autocorrect

# Voice edit clipboard
cmd + shift + v : /path/to/agent-cli voice-edit --toggle --input-device-index 1
cmd + shift - ` : /path/to/agent-cli voice-edit --toggle --input-device-index 1

# Speak clipboard
cmd + shift + s : /path/to/agent-cli speak
Expand Down
6 changes: 3 additions & 3 deletions scripts/macos-hotkeys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ System-wide hotkeys for agent-cli voice AI features on macOS.

## Usage

- **`Cmd+Shift+R`** → Toggle voice transcription (start/stop with result)
- **`Cmd+Shift+A`** → Autocorrect clipboard text
- **`Cmd+Shift+V`** → Toggle voice edit mode for clipboard
- **`Cmd+Shift+1`** → Toggle voice transcription (start/stop with result)
- **`Cmd+Shift+2`** → Autocorrect clipboard text
- **`Cmd+Shift+\``** → Toggle voice edit mode for clipboard

Results appear in notifications and clipboard.

Expand Down
30 changes: 30 additions & 0 deletions scripts/macos-hotkeys/menubar-icon.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env swift
// Minimal menu bar icon that shows while recording.
// Usage: menubar-icon [icon] [tooltip]
// Exits on SIGTERM or SIGINT. Kill the process to remove the icon.

import AppKit

let icon = CommandLine.arguments.count > 1 ? CommandLine.arguments[1] : "🎙️"
let tooltip = CommandLine.arguments.count > 2 ? CommandLine.arguments[2] : "agent-cli: recording"

let app = NSApplication.shared
app.setActivationPolicy(.accessory)

let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
statusItem.button?.title = icon
statusItem.button?.toolTip = tooltip

// Use DispatchSource for safe signal handling on the main queue
signal(SIGTERM, SIG_IGN)
signal(SIGINT, SIG_IGN)

let sigterm = DispatchSource.makeSignalSource(signal: SIGTERM, queue: .main)
sigterm.setEventHandler { NSApp.terminate(nil) }
sigterm.resume()

let sigint = DispatchSource.makeSignalSource(signal: SIGINT, queue: .main)
sigint.setEventHandler { NSApp.terminate(nil) }
sigint.resume()

app.run()
4 changes: 2 additions & 2 deletions scripts/macos-hotkeys/skhd-config-example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Simple skhd configuration for transcription toggle
# Save to ~/.config/skhd/skhdrc

# Press Cmd+Shift+R to toggle transcription
cmd + shift - r : /path/to/toggle-transcription.sh
# Press Cmd+Shift+1 to toggle transcription
cmd + shift - 1 : /path/to/toggle-transcription.sh
41 changes: 35 additions & 6 deletions scripts/macos-hotkeys/toggle-transcription.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#!/usr/bin/env bash

# Toggle script for agent-cli transcription on macOS
# Shows a subtle menu bar icon while recording instead of notification banners.

NOTIFIER=${NOTIFIER:-/opt/homebrew/bin/terminal-notifier}
AGENT_CLI=${AGENT_CLI:-"$HOME/.local/bin/agent-cli"}
PID_FILE=${PID_FILE:-"$HOME/.cache/agent-cli/transcribe.pid"}
RECORDING_GROUP="agent-cli-transcribe-recording"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
MENUBAR_ICON="$SCRIPT_DIR/menubar-icon"
MENUBAR_PID_FILE="$HOME/.cache/agent-cli/menubar-icon.pid"
TEMP_PREFIX="agent-cli-transcribe-temp"

notify_temp() {
local title=$1
local message=$2
local duration=${3:-4} # 4 seconds default
local duration=${3:-4}
local group="${TEMP_PREFIX}-${RANDOM}-$$"

"$NOTIFIER" -title "$title" -message "$message" -group "$group"
Expand All @@ -21,6 +24,31 @@ notify_temp() {
) &
}

show_menubar_icon() {
# Compile on first use if binary doesn't exist
if [ ! -x "$MENUBAR_ICON" ] && [ -f "$MENUBAR_ICON.swift" ]; then
swiftc -O "$MENUBAR_ICON.swift" -o "$MENUBAR_ICON" 2>/dev/null
fi
if [ -x "$MENUBAR_ICON" ]; then
"$MENUBAR_ICON" "🎙️" "agent-cli: recording" &
echo $! > "$MENUBAR_PID_FILE"
fi
}

hide_menubar_icon() {
# Kill by PID file
if [ -f "$MENUBAR_PID_FILE" ]; then
local pid
pid=$(cat "$MENUBAR_PID_FILE" 2>/dev/null || true)
if [ -n "$pid" ]; then
kill "$pid" >/dev/null 2>&1 || true
fi
rm -f "$MENUBAR_PID_FILE"
fi
# Fallback: kill any remaining instances
pkill -x menubar-icon >/dev/null 2>&1 || true
}

is_transcribe_running() {
[ -f "$PID_FILE" ] || return 1
local pid
Expand All @@ -30,14 +58,15 @@ is_transcribe_running() {

if is_transcribe_running; then
"$AGENT_CLI" transcribe --toggle --quiet >/dev/null 2>&1 || true

"$NOTIFIER" -remove "$RECORDING_GROUP" >/dev/null 2>&1 || true
hide_menubar_icon
notify_temp "🛑 Stopped" "Processing results..."
else
"$NOTIFIER" -title "🎙️ Started" -message "Listening..." -group "$RECORDING_GROUP"
# Clean up any stale icon from a previous run
hide_menubar_icon
show_menubar_icon
(
OUTPUT=$("$AGENT_CLI" transcribe --toggle --llm --quiet 2>/dev/null)
"$NOTIFIER" -remove "$RECORDING_GROUP" >/dev/null 2>&1 || true
hide_menubar_icon
if [ -n "$OUTPUT" ]; then
notify_temp "📄 Result" "$OUTPUT"
else
Expand Down
12 changes: 6 additions & 6 deletions scripts/setup-macos-hotkeys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ VOICE_EDIT_SCRIPT="$SCRIPT_DIR/macos-hotkeys/toggle-voice-edit.sh"

cat > ~/.config/skhd/skhdrc << EOF
# Agent-CLI Hotkeys
cmd + shift - r : "$TRANSCRIBE_SCRIPT"
cmd + shift - a : "$AUTOCORRECT_SCRIPT"
cmd + shift - v : "$VOICE_EDIT_SCRIPT"
cmd + shift - 1 : "$TRANSCRIBE_SCRIPT"
cmd + shift - 2 : "$AUTOCORRECT_SCRIPT"
cmd + shift - 0x32 : "$VOICE_EDIT_SCRIPT"
EOF

# Start service
Expand All @@ -46,9 +46,9 @@ terminal-notifier -title "⌨️ Setup Complete" -message "Agent-CLI hotkeys rea

echo ""
echo "✅ Done! Hotkeys:"
echo " Cmd+Shift+R - Transcribe voice"
echo " Cmd+Shift+A - Autocorrect clipboard"
echo " Cmd+Shift+V - Voice edit clipboard"
echo " Cmd+Shift+1 - Transcribe voice"
echo " Cmd+Shift+2 - Autocorrect clipboard"
echo " Cmd+Shift+\` - Voice edit clipboard"
echo ""
echo "If the hotkey doesn't work:"
echo "1. Open System Settings → Privacy & Security → Accessibility"
Expand Down