skydive-cli 0.4.0 → 0.4.1-beta.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/dist/js/bin.mjs CHANGED
@@ -1,24 +1,26 @@
1
1
  #!/usr/bin/env node
2
- import { C as setActiveWorkspace, S as listWorkspaces, T as version, _ as themes, b as getActiveWorkspaceId, o as brandHelpArt, t as installCrashHandler, w as name, x as getSessionIdentity, y as ensureActiveOrganization } from "./install-Ba-UTi-l.mjs";
3
- import { A as getStoredApiKeyWorkspaceName, C as getLastSeenVersion, F as resolveManagementAuth, I as resolveSession, M as resolveAppUrl, N as resolveChatAuth, O as getShareMachineDefault, P as resolveConfig, R as saveConfig, S as getConfigPath, T as getPromptHistoryPath, V as setLastSeenVersion, _ as API_KEY_PREFIX, b as PREFERENCES, g as API_KEY_FAMILY_PREFIX, h as API_KEYS_URL, i as resolveAgent, j as getUpdateCheckDisabled, k as getStoredApiKeyId, v as DEFAULT_API_URL, w as getPreference, x as deleteConfig, z as saveSession } from "./print-X2N5wJ5l.mjs";
2
+ import { C as ensureActiveOrganization, D as setActiveWorkspace, E as listWorkspaces, O as name, T as getSessionIdentity, a as installCrashHandler, k as version, t as maybeStartProfiling, u as brandHelpArt, w as getActiveWorkspaceId, x as themes } from "./profiler-BA-c3-gP.mjs";
3
+ import { A as getStoredApiKeyWorkspaceName, C as getLastSeenVersion, F as resolveManagementAuth, I as resolveSession, M as resolveAppUrl, N as resolveChatAuth, O as getShareMachineDefault, P as resolveConfig, R as saveConfig, S as getConfigPath, T as getPromptHistoryPath, V as setLastSeenVersion, _ as API_KEY_PREFIX, b as PREFERENCES, g as API_KEY_FAMILY_PREFIX, h as API_KEYS_URL, i as resolveAgent, j as getUpdateCheckDisabled, k as getStoredApiKeyId, v as DEFAULT_API_URL, w as getPreference, x as deleteConfig, z as saveSession } from "./print-CbayCa87.mjs";
4
4
  import { n as printError, r as printTable, t as output } from "./output-DYzzdXYV.mjs";
5
- import { n as createRestClient, t as HttpError } from "./rest-imDZZGQA.mjs";
6
- import "./billing-blocked-CwfG1BTR.mjs";
7
- import { a as registerPortalDevice, i as grantPortalAccess, n as fetchPortalDevices, o as revokePortalAccess, r as findThisDevice, s as machineIdentity } from "./client-CKzK-12y.mjs";
8
- import { c as PORTAL_DAEMON_FLAG, i as queryDaemonStatus, l as daemonPaths, n as ensureDaemonRunning, o as stopDaemon } from "./daemon-CaFz7Wtw.mjs";
9
- import { t as SandboxStream } from "./client-D8s9vY4p.mjs";
5
+ import { t as HttpError } from "./http-error-DzyrsLAZ.mjs";
6
+ import { t as createRestClient } from "./rest-BY2nADw5.mjs";
7
+ import "./billing-blocked-2wju4gC_.mjs";
8
+ import { a as registerPortalDevice, c as machineIdentity, i as grantPortalAccess, n as fetchPortalDevices, o as revokePortalAccess, r as findThisDevice } from "./client-Cf7cvftg.mjs";
9
+ import { c as PORTAL_DAEMON_FLAG, i as queryDaemonStatus, l as daemonPaths, n as ensureDaemonRunning, o as stopDaemon } from "./daemon-DaUaCMwC.mjs";
10
+ import { t as SandboxStream } from "./client-Cn2af31H.mjs";
10
11
  import { hideBin } from "yargs/helpers";
11
12
  import yargs from "yargs";
12
- import os, { hostname } from "node:os";
13
- import path from "node:path";
13
+ import os, { hostname, tmpdir } from "node:os";
14
+ import path, { join } from "node:path";
14
15
  import { err, ok } from "neverthrow";
15
16
  import { z } from "zod";
16
17
  import open from "open";
17
18
  import fs from "node:fs";
18
19
  import { spawn, spawnSync } from "node:child_process";
19
- import { createHash } from "node:crypto";
20
+ import { createHash, randomBytes } from "node:crypto";
20
21
  import zlib from "node:zlib";
