@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/README.md CHANGED
@@ -60,7 +60,7 @@ mushi init --yes --project-id <uuid> --api-key mushi_xxx --skip-test-report
60
60
  MUSHI_API_KEY=mushi_xxx mushi connect --project-id <uuid> --endpoint <url> --wait # wire a repo, wait for the first SDK heartbeat
61
61
  ```
62
62
 
63
- Other `init` flags: `--framework next`, `--cwd apps/web` (monorepos), `--endpoint <url>` (self-hosted), `--skip-install`, `--audit` (check an existing install instead).
63
+ Other `init` flags: `--framework next`, `--cwd apps/web` (monorepos), `--endpoint <url>` (self-hosted), `--skip-install`, `--audit` (check an existing install instead), `--dry-run` (show what it would install and write, change nothing).
64
64
 
65
65
  **What needs your own key.** Reading reports, diagnoses and fix prompts does not. `mushi fix` hands the report to the built-in fixer by default (`--agent claude_code`): it uses your own Anthropic or OpenAI key when you have added one, and on hosted Mushi Mushi it falls back to Mushi Mushi's key when you have not. `--agent cursor_cloud` needs your own Cursor key. `mushi work` runs the Cursor CLI or Claude Code (`--agent claude`, CLI 0.36.0 or later) on your own computer instead, on the account that tool is signed in to.
66
66
 
@@ -54,6 +54,8 @@ Flags (forwarded to the wizard):
54
54
  --skip-install print the install command instead of running it
55
55
  --skip-test-report don't offer to send a test report at the end
56
56
  --audit health-check an existing install (doctor checks) instead of re-running the wizard
57
+ --dry-run print what the wizard would install and write, then stop (changes nothing,
58
+ no sign-in)
57
59
  --cwd <path> run in a different directory
58
60
  --endpoint <url> override the Mushi API endpoint (self-hosted)
59
61
  -y, --yes take the defaults: detected framework, saved credentials, browser sign-in
@@ -95,6 +97,10 @@ function parseArgs(argv) {
95
97
  out.audit = true;
96
98
  continue;
97
99
  }
100
+ if (a === "--dry-run") {
101
+ out.dryRun = true;
102
+ continue;
103
+ }
98
104
  if (a === "--project-id") {
99
105
  out.projectId = args[++i];
100
106
  continue;
@@ -8,10 +8,10 @@ import {
8
8
  requireConfig,
9
9
  requireUuid,
10
10
  tryLoadWorkerKey
11
- } from "./chunk-QKO42UPX.js";
11
+ } from "./chunk-CGQE3GJK.js";
12
12
  import {
13
13
  MUSHI_CLI_VERSION
14
- } from "./chunk-KQHEYAEK.js";
14
+ } from "./chunk-ZVNRKEVP.js";
15
15
 
16
16
  // src/worker/daemon.ts
17
17
  import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
@@ -1613,7 +1613,7 @@ function registerWorkCommands(program) {
1613
1613
  if (opts.repoDir || opts.report || opts.followups || opts.recheck) {
1614
1614
  throw new MushiCliError("E_INVALID_INPUT", "--daemon takes its lanes and clones from the worker config, not from --repo-dir, --report or --followups.", "mushi worker install");
1615
1615
  }
1616
- const { runDaemon: runDaemon2 } = await import("./daemon-JX6IG454.js");
1616
+ const { runDaemon: runDaemon2 } = await import("./daemon-PPOAKQNF.js");
1617
1617
  await runDaemon2({ configPath: opts.workerConfig, ...opts.agent !== void 0 ? { agent } : {}, ...opts.anyRepo ? { anyRepo: true } : {} });
1618
1618
  return;
1619
1619
  }
@@ -1,3 +1,8 @@
1
+ import {
2
+ ENTRY_CANDIDATES,
3
+ MUSHI_MARKER_START,
4
+ injectSnippet
5
+ } from "./chunk-LFP3NPZT.js";
1
6
  import {
2
7
  CLI_KEY_LABEL,
3
8
  CLI_KEY_SCOPES,
@@ -9,11 +14,13 @@ import {
9
14
  cliSetupDeepLink,
10
15
  consoleUrl,
11
16
  describeUnsafeSdkKey,
17
+ editorKeyCommand,
12
18
  ensureClientId,
13
19
  fetchIngestSetup,
14
20
  loadConfig,
15
21
  maybeShowTelemetryNotice,
16
22
  openInBrowser,
23
+ peekConfig,
17
24
  probeKeyScope,
18
25
  projectIdHint,
19
26
  reportsUrl,
@@ -25,10 +32,10 @@ import {
25
32
  saveConfig,
26
33
  savedSdkKeyFor,
27
34
  trySaveKeyToKeychain
28
- } from "./chunk-KIWSPGQB.js";
35
+ } from "./chunk-JXGVZWRL.js";
29
36
  import {
30
37
  MUSHI_CLI_VERSION
31
- } from "./chunk-CP57NSIY.js";
38
+ } from "./chunk-LWFREQOK.js";
32
39
  import {
33
40
  FRAMEWORKS,
34
41
  detectFramework,
@@ -1316,7 +1323,7 @@ async function runDoctor(config, options = {}) {
1316
1323
  }
1317
1324
  if (sdkCheck) checks.push(sdkCheck);
1318
1325
  if (sdkCheck?.ok && !sdkCheck.warn) {
1319
- const { findSdkImport } = await import("./snippet-inject-AVGVHTUJ.js");
1326
+ const { findSdkImport } = await import("./snippet-inject-CSXHMN7P.js");
1320
1327
  const imported = await findSdkImport(options.cwd ?? process.cwd());
1321
1328
  checks.push(
1322
1329
  imported ? { name: "SDK init snippet wired", ok: true, detail: `Found SDK usage in ${imported.file}` } : {
@@ -1408,6 +1415,11 @@ ${failed.length} check${failed.length === 1 ? "" : "s"} failed.`);
1408
1415
 
