@mushi-mushi/cli 0.7.0 → 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/README.md CHANGED
@@ -1,113 +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.
6
71
 
7
72
  ```bash
8
- npx @mushi-mushi/cli init
9
- # equivalently:
10
- npx mushi-mushi
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
11
81
  ```
12
82
 
13
- The wizard:
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_`
14
93
 
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`.
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
+ ```
22
107
 
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.
108
+ ---
24
109
 
25
- ### Flags
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.
26
116
 
27
117
  ```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
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
35
123
  ```
36
124
 
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.
125
+ Supported frameworks: `next`, `react`, `vue`, `nuxt`, `svelte`, `sveltekit`,
126
+ `angular`, `expo`, `react-native`, `capacitor`, `vanilla`.
38
127
 
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`.
128
+ ---
40
129
 
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`).
130
+ ### `mushi login`
42
131
 
43
- ## Install globally
132
+ Save API credentials to `~/.mushirc` (mode `0o600`, readable only by you).
44
133
 
45
134
  ```bash
46
- npm install -g @mushi-mushi/cli
47
- mushi --help
48
- mushi --version
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
49
139
  ```
50
140
 
51
- ## Other commands
141
+ ---
142
+
143
+ ### `mushi whoami`
144
+
145
+ Verify the API key is valid and print which project it belongs to.
52
146
 
53
147
  ```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)
65
- mushi sourcemaps upload --release <ver> --dir <dist> # upload .js.map / .css.map (sha256-idempotent)
148
+ mushi whoami
149
+ mushi whoami --json # machine-readable
66
150
  ```
67
151
 
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
+ ```
159
+
160
+ ---
161
+
162
+ ### `mushi ping`
163
+
164
+ Check that the Mushi backend is reachable. Useful as a CI health gate.
165
+
166
+ ```bash
167
+ mushi ping
168
+ mushi ping --json # { ok: true, status: 200, latency_ms: 42 }
169
+ ```
170
+
171
+ ---
172
+
173
+ ### `mushi status`
174
+
175
+ Print a project health summary: report counts by status and severity, fix and
176
+ lesson totals.
177
+
178
+ ```bash
179
+ mushi status
180
+ mushi status --json
181
+ ```
182
+
183
+ ---
184
+
185
+ ### `mushi config`
186
+
187
+ View or update the config stored in `~/.mushirc`.
188
+
189
+ ```bash
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
194
+ ```
195
+
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.
222
+
223
+ ```bash
224
+ mushi reports show 7f3e8c20-...
225
+ mushi reports show 7f3e8c20-... --json
226
+ ```
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
+
68
359
  ### `mushi sourcemaps upload`
69
360
 
70
- Recursively scans `--dir` for `.js.map` and `.css.map` files and uploads them
71
- under the given `--release`. Each file is hashed (sha256) and skipped if the
72
- server already has it for that release, so the command is safe to run from
73
- every CI build without churning storage.
361
+ Upload source map files (`.map`) for stack trace symbolication.
74
362
 
75
363
  ```bash
76
- mushi sourcemaps upload --release 1.4.2 --dir ./dist
77
- mushi sourcemaps upload --release "$GITHUB_SHA" --dir ./build --dry-run
78
- mushi sourcemaps upload --release "$GITHUB_SHA" --dir ./build --silent
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
79
367
  ```
80
368
 
81
- Requires `MUSHI_API_ENDPOINT` and `MUSHI_API_KEY` (or pass `--endpoint` /
82
- `--api-key`). Exits non-zero on any upload failure so CI gates fail fast.
369
+ ---
83
370
 
84
371
  ### `mushi migrate`
85
372
 
86
- Reads `package.json` (deps + devDeps + peerDeps) and prints links to the
87
- matching guides on the docs site. Detects:
373
+ Suggest the most relevant migration guide based on your `package.json`.
88
374
 
89
- - **In-transition shapes** — Capacitor + React Native side-by-side, Cordova
90
- (or `cordova-ios`/`cordova-android`), Create React App.
91
- - **Competitor SDKs** — Instabug / Luciq, Shake, LogRocket Feedback,
92
- BugHerd, Pendo Feedback.
375
+ ```bash
376
+ mushi migrate
377
+ mushi migrate --json
378
+ ```
379
+
380
+ ---
381
+
382
+ ### `mushi deploy check`
383
+
384
+ Check that the Mushi edge function is healthy and measure round-trip latency.
385
+
386
+ ```bash
387
+ mushi deploy check
388
+ mushi deploy check --json # { ok: true, status: 200, latency_ms: 38 }
389
+ ```
390
+
391
+ ---
392
+
393
+ ## Exit codes
93
394
 
94
- Exits non-zero when nothing matches, so it composes in shell scripts:
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:
95
407
 
96
408
  ```bash
97
- mushi migrate || echo "no migration suggestions for this project"
409
+ mushi login \
410
+ --api-key mushi_xxx \
411
+ --endpoint https://your-ref.supabase.co/functions/v1/api \
412
+ --project-id <uuid>
98
413
  ```
99
414
 
100
- Only `published` guides ever surface — `draft` entries are filtered out so
101
- the CLI never points users at a 404. This safety property is unit-pinned in
102
- `packages/cli/src/migrate.test.ts` (positive control + negative control +
103
- real-catalog regression guard).
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
+ ---
104
440
 
105
- ## Security notes
441
+ ## Changelog
106
442
 
107
- - `~/.mushirc` is written with mode `0o600` on Unix. Legacy configs with looser permissions are tightened on load.
108
- - `--endpoint` values are parsed through `new URL()` and required to use `https://` except for `localhost` / `127.0.0.1` / `*.local`.
109
- - The `--api-key` flag leaks into `ps -ef` — prefer the interactive prompt on shared machines.
110
- - Full stack traces on error: `DEBUG=mushi mushi init`.
443
+ See [CHANGELOG.md](../../CHANGELOG.md) for release history.
111
444
 
112
445
  ## License
113
446
 
@@ -0,0 +1,6 @@
1
+ // src/version.ts
2
+ var MUSHI_CLI_VERSION = true ? "0.8.0" : "0.0.0-dev";
3
+
4
+ export {
5
+ MUSHI_CLI_VERSION
6
+ };