usepilot 0.9.0 → 0.11.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 CHANGED
@@ -2985,7 +2985,7 @@ var require_compile = __commonJS({
2985
2985
  const schOrFunc = root.refs[ref];
2986
2986
  if (schOrFunc)
2987
2987
  return schOrFunc;
2988
- let _sch = resolve2.call(this, root, ref);
2988
+ let _sch = resolve3.call(this, root, ref);
2989
2989
  if (_sch === void 0) {
2990
2990
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
2991
2991
  const { schemaId } = this.opts;
@@ -3012,7 +3012,7 @@ var require_compile = __commonJS({
3012
3012
  function sameSchemaEnv(s1, s2) {
3013
3013
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
3014
3014
  }
3015
- function resolve2(root, ref) {
3015
+ function resolve3(root, ref) {
3016
3016
  let sch;
3017
3017
  while (typeof (sch = this.refs[ref]) == "string")
3018
3018
  ref = sch;
@@ -3876,7 +3876,7 @@ var require_fast_uri = __commonJS({
3876
3876
  }
3877
3877
  return uri;
3878
3878
  }
3879
- function resolve2(baseURI, relativeURI, options) {
3879
+ function resolve3(baseURI, relativeURI, options) {
3880
3880
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3881
3881
  const {
3882
3882
  parsed: baseParsed,
@@ -3912,50 +3912,50 @@ var require_fast_uri = __commonJS({
3912
3912
  schemelessOptions.skipEscape = true;
3913
3913
  return serialize(resolved, schemelessOptions);
3914
3914
  }
3915
- function resolveComponent(base, relative5, options, skipNormalization) {
3915
+ function resolveComponent(base, relative6, options, skipNormalization) {
3916
3916
  const target = {};
3917
3917
  if (!skipNormalization) {
3918
3918
  base = parse3(serialize(base, options), options);
3919
- relative5 = parse3(serialize(relative5, options), options);
3919
+ relative6 = parse3(serialize(relative6, options), options);
3920
3920
  }
3921
3921
  options = options || {};
3922
- if (!options.tolerant && relative5.scheme) {
3923
- target.scheme = relative5.scheme;
3924
- target.userinfo = relative5.userinfo;
3925
- target.host = relative5.host;
3926
- target.port = relative5.port;
3927
- target.path = removeDotSegments(relative5.path || "");
3928
- target.query = relative5.query;
3922
+ if (!options.tolerant && relative6.scheme) {
3923
+ target.scheme = relative6.scheme;
3924
+ target.userinfo = relative6.userinfo;
3925
+ target.host = relative6.host;
3926
+ target.port = relative6.port;
3927
+ target.path = removeDotSegments(relative6.path || "");
3928
+ target.query = relative6.query;
3929
3929
  } else {
3930
- if (relative5.userinfo !== void 0 || relative5.host !== void 0 || relative5.port !== void 0) {
3931
- target.userinfo = relative5.userinfo;
3932
- target.host = relative5.host;
3933
- target.port = relative5.port;
3934
- target.path = removeDotSegments(relative5.path || "");
3935
- target.query = relative5.query;
3930
+ if (relative6.userinfo !== void 0 || relative6.host !== void 0 || relative6.port !== void 0) {
3931
+ target.userinfo = relative6.userinfo;
3932
+ target.host = relative6.host;
3933
+ target.port = relative6.port;
3934
+ target.path = removeDotSegments(relative6.path || "");
3935
+ target.query = relative6.query;
3936
3936
  } else {
3937
- if (!relative5.path) {
3937
+ if (!relative6.path) {
3938
3938
  target.path = base.path;
3939
- if (relative5.query !== void 0) {
3940
- target.query = relative5.query;
3939
+ if (relative6.query !== void 0) {
3940
+ target.query = relative6.query;
3941
3941
  } else {
3942
3942
  target.query = base.query;
3943
3943
  }
3944
3944
  } else {
3945
- if (relative5.path[0] === "/") {
3946
- target.path = removeDotSegments(relative5.path);
3945
+ if (relative6.path[0] === "/") {
3946
+ target.path = removeDotSegments(relative6.path);
3947
3947
  } else {
3948
3948
  const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
3949
3949
  if (baseHasAuthority && !base.path) {
3950
- target.path = "/" + relative5.path;
3950
+ target.path = "/" + relative6.path;
3951
3951
  } else if (!base.path) {
3952
- target.path = relative5.path;
3952
+ target.path = relative6.path;
3953
3953
  } else {
3954
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative5.path;
3954
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative6.path;
3955
3955
  }
3956
3956
  target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
3957
3957
  }
3958
- target.query = relative5.query;
3958
+ target.query = relative6.query;
3959
3959
  }
3960
3960
  target.userinfo = base.userinfo;
3961
3961
  target.host = base.host;
@@ -3963,7 +3963,7 @@ var require_fast_uri = __commonJS({
3963
3963
  }
3964
3964
  target.scheme = base.scheme;
3965
3965
  }
3966
- target.fragment = relative5.fragment;
3966
+ target.fragment = relative6.fragment;
3967
3967
  return target;
3968
3968
  }
3969
3969
  function equal(uriA, uriB, options) {
@@ -4267,7 +4267,7 @@ var require_fast_uri = __commonJS({
4267
4267
  var fastUri = {
4268
4268
  SCHEMES,
4269
4269
  normalize,
4270
- resolve: resolve2,
4270
+ resolve: resolve3,
4271
4271
  resolveComponent,
4272
4272
  equal,
4273
4273
  serialize,
@@ -12326,7 +12326,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
12326
12326
  var NONE = 0;
12327
12327
  var ASSUMED = 1;
12328
12328
  var PROVEN = 2;
12329
- function isRecursive(inst, stack, resolve2) {
12329
+ function isRecursive(inst, stack, resolve3) {
12330
12330
  const cached2 = recursive.get(inst);
12331
12331
  if (cached2 !== void 0)
12332
12332
  return cached2 ? PROVEN : NONE;
@@ -12336,7 +12336,7 @@ function isRecursive(inst, stack, resolve2) {
12336
12336
  let result = NONE;
12337
12337
  const check2 = (child) => {
12338
12338
  if (result !== PROVEN && child?._zod) {
12339
- const answer = isRecursive(child, stack, resolve2);
12339
+ const answer = isRecursive(child, stack, resolve3);
12340
12340
  if (answer > result)
12341
12341
  result = answer;
12342
12342
  }
@@ -12347,7 +12347,7 @@ function isRecursive(inst, stack, resolve2) {
12347
12347
  const desc = Object.getOwnPropertyDescriptor(sh, key);
12348
12348
  if (spread && !desc.enumerable)
12349
12349
  continue;
12350
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve2) : NONE;
12350
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve3) : NONE;
12351
12351
  if (child > answer)
12352
12352
  answer = child;
12353
12353
  }
@@ -12411,7 +12411,7 @@ function isRecursive(inst, stack, resolve2) {
12411
12411
  break;
12412
12412
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
12413
12413
  case "lazy": {
12414
- const inner = def._cachedInner ?? (resolve2 ? inst._zod.innerType : void 0);
12414
+ const inner = def._cachedInner ?? (resolve3 ? inst._zod.innerType : void 0);
12415
12415
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
12416
12416
  break;
12417
12417
  }
@@ -26761,21 +26761,21 @@ function visit(schema, fnOrHandlers) {
26761
26761
  const h = fnOrHandlers[node2._zod.def.type];
26762
26762
  return h ? h(node2, rewritten) : node2;
26763
26763
  };
26764
- const cache3 = /* @__PURE__ */ new Map();
26764
+ const cache4 = /* @__PURE__ */ new Map();
26765
26765
  function run(s) {
26766
- const cached2 = cache3.get(s);
26766
+ const cached2 = cache4.get(s);
26767
26767
  if (cached2 === RESOLVING) {
26768
26768
  return new $ZodLazy({
26769
26769
  type: "lazy",
26770
- getter: () => cache3.get(s)
26770
+ getter: () => cache4.get(s)
26771
26771
  });
26772
26772
  }
26773
26773
  if (cached2 !== void 0)
26774
26774
  return cached2;
26775
- cache3.set(s, RESOLVING);
26775
+ cache4.set(s, RESOLVING);
26776
26776
  const inner = mapInner(s);
26777
26777
  const mapped = fn(inner, inner !== s);
26778
- cache3.set(s, mapped);
26778
+ cache4.set(s, mapped);
26779
26779
  return mapped;
26780
26780
  }
26781
26781
  function mapInner(s) {
@@ -28600,12 +28600,12 @@ var StdioServerTransport = class {
28600
28600
  this.onclose?.();
28601
28601
  }
28602
28602
  send(message) {
28603
- return new Promise((resolve2) => {
28603
+ return new Promise((resolve3) => {
28604
28604
  const json3 = serializeMessage(message);
28605
28605
  if (this._stdout.write(json3)) {
28606
- resolve2();
28606
+ resolve3();
28607
28607
  } else {
28608
- this._stdout.once("drain", resolve2);
28608
+ this._stdout.once("drain", resolve3);
28609
28609
  }
28610
28610
  });
28611
28611
  }
@@ -28614,7 +28614,7 @@ var StdioServerTransport = class {
28614
28614
  // src/mcp.ts
28615
28615
  import { randomUUID as randomUUID2 } from "crypto";
28616
28616
  import { existsSync as existsSync6 } from "fs";
28617
- import { basename as basename4, isAbsolute as isAbsolute2, resolve } from "path";
28617
+ import { basename as basename5, isAbsolute as isAbsolute2, resolve as resolve2 } from "path";
28618
28618
  import { fileURLToPath } from "url";
28619
28619
 
28620
28620
  // ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v3/helpers/util.js
@@ -34591,7 +34591,7 @@ var Protocol = class {
34591
34591
  return;
34592
34592
  }
34593
34593
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
34594
- await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
34594
+ await new Promise((resolve3) => setTimeout(resolve3, pollInterval));
34595
34595
  options?.signal?.throwIfAborted();
34596
34596
  }
34597
34597
  } catch (error62) {
@@ -34608,7 +34608,7 @@ var Protocol = class {
34608
34608
  */
34609
34609
  request(request, resultSchema, options) {
34610
34610
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
34611
- return new Promise((resolve2, reject) => {
34611
+ return new Promise((resolve3, reject) => {
34612
34612
  const earlyReject = (error62) => {
34613
34613
  reject(error62);
34614
34614
  };
@@ -34686,7 +34686,7 @@ var Protocol = class {
34686
34686
  if (!parseResult.success) {
34687
34687
  reject(parseResult.error);
34688
34688
  } else {
34689
- resolve2(parseResult.data);
34689
+ resolve3(parseResult.data);
34690
34690
  }
34691
34691
  } catch (error62) {
34692
34692
  reject(error62);
@@ -34948,12 +34948,12 @@ var Protocol = class {
34948
34948
  }
34949
34949
  } catch {
34950
34950
  }
34951
- return new Promise((resolve2, reject) => {
34951
+ return new Promise((resolve3, reject) => {
34952
34952
  if (signal.aborted) {
34953
34953
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
34954
34954
  return;
34955
34955
  }
34956
- const timeoutId = setTimeout(resolve2, interval);
34956
+ const timeoutId = setTimeout(resolve3, interval);
34957
34957
  signal.addEventListener("abort", () => {
34958
34958
  clearTimeout(timeoutId);
34959
34959
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -36093,7 +36093,7 @@ var McpServer = class {
36093
36093
  let task = createTaskResult.task;
36094
36094
  const pollInterval = task.pollInterval ?? 5e3;
36095
36095
  while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
36096
- await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
36096
+ await new Promise((resolve3) => setTimeout(resolve3, pollInterval));
36097
36097
  const updatedTask = await extra.taskStore.getTask(taskId);
36098
36098
  if (!updatedTask) {
36099
36099
  throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
@@ -36724,9 +36724,21 @@ function formatPrompt(changeSet, options = {}) {
36724
36724
  edits.forEach((edit, index) => {
36725
36725
  lines.push("", ...formatEdit(edit, index + 1));
36726
36726
  });
36727
+ lines.push(...fileTokenLines(changeSet.fileTokens));
36727
36728
  return `${lines.join("\n")}
36728
36729
  `;
36729
36730
  }
36731
+ function fileTokenLines(tokens) {
36732
+ if (!tokens?.length) return [];
36733
+ return [
36734
+ "",
36735
+ "## The project's tokens in these values",
36736
+ "",
36737
+ "Some values use tokens from the project's files, which Pilot previewed as CSS variables of its own: they're not in the code. Write each the way the project uses that token (its utility, its variable, its theme), never the `var(--\u2026)` itself:",
36738
+ "",
36739
+ ...tokens.map((t) => `- \`var(${t.variable})\` is \`${t.name}\` in \`${t.file}${t.line ? `:${t.line}` : ""}\` (\`${t.value}\`)`)
36740
+ ];
36741
+ }
36730
36742
  var ADVANCED_TASK = "**An advanced task: it needs judgment more than speed.** If you can hand work to a more capable model than the one you run on (a subagent, or another model your agent offers), do: give it this whole prompt (with the job id), have it make the changes and run the width check, and report back; then call `pilot_done` with its notes.";
36731
36743
  var DESIGN_INTENT = "**These are design instructions, not code**: the designer's intent, shown as plain CSS values. Use your judgment and write production code the way this project already styles things, whatever it uses (Tailwind, CSS or Sass modules, StyleX, vanilla-extract, Panda, styled-components, Emotion, a component library's props\u2026). First look at how each element's component is styled, and follow that: its tokens and scale, its variants and props, and the rule that already styles it rather than a new override.";
36732
36744
  var PRODUCTION_CODE = "No inline styles, no `!important`, no hard-coded values where a token or utility fits.";
@@ -36934,6 +36946,7 @@ function formatComment(changeSet, request, options = {}) {
36934
36946
  ...options.guidelines === false ? [EDIT_GUIDELINES_REMINDER] : ["Guidelines:", ...EDIT_GUIDELINES]
36935
36947
  );
36936
36948
  edits.forEach((edit, index) => lines.push("", ...formatEdit(edit, index + 1).map((l) => l.startsWith("## ") ? `#${l}` : l)));
36949
+ lines.push(...fileTokenLines(changeSet.fileTokens));
36937
36950
  }
36938
36951
  if (earlier.length) {
36939
36952
  lines.push("", "## The thread so far (you already did what it asked)", "");
@@ -36985,6 +36998,8 @@ function referenceLines(references) {
36985
36998
  }
36986
36999
  function referenceLine(reference) {
36987
37000
  const as = `- \`${mentionText(reference)}\`:`;
37001
+ if (reference.kind === "token" && reference.source)
37002
+ return `${as} a design token from the project's files (\`${reference.source.file}${reference.source.line ? `:${reference.source.line}` : ""}\`), now \`${reference.value}\`. Use this token the way the project does (its utility, its variable, its theme); it isn't a CSS variable on the page.`;
36988
37003
  if (reference.kind === "token")
36989
37004
  return `${as} a design token (a CSS variable on the page), now \`${reference.value}\`. Use this token (\`var(${reference.name})\`, or the project's form of it).`;
36990
37005
  if (reference.kind === "unlisted")
@@ -37110,7 +37125,7 @@ function formatWidthCheck(check2) {
37110
37125
  }
37111
37126
 
37112
37127
  // ../protocol/src/bridge.ts
37113
- var BRIDGE_VERSION = 5;
37128
+ var BRIDGE_VERSION = 6;
37114
37129
  var DEFAULT_BRIDGE_PORT = 4747 + BRIDGE_VERSION;
37115
37130
  var MAX_CHOICES = 4;
37116
37131
  function questionOf(value) {
@@ -37406,6 +37421,150 @@ function read(path) {
37406
37421
  return found;
37407
37422
  }
37408
37423
 
37424
+ // src/tokenFiles.ts
37425
+ import { readdirSync as readdirSync2, readFileSync as readFileSync2, statSync as statSync2 } from "fs";
37426
+ import { basename as basename3, dirname as dirname3, join as join3, relative as relative2 } from "path";
37427
+ var MAX_FILES2 = 8e3;
37428
+ var MAX_FILE_BYTES2 = 512e3;
37429
+ var MAX_TOKENS = 1e3;
37430
+ var BUDGET_MS2 = 1500;
37431
+ function isTokenJson(path) {
37432
+ const name = basename3(path).toLowerCase();
37433
+ if (!name.endsWith(".json") || name === "package.json" || name.startsWith("tsconfig")) return false;
37434
+ return /(^|[.-])(design-)?tokens?\.json$/.test(name) || /(^|\/)(design-)?tokens?$/.test(dirname3(path).toLowerCase());
37435
+ }
37436
+ function isTokenSass(path) {
37437
+ const name = basename3(path).toLowerCase();
37438
+ return /\.s[ac]ss$/.test(name) && /(token|variable|vars?\b|theme|colou?r|spacing|typograph|radius|radii|shadow|breakpoint)/.test(name);
37439
+ }
37440
+ var cache2 = /* @__PURE__ */ new Map();
37441
+ function fileTokens(folders) {
37442
+ const out = [];
37443
+ const seen = /* @__PURE__ */ new Set();
37444
+ const deadline = Date.now() + BUDGET_MS2;
37445
+ for (const root of new Set(folders.map(workspaceRoot))) {
37446
+ for (const t of scan2(root, deadline)) {
37447
+ if (out.length >= MAX_TOKENS) return out;
37448
+ if (!seen.has(t.name)) {
37449
+ seen.add(t.name);
37450
+ out.push(t);
37451
+ }
37452
+ }
37453
+ }
37454
+ return out;
37455
+ }
37456
+ function scan2(root, deadline) {
37457
+ const known = cache2.get(root) ?? /* @__PURE__ */ new Map();
37458
+ const now = /* @__PURE__ */ new Map();
37459
+ const out = [];
37460
+ let files = 0;
37461
+ const walk = (dir) => {
37462
+ let entries;
37463
+ try {
37464
+ entries = readdirSync2(dir, { withFileTypes: true });
37465
+ } catch {
37466
+ return;
37467
+ }
37468
+ for (const entry of entries) {
37469
+ if (files >= MAX_FILES2 || Date.now() > deadline) return;
37470
+ const name = entry.name;
37471
+ if (SKIP.has(name) || name.startsWith(".")) continue;
37472
+ const path = join3(dir, name);
37473
+ if (entry.isDirectory()) {
37474
+ walk(path);
37475
+ continue;
37476
+ }
37477
+ files++;
37478
+ const json3 = isTokenJson(path);
37479
+ if (!entry.isFile() || !(json3 || isTokenSass(path))) continue;
37480
+ let stat2;
37481
+ try {
37482
+ stat2 = statSync2(path);
37483
+ } catch {
37484
+ continue;
37485
+ }
37486
+ if (stat2.size > MAX_FILE_BYTES2) continue;
37487
+ const before = known.get(path);
37488
+ const file2 = relative2(root, path);
37489
+ const cached2 = before && before.mtime === stat2.mtimeMs ? before : { mtime: stat2.mtimeMs, tokens: read2(path, file2, json3) };
37490
+ now.set(path, cached2);
37491
+ out.push(...cached2.tokens);
37492
+ }
37493
+ };
37494
+ walk(root);
37495
+ cache2.set(root, now);
37496
+ return out;
37497
+ }
37498
+ function read2(path, file2, json3) {
37499
+ let text;
37500
+ try {
37501
+ text = readFileSync2(path, "utf8");
37502
+ } catch {
37503
+ return [];
37504
+ }
37505
+ return json3 ? jsonTokens(text, file2) : sassTokens(text, file2);
37506
+ }
37507
+ function jsonTokens(text, file2) {
37508
+ let data;
37509
+ try {
37510
+ data = JSON.parse(text);
37511
+ } catch {
37512
+ return [];
37513
+ }
37514
+ const raw = /* @__PURE__ */ new Map();
37515
+ const walk = (node2, path) => {
37516
+ if (!node2 || typeof node2 !== "object" || Array.isArray(node2)) return;
37517
+ const n = node2;
37518
+ const value = "$value" in n ? n.$value : "value" in n && typeof n.value !== "object" ? n.value : void 0;
37519
+ if (value !== void 0) {
37520
+ if ((typeof value === "string" || typeof value === "number") && path.length) raw.set(path.join("."), String(value));
37521
+ return;
37522
+ }
37523
+ for (const [key, child] of Object.entries(n)) if (!key.startsWith("$")) walk(child, [...path, key]);
37524
+ };
37525
+ walk(data, []);
37526
+ const lines = text.split("\n");
37527
+ const out = [];
37528
+ for (const [name, value] of raw) {
37529
+ const resolved = resolve(value, (ref) => raw.get(ref), /\{([^{}]+)\}/g);
37530
+ if (resolved === null) continue;
37531
+ const last = name.split(".").at(-1);
37532
+ const at = lines.findIndex((l) => l.includes(`"${last}"`));
37533
+ out.push({ name, value: resolved, file: file2, ...at >= 0 ? { line: at + 1 } : {} });
37534
+ }
37535
+ return out;
37536
+ }
37537
+ function sassTokens(text, file2) {
37538
+ const raw = /* @__PURE__ */ new Map();
37539
+ text.split("\n").forEach((line, i) => {
37540
+ const m = /^\s*\$([\w-]+)\s*:\s*([^;]+?)\s*(?:!default|!global)*\s*;/.exec(line);
37541
+ if (m && !raw.has(m[1])) raw.set(m[1], { value: m[2], line: i + 1 });
37542
+ });
37543
+ const out = [];
37544
+ for (const [name, { value, line }] of raw) {
37545
+ if (/[\w-]\([^)]*\$|map-get|\bif\(|^\(/.test(value)) continue;
37546
+ const resolved = resolve(value, (ref) => raw.get(ref)?.value, /\$([\w-]+)/g);
37547
+ if (resolved === null || resolved.includes("$")) continue;
37548
+ out.push({ name: `$${name}`, value: resolved, file: file2, line });
37549
+ }
37550
+ return out;
37551
+ }
37552
+ function resolve(value, get, pattern) {
37553
+ let v = value;
37554
+ for (let depth = 0; depth < 8; depth++) {
37555
+ let missing = false;
37556
+ const next = v.replace(pattern, (_, ref) => {
37557
+ const found = get(ref);
37558
+ if (found === void 0) missing = true;
37559
+ return found ?? "";
37560
+ });
37561
+ if (missing) return null;
37562
+ if (next === v) return v.trim();
37563
+ v = next;
37564
+ }
37565
+ return null;
37566
+ }
37567
+
37409
37568
  // src/hub.ts
37410
37569
  import { randomUUID } from "crypto";
37411
37570
  var AGENT_TTL = 3e4;
@@ -37478,14 +37637,14 @@ var Hub = class {
37478
37637
  const key = originKey(origin);
37479
37638
  const queued = this.oldestQueued(key);
37480
37639
  if (queued) return Promise.resolve({ job: this.take(queued, this.shown(info)) });
37481
- return new Promise((resolve2) => {
37640
+ return new Promise((resolve3) => {
37482
37641
  const waiter = {
37483
37642
  agentId: info.id,
37484
37643
  origin: key,
37485
37644
  resolve: (job) => {
37486
37645
  clearTimeout(timer);
37487
37646
  signal?.removeEventListener("abort", onAbort);
37488
- resolve2({ job });
37647
+ resolve3({ job });
37489
37648
  }
37490
37649
  };
37491
37650
  const timer = setTimeout(() => this.endWait(waiter, null), timeoutMs);
@@ -37539,12 +37698,12 @@ var Hub = class {
37539
37698
  const job = this.jobs.get(jobId);
37540
37699
  if (!job) return Promise.resolve(null);
37541
37700
  const requestId = randomUUID();
37542
- return new Promise((resolve2) => {
37701
+ return new Promise((resolve3) => {
37543
37702
  const timer = setTimeout(() => finish(null), timeoutMs);
37544
37703
  const finish = (check2) => {
37545
37704
  clearTimeout(timer);
37546
37705
  this.checks.delete(requestId);
37547
- resolve2(check2);
37706
+ resolve3(check2);
37548
37707
  };
37549
37708
  this.checks.set(requestId, { origin: job.origin, resolve: finish });
37550
37709
  if (!this.sendTo(job.origin, { type: "check", requestId, jobId })) finish(null);
@@ -37689,14 +37848,14 @@ function startHub(port, hub = new Hub(), options = {}) {
37689
37848
  });
37690
37849
  const sweep = setInterval(() => hub.sweep(localAgents), 5e3);
37691
37850
  sweep.unref();
37692
- return new Promise((resolve2, reject) => {
37851
+ return new Promise((resolve3, reject) => {
37693
37852
  server.once("error", (error62) => {
37694
37853
  clearInterval(sweep);
37695
37854
  reject(error62);
37696
37855
  });
37697
37856
  server.listen(port, "127.0.0.1", () => {
37698
37857
  const address = server.address();
37699
- resolve2({
37858
+ resolve3({
37700
37859
  hub,
37701
37860
  server,
37702
37861
  port: typeof address === "object" && address ? address.port : port,
@@ -37734,6 +37893,7 @@ async function handle(hub, req, res, attachments) {
37734
37893
  if (req.method !== "POST") return json2(res, 405, { error: "POST only" });
37735
37894
  if (!hub.hasAgents(origin)) return json2(res, 403, { error: "no agent works on this page: run /pilot in your agent" });
37736
37895
  if (path === "/components") return json2(res, 200, { components: projectComponents(hub.folders(origin)) });
37896
+ if (path === "/tokens") return json2(res, 200, { tokens: fileTokens(hub.folders(origin)) });
37737
37897
  if (path === "/attachments") {
37738
37898
  const type = req.headers["content-type"] ?? "";
37739
37899
  if (!extensionOf(type)) return json2(res, 415, { error: "images (png, jpeg, gif, webp), text files (txt, md, csv, json) and PDFs only" });
@@ -37830,7 +37990,7 @@ function json2(res, status, data) {
37830
37990
  res.end(JSON.stringify(data));
37831
37991
  }
37832
37992
  function rawBody(req, max) {
37833
- return new Promise((resolve2, reject) => {
37993
+ return new Promise((resolve3, reject) => {
37834
37994
  const chunks = [];
37835
37995
  let size = 0;
37836
37996
  let over = false;
@@ -37839,20 +37999,20 @@ function rawBody(req, max) {
37839
37999
  size += chunk.length;
37840
38000
  if (size > max) {
37841
38001
  over = true;
37842
- resolve2(null);
38002
+ resolve3(null);
37843
38003
  req.resume();
37844
38004
  return;
37845
38005
  }
37846
38006
  chunks.push(chunk);
37847
38007
  });
37848
38008
  req.on("end", () => {
37849
- if (!over) resolve2(Buffer.concat(chunks));
38009
+ if (!over) resolve3(Buffer.concat(chunks));
37850
38010
  });
37851
38011
  req.on("error", reject);
37852
38012
  });
37853
38013
  }
37854
38014
  function body(req) {
37855
- return new Promise((resolve2, reject) => {
38015
+ return new Promise((resolve3, reject) => {
37856
38016
  let text = "";
37857
38017
  req.setEncoding("utf8");
37858
38018
  req.on("data", (chunk) => {
@@ -37861,9 +38021,9 @@ function body(req) {
37861
38021
  });
37862
38022
  req.on("end", () => {
37863
38023
  try {
37864
- resolve2(text ? JSON.parse(text) : {});
38024
+ resolve3(text ? JSON.parse(text) : {});
37865
38025
  } catch {
37866
- resolve2({});
38026
+ resolve3({});
37867
38027
  }
37868
38028
  });
37869
38029
  req.on("error", reject);
@@ -38065,8 +38225,8 @@ function isConnectionError(error62) {
38065
38225
  }
38066
38226
 
38067
38227
  // src/locate.ts
38068
- import { existsSync as existsSync3, readdirSync as readdirSync2, readFileSync as readFileSync2, statSync as statSync2 } from "fs";
38069
- import { basename as basename3, extname as extname2, isAbsolute, join as join3, relative as relative2 } from "path";
38228
+ import { existsSync as existsSync3, readdirSync as readdirSync3, readFileSync as readFileSync3, statSync as statSync3 } from "fs";
38229
+ import { basename as basename4, extname as extname3, isAbsolute, join as join4, relative as relative3 } from "path";
38070
38230
  var SKIP2 = /* @__PURE__ */ new Set([
38071
38231
  "node_modules",
38072
38232
  "dist",
@@ -38102,40 +38262,40 @@ var EXTENSIONS2 = /* @__PURE__ */ new Set([
38102
38262
  ".liquid",
38103
38263
  ".twig"
38104
38264
  ]);
38105
- var MAX_FILES2 = 4e3;
38106
- var MAX_FILE_BYTES2 = 512e3;
38107
- var BUDGET_MS2 = 800;
38108
- var cache2 = null;
38265
+ var MAX_FILES3 = 4e3;
38266
+ var MAX_FILE_BYTES3 = 512e3;
38267
+ var BUDGET_MS3 = 800;
38268
+ var cache3 = null;
38109
38269
  function sourceFiles(root) {
38110
- if (cache2 && cache2.root === root && Date.now() - cache2.at < 3e4) return cache2.files;
38270
+ if (cache3 && cache3.root === root && Date.now() - cache3.at < 3e4) return cache3.files;
38111
38271
  const files = [];
38112
38272
  const walk = (dir) => {
38113
38273
  let names;
38114
38274
  try {
38115
- names = readdirSync2(dir);
38275
+ names = readdirSync3(dir);
38116
38276
  } catch {
38117
38277
  return;
38118
38278
  }
38119
38279
  for (const name of names) {
38120
- if (files.length >= MAX_FILES2) return;
38280
+ if (files.length >= MAX_FILES3) return;
38121
38281
  if (SKIP2.has(name) || name.startsWith(".") && name !== ".") continue;
38122
- const path = join3(dir, name);
38282
+ const path = join4(dir, name);
38123
38283
  let stat2;
38124
38284
  try {
38125
- stat2 = statSync2(path);
38285
+ stat2 = statSync3(path);
38126
38286
  } catch {
38127
38287
  continue;
38128
38288
  }
38129
38289
  if (stat2.isDirectory()) walk(path);
38130
- else if (EXTENSIONS2.has(extname2(name)) && stat2.size <= MAX_FILE_BYTES2) files.push(path);
38290
+ else if (EXTENSIONS2.has(extname3(name)) && stat2.size <= MAX_FILE_BYTES3) files.push(path);
38131
38291
  }
38132
38292
  };
38133
38293
  walk(root);
38134
- cache2 = { root, at: Date.now(), files };
38294
+ cache3 = { root, at: Date.now(), files };
38135
38295
  return files;
38136
38296
  }
38137
38297
  function searchable(cwd) {
38138
- return existsSync3(join3(cwd, "package.json")) || existsSync3(join3(cwd, ".git"));
38298
+ return existsSync3(join4(cwd, "package.json")) || existsSync3(join4(cwd, ".git"));
38139
38299
  }
38140
38300
  var escape2 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
38141
38301
  function needles(target) {
@@ -38150,12 +38310,12 @@ function needles(target) {
38150
38310
  tag: new RegExp(`<${escape2(target.tag)}[\\s>/]`, "i")
38151
38311
  };
38152
38312
  }
38153
- function locate(target, root, deadline = Date.now() + BUDGET_MS2) {
38313
+ function locate(target, root, deadline = Date.now() + BUDGET_MS3) {
38154
38314
  const n = needles(target);
38155
38315
  const known = target.source?.file && target.source.line ? sourcePath(target.source.file, root) : null;
38156
38316
  if (known && target.source?.line) {
38157
38317
  try {
38158
- const lines = readFileSync2(join3(root, known), "utf8").split("\n");
38318
+ const lines = readFileSync3(join4(root, known), "utf8").split("\n");
38159
38319
  const from = target.source.line - 1;
38160
38320
  const own2 = bestLine(n, lines, from);
38161
38321
  const index = own2 && own2.score >= 2 ? own2.index : from;
@@ -38169,7 +38329,7 @@ function locate(target, root, deadline = Date.now() + BUDGET_MS2) {
38169
38329
  if (Date.now() > deadline) break;
38170
38330
  let content;
38171
38331
  try {
38172
- content = readFileSync2(file2, "utf8");
38332
+ content = readFileSync3(file2, "utf8");
38173
38333
  } catch {
38174
38334
  continue;
38175
38335
  }
@@ -38182,7 +38342,7 @@ function locate(target, root, deadline = Date.now() + BUDGET_MS2) {
38182
38342
  }
38183
38343
  const enough = best && (best.score >= 6 || n.classes.length >= 3 && best.score >= n.classes.length + 2);
38184
38344
  if (!best || !enough) return null;
38185
- return { file: relative2(root, best.file), line: best.line + 1, snippet: snippetAt(best.lines, best.line) };
38345
+ return { file: relative3(root, best.file), line: best.line + 1, snippet: snippetAt(best.lines, best.line) };
38186
38346
  }
38187
38347
  function bestLine(n, lines, from = 0) {
38188
38348
  const classesOn = (i) => lines[i] === void 0 ? 0 : n.classes.filter((re) => re.test(lines[i])).length;
@@ -38206,23 +38366,23 @@ function snippetAt(lines, index) {
38206
38366
  return lines.slice(Math.max(0, index - 2), index + 3).map((l) => l.length > 160 ? `${l.slice(0, 159)}\u2026` : l).join("\n");
38207
38367
  }
38208
38368
  function sourcePath(file2, root) {
38209
- const rel = isAbsolute(file2) ? relative2(root, file2) : file2.replace(/^\.\//, "");
38369
+ const rel = isAbsolute(file2) ? relative3(root, file2) : file2.replace(/^\.\//, "");
38210
38370
  if (rel.startsWith("..") || isAbsolute(rel)) return null;
38211
- return existsSync3(join3(root, rel)) ? rel : null;
38371
+ return existsSync3(join4(root, rel)) ? rel : null;
38212
38372
  }
38213
- function componentFile(name, root, deadline = Date.now() + BUDGET_MS2, within) {
38373
+ function componentFile(name, root, deadline = Date.now() + BUDGET_MS3, within) {
38214
38374
  if (!/^[A-Za-z_$][\w$]*$/.test(name)) return null;
38215
38375
  const declaration = new RegExp(
38216
38376
  `^\\s*(export\\s+(?:default\\s+)?)?(?:(?:async\\s+)?function\\s*\\*?\\s+${name}\\b|class\\s+${name}\\b|(?:const|let|var)\\s+${name}\\s*[:=])`
38217
38377
  );
38218
38378
  let best = null;
38219
- const files = within ? [join3(root, within)] : sourceFiles(root);
38379
+ const files = within ? [join4(root, within)] : sourceFiles(root);
38220
38380
  for (const file2 of files) {
38221
38381
  if (Date.now() > deadline) break;
38222
38382
  if (!/\.[jt]sx?$|\.mjs$/.test(file2)) continue;
38223
38383
  let content;
38224
38384
  try {
38225
- content = readFileSync2(file2, "utf8");
38385
+ content = readFileSync3(file2, "utf8");
38226
38386
  } catch {
38227
38387
  continue;
38228
38388
  }
@@ -38231,16 +38391,16 @@ function componentFile(name, root, deadline = Date.now() + BUDGET_MS2, within) {
38231
38391
  for (let i = 0; i < lines.length; i++) {
38232
38392
  const m = declaration.exec(lines[i]);
38233
38393
  if (!m) continue;
38234
- const score = (basename3(file2).replace(/\.[^.]+$/, "") === name ? 2 : 0) + (m[1] ? 1 : 0);
38394
+ const score = (basename4(file2).replace(/\.[^.]+$/, "") === name ? 2 : 0) + (m[1] ? 1 : 0);
38235
38395
  if (!best || score > best.score) best = { file: file2, line: i + 1, score };
38236
38396
  break;
38237
38397
  }
38238
38398
  }
38239
- return best ? { file: relative2(root, best.file), line: best.line } : null;
38399
+ return best ? { file: relative3(root, best.file), line: best.line } : null;
38240
38400
  }
38241
38401
  function withComponentFiles(job, root) {
38242
38402
  if (!searchable(root)) return job;
38243
- const deadline = Date.now() + BUDGET_MS2;
38403
+ const deadline = Date.now() + BUDGET_MS3;
38244
38404
  const fill = (target) => {
38245
38405
  const source = target.source;
38246
38406
  if (!source?.component || source.line) return target;
@@ -38252,9 +38412,14 @@ function withComponentFiles(job, root) {
38252
38412
  const workspace = workspaceRoot(root);
38253
38413
  const declared = (name) => {
38254
38414
  const found = componentFile(name, workspace, deadline);
38255
- return found ? { file: relative2(root, join3(workspace, found.file)), line: found.line } : null;
38415
+ return found ? { file: relative3(root, join4(workspace, found.file)), line: found.line } : null;
38416
+ };
38417
+ const local = (file2) => {
38418
+ const path = join4(workspace, file2);
38419
+ return existsSync3(path) ? relative3(root, path) : file2;
38256
38420
  };
38257
38421
  const mention = (r) => {
38422
+ if (r.kind === "token") return r.source ? { ...r, source: { ...r.source, file: local(r.source.file) } } : r;
38258
38423
  if (r.kind === "element") return { ...r, target: fill(r.target) };
38259
38424
  if (r.kind === "unlisted") {
38260
38425
  const source2 = declared(r.name);
@@ -38262,8 +38427,8 @@ function withComponentFiles(job, root) {
38262
38427
  }
38263
38428
  if (r.kind !== "component") return r;
38264
38429
  if (r.source) {
38265
- const path = join3(workspace, r.source.file);
38266
- return existsSync3(path) ? { ...r, source: { ...r.source, file: relative2(root, path) } } : r;
38430
+ const path = join4(workspace, r.source.file);
38431
+ return existsSync3(path) ? { ...r, source: { ...r.source, file: relative3(root, path) } } : r;
38267
38432
  }
38268
38433
  if (r.target?.source?.file) return { ...r, target: fill(r.target) };
38269
38434
  const source = declared(r.name);
@@ -38277,6 +38442,7 @@ function withComponentFiles(job, root) {
38277
38442
  changeSet: {
38278
38443
  ...changeSet,
38279
38444
  edits: changeSet.edits.map((e) => ({ ...e, target: fill(e.target) })),
38445
+ ...changeSet.fileTokens ? { fileTokens: changeSet.fileTokens.map((t) => ({ ...t, file: local(t.file) })) } : {},
38280
38446
  ...request ? {
38281
38447
  request: {
38282
38448
  ...request,
@@ -38291,12 +38457,12 @@ function withComponentFiles(job, root) {
38291
38457
  function whereSection(job, root) {
38292
38458
  if (!searchable(root)) return "";
38293
38459
  const targets = job.changeSet.request ? requestTargets(job.changeSet.request) : job.changeSet.edits.map((e) => e.target);
38294
- const deadline = Date.now() + BUDGET_MS2;
38460
+ const deadline = Date.now() + BUDGET_MS3;
38295
38461
  const found = [];
38296
38462
  for (const target of targets) {
38297
38463
  const at = locate(target, root, deadline);
38298
38464
  if (!at) continue;
38299
- const lang = extname2(at.file).slice(1) || "text";
38465
+ const lang = extname3(at.file).slice(1) || "text";
38300
38466
  found.push(
38301
38467
  `- \`${target.path}\` \u2192 \`${at.file}:${at.line}\`:`,
38302
38468
  "",
@@ -38334,16 +38500,16 @@ function clientOf(name) {
38334
38500
 
38335
38501
  // src/init.ts
38336
38502
  import { spawnSync } from "child_process";
38337
- import { existsSync as existsSync5, readdirSync as readdirSync3, readFileSync as readFileSync3 } from "fs";
38503
+ import { existsSync as existsSync5, readdirSync as readdirSync4, readFileSync as readFileSync4 } from "fs";
38338
38504
  import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
38339
38505
  import { homedir as homedir2 } from "os";
38340
- import { dirname as dirname3, join as join5, relative as relative4 } from "path";
38506
+ import { dirname as dirname4, join as join6, relative as relative5 } from "path";
38341
38507
 
38342
38508
  // src/setup.ts
38343
38509
  import { existsSync as existsSync4 } from "fs";
38344
38510
  import { lstat, mkdir as mkdir2, readFile as readFile2, unlink, writeFile as writeFile2 } from "fs/promises";
38345
38511
  import { homedir } from "os";
38346
- import { join as join4, relative as relative3 } from "path";
38512
+ import { join as join5, relative as relative4 } from "path";
38347
38513
 
38348
38514
  // ../../skills/pilot/SKILL.md
38349
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";
@@ -38354,7 +38520,7 @@ async function setup(options = {}) {
38354
38520
  return options.project ? setupProject(options.cwd ?? process.cwd()) : setupMachine(options.home ?? homedir());
38355
38521
  }
38356
38522
  async function setupMachine(home) {
38357
- const file2 = await writeSkill(join4(home, ".claude", "skills", "pilot"));
38523
+ const file2 = await writeSkill(join5(home, ".claude", "skills", "pilot"));
38358
38524
  return `Installed the /pilot skill: ${file2}
38359
38525
 
38360
38526
  Now register Pilot's MCP server with Claude Code, once, for every project:
@@ -38366,11 +38532,11 @@ Then, in any Claude Code chat: /pilot
38366
38532
  `;
38367
38533
  }
38368
38534
  async function setupProject(cwd) {
38369
- const skillFile = await writeSkill(join4(cwd, ".claude", "skills", "pilot"));
38370
- const mcpFile = join4(cwd, ".mcp.json");
38535
+ const skillFile = await writeSkill(join5(cwd, ".claude", "skills", "pilot"));
38536
+ const mcpFile = join5(cwd, ".mcp.json");
38371
38537
  const { added } = await addMcpServer(mcpFile);
38372
- const rel = (f) => relative3(cwd, f);
38373
- const app = existsSync4(join4(cwd, "package.json")) ? "" : "\nNo package.json here: run this in the project's root folder, where the app is.\n";
38538
+ const rel = (f) => relative4(cwd, f);
38539
+ const app = existsSync4(join5(cwd, "package.json")) ? "" : "\nNo package.json here: run this in the project's root folder, where the app is.\n";
38374
38540
  const width = rel(skillFile).length + 2;
38375
38541
  return `Set up /pilot for this repo:
38376
38542
  ${rel(skillFile).padEnd(width)}the /pilot skill
@@ -38389,7 +38555,7 @@ Then, in a Claude Code chat in this folder: /pilot
38389
38555
  async function writeSkill(dir) {
38390
38556
  if (await isLink(dir)) await unlink(dir);
38391
38557
  await mkdir2(dir, { recursive: true });
38392
- const file2 = join4(dir, "SKILL.md");
38558
+ const file2 = join5(dir, "SKILL.md");
38393
38559
  await writeFile2(file2, SKILL_default);
38394
38560
  return file2;
38395
38561
  }
@@ -38419,7 +38585,7 @@ async function addMcpServer(file2) {
38419
38585
  }
38420
38586
 
38421
38587
  // src/version.ts
38422
- var VERSION = "0.9.0";
38588
+ var VERSION = "0.11.0";
38423
38589
  function olderThan(a, b) {
38424
38590
  const parts = (v) => v.replace(/^[^\d]*/, "").split(/[.-]/).slice(0, 3).map((n) => Number.parseInt(n, 10) || 0);
38425
38591
  const [x, y] = [parts(a), parts(b)];
@@ -38435,15 +38601,15 @@ var AGENTS = [
38435
38601
  id: "claude-code",
38436
38602
  name: "Claude Code",
38437
38603
  mcp: { file: ".mcp.json", key: "mcpServers", entry: MCP_SERVER },
38438
- skills: join5(".claude", "skills"),
38604
+ skills: join6(".claude", "skills"),
38439
38605
  invoke: "`/pilot`",
38440
38606
  signals: [".mcp.json", ".claude"]
38441
38607
  },
38442
38608
  {
38443
38609
  id: "cursor",
38444
38610
  name: "Cursor",
38445
- mcp: { file: join5(".cursor", "mcp.json"), key: "mcpServers", entry: MCP_SERVER },
38446
- skills: join5(".cursor", "skills"),
38611
+ mcp: { file: join6(".cursor", "mcp.json"), key: "mcpServers", entry: MCP_SERVER },
38612
+ skills: join6(".cursor", "skills"),
38447
38613
  invoke: "`/pilot`",
38448
38614
  signals: [".cursor"],
38449
38615
  // Cursor sees a project's new MCP server but leaves it off: it never starts until the user turns it on.
@@ -38452,16 +38618,16 @@ var AGENTS = [
38452
38618
  {
38453
38619
  id: "vscode",
38454
38620
  name: "VS Code",
38455
- mcp: { file: join5(".vscode", "mcp.json"), key: "servers", entry: { type: "stdio", ...MCP_SERVER } },
38456
- skills: join5(".github", "skills"),
38621
+ mcp: { file: join6(".vscode", "mcp.json"), key: "servers", entry: { type: "stdio", ...MCP_SERVER } },
38622
+ skills: join6(".github", "skills"),
38457
38623
  invoke: "`/pilot`",
38458
- signals: [join5(".vscode", "mcp.json"), join5(".github", "skills"), join5(".github", "copilot-instructions.md")]
38624
+ signals: [join6(".vscode", "mcp.json"), join6(".github", "skills"), join6(".github", "copilot-instructions.md")]
38459
38625
  },
38460
38626
  {
38461
38627
  id: "codex",
38462
38628
  name: "Codex",
38463
38629
  register: `\`codex mcp add pilot -- ${COMMAND}\``,
38464
- skills: join5(".agents", "skills"),
38630
+ skills: join6(".agents", "skills"),
38465
38631
  invoke: "`$pilot`",
38466
38632
  signals: [".codex"]
38467
38633
  },
@@ -38470,7 +38636,7 @@ var AGENTS = [
38470
38636
  name: "your agent",
38471
38637
  register: `in your MCP settings: a server named \`pilot\`, running \`${COMMAND}\``,
38472
38638
  // The open skills folder, read by many agents.
38473
- skills: join5(".agents", "skills"),
38639
+ skills: join6(".agents", "skills"),
38474
38640
  invoke: "the `pilot` skill",
38475
38641
  signals: []
38476
38642
  }
@@ -38481,35 +38647,35 @@ var MACHINE = {
38481
38647
  command: {
38482
38648
  cmd: "claude",
38483
38649
  args: ["mcp", "add", "--scope", "user", "pilot", "--", ...MCP_SERVER_ARGV],
38484
- has: (home) => !!readJson(join5(home, ".claude.json"))?.mcpServers?.pilot
38650
+ has: (home) => !!readJson(join6(home, ".claude.json"))?.mcpServers?.pilot
38485
38651
  },
38486
- skills: (home) => join5(home, ".claude", "skills")
38652
+ skills: (home) => join6(home, ".claude", "skills")
38487
38653
  },
38488
38654
  cursor: {
38489
- mcp: { file: (home) => join5(home, ".cursor", "mcp.json"), key: "mcpServers", entry: MCP_SERVER },
38490
- skills: (home) => join5(home, ".cursor", "skills")
38655
+ mcp: { file: (home) => join6(home, ".cursor", "mcp.json"), key: "mcpServers", entry: MCP_SERVER },
38656
+ skills: (home) => join6(home, ".cursor", "skills")
38491
38657
  },
38492
38658
  vscode: {
38493
38659
  mcp: {
38494
- file: (home, platform) => join5(vscodeUserDir(home, platform), "mcp.json"),
38660
+ file: (home, platform) => join6(vscodeUserDir(home, platform), "mcp.json"),
38495
38661
  key: "servers",
38496
38662
  entry: { type: "stdio", ...MCP_SERVER }
38497
38663
  },
38498
- skills: (home) => join5(home, ".copilot", "skills")
38664
+ skills: (home) => join6(home, ".copilot", "skills")
38499
38665
  },
38500
38666
  codex: {
38501
38667
  command: {
38502
38668
  cmd: "codex",
38503
38669
  args: ["mcp", "add", "pilot", "--", ...MCP_SERVER_ARGV],
38504
- has: (home) => /\[mcp_servers\.pilot\]/.test(readText(join5(home, ".codex", "config.toml")))
38670
+ has: (home) => /\[mcp_servers\.pilot\]/.test(readText(join6(home, ".codex", "config.toml")))
38505
38671
  },
38506
- skills: (home) => join5(home, ".agents", "skills")
38672
+ skills: (home) => join6(home, ".agents", "skills")
38507
38673
  },
38508
- other: { skills: (home) => join5(home, ".agents", "skills") }
38674
+ other: { skills: (home) => join6(home, ".agents", "skills") }
38509
38675
  };
38510
38676
  function skillFolders(root, home) {
38511
- const machine = AGENT_IDS.map((id) => join5(MACHINE[id].skills(home), "pilot"));
38512
- const project = AGENTS.map((a) => join5(root, a.skills, "pilot"));
38677
+ const machine = AGENT_IDS.map((id) => join6(MACHINE[id].skills(home), "pilot"));
38678
+ const project = AGENTS.map((a) => join6(root, a.skills, "pilot"));
38513
38679
  return [.../* @__PURE__ */ new Set([...machine, ...project])];
38514
38680
  }
38515
38681
  function agentsWithPilot(root, home, platform = process.platform) {
@@ -38519,24 +38685,24 @@ function agentsWithPilot(root, home, platform = process.platform) {
38519
38685
  const machine = MACHINE[a.id];
38520
38686
  if (machine.mcp && hasServer(machine.mcp.file(home, platform), machine.mcp.key)) return true;
38521
38687
  if (machine.command?.has(home)) return true;
38522
- if (a.mcp && hasServer(join5(root, a.mcp.file), a.mcp.key)) return true;
38523
- return a.id !== "codex" && existsSync5(join5(machine.skills(home), "pilot"));
38688
+ if (a.mcp && hasServer(join6(root, a.mcp.file), a.mcp.key)) return true;
38689
+ return a.id !== "codex" && existsSync5(join6(machine.skills(home), "pilot"));
38524
38690
  }).map((a) => a.id);
38525
38691
  }
38526
38692
  function installArgs(pm, spec = "usepilot") {
38527
38693
  return pm === "npm" ? ["install", "-D", spec] : pm === "bun" ? ["add", "-d", spec] : ["add", "-D", spec];
38528
38694
  }
38529
38695
  function installedVersion(cwd, root) {
38530
- for (let dir = cwd; ; dir = dirname3(dir)) {
38531
- const version2 = readJson(join5(dir, "node_modules", "usepilot", "package.json"))?.version;
38696
+ for (let dir = cwd; ; dir = dirname4(dir)) {
38697
+ const version2 = readJson(join6(dir, "node_modules", "usepilot", "package.json"))?.version;
38532
38698
  if (version2) return version2;
38533
- if (dir === root || dirname3(dir) === dir) return null;
38699
+ if (dir === root || dirname4(dir) === dir) return null;
38534
38700
  }
38535
38701
  }
38536
38702
  function vscodeUserDir(home, platform) {
38537
- if (platform === "darwin") return join5(home, "Library", "Application Support", "Code", "User");
38538
- if (platform === "win32") return join5(process.env.APPDATA ?? join5(home, "AppData", "Roaming"), "Code", "User");
38539
- return join5(home, ".config", "Code", "User");
38703
+ if (platform === "darwin") return join6(home, "Library", "Application Support", "Code", "User");
38704
+ if (platform === "win32") return join6(process.env.APPDATA ?? join6(home, "AppData", "Roaming"), "Code", "User");
38705
+ return join6(home, ".config", "Code", "User");
38540
38706
  }
38541
38707
  function tilde(path, home) {
38542
38708
  return path.startsWith(home) ? `~${path.slice(home.length)}` : path;
@@ -38550,7 +38716,7 @@ function detectAgent(env) {
38550
38716
  async function init(options = {}) {
38551
38717
  const cwd = options.cwd ?? process.cwd();
38552
38718
  const run = options.run ?? runCommand;
38553
- const pkgFile = join5(cwd, "package.json");
38719
+ const pkgFile = join6(cwd, "package.json");
38554
38720
  if (!existsSync5(pkgFile)) {
38555
38721
  return `# Pilot: not set up
38556
38722
 
@@ -38607,16 +38773,16 @@ ${apps.map((a) => `- ${a}`).join("\n")}` : "."}
38607
38773
  } else if (agent.register) {
38608
38774
  todo.push(`**Register Pilot's MCP server with yourself**, for every project: ${agent.register}.`);
38609
38775
  }
38610
- const skill = join5(machine.skills(home), "pilot");
38776
+ const skill = join6(machine.skills(home), "pilot");
38611
38777
  await writeSkill(skill);
38612
38778
  parts.push(`the \`pilot\` skill (\`${tilde(skill, home)}/\`)`);
38613
38779
  done.push(`Connected ${agent.name} to Pilot, once for every project on this machine: ${list(parts)}. Nothing was added to the repo.`);
38614
38780
  } else if (named) {
38615
- const present = AGENTS.filter((a) => a.id !== named && a.signals.some((p) => existsSync5(join5(root, p))));
38781
+ const present = AGENTS.filter((a) => a.id !== named && a.signals.some((p) => existsSync5(join6(root, p))));
38616
38782
  for (const agent of [...AGENTS.filter((a) => a.id === named), ...present]) {
38617
38783
  const parts = [];
38618
38784
  if (agent.mcp) {
38619
- const file2 = join5(root, agent.mcp.file);
38785
+ const file2 = join6(root, agent.mcp.file);
38620
38786
  if (await addServer(file2, agent.mcp.key, agent.mcp.entry) === "invalid") {
38621
38787
  todo.push(
38622
38788
  `\`${agent.mcp.file}\` isn't valid JSON, so Pilot wasn't added to it: fix it, and add the \`pilot\` server (\`${COMMAND}\`).`
@@ -38626,8 +38792,8 @@ ${apps.map((a) => `- ${a}`).join("\n")}` : "."}
38626
38792
  written.push(`\`${agent.mcp.file}\``);
38627
38793
  }
38628
38794
  }
38629
- const skill = join5(agent.skills, "pilot");
38630
- await writeSkill(join5(root, skill));
38795
+ const skill = join6(agent.skills, "pilot");
38796
+ await writeSkill(join6(root, skill));
38631
38797
  parts.push(`the \`pilot\` skill (\`${skill}/\`)`);
38632
38798
  if (!written.includes(`\`${skill}/\``)) written.push(`\`${skill}/\``);
38633
38799
  done.push(`Set Pilot up for ${agent.name} in this project: ${list(parts)}.`);
@@ -38638,7 +38804,7 @@ ${apps.map((a) => `- ${a}`).join("\n")}` : "."}
38638
38804
  `**Connect yourself:** run \`npx usepilot@latest init --agent <you>\` in ${cwd}, with \`<you>\` the agent you are: ${AGENT_IDS.map((a) => `\`${a}\``).join(", ")}.`
38639
38805
  );
38640
38806
  }
38641
- if (framework.loads) done.push(`The app already loads Pilot (\`${relative4(cwd, framework.loads)}\`).`);
38807
+ if (framework.loads) done.push(`The app already loads Pilot (\`${relative5(cwd, framework.loads)}\`).`);
38642
38808
  else todo.push(loadStep(framework, cwd));
38643
38809
  const me = AGENTS.find((a) => a.id === named);
38644
38810
  const enable = project && me?.enable ? `Before that, ${me.enable}. ` : "";
@@ -38655,23 +38821,23 @@ ${todo.map((t, i) => `${i + 1}. ${t}`).join("\n")}
38655
38821
  `;
38656
38822
  }
38657
38823
  function projectRoot(cwd) {
38658
- for (let dir = cwd; ; dir = dirname3(dir)) {
38659
- if (existsSync5(join5(dir, ".git"))) return dir;
38660
- if (dirname3(dir) === dir) return cwd;
38824
+ for (let dir = cwd; ; dir = dirname4(dir)) {
38825
+ if (existsSync5(join6(dir, ".git"))) return dir;
38826
+ if (dirname4(dir) === dir) return cwd;
38661
38827
  }
38662
38828
  }
38663
38829
  function packageManager(cwd, root) {
38664
- for (let dir = cwd; ; dir = dirname3(dir)) {
38665
- if (existsSync5(join5(dir, "pnpm-lock.yaml"))) return "pnpm";
38666
- if (existsSync5(join5(dir, "yarn.lock"))) return "yarn";
38667
- if (existsSync5(join5(dir, "bun.lock")) || existsSync5(join5(dir, "bun.lockb"))) return "bun";
38668
- if (existsSync5(join5(dir, "package-lock.json"))) return "npm";
38669
- if (dir === root || dirname3(dir) === dir) return "npm";
38830
+ for (let dir = cwd; ; dir = dirname4(dir)) {
38831
+ if (existsSync5(join6(dir, "pnpm-lock.yaml"))) return "pnpm";
38832
+ if (existsSync5(join6(dir, "yarn.lock"))) return "yarn";
38833
+ if (existsSync5(join6(dir, "bun.lock")) || existsSync5(join6(dir, "bun.lockb"))) return "bun";
38834
+ if (existsSync5(join6(dir, "package-lock.json"))) return "npm";
38835
+ if (dir === root || dirname4(dir) === dir) return "npm";
38670
38836
  }
38671
38837
  }
38672
38838
  function detectFramework(cwd, deps) {
38673
38839
  const has = (name) => name in deps;
38674
- const first = (...files) => files.map((f) => join5(cwd, f)).find((f) => existsSync5(f));
38840
+ const first = (...files) => files.map((f) => join6(cwd, f)).find((f) => existsSync5(f));
38675
38841
  const loads = findLoader(cwd);
38676
38842
  const result = (kind, file2) => ({ kind, file: file2, loads });
38677
38843
  if (has("next")) {
@@ -38693,8 +38859,8 @@ function detectFramework(cwd, deps) {
38693
38859
  if (has("vite") || Object.keys(deps).some((d) => d.startsWith("@vitejs/"))) {
38694
38860
  const entry = viteEntry(cwd);
38695
38861
  if (entry) return result("vite", entry);
38696
- if (existsSync5(join5(cwd, "index.html"))) {
38697
- const config2 = ["vite.config.ts", "vite.config.mts", "vite.config.js", "vite.config.mjs"].map((f) => join5(cwd, f)).find((f) => existsSync5(f));
38862
+ if (existsSync5(join6(cwd, "index.html"))) {
38863
+ const config2 = ["vite.config.ts", "vite.config.mts", "vite.config.js", "vite.config.mjs"].map((f) => join6(cwd, f)).find((f) => existsSync5(f));
38698
38864
  return result("vite-html", config2);
38699
38865
  }
38700
38866
  return result("vite");
@@ -38708,16 +38874,16 @@ function detectFramework(cwd, deps) {
38708
38874
  return { kind: "unknown", loads };
38709
38875
  }
38710
38876
  function viteEntry(cwd) {
38711
- const html = join5(cwd, "index.html");
38877
+ const html = join6(cwd, "index.html");
38712
38878
  if (existsSync5(html)) {
38713
- for (const tag of readFileSync3(html, "utf8").match(/<script\b[^>]*>/gi) ?? []) {
38879
+ for (const tag of readFileSync4(html, "utf8").match(/<script\b[^>]*>/gi) ?? []) {
38714
38880
  if (!/type=["']module["']/i.test(tag)) continue;
38715
38881
  const src = /src=["']\/?([^"'?#]+)/i.exec(tag)?.[1];
38716
- if (src && existsSync5(join5(cwd, src))) return join5(cwd, src);
38882
+ if (src && existsSync5(join6(cwd, src))) return join6(cwd, src);
38717
38883
  }
38718
38884
  return void 0;
38719
38885
  }
38720
- return ["src/main.tsx", "src/main.ts", "src/main.jsx", "src/main.js", "src/index.tsx", "src/index.ts"].map((f) => join5(cwd, f)).find((f) => existsSync5(f));
38886
+ return ["src/main.tsx", "src/main.ts", "src/main.jsx", "src/main.js", "src/index.tsx", "src/index.ts"].map((f) => join6(cwd, f)).find((f) => existsSync5(f));
38721
38887
  }
38722
38888
  var SOURCE_DIRS = ["src", "app", "pages", "plugins", "components", "lib"];
38723
38889
  var SOURCE_FILE = /\.(m?[jt]sx?|vue|svelte|astro|html)$/;
@@ -38726,13 +38892,13 @@ function findLoader(cwd) {
38726
38892
  const walk = (dir, depth) => {
38727
38893
  let names;
38728
38894
  try {
38729
- names = readdirSync3(dir);
38895
+ names = readdirSync4(dir);
38730
38896
  } catch {
38731
38897
  return void 0;
38732
38898
  }
38733
38899
  for (const name of names) {
38734
38900
  if (budget-- <= 0 || name === "node_modules" || name.startsWith(".")) continue;
38735
- const path = join5(dir, name);
38901
+ const path = join6(dir, name);
38736
38902
  if (SOURCE_FILE.test(name)) {
38737
38903
  if (/["']usepilot(\/auto)?["']/.test(readText(path))) return path;
38738
38904
  } else if (depth > 0 && !name.includes(".")) {
@@ -38743,40 +38909,40 @@ function findLoader(cwd) {
38743
38909
  return void 0;
38744
38910
  };
38745
38911
  for (const name of ["index.html", "vite.config.ts", "vite.config.mts", "vite.config.js", "vite.config.mjs"]) {
38746
- const file2 = join5(cwd, name);
38912
+ const file2 = join6(cwd, name);
38747
38913
  if (existsSync5(file2) && /usepilot/.test(readText(file2))) return file2;
38748
38914
  }
38749
38915
  for (const dir of SOURCE_DIRS) {
38750
- const found = walk(join5(cwd, dir), 6);
38916
+ const found = walk(join6(cwd, dir), 6);
38751
38917
  if (found) return found;
38752
38918
  }
38753
38919
  return void 0;
38754
38920
  }
38755
38921
  function readText(file2) {
38756
38922
  try {
38757
- return readFileSync3(file2, "utf8");
38923
+ return readFileSync4(file2, "utf8");
38758
38924
  } catch {
38759
38925
  return "";
38760
38926
  }
38761
38927
  }
38762
38928
  function isWorkspaceRoot(cwd, pkg) {
38763
- return !!pkg.workspaces || existsSync5(join5(cwd, "pnpm-workspace.yaml"));
38929
+ return !!pkg.workspaces || existsSync5(join6(cwd, "pnpm-workspace.yaml"));
38764
38930
  }
38765
38931
  function workspaceApps(cwd) {
38766
38932
  const found = [];
38767
38933
  for (const group of ["apps", "packages", "examples", "sites"]) {
38768
- const dir = join5(cwd, group);
38934
+ const dir = join6(cwd, group);
38769
38935
  if (!existsSync5(dir)) continue;
38770
- for (const name of readdirSync3(dir)) {
38771
- const pkg = readJson(join5(dir, name, "package.json"));
38772
- if (pkg && detectFramework(join5(dir, name), { ...pkg.dependencies, ...pkg.devDependencies }).kind !== "unknown")
38773
- found.push(join5(group, name));
38936
+ for (const name of readdirSync4(dir)) {
38937
+ const pkg = readJson(join6(dir, name, "package.json"));
38938
+ if (pkg && detectFramework(join6(dir, name), { ...pkg.dependencies, ...pkg.devDependencies }).kind !== "unknown")
38939
+ found.push(join6(group, name));
38774
38940
  }
38775
38941
  }
38776
38942
  return found;
38777
38943
  }
38778
38944
  function loadStep(framework, cwd) {
38779
- const at = (file2, otherwise) => file2 ? `\`${relative4(cwd, file2)}\`` : otherwise;
38945
+ const at = (file2, otherwise) => file2 ? `\`${relative5(cwd, file2)}\`` : otherwise;
38780
38946
  const code = (lang, text) => `
38781
38947
 
38782
38948
  \`\`\`${lang}
@@ -38858,14 +39024,14 @@ async function addServer(file2, key, entry) {
38858
39024
  const servers = config2[key] ?? {};
38859
39025
  const result = "pilot" in servers ? "updated" : "added";
38860
39026
  config2[key] = { ...servers, pilot: entry };
38861
- await mkdir3(dirname3(file2), { recursive: true });
39027
+ await mkdir3(dirname4(file2), { recursive: true });
38862
39028
  await writeFile3(file2, `${JSON.stringify(config2, null, 2)}
38863
39029
  `);
38864
39030
  return result;
38865
39031
  }
38866
39032
  function readJson(file2) {
38867
39033
  try {
38868
- return JSON.parse(readFileSync3(file2, "utf8"));
39034
+ return JSON.parse(readFileSync4(file2, "utf8"));
38869
39035
  } catch {
38870
39036
  return null;
38871
39037
  }
@@ -38907,7 +39073,7 @@ function agentLabel(clientName, cwd) {
38907
39073
  codex: "Codex"
38908
39074
  };
38909
39075
  const app = clientName && (names[clientName.toLowerCase()] ?? clientName) || "Agent";
38910
- return `${app} \xB7 ${basename4(cwd)}`;
39076
+ return `${app} \xB7 ${basename5(cwd)}`;
38911
39077
  }
38912
39078
  function jobPrompt(job, where = "") {
38913
39079
  const body2 = job.attempt === 2 && job.issues?.length ? taskFollowUp(job) : job.attempt === 2 && job.differences?.length ? followUp(job) : job.answer && job.question ? answered(job) : formatPrompt(job.changeSet, { guidelines: false });
@@ -39031,7 +39197,7 @@ function projectFolder(candidate) {
39031
39197
  }
39032
39198
  }
39033
39199
  if (!isAbsolute2(path)) return null;
39034
- path = resolve(path);
39200
+ path = resolve2(path);
39035
39201
  return existsSync6(path) && searchable(path) ? path : null;
39036
39202
  }
39037
39203
  function createPilotServer(options = {}) {
@@ -39213,14 +39379,14 @@ ${p.text}` }, ...p.blocks])
39213
39379
 
39214
39380
  // src/update.ts
39215
39381
  import { spawnSync as spawnSync2 } from "child_process";
39216
- import { existsSync as existsSync7, lstatSync, readFileSync as readFileSync4 } from "fs";
39382
+ import { existsSync as existsSync7, lstatSync, readFileSync as readFileSync5 } from "fs";
39217
39383
  import { homedir as homedir3 } from "os";
39218
- import { dirname as dirname4, join as join6 } from "path";
39384
+ import { dirname as dirname5, join as join7 } from "path";
39219
39385
  async function update(options = {}) {
39220
39386
  const cwd = options.cwd ?? process.cwd();
39221
39387
  const run = options.run ?? runCommand2;
39222
39388
  const home = options.home ?? homedir3();
39223
- const pkg = readJson2(join6(cwd, "package.json"));
39389
+ const pkg = readJson2(join7(cwd, "package.json"));
39224
39390
  const deps = { ...pkg?.dependencies, ...pkg?.devDependencies };
39225
39391
  if (!pkg || !deps.usepilot) {
39226
39392
  return `# Pilot isn't installed here
@@ -39274,13 +39440,13 @@ ${steps.map((s, i) => `${i + 1}. ${s}`).join("\n")}
39274
39440
  ` : "Nothing else to do.\n"}`;
39275
39441
  }
39276
39442
  function bridgeOf(cwd, root) {
39277
- for (let dir = cwd; ; dir = dirname4(dir)) {
39278
- const file2 = join6(dir, "node_modules", "usepilot", "cli", "index.js");
39443
+ for (let dir = cwd; ; dir = dirname5(dir)) {
39444
+ const file2 = join7(dir, "node_modules", "usepilot", "cli", "index.js");
39279
39445
  if (existsSync7(file2)) {
39280
- const match = /BRIDGE_VERSION = (\d+)/.exec(readFileSync4(file2, "utf8"));
39446
+ const match = /BRIDGE_VERSION = (\d+)/.exec(readFileSync5(file2, "utf8"));
39281
39447
  return match ? Number(match[1]) : null;
39282
39448
  }
39283
- if (dir === root || dirname4(dir) === dir) return null;
39449
+ if (dir === root || dirname5(dir) === dir) return null;
39284
39450
  }
39285
39451
  }
39286
39452
  function isLink2(path) {
@@ -39292,7 +39458,7 @@ function isLink2(path) {
39292
39458
  }
39293
39459
  function readJson2(file2) {
39294
39460
  try {
39295
- return JSON.parse(readFileSync4(file2, "utf8"));
39461
+ return JSON.parse(readFileSync5(file2, "utf8"));
39296
39462
  } catch {
39297
39463
  return null;
39298
39464
  }