usepilot 0.7.1 → 0.7.2
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 +11 -1
- package/cli/index.js +137 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,11 +30,21 @@ Your agent is connected once for this machine, with nothing added to the repo. I
|
|
|
30
30
|
|
|
31
31
|
**No agent?** Run `npx usepilot@latest init --agent other` yourself and do the step it prints for loading Pilot. Then press **Option+P** (Alt+P on Windows and Linux) in your app, and **Copy prompt** hands your changes to any chat.
|
|
32
32
|
|
|
33
|
+
### Updating Pilot
|
|
34
|
+
|
|
35
|
+
Ask your agent to **update Pilot**, or run this in your project's folder:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx usepilot@latest update
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Then restart your app and open a new chat.
|
|
42
|
+
|
|
33
43
|
### If something doesn't work
|
|
34
44
|
|
|
35
45
|
- **The toolbar doesn't appear.** Pilot only loads in development, in the browser. Ask your agent to check where `usepilot/auto` is imported. The shortcut is ignored while you're typing in a text field.
|
|
36
46
|
- **The agent doesn't know Pilot.** Start a new chat: agents load their MCP servers when a chat starts. Some ask once to approve the project's server: say yes. In Cursor, if `pilot` shows switched off in Cursor Settings (MCP section), switch it on: Cursor keeps servers set up in a repo off until you do.
|
|
37
|
-
- **Pilot doesn't open, and another project's chat runs an older Pilot.** Pilots before 0.7.0 all used one port, so two projects on different versions blocked each other. Update Pilot in the older project (
|
|
47
|
+
- **Pilot doesn't open, and another project's chat runs an older Pilot.** Pilots before 0.7.0 all used one port, so two projects on different versions blocked each other. Update Pilot in the older project (`npx usepilot@latest update` there), or close that chat. From 0.7.0, each version has its own port, and projects on different versions run side by side.
|
|
38
48
|
|
|
39
49
|
## Using Pilot
|
|
40
50
|
|
package/cli/index.js
CHANGED
|
@@ -37937,6 +37937,15 @@ function whereSection(job, root) {
|
|
|
37937
37937
|
].join("\n");
|
|
37938
37938
|
}
|
|
37939
37939
|
|
|
37940
|
+
// src/version.ts
|
|
37941
|
+
var VERSION = "0.7.2";
|
|
37942
|
+
function olderThan(a, b) {
|
|
37943
|
+
const parts = (v) => v.replace(/^[^\d]*/, "").split(/[.-]/).slice(0, 3).map((n) => Number.parseInt(n, 10) || 0);
|
|
37944
|
+
const [x, y] = [parts(a), parts(b)];
|
|
37945
|
+
for (let i = 0; i < 3; i++) if ((x[i] ?? 0) !== (y[i] ?? 0)) return (x[i] ?? 0) < (y[i] ?? 0);
|
|
37946
|
+
return false;
|
|
37947
|
+
}
|
|
37948
|
+
|
|
37940
37949
|
// src/mcp.ts
|
|
37941
37950
|
function waitMsFor(clientName) {
|
|
37942
37951
|
const configured = Number(process.env.PILOT_WAIT_MS);
|
|
@@ -37952,6 +37961,8 @@ The loop, when the user asks to launch or start Pilot, runs /pilot, or asks to h
|
|
|
37952
37961
|
3. Apply the job's edits to the source: they're design instructions, not code, so write production code the way the project already styles things, whatever it uses (see the job's guidelines). Edits are basic: every value is given, so be fast (no screenshots or browser checks: Pilot checks the page). A "make responsive" job is an advanced task: make one element work at every viewport width. A "break and fix" job is one too: stress-test one element with odd but realistic content, fix what breaks, and put the real content back. Their prompts list the steps; check the result with pilot_check_widths (numbers for every width, instead of screenshots). If you can hand advanced tasks to a more capable model than the one you run on (a subagent, or another model your agent offers), do. A "comment" job is the designer's own words about one element: do what it asks (simple asks right away, open-ended ones as advanced tasks), and your pilot_done notes are your reply in their thread: one short sentence, like a chat message, not a report.
|
|
37953
37962
|
4. Call pilot_done with the job id and short notes (values you approximated, anything you did differently). When part of a job needs the designer's decision (they changed only some copies of shared code: each element's "Look-alikes" line counts the others; the jobs' guidelines say when, and what each answer means), do the rest, leave that part, and ask with pilot_done's question and choices ("${SHARED_CHOICES.all.label}", "${SHARED_CHOICES.one.label}", "${SHARED_CHOICES.variant.label}", your suggestion first); go on with other jobs, and their answer comes back as that job. Then call pilot_wait_for_edits again. 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.
|
|
37954
37963
|
|
|
37964
|
+
When the user asks to update Pilot: run \`npx usepilot@latest update\` in the app's folder and tell them, in a few lines, what it prints (the new version, and the steps left).
|
|
37965
|
+
|
|
37955
37966
|
Keep looping until the user interrupts you. Between jobs keep your messages short: a line on what you changed (and anything you approximated) is enough. If the user talks to you meanwhile, help them, then wait again: queued jobs are kept. Pilot keeps previewing each job's changes until you call pilot_done, then checks them against the page's real CSS: changes that didn't land come back once as a follow-up job with what the page gives instead.`;
|
|
37956
37967
|
function agentLabel(clientName, cwd) {
|
|
37957
37968
|
const names = {
|
|
@@ -38065,7 +38076,7 @@ function createPilotServer(options = {}) {
|
|
|
38065
38076
|
const port = options.port ?? (Number(process.env.PILOT_PORT) || DEFAULT_BRIDGE_PORT);
|
|
38066
38077
|
const cwd = options.cwd ?? process.cwd();
|
|
38067
38078
|
let waitMs = options.waitMs ?? waitMsFor(void 0);
|
|
38068
|
-
const server = new McpServer({ name: "pilot", version:
|
|
38079
|
+
const server = new McpServer({ name: "pilot", version: VERSION }, { instructions: INSTRUCTIONS });
|
|
38069
38080
|
const agent = { id: randomUUID2(), label: agentLabel(void 0, cwd) };
|
|
38070
38081
|
const bridge = new Bridge(agent, port);
|
|
38071
38082
|
let origin = null;
|
|
@@ -38219,7 +38230,7 @@ import { homedir } from "os";
|
|
|
38219
38230
|
import { join as join3, relative as relative2 } from "path";
|
|
38220
38231
|
|
|
38221
38232
|
// ../../skills/pilot/SKILL.md
|
|
38222
|
-
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.\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 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. 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";
|
|
38233
|
+
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. 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";
|
|
38223
38234
|
|
|
38224
38235
|
// src/setup.ts
|
|
38225
38236
|
var MCP_SERVER = { command: "npx", args: ["-y", "usepilot", "mcp"] };
|
|
@@ -38371,6 +38382,21 @@ var MACHINE = {
|
|
|
38371
38382
|
},
|
|
38372
38383
|
other: { skills: (home) => join4(home, ".agents", "skills") }
|
|
38373
38384
|
};
|
|
38385
|
+
function skillFolders(root, home) {
|
|
38386
|
+
const machine = AGENT_IDS.map((id) => join4(MACHINE[id].skills(home), "pilot"));
|
|
38387
|
+
const project = AGENTS.map((a) => join4(root, a.skills, "pilot"));
|
|
38388
|
+
return [.../* @__PURE__ */ new Set([...machine, ...project])];
|
|
38389
|
+
}
|
|
38390
|
+
function installArgs(pm, spec = "usepilot") {
|
|
38391
|
+
return pm === "npm" ? ["install", "-D", spec] : pm === "bun" ? ["add", "-d", spec] : ["add", "-D", spec];
|
|
38392
|
+
}
|
|
38393
|
+
function installedVersion(cwd, root) {
|
|
38394
|
+
for (let dir = cwd; ; dir = dirname2(dir)) {
|
|
38395
|
+
const version2 = readJson(join4(dir, "node_modules", "usepilot", "package.json"))?.version;
|
|
38396
|
+
if (version2) return version2;
|
|
38397
|
+
if (dir === root || dirname2(dir) === dir) return null;
|
|
38398
|
+
}
|
|
38399
|
+
}
|
|
38374
38400
|
function vscodeUserDir(home, platform) {
|
|
38375
38401
|
if (platform === "darwin") return join4(home, "Library", "Application Support", "Code", "User");
|
|
38376
38402
|
if (platform === "win32") return join4(process.env.APPDATA ?? join4(home, "AppData", "Roaming"), "Code", "User");
|
|
@@ -38411,10 +38437,15 @@ ${apps.map((a) => `- ${a}`).join("\n")}` : "."}
|
|
|
38411
38437
|
const done = [];
|
|
38412
38438
|
const todo = [];
|
|
38413
38439
|
const pm = packageManager(cwd, root);
|
|
38414
|
-
const
|
|
38415
|
-
const install = `${pm} ${
|
|
38440
|
+
const args = installArgs(pm);
|
|
38441
|
+
const install = `${pm} ${args.join(" ")}`;
|
|
38442
|
+
const installed = deps.usepilot ? installedVersion(cwd, root) : null;
|
|
38443
|
+
if (deps.usepilot && installed && olderThan(installed, VERSION))
|
|
38444
|
+
todo.push(
|
|
38445
|
+
`**Tell the user** Pilot ${installed} is installed here, and ${VERSION} is out: \`npx usepilot@latest update\` updates it (run it now if they ask).`
|
|
38446
|
+
);
|
|
38416
38447
|
if (deps.usepilot) done.push("`usepilot` was already a dependency.");
|
|
38417
|
-
else if (options.install !== false && run(pm,
|
|
38448
|
+
else if (options.install !== false && run(pm, args, cwd))
|
|
38418
38449
|
done.push(`Installed \`usepilot\` as a dev dependency (\`${install}\`).`);
|
|
38419
38450
|
else todo.push(`Install Pilot as a dev dependency: run \`${install}\` in ${cwd}.`);
|
|
38420
38451
|
const named = options.agent ?? detectAgent(options.env ?? process.env);
|
|
@@ -38711,6 +38742,95 @@ function runCommand(command2, args, cwd) {
|
|
|
38711
38742
|
return result.status === 0;
|
|
38712
38743
|
}
|
|
38713
38744
|
|
|
38745
|
+
// src/update.ts
|
|
38746
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
38747
|
+
import { existsSync as existsSync5, lstatSync, readFileSync as readFileSync3 } from "fs";
|
|
38748
|
+
import { homedir as homedir3 } from "os";
|
|
38749
|
+
import { dirname as dirname3, join as join5 } from "path";
|
|
38750
|
+
async function update(options = {}) {
|
|
38751
|
+
const cwd = options.cwd ?? process.cwd();
|
|
38752
|
+
const run = options.run ?? runCommand2;
|
|
38753
|
+
const home = options.home ?? homedir3();
|
|
38754
|
+
const pkg = readJson2(join5(cwd, "package.json"));
|
|
38755
|
+
const deps = { ...pkg?.dependencies, ...pkg?.devDependencies };
|
|
38756
|
+
if (!pkg || !deps.usepilot) {
|
|
38757
|
+
return `# Pilot isn't installed here
|
|
38758
|
+
|
|
38759
|
+
Run this in your app's folder, the one where Pilot was set up. To set Pilot up in this one, run \`npx usepilot@latest init\` instead.
|
|
38760
|
+
`;
|
|
38761
|
+
}
|
|
38762
|
+
const root = projectRoot(cwd);
|
|
38763
|
+
const before = installedVersion(cwd, root);
|
|
38764
|
+
const oldBridge = bridgeOf(cwd, root);
|
|
38765
|
+
const pm = packageManager(cwd, root);
|
|
38766
|
+
const args = installArgs(pm, "usepilot@latest");
|
|
38767
|
+
const installed = run(pm, args, cwd);
|
|
38768
|
+
const after = installed ? installedVersion(cwd, root) ?? VERSION : before;
|
|
38769
|
+
const skills = [];
|
|
38770
|
+
for (const folder of skillFolders(root, home)) {
|
|
38771
|
+
if (!existsSync5(folder) || isLink2(folder)) continue;
|
|
38772
|
+
await writeSkill(folder);
|
|
38773
|
+
skills.push(folder.startsWith(home) ? `~${folder.slice(home.length)}` : folder);
|
|
38774
|
+
}
|
|
38775
|
+
if (!installed) {
|
|
38776
|
+
return `# Pilot: not updated
|
|
38777
|
+
|
|
38778
|
+
Installing the latest Pilot didn't work (the output is above). Run this in ${cwd}, then \`npx usepilot@latest update\` again:
|
|
38779
|
+
|
|
38780
|
+
\`\`\`
|
|
38781
|
+
${pm} ${args.join(" ")}
|
|
38782
|
+
\`\`\`
|
|
38783
|
+
`;
|
|
38784
|
+
}
|
|
38785
|
+
const changed = !!before && !!after && olderThan(before, after);
|
|
38786
|
+
const steps = [
|
|
38787
|
+
"Restart your app's dev server, so the page loads the new Pilot.",
|
|
38788
|
+
"Open a new chat in your agent, and ask it to launch Pilot (or run `/pilot`). A chat that was open keeps the old Pilot."
|
|
38789
|
+
];
|
|
38790
|
+
if (oldBridge !== null && oldBridge !== BRIDGE_VERSION) {
|
|
38791
|
+
steps.push(
|
|
38792
|
+
"Update Pilot in your other projects too (`npx usepilot@latest update` in each): this version can't share its connection with older ones."
|
|
38793
|
+
);
|
|
38794
|
+
}
|
|
38795
|
+
const headline = changed ? `# Pilot updated: ${before} \u2192 ${after}` : `# Pilot is up to date (${after ?? VERSION})`;
|
|
38796
|
+
const skillLine = skills.length ? `
|
|
38797
|
+
The \`pilot\` skill is updated too (${skills.map((s) => `\`${s}\``).join(", ")}).
|
|
38798
|
+
` : "";
|
|
38799
|
+
return `${headline}
|
|
38800
|
+
${skillLine}
|
|
38801
|
+
${changed ? `Next:
|
|
38802
|
+
${steps.map((s, i) => `${i + 1}. ${s}`).join("\n")}
|
|
38803
|
+
` : "Nothing else to do.\n"}`;
|
|
38804
|
+
}
|
|
38805
|
+
function bridgeOf(cwd, root) {
|
|
38806
|
+
for (let dir = cwd; ; dir = dirname3(dir)) {
|
|
38807
|
+
const file2 = join5(dir, "node_modules", "usepilot", "cli", "index.js");
|
|
38808
|
+
if (existsSync5(file2)) {
|
|
38809
|
+
const match = /BRIDGE_VERSION = (\d+)/.exec(readFileSync3(file2, "utf8"));
|
|
38810
|
+
return match ? Number(match[1]) : null;
|
|
38811
|
+
}
|
|
38812
|
+
if (dir === root || dirname3(dir) === dir) return null;
|
|
38813
|
+
}
|
|
38814
|
+
}
|
|
38815
|
+
function isLink2(path) {
|
|
38816
|
+
try {
|
|
38817
|
+
return lstatSync(path).isSymbolicLink();
|
|
38818
|
+
} catch {
|
|
38819
|
+
return false;
|
|
38820
|
+
}
|
|
38821
|
+
}
|
|
38822
|
+
function readJson2(file2) {
|
|
38823
|
+
try {
|
|
38824
|
+
return JSON.parse(readFileSync3(file2, "utf8"));
|
|
38825
|
+
} catch {
|
|
38826
|
+
return null;
|
|
38827
|
+
}
|
|
38828
|
+
}
|
|
38829
|
+
function runCommand2(command2, args, cwd) {
|
|
38830
|
+
const result = spawnSync2(command2, args, { cwd, stdio: ["ignore", "inherit", "inherit"], shell: process.platform === "win32" });
|
|
38831
|
+
return result.status === 0;
|
|
38832
|
+
}
|
|
38833
|
+
|
|
38714
38834
|
// src/index.ts
|
|
38715
38835
|
var HELP = `usepilot: take the controls from your coding agent
|
|
38716
38836
|
|
|
@@ -38724,6 +38844,9 @@ Usage: npx usepilot <command>
|
|
|
38724
38844
|
--project: connect the agent in this repo (files to commit, for a
|
|
38725
38845
|
team) instead of once for every project on this machine
|
|
38726
38846
|
--no-install: print the install command instead of running it
|
|
38847
|
+
update Update Pilot in this project: the latest usepilot, and the pilot
|
|
38848
|
+
skill wherever init put it. Prints what's left (restart the app,
|
|
38849
|
+
open a new chat). Run it in the app's folder.
|
|
38727
38850
|
setup Set up /pilot in Claude Code, for every project on this machine
|
|
38728
38851
|
(--project: for this repo, to commit, so everyone gets it)
|
|
38729
38852
|
mcp Run the MCP server (stdio) agents connect to, and the bridge the
|
|
@@ -38779,6 +38902,15 @@ switch (command) {
|
|
|
38779
38902
|
);
|
|
38780
38903
|
} catch (error62) {
|
|
38781
38904
|
process.stderr.write(`usepilot init: ${error62.message}
|
|
38905
|
+
`);
|
|
38906
|
+
process.exitCode = 1;
|
|
38907
|
+
}
|
|
38908
|
+
break;
|
|
38909
|
+
case "update":
|
|
38910
|
+
try {
|
|
38911
|
+
process.stdout.write(await update());
|
|
38912
|
+
} catch (error62) {
|
|
38913
|
+
process.stderr.write(`usepilot update: ${error62.message}
|
|
38782
38914
|
`);
|
|
38783
38915
|
process.exitCode = 1;
|
|
38784
38916
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "usepilot",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"license": "FSL-1.1-MIT",
|
|
5
5
|
"description": "Pilot: take the controls from your coding agent. A control surface for coding agents, with checked results: edit, comment on and ask for tasks on your running app, and Pilot checks what the agent changed on the page.",
|
|
6
6
|
"keywords": [
|