SLOPSHOPPER

mya

MYA: a voice for Claude Code on Linux/X11. Tap Right Ctrl to talk, Right Ctrl + Space to translate, and MYA answers aloud, with a ringing phone when it is your…

bandcommandtoastpromptmodelprocess
v0.3.0MITupdated 2026-10-10xaiksan1/modnest/mods/mya
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · mya
› fix the failing auth test and add an audit log call ╭────────────────────────────────────────────╮ │ mya │ ⏺ Read(src/auth.ts) │ MYA: the hotkey listener keeps stopping, │ ⎿ Read 6 lines │ retrying │ ⏺ Update(src/auth.ts) ╰────────────────────────────────────────────╯ ⎿ Added 2 lines, removed 1 line ╭───────────────────────╮ ⏺ Bash(bun test) │ mya │ ⎿ 3 pass, 1 fail │ MYA: nothing received │ ╰───────────────────────╯ ● Done. refresh now rejects expired claims and logs an audit event. ✻ Worked for 42s · done 4:20 PM › /mya ⎿ mya: MYA is listening… MYA ▁█▃█▄▇▆▅▇▄█▂ listening, tap Right Ctrl to send ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
MYA ▁█▃█▄▇▆▅▇▄█▂ listening, tap Right Ctrl to send
README

MYA

A voice for Claude Code, as a mod (a plugin of function hooks): talk to your terminal, hear it answer, and see a phone ring when it is your turn.

  • Tap Right Ctrl (X11) or press Ctrl+Alt+M (Wayland) → speak → again: your words are transcribed and sent to Claude.
  • Right Ctrl + Space (X11) or Ctrl+Alt+Shift+M (Wayland) → speak → again: your words are transcribed, translated (default: into English) and sent.
  • A one-line MYA band above the prompt shows what it is doing: listening (with a moving level meter), thinking, speaking, and, when Claude has finished and waits for you, a ringing telephone (with an optional old-fashioned bell: ringSound).
  • MYA has a few lines of its own: a greeting when the session starts and a line when it did not hear you (phrases).
  • When you sent the question by voice, MYA reads Claude's answer aloud with a human-like Cartesia voice (Katie by default). Long answers are first condensed into a few spoken sentences; code and paths are not read out. Three options for other tastes: an ffmpeg robot effect (voiceStyle: robot), a local formant synthesizer with no key and no network (voiceEngine: machine, eSpeak NG), or a free local neural voice (voiceEngine: piper, see below).
  • Hotkey on/off: /mya off and /mya on, or Right Ctrl + Right Shift (X11) / Ctrl+Alt+K (Wayland), switch the hotkey so it never fires while you copy-paste elsewhere (the band turns red and says so). A Ctrl held a while, or used with a key, a mouse click or the scroll wheel (Ctrl+C, Ctrl+click...), is never taken for a tap.
  • /mya fills the prompt instead of sending (/mya go sends, /mya stop ends a recording, /mya mute toggles speech).

Requirements

  • Linux (not macOS or Windows). On an X11 session the hotkey is read with xinput; on Wayland (Ubuntu 26.04 has no other kind) it is three GNOME keyboard shortcuts, see Wayland below.
  • arecord and aplay (alsa-utils), xinput (X11 only), ffmpeg (only for the optional robot effect and the optional bell), libespeak-ng (only for the optional machine voice; it ships with speech-dispatcher), Python 3 (standard library only, nothing to pip install).
  • A Deepgram API key for speech-to-text. A Cartesia API key to hear replies (not needed with voiceEngine: machine).

Install

claude --plugin-dir mods/mya

Then set your keys, either in the plugin's options (/config, stored in secure storage) or in your shell environment (DEEPGRAM_API_KEY, CARTESIA_API_KEY). Never put keys in a file you commit. Set language to what you speak (en, fr, es, de...) and translateTo to the language you want for Right Ctrl + Space.

Options

