@mushi-mushi/cli 0.40.1 → 0.40.3

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/dist/init.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FrameworkId } from './detect.js';
1
+ import { Framework, PackageManager, FrameworkId } from './detect.js';
2
2
 
3
3
  /**
4
4
  * FILE: packages/cli/src/config.ts
@@ -102,6 +102,29 @@ declare function mintProjectKey(endpoint: string, cliToken: string, projectId: s
102
102
  label?: string;
103
103
  }): Promise<string>;
104
104
 
105
+ /**
106
+ * FILE: packages/cli/src/freshness.ts
107
+ * PURPOSE: Best-effort "there's a newer version" hint on wizard start.
108
+ *
109
+ * Matches the pattern used by `create-next-app` and `sentry-wizard`. Users
110
+ * who run `npx mushi-mushi` often hit a cached launcher for days — we
111
+ * politely suggest the upgrade path but never block the wizard.
112
+ *
113
+ * - 2s timeout, fails silent on network errors
114
+ * - Opt out via MUSHI_NO_UPDATE_CHECK=1
115
+ * - Uses a naive semver compare, no extra deps
116
+ */
117
+ interface FreshnessResult {
118
+ current: string;
119
+ latest: string;
120
+ isOutdated: boolean;
121
+ }
122
+ declare function checkFreshness(packageName: string, currentVersion: string, opts?: {
123
+ timeoutMs?: number;
124
+ registry?: string;
125
+ ignoreOptOut?: boolean;
126
+ }): Promise<FreshnessResult | null>;
127
+
105
128
  /**
106
129
  * FILE: packages/cli/src/init.ts
107
130
  * PURPOSE: `mushi init` wizard — detects framework, asks for credentials,
@@ -122,7 +145,23 @@ interface InitOptions {
122
145
  sendTestReport?: boolean;
123
146
  /** Audit an existing install (doctor checks) instead of running the wizard. */
124
147
  audit?: boolean;
148
+ /** Print what the wizard would do and stop: no files, no install, no sign-in. */
149
+ dryRun?: boolean;
150
+ /**
151
+ * Which package to check for a newer version. The `mushi-mushi` and
152
+ * `create-mushi-mushi` bins pass their own; `mushi init` defaults to the CLI.
153
+ */
154
+ freshness?: FreshnessSource;
125
155
  }
156
+ /** A package and the version of it that is running, for the "newer version" hint. */
157
+ interface FreshnessSource {
158
+ packageName: string;
159
+ version: string;
160
+ /** What to run to get the newest version. */
161
+ upgradeCommand: string;
162
+ }
163
+ /** `mushi init` run straight from the CLI: compare the CLI with the CLI. */
164
+ declare const CLI_FRESHNESS_SOURCE: FreshnessSource;
126
165
  /**
127
166
  * The keys the wizard ends up with, one per destination. `sdkKey` goes into
128
167
  * the app's env vars, which ship inside the bundle the end user downloads, so
@@ -216,5 +255,101 @@ declare function isEnvFileCoveredByGitignore(gitignoreContent: string, envFile:
216
255
  * without a browser sign-in.
217
256
  */
218
257
  declare function planCliConfigUpdate(existing: CliConfig, credentials: WizardCredentials, endpoint: string): CliConfig;
