@mushi-mushi/cli 0.6.1 → 0.8.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/CONTRIBUTING.md CHANGED
@@ -91,6 +91,33 @@ pnpm changeset
91
91
 
92
92
  Select the affected packages, the semver bump type, and write a summary. The changeset file gets committed with your PR.
93
93
 
94
+ ## Release flow
95
+
96
+ Releases are fully automated. Maintainers don't run `npm publish` by hand.
97
+
98
+ 1. PRs land on `master` with one or more changeset files in `.changeset/`.
99
+ 2. `release.yml` runs on every push to `master`. It opens (or updates) a `chore: version packages` PR that bumps every affected `package.json`, rolls up the changelogs, and deletes the consumed changesets.
100
+ 3. Merging that "Version Packages" PR re-fires `release.yml`. The publish step authenticates to npm via **OpenID Connect (OIDC) Trusted Publishers** — no long-lived `NPM_TOKEN` is exchanged — and every tarball ships with a **Sigstore provenance attestation** uploaded to the public transparency log.
101
+
102
+ If GitHub's anti-loop protection suppresses the auto re-fire (the squash merge can be attributed to `github-actions[bot]`), trigger the workflow manually: **Actions → release → Run workflow → master**.
103
+
104
+ ### Adding a brand-new publishable package
105
+
106
+ Trusted Publisher bindings are configured **per package** on `npmjs.com` and require the package to already exist on the registry. New packages therefore need a one-time bootstrap before OIDC can take over.
107
+
108
+ 1. Add the package under `packages/<name>/` with a real `version`, `files`, `publishConfig.access: "public"`, `LICENSE`, and the standard fields enforced by `pnpm check:publish-readiness`.
109
+ 2. Build it locally: `pnpm install && pnpm -r build`.
110
+ 3. Mint a short-lived granular access token at `https://www.npmjs.com/settings/<your-user>/tokens/granular-access-tokens/new` — **Bypass 2FA: ON**, **Read and write: All packages**, **Expiration: 7 days**.
111
+ 4. Bootstrap-publish:
112
+ ```bash
113
+ NPM_TOKEN=npm_xxx pnpm bootstrap:new-package
114
+ ```
115
+ The script auto-detects which workspace packages are missing on npm and publishes them via `pnpm publish --no-provenance` (so `workspace:^` specifiers get rewritten to real semver in the tarball).
116
+ 5. The script prints one URL per freshly-published package. Open each, click **GitHub Actions** under "Trusted Publisher", confirm the auto-filled fields (`<owner>` / `<repo>` / `release.yml`), and tap your security key.
117
+ 6. Revoke the bootstrap token at `https://www.npmjs.com/settings/<your-user>/tokens`.
118
+
119
+ From the next changeset bump onward, that package publishes through the normal `release.yml` flow with full OIDC provenance — same as the rest.
120
+
94
121
  ## Code Style
95
122
 
96
123
  - **TypeScript strict mode** — no `any` unless absolutely necessary
package/README.md CHANGED
@@ -1,96 +1,446 @@
1
- # @mushi-mushi/cli
1
+ # `@mushi-mushi/cli`
2
2
 
3
- CLI for Mushi Mushi set up the SDK in one command, then triage reports and monitor the pipeline from your terminal.
3
+ > **The mutation that closes the loop** run Mushi Mushi bug-intelligence from
4
+ > your terminal and CI pipelines, without ever opening a browser.
4
5
 