OptionDefaultMeaning
languageenDeepgram language code of what you say; also the speech language of replies
keytermsMyaComma-separated names Deepgram should favour (and that common mishearings are corrected to)
translateToEnglishTarget language of the translate chord
speakRepliestrueRead answers aloud when the question was voiced
voiceEnginecartesiacartesia (human-like cloud voice), machine (eSpeak NG, local) or piper (local neural voice)
piperModel—Piper engine only: path to a voice .onnx file (its .onnx.json beside it)
machineVoiceen-us+klatt4Machine engine only: eSpeak NG voice and variant (fr+klatt, en+m3...)
voiceStyleplainCartesia only: plain, robot (buzzing 90s computer) or soft (grit only)
machineRate / machineWordGap155 / 4Rhythm of the machine voice: words per minute and the pause between words
ringSoundfalsePlay a telephone bell when it is your turn
phrasestrueMYA's own spoken lines
voiceSpeed1.0Speaking speed from 0.5 (slow) to 2.0 (fast); lower it if a voice talks too fast
voiceId(empty)Cartesia voice id; empty = MYA's original voice (Katie)
showBandtrueShow the MYA band above the prompt
micDeviceautoALSA capture device (auto prefers a USB microphone; see arecord -l)
speakerDevicedefaultALSA playback device
pythonpython3Python 3 command for the helpers
toggleKeycode / chordKeycode / lockKeycode105 / 65 / 62X11 only (ignored under Wayland: change the shortcuts in GNOME's keyboard settings). X11 keycodes: Right Ctrl, Space (translate), Right Shift (hotkey on/off); list yours with xmodmap -pke
maxTapSeconds0.8A dictation key held longer than this is not a tap
hotkeyOnStarttrueWhether the hotkey is active when the session starts

Wayland

Wayland does not let a program watch the keyboard (and reading /dev/input would need a group that can log every password), so MYA never tries. On a Wayland session bin/hotkey.py runs in socket mode: GNOME itself detects its own shortcuts and runs bin/mya-key toggle|translate|lock, which drops one word into a private socket ($XDG_RUNTIME_DIR/mya-hotkey.sock, mode 0600) that the helper prints. Only those three words are accepted; anything else is refused and prints nothing.

python3 bin/mya_gnome_shortcuts.py install     # Ctrl+Alt+M dictate · Ctrl+Alt+Shift+M translate · Ctrl+Alt+K hotkey on/off
python3 bin/mya_gnome_shortcuts.py status      # what is installed
python3 bin/mya_gnome_shortcuts.py remove      # take away exactly those three, nothing else
python3 bin/mya_gnome_shortcuts.py install --toggle Pause --dry-run   # choose other keys, look before changing anything

The installer only touches its own three entries, never replaces a shortcut that already exists (a taken combination is skipped and reported), and refuses anything that is not a plain key combination. The mode is picked from XDG_SESSION_TYPE; force it with MYA_HOTKEY_MODE=x11|socket.

What it sends where (read this)

  • Your microphone audio goes to Deepgram while you record.
  • The text of Claude's answer (or its condensed version) goes to Cartesia when replies are spoken. With voiceEngine: machine nothing is sent for speech.
  • Translation and condensing use a small haiku call through your Claude Code session. The robot effect runs locally with ffmpeg.
  • Under Wayland the hotkey helper reads no key at all (see Wayland below). On X11 it reads every key and mouse-button event with xinput test-xi2 --root and keeps only Right Ctrl and its two chord keys; everything else is dropped on the spot, nothing is stored or written. Read bin/hotkey.py (about 60 lines) before enabling it.

Known limits

  • The chord's Space also reaches the terminal as Ctrl+Space.
  • Recording is manual: it ends when you tap the key again (or after three minutes).
  • Wayland: the one-command installer of the shortcuts is for GNOME. On another desktop, bind any shortcut to bin/mya-key toggle, bin/mya-key translate and bin/mya-key lock yourself. "Right Ctrl tapped alone" cannot be a shortcut there, so the Wayland keys are combinations. Not tested on other desktops or distributions.

Tests

claude plugin validate mods/mya
claude plugin test mods/mya

Optional: a free local voice with Piper

No account, no credit, no network. Piper is a separate project under the GPL-3.0 licence; MYA does not bundle it, you install it yourself, for the Python you give MYA in the python option:

python -m pip install piper-tts                               # installs piper-tts and pathvalidate
python -m piper.download_voices --download-dir ~/.local/share/piper fr_FR-siwis-medium

Then set voiceEngine: piper, piperModel: ~/.local/share/piper/fr_FR-siwis-medium.onnx (full path) and python to that interpreter. Sentences are synthesized one after the other and streamed into a single aplay, so playback does not stop between sentences as long as synthesis is faster than speech (about 5x on a modest CPU in our test).

Source 2 files
hooks/register.tsx 380 lines
1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, PluginOptions, Register } from 'claude-code'
3
4import type { Phase } from '../types'
5
6type Mode = 'dictate' | 'translate'
7
8const phase = atom({ plugin: 'mya', key: 'phase' } as const, 'idle' as Phase)
9const frame = atom({ plugin: 'mya', key: 'frame' } as const, 0)
10
11let options: PluginOptions = {}
12let listening: Mode | undefined
13let root = ''
14let isSpeaking = false
15let stopSpeaking = false
16let isVoiceTurn = false
17let isMuted = false
18let isKeysOn = true // the hotkey: on, or off while you copy-paste elsewhere
19// What the keys are called. The helper says which mode it runs in (a `MODE` line): on X11 it reads Right Ctrl itself; under Wayland
20// no program may read the keyboard, so the keys are GNOME shortcuts that run `mya-key` (see bin/mya_gnome_shortcuts.py).
21const KEY_NAMES = {
22  x11: { tap: 'Right Ctrl', lock: 'Right Ctrl + Right Shift' },
23  socket: { tap: 'Ctrl+Alt+M', lock: 'Ctrl+Alt+K' },
24}
25let keyNames = KEY_NAMES.x11
26let currentPhase: Phase = 'idle'
27let ticker: { cancel: () => void } | undefined
28const stopFile = `/tmp/mya-${Math.random().toString(36).slice(2)}.stop` // one per session
29
30const text = (key: string, fallback = '') => String(options[key] ?? fallback)
31const python = () => text('python', 'python3')
32const envFileArgs = () => (text('envFile') ? ['--env', text('envFile')] : [])
33const keysEnv = (): Record<string, string> => {
34  const env: Record<string, string> = {}
35  if (text('deepgramApiKey')) env.DEEPGRAM_API_KEY = text('deepgramApiKey')
36  if (text('cartesiaApiKey')) env.CARTESIA_API_KEY = text('cartesiaApiKey')
37  return env
38}
39const message = (error: unknown) => (error instanceof Error ? error.message : String(error))
40const rest = (): Phase => (!isKeysOn ? 'off' : isMuted ? 'muted' : 'idle')
41
42// Claude has finished: the phone rings until you answer.
43async function waitForYou($: EngineInterface, isAnswer: boolean) {
44  if (listening || isSpeaking) return
45  await setPhase($, isAnswer && !isMuted ? 'waiting' : rest())
46  if (isAnswer) ring($)
47}
48
49async function setPhase($: EngineInterface, next: Phase) {
50  currentPhase = next
51  await update($, phase, () => next)
52}
53
54// Switch the hotkey on or off (the mic stays untouched until you tap the key again).
55async function toggleKeys($: EngineInterface, on?: boolean) {
56  isKeysOn = on ?? !isKeysOn
57  if (currentPhase === 'idle' || currentPhase === 'off' || currentPhase === 'muted') await setPhase($, rest())
58  $.ui.toast(isKeysOn ? 'MYA: hotkey on' : `MYA: hotkey off (${keyNames.lock} to turn it on)`)
59}
60
61// One tap on the key: start listening, or, if already listening, finish (the text is then sent).
62async function pressed($: EngineInterface, mode: Mode) {
63  if (isSpeaking) stopSpeaking = true // a tap cuts MYA's voice, then we listen
64  try {
65    if (listening) await $.fs.write(stopFile, 'stop')
66    else await listen($, mode, 'submit', 'hotkey')
67  } catch (error) {
68    listening = undefined
69    await setPhase($, rest())
70    $.ui.toast(`MYA: ${message(error)}`)
71  }
72}
73
74async function listen($: EngineInterface, mode: Mode, then: 'submit' | 'fill', how: 'hotkey' | 'command') {
75  listening = mode
76  await setPhase($, mode === 'translate' ? 'translating' : 'listening')
77  let heard = ''
78  let problem = ''
79  try {
80    const manualStop = how === 'hotkey' ? ['--silence-seconds', '3600', '--wait-seconds', '120', '--max-seconds', '180'] : []
81    const recording = $.process.spawn({
82      argv: [
83        python(), `${root}/bin/mic_stt.py`,
84        '--stop-file', stopFile,
85        ...envFileArgs(),
86        '--language', text('language', 'en'),
87        '--keyterms', text('keyterms', 'Mya'),
88        '--device', text('micDevice', 'auto'),
89        ...manualStop,
90      ],
91      env: keysEnv(),
92    })
93    for await (const piece of recording) {
94      if (piece.stream !== 'stdout') continue
95      for (const line of piece.text.split('\n')) {
96        const [kind, ...parts] = line.split('\t')
97        if (kind === 'TEXT') heard = parts.join('\t').trim()
98        if (kind === 'ERR') problem = parts.join('\t').trim()
99      }
100    }
101  } catch (error) {
102    problem = message(error)
103  } finally {
104    listening = undefined
105  }
106  if (!heard) {
107    await setPhase($, rest())
108    $.ui.toast(`MYA: ${problem || 'nothing received'}`)
109    if (options.phrases !== false && text('voiceEngine', 'cartesia') === 'machine') void talk($, 'I did not hear you. Please, repeat.').catch(() => undefined)
110    return
111  }
112
113  if (mode === 'translate') {
114    await setPhase($, 'thinking')
115    const done = await $.model.complete({
116      model: 'haiku',
117      prompt:
118        `Translate the text between the <t> tags into natural ${text('translateTo', 'English')}. ` +
119        'Reply with the translation only, no quotes, no commentary.\n<t>' + heard + '</t>',
120    })
121    if (!done.isAnswered) {
122      await setPhase($, rest())
123      $.ui.toast(`MYA: translation failed (${done.reason})`)
124      await $.prompt.fill({ text: heard, mode: 'append' }) // keep what was said
125      return
126    }
127    heard = done.text.trim()
128  }
129
130  if (then === 'submit') {
131    isVoiceTurn = true
132    await setPhase($, 'thinking')
133    await $.prompt.submit({ text: heard })
134  } else {
135    await setPhase($, rest())
136    await $.prompt.fill({ text: heard, mode: 'append' })
137  }
138}
139
140const LANGUAGES: Record<string, string> = { en: 'English', fr: 'French', de: 'German', es: 'Spanish', it: 'Italian', pt: 'Portuguese', nl: 'Dutch' }
141// The language a machine voice speaks, from its eSpeak name: "en-us+klatt4" -> English.
142const machineLanguage = () => {
143  const code = text('machineVoice', 'en-us+klatt4').split('+')[0]!.split('-')[0]!
144  return LANGUAGES[code] ?? code
145}
146
147// The language a Piper voice speaks, from its file name: "fr_FR-siwis-medium.onnx" -> French.
148const piperLanguage = () => {
149  const code = /^([a-z]{2})[_-]/.exec(text('piperModel').split('/').pop() ?? '')?.[1] ?? text('language', 'en')
150  return LANGUAGES[code] ?? code
151}
152
153// MYA reads Claude's reply aloud. A machine or Piper voice speaks ONE language (a French voice reading English is unintelligible), so the
154// reply is first turned into a short spoken message in that language; a human-like cloud voice only condenses a long reply.
155async function say($: EngineInterface, answer: string) {
156  const engine = text('voiceEngine', 'cartesia')
157  const isMachine = engine === 'machine'
158  const voiceLanguage = isMachine ? machineLanguage() : engine === 'piper' ? piperLanguage() : undefined
159  let spoken = answer
160  const isPlainAscii = !/[^\x00-\x7f]/.test(answer)
161  // A machine voice speaks short plain ASCII as it is; Piper cannot tell the language of a text, so it always goes through the model.
162  if (isMachine ? !(isPlainAscii && answer.length <= 350) : voiceLanguage ? true : answer.length > 350) {
163    const language = voiceLanguage ? `in ${voiceLanguage}` : 'in the same language'
164    const short = await $.model.complete({
165      model: 'haiku',
166      prompt:
167        `Here is a coding assistant's reply to the user. Turn it into a short spoken message ${language}: ` +
168        (voiceLanguage ? `the message MUST be written entirely ${language}, translating anything that is in another language (keep only names of files or tools as they are). ` : '') +
169        '2 to 4 short plain sentences, one idea each, with commas where a speaker would pause, like an old computer reading carefully; ' +
170        'no markdown, no code, no paths or commands to spell out, no abbreviations or symbols ' +
171        'a speech synthesizer would stumble on. Give the gist, and say clearly if the user has to do something. ' +
172        'Reply with the message only.\n<r>' + answer.slice(0, 6000) + '</r>',
173    })
174    if (short.isAnswered) spoken = short.text
175    else if (voiceLanguage) {
176      $.ui.toast('MYA: could not prepare the spoken message')
177      return
178    }
179  }
180  await talk($, spoken)
181}
182
183// Speaks one text aloud with MYA's voice, showing the 'speaking' phase and honouring a tap that cuts it off.
184async function talk($: EngineInterface, spoken: string) {
185  isSpeaking = true
186  stopSpeaking = false
187  await setPhase($, 'speaking')
188  try {
189    const voice = $.process.spawn({
190      argv: [
191        python(), `${root}/bin/speak.py`,
192        ...envFileArgs(),
193        '--engine', text('voiceEngine', 'cartesia'),
194        '--piper-model', text('piperModel'),
195        '--machine-voice', text('machineVoice', 'en-us+klatt4'),
196        '--machine-rate', String(Number(options.machineRate ?? 155)),
197        '--machine-wordgap', String(Number(options.machineWordGap ?? 4)),
198        '--language', text('language', 'en'),
199        '--voice', text('voiceId'),
200        '--style', text('voiceStyle', 'plain'),
201        '--speed', String(Number(options.voiceSpeed ?? 1)),
202        '--device', text('speakerDevice', 'default'),
203      ],
204      env: keysEnv(),
205      input: spoken,
206    })
207    for await (const piece of voice) {
208      if (stopSpeaking) break // leaving the loop stops playback
209      if (piece.stream === 'stdout' && piece.text.startsWith('ERR')) $.ui.toast(`MYA: ${piece.text.split('\t')[1] ?? ''}`)
210    }
211  } finally {
212    isSpeaking = false
213    stopSpeaking = false
214    if (!listening) await setPhase($, rest())
215  }
216}
217
218// The phone: a bell now and then while Claude waits for you.
219function ring($: EngineInterface) {
220  if (options.ringSound !== true) return
221  void (async () => {
222    try {
223      const bell = $.process.spawn({
224        argv: [python(), `${root}/bin/ring.py`, '--times', '2', '--device', text('speakerDevice', 'default')],
225      })
226      for await (const _piece of bell) { /* plays to the end */ }
227    } catch { /* a missing bell is not worth an error */ }
228  })()
229}
230
231const labels = (): Record<Phase, string> => ({
232  off: `hotkey off, ${keyNames.lock} or /mya on`,
233  waiting: `your turn, tap ${keyNames.tap} to answer`,
234  idle: `tap ${keyNames.tap} to talk`,
235  listening: `listening, tap ${keyNames.tap} to send`,
236  translating: `translating, tap ${keyNames.tap} to send`,
237  thinking: 'thinking',
238  speaking: `speaking, tap ${keyNames.tap} to interrupt`,
239  muted: 'muted (/mya mute)',
240})
241const COLOR: Record<Phase, string> = { off: 'red', waiting: 'yellow', idle: 'gray', listening: 'green', translating: 'yellow', thinking: 'magenta', speaking: 'cyan', muted: 'gray' }
242const BARS = '▁▂▃▄▅▆▇█'
243// A telephone that rings: the handset rocks and the sound waves come and go.
244const PHONE = ['  ☎  ', ' ((☎)) ', '(((☎)))', ' ((☎)) ']
245const phone = (tick: number) => PHONE[tick % PHONE.length]!
246
247// A little level meter that moves while MYA listens or speaks.
248const meter = (tick: number, width = 12) =>
249  Array.from({ length: width }, (_, i) => BARS[Math.min(7, Math.floor(Math.abs(Math.sin(tick * 0.9 + i * 1.7)) * 8))]).join('')
250
251export const register: Register = (on, config) => {
252  options = config
253  isKeysOn = options.hotkeyOnStart !== false
254
255  on('turn.complete', async ($, e, next) => {
256    const done = await next(e)
257    if (isVoiceTurn && !e.agentId) {
258      isVoiceTurn = false
259      const willSpeak = options.speakReplies !== false && !isMuted && e.reason === 'answer' && e.answer.trim() !== ''
260      if (willSpeak) {
261        void say($, e.answer)
262          .catch(error => $.ui.toast(`MYA: ${message(error)}`))
263          .finally(() => { void waitForYou($, e.reason === 'answer') })
264        return done
265      }
266    }
267    if (!e.agentId) await waitForYou($, e.reason === 'answer')
268    return done
269  })
270
271  on('prompt.submit', async ($, e, next) => {
272    if (!listening) await setPhase($, 'thinking')
273    return next(e)
274  })
275
276  on('session.start', async ($, e, next) => {
277    root = $.plugin.root
278    await $.command.register({
279      name: 'mya',
280      description: 'MYA voice: /mya (dictate into the prompt), /mya go (dictate and send), /mya stop, /mya mute, /mya off|on (the hotkey).',
281    })
282
283    if (options.phrases !== false && text('voiceEngine', 'cartesia') === 'machine') {
284      void talk($, 'Mya online. I am ready, when you are.').catch(() => undefined)
285    }
286    await setPhase($, rest())
287    ticker?.cancel()
288    ticker = $.clock.every(300, () => {
289      if (currentPhase !== 'idle' && currentPhase !== 'muted' && currentPhase !== 'off') void update($, frame, n => (n ?? 0) + 1) // the band animates
290    })
291
292    // The hotkey: tap = dictate / send, with the chord key held = translate.
293    // The listener (xinput) can die — keyboard replugged, X restarted — and MYA would stay deaf for good. So it is started again, waiting longer
294    // after each quick death (and giving up after repeated failures to start at all).
295    void (async () => {
296      let quickDeaths = 0
297      let startFailures = 0
298      while (startFailures < 5) {
299        const startedAt = Date.now()
300        try {
301          const keys = $.process.spawn({
302            argv: [python(), `${root}/bin/hotkey.py`, String(options.toggleKeycode ?? 105), String(options.chordKeycode ?? 65), String(options.lockKeycode ?? 62), String(options.maxTapSeconds ?? 0.8)],
303          })
304          for await (const piece of keys) {
305            if (piece.stream !== 'stdout') continue
306            for (const line of piece.text.split('\n')) {
307              const [word, ...parts] = line.trim().split('\t')
308              if (word === 'LOCK') void toggleKeys($)
309              else if (word === 'TOGGLE' && isKeysOn) void pressed($, 'dictate')
310              else if (word === 'TRANSLATE' && isKeysOn) void pressed($, 'translate')
311              else if (word === 'MODE') {
312                keyNames = parts[0] === 'socket' ? KEY_NAMES.socket : KEY_NAMES.x11 // an unknown mode shows the X11 names, never nonsense
313                await setPhase($, currentPhase) // the band is drawn again with the right key names
314              } else if (word === 'ERR') $.ui.toast(`MYA: hotkey ${parts.join(' ')}`)
315            }
316          }
317          startFailures = 0
318        } catch {
319          startFailures += 1
320          if (startFailures === 5) $.ui.toast('MYA: the hotkey is unavailable')
321        }
322        quickDeaths = Date.now() - startedAt > 10_000 ? 0 : quickDeaths + 1
323        if (quickDeaths === 4) $.ui.toast('MYA: the hotkey listener keeps stopping, retrying')
324        try {
325          await $.clock.sleep(Math.min(Number(options.hotkeyRetryMs ?? 2000) * 2 ** Math.min(quickDeaths, 4), 30_000))
326        } catch {
327          return // the module was unloaded
328        }
329      }
330    })()
331
332    return next(e)
333  })
334
335  on('command.run', { command: 'mya' }, async ($, e) => {
336    const arg = e.args.trim().toLowerCase()
337    if (arg === 'stop') {
338      if (!listening) return { text: 'MYA is not listening.' }
339      await $.fs.write(stopFile, 'stop')
340      return { text: 'MYA: finishing…' }
341    }
342    if (arg === 'off' || arg === 'on' || arg === 'keys') {
343      await toggleKeys($, arg === 'keys' ? undefined : arg === 'on')
344      return { text: isKeysOn ? 'MYA hotkey is on.' : `MYA hotkey is off: ${keyNames.tap} does nothing until /mya on, or ${keyNames.lock}.` }
345    }
346    if (arg === 'mute') {
347      isMuted = !isMuted
348      if (isMuted) stopSpeaking = true
349      if (currentPhase === 'idle' || currentPhase === 'muted') await setPhase($, rest())
350      return { text: isMuted ? 'MYA will stay quiet.' : 'MYA will speak again.' }
351    }
352    if (arg !== '' && arg !== 'go') return { text: 'Usage: /mya, /mya go, /mya stop, /mya mute, /mya off or /mya on.' }
353    if (listening) return { text: 'MYA is already listening: speak, or /mya stop.' }
354    void listen($, 'dictate', arg === 'go' ? 'submit' : 'fill', 'command').catch(async error => {
355      listening = undefined
356      await setPhase($, rest())
357      $.ui.toast(`MYA: ${message(error)}`)
358    })
359    return { text: 'MYA is listening…' }
360  })
361
362  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
363    if (options.showBand === false || e.props.hasSurvey) return next(e)
364    const { Box, Text } = $.ui.resolve(e)
365    const now = (await read($, phase)) ?? 'idle'
366    const tick = (await read($, frame)) ?? 0
367    const color = COLOR[now]
368    const live = now === 'listening' || now === 'translating' || now === 'speaking'
369    const dots = '.'.repeat((tick % 3) + 1)
370
371    return (
372      <Box>
373        <Text bold inverse color={color}> MYA </Text>
374        <Text color={color}> {live ? meter(tick) : now === 'thinking' ? dots.padEnd(3) : now === 'waiting' ? phone(tick) : '·'} </Text>
375        <Text dimColor>{isKeysOn || now === 'off' ? labels()[now] : labels()[now].split(', tap ')[0]}</Text>
376      </Box>
377    )
378  })
379}
380
types/index.d.ts 8 lines
1export type Phase = 'idle' | 'listening' | 'translating' | 'thinking' | 'speaking' | 'waiting' | 'muted' | 'off'
2
3declare module 'claude-code' {
4  interface PluginState {
5    mya: { phase: Phase; frame: number }
6  }
7}
8