opencode-interrupt-plugin 0.4.30 → 0.4.32

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 +7 -6
  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
@@ -116,16 +116,16 @@ async function transcribeAndSend(sessionID, directory, api) {
116
116
  async function transcribeAndSendV1(sessionID, client) {
117
117
  pttStopRecording();
118
118
  if (!existsSync(RECORDING_FILE)) {
119
- await client.tui.showToast({ body: { title: "PTT", message: "No audio captured", variant: "warning" } });
119
+ await client.tui.showToast({ body: { title: "PTT", message: "No audio captured — try again", variant: "warning" } });
120
120
  return;
121
121
  }
122
- await client.tui.showToast({ body: { title: "PTT", message: "Transcribing...", variant: "info" } });
122
+ await client.tui.showToast({ body: { title: "PTT", message: "Transcribing with Whisper...", variant: "info" } });
123
123
  let text = null;
124
124
  text = await transcribeLocal();
125
125
  if (!text)
126
126
  text = await transcribeAPI();
127
127
  if (!text) {
128
- await client.tui.showToast({ body: { title: "PTT", message: "Missing whisper run scripts/install-whisper.sh or set OPENAI_API_KEY", variant: "error" } });
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 } });
129
129
  try {
130
130
  unlinkSync(RECORDING_FILE);
131
131
  }
@@ -137,11 +137,12 @@ async function transcribeAndSendV1(sessionID, client) {
137
137
  }
138
138
  catch { /* ignore */ }
139
139
  if (!sessionID) {
140
- await client.tui.showToast({ body: { title: "PTT", message: "No active session", variant: "warning" } });
140
+ await client.tui.showToast({ body: { title: "PTT", message: "Open a session first, then type /ptt", variant: "warning", duration: 5000 } });
141
141
  return;
142
142
  }
143
143
  await client.session.prompt({ path: { id: sessionID }, body: { parts: [{ type: "text", text }] } });
144
- await client.tui.showToast({ body: { title: "PTT", message: `Sent: "${text.slice(0, 60)}"`, variant: "success" } });
144
+ 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 } });
145
146
  }
146
147
  const TTS_COMMANDS = [
147
148
  { name: 'tts-on', description: 'Enable streaming TTS', template: 'TTS enabled.' },
@@ -337,7 +338,7 @@ export const InterruptPlugin = (userConfig = {}) => {
337
338
  catch { /* ignore */ }
338
339
  }
339
340
  pttStartRecording();
340
- await client.tui.showToast({ body: { title: "PTT", message: "Recording... (/ptt again to send)", variant: "info" } });
341
+ await client.tui.showToast({ body: { title: "PTT", message: "Recording... type /ptt to stop", variant: "info" } });
341
342
  }
342
343
  throw new Error('Command handled by interrupt plugin');
343
344
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-interrupt-plugin",
3
- "version": "0.4.30",
3
+ "version": "0.4.32",
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",