5
- ## One-command setup
6
+ <div align="center">
7
+
8
+ <a href="https://kensaur.us/mushi-mushi/docs/" title="Full docs with screenshots">
9
+ <img src="https://raw.githubusercontent.com/kensaurus/mushi-mushi/main/docs/screenshots/tour-pdca-loop.gif" alt="Admin console PDCA tour — what mushi init wires your project into" width="100%" />
10
+ </a>
11
+
12
+ <sub>↑ what the CLI connects to · <a href="https://kensaur.us/mushi-mushi/docs/admin/">admin docs with screenshots</a></sub>
13
+
14
+ </div>
15
+
16
+ ## What it does
17
+
18
+ Like DNA repair enzymes that scan a genome for transcription errors and patch
19
+ them before the next cell division, `mushi-mushi` scans your live project for
20
+ bug patterns, feeds them back into your toolchain, and tells you which ones are
21
+ still open. The CLI is the command-line face of that repair loop:
22
+
23
+ | Before `@mushi-mushi/cli` | After `@mushi-mushi/cli` |
24
+ |---|---|
25
+ | Open the console to check if the bug you fixed is actually resolved | `mushi reports show <id>` in 1 second |
26
+ | Manually copy SDK snippets into each new project | `mushi init` auto-detects your framework and installs everything |
27
+ | No idea which mistake rules are active | `mushi lessons list` shows the current rule genome |
28
+ | CI doesn't know about lesson files | `mushi sync-lessons` writes `.mushi/lessons.json` every deploy |
29
+ | Debug auth failures by staring at headers | `mushi whoami` confirms key + endpoint in one shot |
30
+
31
+ ---
32
+
33
+ ## Quick start
34
+
35
+ ```bash
36
+ # 1. Install globally (or use npx without installing)
37
+ npm install -g @mushi-mushi/cli # or: pnpm add -g / yarn global add
38
+
39
+ # 2. Get your credentials from the Mushi console:
40
+ # Project ID → https://kensaur.us/mushi-mushi/projects (copy chip)
41
+ # API key → https://kensaur.us/mushi-mushi/settings/api-keys
42
+
43
+ # 3. Save credentials
44
+ mushi login \
45
+ --api-key mushi_xxxxxxxxxxxxxxxxxxxx \
46
+ --endpoint https://<ref>.supabase.co/functions/v1/api \
47
+ --project-id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
48
+
49
+ # 4. Verify the connection
50
+ mushi whoami
51
+
52
+ # 5. Set up the SDK in a project
53
+ cd my-app && mushi init
54
+ ```
55
+
56
+ ---
57
+
58
+ ## Environment variables
59
+
60
+ All credentials can be supplied via environment variables — ideal for CI
61
+ where a config file per runner is impractical:
62
+
63
+ | Variable | Description |
64
+ |---|---|
65
+ | `MUSHI_API_KEY` | SDK API key, looks like `mushi_...` |
66
+ | `MUSHI_PROJECT_ID` | Project UUID, from the Projects page |
67
+ | `MUSHI_API_ENDPOINT` | Supabase edge function URL |
68
+
69
+ Environment variables override `~/.mushirc`. Explicit command-line flags
70
+ override both.
71
+
72
+ ```bash
73
+ # Example: CI usage without any persistent config file
74
+ export MUSHI_API_KEY=mushi_xxxx
75
+ export MUSHI_PROJECT_ID=542b34e0-019e-41fe-b900-7b637717bb86
76
+ export MUSHI_API_ENDPOINT=https://xyz.supabase.co/functions/v1/api
77
+
78
+ mushi sync-lessons # writes .mushi/lessons.json
79
+ mushi status # print project stats
80
+ mushi ping # smoke-test connectivity
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Finding your credentials
86
+
87
+ ### API key
88
+
89
+ 1. Open the Mushi console → **Settings → API Keys**
90
+ (`https://kensaur.us/mushi-mushi/settings`)
91
+ 2. Click **Create API key**
92
+ 3. Copy the value — it starts with `mushi_`
93
+
94
+ ### Project ID
95
+
96
+ 1. Open the Mushi console → **Projects**
97
+ (`https://kensaur.us/mushi-mushi/projects`)
98
+ 2. On the project card, click the UUID chip to copy it
99
+ 3. The UUID looks like `542b34e0-019e-41fe-b900-7b637717bb86`
100
+
101
+ ### API endpoint
102
+
103
+ Unless you are self-hosting, use:
104
+ ```
105
+ https://dxptnwrhwsqckaftyymj.supabase.co/functions/v1/api
106
+ ```
107
+
108
+ ---
109
+
110
+ ## Commands
111
+
112
+ ### `mushi init`
113
+
114
+ Set up the Mushi SDK in the current project. Auto-detects framework, installs
115
+ the right package, and writes a minimal config file.
116
+
117
+ ```bash
118
+ mushi init
119
+ mushi init --project-id <uuid> --api-key <key> # non-interactive (CI)
120
+ mushi init --framework next # force a framework
121
+ mushi init --skip-install # print install command only
122
+ mushi init --yes # skip confirmation prompts
123
+ ```
124
+
125
+ Supported frameworks: `next`, `react`, `vue`, `nuxt`, `svelte`, `sveltekit`,
126
+ `angular`, `expo`, `react-native`, `capacitor`, `vanilla`.
127
+
128
+ ---
129
+
130
+ ### `mushi login`
131
+
132
+ Save API credentials to `~/.mushirc` (mode `0o600`, readable only by you).
133
+
134
+ ```bash
135
+ mushi login \
136
+ --api-key mushi_xxx \
137
+ --endpoint https://xyz.supabase.co/functions/v1/api \
138
+ --project-id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
139
+ ```
140
+
141
+ ---
142
+
143
+ ### `mushi whoami`
144
+
145
+ Verify the API key is valid and print which project it belongs to.
6
146
 