258
+ /**
259
+ * Where the init snippet goes for a framework: the injectable entry file that
260
+ * exists, or the file named in the snippet's first comment for a human to
261
+ * edit. Read-only; the caller decides whether to write `next`.
262
+ */
263
+ type SnippetPlan = {
264
+ kind: 'inject';
265
+ /** Path relative to the app root, e.g. `src/main.ts`. */
266
+ file: string;
267
+ abs: string;
268
+ /** The file's content with the marker block added or refreshed. */
269
+ next: string;
270
+ alreadyInjected: boolean;
271
+ /** The block is already there and up to date: nothing to write. */
272
+ unchanged: boolean;
273
+ } | {
274
+ kind: 'manual';
275
+ /** Where to paste the snippet, from its first comment line. */
276
+ target: string;
277
+ };
278
+ /**
279
+ * The file a framework's snippet says it belongs in ("src/main.tsx",
280
+ * "app/providers.tsx (or pages/_app.tsx …)"), from its first `//` comment.
281
+ * @internal Exported for tests only.
282
+ */
283
+ declare function snippetTarget(framework: Framework): string;
284
+ /**
285
+ * Plan the snippet edit with the same idempotent marker injection for every
286
+ * mode. Only frameworks in ENTRY_CANDIDATES (a plain top-of-file import) are
287
+ * ever edited; JSX providers have to wrap the render tree, which stays a
288
+ * human edit.
289
+ */
290
+ declare function planSnippetInjection(cwd: string, framework: Framework): Promise<SnippetPlan>;
291
+ /** What happened to the init snippet, for the next-steps checklist. */
292
+ type SnippetOutcome = {
293
+ kind: 'written';
294
+ file: string;
295
+ } | {
296
+ kind: 'manual';
297
+ target: string;
298
+ };
299
+ /**
300
+ * Put the init snippet in the entry file when that is safe (see
301
+ * planSnippetInjection). Interactive runs ask first; `--yes` runs apply it
302
+ * without asking, since the edit is a marker block a re-run replaces. When
303
+ * nothing can be edited, say exactly which file to paste into.
304
+ * @internal Exported for tests only.
305
+ */
306
+ declare function applySnippetPlan(plan: SnippetPlan, opts: {
307
+ yes: boolean;
308
+ confirm: (message: string) => Promise<boolean>;
309
+ }): Promise<SnippetOutcome>;
310
+ /**
311
+ * The "newer version" line, or null. Compares a package with its own latest
312
+ * on npm: the launcher with the launcher, the CLI with the CLI. (Comparing
313
+ * the CLI's 0.x with the launcher's 1.x warned on every run, even @latest.)
314
+ * A dev build has no published version to compare, so it never warns.
315
+ * @internal Exported for tests only.
316
+ */
317
+ declare function freshnessHint(source: FreshnessSource, check?: typeof checkFreshness): Promise<string | null>;
318
+ /**
319
+ * True when the CLI config will hold only the app's ingest key, so the
320
+ * stdio MCP server (which reads that config) would start in setup mode.
321
+ * A key kept from an earlier sign-in is assumed to be the login key.
322
+ * @internal Exported for tests only.
323
+ */
324
+ declare function needsEditorKey(saved: Pick<CliConfig, 'apiKey'>, credentials: WizardCredentials): boolean;
325
+ /**
326
+ * The smallest code that sends a real bug report from the user's own app,
327
+ * so the first report they see came from their app, not from this terminal.
328
+ * Printed only: the wizard never adds a page or button to the app.
329
+ */
330
+ declare function sampleBugSnippet(framework: FrameworkId): string;
331
+ /** Inputs for planInitDryRun, gathered with read-only checks. */
332
+ interface DryRunInput {
333
+ cwd: string;
334
+ framework: Framework;
335
+ /** How the framework was chosen. */
336
+ frameworkSource: 'flag' | 'detected';
337
+ pm: PackageManager;
338
+ hasPackageJson: boolean;
339
+ endpoint: string;
340
+ options: Pick<InitOptions, 'projectId' | 'apiKey' | 'skipInstall' | 'sendTestReport' | 'yes'>;
341
+ /** What a previous sign-in saved. Only presence and the project id are used. */
342
+ saved: {
343
+ projectId?: string;
344
+ hasKey: boolean;
345
+ };
346
+ snippet: SnippetPlan;
347
+ }
348
+ /**
349
+ * What a real run would do, line by line. Reads the env file to tell "add"
350
+ * from "update", and writes nothing.
351
+ * @internal Exported for tests only.
352
+ */
353
+ declare function planInitDryRun(input: DryRunInput): string[];
219
354
 
220
- export { type InitOptions, type SavedCredentialsResolution, type WizardCredentials, type WizardMintDeps, type WizardMintResult, type WizardMintTarget, isEnvFileCoveredByGitignore, mintWizardKeys, planCliConfigUpdate, resolveSavedCredentials, runInit, sanitizeSecret };
355
+ export { CLI_FRESHNESS_SOURCE, type DryRunInput, type FreshnessSource, type InitOptions, type SavedCredentialsResolution, type SnippetOutcome, type SnippetPlan, type WizardCredentials, type WizardMintDeps, type WizardMintResult, type WizardMintTarget, applySnippetPlan, freshnessHint, isEnvFileCoveredByGitignore, mintWizardKeys, needsEditorKey, planCliConfigUpdate, planInitDryRun, planSnippetInjection, resolveSavedCredentials, runInit, sampleBugSnippet, sanitizeSecret, snippetTarget };
package/dist/init.js CHANGED
@@ -1,20 +1,37 @@
1
1
  import {
2
+ CLI_FRESHNESS_SOURCE,
3
+ applySnippetPlan,
4
+ freshnessHint,
2
5
  isEnvFileCoveredByGitignore,
3
6
  mintWizardKeys,
7
+ needsEditorKey,
4
8
  planCliConfigUpdate,
9
+ planInitDryRun,
10
+ planSnippetInjection,
5
11
  resolveSavedCredentials,
6
12
  runInit,
7
- sanitizeSecret
8
- } from "./chunk-RH5VBBIV.js";
9
- import "./chunk-KIWSPGQB.js";
10
- import "./chunk-CP57NSIY.js";
13
+ sampleBugSnippet,
14
+ sanitizeSecret,
15
+ snippetTarget
16
+ } from "./chunk-6ZQFL7SD.js";
17
+ import "./chunk-LFP3NPZT.js";
18
+ import "./chunk-JXGVZWRL.js";
19
+ import "./chunk-LWFREQOK.js";
11
20
  import "./chunk-AWASJDQI.js";