1409
1416
  // src/init.ts
1410
1417
  var NATIVE_FRAMEWORK_IDS = /* @__PURE__ */ new Set(["expo", "react-native", "capacitor"]);
1418
+ var CLI_FRESHNESS_SOURCE = {
1419
+ packageName: "@mushi-mushi/cli",
1420
+ version: MUSHI_CLI_VERSION,
1421
+ upgradeCommand: "mushi upgrade --self"
1422
+ };
1411
1423
  var ENV_FILES = [".env.local", ".env"];
1412
1424
  function isInteractive() {
1413
1425
  return Boolean(process.stdin.isTTY && process.stdout.isTTY);
@@ -1420,10 +1432,14 @@ async function runInit(options = {}) {
1420
1432
  await runInitAudit(cwd);
1421
1433
  return;
1422
1434
  }
1435
+ if (options.dryRun) {
1436
+ await runInitDryRun(cwd, options);
1437
+ return;
1438
+ }
1423
1439
  ensureInteractiveOrBailOut(options);
1424
1440
  if (!isInteractive()) options = { ...options, yes: true };
1425
1441
  p.intro("Mushi setup");
1426
- await printFreshnessHint();
1442
+ await printFreshnessHint(options.freshness);
1427
1443
  warnIfWorkspaceRoot(cwd);
1428
1444
  const pkg = readPackageJson(cwd);
1429
1445
  maybeSuggestAudit(pkg);
@@ -1474,10 +1490,13 @@ async function runInit(options = {}) {
1474
1490
  }
1475
1491
  persistCliConfig(credentials, endpoint);
1476
1492
  emitWizardFunnelEvent(credentials, endpoint, "wizard_env_written", { framework: framework.id });
1493
+ await ensureEditorKey(credentials, options, endpoint);
1477
1494
  const enableRewards = await maybeEnableRewards(options);
1478
- await maybeInjectSnippet(cwd, framework, options);
1479
- printNextSteps(framework, consoleBase, enableRewards);
1495
+ const snippet = await maybeInjectSnippet(cwd, framework, options);
1496
+ printNextSteps(framework, consoleBase, enableRewards, snippet);
1480
1497
  await maybeSendTestReport(credentials, { ...options, endpoint, consoleBase });
1498
+ p.note(sampleBugSnippet(framework.id), "Send a sample bug from your app:");
1499
+ p.log.info("No code change: `npx mushi-mushi test` sends one from this terminal.");
1481
1500
  await maybeOfferConnect(credentials, options, consoleBase);
1482
1501
  p.outro("Setup complete.");
1483
1502
  }
@@ -2074,33 +2093,67 @@ function emitWizardFunnelEvent(credentials, endpoint, event, metadata = {}) {
2074
2093
  }).catch(() => {
2075
2094
  });
2076
2095
  }
