@mushi-mushi/mcp 0.32.2 → 0.33.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/dist/index.js CHANGED
@@ -3,8 +3,8 @@
3
3
  // src/index.ts
4
4
  import { serveStdio } from "@modelcontextprotocol/server/stdio";
5
5
  import { createRequire } from "module";
6
- import { readFileSync } from "fs";
7
- import { join } from "path";
6
+ import { readFileSync as readFileSync3 } from "fs";
7
+ import { join as join3 } from "path";
8
8
  import { homedir } from "os";
9
9
  import { createLogger as createLogger2, DEFAULT_API_ENDPOINT } from "@mushi-mushi/core";
10
10
 
@@ -291,6 +291,31 @@ var TOOL_CATALOG = [
291
291
  hints: { readOnly: false, destructive: false, idempotent: false, openWorld: true },
292
292
  useCase: "Ask to raise the Play rollout to 20%, for a person to approve."
293
293
  },
294
+ {
295
+ name: "get_security_proof",
296
+ title: "Security proof of a release",
297
+ description: "Return the Security proof of one release (releaseId), one commit (commitSha) or, with neither, the newest commit the scans saw: per lane (dependencies = OSV-Scanner, secrets = Gitleaks, ai_review = claude-code-security-review, dast = ZAP baseline + Nuclei, weekly) its state passed | findings | error | skipped | off | unknown | stale, the counts by severity, the run it used and its findings (title, severity, location, report id, deduped_by). The scanners run in the app's own CI (mushi-security.yml) and post their results; Mushi never runs them. state is proven (dependencies and secrets green for the commit, nothing failing elsewhere), attention, incomplete (a required lane has no result for the commit; a lane that never ran is not a pass) or not_pinned (the release names no commit). Optional projectId. Returns { state, headline, commitSha, lanes, findings, release }. Read-only.",
298
+ scope: "mcp:read",
299
+ hints: { readOnly: true, idempotent: true, openWorld: true },
300
+ returnsUntrusted: true,
301
+ useCase: "Did the scans come back green for the commit this release ships?"
302
+ },
303
+ {
304
+ name: "export_release_kit",
305
+ title: "Export a release kit",
306
+ description: "Export the release kit of one release (releaseId) for a product-video tool: signs every ready asset (before/after screenshots copied from the UX baselines, Playwright clips, device recordings) for 24 hours, writes manifest.json beside them in lazycow's release-kit format (schema lazycow.release-kit, version 1: app, release, brand, screens with before/after, recordings, changelog; every asset with its own signed URL, bytes and sha256) and returns { kitUrl, expiresAt, preset, manifest }, where preset is lazycow's name (appstore-iphone | play-promo | social-9x16 | social-1x1). Pass both to lazycow's make_product_video({ kitUrl, preset }); the rendered file comes back as a product_video asset of the kit. Mushi never renders video. Mushi's own fields (per-asset store checks, the preset's output spec, the release's Security proof headline) are under manifest.mushi. An empty kit is 422 KIT_EMPTY. Optional projectId. Write: it writes the manifest and mints signed URLs.",
307
+ scope: "mcp:write",
308
+ hints: { readOnly: false, destructive: false, idempotent: false, openWorld: true },
309
+ useCase: "Hand this release's screenshots and clips to lazycow for a product video."
310
+ },
311
+ {
312
+ name: "request_store_media_upload",
313
+ title: "Ask to upload store media (needs approval)",
314
+ description: `Ask to put release-kit media on a store: action upload_screenshots (App Store, displayType such as APP_IPHONE_67), upload_app_preview (App Store, previewType such as IPHONE_67; 15\u201330 s, H.264 or ProRes 422 HQ, at most 30 fps), upload_listing_images (Google Play, imageType such as phoneScreenshots or featureGraphic) or set_promo_video (Google Play, a YouTube URL). Give releaseId, connectorId (an App Store Connect or Google Play connector bound to the app), locale and assetIds from the kit. Mushi checks each asset against the store's spec first (422 SPEC_CHECK_FAILED with the reason) and stores the exact payload, every asset pinned by its SHA-256. This only creates a request: nothing is uploaded until a team owner or admin approves it in the console and runs it there. Confirm with the user first. Returns { actionId, payloadSha256, payload, status: "pending_approval" }. Write.`,
315
+ scope: "mcp:write",
316
+ hints: { readOnly: false, destructive: false, idempotent: false, openWorld: true },
317
+ useCase: "Ask to put the new screenshots on the App Store, for a person to approve."
318
+ },
294
319
  {
295
320
  name: "get_store_status",
296
321
  title: "Store review status",
@@ -362,6 +387,41 @@ var TOOL_CATALOG = [
362
387
  returnsUntrusted: true,
363
388
  useCase: "Which files are too big to change safely, and is the bundle growing?"
364
389
  },
390
+ {
391
+ name: "get_timeline",
392
+ title: "The app release by release",
393
+ description: "Return how one app got better, release by release (Plan 025, ADR 0072), without screenshots: rail ('releases' when the app has release rows, else 'runs': each UX or scorecard run is a stop), points oldest first [{ id, kind (release | unreleased | run), at, label, title, status, version, runs (run ids), cost_usd (what the runs' AI calls cost; null = not recorded), judged (verdicts that were a model call), cached (verdicts reused because the page had not changed), score (the newest scorecard mean, 1-10), improved_screens, reports_closed, reports [{ id, title }], baselines (screens pinned to it) }], surfaces [{ key, label, path, latest_score, first_score, frames (pinned shots) }], month (the last 30 days: releases, reports_closed, top_reports, screens_improved, runs, cost_usd, judged, cached, movers [{ key, label, from, to }]) and settings { keep_releases }. Optional projectId (defaults to the configured project). Read-only, no model call. Use get_surface_history with a surface key for that screen's screenshots, scores and kept changes; get_ux_run with a run id for one run.",
394
+ scope: "mcp:read",
395
+ hints: { readOnly: true, idempotent: true, openWorld: true },
396
+ returnsUntrusted: true,
397
+ useCase: "Is my app getting better, and what did each release fix and cost?"
398
+ },
399
+ {
400
+ name: "get_surface_history",
401
+ title: "One screen's history",
402
+ description: "Return one screen's history across releases (ADR 0072): surface { key, label, path }, frames oldest first [{ id, viewport (desktop | mobile), version, release_id, run_id, score, penalty, cost_usd, pinned (kept forever), created_at, url (signed for one hour) }], scores across scorecard runs [{ at, run, score, cached (reused, no model call), cost_usd }] and the changes the UX loop kept on it [{ at, run, shipped (its PR merged), what, commit_sha }]. Required surfaceKey (a key from get_timeline's surfaces); optional projectId. Read-only, no model call. Use to show a before and after of a screen, or to check whether a fix changed what users see.",
403
+ scope: "mcp:read",
404
+ hints: { readOnly: true, idempotent: true, openWorld: true },
405
+ returnsUntrusted: true,
406
+ useCase: "Show me how the checkout screen changed over the last releases."
407
+ },
408
+ {
409
+ name: "get_ux_run",
410
+ title: "One UX run",
411
+ description: "Return one UX run (ADR 0020/0067) by its local run id (from get_timeline's points[].runs, or the CLI): run { status, phase, agent, model, judge_model, branch, pr_url, counts, cost_usd, cost { judged, cached, unpriced }, started_at, finished_at, error }, surfaces (each screen with status, problem scores before and after, the review's verdict, and signed screenshot URLs valid for one hour) and iterations (each attempt with outcome, reason, commit and files). Required runId; optional projectId. Read-only. Use to see what a run changed and what it cost; get_timeline for the history across runs.",
412
+ scope: "mcp:read",
413
+ hints: { readOnly: true, idempotent: true, openWorld: true },
414
+ returnsUntrusted: true,
415
+ useCase: "What did the last UX run change, and what did it cost?"
416
+ },
417
+ {
418
+ name: "start_ux_run",
419
+ title: "How to start a UX run",
420
+ description: "Return how to start a UX run for one app, without starting one (ADR 0017/0020/0072): a cloud run spends the repo's Actions minutes and Cursor credits, so only a person in the console starts it. Returns { started: false, why, console_path (the UX runs page, where Run in the cloud is one click), commands { scorecard, loop } (run on your own machine with your own keys; --sync mirrors the run to the console), next }. Optional kind (scorecard | loop, default scorecard) and projectId. No change is made and no model is called. After the run, read it with get_ux_run or get_timeline.",
421
+ scope: "mcp:read",
422
+ hints: { readOnly: true, idempotent: true, openWorld: false },
423
+ useCase: "Run a UX check on my app."
424
+ },
365
425
  {
366
426
  name: "get_ci_overview",
367
427
  title: "CI runners and why fixes wait",
@@ -405,7 +465,7 @@ var TOOL_CATALOG = [
405
465
  scope: "mcp:write",
406
466
  hints: { readOnly: false, destructive: false, idempotent: false, openWorld: true },
407
467
  returnsUntrusted: true,
408
- useCase: "Ask to run yen-yen's PR jobs on the Alienware runner instead of paid GitHub minutes, for a person to approve."
468
+ useCase: "Ask to run my-app's PR jobs on my self-hosted runner instead of paid GitHub minutes, for a person to approve."
409
469
  },
410
470
  {
411
471
  name: "open_ci_cost_fix",
@@ -414,7 +474,7 @@ var TOOL_CATALOG = [
414
474
  scope: "mcp:write",
415
475
  hints: { readOnly: false, destructive: false, idempotent: false, openWorld: true },
416
476
  returnsUntrusted: true,
417
- useCase: "Stop glot.it's CI from running on draft agent PRs: open the skip-drafts fix for ci.yml as a draft PR to review."
477
+ useCase: "Stop my-app's CI from running on draft agent PRs: open the skip-drafts fix for ci.yml as a draft PR to review."
418
478
  },
419
479
  {
420
480
  name: "preview_ci_cost_fix_rollout",
@@ -441,7 +501,7 @@ var TOOL_CATALOG = [
441
501
  scope: "mcp:read",
442
502
  hints: { readOnly: true, idempotent: true, openWorld: true },
443
503
  returnsUntrusted: true,
444
- useCase: "Did the CI fix PR for glot.it open, which fixes were refused, and what did it save after the merge?"
504
+ useCase: "Did the CI fix PR for my-app open, which fixes were refused, and what did it save after the merge?"
445
505
  },
446
506
  {
447
507
  name: "explain_finding",
@@ -550,7 +610,7 @@ var TOOL_CATALOG = [
550
610
  description: "Declare whether one domain renews automatically at its registrar: autoRenew true, false, or null for not known. The domain id comes from get_accounts_register; only a domain one of the caller's apps uses can be changed (404 otherwise). It records what you declare and checks nothing at the registrar; false opens the registrar_autorenew_off rule. Team owners and admins only; needs an account-level key. Returns { id }. Write.",
551
611
  scope: "mcp:write",
552
612
  hints: { readOnly: false, destructive: false, idempotent: true, openWorld: true },
553
- useCase: "Mark glot.it as renewing automatically."
613
+ useCase: "Mark example.com as renewing automatically."
554
614
  },
555
615
  {
556
616
  name: "get_spend_ledger",
@@ -905,6 +965,31 @@ var TOOL_CATALOG = [
905
965
  scope: "mcp:write",
906
966
  hints: { readOnly: false, destructive: false, idempotent: true, openWorld: true },
907
967
  useCase: "Record one in ten visitors for the next day so I can see where people get stuck."
968
+ },
969
+ // ── Native UX captures and personas (Plan 025 P2/P3, ADR 0073) ──────
970
+ {
971
+ name: "upload_ux_captures",
972
+ title: "Upload app screenshots to the UX scorecard",
973
+ description: 'Open a UX scorecard run for screens another driver captured (a Maestro flow, adb screencap, the iOS simulator, an SDK debug build or a browser), so each screen is scored on the same written rubric as a web page (ADR 0073). platform is ios | android | flutter | react_native | capacitor | web | other; optional device ("Pixel 8 (API 35)"), source (maestro | adb | simctl | sdk | playwright | other), app (a name), viewport ("390x844"), maxCostUsd (0.05\u201320, caps the scoring budget the run reserves) and projectId. pages is 1 to 60 of { facts, shots }: facts are the scorecard page facts { key, path (starts with /), label, title, headings, text, controls, settleMs (null), axe (null), overflowX, consoleErrors, cls, viewport { width, height } } and shots is ["settled"] or ["early", "settled"]. Returns { runId, reservedUsd, uploads: [{ page, name, signedUrl }], next }: PUT each PNG (Content-Type image/png, at most 8 MB) to its signedUrl, then score each page with POST next.score { facts, shots: [name] }, group with POST next.group, and close the run with PUT next.finish. On the stdio server, dir instead reads <dir>/pages/<screen>/settled.png (plus early.png, facts.json, an Android window.xml or a Maestro hierarchy.json) and does the uploads itself; score=true also scores, groups and closes the run. Refused with 402 when the AI budget cannot cover the run. Viewers cannot upload. Write: it stores screenshots and a run; nothing in the app or repo changes.',
974
+ scope: "mcp:write",
975
+ hints: { readOnly: false, destructive: false, idempotent: false, openWorld: true },
976
+ useCase: "Score my Android app\u2019s onboarding screens like the web pages."
977
+ },
978
+ {
979
+ name: "list_personas",
980
+ title: "List the app\u2019s personas",
981
+ description: "Return the user profiles a first-time user test or a PDCA critic can play for one project (ADR 0073): each persona { id, name, goal, locale, device (desktop | mobile | tablet), expertise (new | casual | power), accessibility (screen_reader, low_vision, keyboard_only, reduced_motion, color_blind, motor, plain_language), patienceSteps (the step cap), costCapUsd (the most one test may spend on Mushi Mushi's AI calls), brief (the words the visitor model reads), runs (its last 12 tests: status, ttfv_seconds, reached, steps) }, plus presets, the test-account setting { mode: off | mushi | hook } and the AI budget { monthlyUsd, spentUsd, heldUsd }. Optional projectId. Read-only.",
982
+ scope: "mcp:read",
983
+ hints: { readOnly: true, idempotent: true, openWorld: true },
984
+ useCase: "Which personas can test my app, and how did each do last time?"
985
+ },
986
+ {
987
+ name: "start_fresh_eyes",
988
+ title: "Start a first-time user test",
989
+ description: `Queue a first-time user test (fresh eyes, ADR 0053) for the user's own local worker: an AI that has never seen the app tries one goal from its start page while Mushi Mushi times every step and notes where it got stuck. Optional personaId (from list_personas: the visitor's device, language, needs and step cap), url (default: the app's known address), goal (default: the persona's goal, else the last one, else "sign up and start using the app"), sessions (1\u20135, default 3), successText (words on screen that mean the goal was reached), dryRun (true: look around only, file nothing; false, the default, files what stops the visitor as reports) and projectId. It never signs up with test accounts: only an owner or admin can grant those, from the console. Answers 409 NO_WORKER with the one thing to do when no computer of the user's can run it, 402 when the AI budget cannot cover the run, 404 PERSONA_NOT_FOUND. Returns { runId, status: "queued", runner, personaId, reservedUsd }. Write: it queues a run that may file reports. The result shows on the console's First-time user test page.`,
990
+ scope: "mcp:write",
991
+ hints: { readOnly: false, destructive: false, idempotent: false, openWorld: true },
992
+ useCase: "Have a Japanese phone user try to sign up and tell me where they get stuck."
908
993
  }
909
994
  ];
910
995
  var TDD_TOOL_CATALOG = [
@@ -1412,6 +1497,10 @@ var TOOL_FEATURE_MAP = {
1412
1497
  propose_recipe_change: "inventory",
1413
1498
  propose_portfolio_change: "inventory",
1414
1499
  request_connector_action: "inventory",
1500
+ // Plan 025 P4-P6 (ADR 0074): a release's Security proof, its kit, store media requests.
1501
+ get_security_proof: "inventory",
1502
+ export_release_kit: "inventory",
1503
+ request_store_media_upload: "inventory",
1415
1504
  get_store_status: "inventory",
1416
1505
  get_design_deviance: "inventory",
1417
1506
  // Run-now triggers + the by-id finding explanation
@@ -1495,6 +1584,10 @@ var TOOL_FEATURE_MAP = {
1495
1584
  list_qa_story_runs: "qa",
1496
1585
  get_qa_story_run: "qa",
1497
1586
  test_notification_channel: "qa",
1587
+ // Native UX captures and personas (ADR 0073)
1588
+ upload_ux_captures: "qa",
1589
+ list_personas: "qa",
1590
+ start_fresh_eyes: "qa",
1498
1591
  // skills
1499
1592
  list_skills: "skills",
1500
1593
  get_skill: "skills",
@@ -1511,6 +1604,10 @@ var TOOL_FEATURE_MAP = {
1511
1604
  run_fullstack_audit: "audit",
1512
1605
  get_backend_health: "audit",
1513
1606
  get_code_health: "audit",
1607
+ get_timeline: "audit",
1608
+ get_surface_history: "audit",
1609
+ get_ux_run: "audit",
1610
+ start_ux_run: "audit",
1514
1611
  // codebase understand
1515
1612
  ask_codebase: "codebase",
1516
1613
  get_file_summary: "codebase",
@@ -1589,12 +1686,27 @@ function toolMatchesFeatures(toolName, filter) {
1589
1686
 
1590
1687
  // src/server.ts
1591
1688
  import { AsyncLocalStorage } from "async_hooks";
1689
+ import { readFileSync as readFileSync2 } from "fs";
1690
+ import { join as join2 } from "path";
1592
1691
  import { McpServer } from "@modelcontextprotocol/server";
1593
1692
  import { z } from "zod";
1594
1693
  import { createLogger } from "@mushi-mushi/core";
1595
1694
 
1596
1695
  // src/branding.ts
1597
- var MUSHI_WEBSITE_URL = "https://kensaur.us/mushi-mushi";
1696
+ var DEFAULT_PUBLIC_ORIGIN = "https://kensaur.us";
1697
+ function publicOrigin() {
1698
+ const raw = typeof process !== "undefined" ? process.env.MUSHI_PUBLIC_ORIGIN : void 0;
1699
+ const v = raw?.trim();
1700
+ if (v) {
1701
+ try {
1702
+ const u = new URL(v);
1703
+ if (u.protocol === "https:" || u.protocol === "http:") return u.origin;
1704
+ } catch {
1705
+ }
1706
+ }
1707
+ return DEFAULT_PUBLIC_ORIGIN;
1708
+ }
1709
+ var MUSHI_WEBSITE_URL = `${publicOrigin()}/mushi-mushi`;
1598
1710
  var MUSHI_ICON_PNG_URL = `${MUSHI_WEBSITE_URL}/docs/integrations/mushi-mark-512.png`;
1599
1711
  var MUSHI_ICON_SVG_URL = `${MUSHI_WEBSITE_URL}/favicon.svg`;
1600
1712
  var MUSHI_SERVER_ICONS = [
@@ -2101,6 +2213,15 @@ var MUSHI_DOCS_INDEX = [
2101
2213
  headings: ["Refresh and status", "Diagram and list", 'What "not connected" means', "Side panel", "Risk checks", "Related"],
2102
2214
  excerpt: "The App blueprint page in the Mushi Mushi console shows what this app is built from, the state of each part, and the draft pull request a change opens."
2103
2215
  },
2216
+ {
2217
+ title: "Release kits",
2218
+ url: docUrl("/admin/release-kits"),
2219
+ route: "/admin/release-kits",
2220
+ markdown: "admin/release-kits.md",
2221
+ keywords: ["admin", "release-kits", "release", "kits"],
2222
+ headings: ["Record clips (opt-in)", "Make the product video", "Put media on the stores (approval first)"],
2223
+ excerpt: "A release kit gathers a release's screenshots, flow clips, changelog and brand colours for a product video, and store media you approve."
2224
+ },
2104
2225
  {
2105
2226
  title: "Releases",
2106
2227
  url: docUrl("/admin/releases"),
@@ -2164,6 +2285,15 @@ var MUSHI_DOCS_INDEX = [
2164
2285
  headings: ["How it works", "Add the workflow", "What the action does", "Private registries", "Pinning", "Why Mushi Mushi does not write the lockfile or the workflow\u2026", "Limits"],
2165
2286
  excerpt: "Add one workflow to your repo so Mushi Mushi's SDK upgrade PRs arrive with a refreshed lockfile and pass npm ci or pnpm install --frozen-lockfile."
2166
2287
  },
2288
+ {
2289
+ title: "Security proof",
2290
+ url: docUrl("/admin/security-proof"),
2291
+ route: "/admin/security-proof",
2292
+ markdown: "admin/security-proof.md",
2293
+ keywords: ["admin", "security-proof", "security", "proof"],
2294
+ headings: ["Add the workflow", "How a release is proven", "What becomes a bug", "From an agent"],
2295
+ excerpt: "Each release's Security proof: the scans your own CI ran for the commit it ships. Dependencies, secrets, an optional AI review, a live scan."
2296
+ },
2167
2297
  {
2168
2298
  title: "Settings",
2169
2299
  url: docUrl("/admin/settings"),
@@ -2227,6 +2357,15 @@ var MUSHI_DOCS_INDEX = [
2227
2357
  headings: ["Plans", "Roles", "Invitation Flow"],
2228
2358
  excerpt: "How teams work in Mushi Mushi. Organizations own projects, billing, invitations and the member roster, and project access comes from membership."
2229
2359
  },
2360
+ {
2361
+ title: "Timeline",
2362
+ url: docUrl("/admin/timeline"),
2363
+ route: "/admin/timeline",
2364
+ markdown: "admin/timeline.md",
2365
+ keywords: ["admin", "timeline"],
2366
+ headings: ["Pin each release's screens", "From your editor"],
2367
+ excerpt: "The Timeline shows your app release by release: bugs fixed, screens improved, scores, AI cost and a before/after of every screen."
2368
+ },
2230
2369
  {
2231
2370
  title: "All users",
2232
2371
  url: docUrl("/admin/users"),
@@ -3895,6 +4034,92 @@ function wrapUntrustedJson(value, role) {
3895
4034
  return wrapUntrusted(serialised, role);
3896
4035
  }
3897
4036
 
4037
+ // src/ux-captures.ts
4038
+ import { closeSync, existsSync, fstatSync, openSync, readdirSync, readFileSync, readSync, statSync } from "fs";
4039
+ import { join } from "path";
4040
+ var UX_CAPTURE_MAX_PAGES = 60;
4041
+ var UX_CAPTURE_MAX_PNG_BYTES = 8 * 1024 * 1024;
4042
+ var PNG_SIG = [137, 80, 78, 71, 13, 10, 26, 10];
4043
+ function sizeAndHead(file) {
4044
+ const fd = openSync(file, "r");
4045
+ try {
4046
+ const head = Buffer.alloc(32);
4047
+ const n = readSync(fd, head, 0, 32, 0);
4048
+ return { size: fstatSync(fd).size, head: head.subarray(0, n) };
4049
+ } finally {
4050
+ closeSync(fd);
4051
+ }
4052
+ }
4053
+ function pngDimensions(bytes) {
4054
+ if (bytes.length < 24 || PNG_SIG.some((b, i) => bytes[i] !== b)) return null;
4055
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
4056
+ const width = view.getUint32(16);
4057
+ const height = view.getUint32(20);
4058
+ return width > 0 && height > 0 ? { width, height } : null;
4059
+ }
4060
+ var clampDim = (n) => Math.max(200, Math.min(4e3, Math.round(n)));
4061
+ function pathFor(name) {
4062
+ const slug = name.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).join("-");
4063
+ return `/${slug || "screen"}`.slice(0, 500);
4064
+ }
4065
+ function readCapturePages(dir) {
4066
+ const root = join(dir, "pages");
4067
+ if (!existsSync(root)) throw new Error(`No ${root} folder: put each screen in <dir>/pages/<screen>/settled.png.`);
4068
+ const out = [];
4069
+ for (const name of readdirSync(root).sort()) {
4070
+ const folder = join(root, name);
4071
+ if (!statSync(folder).isDirectory()) continue;
4072
+ const shots = ["early", "settled"].filter((s) => existsSync(join(folder, `${s}.png`)));
4073
+ if (!shots.length) continue;
4074
+ let dims = null;
4075
+ for (const s of shots) {
4076
+ const file = join(folder, `${s}.png`);
4077
+ const { size, head } = sizeAndHead(file);
4078
+ if (size > UX_CAPTURE_MAX_PNG_BYTES) throw new Error(`${file} is over 8 MB.`);
4079
+ const d = pngDimensions(head);
4080
+ if (!d) throw new Error(`${file} is not a PNG.`);
4081
+ dims = d;
4082
+ }
4083
+ let given = {};
4084
+ const factsFile = join(folder, "facts.json");
4085
+ if (existsSync(factsFile)) {
4086
+ try {
4087
+ given = JSON.parse(readFileSync(factsFile, "utf8"));
4088
+ } catch {
4089
+ throw new Error(`${factsFile} is not valid JSON.`);
4090
+ }
4091
+ }
4092
+ const path = typeof given.path === "string" && given.path.startsWith("/") ? given.path : pathFor(typeof given.key === "string" ? given.key : name);
4093
+ const key = typeof given.key === "string" && given.key ? given.key : path;
4094
+ const gv = given.viewport;
4095
+ const viewport = gv && typeof gv.width === "number" && typeof gv.height === "number" ? { width: clampDim(gv.width), height: clampDim(gv.height) } : dims ? { width: clampDim(dims.width), height: clampDim(dims.height) } : { width: 390, height: 844 };
4096
+ const label = typeof given.label === "string" && given.label ? given.label : name.replace(/[-_]+/g, " ");
4097
+ out.push({
4098
+ folder,
4099
+ shots: [...shots],
4100
+ facts: {
4101
+ title: label,
4102
+ headings: [],
4103
+ text: "",
4104
+ controls: [],
4105
+ settleMs: null,
4106
+ axe: null,
4107
+ overflowX: false,
4108
+ consoleErrors: 0,
4109
+ cls: 0,
4110
+ ...given,
4111
+ key,
4112
+ path,
4113
+ label,
4114
+ viewport
4115
+ }
4116
+ });
4117
+ }
4118
+ if (!out.length) throw new Error(`No screenshots in ${root}.`);
4119
+ if (out.length > UX_CAPTURE_MAX_PAGES) throw new Error(`${out.length} screens; one upload takes at most ${UX_CAPTURE_MAX_PAGES}.`);
4120
+ return out;
4121
+ }
4122
+
3898
4123
  // src/key-scopes.ts
3899
4124
  async function fetchKeyScopes(opts) {
3900
4125
  const doFetch = opts.fetch ?? fetch;
@@ -5377,6 +5602,83 @@ function createMushiServer(config) {
5377
5602
  return jsonText(await apiCall(`/v1/admin/orgs/${org}/connector-actions`, { method: "POST", body: JSON.stringify(body) }));
5378
5603
  }
5379
5604
  );
5605
+ server.registerTool(
5606
+ "get_security_proof",
5607
+ {
5608
+ title: titleOf("get_security_proof"),
5609
+ description: descOf("get_security_proof"),
5610
+ annotations: annotationsFor("get_security_proof"),
5611
+ inputSchema: z.object({
5612
+ projectId: z.string().optional().describe("Project UUID \u2014 defaults to the server-configured project when omitted"),
5613
+ releaseId: z.string().uuid().optional().describe("Release UUID; its pinned commit is the one proven"),
5614
+ commitSha: z.string().regex(/^[0-9a-fA-F]{7,40}$/).optional().describe("A commit to prove instead of a release")
5615
+ })
5616
+ },
5617
+ async (args) => {
5618
+ const pid = await resolveProjectId(args.projectId);
5619
+ const q = new URLSearchParams();
5620
+ if (args.releaseId) q.set("release", args.releaseId);
5621
+ if (args.commitSha) q.set("commit", args.commitSha);
5622
+ const qs = q.toString();
5623
+ return jsonText(await apiCall(`/v1/admin/projects/${encodeURIComponent(pid)}/security-proof${qs ? `?${qs}` : ""}`));
5624
+ }
5625
+ );
5626
+ server.registerTool(
5627
+ "export_release_kit",
5628
+ {
5629
+ title: titleOf("export_release_kit"),
5630
+ description: descOf("export_release_kit"),
5631
+ annotations: annotationsFor("export_release_kit"),
5632
+ inputSchema: z.object({
5633
+ projectId: z.string().optional().describe("Project UUID \u2014 defaults to the server-configured project when omitted"),
5634
+ releaseId: z.string().uuid().describe("Release UUID (list releases in the console or with get_release_calendar)")
5635
+ })
5636
+ },
5637
+ async (args) => {
5638
+ const pid = await resolveProjectId(args.projectId);
5639
+ return jsonText(await apiCall(`/v1/admin/projects/${encodeURIComponent(pid)}/releases/${encodeURIComponent(args.releaseId)}/kit/export`, { method: "POST", body: "{}" }));
5640
+ }
5641
+ );
5642
+ server.registerTool(
5643
+ "request_store_media_upload",
5644
+ {
5645
+ title: titleOf("request_store_media_upload"),
5646
+ description: descOf("request_store_media_upload"),
5647
+ annotations: annotationsFor("request_store_media_upload"),
5648
+ inputSchema: z.object({
5649
+ projectId: z.string().optional().describe("Project UUID \u2014 defaults to the server-configured project when omitted"),
5650
+ releaseId: z.string().uuid().describe("Release UUID whose kit holds the assets"),
5651
+ connectorId: z.string().uuid().describe("App Store Connect or Google Play connector bound to the app (list_connectors)"),
5652
+ action: z.enum(["upload_screenshots", "upload_app_preview", "upload_listing_images", "set_promo_video"]),
5653
+ locale: z.string().min(2).max(20).describe("Store language, e.g. en-US"),
5654
+ displayType: z.string().max(40).optional().describe("upload_screenshots: e.g. APP_IPHONE_67, APP_IPAD_PRO_3GEN_129"),
5655
+ previewType: z.string().max(40).optional().describe("upload_app_preview: e.g. IPHONE_67"),
5656
+ imageType: z.string().max(40).optional().describe("upload_listing_images: phoneScreenshots, featureGraphic, icon, \u2026"),
5657
+ replace: z.boolean().optional().describe("upload_listing_images: clear that image type for the language first"),
5658
+ youtubeUrl: z.string().url().max(200).optional().describe("set_promo_video: the published YouTube video"),
5659
+ previewFrameTimeCode: z.string().regex(/^\d{2}:\d{2}:\d{2}:\d{2}$/).optional().describe("upload_app_preview: poster frame, e.g. 00:00:05:00"),
5660
+ assetIds: z.array(z.string().uuid()).max(10).optional().describe("Kit asset ids to upload"),
5661
+ reason: z.string().max(500).optional().describe("Why, shown to the approver")
5662
+ })
5663
+ },
5664
+ async (args) => {
5665
+ const pid = await resolveProjectId(args.projectId);
5666
+ const body = {
5667
+ connectorId: args.connectorId,
5668
+ action: args.action,
5669
+ locale: args.locale,
5670
+ displayType: args.displayType,
5671
+ previewType: args.previewType,
5672
+ imageType: args.imageType,
5673
+ replace: args.replace,
5674
+ youtubeUrl: args.youtubeUrl,
5675
+ previewFrameTimeCode: args.previewFrameTimeCode,
5676
+ assetIds: args.assetIds ?? [],
5677
+ reason: args.reason
5678
+ };
5679
+ return jsonText(await apiCall(`/v1/admin/projects/${encodeURIComponent(pid)}/releases/${encodeURIComponent(args.releaseId)}/kit/store-upload`, { method: "POST", body: JSON.stringify(body) }));
5680
+ }
5681
+ );
5380
5682
  server.registerTool(
5381
5683
  "get_store_status",
5382
5684
  {
@@ -5500,6 +5802,70 @@ function createMushiServer(config) {
5500
5802
  return jsonText(await apiCall(`/v1/admin/code-health?${qs}`));
5501
5803
  }
5502
5804
  );
5805
+ server.registerTool(
5806
+ "get_timeline",
5807
+ {
5808
+ title: titleOf("get_timeline"),
5809
+ description: descOf("get_timeline"),
5810
+ annotations: annotationsFor("get_timeline"),
5811
+ inputSchema: z.object({
5812
+ projectId: z.string().optional().describe("Project UUID \u2014 defaults to the server-configured project when omitted")
5813
+ })
5814
+ },
5815
+ async (args) => {
5816
+ const pid = await resolveProjectId(args.projectId);
5817
+ return jsonText(await apiCall(`/v1/admin/projects/${encodeURIComponent(pid)}/timeline?compact=1`));
5818
+ }
5819
+ );
5820
+ server.registerTool(
5821
+ "get_surface_history",
5822
+ {
5823
+ title: titleOf("get_surface_history"),
5824
+ description: descOf("get_surface_history"),
5825
+ annotations: annotationsFor("get_surface_history"),
5826
+ inputSchema: z.object({
5827
+ surfaceKey: z.string().regex(/^[a-z0-9][a-z0-9-]{0,119}$/).describe("A screen key from get_timeline's surfaces[].key"),
5828
+ projectId: z.string().optional().describe("Project UUID \u2014 defaults to the server-configured project when omitted")
5829
+ })
5830
+ },
5831
+ async (args) => {
5832
+ const pid = await resolveProjectId(args.projectId);
5833
+ return jsonText(await apiCall(`/v1/admin/projects/${encodeURIComponent(pid)}/timeline/surfaces/${encodeURIComponent(args.surfaceKey)}`));
5834
+ }
5835
+ );
5836
+ server.registerTool(
5837
+ "get_ux_run",
5838
+ {
5839
+ title: titleOf("get_ux_run"),
5840
+ description: descOf("get_ux_run"),
5841
+ annotations: annotationsFor("get_ux_run"),
5842
+ inputSchema: z.object({
5843
+ runId: z.string().regex(/^[0-9]{8}-[0-9]{6}-[a-z0-9]{4}$/).describe("Local run id, e.g. 20261127-091500-ab3d (get_timeline points[].runs)"),
5844
+ projectId: z.string().optional().describe("Project UUID \u2014 defaults to the server-configured project when omitted")
5845
+ })
5846
+ },
5847
+ async (args) => {
5848
+ const pid = await resolveProjectId(args.projectId);
5849
+ return jsonText(await apiCall(`/v1/admin/projects/${encodeURIComponent(pid)}/ux-runs/${encodeURIComponent(args.runId)}`));
5850
+ }
5851
+ );
5852
+ server.registerTool(
5853
+ "start_ux_run",
5854
+ {
5855
+ title: titleOf("start_ux_run"),
5856
+ description: descOf("start_ux_run"),
5857
+ annotations: annotationsFor("start_ux_run"),
5858
+ inputSchema: z.object({
5859
+ kind: z.enum(["scorecard", "loop"]).optional().describe("scorecard (score every page, default) or loop (a coding agent improves screens)"),
5860
+ projectId: z.string().optional().describe("Project UUID \u2014 defaults to the server-configured project when omitted")
5861
+ })
5862
+ },
5863
+ async (args) => {
5864
+ const pid = await resolveProjectId(args.projectId);
5865
+ const qs = new URLSearchParams({ kind: args.kind ?? "scorecard" });
5866
+ return jsonText(await apiCall(`/v1/admin/projects/${encodeURIComponent(pid)}/timeline/run-plan?${qs}`));
5867
+ }
5868
+ );
5503
5869
  const CI_ADVICE_OUTPUT = z.looseObject({
5504
5870
  id: z.string(),
5505
5871
  severity: z.string(),
@@ -7585,6 +7951,133 @@ function createMushiServer(config) {
7585
7951
  return jsonText({ ...data, next: journeyRecordingNextOf(checked.body.hours) });
7586
7952
  }
7587
7953
  );
7954
+ const UX_PLATFORMS = ["ios", "android", "flutter", "react_native", "capacitor", "web", "other"];
7955
+ const UX_SOURCES = ["maestro", "adb", "simctl", "sdk", "playwright", "other"];
7956
+ server.registerTool(
7957
+ "upload_ux_captures",
7958
+ {
7959
+ title: titleOf("upload_ux_captures"),
7960
+ description: descOf("upload_ux_captures"),
7961
+ annotations: annotationsFor("upload_ux_captures"),
7962
+ inputSchema: z.object({
7963
+ projectId: z.string().optional().describe("Project UUID \u2014 defaults to the server-configured project when omitted"),
7964
+ platform: z.enum(UX_PLATFORMS).describe("What the screens are from"),
7965
+ device: z.string().max(120).optional().describe('The device or simulator, e.g. "Pixel 8 (API 35)"'),
7966
+ source: z.enum(UX_SOURCES).optional().describe("The driver that captured them"),
7967
+ app: z.string().max(120).optional().describe("What to call the app"),
7968
+ viewport: z.string().optional().describe("WIDTHxHEIGHT, e.g. 390x844 (default: the first screen)"),
7969
+ maxCostUsd: z.number().min(0.05).max(20).optional().describe("The most the run may spend on server scoring"),
7970
+ pages: z.array(z.object({ facts: z.record(z.string(), z.unknown()), shots: z.array(z.enum(["early", "settled"])).min(1).max(2) })).max(60).optional().describe("The screens: { facts, shots }. Omit when dir is given."),
7971
+ dir: z.string().optional().describe("stdio only: a folder with pages/<screen>/settled.png (+ early.png, facts.json); uploads the PNGs too"),
7972
+ score: z.boolean().optional().describe("With dir: score each screen, group the causes and close the run")
7973
+ })
7974
+ },
7975
+ async (args) => {
7976
+ const pid = await resolveProjectId(args.projectId);
7977
+ if (!args.dir && !args.pages?.length) throw new MushiApiError(400, "INVALID_PARAMS", "Give pages, or dir on this stdio server.");
7978
+ const local = args.dir ? readCapturePages(args.dir) : null;
7979
+ const pages = local ? local.map((p) => ({ facts: p.facts, shots: p.shots })) : args.pages ?? [];
7980
+ const created = await apiCall("/v1/ux/captures", {
7981
+ method: "POST",
7982
+ body: JSON.stringify({
7983
+ projectId: pid,
7984
+ platform: args.platform,
7985
+ ...args.device ? { device: args.device } : {},
7986
+ ...args.source ? { source: args.source } : {},
7987
+ ...args.app ? { app: args.app } : {},
7988
+ ...args.viewport ? { viewport: args.viewport } : {},
7989
+ ...args.maxCostUsd !== void 0 ? { maxCostUsd: args.maxCostUsd } : {},
7990
+ pages
7991
+ })
7992
+ });
7993
+ if (!local) return jsonText(created);
7994
+ const byKey = new Map(local.map((p) => [p.facts.key, p]));
7995
+ const names = /* @__PURE__ */ new Map();
7996
+ for (const u of created.uploads ?? []) {
7997
+ const p = byKey.get(u.page);
7998
+ if (!p) continue;
7999
+ const shot = u.name.endsWith("/early.png") ? "early" : "settled";
8000
+ const put = await doFetch(u.signedUrl, { method: "PUT", headers: { "Content-Type": "image/png" }, body: new Uint8Array(readFileSync2(join2(p.folder, `${shot}.png`))) });
8001
+ if (!put.ok) throw new MushiApiError(502, "UPLOAD_FAILED", `Screenshot ${u.name} not uploaded (storage answered ${put.status}). The run is ${created.runId}.`);
8002
+ names.set(u.page, [...names.get(u.page) ?? [], u.name]);
8003
+ }
8004
+ if (!args.score) return jsonText({ ...created, uploaded: [...names.values()].flat().length });
8005
+ const base = `/v1/admin/projects/${encodeURIComponent(pid)}/ux-scorecard/${created.runId}`;
8006
+ const scores = /* @__PURE__ */ new Map();
8007
+ const errors = [];
8008
+ for (const p of local) {
8009
+ try {
8010
+ const r = await apiCall(`${base}/score`, { method: "POST", body: JSON.stringify({ facts: p.facts, shots: names.get(p.facts.key) ?? [], app: args.app ?? "this app" }) });
8011
+ if (r.score) scores.set(p.facts.key, r.score);
8012
+ } catch (err) {
8013
+ errors.push(`${p.facts.key}: ${err instanceof Error ? err.message : String(err)}`);
8014
+ }
8015
+ }
8016
+ let causes = [];
8017
+ try {
8018
+ causes = (await apiCall(`${base}/group`, { method: "POST", body: "{}" })).causes ?? [];
8019
+ } catch (err) {
8020
+ errors.push(`grouping: ${err instanceof Error ? err.message : String(err)}`);
8021
+ }
8022
+ const vp = args.viewport ?? `${local[0].facts.viewport.width}x${local[0].facts.viewport.height}`;
8023
+ await apiCall(base, {
8024
+ method: "PUT",
8025
+ body: JSON.stringify({
8026
+ status: "done",
8027
+ viewport: vp,
8028
+ scored_by: "server",
8029
+ started_at: (/* @__PURE__ */ new Date()).toISOString(),
8030
+ finished_at: (/* @__PURE__ */ new Date()).toISOString(),
8031
+ pages: local.map((p) => ({ facts: p.facts, score: scores.get(p.facts.key) ?? null, shots: names.get(p.facts.key) ?? [], ...scores.has(p.facts.key) ? {} : { error: "Not scored." } })),
8032
+ causes
8033
+ })
8034
+ });
8035
+ const overall = [...scores.values()].map((s) => s.overall ?? 0);
8036
+ return jsonText({ runId: created.runId, reservedUsd: created.reservedUsd, scored: scores.size, pages: local.length, mean: overall.length ? Math.round(overall.reduce((a, b) => a + b, 0) / overall.length * 10) / 10 : null, causes: causes.length, errors, next: created.next });
8037
+ }
8038
+ );
8039
+ server.registerTool(
8040
+ "list_personas",
8041
+ {
8042
+ title: titleOf("list_personas"),
8043
+ description: descOf("list_personas"),
8044
+ annotations: annotationsFor("list_personas"),
8045
+ inputSchema: PROJECT_ID_INPUT
8046
+ },
8047
+ async (args) => {
8048
+ const pid = await resolveProjectId(args.projectId);
8049
+ return jsonText(await apiCall(`/v1/admin/projects/${encodeURIComponent(pid)}/personas`));
8050
+ }
8051
+ );
8052
+ server.registerTool(
8053
+ "start_fresh_eyes",
8054
+ {
8055
+ title: titleOf("start_fresh_eyes"),
8056
+ description: descOf("start_fresh_eyes"),
8057
+ annotations: annotationsFor("start_fresh_eyes"),
8058
+ inputSchema: z.object({
8059
+ projectId: z.string().optional().describe("Project UUID \u2014 defaults to the server-configured project when omitted"),
8060
+ personaId: z.string().optional().describe("A persona id from list_personas"),
8061
+ url: z.string().max(500).optional().describe("The start page (default: the app's known address)"),
8062
+ goal: z.string().max(300).optional().describe("What the visitor came to do (default: the persona's goal, else the last one)"),
8063
+ sessions: z.number().int().min(1).max(5).optional().describe("Visitors, 1-5 (default 3)"),
8064
+ successText: z.string().max(120).optional().describe("Words on screen that mean the goal was reached"),
8065
+ dryRun: z.boolean().optional().describe("Look around only and file nothing")
8066
+ })
8067
+ },
8068
+ async (args) => {
8069
+ const pid = await resolveProjectId(args.projectId);
8070
+ const body = {
8071
+ ...args.personaId ? { personaId: args.personaId } : {},
8072
+ ...args.url ? { url: args.url } : {},
8073
+ ...args.goal ? { goal: args.goal } : {},
8074
+ ...args.sessions !== void 0 ? { sessions: args.sessions } : {},
8075
+ ...args.successText ? { successText: args.successText } : {},
8076
+ ...args.dryRun !== void 0 ? { dryRun: args.dryRun } : {}
8077
+ };
8078
+ return jsonText(await apiCall(`/v1/admin/projects/${encodeURIComponent(pid)}/fresh-eyes`, { method: "POST", body: JSON.stringify(body) }));
8079
+ }
8080
+ );
7588
8081
  server.registerResource(
7589
8082
  "activation_status",
7590
8083
  "mushi://activation",
@@ -9039,13 +9532,13 @@ var log = createLogger2({ scope: "mushi:mcp", level: "info", destination: "stder
9039
9532
  function resolveCliConfigPath() {
9040
9533
  const xdg = process.env.XDG_CONFIG_HOME;
9041
9534
  const appData = process.env.APPDATA;
9042
- const base = xdg && xdg.length > 0 ? xdg : process.platform === "win32" && appData && appData.length > 0 ? appData : join(homedir(), ".config");
9043
- return join(base, "mushi", "config.json");
9535
+ const base = xdg && xdg.length > 0 ? xdg : process.platform === "win32" && appData && appData.length > 0 ? appData : join3(homedir(), ".config");
9536
+ return join3(base, "mushi", "config.json");
9044
9537
  }
9045
9538
  function readCliConfig() {
9046
9539
  const configPath = resolveCliConfigPath();
9047
9540
  try {
9048
- const raw = readFileSync(configPath, "utf8");
9541
+ const raw = readFileSync3(configPath, "utf8");
9049
9542
  const parsed = JSON.parse(raw);
9050
9543
  return {
9051
9544
  apiKey: typeof parsed.apiKey === "string" ? parsed.apiKey : void 0,