usepilot 0.11.0 → 0.12.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/cli/index.js +48 -7
- package/dist/{mount-CoCh8xCo.js → mount-Bj7L7fi9.js} +2158 -2130
- package/dist/pilot-auto.js +1 -1
- package/dist/pilot.js +1 -1
- package/package.json +1 -1
package/cli/index.js
CHANGED
|
@@ -38515,7 +38515,7 @@ import { join as join5, relative as relative4 } from "path";
|
|
|
38515
38515
|
var SKILL_default = "---\nname: pilot\ndescription: Hand the UI to the designer with Pilot, then apply the design edits they send, job after job. Use when the user runs /pilot, says they want to take control of the design or edit the UI in the browser, or pastes a \"Pilot design edits\" brief, or asks to update Pilot.\n---\n\n# Pilot\n\nPilot lets the designer edit the running app in the browser. They select elements, change CSS properties with Pilot's editors, and press **Send**. Each Send reaches you as a **job**: plain CSS `property: from \u2192 to` (and new text, when they rewrote one) on identifiable elements, for you to write into the source in this project's conventions. The designer keeps designing while you work; Pilot previews each job's changes until you report it done, then checks them against the page's real CSS.\n\n## When the user asks to update Pilot\n\nRun `npx usepilot@latest update` in the app's folder (the one with `usepilot` in its `package.json`), and tell the user in a few lines what it prints: the new version and the steps left (restart the app's dev server, open a new chat).\n\n## When the user runs /pilot (or asks to launch Pilot)\n\n0. **Check that Pilot's tools are here** (`pilot_launch`, `pilot_wait_for_edits`, `pilot_done`). If they aren't, don't look for them in files, packages or settings: they come from Pilot's MCP server, which an agent loads when a chat starts, so a chat opened before Pilot was set up doesn't have them. Say so in one or two lines and stop: open a new chat (approve Pilot's server if asked, or turn it on in the agent's MCP settings: Cursor keeps a project's new servers off until they're switched on in Cursor Settings, MCP section), then run `/pilot` there. If the project has no Pilot at all (no `usepilot` in its `package.json`), offer to set it up instead: `npx usepilot@latest init --agent <you>`.\n1. **Find the page.** Work out the URL of the app's dev server: the dev script and its config (`vite.config.*` \u2192 `server.port`, Next.js \u2192 3000, a `--port` flag\u2026), or a server already running in a terminal. If the dev server isn't running, start it in the background. If you can't tell the URL, ask.\n2. **Launch:** call `pilot_launch` with that URL and `folder`, the project's folder as an absolute path (your working directory): Pilot searches the code there for each job, and some agents start its server elsewhere. Pilot opens in the page (if the page isn't open yet, tell the designer to open it).\n3. **Tell the designer** in one line that Pilot is ready: select an element, edit, press Send.\n4. **Wait:** call `pilot_wait_for_edits`. It returns a job when the designer presses Send, or \"no edits yet\" after a while: call it again, without saying anything to the user. In Claude Code, a wait longer than two minutes moves to the background: end your turn with a short \"Waiting for your edits\", and the job arrives as the task's result.\n5. **Apply the job** (below), then call `pilot_done` with the job id and short notes, and go back to step 4. When several jobs were queued, one wait returns them all: do them all, then call `pilot_done` once per job, each with its own id and notes.\n\nKeep looping until the user asks you to stop. Keep your messages between jobs short: a line on what you changed (and anything you approximated) is enough. If the user talks to you meanwhile, help them, and keep (or start again) a wait in the background so their next Send reaches you (queued jobs are kept).\n\n## Applying a job\n\nJobs come in three kinds:\n\n- **Edits** (basic): the designer set every value; you only translate them. **Speed is what matters**: go straight to the code, apply, call `pilot_done`. No screenshots, browser checks, builds or tests: Pilot checks the page itself and sends back what didn't land.\n- **Comments**: the designer's own words about one element (\"make it the brand green\", \"can this be calmer?\"), with the thread so far. Do what the latest one asks: a specific, small ask right away (like an edit), an open-ended one as an advanced task (below). A question gets an answer and no change. Your `pilot_done` notes are your reply in their thread, a small chat box for quick design back-and-forth: one short sentence, like a chat message (about 120 characters), with no lists or code blocks. Not a report: they see the result on the page.\n- **Tasks** (advanced), like **Make responsive** and **Break and fix**: the designer selected an element and asked for an outcome (work at every viewport width; hold up with odd but realistic content, like very long text, with the real content put back after testing). They need judgment more than speed. The prompt has the steps. Check the result with `pilot_check_widths` (numbers for every width, no screenshots needed). If you can hand it to a more capable model than the one you run on (a subagent, or another model your agent offers), do, then call `pilot_done` with its notes. Pilot checks the widths again when you're done; problems come back once as a follow-up.\n\n### Edits\n\nThe values are **design instructions, not code**: the designer's intent. Use your judgment and write production code the way this project already styles things, whatever it uses. First look at how the element's component is styled, and follow that. For example:\n\n- **Utility classes (Tailwind):** the closest utility or theme value (`border-radius: 12px` \u2192 `rounded-xl`, `padding-top: 24px` \u2192 `pt-6`). Arbitrary values only when nothing fits.\n- **CSS / CSS modules / Sass:** edit the rule that styles the element. Don't add a new override.\n- **Design tokens / CSS variables:** prefer an existing token that matches. Don't hard-code its value.\n- **CSS-in-JS and compiled styles (StyleX, vanilla-extract, Panda, styled-components, Emotion):** edit the style definition where the component is styled, with the project's tokens.\n- **A component library's props (MUI, Chakra\u2026):** use its props and theme values before any custom CSS.\n\nRules:\n\n- Never leave inline styles or `!important` behind. Pilot's preview is only a preview.\n- Find each element by its selector, DOM path and text snippet, then the component that renders it.\n- **Shared code, only some copies:** an element's \"Look-alikes\" line counts the elements like it the job leaves out. If they come from the same code (a shared component, a loop over data) and the designer didn't say which they meant, don't guess: do the rest of the job, leave that part, and ask with `pilot_done`'s `question` (one short sentence, the component's name in **bold**) and `choices` \"All of them\", \"Only this\", \"New variant\" (your suggestion first). Go on with other jobs; the answer comes back as that job. **All of them**: change the component itself. **Only this**: change it where it's used, with what the component accepts (classes through its `className`, merged the project's way; a prop), else the smallest pass-through, not a variant. **New variant**: add a named option the way the component defines variants (`cva`, a `variant` prop), use it here, and name it in your notes. Don't ask when the designer already said, when every copy is in the job, or when nothing else uses that code.\n- **Widths:** a change for some viewport widths goes in a media query; use the project's breakpoints when one matches (or is within a few pixels). \"Every width\" means no media query should override it.\n- **Removed:** the element shouldn't declare the property at all (not `0` or `none`).\n- **Text:** the designer rewrote the element's copy. Change it where it comes from (the markup, a prop, a translation file), for this element only; Pilot checks that the page shows the new text.\n- If you approximated a value to fit a token or scale, say which and by how much in `pilot_done`'s notes (`22px \u2192 pt-6, 24px`). Pilot checks the page after each job: a change that doesn't give the designer's value comes back to you once as a follow-up. Fix it, or keep a deliberate choice and say why; after that, Pilot takes what the code gives.\n- Don't run builds or tests for a job unless it's needed: hot reload shows the result, and the designer is waiting to see it.\n";
|
|
38516
38516
|
|
|
38517
38517
|
// src/setup.ts
|
|
38518
|
-
var MCP_SERVER = { command: "npx", args: ["-y", "usepilot", "mcp"] };
|
|
38518
|
+
var MCP_SERVER = { command: "npx", args: ["-y", "usepilot@latest", "mcp"] };
|
|
38519
38519
|
async function setup(options = {}) {
|
|
38520
38520
|
return options.project ? setupProject(options.cwd ?? process.cwd()) : setupMachine(options.home ?? homedir());
|
|
38521
38521
|
}
|
|
@@ -38525,7 +38525,7 @@ async function setupMachine(home) {
|
|
|
38525
38525
|
|
|
38526
38526
|
Now register Pilot's MCP server with Claude Code, once, for every project:
|
|
38527
38527
|
|
|
38528
|
-
claude mcp add --scope user pilot -- npx -y usepilot mcp
|
|
38528
|
+
claude mcp add --scope user pilot -- npx -y usepilot@latest mcp
|
|
38529
38529
|
|
|
38530
38530
|
Then, in any Claude Code chat: /pilot
|
|
38531
38531
|
(For a repo you share, run \`npx usepilot setup --project\` in it instead.)
|
|
@@ -38585,7 +38585,7 @@ async function addMcpServer(file2) {
|
|
|
38585
38585
|
}
|
|
38586
38586
|
|
|
38587
38587
|
// src/version.ts
|
|
38588
|
-
var VERSION = "0.
|
|
38588
|
+
var VERSION = "0.12.0";
|
|
38589
38589
|
function olderThan(a, b) {
|
|
38590
38590
|
const parts = (v) => v.replace(/^[^\d]*/, "").split(/[.-]/).slice(0, 3).map((n) => Number.parseInt(n, 10) || 0);
|
|
38591
38591
|
const [x, y] = [parts(a), parts(b)];
|
|
@@ -38689,6 +38689,40 @@ function agentsWithPilot(root, home, platform = process.platform) {
|
|
|
38689
38689
|
return a.id !== "codex" && existsSync5(join6(machine.skills(home), "pilot"));
|
|
38690
38690
|
}).map((a) => a.id);
|
|
38691
38691
|
}
|
|
38692
|
+
function isStaleServer(entry) {
|
|
38693
|
+
const e = entry;
|
|
38694
|
+
return !!e && e.command === "npx" && Array.isArray(e.args) && e.args.includes("usepilot");
|
|
38695
|
+
}
|
|
38696
|
+
async function freshenServers(root, home, platform, run) {
|
|
38697
|
+
const moved = [];
|
|
38698
|
+
const files = [
|
|
38699
|
+
...AGENT_IDS.flatMap((id) => {
|
|
38700
|
+
const m = MACHINE[id].mcp;
|
|
38701
|
+
return m ? [{ file: m.file(home, platform), key: m.key }] : [];
|
|
38702
|
+
}),
|
|
38703
|
+
...AGENTS.flatMap((a) => a.mcp ? [{ file: join6(root, a.mcp.file), key: a.mcp.key }] : [])
|
|
38704
|
+
];
|
|
38705
|
+
for (const { file: file2, key } of files) {
|
|
38706
|
+
const config2 = readJson(file2);
|
|
38707
|
+
const entry = config2?.[key]?.pilot;
|
|
38708
|
+
if (!config2 || !entry || !isStaleServer(entry)) continue;
|
|
38709
|
+
entry.args = entry.args.map((a) => a === "usepilot" ? "usepilot@latest" : a);
|
|
38710
|
+
await writeFile3(file2, `${JSON.stringify(config2, null, 2)}
|
|
38711
|
+
`);
|
|
38712
|
+
moved.push(tilde(file2, home));
|
|
38713
|
+
}
|
|
38714
|
+
const claude = readJson(join6(home, ".claude.json"))?.mcpServers?.pilot;
|
|
38715
|
+
const codex = /\[mcp_servers\.pilot\][^[]*"usepilot"/.test(readText(join6(home, ".codex", "config.toml")));
|
|
38716
|
+
for (const [id, stale, remove] of [
|
|
38717
|
+
["claude-code", isStaleServer(claude), ["mcp", "remove", "--scope", "user", "pilot"]],
|
|
38718
|
+
["codex", codex, ["mcp", "remove", "pilot"]]
|
|
38719
|
+
]) {
|
|
38720
|
+
const command2 = MACHINE[id].command;
|
|
38721
|
+
if (!stale || !command2) continue;
|
|
38722
|
+
if (run(command2.cmd, [...remove], home) && run(command2.cmd, command2.args, home)) moved.push(id === "codex" ? "Codex" : "Claude Code");
|
|
38723
|
+
}
|
|
38724
|
+
return moved;
|
|
38725
|
+
}
|
|
38692
38726
|
function installArgs(pm, spec = "usepilot") {
|
|
38693
38727
|
return pm === "npm" ? ["install", "-D", spec] : pm === "bun" ? ["add", "-d", spec] : ["add", "-D", spec];
|
|
38694
38728
|
}
|
|
@@ -38804,6 +38838,8 @@ ${apps.map((a) => `- ${a}`).join("\n")}` : "."}
|
|
|
38804
38838
|
`**Connect yourself:** run \`npx usepilot@latest init --agent <you>\` in ${cwd}, with \`<you>\` the agent you are: ${AGENT_IDS.map((a) => `\`${a}\``).join(", ")}.`
|
|
38805
38839
|
);
|
|
38806
38840
|
}
|
|
38841
|
+
const moved = await freshenServers(root, home, options.platform ?? process.platform, run);
|
|
38842
|
+
if (moved.length) done.push(`Pilot's server now always starts the latest version (${moved.map((m) => `\`${m}\``).join(", ")}): it used to keep the one it downloaded first.`);
|
|
38807
38843
|
if (framework.loads) done.push(`The app already loads Pilot (\`${relative5(cwd, framework.loads)}\`).`);
|
|
38808
38844
|
else todo.push(loadStep(framework, cwd));
|
|
38809
38845
|
const me = AGENTS.find((a) => a.id === named);
|
|
@@ -39250,7 +39286,7 @@ function createPilotServer(options = {}) {
|
|
|
39250
39286
|
const pages = await bridge.launch(o);
|
|
39251
39287
|
const where = pages > 0 ? `Pilot is open in ${pages === 1 ? "the page" : `${pages} pages`} at ${o}.` : `No page at ${o} is connected yet. Ask the designer to open ${url2} (with the dev server running): Pilot opens there.`;
|
|
39252
39288
|
const installed = searchable(project) ? installedVersion(project, project) : null;
|
|
39253
|
-
const stale = installed && olderThan(VERSION, installed) ? ` This chat's Pilot server is ${VERSION}, older than the project's ${installed}: tell the user to
|
|
39289
|
+
const stale = installed && olderThan(VERSION, installed) ? ` This chat's Pilot server is ${VERSION}, older than the project's ${installed}, so they may not connect. Don't look into ports or processes: tell the user to run \`npx usepilot@latest update\` in the app's folder (it makes the server start the latest Pilot), then restart it. ${RESTART[clientOf(client) ?? "other"]}` : installed && pages === 0 && olderThan(installed, VERSION) ? ` The project's Pilot is ${installed}, older than this server's ${VERSION}, so the page may not connect. Don't look into ports or processes: tell the user to run \`npx usepilot@latest update\` in the app's folder, then restart the app's dev server.` : "";
|
|
39254
39290
|
return text(`${where} Now call pilot_wait_for_edits and wait for the designer to press Send.${lost}${stale}`);
|
|
39255
39291
|
} catch (error62) {
|
|
39256
39292
|
return text(`Pilot couldn't start its bridge: ${error62.message}`, true);
|
|
@@ -39407,6 +39443,7 @@ Run this in your app's folder, the one where Pilot was set up. To set Pilot up i
|
|
|
39407
39443
|
await writeSkill(folder);
|
|
39408
39444
|
skills.push(folder.startsWith(home) ? `~${folder.slice(home.length)}` : folder);
|
|
39409
39445
|
}
|
|
39446
|
+
const servers = installed ? await freshenServers(root, home, options.platform ?? process.platform, run) : [];
|
|
39410
39447
|
if (!installed) {
|
|
39411
39448
|
return `# Pilot: not updated
|
|
39412
39449
|
|
|
@@ -39417,7 +39454,7 @@ ${pm} ${args.join(" ")}
|
|
|
39417
39454
|
\`\`\`
|
|
39418
39455
|
`;
|
|
39419
39456
|
}
|
|
39420
|
-
const changed = !!before && !!after && olderThan(before, after);
|
|
39457
|
+
const changed = !!before && !!after && olderThan(before, after) || servers.length > 0;
|
|
39421
39458
|
const agents = agentsWithPilot(root, home, options.platform);
|
|
39422
39459
|
const steps = [
|
|
39423
39460
|
"Restart your app's dev server, so the page loads the new Pilot.",
|
|
@@ -39429,12 +39466,16 @@ ${pm} ${args.join(" ")}
|
|
|
39429
39466
|
"Update Pilot in your other projects too (`npx usepilot@latest update` in each): this version can't share its connection with older ones."
|
|
39430
39467
|
);
|
|
39431
39468
|
}
|
|
39432
|
-
const
|
|
39469
|
+
const bumped = !!before && !!after && olderThan(before, after);
|
|
39470
|
+
const headline = bumped ? `# Pilot updated: ${before} \u2192 ${after}` : servers.length ? `# Pilot is up to date (${after ?? VERSION}); its server is fixed` : `# Pilot is up to date (${after ?? VERSION})`;
|
|
39433
39471
|
const skillLine = skills.length ? `
|
|
39434
39472
|
The \`pilot\` skill is updated too (${skills.map((s) => `\`${s}\``).join(", ")}).
|
|
39473
|
+
` : "";
|
|
39474
|
+
const serverLine = servers.length ? `
|
|
39475
|
+
Pilot's server now always starts the latest version (${servers.map((s) => `\`${s}\``).join(", ")}): it used to keep the one it downloaded first.
|
|
39435
39476
|
` : "";
|
|
39436
39477
|
return `${headline}
|
|
39437
|
-
${skillLine}
|
|
39478
|
+
${skillLine}${serverLine}
|
|
39438
39479
|
${changed ? `Next:
|
|
39439
39480
|
${steps.map((s, i) => `${i + 1}. ${s}`).join("\n")}
|
|
39440
39481
|
` : "Nothing else to do.\n"}`;
|