2077
- async function maybeInjectSnippet(cwd, framework, options) {
2078
- if (options.yes || !process.stdin.isTTY) return;
2079
- const { ENTRY_CANDIDATES, injectSnippet, MUSHI_MARKER_START } = await import("./snippet-inject-AVGVHTUJ.js");
2080
- const candidates = ENTRY_CANDIDATES[framework.id];
2081
- if (!candidates) return;
2082
- const { readFile, writeFile } = await import("fs/promises");
2083
- const nodePath = await import("path");
2096
+ function snippetTarget(framework) {
2097
+ const comment = framework.snippet().split("\n").map((l) => l.trim()).find((l) => l.startsWith("//"));
2098
+ const text2 = comment?.replace(/^\/\/\s*/, "").trim();
2099
+ return text2 && text2.length > 0 ? text2 : "your app entry file";
2100
+ }
2101
+ async function planSnippetInjection(cwd, framework) {
2102
+ const candidates = ENTRY_CANDIDATES[framework.id] ?? [];
2103
+ const { readFile } = await import("fs/promises");
2084
2104
  for (const rel of candidates) {
2085
- const abs = nodePath.join(cwd, rel);
2105
+ const abs = join2(cwd, rel);
2086
2106
  let source;
2087
2107
  try {
2088
2108
  source = await readFile(abs, "utf8");
2089
2109
  } catch {
2090
2110
  continue;
2091
2111
  }
2092
- const alreadyInjected = source.includes(MUSHI_MARKER_START);
2093
- const confirmed = await p.confirm({
2094
- message: alreadyInjected ? `Refresh the Mushi init block in ${rel}?` : `Add the Mushi init snippet to ${rel}? (wrapped in markers; re-runs update in place)`
2095
- });
2096
- if (p.isCancel(confirmed) || !confirmed) return;
2097
- await writeFile(abs, injectSnippet(source, framework.snippet()), "utf8");
2098
- p.log.success(`${alreadyInjected ? "Updated" : "Added"} Mushi init block in ${rel}`);
2099
- return;
2112
+ const next = injectSnippet(source, framework.snippet());
2113
+ return {
2114
+ kind: "inject",
2115
+ file: rel,
2116
+ abs,
2117
+ next,
2118
+ alreadyInjected: source.includes(MUSHI_MARKER_START),
2119
+ unchanged: next === source
2120
+ };
2121
+ }
2122
+ return { kind: "manual", target: snippetTarget(framework) };
2123
+ }
2124
+ async function applySnippetPlan(plan, opts) {
2125
+ if (plan.kind === "manual") return plan;
2126
+ if (plan.unchanged) {
2127
+ p.log.info(`The Mushi Mushi init block in ${plan.file} is already up to date.`);
2128
+ return { kind: "written", file: plan.file };
2129
+ }
2130
+ if (!opts.yes) {
2131
+ const ok = await opts.confirm(
2132
+ plan.alreadyInjected ? `Refresh the Mushi Mushi init block in ${plan.file}?` : `Add the Mushi Mushi init snippet to ${plan.file}? (wrapped in markers; re-runs update in place)`
2133
+ );
2134
+ if (!ok) return { kind: "manual", target: plan.file };
2135
+ }
2136
+ const { writeFile } = await import("fs/promises");
2137
+ await writeFile(plan.abs, plan.next, "utf8");
2138
+ p.log.success(`${plan.alreadyInjected ? "Updated" : "Added"} the Mushi Mushi init block in ${plan.file}`);
2139
+ return { kind: "written", file: plan.file };
2140
+ }
2141
+ async function maybeInjectSnippet(cwd, framework, options) {
2142
+ const plan = await planSnippetInjection(cwd, framework);
2143
+ const outcome = await applySnippetPlan(plan, {
2144
+ yes: Boolean(options.yes) || !isInteractive(),
2145
+ confirm: async (message) => {
2146
+ const answer = await p.confirm({ message });
2147
+ return !p.isCancel(answer) && Boolean(answer);
2148
+ }
2149
+ });
2150
+ if (outcome.kind === "manual" && (options.yes || !isInteractive())) {
2151
+ p.log.info(`One edit left: paste the "Add this to your app" snippet below (${outcome.target}).`);
2100
2152
  }
2153
+ return outcome;
2101
2154
  }
2102
- function printNextSteps(framework, consoleBase, enableRewards = false) {
2103
- p.note(framework.snippet(), "Add this to your app:");
2155
+ function printNextSteps(framework, consoleBase, enableRewards = false, snippet = { kind: "manual", target: snippetTarget(framework) }) {
2156
+ p.note(framework.snippet(), snippet.kind === "written" ? `Added to ${snippet.file}:` : "Add this to your app:");
2104
2157
  if (enableRewards) {
2105
2158
  const badgeSnippet = framework.id === "react" ? `// Add to your user menu or profile UI:
2106
2159
  import { MushiRewardsBadge } from 'mushi-mushi/react';
@@ -2115,7 +2168,7 @@ import { MushiRewardsBadge } from 'mushi-mushi/react';
2115
2168
  }
2116
2169
  p.note(
2117
2170
  [
2118
- " [ ] 1. Paste the init snippet above into your app entry file",
2171
+ snippet.kind === "written" ? ` [x] 1. Init snippet added to ${snippet.file}` : ` [ ] 1. Paste the init snippet above (${snippet.target})`,
2119
2172
  " [ ] 2. Start your dev server",
2120
2173
  " [ ] 3. Wire your editor: npx mushi-mushi setup --ide cursor (or --ide claude)",
2121
2174
  ` [ ] 4. Open the Test it tab to send a test report: ${consoleUrl(consoleBase, "/onboarding?tab=verify")}`
@@ -2132,7 +2185,7 @@ async function maybeOfferConnect(credentials, options, _consoleBase) {
2132
2185
  if (p.isCancel(answer) || !answer) return;
2133
2186
  const endpoint = resolveCloudEndpoint(options.endpoint);
2134
2187
  try {
2135
- const { runConnect } = await import("./connect-Q6LFT6QA.js");
2188
+ const { runConnect } = await import("./connect-OJXHNDFB.js");
2136
2189
  const saved = loadConfig();
2137
2190
  const result = await runConnect(
2138
2191
  {
@@ -2236,12 +2289,185 @@ async function maybeSendTestReport(credentials, options) {
2236
2289
  clearTimeout(timer);
2237
2290
  }
2238
2291
  }
2239
- async function printFreshnessHint() {
2240
- const result = await checkFreshness("mushi-mushi", MUSHI_CLI_VERSION);
2241
- if (!result || !result.isOutdated) return;
2242
- p.log.info(
2243
- `A newer version of mushi-mushi is available: ${result.current} \u2192 ${result.latest}. Run \`npx mushi-mushi@latest\` to get the freshest wizard.`
2292
+ async function freshnessHint(source, check = checkFreshness) {
2293
+ if (!source.version || source.version === "0.0.0-dev") return null;
2294
+ const result = await check(source.packageName, source.version);
2295
+ if (!result || !result.isOutdated) return null;
2296
+ return `A newer version of ${source.packageName} is available: ${result.current} \u2192 ${result.latest}. Run \`${source.upgradeCommand}\` to get the newest wizard.`;
2297
+ }
2298
+ async function printFreshnessHint(source = CLI_FRESHNESS_SOURCE) {
2299
+ const hint = await freshnessHint(source);
2300
+ if (hint) p.log.info(hint);
2301
+ }
2302
+ function needsEditorKey(saved, credentials) {
2303
+ if (credentials.cliKey) return false;
2304
+ return !saved.apiKey || saved.apiKey === credentials.sdkKey;
2305
+ }
2306
+ async function ensureEditorKey(credentials, options, endpoint) {
2307
+ const saved = loadConfig();
2308
+ if (!needsEditorKey(saved, credentials)) return;
2309
+ const command = editorKeyCommand(credentials.projectId);
2310
+ const why = "Your editor's MCP server needs a key that can read reports; the app's key can only send them.";
2311
+ if (options.yes || !isInteractive()) {
2312
+ p.log.info(`${why} To get one, run: ${command}`);
2313
+ return;
2314
+ }
2315
+ const answer = await p.confirm({
2316
+ message: `${why} Approve one more browser sign-in to make it now?`,
2317
+ initialValue: true
2318
+ });
2319
+ if (p.isCancel(answer) || !answer) {
2320
+ p.log.info(`Later: ${command}`);
2321
+ return;
2322
+ }
2323
+ const key = await mintEditorKey(endpoint, credentials.projectId);
2324
+ if (!key) {
2325
+ p.log.warn(`No editor key was made. Run it yourself: ${command}`);
2326
+ return;
2327
+ }
2328
+ saveConfig({ ...loadConfig(), apiKey: key });
2329
+ trySaveKeyToKeychain(key, resolveProfileName());
2330
+ credentials.cliKey = key;
2331
+ p.log.success("Editor key saved to the CLI config (report:write + mcp:read). Restart your editor to use it.");
2332
+ }
2333
+ async function mintEditorKey(endpoint, projectId) {
2334
+ let session;
2335
+ try {
2336
+ session = await startDeviceAuth(endpoint, ensureClientId());
2337
+ } catch (err) {
2338
+ p.log.warn(err instanceof Error ? err.message : String(err));
2339
+ return null;
2340
+ }
2341
+ try {
2342
+ await openInBrowser(session.verification_uri);
2343
+ } catch {
2344
+ }
2345
+ printAuthBanner(session.user_code, session.verification_uri);
2346
+ const spin = p.spinner();
2347
+ spin.start("Waiting for you to approve in the browser\u2026");
2348
+ try {
2349
+ const cliToken = await waitForCliToken(endpoint, session);
2350
+ const key = await mintProjectKey(endpoint, cliToken, projectId, {
2351
+ scopes: CLI_KEY_SCOPES,
2352
+ label: CLI_KEY_LABEL
2353
+ });
2354
+ spin.stop("Approved.");
2355
+ return key;
2356
+ } catch (err) {
2357
+ spin.stop("Browser sign-in didn't complete.");
2358
+ p.log.warn(err instanceof Error ? err.message : String(err));
2359
+ return null;
2360
+ }
2361
+ }
2362
+ var WEB_SAMPLE_BUG = `// In any click handler (every web adapter shares this one SDK instance):
2363
+ import { Mushi } from 'mushi-mushi'
2364
+
2365
+ Mushi.getInstance()?.captureException(new Error('Sample bug from Mushi Mushi setup'))`;
2366
+ var NODE_SAMPLE_BUG = `// Anywhere in your server code, e.g. a test route:
2367
+ import { mushi } from './instrument'
2368
+
2369
+ await mushi.captureException(new Error('Sample bug from Mushi Mushi setup'))`;
2370
+ var NATIVE_SAMPLE_BUG = `// In any component inside <MushiProvider>, e.g. a button's onPress:
2371
+ import { useMushi } from '@mushi-mushi/react-native'
2372
+
2373
+ const mushi = useMushi()
2374
+ mushi.submitReport({ description: 'Sample bug from Mushi Mushi setup', category: 'bug' })`;
2375
+ var CAPACITOR_SAMPLE_BUG = `// Anywhere after Mushi.configure(...):
2376
+ import { Mushi } from '@mushi-mushi/capacitor'
2377
+
2378
+ await Mushi.report({ description: 'Sample bug from Mushi Mushi setup', category: 'bug' })`;
2379
+ var SAMPLE_BUG_SNIPPETS = {
2380
+ next: WEB_SAMPLE_BUG,
2381
+ react: WEB_SAMPLE_BUG,
2382
+ cra: WEB_SAMPLE_BUG,
2383
+ remix: WEB_SAMPLE_BUG,
2384
+ astro: WEB_SAMPLE_BUG,
2385
+ solid: WEB_SAMPLE_BUG,
2386
+ vue: WEB_SAMPLE_BUG,
2387
+ nuxt: WEB_SAMPLE_BUG,
2388
+ svelte: WEB_SAMPLE_BUG,
2389
+ sveltekit: WEB_SAMPLE_BUG,
2390
+ angular: WEB_SAMPLE_BUG,
2391
+ vanilla: WEB_SAMPLE_BUG,
2392
+ expo: NATIVE_SAMPLE_BUG,
2393
+ "react-native": NATIVE_SAMPLE_BUG,
2394
+ capacitor: CAPACITOR_SAMPLE_BUG,
2395
+ express: NODE_SAMPLE_BUG,
2396
+ fastify: NODE_SAMPLE_BUG,
2397
+ hono: NODE_SAMPLE_BUG
2398
+ };
2399
+ function sampleBugSnippet(framework) {
2400
+ return SAMPLE_BUG_SNIPPETS[framework];
2401
+ }
2402
+ function planInitDryRun(input) {
2403
+ const { framework, options } = input;
2404
+ const lines = [];
2405
+ if (!input.hasPackageJson) {
2406
+ lines.push("No package.json here: a real run stops (or asks first). Run from your app folder, or pass --cwd.");
2407
+ }
2408
+ lines.push(
2409
+ `Framework: ${framework.label}${input.frameworkSource === "flag" ? " (from --framework)" : " (detected)"}`
2410
+ );
2411
+ if (options.projectId && options.apiKey) {
2412
+ lines.push("Credentials: use --project-id and --api-key (checked first: the key must be ingest-only).");
2413
+ } else if (input.saved.projectId && input.saved.hasKey) {
2414
+ lines.push(
2415
+ `Credentials: reuse your saved sign-in (project ${input.saved.projectId.slice(0, 8)}\u2026), or open a browser sign-in if those keys no longer work.`
2416
+ );
2417
+ } else {
2418
+ lines.push(
2419
+ "Credentials: open a browser sign-in. You approve once; it picks or creates the project and makes two keys: an ingest-only key for the app and a read key for your editor's MCP server."
2420
+ );
2421
+ }
2422
+ const packages = framework.needsWebPackage ? [framework.packageName, "mushi-mushi"] : [framework.packageName];
2423
+ const command = installCommand(input.pm, packages);
2424
+ lines.push(options.skipInstall ? `Install: skipped (--skip-install); you run \`${command}\`` : `Install: ${command}`);
2425
+ const envFile = ENV_FILES.find((f) => existsSync2(join2(input.cwd, f))) ?? ENV_FILES[0];
2426
+ const names = envVarsToWrite("<key>", "<id>", framework, input.endpoint).split("\n").map((l) => l.split("=")[0]).filter(Boolean);
2427
+ let existingEnv = "";
2428
+ try {
2429
+ existingEnv = readFileSync2(join2(input.cwd, envFile), "utf-8");
2430
+ } catch {
2431
+ existingEnv = "";
2432
+ }
2433
+ lines.push(
2434
+ existingEnv.includes("MUSHI_PROJECT_ID") ? `Env: update the MUSHI_* lines in ${envFile} (${names.join(", ")})${options.yes ? "" : ", after asking"}` : `Env: add ${names.join(", ")} to ${envFile}`
2435
+ );
2436
+ lines.push("CLI config: save the keys to your private CLI config, outside the repo.");
2437
+ if (input.snippet.kind === "inject") {
2438
+ lines.push(
2439
+ input.snippet.unchanged ? `Snippet: ${input.snippet.file} already has the init block; no change.` : `Snippet: ${input.snippet.alreadyInjected ? "refresh" : "add"} the init block in ${input.snippet.file}` + (options.yes ? "" : ", after asking")
2440
+ );
2441
+ } else {
2442
+ lines.push(`Snippet: not edited automatically; you paste it in (${input.snippet.target}).`);
2443
+ }
2444
+ if (options.sendTestReport !== false) lines.push("Test report: send one test report to check the pipeline.");
2445
+ lines.push("Sample bug: print the one call that sends a bug from your own app.");
2446
+ return lines;
2447
+ }
2448
+ async function runInitDryRun(cwd, options) {
2449
+ p.intro("Mushi Mushi setup (dry run)");
2450
+ await printFreshnessHint(options.freshness);
2451
+ warnIfWorkspaceRoot(cwd);
2452
+ const pkg = readPackageJson(cwd);
2453
+ const framework = options.framework ? FRAMEWORKS[options.framework] : detectFramework(cwd, pkg);
2454
+ const config = peekConfig();
2455
+ const endpoint = resolveCloudEndpoint(
2456
+ firstEndpoint(options.endpoint, process.env.MUSHI_API_ENDPOINT, config.endpoint)
2244
2457
  );
2458
+ const lines = planInitDryRun({
2459
+ cwd,
2460
+ framework,
2461
+ frameworkSource: options.framework ? "flag" : "detected",
2462
+ pm: detectPackageManager(cwd),
2463
+ hasPackageJson: Boolean(pkg),
2464
+ endpoint,
2465
+ options,
2466
+ saved: { projectId: config.projectId, hasKey: Boolean(config.apiKey) },
2467
+ snippet: await planSnippetInjection(cwd, framework)
2468
+ });
2469
+ p.note(lines.map((l) => `\u2022 ${l}`).join("\n"), "A real run would:");
2470
+ p.outro("Dry run: nothing was changed. Run again without --dry-run to set up.");
2245
2471
  }
2246
2472
  function warnIfWorkspaceRoot(cwd) {
2247
2473
  let hint;
@@ -2270,10 +2496,18 @@ function isSameDirectory(a, b) {
2270
2496
  }
2271
2497
 
2272
2498
  export {
2499
+ CLI_FRESHNESS_SOURCE,
2273
2500
  runInit,
2274
2501
  resolveSavedCredentials,
2275
2502
  mintWizardKeys,
2276
2503
  sanitizeSecret,
2277
2504
  isEnvFileCoveredByGitignore,
2278
- planCliConfigUpdate
2505
+ planCliConfigUpdate,
2506
+ snippetTarget,
2507
+ planSnippetInjection,
2508
+ applySnippetPlan,
2509
+ freshnessHint,
2510
+ needsEditorKey,
2511
+ sampleBugSnippet,
2512
+ planInitDryRun
2279
2513
  };
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  MUSHI_CLI_VERSION
4
- } from "./chunk-KQHEYAEK.js";
4
+ } from "./chunk-ZVNRKEVP.js";
5
5
  import {
6
6
  CLOUD_API_ENDPOINT,
7
7
  normalizeEndpoint
@@ -290,6 +290,25 @@ function loadConfig(path = CONFIG_PATH, opts = {}) {
290
290
  };
291
291
  return { ...file, ...fromEnv };
292
292
  }
293
+ function peekConfig(path = CONFIG_PATH) {
294
+ let file = {};
295
+ try {
296
+ const parsed = JSON.parse(readFileSync(path, "utf-8"));
297
+ if (isMultiProfileFile(parsed)) {
298
+ file = parsed.profiles[resolveProfileName(void 0, parsed.activeProfile)] ?? {};
299
+ } else if (resolveProfileName(void 0, void 0) === DEFAULT_PROFILE) {
300
+ file = parsed ?? {};
301
+ }
302
+ } catch {
303
+ }
304
+ const endpointFromEnv = process.env["MUSHI_API_ENDPOINT"]?.trim() || process.env["MUSHI_ENDPOINT"]?.trim() || void 0;
305
+ return {
306
+ ...file,
307
+ ...process.env["MUSHI_API_KEY"] ? { apiKey: process.env["MUSHI_API_KEY"] } : {},
308
+ ...process.env["MUSHI_PROJECT_ID"] ? { projectId: process.env["MUSHI_PROJECT_ID"] } : {},
309
+ ...endpointFromEnv ? { endpoint: normalizeEndpoint(endpointFromEnv) } : {}
310
+ };
311
+ }
293
312
  function ensureClientId(path = CONFIG_PATH) {
294
313
  const existing = loadConfig(path);
295
314
  if (existing.clientId && /^[A-Za-z0-9_-]{8,64}$/.test(existing.clientId)) {
@@ -781,6 +800,7 @@ export {
781
800
  resolveProfileName,
782
801
  CONFIG_PATH,
783
802
  loadConfig,
803
+ peekConfig,
784
804
  ensureClientId,
785
805
  maybeShowTelemetryNotice,
786
806
  saveConfig,
@@ -9,10 +9,10 @@ import {
9
9
  requireUuid,
10
10
  saveConfig,
11
11
  savedSdkKeyFor
12
- } from "./chunk-QKO42UPX.js";
12
+ } from "./chunk-CGQE3GJK.js";
13
13
  import {
14
14
  MUSHI_MCP_PIN_SPEC
15
- } from "./chunk-KQHEYAEK.js";
15
+ } from "./chunk-ZVNRKEVP.js";
16
16
  import {
17
17
  assertEndpoint,
18
18
  normalizeEndpoint
@@ -137,6 +137,9 @@ async function waitForIngestReady(options) {
137
137
  var SDK_KEY_SCOPES = ["report:write"];
138
138
  var CLI_KEY_SCOPES = ["report:write", "mcp:read"];
139
139
  var FULL_CLI_KEY_SCOPES = ["report:write", "mcp:read", "mcp:write"];
140
+ function editorKeyCommand(projectId) {
141
+ return `npx mushi-mushi login${projectId ? ` --project-id ${projectId}` : ""}`;
142
+ }
140
143
  var SDK_KEY_LABEL = "sdk-ingest";
141
144
  var CLI_KEY_LABEL = "cli-login";
142
145
  async function probeKeyScope(endpoint, apiKey, projectId, doFetch = globalThis.fetch) {
@@ -409,6 +412,7 @@ export {
409
412
  SDK_KEY_SCOPES,
410
413
  CLI_KEY_SCOPES,
411
414
  FULL_CLI_KEY_SCOPES,
415
+ editorKeyCommand,
412
416
  SDK_KEY_LABEL,
413
417
  CLI_KEY_LABEL,
414
418
  probeKeyScope,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MUSHI_CLI_VERSION
3
- } from "./chunk-CP57NSIY.js";
3
+ } from "./chunk-LWFREQOK.js";
4
4
  import {
5
5
  assertEndpoint,
6
6
  normalizeEndpoint
@@ -124,6 +124,25 @@ function loadConfig(path = CONFIG_PATH, opts = {}) {
124
124
  };
125
125
  return { ...file, ...fromEnv };
126
126
  }
127
+ function peekConfig(path = CONFIG_PATH) {
128
+ let file = {};
129
+ try {
130
+ const parsed = JSON.parse(readFileSync(path, "utf-8"));
131
+ if (isMultiProfileFile(parsed)) {
132
+ file = parsed.profiles[resolveProfileName(void 0, parsed.activeProfile)] ?? {};
133
+ } else if (resolveProfileName(void 0, void 0) === DEFAULT_PROFILE) {
134
+ file = parsed ?? {};
135
+ }
136
+ } catch {
137
+ }
138
+ const endpointFromEnv = process.env["MUSHI_API_ENDPOINT"]?.trim() || process.env["MUSHI_ENDPOINT"]?.trim() || void 0;
139
+ return {
140
+ ...file,
141
+ ...process.env["MUSHI_API_KEY"] ? { apiKey: process.env["MUSHI_API_KEY"] } : {},
142
+ ...process.env["MUSHI_PROJECT_ID"] ? { projectId: process.env["MUSHI_PROJECT_ID"] } : {},
143
+ ...endpointFromEnv ? { endpoint: normalizeEndpoint(endpointFromEnv) } : {}
144
+ };
145
+ }
127
146
  function ensureClientId(path = CONFIG_PATH) {
128
147
  const existing = loadConfig(path);
129
148
  if (existing.clientId && /^[A-Za-z0-9_-]{8,64}$/.test(existing.clientId)) {
@@ -254,6 +273,9 @@ function tightenWindowsAcl(path, type) {
254
273
  // src/key-scopes.ts
255
274
  var SDK_KEY_SCOPES = ["report:write"];
256
275
  var CLI_KEY_SCOPES = ["report:write", "mcp:read"];
276
+ function editorKeyCommand(projectId) {
277
+ return `npx mushi-mushi login${projectId ? ` --project-id ${projectId}` : ""}`;
278
+ }
257
279
  var SDK_KEY_LABEL = "sdk-ingest";
258
280
  var CLI_KEY_LABEL = "cli-login";
259
281
  async function probeKeyScope(endpoint, apiKey, projectId, doFetch = globalThis.fetch) {
@@ -713,11 +735,13 @@ export {
713
735
  resolveProfileName,
714
736
  CONFIG_PATH,
715
737
  loadConfig,
738
+ peekConfig,
716
739
  ensureClientId,
717
740
  maybeShowTelemetryNotice,
718
741
  saveConfig,
719
742
  SDK_KEY_SCOPES,
720
743
  CLI_KEY_SCOPES,
744
+ editorKeyCommand,
721
745
  SDK_KEY_LABEL,
722
746
  CLI_KEY_LABEL,
723
747
  probeKeyScope,
@@ -73,10 +73,11 @@ async function findSdkImport(cwd) {
73
73
  }
74
74
  return null;
75
75
  }
76
+
76
77
  export {
77
- ENTRY_CANDIDATES,
78
- MUSHI_MARKER_END,
79
78
  MUSHI_MARKER_START,
80
- findSdkImport,
81
- injectSnippet
79
+ MUSHI_MARKER_END,
80
+ ENTRY_CANDIDATES,
81
+ injectSnippet,
82
+ findSdkImport
82
83
  };
@@ -0,0 +1,8 @@
1
+ // src/version.ts
2
+ var MUSHI_CLI_VERSION = true ? "0.40.3" : "0.0.0-dev";
3
+ var MUSHI_MCP_PIN_SPEC = "@mushi-mushi/mcp@0.31.5";
4
+
5
+ export {
6
+ MUSHI_CLI_VERSION,
7
+ MUSHI_MCP_PIN_SPEC
8
+ };
@@ -75,10 +75,11 @@ async function findSdkImport(cwd) {
75
75
  }
76
76
  return null;
77
77
  }
78
+
78
79
  export {
79
- ENTRY_CANDIDATES,
80
- MUSHI_MARKER_END,
81
80
  MUSHI_MARKER_START,
82
- findSdkImport,
83
- injectSnippet
81
+ MUSHI_MARKER_END,
82
+ ENTRY_CANDIDATES,
83
+ injectSnippet,
84
+ findSdkImport
84
85
  };
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/version.ts
4
+ var MUSHI_CLI_VERSION = true ? "0.40.3" : "0.0.0-dev";
5
+ var MUSHI_MCP_PIN_SPEC = "@mushi-mushi/mcp@0.31.5";
6
+
7
+ export {
8
+ MUSHI_CLI_VERSION,
9
+ MUSHI_MCP_PIN_SPEC
10
+ };
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  resolveSdkEnvKey,
4
4
  runConnect
5
- } from "./chunk-OVBRQDHI.js";
5
+ } from "./chunk-HNVCLEDF.js";
6
6
  import "./chunk-CG5KPP4S.js";
7
- import "./chunk-QKO42UPX.js";
8
- import "./chunk-KQHEYAEK.js";
7
+ import "./chunk-CGQE3GJK.js";
8
+ import "./chunk-ZVNRKEVP.js";
9
9
  import "./chunk-LGGE3LH7.js";
10
10
  export {
11
11
  resolveSdkEnvKey,
@@ -6,10 +6,10 @@ import {
6
6
  saveConfig,
7
7
  savedSdkKeyFor,
8
8
  waitForIngestReady
9
- } from "./chunk-KIWSPGQB.js";
9
+ } from "./chunk-JXGVZWRL.js";
10
10
  import {
11
11
  MUSHI_MCP_PIN_SPEC
12
- } from "./chunk-CP57NSIY.js";
12
+ } from "./chunk-LWFREQOK.js";
13
13
  import {
14
14
  detectFramework,
15
15
  envVarsToWrite,