7
147
  ```bash
8
- npx @mushi-mushi/cli init
9
- # equivalently:
10
- npx mushi-mushi
148
+ mushi whoami
149
+ mushi whoami --json # machine-readable
11
150
  ```
12
151
 
13
- The wizard:
152
+ Example output:
153
+ ```
154
+ ✓ Authenticated
155
+ Project: My App (542b34e0-019e-41fe-b900-7b637717bb86)
156
+ Endpoint: https://xyz.supabase.co/functions/v1/api
157
+ Reports: 47 total · 3 open
158
+ ```
14
159
 
15
- 1. Detects your framework (Next.js, Nuxt, SvelteKit, Angular, Expo, Capacitor, plain React/Vue/Svelte, or vanilla JS) from `package.json` and config files.
16
- 2. Picks the right SDK package (`@mushi-mushi/react`, `@mushi-mushi/vue`, etc.) plus `@mushi-mushi/web` when the framework SDK is API-only.
17
- 3. Detects your package manager (npm / pnpm / yarn / bun) from your lockfile and installs with that — `shell: false`, with Windows `.cmd` shim resolution.
18
- 4. Writes `MUSHI_PROJECT_ID` and `MUSHI_API_KEY` (with the right framework prefix — `NEXT_PUBLIC_`, `NUXT_PUBLIC_`, `VITE_`) to `.env.local` (or `.env`).
19
- 5. Warns you if `.env.local` isn't in `.gitignore` (covers `.env*.local`, `*.local`, etc.).
20
- 6. Prints the framework-specific provider snippet to copy-paste.
21
- 7. Offers to **send a real test report** so you see your first classified bug in the console immediately. Opt out via `--skip-test-report`.
160
+ ---
22
161
 
23
- It never silently overwrites existing env vars or modifies application code. Pasted credentials are sanitized (stripped of quotes / CR / LF / NUL) and validated against `^proj_[A-Za-z0-9_-]{10,}$` / `^mushi_[A-Za-z0-9_-]{10,}$` before anything is written to disk.
162
+ ### `mushi ping`
24
163
 
25
- ### Flags
164
+ Check that the Mushi backend is reachable. Useful as a CI health gate.
26
165
 
27
166
  ```bash
28
- mushi init --framework next # skip framework detection
29
- mushi init --project-id proj_xxx --api-key mushi_xxx # skip credential prompts
30
- mushi init --skip-install # print the install command instead
31
- mushi init --skip-test-report # don't offer to send a test report
32
- mushi init --cwd apps/web # run in a sub-package of a monorepo
33
- mushi init --endpoint https://mushi.your-company.com # self-hosted Mushi API
34
- mushi init -y # accept the detected framework
167
+ mushi ping
168
+ mushi ping --json # { ok: true, status: 200, latency_ms: 42 }
35
169
  ```