21
- import fsp from "node:fs/promises";
22
+ import fsp, { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
23
+ import { quote } from "shell-quote";
22
24
  import semver from "semver";
23
25
  import { createInterface } from "node:readline";
24
26
 
@@ -177,7 +179,7 @@ var SkydiveApiClient = class {
177
179
  if (body.error && typeof body.error === "string") message = body.error;
178
180
  else if (body.error?.message) message = body.error.message;
179
181
  } catch {}
180
- if (response.status === 401 && this.authKind === "session") message = `${message} your chat session may have expired. Run \`skydive auth login\`.`;
182
+ if (response.status === 401 && this.authKind === "session") message = `${message}. Your chat session may have expired. Run \`skydive auth login\`.`;
181
183
  return err({
182
184
  message,
183
185
  status: response.status
@@ -531,7 +533,7 @@ async function runBrowserLogin(argv) {
531
533
  appUrl,
532
534
  sessionToken
533
535
  })).unwrapOr(null);
534
- const keyName = identity?.activeWorkspaceName ? `CLI (${hostname()}) ${identity.activeWorkspaceName}` : `CLI (${hostname()})`;
536
+ const keyName = identity?.activeWorkspaceName ? `CLI (${hostname()}) for ${identity.activeWorkspaceName}` : `CLI (${hostname()})`;
535
537
  const replaced = await revokeKeysByName({
536
538
  appUrl,
537
539
  sessionToken,
@@ -1230,6 +1232,15 @@ const PINNED_BUN_VERSION = "1.3.14";
1230
1232
  const BUN_RELEASE_BASE = process.env["SKYDIVE_BUN_RELEASE_BASE"] ?? "https://github.com/oven-sh/bun/releases/download";
1231
1233
  /** Guard env var: set on the child so a re-exec can never recurse. */
1232
1234
  const REEXEC_GUARD = "SKYDIVE_BUN_REEXEC";
1235
+ /**
1236
+ * Whether this process is the Bun child that `chat` re-exec'd itself into.
1237
+ * The parent Node process is still alive, blocked on spawnSync, and already
1238
+ * ran the per-invocation startup notices (update check, what's-new) — so the
1239
+ * child must not repeat them or the user sees each notice twice.
1240
+ */
1241
+ function isBunReexecChild(env = process.env) {
1242
+ return env[REEXEC_GUARD] === "1";
1243
+ }
1233
1244
  function isBun() {
1234
1245
  return typeof process !== "undefined" && "bun" in process.versions;
1235
1246
  }
@@ -1459,9 +1470,9 @@ function ensureBunAndReexec(onProgress) {
1459
1470
  */
1460
1471
  function buildImportSeedPrompt(projectDir) {
1461
1472
  return [
1462
- "I'm migrating from another coding agent import my setup from this machine.",
1473
+ "I'm migrating from another coding agent. Import my setup from this machine.",
1463
1474
  "",
1464
- `Use your import-config skill. I ran this from \`${projectDir}\`, so start there (and my home directory) when you inventory what I have. Show me the plan first what you'll bring over, where it lands in you, and anything you're leaving out (credentials especially) and wait for my OK before committing anything.`
1475
+ `Use your import-config skill. I ran this from \`${projectDir}\`, so start there (and my home directory) when you inventory what I have. Show me the plan first: what you'll bring over, where it lands in you, and anything you're leaving out (credentials especially). Then wait for my OK before committing anything.`
1465
1476
  ].join("\n");
1466
1477
  }
1467
1478
  const importCommand = {
@@ -1473,7 +1484,7 @@ const importCommand = {
1473
1484
  }).option("print", {
1474
1485
  alias: "p",
1475
1486
  type: "string",
1476
- describe: "Non-interactive: send the import request as a one-shot, print the agent's plan, and exit (drivable from scripts or another coding agent). An optional value adds extra instructions to the request. The agent still waits for approval continue the printed conversation with `skydive chat -p \"go ahead\" --resume <id> --share-machine`. Runs under Node."
1487
+ describe: "Non-interactive: send the import request as a one-shot, print the agent's plan, and exit (drivable from scripts or another coding agent). An optional value adds extra instructions to the request. The agent still waits for approval; continue the printed conversation with `skydive chat -p \"go ahead\" --resume <id> --share-machine`. Runs under Node."
1477
1488
  }).example("skydive import", "Import from the current directory").example("skydive import --agent kit", "Import into a specific agent, skipping the picker").example("skydive import -p --agent kit", "One-shot: print the agent's import plan and exit"),
1478
1489
  handler: async (argv) => {
1479
1490
  const appUrl = resolveAppUrl({ appUrl: argv["api-url"] });
@@ -1505,7 +1516,7 @@ const importCommand = {
1505
1516
  process.exit(1);
1506
1517
  }
1507
1518
  }
1508
- const { runChat } = await import("./boot-on5ucI_Z.mjs");
1519
+ const { runChat } = await import("./boot-DZYbTxev.mjs");
1509
1520
  await runChat({
1510
1521
  appUrl,
1511
1522
  sessionToken: session.value.sessionToken,
@@ -1532,7 +1543,7 @@ async function runImportPrintMode({ argv, appUrl }) {
1532
1543
  printError(`${session.error.message} For non-interactive use, run \`skydive auth login --web\` first, or set SKYDIVE_SESSION_TOKEN.`);
1533
1544
  process.exit(1);
1534
1545
  }
1535
- const { connectMachineShare } = await import("./print-share-D72CfWJk.mjs");
1546
+ const { connectMachineShare } = await import("./print-share-CT4ltX7u.mjs");
1536
1547
  const machineShare = await connectMachineShare({
1537
1548
  appUrl,
1538
1549
  sessionToken: session.value.sessionToken,
@@ -1540,7 +1551,7 @@ async function runImportPrintMode({ argv, appUrl }) {
1540
1551
  });
1541
1552
  const extra = (argv.print ?? "").trim();
1542
1553
  const prompt = buildImportSeedPrompt(process.cwd()) + (extra ? `\n\nAdditional instructions: ${extra}` : "");
1543
- const { runPrint } = await import("./print-BXNq9UxE.mjs");
1554
+ const { runPrint } = await import("./print-ba_0hiV9.mjs");
1544
1555
  try {
1545
1556
  const result = await runPrint({
1546
1557
  appUrl,
@@ -1622,7 +1633,7 @@ const createCommand = {
1622
1633
  console.log(` Name: ${key.name}`);
1623
1634
  console.log(` Key: ${key.key}`);
1624
1635
  console.log("");
1625
- console.log(" Save this key it will not be shown again.");
1636
+ console.log(" Save this key. It will not be shown again.");
1626
1637
  }
1627
1638
  };
1628
1639
  const revokeCommand$1 = {
@@ -1695,7 +1706,7 @@ const setCommand$1 = {
1695
1706
  describe: "Secret name (uppercase letters, digits, underscores)"
1696
1707
  }).positional("value", {
1697
1708
  type: "string",
1698
- describe: "Secret value. If omitted, read from stdin keeps the value out of shell history."
1709
+ describe: "Secret value. If omitted, read from stdin, which keeps the value out of shell history."
1699
1710
  }),
1700
1711
  handler: async (argv) => {
1701
1712
  let value = argv.value;
@@ -1854,7 +1865,7 @@ const chatCommand = {
1854
1865
  builder: (y) => y.option("print", {
1855
1866
  alias: "p",
1856
1867
  type: "string",
1857
- describe: "Non-interactive: send one prompt, print the reply, and exit (like `claude -p`). Reads the prompt from stdin if given no value. Runs under Node no Bun required."
1868
+ describe: "Non-interactive: send one prompt, print the reply, and exit (like `claude -p`). Reads the prompt from stdin if given no value. Runs under Node; no Bun required."
1858
1869
  }).option("agent", {
1859
1870
  type: "string",
1860
1871
  describe: "Target agent, by id, slug, or name. With -p, the agent to send the one-shot prompt to. Without -p, pre-selects the agent and opens its conversation list, skipping the agent picker. Optional when the account has exactly one agent."
@@ -1917,7 +1928,7 @@ const chatCommand = {
1917
1928
  sessionToken: auth.value.token,
1918
1929
  agentSelector: argv.agent ?? null
1919
1930
  });
1920
- const { runChat } = await import("./boot-on5ucI_Z.mjs");
1931
+ const { runChat } = await import("./boot-DZYbTxev.mjs");
1921
1932
  await runChat({
1922
1933
  appUrl: auth.value.appUrl,
1923
1934
  sessionToken: auth.value.token,
@@ -1964,7 +1975,7 @@ async function ensureAgentWorkspace({ appUrl, sessionToken, agentSelector }) {
1964
1975
  });
1965
1976
  if (resolution.kind === "active") return;
1966
1977
  if (resolution.kind === "switched") {
1967
- console.error(`Switched workspace to ${resolution.workspace.name} (${resolution.workspace.slug}) ${resolution.agentName} lives there.`);
1978
+ console.error(`Switched workspace to ${resolution.workspace.name} (${resolution.workspace.slug}). ${resolution.agentName} lives there.`);
1968
1979
  return;
1969
1980
  }
1970
1981
  if (resolution.kind === "list-failed") {
@@ -1975,7 +1986,7 @@ async function ensureAgentWorkspace({ appUrl, sessionToken, agentSelector }) {
1975
1986
  printError(`Agent found in workspace ${resolution.workspace.name}, but switching to it failed: ${resolution.message}. Run \`skydive workspace switch ${resolution.workspace.slug}\` and retry.`);
1976
1987
  process.exit(1);
1977
1988
  }
1978
- printError(`No agent with id ${agentSelector} in any workspace on this account. It may belong to a different account run \`skydive auth login\` with the right one or the agent may have been archived.`);
1989
+ printError(`No agent with id ${agentSelector} in any workspace on this account. It may belong to a different account (run \`skydive auth login\` with the right one), or the agent may have been archived.`);
1979
1990
  process.exit(1);
1980
1991
  }
1981
1992
  async function runPrintMode({ argv, appUrl }) {
@@ -1984,7 +1995,7 @@ async function runPrintMode({ argv, appUrl }) {
1984
1995
  printError(`${auth.error.message} For non-interactive use, run \`skydive auth login\` first, or set SKYDIVE_API_KEY / SKYDIVE_SESSION_TOKEN.`);
1985
1996
  process.exit(1);
1986
1997
  }
1987
- const { runPrint, readStdin } = await import("./print-BXNq9UxE.mjs");
1998
+ const { runPrint, readStdin } = await import("./print-ba_0hiV9.mjs");
1988
1999
  await ensureAgentWorkspace({
1989
2000
  appUrl,
1990
2001
  sessionToken: auth.value.token,
@@ -2009,7 +2020,7 @@ async function runPrintMode({ argv, appUrl }) {
2009
2020
  process.exit(1);
2010
2021
  }
2011
2022
  } else {
2012
- const { connectMachineShare } = await import("./print-share-D72CfWJk.mjs");
2023
+ const { connectMachineShare } = await import("./print-share-CT4ltX7u.mjs");
2013
2024
  machineShare = await connectMachineShare({
2014
2025
  appUrl: auth.value.appUrl,
2015
2026
  sessionToken: auth.value.token,
@@ -2029,7 +2040,7 @@ async function runPrintMode({ argv, appUrl }) {
2029
2040
  });
2030
2041
  if (argv.json) output(argv, result);
2031
2042
  } catch (error) {
2032
- const { BillingBlockedError, BILLING_BLOCKED_EXIT_CODE, billingBlockedJsonResult } = await import("./billing-blocked-euid6MN9.mjs");
2043
+ const { BillingBlockedError, BILLING_BLOCKED_EXIT_CODE, billingBlockedJsonResult } = await import("./billing-blocked-Dgu5-oDy.mjs");
2033
2044
  if (error instanceof BillingBlockedError) {
2034
2045
  if (argv.json) output(argv, billingBlockedJsonResult(error, null));
2035
2046
  printError(error.message);
@@ -2073,7 +2084,7 @@ const getCommand$1 = {
2073
2084
  printError(`${auth.error.message} Run \`skydive auth login\` first, or set SKYDIVE_API_KEY / SKYDIVE_SESSION_TOKEN.`);
2074
2085
  process.exit(1);
2075
2086
  }
2076
- const { messageGet } = await import("./print-BXNq9UxE.mjs");
2087
+ const { messageGet } = await import("./print-ba_0hiV9.mjs");
2077
2088
  try {
2078
2089
  const result = await messageGet({
2079
2090
  appUrl: auth.value.appUrl,
@@ -2083,7 +2094,7 @@ const getCommand$1 = {
2083
2094
  });
2084
2095
  if (argv.json) output(argv, result);
2085
2096
  } catch (error) {
2086
- const { BillingBlockedError, BILLING_BLOCKED_EXIT_CODE, billingBlockedJsonResult } = await import("./billing-blocked-euid6MN9.mjs");
2097
+ const { BillingBlockedError, BILLING_BLOCKED_EXIT_CODE, billingBlockedJsonResult } = await import("./billing-blocked-Dgu5-oDy.mjs");
2087
2098
  if (error instanceof BillingBlockedError) {
2088
2099
  if (argv.json) output(argv, billingBlockedJsonResult(error, argv["message-id"]));
2089
2100
  printError(error.message);
@@ -2276,7 +2287,7 @@ const switchCommand = {
2276
2287
  printError("The workspace picker needs the Bun runtime and it could not be set up automatically. Pass a workspace slug instead, or install Bun and retry.");
2277
2288
  process.exit(1);
2278
2289
  }
2279
- const { runWorkspacePicker } = await import("./boot-on5ucI_Z.mjs");
2290
+ const { runWorkspacePicker } = await import("./boot-DZYbTxev.mjs");
2280
2291
  await runWorkspacePicker(session);
2281
2292
  return;
2282
2293
  }
@@ -2354,19 +2365,18 @@ const openCommand = {
2354
2365
  const agent = argv.agent ? resolveAgent((await fetchPortalDevices(session)).agents, argv.agent) : null;
2355
2366
  const cwd = argv.cwd ? path.resolve(argv.cwd) : process.cwd();
2356
2367
  const { machineName } = machineIdentity();
2357
- const { PortalClient } = await import("./client-D6apKmV0.mjs");
2368
+ const { PortalDaemonClient } = await import("./daemon-client-DlblQIR9.mjs");
2358
2369
  let lastLine = "";
2359
2370
  let signalConnected;
2360
2371
  const connected = new Promise((resolve) => {
2361
2372
  signalConnected = resolve;
2362
2373
  });
2363
- const client = new PortalClient({
2374
+ const client = new PortalDaemonClient({
2364
2375
  appUrl: session.appUrl,
2365
2376
  sessionToken: session.sessionToken,
2366
- resolveCwd: () => cwd,
2367
2377
  onState: (state) => {
2368
2378
  if (state.status === "connected") signalConnected();
2369
- const line = state.status === "error" ? `portal: connection error: ${state.error ?? "unknown"} retrying` : `portal: ${state.status}`;
2379
+ const line = state.status === "error" ? `portal: connection error: ${state.error ?? "unknown"}; retrying` : `portal: ${state.status}`;
2370
2380
  if (line === lastLine) return;
2371
2381
  lastLine = line;
2372
2382
  if (state.status === "error") console.error(line);
@@ -2379,13 +2389,15 @@ const openCommand = {
2379
2389
  };
2380
2390
  process.on("SIGINT", stop);
2381
2391
  process.on("SIGTERM", stop);
2392
+ await client.start();
2393
+ client.setFallbackCwd(cwd);
2382
2394
  client.enable();
2383
2395
  await connected;
2384
2396
  if (agent) {
2385
2397
  await client.grantAgent(agent.id);
2386
2398
  console.log(`portal: granted ${agent.name} access to this machine (persists until revoked)`);
2387
2399
  }
2388
- console.log(`portal: open granted agents can run commands on ${machineName} as your user, cwd ${cwd}. ctrl+c to close.`);
2400
+ console.log(`portal: open. granted agents can run commands on ${machineName} as your user, cwd ${cwd}. ctrl+c to close.`);
2389
2401
  await new Promise(() => {});
2390
2402
  }
2391
2403
  };
@@ -2411,7 +2423,7 @@ const grantCommand = {
2411
2423
  });
2412
2424
  return;
2413
2425
  }
2414
- console.log(`Granted ${agent.name} access to ${device?.friendlyName ?? friendlyName}. The agent can run commands here whenever its portal is open start with \`skydive portal open\`, or pass \`--share-machine\` on a \`chat -p\` run. Revoke with \`skydive portal revoke --agent ${agent.name}\`.`);
2426
+ console.log(`Granted ${agent.name} access to ${device?.friendlyName ?? friendlyName}. The agent can run commands here whenever its portal is open. Start with \`skydive portal open\`, or pass \`--share-machine\` on a \`chat -p\` run. Revoke with \`skydive portal revoke --agent ${agent.name}\`.`);
2415
2427
  }
2416
2428
  };
2417
2429
  const revokeCommand = {
@@ -2420,7 +2432,7 @@ const revokeCommand = {
2420
2432
  builder: agentOption,
2421
2433
  handler: async (argv) => {
2422
2434
  const { session, agent, device } = await resolveGrantTarget(argv);
2423
- if (!device) throw new Error(`this machine (${machineIdentity().machineName}) isn't registered with the portal there's nothing to revoke.`);
2435
+ if (!device) throw new Error(`this machine (${machineIdentity().machineName}) isn't registered with the portal, so there's nothing to revoke.`);
2424
2436
  await revokePortalAccess(session, {
2425
2437
  deviceId: device.id,
2426
2438
  agentId: agent.id
@@ -2589,7 +2601,7 @@ const portalCommand = {
2589
2601
  //#endregion
2590
2602
  //#region src/commands/sandbox.ts
2591
2603
  /** POSIX single-quote one word so the remote shell treats it as one token. */
2592
- function shellQuote(word) {
2604
+ function shellQuote$1(word) {
2593
2605
  if (/^[A-Za-z0-9_@%+=:,./-]+$/.test(word)) return word;
2594
2606
  return `'${word.replace(/'/g, `'\\''`)}'`;
2595
2607
  }
@@ -2604,7 +2616,7 @@ function shellQuote(word) {
2604
2616
  * for too. yargs number-coerces bare numerals, so words are stringified.
2605
2617
  */
2606
2618
  function joinCommandWords(words) {
2607
- return words.map(String).map(shellQuote).join(" ").trim();
2619
+ return words.map(String).map(shellQuote$1).join(" ").trim();
2608
2620
  }
2609
2621
  /**
2610
2622
  * `skydive sandbox` — the standalone counterpart to the chat TUI's `/sandbox`
@@ -2627,8 +2639,8 @@ const sandboxCommand = {
2627
2639
  }).example("skydive sandbox --agent grace", "Live terminal (Ctrl-] detaches)").example("skydive sandbox --agent grace -- tail -n 50 /tmp/harness.log", "One-shot command (use `--` so its flags reach the sandbox)").example("skydive sandbox --agent grace -- sh -c 'ls /tmp | wc -l'", "Shell features go through an explicit `sh -c`"),
2628
2640
  handler: async (argv) => {
2629
2641
  const session = requireSession(argv);
2630
- const { createRestClient } = await import("./rest-Br2eFTlj.mjs");
2631
- const { resolveAgent } = await import("./print-BXNq9UxE.mjs");
2642
+ const { createRestClient } = await import("./rest-DADJh0bi.mjs");
2643
+ const { resolveAgent } = await import("./print-ba_0hiV9.mjs");
2632
2644
  const client = createRestClient({
2633
2645
  appUrl: session.appUrl,
2634
2646
  sessionToken: session.sessionToken
@@ -2697,7 +2709,7 @@ async function runPty({ session, agentId, agentName }) {
2697
2709
  return 1;
2698
2710
  }
2699
2711
  console.error(`Connecting to ${agentName}'s sandbox… (Ctrl-] detaches)`);
2700
- const { runRawPtyPassthrough } = await import("./raw-pty-t5DC-e1T.mjs");
2712
+ const { runRawPtyPassthrough } = await import("./raw-pty-3EkG-jjH.mjs");
2701
2713
  const result = await runRawPtyPassthrough({
2702
2714
  stdin: process.stdin,
2703
2715
  stdout: process.stdout,
@@ -2709,6 +2721,275 @@ async function runPty({ session, agentId, agentName }) {
2709
2721
  return result.code;
2710
2722
  }
2711
2723
 
2724
+ //#endregion
2725
+ //#region src/commands/fs.ts
2726
+ /**
2727
+ * POSIX-quote one word so the remote shell treats it as a single token. Wraps
2728
+ * `shell-quote`'s `quote` (already a repo dependency, used elsewhere in the
2729
+ * CLI) rather than hand-rolling the escaping — it is the well-tested source of
2730
+ * truth for making a path/arg with spaces, quotes, `$`, `;`, globs, etc. inert
2731
+ * when interpolated into an `sh -c` line.
2732
+ */
2733
+ function shellQuote(word) {
2734
+ return quote([word]);
2735
+ }
2736
+ const MISSING_FILE_EXIT = 44;
2737
+ /**
2738
+ * Build the remote shell command that base64-encodes a file to stdout. Exits
2739
+ * {@link MISSING_FILE_EXIT} when the path doesn't exist, 1 when it's a
2740
+ * directory, so the caller can tell "create new" from a genuine error.
2741
+ */
2742
+ function buildReadCommand(path) {
2743
+ const q = shellQuote(path);
2744
+ return `sh -c ${shellQuote(`if [ ! -e ${q} ]; then exit ${MISSING_FILE_EXIT}; fi; if [ -d ${q} ]; then echo 'path is a directory' >&2; exit 1; fi; base64 < ${q}`)}`;
2745
+ }
2746
+ /**
2747
+ * Build the remote shell command that decodes `b64` and writes it to `path`
2748
+ * atomically (temp file + `mv`) so a dropped connection can't truncate the
2749
+ * original in place. `token` is a caller-supplied unique suffix for the temp
2750
+ * file — generated in JS (not the shell's `$$`, which shell-quote would escape
2751
+ * to a literal, so every write would collide on the same temp name).
2752
+ */
2753
+ function buildWriteCommand(path, b64, token) {
2754
+ const tmp = `${path}.skydive-edit.${token}`;
2755
+ return `sh -c ${shellQuote(`printf %s ${shellQuote(b64)} | base64 -d > ${shellQuote(tmp)} && mv -f ${shellQuote(tmp)} ${shellQuote(path)}`)}`;
2756
+ }
2757
+ /**
2758
+ * Resolve the editor command from an explicit override, then $VISUAL, $EDITOR,
2759
+ * then `vi`. Split so `EDITOR="code --wait"` (command + flags) is honored.
2760
+ */
2761
+ function resolveEditor(override, env) {
2762
+ const parts = (override || env.VISUAL || env.EDITOR || "vi").split(/\s+/).filter(Boolean);
2763
+ return {
2764
+ bin: parts[0] ?? "vi",
2765
+ args: parts.slice(1)
2766
+ };
2767
+ }
2768
+ /**
2769
+ * `skydive fs edit <path>` — edit a file that lives on the agent's computer
2770
+ * (its sandbox) with your LOCAL editor. It reads the remote file down over the
2771
+ * same relay `skydive sandbox` uses, opens it in `$EDITOR`, and writes your
2772
+ * changes back when you save and close — so you edit a remote file as if it
2773
+ * were local, without opening the chat TUI.
2774
+ *
2775
+ * There is no server-side "file" endpoint yet: this rides entirely on the
2776
+ * existing one-shot `exec` mode of the sandbox stream. Contents move
2777
+ * base64-encoded in BOTH directions (exec has no stdin, so the write payload is
2778
+ * embedded in the command string) which keeps binary bytes, trailing newlines,
2779
+ * and CRLF intact. Access gating (EDIT on the agent + the sandbox kill switch)
2780
+ * is enforced by the relay, exactly as for `skydive sandbox`. A future PR adds
2781
+ * a first-class `fs` channel that `edit` (and `fs mount`) will ride instead.
2782
+ */
2783
+ const fsEditCommand = {
2784
+ command: "edit <path>",
2785
+ describe: "Edit a file on the agent's computer (its sandbox) with your local $EDITOR",
2786
+ builder: (y) => y.positional("path", {
2787
+ type: "string",
2788
+ demandOption: true,
2789
+ describe: "Absolute or sandbox-relative path of the file to edit"
2790
+ }).option("agent", {
2791
+ type: "string",
2792
+ describe: "Target agent, by id, slug, or name. Optional when the account has exactly one agent."
2793
+ }).option("editor", {
2794
+ type: "string",
2795
+ describe: "Editor command to open (defaults to $VISUAL, then $EDITOR, then vi)"
2796
+ }).example("skydive fs edit --agent grace /tmp/notes.md", "Edit a remote file").example("EDITOR=nano skydive fs edit /home/user/.self/soul.md", "Pick the editor via $EDITOR"),
2797
+ handler: async (argv) => {
2798
+ const session = requireSession(argv);
2799
+ const remotePath = argv.path;
2800
+ const { createRestClient } = await import("./rest-DADJh0bi.mjs");
2801
+ const { resolveAgent } = await import("./print-ba_0hiV9.mjs");
2802
+ const client = createRestClient({
2803
+ appUrl: session.appUrl,
2804
+ sessionToken: session.sessionToken
2805
+ });
2806
+ let agent;
2807
+ try {
2808
+ agent = resolveAgent(await client.listAgents({
2809
+ scope: "org",
2810
+ onPage: null
2811
+ }), argv.agent ?? null);
2812
+ } catch (error) {
2813
+ printError(error instanceof Error ? error.message : String(error));
2814
+ process.exit(1);
2815
+ }
2816
+ const opts = {
2817
+ session,
2818
+ agentId: agent.id
2819
+ };
2820
+ console.error(`Reading ${remotePath} from ${agent.name}'s sandbox…`);
2821
+ const read = await readRemote({
2822
+ ...opts,
2823
+ path: remotePath
2824
+ });
2825
+ if (read.kind === "error") {
2826
+ printError(read.message);
2827
+ process.exit(1);
2828
+ }
2829
+ const original = read.content;
2830
+ if (read.kind === "missing") console.error(`${remotePath} does not exist yet — it will be created when you save.`);
2831
+ const dir = await mkdtemp(join(tmpdir(), "skydive-edit-"));
2832
+ const local = join(dir, remotePath.split("/").pop() || "file");
2833
+ try {
2834
+ await writeFile(local, original);
2835
+ if (!await openEditor(argv.editor, local)) {
2836
+ printError("Editor exited non-zero; not saving any changes.");
2837
+ process.exit(1);
2838
+ }
2839
+ const edited = await readFile(local);
2840
+ if (edited.equals(original)) {
2841
+ console.error("No changes — nothing written.");
2842
+ process.exit(0);
2843
+ }
2844
+ console.error(`Writing changes back to ${remotePath}…`);
2845
+ const wrote = await writeRemote({
2846
+ ...opts,
2847
+ path: remotePath,
2848
+ content: edited
2849
+ });
2850
+ if (wrote.kind === "error") {
2851
+ printError(`${wrote.message}\nYour edited copy is kept at ${local} so you don't lose it.`);
2852
+ process.exit(1);
2853
+ }
2854
+ console.error("Saved.");
2855
+ process.exit(0);
2856
+ } finally {
2857
+ await rm(dir, {
2858
+ recursive: true,
2859
+ force: true
2860
+ }).catch((error) => {
2861
+ console.error(`Note: could not remove temp dir ${dir}: ${error instanceof Error ? error.message : String(error)}`);
2862
+ });
2863
+ }
2864
+ }
2865
+ };
2866
+ /**
2867
+ * Read a remote file as bytes. Runs `base64` on the file in the sandbox and
2868
+ * decodes the streamed stdout locally. Distinguishes "file is missing" (exit
2869
+ * code 44, so `edit` can create it) from a real read failure.
2870
+ */
2871
+ function readRemote({ session, agentId, path }) {
2872
+ const command = buildReadCommand(path);
2873
+ const chunks = [];
2874
+ const stderr = [];
2875
+ return new Promise((resolve) => {
2876
+ SandboxStream.open({
2877
+ mode: "exec",
2878
+ appUrl: session.appUrl,
2879
+ sessionToken: session.sessionToken,
2880
+ agentId,
2881
+ command,
2882
+ onEvent: (e) => {
2883
+ switch (e.type) {
2884
+ case "data":
2885
+ chunks.push(Buffer.from(e.bytes));
2886
+ break;
2887
+ case "exit":
2888
+ if (e.code === MISSING_FILE_EXIT) resolve({
2889
+ kind: "missing",
2890
+ content: Buffer.alloc(0)
2891
+ });
2892
+ else if (e.code === 0) resolve({
2893
+ kind: "ok",
2894
+ content: Buffer.from(Buffer.concat(chunks).toString("utf8").replace(/\s+/g, ""), "base64")
2895
+ });
2896
+ else resolve({
2897
+ kind: "error",
2898
+ message: stderr.join("").trim() || `Could not read the file (exit ${e.code}).`
2899
+ });
2900
+ break;
2901
+ case "error":
2902
+ stderr.push(e.message);
2903
+ break;
2904
+ case "close":
2905
+ resolve({
2906
+ kind: "error",
2907
+ message: e.failure || "The connection to the sandbox closed before the file could be read."
2908
+ });
2909
+ break;
2910
+ }
2911
+ }
2912
+ });
2913
+ });
2914
+ }
2915
+ /**
2916
+ * Write bytes to a remote file. Exec has no stdin, so the base64 payload is
2917
+ * embedded in the command and decoded on the far side. Writes atomically via a
2918
+ * temp file + `mv` so a dropped connection mid-write can't leave a truncated
2919
+ * file in place of the original.
2920
+ */
2921
+ function writeRemote({ session, agentId, path, content }) {
2922
+ const token = randomBytes(6).toString("hex");
2923
+ const command = buildWriteCommand(path, content.toString("base64"), token);
2924
+ const stderr = [];
2925
+ return new Promise((resolve) => {
2926
+ SandboxStream.open({
2927
+ mode: "exec",
2928
+ appUrl: session.appUrl,
2929
+ sessionToken: session.sessionToken,
2930
+ agentId,
2931
+ command,
2932
+ onEvent: (e) => {
2933
+ switch (e.type) {
2934
+ case "data":
2935
+ stderr.push(Buffer.from(e.bytes).toString("utf8"));
2936
+ break;
2937
+ case "exit":
2938
+ resolve(e.code === 0 ? { kind: "ok" } : {
2939
+ kind: "error",
2940
+ message: stderr.join("").trim() || `Could not write the file (exit ${e.code}).`
2941
+ });
2942
+ break;
2943
+ case "error":
2944
+ stderr.push(e.message);
2945
+ break;
2946
+ case "close":
2947
+ resolve({
2948
+ kind: "error",
2949
+ message: e.failure || "The connection to the sandbox closed before the file was written."
2950
+ });
2951
+ break;
2952
+ }
2953
+ }
2954
+ });
2955
+ });
2956
+ }
2957
+ /**
2958
+ * Open `file` in the caller's editor and resolve to whether it exited cleanly.
2959
+ * Precedence: explicit `--editor`, then $VISUAL, $EDITOR, then `vi`. The editor
2960
+ * inherits the real TTY so full-screen editors (vim/nano) work.
2961
+ */
2962
+ function openEditor(override, file) {
2963
+ const { bin, args: editorArgs } = resolveEditor(override, process.env);
2964
+ const args = [...editorArgs, file];
2965
+ return new Promise((resolve) => {
2966
+ const child = spawn(bin, args, { stdio: "inherit" });
2967
+ child.on("error", (err) => {
2968
+ printError(`Could not launch editor "${bin}": ${err.message}`);
2969
+ resolve(false);
2970
+ });
2971
+ child.on("exit", (code) => resolve(code === 0));
2972
+ });
2973
+ }
2974
+ /**
2975
+ * `skydive fs` — work with the files on an agent's computer (its sandbox) from
2976
+ * your own machine. The namespace for filesystem access:
2977
+ *
2978
+ * - `fs edit <path>` edit one remote file with your local editor (shipped).
2979
+ * - `fs mount <dir>` mount the whole sandbox filesystem locally (coming in a
2980
+ * later PR, on a first-class `fs` relay channel).
2981
+ *
2982
+ * Grouping these under one command keeps the file surface discoverable and
2983
+ * leaves room to grow (`fs ls`, `fs cat`, `fs pull`) without adding more
2984
+ * top-level commands.
2985
+ */
2986
+ const fsCommand = {
2987
+ command: "fs <command>",
2988
+ describe: "Work with the files on an agent's computer (its sandbox)",
2989
+ builder: (y) => y.command(fsEditCommand).demandCommand(1, "Specify a subcommand: edit"),
2990
+ handler: () => {}
2991
+ };
2992
+
2712
2993
  //#endregion
2713
2994
  //#region src/update-check/manifest.ts
2714
2995
  /**
@@ -2937,7 +3218,7 @@ async function downloadAndVerify(opts) {
2937
3218
  const bytes = new Uint8Array(await response.arrayBuffer());
2938
3219
  if (bytes.byteLength === 0) throw new UpdateError(`download from ${url} was empty`);
2939
3220
  const actual = sha256Hex(bytes);
2940
- if (actual !== opts.expectedSha256) throw new UpdateError(`sha256 mismatch (expected ${opts.expectedSha256}, got ${actual}) the download may be corrupt; re-run \`skydive update\``);
3221
+ if (actual !== opts.expectedSha256) throw new UpdateError(`sha256 mismatch (expected ${opts.expectedSha256}, got ${actual}). the download may be corrupt; re-run \`skydive update\``);
2941
3222
  return bytes;
2942
3223
  }
2943
3224
  /**
@@ -3312,7 +3593,7 @@ const updateCommand = {
3312
3593
  });
3313
3594
  return;
3314
3595
  }
3315
- throw new UpdateError(source === "binary" ? `couldn't reach the ${channel} release channel check your connection and try again.` : `couldn't reach the npm registry to look up the ${channel} release check your connection and try again.`);
3596
+ throw new UpdateError(source === "binary" ? `couldn't reach the ${channel} release channel; check your connection and try again.` : `couldn't reach the npm registry to look up the ${channel} release; check your connection and try again.`);
3316
3597
  }
3317
3598
  const plan = planUpdate({
3318
3599
  currentVersion,
@@ -3367,7 +3648,7 @@ const updateCommand = {
3367
3648
  return;
3368
3649
  }
3369
3650
  const selfPath = resolveSelfPath();
3370
- if (!selfPath) throw new UpdateError("couldn't determine this binary's path to replace it reinstall with the install script instead.");
3651
+ if (!selfPath) throw new UpdateError("couldn't determine this binary's path to replace it; reinstall with the install script instead.");
3371
3652
  console.log(describePlan(plan, channel, false));
3372
3653
  await applyBinary(selfPath, await downloadAndVerify({
3373
3654
  downloadBaseUrl: RELEASE_CDN_URL,
@@ -3517,7 +3798,7 @@ const configCommand = {
3517
3798
  //#endregion
3518
3799
  //#region src/cli.ts
3519
3800
  function createCli(argv) {
3520
- return yargs(argv).scriptName("skydive").usage("$0 <command> [options]").parserConfiguration({ "populate--": true }).example("skydive auth login", "Store your API key").example("skydive chat", "Open the interactive chat TUI (prod)").example("skydive chat --api-url http://localhost:4500", "Chat against a local dev API").example("skydive agents list", "List your agents").example("skydive completion install", "Set up TAB completion for your shell").example("skydive keys create \"my-key\"", "Create an API key").example("skydive secrets set OPENAI_API_KEY --agent-id <id>", "Set a secret (value from stdin)").example("skydive workspace list", "List workspaces on your account").example("skydive config set updateCheck false", "Disable the daily update check").example("skydive workspace switch acme-team", "Switch the workspace all `skydive` commands act on").example("skydive portal open --agent grace", "Open the portal to this machine for an agent, headless (no TUI)").option("json", {
3801
+ return yargs(argv).scriptName("skydive").usage("$0 <command> [options]").parserConfiguration({ "populate--": true }).example("skydive auth login", "Store your API key").example("skydive chat", "Open the interactive chat TUI (prod)").example("skydive chat --api-url http://localhost:4500", "Chat against a local dev API").example("skydive agents list", "List your agents").example("skydive completion install", "Set up TAB completion for your shell").example("skydive keys create \"my-key\"", "Create an API key").example("skydive secrets set OPENAI_API_KEY --agent-id <id>", "Set a secret (value from stdin)").example("skydive workspace list", "List workspaces on your account").example("skydive config set updateCheck false", "Disable the daily update check").example("skydive workspace switch acme-team", "Switch the workspace all `skydive` commands act on").example("skydive portal open --agent grace", "Open the portal to this machine for an agent, headless (no TUI)").example("skydive fs edit --agent grace /tmp/notes.md", "Edit a file on the agent's computer with your local editor").option("json", {
3521
3802
  type: "boolean",
3522
3803
  default: false,
3523
3804
  global: true,
@@ -3531,7 +3812,7 @@ function createCli(argv) {
3531
3812
  type: "string",
3532
3813
  global: true,
3533
3814
  describe: "Override API base URL"
3534
- }).command(authCommand).command(chatCommand).command(messagesCommand).command(conversationsCommand).command(agentsCommand).command(importCommand).command(keysCommand).command(secretsCommand).command(workspaceCommand).command(portalCommand).command(sandboxCommand).command(updateCommand).command(configCommand).command(completionCommand).demandCommand(1, "Specify a command. Run --help for usage.").strict().wrap(null).version(version).alias("v", "version").alias("h", "help").help().fail((msg, err) => {
3815
+ }).command(authCommand).command(chatCommand).command(messagesCommand).command(conversationsCommand).command(agentsCommand).command(importCommand).command(keysCommand).command(secretsCommand).command(workspaceCommand).command(portalCommand).command(sandboxCommand).command(fsCommand).command(updateCommand).command(configCommand).command(completionCommand).demandCommand(1, "Specify a command. Run --help for usage.").strict().wrap(null).version(version).alias("v", "version").alias("h", "help").help().fail((msg, err) => {
3535
3816
  printError(err ? err instanceof Error ? err.message : String(err) : msg ?? "Unknown error");
3536
3817
  process.exit(1);
3537
3818
  });
@@ -3744,7 +4025,7 @@ function setupUpdateCheck(argv) {
3744
4025
 
3745
4026
  //#endregion
3746
4027
  //#region src/changelog.generated.ts
3747
- const CHANGELOG_MD = "# Changelog\n\nAll notable changes to the Skydive CLI are documented here.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n\n## [Unreleased]\n\n## [0.4.0] - 2026-08-07\n\n### Added\n\n- `skydive chat` works with API key auth: an API key alone now opens the chat TUI (and headless `chat -p`) without a browser login, using the key's pinned workspace.\n- `skydive config` command to view and set the safe, hand-editable CLI preferences (`shareMachineDefault`, `updateCheck`) without opening `config.json`. `config`/`config list` shows each key, its effective value, and whether it comes from the file or the built-in default; `config get`/`set`/`unset` read and change one key; `config path` prints the config file location. It only ever touches those preference keys, never credentials or flow-managed state.\n- Billing-blocked sends and runs now surface the server-authored recovery\n guidance from the typed billing outcome. The chat TUI renders it as a\n warning-toned system-notice row — live when a send is refused or a run is\n stopped at the billing boundary, and again when reopening a conversation\n that holds a persisted billing notice — instead of a generic error.\n Headless `chat -p` and `messages get` print the guidance (state, recovery\n step, and manage-billing URL) on stderr, keep any partial output already\n streamed on stdout, and exit with code `5` (distinct from the generic `1`)\n so scripted callers can tell a billing pause from a failure.\n- Syntax highlighting for 14 more languages in the chat transcript and file/review panes (python, bash, go, rust, c, cpp, java, ruby, css, html, json, yaml, and more) — previously only JavaScript/TypeScript rendered colored.\n\n### Changed\n\n- `skydive agent list` lists the full agent roster by default instead of a truncated page.\n\n### Fixed\n\n- Long multi-line bash tool-call commands (e.g. heredocs) are clamped with a `+N more · click to expand` tail instead of dumping their whole body into the scrollback.\n- Tool error output is clipped the same way as ok output, so a failing command no longer floods the transcript.\n- The TUI toast overlay has an opaque background instead of letting the transcript bleed through.\n\n## [0.3.0] - 2026-08-04\n\n### Added\n\n**Chat TUI**\n\n- `/fork` slash command to fork a conversation at any point and continue in a new thread.\n- `/conversation` switches threads from inside a live session.\n- `/compact` triggers manual conversation compaction.\n- `/portal` and `/copy` slash commands.\n- Archive the current conversation from the chat TUI.\n- `--new` flag on `skydive chat` to start a fresh conversation.\n- Debounced server-side conversation search in the picker, with title matches ranked first.\n- File review pane orientation toggle, and review comments in the file pane.\n- Pinned plan card controls and a jump-to-latest hint.\n- Terminal title (OSC) follows the live conversation title on every screen; inside cmux the workspace is renamed too, and linked PRs are pushed to the cmux sidebar.\n- Every participating agent shows in the conversation list; connect cards each have their own identity, and ctrl+r asks which connect card to act on.\n- Colored Skydive splash art in `skydive --help` and the TUI pickers.\n- New-agent name prefilled from the server's suggestion.\n\n**CLI & platform**\n\n- `skydive update` self-updater, with an update notice when a new version is available.\n- Shell completions for bash, zsh, and fish via `completion install`.\n- Portal daemon: one connection per host with per-conversation working directories.\n- Agent-led coding-agent import (`skydive import`).\n- Per-workspace scoping on the REST client, and cross-org `--agent <uuid>` auto-switches workspace.\n- `skydive-beta` wrapper for the canary channel.\n\n### Fixed\n\n- `skydive update` no longer claims an update is available on every npm install.\n- Chat memory is bounded (payload clamps + windowed rows) with a memory watchdog and OOM diagnostic report; transcript rows are memoized so streaming stops re-rendering the whole chat.\n- Chat-send failures map to real error messages.\n- Notification and sidebar previews use the last text block of the reply and strip inline markdown.\n- Picker rows no longer overlap when a conversation title contains a newline, tab, or control character.\n- Sending to non-web channel conversations is blocked in the TUI.\n- GitHub bot connect opens on the web front door, not api.skydive.com.\n- TUI activity counter times from the run, not the screen.\n\n## [0.2.0] - 2026-07-29\n\n### Added\n\n**Sandbox & machine access**\n\n- Standalone `skydive sandbox` command for direct access to an agent's sandbox.\n- `/sandbox` in the chat TUI — live PTY session and one-shot command execution.\n- Headless machine sharing via `skydive portal`, with self-registering portal grants.\n- `shareMachineDefault` config key for always-on portal sharing.\n\n**Chat TUI**\n\n- File pane (`ctrl+g`) with Changes and Files tabs: a shared file tree plus source viewer and a workspace browser, mouse-resizable and responsive to terminal size.\n- Agent todo list rendered in the chat TUI, above the composer, mirroring the web chat's todo card.\n- Fuzzy finder in the conversation and agent pickers.\n- Slash-command autocomplete menu.\n- Paste or drag-and-drop any file into the composer; paste clipboard images with Cmd+V.\n- Run local shell commands with `!` in the composer.\n- Conversation recaps, streamed live title updates, and per-agent attribution on assistant turns.\n- Working timer rolls up into minutes and hours.\n- Conversation picker paginates past 50 conversations and shows only your own conversations.\n- Esc leaves a live run; typing `exit` quits the chat.\n- Cursor Dark theme.\n- Picker rows no longer overlap when a conversation title contains a newline, tab, or control character.\n\n**Headless & scripting**\n\n- Resume a conversation by id.\n- `conversations list` and `conversations show` for transcript reads.\n- `messages get`, with run recovery keyed on message id.\n- Connect cards surface in headless `-p` mode so a driving agent never gets stuck.\n\n**Authentication**\n\n- `skydive auth login` via the browser now auto-mints an API key, so one login yields both a chat session and a usable management credential. Management commands announce the key's pinned workspace when it drives them, so a workspace mismatch is visible at use time.\n- Workspace picker on the device authorization page.\n- Account and workspace identity shown in `auth status`.\n\n**Platform**\n\n- Standalone binary builds compiling the CLI into a per-target executable.\n- Interactive workspace switcher; management commands follow the active workspace.\n- Terminal host integrations and agent notifications.\n\n### Fixed\n\n- Transcript errors collapse to one line, click to expand (REST and portal errors keep their full body).\n- Dragged/pasted image file paths attach the file instead of inserting path text, including macOS paths with literal parentheses.\n- Bare URLs in chat markdown are hyperlinked so they survive text wrap.\n- Composer draft is preserved across TUI overlays.\n- Relative connect links resolve before opening the browser.\n- Numbered markdown headings render colored in the TUI.\n- Chat transcript pages by 75% of a screen; picker rows stay on one line.\n- Run starts push to the TUI over the conversation stream.\n- Security: remediated high-severity dependency findings and cleared tar/shell-quote CVEs.\n\n## [0.1.0] - 2026-07-21\n\nInitial public release: `skydive chat` TUI, agent and conversation management,\ndevice authorization, and headless `-p` mode.\n";
4028
+ const CHANGELOG_MD = "# Changelog\n\nAll notable changes to the Skydive CLI are documented here.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n\n## [Unreleased]\n\n### Added\n\n- `skydive fs` — a namespace for working with the files on an agent's computer (its sandbox) from your own machine. Its first subcommand, `skydive fs edit <path>`, reads a remote file down over the same relay `skydive sandbox` uses, opens it in your local editor (`$VISUAL`/`$EDITOR`, override with `--editor`, defaults to `vi`), and writes your changes back atomically when you save and close — so you can edit a remote file as if it were local without opening the chat TUI. A path that doesn't exist yet is created on save; no changes means nothing is written. Access is gated on EDIT permission for the agent, exactly like `skydive sandbox`. (A first-class `fs` relay channel and `skydive fs mount` land in follow-ups.)\n\n## [0.4.0] - 2026-08-07\n\n### Added\n\n- `skydive chat` works with API key auth: an API key alone now opens the chat TUI (and headless `chat -p`) without a browser login, using the key's pinned workspace.\n- `skydive config` command to view and set the safe, hand-editable CLI preferences (`shareMachineDefault`, `updateCheck`) without opening `config.json`. `config`/`config list` shows each key, its effective value, and whether it comes from the file or the built-in default; `config get`/`set`/`unset` read and change one key; `config path` prints the config file location. It only ever touches those preference keys, never credentials or flow-managed state.\n- Billing-blocked sends and runs now surface the server-authored recovery\n guidance from the typed billing outcome. The chat TUI renders it as a\n warning-toned system-notice row — live when a send is refused or a run is\n stopped at the billing boundary, and again when reopening a conversation\n that holds a persisted billing notice — instead of a generic error.\n Headless `chat -p` and `messages get` print the guidance (state, recovery\n step, and manage-billing URL) on stderr, keep any partial output already\n streamed on stdout, and exit with code `5` (distinct from the generic `1`)\n so scripted callers can tell a billing pause from a failure.\n- Syntax highlighting for 14 more languages in the chat transcript and file/review panes (python, bash, go, rust, c, cpp, java, ruby, css, html, json, yaml, and more) — previously only JavaScript/TypeScript rendered colored.\n\n### Changed\n\n- `skydive agent list` lists the full agent roster by default instead of a truncated page.\n\n### Fixed\n\n- Long multi-line bash tool-call commands (e.g. heredocs) are clamped with a `+N more · click to expand` tail instead of dumping their whole body into the scrollback.\n- Tool error output is clipped the same way as ok output, so a failing command no longer floods the transcript.\n- The TUI toast overlay has an opaque background instead of letting the transcript bleed through.\n\n## [0.3.0] - 2026-08-04\n\n### Added\n\n**Chat TUI**\n\n- `/fork` slash command to fork a conversation at any point and continue in a new thread.\n- `/conversation` switches threads from inside a live session.\n- `/compact` triggers manual conversation compaction.\n- `/portal` and `/copy` slash commands.\n- Archive the current conversation from the chat TUI.\n- `--new` flag on `skydive chat` to start a fresh conversation.\n- Debounced server-side conversation search in the picker, with title matches ranked first.\n- File review pane orientation toggle, and review comments in the file pane.\n- Pinned plan card controls and a jump-to-latest hint.\n- Terminal title (OSC) follows the live conversation title on every screen; inside cmux the workspace is renamed too, and linked PRs are pushed to the cmux sidebar.\n- Every participating agent shows in the conversation list; connect cards each have their own identity, and ctrl+r asks which connect card to act on.\n- Colored Skydive splash art in `skydive --help` and the TUI pickers.\n- New-agent name prefilled from the server's suggestion.\n\n**CLI & platform**\n\n- `skydive update` self-updater, with an update notice when a new version is available.\n- Shell completions for bash, zsh, and fish via `completion install`.\n- Portal daemon: one connection per host with per-conversation working directories.\n- Agent-led coding-agent import (`skydive import`).\n- Per-workspace scoping on the REST client, and cross-org `--agent <uuid>` auto-switches workspace.\n- `skydive-beta` wrapper for the canary channel.\n\n### Fixed\n\n- `skydive update` no longer claims an update is available on every npm install.\n- Chat memory is bounded (payload clamps + windowed rows) with a memory watchdog and OOM diagnostic report; transcript rows are memoized so streaming stops re-rendering the whole chat.\n- Chat-send failures map to real error messages.\n- Notification and sidebar previews use the last text block of the reply and strip inline markdown.\n- Picker rows no longer overlap when a conversation title contains a newline, tab, or control character.\n- Sending to non-web channel conversations is blocked in the TUI.\n- GitHub bot connect opens on the web front door, not api.skydive.com.\n- TUI activity counter times from the run, not the screen.\n\n## [0.2.0] - 2026-07-29\n\n### Added\n\n**Sandbox & machine access**\n\n- Standalone `skydive sandbox` command for direct access to an agent's sandbox.\n- `/sandbox` in the chat TUI — live PTY session and one-shot command execution.\n- Headless machine sharing via `skydive portal`, with self-registering portal grants.\n- `shareMachineDefault` config key for always-on portal sharing.\n\n**Chat TUI**\n\n- File pane (`ctrl+g`) with Changes and Files tabs: a shared file tree plus source viewer and a workspace browser, mouse-resizable and responsive to terminal size.\n- Agent todo list rendered in the chat TUI, above the composer, mirroring the web chat's todo card.\n- Fuzzy finder in the conversation and agent pickers.\n- Slash-command autocomplete menu.\n- Paste or drag-and-drop any file into the composer; paste clipboard images with Cmd+V.\n- Run local shell commands with `!` in the composer.\n- Conversation recaps, streamed live title updates, and per-agent attribution on assistant turns.\n- Working timer rolls up into minutes and hours.\n- Conversation picker paginates past 50 conversations and shows only your own conversations.\n- Esc leaves a live run; typing `exit` quits the chat.\n- Cursor Dark theme.\n- Picker rows no longer overlap when a conversation title contains a newline, tab, or control character.\n\n**Headless & scripting**\n\n- Resume a conversation by id.\n- `conversations list` and `conversations show` for transcript reads.\n- `messages get`, with run recovery keyed on message id.\n- Connect cards surface in headless `-p` mode so a driving agent never gets stuck.\n\n**Authentication**\n\n- `skydive auth login` via the browser now auto-mints an API key, so one login yields both a chat session and a usable management credential. Management commands announce the key's pinned workspace when it drives them, so a workspace mismatch is visible at use time.\n- Workspace picker on the device authorization page.\n- Account and workspace identity shown in `auth status`.\n\n**Platform**\n\n- Standalone binary builds compiling the CLI into a per-target executable.\n- Interactive workspace switcher; management commands follow the active workspace.\n- Terminal host integrations and agent notifications.\n\n### Fixed\n\n- Transcript errors collapse to one line, click to expand (REST and portal errors keep their full body).\n- Dragged/pasted image file paths attach the file instead of inserting path text, including macOS paths with literal parentheses.\n- Bare URLs in chat markdown are hyperlinked so they survive text wrap.\n- Composer draft is preserved across TUI overlays.\n- Relative connect links resolve before opening the browser.\n- Numbered markdown headings render colored in the TUI.\n- Chat transcript pages by 75% of a screen; picker rows stay on one line.\n- Run starts push to the TUI over the conversation stream.\n- Security: remediated high-severity dependency findings and cleared tar/shell-quote CVEs.\n\n## [0.1.0] - 2026-07-21\n\nInitial public release: `skydive chat` TUI, agent and conversation management,\ndevice authorization, and headless `-p` mode.\n";
3748
4029
 
3749
4030
  //#endregion
3750
4031
  //#region src/whats-new.ts
@@ -3881,17 +4162,18 @@ function maybePrintWhatsNew({ stderrIsTTY = process.stderr.isTTY ?? false, nonIn
3881
4162
  //#endregion
3882
4163
  //#region src/bin.ts
3883
4164
  installCrashHandler();
4165
+ maybeStartProfiling(hideBin(process.argv), version);
3884
4166
  if (process.argv.includes(UPDATE_WORKER_FLAG)) {
3885
4167
  await runUpdateCheckWorker();
3886
4168
  process.exit(0);
3887
4169
  }
3888
4170
  if (process.argv.includes(PORTAL_DAEMON_FLAG)) {
3889
- const { runPortalDaemon } = await import("./daemon-BADmpJAs.mjs");
4171
+ const { runPortalDaemon } = await import("./daemon-imLBqTGg.mjs");
3890
4172
  runPortalDaemon(process.argv);
3891
4173
  } else runCli();
3892
4174
  function runCli() {
3893
4175
  const completionProbe = isCompletionProbe(process.argv);
3894
- if (!completionProbe) {
4176
+ if (!completionProbe && !isBunReexecChild()) {
3895
4177
  maybePrintWhatsNew();
3896
4178
  setupUpdateCheck(hideBin(process.argv));
3897
4179
  }