@buoy-gg/mcp 7.0.31 → 7.0.32
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 +13 -1
- package/dist/{chunk-HUL2D27L.mjs → chunk-HWYVQNMR.mjs} +576 -193
- package/dist/cli.js +595 -212
- package/dist/cli.mjs +1 -1
- package/dist/index.js +595 -212
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -640,7 +640,7 @@ var delay = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
|
640
640
|
|
|
641
641
|
// src/server.ts
|
|
642
642
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
643
|
-
var
|
|
643
|
+
var import_zod24 = require("zod");
|
|
644
644
|
|
|
645
645
|
// src/tools/generic.ts
|
|
646
646
|
var import_zod = require("zod");
|
|
@@ -651,7 +651,7 @@ var import_node_os = __toESM(require("os"));
|
|
|
651
651
|
var import_node_path = __toESM(require("path"));
|
|
652
652
|
|
|
653
653
|
// src/version.ts
|
|
654
|
-
var VERSION = "7.0.
|
|
654
|
+
var VERSION = "7.0.32" ? "7.0.32" : "0.0.0-dev";
|
|
655
655
|
var PACKAGE_NAME = "@buoy-gg/mcp";
|
|
656
656
|
|
|
657
657
|
// src/update/checkForUpdate.ts
|
|
@@ -1384,7 +1384,7 @@ ${JSON.stringify(summary, null, 2)}
|
|
|
1384
1384
|
let sawActive = false;
|
|
1385
1385
|
let idleStreak = 0;
|
|
1386
1386
|
let lastCount = -1;
|
|
1387
|
-
let
|
|
1387
|
+
let resolved2 = null;
|
|
1388
1388
|
while (Date.now() - start < cap3) {
|
|
1389
1389
|
let snap2;
|
|
1390
1390
|
try {
|
|
@@ -1396,7 +1396,7 @@ ${JSON.stringify(summary, null, 2)}
|
|
|
1396
1396
|
const completed = snap2.live?.automationCompleted;
|
|
1397
1397
|
if (completed?.phase === "cancelled") return fail2(`Batch ${completed.batchId} was cancelled.`);
|
|
1398
1398
|
if (completed?.phase === "done") {
|
|
1399
|
-
|
|
1399
|
+
resolved2 = { batchId: completed.batchId, failures: completed.failures ?? failuresFromIndex(snap2.index, completed.batchId) };
|
|
1400
1400
|
break;
|
|
1401
1401
|
}
|
|
1402
1402
|
const phase = snap2.live?.automation?.phase ?? "idle";
|
|
@@ -1406,11 +1406,11 @@ ${JSON.stringify(summary, null, 2)}
|
|
|
1406
1406
|
const count = runCountFor(snap2.index, newest);
|
|
1407
1407
|
if (count === lastCount) {
|
|
1408
1408
|
if (sawActive && ++idleStreak >= 3) {
|
|
1409
|
-
|
|
1409
|
+
resolved2 = { batchId: newest, failures: failuresFromIndex(snap2.index, newest) };
|
|
1410
1410
|
break;
|
|
1411
1411
|
}
|
|
1412
1412
|
if (!sawActive && Date.now() - start > 4e3) {
|
|
1413
|
-
|
|
1413
|
+
resolved2 = { batchId: newest, failures: failuresFromIndex(snap2.index, newest) };
|
|
1414
1414
|
break;
|
|
1415
1415
|
}
|
|
1416
1416
|
} else {
|
|
@@ -1422,11 +1422,11 @@ ${JSON.stringify(summary, null, 2)}
|
|
|
1422
1422
|
}
|
|
1423
1423
|
await delay2(POLL_INTERVAL_MS);
|
|
1424
1424
|
}
|
|
1425
|
-
if (!
|
|
1425
|
+
if (!resolved2) return fail2("No automation batch completed within the wait window.");
|
|
1426
1426
|
await sync.callAction(PERF_TOOL_ID, "refreshIndex", {}, target).catch(() => {
|
|
1427
1427
|
});
|
|
1428
1428
|
const snap = await readPerfSnapshot(sync, target);
|
|
1429
|
-
const ranking = rankBatchFromIndex(snap.index ?? [],
|
|
1429
|
+
const ranking = rankBatchFromIndex(snap.index ?? [], resolved2.batchId, void 0, resolved2.failures);
|
|
1430
1430
|
await sync.callAction(PERF_TOOL_ID, "acknowledgeAutomation", {}, target).catch(() => {
|
|
1431
1431
|
});
|
|
1432
1432
|
return text(`${formatRankingMarkdown(ranking)}
|
|
@@ -1753,8 +1753,8 @@ _${skipped} more withheld ${skipped === 1 ? "body was" : "bodies were"} not fetc
|
|
|
1753
1753
|
}
|
|
1754
1754
|
function bodyLines(e, fetched) {
|
|
1755
1755
|
const got = e.id ? fetched.get(e.id) : void 0;
|
|
1756
|
-
const label = (inline,
|
|
1757
|
-
const value = inline ??
|
|
1756
|
+
const label = (inline, resolved2, omitted) => {
|
|
1757
|
+
const value = inline ?? resolved2;
|
|
1758
1758
|
if (value !== void 0 && value !== null) return truncate(value);
|
|
1759
1759
|
if (!omitted) return "(none)";
|
|
1760
1760
|
return got?.unresolved ? "(withheld \u2014 the device did not answer getEventBody)" : "(none)";
|
|
@@ -3335,9 +3335,9 @@ function reasonMessage(res, query) {
|
|
|
3335
3335
|
return res.reason ? `Locate failed: ${res.reason}` : "Couldn't locate that component.";
|
|
3336
3336
|
}
|
|
3337
3337
|
}
|
|
3338
|
-
function candidatesText(
|
|
3339
|
-
if (!
|
|
3340
|
-
const lines =
|
|
3338
|
+
function candidatesText(candidates2) {
|
|
3339
|
+
if (!candidates2 || candidates2.length === 0) return "";
|
|
3340
|
+
const lines = candidates2.map((c) => {
|
|
3341
3341
|
const id = c.testID || c.nativeID;
|
|
3342
3342
|
return `- ${c.componentName || c.viewType}${id ? ` (${id})` : ""} \u2014 nativeTag ${c.nativeTag}, rendered \xD7${c.renderCount}`;
|
|
3343
3343
|
});
|
|
@@ -3436,14 +3436,383 @@ function registerScreenshotTools(server, sync) {
|
|
|
3436
3436
|
);
|
|
3437
3437
|
}
|
|
3438
3438
|
|
|
3439
|
-
// src/tools/packs/
|
|
3439
|
+
// src/tools/packs/camera.ts
|
|
3440
3440
|
var import_zod15 = require("zod");
|
|
3441
|
-
|
|
3441
|
+
|
|
3442
|
+
// src/capture/camera.ts
|
|
3443
|
+
var import_node_child_process2 = require("child_process");
|
|
3444
|
+
var import_node_util2 = require("util");
|
|
3445
|
+
var import_node_fs3 = require("fs");
|
|
3446
|
+
var import_node_os3 = __toESM(require("os"));
|
|
3447
|
+
var import_node_path3 = __toESM(require("path"));
|
|
3448
|
+
var execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process2.execFile);
|
|
3449
|
+
function candidates() {
|
|
3450
|
+
const fromEnv = process.env.BUOY_SIMCAM_DIR;
|
|
3451
|
+
const list = [
|
|
3452
|
+
...fromEnv ? [import_node_path3.default.join(fromEnv, "buoycam")] : [],
|
|
3453
|
+
"/Applications/Buoy.app/Contents/Resources/simcam/buoycam",
|
|
3454
|
+
import_node_path3.default.join(import_node_os3.default.homedir(), "Applications/Buoy.app/Contents/Resources/simcam/buoycam")
|
|
3455
|
+
];
|
|
3456
|
+
let dir = __dirname;
|
|
3457
|
+
for (let i = 0; i < 8; i++) {
|
|
3458
|
+
list.push(import_node_path3.default.join(dir, "apps/desktop/resources/simcam/buoycam"));
|
|
3459
|
+
const parent = import_node_path3.default.dirname(dir);
|
|
3460
|
+
if (parent === dir) break;
|
|
3461
|
+
dir = parent;
|
|
3462
|
+
}
|
|
3463
|
+
return list;
|
|
3464
|
+
}
|
|
3465
|
+
var resolved = null;
|
|
3466
|
+
function cliPath() {
|
|
3467
|
+
if (resolved) return resolved;
|
|
3468
|
+
resolved = candidates().find((c) => (0, import_node_fs3.existsSync)(c)) ?? null;
|
|
3469
|
+
return resolved;
|
|
3470
|
+
}
|
|
3471
|
+
async function run(args) {
|
|
3472
|
+
const cli = cliPath();
|
|
3473
|
+
if (!cli) {
|
|
3474
|
+
return {
|
|
3475
|
+
ok: false,
|
|
3476
|
+
error: "The simulator camera components were not found. They ship with the Buoy desktop app \u2014 install it, or set BUOY_SIMCAM_DIR to the directory holding `buoycam`."
|
|
3477
|
+
};
|
|
3478
|
+
}
|
|
3479
|
+
try {
|
|
3480
|
+
const { stdout } = await execFileAsync2(cli, [...args, "--json"], { timeout: 3e4 });
|
|
3481
|
+
return { ok: true, data: JSON.parse(stdout) };
|
|
3482
|
+
} catch (err) {
|
|
3483
|
+
const stdout = err.stdout ?? "";
|
|
3484
|
+
try {
|
|
3485
|
+
return { ok: false, data: JSON.parse(stdout) };
|
|
3486
|
+
} catch {
|
|
3487
|
+
return {
|
|
3488
|
+
ok: false,
|
|
3489
|
+
error: err.message || "the simulator camera CLI failed"
|
|
3490
|
+
};
|
|
3491
|
+
}
|
|
3492
|
+
}
|
|
3493
|
+
}
|
|
3494
|
+
function describeDiagnosis(checks) {
|
|
3495
|
+
const failed = checks.filter((c) => c.level === "fail");
|
|
3496
|
+
const warned = checks.filter((c) => c.level === "warn");
|
|
3497
|
+
if (failed.length === 0 && warned.length === 0) {
|
|
3498
|
+
return "The simulator camera is healthy \u2014 every check passed.";
|
|
3499
|
+
}
|
|
3500
|
+
const lines = [];
|
|
3501
|
+
for (const c of [...failed, ...warned]) {
|
|
3502
|
+
lines.push(`- **${c.name}** (${c.level}): ${c.detail}`);
|
|
3503
|
+
if (c.fix) lines.push(` ${c.fix}`);
|
|
3504
|
+
}
|
|
3505
|
+
const headline = failed.length > 0 ? `${failed.length} problem${failed.length === 1 ? "" : "s"} found.` : `No hard failures, but ${warned.length} thing${warned.length === 1 ? "" : "s"} worth knowing.`;
|
|
3506
|
+
return [headline, "", ...lines].join("\n");
|
|
3507
|
+
}
|
|
3508
|
+
function describeDevices(devices, apps) {
|
|
3509
|
+
if (devices.length === 0) {
|
|
3510
|
+
return "No booted simulators.\n\n_Boot one first \u2014 `xcrun simctl boot <udid>`, or open Simulator.app. The camera attaches to a simulator, so nothing else here works until one is running._";
|
|
3511
|
+
}
|
|
3512
|
+
const lines = [
|
|
3513
|
+
devices.length === 1 ? "1 booted simulator:" : `${devices.length} booted simulators:`,
|
|
3514
|
+
...devices.map((d) => `- **${d.name}** (${d.runtime}) \u2014 \`${d.udid}\``)
|
|
3515
|
+
];
|
|
3516
|
+
if (devices.length > 1 && apps === null) {
|
|
3517
|
+
lines.push(
|
|
3518
|
+
"",
|
|
3519
|
+
"_More than one is booted, so pass `udid` to list a specific one's apps \u2014 and to every other camera tool that takes one._"
|
|
3520
|
+
);
|
|
3521
|
+
return lines.join("\n");
|
|
3522
|
+
}
|
|
3523
|
+
if (apps === null) {
|
|
3524
|
+
lines.push("", "_Could not read the installed apps._");
|
|
3525
|
+
return lines.join("\n");
|
|
3526
|
+
}
|
|
3527
|
+
if (apps.length === 0) {
|
|
3528
|
+
lines.push("", "No apps installed on it.");
|
|
3529
|
+
return lines.join("\n");
|
|
3530
|
+
}
|
|
3531
|
+
lines.push(
|
|
3532
|
+
"",
|
|
3533
|
+
`${apps.length} installed app${apps.length === 1 ? "" : "s"}:`,
|
|
3534
|
+
...apps.map((a) => `- ${a.name} \u2014 \`${a.bundleId}\``),
|
|
3535
|
+
"",
|
|
3536
|
+
"_Pass one of these bundle ids to `camera_launch` to relaunch it with the camera attached._"
|
|
3537
|
+
);
|
|
3538
|
+
return lines.join("\n");
|
|
3539
|
+
}
|
|
3540
|
+
function describeInputs(cameras, windows) {
|
|
3541
|
+
const lines = [];
|
|
3542
|
+
lines.push(cameras.length ? '**Mac cameras** (for `kind: "camera"`):' : "**Mac cameras**: none found.");
|
|
3543
|
+
if (cameras.length) {
|
|
3544
|
+
lines.push(...cameras.map((c) => `- ${c.name} \u2014 \`${c.uniqueId}\``));
|
|
3545
|
+
} else {
|
|
3546
|
+
lines.push(
|
|
3547
|
+
"_If this Mac has a webcam, Buoy has not been granted Camera permission (System Settings \u2192 Privacy & Security \u2192 Camera)._"
|
|
3548
|
+
);
|
|
3549
|
+
}
|
|
3550
|
+
lines.push("");
|
|
3551
|
+
lines.push(
|
|
3552
|
+
windows.length ? '**Capturable windows** (for `kind: "screen"`, `value: "window:<id>"`):' : "**Capturable windows**: none found."
|
|
3553
|
+
);
|
|
3554
|
+
if (windows.length) {
|
|
3555
|
+
lines.push(
|
|
3556
|
+
...windows.map((w) => `- ${w.app}${w.title ? ` \u2014 ${w.title}` : ""} \u2014 \`window:${w.id}\``)
|
|
3557
|
+
);
|
|
3558
|
+
} else {
|
|
3559
|
+
lines.push(
|
|
3560
|
+
"_Screen Recording permission is almost certainly missing (System Settings \u2192 Privacy & Security \u2192 Screen & System Audio Recording)._"
|
|
3561
|
+
);
|
|
3562
|
+
}
|
|
3563
|
+
return lines.join("\n");
|
|
3564
|
+
}
|
|
3565
|
+
function entitlementPaths() {
|
|
3566
|
+
const fromEnv = process.env.BUOY_ENTITLEMENT_FILE;
|
|
3567
|
+
if (fromEnv) return [fromEnv];
|
|
3568
|
+
return [
|
|
3569
|
+
import_node_path3.default.join(import_node_os3.default.homedir(), "Library/Application Support/Buoy/entitlement.json"),
|
|
3570
|
+
import_node_path3.default.join(import_node_os3.default.homedir(), "Library/Application Support/buoy-desktop/entitlement.json")
|
|
3571
|
+
];
|
|
3572
|
+
}
|
|
3573
|
+
function readEntitlement() {
|
|
3574
|
+
for (const p of entitlementPaths()) {
|
|
3575
|
+
try {
|
|
3576
|
+
if (!(0, import_node_fs3.existsSync)(p)) continue;
|
|
3577
|
+
const parsed = JSON.parse((0, import_node_fs3.readFileSync)(p, "utf8"));
|
|
3578
|
+
return {
|
|
3579
|
+
tier: parsed.tier === "pro" || parsed.tier === "free" ? parsed.tier : "anonymous",
|
|
3580
|
+
isPro: parsed.isPro === true
|
|
3581
|
+
};
|
|
3582
|
+
} catch {
|
|
3583
|
+
}
|
|
3584
|
+
}
|
|
3585
|
+
return { tier: "anonymous", isPro: false };
|
|
3586
|
+
}
|
|
3587
|
+
function proRequired(tool) {
|
|
3588
|
+
return `\`${tool}\` is a Buoy Pro feature.
|
|
3589
|
+
|
|
3590
|
+
The simulator camera itself is free \u2014 the Mac camera, image, video, test-pattern and QR sources all work in the Buoy desktop panel without a licence. Pro adds the screen region, the non-QR symbologies (PDF417, Aztec, DataMatrix, Code 128), and driving any of it from an agent.
|
|
3591
|
+
|
|
3592
|
+
_Tell the user to enter a licence in Buoy Desktop, or see https://buoy.gg/pricing. Don't try to work around it \u2014 use the desktop panel by hand instead._`;
|
|
3593
|
+
}
|
|
3594
|
+
|
|
3595
|
+
// src/tools/packs/camera.ts
|
|
3442
3596
|
var text13 = (s) => ({ content: [{ type: "text", text: s }] });
|
|
3597
|
+
var gate = (tool) => readEntitlement().isPro ? null : fail15(proRequired(tool));
|
|
3443
3598
|
var fail15 = (message) => ({
|
|
3444
3599
|
isError: true,
|
|
3445
3600
|
content: [{ type: "text", text: message }]
|
|
3446
3601
|
});
|
|
3602
|
+
function registerCameraTools(server) {
|
|
3603
|
+
server.registerTool(
|
|
3604
|
+
"camera_source",
|
|
3605
|
+
{
|
|
3606
|
+
description: "Give the iOS Simulator a camera, and choose what it shows. Use this before testing anything that opens a camera \u2014 a QR or barcode scanner, document capture, an avatar picker. `barcode` generates the code from text, so testing a scanner needs no printed code and no second device; pdf417 is the barcode on a driver's licence. `screen` points the phone's camera at this Mac's screen. Needs no Buoy integration in the app under test.",
|
|
3607
|
+
inputSchema: {
|
|
3608
|
+
kind: import_zod15.z.enum(["barcode", "image", "video", "camera", "screen", "pattern"]).describe("What the camera should show."),
|
|
3609
|
+
value: import_zod15.z.string().optional().describe(
|
|
3610
|
+
"Text for `barcode`, a file path for `image`/`video`, a camera uniqueId for `camera` (see `camera_inputs`), or one of `behind` / `display` / `window:<id>` / `region:<id>[:<gutter>]` for `screen`."
|
|
3611
|
+
),
|
|
3612
|
+
format: import_zod15.z.enum(["qr", "pdf417", "aztec", "code128"]).optional().describe("Barcode symbology; defaults to qr.")
|
|
3613
|
+
}
|
|
3614
|
+
},
|
|
3615
|
+
async (args) => {
|
|
3616
|
+
const blocked = gate("camera_source");
|
|
3617
|
+
if (blocked) return blocked;
|
|
3618
|
+
const cmd = ["source", args.kind];
|
|
3619
|
+
if (args.value) cmd.push(args.value);
|
|
3620
|
+
if (args.format) cmd.push("--format", args.format);
|
|
3621
|
+
const result = await run(cmd);
|
|
3622
|
+
if (!result.ok) {
|
|
3623
|
+
return fail15(
|
|
3624
|
+
result.error ?? result.data?.error ?? "could not set the camera source"
|
|
3625
|
+
);
|
|
3626
|
+
}
|
|
3627
|
+
const what = args.kind === "barcode" ? `a ${args.format ?? "qr"} code reading "${args.value}"` : args.kind === "screen" ? `this Mac's screen (${args.value ?? "behind the simulator window"})` : args.value ?? args.kind;
|
|
3628
|
+
return text13(
|
|
3629
|
+
`The simulator camera is now showing ${what}, at ${result.data?.fps ?? 0} fps.
|
|
3630
|
+
|
|
3631
|
+
_Apps already running do not pick up a camera they started without \u2014 use \`camera_launch\` to relaunch one, or \`camera_zero_setup\` so that anything the simulator launches gets it._`
|
|
3632
|
+
);
|
|
3633
|
+
}
|
|
3634
|
+
);
|
|
3635
|
+
server.registerTool(
|
|
3636
|
+
"camera_status",
|
|
3637
|
+
{
|
|
3638
|
+
description: "Check what the simulator camera is doing and what it is currently decoding. Use this to confirm a scanner test is actually seeing a code before concluding the app is broken.",
|
|
3639
|
+
inputSchema: {}
|
|
3640
|
+
},
|
|
3641
|
+
async () => {
|
|
3642
|
+
const blocked = gate("camera_status");
|
|
3643
|
+
if (blocked) return blocked;
|
|
3644
|
+
const result = await run(["status"]);
|
|
3645
|
+
if (!result.ok || !result.data) {
|
|
3646
|
+
return fail15(result.error ?? "could not read the simulator camera status");
|
|
3647
|
+
}
|
|
3648
|
+
const { publishing, fps, codes } = result.data;
|
|
3649
|
+
if (!publishing) {
|
|
3650
|
+
return text13(
|
|
3651
|
+
"The simulator camera is not publishing anything.\n\n_Set a source with `camera_source` first._"
|
|
3652
|
+
);
|
|
3653
|
+
}
|
|
3654
|
+
return text13(
|
|
3655
|
+
[
|
|
3656
|
+
`Publishing at ${fps} fps.`,
|
|
3657
|
+
codes.length ? `Currently decoding: ${codes.map((c) => `\`${c}\``).join(", ")}` : "No barcode in the current frame.",
|
|
3658
|
+
"",
|
|
3659
|
+
"_A code shown here is what the app receives. If the app is not reacting to it, the problem is in the app, not the camera \u2014 `camera_diagnose` will say whether the app is even reading the feed._"
|
|
3660
|
+
].join("\n")
|
|
3661
|
+
);
|
|
3662
|
+
}
|
|
3663
|
+
);
|
|
3664
|
+
server.registerTool(
|
|
3665
|
+
"camera_launch",
|
|
3666
|
+
{
|
|
3667
|
+
description: "Relaunch a simulator app with the camera attached. A camera can only be attached when a process starts, so an app that is already running cannot be given one \u2014 this terminates and relaunches it.",
|
|
3668
|
+
inputSchema: {
|
|
3669
|
+
bundleId: import_zod15.z.string().describe("The app's bundle identifier."),
|
|
3670
|
+
udid: import_zod15.z.string().optional().describe("Simulator udid, if more than one is booted.")
|
|
3671
|
+
}
|
|
3672
|
+
},
|
|
3673
|
+
async (args) => {
|
|
3674
|
+
const blocked = gate("camera_launch");
|
|
3675
|
+
if (blocked) return blocked;
|
|
3676
|
+
const cmd = ["launch", args.bundleId];
|
|
3677
|
+
if (args.udid) cmd.push("--udid", args.udid);
|
|
3678
|
+
const result = await run(cmd);
|
|
3679
|
+
if (!result.ok) {
|
|
3680
|
+
return fail15(result.error ?? result.data?.error ?? "could not launch the app");
|
|
3681
|
+
}
|
|
3682
|
+
return text13(
|
|
3683
|
+
`Relaunched \`${args.bundleId}\` with the camera attached${result.data?.pid ? ` (pid ${result.data.pid})` : ""}.`
|
|
3684
|
+
);
|
|
3685
|
+
}
|
|
3686
|
+
);
|
|
3687
|
+
server.registerTool(
|
|
3688
|
+
"camera_diagnose",
|
|
3689
|
+
{
|
|
3690
|
+
description: "Work out why the simulator camera is not working. Checks that the pieces are present, a simulator is booted, something is publishing, SOMETHING IS READING IT, the library is loaded in the target app, no other tool owns the injection, and no camera library in the project disables simulator cameras at compile time.",
|
|
3691
|
+
inputSchema: {
|
|
3692
|
+
bundleId: import_zod15.z.string().optional().describe("Check a specific app \u2014 whether the library is actually loaded in it.")
|
|
3693
|
+
}
|
|
3694
|
+
},
|
|
3695
|
+
async (args) => {
|
|
3696
|
+
const cmd = ["diagnose"];
|
|
3697
|
+
if (args.bundleId) cmd.push(args.bundleId);
|
|
3698
|
+
const result = await run(cmd);
|
|
3699
|
+
if (!result.data?.checks) {
|
|
3700
|
+
return fail15(result.error ?? "could not run the simulator camera diagnosis");
|
|
3701
|
+
}
|
|
3702
|
+
const ent = readEntitlement();
|
|
3703
|
+
const tierNote = ent.isPro ? "" : "\n\n_This install is on the **free** tier, so the other `camera_*` tools are blocked. The camera still works by hand in the Buoy desktop panel._";
|
|
3704
|
+
return text13(describeDiagnosis(result.data.checks) + tierNote);
|
|
3705
|
+
}
|
|
3706
|
+
);
|
|
3707
|
+
server.registerTool(
|
|
3708
|
+
"camera_stop",
|
|
3709
|
+
{
|
|
3710
|
+
description: "Turn the simulator camera off and stop publishing frames. The camera stays on until stopped \u2014 across app relaunches and after a test finishes \u2014 so call this when done, or the next thing that opens a camera will still see the last source.",
|
|
3711
|
+
inputSchema: {}
|
|
3712
|
+
},
|
|
3713
|
+
async () => {
|
|
3714
|
+
const blocked = gate("camera_stop");
|
|
3715
|
+
if (blocked) return blocked;
|
|
3716
|
+
const result = await run(["stop"]);
|
|
3717
|
+
if (!result.ok) {
|
|
3718
|
+
return fail15(result.error ?? result.data?.error ?? "could not stop the camera");
|
|
3719
|
+
}
|
|
3720
|
+
return text13("The simulator camera is off.");
|
|
3721
|
+
}
|
|
3722
|
+
);
|
|
3723
|
+
server.registerTool(
|
|
3724
|
+
"camera_devices",
|
|
3725
|
+
{
|
|
3726
|
+
description: "List booted simulators and the apps installed on one. Use this to find the bundle id `camera_launch` needs, or the udid to pass when more than one simulator is booted. Lists every app on the simulator, not just Buoy-integrated ones \u2014 the camera works on any of them.",
|
|
3727
|
+
inputSchema: {
|
|
3728
|
+
udid: import_zod15.z.string().optional().describe("Which simulator's apps to list. Only needed when several are booted.")
|
|
3729
|
+
}
|
|
3730
|
+
},
|
|
3731
|
+
async (args) => {
|
|
3732
|
+
const blocked = gate("camera_devices");
|
|
3733
|
+
if (blocked) return blocked;
|
|
3734
|
+
const devicesResult = await run(["devices"]);
|
|
3735
|
+
if (!devicesResult.ok || !devicesResult.data) {
|
|
3736
|
+
return fail15(devicesResult.error ?? "could not list booted simulators");
|
|
3737
|
+
}
|
|
3738
|
+
const devices = devicesResult.data.devices ?? [];
|
|
3739
|
+
let apps = null;
|
|
3740
|
+
if (devices.length === 1 || args.udid) {
|
|
3741
|
+
const appsResult = await run([
|
|
3742
|
+
"apps",
|
|
3743
|
+
...args.udid ? ["--udid", args.udid] : []
|
|
3744
|
+
]);
|
|
3745
|
+
apps = appsResult.ok ? appsResult.data?.apps ?? [] : null;
|
|
3746
|
+
}
|
|
3747
|
+
return text13(describeDevices(devices, apps));
|
|
3748
|
+
}
|
|
3749
|
+
);
|
|
3750
|
+
server.registerTool(
|
|
3751
|
+
"camera_inputs",
|
|
3752
|
+
{
|
|
3753
|
+
description: "List what this Mac can point the simulator camera at: its webcams (the uniqueId for `camera_source` with kind `camera`) and the windows the screen source can film (the id for `window:<id>`). Call this before choosing a `camera` or windowed `screen` source \u2014 those ids cannot be guessed.",
|
|
3754
|
+
inputSchema: {}
|
|
3755
|
+
},
|
|
3756
|
+
async () => {
|
|
3757
|
+
const blocked = gate("camera_inputs");
|
|
3758
|
+
if (blocked) return blocked;
|
|
3759
|
+
const [cams, wins] = await Promise.all([
|
|
3760
|
+
run(["cameras"]),
|
|
3761
|
+
run(["windows"])
|
|
3762
|
+
]);
|
|
3763
|
+
if (!cams.ok && !wins.ok) {
|
|
3764
|
+
return fail15(
|
|
3765
|
+
cams.error ?? wins.error ?? "could not list the Mac's cameras or windows"
|
|
3766
|
+
);
|
|
3767
|
+
}
|
|
3768
|
+
return text13(
|
|
3769
|
+
describeInputs(cams.data?.cameras ?? [], wins.data?.windows ?? [])
|
|
3770
|
+
);
|
|
3771
|
+
}
|
|
3772
|
+
);
|
|
3773
|
+
server.registerTool(
|
|
3774
|
+
"camera_zero_setup",
|
|
3775
|
+
{
|
|
3776
|
+
description: "Make every app the simulator launches get a camera, however it was launched \u2014 `expo start`, `react-native run-ios`, Xcode, a test runner. Use this when you are not the one starting the app, so `camera_launch` is not an option. It loads Buoy's library into every process in that simulator, SpringBoard included, so turn it off when finished.",
|
|
3777
|
+
inputSchema: {
|
|
3778
|
+
action: import_zod15.z.enum(["on", "off", "status"]).describe("Turn it on, off, or report the current state."),
|
|
3779
|
+
udid: import_zod15.z.string().optional().describe("Which simulator. Only needed when several are booted.")
|
|
3780
|
+
}
|
|
3781
|
+
},
|
|
3782
|
+
async (args) => {
|
|
3783
|
+
const blocked = gate("camera_zero_setup");
|
|
3784
|
+
if (blocked) return blocked;
|
|
3785
|
+
const result = await run(["zero-setup", args.action, ...args.udid ? ["--udid", args.udid] : []]);
|
|
3786
|
+
if (!result.ok) {
|
|
3787
|
+
return fail15(
|
|
3788
|
+
result.error ?? result.data?.error ?? "could not change zero-setup mode"
|
|
3789
|
+
);
|
|
3790
|
+
}
|
|
3791
|
+
const d = result.data ?? {};
|
|
3792
|
+
if (args.action === "status") {
|
|
3793
|
+
if (!d.enabled) return text13("Zero-setup mode is **off**.");
|
|
3794
|
+
return text13(
|
|
3795
|
+
d.foreign ? `Zero-setup is on, but **another tool owns it** (\`${d.path}\`). Quit that tool before turning Buoy's on.` : "Zero-setup mode is **on** \u2014 anything this simulator launches gets the camera."
|
|
3796
|
+
);
|
|
3797
|
+
}
|
|
3798
|
+
if (args.action === "on") {
|
|
3799
|
+
return text13(
|
|
3800
|
+
"Zero-setup mode is **on**. Anything this simulator launches from now on gets the camera \u2014 start your app however you normally would.\n\n_This loads the library into every process in the simulator. Turn it off with `camera_zero_setup` action `off` when you are done._"
|
|
3801
|
+
);
|
|
3802
|
+
}
|
|
3803
|
+
return text13("Zero-setup mode is **off**.");
|
|
3804
|
+
}
|
|
3805
|
+
);
|
|
3806
|
+
}
|
|
3807
|
+
|
|
3808
|
+
// src/tools/packs/interact.ts
|
|
3809
|
+
var import_zod16 = require("zod");
|
|
3810
|
+
var TOOL_ID2 = "highlight-updates";
|
|
3811
|
+
var text14 = (s) => ({ content: [{ type: "text", text: s }] });
|
|
3812
|
+
var fail16 = (message) => ({
|
|
3813
|
+
isError: true,
|
|
3814
|
+
content: [{ type: "text", text: message }]
|
|
3815
|
+
});
|
|
3447
3816
|
var errMsg15 = (e) => e instanceof Error ? e.message : String(e);
|
|
3448
3817
|
function formatElement(e) {
|
|
3449
3818
|
let line = e.interactive ? "\u2022 " : " ";
|
|
@@ -3467,8 +3836,8 @@ function registerInteractTools(server, sync) {
|
|
|
3467
3836
|
{
|
|
3468
3837
|
description: "List the interactive / labeled elements currently on screen \u2014 the app's live accessibility-style tree walked from the React fiber tree. Each row shows the component name, visible text/label, role, testID, a normalized tap point (tap: x,y in 0\u20131), and its #nativeTag. Rows marked with \u2022 are tappable (have an onPress). Use this to see what's on screen and pick something to tap with tap_element \u2014 no screenshot needed. If you already know the sequence you want to drive, `run_flow` does the whole thing (taps, waits, assertions) in one call instead. Re-run after navigating or when the screen changes, since positions move. Requires Buoy Pro.",
|
|
3469
3838
|
inputSchema: {
|
|
3470
|
-
interactiveOnly:
|
|
3471
|
-
deviceId:
|
|
3839
|
+
interactiveOnly: import_zod16.z.boolean().optional().describe("Only return tappable (onPress) elements. Default false (include labels/text for context)."),
|
|
3840
|
+
deviceId: import_zod16.z.string().optional().describe("Target device id (auto-selected if one is connected).")
|
|
3472
3841
|
}
|
|
3473
3842
|
},
|
|
3474
3843
|
async (args) => {
|
|
@@ -3478,16 +3847,16 @@ function registerInteractTools(server, sync) {
|
|
|
3478
3847
|
const all = res?.elements ?? [];
|
|
3479
3848
|
const elements = args.interactiveOnly ? all.filter((e) => e.interactive) : all;
|
|
3480
3849
|
if (elements.length === 0) {
|
|
3481
|
-
return
|
|
3850
|
+
return text14(
|
|
3482
3851
|
"No elements found on screen. If the app just navigated, wait a moment and retry; make sure highlight-updates is enabled in the app."
|
|
3483
3852
|
);
|
|
3484
3853
|
}
|
|
3485
3854
|
const header = `Screen ${res.screen.width}\xD7${res.screen.height} \u2014 ${elements.length} element${elements.length === 1 ? "" : "s"} (\u2022 = tappable). Tap with tap_element({ testID | query | nativeTag }).`;
|
|
3486
|
-
return
|
|
3855
|
+
return text14(`${header}
|
|
3487
3856
|
|
|
3488
3857
|
${elements.map(formatElement).join("\n")}`);
|
|
3489
3858
|
} catch (e) {
|
|
3490
|
-
return
|
|
3859
|
+
return fail16(errMsg15(e));
|
|
3491
3860
|
}
|
|
3492
3861
|
}
|
|
3493
3862
|
);
|
|
@@ -3496,20 +3865,20 @@ ${elements.map(formatElement).join("\n")}`);
|
|
|
3496
3865
|
{
|
|
3497
3866
|
description: "Interact with an on-screen element by invoking its handler directly in JS (no screenshot, no coordinate math, works on real devices). Handles buttons (onPress + onLongPress), toggles/switches and sliders (onValueChange), and text inputs (onChangeText) \u2014 see each element's `control` in describe_screen. Identify the target with an exact `nativeTag` or `testID`, or a fuzzy `query`. Pass `longPress:true` to invoke onLongPress instead of onPress (elements that support it show {long-press} in describe_screen). For a toggle, pass `value:true/false` (omit to flip); for a slider, pass a numeric `value` (omit to jump to the far end); for a text input, pass `text`. If the element is off-screen it's scrolled into view first (scrollIntoView:false to skip). Call describe_screen first to see options + current values. Driving MORE THAN ONE step (reproducing a bug, verifying a fix)? Use `run_flow` instead \u2014 it runs the whole sequence in one call. Requires Buoy Pro.",
|
|
3498
3867
|
inputSchema: {
|
|
3499
|
-
nativeTag:
|
|
3500
|
-
testID:
|
|
3501
|
-
query:
|
|
3502
|
-
value:
|
|
3503
|
-
text:
|
|
3504
|
-
longPress:
|
|
3505
|
-
scrollIntoView:
|
|
3506
|
-
deviceId:
|
|
3868
|
+
nativeTag: import_zod16.z.number().optional().describe("Exact nativeTag from describe_screen (most precise)."),
|
|
3869
|
+
testID: import_zod16.z.string().optional().describe("Exact testID of the element."),
|
|
3870
|
+
query: import_zod16.z.string().optional().describe('Fuzzy match against testID / label / visible text / component name \u2014 e.g. "Sign in".'),
|
|
3871
|
+
value: import_zod16.z.union([import_zod16.z.number(), import_zod16.z.boolean()]).optional().describe("For a toggle: true/false (omit to flip). For a slider: the numeric value (omit to jump to the far end)."),
|
|
3872
|
+
text: import_zod16.z.string().optional().describe("For a text input: the string to set via onChangeText."),
|
|
3873
|
+
longPress: import_zod16.z.boolean().optional().describe("Invoke the element's onLongPress instead of onPress. Fails with a clear reason if the element has no onLongPress handler."),
|
|
3874
|
+
scrollIntoView: import_zod16.z.boolean().optional().describe("Scroll the target into view first if it's off-screen. Default true."),
|
|
3875
|
+
deviceId: import_zod16.z.string().optional().describe("Target device id (auto-selected if one is connected).")
|
|
3507
3876
|
}
|
|
3508
3877
|
},
|
|
3509
3878
|
async (args) => {
|
|
3510
3879
|
try {
|
|
3511
3880
|
if (args.nativeTag == null && !args.testID && !args.query) {
|
|
3512
|
-
return
|
|
3881
|
+
return fail16("Provide one of: nativeTag, testID, or query (from describe_screen).");
|
|
3513
3882
|
}
|
|
3514
3883
|
const target = sync.requireProDevice(args.deviceId);
|
|
3515
3884
|
const res = await sync.callAction(
|
|
@@ -3534,25 +3903,25 @@ ${elements.map(formatElement).join("\n")}`);
|
|
|
3534
3903
|
const id = m.testID ? ` [testID=${m.testID}]` : m.nativeTag != null ? ` #${m.nativeTag}` : "";
|
|
3535
3904
|
const scrolledNote = res.scrolled ? " (scrolled into view)" : "";
|
|
3536
3905
|
const verb = m.via === "onValueChange" ? `Set "${label}"${id} \u2192 ${JSON.stringify(m.value)}` : m.via === "onChangeText" ? `Typed ${JSON.stringify(m.value)} into "${label}"${id}` : m.via === "onLongPress" ? `Long-pressed "${label}"${id}` : `Tapped "${label}"${id}`;
|
|
3537
|
-
return
|
|
3906
|
+
return text14(`${verb}${scrolledNote}.${flowTip}`);
|
|
3538
3907
|
}
|
|
3539
3908
|
let msg = res?.reason ?? "Tap failed.";
|
|
3540
3909
|
if (res?.candidates?.length) {
|
|
3541
3910
|
msg += "\n\nTappable candidates:\n" + res.candidates.map((c) => `- ${c.name}${c.text ? ` "${c.text}"` : ""}${c.testID ? ` [testID=${c.testID}]` : ""}${c.nativeTag != null ? ` #${c.nativeTag}` : ""}`).join("\n");
|
|
3542
3911
|
}
|
|
3543
|
-
return
|
|
3912
|
+
return fail16(msg);
|
|
3544
3913
|
} catch (e) {
|
|
3545
|
-
return
|
|
3914
|
+
return fail16(errMsg15(e));
|
|
3546
3915
|
}
|
|
3547
3916
|
}
|
|
3548
3917
|
);
|
|
3549
3918
|
}
|
|
3550
3919
|
|
|
3551
3920
|
// src/tools/packs/jsThread.ts
|
|
3552
|
-
var
|
|
3921
|
+
var import_zod17 = require("zod");
|
|
3553
3922
|
var JS_TOP_TOOL_ID = "js-top";
|
|
3554
|
-
var
|
|
3555
|
-
var
|
|
3923
|
+
var text15 = (s) => ({ content: [{ type: "text", text: s }] });
|
|
3924
|
+
var fail17 = (message) => ({ isError: true, content: [{ type: "text", text: message }] });
|
|
3556
3925
|
var errMsg16 = (e) => e instanceof Error ? e.message : String(e);
|
|
3557
3926
|
var SPARK_CHARS = "\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";
|
|
3558
3927
|
function sparkline(values) {
|
|
@@ -3624,9 +3993,9 @@ function registerJsThreadTools(server, sync) {
|
|
|
3624
3993
|
{
|
|
3625
3994
|
description: 'Task Manager for the React Native JS thread: sample for a few seconds and return a ranked table of which task origins (timers, Promise chains, rAF callbacks, bridge call-ins) consumed JS-thread time \u2014 plus thread busy% and freeze (50ms+ block) attribution. Use when JS FPS is low and you need to know WHAT is eating the thread. To profile one specific interaction, pass clearFirst:true, then drive the UI with tap_element while the sample runs. Drill into a row with get_js_thread_origin_detail. NOT the tool for React components re-rendering too often \u2014 this measures TASKS on the thread, not renders; for "the page re-renders constantly / typing lags / tapping one button re-renders everything" use measure_renders. Requires @buoy-gg/js-top on the device.',
|
|
3626
3995
|
inputSchema: {
|
|
3627
|
-
deviceId:
|
|
3628
|
-
durationMs:
|
|
3629
|
-
clearFirst:
|
|
3996
|
+
deviceId: import_zod17.z.string().optional().describe("Target device id (auto-selected if one is connected)."),
|
|
3997
|
+
durationMs: import_zod17.z.number().optional().describe("How long to sample before reading the table. Default 3000, max 30000."),
|
|
3998
|
+
clearFirst: import_zod17.z.boolean().optional().describe("Reset all stats before sampling, so the result attributes only what happens during this sample.")
|
|
3630
3999
|
}
|
|
3631
4000
|
},
|
|
3632
4001
|
async ({ deviceId, durationMs, clearFirst }) => {
|
|
@@ -3639,7 +4008,7 @@ function registerJsThreadTools(server, sync) {
|
|
|
3639
4008
|
{ durationMs: duration, clearFirst: clearFirst === true },
|
|
3640
4009
|
target
|
|
3641
4010
|
);
|
|
3642
|
-
if (!snap) return
|
|
4011
|
+
if (!snap) return fail17("Device returned no snapshot \u2014 is @buoy-gg/js-top installed in the app?");
|
|
3643
4012
|
const md = formatTopMarkdown(snap, duration);
|
|
3644
4013
|
const slim = {
|
|
3645
4014
|
busyPct: Math.round(snap.busyPct * 10) / 10,
|
|
@@ -3658,13 +4027,13 @@ function registerJsThreadTools(server, sync) {
|
|
|
3658
4027
|
worstFreezeMs: r.worstFreezeMs
|
|
3659
4028
|
}))
|
|
3660
4029
|
};
|
|
3661
|
-
return
|
|
4030
|
+
return text15(`${md}
|
|
3662
4031
|
|
|
3663
4032
|
\`\`\`json
|
|
3664
4033
|
${JSON.stringify(slim)}
|
|
3665
4034
|
\`\`\``);
|
|
3666
4035
|
} catch (e) {
|
|
3667
|
-
return
|
|
4036
|
+
return fail17(errMsg16(e));
|
|
3668
4037
|
}
|
|
3669
4038
|
}
|
|
3670
4039
|
);
|
|
@@ -3673,8 +4042,8 @@ ${JSON.stringify(slim)}
|
|
|
3673
4042
|
{
|
|
3674
4043
|
description: 'Inspect one js-top task origin in depth: schedules vs runs, avg/max/total exclusive ms, a 5s activity sparkline, freeze attribution, and the captured scheduling site (caller function + stack frames). Pass a row `key` from get_js_thread_top\'s JSON (e.g. "interval|pollFeed" or "unattributed" for the system row).',
|
|
3675
4044
|
inputSchema: {
|
|
3676
|
-
deviceId:
|
|
3677
|
-
key:
|
|
4045
|
+
deviceId: import_zod17.z.string().optional().describe("Target device id (auto-selected if one is connected)."),
|
|
4046
|
+
key: import_zod17.z.string().describe("Origin key from get_js_thread_top's JSON rows.")
|
|
3678
4047
|
}
|
|
3679
4048
|
},
|
|
3680
4049
|
async ({ deviceId, key }) => {
|
|
@@ -3687,18 +4056,18 @@ ${JSON.stringify(slim)}
|
|
|
3687
4056
|
target
|
|
3688
4057
|
);
|
|
3689
4058
|
if (!detail) {
|
|
3690
|
-
return
|
|
4059
|
+
return fail17(
|
|
3691
4060
|
`Origin "${key}" is not tracked (cleared, evicted, or never existed). Re-run get_js_thread_top for current keys.`
|
|
3692
4061
|
);
|
|
3693
4062
|
}
|
|
3694
4063
|
const md = formatDetailMarkdown(detail);
|
|
3695
|
-
return
|
|
4064
|
+
return text15(`${md}
|
|
3696
4065
|
|
|
3697
4066
|
\`\`\`json
|
|
3698
4067
|
${JSON.stringify(detail)}
|
|
3699
4068
|
\`\`\``);
|
|
3700
4069
|
} catch (e) {
|
|
3701
|
-
return
|
|
4070
|
+
return fail17(errMsg16(e));
|
|
3702
4071
|
}
|
|
3703
4072
|
}
|
|
3704
4073
|
);
|
|
@@ -3707,26 +4076,26 @@ ${JSON.stringify(detail)}
|
|
|
3707
4076
|
{
|
|
3708
4077
|
description: "Reset the js-top task table, freeze history, and busy history on the device (fresh measurement window).",
|
|
3709
4078
|
inputSchema: {
|
|
3710
|
-
deviceId:
|
|
4079
|
+
deviceId: import_zod17.z.string().optional().describe("Target device id (auto-selected if one is connected).")
|
|
3711
4080
|
}
|
|
3712
4081
|
},
|
|
3713
4082
|
async ({ deviceId }) => {
|
|
3714
4083
|
try {
|
|
3715
4084
|
const target = sync.requireProDevice(deviceId);
|
|
3716
4085
|
await sync.callAction(JS_TOP_TOOL_ID, "clear", {}, target);
|
|
3717
|
-
return
|
|
4086
|
+
return text15("Cleared js-top stats.");
|
|
3718
4087
|
} catch (e) {
|
|
3719
|
-
return
|
|
4088
|
+
return fail17(errMsg16(e));
|
|
3720
4089
|
}
|
|
3721
4090
|
}
|
|
3722
4091
|
);
|
|
3723
4092
|
}
|
|
3724
4093
|
|
|
3725
4094
|
// src/tools/packs/images.ts
|
|
3726
|
-
var
|
|
4095
|
+
var import_zod18 = require("zod");
|
|
3727
4096
|
var IMAGES_TOOL_ID = "images";
|
|
3728
|
-
var
|
|
3729
|
-
var
|
|
4097
|
+
var text16 = (s) => ({ content: [{ type: "text", text: s }] });
|
|
4098
|
+
var fail18 = (message) => ({ isError: true, content: [{ type: "text", text: message }] });
|
|
3730
4099
|
var errMsg17 = (e) => e instanceof Error ? e.message : String(e);
|
|
3731
4100
|
function uriTail(uri) {
|
|
3732
4101
|
if (!uri) return "(no source)";
|
|
@@ -3815,9 +4184,9 @@ function registerImagesTools(server, sync) {
|
|
|
3815
4184
|
{
|
|
3816
4185
|
description: "Live image registry from the app: every RN <Image> and expo-image load with cache verdict (memory/disk/network), load ms, decoded vs displayed size with an oversize/upscale verdict and wasted-KB estimate, error details, and any active simulation overrides. Image HTTP never hits the JS network stack, so this is the only visibility into image loading. Requires @buoy-gg/images on the device.",
|
|
3817
4186
|
inputSchema: {
|
|
3818
|
-
deviceId:
|
|
3819
|
-
limit:
|
|
3820
|
-
status:
|
|
4187
|
+
deviceId: import_zod18.z.string().optional().describe("Target device id (auto-selected if one is connected)."),
|
|
4188
|
+
limit: import_zod18.z.number().optional().describe("Max records to return (newest first). Default 30, max 200."),
|
|
4189
|
+
status: import_zod18.z.enum(["pending", "loading", "loaded", "error"]).optional().describe("Only records in this state (e.g. 'error' for the failure log).")
|
|
3821
4190
|
}
|
|
3822
4191
|
},
|
|
3823
4192
|
async ({ deviceId, limit, status }) => {
|
|
@@ -3830,7 +4199,7 @@ function registerImagesTools(server, sync) {
|
|
|
3830
4199
|
{ limit: capped, status },
|
|
3831
4200
|
target
|
|
3832
4201
|
);
|
|
3833
|
-
if (!list) return
|
|
4202
|
+
if (!list) return fail18("Device returned nothing \u2014 is @buoy-gg/images installed in the app?");
|
|
3834
4203
|
const md = formatListMarkdown(list, capped);
|
|
3835
4204
|
const slim = {
|
|
3836
4205
|
stats: list.stats,
|
|
@@ -3857,13 +4226,13 @@ function registerImagesTools(server, sync) {
|
|
|
3857
4226
|
layoutShifts: r.layoutShifts
|
|
3858
4227
|
}))
|
|
3859
4228
|
};
|
|
3860
|
-
return
|
|
4229
|
+
return text16(`${md}
|
|
3861
4230
|
|
|
3862
4231
|
\`\`\`json
|
|
3863
4232
|
${JSON.stringify(slim)}
|
|
3864
4233
|
\`\`\``);
|
|
3865
4234
|
} catch (e) {
|
|
3866
|
-
return
|
|
4235
|
+
return fail18(errMsg17(e));
|
|
3867
4236
|
}
|
|
3868
4237
|
}
|
|
3869
4238
|
);
|
|
@@ -3872,9 +4241,9 @@ ${JSON.stringify(slim)}
|
|
|
3872
4241
|
{
|
|
3873
4242
|
description: "Act on one image from get_images (by id): hard_reload (bypass caches + refetch), retry, evict_disk (expo disk entry), flash (red border to locate it on screen), prove_savings (re-encode at displayed size as WebP ON DEVICE and return real byte savings + a previewable file:// uri), or simulation overrides \u2014 force_error (instant offline-safe failure), force_loading (request hangs forever), force_blank, swap_url (requires url), restore (remove override). Returns the record's state after the action so the effect is visible.",
|
|
3874
4243
|
inputSchema: {
|
|
3875
|
-
deviceId:
|
|
3876
|
-
id:
|
|
3877
|
-
action:
|
|
4244
|
+
deviceId: import_zod18.z.string().optional().describe("Target device id (auto-selected if one is connected)."),
|
|
4245
|
+
id: import_zod18.z.number().describe("Record id from get_images."),
|
|
4246
|
+
action: import_zod18.z.enum([
|
|
3878
4247
|
"hard_reload",
|
|
3879
4248
|
"retry",
|
|
3880
4249
|
"evict_disk",
|
|
@@ -3886,7 +4255,7 @@ ${JSON.stringify(slim)}
|
|
|
3886
4255
|
"swap_url",
|
|
3887
4256
|
"restore"
|
|
3888
4257
|
]).describe("What to do."),
|
|
3889
|
-
url:
|
|
4258
|
+
url: import_zod18.z.string().optional().describe("Replacement URL (swap_url only).")
|
|
3890
4259
|
}
|
|
3891
4260
|
},
|
|
3892
4261
|
async ({ deviceId, id, action, url }) => {
|
|
@@ -3894,8 +4263,8 @@ ${JSON.stringify(slim)}
|
|
|
3894
4263
|
const target = sync.requireProDevice(deviceId);
|
|
3895
4264
|
if (action === "prove_savings") {
|
|
3896
4265
|
const savings = await sync.callAction(IMAGES_TOOL_ID, "proveSavings", { id }, target);
|
|
3897
|
-
if (!savings) return
|
|
3898
|
-
if (!savings.ok) return
|
|
4266
|
+
if (!savings) return fail18("Device returned nothing for proveSavings.");
|
|
4267
|
+
if (!savings.ok) return fail18(savings.message);
|
|
3899
4268
|
const parts = [`**prove_savings** on #${id}: ${savings.message}`];
|
|
3900
4269
|
if (savings.originalBytes != null)
|
|
3901
4270
|
parts.push(`Original: ${Math.round(savings.originalBytes / 1024)}KB (${savings.originalBytesSource})`);
|
|
@@ -3907,11 +4276,11 @@ ${JSON.stringify(slim)}
|
|
|
3907
4276
|
parts.push(`**Saved: ${Math.round(savings.savedBytes / 1024)}KB (${savings.savedPct}%)**`);
|
|
3908
4277
|
if (savings.optimizedUri)
|
|
3909
4278
|
parts.push(`Preview in place: image_action {id:${id}, action:"swap_url", url:"${savings.optimizedUri}"}`);
|
|
3910
|
-
return
|
|
4279
|
+
return text16(parts.join("\n"));
|
|
3911
4280
|
}
|
|
3912
4281
|
const entry = ACTION_MAP[action];
|
|
3913
|
-
if (!entry) return
|
|
3914
|
-
if (action === "swap_url" && !url) return
|
|
4282
|
+
if (!entry) return fail18(`Unknown action: ${action}`);
|
|
4283
|
+
if (action === "swap_url" && !url) return fail18("swap_url requires the `url` param.");
|
|
3915
4284
|
const result = await sync.callAction(
|
|
3916
4285
|
IMAGES_TOOL_ID,
|
|
3917
4286
|
entry.action,
|
|
@@ -3931,9 +4300,9 @@ ${JSON.stringify(slim)}
|
|
|
3931
4300
|
);
|
|
3932
4301
|
if (detail.error) lines.push(`Error: ${detail.error}`);
|
|
3933
4302
|
}
|
|
3934
|
-
return
|
|
4303
|
+
return text16(lines.join("\n"));
|
|
3935
4304
|
} catch (e) {
|
|
3936
|
-
return
|
|
4305
|
+
return fail18(errMsg17(e));
|
|
3937
4306
|
}
|
|
3938
4307
|
}
|
|
3939
4308
|
);
|
|
@@ -3942,12 +4311,12 @@ ${JSON.stringify(slim)}
|
|
|
3942
4311
|
{
|
|
3943
4312
|
description: "App-wide image simulation modes: network 'offline' (every NETWORK image load fails immediately, both libs \u2014 bundled assets still load; reload/remount on-screen images to see it), 'cold' (every image bypasses caches \u2014 first-launch behavior, nothing cleared), 'normal' to reset. blankImages renders every image without a source. massAction applies per-image simulations to everything mounted. Also clears the registry or expo caches when asked.",
|
|
3944
4313
|
inputSchema: {
|
|
3945
|
-
deviceId:
|
|
3946
|
-
network:
|
|
3947
|
-
blankImages:
|
|
3948
|
-
massAction:
|
|
3949
|
-
clearRegistry:
|
|
3950
|
-
clearExpoCaches:
|
|
4314
|
+
deviceId: import_zod18.z.string().optional().describe("Target device id (auto-selected if one is connected)."),
|
|
4315
|
+
network: import_zod18.z.enum(["normal", "offline", "cold"]).optional().describe("Network simulation mode."),
|
|
4316
|
+
blankImages: import_zod18.z.boolean().optional().describe("Render all images without a source."),
|
|
4317
|
+
massAction: import_zod18.z.enum(["error", "loading", "blank", "reload", "flash", "restore"]).optional().describe("Apply to EVERY mounted image at once: force error/loading/blank overrides, hard-reload all, flash all, or restore all overrides."),
|
|
4318
|
+
clearRegistry: import_zod18.z.boolean().optional().describe("Clear the captured image log."),
|
|
4319
|
+
clearExpoCaches: import_zod18.z.boolean().optional().describe("Clear expo-image memory + disk caches.")
|
|
3951
4320
|
}
|
|
3952
4321
|
},
|
|
3953
4322
|
async ({ deviceId, network, blankImages, massAction, clearRegistry, clearExpoCaches }) => {
|
|
@@ -3974,17 +4343,17 @@ ${JSON.stringify(slim)}
|
|
|
3974
4343
|
const r = await sync.callAction(IMAGES_TOOL_ID, "clearExpoCaches", {}, target);
|
|
3975
4344
|
done.push(r?.message ?? "expo caches cleared");
|
|
3976
4345
|
}
|
|
3977
|
-
if (done.length === 0) return
|
|
3978
|
-
return
|
|
4346
|
+
if (done.length === 0) return fail18("Pass at least one of: network, blankImages, massAction, clearRegistry, clearExpoCaches.");
|
|
4347
|
+
return text16(`Applied: ${done.join(" \xB7 ")}`);
|
|
3979
4348
|
} catch (e) {
|
|
3980
|
-
return
|
|
4349
|
+
return fail18(errMsg17(e));
|
|
3981
4350
|
}
|
|
3982
4351
|
}
|
|
3983
4352
|
);
|
|
3984
4353
|
}
|
|
3985
4354
|
|
|
3986
4355
|
// src/tools/packs/assets.ts
|
|
3987
|
-
var
|
|
4356
|
+
var import_zod19 = require("zod");
|
|
3988
4357
|
|
|
3989
4358
|
// src/tools/packs/assetsGraphNote.ts
|
|
3990
4359
|
function graphUnavailableNote(ss) {
|
|
@@ -3999,8 +4368,8 @@ function graphUnavailableNote(ss) {
|
|
|
3999
4368
|
|
|
4000
4369
|
// src/tools/packs/assets.ts
|
|
4001
4370
|
var ASSETS_TOOL_ID = "assets";
|
|
4002
|
-
var
|
|
4003
|
-
var
|
|
4371
|
+
var text17 = (s) => ({ content: [{ type: "text", text: s }] });
|
|
4372
|
+
var fail19 = (message) => ({ isError: true, content: [{ type: "text", text: message }] });
|
|
4004
4373
|
var errMsg18 = (e) => e instanceof Error ? e.message : String(e);
|
|
4005
4374
|
function kb2(bytes) {
|
|
4006
4375
|
if (bytes == null || bytes <= 0) return "\u2013";
|
|
@@ -4089,10 +4458,10 @@ function registerAssetsTools(server, sync) {
|
|
|
4089
4458
|
{
|
|
4090
4459
|
description: "Bundled-asset inventory from the app: every asset (images, fonts, video, audio) with dimensions, @1x/@2x/@3x scale coverage, byte sizes (measured from the Metro server in dev), loaded vs never-loaded state, and audit findings \u2014 duplicates (by content hash), shipped-but-never-loaded, WebP candidates, images decoding larger than the screen, heavy GIFs/fonts, scale gaps \u2014 plus the change vs a saved baseline. This is what the app SHIPS; use get_images for what it RENDERS. Requires @buoy-gg/assets on the device.",
|
|
4091
4460
|
inputSchema: {
|
|
4092
|
-
deviceId:
|
|
4093
|
-
limit:
|
|
4094
|
-
kind:
|
|
4095
|
-
unusedOnly:
|
|
4461
|
+
deviceId: import_zod19.z.string().optional().describe("Target device id (auto-selected if one is connected)."),
|
|
4462
|
+
limit: import_zod19.z.number().optional().describe("Max records to return (largest first). Default 40, max 500."),
|
|
4463
|
+
kind: import_zod19.z.enum(["image", "font", "video", "audio", "data", "other"]).optional().describe("Only assets of this kind."),
|
|
4464
|
+
unusedOnly: import_zod19.z.boolean().optional().describe("Only assets shipped in the bundle but never loaded at runtime.")
|
|
4096
4465
|
}
|
|
4097
4466
|
},
|
|
4098
4467
|
async ({ deviceId, limit, kind, unusedOnly }) => {
|
|
@@ -4105,7 +4474,7 @@ function registerAssetsTools(server, sync) {
|
|
|
4105
4474
|
{ limit: unusedOnly ? 500 : capped, kind, loadedOnly: false },
|
|
4106
4475
|
target
|
|
4107
4476
|
);
|
|
4108
|
-
if (!list) return
|
|
4477
|
+
if (!list) return fail19("Device returned nothing \u2014 is @buoy-gg/assets installed in the app?");
|
|
4109
4478
|
if (unusedOnly) {
|
|
4110
4479
|
list.records = list.records.filter((r) => !r.loaded).slice(0, capped);
|
|
4111
4480
|
}
|
|
@@ -4129,13 +4498,13 @@ function registerAssetsTools(server, sync) {
|
|
|
4129
4498
|
sizeSource: r.sizeSource
|
|
4130
4499
|
}))
|
|
4131
4500
|
};
|
|
4132
|
-
return
|
|
4501
|
+
return text17(`${md}
|
|
4133
4502
|
|
|
4134
4503
|
\`\`\`json
|
|
4135
4504
|
${JSON.stringify(slim)}
|
|
4136
4505
|
\`\`\``);
|
|
4137
4506
|
} catch (e) {
|
|
4138
|
-
return
|
|
4507
|
+
return fail19(errMsg18(e));
|
|
4139
4508
|
}
|
|
4140
4509
|
}
|
|
4141
4510
|
);
|
|
@@ -4144,9 +4513,9 @@ ${JSON.stringify(slim)}
|
|
|
4144
4513
|
{
|
|
4145
4514
|
description: "Drive the assets tool: rescan (re-walk the registry + merge the Metro bundle graph + refresh fonts + measure sizes \u2014 run this first if the inventory looks stale or empty), measure_sizes (re-measure byte sizes only), detail (full metadata for one asset by id: source dir, per-scale sizes, resolved URI, per-file graph paths), save_baseline (persist the current inventory for before/after comparison \u2014 save, make your change, then get_assets shows added/removed/grown/net bytes), clear_baseline, clear_records (wipe + rescan rebuilds).",
|
|
4146
4515
|
inputSchema: {
|
|
4147
|
-
deviceId:
|
|
4148
|
-
action:
|
|
4149
|
-
id:
|
|
4516
|
+
deviceId: import_zod19.z.string().optional().describe("Target device id (auto-selected if one is connected)."),
|
|
4517
|
+
action: import_zod19.z.enum(["rescan", "measure_sizes", "detail", "save_baseline", "clear_baseline", "clear_records"]).describe("What to do."),
|
|
4518
|
+
id: import_zod19.z.number().optional().describe("Asset id from get_assets (detail only).")
|
|
4150
4519
|
}
|
|
4151
4520
|
},
|
|
4152
4521
|
async ({ deviceId, action, id }) => {
|
|
@@ -4156,19 +4525,19 @@ ${JSON.stringify(slim)}
|
|
|
4156
4525
|
case "rescan": {
|
|
4157
4526
|
const result = await sync.callAction(ASSETS_TOOL_ID, "rescan", {}, target);
|
|
4158
4527
|
const ss = result?.scanStatus;
|
|
4159
|
-
if (!ss) return
|
|
4160
|
-
return
|
|
4528
|
+
if (!ss) return fail19("Device returned nothing for rescan.");
|
|
4529
|
+
return text17(
|
|
4161
4530
|
`Rescan done: ${ss.registryCount} registered at runtime` + (ss.graphCount != null ? ` \xB7 ${ss.graphCount} in the bundle graph` : " \xB7 no bundle graph") + (ss.graphError ? ` (graph: ${ss.graphError})` : "") + ` \xB7 ${ss.fontFamilies.length} font families` + (ss.measuring ? " \xB7 size measurement running \u2014 get_assets in a moment" : "")
|
|
4162
4531
|
);
|
|
4163
4532
|
}
|
|
4164
4533
|
case "measure_sizes": {
|
|
4165
4534
|
const result = await sync.callAction(ASSETS_TOOL_ID, "measureSizes", {}, target);
|
|
4166
|
-
return
|
|
4535
|
+
return text17(`Measured ${result?.measured ?? 0} of ${result?.total ?? 0} assets.`);
|
|
4167
4536
|
}
|
|
4168
4537
|
case "detail": {
|
|
4169
|
-
if (id == null) return
|
|
4538
|
+
if (id == null) return fail19("detail requires the `id` param (from get_assets).");
|
|
4170
4539
|
const detail = await sync.callAction(ASSETS_TOOL_ID, "getDetail", { id }, target);
|
|
4171
|
-
if (!detail) return
|
|
4540
|
+
if (!detail) return fail19(`Asset ${id} not found \u2014 re-run get_assets for current ids.`);
|
|
4172
4541
|
const lines = [
|
|
4173
4542
|
`## ${detail.name}.${detail.type} (#${detail.id})`,
|
|
4174
4543
|
"",
|
|
@@ -4186,32 +4555,32 @@ ${JSON.stringify(slim)}
|
|
|
4186
4555
|
if (detail.fileSystemLocation) lines.push(`- Source dir: ${detail.fileSystemLocation}`);
|
|
4187
4556
|
if (detail.files?.length) lines.push(`- Files: ${detail.files.join(", ")}`);
|
|
4188
4557
|
if (detail.uri) lines.push(`- Resolved URI: ${detail.uri}`);
|
|
4189
|
-
return
|
|
4558
|
+
return text17(lines.join("\n"));
|
|
4190
4559
|
}
|
|
4191
4560
|
case "save_baseline": {
|
|
4192
4561
|
const result = await sync.callAction(ASSETS_TOOL_ID, "saveBaseline", {}, target);
|
|
4193
|
-
return
|
|
4562
|
+
return text17(
|
|
4194
4563
|
`Baseline saved (${result?.assets ?? 0} assets). Make your change, then get_assets reports added/removed/grown/net bytes against it.`
|
|
4195
4564
|
);
|
|
4196
4565
|
}
|
|
4197
4566
|
case "clear_baseline": {
|
|
4198
4567
|
await sync.callAction(ASSETS_TOOL_ID, "clearBaseline", {}, target);
|
|
4199
|
-
return
|
|
4568
|
+
return text17("Baseline cleared.");
|
|
4200
4569
|
}
|
|
4201
4570
|
case "clear_records": {
|
|
4202
4571
|
const result = await sync.callAction(ASSETS_TOOL_ID, "clearRecords", {}, target);
|
|
4203
|
-
return
|
|
4572
|
+
return text17(result?.message ?? "Inventory cleared.");
|
|
4204
4573
|
}
|
|
4205
4574
|
}
|
|
4206
4575
|
} catch (e) {
|
|
4207
|
-
return
|
|
4576
|
+
return fail19(errMsg18(e));
|
|
4208
4577
|
}
|
|
4209
4578
|
}
|
|
4210
4579
|
);
|
|
4211
4580
|
}
|
|
4212
4581
|
|
|
4213
4582
|
// src/tools/packs/reload.ts
|
|
4214
|
-
var
|
|
4583
|
+
var import_zod20 = require("zod");
|
|
4215
4584
|
|
|
4216
4585
|
// src/capture/devServerReload.ts
|
|
4217
4586
|
var import_ws = require("ws");
|
|
@@ -4274,8 +4643,8 @@ var DEFAULT_WAIT_MS = 3e4;
|
|
|
4274
4643
|
var TEARDOWN_GRACE_MS = 1200;
|
|
4275
4644
|
var PROBE_TIMEOUT_MS = 1500;
|
|
4276
4645
|
var PROBE_INTERVAL_MS = 400;
|
|
4277
|
-
var
|
|
4278
|
-
var
|
|
4646
|
+
var text18 = (s) => ({ content: [{ type: "text", text: s }] });
|
|
4647
|
+
var fail20 = (message) => ({ isError: true, content: [{ type: "text", text: message }] });
|
|
4279
4648
|
var errMsg19 = (e) => e instanceof Error ? e.message : String(e);
|
|
4280
4649
|
var delay3 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
4281
4650
|
async function ping(sync, deviceId, timeoutMs) {
|
|
@@ -4315,12 +4684,12 @@ function registerReloadTools(server, sync) {
|
|
|
4315
4684
|
{
|
|
4316
4685
|
description: "Reload the running app's JS bundle (Expo Go, dev client, or RN CLI) \u2014 the equivalent of shaking the device and hitting Reload, but from here. Use it to pick up a change Fast Refresh didn't apply, to clear leaked in-memory state before a measurement, to re-run app startup, or to RECOVER A CRASHED APP: after a fatal error the other tools stop answering, and reloading is how you get them back (it falls through to the dev server when the app is too broken to reload itself). In dev builds it uses React Native's DevSettings.reload(); otherwise it falls back to expo-updates (if the app installs it). All in-memory state is lost \u2014 read anything you need from get_console/get_storage BEFORE reloading. By default this waits for the app to come back up and reports how long the reload took. Works on any app running @buoy-gg/core \u2014 no particular tool package needed. Requires Buoy Pro.",
|
|
4317
4686
|
inputSchema: {
|
|
4318
|
-
strategy:
|
|
4687
|
+
strategy: import_zod20.z.enum(["auto", "dev-settings", "expo-updates"]).optional().describe(
|
|
4319
4688
|
"Reload mechanism. 'auto' (default) uses DevSettings in dev builds and expo-updates otherwise. Force one only when debugging the reload itself."
|
|
4320
4689
|
),
|
|
4321
|
-
wait:
|
|
4322
|
-
timeoutMs:
|
|
4323
|
-
deviceId:
|
|
4690
|
+
wait: import_zod20.z.boolean().optional().describe("Wait for the app to come back before returning. Default true \u2014 turn off for fire-and-forget."),
|
|
4691
|
+
timeoutMs: import_zod20.z.number().optional().describe("How long to wait for the app to reconnect, in ms. Default 30000."),
|
|
4692
|
+
deviceId: import_zod20.z.string().optional().describe('Target device id (auto-selected if one is connected). Use "All" to reload every connected app.')
|
|
4324
4693
|
}
|
|
4325
4694
|
},
|
|
4326
4695
|
async (args) => {
|
|
@@ -4362,28 +4731,28 @@ function registerReloadTools(server, sync) {
|
|
|
4362
4731
|
}
|
|
4363
4732
|
const via = recovered ? ` via the dev server (the app was unresponsive \u2014 its own reload could not be reached)` : ack?.strategy ? ` via ${ack.strategy}` : "";
|
|
4364
4733
|
if (args.wait === false) {
|
|
4365
|
-
return
|
|
4734
|
+
return text18(`Reload requested${via}. The app is restarting \u2014 its in-memory state is gone; re-read anything you cached.`);
|
|
4366
4735
|
}
|
|
4367
4736
|
const elapsed = await waitForAppBack(sync, target, args.timeoutMs ?? DEFAULT_WAIT_MS, previousRealm);
|
|
4368
4737
|
if (elapsed == null) {
|
|
4369
|
-
return
|
|
4738
|
+
return fail20(
|
|
4370
4739
|
`Reload was accepted${via}, but the app hasn't reconnected yet. It may still be building the bundle (a cold Metro rebuild can take a while) \u2014 check the device, then run list_devices.`
|
|
4371
4740
|
);
|
|
4372
4741
|
}
|
|
4373
|
-
return
|
|
4742
|
+
return text18(
|
|
4374
4743
|
`Reloaded the app${via} \u2014 back and connected after ${(elapsed / 1e3).toFixed(1)}s. All in-memory state was reset, so re-read any state you cached before this.`
|
|
4375
4744
|
);
|
|
4376
4745
|
} catch (e) {
|
|
4377
|
-
return
|
|
4746
|
+
return fail20(errMsg19(e));
|
|
4378
4747
|
}
|
|
4379
4748
|
}
|
|
4380
4749
|
);
|
|
4381
4750
|
}
|
|
4382
4751
|
|
|
4383
4752
|
// src/tools/packs/triage.ts
|
|
4384
|
-
var
|
|
4385
|
-
var
|
|
4386
|
-
var
|
|
4753
|
+
var import_zod21 = require("zod");
|
|
4754
|
+
var text19 = (s) => ({ content: [{ type: "text", text: s }] });
|
|
4755
|
+
var fail21 = (message) => ({
|
|
4387
4756
|
isError: true,
|
|
4388
4757
|
content: [{ type: "text", text: message }]
|
|
4389
4758
|
});
|
|
@@ -4418,9 +4787,9 @@ async function otherBackends(sync, target, opts) {
|
|
|
4418
4787
|
return notes.length ? `
|
|
4419
4788
|
${notes.join(" \xB7 ")} \u2014 read with get_storage` : "";
|
|
4420
4789
|
}
|
|
4421
|
-
async function section(title,
|
|
4790
|
+
async function section(title, run2) {
|
|
4422
4791
|
try {
|
|
4423
|
-
const body = await
|
|
4792
|
+
const body = await run2();
|
|
4424
4793
|
return body ? `${title}
|
|
4425
4794
|
${body}` : null;
|
|
4426
4795
|
} catch (e) {
|
|
@@ -4439,7 +4808,7 @@ function registerTriageTools(server, sync) {
|
|
|
4439
4808
|
{
|
|
4440
4809
|
description: "START HERE when debugging a running app. One call = the app's current runtime state: connected device, recent console errors (including [FATAL] crashes), recent network requests with statuses, persisted storage values, and what's on screen right now. Use it as the first step for ANY 'why is the app doing X' question \u2014 it is far cheaper than calling get_console + get_network_requests + get_storage + describe_screen separately, and it tells you which of those to drill into next. If the app has crashed it says so and shows the crash. Requires Buoy Pro.",
|
|
4441
4810
|
inputSchema: {
|
|
4442
|
-
deviceId:
|
|
4811
|
+
deviceId: import_zod21.z.string().optional().describe("Target device id (auto-selected if one is connected).")
|
|
4443
4812
|
}
|
|
4444
4813
|
},
|
|
4445
4814
|
async (args) => {
|
|
@@ -4546,7 +4915,7 @@ _Values: get_storage includeValues:true_`;
|
|
|
4546
4915
|
|
|
4547
4916
|
\u{1F6D1} ${sync.unresponsiveNote(target)}` : "";
|
|
4548
4917
|
const body = [consoleSec, netSec, storeSec, screenSec].filter(Boolean).join("\n\n");
|
|
4549
|
-
return
|
|
4918
|
+
return text19(
|
|
4550
4919
|
`${head}${banner}
|
|
4551
4920
|
|
|
4552
4921
|
${body}
|
|
@@ -4554,18 +4923,18 @@ ${body}
|
|
|
4554
4923
|
_Drill in with get_console, get_network_requests (includeBodies:true for response bodies), get_storage (includeValues:true), describe_screen._`
|
|
4555
4924
|
);
|
|
4556
4925
|
} catch (e) {
|
|
4557
|
-
return
|
|
4926
|
+
return fail21(errMsg20(e));
|
|
4558
4927
|
}
|
|
4559
4928
|
}
|
|
4560
4929
|
);
|
|
4561
4930
|
}
|
|
4562
4931
|
|
|
4563
4932
|
// src/tools/packs/flow.ts
|
|
4564
|
-
var
|
|
4933
|
+
var import_zod22 = require("zod");
|
|
4565
4934
|
var UI_TOOL_ID = "highlight-updates";
|
|
4566
4935
|
var APP_TOOL_ID2 = "app";
|
|
4567
|
-
var
|
|
4568
|
-
var
|
|
4936
|
+
var text20 = (s) => ({ content: [{ type: "text", text: s }] });
|
|
4937
|
+
var fail22 = (message) => ({
|
|
4569
4938
|
isError: true,
|
|
4570
4939
|
content: [{ type: "text", text: message }]
|
|
4571
4940
|
});
|
|
@@ -4586,19 +4955,19 @@ function formatElement2(e) {
|
|
|
4586
4955
|
const display = e.text ?? e.label;
|
|
4587
4956
|
return `${e.interactive ? "\u2022 " : " "}${e.name}${display ? ` "${display}"` : ""}${e.testID ? ` [testID=${e.testID}]` : ""}`;
|
|
4588
4957
|
}
|
|
4589
|
-
var stepSchema =
|
|
4590
|
-
tap:
|
|
4591
|
-
longPress:
|
|
4592
|
-
type:
|
|
4593
|
-
into:
|
|
4594
|
-
set:
|
|
4595
|
-
reload:
|
|
4596
|
-
waitMs:
|
|
4597
|
-
waitFor:
|
|
4598
|
-
waitGone:
|
|
4599
|
-
expect:
|
|
4600
|
-
expectGone:
|
|
4601
|
-
timeoutMs:
|
|
4958
|
+
var stepSchema = import_zod22.z.object({
|
|
4959
|
+
tap: import_zod22.z.string().optional().describe("Tap this element: exact testID, or fuzzy visible text."),
|
|
4960
|
+
longPress: import_zod22.z.boolean().optional().describe("Make `tap` a long-press instead."),
|
|
4961
|
+
type: import_zod22.z.string().optional().describe("Text to type (needs `into`)."),
|
|
4962
|
+
into: import_zod22.z.string().optional().describe("Target text input for `type`: testID or fuzzy text."),
|
|
4963
|
+
set: import_zod22.z.union([import_zod22.z.number(), import_zod22.z.boolean()]).optional().describe("Set a toggle (true/false) or slider (number) \u2014 pair with `tap` as the target."),
|
|
4964
|
+
reload: import_zod22.z.boolean().optional().describe("Reload the JS bundle before this step's action."),
|
|
4965
|
+
waitMs: import_zod22.z.number().min(0).max(3e4).optional().describe("Fixed pause after the action, in ms (max 30000)."),
|
|
4966
|
+
waitFor: import_zod22.z.string().optional().describe("Wait until an element matching this appears (default 5s)."),
|
|
4967
|
+
waitGone: import_zod22.z.string().optional().describe("Wait until no element matches this (default 5s)."),
|
|
4968
|
+
expect: import_zod22.z.string().optional().describe("Assert an element matching this IS on screen (waits up to 2s for it); fails the flow if not."),
|
|
4969
|
+
expectGone: import_zod22.z.string().optional().describe("Assert nothing matches this (waits up to 2s for it to go); fails the flow if something does."),
|
|
4970
|
+
timeoutMs: import_zod22.z.number().min(0).max(6e4).optional().describe("Budget for this step's waitFor/waitGone/expect, max 60000. Default 5000 (2000 for expect).")
|
|
4602
4971
|
}).describe("One flow step. Order within a step: reload \u2192 tap/type/set \u2192 waitMs \u2192 waitFor/waitGone \u2192 expect.");
|
|
4603
4972
|
function registerFlowTools(server, sync) {
|
|
4604
4973
|
server.registerTool(
|
|
@@ -4606,10 +4975,10 @@ function registerFlowTools(server, sync) {
|
|
|
4606
4975
|
{
|
|
4607
4976
|
description: "Run a scripted sequence of UI interactions in ONE call and report what happened: per-step results, the final screen, plus the network requests and console errors the flow produced. Use this instead of alternating describe_screen/tap_element \u2014 reproducing a bug ('open cart, checkout, submit') or verifying a fix after an edit is one call, not a dozen. Steps run in order and stop at the first failure, returning the screen at that point so you can see WHERE it broke. Each step can tap, type, set a toggle/slider, reload, wait for an element, and assert. Requires Buoy Pro.",
|
|
4608
4977
|
inputSchema: {
|
|
4609
|
-
steps:
|
|
4610
|
-
include:
|
|
4611
|
-
continueOnFailure:
|
|
4612
|
-
deviceId:
|
|
4978
|
+
steps: import_zod22.z.array(stepSchema).min(1).describe("Steps to run, in order."),
|
|
4979
|
+
include: import_zod22.z.enum(["all", "screen", "none"]).optional().describe("What to report after the flow: 'all' (default) = final screen + network/console produced by the flow; 'screen' = final screen only; 'none' = step results only."),
|
|
4980
|
+
continueOnFailure: import_zod22.z.boolean().optional().describe("Keep going after a failed step instead of stopping. Default false."),
|
|
4981
|
+
deviceId: import_zod22.z.string().optional().describe("Target device id (auto-selected if one is connected).")
|
|
4613
4982
|
}
|
|
4614
4983
|
},
|
|
4615
4984
|
async (args) => {
|
|
@@ -4833,9 +5202,9 @@ ${shown.map(formatElement2).join("\n")}`
|
|
|
4833
5202
|
}
|
|
4834
5203
|
}
|
|
4835
5204
|
}
|
|
4836
|
-
return
|
|
5205
|
+
return text20(parts.join("\n\n"));
|
|
4837
5206
|
} catch (e) {
|
|
4838
|
-
return
|
|
5207
|
+
return fail22(errMsg21(e));
|
|
4839
5208
|
}
|
|
4840
5209
|
}
|
|
4841
5210
|
);
|
|
@@ -4856,10 +5225,10 @@ var cap2 = (s, n = 160) => s.length > n ? `${s.slice(0, n)}\u2026` : s;
|
|
|
4856
5225
|
var firstLines = (s, n = 3) => s.split("\n").map((l) => l.trim()).filter(Boolean).slice(0, n).join(" \u23CE ");
|
|
4857
5226
|
|
|
4858
5227
|
// src/tools/packs/renders.ts
|
|
4859
|
-
var
|
|
5228
|
+
var import_zod23 = require("zod");
|
|
4860
5229
|
var UI_TOOL_ID2 = "highlight-updates";
|
|
4861
|
-
var
|
|
4862
|
-
var
|
|
5230
|
+
var text21 = (s) => ({ content: [{ type: "text", text: s }] });
|
|
5231
|
+
var fail23 = (message) => ({
|
|
4863
5232
|
isError: true,
|
|
4864
5233
|
content: [{ type: "text", text: message }]
|
|
4865
5234
|
});
|
|
@@ -4869,12 +5238,12 @@ var DEFAULT_IDLE_MS = 3e3;
|
|
|
4869
5238
|
var SETTLE_MS = 400;
|
|
4870
5239
|
var DEFAULT_TOP = 12;
|
|
4871
5240
|
var lastCapture = /* @__PURE__ */ new Map();
|
|
4872
|
-
var stepSchema2 =
|
|
4873
|
-
tap:
|
|
4874
|
-
type:
|
|
4875
|
-
into:
|
|
4876
|
-
waitMs:
|
|
4877
|
-
repeat:
|
|
5241
|
+
var stepSchema2 = import_zod23.z.object({
|
|
5242
|
+
tap: import_zod23.z.string().optional().describe("Tap this element: exact testID, or fuzzy visible text."),
|
|
5243
|
+
type: import_zod23.z.string().optional().describe("Text to type (needs `into`)."),
|
|
5244
|
+
into: import_zod23.z.string().optional().describe("Target text input for `type`: testID or fuzzy text."),
|
|
5245
|
+
waitMs: import_zod23.z.number().min(0).max(1e4).optional().describe("Pause after the action, in ms."),
|
|
5246
|
+
repeat: import_zod23.z.number().min(1).max(20).optional().describe("Do this step N times (default 1). Useful for 'tap it five times'.")
|
|
4878
5247
|
}).describe("One interaction to measure. Keep it to the thing you're asking about.");
|
|
4879
5248
|
function selector2(needle) {
|
|
4880
5249
|
return /\s/.test(needle) ? { query: needle } : { testID: needle, query: needle };
|
|
@@ -4967,14 +5336,14 @@ function registerRenderTools(server, sync) {
|
|
|
4967
5336
|
{
|
|
4968
5337
|
description: "Find out WHAT re-rendered on the current screen and WHY, in one call \u2014 no test route, no scaffolding. THE tool for 'this page is slow/laggy/janky', 'typing lags', 'the whole page re-renders when I tap one button'. Give it `steps` to measure a specific interaction (tap a button, type in a field) \u2014 measuring an idle window instead tells you nothing about what taps cost, which is how re-render fixes usually go wrong. Returns per-component render COST in ms (sorted by it \u2014 a component rendering 40x for 0.4ms is noise, one rendering 4x for 38ms is the answer), the CAUSE of each (parent cascade / own state / changed props), which parent dragged it along, and which props changed. `wasted` counts renders that produced nothing new \u2014 that's the removable part. AFTER YOU EDIT, call it again with the same steps and compareToPrevious:true to prove the fix landed and didn't move the cost somewhere else. (For choosing between several implementations of a screen, use run_benchmark_batch instead \u2014 that ranks variants; this explains one screen.) Requires Buoy Pro and @buoy-gg/highlight-updates.",
|
|
4969
5338
|
inputSchema: {
|
|
4970
|
-
steps:
|
|
5339
|
+
steps: import_zod23.z.array(stepSchema2).max(20).optional().describe(
|
|
4971
5340
|
"The interaction to measure, e.g. [{tap:'favorite-deal-2', repeat:5}] or [{type:'bench', into:'deals-search'}]. Omit to sample the screen idle \u2014 only useful for churn that happens with nobody touching it."
|
|
4972
5341
|
),
|
|
4973
|
-
idleMs:
|
|
4974
|
-
label:
|
|
4975
|
-
compareToPrevious:
|
|
4976
|
-
top:
|
|
4977
|
-
deviceId:
|
|
5342
|
+
idleMs: import_zod23.z.number().min(500).max(2e4).optional().describe(`Idle sample length when no steps are given. Default ${DEFAULT_IDLE_MS}.`),
|
|
5343
|
+
label: import_zod23.z.string().optional().describe('Name this measurement, e.g. "before fix". Shown in the next comparison.'),
|
|
5344
|
+
compareToPrevious: import_zod23.z.boolean().optional().describe("Diff against the previous measure_renders on this device. Use after an edit to prove the fix."),
|
|
5345
|
+
top: import_zod23.z.number().min(1).max(40).optional().describe(`Components to list. Default ${DEFAULT_TOP}.`),
|
|
5346
|
+
deviceId: import_zod23.z.string().optional().describe("Target device id (auto-selected if one is connected).")
|
|
4978
5347
|
}
|
|
4979
5348
|
},
|
|
4980
5349
|
async (args) => {
|
|
@@ -4983,18 +5352,18 @@ function registerRenderTools(server, sync) {
|
|
|
4983
5352
|
const device = sync.connectedDevices().find((d) => d.deviceId === target);
|
|
4984
5353
|
const uiTool = (device?.tools ?? []).find((t) => t.toolId === UI_TOOL_ID2);
|
|
4985
5354
|
if (!uiTool) {
|
|
4986
|
-
return
|
|
5355
|
+
return fail23(
|
|
4987
5356
|
"This app doesn't expose the highlight-updates tool, so renders can't be measured. Install @buoy-gg/highlight-updates."
|
|
4988
5357
|
);
|
|
4989
5358
|
}
|
|
4990
5359
|
if (!(uiTool.actions ?? []).includes("beginMeasurement")) {
|
|
4991
|
-
return
|
|
5360
|
+
return fail23(
|
|
4992
5361
|
"This app's @buoy-gg/highlight-updates is too old to measure renders (needs the version with beginMeasurement). Upgrade it, then try again. Meanwhile run_benchmark_batch with captureRenders can still give counts if you have a test route."
|
|
4993
5362
|
);
|
|
4994
5363
|
}
|
|
4995
5364
|
const began = await sync.callAction(UI_TOOL_ID2, "beginMeasurement", {}, target);
|
|
4996
5365
|
if (began && began.ok === false) {
|
|
4997
|
-
return
|
|
5366
|
+
return fail23(`Can't measure renders: ${began.reason ?? "capture unavailable"}`);
|
|
4998
5367
|
}
|
|
4999
5368
|
await delay5(SETTLE_MS);
|
|
5000
5369
|
const startedAt = Date.now();
|
|
@@ -5039,7 +5408,7 @@ function registerRenderTools(server, sync) {
|
|
|
5039
5408
|
const ended = await sync.callAction(UI_TOOL_ID2, "endMeasurement", {}, target);
|
|
5040
5409
|
const summary = ended?.summary;
|
|
5041
5410
|
if (!summary) {
|
|
5042
|
-
return
|
|
5411
|
+
return fail23(
|
|
5043
5412
|
"The capture window closed without returning anything. If the app reloaded mid-measurement, try again."
|
|
5044
5413
|
);
|
|
5045
5414
|
}
|
|
@@ -5064,17 +5433,17 @@ function registerRenderTools(server, sync) {
|
|
|
5064
5433
|
} else if (!args.compareToPrevious) {
|
|
5065
5434
|
parts.push("", "_Fixed something? Call this again with the same steps and `compareToPrevious:true` to prove it landed._");
|
|
5066
5435
|
}
|
|
5067
|
-
return
|
|
5436
|
+
return text21(parts.join("\n"));
|
|
5068
5437
|
} catch (e) {
|
|
5069
|
-
return
|
|
5438
|
+
return fail23(errMsg22(e));
|
|
5070
5439
|
}
|
|
5071
5440
|
}
|
|
5072
5441
|
);
|
|
5073
5442
|
}
|
|
5074
5443
|
|
|
5075
5444
|
// src/verify/editWatcher.ts
|
|
5076
|
-
var
|
|
5077
|
-
var
|
|
5445
|
+
var import_node_fs4 = __toESM(require("fs"));
|
|
5446
|
+
var import_node_path4 = __toESM(require("path"));
|
|
5078
5447
|
var WATCHED_EXT = /* @__PURE__ */ new Set([
|
|
5079
5448
|
".ts",
|
|
5080
5449
|
".tsx",
|
|
@@ -5117,14 +5486,14 @@ var EditWatcher = class {
|
|
|
5117
5486
|
if (mode === "never" || this.started) return;
|
|
5118
5487
|
this.started = true;
|
|
5119
5488
|
try {
|
|
5120
|
-
this.watcher =
|
|
5489
|
+
this.watcher = import_node_fs4.default.watch(
|
|
5121
5490
|
rootDir,
|
|
5122
5491
|
{ recursive: true },
|
|
5123
5492
|
(_event, filename) => {
|
|
5124
5493
|
if (!filename) return;
|
|
5125
5494
|
const rel2 = String(filename);
|
|
5126
|
-
if (rel2.split(
|
|
5127
|
-
if (!WATCHED_EXT.has(
|
|
5495
|
+
if (rel2.split(import_node_path4.default.sep).some((seg) => IGNORED_DIRS.has(seg))) return;
|
|
5496
|
+
if (!WATCHED_EXT.has(import_node_path4.default.extname(rel2))) return;
|
|
5128
5497
|
this.noteEdit(rel2);
|
|
5129
5498
|
}
|
|
5130
5499
|
);
|
|
@@ -5224,6 +5593,19 @@ requests the DEVELOPER kept: those are snapshots that outlive Clear, the 500-req
|
|
|
5224
5593
|
restarts, so treat a pinned request as "a human flagged this as the problem". \`network_action\`
|
|
5225
5594
|
pins/saves one \u2014 pin the failing call you want a human to see, or keep one before the log rolls over.
|
|
5226
5595
|
|
|
5596
|
+
Testing anything that opens a CAMERA \u2014 a QR/barcode scanner, document capture, an avatar
|
|
5597
|
+
picker? The iOS Simulator has no camera, so those screens normally cannot be exercised at
|
|
5598
|
+
all. \`camera_source\` gives it one: \`barcode\` generates the code from text you supply
|
|
5599
|
+
(pdf417 is what a driver's licence carries), \`image\`/\`video\` play a file, \`screen\` points
|
|
5600
|
+
the phone at this Mac. \`camera_devices\` lists the booted simulators and their apps when
|
|
5601
|
+
you need a bundle id; \`camera_inputs\` lists this Mac's cameras and windows when you need
|
|
5602
|
+
one of those ids. Then \`camera_launch\` to relaunch the app with it attached \u2014 a camera
|
|
5603
|
+
can only be attached at process start \u2014 or \`camera_zero_setup\` when something else starts
|
|
5604
|
+
the app. \`camera_status\` shows what is being decoded right now, which separates "the
|
|
5605
|
+
scanner is broken" from "it never saw the code", \`camera_diagnose\` says why when nothing
|
|
5606
|
+
works, and \`camera_stop\` turns it off when you are done. These need no device connection
|
|
5607
|
+
and no Buoy integration in the app.
|
|
5608
|
+
|
|
5227
5609
|
Need to SEE a component (verify a UI change, check styling/layout)? Use \`screenshot_component\` with
|
|
5228
5610
|
a testID/name \u2014 it locates the live component on-device and returns a cropped screenshot inline.
|
|
5229
5611
|
iOS Simulator only, and only works when this MCP server runs on the same Mac as the booted Simulator.
|
|
@@ -5340,6 +5722,7 @@ function createMcpServer(sync) {
|
|
|
5340
5722
|
registerTimeMachineTools(server, sync);
|
|
5341
5723
|
registerScenariosTools(server, sync);
|
|
5342
5724
|
registerScreenshotTools(server, sync);
|
|
5725
|
+
registerCameraTools(server);
|
|
5343
5726
|
registerInteractTools(server, sync);
|
|
5344
5727
|
registerJsThreadTools(server, sync);
|
|
5345
5728
|
registerImagesTools(server, sync);
|
|
@@ -5348,16 +5731,16 @@ function createMcpServer(sync) {
|
|
|
5348
5731
|
return server;
|
|
5349
5732
|
}
|
|
5350
5733
|
var deviceIdField = {
|
|
5351
|
-
deviceId:
|
|
5734
|
+
deviceId: import_zod24.z.string().optional().describe(
|
|
5352
5735
|
'Target device id (from list_devices). Omit to auto-select when exactly one device is connected. Use "All" to broadcast.'
|
|
5353
5736
|
)
|
|
5354
5737
|
};
|
|
5355
5738
|
|
|
5356
5739
|
// src/init.ts
|
|
5357
|
-
var
|
|
5358
|
-
var
|
|
5359
|
-
var
|
|
5360
|
-
var
|
|
5740
|
+
var import_node_child_process3 = require("child_process");
|
|
5741
|
+
var import_node_fs5 = __toESM(require("fs"));
|
|
5742
|
+
var import_node_os4 = __toESM(require("os"));
|
|
5743
|
+
var import_node_path5 = __toESM(require("path"));
|
|
5361
5744
|
function defaultEnv() {
|
|
5362
5745
|
return { BUOY_VERIFY: "auto" };
|
|
5363
5746
|
}
|
|
@@ -5365,19 +5748,19 @@ var PUBLIC_REGISTRY = "https://registry.npmjs.org";
|
|
|
5365
5748
|
var PROBE_TIMEOUT_MS3 = 3e3;
|
|
5366
5749
|
function runInit(opts = {}) {
|
|
5367
5750
|
const cwd = opts.cwd ?? process.cwd();
|
|
5368
|
-
const skillSrcDir = opts.skillSrcDir ??
|
|
5751
|
+
const skillSrcDir = opts.skillSrcDir ?? import_node_path5.default.resolve(__dirname, "../skill");
|
|
5369
5752
|
const log = opts.log ?? ((m) => process.stdout.write(m + "\n"));
|
|
5370
5753
|
const entry = resolveEntry(opts, log);
|
|
5371
5754
|
const done = [];
|
|
5372
|
-
upsertMcpConfig(
|
|
5373
|
-
|
|
5374
|
-
upsertMcpConfig(
|
|
5375
|
-
if (
|
|
5376
|
-
upsertMcpConfig(
|
|
5755
|
+
upsertMcpConfig(import_node_path5.default.join(cwd, ".mcp.json"), "mcpServers", entry, cwd, done);
|
|
5756
|
+
import_node_fs5.default.mkdirSync(import_node_path5.default.join(cwd, ".cursor"), { recursive: true });
|
|
5757
|
+
upsertMcpConfig(import_node_path5.default.join(cwd, ".cursor", "mcp.json"), "mcpServers", entry, cwd, done);
|
|
5758
|
+
if (import_node_fs5.default.existsSync(import_node_path5.default.join(cwd, ".vscode"))) {
|
|
5759
|
+
upsertMcpConfig(import_node_path5.default.join(cwd, ".vscode", "mcp.json"), "servers", entry, cwd, done);
|
|
5377
5760
|
}
|
|
5378
5761
|
installSkills(skillSrcDir, cwd, done);
|
|
5379
|
-
appendDebuggingGuide(
|
|
5380
|
-
appendDebuggingGuide(
|
|
5762
|
+
appendDebuggingGuide(import_node_path5.default.join(cwd, "CLAUDE.md"), cwd, done);
|
|
5763
|
+
appendDebuggingGuide(import_node_path5.default.join(cwd, "AGENTS.md"), cwd, done);
|
|
5381
5764
|
log("Buoy MCP installed:");
|
|
5382
5765
|
for (const line of done) log(" \u2022 " + line);
|
|
5383
5766
|
log("");
|
|
@@ -5419,21 +5802,21 @@ function npxEntry() {
|
|
|
5419
5802
|
return { type: "stdio", command: "npx", args: ["-y", `${PACKAGE_NAME}@latest`], env: defaultEnv() };
|
|
5420
5803
|
}
|
|
5421
5804
|
function localEntry(opts, log) {
|
|
5422
|
-
const installDir = opts.installDir ?? process.env.BUOY_MCP_HOME ??
|
|
5805
|
+
const installDir = opts.installDir ?? process.env.BUOY_MCP_HOME ?? import_node_path5.default.join(import_node_os4.default.homedir(), ".buoy-mcp");
|
|
5423
5806
|
const registry = opts.registry ?? PUBLIC_REGISTRY;
|
|
5424
|
-
const
|
|
5425
|
-
if (
|
|
5426
|
-
return { type: "stdio", command: "node", args: [
|
|
5807
|
+
const cliPath2 = installLocalCopy(installDir, registry, log);
|
|
5808
|
+
if (cliPath2) {
|
|
5809
|
+
return { type: "stdio", command: "node", args: [cliPath2], env: defaultEnv() };
|
|
5427
5810
|
}
|
|
5428
5811
|
log("\u26A0 local install failed \u2014 writing the npx entry instead (see the error above).");
|
|
5429
5812
|
return npxEntry();
|
|
5430
5813
|
}
|
|
5431
5814
|
function installLocalCopy(installDir, registry, log) {
|
|
5432
5815
|
const spec = `${PACKAGE_NAME}@${VERSION === "0.0.0-dev" ? "latest" : VERSION}`;
|
|
5433
|
-
|
|
5816
|
+
import_node_fs5.default.mkdirSync(installDir, { recursive: true });
|
|
5434
5817
|
const npm = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
5435
5818
|
log(`Installing ${spec} into ${installDir} from ${registry} \u2026`);
|
|
5436
|
-
const res = (0,
|
|
5819
|
+
const res = (0, import_node_child_process3.spawnSync)(
|
|
5437
5820
|
npm,
|
|
5438
5821
|
[
|
|
5439
5822
|
"install",
|
|
@@ -5453,12 +5836,12 @@ function installLocalCopy(installDir, registry, log) {
|
|
|
5453
5836
|
log(`\u26A0 npm install exited with code ${res.status ?? "?"}${res.error ? ` (${res.error.message})` : ""}.`);
|
|
5454
5837
|
return null;
|
|
5455
5838
|
}
|
|
5456
|
-
const
|
|
5457
|
-
if (!
|
|
5458
|
-
log(`\u26A0 install finished but ${
|
|
5839
|
+
const cliPath2 = import_node_path5.default.join(installDir, "node_modules", PACKAGE_NAME, "dist", "cli.js");
|
|
5840
|
+
if (!import_node_fs5.default.existsSync(cliPath2)) {
|
|
5841
|
+
log(`\u26A0 install finished but ${cliPath2} is missing.`);
|
|
5459
5842
|
return null;
|
|
5460
5843
|
}
|
|
5461
|
-
return
|
|
5844
|
+
return cliPath2;
|
|
5462
5845
|
}
|
|
5463
5846
|
function probeRegistry() {
|
|
5464
5847
|
const registry = effectiveRegistry();
|
|
@@ -5476,14 +5859,14 @@ function effectiveRegistry() {
|
|
|
5476
5859
|
}
|
|
5477
5860
|
function npmConfigGet(key) {
|
|
5478
5861
|
const npm = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
5479
|
-
const res = (0,
|
|
5862
|
+
const res = (0, import_node_child_process3.spawnSync)(npm, ["config", "get", key], { encoding: "utf8", timeout: PROBE_TIMEOUT_MS3 });
|
|
5480
5863
|
if (res.status !== 0 || typeof res.stdout !== "string") return null;
|
|
5481
5864
|
const val = res.stdout.trim();
|
|
5482
5865
|
if (!val || val === "undefined" || val === "null") return null;
|
|
5483
5866
|
return val;
|
|
5484
5867
|
}
|
|
5485
5868
|
function hostReachable(registry) {
|
|
5486
|
-
const done = (0,
|
|
5869
|
+
const done = (0, import_node_child_process3.spawnSync)(
|
|
5487
5870
|
process.execPath,
|
|
5488
5871
|
["-e", REACHABILITY_PROBE, registry, String(PROBE_TIMEOUT_MS3)],
|
|
5489
5872
|
{ encoding: "utf8", timeout: PROBE_TIMEOUT_MS3 + 2e3 }
|
|
@@ -5506,22 +5889,22 @@ fetch(url, { method: 'HEAD', signal: c.signal })
|
|
|
5506
5889
|
`;
|
|
5507
5890
|
function upsertMcpConfig(file, key, entry, cwd, done) {
|
|
5508
5891
|
let json3 = {};
|
|
5509
|
-
if (
|
|
5892
|
+
if (import_node_fs5.default.existsSync(file)) {
|
|
5510
5893
|
try {
|
|
5511
|
-
json3 = JSON.parse(
|
|
5894
|
+
json3 = JSON.parse(import_node_fs5.default.readFileSync(file, "utf8"));
|
|
5512
5895
|
} catch {
|
|
5513
|
-
|
|
5896
|
+
import_node_fs5.default.copyFileSync(file, file + ".bak");
|
|
5514
5897
|
done.push(`existing ${rel(file, cwd)} was invalid JSON \u2014 backed up to ${rel(file, cwd)}.bak`);
|
|
5515
5898
|
json3 = {};
|
|
5516
5899
|
}
|
|
5517
5900
|
} else {
|
|
5518
|
-
|
|
5901
|
+
import_node_fs5.default.mkdirSync(import_node_path5.default.dirname(file), { recursive: true });
|
|
5519
5902
|
}
|
|
5520
5903
|
const servers = json3[key] && typeof json3[key] === "object" ? json3[key] : {};
|
|
5521
5904
|
const existed = "buoy" in servers;
|
|
5522
5905
|
servers.buoy = entry;
|
|
5523
5906
|
json3[key] = servers;
|
|
5524
|
-
|
|
5907
|
+
import_node_fs5.default.writeFileSync(file, JSON.stringify(json3, null, 2) + "\n");
|
|
5525
5908
|
done.push(`${existed ? "updated" : "added"} \`buoy\` in ${rel(file, cwd)}`);
|
|
5526
5909
|
}
|
|
5527
5910
|
var GUIDE_HEADING = "# Debugging with Buoy";
|
|
@@ -5581,9 +5964,9 @@ mentions it.
|
|
|
5581
5964
|
`;
|
|
5582
5965
|
function appendDebuggingGuide(file, cwd, done) {
|
|
5583
5966
|
let existing = "";
|
|
5584
|
-
if (
|
|
5967
|
+
if (import_node_fs5.default.existsSync(file)) {
|
|
5585
5968
|
try {
|
|
5586
|
-
existing =
|
|
5969
|
+
existing = import_node_fs5.default.readFileSync(file, "utf8");
|
|
5587
5970
|
} catch {
|
|
5588
5971
|
done.push(`\u26A0 could not read ${rel(file, cwd)} \u2014 skipped the debugging guide`);
|
|
5589
5972
|
return;
|
|
@@ -5595,40 +5978,40 @@ function appendDebuggingGuide(file, cwd, done) {
|
|
|
5595
5978
|
}
|
|
5596
5979
|
const separator = existing === "" ? "" : existing.endsWith("\n") ? "\n" : "\n\n";
|
|
5597
5980
|
try {
|
|
5598
|
-
|
|
5981
|
+
import_node_fs5.default.writeFileSync(file, existing + separator + DEBUGGING_GUIDE);
|
|
5599
5982
|
done.push(`${existing ? "appended" : "created"} "${GUIDE_HEADING}" block in ${rel(file, cwd)}`);
|
|
5600
5983
|
} catch {
|
|
5601
5984
|
done.push(`\u26A0 could not write ${rel(file, cwd)} \u2014 skipped the debugging guide`);
|
|
5602
5985
|
}
|
|
5603
5986
|
}
|
|
5604
5987
|
function installSkills(skillSrcDir, cwd, done) {
|
|
5605
|
-
if (!
|
|
5988
|
+
if (!import_node_fs5.default.existsSync(skillSrcDir)) {
|
|
5606
5989
|
done.push("\u26A0 no bundled skills found \u2014 skipped");
|
|
5607
5990
|
return;
|
|
5608
5991
|
}
|
|
5609
|
-
const skills =
|
|
5992
|
+
const skills = import_node_fs5.default.readdirSync(skillSrcDir, { withFileTypes: true }).filter((e) => e.isDirectory() && import_node_fs5.default.existsSync(import_node_path5.default.join(skillSrcDir, e.name, "SKILL.md")));
|
|
5610
5993
|
if (skills.length === 0) {
|
|
5611
5994
|
done.push("\u26A0 no skills with a SKILL.md found \u2014 skipped");
|
|
5612
5995
|
return;
|
|
5613
5996
|
}
|
|
5614
5997
|
for (const skill of skills) {
|
|
5615
|
-
const from =
|
|
5616
|
-
const to =
|
|
5998
|
+
const from = import_node_path5.default.join(skillSrcDir, skill.name);
|
|
5999
|
+
const to = import_node_path5.default.join(cwd, ".claude", "skills", skill.name);
|
|
5617
6000
|
copyDir(from, to);
|
|
5618
|
-
done.push(`installed the ${skill.name} skill \u2192 ${rel(
|
|
6001
|
+
done.push(`installed the ${skill.name} skill \u2192 ${rel(import_node_path5.default.join(to, "SKILL.md"), cwd)}`);
|
|
5619
6002
|
}
|
|
5620
6003
|
}
|
|
5621
6004
|
function copyDir(from, to) {
|
|
5622
|
-
|
|
5623
|
-
for (const entry of
|
|
5624
|
-
const s =
|
|
5625
|
-
const d =
|
|
6005
|
+
import_node_fs5.default.mkdirSync(to, { recursive: true });
|
|
6006
|
+
for (const entry of import_node_fs5.default.readdirSync(from, { withFileTypes: true })) {
|
|
6007
|
+
const s = import_node_path5.default.join(from, entry.name);
|
|
6008
|
+
const d = import_node_path5.default.join(to, entry.name);
|
|
5626
6009
|
if (entry.isDirectory()) copyDir(s, d);
|
|
5627
|
-
else
|
|
6010
|
+
else import_node_fs5.default.copyFileSync(s, d);
|
|
5628
6011
|
}
|
|
5629
6012
|
}
|
|
5630
6013
|
function rel(file, cwd) {
|
|
5631
|
-
const r =
|
|
6014
|
+
const r = import_node_path5.default.relative(cwd, file);
|
|
5632
6015
|
return r && !r.startsWith("..") ? r : file;
|
|
5633
6016
|
}
|
|
5634
6017
|
|