12
21
  import "./chunk-2DMHQVRU.js";
13
22
  export {
23
+ CLI_FRESHNESS_SOURCE,
24
+ applySnippetPlan,
25
+ freshnessHint,
14
26
  isEnvFileCoveredByGitignore,
15
27
  mintWizardKeys,
28
+ needsEditorKey,
16
29
  planCliConfigUpdate,
30
+ planInitDryRun,
31
+ planSnippetInjection,
17
32
  resolveSavedCredentials,
18
33
  runInit,
19
- sanitizeSecret
34
+ sampleBugSnippet,
35
+ sanitizeSecret,
36
+ snippetTarget
20
37
  };
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ ENTRY_CANDIDATES,
4
+ MUSHI_MARKER_END,
5
+ MUSHI_MARKER_START,
6
+ findSdkImport,
7
+ injectSnippet
8
+ } from "./chunk-ZDAN3RYF.js";
9
+ export {
10
+ ENTRY_CANDIDATES,
11
+ MUSHI_MARKER_END,
12
+ MUSHI_MARKER_START,
13
+ findSdkImport,
14
+ injectSnippet
15
+ };
@@ -0,0 +1,14 @@
1
+ import {
2
+ ENTRY_CANDIDATES,
3
+ MUSHI_MARKER_END,
4
+ MUSHI_MARKER_START,
5
+ findSdkImport,
6
+ injectSnippet
7
+ } from "./chunk-LFP3NPZT.js";
8
+ export {
9
+ ENTRY_CANDIDATES,
10
+ MUSHI_MARKER_END,
11
+ MUSHI_MARKER_START,
12
+ findSdkImport,
13
+ injectSnippet
14
+ };
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  MUSHI_CLI_VERSION,
4
4
  MUSHI_MCP_PIN_SPEC
