@evious/voice-agent 0.0.0-stage → 0.1.0

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 (135) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +207 -2
  3. package/dist/cli/args.d.ts +16 -0
  4. package/dist/cli/args.d.ts.map +1 -0
  5. package/dist/cli/args.js +63 -0
  6. package/dist/cli/args.js.map +1 -0
  7. package/dist/cli/config.d.ts +4 -0
  8. package/dist/cli/config.d.ts.map +1 -0
  9. package/dist/cli/config.js +80 -0
  10. package/dist/cli/config.js.map +1 -0
  11. package/dist/cli/dictate.d.ts +4 -0
  12. package/dist/cli/dictate.d.ts.map +1 -0
  13. package/dist/cli/dictate.js +68 -0
  14. package/dist/cli/dictate.js.map +1 -0
  15. package/dist/cli/doctor.d.ts +8 -0
  16. package/dist/cli/doctor.d.ts.map +1 -0
  17. package/dist/cli/doctor.js +106 -0
  18. package/dist/cli/doctor.js.map +1 -0
  19. package/dist/cli/io.d.ts +15 -0
  20. package/dist/cli/io.d.ts.map +1 -0
  21. package/dist/cli/io.js +74 -0
  22. package/dist/cli/io.js.map +1 -0
  23. package/dist/cli/menu.d.ts +8 -0
  24. package/dist/cli/menu.d.ts.map +1 -0
  25. package/dist/cli/menu.js +177 -0
  26. package/dist/cli/menu.js.map +1 -0
  27. package/dist/cli/models.d.ts +4 -0
  28. package/dist/cli/models.d.ts.map +1 -0
  29. package/dist/cli/models.js +54 -0
  30. package/dist/cli/models.js.map +1 -0
  31. package/dist/cli/speech.d.ts +8 -0
  32. package/dist/cli/speech.d.ts.map +1 -0
  33. package/dist/cli/speech.js +219 -0
  34. package/dist/cli/speech.js.map +1 -0
  35. package/dist/cli.d.ts +3 -0
  36. package/dist/cli.d.ts.map +1 -0
  37. package/dist/cli.js +115 -0
  38. package/dist/cli.js.map +1 -0
  39. package/dist/core/audio.d.ts +8 -0
  40. package/dist/core/audio.d.ts.map +1 -0
  41. package/dist/core/audio.js +43 -0
  42. package/dist/core/audio.js.map +1 -0
  43. package/dist/core/clipboard.d.ts +15 -0
  44. package/dist/core/clipboard.d.ts.map +1 -0
  45. package/dist/core/clipboard.js +72 -0
  46. package/dist/core/clipboard.js.map +1 -0
  47. package/dist/core/config.d.ts +39 -0
  48. package/dist/core/config.d.ts.map +1 -0
  49. package/dist/core/config.js +116 -0
  50. package/dist/core/config.js.map +1 -0
  51. package/dist/core/deps.d.ts +27 -0
  52. package/dist/core/deps.d.ts.map +1 -0
  53. package/dist/core/deps.js +90 -0
  54. package/dist/core/deps.js.map +1 -0
  55. package/dist/core/dictate.d.ts +36 -0
  56. package/dist/core/dictate.d.ts.map +1 -0
  57. package/dist/core/dictate.js +124 -0
  58. package/dist/core/dictate.js.map +1 -0
  59. package/dist/core/doctor.d.ts +29 -0
  60. package/dist/core/doctor.d.ts.map +1 -0
  61. package/dist/core/doctor.js +52 -0
  62. package/dist/core/doctor.js.map +1 -0
  63. package/dist/core/errors.d.ts +35 -0
  64. package/dist/core/errors.d.ts.map +1 -0
  65. package/dist/core/errors.js +62 -0
  66. package/dist/core/errors.js.map +1 -0
  67. package/dist/core/exec.d.ts +66 -0
  68. package/dist/core/exec.d.ts.map +1 -0
  69. package/dist/core/exec.js +276 -0
  70. package/dist/core/exec.js.map +1 -0
  71. package/dist/core/index.d.ts +19 -0
  72. package/dist/core/index.d.ts.map +1 -0
  73. package/dist/core/index.js +18 -0
  74. package/dist/core/index.js.map +1 -0
  75. package/dist/core/models.d.ts +72 -0
  76. package/dist/core/models.d.ts.map +1 -0
  77. package/dist/core/models.js +311 -0
  78. package/dist/core/models.js.map +1 -0
  79. package/dist/core/paths.d.ts +23 -0
  80. package/dist/core/paths.d.ts.map +1 -0
  81. package/dist/core/paths.js +76 -0
  82. package/dist/core/paths.js.map +1 -0
  83. package/dist/core/piper.d.ts +79 -0
  84. package/dist/core/piper.d.ts.map +1 -0
  85. package/dist/core/piper.js +356 -0
  86. package/dist/core/piper.js.map +1 -0
  87. package/dist/core/playback.d.ts +66 -0
  88. package/dist/core/playback.d.ts.map +1 -0
  89. package/dist/core/playback.js +177 -0
  90. package/dist/core/playback.js.map +1 -0
  91. package/dist/core/record.d.ts +77 -0
  92. package/dist/core/record.d.ts.map +1 -0
  93. package/dist/core/record.js +271 -0
  94. package/dist/core/record.js.map +1 -0
  95. package/dist/core/speech.d.ts +24 -0
  96. package/dist/core/speech.d.ts.map +1 -0
  97. package/dist/core/speech.js +36 -0
  98. package/dist/core/speech.js.map +1 -0
  99. package/dist/core/text.d.ts +17 -0
  100. package/dist/core/text.d.ts.map +1 -0
  101. package/dist/core/text.js +88 -0
  102. package/dist/core/text.js.map +1 -0
  103. package/dist/core/transcribe.d.ts +22 -0
  104. package/dist/core/transcribe.d.ts.map +1 -0
  105. package/dist/core/transcribe.js +79 -0
  106. package/dist/core/transcribe.js.map +1 -0
  107. package/dist/core/transcript.d.ts +5 -0
  108. package/dist/core/transcript.d.ts.map +1 -0
  109. package/dist/core/transcript.js +71 -0
  110. package/dist/core/transcript.js.map +1 -0
  111. package/dist/core/tts.d.ts +37 -0
  112. package/dist/core/tts.d.ts.map +1 -0
  113. package/dist/core/tts.js +110 -0
  114. package/dist/core/tts.js.map +1 -0
  115. package/dist/core/types.d.ts +49 -0
  116. package/dist/core/types.d.ts.map +1 -0
  117. package/dist/core/types.js +3 -0
  118. package/dist/core/types.js.map +1 -0
  119. package/dist/core/voices.d.ts +26 -0
  120. package/dist/core/voices.d.ts.map +1 -0
  121. package/dist/core/voices.js +107 -0
  122. package/dist/core/voices.js.map +1 -0
  123. package/dist/mcp.d.ts +3 -0
  124. package/dist/mcp.d.ts.map +1 -0
  125. package/dist/mcp.js +281 -0
  126. package/dist/mcp.js.map +1 -0
  127. package/dist/platforms/linux.d.ts +14 -0
  128. package/dist/platforms/linux.d.ts.map +1 -0
  129. package/dist/platforms/linux.js +129 -0
  130. package/dist/platforms/linux.js.map +1 -0
  131. package/dist/platforms/windows.d.ts +16 -0
  132. package/dist/platforms/windows.d.ts.map +1 -0
  133. package/dist/platforms/windows.js +199 -0
  134. package/dist/platforms/windows.js.map +1 -0
  135. package/package.json +76 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 evious
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,208 @@
1
- # Temporary Holding Version
1
+ # voice-agent
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Local voice dictation and read-aloud for AI coding agents.
4
+
5
+ One core, exposed twice: a **CLI** and an **MCP server**. Thin skills tell
6
+ Claude Code, Cursor and GitHub Copilot when to call them.
7
+
8
+ - **Local by default**: whisper.cpp for dictation, system voices for speech.
9
+ - **No cloud**: Edge TTS exists as an explicit opt-in engine, never a default.
10
+ - **No Electron, no editor plugin**: a small Node package plus process adapters.
11
+
12
+ ## Status
13
+
14
+ Early development. Speech and dictation work on Windows and Linux; the MCP
15
+ server is next.
16
+
17
+ | Milestone | Scope | State |
18
+ | --- | --- | --- |
19
+ | M0 | Scaffold, core primitives, CI | done |
20
+ | M1 | `speak` / `stop` / `voices` / `doctor` / `config` | done |
21
+ | M2 | `dictate` with whisper.cpp, models, clipboard | done |
22
+ | M3 | Windows capture (DirectShow) parity | done |
23
+ | M4 | MCP server (`dictate`, `speak`, `stop`, `doctor`) | done |
24
+ | M4.1 | Configurable dictation model | done |
25
+ | M5 | piper neural voice (offline) | done |
26
+ | M6 | `menu` + config tools in MCP | done |
27
+ | M7 | VS Code extension (status bar) | built, needs field validation |
28
+ | M8 | `setup` + skills for Claude Code, Cursor, Copilot | next |
29
+ | M9 | npm release | planned |
30
+
31
+ ## VS Code extension
32
+
33
+ `vscode/` builds a small extension with two status-bar buttons:
34
+
35
+ - **$(mic) Dictar** — start recording; click again to stop and transcribe.
36
+ No silence detection: you decide when it ends, which is the only thing that
37
+ works in a noisy room.
38
+ - **$(unmute) Leer** — read the last Copilot answer (falls back to the
39
+ selection) with piper.
40
+
41
+ Dictated text goes where `voiceAgent.insert` says: `chat` (default), `editor`
42
+ or `clipboard`. In `chat` mode it focuses the chat input and pastes, so it
43
+ does not overwrite what you already typed.
44
+
45
+ ```bash
46
+ cd vscode
47
+ npm install
48
+ npm run package # -> voice-agent-0.1.0.vsix
49
+ ```
50
+
51
+ Then install the `.vsix` from the Extensions view (⋯ → Install from VSIX) or
52
+ with `code --install-extension voice-agent-0.1.0.vsix`.
53
+
54
+ ## Quick start
55
+
56
+ ```bash
57
+ npm install
58
+ npm run build
59
+
60
+ node dist/cli.js doctor # what is installed, what is missing
61
+ node dist/cli.js voices # voices for your language
62
+ node dist/cli.js speak --text "Hola, esto es una prueba."
63
+ node dist/cli.js stop # interrupt from another terminal
64
+
65
+ node dist/cli.js models download # whisper.cpp + model, ~65 MB, once
66
+ node dist/cli.js voices install # piper + Spanish voice, ~90 MB, once
67
+ node dist/cli.js dictate # press Enter to stop, or wait for silence
68
+ node dist/cli.js menu # language, engine, voice, model, rate
69
+ ```
70
+
71
+ Read a file or a pipe:
72
+
73
+ ```bash
74
+ node dist/cli.js speak --file respuesta.md
75
+ cat respuesta.md | node dist/cli.js speak --stdin
76
+ ```
77
+
78
+ ## Commands
79
+
80
+ | Command | What it does |
81
+ | --- | --- |
82
+ | `speak --text/--file/--stdin` | Clean the Markdown and read it aloud |
83
+ | `dictate` | Record, transcribe with whisper.cpp, optionally copy |
84
+ | `stop` | Kill the active playback (works across processes) |
85
+ | `voices [--language es]` | List installed voices, default marked with `*` |
86
+ | `voices install [id]` | Download piper and a neural voice |
87
+ | `menu` | Interactive settings: language, engine, voice, model, rate, tests |
88
+ | `models [list\|download [id]]` | Manage the whisper.cpp binary and models |
89
+ | `doctor [--fix] [--json]` | Check tools, paths, models and config |
90
+ | `config get` / `set` / `path` | Inspect or change voice, rate, language, `skipCode` |
91
+
92
+ Useful flags: `--voice <id>`, `--rate 0.5..2`, `--engine system`,
93
+ `--model base-q5_1`, `--max-seconds 60`, `--copy`, `--no-download`,
94
+ `--no-skip-code`, `--wait`, `--json`.
95
+
96
+ ## MCP server
97
+
98
+ `voice-agent-mcp` speaks Model Context Protocol over stdio. stdout belongs to
99
+ the protocol, so every log line goes to stderr.
100
+
101
+ | Tool | What it does |
102
+ | --- | --- |
103
+ | `voice_dictate` | Record, transcribe, optionally copy. Blocks until silence or `maxSeconds` (default 15). |
104
+ | `voice_speak` | Start read-aloud and return immediately, so the agent can keep working. |
105
+ | `voice_stop` | Stop the active playback. Idempotent. |
106
+ | `voice_doctor` | Report engines, voices, models and paths. |
107
+ | `voice_config_get` / `voice_config_set` | Read or change language, engine, voice, model, rate. |
108
+ | `voice_install` | Download a piper voice or a dictation model (verified, resumable). |
109
+
110
+ Every tool answers with JSON in a text block. `voice_dictate` returns
111
+ `empty: true` when nothing was heard: that is an answer, not a tool error, so
112
+ the agent can ask the user to repeat instead of breaking the turn.
113
+
114
+ VS Code / Copilot (`.vscode/mcp.json`):
115
+
116
+ ```json
117
+ {
118
+ "servers": {
119
+ "voice-agent": {
120
+ "type": "stdio",
121
+ "command": "node",
122
+ "args": ["/absolute/path/to/voice-agent/dist/mcp.js"]
123
+ }
124
+ }
125
+ }
126
+ ```
127
+
128
+ Claude Code:
129
+
130
+ ```bash
131
+ claude mcp add voice -- node /absolute/path/to/voice-agent/dist/mcp.js
132
+ ```
133
+
134
+ The MCP server must run on the machine with the microphone. Under WSL that is
135
+ WSLg; on Windows it is DirectShow.
136
+
137
+ ## Requirements
138
+
139
+ - Node.js 22 or newer.
140
+ - Linux: `ffmpeg` and `espeak-ng` (both in `apt`).
141
+ - Windows 11: `ffmpeg` on `PATH`; PowerShell and SAPI voices ship with Windows.
142
+
143
+ `voice-agent doctor` reports exactly what is missing and, on Debian/Ubuntu,
144
+ `doctor --fix` offers to install it after asking.
145
+
146
+ ## Design notes
147
+
148
+ - Every subprocess runs through `core/exec.ts` with `shell: false` and an
149
+ argument array. User profiles contain spaces, paths contain backslashes and
150
+ Spanish text contains non-ASCII characters; arrays avoid all quoting bugs.
151
+ - Playback is detached and tracked through a pidfile, so `stop` works from a
152
+ different process and from a future MCP call. Only one utterance plays at a
153
+ time: a new one replaces the previous one.
154
+ - **Windows**: the player is spawned with `DETACHED_PROCESS`. Without it the
155
+ child shares the parent console and dies the moment `speak` exits, which
156
+ makes `stop` impossible. Found the hard way.
157
+ - **Dictation**: whisper.cpp is pinned to a release and every download is
158
+ verified against a sha256 from the Hugging Face index. Transfers resume from
159
+ `<file>.part`, so a dropped connection does not restart 57 MB.
160
+ - **Endpointing**: `silencedetect` ends the utterance, but only after speech
161
+ was detected once. A leading silence must not cut the user off before they
162
+ start talking.
163
+ - **Windows capture** uses the DirectShow *alternative name*
164
+ (`@device_cm_...\wave_...`), not the friendly name: on a Spanish Windows the
165
+ friendly name is localized and parsing it is a bug waiting to happen.
166
+ - **piper** is pinned to the last MIT release with standalone binaries
167
+ (2023.11.14). The maintained fork is GPL-3 and ships Python wheels only.
168
+ That release rejects phoneme maps with multi-codepoint entries, which every
169
+ current Spanish voice has (English diphthongs such as `aɪ`), so the voice
170
+ config is sanitized before use: those keys are dropped, everything else is
171
+ kept. Without that patch piper aborts with "Phonemes must be one codepoint".
172
+ - **`engine: auto`** means "piper if installed, otherwise the system voice",
173
+ so installing a voice is all it takes to upgrade read-aloud.
174
+ - **Recording has two modes**: silence endpointing (for the MCP tool, where
175
+ nobody can press a button) and push-to-talk (`silenceMs: 0`, used by the
176
+ extension). Endpointing assumes speech when the microphone never reported
177
+ silence, otherwise a recording that starts mid-sentence was cut at 5 s.
178
+ - `VOICE_AGENT_INPUT=<file.wav>` feeds a file instead of the microphone (in
179
+ real time) and `VOICE_AGENT_PLAYER` replaces the audio player. Both exist for
180
+ tests and headless machines.
181
+ - **Windows**: PowerShell scripts are written as UTF-8 **with BOM** and force
182
+ `[Console]::OutputEncoding = UTF8`. Without that, PowerShell 5.1 reads
183
+ accents as ANSI and returns stdout as CP850 (`ñ` becomes `0xA4`).
184
+ - **Windows** has no `LANG`, so the UI culture is queried from PowerShell to
185
+ pick the default voice. Otherwise Spanish text is read by an English voice.
186
+ - Paths follow platform conventions (`XDG_*`, `%APPDATA%`, `%LOCALAPPDATA%`).
187
+ `VOICE_AGENT_HOME` overrides everything, which the tests use as a sandbox.
188
+ - Temporary WAVs are deleted on stop and swept after one minute, never while
189
+ they are still playing. Nothing is logged: no text, no audio.
190
+
191
+ ## Development
192
+
193
+ ```bash
194
+ npm run typecheck
195
+ npm run test
196
+ npm run build
197
+ node scripts/smoke-mcp.mjs # real MCP session, needs a downloaded model
198
+ ```
199
+
200
+ CI runs the same steps on Ubuntu and Windows with Node 22 and 24.
201
+
202
+ `.vscode/mcp.json` points at this workspace with an absolute `node` path,
203
+ because nvm is only on `PATH` in interactive shells. Change it to plain `node`
204
+ if your editor's environment can find it.
205
+
206
+ ## License
207
+
208
+ MIT
@@ -0,0 +1,16 @@
1
+ export interface ParsedArgs {
2
+ command: string | undefined;
3
+ positionals: string[];
4
+ flags: Map<string, string | true>;
5
+ }
6
+ /**
7
+ * Minimal, dependency-free parser.
8
+ *
9
+ * Supports `--key value`, `--key=value`, `-h` and positional arguments. A
10
+ * `--flag` followed by another `-flag` is treated as boolean.
11
+ */
12
+ export declare function parseArgs(argv: readonly string[]): ParsedArgs;
13
+ export declare function hasFlag(args: ParsedArgs, ...names: string[]): boolean;
14
+ export declare function stringFlag(args: ParsedArgs, ...names: string[]): string | undefined;
15
+ export declare function numberFlag(args: ParsedArgs, ...names: string[]): number | undefined;
16
+ //# sourceMappingURL=args.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAA;CAClC;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CAkC7D;AAUD,wBAAgB,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAErE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAGnF;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAKnF"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Minimal, dependency-free parser.
3
+ *
4
+ * Supports `--key value`, `--key=value`, `-h` and positional arguments. A
5
+ * `--flag` followed by another `-flag` is treated as boolean.
6
+ */
7
+ export function parseArgs(argv) {
8
+ const flags = new Map();
9
+ const positionals = [];
10
+ let command;
11
+ for (let index = 0; index < argv.length; index += 1) {
12
+ const arg = argv[index];
13
+ if (arg === undefined)
14
+ continue;
15
+ if (arg.startsWith("--") && arg.includes("=")) {
16
+ const separator = arg.indexOf("=");
17
+ const key = arg.slice(0, separator);
18
+ flags.set(key, arg.slice(separator + 1));
19
+ continue;
20
+ }
21
+ if (arg.startsWith("-")) {
22
+ const next = argv[index + 1];
23
+ // `-1` is a value, `-v` is another flag.
24
+ const isNegativeNumber = next !== undefined && /^-\d/.test(next);
25
+ if (next !== undefined && (!next.startsWith("-") || isNegativeNumber)) {
26
+ flags.set(arg, next);
27
+ index += 1;
28
+ }
29
+ else {
30
+ flags.set(arg, true);
31
+ }
32
+ continue;
33
+ }
34
+ if (command === undefined)
35
+ command = arg;
36
+ else
37
+ positionals.push(arg);
38
+ }
39
+ return { command, positionals, flags };
40
+ }
41
+ function find(flags, names) {
42
+ for (const name of names) {
43
+ const value = flags.get(name);
44
+ if (value !== undefined)
45
+ return value;
46
+ }
47
+ return undefined;
48
+ }
49
+ export function hasFlag(args, ...names) {
50
+ return find(args.flags, names) !== undefined;
51
+ }
52
+ export function stringFlag(args, ...names) {
53
+ const value = find(args.flags, names);
54
+ return typeof value === "string" ? value : undefined;
55
+ }
56
+ export function numberFlag(args, ...names) {
57
+ const value = stringFlag(args, ...names);
58
+ if (value === undefined)
59
+ return undefined;
60
+ const parsed = Number(value);
61
+ return Number.isFinite(parsed) ? parsed : undefined;
62
+ }
63
+ //# sourceMappingURL=args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,IAAuB;IAC/C,MAAM,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAA;IAC9C,MAAM,WAAW,GAAa,EAAE,CAAA;IAChC,IAAI,OAA2B,CAAA;IAE/B,KAAK,IAAI,KAAK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AC5B,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,CAAA;AACxC,CAAC;AAED,SAAS,IAAI,CAAC,KAAiC,EAAE,KAAwB;IACvE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC7B,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAA;IACvC,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,IAAgB,EAAE,GAAG,KAAe;IAC1D,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,SAAS,CAAA;AAC9C,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAgB,EAAE,GAAG,KAAe;IAC7D,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;AACtD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAgB,EAAE,GAAG,KAAe;IAC7D,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,CAAA;IACxC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACzC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAC5B,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;AACrD,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type ParsedArgs } from "./args.js";
2
+ import type { Io } from "./io.js";
3
+ export declare function runConfig(args: ParsedArgs, io: Io): Promise<number>;
4
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAOA,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,WAAW,CAAA;AACpD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAEjC,wBAAsB,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAkEzE"}
@@ -0,0 +1,80 @@
1
+ import { ConfigSchema, DEFAULT_CONFIG, loadConfig, saveConfig } from "../core/config.js";
2
+ import { VoiceError } from "../core/errors.js";
3
+ import { modelById } from "../core/models.js";
4
+ import { appPaths } from "../core/paths.js";
5
+ import { assertPiperVoiceSelectable } from "../core/piper.js";
6
+ import { hasFlag } from "./args.js";
7
+ export async function runConfig(args, io) {
8
+ const paths = appPaths(io.env);
9
+ const action = args.positionals[0] ?? "get";
10
+ if (action === "path") {
11
+ io.out(`${paths.configFile}\n`);
12
+ return 0;
13
+ }
14
+ if (action === "get") {
15
+ io.out(`${JSON.stringify(await loadConfig(paths), null, 2)}\n`);
16
+ return 0;
17
+ }
18
+ if (action === "set") {
19
+ const key = args.positionals[1];
20
+ const raw = args.positionals[2];
21
+ if (!key || raw === undefined) {
22
+ throw new VoiceError({
23
+ code: "CONFIG",
24
+ message: "usage: voice-agent config set <key> <value>",
25
+ nextStep: `keys: ${Object.keys(DEFAULT_CONFIG).join(", ")}`,
26
+ });
27
+ }
28
+ const shape = ConfigSchema.shape;
29
+ const field = shape[key];
30
+ if (!field) {
31
+ throw new VoiceError({
32
+ code: "CONFIG",
33
+ message: `Unknown config key "${key}".`,
34
+ nextStep: `keys: ${Object.keys(DEFAULT_CONFIG).join(", ")}`,
35
+ });
36
+ }
37
+ const parsed = field.safeParse(coerce(raw));
38
+ if (!parsed.success) {
39
+ throw new VoiceError({
40
+ code: "CONFIG",
41
+ message: `Invalid value for "${key}": ${raw}`,
42
+ nextStep: parsed.error.issues.map((issue) => issue.message).join("; "),
43
+ });
44
+ }
45
+ // Catch typos in model ids before they fail a minute later, mid-dictation.
46
+ if (key === "model" && typeof parsed.data === "string")
47
+ modelById(parsed.data);
48
+ // A piper voice that is not downloaded would fail at speak time.
49
+ if (key === "voice" && typeof parsed.data === "string") {
50
+ await assertPiperVoiceSelectable(paths, parsed.data);
51
+ }
52
+ const current = await loadConfig(paths);
53
+ const next = ConfigSchema.parse({ ...current, [key]: parsed.data });
54
+ await saveConfig(paths, next);
55
+ if (hasFlag(args, "--json"))
56
+ io.out(`${JSON.stringify({ key, value: parsed.data })}\n`);
57
+ else
58
+ io.out(`${key} = ${JSON.stringify(parsed.data)}\n`);
59
+ return 0;
60
+ }
61
+ throw new VoiceError({
62
+ code: "CONFIG",
63
+ message: `Unknown config action "${action}".`,
64
+ nextStep: "Use `config get`, `config set <key> <value>` or `config path`.",
65
+ });
66
+ }
67
+ /** CLI values arrive as strings; booleans, null and numbers are inferred. */
68
+ function coerce(raw) {
69
+ const value = raw.trim();
70
+ if (value === "true")
71
+ return true;
72
+ if (value === "false")
73
+ return false;
74
+ if (value === "null")
75
+ return null;
76
+ if (value !== "" && Number.isFinite(Number(value)))
77
+ return Number(value);
78
+ return value;
79
+ }
80
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAmB,MAAM,WAAW,CAAA;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AI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAA;;YAClF,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACxD,OAAO,CAAC,CAAA;IACV,CAAC;IAED,MAAM,IAAI,UAAU,CAAC;QACnB,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,0BAA0B,MAAM,IAAI;QAC7C,QAAQ,EAAE,gEAAgE;KAC3E,CAAC,CAAA;AACJ,CAAC;AAED,6EAA6E;AAC7E,SAAS,MAAM,CAAC,GAAW;IACzB,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,EAAE,CAAA;IACxB,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,IAAI,CAAA;IACjC,IAAI,KAAK,KAAK,OAAO;QAAE,OAAO,KAAK,CAAA;IACnC,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,IAAI,CAAA;IACjC,IAAI,KAAK,KAAK,EAAE,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;IACxE,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type ParsedArgs } from "./args.js";
2
+ import type { Io } from "./io.js";
3
+ export declare function runDictate(args: ParsedArgs, io: Io): Promise<number>;
4
+ //# sourceMappingURL=dictate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dictate.d.ts","sourceRoot":"","sources":["../../src/cli/dictate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmC,KAAK,UAAU,EAAE,MAAM,WAAW,CAAA;AAC5E,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAEjC,wBAAsB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA2D1E"}
@@ -0,0 +1,68 @@
1
+ import { dictate } from "../core/dictate.js";
2
+ import { VoiceError } from "../core/errors.js";
3
+ import { appPaths } from "../core/paths.js";
4
+ import { hasFlag, numberFlag, stringFlag } from "./args.js";
5
+ export async function runDictate(args, io) {
6
+ const paths = appPaths(io.env);
7
+ const progress = progressReporter(io);
8
+ // On a TTY, Enter stops the recording; otherwise silence detection does.
9
+ const stopSignal = io.isTTY ? io.waitForEnter() : undefined;
10
+ try {
11
+ const result = await dictate({
12
+ language: stringFlag(args, "--language", "-l"),
13
+ maxSeconds: numberFlag(args, "--max-seconds"),
14
+ modelId: stringFlag(args, "--model"),
15
+ copy: hasFlag(args, "--copy") ? true : hasFlag(args, "--no-copy") ? false : undefined,
16
+ noDownload: hasFlag(args, "--no-download"),
17
+ onProgress: progress.report,
18
+ onRecordingStart: () => {
19
+ if (io.isTTY)
20
+ io.err("Recording... press Enter to stop, or wait for silence.\n");
21
+ },
22
+ onWarning: (warning) => io.err(`warning: ${warning}\n`),
23
+ ...(stopSignal === undefined ? {} : { stopSignal }),
24
+ }, paths);
25
+ if (result.empty) {
26
+ throw new VoiceError({
27
+ code: "EMPTY_AUDIO",
28
+ message: "No speech was recognised in the recording.",
29
+ nextStep: "Speak closer to the microphone, or check the input level with `voice-agent doctor`.",
30
+ details: { recordingMs: result.recordingMs },
31
+ });
32
+ }
33
+ if (hasFlag(args, "--json")) {
34
+ io.out(`${JSON.stringify({
35
+ text: result.text,
36
+ language: result.language,
37
+ model: result.model,
38
+ audioDurationMs: result.audioDurationMs,
39
+ transcribeMs: result.transcribeMs,
40
+ copied: result.copied,
41
+ ...(result.copyMethod === undefined ? {} : { copyMethod: result.copyMethod }),
42
+ }, null, 2)}\n`);
43
+ }
44
+ else {
45
+ io.out(`${result.text}\n`);
46
+ if (result.copied)
47
+ io.err("(copied to the clipboard)\n");
48
+ }
49
+ return 0;
50
+ }
51
+ finally {
52
+ progress.finish();
53
+ }
54
+ }
55
+ function progressReporter(io) {
56
+ let active = false;
57
+ return {
58
+ report: (message) => {
59
+ active = true;
60
+ io.err(`\r ${message}`);
61
+ },
62
+ finish: () => {
63
+ if (active)
64
+ io.err("\n");
65
+ },
66
+ };
67
+ }
68
+ //# sourceMappingURL=dictate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dictate.js","sourceRoot":"","sources":["../../src/cli/dictate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAmB,MAAM,WAAW,CAAA;AAG5E,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAgB,EAAE,EAAM;IACvD,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;IAC9B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAA;IAErC,yEAAyE;IACzE,MAAM,UAAU,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;IAE3D,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAC1B;YACE,QAAQ,EAAE,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC;YAC9C,UAAU,EAAE,UAAU,CAAC,IAAI,EAAE,eAAe,CAAC;YAC7C,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC;YACpC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,C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ACJ,CAAC,CACF,IAAI,CACN,CAAA;QACH,CAAC;aAAM,CAAC;YACN,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,IAAI,CAAC,CAAA;YAC1B,IAAI,MAAM,CAAC,MAAM;gBAAE,EAAE,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAA;QAC1D,CAAC;QAED,OAAO,CAAC,CAAA;IACV,CAAC;YAAS,CAAC;QACT,QAAQ,CAAC,MAAM,EAAE,CAAA;IACnB,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,EAAM;IAC9B,IAAI,MAAM,GAAG,KAAK,CAAA;IAClB,OAAO;QACL,MAAM,EAAE,CAAC,OAAe,EAAE,EAAE;YAC1B,MAAM,GAAG,IAAI,CAAA;YACb,EAAE,CAAC,GAAG,CAAC,OAAO,OAAO,EAAE,CAAC,CAAA;QAC1B,CAAC;QACD,MAAM,EAAE,GAAG,EAAE;YACX,IAAI,MAAM;gBAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC1B,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Io } from "./io.js";
2
+ export interface DoctorOptions {
3
+ json: boolean;
4
+ fix: boolean;
5
+ yes: boolean;
6
+ }
7
+ export declare function runDoctor(version: string, options: DoctorOptions, io: Io): Promise<number>;
8
+ //# sourceMappingURL=doctor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAEjC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,CAAA;IACb,GAAG,EAAE,OAAO,CAAA;IACZ,GAAG,EAAE,OAAO,CAAA;CACb;AAED,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,aAAa,EACtB,EAAE,EAAE,EAAE,GACL,OAAO,CAAC,MAAM,CAAC,CAwBjB"}
@@ -0,0 +1,106 @@
1
+ import { buildDoctorReport } from "../core/doctor.js";
2
+ import { execInteractive } from "../core/exec.js";
3
+ import { collectTools } from "../core/deps.js";
4
+ import { appPaths } from "../core/paths.js";
5
+ export async function runDoctor(version, options, io) {
6
+ const paths = appPaths(io.env);
7
+ let tools = await collectTools();
8
+ if (options.fix) {
9
+ const missing = tools.filter((tool) => tool.required && !tool.found);
10
+ if (missing.length > 0) {
11
+ await fixMissing(missing, options, io);
12
+ tools = await collectTools();
13
+ }
14
+ }
15
+ // buildDoctorReport re-collects tools; reuse the fixed list when there was one.
16
+ const report = await buildDoctorReport(paths, version);
17
+ report.tools = tools;
18
+ report.ok = tools.every((tool) => !tool.required || tool.found);
19
+ if (options.json) {
20
+ io.out(`${JSON.stringify(report, null, 2)}\n`);
21
+ return report.ok ? 0 : 1;
22
+ }
23
+ render(report, options, io);
24
+ return report.ok ? 0 : 1;
25
+ }
26
+ function render(report, options, io) {
27
+ const lines = [];
28
+ lines.push(`voice-agent ${report.version}`);
29
+ lines.push(`platform ${report.platform} ${report.arch} - node ${report.node}`);
30
+ lines.push(`config ${report.paths.configFile}${report.configExists ? "" : " (defaults in use)"}`);
31
+ lines.push(`cache ${report.paths.cacheDir}`);
32
+ lines.push("");
33
+ lines.push("tools");
34
+ for (const tool of report.tools) {
35
+ const status = tool.found ? "ok " : "MISSING";
36
+ const label = tool.name.padEnd(12);
37
+ const suffix = tool.version ?? (tool.found ? "" : (tool.hint ?? ""));
38
+ lines.push(` ${status} ${label} ${suffix}${tool.required ? " *" : ""}`);
39
+ if (!tool.found && tool.install)
40
+ lines.push(` fix: ${tool.install.label}`);
41
+ }
42
+ lines.push("");
43
+ lines.push(" * = required on this platform");
44
+ lines.push("");
45
+ lines.push("dictation");
46
+ lines.push(` ${report.dictation.binaryInstalled ? "ok " : "MISSING"} whisper-cli ${report.dictation.binary}`);
47
+ lines.push(` ${report.dictation.modelInstalled ? "ok " : "MISSING"} ${report.dictation.model.padEnd(12)} ${report.dictation.modelPath}`);
48
+ if (!report.dictation.binaryInstalled || !report.dictation.modelInstalled) {
49
+ lines.push(" fix: voice-agent models download");
50
+ }
51
+ lines.push("");
52
+ lines.push("speech engine");
53
+ lines.push(` ${report.piper.binaryInstalled ? "ok " : "MISSING"} piper ${report.piper.binary}`);
54
+ if (report.piper.voices.length > 0) {
55
+ lines.push(` ok piper voices ${report.piper.voices.join(", ")}`);
56
+ }
57
+ else {
58
+ lines.push(" MISSING piper voices none installed");
59
+ lines.push(" fix: voice-agent voices install");
60
+ }
61
+ const missing = report.tools.filter((tool) => tool.required && !tool.found);
62
+ if (missing.length > 0) {
63
+ lines.push("");
64
+ lines.push(`doctor failed: missing ${missing.map((tool) => tool.name).join(", ")}`);
65
+ lines.push(options.fix
66
+ ? "fix: retry with --yes, or install manually with the commands above."
67
+ : "fix: run `voice-agent doctor --fix` to install what can be installed automatically.");
68
+ }
69
+ else {
70
+ lines.push("");
71
+ lines.push("doctor: ok");
72
+ }
73
+ io.out(`${lines.join("\n")}\n`);
74
+ }
75
+ async function fixMissing(missing, options, io) {
76
+ for (const tool of missing) {
77
+ const plan = tool.install;
78
+ if (!plan) {
79
+ io.err(`\n${tool.name} cannot be installed automatically. ${tool.hint ?? ""}\n`);
80
+ continue;
81
+ }
82
+ if (!options.yes) {
83
+ if (!io.isTTY) {
84
+ io.err(`\n${tool.name} is missing. Run: ${plan.label}\n`);
85
+ continue;
86
+ }
87
+ const accepted = await io.confirm(`\n${tool.name} is missing and is needed for local speech.\nInstall it now with: ${plan.label} ? [y/N] `);
88
+ if (!accepted) {
89
+ io.err(`skipped ${tool.name}\n`);
90
+ continue;
91
+ }
92
+ }
93
+ const command = plan.needsRoot ? "sudo" : plan.command;
94
+ const args = plan.needsRoot ? [plan.command, ...plan.args] : plan.args;
95
+ io.err(`\nrunning: ${plan.label}\n`);
96
+ try {
97
+ const code = await execInteractive(command, args, { env: io.env });
98
+ if (code !== 0)
99
+ io.err(`${tool.name} install exited with code ${String(code)}.\n`);
100
+ }
101
+ catch (error) {
102
+ io.err(`could not run ${plan.label}: ${error instanceof Error ? error.message : String(error)}\n`);
103
+ }
104
+ }
105
+ }
106
+ //# sourceMappingURL=doctor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAmB,MAAM,iBAAiB,CAAA;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAS3C,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,OAAe,EACf,OAAsB,EACtB,EAAM;IAEN,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;IAC9B,IAAI,KAAK,GAAG,MAAM,YAAY,EAAE,CAAA;IAEhC,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACpE,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,CAAA;YACtC,KAAK,GAAG,MAAM,YAAY,EAAE,CAAA;QAC9B,CAAC;IACH,CAAC;IAED,gFAAgF;IAChF,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IACtD,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE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C,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAA;QACtE,EAAE,CAAC,GAAG,CAAC,cAAc,IAAI,CAAC,KAAK,IAAI,CAAC,CAAA;QAEpC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAA;YAClE,IAAI,IAAI,KAAK,CAAC;gBAAE,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,6BAA6B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACpF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,EAAE,CAAC,GAAG,CAAC,iBAAiB,IAAI,CAAC,KAAK,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACpG,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ /** Everything a command needs from the outside world, injectable for tests. */
2
+ export interface Io {
3
+ out(text: string): void;
4
+ err(text: string): void;
5
+ env: NodeJS.ProcessEnv;
6
+ isTTY: boolean;
7
+ readStdin(): Promise<string>;
8
+ confirm(question: string): Promise<boolean>;
9
+ /** Ask for a free-form answer (menu). */
10
+ ask(question: string): Promise<string>;
11
+ /** Resolves when the user presses Enter. Only meaningful on a TTY. */
12
+ waitForEnter(): Promise<void>;
13
+ }
14
+ export declare function processIo(): Io;
15
+ //# sourceMappingURL=io.d.ts.map