opencode-interrupt-plugin 0.4.29 → 0.4.31

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.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import type { Plugin } from '@opencode-ai/plugin';
2
- import type { TuiPlugin } from '@opencode-ai/plugin/tui';
3
2
  import { type PluginConfig } from './config.js';
4
3
  export declare const InterruptPlugin: (userConfig?: PluginConfig) => Plugin;
5
- export declare const tui: TuiPlugin;
6
4
  declare const _default: Plugin;
7
5
  export default _default;
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
  }
@@ -443,55 +444,4 @@ function extractText(parts) {
443
444
  return '';
444
445
  }
445
446
  }
446
- export const tui = async (api, _options, _meta) => {
447
- console.log("[interrupt] TUI plugin initializing");
448
- try {
449
- api.keymap.registerLayer({
450
- priority: 0,
451
- commands: [
452
- {
453
- name: "interrupt.ptt",
454
- title: "Walkie-Talkie (insert to record, press again to send)",
455
- category: "Plugin",
456
- run: async () => {
457
- console.log("[interrupt] Command interrupt.ptt executed");
458
- const route = api.route.current;
459
- const sessionID = route.name === "session"
460
- ? route.params?.sessionID
461
- : undefined;
462
- const directory = api.state.path.directory;
463
- if (pttActive) {
464
- pttActive = false;
465
- await transcribeAndSend(sessionID, directory, api);
466
- }
467
- else {
468
- pttActive = true;
469
- if (sessionID) {
470
- try {
471
- await api.client.session.abort({ sessionID, directory });
472
- }
473
- catch { /* ignore */ }
474
- }
475
- pttStartRecording();
476
- api.ui.toast({ variant: "info", title: "PTT", message: "Recording... (insert again to send)" });
477
- }
478
- },
479
- },
480
- ],
481
- bindings: [{ key: "insert", cmd: "interrupt.ptt" }],
482
- });
483
- console.log("[interrupt] Layer registered successfully");
484
- }
485
- catch (err) {
486
- console.error("[interrupt] Failed to register layer:", err);
487
- }
488
- api.lifecycle.onDispose(() => {
489
- console.log("[interrupt] TUI plugin disposed");
490
- if (recordingProcess) {
491
- recordingProcess.kill("SIGTERM");
492
- recordingProcess = null;
493
- }
494
- pttActive = false;
495
- });
496
- };
497
447
  export default InterruptPlugin();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-interrupt-plugin",
3
- "version": "0.4.29",
3
+ "version": "0.4.31",
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",