opencode-interrupt-plugin 0.4.31 → 0.4.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +11 -12
  2. package/dist/index.js +13 -10
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,36 +1,35 @@
1
1
  # OpenCode Interrupt Plugin
2
2
 
3
- Streaming TTS + voice interruption for OpenCode. Speaks responses as they arrive and detects when you talk over it. **Walkie-talkie mode** lets you hold the spacebar to redirect the model on the fly.
3
+ Streaming TTS + voice interruption for OpenCode. Speaks responses as they arrive and detects when you talk over it. **Walkie-talkie mode** lets you type `/ptt` to redirect the model on the fly.
4
4
 
5
5
  ## Installation
6
6
 
7
- Add both the server plugin and the TUI plugin to your `~/.config/opencode/opencode.json`:
7
+ Add the plugin to your `~/.config/opencode/opencode.json`:
8
8
 
9
9
  ```json
10
10
  {
11
11
  "plugin": [
12
- "opencode-interrupt-plugin",
13
- "opencode-interrupt-plugin/tui"
12
+ "opencode-interrupt-plugin"
14
13
  ]
15
14
  }
16
15
  ```
17
16
 
18
- The server plugin handles TTS streaming, voice overlap detection, and interrupt injection. The TUI plugin adds the walkie-talkie keybinding (`space`).
17
+ The plugin handles TTS streaming, voice overlap detection, interrupt injection, and the `/ptt` walkie-talkie slash command.
19
18
 
20
19
  ## Usage
21
20
 
22
21
  ### Walkie-Talkie Mode
23
22
 
24
- Hold down the **spacebar** while speaking, then release it to redirect the model:
23
+ Type `/ptt` to toggle recording, speak, then type `/ptt` again to send:
25
24
 
26
25
  1. The model is generating a response — TTS is playing
27
- 2. **Press and hold** spacebar — generation aborts, TTS stops, mic starts recording
28
- 3. **Speak your correction** while holding spacebar
29
- 4. **Release** spacebar — audio is transcribed via Whisper and sent as your next message
26
+ 2. **Type `/ptt`** — generation aborts, TTS stops, mic starts recording
27
+ 3. **Speak your correction**
28
+ 4. **Type `/ptt` again** — audio is transcribed via Whisper and sent as your next message
30
29
  5. The model responds to your correction
31
30
 
32
31
  ```
33
- [Model speaking] → hold space → speak correction → release space → model redirects
32
+ [Model speaking] → type /ptt → speak correction → type /ptt → model redirects
34
33
  ```
35
34
 