36
170
 
37
- Non-interactive use (CI): pass `--yes --project-id proj_xxx --api-key mushi_xxx` or the wizard exits with a clear error instead of hanging on a prompt.
171
+ ---
172
+
173
+ ### `mushi status`
38
174
 
39
- Stale-version hint: the wizard checks the npm registry (2s timeout) and prints a one-line upgrade nudge if a newer stable is published. Opt out with `MUSHI_NO_UPDATE_CHECK=1`.
175
+ Print a project health summary: report counts by status and severity, fix and
176
+ lesson totals.
40
177
 
41
- Monorepo awareness: if you run the wizard at a workspace root with no framework dep, it scans `apps/*`, `packages/*`, `examples/*` and tells you which sub-package you probably meant (`mushi init --cwd apps/web`).
178
+ ```bash
179
+ mushi status
180
+ mushi status --json
181
+ ```
182
+
183
+ ---
42
184
 
43
- ## Install globally
185
+ ### `mushi config`
186
+
187
+ View or update the config stored in `~/.mushirc`.
44
188
 
45
189
  ```bash
46
- npm install -g @mushi-mushi/cli
47
- mushi --help
48
- mushi --version
190
+ mushi config # show all config
191
+ mushi config apiKey mushi_xxx # update a value
192
+ mushi config endpoint https://... # update endpoint
193
+ mushi config projectId <uuid> # update project ID
49
194
  ```
50
195
 
51
- ## Other commands
196
+ ---
197
+
198
+ ### `mushi reports list`
199
+
200
+ List recent reports for the project.
201
+
202
+ ```bash
203
+ mushi reports list
204
+ mushi reports list --status new --severity critical
205
+ mushi reports list --search "login button"
206
+ mushi reports list --limit 50 --json
207
+ ```
208
+
209
+ Options:
210
+ - `--limit <n>` — max results, 1–100 (default: 20)
211
+ - `--status` — filter: `new`, `triaged`, `in_progress`, `resolved`, `dismissed`
212
+ - `--severity` — filter: `critical`, `high`, `medium`, `low`
213
+ - `--search <query>` — full-text search in summary and description
214
+ - `--json` — machine-readable output
215
+
216
+ ---
217
+
218
+ ### `mushi reports show <id>`
219
+
220
+ Print full details for a single report including environment, breadcrumbs, and
221
+ linked fix.
52
222
 
53
223
  ```bash
54
- mushi login --api-key mushi_xxx # store credentials in ~/.mushirc (mode 0o600)
55
- mushi status # project overview
56
- mushi reports list # recent reports
57
- mushi reports show <id> # one report
58
- mushi reports triage <id> --status acknowledged --severity high
59
- mushi deploy check # edge-function health probe
60
- mushi index <path> # walk a local repo and feed RAG
61
- mushi test # submit a test report end-to-end
62
- mushi migrate # suggest the most relevant migration guide
63
- mushi migrate --json # machine-readable JSON for CI
64
- mushi config endpoint https://... # set API endpoint (https:// required outside localhost)
224
+ mushi reports show 7f3e8c20-...
225
+ mushi reports show 7f3e8c20-... --json
65
226
  ```
66
227
 
