@somewhere-cloud/cli 0.38.123 → 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.
@@ -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
  }
@@ -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 };
@@ -38513,13 +38563,13 @@ declare module '*.${ext}' {
38513
38563
  });
38514
38564
 
38515
38565
  // dist/lib/init-green-template.js
38516
- function createGreenTemplate() {
38566
+ function createGreenTemplate(appName = "somewhere-starter") {
38517
38567
  return [
38518
38568
  { path: ".gitignore", content: buildScaffoldGitignore() },
38519
38569
  { path: "AGENTS.md", content: INIT_AGENTS_MD },
38520
38570
  { path: "CLAUDE.md", content: INIT_CLAUDE_MD },
38521
38571
  { path: "README.md", content: README },
38522
- { path: "package.json", content: PACKAGE_JSON },
38572
+ { path: "package.json", content: packageJson(appName) },
38523
38573
  { path: "tsconfig.json", content: TSCONFIG },
38524
38574
  {
38525
38575
  path: "index.html",
@@ -38536,7 +38586,7 @@ function createGreenTemplate() {
38536
38586
  ASSET_TYPES_FILE
38537
38587
  ];
38538
38588
  }
38539
- 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;
38540
38590
  var init_init_green_template = __esm({
38541
38591
  "dist/lib/init-green-template.js"() {
38542
38592
  "use strict";
@@ -38545,12 +38595,12 @@ var init_init_green_template = __esm({
38545
38595
  init_init_scaffold();
38546
38596
  init_init_agent_guide();
38547
38597
  init_init_asset_types();
38548
- PACKAGE_JSON = `{
38549
- "name": "somewhere-starter",
38598
+ packageJson = /* @__PURE__ */ __name((appName) => `{
38599
+ "name": ${JSON.stringify(starterNameSlug(appName).slice(0, 214) || "somewhere-starter")},
38550
38600
  "private": true,
38551
38601
  "version": "0.1.0",
38552
38602
  "type": "module",
38553
- "somewhere": { "cli_version": "${CLI_VERSION}" },
38603
+ "somewhere": { "cli_version": "${CLI_VERSION}", "project_name": ${JSON.stringify(appName)} },
38554
38604
  "scripts": {
38555
38605
  "dev": "npx -y @somewhere-cloud/cli dev",
38556
38606
  "typecheck": "npx -y @somewhere-cloud/cli typecheck"
@@ -38570,7 +38620,7 @@ var init_init_green_template = __esm({
38570
38620
  "esbuild": true
38571
38621
  }
38572
38622
  }
38573
- `;
38623
+ `, "packageJson");
38574
38624
  TSCONFIG = `{
38575
38625
  "compilerOptions": {
38576
38626
  "target": "ES2022",
@@ -40782,13 +40832,13 @@ var require_semver2 = __commonJS({
40782
40832
  });
40783
40833
 
40784
40834
  // dist/lib/project-pin.js
40785
- import { existsSync as existsSync7, readFileSync as readFileSync8, writeFileSync as writeFileSync7 } from "node:fs";
40835
+ import { existsSync as existsSync7, readFileSync as readFileSync9, writeFileSync as writeFileSync7 } from "node:fs";
40786
40836
  import { dirname as dirname2, join as join7 } from "node:path";
40787
40837
  function readJson(path3) {
40788
40838
  if (!existsSync7(path3))
40789
40839
  return null;
40790
40840
  try {
40791
- const value = JSON.parse(readFileSync8(path3, "utf8"));
40841
+ const value = JSON.parse(readFileSync9(path3, "utf8"));
40792
40842
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
40793
40843
  } catch {
40794
40844
  return null;
@@ -40860,6 +40910,8 @@ function decidePin(dir, running, argv, env) {
40860
40910
  const pin = readProjectPin(dir);
40861
40911
  if (!pin || pinSatisfied(pin, running))
40862
40912
  return none;
40913
+ if (argv[2] === "login" && loadConfig()?.temporary)
40914
+ return none;
40863
40915
  const installed = installedPinnedCli(dir, pin, running);
40864
40916
  if (pin.versionOnly) {
40865
40917
  if (installed)
@@ -40894,7 +40946,7 @@ function writeProjectPins(dir, pins, version2) {
40894
40946
  const written = [];
40895
40947
  for (const pin of pins) {
40896
40948
  const path3 = join7(dir, pin.source);
40897
- const raw = readFileSync8(path3, "utf8");
40949
+ const raw = readFileSync9(path3, "utf8");
40898
40950
  const json2 = JSON.parse(raw);
40899
40951
  if (pin.versionOnly) {
40900
40952
  json2.somewhere[PIN_FILE_KEY] = version2;
@@ -40926,7 +40978,7 @@ function recordPinIfMissing(dir, version2) {
40926
40978
  return true;
40927
40979
  }
40928
40980
  function readBundledChangelog() {
40929
- return readFileSync8(join7(CLI_PACKAGE_ROOT, "CHANGELOG.md"), "utf8");
40981
+ return readFileSync9(join7(CLI_PACKAGE_ROOT, "CHANGELOG.md"), "utf8");
40930
40982
  }
40931
40983
  function changelogBetween(markdown, from, to2) {
40932
40984
  const entries = [];
@@ -40948,6 +41000,7 @@ var init_project_pin = __esm({
40948
41000
  "use strict";
40949
41001
  init_package_root();
40950
41002
  init_cli_invocation();
41003
+ init_config();
40951
41004
  import_semver = __toESM(require_semver2(), 1);
40952
41005
  CLI_PACKAGE_NAME = "@somewhere-cloud/cli";
40953
41006
  PIN_FILE_KEY = "cli_version";
@@ -42852,7 +42905,7 @@ Rerun only to answer a question. A pass means the checks you wrote passed; say w
42852
42905
  After edits:`) },
42853
42906
  { path: "CLAUDE.md", content: INIT_CLAUDE_MD },
42854
42907
  { path: "README.md", content: readme(selection) },
42855
- { path: "package.json", content: PACKAGE_JSON2 },
42908
+ { path: "package.json", content: packageJson2(options2.appName) },
42856
42909
  { path: "tsconfig.json", content: TSCONFIG2 },
42857
42910
  { path: "index.html", content: indexHtml(options2.appName) },
42858
42911
  { path: "api/auth/[...path].ts", content: AUTH_API },
@@ -42903,7 +42956,7 @@ After edits:`) },
42903
42956
  }
42904
42957
  return files;
42905
42958
  }
42906
- 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;
42907
42960
  var init_init_feature_template = __esm({
42908
42961
  "dist/lib/init-feature-template.js"() {
42909
42962
  "use strict";
@@ -42915,12 +42968,12 @@ var init_init_feature_template = __esm({
42915
42968
  init_init_scaffold();
42916
42969
  init_init_agent_guide();
42917
42970
  init_init_ui_kit();
42918
- PACKAGE_JSON2 = `{
42919
- "name": "somewhere-app",
42971
+ packageJson2 = /* @__PURE__ */ __name((appName) => `{
42972
+ "name": ${JSON.stringify(starterNameSlug(appName).slice(0, 214) || "somewhere-app")},
42920
42973
  "private": true,
42921
42974
  "version": "0.1.0",
42922
42975
  "type": "module",
42923
- "somewhere": { "cli_version": "${CLI_VERSION}" },
42976
+ "somewhere": { "cli_version": "${CLI_VERSION}", "project_name": ${JSON.stringify(appName)} },
42924
42977
  "scripts": {
42925
42978
  "dev": "npx -y @somewhere-cloud/cli dev",
42926
42979
  "typecheck": "npx -y @somewhere-cloud/cli typecheck"
@@ -42940,7 +42993,7 @@ var init_init_feature_template = __esm({
42940
42993
  "esbuild": true
42941
42994
  }
42942
42995
  }
42943
- `;
42996
+ `, "packageJson");
42944
42997
  TSCONFIG2 = `{
42945
42998
  "compilerOptions": {
42946
42999
  "target": "ES2022",
@@ -46091,7 +46144,7 @@ async function runInit(opts, command) {
46091
46144
  process.exit(2);
46092
46145
  }
46093
46146
  }
46094
- 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");
46095
46148
  const storedConfig = loadConfig();
46096
46149
  if (!hasUsableCredential(storedConfig) && !opts.link && !opts.bare) {
46097
46150
  const expiredTemporaryAt = temporaryConfigExpired(storedConfig) ? storedConfig.temp_expires_at : void 0;
@@ -72074,7 +72127,7 @@ var init_privacy = __esm({
72074
72127
  });
72075
72128
 
72076
72129
  // dist/lib/role-method-hints.js
72077
- 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";
72078
72131
  import { createRequire as createRequire2 } from "node:module";
72079
72132
  import { join as join9, relative as relative2, resolve as resolve4 } from "node:path";
72080
72133
  function roleMethodHints(projectDir, { removedOnly = false } = {}) {
@@ -72113,7 +72166,7 @@ function roleMethodHints(projectDir, { removedOnly = false } = {}) {
72113
72166
  }
72114
72167
  if (!entry.isFile() || !/\.[cm]?[jt]sx?$/.test(entry.name) || /\.d\.ts$/.test(entry.name))
72115
72168
  continue;
72116
- 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);
72117
72170
  const exports = /* @__PURE__ */ new Set();
72118
72171
  let unknown2 = false;
72119
72172
  for (const statement of file2.statements) {
@@ -72171,7 +72224,7 @@ var init_role_method_hints = __esm({
72171
72224
  });
72172
72225
 
72173
72226
  // dist/lib/notify/providers/update.js
72174
- import { existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync8 } from "node:fs";
72227
+ import { existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync11, writeFileSync as writeFileSync8 } from "node:fs";
72175
72228
  import { dirname as dirname3, join as join10 } from "node:path";
72176
72229
  function isNewer(a, b2) {
72177
72230
  const parse3 = /* @__PURE__ */ __name((v2) => v2.split("-")[0].split(".").map((n) => Number(n)), "parse");
@@ -72187,7 +72240,7 @@ function isNewer(a, b2) {
72187
72240
  }
72188
72241
  function readCache(cachePath = CACHE_PATH) {
72189
72242
  try {
72190
- const c = JSON.parse(readFileSync10(cachePath, "utf8"));
72243
+ const c = JSON.parse(readFileSync11(cachePath, "utf8"));
72191
72244
  if (typeof c?.checkedAt !== "number")
72192
72245
  return null;
72193
72246
  return c;
@@ -72250,7 +72303,7 @@ async function getOutdatedWarning(currentVersion3, options2 = {}) {
72250
72303
  const warnedPath = options2.warnedPath ?? WARNED_PATH;
72251
72304
  const now2 = (options2.now ?? Date.now)();
72252
72305
  try {
72253
- const warned2 = JSON.parse(readFileSync10(warnedPath, "utf8"));
72306
+ const warned2 = JSON.parse(readFileSync11(warnedPath, "utf8"));
72254
72307
  if (typeof warned2.warnedAt === "number" && now2 - warned2.warnedAt < ONE_DAY && now2 >= warned2.warnedAt)
72255
72308
  return null;
72256
72309
  } catch {
@@ -72322,7 +72375,7 @@ var init_update = __esm({
72322
72375
  });
72323
72376
 
72324
72377
  // dist/lib/notify/index.js
72325
- import { readFileSync as readFileSync11 } from "node:fs";
72378
+ import { readFileSync as readFileSync12 } from "node:fs";
72326
72379
  import { join as join11 } from "node:path";
72327
72380
  function suppressExitNotices() {
72328
72381
  exitNoticesSuppressed = true;
@@ -72337,7 +72390,7 @@ function subcommandSuppressesNotifications(argv) {
72337
72390
  }
72338
72391
  function currentVersion() {
72339
72392
  try {
72340
- 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"));
72341
72394
  return pkg.version;
72342
72395
  } catch {
72343
72396
  return "0.0.0";
@@ -72399,11 +72452,11 @@ __export(declared_data_exports, {
72399
72452
  declaredDataPlugin: () => declaredDataPlugin,
72400
72453
  prepareDeclaredData: () => prepareDeclaredData
72401
72454
  });
72402
- 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";
72403
72456
  import { createRequire as createRequire3 } from "node:module";
72404
72457
  import { join as join12, resolve as resolve5 } from "node:path";
72405
72458
  function generatedContents(path3) {
72406
- const previous = existsSync11(path3) ? readFileSync12(path3, "utf8") : void 0;
72459
+ const previous = existsSync11(path3) ? readFileSync13(path3, "utf8") : void 0;
72407
72460
  if (previous !== void 0 && !previous.startsWith(GENERATED_DATA_HEADER)) {
72408
72461
  throw new Error(`Cannot overwrite ${path3}; this path is reserved for a generated declaration.`);
72409
72462
  }
@@ -72414,8 +72467,8 @@ function prepareDeclaredData(projectDir) {
72414
72467
  const declarationDir = existsSync11(join12(projectDir, "src")) ? join12(projectDir, "src") : projectDir;
72415
72468
  const declarationPath = join12(declarationDir, DATA_DECLARATION_FILE);
72416
72469
  const filesPath = join12(declarationDir, FILES_DECLARATION_FILE);
72417
- const previous = existsSync11(declarationPath) ? readFileSync12(declarationPath, "utf8") : void 0;
72418
- 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;
72419
72472
  if (!existsSync11(schemaPath)) {
72420
72473
  if (previousFiles?.startsWith(GENERATED_DATA_HEADER))
72421
72474
  rmSync2(filesPath);
@@ -72436,7 +72489,7 @@ function prepareDeclaredData(projectDir) {
72436
72489
  let filesDeclaration;
72437
72490
  const generator = require3("./runtime/declared-data.cjs");
72438
72491
  try {
72439
- const files = { "db/schema.ts": readFileSync12(schemaPath, "utf8") };
72492
+ const files = { "db/schema.ts": readFileSync13(schemaPath, "utf8") };
72440
72493
  client = generator.generateFromFiles(files);
72441
72494
  localDeclaration = generator.localDeclarationFromFiles(files);
72442
72495
  tables = generator.declaredTablesFromFiles(files);
@@ -72566,7 +72619,7 @@ __export(typecheck_exports, {
72566
72619
  typecheckTimeoutMs: () => typecheckTimeoutMs
72567
72620
  });
72568
72621
  import { spawn as spawn3, spawnSync } from "node:child_process";
72569
- 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";
72570
72623
  import { randomUUID as randomUUID4 } from "node:crypto";
72571
72624
  import { dirname as dirname4, join as join13, relative as relative3 } from "node:path";
72572
72625
  function isUnresolvedBareImport(e) {
@@ -72606,7 +72659,7 @@ function resolveTsc(projectDir) {
72606
72659
  function declaredDependencies(projectDir) {
72607
72660
  let manifest;
72608
72661
  try {
72609
- manifest = JSON.parse(readFileSync13(join13(projectDir, "package.json"), "utf8"));
72662
+ manifest = JSON.parse(readFileSync14(join13(projectDir, "package.json"), "utf8"));
72610
72663
  } catch {
72611
72664
  return {};
72612
72665
  }
@@ -74813,7 +74866,7 @@ __export(files_exports, {
74813
74866
  testExclusionReason: () => testExclusionReason,
74814
74867
  testFolderOf: () => testFolderOf
74815
74868
  });
74816
- 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";
74817
74870
  import { extname as extname3, isAbsolute as isAbsolute2, join as join16, relative as relative6 } from "node:path";
74818
74871
  function isTestSourcePath(relPath) {
74819
74872
  return TEST_SOURCE_NAME.test(relPath.slice(relPath.lastIndexOf("/") + 1));
@@ -74883,7 +74936,7 @@ function collectFiles(baseDir, options2 = {}) {
74883
74936
  }
74884
74937
  const corpusFiles = /* @__PURE__ */ __name((paths) => paths.filter((relPath) => isReferenceCorpusPath(relPath) && (sizes.get(relPath) ?? 0) <= MAX_FILE_SIZE).map((relPath) => {
74885
74938
  try {
74886
- return [relPath, readFileSync14(join16(baseDir, relPath), "utf-8")];
74939
+ return [relPath, readFileSync15(join16(baseDir, relPath), "utf-8")];
74887
74940
  } catch {
74888
74941
  return [relPath, ""];
74889
74942
  }
@@ -74962,7 +75015,7 @@ function walk(baseDir, currentDir, out, ignore, candidates, sizes) {
74962
75015
  out.sensitive.push({ path: relPath, reason: SENSITIVE_FILE_REASON, referencedBy: [] });
74963
75016
  continue;
74964
75017
  }
74965
- 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))
74966
75019
  continue;
74967
75020
  sizes.set(relPath, statSync2(fullPath).size);
74968
75021
  candidates.push(relPath);
@@ -74986,11 +75039,11 @@ function classifyInto(out, baseDir, relPath, readBinary = true) {
74986
75039
  const fullPath = join16(baseDir, relPath);
74987
75040
  const { kind, key } = classifyKey(relPath);
74988
75041
  if (kind === "function") {
74989
- out.functions[key] = readFileSync14(fullPath, "utf-8");
75042
+ out.functions[key] = readFileSync15(fullPath, "utf-8");
74990
75043
  } else if (kind === "binary") {
74991
- out.binaryFiles[key] = readBinary ? readFileSync14(fullPath).toString("base64") : "";
75044
+ out.binaryFiles[key] = readBinary ? readFileSync15(fullPath).toString("base64") : "";
74992
75045
  } else {
74993
- out.files[key] = readFileSync14(fullPath, "utf-8");
75046
+ out.files[key] = readFileSync15(fullPath, "utf-8");
74994
75047
  }
74995
75048
  }
74996
75049
  function formatBytes(bytes) {
@@ -75010,7 +75063,7 @@ function loadDeployIgnore(baseDir) {
75010
75063
  const path3 = join16(baseDir, fileName2);
75011
75064
  if (!existsSync13(path3))
75012
75065
  continue;
75013
- const lines = readFileSync14(path3, "utf8").split(/\r?\n/);
75066
+ const lines = readFileSync15(path3, "utf8").split(/\r?\n/);
75014
75067
  for (const raw of lines) {
75015
75068
  const rule = parseIgnoreRule(raw);
75016
75069
  if (!rule)
@@ -75266,12 +75319,12 @@ var init_files = __esm({
75266
75319
 
75267
75320
  // dist/lib/deploy-check.js
75268
75321
  import { randomUUID as randomUUID5 } from "node:crypto";
75269
- 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";
75270
75323
  import { createRequire as createRequire4 } from "node:module";
75271
75324
  import { isAbsolute as isAbsolute3, join as join17, relative as relative7, resolve as resolve8 } from "node:path";
75272
75325
  function projectTypeScriptVersion(projectDir) {
75273
75326
  try {
75274
- 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;
75275
75328
  return typeof version2 === "string" && version2 ? version2 : null;
75276
75329
  } catch {
75277
75330
  return null;
@@ -75285,7 +75338,7 @@ function announceDeployCheckFetch(projectDir) {
75285
75338
  function deployCheckTsc(projectDir, platform2 = process.platform) {
75286
75339
  try {
75287
75340
  const manifest = join17(projectDir, "node_modules", "typescript", "package.json");
75288
- if (JSON.parse(readFileSync15(manifest, "utf8")).version === DEPLOY_CHECK_TYPESCRIPT_VERSION) {
75341
+ if (JSON.parse(readFileSync16(manifest, "utf8")).version === DEPLOY_CHECK_TYPESCRIPT_VERSION) {
75289
75342
  return { command: process.execPath, args: [join17(projectDir, "node_modules", "typescript", "bin", "tsc")] };
75290
75343
  }
75291
75344
  } catch {
@@ -75390,7 +75443,7 @@ async function startDeployCheck(projectDir) {
75390
75443
  if (checked.length === 0)
75391
75444
  return { ok: true, findings: [], typescript, checkedFiles: 0 };
75392
75445
  const tsconfigPath = join17(projectDir, "tsconfig.json");
75393
- const own = projectCompilerOptions(existsSync14(tsconfigPath) ? readFileSync15(tsconfigPath, "utf8") : void 0);
75446
+ const own = projectCompilerOptions(existsSync14(tsconfigPath) ? readFileSync16(tsconfigPath, "utf8") : void 0);
75394
75447
  const id = randomUUID5();
75395
75448
  const config2 = join17(projectDir, `.__somewhere_deploy_check_${id}.json`);
75396
75449
  const declarationsDir = join17(projectDir, `.__somewhere_deploy_check_${id}`);
@@ -75460,7 +75513,7 @@ var init_deploy_check = __esm({
75460
75513
  });
75461
75514
 
75462
75515
  // dist/lib/agent-hooks.js
75463
- 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";
75464
75517
  import { homedir as homedir2 } from "node:os";
75465
75518
  import { delimiter, dirname as dirname7, isAbsolute as isAbsolute4, join as join18, relative as relative8, resolve as resolve9, sep } from "node:path";
75466
75519
  function isAgentHost(value) {
@@ -75498,7 +75551,7 @@ function readConfig(path3) {
75498
75551
  if (!existsSync15(path3))
75499
75552
  return {};
75500
75553
  try {
75501
- const parsed = JSON.parse(readFileSync16(path3, "utf8"));
75554
+ const parsed = JSON.parse(readFileSync17(path3, "utf8"));
75502
75555
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : new Error("is not a JSON object");
75503
75556
  } catch (error3) {
75504
75557
  return error3 instanceof Error ? error3 : new Error(String(error3));
@@ -75638,7 +75691,7 @@ function hookProjectRoot(host, payload, env = process.env, cwd = process.cwd())
75638
75691
  return null;
75639
75692
  for (let dir = resolve9(start); ; dir = dirname7(dir)) {
75640
75693
  const config2 = join18(dir, HOSTS[host].configPath);
75641
- if (existsSync15(config2) && HOOK_MARKER.test(readFileSync16(config2, "utf8")))
75694
+ if (existsSync15(config2) && HOOK_MARKER.test(readFileSync17(config2, "utf8")))
75642
75695
  return dir;
75643
75696
  if (dirname7(dir) === dir)
75644
75697
  return null;
@@ -75962,7 +76015,7 @@ var init_typecheck2 = __esm({
75962
76015
 
75963
76016
  // dist/lib/base-files.js
75964
76017
  import { createHash as createHash3 } from "node:crypto";
75965
- 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";
75966
76019
  import { join as join20 } from "node:path";
75967
76020
  function sha2562(content) {
75968
76021
  return createHash3("sha256").update(content).digest("hex");
@@ -75970,7 +76023,7 @@ function sha2562(content) {
75970
76023
  function hashFiles(dir, paths) {
75971
76024
  const out = {};
75972
76025
  for (const path3 of paths)
75973
- out[path3] = sha2562(readFileSync17(join20(dir, path3)));
76026
+ out[path3] = sha2562(readFileSync18(join20(dir, path3)));
75974
76027
  return out;
75975
76028
  }
75976
76029
  function saveBaseFiles(dir, base) {
@@ -75985,7 +76038,7 @@ function loadBaseFiles(dir, projectId, releaseId) {
75985
76038
  if (!existsSync17(path3) || releaseId === void 0)
75986
76039
  return null;
75987
76040
  try {
75988
- const parsed = JSON.parse(readFileSync17(path3, "utf8"));
76041
+ const parsed = JSON.parse(readFileSync18(path3, "utf8"));
75989
76042
  if (parsed.project_id !== projectId || parsed.release_id !== releaseId || !parsed.files || typeof parsed.files !== "object")
75990
76043
  return null;
75991
76044
  return parsed;
@@ -76002,7 +76055,7 @@ function loadLastActivation(dir) {
76002
76055
  if (!existsSync17(path3))
76003
76056
  return null;
76004
76057
  try {
76005
- return JSON.parse(readFileSync17(path3, "utf8"));
76058
+ return JSON.parse(readFileSync18(path3, "utf8"));
76006
76059
  } catch {
76007
76060
  return null;
76008
76061
  }
@@ -76117,7 +76170,7 @@ var init_live_refusal = __esm({
76117
76170
  });
76118
76171
 
76119
76172
  // dist/lib/build-errors.js
76120
- import { existsSync as existsSync18, readFileSync as readFileSync18 } from "node:fs";
76173
+ import { existsSync as existsSync18, readFileSync as readFileSync19 } from "node:fs";
76121
76174
  import { isAbsolute as isAbsolute5, join as join21 } from "node:path";
76122
76175
  function parseBundleErrorText(text) {
76123
76176
  const out = [];
@@ -76151,7 +76204,7 @@ function frameFor(detail, baseDir, serverFrame) {
76151
76204
  const abs = isAbsolute5(detail.file) ? detail.file : join21(baseDir, detail.file);
76152
76205
  if (existsSync18(abs)) {
76153
76206
  try {
76154
- const frame = localCodeFrame(readFileSync18(abs, "utf-8"), detail.line, detail.column);
76207
+ const frame = localCodeFrame(readFileSync19(abs, "utf-8"), detail.line, detail.column);
76155
76208
  if (frame)
76156
76209
  return frame;
76157
76210
  } catch {
@@ -76487,7 +76540,7 @@ var init_claim_handoff = __esm({
76487
76540
  });
76488
76541
 
76489
76542
  // dist/lib/project-notices.js
76490
- import { existsSync as existsSync19, mkdirSync as mkdirSync11, readFileSync as readFileSync19, writeFileSync as writeFileSync14 } from "node:fs";
76543
+ import { existsSync as existsSync19, mkdirSync as mkdirSync11, readFileSync as readFileSync20, writeFileSync as writeFileSync14 } from "node:fs";
76491
76544
  import { dirname as dirname8, join as join22 } from "node:path";
76492
76545
  function localDay(now2) {
76493
76546
  const date5 = new Date(now2);
@@ -76497,7 +76550,7 @@ function readState(path3) {
76497
76550
  if (!existsSync19(path3))
76498
76551
  return { shown: {} };
76499
76552
  try {
76500
- const parsed = JSON.parse(readFileSync19(path3, "utf8"));
76553
+ const parsed = JSON.parse(readFileSync20(path3, "utf8"));
76501
76554
  return parsed.shown && typeof parsed.shown === "object" ? { shown: parsed.shown } : { shown: {} };
76502
76555
  } catch {
76503
76556
  return { shown: {} };
@@ -76549,7 +76602,7 @@ var init_project_notices = __esm({
76549
76602
  });
76550
76603
 
76551
76604
  // dist/lib/test-identities.js
76552
- 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";
76553
76606
  import { join as join23 } from "node:path";
76554
76607
  import { randomBytes as randomBytes3 } from "node:crypto";
76555
76608
  function parseActorSpecs(values) {
@@ -76606,7 +76659,7 @@ ${TEST_STATE_GITIGNORE_LINE}
76606
76659
  `);
76607
76660
  return "created";
76608
76661
  }
76609
- const text = readFileSync20(path3, "utf8");
76662
+ const text = readFileSync21(path3, "utf8");
76610
76663
  const lines = text.split(/\r?\n/).map((line) => line.trim());
76611
76664
  if (lines.some((line) => [".somewhere/test/", ".somewhere/test", "/.somewhere/test/", "/.somewhere/test", ".somewhere/", ".somewhere", "/.somewhere/", "/.somewhere"].includes(line)))
76612
76665
  return "present";
@@ -76623,7 +76676,7 @@ function readManifest(root) {
76623
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");
76624
76677
  let value;
76625
76678
  try {
76626
- value = JSON.parse(readFileSync20(path3, "utf8"));
76679
+ value = JSON.parse(readFileSync21(path3, "utf8"));
76627
76680
  } catch {
76628
76681
  throw invalid("not JSON");
76629
76682
  }
@@ -76793,7 +76846,7 @@ var init_test_identities = __esm({
76793
76846
  });
76794
76847
 
76795
76848
  // dist/lib/form-accounts.js
76796
- 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";
76797
76850
  import { join as join24 } from "node:path";
76798
76851
  import { randomBytes as randomBytes4 } from "node:crypto";
76799
76852
  function readDeletionAnswer(ids, answer) {
@@ -76890,7 +76943,7 @@ function recordAttempt(control, root, email3) {
76890
76943
  return path3;
76891
76944
  }
76892
76945
  function recordId(path3, id) {
76893
- const record3 = JSON.parse(readFileSync21(path3, "utf8"));
76946
+ const record3 = JSON.parse(readFileSync22(path3, "utf8"));
76894
76947
  writePrivateFile(path3, JSON.stringify({ ...record3, id }) + "\n");
76895
76948
  }
76896
76949
  function forgetRecord(path3) {
@@ -76926,7 +76979,7 @@ async function sweepAccounts(control, root) {
76926
76979
  const path3 = join24(dir, name);
76927
76980
  let record3;
76928
76981
  try {
76929
- record3 = JSON.parse(readFileSync21(path3, "utf8"));
76982
+ record3 = JSON.parse(readFileSync22(path3, "utf8"));
76930
76983
  } catch {
76931
76984
  result.failed.push(name);
76932
76985
  continue;
@@ -77113,14 +77166,14 @@ var init_test_target = __esm({
77113
77166
  });
77114
77167
 
77115
77168
  // dist/lib/preview-credential.js
77116
- 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";
77117
77170
  import { join as join25 } from "node:path";
77118
77171
  function loadPreviewCredential(projectId, previewSessionId) {
77119
77172
  const path3 = join25(cliConfigDir(), SUBDIR, fileName(projectId, previewSessionId));
77120
77173
  if (!existsSync22(path3))
77121
77174
  return null;
77122
77175
  try {
77123
- const stored = JSON.parse(readFileSync22(path3, "utf8"));
77176
+ const stored = JSON.parse(readFileSync23(path3, "utf8"));
77124
77177
  return stored.project_id === projectId && stored.preview_session_id === previewSessionId && typeof stored.credential === "string" ? stored.credential : null;
77125
77178
  } catch {
77126
77179
  return null;
@@ -77164,14 +77217,14 @@ var init_preview_credential = __esm({
77164
77217
  });
77165
77218
 
77166
77219
  // dist/lib/preview-record.js
77167
- 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";
77168
77221
  import { join as join26 } from "node:path";
77169
77222
  function loadPreviewRecord(dir, projectId) {
77170
77223
  const path3 = join26(dir, PREVIEW_RECORD);
77171
77224
  if (!existsSync23(path3))
77172
77225
  return null;
77173
77226
  try {
77174
- const parsed = JSON.parse(readFileSync23(path3, "utf8"));
77227
+ const parsed = JSON.parse(readFileSync24(path3, "utf8"));
77175
77228
  if (parsed.project_id !== projectId || typeof parsed.preview_session_id !== "string" || typeof parsed.preview_id !== "string" || !isRecord(parsed.files))
77176
77229
  return null;
77177
77230
  return parsed;
@@ -77633,7 +77686,7 @@ import { createRequire as createRequire5 } from "node:module";
77633
77686
  import { pathToFileURL } from "node:url";
77634
77687
  import { join as join28, dirname as dirname9 } from "node:path";
77635
77688
  import { spawn as spawn4, spawnSync as spawnSync2 } from "node:child_process";
77636
- 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";
77637
77690
  import { createHash as createHash6, randomUUID as randomUUID6 } from "node:crypto";
77638
77691
  function testImportEnv(root, env) {
77639
77692
  if (!readProjectPin(root)?.versionOnly)
@@ -77680,7 +77733,7 @@ async function prepareRunner(root) {
77680
77733
  mark("browser-probe:end");
77681
77734
  let playwright = "unknown";
77682
77735
  try {
77683
- playwright = JSON.parse(readFileSync24(join28(dirname9(cli), "package.json"), "utf8")).version ?? "unknown";
77736
+ playwright = JSON.parse(readFileSync25(join28(dirname9(cli), "package.json"), "utf8")).version ?? "unknown";
77684
77737
  } catch {
77685
77738
  }
77686
77739
  return { cli, channel, version: version2, browserLaunchMs, playwright };
@@ -77712,7 +77765,7 @@ async function runTests(input) {
77712
77765
  const dir = join28(root, ".somewhere", "tests");
77713
77766
  ensurePrivateDir(dir);
77714
77767
  const ignorePath = join28(root, ".gitignore");
77715
- const ignored = existsSync24(ignorePath) ? readFileSync24(ignorePath, "utf8") : "";
77768
+ const ignored = existsSync24(ignorePath) ? readFileSync25(ignorePath, "utf8") : "";
77716
77769
  for (const line of [".somewhere/", "playwright-report/", "test-results/"])
77717
77770
  if (!ignored.split(/\r?\n/).includes(line))
77718
77771
  appendFileSync2(ignorePath, `
@@ -77726,7 +77779,7 @@ ${line}
77726
77779
  const artifacts = join28(dir, createHash6("sha256").update(projectId + origin + (target.environment === "preview" ? `${target.previewSessionId}:${target.releaseId}` : "")).digest("hex").slice(0, 16));
77727
77780
  if (failed) {
77728
77781
  const lastRun = join28(artifacts, ".last-run.json");
77729
- if (!existsSync24(lastRun) || !JSON.parse(readFileSync24(lastRun, "utf8")).failedTests?.length) {
77782
+ if (!existsSync24(lastRun) || !JSON.parse(readFileSync25(lastRun, "utf8")).failedTests?.length) {
77730
77783
  throw new Error("No failed tests are recorded from the last run here; run somewhere test.");
77731
77784
  }
77732
77785
  }
@@ -77773,7 +77826,7 @@ ${line}
77773
77826
  }, "cleanArtifacts");
77774
77827
  cleanArtifacts(artifacts);
77775
77828
  const exitCode = status === null ? 1 : status || (after === null || after.failed.length || after.unknownId.length ? 1 : 0);
77776
- const results = existsSync24(resultsPath) ? JSON.parse(readFileSync24(resultsPath, "utf8")) : null;
77829
+ const results = existsSync24(resultsPath) ? JSON.parse(readFileSync25(resultsPath, "utf8")) : null;
77777
77830
  return { exitCode, results, target };
77778
77831
  }
77779
77832
  var init_test_run = __esm({
@@ -78086,7 +78139,7 @@ var init_browser_refusal = __esm({
78086
78139
  });
78087
78140
 
78088
78141
  // dist/lib/browser-actions.js
78089
- import { readFileSync as readFileSync25, statSync as statSync4 } from "node:fs";
78142
+ import { readFileSync as readFileSync26, statSync as statSync4 } from "node:fs";
78090
78143
  import { basename as basename4, extname as extname4, resolve as resolve11 } from "node:path";
78091
78144
  function decodedBase64Bytes(base643) {
78092
78145
  if (!base643 || base643.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(base643))
@@ -78142,7 +78195,7 @@ function resolveBrowserUpload(raw, baseDir = process.cwd()) {
78142
78195
  }
78143
78196
  const name = basename4(absolute);
78144
78197
  const contentType = MIME_TYPES[extname4(name).toLowerCase()] ?? "application/octet-stream";
78145
- const bytes = readFileSync25(absolute);
78198
+ const bytes = readFileSync26(absolute);
78146
78199
  if (bytes.length > MAX_BROWSER_UPLOAD_BYTES) {
78147
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).`);
78148
78201
  }
@@ -79275,7 +79328,7 @@ var init_verify_report = __esm({
79275
79328
 
79276
79329
  // dist/commands/browser.js
79277
79330
  import { dirname as dirname10, resolve as resolve13 } from "node:path";
79278
- import { readFileSync as readFileSync26 } from "node:fs";
79331
+ import { readFileSync as readFileSync27 } from "node:fs";
79279
79332
  function readBrowserIncomplete(r) {
79280
79333
  const raw = r.incomplete;
79281
79334
  if (!raw || typeof raw !== "object")
@@ -79644,7 +79697,7 @@ function registerBrowser(program2) {
79644
79697
  const collectActionsFile = /* @__PURE__ */ __name((file2) => {
79645
79698
  try {
79646
79699
  const absolute = resolve13(file2);
79647
- const raw = JSON.parse(readFileSync26(absolute, "utf8"));
79700
+ const raw = JSON.parse(readFileSync27(absolute, "utf8"));
79648
79701
  const normalized = normalizeBrowserActions(raw, dirname10(absolute));
79649
79702
  if (!normalized.ok)
79650
79703
  throw new InvalidArgumentError(normalized.error);
@@ -79798,7 +79851,7 @@ var init_browser = __esm({
79798
79851
 
79799
79852
  // dist/lib/verify-keep.js
79800
79853
  import { createHash as createHash7, randomBytes as randomBytes5 } from "node:crypto";
79801
- 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";
79802
79855
  import { join as join32 } from "node:path";
79803
79856
  function path(root) {
79804
79857
  return join32(stateDir(root), KEEP_FILE);
@@ -79807,7 +79860,7 @@ function readFile(root) {
79807
79860
  if (!existsSync26(path(root)))
79808
79861
  return {};
79809
79862
  try {
79810
- const parsed = JSON.parse(readFileSync27(path(root), "utf-8"));
79863
+ const parsed = JSON.parse(readFileSync28(path(root), "utf-8"));
79811
79864
  return parsed && typeof parsed === "object" ? parsed : {};
79812
79865
  } catch {
79813
79866
  return {};
@@ -79879,7 +79932,7 @@ function lockKeep(root, key, now2 = Date.now()) {
79879
79932
  throw cause;
79880
79933
  let stale = true;
79881
79934
  try {
79882
- const held = JSON.parse(readFileSync27(lock, "utf-8"));
79935
+ const held = JSON.parse(readFileSync28(lock, "utf-8"));
79883
79936
  const alive2 = typeof held.pid === "number" && (() => {
79884
79937
  try {
79885
79938
  process.kill(held.pid, 0);
@@ -80001,7 +80054,7 @@ var init_verify_keep = __esm({
80001
80054
 
80002
80055
  // dist/commands/verify.js
80003
80056
  import { randomBytes as randomBytes6 } from "node:crypto";
80004
- import { existsSync as existsSync27, readFileSync as readFileSync28 } from "node:fs";
80057
+ import { existsSync as existsSync27, readFileSync as readFileSync29 } from "node:fs";
80005
80058
  import { dirname as dirname11, resolve as resolve14 } from "node:path";
80006
80059
  function navigationRetryNote(retries) {
80007
80060
  if (!retries.length)
@@ -80222,7 +80275,7 @@ function normalizeVerifyFlow(raw, baseDir = process.cwd()) {
80222
80275
  function readVerifyFlowFile(absolute, flag) {
80223
80276
  let source;
80224
80277
  try {
80225
- source = readFileSync28(absolute, "utf8");
80278
+ source = readFileSync29(absolute, "utf8");
80226
80279
  } catch (cause) {
80227
80280
  if (cause instanceof Error && "code" in cause && cause.code === "ENOENT") {
80228
80281
  throw new Error(`Flow file not found. Pass ${flag} <path> with an existing JSON file. Run \`${cliInvocation()} verify --schema\` for the flow format.`);
@@ -81864,15 +81917,10 @@ function deriveNewProjectName(dirPath) {
81864
81917
  const base = slugify2(basename5(dirPath)) || "project";
81865
81918
  return `${base}-${randomSuffix()}`;
81866
81919
  }
81867
- function formatTtlHours(ttlSeconds) {
81868
- if (!ttlSeconds || !Number.isFinite(ttlSeconds))
81869
- return 3;
81870
- return Math.round(ttlSeconds / 3600) || 3;
81871
- }
81872
81920
  function formatTempExpiry(expiresAt, ttlSeconds, nowMs = Date.now()) {
81873
81921
  const remainingMs = expiresAt ? Date.parse(expiresAt) - nowMs : NaN;
81874
81922
  if (!Number.isFinite(remainingMs) || ttlSeconds !== void 0 && Number.isFinite(ttlSeconds) && (remainingMs > ttlSeconds * 1e3 + 6e4 || remainingMs < -6e4)) {
81875
- return `Temporary app. Expires about ${plural3(formatTtlHours(ttlSeconds), "hour")} after it was created.`;
81923
+ return "Temporary app.";
81876
81924
  }
81877
81925
  if (remainingMs <= 0)
81878
81926
  return "Temporary app. It has expired.";
@@ -82132,7 +82180,7 @@ No project yet? Signed in, deploy never creates one on its own:
82132
82180
  ${cliInvocation()} init --bare --name <name> create a project in your account and link this folder
82133
82181
  ${cliInvocation()} deploy then deploy it
82134
82182
  Existing project: \`${cliInvocation()} init --link --project <ref>\` (see \`${cliInvocation()} projects\`), or \`--project <ref>\` here.
82135
- `).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) => {
82136
82184
  const startupMs = performance.now();
82137
82185
  const targetDir = resolveTargetDir(dir);
82138
82186
  if (opts.new && (opts.project || opts.dryRun || opts.temporary)) {
@@ -82336,13 +82384,18 @@ Existing project: \`${cliInvocation()} init --link --project <ref>\` (see \`${cl
82336
82384
  } else if (tempSession || opts.new) {
82337
82385
  const createSpinner = opts.json ? null : ora(tempSession ? "Creating a temporary project..." : "Creating a new project...").start();
82338
82386
  try {
82339
- const name = deriveNewProjectName(targetDir);
82340
- 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
+ }
82341
82394
  createSpinner?.stop();
82342
82395
  targetProjectConfig = {
82343
82396
  project_id: created.id,
82344
82397
  name: created.name,
82345
- subdomain: created.subdomain ?? name,
82398
+ subdomain: created.subdomain ?? subdomain,
82346
82399
  source_base: sourceBaseState(created.id, null)
82347
82400
  };
82348
82401
  if (besideRealLogin && sideCar) {
@@ -83254,6 +83307,7 @@ var init_deploy = __esm({
83254
83307
  "dist/commands/deploy.js"() {
83255
83308
  "use strict";
83256
83309
  init_first_cli_permission();
83310
+ init_init_scaffold();
83257
83311
  init_link_hint();
83258
83312
  init_role_method_hints();
83259
83313
  init_cli_invocation();
@@ -83309,7 +83363,6 @@ var init_deploy = __esm({
83309
83363
  __name(slugify2, "slugify");
83310
83364
  __name(randomSuffix, "randomSuffix");
83311
83365
  __name(deriveNewProjectName, "deriveNewProjectName");
83312
- __name(formatTtlHours, "formatTtlHours");
83313
83366
  __name(formatTempExpiry, "formatTempExpiry");
83314
83367
  __name(plural3, "plural");
83315
83368
  __name(formatElapsed, "formatElapsed");
@@ -83460,7 +83513,7 @@ var init_deploys = __esm({
83460
83513
  });
83461
83514
 
83462
83515
  // dist/commands/pull.js
83463
- 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";
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";
83464
83517
  import { basename as basename6, dirname as dirname12, join as join34, relative as relative10, resolve as resolve16 } from "node:path";
83465
83518
  function registerPull(program2) {
83466
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) => {
@@ -83545,7 +83598,7 @@ function registerPull(program2) {
83545
83598
  const target = join34(outDir, path3);
83546
83599
  if (!existsSync29(target))
83547
83600
  continue;
83548
- const local = readFileSync29(target);
83601
+ const local = readFileSync30(target);
83549
83602
  if (local.equals(contents))
83550
83603
  continue;
83551
83604
  if (opts.force) {
@@ -83679,7 +83732,7 @@ function reconcileRemovedFiles(outDir, expected, force, base = null) {
83679
83732
  const was = base?.files[relPath];
83680
83733
  if (base && was === void 0)
83681
83734
  continue;
83682
- const unedited = was !== void 0 && was === sha2562(readFileSync29(fullPath));
83735
+ const unedited = was !== void 0 && was === sha2562(readFileSync30(fullPath));
83683
83736
  if (!force && !unedited) {
83684
83737
  skipped.push(relPath);
83685
83738
  continue;
@@ -84832,7 +84885,7 @@ var init_db = __esm({
84832
84885
  });
84833
84886
 
84834
84887
  // dist/commands/postgres.js
84835
- import { readFileSync as readFileSync30 } from "node:fs";
84888
+ import { readFileSync as readFileSync31 } from "node:fs";
84836
84889
  function str(value) {
84837
84890
  return typeof value === "string" && value.length > 0 ? value : null;
84838
84891
  }
@@ -84841,7 +84894,7 @@ async function readNeonApiKey() {
84841
84894
  if (fromEnv)
84842
84895
  return fromEnv;
84843
84896
  if (!process.stdin.isTTY) {
84844
- return readFileSync30(0, "utf8").trim();
84897
+ return readFileSync31(0, "utf8").trim();
84845
84898
  }
84846
84899
  const response = await (0, import_prompts8.default)({
84847
84900
  type: "password",
@@ -85170,7 +85223,7 @@ var init_postgres = __esm({
85170
85223
  });
85171
85224
 
85172
85225
  // dist/lib/advisor-context.js
85173
- import { readFileSync as readFileSync31, statSync as statSync6 } from "node:fs";
85226
+ import { readFileSync as readFileSync32, statSync as statSync6 } from "node:fs";
85174
85227
  import { basename as basename7 } from "node:path";
85175
85228
  function tail(value, limit) {
85176
85229
  return value.length <= limit ? value : `\u2026${value.slice(-limit)}`;
@@ -85192,7 +85245,7 @@ function buildAdvisorContext(filePath) {
85192
85245
  const stat6 = statSync6(filePath);
85193
85246
  if (!stat6.isFile())
85194
85247
  throw new Error("--file must name a regular file.");
85195
- const content = readFileSync31(filePath, "utf8");
85248
+ const content = readFileSync32(filePath, "utf8");
85196
85249
  context.file = {
85197
85250
  path: filePath,
85198
85251
  content: tail(redactAdvisorText(content, isDotenvPath(filePath)), FILE_LIMIT)
@@ -85218,7 +85271,7 @@ var init_advisor_context = __esm({
85218
85271
 
85219
85272
  // dist/lib/advisor-runs.js
85220
85273
  import { randomBytes as randomBytes7, randomUUID as randomUUID7 } from "node:crypto";
85221
- 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";
85222
85275
  import { join as join36 } from "node:path";
85223
85276
  function path2(id) {
85224
85277
  if (!/^[a-f0-9-]{36}$/i.test(id))
@@ -85255,7 +85308,7 @@ function expiredResult(record3) {
85255
85308
  function load(id) {
85256
85309
  if (!existsSync31(path2(id)))
85257
85310
  throw Error("Advisor request was not found in this CLI configuration.");
85258
- const record3 = JSON.parse(readFileSync32(path2(id), "utf8"));
85311
+ const record3 = JSON.parse(readFileSync33(path2(id), "utf8"));
85259
85312
  prune(record3);
85260
85313
  save(record3);
85261
85314
  return record3;
@@ -86630,7 +86683,7 @@ var init_envfile_write = __esm({
86630
86683
  });
86631
86684
 
86632
86685
  // dist/commands/env.js
86633
- 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";
86634
86687
  import { resolve as resolve19 } from "node:path";
86635
86688
  function resolveProjectId(explicit) {
86636
86689
  if (explicit)
@@ -86700,7 +86753,7 @@ function registerEnv(program2) {
86700
86753
  process.exit(1);
86701
86754
  }
86702
86755
  if (existsSync32(outPath) && !opts.force) {
86703
- const existing = readFileSync33(outPath, "utf-8");
86756
+ const existing = readFileSync34(outPath, "utf-8");
86704
86757
  const hasValues = existing.split("\n").some((l) => /^[^#=]+=.+/.test(l.trim()));
86705
86758
  const { ok } = await (0, import_prompts9.default)({
86706
86759
  type: "confirm",
@@ -86753,7 +86806,7 @@ function registerEnv(program2) {
86753
86806
  if (inputNote && !opts.json)
86754
86807
  process.stderr.write(`Note: ${inputNote}
86755
86808
  `);
86756
- const value = opts.stdin ? readFileSync33(0, "utf8").replace(/\r?\n$/, "") : positionalValue;
86809
+ const value = opts.stdin ? readFileSync34(0, "utf8").replace(/\r?\n$/, "") : positionalValue;
86757
86810
  const client = new ApiClient(getToken());
86758
86811
  const pid = resolveProjectId(opts.project);
86759
86812
  try {
@@ -86822,7 +86875,7 @@ var init_env = __esm({
86822
86875
  });
86823
86876
 
86824
86877
  // dist/commands/run.js
86825
- import { existsSync as existsSync33, readFileSync as readFileSync34 } from "node:fs";
86878
+ import { existsSync as existsSync33, readFileSync as readFileSync35 } from "node:fs";
86826
86879
  import { isAbsolute as isAbsolute6, resolve as resolve20 } from "node:path";
86827
86880
  function parseArgs(values) {
86828
86881
  if (!values.length)
@@ -86872,7 +86925,7 @@ function registerRun(program2) {
86872
86925
  error(`File not found: ${script}`);
86873
86926
  process.exit(1);
86874
86927
  }
86875
- const code = readFileSync34(absPath, "utf-8");
86928
+ const code = readFileSync35(absPath, "utf-8");
86876
86929
  if (!code.trim()) {
86877
86930
  error(`${script} is empty \u2014 nothing to run.`);
86878
86931
  process.exit(1);
@@ -87515,7 +87568,7 @@ var init_preview_jobs = __esm({
87515
87568
 
87516
87569
  // dist/commands/dev.js
87517
87570
  import { randomUUID as randomUUID8 } from "node:crypto";
87518
- import { existsSync as existsSync34, readFileSync as readFileSync35 } from "node:fs";
87571
+ import { existsSync as existsSync34, readFileSync as readFileSync36 } from "node:fs";
87519
87572
  import { join as join38, relative as relative11 } from "node:path";
87520
87573
  function previewFinishedReason(err) {
87521
87574
  if (!(err instanceof CliApiError) || err.code !== "DRAFT_SESSION_TERMINAL")
@@ -88504,11 +88557,11 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
88504
88557
  continue;
88505
88558
  const { kind, key } = classifyKey(rel);
88506
88559
  if (kind === "function")
88507
- updateFunctions[key] = readFileSync35(abs, "utf-8");
88560
+ updateFunctions[key] = readFileSync36(abs, "utf-8");
88508
88561
  else if (kind === "binary")
88509
- updateBinary[key] = readFileSync35(abs).toString("base64");
88562
+ updateBinary[key] = readFileSync36(abs).toString("base64");
88510
88563
  else
88511
- updateFiles[key] = readFileSync35(abs, "utf-8");
88564
+ updateFiles[key] = readFileSync36(abs, "utf-8");
88512
88565
  }
88513
88566
  for (const rel of deleted)
88514
88567
  deleteKeys.push(classifyKey(rel).key);
@@ -128649,7 +128702,7 @@ var require_dist15 = __commonJS({
128649
128702
 
128650
128703
  // dist/lib/update-security.js
128651
128704
  import { createHash as createHash8, timingSafeEqual } from "node:crypto";
128652
- 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";
128653
128706
  import { join as join41 } from "node:path";
128654
128707
  import { Readable as Readable2 } from "node:stream";
128655
128708
  import { pipeline as pipeline3 } from "node:stream/promises";
@@ -129022,8 +129075,8 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
129022
129075
  try {
129023
129076
  if (statSync7(lockPath).size > MAX_LOCKFILE_BYTES)
129024
129077
  throw new Error("lockfile too large");
129025
- manifest = JSON.parse(readFileSync36(manifestPath, "utf8"));
129026
- lock = JSON.parse(readFileSync36(lockPath, "utf8"));
129078
+ manifest = JSON.parse(readFileSync37(manifestPath, "utf8"));
129079
+ lock = JSON.parse(readFileSync37(lockPath, "utf8"));
129027
129080
  } catch (cause) {
129028
129081
  throw new Error(`the verified artifact has no readable npm-shrinkwrap dependency lock: ${message(cause)}`);
129029
129082
  }
@@ -129061,7 +129114,7 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
129061
129114
  let bundledManifest;
129062
129115
  try {
129063
129116
  const bundledPath = join41(extractionDir, ...lockPath2.split("/"), "package.json");
129064
- bundledManifest = JSON.parse(readFileSync36(bundledPath, "utf8"));
129117
+ bundledManifest = JSON.parse(readFileSync37(bundledPath, "utf8"));
129065
129118
  } catch (cause) {
129066
129119
  throw new Error(`the verified artifact has an unreadable bundled dependency ${lockPath2}: ${message(cause)}`);
129067
129120
  }
@@ -129131,7 +129184,7 @@ ${GITHUB_REPOSITORY_ID}`,
129131
129184
  // dist/commands/update.js
129132
129185
  import { spawn as spawn6 } from "node:child_process";
129133
129186
  import { randomBytes as randomBytes8 } from "node:crypto";
129134
- 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";
129135
129188
  import { createServer } from "node:http";
129136
129189
  import { tmpdir as tmpdir2 } from "node:os";
129137
129190
  import { join as join42 } from "node:path";
@@ -129142,7 +129195,7 @@ function refuse2(cause) {
129142
129195
  }
129143
129196
  function currentVersion2() {
129144
129197
  try {
129145
- 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"));
129146
129199
  return pkg.version;
129147
129200
  } catch {
129148
129201
  return "0.0.0";
@@ -129487,7 +129540,7 @@ var init_upgrade = __esm({
129487
129540
  });
129488
129541
 
129489
129542
  // dist/commands/call.js
129490
- import { readFileSync as readFileSync38 } from "node:fs";
129543
+ import { readFileSync as readFileSync39 } from "node:fs";
129491
129544
  function parseArguments(value, file2) {
129492
129545
  if (value === void 0)
129493
129546
  return {};
@@ -129511,7 +129564,7 @@ function readCallArguments(jsonArgs, file2) {
129511
129564
  }
129512
129565
  let text;
129513
129566
  try {
129514
- text = readFileSync38(file2, "utf8");
129567
+ text = readFileSync39(file2, "utf8");
129515
129568
  } catch (err) {
129516
129569
  const code = err?.code;
129517
129570
  throw new Error(`Could not read --file ${file2}${code ? ` (${code})` : ""}. The requested tool was not called.`);
@@ -131081,7 +131134,7 @@ var init_reference_check_note = __esm({
131081
131134
 
131082
131135
  // dist/lib/test-scripts.js
131083
131136
  import { createRequire as createRequire8 } from "node:module";
131084
- 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";
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";
131085
131138
  import { dirname as dirname14, join as join43, relative as relative12, resolve as resolve24 } from "node:path";
131086
131139
  import { spawn as spawn7, spawnSync as spawnSync5 } from "node:child_process";
131087
131140
  function hasSpecFiles(root) {
@@ -131181,7 +131234,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
131181
131234
  stderrLines("", true);
131182
131235
  let report2 = null;
131183
131236
  try {
131184
- report2 = existsSync36(handOver) ? JSON.parse(readFileSync39(handOver, "utf8")) : null;
131237
+ report2 = existsSync36(handOver) ? JSON.parse(readFileSync40(handOver, "utf8")) : null;
131185
131238
  } catch {
131186
131239
  report2 = null;
131187
131240
  }
@@ -131218,13 +131271,13 @@ function lastFailedScripts(root) {
131218
131271
  if (!existsSync36(path3))
131219
131272
  return [];
131220
131273
  try {
131221
- 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);
131222
131275
  } catch {
131223
131276
  return [];
131224
131277
  }
131225
131278
  }
131226
131279
  function recordScriptResults(root, results, rerunOnly) {
131227
- 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 ?? [] : [];
131228
131281
  const merged = [...previous.filter((p2) => !results.some((r) => r.script === p2.script)), ...results];
131229
131282
  mkdirSync18(join43(root, ".somewhere", "tests"), { recursive: true });
131230
131283
  writeFileSync24(join43(root, LAST), JSON.stringify({ finished: (/* @__PURE__ */ new Date()).toISOString(), results: merged }, null, 2) + "\n");
@@ -131308,7 +131361,7 @@ var init_test = __esm({
131308
131361
  });
131309
131362
 
131310
131363
  // dist/commands/test-users.js
131311
- 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";
131312
131365
  import { basename as basename9, join as join44 } from "node:path";
131313
131366
  import { randomBytes as randomBytes9 } from "node:crypto";
131314
131367
  async function resolveTarget(projectOpt, originOpt) {
@@ -131823,7 +131876,7 @@ var init_skills = __esm({
131823
131876
  });
131824
131877
 
131825
131878
  // dist/commands/ai.js
131826
- import { readFileSync as readFileSync41 } from "node:fs";
131879
+ import { readFileSync as readFileSync42 } from "node:fs";
131827
131880
  function fail4(message3) {
131828
131881
  error(message3);
131829
131882
  process.exit(1);
@@ -131844,7 +131897,7 @@ async function readKey(stdin) {
131844
131897
  if (stdin) {
131845
131898
  if (process.stdin.isTTY)
131846
131899
  fail4("Pipe the key into --stdin, or leave out --stdin to type it into a hidden prompt.");
131847
- raw = readFileSync41(0, "utf8");
131900
+ raw = readFileSync42(0, "utf8");
131848
131901
  } else {
131849
131902
  if (!process.stdin.isTTY)
131850
131903
  fail4("Pass --stdin to read the key from a pipe. Nothing was sent.");
@@ -132074,7 +132127,7 @@ __export(dist_exports, {
132074
132127
  runCli: () => runCli
132075
132128
  });
132076
132129
  import { spawnSync as spawnSync6 } from "node:child_process";
132077
- import { readFileSync as readFileSync42 } from "node:fs";
132130
+ import { readFileSync as readFileSync43 } from "node:fs";
132078
132131
  import { join as join47 } from "node:path";
132079
132132
  async function runCli() {
132080
132133
  const pinned = decidePin(process.cwd(), CLI_VERSION, process.argv, process.env);
@@ -132103,7 +132156,7 @@ async function runCli() {
132103
132156
  process.exit(child.status ?? 1);
132104
132157
  }
132105
132158
  removeStaleRunRecord();
132106
- 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"));
132107
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);
132108
132161
  recordLastRun(pkg.version);
132109
132162
  const jsonOutputRequested = process.argv.includes("--json");
@@ -132892,7 +132945,7 @@ var init_form_auth = __esm({
132892
132945
  import { randomUUID as randomUUID10 } from "node:crypto";
132893
132946
  import { setDefaultResultOrder } from "node:dns";
132894
132947
  import { lookup } from "node:dns/promises";
132895
- import { existsSync as existsSync38, mkdirSync as mkdirSync20, readFileSync as readFileSync43, writeFileSync as writeFileSync26 } from "node:fs";
132948
+ import { existsSync as existsSync38, mkdirSync as mkdirSync20, readFileSync as readFileSync44, writeFileSync as writeFileSync26 } from "node:fs";
132896
132949
  import { basename as basename10, dirname as dirname15, join as join48, relative as relative14, resolve as resolve25 } from "node:path";
132897
132950
  function launchOptions(extra = {}) {
132898
132951
  return { ...extra, args: ["--disable-features=AsyncDns", ...extra.args ?? []] };
@@ -132930,7 +132983,7 @@ function undeployedChanges(root, projectId, preview = false) {
132930
132983
  const path3 = join48(root, ".somewhere", "base-files.json");
132931
132984
  if (!existsSync38(path3))
132932
132985
  return null;
132933
- base = JSON.parse(readFileSync43(path3, "utf8"));
132986
+ base = JSON.parse(readFileSync44(path3, "utf8"));
132934
132987
  }
132935
132988
  if (base.project_id !== projectId || !base.files)
132936
132989
  return null;