5
- } from "./chunk-KQHEYAEK.js";
5
+ } from "./chunk-ZVNRKEVP.js";
6
6
  export {
7
7
  MUSHI_CLI_VERSION,
8
8
  MUSHI_MCP_PIN_SPEC
package/dist/version.d.ts CHANGED
@@ -14,6 +14,6 @@ declare const MUSHI_CLI_VERSION: string;
14
14
  * setup refreshes the pin. Synced to packages/mcp/package.json by
15
15
  * `scripts/sync-mcp-pin.mjs` — never hand-edit the version.
16
16
  */
17
- declare const MUSHI_MCP_PIN_SPEC = "@mushi-mushi/mcp@0.31.3";
17
+ declare const MUSHI_MCP_PIN_SPEC = "@mushi-mushi/mcp@0.31.5";
18
18
 
19
19
  export { MUSHI_CLI_VERSION, MUSHI_MCP_PIN_SPEC };
package/dist/version.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MUSHI_CLI_VERSION,
3
3
  MUSHI_MCP_PIN_SPEC
4
- } from "./chunk-CP57NSIY.js";
4
+ } from "./chunk-LWFREQOK.js";
5
5
  export {
6
6
  MUSHI_CLI_VERSION,
7
7
  MUSHI_MCP_PIN_SPEC
@@ -53,6 +53,8 @@ interface ParsedArgs {
53
53
  cwd?: string;
54
54
  endpoint?: string;
55
55
  audit?: boolean;
56
+ /** `--dry-run`: print what the wizard would do; change nothing. */
57
+ dryRun?: boolean;
56
58
  /** `--template <id>`: scaffold a starter app instead of running the wizard. */
57
59
  template?: TemplateId;
58
60
  /** Optional directory right after the template id. */
@@ -7,7 +7,7 @@ import {
7
7
  isUnknownTopLevelCommand,
8
8
  newAppHint,
9
9
  parseArgs
10
- } from "./chunk-TNTSV54C.js";
10
+ } from "./chunk-4JF7C3MY.js";
11
11
  import "./chunk-AWASJDQI.js";
12
12
  export {
13
13
  FLAGS_HELP,
@@ -26,7 +26,13 @@ interface WizardBinOptions {
26
26
  */
27
27
  usage: string;
28
28
  }
29
+ /**
30
+ * How to run the newest wizard from a given bin: `create-mushi-mushi` runs
31
+ * through `npm create`, the others through `npx`.
32
+ * @internal Exported for tests only.
33
+ */
34
+ declare function wizardUpgradeCommand(bin: string): string;
29
35
  /** Run a bin's argv (`process.argv.slice(2)`), printing failures and exiting 1. */
30
36
  declare function runWizardBin(argv: readonly string[], opts: WizardBinOptions): Promise<void>;
31
37
 
32
- export { type WizardBinOptions, runWizardBin };
38
+ export { type WizardBinOptions, runWizardBin, wizardUpgradeCommand };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runInit
3
- } from "./chunk-RH5VBBIV.js";
3
+ } from "./chunk-6ZQFL7SD.js";
4
4
  import {
5
5
  FLAGS_HELP,
6
6
  UNKNOWN_COMMAND_EXIT,
@@ -9,9 +9,10 @@ import {
9
9
  newAppHint,
10
10
  parseArgs,
11
11
  scaffoldTemplate
12
- } from "./chunk-TNTSV54C.js";
13
- import "./chunk-KIWSPGQB.js";
14
- import "./chunk-CP57NSIY.js";
12
+ } from "./chunk-4JF7C3MY.js";
13
+ import "./chunk-LFP3NPZT.js";
14
+ import "./chunk-JXGVZWRL.js";
15
+ import "./chunk-LWFREQOK.js";
15
16
  import "./chunk-AWASJDQI.js";
16
17
  import "./chunk-2DMHQVRU.js";
17
18
 
@@ -83,9 +84,20 @@ ${FLAGS_HELP}
83
84
  cwd: parsed.cwd,
84
85
  endpoint: parsed.endpoint,
85
86
  sendTestReport: parsed.skipTestReport ? false : void 0,
86
- audit: parsed.audit
87
+ audit: parsed.audit,
88
+ dryRun: parsed.dryRun,
89
+ // Compare this bin's own version with its own latest on npm; the CLI's
90
+ // version (0.x) against the launcher's (1.x) warned on every run.
91
+ freshness: {
92
+ packageName: opts.bin,
93
+ version: opts.version,
94
+ upgradeCommand: wizardUpgradeCommand(opts.bin)
95
+ }
87
96
  });
88
97
  }
98
+ function wizardUpgradeCommand(bin) {
99
+ return bin.startsWith("create-") ? `npm create ${bin.slice("create-".length)}@latest` : `npx ${bin}@latest`;
100
+ }
89
101
  function runWizardBin(argv, opts) {
90
102
  return main(argv, opts).catch((err) => {
91
103
  const message = err instanceof Error ? err.message : String(err);
@@ -102,5 +114,6 @@ If this is a bug, please report it at ${ISSUES_URL}
102
114
  });
103
115
  }
104
116
  export {
105
- runWizardBin
117
+ runWizardBin,
118
+ wizardUpgradeCommand
106
119
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mushi-mushi/cli",
3
- "version": "0.40.1",
3
+ "version": "0.40.3",
4
4
  "license": "MIT",
5
5
  "description": "Mushi Mushi CLI: SDK setup, MCP wiring, triage. One place to improve AI-built apps: fix bugs, smooth user journeys and clean up the code.",
6
6
  "bin": {
@@ -1,8 +0,0 @@
1
- // src/version.ts
2
- var MUSHI_CLI_VERSION = true ? "0.40.1" : "0.0.0-dev";
3
- var MUSHI_MCP_PIN_SPEC = "@mushi-mushi/mcp@0.31.3";
4
-
5
- export {
6
- MUSHI_CLI_VERSION,
7
- MUSHI_MCP_PIN_SPEC
8
- };
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/version.ts
4
- var MUSHI_CLI_VERSION = true ? "0.40.1" : "0.0.0-dev";
5
- var MUSHI_MCP_PIN_SPEC = "@mushi-mushi/mcp@0.31.3";
6
-
7
- export {
8
- MUSHI_CLI_VERSION,
9
- MUSHI_MCP_PIN_SPEC
10
- };