@senad-d/micme 0.1.1 → 0.2.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.
- package/CHANGELOG.md +2 -0
- package/README.md +29 -20
- package/SECURITY.md +5 -3
- package/micme.example.json +31 -0
- package/micme.schema.json +85 -0
- package/package.json +5 -3
- package/scripts/check-package-contents.mjs +4 -1
- package/scripts/doctor.mjs +61 -29
- package/src/audio.ts +539 -34
- package/src/config.ts +136 -85
- package/src/constants.ts +3 -1
- package/src/extension.ts +20 -7
- package/src/settings.ts +48 -43
- package/src/streaming.ts +229 -34
- package/src/types.ts +3 -2
- package/.env.example +0 -75
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,8 @@ All notable changes to Micme will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
- Move normal Micme persistence to the global `~/.pi/agent/micme.json` store; shell environment variables still override saved settings.
|
|
8
|
+
- Update `/micme conf`, `micme-doctor`, docs, and package examples for the new global JSON config path.
|
|
7
9
|
- Document the scoped npm package name, `@senad-d/micme`, in install, diagnostics, update, and uninstall commands.
|
|
8
10
|
- Add an interactive npm publishing script that prompts for a version, validates the package, creates the release commit/tag, and publishes with public scoped-package access.
|
|
9
11
|
- Keep publication on hold until package name, metadata, security review, validation, and smoke tests are complete.
|
package/README.md
CHANGED
|
@@ -20,9 +20,9 @@ Micme is a pi extension for short coding prompts. It records your microphone wit
|
|
|
20
20
|
- **Local-first:** no telemetry and no cloud STT service by default.
|
|
21
21
|
- **Review-first:** transcripts paste into the editor unless you enable auto-submit.
|
|
22
22
|
- **Pi-native:** install globally, project-locally, from git, or from a source checkout.
|
|
23
|
-
- **Configurable:** use `/micme conf`,
|
|
23
|
+
- **Configurable:** use `/micme conf`, `~/.pi/agent/micme.json`, or shell variables.
|
|
24
24
|
|
|
25
|
-
> **Security:** pi packages run with your full system permissions. Micme can use your microphone, spawn local commands, write `MICME_*` settings to
|
|
25
|
+
> **Security:** pi packages run with your full system permissions. Micme can use your microphone, spawn local commands, write `MICME_*` settings to `~/.pi/agent/micme.json`, and optionally download Whisper model files. Read [`SECURITY.md`](SECURITY.md).
|
|
26
26
|
|
|
27
27
|
## Table of Contents
|
|
28
28
|
|
|
@@ -136,32 +136,38 @@ MICME_WHISPER_CPP_MODEL=/path/to/ggml-small.en.bin
|
|
|
136
136
|
|
|
137
137
|
## Configuration
|
|
138
138
|
|
|
139
|
-
Micme reads settings from shell environment variables and from
|
|
139
|
+
Micme reads settings from shell environment variables and from the global Micme config file at `~/.pi/agent/micme.json`. Shell variables win. `/micme conf` writes only `MICME_*` keys to that JSON file, so settings follow you across pi projects on the same machine.
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
The usual setup path is to run:
|
|
142
142
|
|
|
143
|
-
```
|
|
144
|
-
|
|
143
|
+
```text
|
|
144
|
+
/micme conf
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
MICME_LANGUAGE
|
|
153
|
-
MICME_AUTO_DOWNLOAD_MODEL
|
|
154
|
-
MICME_DEFAULT_WHISPER_CPP_MODEL
|
|
155
|
-
MICME_AUTO_SUBMIT
|
|
156
|
-
MICME_KEEP_AUDIO
|
|
147
|
+
You can also edit the JSON manually. Minimal `~/.pi/agent/micme.json`:
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"$schema": "https://raw.githubusercontent.com/senad-d/micme/main/micme.schema.json",
|
|
152
|
+
"MICME_LANGUAGE": "en",
|
|
153
|
+
"MICME_AUTO_DOWNLOAD_MODEL": "1",
|
|
154
|
+
"MICME_DEFAULT_WHISPER_CPP_MODEL": "small.en",
|
|
155
|
+
"MICME_AUTO_SUBMIT": "0",
|
|
156
|
+
"MICME_KEEP_AUDIO": "0"
|
|
157
|
+
}
|
|
157
158
|
```
|
|
158
159
|
|
|
160
|
+
For temporary one-off overrides, set shell variables when starting pi, for example `MICME_KEEP_AUDIO=1 pi`.
|
|
161
|
+
|
|
159
162
|
Common settings:
|
|
160
163
|
|
|
161
164
|
| Variable | Meaning |
|
|
162
165
|
| --- | --- |
|
|
163
166
|
| `MICME_TRANSCRIPTION_MODE=clip` | Stable default: transcribe after recording stops. |
|
|
164
|
-
| `MICME_TRANSCRIPTION_MODE=stream` | Experimental live
|
|
167
|
+
| `MICME_TRANSCRIPTION_MODE=stream` | Experimental append-only live dictation with `whisper-stream`. |
|
|
168
|
+
| `MICME_STREAM_KEEP_CONTEXT=0` | Stream default: avoid Whisper prompt carry-over so live chunks are less likely to rewrite each other. |
|
|
169
|
+
| `MICME_STREAM_FLUSH_MS=650` | Stream profile quiet interval before tentative words are committed append-only. |
|
|
170
|
+
| `MICME_STREAM_FINALIZE_WITH_CLIP=0` | Keep the append-only live transcript on stop. Set `1` to opt in to final clip replacement. |
|
|
165
171
|
| `MICME_AUTO_SUBMIT=0` | Paste for review. Set `1` to send automatically. |
|
|
166
172
|
| `MICME_SHORTCUT=alt+m` | Toggle shortcut. Restart or `/reload` after changing. |
|
|
167
173
|
| `MICME_PRINTABLE_SHORTCUTS=§` | macOS Option-key fallback. |
|
|
@@ -169,7 +175,9 @@ Common settings:
|
|
|
169
175
|
| `MICME_KEEP_AUDIO=0` | Delete successful temp audio. Set `1` for debugging. |
|
|
170
176
|
| `MICME_MODEL_DIR=~/.cache/whisper.cpp` | Model cache/discovery directory. |
|
|
171
177
|
|
|
172
|
-
See [
|
|
178
|
+
See [`micme.example.json`](micme.example.json) for the full JSON template.
|
|
179
|
+
|
|
180
|
+
Streaming mode treats `whisper-stream` output as repeated, overlapping hypotheses rather than committed word deltas. Micme only appends committed words to the editor during live streaming; tentative words are held internally and committed after agreement, overlap, stop, or the quiet interval configured by `MICME_STREAM_FLUSH_MS`. If `MICME_STREAM_FINALIZE_WITH_CLIP=1`, the stop-time clip transcript can intentionally replace the live append-only text.
|
|
173
181
|
|
|
174
182
|
---
|
|
175
183
|
|
|
@@ -179,7 +187,7 @@ See [`.env.example`](.env.example) for the full template.
|
|
|
179
187
|
| --- | --- |
|
|
180
188
|
| `/micme` | Toggle recording. |
|
|
181
189
|
| `/micme conf` | Open the TUI configuration screen. |
|
|
182
|
-
| `/micme devices` |
|
|
190
|
+
| `/micme devices` | Show compact audio/video capture device inventory. |
|
|
183
191
|
| `/micme last` | Paste the previous transcript again. |
|
|
184
192
|
| `/micme audio` | Show the last kept audio directory. |
|
|
185
193
|
| `/micme help` | Show short help. |
|
|
@@ -236,6 +244,8 @@ npm run doctor
|
|
|
236
244
|
|
|
237
245
|
The doctor checks Node, pi, `ffmpeg`, whisper.cpp, optional `whisper-stream`, model paths, and macOS devices when available. Custom command values are redacted.
|
|
238
246
|
|
|
247
|
+
For stream state investigation, start pi with `MICME_STREAM_DIAGNOSTICS=1`. Diagnostics are opt-in and include sanitized frames, extraction mode, committed words, and tentative candidate words.
|
|
248
|
+
|
|
239
249
|
---
|
|
240
250
|
|
|
241
251
|
## Update and Uninstall
|
|
@@ -254,7 +264,6 @@ pi remove npm:@senad-d/micme -l # remove project-local install
|
|
|
254
264
|
```bash
|
|
255
265
|
npm ci
|
|
256
266
|
npm run validate
|
|
257
|
-
pi -e . --list-models micme-load-test
|
|
258
267
|
```
|
|
259
268
|
|
|
260
269
|
## Publishing
|
package/SECURITY.md
CHANGED
|
@@ -61,11 +61,13 @@ MICME_AUTO_DOWNLOAD_MODEL=0
|
|
|
61
61
|
|
|
62
62
|
You can also download models manually and set `MICME_WHISPER_CPP_MODEL=/path/to/model.bin`.
|
|
63
63
|
|
|
64
|
-
##
|
|
64
|
+
## Micme config handling
|
|
65
65
|
|
|
66
|
-
Micme reads only `MICME_*` keys from
|
|
66
|
+
Micme reads only `MICME_*` runtime keys from `~/.pi/agent/micme.json`. Shell environment variables override saved JSON values.
|
|
67
67
|
|
|
68
|
-
`/micme conf` writes only `MICME_*` values to
|
|
68
|
+
`/micme conf` writes only `MICME_*` values to `micme.json` and preserves other JSON metadata. Micme uses its own global config store to reduce accidental project influence over microphone and command-hook behavior.
|
|
69
|
+
|
|
70
|
+
Treat `micme.json` as trusted local user configuration. Command hooks stored there, especially `MICME_RECORD_COMMAND` and `MICME_TRANSCRIBE_COMMAND`, execute local shell commands with your user permissions. Avoid placing secrets in custom commands.
|
|
69
71
|
|
|
70
72
|
## Telemetry and retention
|
|
71
73
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/senad-d/micme/main/micme.schema.json",
|
|
3
|
+
"MICME_SHORTCUT": "alt+m",
|
|
4
|
+
"MICME_PRINTABLE_SHORTCUTS": "§",
|
|
5
|
+
"MICME_TRANSCRIPTION_MODE": "clip",
|
|
6
|
+
"MICME_AUTO_SUBMIT": "0",
|
|
7
|
+
"MICME_LANGUAGE": "en",
|
|
8
|
+
"MICME_TRANSCRIBE_TIMEOUT_MS": "120000",
|
|
9
|
+
"MICME_AUTO_DOWNLOAD_MODEL": "1",
|
|
10
|
+
"MICME_DEFAULT_WHISPER_CPP_MODEL": "small.en",
|
|
11
|
+
"MICME_MODEL_DIR": "${HOME}/.cache/whisper.cpp",
|
|
12
|
+
"MICME_AUDIO_DEVICE": "0",
|
|
13
|
+
"MICME_RECORD_SAMPLE_RATE": "48000",
|
|
14
|
+
"MICME_TRANSCRIBE_SAMPLE_RATE": "16000",
|
|
15
|
+
"MICME_PROCESS_AUDIO": "1",
|
|
16
|
+
"MICME_AUDIO_FILTER": "highpass=f=80,lowpass=f=7600",
|
|
17
|
+
"MICME_VALIDATE_AUDIO": "1",
|
|
18
|
+
"MICME_KEEP_AUDIO": "0",
|
|
19
|
+
"MICME_METER_GAIN": "1",
|
|
20
|
+
"MICME_STREAM_CAPTURE": "-1",
|
|
21
|
+
"MICME_STREAM_WORDS_PER_CHUNK": "5",
|
|
22
|
+
"MICME_STREAM_FLUSH_MS": "650",
|
|
23
|
+
"MICME_STREAM_STEP_MS": "500",
|
|
24
|
+
"MICME_STREAM_LENGTH_MS": "3000",
|
|
25
|
+
"MICME_STREAM_KEEP_MS": "300",
|
|
26
|
+
"MICME_STREAM_MAX_TOKENS": "32",
|
|
27
|
+
"MICME_STREAM_KEEP_CONTEXT": "0",
|
|
28
|
+
"MICME_STREAM_FINALIZE_WITH_CLIP": "0",
|
|
29
|
+
"MICME_STREAM_VAD_THRESHOLD": "0.35",
|
|
30
|
+
"MICME_STREAM_DIAGNOSTICS": "0"
|
|
31
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/senad-d/micme/main/micme.schema.json",
|
|
4
|
+
"title": "Micme configuration",
|
|
5
|
+
"description": "Machine-level Micme settings. Shell environment variables override saved values.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"$schema": {
|
|
9
|
+
"type": "string"
|
|
10
|
+
},
|
|
11
|
+
"MICME_SHORTCUT": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"default": "alt+m"
|
|
14
|
+
},
|
|
15
|
+
"MICME_PRINTABLE_SHORTCUTS": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"default": "§"
|
|
18
|
+
},
|
|
19
|
+
"MICME_TRANSCRIPTION_MODE": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"enum": ["clip", "stream"],
|
|
22
|
+
"default": "clip"
|
|
23
|
+
},
|
|
24
|
+
"MICME_AUTO_SUBMIT": {
|
|
25
|
+
"$ref": "#/$defs/stringFlag"
|
|
26
|
+
},
|
|
27
|
+
"MICME_LANGUAGE": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"default": "en"
|
|
30
|
+
},
|
|
31
|
+
"MICME_AUTO_DOWNLOAD_MODEL": {
|
|
32
|
+
"$ref": "#/$defs/stringFlag"
|
|
33
|
+
},
|
|
34
|
+
"MICME_DEFAULT_WHISPER_CPP_MODEL": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"default": "small.en"
|
|
37
|
+
},
|
|
38
|
+
"MICME_MODEL_DIR": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"default": "${HOME}/.cache/whisper.cpp"
|
|
41
|
+
},
|
|
42
|
+
"MICME_AUDIO_DEVICE": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"default": "0"
|
|
45
|
+
},
|
|
46
|
+
"MICME_KEEP_AUDIO": {
|
|
47
|
+
"$ref": "#/$defs/stringFlag"
|
|
48
|
+
},
|
|
49
|
+
"MICME_STREAM_KEEP_CONTEXT": {
|
|
50
|
+
"$ref": "#/$defs/stringFlag",
|
|
51
|
+
"description": "Pass --keep-context to whisper-stream. Defaults to off for append-only dictation."
|
|
52
|
+
},
|
|
53
|
+
"MICME_STREAM_FINALIZE_WITH_CLIP": {
|
|
54
|
+
"$ref": "#/$defs/stringFlag",
|
|
55
|
+
"description": "When enabled, stop-time clip transcription may replace the append-only live stream transcript."
|
|
56
|
+
},
|
|
57
|
+
"MICME_STREAM_FLUSH_MS": {
|
|
58
|
+
"type": ["string", "number"],
|
|
59
|
+
"default": "700",
|
|
60
|
+
"description": "Quiet interval in milliseconds before tentative stream words are committed append-only."
|
|
61
|
+
},
|
|
62
|
+
"MICME_RECORD_COMMAND": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"description": "Advanced shell command hook. Use only trusted commands."
|
|
65
|
+
},
|
|
66
|
+
"MICME_TRANSCRIBE_COMMAND": {
|
|
67
|
+
"type": "string",
|
|
68
|
+
"description": "Advanced shell command hook. Use only trusted commands."
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"patternProperties": {
|
|
72
|
+
"^MICME_": {
|
|
73
|
+
"type": ["string", "number", "boolean"],
|
|
74
|
+
"description": "Micme runtime setting. Values are read as strings by Micme."
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"additionalProperties": true,
|
|
78
|
+
"$defs": {
|
|
79
|
+
"stringFlag": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"enum": ["0", "1", "true", "false", "yes", "no", "on", "off"],
|
|
82
|
+
"default": "0"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@senad-d/micme",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Local voice-to-text for pi, optimized for fast Whisper-style backends.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"LICENSE",
|
|
35
35
|
"SECURITY.md",
|
|
36
36
|
"CHANGELOG.md",
|
|
37
|
-
".
|
|
37
|
+
"micme.example.json",
|
|
38
|
+
"micme.schema.json",
|
|
38
39
|
"img/micme_logo.png",
|
|
39
40
|
"src/**/*.ts",
|
|
40
41
|
"scripts/*.mjs",
|
|
@@ -44,10 +45,11 @@
|
|
|
44
45
|
"scripts": {
|
|
45
46
|
"doctor": "node scripts/doctor.mjs",
|
|
46
47
|
"check": "node --check scripts/doctor.mjs && node --check scripts/check-package-contents.mjs && node --check scripts/publish-npm.mjs",
|
|
48
|
+
"test": "node --test test/streaming.test.mjs",
|
|
47
49
|
"typecheck": "tsc --noEmit",
|
|
48
50
|
"pack:dry-run": "npm pack --dry-run --json",
|
|
49
51
|
"check:pack": "node scripts/check-package-contents.mjs",
|
|
50
|
-
"validate": "npm run typecheck && npm run check && npm run check:pack",
|
|
52
|
+
"validate": "npm run typecheck && npm run test && npm run check && npm run check:pack",
|
|
51
53
|
"publish:npm": "node scripts/publish-npm.mjs",
|
|
52
54
|
"prepublishOnly": "npm run validate"
|
|
53
55
|
},
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execFileSync } from "node:child_process";
|
|
3
3
|
|
|
4
|
+
const hiddenEnvironmentFilePattern = new RegExp(`^\\.${"env"}(?:$|\\.)`);
|
|
5
|
+
|
|
4
6
|
const forbiddenChecks = [
|
|
5
7
|
{
|
|
6
8
|
label: "environment files",
|
|
7
|
-
test: (path) =>
|
|
9
|
+
test: (path) => hiddenEnvironmentFilePattern.test(path),
|
|
8
10
|
},
|
|
9
11
|
{ label: "project-local pi state", test: (path) => path.startsWith(".pi/") },
|
|
12
|
+
{ label: "generated Micme config", test: (path) => path === "micme.json" || path.endsWith("/micme.json") },
|
|
10
13
|
{ label: "node_modules", test: (path) => path.startsWith("node_modules/") || path.includes("/node_modules/") },
|
|
11
14
|
{ label: "planning specs", test: (path) => path.startsWith("specs/") },
|
|
12
15
|
{ label: "Micme cache", test: (path) => path.startsWith(".micme/") || path.includes("/.micme/") },
|
package/scripts/doctor.mjs
CHANGED
|
@@ -1,34 +1,55 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { access } from "node:fs/promises";
|
|
4
|
-
import { delimiter, join } from "node:path";
|
|
4
|
+
import { delimiter, join, resolve } from "node:path";
|
|
5
|
+
import { homedir } from "node:os";
|
|
5
6
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
6
7
|
|
|
7
8
|
const isWin = process.platform === "win32";
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
values
|
|
9
|
+
const micmeConfig = loadMicmeConfig();
|
|
10
|
+
|
|
11
|
+
function getMicmeConfigPath() {
|
|
12
|
+
const agentDir = process.env.PI_CODING_AGENT_DIR ? resolve(process.env.PI_CODING_AGENT_DIR) : join(homedir(), ".pi", "agent");
|
|
13
|
+
return join(agentDir, "micme.json");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function loadMicmeConfig() {
|
|
17
|
+
const path = getMicmeConfigPath();
|
|
18
|
+
if (!existsSync(path)) return { path, found: false, values: {} };
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(readFileSync(path, "utf8").replace(/^\uFEFF/, ""));
|
|
22
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
23
|
+
return { path, found: true, values: {}, error: "top-level value must be a JSON object" };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const values = {};
|
|
27
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
28
|
+
if (!key.startsWith("MICME_")) continue;
|
|
29
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") values[key] = String(value);
|
|
30
|
+
}
|
|
31
|
+
return { path, found: true, values };
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return { path, found: true, values: {}, error: error instanceof Error ? error.message : String(error) };
|
|
26
34
|
}
|
|
27
|
-
return { path, values };
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
function env(name) {
|
|
31
|
-
return process.env[name] ??
|
|
38
|
+
return process.env[name] ?? micmeConfig.values[name];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function expandConfigValue(value) {
|
|
42
|
+
const home = process.env.HOME || homedir();
|
|
43
|
+
const withHome = value.startsWith("~/") && home ? `${home}${value.slice(1)}` : value;
|
|
44
|
+
return withHome.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}|\$([A-Za-z_][A-Za-z0-9_]*)/g, (_m, braced, bare) => {
|
|
45
|
+
const key = braced || bare || "";
|
|
46
|
+
return process.env[key] ?? micmeConfig.values[key] ?? "";
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function envPath(name) {
|
|
51
|
+
const value = env(name);
|
|
52
|
+
return value ? expandConfigValue(value) : undefined;
|
|
32
53
|
}
|
|
33
54
|
|
|
34
55
|
function which(names) {
|
|
@@ -46,7 +67,7 @@ function which(names) {
|
|
|
46
67
|
}
|
|
47
68
|
|
|
48
69
|
function resolveExecutable(value) {
|
|
49
|
-
const expanded = value
|
|
70
|
+
const expanded = expandConfigValue(value);
|
|
50
71
|
if (/[\\/]/.test(expanded)) return expanded;
|
|
51
72
|
return which([expanded]) || expanded;
|
|
52
73
|
}
|
|
@@ -70,12 +91,23 @@ function summarizeConfiguredCommand(value) {
|
|
|
70
91
|
return `configured (${trimmed.length} chars${placeholderText}; full value redacted)`;
|
|
71
92
|
}
|
|
72
93
|
|
|
94
|
+
function printConfigDiagnostics() {
|
|
95
|
+
if (micmeConfig.error) warn("micme.json invalid", `${micmeConfig.path}: ${micmeConfig.error}`);
|
|
96
|
+
else if (micmeConfig.found) ok("micme.json loaded", `${micmeConfig.path} (${Object.keys(micmeConfig.values).length} MICME_* key(s))`);
|
|
97
|
+
else info("micme.json", `not found; /micme conf will create ${micmeConfig.path}`);
|
|
98
|
+
|
|
99
|
+
const micmeEnvKeys = Object.keys(process.env).filter((key) => key.startsWith("MICME_")).sort((a, b) => a.localeCompare(b));
|
|
100
|
+
const overrides = micmeEnvKeys.filter((key) => micmeConfig.values[key] !== undefined);
|
|
101
|
+
const shellOnly = micmeEnvKeys.filter((key) => micmeConfig.values[key] === undefined);
|
|
102
|
+
if (overrides.length) warn("shell env overrides micme.json", overrides.join(", "));
|
|
103
|
+
if (shellOnly.length) info("MICME_* shell values", shellOnly.join(", "));
|
|
104
|
+
}
|
|
105
|
+
|
|
73
106
|
async function main() {
|
|
74
107
|
console.log("Micme doctor\n");
|
|
75
108
|
info("platform", `${process.platform} ${process.arch}`);
|
|
76
109
|
info("node", process.version);
|
|
77
|
-
|
|
78
|
-
else info(".env", "not found");
|
|
110
|
+
printConfigDiagnostics();
|
|
79
111
|
|
|
80
112
|
const pi = which(["pi"]);
|
|
81
113
|
if (pi) ok("pi CLI", pi);
|
|
@@ -87,15 +119,15 @@ async function main() {
|
|
|
87
119
|
|
|
88
120
|
const configuredWhisperCpp = env("MICME_WHISPER_CPP_BIN");
|
|
89
121
|
const whisperCpp = configuredWhisperCpp ? resolveExecutable(configuredWhisperCpp) : which(["whisper-cli", "whisper-cpp"]);
|
|
90
|
-
const whisperCppModel =
|
|
122
|
+
const whisperCppModel = envPath("MICME_WHISPER_CPP_MODEL");
|
|
91
123
|
if (whisperCpp && existsSync(whisperCpp)) ok("whisper.cpp binary", whisperCpp);
|
|
92
|
-
else if (configuredWhisperCpp) warn("MICME_WHISPER_CPP_BIN is set but not found", configuredWhisperCpp);
|
|
124
|
+
else if (configuredWhisperCpp) warn("MICME_WHISPER_CPP_BIN is set but not found", resolveExecutable(configuredWhisperCpp));
|
|
93
125
|
else warn("whisper.cpp binary missing", "recommended backend for portable local transcription");
|
|
94
126
|
|
|
95
127
|
const configuredWhisperStream = env("MICME_WHISPER_STREAM_BIN");
|
|
96
128
|
const whisperStream = configuredWhisperStream ? resolveExecutable(configuredWhisperStream) : which(["whisper-stream"]);
|
|
97
129
|
if (whisperStream && existsSync(whisperStream)) ok("whisper-stream binary", whisperStream);
|
|
98
|
-
else if (configuredWhisperStream) warn("MICME_WHISPER_STREAM_BIN is set but not found", configuredWhisperStream);
|
|
130
|
+
else if (configuredWhisperStream) warn("MICME_WHISPER_STREAM_BIN is set but not found", resolveExecutable(configuredWhisperStream));
|
|
99
131
|
else info("whisper-stream binary", "not installed; only needed for MICME_TRANSCRIPTION_MODE=stream");
|
|
100
132
|
|
|
101
133
|
if (whisperCppModel) {
|
|
@@ -108,7 +140,7 @@ async function main() {
|
|
|
108
140
|
}
|
|
109
141
|
} else {
|
|
110
142
|
const defaultModel = env("MICME_DEFAULT_WHISPER_CPP_MODEL") || "small.en";
|
|
111
|
-
const modelDir = env("MICME_MODEL_DIR") ||
|
|
143
|
+
const modelDir = expandConfigValue(env("MICME_MODEL_DIR") || join(homedir(), ".cache", "whisper.cpp"));
|
|
112
144
|
info("MICME_WHISPER_CPP_MODEL", `not set; Micme defaults to ${modelDir}/ggml-${defaultModel}.bin and auto-downloads when needed`);
|
|
113
145
|
}
|
|
114
146
|
|
|
@@ -140,7 +172,7 @@ async function main() {
|
|
|
140
172
|
if (macbookMic) {
|
|
141
173
|
const current = env("MICME_AUDIO_DEVICE") || "0";
|
|
142
174
|
if (current !== macbookMic[1]) {
|
|
143
|
-
warn("MacBook Pro microphone is not the configured default", `try:
|
|
175
|
+
warn("MacBook Pro microphone is not the configured default", `try: MICME_AUDIO_DEVICE=${macbookMic[1]} pi`);
|
|
144
176
|
}
|
|
145
177
|
}
|
|
146
178
|
console.log("\nSet MICME_AUDIO_DEVICE to the numeric audio device id if device 0 is wrong.");
|