@senad-d/micme 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.
package/.env.example ADDED
@@ -0,0 +1,75 @@
1
+ # Micme safe example configuration
2
+ # Copy this file to .env, then run /micme conf inside pi to adjust it for your machine.
3
+ # Shell environment variables override values from .env.
4
+
5
+ # Shortcut used by the extension. macOS displays alt as Option.
6
+ # Some terminals insert a printable character for Option+M instead of sending Alt+M.
7
+ MICME_SHORTCUT=alt+m
8
+ MICME_PRINTABLE_SHORTCUTS=§
9
+
10
+ # Transcription behavior.
11
+ # clip = stable default: record first, then transcribe when stopped.
12
+ # stream = experimental live preview using whisper-stream.
13
+ MICME_TRANSCRIPTION_MODE=clip
14
+ MICME_AUTO_SUBMIT=0
15
+ MICME_LANGUAGE=en
16
+ MICME_TRANSCRIBE_TIMEOUT_MS=120000
17
+
18
+ # Privacy/debugging.
19
+ # By default Micme removes temp audio after successful transcription.
20
+ MICME_KEEP_AUDIO=0
21
+ MICME_VALIDATE_AUDIO=1
22
+ MICME_MIN_MAX_VOLUME_DB=-50
23
+
24
+ # Recorder selection.
25
+ # Leave these unset until /micme devices shows the right value for your OS.
26
+ # macOS avfoundation examples:
27
+ # MICME_AUDIO_DEVICE=0
28
+ # MICME_AVFOUNDATION_INPUT=:0
29
+ # Linux PulseAudio example:
30
+ # MICME_PULSE_SOURCE=default
31
+ # Windows DirectShow example:
32
+ # MICME_DSHOW_AUDIO_DEVICE=default
33
+
34
+ # Recording/preprocessing. Micme records a raw WAV, then prepares a 16 kHz WAV for Whisper.
35
+ MICME_RECORD_SAMPLE_RATE=48000
36
+ MICME_TRANSCRIBE_SAMPLE_RATE=16000
37
+ MICME_PROCESS_AUDIO=1
38
+ MICME_AUDIO_FILTER=highpass=f=80,lowpass=f=7600
39
+
40
+ # Recording meter tuning. Defaults should be fine for most microphones.
41
+ MICME_METER_GAIN=1
42
+ MICME_METER_FLOOR_DB=55
43
+ MICME_METER_RANGE_DB=35
44
+
45
+ # Recommended backend: whisper.cpp. Install it separately, then either leave the binary unset
46
+ # so Micme searches PATH, or set MICME_WHISPER_CPP_BIN to an explicit local path.
47
+ MICME_AUTO_DOWNLOAD_MODEL=1
48
+ MICME_DEFAULT_WHISPER_CPP_MODEL=small.en
49
+ MICME_MODEL_DIR=$HOME/.cache/whisper.cpp
50
+ # MICME_WHISPER_CPP_BIN=whisper-cli
51
+ # MICME_WHISPER_STREAM_BIN=whisper-stream
52
+ # MICME_WHISPER_CPP_MODEL=$HOME/.cache/whisper.cpp/ggml-small.en.bin
53
+
54
+ # Python openai-whisper fallback. Used only when whisper.cpp is not configured/found.
55
+ MICME_WHISPER_MODEL=base.en
56
+ MICME_WHISPER_DEVICE=cpu
57
+ MICME_WHISPER_FP16=False
58
+
59
+ # Experimental streaming profile. /micme conf can apply a low-latency profile automatically.
60
+ MICME_STREAM_CAPTURE=-1
61
+ MICME_STREAM_WORDS_PER_CHUNK=5
62
+ MICME_STREAM_STEP_MS=500
63
+ MICME_STREAM_LENGTH_MS=3000
64
+ MICME_STREAM_KEEP_MS=300
65
+ MICME_STREAM_MAX_TOKENS=32
66
+ MICME_STREAM_KEEP_CONTEXT=1
67
+ MICME_STREAM_FINALIZE_WITH_CLIP=0
68
+ MICME_STREAM_VAD_THRESHOLD=0.35
69
+ MICME_STREAM_DIAGNOSTICS=0
70
+
71
+ # Advanced custom hooks. Placeholders are shell-quoted unless the Raw suffix is used:
72
+ # {audio}, {audioRaw}, {tempDir}, {tempDirRaw}, {transcript}, {transcriptRaw}
73
+ # Raw placeholders bypass shell quoting; use them only when you fully control the command.
74
+ # MICME_RECORD_COMMAND=ffmpeg -hide_banner -loglevel error -f avfoundation -i :0 -ac 1 -ar 16000 -y {audio}
75
+ # MICME_TRANSCRIBE_COMMAND=whisper-cli -m /path/to/model.bin -f {audio} -otxt -of {tempDirRaw}/out -nt -np && cat {tempDirRaw}/out.txt
package/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ All notable changes to Micme will be documented in this file.
4
+
5
+ ## Unreleased
6
+
7
+ - Keep publication on hold until package name, metadata, security review, validation, and smoke tests are complete.
8
+ - Use the `docs/PUBLISHING.md` checklist for the first npm release.
9
+
10
+ ## 0.1.0 - 2026-06-18
11
+
12
+ Initial publication-readiness candidate.
13
+
14
+ - Adds a pi package manifest that loads `./src/extension.ts` from the package root.
15
+ - Provides local clip-mode transcription with `ffmpeg`, `whisper.cpp`, optional Python `whisper`, and advanced custom command hooks.
16
+ - Adds experimental streaming preview support through `whisper-stream`.
17
+ - Adds `/micme`, `/micme conf`, `/micme devices`, `/micme last`, `/micme audio`, and `/micme help`.
18
+ - Documents beginner install, privacy/security behavior, diagnostics, and maintainer publishing steps.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Senad Dizdarević
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 ADDED
@@ -0,0 +1,259 @@
1
+ <p align="center">
2
+ <img alt="Micme logo" src="img/micme_logo.png" width="128">
3
+ </p>
4
+
5
+ <p align="center">
6
+ <a href="https://pi.dev"><img alt="pi package" src="https://img.shields.io/badge/pi-package-6f42c1?style=flat-square" /></a>
7
+ <a href="https://www.npmjs.com/package/micme"><img alt="npm" src="https://img.shields.io/npm/v/micme?style=flat-square" /></a>
8
+ <a href="LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" /></a>
9
+ </p>
10
+
11
+ <p align="center">
12
+ Local voice-to-text for <a href="https://pi.dev">pi</a>.
13
+ <br />Tap a shortcut, speak, and paste the transcript into pi's editor.
14
+ </p>
15
+
16
+ ---
17
+
18
+ Micme is a pi extension for short coding prompts. It records your microphone with `ffmpeg`, transcribes locally with `whisper.cpp` or another local backend, and inserts the transcript into pi.
19
+
20
+ - **Local-first:** no telemetry and no cloud STT service by default.
21
+ - **Review-first:** transcripts paste into the editor unless you enable auto-submit.
22
+ - **Pi-native:** install globally, project-locally, from git, or from a source checkout.
23
+ - **Configurable:** use `/micme conf`, `.env`, or shell variables.
24
+
25
+ > **Security:** pi packages run with your full system permissions. Micme can use your microphone, spawn local commands, write `MICME_*` settings to `.env`, and optionally download Whisper model files. Read [`SECURITY.md`](SECURITY.md).
26
+
27
+ ## Table of Contents
28
+
29
+ - [Quick Start](#quick-start)
30
+ - [Installation](#installation)
31
+ - [Backend Setup](#backend-setup)
32
+ - [Configuration](#configuration)
33
+ - [Commands](#commands)
34
+ - [Models and Backends](#models-and-backends)
35
+ - [Troubleshooting](#troubleshooting)
36
+ - [Diagnostics](#diagnostics)
37
+ - [Update and Uninstall](#update-and-uninstall)
38
+
39
+ ---
40
+
41
+ ## Quick Start
42
+
43
+ ```bash
44
+ pi install npm:micme
45
+ ```
46
+
47
+ Install a local backend. On macOS:
48
+
49
+ ```bash
50
+ brew install ffmpeg whisper-cpp
51
+ ```
52
+
53
+ Start pi and configure Micme:
54
+
55
+ ```bash
56
+ pi
57
+ ```
58
+
59
+ ```text
60
+ /micme conf
61
+ /micme devices
62
+ ```
63
+
64
+ Use it:
65
+
66
+ 1. Press `alt+m` / `Option+m` to start recording.
67
+ 2. Speak your prompt.
68
+ 3. Press `alt+m` again to stop.
69
+ 4. Review the pasted transcript and press Enter.
70
+
71
+ Micme is toggle-based. Press-and-hold recording is not used because terminal key-up events are not portable.
72
+
73
+ ---
74
+
75
+ ## Installation
76
+
77
+ | Scope | Command | Notes |
78
+ | --- | --- | --- |
79
+ | Global | `pi install npm:micme` | Loads in every trusted pi project. |
80
+ | Project-local | `pi install npm:micme -l` | Writes to `.pi/settings.json` in the current project. |
81
+ | One run | `pi -e npm:micme` | Try without changing settings. |
82
+ | Git | `pi install git:github.com/senad-d/micme@<tag>` | Pin a tag or commit. |
83
+ | Local checkout | `pi -e .` | Develop or test this repository. |
84
+
85
+ Source checkout:
86
+
87
+ ```bash
88
+ git clone https://github.com/senad-d/micme.git
89
+ cd micme
90
+ npm install --ignore-scripts
91
+ npm run doctor
92
+ pi -e .
93
+ ```
94
+
95
+ Use the checkout globally while developing:
96
+
97
+ ```bash
98
+ pi install /absolute/path/to/micme
99
+ ```
100
+
101
+ ---
102
+
103
+ ## Backend Setup
104
+
105
+ Micme does not bundle recorder, transcriber, or model binaries.
106
+
107
+ | OS | Install | Device setting |
108
+ | --- | --- | --- |
109
+ | macOS | `brew install ffmpeg whisper-cpp` | `MICME_AUDIO_DEVICE=0` or `MICME_AVFOUNDATION_INPUT=:0` |
110
+ | Linux | Install `ffmpeg` and `whisper.cpp` with your package manager, Nix, Homebrew, or source build. | `MICME_PULSE_SOURCE=default` |
111
+ | Windows | `winget install Gyan.FFmpeg`, then install/build `whisper.cpp`. | `MICME_DSHOW_AUDIO_DEVICE=Microphone Name` |
112
+
113
+ List devices inside pi:
114
+
115
+ ```text
116
+ /micme devices
117
+ ```
118
+
119
+ macOS device listing outside pi:
120
+
121
+ ```bash
122
+ ffmpeg -hide_banner -f avfoundation -list_devices true -i ""
123
+ ```
124
+
125
+ If `whisper-cli` is not on `PATH`, set it explicitly:
126
+
127
+ ```env
128
+ MICME_WHISPER_CPP_BIN=/path/to/whisper-cli
129
+ MICME_WHISPER_CPP_MODEL=/path/to/ggml-small.en.bin
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Configuration
135
+
136
+ Micme reads settings from shell environment variables and from a project `.env`. Shell variables win. `/micme conf` writes only `MICME_*` keys to `.env`.
137
+
138
+ Use the example file in the project where you run pi:
139
+
140
+ ```bash
141
+ cp .env.example .env
142
+ ```
143
+
144
+ If the project already has a `.env`, copy only the `MICME_*` lines you need. For a global pi install, do not edit the package directory; put `.env` in each project or set shell variables in your shell profile.
145
+
146
+ Minimal `.env`:
147
+
148
+ ```env
149
+ MICME_LANGUAGE=en
150
+ MICME_AUTO_DOWNLOAD_MODEL=1
151
+ MICME_DEFAULT_WHISPER_CPP_MODEL=small.en
152
+ MICME_AUTO_SUBMIT=0
153
+ MICME_KEEP_AUDIO=0
154
+ ```
155
+
156
+ Common settings:
157
+
158
+ | Variable | Meaning |
159
+ | --- | --- |
160
+ | `MICME_TRANSCRIPTION_MODE=clip` | Stable default: transcribe after recording stops. |
161
+ | `MICME_TRANSCRIPTION_MODE=stream` | Experimental live preview with `whisper-stream`. |
162
+ | `MICME_AUTO_SUBMIT=0` | Paste for review. Set `1` to send automatically. |
163
+ | `MICME_SHORTCUT=alt+m` | Toggle shortcut. Restart or `/reload` after changing. |
164
+ | `MICME_PRINTABLE_SHORTCUTS=§` | macOS Option-key fallback. |
165
+ | `MICME_VALIDATE_AUDIO=1` | Reject near-silent recordings. |
166
+ | `MICME_KEEP_AUDIO=0` | Delete successful temp audio. Set `1` for debugging. |
167
+ | `MICME_MODEL_DIR=~/.cache/whisper.cpp` | Model cache/discovery directory. |
168
+
169
+ See [`.env.example`](.env.example) for the full template.
170
+
171
+ ---
172
+
173
+ ## Commands
174
+
175
+ | Command | Description |
176
+ | --- | --- |
177
+ | `/micme` | Toggle recording. |
178
+ | `/micme conf` | Open the TUI configuration screen. |
179
+ | `/micme devices` | List audio input devices. |
180
+ | `/micme last` | Paste the previous transcript again. |
181
+ | `/micme audio` | Show the last kept audio directory. |
182
+ | `/micme help` | Show short help. |
183
+
184
+ ---
185
+
186
+ ## Models and Backends
187
+
188
+ Default backend: `whisper.cpp` via `whisper-cli`.
189
+
190
+ With `MICME_AUTO_DOWNLOAD_MODEL=1`, Micme downloads missing standard models into `MICME_MODEL_DIR`. Disable downloads with:
191
+
192
+ ```env
193
+ MICME_AUTO_DOWNLOAD_MODEL=0
194
+ ```
195
+
196
+ Recommended model progression: `base.en` for speed, `small.en` for a stronger default, `medium.en` for accuracy.
197
+
198
+ Advanced users can replace the recorder or transcriber:
199
+
200
+ ```env
201
+ MICME_RECORD_COMMAND=ffmpeg -hide_banner -loglevel error -f avfoundation -i :0 -ac 1 -ar 16000 -y {audio}
202
+ MICME_TRANSCRIBE_COMMAND=whisper-cli -m /path/to/model.bin -f {audio} -otxt -of {tempDirRaw}/out -nt -np && cat {tempDirRaw}/out.txt
203
+ ```
204
+
205
+ `{audio}`, `{tempDir}`, and `{transcript}` are shell-quoted. `*Raw` placeholders bypass quoting and should only be used when you fully control the command.
206
+
207
+ ---
208
+
209
+ ## Troubleshooting
210
+
211
+ | Problem | Try |
212
+ | --- | --- |
213
+ | No backend found | Install `whisper.cpp`, put `whisper-cli` on `PATH`, or set `MICME_WHISPER_CPP_BIN`. |
214
+ | Wrong microphone | Run `/micme devices`, then set the OS-specific device variable. |
215
+ | Unrelated transcript | You probably recorded silence. Set `MICME_KEEP_AUDIO=1` and check `/micme audio`. |
216
+ | Slow transcription | Use `whisper.cpp`, a smaller model, and shorter recordings. |
217
+ | Option/Alt inserts `§` or `µ` | Set `MICME_PRINTABLE_SHORTCUTS=§` or change `MICME_SHORTCUT`, then `/reload`. |
218
+ | Need automatic sending | Set `MICME_AUTO_SUBMIT=1`. |
219
+
220
+ ---
221
+
222
+ ## Diagnostics
223
+
224
+ ```bash
225
+ npx -p micme micme-doctor
226
+ ```
227
+
228
+ From a source checkout:
229
+
230
+ ```bash
231
+ npm run doctor
232
+ ```
233
+
234
+ The doctor checks Node, pi, `ffmpeg`, whisper.cpp, optional `whisper-stream`, model paths, and macOS devices when available. Custom command values are redacted.
235
+
236
+ ---
237
+
238
+ ## Update and Uninstall
239
+
240
+ ```bash
241
+ pi update --extensions # update installed pi packages
242
+ pi update npm:micme # update Micme only
243
+ pi remove npm:micme # remove global install
244
+ pi remove npm:micme -l # remove project-local install
245
+ ```
246
+
247
+ ---
248
+
249
+ ## Development
250
+
251
+ ```bash
252
+ npm ci
253
+ npm run validate
254
+ pi -e . --list-models micme-load-test
255
+ ```
256
+
257
+ ## License
258
+
259
+ MIT
package/SECURITY.md ADDED
@@ -0,0 +1,78 @@
1
+ # Security and Privacy
2
+
3
+ Micme is a pi extension package. Treat it like any other local program that can read files, start processes, and interact with your terminal.
4
+
5
+ ## Trust model
6
+
7
+ Pi packages and extensions run with full system permissions of the user account that starts pi. A Micme package can execute code during pi startup and when commands or shortcuts run. Review the source, install only trusted versions, and pin versions in sensitive environments:
8
+
9
+ ```bash
10
+ pi install npm:<package>@<version>
11
+ pi install git:<repo>@<tag>
12
+ ```
13
+
14
+ Micme does not add install-time scripts such as `postinstall`, and package installation should not contact the network beyond normal npm/git package retrieval.
15
+
16
+ ## Microphone and local audio handling
17
+
18
+ Micme records only when you run `/micme` or press the configured shortcut. It does not start recording from the extension factory at package load time.
19
+
20
+ The default recorder uses `ffmpeg` and your operating system's microphone APIs:
21
+
22
+ - macOS: `avfoundation`
23
+ - Linux: PulseAudio through `ffmpeg -f pulse`
24
+ - Windows: DirectShow through `ffmpeg -f dshow`
25
+
26
+ Micme writes temporary audio files under the operating system temp directory while a recording is being processed. After successful transcription, those files are removed by default. Set `MICME_KEEP_AUDIO=1` only when you intentionally want to keep the last raw/preprocessed audio for debugging.
27
+
28
+ ## Local process execution
29
+
30
+ Micme spawns local processes for recording and transcription:
31
+
32
+ - `ffmpeg` for recording, device listing, preprocessing, and volume validation.
33
+ - `whisper-cli` or `whisper-cpp` for whisper.cpp transcription.
34
+ - `whisper-stream` for experimental streaming mode.
35
+ - `whisper` for the optional Python openai-whisper fallback.
36
+ - Optional user-provided shell commands in `MICME_RECORD_COMMAND` and `MICME_TRANSCRIBE_COMMAND`.
37
+
38
+ The default process output is capped before it is shown to users or errors. Diagnostics should not print secret values.
39
+
40
+ ## Custom command risks
41
+
42
+ `MICME_RECORD_COMMAND` and `MICME_TRANSCRIBE_COMMAND` are advanced escape hatches. They run through the local shell (`sh -lc` on Unix-like systems and `cmd.exe` on Windows). Only use commands you wrote or fully trust.
43
+
44
+ Micme replaces these placeholders in custom commands:
45
+
46
+ - `{audio}` / `{audioRaw}`
47
+ - `{tempDir}` / `{tempDirRaw}`
48
+ - `{transcript}` / `{transcriptRaw}`
49
+
50
+ Placeholders without `Raw` are shell-quoted. `*Raw` placeholders bypass shell quoting and can break command safety if a path contains shell syntax. Use raw placeholders only where the target CLI requires an unquoted path fragment and you understand the risk.
51
+
52
+ ## Model downloads
53
+
54
+ When `MICME_AUTO_DOWNLOAD_MODEL=1` (default), Micme can download missing standard whisper.cpp model files from the whisper.cpp Hugging Face repository on first use or model selection. Downloads are stored in `MICME_MODEL_DIR`, defaulting to `~/.cache/whisper.cpp`.
55
+
56
+ Disable model downloads with:
57
+
58
+ ```bash
59
+ MICME_AUTO_DOWNLOAD_MODEL=0
60
+ ```
61
+
62
+ You can also download models manually and set `MICME_WHISPER_CPP_MODEL=/path/to/model.bin`.
63
+
64
+ ## `.env` handling
65
+
66
+ Micme reads only `MICME_*` keys from a project `.env`. Shell environment variables override `.env` values.
67
+
68
+ `/micme conf` writes only `MICME_*` values to the current project's `.env` file. It does not write arbitrary environment variables. Keep `.env` ignored by git and avoid placing secrets in Micme custom commands.
69
+
70
+ ## Telemetry and retention
71
+
72
+ Micme has no telemetry. It does not send audio or transcripts to a remote service by default. It does not retain audio after successful transcription unless `MICME_KEEP_AUDIO=1` is configured.
73
+
74
+ Network access can occur only when you explicitly use features that need it, such as automatic model downloads, or when your own custom commands contact the network.
75
+
76
+ ## Reporting vulnerabilities
77
+
78
+ Before publishing, confirm the final security contact in `package.json` and this file. For now, report issues through the repository issue tracker listed in `package.json` and avoid posting sensitive exploit details publicly.
Binary file
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@senad-d/micme",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Local voice-to-text for pi, optimized for fast Whisper-style backends.",
6
+ "license": "MIT",
7
+ "author": "Senad Dizdarević <112484166+senad-d@users.noreply.github.com>",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/senad-d/micme.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/senad-d/micme/issues"
14
+ },
15
+ "homepage": "https://github.com/senad-d/micme#readme",
16
+ "keywords": [
17
+ "pi-package",
18
+ "pi-extension",
19
+ "voice-to-text",
20
+ "speech-to-text",
21
+ "dictation",
22
+ "whisper",
23
+ "whisper.cpp",
24
+ "local-first"
25
+ ],
26
+ "engines": {
27
+ "node": ">=22.19.0"
28
+ },
29
+ "bin": {
30
+ "micme-doctor": "./scripts/doctor.mjs"
31
+ },
32
+ "files": [
33
+ "README.md",
34
+ "LICENSE",
35
+ "SECURITY.md",
36
+ "CHANGELOG.md",
37
+ ".env.example",
38
+ "img/micme_logo.png",
39
+ "src/**/*.ts",
40
+ "scripts/*.mjs",
41
+ "docs/**/*.md",
42
+ "tsconfig.json"
43
+ ],
44
+ "scripts": {
45
+ "doctor": "node scripts/doctor.mjs",
46
+ "check": "node --check scripts/doctor.mjs && node --check scripts/check-package-contents.mjs",
47
+ "typecheck": "tsc --noEmit",
48
+ "pack:dry-run": "npm pack --dry-run --json",
49
+ "check:pack": "node scripts/check-package-contents.mjs",
50
+ "validate": "npm run typecheck && npm run check && npm run check:pack",
51
+ "prepublishOnly": "npm run validate"
52
+ },
53
+ "pi": {
54
+ "extensions": [
55
+ "./src/extension.ts"
56
+ ]
57
+ },
58
+ "peerDependencies": {
59
+ "@earendil-works/pi-coding-agent": "*",
60
+ "@earendil-works/pi-tui": "*"
61
+ },
62
+ "devDependencies": {
63
+ "@earendil-works/pi-coding-agent": "file:./dev-shims/pi-coding-agent",
64
+ "@earendil-works/pi-tui": "*",
65
+ "@types/node": "^25.9.3",
66
+ "typescript": "^6.0.3"
67
+ }
68
+ }
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+ import { execFileSync } from "node:child_process";
3
+
4
+ const forbiddenChecks = [
5
+ {
6
+ label: "environment files",
7
+ test: (path) => path === ".env" || (path.startsWith(".env.") && path !== ".env.example"),
8
+ },
9
+ { label: "project-local pi state", test: (path) => path.startsWith(".pi/") },
10
+ { label: "node_modules", test: (path) => path.startsWith("node_modules/") || path.includes("/node_modules/") },
11
+ { label: "planning specs", test: (path) => path.startsWith("specs/") },
12
+ { label: "Micme cache", test: (path) => path.startsWith(".micme/") || path.includes("/.micme/") },
13
+ { label: "token insight files", test: (path) => path.includes("token-insights") },
14
+ { label: "npm tarballs", test: (path) => /(^|\/)micme-[^/]+\.tgz$/i.test(path) || path.endsWith(".tgz") },
15
+ { label: "audio artifacts", test: (path) => /\.(wav|mp3|m4a|flac|ogg|opus|aiff?|pcm)$/i.test(path) },
16
+ { label: "model artifacts", test: (path) => /(^|\/)(ggml-.+\.(bin|gguf)|.+\.gguf)$/i.test(path) },
17
+ ];
18
+
19
+ function readPackFiles() {
20
+ const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm";
21
+ const output = execFileSync(npmCommand, ["pack", "--dry-run", "--json"], {
22
+ encoding: "utf8",
23
+ stdio: ["ignore", "pipe", "pipe"],
24
+ });
25
+ const parsed = JSON.parse(output);
26
+ const pack = Array.isArray(parsed) ? parsed[0] : parsed;
27
+ if (!pack || !Array.isArray(pack.files)) {
28
+ throw new Error("Unexpected npm pack --dry-run --json output.");
29
+ }
30
+ return pack.files.map((file) => file.path).sort((a, b) => a.localeCompare(b));
31
+ }
32
+
33
+ const files = readPackFiles();
34
+ const violations = [];
35
+ for (const file of files) {
36
+ for (const check of forbiddenChecks) {
37
+ if (check.test(file)) violations.push({ file, label: check.label });
38
+ }
39
+ }
40
+
41
+ console.log(`Micme package dry-run contains ${files.length} file(s).`);
42
+ for (const file of files) console.log(`- ${file}`);
43
+
44
+ if (violations.length > 0) {
45
+ console.error("\nForbidden package contents detected:");
46
+ for (const violation of violations) {
47
+ console.error(`- ${violation.file} (${violation.label})`);
48
+ }
49
+ process.exitCode = 1;
50
+ }