36
35
  Requires [whisper.cpp](https://github.com/ggerganov/whisper.cpp) with the `base` model installed.
@@ -42,7 +41,7 @@ bash scripts/install-whisper.sh
42
41
 
43
42
  Or set `OPENAI_API_KEY` in your environment as a fallback.
44
43
 
45
- ### Voice Interruption (server plugin)
44
+ ### Voice Interruption
46
45
 
47
46
  When TTS is playing, just speak — the plugin detects your voice, stops TTS, and marks the session for correction injection.
48
47
 
@@ -63,4 +62,4 @@ When TTS is playing, just speak — the plugin detects your voice, stops TTS, an
63
62
  ## How It Works
64
63
 
65
64
  - **Server plugin**: Monitors mic via sox (continuous PCM pipe), detects voice during TTS playback, injects correction context into the next LLM request
66
- - **TUI plugin**: Registers a `space` keybinding in OpenCode's TUI keymap; key repeats while held keep the recording active; 300ms of silence after release triggers transcription and redirect
65
+ - **`/ptt` command**: `command.execute.before` hook intercepts `/ptt`, toggles recording on/off, transcribes via whisper.cpp, and sends the transcript via `session.prompt()`
package/dist/index.js CHANGED
@@ -89,13 +89,13 @@ async function transcribeAndSend(sessionID, directory, api) {
89
89
  api.ui.toast({ variant: "warning", title: "PTT", message: "No audio captured" });
90
90
  return;
91
91
  }
92
- api.ui.toast({ variant: "info", title: "PTT", message: "Transcribing..." });
92
+ api.ui.toast({ variant: "info", title: "PTT", message: "Transcribing with Whisper..." });
93
93
  let text = null;
94
94
  text = await transcribeLocal();
95
95
  if (!text)
96
96
  text = await transcribeAPI();
97
97
  if (!text) {
98
- api.ui.toast({ variant: "error", title: "PTT", message: "Missing whisper run scripts/install-whisper.sh or set OPENAI_API_KEY" });
98
+ api.ui.toast({ variant: "error", title: "PTT", message: " Install whisper: run scripts/install-whisper.sh, or set OPENAI_API_KEY" });
99
99
  try {
100
100
  unlinkSync(RECORDING_FILE);
101
101
  }
@@ -107,25 +107,27 @@ async function transcribeAndSend(sessionID, directory, api) {
107
107
  }
108
108
  catch { /* ignore */ }
109
109
  if (!sessionID) {
110
- api.ui.toast({ variant: "warning", title: "PTT", message: "No active session" });
110
+ api.ui.toast({ variant: "warning", title: "PTT", message: "⚠️ Open a session first, then type /ptt" });
111
111
  return;
112
112
  }
113
+ api.ui.toast({ variant: "info", title: "PTT", message: "✉️ Sending transcript..." });
113
114
  await api.client.session.prompt({ sessionID, directory, parts: [{ type: "text", text }] });
114
- api.ui.toast({ variant: "success", title: "PTT", message: `Sent: "${text.slice(0, 60)}"` });
115
+ const preview = text.length > 80 ? text.slice(0, 77) + "..." : text;
116
+ api.ui.toast({ variant: "success", title: "PTT", message: `✅ Sent: "${preview}"` });
115
117
  }
116
118
  async function transcribeAndSendV1(sessionID, client) {
117
119
  pttStopRecording();
118
120
  if (!existsSync(RECORDING_FILE)) {
119
- await client.tui.showToast({ body: { title: "PTT", message: "No audio captured — try again", variant: "warning" } });
121
+ await client.tui.showToast({ body: { title: "PTT", message: "⚠️ No audio captured — try again", variant: "warning" } });
120
122
  return;
121
123
  }
122
- await client.tui.showToast({ body: { title: "PTT", message: "Transcribing with Whisper...", variant: "info" } });
124
+ await client.tui.showToast({ body: { title: "PTT", message: "Transcribing with Whisper...", variant: "info" } });
123
125
  let text = null;
124
126
  text = await transcribeLocal();
125
127
  if (!text)
126
128
  text = await transcribeAPI();
127
129
  if (!text) {
128
- await client.tui.showToast({ body: { title: "PTT", message: "Install whisper: run scripts/install-whisper.sh, or set OPENAI_API_KEY", variant: "error", duration: 8000 } });
130
+ await client.tui.showToast({ body: { title: "PTT", message: "Install whisper: run scripts/install-whisper.sh, or set OPENAI_API_KEY", variant: "error", duration: 8000 } });
129
131
  try {
130
132
  unlinkSync(RECORDING_FILE);
131
133
  }
@@ -137,12 +139,13 @@ async function transcribeAndSendV1(sessionID, client) {
137
139
  }
138
140
  catch { /* ignore */ }
139
141
  if (!sessionID) {
140
- await client.tui.showToast({ body: { title: "PTT", message: "Open a session first, then type /ptt", variant: "warning", duration: 5000 } });
142
+ await client.tui.showToast({ body: { title: "PTT", message: "⚠️ Open a session first, then type /ptt", variant: "warning", duration: 5000 } });
141
143
  return;
142
144
  }
145
+ await client.tui.showToast({ body: { title: "PTT", message: "✉️ Sending transcript...", variant: "info" } });
143
146
  await client.session.prompt({ path: { id: sessionID }, body: { parts: [{ type: "text", text }] } });
144
147
  const preview = text.length > 80 ? text.slice(0, 77) + "..." : text;
145
- await client.tui.showToast({ body: { title: "PTT", message: `Sent: "${preview}"`, variant: "success", duration: 5000 } });
148
+ await client.tui.showToast({ body: { title: "PTT", message: `✅ Sent: "${preview}"`, variant: "success", duration: 5000 } });
146
149
  }
147
150
  const TTS_COMMANDS = [
148
151
  { name: 'tts-on', description: 'Enable streaming TTS', template: 'TTS enabled.' },
@@ -338,7 +341,7 @@ export const InterruptPlugin = (userConfig = {}) => {
338
341
  catch { /* ignore */ }
339
342
  }
340
343
  pttStartRecording();
341
- await client.tui.showToast({ body: { title: "PTT", message: "Recording... type /ptt to stop", variant: "info" } });
344
+ await client.tui.showToast({ body: { title: "PTT", message: "🎤 Recording... type /ptt to stop", variant: "info" } });
342
345
  }
343
346
  throw new Error('Command handled by interrupt plugin');
344
347
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-interrupt-plugin",
3
- "version": "0.4.31",
3
+ "version": "0.4.33",
4
4
  "description": "Streaming TTS + voice interruption for OpenCode. Speaks responses as they arrive and detects when you talk over it.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",