@somewhere-cloud/cli 0.38.122 → 0.38.124

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.
@@ -24502,7 +24502,7 @@ var require_snapshot_recorder = __commonJS({
24502
24502
  "node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
24503
24503
  "use strict";
24504
24504
  var { writeFile: writeFile2, readFile: readFile2, mkdir } = __require("node:fs/promises");
24505
- var { dirname: dirname15, resolve: resolve26 } = __require("node:path");
24505
+ var { dirname: dirname16, resolve: resolve26 } = __require("node:path");
24506
24506
  var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
24507
24507
  var { InvalidArgumentError: InvalidArgumentError2, UndiciError } = require_errors();
24508
24508
  var { hashId, isUrlExcludedFactory, normalizeHeaders: normalizeHeaders2, createHeaderFilters } = require_snapshot_utils();
@@ -24757,7 +24757,7 @@ var require_snapshot_recorder = __commonJS({
24757
24757
  throw new InvalidArgumentError2("Snapshot path is required");
24758
24758
  }
24759
24759
  const resolvedPath = resolve26(path3);
24760
- await mkdir(dirname15(resolvedPath), { recursive: true });
24760
+ await mkdir(dirname16(resolvedPath), { recursive: true });
24761
24761
  const data2 = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
24762
24762
  hash: hash2,
24763
24763
  snapshot
@@ -36800,36 +36800,59 @@ function describeThisDevice() {
36800
36800
  arch: arch()
36801
36801
  };
36802
36802
  }
36803
- async function deviceLogin(callbacks) {
36803
+ async function deviceLogin(callbacks, temporaryToken) {
36804
36804
  const code = generateCode();
36805
36805
  const verifier = randomBytes(32).toString("base64url");
36806
36806
  const codeChallenge = createHash("sha256").update(verifier).digest("hex");
36807
36807
  const deviceName = getDeviceKeyName();
36808
36808
  const startRes = await fetchWithProxy(`${API_BASE}/v1/auth/device-code`, {
36809
36809
  method: "POST",
36810
- headers: { "Content-Type": "application/json" },
36811
- body: JSON.stringify({ code, code_challenge: codeChallenge, device_name: deviceName, client: describeThisDevice() })
36810
+ headers: {
36811
+ "Content-Type": "application/json",
36812
+ ...temporaryToken ? { Authorization: `Bearer ${temporaryToken}` } : {}
36813
+ },
36814
+ body: JSON.stringify({
36815
+ code,
36816
+ code_challenge: codeChallenge,
36817
+ device_name: deviceName,
36818
+ client: describeThisDevice(),
36819
+ ...temporaryToken ? { merge_temporary: true } : {}
36820
+ })
36812
36821
  });
36813
36822
  if (startRes.status === 404) {
36814
36823
  throw new DeviceCodeUnsupported();
36815
36824
  }
36816
36825
  if (!startRes.ok) {
36826
+ if (temporaryToken) {
36827
+ const reason = startRes.status === 401 ? "The temporary session is invalid or expired." : `The server refused the request (HTTP ${startRes.status}).`;
36828
+ throw new Error(`Could not start sign-in to save temporary projects. ${reason}`);
36829
+ }
36817
36830
  const text = await startRes.text();
36818
36831
  throw new Error(`Failed to start login: ${new URL(API_BASE).host} answered HTTP ${startRes.status} ${text.slice(0, 200)}. If this shell only allows listed sites (an agent sandbox), add ${new URL(API_BASE).host}, or run \`${cliInvocation()} login\` in your own terminal.`);
36819
36832
  }
36820
- const start = await startRes.json();
36833
+ const start = await startRes.json().catch(() => {
36834
+ throw new Error("The server returned an unreadable login registration. Start login again.");
36835
+ });
36821
36836
  if (start.data.verifier_bound !== true)
36822
36837
  throw new Error("This server does not support secure device redemption. Update the platform before login.");
36823
- callbacks.onPrompt({ code, approvalUrl: start.data.approval_url });
36838
+ const expiresIn = start.data.expires_in;
36839
+ if (!Number.isSafeInteger(expiresIn) || expiresIn <= 0) {
36840
+ throw new Error("The server did not say when the login code expires. Start login again.");
36841
+ }
36842
+ const deadline = performance.now() + expiresIn * 1e3;
36843
+ callbacks.onPrompt({ code, approvalUrl: start.data.approval_url, expiresIn });
36824
36844
  callbacks.onWaiting?.();
36825
- const startedAt = Date.now();
36826
- while (Date.now() - startedAt < TIMEOUT_MS) {
36827
- await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));
36845
+ while (performance.now() < deadline) {
36846
+ await new Promise((r) => setTimeout(r, Math.min(POLL_INTERVAL_MS, Math.ceil(deadline - performance.now()))));
36847
+ if (performance.now() >= deadline)
36848
+ break;
36828
36849
  const pollRes = await fetchWithProxy(`${API_BASE}/v1/auth/device-code/status`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ code, verifier }) });
36829
36850
  if (!pollRes.ok) {
36830
36851
  throw new Error(`Login delivery could not be confirmed (HTTP ${pollRes.status}). Restart login; this redemption will not be retried.`);
36831
36852
  }
36832
- const status = await pollRes.json();
36853
+ const status = await pollRes.json().catch(() => {
36854
+ throw new Error("Login delivery could not be confirmed. Restart login; this redemption will not be retried.");
36855
+ });
36833
36856
  if (status.data.status === "expired") {
36834
36857
  throw new DeviceLoginTimeout();
36835
36858
  }
@@ -36837,6 +36860,9 @@ async function deviceLogin(callbacks) {
36837
36860
  throw new DeviceLoginDenied();
36838
36861
  }
36839
36862
  if (status.data.status === "approved") {
36863
+ if (typeof status.data.token !== "string" || !status.data.token || typeof status.data.email !== "string") {
36864
+ throw new Error("The server did not return a complete login session. Start login again.");
36865
+ }
36840
36866
  const config2 = {
36841
36867
  token: status.data.token,
36842
36868
  user: { email: status.data.email, username: "" }
@@ -36845,12 +36871,12 @@ async function deviceLogin(callbacks) {
36845
36871
  config2.refresh_token = status.data.refresh_token;
36846
36872
  if (status.data.expires_at)
36847
36873
  config2.access_expires_at = status.data.expires_at;
36848
- return { config: config2, scope: status.data.scope ?? null };
36874
+ return { config: config2, scope: status.data.scope ?? null, mergedProjectCount: status.data.merged_project_count };
36849
36875
  }
36850
36876
  }
36851
36877
  throw new DeviceLoginTimeout();
36852
36878
  }
36853
- var API_BASE, POLL_INTERVAL_MS, TIMEOUT_MS, ALPHABET, DeviceLoginTimeout, DeviceCodeUnsupported, DeviceLoginDenied;
36879
+ var API_BASE, POLL_INTERVAL_MS, ALPHABET, DeviceLoginTimeout, DeviceCodeUnsupported, DeviceLoginDenied;
36854
36880
  var init_device_login = __esm({
36855
36881
  "dist/lib/device-login.js"() {
36856
36882
  "use strict";
@@ -36861,7 +36887,6 @@ var init_device_login = __esm({
36861
36887
  init_http();
36862
36888
  API_BASE = API_BASE_URL.replace(/\/v1$/, "");
36863
36889
  POLL_INTERVAL_MS = 1e3;
36864
- TIMEOUT_MS = 5 * 60 * 1e3;
36865
36890
  ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
36866
36891
  __name(generateCode, "generateCode");
36867
36892
  DeviceLoginTimeout = class extends Error {
@@ -37132,7 +37157,8 @@ async function loginAction(opts) {
37132
37157
  await runBrowserCallbackLogin();
37133
37158
  return;
37134
37159
  }
37135
- await runDeviceLogin();
37160
+ const saved = loadConfig();
37161
+ await runDeviceLogin(saved?.temporary ? saved.token : void 0);
37136
37162
  }
37137
37163
  async function readPlanName(client, tierId) {
37138
37164
  try {
@@ -37479,21 +37505,27 @@ function installCancelHandler(getSpinner) {
37479
37505
  process.exit(130);
37480
37506
  });
37481
37507
  }
37482
- async function runDeviceLogin() {
37508
+ async function runDeviceLogin(temporaryToken) {
37483
37509
  for (const line of loginIntroLines())
37484
37510
  console.log(line);
37485
37511
  let spinner = null;
37486
37512
  installCancelHandler(() => spinner);
37487
37513
  try {
37488
- const { config: config2, scope } = await deviceLogin({
37489
- onPrompt: /* @__PURE__ */ __name(({ code, approvalUrl }) => {
37514
+ const { config: config2, scope, mergedProjectCount } = await deviceLogin({
37515
+ onPrompt: /* @__PURE__ */ __name(({ code, approvalUrl, expiresIn }) => {
37490
37516
  console.log(` Code: ${teal(code)}`);
37517
+ const minutes = expiresIn % 60 === 0 ? expiresIn / 60 : null;
37518
+ const duration3 = minutes === null ? `${expiresIn} second${expiresIn === 1 ? "" : "s"}` : `${minutes} minute${minutes === 1 ? "" : "s"}`;
37519
+ info(`Code expires in ${duration3}.`);
37491
37520
  console.log("");
37492
- console.log(" Opening your browser\u2026");
37493
- console.log(` If it doesn't open, visit: ${teal(approvalUrl)}`);
37521
+ const openBrowser = !process.env.SOMEWHERE_NO_BROWSER;
37522
+ if (openBrowser)
37523
+ console.log(" Opening your browser\u2026");
37524
+ console.log(` ${openBrowser ? "If it doesn't open, visit" : "Visit"}: ${teal(approvalUrl)}`);
37494
37525
  console.log("");
37495
- open(approvalUrl).catch(() => {
37496
- });
37526
+ if (openBrowser)
37527
+ open(approvalUrl).catch(() => {
37528
+ });
37497
37529
  }, "onPrompt"),
37498
37530
  onWaiting: /* @__PURE__ */ __name(() => {
37499
37531
  spinner = ora({
@@ -37501,11 +37533,14 @@ async function runDeviceLogin() {
37501
37533
  color: "cyan"
37502
37534
  }).start();
37503
37535
  }, "onWaiting")
37504
- });
37536
+ }, temporaryToken);
37505
37537
  spinner?.stop();
37506
37538
  saveConfig(config2);
37507
37539
  saveGlobalMcpConfig();
37508
37540
  success(`Logged in as ${teal(config2.user.email || "(unknown)")}`);
37541
+ if (mergedProjectCount && mergedProjectCount > 0) {
37542
+ info(`Added ${mergedProjectCount} temporary project${mergedProjectCount === 1 ? "" : "s"} to ${config2.user.email}.`);
37543
+ }
37509
37544
  success(`Device: ${getDeviceKeyName()}`);
37510
37545
  success(`Access: ${describeScope(scope)}`);
37511
37546
  success("Claude Code MCP configured");
@@ -37517,7 +37552,8 @@ async function runDeviceLogin() {
37517
37552
  error(err.message);
37518
37553
  process.exit(1);
37519
37554
  }
37520
- error(err instanceof Error ? err.message : String(err), err);
37555
+ const message3 = err instanceof Error ? err.message : String(err);
37556
+ error(message3, temporaryToken ? void 0 : err);
37521
37557
  process.exit(1);
37522
37558
  }
37523
37559
  }
@@ -37593,7 +37629,7 @@ import { spawn as spawn2 } from "node:child_process";
37593
37629
  function initInstallSpawnSpec(platform2) {
37594
37630
  return {
37595
37631
  command: platform2 === "win32" ? "npm.cmd" : "npm",
37596
- args: ["install", "--no-audit", "--no-fund"],
37632
+ args: ["install", "--no-audit", "--no-fund", "--omit=optional"],
37597
37633
  shell: platform2 === "win32"
37598
37634
  };
37599
37635
  }
@@ -37814,8 +37850,20 @@ var init_publish_surface = __esm({
37814
37850
  });
37815
37851
 
37816
37852
  // dist/lib/init-scaffold.js
37817
- import { existsSync as existsSync5, lstatSync, mkdirSync as mkdirSync5, readdirSync, writeFileSync as writeFileSync5 } from "node:fs";
37853
+ import { existsSync as existsSync5, lstatSync, mkdirSync as mkdirSync5, readFileSync as readFileSync7, readdirSync, writeFileSync as writeFileSync5 } from "node:fs";
37818
37854
  import { dirname, relative, resolve as resolve3 } from "node:path";
37855
+ function starterNameSlug(name) {
37856
+ return name.toLowerCase().replace(/[^a-z0-9\s-]/g, "").replace(/[\s-]+/g, "-").replace(/^-|-$/g, "");
37857
+ }
37858
+ function readStarterProjectName(dir) {
37859
+ try {
37860
+ const pkg = JSON.parse(readFileSync7(resolve3(dir, "package.json"), "utf8"));
37861
+ const name = pkg?.somewhere?.project_name;
37862
+ return typeof name === "string" ? name.trim() || void 0 : void 0;
37863
+ } catch {
37864
+ return void 0;
37865
+ }
37866
+ }
37819
37867
  function canWriteInitScaffold(dir) {
37820
37868
  if (!existsSync5(dir))
37821
37869
  return true;
@@ -37890,6 +37938,8 @@ var init_init_scaffold = __esm({
37890
37938
  "use strict";
37891
37939
  init_publish_surface();
37892
37940
  PROJECT_LINK_README = "`.somewhere.json` records which Somewhere project this folder deploys to and is safe to commit.";
37941
+ __name(starterNameSlug, "starterNameSlug");
37942
+ __name(readStarterProjectName, "readStarterProjectName");
37893
37943
  INIT_METADATA = /* @__PURE__ */ new Set([
37894
37944
  ".DS_Store",
37895
37945
  ".git",
@@ -37906,7 +37956,7 @@ var init_init_scaffold = __esm({
37906
37956
 
37907
37957
  // dist/lib/skills-pack.js
37908
37958
  import { createHash as createHash2 } from "node:crypto";
37909
- import { existsSync as existsSync6, lstatSync as lstatSync2, mkdirSync as mkdirSync6, readFileSync as readFileSync7, readlinkSync, rmSync, rmdirSync, symlinkSync, writeFileSync as writeFileSync6 } from "node:fs";
37959
+ import { existsSync as existsSync6, lstatSync as lstatSync2, mkdirSync as mkdirSync6, readFileSync as readFileSync8, readlinkSync, rmSync, rmdirSync, symlinkSync, writeFileSync as writeFileSync6 } from "node:fs";
37910
37960
  import { join as join6 } from "node:path";
37911
37961
  function verifyPack(pack) {
37912
37962
  if (!pack || pack.schema !== 1 || pack.name !== "somewhere-skills" || typeof pack.version !== "string" || !Array.isArray(pack.files) || pack.files.length === 0) {
@@ -37940,7 +37990,7 @@ function readLock(dir) {
37940
37990
  return null;
37941
37991
  if (isSymlink(path3))
37942
37992
  throw new Error("Skills lock must not be a symlink.");
37943
- const lock = JSON.parse(readFileSync7(path3, "utf8"));
37993
+ const lock = JSON.parse(readFileSync8(path3, "utf8"));
37944
37994
  if (!lock || lock.pack !== "somewhere-skills" || typeof lock.version !== "string" || !lock.files || typeof lock.files !== "object" || Array.isArray(lock.files) || Object.entries(lock.files).some(([file2, hash2]) => !/^\.agents\/skills\/[a-z0-9][a-z0-9-]*\/SKILL\.md$/.test(file2) || typeof hash2 !== "string" || !/^[a-f0-9]{64}$/.test(hash2))) {
37945
37995
  throw new Error("Skills lock is malformed; nothing was changed.");
37946
37996
  }
@@ -37953,7 +38003,7 @@ function linkForClaude(dir, name) {
37953
38003
  if (existsSync6(at2) || isSymlink(at2)) {
37954
38004
  if (isSymlink(at2) && readlinkSync(at2) === target)
37955
38005
  return "link";
37956
- writeFileSync6(join6(at2, "SKILL.md"), readFileSync7(join6(dir, SKILLS_DIR, name, "SKILL.md")));
38006
+ writeFileSync6(join6(at2, "SKILL.md"), readFileSync8(join6(dir, SKILLS_DIR, name, "SKILL.md")));
37957
38007
  return "copy";
37958
38008
  }
37959
38009
  try {
@@ -37961,7 +38011,7 @@ function linkForClaude(dir, name) {
37961
38011
  return "link";
37962
38012
  } catch {
37963
38013
  mkdirSync6(at2, { recursive: true });
37964
- writeFileSync6(join6(at2, "SKILL.md"), readFileSync7(join6(dir, SKILLS_DIR, name, "SKILL.md")));
38014
+ writeFileSync6(join6(at2, "SKILL.md"), readFileSync8(join6(dir, SKILLS_DIR, name, "SKILL.md")));
37965
38015
  return "copy";
37966
38016
  }
37967
38017
  }
@@ -38047,7 +38097,7 @@ function preflightInstall(dir, pack, previous, state) {
38047
38097
  conflicts.push(claude);
38048
38098
  } else if (existsSync6(claude)) {
38049
38099
  const copy = join6(claude, "SKILL.md");
38050
- if (!owned || isSymlink(copy) || !existsSync6(copy) || sha256(readFileSync7(copy, "utf8")) !== owned)
38100
+ if (!owned || isSymlink(copy) || !existsSync6(copy) || sha256(readFileSync8(copy, "utf8")) !== owned)
38051
38101
  conflicts.push(claude);
38052
38102
  }
38053
38103
  }
@@ -38061,7 +38111,7 @@ function inspectFiles(dir, lock) {
38061
38111
  const full = join6(dir, path3);
38062
38112
  if (!existsSync6(full))
38063
38113
  missing.push(path3);
38064
- else if (sha256(readFileSync7(full, "utf8")) !== hash2)
38114
+ else if (sha256(readFileSync8(full, "utf8")) !== hash2)
38065
38115
  modified.push(path3);
38066
38116
  }
38067
38117
  return { missing, modified };
@@ -38321,6 +38371,8 @@ Keep each run short:
38321
38371
  - Stop at the first failure and print what the page showed (page.url(), the visible error
38322
38372
  text). Checks after a failure only wait out their timeouts. app.check() does both.
38323
38373
  - After a fix, rerun the scripts that failed, each one whole: npx @somewhere-cloud/cli test --failed.
38374
+ The CLI supplies its test helpers when it runs your tests. For the first browser test, install Playwright with npm install -D --save-exact @playwright/test@1.65.0.
38375
+ For a local Vite server, install the frontend tools with npm install --include=optional -D --save-exact vite@7.2.2.
38324
38376
  The test helper, @somewhere-cloud/cli/script (import or require); these are all the calls a test needs:
38325
38377
  const app = await openAppTest(); // the live origin, release and data contract
38326
38378
  const ana = await app.signUp(page); // through your form: { id, email, password, verified }
@@ -38511,13 +38563,13 @@ declare module '*.${ext}' {
38511
38563
  });
38512
38564
 
38513
38565
  // dist/lib/init-green-template.js
38514
- function createGreenTemplate() {
38566
+ function createGreenTemplate(appName = "somewhere-starter") {
38515
38567
  return [
38516
38568
  { path: ".gitignore", content: buildScaffoldGitignore() },
38517
38569
  { path: "AGENTS.md", content: INIT_AGENTS_MD },
38518
38570
  { path: "CLAUDE.md", content: INIT_CLAUDE_MD },
38519
38571
  { path: "README.md", content: README },
38520
- { path: "package.json", content: PACKAGE_JSON },
38572
+ { path: "package.json", content: packageJson(appName) },
38521
38573
  { path: "tsconfig.json", content: TSCONFIG },
38522
38574
  {
38523
38575
  path: "index.html",
@@ -38534,7 +38586,7 @@ function createGreenTemplate() {
38534
38586
  ASSET_TYPES_FILE
38535
38587
  ];
38536
38588
  }
38537
- var PACKAGE_JSON, TSCONFIG, APP_TYPES, SCHEMA, API, SERVICE, APP, MAIN, STYLES, README;
38589
+ var packageJson, TSCONFIG, APP_TYPES, SCHEMA, API, SERVICE, APP, MAIN, STYLES, README;
38538
38590
  var init_init_green_template = __esm({
38539
38591
  "dist/lib/init-green-template.js"() {
38540
38592
  "use strict";
@@ -38543,32 +38595,32 @@ var init_init_green_template = __esm({
38543
38595
  init_init_scaffold();
38544
38596
  init_init_agent_guide();
38545
38597
  init_init_asset_types();
38546
- PACKAGE_JSON = `{
38547
- "name": "somewhere-starter",
38598
+ packageJson = /* @__PURE__ */ __name((appName) => `{
38599
+ "name": ${JSON.stringify(starterNameSlug(appName).slice(0, 214) || "somewhere-starter")},
38548
38600
  "private": true,
38549
38601
  "version": "0.1.0",
38550
38602
  "type": "module",
38603
+ "somewhere": { "cli_version": "${CLI_VERSION}", "project_name": ${JSON.stringify(appName)} },
38551
38604
  "scripts": {
38552
- "dev": "somewhere dev",
38553
- "typecheck": "somewhere typecheck"
38605
+ "dev": "npx -y @somewhere-cloud/cli dev",
38606
+ "typecheck": "npx -y @somewhere-cloud/cli typecheck"
38554
38607
  },
38555
38608
  "dependencies": {
38556
- "@somewhere-cloud/sdk": "0.14.2",
38609
+ "@somewhere-cloud/sdk": "0.14.2"
38610
+ },
38611
+ "optionalDependencies": {
38557
38612
  "react": "19.2.7",
38558
38613
  "react-dom": "19.2.7"
38559
38614
  },
38560
38615
  "devDependencies": {
38561
- "@somewhere-cloud/cli": "${CLI_VERSION}",
38562
38616
  "@types/react": "19.2.2",
38563
- "@types/react-dom": "19.2.2",
38564
- "typescript": "5.9.3",
38565
- "vite": "7.2.2"
38617
+ "@types/react-dom": "19.2.2"
38566
38618
  },
38567
38619
  "allowScripts": {
38568
38620
  "esbuild": true
38569
38621
  }
38570
38622
  }
38571
- `;
38623
+ `, "packageJson");
38572
38624
  TSCONFIG = `{
38573
38625
  "compilerOptions": {
38574
38626
  "target": "ES2022",
@@ -40780,13 +40832,13 @@ var require_semver2 = __commonJS({
40780
40832
  });
40781
40833
 
40782
40834
  // dist/lib/project-pin.js
40783
- import { existsSync as existsSync7, readFileSync as readFileSync8, writeFileSync as writeFileSync7 } from "node:fs";
40784
- import { join as join7 } from "node:path";
40835
+ import { existsSync as existsSync7, readFileSync as readFileSync9, writeFileSync as writeFileSync7 } from "node:fs";
40836
+ import { dirname as dirname2, join as join7 } from "node:path";
40785
40837
  function readJson(path3) {
40786
40838
  if (!existsSync7(path3))
40787
40839
  return null;
40788
40840
  try {
40789
- const value = JSON.parse(readFileSync8(path3, "utf8"));
40841
+ const value = JSON.parse(readFileSync9(path3, "utf8"));
40790
40842
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
40791
40843
  } catch {
40792
40844
  return null;
@@ -40805,7 +40857,13 @@ function packageJsonSpec(pkg) {
40805
40857
  }
40806
40858
  function readProjectPins(dir) {
40807
40859
  const pins = [];
40808
- const fromPackage = packageJsonSpec(readJson(join7(dir, "package.json")));
40860
+ const pkg = readJson(join7(dir, "package.json"));
40861
+ const settings = pkg?.somewhere;
40862
+ const fromSettings = settings && typeof settings === "object" && !Array.isArray(settings) ? settings[PIN_FILE_KEY] : void 0;
40863
+ if (typeof fromSettings === "string" && fromSettings.trim()) {
40864
+ pins.push({ spec: fromSettings.trim(), source: "package.json", versionOnly: true });
40865
+ }
40866
+ const fromPackage = packageJsonSpec(pkg);
40809
40867
  if (fromPackage)
40810
40868
  pins.push({ spec: fromPackage, source: "package.json" });
40811
40869
  const recorded = readJson(join7(dir, ".somewhere.json"))?.[PIN_FILE_KEY];
@@ -40843,7 +40901,7 @@ function pinNotice(pin, running, delegatedTo) {
40843
40901
  if (newer)
40844
40902
  return `${head}; you are running ${running}. ${move}`;
40845
40903
  const exact = import_semver.default.valid(pin.spec) ? pin.spec : import_semver.default.minVersion(pin.spec)?.version ?? pin.spec;
40846
- return `${head}; you are running ${running}, which is older. ` + (pin.source === "package.json" ? "Run `npm install` here, or use " : "Use ") + `\`npx -y ${CLI_PACKAGE_NAME}@${exact} <command>\`.`;
40904
+ return `${head}; you are running ${running}, which is older. ` + (pin.source === "package.json" && !pin.versionOnly ? "Run `npm install` here, or use " : "Use ") + `\`npx -y ${CLI_PACKAGE_NAME}@${exact} <command>\`.`;
40847
40905
  }
40848
40906
  function decidePin(dir, running, argv, env) {
40849
40907
  const none = { notice: null, delegate: null };
@@ -40852,7 +40910,21 @@ function decidePin(dir, running, argv, env) {
40852
40910
  const pin = readProjectPin(dir);
40853
40911
  if (!pin || pinSatisfied(pin, running))
40854
40912
  return none;
40913
+ if (argv[2] === "login" && loadConfig()?.temporary)
40914
+ return none;
40855
40915
  const installed = installedPinnedCli(dir, pin, running);
40916
+ if (pin.versionOnly) {
40917
+ if (installed)
40918
+ return { notice: pinNotice(pin, running, installed.version), delegate: installed.bin };
40919
+ const version2 = import_semver.default.valid(pin.spec);
40920
+ if (version2) {
40921
+ return {
40922
+ notice: `This project is pinned to somewhere CLI ${version2}. Running it through npm\u2019s cache. Run \`${cliInvocation()} upgrade\` to move the pin.`,
40923
+ delegate: null,
40924
+ delegateVersion: version2
40925
+ };
40926
+ }
40927
+ }
40856
40928
  if (argv[2] === "deploy" && installed && import_semver.default.valid(running) && import_semver.default.lt(installed.version, running)) {
40857
40929
  return {
40858
40930
  notice: `This project is pinned to somewhere CLI ${pin.spec} (${pin.source}); deploy is using the running CLI ${running}.`,
@@ -40861,13 +40933,24 @@ function decidePin(dir, running, argv, env) {
40861
40933
  }
40862
40934
  return { notice: pinNotice(pin, running, installed?.version ?? null), delegate: installed?.bin ?? null };
40863
40935
  }
40936
+ function pinnedNpx(version2) {
40937
+ const args = ["--yes", "--prefer-offline", "--ignore-scripts", `${CLI_PACKAGE_NAME}@${version2}`];
40938
+ if (process.platform !== "win32")
40939
+ return { command: "npx", args };
40940
+ const besideNode = join7(dirname2(process.execPath), "node_modules", "npm", "bin", "npx-cli.js");
40941
+ const besideNpm = process.env.npm_execpath?.endsWith("npm-cli.js") ? join7(dirname2(process.env.npm_execpath), "npx-cli.js") : besideNode;
40942
+ const entry = [besideNpm, besideNode].find((path3) => existsSync7(path3));
40943
+ return entry ? { command: process.execPath, args: [entry, ...args] } : null;
40944
+ }
40864
40945
  function writeProjectPins(dir, pins, version2) {
40865
40946
  const written = [];
40866
40947
  for (const pin of pins) {
40867
40948
  const path3 = join7(dir, pin.source);
40868
- const raw = readFileSync8(path3, "utf8");
40949
+ const raw = readFileSync9(path3, "utf8");
40869
40950
  const json2 = JSON.parse(raw);
40870
- if (pin.source === "package.json") {
40951
+ if (pin.versionOnly) {
40952
+ json2.somewhere[PIN_FILE_KEY] = version2;
40953
+ } else if (pin.source === "package.json") {
40871
40954
  for (const section of ["devDependencies", "dependencies"]) {
40872
40955
  const deps = json2[section];
40873
40956
  if (deps && typeof deps === "object" && typeof deps[CLI_PACKAGE_NAME] === "string")
@@ -40878,7 +40961,8 @@ function writeProjectPins(dir, pins, version2) {
40878
40961
  }
40879
40962
  const indent = /^\{\s*\n(\s+)/.exec(raw)?.[1] ?? " ";
40880
40963
  writeFileSync7(path3, JSON.stringify(json2, null, indent) + "\n");
40881
- written.push(pin.source);
40964
+ if (!written.includes(pin.source))
40965
+ written.push(pin.source);
40882
40966
  }
40883
40967
  return written;
40884
40968
  }
@@ -40894,7 +40978,7 @@ function recordPinIfMissing(dir, version2) {
40894
40978
  return true;
40895
40979
  }
40896
40980
  function readBundledChangelog() {
40897
- return readFileSync8(join7(CLI_PACKAGE_ROOT, "CHANGELOG.md"), "utf8");
40981
+ return readFileSync9(join7(CLI_PACKAGE_ROOT, "CHANGELOG.md"), "utf8");
40898
40982
  }
40899
40983
  function changelogBetween(markdown, from, to2) {
40900
40984
  const entries = [];
@@ -40916,6 +41000,7 @@ var init_project_pin = __esm({
40916
41000
  "use strict";
40917
41001
  init_package_root();
40918
41002
  init_cli_invocation();
41003
+ init_config();
40919
41004
  import_semver = __toESM(require_semver2(), 1);
40920
41005
  CLI_PACKAGE_NAME = "@somewhere-cloud/cli";
40921
41006
  PIN_FILE_KEY = "cli_version";
@@ -40929,6 +41014,7 @@ var init_project_pin = __esm({
40929
41014
  PIN_EXEMPT = /* @__PURE__ */ new Set(["upgrade", "update", "init", "--version", "-V"]);
40930
41015
  PINNED_CHILD_ENV = "SOMEWHERE_PINNED_CLI";
40931
41016
  __name(decidePin, "decidePin");
41017
+ __name(pinnedNpx, "pinnedNpx");
40932
41018
  __name(writeProjectPins, "writeProjectPins");
40933
41019
  __name(recordPinIfMissing, "recordPinIfMissing");
40934
41020
  __name(readBundledChangelog, "readBundledChangelog");
@@ -42819,7 +42905,7 @@ Rerun only to answer a question. A pass means the checks you wrote passed; say w
42819
42905
  After edits:`) },
42820
42906
  { path: "CLAUDE.md", content: INIT_CLAUDE_MD },
42821
42907
  { path: "README.md", content: readme(selection) },
42822
- { path: "package.json", content: PACKAGE_JSON2 },
42908
+ { path: "package.json", content: packageJson2(options2.appName) },
42823
42909
  { path: "tsconfig.json", content: TSCONFIG2 },
42824
42910
  { path: "index.html", content: indexHtml(options2.appName) },
42825
42911
  { path: "api/auth/[...path].ts", content: AUTH_API },
@@ -42870,7 +42956,7 @@ After edits:`) },
42870
42956
  }
42871
42957
  return files;
42872
42958
  }
42873
- var PACKAGE_JSON2, TSCONFIG2, AUTH_API, AUTH_TYPES, PROVIDER_SIGN_IN_HOOK, AUTH_CALLBACK_PAGE, AUTH_SERVICE, AUTH_HOOKS, ROUTES, APP2, SCHEMA2, NOTES_TYPES, NOTES_SERVICE, USE_NOTES, AGENT_TABLES, AGENT_SCHEMA_NOTE, CHAT_API, PROPOSALS_API, ASSISTANT_TYPES, ASSISTANT_SERVICE, USE_ASSISTANT, ASSISTANT_FIXTURES, ASSISTANT_FIXTURES_PAGE, ASSISTANT_FIXTURES_FLOW, STYLED_ASSISTANT_PANEL, PLAIN_ASSISTANT_PANEL, MFA_HOOK, MFA_VIEW, SIGN_IN_PAGE, SIGNED_IN_LAYOUT, NOTE_DETAIL_PAGE, DETAIL_PAGE, NOT_FOUND_PAGE, STYLED_FEEDBACK, STYLED_APP_SHELL, STYLED_NOTES_BOARD, PLAIN_FEEDBACK, PLAIN_APP_SHELL, PLAIN_NOTES_BOARD, NOTES_CSS, ASSISTANT_CSS, MAGIC_LINK_TYPES, MAGIC_LINK_HOOKS, CONNECTION_RETURN, MAGIC_LINK_PAGE, MAGIC_SIGN_IN_PAGE, STYLED_MAGIC_LINK, PLAIN_MAGIC_LINK, FORGOT_PASSWORD_API, RESET_PASSWORD_API, PASSWORD_RESET_PAGE, VERIFY_EMAIL_HOOK, PLAIN_VERIFY_EMAIL;
42959
+ var packageJson2, TSCONFIG2, AUTH_API, AUTH_TYPES, PROVIDER_SIGN_IN_HOOK, AUTH_CALLBACK_PAGE, AUTH_SERVICE, AUTH_HOOKS, ROUTES, APP2, SCHEMA2, NOTES_TYPES, NOTES_SERVICE, USE_NOTES, AGENT_TABLES, AGENT_SCHEMA_NOTE, CHAT_API, PROPOSALS_API, ASSISTANT_TYPES, ASSISTANT_SERVICE, USE_ASSISTANT, ASSISTANT_FIXTURES, ASSISTANT_FIXTURES_PAGE, ASSISTANT_FIXTURES_FLOW, STYLED_ASSISTANT_PANEL, PLAIN_ASSISTANT_PANEL, MFA_HOOK, MFA_VIEW, SIGN_IN_PAGE, SIGNED_IN_LAYOUT, NOTE_DETAIL_PAGE, DETAIL_PAGE, NOT_FOUND_PAGE, STYLED_FEEDBACK, STYLED_APP_SHELL, STYLED_NOTES_BOARD, PLAIN_FEEDBACK, PLAIN_APP_SHELL, PLAIN_NOTES_BOARD, NOTES_CSS, ASSISTANT_CSS, MAGIC_LINK_TYPES, MAGIC_LINK_HOOKS, CONNECTION_RETURN, MAGIC_LINK_PAGE, MAGIC_SIGN_IN_PAGE, STYLED_MAGIC_LINK, PLAIN_MAGIC_LINK, FORGOT_PASSWORD_API, RESET_PASSWORD_API, PASSWORD_RESET_PAGE, VERIFY_EMAIL_HOOK, PLAIN_VERIFY_EMAIL;
42874
42960
  var init_init_feature_template = __esm({
42875
42961
  "dist/lib/init-feature-template.js"() {
42876
42962
  "use strict";
@@ -42882,33 +42968,32 @@ var init_init_feature_template = __esm({
42882
42968
  init_init_scaffold();
42883
42969
  init_init_agent_guide();
42884
42970
  init_init_ui_kit();
42885
- PACKAGE_JSON2 = `{
42886
- "name": "somewhere-app",
42971
+ packageJson2 = /* @__PURE__ */ __name((appName) => `{
42972
+ "name": ${JSON.stringify(starterNameSlug(appName).slice(0, 214) || "somewhere-app")},
42887
42973
  "private": true,
42888
42974
  "version": "0.1.0",
42889
42975
  "type": "module",
42976
+ "somewhere": { "cli_version": "${CLI_VERSION}", "project_name": ${JSON.stringify(appName)} },
42890
42977
  "scripts": {
42891
- "dev": "somewhere dev",
42892
- "typecheck": "somewhere typecheck"
42978
+ "dev": "npx -y @somewhere-cloud/cli dev",
42979
+ "typecheck": "npx -y @somewhere-cloud/cli typecheck"
42893
42980
  },
42894
42981
  "dependencies": {
42895
- "@somewhere-cloud/sdk": "0.14.2",
42982
+ "@somewhere-cloud/sdk": "0.14.2"
42983
+ },
42984
+ "optionalDependencies": {
42896
42985
  "react": "19.2.7",
42897
42986
  "react-dom": "19.2.7"
42898
42987
  },
42899
42988
  "devDependencies": {
42900
- "@somewhere-cloud/cli": "${CLI_VERSION}",
42901
- "@playwright/test": "1.65.0",
42902
42989
  "@types/react": "19.2.2",
42903
- "@types/react-dom": "19.2.2",
42904
- "typescript": "5.9.3",
42905
- "vite": "7.2.2"
42990
+ "@types/react-dom": "19.2.2"
42906
42991
  },
42907
42992
  "allowScripts": {
42908
42993
  "esbuild": true
42909
42994
  }
42910
42995
  }
42911
- `;
42996
+ `, "packageJson");
42912
42997
  TSCONFIG2 = `{
42913
42998
  "compilerOptions": {
42914
42999
  "target": "ES2022",
@@ -45959,7 +46044,7 @@ __export(init_exports, {
45959
46044
  import { basename, join as join8 } from "node:path";
45960
46045
  import { existsSync as existsSync8 } from "node:fs";
45961
46046
  function registerInit(program2) {
45962
- program2.command("init").description("Write a starter app with a generated AGENTS.md guide").option("--name <name>", "Project name (skip prompt); sign-in and invitation emails show it").option("--subdomain <slug>", "Subdomain for the new project; default: derived from --name").option("--link", "Scaffold an empty directory and link an existing project; non-empty directories are link-only").option("--project <ref>", "Existing project ID, name, slug, or subdomain (requires --link)").option("--bare", "Create and link only: no starter source or dependencies (AGENTS.md/CLAUDE.md are still added when absent)").option("--template <name>", "Starter to write: auth (default, cookie sign-in) or minimal (auth route, no sign-in UI)", "auth").option("--features <ids>", "Generate selected modules into an empty directory, comma-separated: auth, magic-link, private-data, agent (see --catalog)").option("--ui <mode>", "With --features: styled (default; src/ui + design tokens) or headless (hooks and plain markup)").option("--catalog", "Print the module catalog for --features and exit; no login, project or files").option("--dry-run", "With --features: validate the selection and print the file plan; nothing is created").option("--json", "Print the created or linked project as JSON").addHelpText("after", `
46047
+ program2.command("init").description("Write a starter app with a generated AGENTS.md guide").option("--name <name>", "Project name (skip prompt); sign-in and invitation emails show it").option("--subdomain <slug>", "Subdomain for the new project; default: derived from --name").option("--link", "Scaffold an empty directory and link an existing project; non-empty directories are link-only").option("--project <ref>", "Existing project ID, name, slug, or subdomain (requires --link)").option("--bare", "Create and link only: no starter source or dependencies (AGENTS.md/CLAUDE.md are still added when absent)").option("--template <name>", "Starter to write: auth (default), minimal (auth route, no sign-in UI), or bare (link only)", "auth").option("--features <ids>", "Generate selected modules into an empty directory, comma-separated: auth, magic-link, private-data, agent (see --catalog)").option("--ui <mode>", "With --features: styled (default; src/ui + design tokens) or headless (hooks and plain markup)").option("--catalog", "Print the module catalog for --features and exit; no login, project or files").option("--dry-run", "With --features: validate the selection and print the file plan; nothing is created").option("--json", "Print the created or linked project as JSON").addHelpText("after", `
45963
46048
  ${FIRST_CLI_PERMISSION}
45964
46049
 
45965
46050
  Recommended for a new app: run \`${cliInvocation()} init\` in an empty directory.
@@ -45970,7 +46055,8 @@ replaceable views in src/ui/ and styles in src/styles/, plus an AGENTS.md workfl
45970
46055
  (deploy, then test). Sign-in and invitation links (sw.auth.invite) open
45971
46056
  /auth/magic, which the starter routes before the sign-in gate.
45972
46057
  \`--template minimal\` includes the SDK and auth route without sign-in screens.
45973
- Init installs the starter's pinned dependencies with npm install (downloads from npm and runs package install scripts).
46058
+ Init installs the SDK and editor types. The platform builds React when you deploy. Install the runtime for local development.
46059
+ TypeScript is fetched when first needed. Vite and Playwright are installed only if you choose to use them.
45974
46060
  New starters and --bare also install ${skillNames(BUNDLED_SKILLS_PACK).length} agent skills in .agents/skills, pinned by skills-lock.json.
45975
46061
 
45976
46062
  A directory that already holds an app (package.json, index.html, src/, \u2026) is
@@ -45989,6 +46075,8 @@ writes into an empty directory and is checked before the project is created.
45989
46075
  }
45990
46076
  async function runInit(opts, command) {
45991
46077
  const dir = process.cwd();
46078
+ if (opts.template === "bare")
46079
+ opts = { ...opts, bare: true };
45992
46080
  let plan;
45993
46081
  try {
45994
46082
  if (opts.catalog) {
@@ -46056,7 +46144,7 @@ async function runInit(opts, command) {
46056
46144
  process.exit(2);
46057
46145
  }
46058
46146
  }
46059
- const scaffoldFiles = /* @__PURE__ */ __name((projectName) => template === "minimal" && !plan ? createGreenTemplate() : createFeatureTemplate(plan?.selection ?? DEFAULT_AUTH_SELECTION, { appName: projectName }), "scaffoldFiles");
46147
+ const scaffoldFiles = /* @__PURE__ */ __name((projectName) => template === "minimal" && !plan ? createGreenTemplate(projectName) : createFeatureTemplate(plan?.selection ?? DEFAULT_AUTH_SELECTION, { appName: projectName }), "scaffoldFiles");
46060
46148
  const storedConfig = loadConfig();
46061
46149
  if (!hasUsableCredential(storedConfig) && !opts.link && !opts.bare) {
46062
46150
  const expiredTemporaryAt = temporaryConfigExpired(storedConfig) ? storedConfig.temp_expires_at : void 0;
@@ -46421,7 +46509,7 @@ var init_init = __esm({
46421
46509
  init_next_actions();
46422
46510
  init_output();
46423
46511
  INSTALL_STARTER_MESSAGE = "Installing the starter's pinned dependencies with `npm install` (downloads from npm and runs package install scripts)\u2026";
46424
- INIT_TEMPLATES = ["auth", "minimal"];
46512
+ INIT_TEMPLATES = ["auth", "minimal", "bare"];
46425
46513
  DEFAULT_AUTH_SELECTION = { requested: ["auth", "private-data"], added: [], modules: ["auth", "private-data"], ui: "styled" };
46426
46514
  __name(registerInit, "registerInit");
46427
46515
  __name(runInit, "runInit");
@@ -72039,7 +72127,7 @@ var init_privacy = __esm({
72039
72127
  });
72040
72128
 
72041
72129
  // dist/lib/role-method-hints.js
72042
- import { existsSync as existsSync9, readdirSync as readdirSync2, readFileSync as readFileSync9 } from "node:fs";
72130
+ import { existsSync as existsSync9, readdirSync as readdirSync2, readFileSync as readFileSync10 } from "node:fs";
72043
72131
  import { createRequire as createRequire2 } from "node:module";
72044
72132
  import { join as join9, relative as relative2, resolve as resolve4 } from "node:path";
72045
72133
  function roleMethodHints(projectDir, { removedOnly = false } = {}) {
@@ -72078,7 +72166,7 @@ function roleMethodHints(projectDir, { removedOnly = false } = {}) {
72078
72166
  }
72079
72167
  if (!entry.isFile() || !/\.[cm]?[jt]sx?$/.test(entry.name) || /\.d\.ts$/.test(entry.name))
72080
72168
  continue;
72081
- const file2 = ts2.createSourceFile(path3, readFileSync9(path3, "utf8"), ts2.ScriptTarget.Latest, true);
72169
+ const file2 = ts2.createSourceFile(path3, readFileSync10(path3, "utf8"), ts2.ScriptTarget.Latest, true);
72082
72170
  const exports = /* @__PURE__ */ new Set();
72083
72171
  let unknown2 = false;
72084
72172
  for (const statement of file2.statements) {
@@ -72136,8 +72224,8 @@ var init_role_method_hints = __esm({
72136
72224
  });
72137
72225
 
72138
72226
  // dist/lib/notify/providers/update.js
72139
- import { existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync8 } from "node:fs";
72140
- import { dirname as dirname2, join as join10 } from "node:path";
72227
+ import { existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync11, writeFileSync as writeFileSync8 } from "node:fs";
72228
+ import { dirname as dirname3, join as join10 } from "node:path";
72141
72229
  function isNewer(a, b2) {
72142
72230
  const parse3 = /* @__PURE__ */ __name((v2) => v2.split("-")[0].split(".").map((n) => Number(n)), "parse");
72143
72231
  const pa = parse3(a);
@@ -72152,7 +72240,7 @@ function isNewer(a, b2) {
72152
72240
  }
72153
72241
  function readCache(cachePath = CACHE_PATH) {
72154
72242
  try {
72155
- const c = JSON.parse(readFileSync10(cachePath, "utf8"));
72243
+ const c = JSON.parse(readFileSync11(cachePath, "utf8"));
72156
72244
  if (typeof c?.checkedAt !== "number")
72157
72245
  return null;
72158
72246
  return c;
@@ -72162,7 +72250,7 @@ function readCache(cachePath = CACHE_PATH) {
72162
72250
  }
72163
72251
  function writeCache(latest, checkedAt, cachePath = CACHE_PATH) {
72164
72252
  try {
72165
- const dir = dirname2(cachePath);
72253
+ const dir = dirname3(cachePath);
72166
72254
  if (!existsSync10(dir))
72167
72255
  mkdirSync7(dir, { recursive: true });
72168
72256
  writeFileSync8(cachePath, JSON.stringify({ checkedAt, latest }) + "\n", { mode: 384 });
@@ -72215,7 +72303,7 @@ async function getOutdatedWarning(currentVersion3, options2 = {}) {
72215
72303
  const warnedPath = options2.warnedPath ?? WARNED_PATH;
72216
72304
  const now2 = (options2.now ?? Date.now)();
72217
72305
  try {
72218
- const warned2 = JSON.parse(readFileSync10(warnedPath, "utf8"));
72306
+ const warned2 = JSON.parse(readFileSync11(warnedPath, "utf8"));
72219
72307
  if (typeof warned2.warnedAt === "number" && now2 - warned2.warnedAt < ONE_DAY && now2 >= warned2.warnedAt)
72220
72308
  return null;
72221
72309
  } catch {
@@ -72224,7 +72312,7 @@ async function getOutdatedWarning(currentVersion3, options2 = {}) {
72224
72312
  if (!latest || !isMinorBehind(currentVersion3, latest))
72225
72313
  return null;
72226
72314
  try {
72227
- const dir = dirname2(warnedPath);
72315
+ const dir = dirname3(warnedPath);
72228
72316
  if (!existsSync10(dir))
72229
72317
  mkdirSync7(dir, { recursive: true });
72230
72318
  writeFileSync8(warnedPath, JSON.stringify({ warnedAt: now2 }) + "\n", { mode: 384 });
@@ -72287,7 +72375,7 @@ var init_update = __esm({
72287
72375
  });
72288
72376
 
72289
72377
  // dist/lib/notify/index.js
72290
- import { readFileSync as readFileSync11 } from "node:fs";
72378
+ import { readFileSync as readFileSync12 } from "node:fs";
72291
72379
  import { join as join11 } from "node:path";
72292
72380
  function suppressExitNotices() {
72293
72381
  exitNoticesSuppressed = true;
@@ -72302,7 +72390,7 @@ function subcommandSuppressesNotifications(argv) {
72302
72390
  }
72303
72391
  function currentVersion() {
72304
72392
  try {
72305
- const pkg = JSON.parse(readFileSync11(join11(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
72393
+ const pkg = JSON.parse(readFileSync12(join11(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
72306
72394
  return pkg.version;
72307
72395
  } catch {
72308
72396
  return "0.0.0";
@@ -72364,11 +72452,11 @@ __export(declared_data_exports, {
72364
72452
  declaredDataPlugin: () => declaredDataPlugin,
72365
72453
  prepareDeclaredData: () => prepareDeclaredData
72366
72454
  });
72367
- import { existsSync as existsSync11, readFileSync as readFileSync12, rmSync as rmSync2, writeFileSync as writeFileSync9 } from "node:fs";
72455
+ import { existsSync as existsSync11, readFileSync as readFileSync13, rmSync as rmSync2, writeFileSync as writeFileSync9 } from "node:fs";
72368
72456
  import { createRequire as createRequire3 } from "node:module";
72369
72457
  import { join as join12, resolve as resolve5 } from "node:path";
72370
72458
  function generatedContents(path3) {
72371
- const previous = existsSync11(path3) ? readFileSync12(path3, "utf8") : void 0;
72459
+ const previous = existsSync11(path3) ? readFileSync13(path3, "utf8") : void 0;
72372
72460
  if (previous !== void 0 && !previous.startsWith(GENERATED_DATA_HEADER)) {
72373
72461
  throw new Error(`Cannot overwrite ${path3}; this path is reserved for a generated declaration.`);
72374
72462
  }
@@ -72379,8 +72467,8 @@ function prepareDeclaredData(projectDir) {
72379
72467
  const declarationDir = existsSync11(join12(projectDir, "src")) ? join12(projectDir, "src") : projectDir;
72380
72468
  const declarationPath = join12(declarationDir, DATA_DECLARATION_FILE);
72381
72469
  const filesPath = join12(declarationDir, FILES_DECLARATION_FILE);
72382
- const previous = existsSync11(declarationPath) ? readFileSync12(declarationPath, "utf8") : void 0;
72383
- const previousFiles = existsSync11(filesPath) ? readFileSync12(filesPath, "utf8") : void 0;
72470
+ const previous = existsSync11(declarationPath) ? readFileSync13(declarationPath, "utf8") : void 0;
72471
+ const previousFiles = existsSync11(filesPath) ? readFileSync13(filesPath, "utf8") : void 0;
72384
72472
  if (!existsSync11(schemaPath)) {
72385
72473
  if (previousFiles?.startsWith(GENERATED_DATA_HEADER))
72386
72474
  rmSync2(filesPath);
@@ -72401,7 +72489,7 @@ function prepareDeclaredData(projectDir) {
72401
72489
  let filesDeclaration;
72402
72490
  const generator = require3("./runtime/declared-data.cjs");
72403
72491
  try {
72404
- const files = { "db/schema.ts": readFileSync12(schemaPath, "utf8") };
72492
+ const files = { "db/schema.ts": readFileSync13(schemaPath, "utf8") };
72405
72493
  client = generator.generateFromFiles(files);
72406
72494
  localDeclaration = generator.localDeclarationFromFiles(files);
72407
72495
  tables = generator.declaredTablesFromFiles(files);
@@ -72531,9 +72619,9 @@ __export(typecheck_exports, {
72531
72619
  typecheckTimeoutMs: () => typecheckTimeoutMs
72532
72620
  });
72533
72621
  import { spawn as spawn3, spawnSync } from "node:child_process";
72534
- import { existsSync as existsSync12, readFileSync as readFileSync13, rmSync as rmSync3, writeFileSync as writeFileSync10 } from "node:fs";
72622
+ import { existsSync as existsSync12, readFileSync as readFileSync14, rmSync as rmSync3, writeFileSync as writeFileSync10 } from "node:fs";
72535
72623
  import { randomUUID as randomUUID4 } from "node:crypto";
72536
- import { dirname as dirname3, join as join13, relative as relative3 } from "node:path";
72624
+ import { dirname as dirname4, join as join13, relative as relative3 } from "node:path";
72537
72625
  function isUnresolvedBareImport(e) {
72538
72626
  if (!UNRESOLVED_DEP_CODES.has(e.code))
72539
72627
  return false;
@@ -72571,7 +72659,7 @@ function resolveTsc(projectDir) {
72571
72659
  function declaredDependencies(projectDir) {
72572
72660
  let manifest;
72573
72661
  try {
72574
- manifest = JSON.parse(readFileSync13(join13(projectDir, "package.json"), "utf8"));
72662
+ manifest = JSON.parse(readFileSync14(join13(projectDir, "package.json"), "utf8"));
72575
72663
  } catch {
72576
72664
  return {};
72577
72665
  }
@@ -72596,10 +72684,10 @@ function declaredDependencies(projectDir) {
72596
72684
  return declared;
72597
72685
  }
72598
72686
  function dependencyInstalled(projectDir, name) {
72599
- for (let dir = projectDir; ; dir = dirname3(dir)) {
72687
+ for (let dir = projectDir; ; dir = dirname4(dir)) {
72600
72688
  if (existsSync12(join13(dir, "node_modules", name, "package.json")))
72601
72689
  return true;
72602
- if (dirname3(dir) === dir)
72690
+ if (dirname4(dir) === dir)
72603
72691
  return false;
72604
72692
  }
72605
72693
  }
@@ -73675,9 +73763,9 @@ var init_handler = __esm({
73675
73763
  if (this.fsw.closed) {
73676
73764
  return;
73677
73765
  }
73678
- const dirname15 = sysPath.dirname(file2);
73766
+ const dirname16 = sysPath.dirname(file2);
73679
73767
  const basename11 = sysPath.basename(file2);
73680
- const parent = this.fsw._getWatchedDir(dirname15);
73768
+ const parent = this.fsw._getWatchedDir(dirname16);
73681
73769
  let prevStats = stats;
73682
73770
  if (parent.has(basename11))
73683
73771
  return;
@@ -73704,7 +73792,7 @@ var init_handler = __esm({
73704
73792
  prevStats = newStats2;
73705
73793
  }
73706
73794
  } catch (error3) {
73707
- this.fsw._remove(dirname15, basename11);
73795
+ this.fsw._remove(dirname16, basename11);
73708
73796
  }
73709
73797
  } else if (parent.has(basename11)) {
73710
73798
  const at2 = newStats.atimeMs;
@@ -74778,7 +74866,7 @@ __export(files_exports, {
74778
74866
  testExclusionReason: () => testExclusionReason,
74779
74867
  testFolderOf: () => testFolderOf
74780
74868
  });
74781
- import { existsSync as existsSync13, readdirSync as readdirSync3, readFileSync as readFileSync14, statSync as statSync2 } from "node:fs";
74869
+ import { existsSync as existsSync13, readdirSync as readdirSync3, readFileSync as readFileSync15, statSync as statSync2 } from "node:fs";
74782
74870
  import { extname as extname3, isAbsolute as isAbsolute2, join as join16, relative as relative6 } from "node:path";
74783
74871
  function isTestSourcePath(relPath) {
74784
74872
  return TEST_SOURCE_NAME.test(relPath.slice(relPath.lastIndexOf("/") + 1));
@@ -74848,7 +74936,7 @@ function collectFiles(baseDir, options2 = {}) {
74848
74936
  }
74849
74937
  const corpusFiles = /* @__PURE__ */ __name((paths) => paths.filter((relPath) => isReferenceCorpusPath(relPath) && (sizes.get(relPath) ?? 0) <= MAX_FILE_SIZE).map((relPath) => {
74850
74938
  try {
74851
- return [relPath, readFileSync14(join16(baseDir, relPath), "utf-8")];
74939
+ return [relPath, readFileSync15(join16(baseDir, relPath), "utf-8")];
74852
74940
  } catch {
74853
74941
  return [relPath, ""];
74854
74942
  }
@@ -74927,7 +75015,7 @@ function walk(baseDir, currentDir, out, ignore, candidates, sizes) {
74927
75015
  out.sensitive.push({ path: relPath, reason: SENSITIVE_FILE_REASON, referencedBy: [] });
74928
75016
  continue;
74929
75017
  }
74930
- if ((entry.name === DATA_DECLARATION_FILE || entry.name === FILES_DECLARATION_FILE) && readFileSync14(fullPath, "utf8").startsWith(GENERATED_DATA_HEADER))
75018
+ if ((entry.name === DATA_DECLARATION_FILE || entry.name === FILES_DECLARATION_FILE) && readFileSync15(fullPath, "utf8").startsWith(GENERATED_DATA_HEADER))
74931
75019
  continue;
74932
75020
  sizes.set(relPath, statSync2(fullPath).size);
74933
75021
  candidates.push(relPath);
@@ -74951,11 +75039,11 @@ function classifyInto(out, baseDir, relPath, readBinary = true) {
74951
75039
  const fullPath = join16(baseDir, relPath);
74952
75040
  const { kind, key } = classifyKey(relPath);
74953
75041
  if (kind === "function") {
74954
- out.functions[key] = readFileSync14(fullPath, "utf-8");
75042
+ out.functions[key] = readFileSync15(fullPath, "utf-8");
74955
75043
  } else if (kind === "binary") {
74956
- out.binaryFiles[key] = readBinary ? readFileSync14(fullPath).toString("base64") : "";
75044
+ out.binaryFiles[key] = readBinary ? readFileSync15(fullPath).toString("base64") : "";
74957
75045
  } else {
74958
- out.files[key] = readFileSync14(fullPath, "utf-8");
75046
+ out.files[key] = readFileSync15(fullPath, "utf-8");
74959
75047
  }
74960
75048
  }
74961
75049
  function formatBytes(bytes) {
@@ -74975,7 +75063,7 @@ function loadDeployIgnore(baseDir) {
74975
75063
  const path3 = join16(baseDir, fileName2);
74976
75064
  if (!existsSync13(path3))
74977
75065
  continue;
74978
- const lines = readFileSync14(path3, "utf8").split(/\r?\n/);
75066
+ const lines = readFileSync15(path3, "utf8").split(/\r?\n/);
74979
75067
  for (const raw of lines) {
74980
75068
  const rule = parseIgnoreRule(raw);
74981
75069
  if (!rule)
@@ -75231,12 +75319,12 @@ var init_files = __esm({
75231
75319
 
75232
75320
  // dist/lib/deploy-check.js
75233
75321
  import { randomUUID as randomUUID5 } from "node:crypto";
75234
- import { existsSync as existsSync14, mkdirSync as mkdirSync8, readFileSync as readFileSync15, realpathSync as realpathSync2, rmSync as rmSync4, writeFileSync as writeFileSync11 } from "node:fs";
75322
+ import { existsSync as existsSync14, mkdirSync as mkdirSync8, readFileSync as readFileSync16, realpathSync as realpathSync2, rmSync as rmSync4, writeFileSync as writeFileSync11 } from "node:fs";
75235
75323
  import { createRequire as createRequire4 } from "node:module";
75236
75324
  import { isAbsolute as isAbsolute3, join as join17, relative as relative7, resolve as resolve8 } from "node:path";
75237
75325
  function projectTypeScriptVersion(projectDir) {
75238
75326
  try {
75239
- const version2 = JSON.parse(readFileSync15(join17(projectDir, "node_modules", "typescript", "package.json"), "utf8")).version;
75327
+ const version2 = JSON.parse(readFileSync16(join17(projectDir, "node_modules", "typescript", "package.json"), "utf8")).version;
75240
75328
  return typeof version2 === "string" && version2 ? version2 : null;
75241
75329
  } catch {
75242
75330
  return null;
@@ -75250,7 +75338,7 @@ function announceDeployCheckFetch(projectDir) {
75250
75338
  function deployCheckTsc(projectDir, platform2 = process.platform) {
75251
75339
  try {
75252
75340
  const manifest = join17(projectDir, "node_modules", "typescript", "package.json");
75253
- if (JSON.parse(readFileSync15(manifest, "utf8")).version === DEPLOY_CHECK_TYPESCRIPT_VERSION) {
75341
+ if (JSON.parse(readFileSync16(manifest, "utf8")).version === DEPLOY_CHECK_TYPESCRIPT_VERSION) {
75254
75342
  return { command: process.execPath, args: [join17(projectDir, "node_modules", "typescript", "bin", "tsc")] };
75255
75343
  }
75256
75344
  } catch {
@@ -75355,7 +75443,7 @@ async function startDeployCheck(projectDir) {
75355
75443
  if (checked.length === 0)
75356
75444
  return { ok: true, findings: [], typescript, checkedFiles: 0 };
75357
75445
  const tsconfigPath = join17(projectDir, "tsconfig.json");
75358
- const own = projectCompilerOptions(existsSync14(tsconfigPath) ? readFileSync15(tsconfigPath, "utf8") : void 0);
75446
+ const own = projectCompilerOptions(existsSync14(tsconfigPath) ? readFileSync16(tsconfigPath, "utf8") : void 0);
75359
75447
  const id = randomUUID5();
75360
75448
  const config2 = join17(projectDir, `.__somewhere_deploy_check_${id}.json`);
75361
75449
  const declarationsDir = join17(projectDir, `.__somewhere_deploy_check_${id}`);
@@ -75425,9 +75513,9 @@ var init_deploy_check = __esm({
75425
75513
  });
75426
75514
 
75427
75515
  // dist/lib/agent-hooks.js
75428
- import { existsSync as existsSync15, lstatSync as lstatSync3, mkdirSync as mkdirSync9, readFileSync as readFileSync16, realpathSync as realpathSync3, statSync as statSync3, writeFileSync as writeFileSync12 } from "node:fs";
75516
+ import { existsSync as existsSync15, lstatSync as lstatSync3, mkdirSync as mkdirSync9, readFileSync as readFileSync17, realpathSync as realpathSync3, statSync as statSync3, writeFileSync as writeFileSync12 } from "node:fs";
75429
75517
  import { homedir as homedir2 } from "node:os";
75430
- import { delimiter, dirname as dirname6, isAbsolute as isAbsolute4, join as join18, relative as relative8, resolve as resolve9, sep } from "node:path";
75518
+ import { delimiter, dirname as dirname7, isAbsolute as isAbsolute4, join as join18, relative as relative8, resolve as resolve9, sep } from "node:path";
75431
75519
  function isAgentHost(value) {
75432
75520
  return AGENT_HOSTS.includes(value);
75433
75521
  }
@@ -75463,7 +75551,7 @@ function readConfig(path3) {
75463
75551
  if (!existsSync15(path3))
75464
75552
  return {};
75465
75553
  try {
75466
- const parsed = JSON.parse(readFileSync16(path3, "utf8"));
75554
+ const parsed = JSON.parse(readFileSync17(path3, "utf8"));
75467
75555
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : new Error("is not a JSON object");
75468
75556
  } catch (error3) {
75469
75557
  return error3 instanceof Error ? error3 : new Error(String(error3));
@@ -75556,7 +75644,7 @@ function installAgentHooks(options2) {
75556
75644
  status = "added";
75557
75645
  }
75558
75646
  if (status !== "unchanged") {
75559
- mkdirSync9(dirname6(path3), { recursive: true });
75647
+ mkdirSync9(dirname7(path3), { recursive: true });
75560
75648
  writeFileSync12(path3, JSON.stringify(config2, null, 2) + "\n");
75561
75649
  }
75562
75650
  return { host, path: path3, status, activation: spec.activation };
@@ -75601,11 +75689,11 @@ function hookProjectRoot(host, payload, env = process.env, cwd = process.cwd())
75601
75689
  ].find((dir) => typeof dir === "string" && isAbsolute4(dir) && existsSync15(dir));
75602
75690
  if (!start)
75603
75691
  return null;
75604
- for (let dir = resolve9(start); ; dir = dirname6(dir)) {
75692
+ for (let dir = resolve9(start); ; dir = dirname7(dir)) {
75605
75693
  const config2 = join18(dir, HOSTS[host].configPath);
75606
- if (existsSync15(config2) && HOOK_MARKER.test(readFileSync16(config2, "utf8")))
75694
+ if (existsSync15(config2) && HOOK_MARKER.test(readFileSync17(config2, "utf8")))
75607
75695
  return dir;
75608
- if (dirname6(dir) === dir)
75696
+ if (dirname7(dir) === dir)
75609
75697
  return null;
75610
75698
  }
75611
75699
  }
@@ -75927,7 +76015,7 @@ var init_typecheck2 = __esm({
75927
76015
 
75928
76016
  // dist/lib/base-files.js
75929
76017
  import { createHash as createHash3 } from "node:crypto";
75930
- import { existsSync as existsSync17, mkdirSync as mkdirSync10, readFileSync as readFileSync17, rmSync as rmSync5, writeFileSync as writeFileSync13 } from "node:fs";
76018
+ import { existsSync as existsSync17, mkdirSync as mkdirSync10, readFileSync as readFileSync18, rmSync as rmSync5, writeFileSync as writeFileSync13 } from "node:fs";
75931
76019
  import { join as join20 } from "node:path";
75932
76020
  function sha2562(content) {
75933
76021
  return createHash3("sha256").update(content).digest("hex");
@@ -75935,7 +76023,7 @@ function sha2562(content) {
75935
76023
  function hashFiles(dir, paths) {
75936
76024
  const out = {};
75937
76025
  for (const path3 of paths)
75938
- out[path3] = sha2562(readFileSync17(join20(dir, path3)));
76026
+ out[path3] = sha2562(readFileSync18(join20(dir, path3)));
75939
76027
  return out;
75940
76028
  }
75941
76029
  function saveBaseFiles(dir, base) {
@@ -75950,7 +76038,7 @@ function loadBaseFiles(dir, projectId, releaseId) {
75950
76038
  if (!existsSync17(path3) || releaseId === void 0)
75951
76039
  return null;
75952
76040
  try {
75953
- const parsed = JSON.parse(readFileSync17(path3, "utf8"));
76041
+ const parsed = JSON.parse(readFileSync18(path3, "utf8"));
75954
76042
  if (parsed.project_id !== projectId || parsed.release_id !== releaseId || !parsed.files || typeof parsed.files !== "object")
75955
76043
  return null;
75956
76044
  return parsed;
@@ -75967,7 +76055,7 @@ function loadLastActivation(dir) {
75967
76055
  if (!existsSync17(path3))
75968
76056
  return null;
75969
76057
  try {
75970
- return JSON.parse(readFileSync17(path3, "utf8"));
76058
+ return JSON.parse(readFileSync18(path3, "utf8"));
75971
76059
  } catch {
75972
76060
  return null;
75973
76061
  }
@@ -76082,7 +76170,7 @@ var init_live_refusal = __esm({
76082
76170
  });
76083
76171
 
76084
76172
  // dist/lib/build-errors.js
76085
- import { existsSync as existsSync18, readFileSync as readFileSync18 } from "node:fs";
76173
+ import { existsSync as existsSync18, readFileSync as readFileSync19 } from "node:fs";
76086
76174
  import { isAbsolute as isAbsolute5, join as join21 } from "node:path";
76087
76175
  function parseBundleErrorText(text) {
76088
76176
  const out = [];
@@ -76116,7 +76204,7 @@ function frameFor(detail, baseDir, serverFrame) {
76116
76204
  const abs = isAbsolute5(detail.file) ? detail.file : join21(baseDir, detail.file);
76117
76205
  if (existsSync18(abs)) {
76118
76206
  try {
76119
- const frame = localCodeFrame(readFileSync18(abs, "utf-8"), detail.line, detail.column);
76207
+ const frame = localCodeFrame(readFileSync19(abs, "utf-8"), detail.line, detail.column);
76120
76208
  if (frame)
76121
76209
  return frame;
76122
76210
  } catch {
@@ -76452,8 +76540,8 @@ var init_claim_handoff = __esm({
76452
76540
  });
76453
76541
 
76454
76542
  // dist/lib/project-notices.js
76455
- import { existsSync as existsSync19, mkdirSync as mkdirSync11, readFileSync as readFileSync19, writeFileSync as writeFileSync14 } from "node:fs";
76456
- import { dirname as dirname7, join as join22 } from "node:path";
76543
+ import { existsSync as existsSync19, mkdirSync as mkdirSync11, readFileSync as readFileSync20, writeFileSync as writeFileSync14 } from "node:fs";
76544
+ import { dirname as dirname8, join as join22 } from "node:path";
76457
76545
  function localDay(now2) {
76458
76546
  const date5 = new Date(now2);
76459
76547
  return [date5.getFullYear(), date5.getMonth() + 1, date5.getDate()].map((part) => String(part).padStart(2, "0")).join("-");
@@ -76462,7 +76550,7 @@ function readState(path3) {
76462
76550
  if (!existsSync19(path3))
76463
76551
  return { shown: {} };
76464
76552
  try {
76465
- const parsed = JSON.parse(readFileSync19(path3, "utf8"));
76553
+ const parsed = JSON.parse(readFileSync20(path3, "utf8"));
76466
76554
  return parsed.shown && typeof parsed.shown === "object" ? { shown: parsed.shown } : { shown: {} };
76467
76555
  } catch {
76468
76556
  return { shown: {} };
@@ -76492,7 +76580,7 @@ async function showProjectNotices(client, projectRef3, options2 = {}) {
76492
76580
  const shown = Object.fromEntries(Object.entries(state.shown).filter(([, shownDay]) => shownDay === day));
76493
76581
  for (const notice of unseen)
76494
76582
  shown[`${response.project_id}:${notice.id}`] = day;
76495
- mkdirSync11(dirname7(statePath), { recursive: true });
76583
+ mkdirSync11(dirname8(statePath), { recursive: true });
76496
76584
  writeFileSync14(statePath, JSON.stringify({ shown }, null, 2) + "\n", { mode: 384 });
76497
76585
  return unseen;
76498
76586
  } catch {
@@ -76514,7 +76602,7 @@ var init_project_notices = __esm({
76514
76602
  });
76515
76603
 
76516
76604
  // dist/lib/test-identities.js
76517
- import { chmodSync as chmodSync2, existsSync as existsSync20, mkdirSync as mkdirSync12, readFileSync as readFileSync20, renameSync as renameSync3, rmSync as rmSync6, writeFileSync as writeFileSync15 } from "node:fs";
76605
+ import { chmodSync as chmodSync2, existsSync as existsSync20, mkdirSync as mkdirSync12, readFileSync as readFileSync21, renameSync as renameSync3, rmSync as rmSync6, writeFileSync as writeFileSync15 } from "node:fs";
76518
76606
  import { join as join23 } from "node:path";
76519
76607
  import { randomBytes as randomBytes3 } from "node:crypto";
76520
76608
  function parseActorSpecs(values) {
@@ -76571,7 +76659,7 @@ ${TEST_STATE_GITIGNORE_LINE}
76571
76659
  `);
76572
76660
  return "created";
76573
76661
  }
76574
- const text = readFileSync20(path3, "utf8");
76662
+ const text = readFileSync21(path3, "utf8");
76575
76663
  const lines = text.split(/\r?\n/).map((line) => line.trim());
76576
76664
  if (lines.some((line) => [".somewhere/test/", ".somewhere/test", "/.somewhere/test/", "/.somewhere/test", ".somewhere/", ".somewhere", "/.somewhere/", "/.somewhere"].includes(line)))
76577
76665
  return "present";
@@ -76588,7 +76676,7 @@ function readManifest(root) {
76588
76676
  const invalid = /* @__PURE__ */ __name((why) => Object.assign(new Error(`${path3} is not a valid test-users manifest (${why}); nothing was changed.`), { code: "MANIFEST_INVALID" }), "invalid");
76589
76677
  let value;
76590
76678
  try {
76591
- value = JSON.parse(readFileSync20(path3, "utf8"));
76679
+ value = JSON.parse(readFileSync21(path3, "utf8"));
76592
76680
  } catch {
76593
76681
  throw invalid("not JSON");
76594
76682
  }
@@ -76758,7 +76846,7 @@ var init_test_identities = __esm({
76758
76846
  });
76759
76847
 
76760
76848
  // dist/lib/form-accounts.js
76761
- import { existsSync as existsSync21, readdirSync as readdirSync4, readFileSync as readFileSync21, rmSync as rmSync7 } from "node:fs";
76849
+ import { existsSync as existsSync21, readdirSync as readdirSync4, readFileSync as readFileSync22, rmSync as rmSync7 } from "node:fs";
76762
76850
  import { join as join24 } from "node:path";
76763
76851
  import { randomBytes as randomBytes4 } from "node:crypto";
76764
76852
  function readDeletionAnswer(ids, answer) {
@@ -76855,7 +76943,7 @@ function recordAttempt(control, root, email3) {
76855
76943
  return path3;
76856
76944
  }
76857
76945
  function recordId(path3, id) {
76858
- const record3 = JSON.parse(readFileSync21(path3, "utf8"));
76946
+ const record3 = JSON.parse(readFileSync22(path3, "utf8"));
76859
76947
  writePrivateFile(path3, JSON.stringify({ ...record3, id }) + "\n");
76860
76948
  }
76861
76949
  function forgetRecord(path3) {
@@ -76891,7 +76979,7 @@ async function sweepAccounts(control, root) {
76891
76979
  const path3 = join24(dir, name);
76892
76980
  let record3;
76893
76981
  try {
76894
- record3 = JSON.parse(readFileSync21(path3, "utf8"));
76982
+ record3 = JSON.parse(readFileSync22(path3, "utf8"));
76895
76983
  } catch {
76896
76984
  result.failed.push(name);
76897
76985
  continue;
@@ -77078,14 +77166,14 @@ var init_test_target = __esm({
77078
77166
  });
77079
77167
 
77080
77168
  // dist/lib/preview-credential.js
77081
- import { existsSync as existsSync22, readFileSync as readFileSync22, unlinkSync as unlinkSync4 } from "node:fs";
77169
+ import { existsSync as existsSync22, readFileSync as readFileSync23, unlinkSync as unlinkSync4 } from "node:fs";
77082
77170
  import { join as join25 } from "node:path";
77083
77171
  function loadPreviewCredential(projectId, previewSessionId) {
77084
77172
  const path3 = join25(cliConfigDir(), SUBDIR, fileName(projectId, previewSessionId));
77085
77173
  if (!existsSync22(path3))
77086
77174
  return null;
77087
77175
  try {
77088
- const stored = JSON.parse(readFileSync22(path3, "utf8"));
77176
+ const stored = JSON.parse(readFileSync23(path3, "utf8"));
77089
77177
  return stored.project_id === projectId && stored.preview_session_id === previewSessionId && typeof stored.credential === "string" ? stored.credential : null;
77090
77178
  } catch {
77091
77179
  return null;
@@ -77129,14 +77217,14 @@ var init_preview_credential = __esm({
77129
77217
  });
77130
77218
 
77131
77219
  // dist/lib/preview-record.js
77132
- import { existsSync as existsSync23, mkdirSync as mkdirSync13, readFileSync as readFileSync23, rmSync as rmSync8, writeFileSync as writeFileSync16 } from "node:fs";
77220
+ import { existsSync as existsSync23, mkdirSync as mkdirSync13, readFileSync as readFileSync24, rmSync as rmSync8, writeFileSync as writeFileSync16 } from "node:fs";
77133
77221
  import { join as join26 } from "node:path";
77134
77222
  function loadPreviewRecord(dir, projectId) {
77135
77223
  const path3 = join26(dir, PREVIEW_RECORD);
77136
77224
  if (!existsSync23(path3))
77137
77225
  return null;
77138
77226
  try {
77139
- const parsed = JSON.parse(readFileSync23(path3, "utf8"));
77227
+ const parsed = JSON.parse(readFileSync24(path3, "utf8"));
77140
77228
  if (parsed.project_id !== projectId || typeof parsed.preview_session_id !== "string" || typeof parsed.preview_id !== "string" || !isRecord(parsed.files))
77141
77229
  return null;
77142
77230
  return parsed;
@@ -77595,11 +77683,21 @@ var init_test_connectivity = __esm({
77595
77683
 
77596
77684
  // dist/lib/test-run.js
77597
77685
  import { createRequire as createRequire5 } from "node:module";
77598
- import { join as join28, dirname as dirname8 } from "node:path";
77686
+ import { pathToFileURL } from "node:url";
77687
+ import { join as join28, dirname as dirname9 } from "node:path";
77599
77688
  import { spawn as spawn4, spawnSync as spawnSync2 } from "node:child_process";
77600
- import { appendFileSync as appendFileSync2, existsSync as existsSync24, readFileSync as readFileSync24, readdirSync as readdirSync5, rmSync as rmSync9 } from "node:fs";
77689
+ import { appendFileSync as appendFileSync2, existsSync as existsSync24, readFileSync as readFileSync25, readdirSync as readdirSync5, rmSync as rmSync9 } from "node:fs";
77601
77690
  import { createHash as createHash6, randomUUID as randomUUID6 } from "node:crypto";
77691
+ function testImportEnv(root, env) {
77692
+ if (!readProjectPin(root)?.versionOnly)
77693
+ return env;
77694
+ const hook2 = pathToFileURL(join28(CLI_PACKAGE_ROOT, "bin", "starter-test-imports.mjs"));
77695
+ return { ...env, NODE_OPTIONS: [env.NODE_OPTIONS, "--import=" + hook2.href].filter(Boolean).join(" ") };
77696
+ }
77602
77697
  function testDependencyError(root) {
77698
+ if (readProjectPin(root)?.versionOnly) {
77699
+ return new Error("Install Playwright for this project: npm install -D --save-exact @playwright/test@1.65.0");
77700
+ }
77603
77701
  return new Error(missingProjectDependencies(root).includes("@playwright/test") ? INSTALL_PROJECT_DEPENDENCIES : "Install project test dependencies: npm install -D @playwright/test @somewhere-cloud/cli");
77604
77702
  }
77605
77703
  async function prepareRunner(root) {
@@ -77635,7 +77733,7 @@ async function prepareRunner(root) {
77635
77733
  mark("browser-probe:end");
77636
77734
  let playwright = "unknown";
77637
77735
  try {
77638
- playwright = JSON.parse(readFileSync24(join28(dirname8(cli), "package.json"), "utf8")).version ?? "unknown";
77736
+ playwright = JSON.parse(readFileSync25(join28(dirname9(cli), "package.json"), "utf8")).version ?? "unknown";
77639
77737
  } catch {
77640
77738
  }
77641
77739
  return { cli, channel, version: version2, browserLaunchMs, playwright };
@@ -77667,21 +77765,21 @@ async function runTests(input) {
77667
77765
  const dir = join28(root, ".somewhere", "tests");
77668
77766
  ensurePrivateDir(dir);
77669
77767
  const ignorePath = join28(root, ".gitignore");
77670
- const ignored = existsSync24(ignorePath) ? readFileSync24(ignorePath, "utf8") : "";
77768
+ const ignored = existsSync24(ignorePath) ? readFileSync25(ignorePath, "utf8") : "";
77671
77769
  for (const line of [".somewhere/", "playwright-report/", "test-results/"])
77672
77770
  if (!ignored.split(/\r?\n/).includes(line))
77673
77771
  appendFileSync2(ignorePath, `
77674
77772
  ${line}
77675
77773
  `);
77676
77774
  const ipv4First = await span("address-probe", {}, () => addressOrder ?? testAddressOrder(origin));
77677
- const runnerEnv = { ...process.env, ...ipv4First ? { NODE_OPTIONS: `${process.env.NODE_OPTIONS ?? ""} --dns-result-order=ipv4first` } : {} };
77775
+ const runnerEnv = testImportEnv(root, { ...process.env, ...ipv4First ? { NODE_OPTIONS: `${process.env.NODE_OPTIONS ?? ""} --dns-result-order=ipv4first` } : {} });
77678
77776
  const files = options2.files ?? [];
77679
77777
  const failed = Boolean(options2.failed);
77680
77778
  const browser = `${prepared.channel ?? "chromium"} ${prepared.version}`;
77681
77779
  const artifacts = join28(dir, createHash6("sha256").update(projectId + origin + (target.environment === "preview" ? `${target.previewSessionId}:${target.releaseId}` : "")).digest("hex").slice(0, 16));
77682
77780
  if (failed) {
77683
77781
  const lastRun = join28(artifacts, ".last-run.json");
77684
- if (!existsSync24(lastRun) || !JSON.parse(readFileSync24(lastRun, "utf8")).failedTests?.length) {
77782
+ if (!existsSync24(lastRun) || !JSON.parse(readFileSync25(lastRun, "utf8")).failedTests?.length) {
77685
77783
  throw new Error("No failed tests are recorded from the last run here; run somewhere test.");
77686
77784
  }
77687
77785
  }
@@ -77728,13 +77826,14 @@ ${line}
77728
77826
  }, "cleanArtifacts");
77729
77827
  cleanArtifacts(artifacts);
77730
77828
  const exitCode = status === null ? 1 : status || (after === null || after.failed.length || after.unknownId.length ? 1 : 0);
77731
- const results = existsSync24(resultsPath) ? JSON.parse(readFileSync24(resultsPath, "utf8")) : null;
77829
+ const results = existsSync24(resultsPath) ? JSON.parse(readFileSync25(resultsPath, "utf8")) : null;
77732
77830
  return { exitCode, results, target };
77733
77831
  }
77734
77832
  var init_test_run = __esm({
77735
77833
  "dist/lib/test-run.js"() {
77736
77834
  "use strict";
77737
77835
  init_package_root();
77836
+ init_project_pin();
77738
77837
  init_config();
77739
77838
  init_test_identities();
77740
77839
  init_form_accounts();
@@ -77743,6 +77842,7 @@ var init_test_run = __esm({
77743
77842
  init_test_connectivity();
77744
77843
  init_typecheck();
77745
77844
  init_test_timeline();
77845
+ __name(testImportEnv, "testImportEnv");
77746
77846
  __name(testDependencyError, "testDependencyError");
77747
77847
  __name(prepareRunner, "prepareRunner");
77748
77848
  __name(runTests, "runTests");
@@ -78039,7 +78139,7 @@ var init_browser_refusal = __esm({
78039
78139
  });
78040
78140
 
78041
78141
  // dist/lib/browser-actions.js
78042
- import { readFileSync as readFileSync25, statSync as statSync4 } from "node:fs";
78142
+ import { readFileSync as readFileSync26, statSync as statSync4 } from "node:fs";
78043
78143
  import { basename as basename4, extname as extname4, resolve as resolve11 } from "node:path";
78044
78144
  function decodedBase64Bytes(base643) {
78045
78145
  if (!base643 || base643.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(base643))
@@ -78095,7 +78195,7 @@ function resolveBrowserUpload(raw, baseDir = process.cwd()) {
78095
78195
  }
78096
78196
  const name = basename4(absolute);
78097
78197
  const contentType = MIME_TYPES[extname4(name).toLowerCase()] ?? "application/octet-stream";
78098
- const bytes = readFileSync25(absolute);
78198
+ const bytes = readFileSync26(absolute);
78099
78199
  if (bytes.length > MAX_BROWSER_UPLOAD_BYTES) {
78100
78200
  throw new Error(`BROWSER_UPLOAD_TOO_LARGE: Upload file is ${bytes.length} bytes; the browser upload limit is ${MAX_BROWSER_UPLOAD_BYTES} bytes (10 MB).`);
78101
78201
  }
@@ -78681,7 +78781,7 @@ var init_chrome = __esm({
78681
78781
  // dist/lib/browser-run.js
78682
78782
  import { writeFileSync as writeFileSync17 } from "node:fs";
78683
78783
  import { join as join30, resolve as resolve12 } from "node:path";
78684
- import { pathToFileURL } from "node:url";
78784
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
78685
78785
  function isLoopbackUrl(raw) {
78686
78786
  let url3;
78687
78787
  try {
@@ -78698,7 +78798,7 @@ function isLoopbackUrl(raw) {
78698
78798
  }
78699
78799
  async function domOutlineScript() {
78700
78800
  const path3 = join30(CLI_PACKAGE_ROOT, "runtime", "browser-probes.mjs");
78701
- const probes = await import(pathToFileURL(path3).href);
78801
+ const probes = await import(pathToFileURL2(path3).href);
78702
78802
  return probes.DOM_OUTLINE_SCRIPT;
78703
78803
  }
78704
78804
  function isBrowserOwnFaviconRequest(url3, initiatorType) {
@@ -79227,8 +79327,8 @@ var init_verify_report = __esm({
79227
79327
  });
79228
79328
 
79229
79329
  // dist/commands/browser.js
79230
- import { dirname as dirname9, resolve as resolve13 } from "node:path";
79231
- import { readFileSync as readFileSync26 } from "node:fs";
79330
+ import { dirname as dirname10, resolve as resolve13 } from "node:path";
79331
+ import { readFileSync as readFileSync27 } from "node:fs";
79232
79332
  function readBrowserIncomplete(r) {
79233
79333
  const raw = r.incomplete;
79234
79334
  if (!raw || typeof raw !== "object")
@@ -79597,8 +79697,8 @@ function registerBrowser(program2) {
79597
79697
  const collectActionsFile = /* @__PURE__ */ __name((file2) => {
79598
79698
  try {
79599
79699
  const absolute = resolve13(file2);
79600
- const raw = JSON.parse(readFileSync26(absolute, "utf8"));
79601
- const normalized = normalizeBrowserActions(raw, dirname9(absolute));
79700
+ const raw = JSON.parse(readFileSync27(absolute, "utf8"));
79701
+ const normalized = normalizeBrowserActions(raw, dirname10(absolute));
79602
79702
  if (!normalized.ok)
79603
79703
  throw new InvalidArgumentError(normalized.error);
79604
79704
  actionSequence.push(...normalized.actions);
@@ -79751,7 +79851,7 @@ var init_browser = __esm({
79751
79851
 
79752
79852
  // dist/lib/verify-keep.js
79753
79853
  import { createHash as createHash7, randomBytes as randomBytes5 } from "node:crypto";
79754
- import { closeSync as closeSync4, existsSync as existsSync26, openSync as openSync4, readFileSync as readFileSync27, rmSync as rmSync11, statSync as statSync5, writeSync } from "node:fs";
79854
+ import { closeSync as closeSync4, existsSync as existsSync26, openSync as openSync4, readFileSync as readFileSync28, rmSync as rmSync11, statSync as statSync5, writeSync } from "node:fs";
79755
79855
  import { join as join32 } from "node:path";
79756
79856
  function path(root) {
79757
79857
  return join32(stateDir(root), KEEP_FILE);
@@ -79760,7 +79860,7 @@ function readFile(root) {
79760
79860
  if (!existsSync26(path(root)))
79761
79861
  return {};
79762
79862
  try {
79763
- const parsed = JSON.parse(readFileSync27(path(root), "utf-8"));
79863
+ const parsed = JSON.parse(readFileSync28(path(root), "utf-8"));
79764
79864
  return parsed && typeof parsed === "object" ? parsed : {};
79765
79865
  } catch {
79766
79866
  return {};
@@ -79832,7 +79932,7 @@ function lockKeep(root, key, now2 = Date.now()) {
79832
79932
  throw cause;
79833
79933
  let stale = true;
79834
79934
  try {
79835
- const held = JSON.parse(readFileSync27(lock, "utf-8"));
79935
+ const held = JSON.parse(readFileSync28(lock, "utf-8"));
79836
79936
  const alive2 = typeof held.pid === "number" && (() => {
79837
79937
  try {
79838
79938
  process.kill(held.pid, 0);
@@ -79954,8 +80054,8 @@ var init_verify_keep = __esm({
79954
80054
 
79955
80055
  // dist/commands/verify.js
79956
80056
  import { randomBytes as randomBytes6 } from "node:crypto";
79957
- import { existsSync as existsSync27, readFileSync as readFileSync28 } from "node:fs";
79958
- import { dirname as dirname10, resolve as resolve14 } from "node:path";
80057
+ import { existsSync as existsSync27, readFileSync as readFileSync29 } from "node:fs";
80058
+ import { dirname as dirname11, resolve as resolve14 } from "node:path";
79959
80059
  function navigationRetryNote(retries) {
79960
80060
  if (!retries.length)
79961
80061
  return "";
@@ -80175,7 +80275,7 @@ function normalizeVerifyFlow(raw, baseDir = process.cwd()) {
80175
80275
  function readVerifyFlowFile(absolute, flag) {
80176
80276
  let source;
80177
80277
  try {
80178
- source = readFileSync28(absolute, "utf8");
80278
+ source = readFileSync29(absolute, "utf8");
80179
80279
  } catch (cause) {
80180
80280
  if (cause instanceof Error && "code" in cause && cause.code === "ENOENT") {
80181
80281
  throw new Error(`Flow file not found. Pass ${flag} <path> with an existing JSON file. Run \`${cliInvocation()} verify --schema\` for the flow format.`);
@@ -80193,7 +80293,7 @@ function loadVerifyFlow(path3, cwd = process.cwd()) {
80193
80293
  return normalizeVerifyFlow(void 0);
80194
80294
  const absolute = resolve14(cwd, path3);
80195
80295
  const parsed = readVerifyFlowFile(absolute, "--verify");
80196
- return normalizeVerifyFlow(parsed, dirname10(absolute));
80296
+ return normalizeVerifyFlow(parsed, dirname11(absolute));
80197
80297
  }
80198
80298
  function resolveViewport(input) {
80199
80299
  if (input === "desktop")
@@ -80710,7 +80810,7 @@ function loadVerifyInput(path3, cwd = process.cwd()) {
80710
80810
  return { kind: "single", flow: normalizeVerifyFlow(void 0) };
80711
80811
  const absolute = resolve14(cwd, path3);
80712
80812
  const parsed = readVerifyFlowFile(absolute, "--flow");
80713
- return isVerifyJourneyInput(parsed) ? { kind: "journey", journey: normalizeVerifyJourney(parsed, dirname10(absolute)) } : { kind: "single", flow: normalizeVerifyFlow(parsed, dirname10(absolute)) };
80813
+ return isVerifyJourneyInput(parsed) ? { kind: "journey", journey: normalizeVerifyJourney(parsed, dirname11(absolute)) } : { kind: "single", flow: normalizeVerifyFlow(parsed, dirname11(absolute)) };
80714
80814
  }
80715
80815
  function settleWithin(promise2, ms2) {
80716
80816
  if (ms2 <= 0)
@@ -81817,15 +81917,10 @@ function deriveNewProjectName(dirPath) {
81817
81917
  const base = slugify2(basename5(dirPath)) || "project";
81818
81918
  return `${base}-${randomSuffix()}`;
81819
81919
  }
81820
- function formatTtlHours(ttlSeconds) {
81821
- if (!ttlSeconds || !Number.isFinite(ttlSeconds))
81822
- return 3;
81823
- return Math.round(ttlSeconds / 3600) || 3;
81824
- }
81825
81920
  function formatTempExpiry(expiresAt, ttlSeconds, nowMs = Date.now()) {
81826
81921
  const remainingMs = expiresAt ? Date.parse(expiresAt) - nowMs : NaN;
81827
81922
  if (!Number.isFinite(remainingMs) || ttlSeconds !== void 0 && Number.isFinite(ttlSeconds) && (remainingMs > ttlSeconds * 1e3 + 6e4 || remainingMs < -6e4)) {
81828
- return `Temporary app. Expires about ${plural3(formatTtlHours(ttlSeconds), "hour")} after it was created.`;
81923
+ return "Temporary app.";
81829
81924
  }
81830
81925
  if (remainingMs <= 0)
81831
81926
  return "Temporary app. It has expired.";
@@ -82085,7 +82180,7 @@ No project yet? Signed in, deploy never creates one on its own:
82085
82180
  ${cliInvocation()} init --bare --name <name> create a project in your account and link this folder
82086
82181
  ${cliInvocation()} deploy then deploy it
82087
82182
  Existing project: \`${cliInvocation()} init --link --project <ref>\` (see \`${cliInvocation()} projects\`), or \`--project <ref>\` here.
82088
- `).option("--project <ref>", `Existing project to deploy to \u2014 accepts the project UUID, slug, or subdomain (all three resolve server-side). To create one, run \`${cliInvocation()} init --bare --name <name>\``).option("--scope <scope>", "Partial deploy: 'functions' (backend only, leaves the site untouched) or 'static' (site only, leaves functions untouched). Default deploys both.").option("--dry-run", "Show what would change (added / modified / removed files) in an already deployed project, without deploying. The files a deploy would publish are sent to Somewhere to compute the change; nothing is published. Never creates a project or a temporary workspace.").option("--replace-functions", "Delete deployed functions that are not in this directory. A full deploy already does; use it with --scope functions, which otherwise keeps them.").option("--prebuilt", "Deploy pre-built / bundled output (e.g. a dist/ folder) instead of raw source. Raw source is the default and recommended path: the platform compiles your TSX/JSX/TS on deploy, which keeps the app editable end-to-end. Choosing --prebuilt trades that away \u2014 pull/export round-trips, find/replace patches, and visual (source-map) editing are disabled for the bundled files. Use it only when you need full control of your own build.").option("--allow-bundled", "Alias for --prebuilt.").option("--new", "Publish to a new project and replace this folder\u2019s .somewhere.json link").option("--temporary", "Explicitly deploy to a temporary 3-hour workspace (automatic when logged out)").option("--force", "Overwrite remote changes even when this machine last deployed an older version").option("--include <paths>", 'Publish a file or folder the deploy would otherwise hold back, e.g. --include NOTES.md or --include tests (comma-separate several, or repeat the flag). A "!NOTES.md" or "!tests/" line in .somewhereignore does the same thing permanently.', (value, previous = []) => previous.concat(value.split(",").map((v2) => v2.trim()).filter(Boolean))).option("--yes", "Skip confirmation prompts (for --force)").option("--verify [flow.json]", "After the deploy is live, run one browser verification flow at desktop and phone size. Omit the file for the default health check.").addOption(new Option("--test", "After a successful deploy, run somewhere test once against the new release").hideHelp()).option("-m, --message <text>", "User-supplied note for this version (max 200 characters)").option("--json", "Print the deploy result and its uploaded file list as JSON on stdout. Stderr lists files left out locally by path and reason.").option("--list-unpublished", "List the local files deploy would keep on your machine, then exit").option("--allow-type-errors", "Upload even when the local TypeScript check fails").option("--timing", "Print deploy details and timings").action(async (dir, opts) => {
82183
+ `).option("--project <ref>", `Existing project to deploy to \u2014 accepts the project UUID, slug, or subdomain (all three resolve server-side). To create one, run \`${cliInvocation()} init --bare --name <name>\``).option("--scope <scope>", "Partial deploy: 'functions' (backend only, leaves the site untouched) or 'static' (site only, leaves functions untouched). Default deploys both.").option("--dry-run", "Show what would change (added / modified / removed files) in an already deployed project, without deploying. The files a deploy would publish are sent to Somewhere to compute the change; nothing is published. Never creates a project or a temporary workspace.").option("--replace-functions", "Delete deployed functions that are not in this directory. A full deploy already does; use it with --scope functions, which otherwise keeps them.").option("--prebuilt", "Deploy pre-built / bundled output (e.g. a dist/ folder) instead of raw source. Raw source is the default and recommended path: the platform compiles your TSX/JSX/TS on deploy, which keeps the app editable end-to-end. Choosing --prebuilt trades that away \u2014 pull/export round-trips, find/replace patches, and visual (source-map) editing are disabled for the bundled files. Use it only when you need full control of your own build.").option("--allow-bundled", "Alias for --prebuilt.").option("--new", "Publish to a new project and replace this folder\u2019s .somewhere.json link").option("--temporary", "Deploy to a temporary workspace and show when it expires (automatic when logged out)").option("--force", "Overwrite remote changes even when this machine last deployed an older version").option("--include <paths>", 'Publish a file or folder the deploy would otherwise hold back, e.g. --include NOTES.md or --include tests (comma-separate several, or repeat the flag). A "!NOTES.md" or "!tests/" line in .somewhereignore does the same thing permanently.', (value, previous = []) => previous.concat(value.split(",").map((v2) => v2.trim()).filter(Boolean))).option("--yes", "Skip confirmation prompts (for --force)").option("--verify [flow.json]", "After the deploy is live, run one browser verification flow at desktop and phone size. Omit the file for the default health check.").addOption(new Option("--test", "After a successful deploy, run somewhere test once against the new release").hideHelp()).option("-m, --message <text>", "User-supplied note for this version (max 200 characters)").option("--json", "Print the deploy result and its uploaded file list as JSON on stdout. Stderr lists files left out locally by path and reason.").option("--list-unpublished", "List the local files deploy would keep on your machine, then exit").option("--allow-type-errors", "Upload even when the local TypeScript check fails").option("--timing", "Print deploy details and timings").action(async (dir, opts) => {
82089
82184
  const startupMs = performance.now();
82090
82185
  const targetDir = resolveTargetDir(dir);
82091
82186
  if (opts.new && (opts.project || opts.dryRun || opts.temporary)) {
@@ -82289,13 +82384,18 @@ Existing project: \`${cliInvocation()} init --link --project <ref>\` (see \`${cl
82289
82384
  } else if (tempSession || opts.new) {
82290
82385
  const createSpinner = opts.json ? null : ora(tempSession ? "Creating a temporary project..." : "Creating a new project...").start();
82291
82386
  try {
82292
- const name = deriveNewProjectName(targetDir);
82293
- const created = await client.call("POST", "/projects", { name, subdomain: name, cli_version: CLI_VERSION });
82387
+ const starterName = tempSession && !besideRealLogin && !opts.new ? readStarterProjectName(targetDir) : void 0;
82388
+ const name = starterName ?? deriveNewProjectName(targetDir);
82389
+ const subdomain = starterName ? `${starterNameSlug(starterName).slice(0, 35).replace(/-$/, "") || "project"}-${randomSuffix()}` : name;
82390
+ const created = await client.call("POST", "/projects", { name, subdomain, cli_version: CLI_VERSION });
82391
+ if (starterName && created.status && created.status !== "draft") {
82392
+ throw new Error("A temporary project already uses this name. Change somewhere.project_name in package.json or deploy from the linked folder.");
82393
+ }
82294
82394
  createSpinner?.stop();
82295
82395
  targetProjectConfig = {
82296
82396
  project_id: created.id,
82297
82397
  name: created.name,
82298
- subdomain: created.subdomain ?? name,
82398
+ subdomain: created.subdomain ?? subdomain,
82299
82399
  source_base: sourceBaseState(created.id, null)
82300
82400
  };
82301
82401
  if (besideRealLogin && sideCar) {
@@ -83207,6 +83307,7 @@ var init_deploy = __esm({
83207
83307
  "dist/commands/deploy.js"() {
83208
83308
  "use strict";
83209
83309
  init_first_cli_permission();
83310
+ init_init_scaffold();
83210
83311
  init_link_hint();
83211
83312
  init_role_method_hints();
83212
83313
  init_cli_invocation();
@@ -83262,7 +83363,6 @@ var init_deploy = __esm({
83262
83363
  __name(slugify2, "slugify");
83263
83364
  __name(randomSuffix, "randomSuffix");
83264
83365
  __name(deriveNewProjectName, "deriveNewProjectName");
83265
- __name(formatTtlHours, "formatTtlHours");
83266
83366
  __name(formatTempExpiry, "formatTempExpiry");
83267
83367
  __name(plural3, "plural");
83268
83368
  __name(formatElapsed, "formatElapsed");
@@ -83413,8 +83513,8 @@ var init_deploys = __esm({
83413
83513
  });
83414
83514
 
83415
83515
  // dist/commands/pull.js
83416
- import { existsSync as existsSync29, lstatSync as lstatSync4, mkdirSync as mkdirSync15, readFileSync as readFileSync29, readdirSync as readdirSync7, rmSync as rmSync12, writeFileSync as writeFileSync19 } from "node:fs";
83417
- import { basename as basename6, dirname as dirname11, join as join34, relative as relative10, resolve as resolve16 } from "node:path";
83516
+ import { existsSync as existsSync29, lstatSync as lstatSync4, mkdirSync as mkdirSync15, readFileSync as readFileSync30, readdirSync as readdirSync7, rmSync as rmSync12, writeFileSync as writeFileSync19 } from "node:fs";
83517
+ import { basename as basename6, dirname as dirname12, join as join34, relative as relative10, resolve as resolve16 } from "node:path";
83418
83518
  function registerPull(program2) {
83419
83519
  program2.command("pull [project]").description(`Download a project's deployed source files to the current directory. Scaffolds a tsconfig.json + package.json (only if absent) so \`${cliInvocation()} typecheck\` can catch undefined symbols locally before you deploy. In a linked folder, plain pull is the safe update when live is newer: files you have not edited move to the live version, your local edits and local-only files (AGENTS.md, notes, tests) are kept, and it stops without writing anything if a file changed both here and live.`).option("--env <env>", "Environment to pull from (dev or prod)", "prod").option("--out <dir>", "Output directory", ".").option("--force", "Also replace files you edited here with live, and delete published files you edited that live no longer has. Never deletes a file a deploy would not upload (AGENTS.md, CLAUDE.md, README.md, tests, dotfiles, .somewhereignore matches)").option("--json", "Print the raw source response as JSON").action(async (projectArg, opts) => {
83420
83520
  const token = getToken();
@@ -83498,7 +83598,7 @@ function registerPull(program2) {
83498
83598
  const target = join34(outDir, path3);
83499
83599
  if (!existsSync29(target))
83500
83600
  continue;
83501
- const local = readFileSync29(target);
83601
+ const local = readFileSync30(target);
83502
83602
  if (local.equals(contents))
83503
83603
  continue;
83504
83604
  if (opts.force) {
@@ -83527,7 +83627,7 @@ function registerPull(program2) {
83527
83627
  if (existsSync29(target) && !overwrite.has(relPath)) {
83528
83628
  return;
83529
83629
  }
83530
- mkdirSync15(dirname11(target), { recursive: true });
83630
+ mkdirSync15(dirname12(target), { recursive: true });
83531
83631
  writeFileSync19(target, contents);
83532
83632
  written.push(relPath);
83533
83633
  }, "writeOne");
@@ -83632,7 +83732,7 @@ function reconcileRemovedFiles(outDir, expected, force, base = null) {
83632
83732
  const was = base?.files[relPath];
83633
83733
  if (base && was === void 0)
83634
83734
  continue;
83635
- const unedited = was !== void 0 && was === sha2562(readFileSync29(fullPath));
83735
+ const unedited = was !== void 0 && was === sha2562(readFileSync30(fullPath));
83636
83736
  if (!force && !unedited) {
83637
83737
  skipped.push(relPath);
83638
83738
  continue;
@@ -84785,7 +84885,7 @@ var init_db = __esm({
84785
84885
  });
84786
84886
 
84787
84887
  // dist/commands/postgres.js
84788
- import { readFileSync as readFileSync30 } from "node:fs";
84888
+ import { readFileSync as readFileSync31 } from "node:fs";
84789
84889
  function str(value) {
84790
84890
  return typeof value === "string" && value.length > 0 ? value : null;
84791
84891
  }
@@ -84794,7 +84894,7 @@ async function readNeonApiKey() {
84794
84894
  if (fromEnv)
84795
84895
  return fromEnv;
84796
84896
  if (!process.stdin.isTTY) {
84797
- return readFileSync30(0, "utf8").trim();
84897
+ return readFileSync31(0, "utf8").trim();
84798
84898
  }
84799
84899
  const response = await (0, import_prompts8.default)({
84800
84900
  type: "password",
@@ -85123,7 +85223,7 @@ var init_postgres = __esm({
85123
85223
  });
85124
85224
 
85125
85225
  // dist/lib/advisor-context.js
85126
- import { readFileSync as readFileSync31, statSync as statSync6 } from "node:fs";
85226
+ import { readFileSync as readFileSync32, statSync as statSync6 } from "node:fs";
85127
85227
  import { basename as basename7 } from "node:path";
85128
85228
  function tail(value, limit) {
85129
85229
  return value.length <= limit ? value : `\u2026${value.slice(-limit)}`;
@@ -85145,7 +85245,7 @@ function buildAdvisorContext(filePath) {
85145
85245
  const stat6 = statSync6(filePath);
85146
85246
  if (!stat6.isFile())
85147
85247
  throw new Error("--file must name a regular file.");
85148
- const content = readFileSync31(filePath, "utf8");
85248
+ const content = readFileSync32(filePath, "utf8");
85149
85249
  context.file = {
85150
85250
  path: filePath,
85151
85251
  content: tail(redactAdvisorText(content, isDotenvPath(filePath)), FILE_LIMIT)
@@ -85171,7 +85271,7 @@ var init_advisor_context = __esm({
85171
85271
 
85172
85272
  // dist/lib/advisor-runs.js
85173
85273
  import { randomBytes as randomBytes7, randomUUID as randomUUID7 } from "node:crypto";
85174
- import { chmodSync as chmodSync4, existsSync as existsSync31, mkdirSync as mkdirSync16, readFileSync as readFileSync32, renameSync as renameSync5, writeFileSync as writeFileSync21 } from "node:fs";
85274
+ import { chmodSync as chmodSync4, existsSync as existsSync31, mkdirSync as mkdirSync16, readFileSync as readFileSync33, renameSync as renameSync5, writeFileSync as writeFileSync21 } from "node:fs";
85175
85275
  import { join as join36 } from "node:path";
85176
85276
  function path2(id) {
85177
85277
  if (!/^[a-f0-9-]{36}$/i.test(id))
@@ -85208,7 +85308,7 @@ function expiredResult(record3) {
85208
85308
  function load(id) {
85209
85309
  if (!existsSync31(path2(id)))
85210
85310
  throw Error("Advisor request was not found in this CLI configuration.");
85211
- const record3 = JSON.parse(readFileSync32(path2(id), "utf8"));
85311
+ const record3 = JSON.parse(readFileSync33(path2(id), "utf8"));
85212
85312
  prune(record3);
85213
85313
  save(record3);
85214
85314
  return record3;
@@ -86583,7 +86683,7 @@ var init_envfile_write = __esm({
86583
86683
  });
86584
86684
 
86585
86685
  // dist/commands/env.js
86586
- import { existsSync as existsSync32, readFileSync as readFileSync33, writeFileSync as writeFileSync22 } from "node:fs";
86686
+ import { existsSync as existsSync32, readFileSync as readFileSync34, writeFileSync as writeFileSync22 } from "node:fs";
86587
86687
  import { resolve as resolve19 } from "node:path";
86588
86688
  function resolveProjectId(explicit) {
86589
86689
  if (explicit)
@@ -86653,7 +86753,7 @@ function registerEnv(program2) {
86653
86753
  process.exit(1);
86654
86754
  }
86655
86755
  if (existsSync32(outPath) && !opts.force) {
86656
- const existing = readFileSync33(outPath, "utf-8");
86756
+ const existing = readFileSync34(outPath, "utf-8");
86657
86757
  const hasValues = existing.split("\n").some((l) => /^[^#=]+=.+/.test(l.trim()));
86658
86758
  const { ok } = await (0, import_prompts9.default)({
86659
86759
  type: "confirm",
@@ -86706,7 +86806,7 @@ function registerEnv(program2) {
86706
86806
  if (inputNote && !opts.json)
86707
86807
  process.stderr.write(`Note: ${inputNote}
86708
86808
  `);
86709
- const value = opts.stdin ? readFileSync33(0, "utf8").replace(/\r?\n$/, "") : positionalValue;
86809
+ const value = opts.stdin ? readFileSync34(0, "utf8").replace(/\r?\n$/, "") : positionalValue;
86710
86810
  const client = new ApiClient(getToken());
86711
86811
  const pid = resolveProjectId(opts.project);
86712
86812
  try {
@@ -86775,7 +86875,7 @@ var init_env = __esm({
86775
86875
  });
86776
86876
 
86777
86877
  // dist/commands/run.js
86778
- import { existsSync as existsSync33, readFileSync as readFileSync34 } from "node:fs";
86878
+ import { existsSync as existsSync33, readFileSync as readFileSync35 } from "node:fs";
86779
86879
  import { isAbsolute as isAbsolute6, resolve as resolve20 } from "node:path";
86780
86880
  function parseArgs(values) {
86781
86881
  if (!values.length)
@@ -86825,7 +86925,7 @@ function registerRun(program2) {
86825
86925
  error(`File not found: ${script}`);
86826
86926
  process.exit(1);
86827
86927
  }
86828
- const code = readFileSync34(absPath, "utf-8");
86928
+ const code = readFileSync35(absPath, "utf-8");
86829
86929
  if (!code.trim()) {
86830
86930
  error(`${script} is empty \u2014 nothing to run.`);
86831
86931
  process.exit(1);
@@ -87251,7 +87351,7 @@ import { createRequire as createRequire7 } from "node:module";
87251
87351
  import { realpathSync as realpathSync4 } from "node:fs";
87252
87352
  import { createConnection, createServer as createNetServer } from "node:net";
87253
87353
  import { join as join37 } from "node:path";
87254
- import { pathToFileURL as pathToFileURL2 } from "node:url";
87354
+ import { pathToFileURL as pathToFileURL3 } from "node:url";
87255
87355
  function deployedOrigin(value) {
87256
87356
  const url3 = new URL(value);
87257
87357
  if (url3.protocol !== "https:" || url3.username || url3.password || url3.port || url3.pathname !== "/" || url3.search || url3.hash) {
@@ -87350,9 +87450,12 @@ async function startFrontendDev(cwd, target, port = 8787, open3 = false) {
87350
87450
  try {
87351
87451
  vitePath = createRequire7(join37(cwd, "package.json")).resolve("vite");
87352
87452
  } catch {
87453
+ if (readProjectPin(cwd)?.versionOnly) {
87454
+ throw new Error("Install the local frontend tools: npm install --include=optional -D --save-exact vite@7.2.2");
87455
+ }
87353
87456
  throw new Error(`Install this frontend\u2019s Vite dependencies before running ${cliInvocation()} dev. Backend changes run through ${cliInvocation()} deploy or ${cliInvocation()} preview.`);
87354
87457
  }
87355
- const vite = await import(pathToFileURL2(vitePath).href);
87458
+ const vite = await import(pathToFileURL3(vitePath).href);
87356
87459
  const localOrigin = `http://localhost:${port}`;
87357
87460
  const proxy = frontendProxy(origin, localOrigin);
87358
87461
  const server = await vite.createServer({
@@ -87407,6 +87510,7 @@ var FRONTEND_API_PATH, FRONTEND_DATA_PATH;
87407
87510
  var init_frontend_dev = __esm({
87408
87511
  "dist/lib/frontend-dev.js"() {
87409
87512
  "use strict";
87513
+ init_project_pin();
87410
87514
  init_cli_invocation();
87411
87515
  init_typecheck();
87412
87516
  init_declared_data();
@@ -87464,7 +87568,7 @@ var init_preview_jobs = __esm({
87464
87568
 
87465
87569
  // dist/commands/dev.js
87466
87570
  import { randomUUID as randomUUID8 } from "node:crypto";
87467
- import { existsSync as existsSync34, readFileSync as readFileSync35 } from "node:fs";
87571
+ import { existsSync as existsSync34, readFileSync as readFileSync36 } from "node:fs";
87468
87572
  import { join as join38, relative as relative11 } from "node:path";
87469
87573
  function previewFinishedReason(err) {
87470
87574
  if (!(err instanceof CliApiError) || err.code !== "DRAFT_SESSION_TERMINAL")
@@ -88453,11 +88557,11 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
88453
88557
  continue;
88454
88558
  const { kind, key } = classifyKey(rel);
88455
88559
  if (kind === "function")
88456
- updateFunctions[key] = readFileSync35(abs, "utf-8");
88560
+ updateFunctions[key] = readFileSync36(abs, "utf-8");
88457
88561
  else if (kind === "binary")
88458
- updateBinary[key] = readFileSync35(abs).toString("base64");
88562
+ updateBinary[key] = readFileSync36(abs).toString("base64");
88459
88563
  else
88460
- updateFiles[key] = readFileSync35(abs, "utf-8");
88564
+ updateFiles[key] = readFileSync36(abs, "utf-8");
88461
88565
  }
88462
88566
  for (const rel of deleted)
88463
88567
  deleteKeys.push(classifyKey(rel).key);
@@ -89238,7 +89342,7 @@ var init_api2 = __esm({
89238
89342
  import { createReadStream as createReadStream2, createWriteStream as createWriteStream2 } from "node:fs";
89239
89343
  import { stat as stat5, rename, unlink } from "node:fs/promises";
89240
89344
  import { randomUUID as randomUUID9 } from "node:crypto";
89241
- import { basename as basename8, dirname as dirname12, extname as extname6, join as join40, resolve as resolve23 } from "node:path";
89345
+ import { basename as basename8, dirname as dirname13, extname as extname6, join as join40, resolve as resolve23 } from "node:path";
89242
89346
  import { pipeline as pipeline2 } from "node:stream/promises";
89243
89347
  function registerFs(program2) {
89244
89348
  const fs2 = program2.command("fs").description("Manage project file storage");
@@ -89282,7 +89386,7 @@ function registerFs(program2) {
89282
89386
  if (!response.body)
89283
89387
  throw new Error("The server returned an empty file response.");
89284
89388
  const destination = resolve23(local);
89285
- tempPath = join40(dirname12(destination), `.${basename8(destination)}.${randomUUID9()}.tmp`);
89389
+ tempPath = join40(dirname13(destination), `.${basename8(destination)}.${randomUUID9()}.tmp`);
89286
89390
  await pipeline2(response.body, createWriteStream2(tempPath, { flags: "wx" }));
89287
89391
  await rename(tempPath, destination);
89288
89392
  tempPath = void 0;
@@ -107048,7 +107152,7 @@ var require_polyfill = __commonJS({
107048
107152
  utimes
107049
107153
  } = __require("fs/promises");
107050
107154
  var {
107051
- dirname: dirname15,
107155
+ dirname: dirname16,
107052
107156
  isAbsolute: isAbsolute7,
107053
107157
  join: join50,
107054
107158
  parse: parse3,
@@ -107152,7 +107256,7 @@ var require_polyfill = __commonJS({
107152
107256
  }
107153
107257
  __name(getStats, "getStats");
107154
107258
  async function checkParentDir(destStat, src, dest, opts) {
107155
- const destParent = dirname15(dest);
107259
+ const destParent = dirname16(dest);
107156
107260
  const dirExists = await pathExists(destParent);
107157
107261
  if (dirExists) {
107158
107262
  return getStatsForCopy(destStat, src, dest, opts);
@@ -107170,8 +107274,8 @@ var require_polyfill = __commonJS({
107170
107274
  }
107171
107275
  __name(pathExists, "pathExists");
107172
107276
  async function checkParentPaths(src, srcStat, dest) {
107173
- const srcParent = resolve26(dirname15(src));
107174
- const destParent = resolve26(dirname15(dest));
107277
+ const srcParent = resolve26(dirname16(src));
107278
+ const destParent = resolve26(dirname16(dest));
107175
107279
  if (destParent === srcParent || destParent === parse3(destParent).root) {
107176
107280
  return;
107177
107281
  }
@@ -107341,7 +107445,7 @@ var require_polyfill = __commonJS({
107341
107445
  async function onLink(destStat, src, dest) {
107342
107446
  let resolvedSrc = await readlink(src);
107343
107447
  if (!isAbsolute7(resolvedSrc)) {
107344
- resolvedSrc = resolve26(dirname15(src), resolvedSrc);
107448
+ resolvedSrc = resolve26(dirname16(src), resolvedSrc);
107345
107449
  }
107346
107450
  if (!destStat) {
107347
107451
  return symlink(resolvedSrc, dest);
@@ -107356,7 +107460,7 @@ var require_polyfill = __commonJS({
107356
107460
  throw err;
107357
107461
  }
107358
107462
  if (!isAbsolute7(resolvedDest)) {
107359
- resolvedDest = resolve26(dirname15(dest), resolvedDest);
107463
+ resolvedDest = resolve26(dirname16(dest), resolvedDest);
107360
107464
  }
107361
107465
  if (isSrcSubdir(resolvedSrc, resolvedDest)) {
107362
107466
  throw new ERR_FS_CP_EINVAL({
@@ -107462,7 +107566,7 @@ var require_readdir_scoped = __commonJS({
107462
107566
  // node_modules/@npmcli/fs/lib/move-file.js
107463
107567
  var require_move_file = __commonJS({
107464
107568
  "node_modules/@npmcli/fs/lib/move-file.js"(exports, module) {
107465
- var { dirname: dirname15, join: join50, resolve: resolve26, relative: relative15, isAbsolute: isAbsolute7 } = __require("path");
107569
+ var { dirname: dirname16, join: join50, resolve: resolve26, relative: relative15, isAbsolute: isAbsolute7 } = __require("path");
107466
107570
  var fs2 = __require("fs/promises");
107467
107571
  var pathExists = /* @__PURE__ */ __name(async (path3) => {
107468
107572
  try {
@@ -107483,7 +107587,7 @@ var require_move_file = __commonJS({
107483
107587
  if (!options2.overwrite && await pathExists(destination)) {
107484
107588
  throw new Error(`The destination file exists: ${destination}`);
107485
107589
  }
107486
- await fs2.mkdir(dirname15(destination), { recursive: true });
107590
+ await fs2.mkdir(dirname16(destination), { recursive: true });
107487
107591
  try {
107488
107592
  await fs2.rename(source, destination);
107489
107593
  } catch (error3) {
@@ -107511,7 +107615,7 @@ var require_move_file = __commonJS({
107511
107615
  }
107512
107616
  let targetStat = "file";
107513
107617
  try {
107514
- targetStat = await fs2.stat(resolve26(dirname15(symSource), target));
107618
+ targetStat = await fs2.stat(resolve26(dirname16(symSource), target));
107515
107619
  if (targetStat.isDirectory()) {
107516
107620
  targetStat = "junction";
107517
107621
  }
@@ -128598,7 +128702,7 @@ var require_dist15 = __commonJS({
128598
128702
 
128599
128703
  // dist/lib/update-security.js
128600
128704
  import { createHash as createHash8, timingSafeEqual } from "node:crypto";
128601
- import { mkdirSync as mkdirSync17, readFileSync as readFileSync36, statSync as statSync7 } from "node:fs";
128705
+ import { mkdirSync as mkdirSync17, readFileSync as readFileSync37, statSync as statSync7 } from "node:fs";
128602
128706
  import { join as join41 } from "node:path";
128603
128707
  import { Readable as Readable2 } from "node:stream";
128604
128708
  import { pipeline as pipeline3 } from "node:stream/promises";
@@ -128971,8 +129075,8 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
128971
129075
  try {
128972
129076
  if (statSync7(lockPath).size > MAX_LOCKFILE_BYTES)
128973
129077
  throw new Error("lockfile too large");
128974
- manifest = JSON.parse(readFileSync36(manifestPath, "utf8"));
128975
- lock = JSON.parse(readFileSync36(lockPath, "utf8"));
129078
+ manifest = JSON.parse(readFileSync37(manifestPath, "utf8"));
129079
+ lock = JSON.parse(readFileSync37(lockPath, "utf8"));
128976
129080
  } catch (cause) {
128977
129081
  throw new Error(`the verified artifact has no readable npm-shrinkwrap dependency lock: ${message(cause)}`);
128978
129082
  }
@@ -129010,7 +129114,7 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
129010
129114
  let bundledManifest;
129011
129115
  try {
129012
129116
  const bundledPath = join41(extractionDir, ...lockPath2.split("/"), "package.json");
129013
- bundledManifest = JSON.parse(readFileSync36(bundledPath, "utf8"));
129117
+ bundledManifest = JSON.parse(readFileSync37(bundledPath, "utf8"));
129014
129118
  } catch (cause) {
129015
129119
  throw new Error(`the verified artifact has an unreadable bundled dependency ${lockPath2}: ${message(cause)}`);
129016
129120
  }
@@ -129080,7 +129184,7 @@ ${GITHUB_REPOSITORY_ID}`,
129080
129184
  // dist/commands/update.js
129081
129185
  import { spawn as spawn6 } from "node:child_process";
129082
129186
  import { randomBytes as randomBytes8 } from "node:crypto";
129083
- import { closeSync as closeSync5, constants as constants2, fstatSync, mkdtempSync as mkdtempSync3, openSync as openSync5, readFileSync as readFileSync37, readSync, rmSync as rmSync13, unlinkSync as unlinkSync5, writeFileSync as writeFileSync23 } from "node:fs";
129187
+ import { closeSync as closeSync5, constants as constants2, fstatSync, mkdtempSync as mkdtempSync3, openSync as openSync5, readFileSync as readFileSync38, readSync, rmSync as rmSync13, unlinkSync as unlinkSync5, writeFileSync as writeFileSync23 } from "node:fs";
129084
129188
  import { createServer } from "node:http";
129085
129189
  import { tmpdir as tmpdir2 } from "node:os";
129086
129190
  import { join as join42 } from "node:path";
@@ -129091,7 +129195,7 @@ function refuse2(cause) {
129091
129195
  }
129092
129196
  function currentVersion2() {
129093
129197
  try {
129094
- const pkg = JSON.parse(readFileSync37(join42(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
129198
+ const pkg = JSON.parse(readFileSync38(join42(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
129095
129199
  return pkg.version;
129096
129200
  } catch {
129097
129201
  return "0.0.0";
@@ -129375,15 +129479,14 @@ function upgradeProject(dir, running, changelog = readBundledChangelog) {
129375
129479
  }
129376
129480
  const alreadyExact = pins.every((pin) => pin.spec === running);
129377
129481
  const updated = alreadyExact ? [] : writeProjectPins(dir, pins, running);
129378
- const next = updated.includes("package.json") ? ["npm install"] : [];
129482
+ const next = pins.some((pin) => pin.source === "package.json" && !pin.versionOnly && pin.spec !== running) ? ["npm install"] : [];
129379
129483
  return { from, to: running, updated, changes: changelogBetween(changelog(), from, running), next };
129380
129484
  }
129381
129485
  function registerUpgrade(program2) {
129382
129486
  program2.command("upgrade").description("Move this project to the CLI you are running: rewrite its recorded CLI version and print the changes in between").option("--json", "Print the result as JSON").addHelpText("after", `
129383
- A project records the CLI version it was built with (package.json devDependency
129384
- "${CLI_PACKAGE_NAME}", or "cli_version" in .somewhere.json). Commands run in a
129385
- project pinned to another version print one line saying so, and hand off to the
129386
- pinned version when it is installed in node_modules. To move to the newest release:
129487
+ New starters record somewhere.cli_version in package.json. The CLI uses the exact
129488
+ version from npm\u2019s cache when needed. Existing package dependencies and .somewhere.json
129489
+ pins still work. To move to the newest release:
129387
129490
  npx -y ${CLI_PACKAGE_NAME}@latest upgrade
129388
129491
  Agent skills are not changed; \`${cliInvocation()} skills update\` refreshes them.
129389
129492
  `).action((opts) => {
@@ -129437,7 +129540,7 @@ var init_upgrade = __esm({
129437
129540
  });
129438
129541
 
129439
129542
  // dist/commands/call.js
129440
- import { readFileSync as readFileSync38 } from "node:fs";
129543
+ import { readFileSync as readFileSync39 } from "node:fs";
129441
129544
  function parseArguments(value, file2) {
129442
129545
  if (value === void 0)
129443
129546
  return {};
@@ -129461,7 +129564,7 @@ function readCallArguments(jsonArgs, file2) {
129461
129564
  }
129462
129565
  let text;
129463
129566
  try {
129464
- text = readFileSync38(file2, "utf8");
129567
+ text = readFileSync39(file2, "utf8");
129465
129568
  } catch (err) {
129466
129569
  const code = err?.code;
129467
129570
  throw new Error(`Could not read --file ${file2}${code ? ` (${code})` : ""}. The requested tool was not called.`);
@@ -130480,7 +130583,7 @@ async function findNamedCronRow(target, explicit, signal) {
130480
130583
  throw new Error("cron_list returned a scheduled task without a cron_id.");
130481
130584
  return { ...matches[0], cron_id: id };
130482
130585
  }
130483
- async function resolveCronRunId(target, explicit) {
130586
+ async function resolveCronId(target, explicit) {
130484
130587
  if (target.startsWith("cron_"))
130485
130588
  return target;
130486
130589
  return (await findNamedCronRow(target, explicit)).cron_id;
@@ -130634,7 +130737,7 @@ zone each trigger is stored in, and \`cron update --schedule\` keeps that zone u
130634
130737
  if (opts.timeout !== void 0 && !opts.wait) {
130635
130738
  throw new Error("USAGE_ERROR: --timeout only applies with --wait.");
130636
130739
  }
130637
- const cronId = await resolveCronRunId(target, opts.project);
130740
+ const cronId = await resolveCronId(target, opts.project);
130638
130741
  if (opts.preview) {
130639
130742
  await runCronInPreview(cronId, opts, timeoutSeconds);
130640
130743
  return;
@@ -130753,12 +130856,11 @@ zone each trigger is stored in, and \`cron update --schedule\` keeps that zone u
130753
130856
  process.exitCode = 1;
130754
130857
  }
130755
130858
  });
130756
- cron.command("update <cron-id>").description("Update a scheduled trigger").option("--schedule <expression>", "New 5-field cron expression, read in the trigger's stored time zone (shown by cron list) unless --timezone changes it").option("--timezone <iana>", "New IANA time zone the schedule is read in, e.g. America/Los_Angeles; omit to keep the stored zone").option("--handler <path-or-url>", "New project-relative /api path or https URL").option("--name <name>", "New display name").option("--payload <json>", "New JSON object sent to the handler").option("--enable", "Resume future runs").option("--disable", "Pause future runs").option("--json", "Print the complete response as JSON").action(async (cronId, opts) => {
130859
+ cron.command("update <cron-id-or-name>").description("Update a scheduled trigger").option("-p, --project <project>", "Project slug or ID used to resolve a task name; defaults to the linked project").option("--schedule <expression>", "New 5-field cron expression, read in the trigger's stored time zone (shown by cron list) unless --timezone changes it").option("--timezone <iana>", "New IANA time zone the schedule is read in, e.g. America/Los_Angeles; omit to keep the stored zone").option("--handler <path-or-url>", "New project-relative /api path or https URL").option("--name <name>", "New display name").option("--payload <json>", "New JSON object sent to the handler").option("--enable", "Resume future runs").option("--disable", "Pause future runs").option("--json", "Print the complete response as JSON").action(async (target, opts) => {
130757
130860
  try {
130758
130861
  if (opts.enable && opts.disable)
130759
130862
  throw new Error("Pass --enable or --disable, not both.");
130760
130863
  const args = compactRecord([
130761
- ["cron_id", cronId],
130762
130864
  ["schedule", opts.schedule],
130763
130865
  ["timezone", opts.timezone],
130764
130866
  ["handler", opts.handler],
@@ -130766,19 +130868,26 @@ zone each trigger is stored in, and \`cron update --schedule\` keeps that zone u
130766
130868
  ["payload", parsePayload(opts.payload)],
130767
130869
  ["enabled", opts.enable ? true : opts.disable ? false : void 0]
130768
130870
  ]);
130769
- if (Object.keys(args).length === 1) {
130871
+ if (Object.keys(args).length === 0) {
130770
130872
  throw new Error("No update supplied. Pass a field such as --schedule, --timezone, --handler, --enable, or --disable.");
130771
130873
  }
130772
- await runCronTool("cron_update", args, opts.json, (value) => printCronMutation("Scheduled trigger updated", value));
130874
+ const cronId = await resolveCronId(target, opts.project);
130875
+ await runCronTool("cron_update", { cron_id: cronId, ...args }, opts.json, (value) => printCronMutation("Scheduled trigger updated", value));
130773
130876
  } catch (err) {
130774
- error(err instanceof Error ? err.message : String(err), err);
130775
- process.exitCode = 1;
130877
+ const { code, message: message3, extra } = platformErrorParts(err);
130878
+ printTypedCronError(code, message3, opts.json, extra);
130776
130879
  }
130777
130880
  });
130778
- cron.command("delete <cron-id>").alias("rm").description("Delete a scheduled trigger").option("--json", "Print the complete response as JSON").action(async (cronId, opts) => {
130779
- await runCronTool("cron_delete", { cron_id: cronId }, opts.json, (value) => {
130780
- printCronMutation("Scheduled trigger deleted", value);
130781
- });
130881
+ cron.command("delete <cron-id-or-name>").alias("rm").description("Delete a scheduled trigger").option("-p, --project <project>", "Project slug or ID used to resolve a task name; defaults to the linked project").option("--json", "Print the complete response as JSON").action(async (target, opts) => {
130882
+ try {
130883
+ const cronId = await resolveCronId(target, opts.project);
130884
+ await runCronTool("cron_delete", { cron_id: cronId }, opts.json, (value) => {
130885
+ printCronMutation("Scheduled trigger deleted", value);
130886
+ });
130887
+ } catch (err) {
130888
+ const { code, message: message3, extra } = platformErrorParts(err);
130889
+ printTypedCronError(code, message3, opts.json, extra);
130890
+ }
130782
130891
  });
130783
130892
  }
130784
130893
  var DEFAULT_WAIT_TIMEOUT_SECONDS, WAIT_POLL_INTERVAL_MS, JOB_SUCCESS_STATUS, JOB_FAILURE_STATUSES, CRON_RUN_UNAVAILABLE;
@@ -130817,7 +130926,7 @@ var init_cron = __esm({
130817
130926
  __name(printTypedCronError, "printTypedCronError");
130818
130927
  __name(cronProjectScope, "cronProjectScope");
130819
130928
  __name(findNamedCronRow, "findNamedCronRow");
130820
- __name(resolveCronRunId, "resolveCronRunId");
130929
+ __name(resolveCronId, "resolveCronId");
130821
130930
  __name(findCronRow, "findCronRow");
130822
130931
  __name(nextRunLabel, "nextRunLabel");
130823
130932
  __name(isOverdue, "isOverdue");
@@ -131025,8 +131134,8 @@ var init_reference_check_note = __esm({
131025
131134
 
131026
131135
  // dist/lib/test-scripts.js
131027
131136
  import { createRequire as createRequire8 } from "node:module";
131028
- import { existsSync as existsSync36, mkdirSync as mkdirSync18, readFileSync as readFileSync39, readdirSync as readdirSync8, rmSync as rmSync14, statSync as statSync8, writeFileSync as writeFileSync24 } from "node:fs";
131029
- import { dirname as dirname13, join as join43, relative as relative12, resolve as resolve24 } from "node:path";
131137
+ import { existsSync as existsSync36, mkdirSync as mkdirSync18, readFileSync as readFileSync40, readdirSync as readdirSync8, rmSync as rmSync14, statSync as statSync8, writeFileSync as writeFileSync24 } from "node:fs";
131138
+ import { dirname as dirname14, join as join43, relative as relative12, resolve as resolve24 } from "node:path";
131030
131139
  import { spawn as spawn7, spawnSync as spawnSync5 } from "node:child_process";
131031
131140
  function hasSpecFiles(root) {
131032
131141
  const walk2 = /* @__PURE__ */ __name((dir) => {
@@ -131083,6 +131192,7 @@ function failureReason(output) {
131083
131192
  return (error3 ?? detail.at(-1) ?? null)?.trim().slice(0, 300) ?? null;
131084
131193
  }
131085
131194
  async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)) {
131195
+ env = testImportEnv(root, env);
131086
131196
  const results = [];
131087
131197
  for (const script of scripts) {
131088
131198
  if (!existsSync36(join43(root, script))) {
@@ -131095,7 +131205,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
131095
131205
  const started = performance.now();
131096
131206
  let output = "";
131097
131207
  const handOver = join43(root, ".somewhere", "tests", `report-${results.length}.json`);
131098
- mkdirSync18(dirname13(handOver), { recursive: true });
131208
+ mkdirSync18(dirname14(handOver), { recursive: true });
131099
131209
  rmSync14(handOver, { force: true });
131100
131210
  const askedForBrowserLog = /(^|,)\s*(pw:browser|pw:\*|\*)\s*(,|$)/.test(env.DEBUG ?? "");
131101
131211
  const childEnv = { ...env, SW_TEST_REPORT: handOver, DEBUG: askedForBrowserLog ? env.DEBUG : [env.DEBUG, "pw:browser"].filter(Boolean).join(",") };
@@ -131124,7 +131234,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
131124
131234
  stderrLines("", true);
131125
131235
  let report2 = null;
131126
131236
  try {
131127
- report2 = existsSync36(handOver) ? JSON.parse(readFileSync39(handOver, "utf8")) : null;
131237
+ report2 = existsSync36(handOver) ? JSON.parse(readFileSync40(handOver, "utf8")) : null;
131128
131238
  } catch {
131129
131239
  report2 = null;
131130
131240
  }
@@ -131161,13 +131271,13 @@ function lastFailedScripts(root) {
131161
131271
  if (!existsSync36(path3))
131162
131272
  return [];
131163
131273
  try {
131164
- return (JSON.parse(readFileSync39(path3, "utf8")).results ?? []).filter((r) => !r.ok).map((r) => r.script);
131274
+ return (JSON.parse(readFileSync40(path3, "utf8")).results ?? []).filter((r) => !r.ok).map((r) => r.script);
131165
131275
  } catch {
131166
131276
  return [];
131167
131277
  }
131168
131278
  }
131169
131279
  function recordScriptResults(root, results, rerunOnly) {
131170
- const previous = rerunOnly && existsSync36(join43(root, LAST)) ? JSON.parse(readFileSync39(join43(root, LAST), "utf8")).results ?? [] : [];
131280
+ const previous = rerunOnly && existsSync36(join43(root, LAST)) ? JSON.parse(readFileSync40(join43(root, LAST), "utf8")).results ?? [] : [];
131171
131281
  const merged = [...previous.filter((p2) => !results.some((r) => r.script === p2.script)), ...results];
131172
131282
  mkdirSync18(join43(root, ".somewhere", "tests"), { recursive: true });
131173
131283
  writeFileSync24(join43(root, LAST), JSON.stringify({ finished: (/* @__PURE__ */ new Date()).toISOString(), results: merged }, null, 2) + "\n");
@@ -131251,7 +131361,7 @@ var init_test = __esm({
131251
131361
  });
131252
131362
 
131253
131363
  // dist/commands/test-users.js
131254
- import { existsSync as existsSync37, readFileSync as readFileSync40, rmSync as rmSync15 } from "node:fs";
131364
+ import { existsSync as existsSync37, readFileSync as readFileSync41, rmSync as rmSync15 } from "node:fs";
131255
131365
  import { basename as basename9, join as join44 } from "node:path";
131256
131366
  import { randomBytes as randomBytes9 } from "node:crypto";
131257
131367
  async function resolveTarget(projectOpt, originOpt) {
@@ -131766,7 +131876,7 @@ var init_skills = __esm({
131766
131876
  });
131767
131877
 
131768
131878
  // dist/commands/ai.js
131769
- import { readFileSync as readFileSync41 } from "node:fs";
131879
+ import { readFileSync as readFileSync42 } from "node:fs";
131770
131880
  function fail4(message3) {
131771
131881
  error(message3);
131772
131882
  process.exit(1);
@@ -131787,7 +131897,7 @@ async function readKey(stdin) {
131787
131897
  if (stdin) {
131788
131898
  if (process.stdin.isTTY)
131789
131899
  fail4("Pipe the key into --stdin, or leave out --stdin to type it into a hidden prompt.");
131790
- raw = readFileSync41(0, "utf8");
131900
+ raw = readFileSync42(0, "utf8");
131791
131901
  } else {
131792
131902
  if (!process.stdin.isTTY)
131793
131903
  fail4("Pass --stdin to read the key from a pipe. Nothing was sent.");
@@ -132017,25 +132127,36 @@ __export(dist_exports, {
132017
132127
  runCli: () => runCli
132018
132128
  });
132019
132129
  import { spawnSync as spawnSync6 } from "node:child_process";
132020
- import { readFileSync as readFileSync42 } from "node:fs";
132130
+ import { readFileSync as readFileSync43 } from "node:fs";
132021
132131
  import { join as join47 } from "node:path";
132022
132132
  async function runCli() {
132023
132133
  const pinned = decidePin(process.cwd(), CLI_VERSION, process.argv, process.env);
132024
132134
  if (pinned.notice)
132025
132135
  process.stderr.write(pinned.notice + "\n");
132026
- if (pinned.delegate) {
132027
- const child = spawnSync6(process.execPath, [pinned.delegate, ...process.argv.slice(2)], {
132136
+ const invocation2 = pinned.delegate ? { command: process.execPath, args: [pinned.delegate] } : pinned.delegateVersion && pinnedNpx(pinned.delegateVersion);
132137
+ if (!invocation2 && pinned.delegateVersion) {
132138
+ process.stderr.write(`Could not find npx. Run npx -y @somewhere-cloud/cli@${pinned.delegateVersion} with this command.
132139
+ `);
132140
+ process.exitCode = 1;
132141
+ return;
132142
+ }
132143
+ if (invocation2) {
132144
+ const child = spawnSync6(invocation2.command, [...invocation2.args, ...process.argv.slice(2)], {
132028
132145
  stdio: "inherit",
132029
132146
  env: { ...process.env, [PINNED_CHILD_ENV]: "1" }
132030
132147
  });
132031
- if (child.error)
132032
- throw child.error;
132148
+ if (child.error) {
132149
+ process.stderr.write(`Could not start the pinned CLI: ${child.error.message}
132150
+ `);
132151
+ process.exitCode = 1;
132152
+ return;
132153
+ }
132033
132154
  if (child.signal)
132034
132155
  process.kill(process.pid, child.signal);
132035
132156
  process.exit(child.status ?? 1);
132036
132157
  }
132037
132158
  removeStaleRunRecord();
132038
- const pkg = JSON.parse(readFileSync42(join47(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
132159
+ const pkg = JSON.parse(readFileSync43(join47(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
132039
132160
  const program2 = new Command().name(cliInvocation()).description(`CLI for somewhere.cloud. Run ${cliInvocation()} init first, then read generated AGENTS.md: call shapes and access patterns for a typical app; docs are for exceptions.`).version(pkg.version);
132040
132161
  recordLastRun(pkg.version);
132041
132162
  const jsonOutputRequested = process.argv.includes("--json");
@@ -132824,8 +132945,8 @@ var init_form_auth = __esm({
132824
132945
  import { randomUUID as randomUUID10 } from "node:crypto";
132825
132946
  import { setDefaultResultOrder } from "node:dns";
132826
132947
  import { lookup } from "node:dns/promises";
132827
- import { existsSync as existsSync38, mkdirSync as mkdirSync20, readFileSync as readFileSync43, writeFileSync as writeFileSync26 } from "node:fs";
132828
- import { basename as basename10, dirname as dirname14, join as join48, relative as relative14, resolve as resolve25 } from "node:path";
132948
+ import { existsSync as existsSync38, mkdirSync as mkdirSync20, readFileSync as readFileSync44, writeFileSync as writeFileSync26 } from "node:fs";
132949
+ import { basename as basename10, dirname as dirname15, join as join48, relative as relative14, resolve as resolve25 } from "node:path";
132829
132950
  function launchOptions(extra = {}) {
132830
132951
  return { ...extra, args: ["--disable-features=AsyncDns", ...extra.args ?? []] };
132831
132952
  }
@@ -132862,7 +132983,7 @@ function undeployedChanges(root, projectId, preview = false) {
132862
132983
  const path3 = join48(root, ".somewhere", "base-files.json");
132863
132984
  if (!existsSync38(path3))
132864
132985
  return null;
132865
- base = JSON.parse(readFileSync43(path3, "utf8"));
132986
+ base = JSON.parse(readFileSync44(path3, "utf8"));
132866
132987
  }
132867
132988
  if (base.project_id !== projectId || !base.files)
132868
132989
  return null;
@@ -133188,7 +133309,7 @@ Stopping here: later checks are skipped. After a fix, rerun the scripts that fai
133188
133309
  this.checks.push({ name: "cleanup of sign-up accounts", ok: false, ms: 0, error: cleanup.join("; ") });
133189
133310
  const passed = this.checks.filter((check2) => check2.ok).length;
133190
133311
  const failed = this.checks.filter((check2) => !check2.ok && !check2.skipped).length;
133191
- mkdirSync20(dirname14(this.resultsPath), { recursive: true });
133312
+ mkdirSync20(dirname15(this.resultsPath), { recursive: true });
133192
133313
  writeFileSync26(this.resultsPath, JSON.stringify({
133193
133314
  identity: this.identity(),
133194
133315
  origin: this.origin,