228
+ ---
229
+
230
+ ### `mushi reports triage <id>`
231
+
232
+ Update the status and/or severity of a report, and optionally add a note.
233
+
234
+ ```bash
235
+ mushi reports triage <id> --status triaged --severity high
236
+ mushi reports triage <id> --status in_progress --note "assigned to @alice"
237
+ mushi reports triage <id> --severity critical --json
238
+ ```
239
+
240
+ ---
241
+
242
+ ### `mushi reports resolve <id>`
243
+
244
+ Mark a report resolved. Shorthand for `triage --status resolved`.
245
+
246
+ ```bash
247
+ mushi reports resolve <id>
248
+ mushi reports resolve <id> --note "fixed in PR #123"
249
+ ```
250
+
251
+ ---
252
+
253
+ ### `mushi reports reopen <id>`
254
+
255
+ Reopen a resolved or dismissed report.
256
+
257
+ ```bash
258
+ mushi reports reopen <id>
259
+ mushi reports reopen <id> --note "regression in v2.1"
260
+ ```
261
+
262
+ ---
263
+
264
+ ### `mushi reports dismiss <id>`
265
+
266
+ Dismiss a report (not a real bug / out of scope).
267
+
268
+ ```bash
269
+ mushi reports dismiss <id>
270
+ mushi reports dismiss <id> --note "working as intended"
271
+ ```
272
+
273
+ ---
274
+
275
+ ### `mushi reports search <query>`
276
+
277
+ Search reports by keyword. Equivalent to `reports list --search <query>`.
278
+
279
+ ```bash
280
+ mushi reports search "button not working"
281
+ mushi reports search "404" --status new --limit 20 --json
282
+ ```
283
+
284
+ ---
285
+
286
+ ### `mushi lessons list`
287
+
288
+ List active mistake rules (lessons) extracted from past bug reports.
289
+
290
+ ```bash
291
+ mushi lessons list
292
+ mushi lessons list --severity critical
293
+ mushi lessons list --limit 100 --json
294
+ ```
295
+
296
+ ---
297
+
298
+ ### `mushi lessons show <id>`
299
+
300
+ Print full detail for a lesson: rule text, anti-pattern, and summary paragraph.
301
+
302
+ ```bash
303
+ mushi lessons show <lesson-uuid>
304
+ mushi lessons show <lesson-uuid> --json
305
+ ```
306
+
307
+ ---
308
+
309
+ ### `mushi sync-lessons`
310
+
311
+ Pull all active lessons from the Mushi API and write `.mushi/lessons.json`
312
+ into the repo. Used in CI to keep the lesson file fresh for the Mushi MCP
313
+ server and Cursor rules.
314
+
315
+ ```bash
316
+ mushi sync-lessons # writes .mushi/lessons.json
317
+ mushi sync-lessons --dry-run # print JSON without writing
318
+ mushi sync-lessons --json # { ok: true, path: "...", count: 12 }
319
+ mushi sync-lessons --cwd ./apps/mobile
320
+ ```
321
+
322
+ CI example (GitHub Actions):
323
+ ```yaml
324
+ - name: Sync Mushi lessons
325
+ env:
326
+ MUSHI_API_KEY: ${{ secrets.MUSHI_API_KEY }}
327
+ MUSHI_PROJECT_ID: ${{ secrets.MUSHI_PROJECT_ID }}
328
+ MUSHI_API_ENDPOINT: https://dxptnwrhwsqckaftyymj.supabase.co/functions/v1/api
329
+ run: npx @mushi-mushi/cli sync-lessons
330
+ ```
331
+
332
+ ---
333
+
334
+ ### `mushi test`
335
+
336
+ Submit a synthetic test report to verify the ingestion pipeline end-to-end.
337
+ Run this after deployment to confirm the SDK → API → DB path is healthy.
338
+
339
+ ```bash
340
+ mushi test
341
+ mushi test --json
342
+ ```
343
+
344
+ ---
345
+
346
+ ### `mushi index <path>`
347
+
348
+ Walk a local repo and upload source code to the Mushi RAG vector index. Used
349
+ for private repos that cannot be auto-indexed via the GitHub App integration.
350
+
351
+ ```bash
352
+ mushi index ./src
353
+ mushi index ./src --language ts --dry-run
354
+ mushi index . --json # { ok: true, files: 42, bytes: 123456 }
355
+ ```
356
+
357
+ ---
358
+
359
+ ### `mushi sourcemaps upload`
360
+
361
+ Upload source map files (`.map`) for stack trace symbolication.
362
+
363
+ ```bash
364
+ mushi sourcemaps upload --release 1.0.0
365
+ mushi sourcemaps upload --release $(git rev-parse --short HEAD) --dir ./dist
366
+ mushi sourcemaps upload --release 1.0.0 --dry-run --silent
367
+ ```
368
+
369
+ ---
370
+
67
371
  ### `mushi migrate`
68
372
 
69
- Reads `package.json` (deps + devDeps + peerDeps) and prints links to the
70
- matching guides on the docs site. Detects:
373
+ Suggest the most relevant migration guide based on your `package.json`.
71
374
 
72
- - **In-transition shapes** — Capacitor + React Native side-by-side, Cordova
73
- (or `cordova-ios`/`cordova-android`), Create React App.
74
- - **Competitor SDKs** — Instabug / Luciq, Shake, LogRocket Feedback,
75
- BugHerd, Pendo Feedback.
375
+ ```bash
376
+ mushi migrate
377
+ mushi migrate --json
378
+ ```
379
+
380
+ ---
76
381
 
77
- Exits non-zero when nothing matches, so it composes in shell scripts:
382
+ ### `mushi deploy check`
383
+
384
+ Check that the Mushi edge function is healthy and measure round-trip latency.
78
385
 
79
386
  ```bash
80
- mushi migrate || echo "no migration suggestions for this project"
387
+ mushi deploy check
388
+ mushi deploy check --json # { ok: true, status: 200, latency_ms: 38 }
81
389
  ```
82
390
 
83
- Only `published` guides ever surface — `draft` entries are filtered out so
84
- the CLI never points users at a 404. This safety property is unit-pinned in
85
- `packages/cli/src/migrate.test.ts` (positive control + negative control +
86
- real-catalog regression guard).
391
+ ---
392
+
393
+ ## Exit codes
394
+
395
+ | Code | Meaning |
396
+ |------|---------|
397
+ | `0` | Success |
398
+ | `1` | API or runtime error |
399
+ | `2` | Configuration error (missing credentials or endpoint) |
400
+ | `3` | Not found (report or lesson ID does not exist) |
401
+
402
+ ---
403
+
404
+ ## Self-hosted Mushi
405
+
406
+ If you run a self-hosted Mushi instance, point the CLI at your edge function:
407
+
408
+ ```bash
409
+ mushi login \
410
+ --api-key mushi_xxx \
411
+ --endpoint https://your-ref.supabase.co/functions/v1/api \
412
+ --project-id <uuid>
413
+ ```
414
+
415
+ Or set `MUSHI_API_ENDPOINT` globally in CI.
416
+
417
+ ---
418
+
419
+ ## Biological evolution analogy
420
+
421
+ Mushi Mushi is modelled on **cumulative selection** (Dawkins, _The Blind
422
+ Watchmaker_) and **closed-loop error correction** (Black Box Thinking, Matthew
423
+ Syed):
424
+
425
+ 1. **Variation** — users report bugs via the SDK widget → raw reports accumulate
426
+ 2. **Selection pressure** — the clustering pipeline groups similar bugs and
427
+ scores them by frequency and severity → weak signals are filtered out
428
+ 3. **Memory** — high-signal clusters are promoted to _lessons_ (mistake rules)
429
+ → the genome of known failure modes grows
430
+ 4. **Expression** — the MCP server and CLI inject lessons into AI code review
431
+ → the codebase adapts before the next mutation slips through
432
+
433
+ The CLI is the **field instrument** for monitoring this loop:
434
+ - `mushi status` — read the current fitness of your bug pipeline
435
+ - `mushi sync-lessons` — express the latest genome into your repo
436
+ - `mushi reports triage` — apply selection pressure manually when the
437
+ automated pipeline needs a nudge
438
+
439
+ ---
87
440
 
88
- ## Security notes
441
+ ## Changelog
89
442
 
90
- - `~/.mushirc` is written with mode `0o600` on Unix. Legacy configs with looser permissions are tightened on load.
91
- - `--endpoint` values are parsed through `new URL()` and required to use `https://` except for `localhost` / `127.0.0.1` / `*.local`.
92
- - The `--api-key` flag leaks into `ps -ef` — prefer the interactive prompt on shared machines.
93
- - Full stack traces on error: `DEBUG=mushi mushi init`.
443
+ See [CHANGELOG.md](../../CHANGELOG.md) for release history.
94
444
 
95
445
  ## License
96
446