@somewhere-cloud/cli 0.38.155 → 0.38.156

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.
Files changed (142) hide show
  1. package/CHANGELOG.md +4 -1
  2. package/dist/commands/docs.js +1 -1
  3. package/dist/lib/bundle.js +276 -188
  4. package/dist/lib/bundle.js.map +3 -3
  5. package/npm-shrinkwrap.json +2 -2
  6. package/package.json +2 -3
  7. package/dist/docs/adopt.md +0 -39
  8. package/dist/docs/analytics.md +0 -161
  9. package/dist/docs/api-reference.md +0 -339
  10. package/dist/docs/api-surface.md +0 -2067
  11. package/dist/docs/app-mcp.md +0 -162
  12. package/dist/docs/architecture-patterns.md +0 -334
  13. package/dist/docs/auth-client.md +0 -531
  14. package/dist/docs/billing.md +0 -76
  15. package/dist/docs/browser.md +0 -639
  16. package/dist/docs/calendar.md +0 -298
  17. package/dist/docs/changes.md +0 -323
  18. package/dist/docs/cli.md +0 -407
  19. package/dist/docs/common-mistakes.md +0 -199
  20. package/dist/docs/connect-agent.md +0 -72
  21. package/dist/docs/cors.md +0 -114
  22. package/dist/docs/cron.md +0 -167
  23. package/dist/docs/database-engine.md +0 -167
  24. package/dist/docs/declared-data.md +0 -1656
  25. package/dist/docs/declared-files.md +0 -475
  26. package/dist/docs/deploy-intelligence.md +0 -188
  27. package/dist/docs/deploy.md +0 -733
  28. package/dist/docs/design-system.md +0 -273
  29. package/dist/docs/dev-environments.md +0 -496
  30. package/dist/docs/domain-ownership.md +0 -31
  31. package/dist/docs/domains.md +0 -370
  32. package/dist/docs/feedback.md +0 -88
  33. package/dist/docs/file-tools.md +0 -116
  34. package/dist/docs/functions.md +0 -489
  35. package/dist/docs/getting-started.md +0 -238
  36. package/dist/docs/github.md +0 -95
  37. package/dist/docs/google-calendar.md +0 -212
  38. package/dist/docs/groups.md +0 -836
  39. package/dist/docs/guarantees.md +0 -58
  40. package/dist/docs/handled-for-you.md +0 -224
  41. package/dist/docs/inspect.md +0 -171
  42. package/dist/docs/limits.md +0 -68
  43. package/dist/docs/live-data.md +0 -197
  44. package/dist/docs/live.md +0 -92
  45. package/dist/docs/local-dev.md +0 -30
  46. package/dist/docs/migration-supabase.md +0 -58
  47. package/dist/docs/payments.md +0 -1102
  48. package/dist/docs/portability.md +0 -194
  49. package/dist/docs/postgres.md +0 -301
  50. package/dist/docs/pricing-comparison.md +0 -42
  51. package/dist/docs/pricing.md +0 -39
  52. package/dist/docs/project-groups.md +0 -107
  53. package/dist/docs/projects.md +0 -380
  54. package/dist/docs/recipe-ai-agent.md +0 -112
  55. package/dist/docs/recipe-ai-features.md +0 -227
  56. package/dist/docs/recipe-ai-receipts.md +0 -783
  57. package/dist/docs/recipe-background-jobs.md +0 -369
  58. package/dist/docs/recipe-booking.md +0 -348
  59. package/dist/docs/recipe-csv-import.md +0 -390
  60. package/dist/docs/recipe-ecommerce.md +0 -127
  61. package/dist/docs/recipe-email.md +0 -282
  62. package/dist/docs/recipe-escalation.md +0 -133
  63. package/dist/docs/recipe-file-uploads.md +0 -159
  64. package/dist/docs/recipe-import-app.md +0 -110
  65. package/dist/docs/recipe-login.md +0 -457
  66. package/dist/docs/recipe-multi-chat.md +0 -198
  67. package/dist/docs/recipe-paid-api.md +0 -161
  68. package/dist/docs/recipe-pdfs.md +0 -205
  69. package/dist/docs/recipe-push-notifications.md +0 -107
  70. package/dist/docs/recipe-seo.md +0 -200
  71. package/dist/docs/recipe-signed-in-app.md +0 -330
  72. package/dist/docs/render.md +0 -99
  73. package/dist/docs/rooms.md +0 -554
  74. package/dist/docs/sdk.md +0 -287
  75. package/dist/docs/sdks.md +0 -24
  76. package/dist/docs/search.md +0 -199
  77. package/dist/docs/security-model.md +0 -168
  78. package/dist/docs/setup.md +0 -212
  79. package/dist/docs/smoke.md +0 -102
  80. package/dist/docs/speed.md +0 -298
  81. package/dist/docs/sql-compatibility.md +0 -96
  82. package/dist/docs/sw.agent.md +0 -248
  83. package/dist/docs/sw.ai.md +0 -1291
  84. package/dist/docs/sw.auth.md +0 -1811
  85. package/dist/docs/sw.billing.md +0 -171
  86. package/dist/docs/sw.db.md +0 -2128
  87. package/dist/docs/sw.email.md +0 -661
  88. package/dist/docs/sw.endpoint.md +0 -187
  89. package/dist/docs/sw.env.md +0 -303
  90. package/dist/docs/sw.fetch.md +0 -115
  91. package/dist/docs/sw.fs.md +0 -424
  92. package/dist/docs/sw.groups.md +0 -836
  93. package/dist/docs/sw.image.md +0 -69
  94. package/dist/docs/sw.jobs.md +0 -520
  95. package/dist/docs/sw.logs.md +0 -61
  96. package/dist/docs/sw.mail.md +0 -106
  97. package/dist/docs/sw.notifications.md +0 -78
  98. package/dist/docs/sw.push.md +0 -161
  99. package/dist/docs/sw.rateLimit.md +0 -67
  100. package/dist/docs/sw.web.md +0 -128
  101. package/dist/docs/tasks.md +0 -269
  102. package/dist/docs/test.md +0 -220
  103. package/dist/docs/tool-reference-account.md +0 -7
  104. package/dist/docs/tool-reference-ai.md +0 -121
  105. package/dist/docs/tool-reference-analytics.md +0 -37
  106. package/dist/docs/tool-reference-api.md +0 -19
  107. package/dist/docs/tool-reference-artifacts.md +0 -35
  108. package/dist/docs/tool-reference-auth.md +0 -163
  109. package/dist/docs/tool-reference-browser.md +0 -114
  110. package/dist/docs/tool-reference-code.md +0 -26
  111. package/dist/docs/tool-reference-connect.md +0 -21
  112. package/dist/docs/tool-reference-cron.md +0 -48
  113. package/dist/docs/tool-reference-db.md +0 -282
  114. package/dist/docs/tool-reference-domains.md +0 -107
  115. package/dist/docs/tool-reference-email.md +0 -55
  116. package/dist/docs/tool-reference-env.md +0 -19
  117. package/dist/docs/tool-reference-feedback.md +0 -56
  118. package/dist/docs/tool-reference-fs.md +0 -265
  119. package/dist/docs/tool-reference-github.md +0 -57
  120. package/dist/docs/tool-reference-groups.md +0 -85
  121. package/dist/docs/tool-reference-help.md +0 -29
  122. package/dist/docs/tool-reference-jobs.md +0 -39
  123. package/dist/docs/tool-reference-live.md +0 -48
  124. package/dist/docs/tool-reference-logs.md +0 -16
  125. package/dist/docs/tool-reference-payments.md +0 -44
  126. package/dist/docs/tool-reference-project.md +0 -706
  127. package/dist/docs/tool-reference-push.md +0 -78
  128. package/dist/docs/tool-reference-rate-limit.md +0 -18
  129. package/dist/docs/tool-reference-search.md +0 -68
  130. package/dist/docs/tool-reference-security.md +0 -42
  131. package/dist/docs/tool-reference-smoke.md +0 -17
  132. package/dist/docs/tool-reference-stock-photos.md +0 -20
  133. package/dist/docs/tool-reference-tasks.md +0 -73
  134. package/dist/docs/tool-reference-telegram.md +0 -32
  135. package/dist/docs/tool-reference-usage.md +0 -9
  136. package/dist/docs/tool-reference-web.md +0 -71
  137. package/dist/docs/tool-reference-webhooks.md +0 -9
  138. package/dist/docs/troubleshooting.md +0 -411
  139. package/dist/docs/typed-functions.md +0 -94
  140. package/dist/docs/verify-before-deploy.md +0 -67
  141. package/dist/docs/vs-supabase.md +0 -75
  142. package/dist/docs/vs-vercel.md +0 -103
@@ -44184,7 +44184,8 @@ Use \`somewhere docs <topic> --section <id>\` for one section or \`--full\` for
44184
44184
  INIT_AGENTS_MD = `# somewhere.cloud project contract
44185
44185
  ${AGENT_WORKFLOW}
44186
44186
  ${SKILLS_POINTER}
44187
- Search the installed topic Markdown in \`node_modules/@somewhere-cloud/cli/dist/docs/\`.
44187
+ Search the live docs with \`somewhere docs --search "<words>"\`.
44188
+ Download Markdown to \`.somewhere/docs/\` with \`somewhere docs pull\`.
44188
44189
  Without a global CLI, use \`npx @somewhere-cloud/cli deploy\` and \`npx @somewhere-cloud/cli test\`.
44189
44190
 
44190
44191
  For Node or Playwright tests, see [Testing your app](https://somewhere.cloud/docs/test).
@@ -87274,8 +87275,76 @@ var init_postgres = __esm({
87274
87275
  }
87275
87276
  });
87276
87277
 
87278
+ // dist/lib/local-docs.js
87279
+ import { appendFileSync as appendFileSync3, existsSync as existsSync31, lstatSync as lstatSync5, mkdirSync as mkdirSync16, mkdtempSync as mkdtempSync3, readFileSync as readFileSync32, renameSync as renameSync5, rmSync as rmSync13, writeFileSync as writeFileSync21 } from "node:fs";
87280
+ import { join as join36 } from "node:path";
87281
+ function localDocsVersion(root = process.cwd()) {
87282
+ const path3 = join36(root, FOLDER, DOCS, STAMP);
87283
+ if (!existsSync31(path3))
87284
+ return void 0;
87285
+ const stamp2 = JSON.parse(readFileSync32(path3, "utf8"));
87286
+ return typeof stamp2.version === "string" && /^[a-f0-9]{16}$/.test(stamp2.version) ? stamp2.version : void 0;
87287
+ }
87288
+ function ensureGitIgnore(root) {
87289
+ const path3 = join36(root, ".gitignore");
87290
+ const text = existsSync31(path3) ? readFileSync32(path3, "utf8") : "";
87291
+ if (text.split(/\r?\n/).some((line) => line === ".somewhere/" || line === "/.somewhere/"))
87292
+ return;
87293
+ appendFileSync3(path3, `${text && !text.endsWith("\n") ? "\n" : ""}/.somewhere/
87294
+ `);
87295
+ }
87296
+ function saveLocalDocs(version2, files, root = process.cwd()) {
87297
+ const state = join36(root, FOLDER);
87298
+ const target = join36(state, DOCS);
87299
+ if (existsSync31(state) && !lstatSync5(state).isDirectory())
87300
+ throw new Error(`${state} must be a directory.`);
87301
+ if (existsSync31(target) && (!lstatSync5(target).isDirectory() || !localDocsVersion(root))) {
87302
+ throw new Error(`Move the existing folder at ${target} before pulling docs.`);
87303
+ }
87304
+ ensureGitIgnore(root);
87305
+ mkdirSync16(state, { recursive: true });
87306
+ const staging = mkdtempSync3(join36(state, "docs-pull-"));
87307
+ const next = join36(staging, "next");
87308
+ const previous = join36(staging, "previous");
87309
+ let installed = false;
87310
+ try {
87311
+ mkdirSync16(next);
87312
+ for (const [name, content] of files)
87313
+ writeFileSync21(join36(next, name), content, { flag: "wx" });
87314
+ const pulledAt = (/* @__PURE__ */ new Date()).toISOString();
87315
+ writeFileSync21(join36(next, STAMP), JSON.stringify({ version: version2, pulledAt }) + "\n");
87316
+ writeFileSync21(join36(next, "README.md"), `# Somewhere docs
87317
+
87318
+ Pulled platform docs version ${version2} on ${pulledAt}. Run \`${cliInvocation()} docs\` to check whether this copy is older than the current docs and \`${cliInvocation()} docs pull\` to refresh it.
87319
+ `, { flag: "wx" });
87320
+ if (existsSync31(target))
87321
+ renameSync5(target, previous);
87322
+ renameSync5(next, target);
87323
+ installed = true;
87324
+ return target;
87325
+ } finally {
87326
+ if (!installed && existsSync31(previous) && !existsSync31(target))
87327
+ renameSync5(previous, target);
87328
+ if (installed || !existsSync31(previous))
87329
+ rmSync13(staging, { recursive: true, force: true });
87330
+ }
87331
+ }
87332
+ var FOLDER, DOCS, STAMP;
87333
+ var init_local_docs = __esm({
87334
+ "dist/lib/local-docs.js"() {
87335
+ "use strict";
87336
+ init_cli_invocation();
87337
+ FOLDER = ".somewhere";
87338
+ DOCS = "docs";
87339
+ STAMP = ".stamp.json";
87340
+ __name(localDocsVersion, "localDocsVersion");
87341
+ __name(ensureGitIgnore, "ensureGitIgnore");
87342
+ __name(saveLocalDocs, "saveLocalDocs");
87343
+ }
87344
+ });
87345
+
87277
87346
  // dist/lib/advisor-context.js
87278
- import { readFileSync as readFileSync32, statSync as statSync6 } from "node:fs";
87347
+ import { readFileSync as readFileSync33, statSync as statSync6 } from "node:fs";
87279
87348
  import { basename as basename7 } from "node:path";
87280
87349
  function tail(value, limit) {
87281
87350
  return value.length <= limit ? value : `\u2026${value.slice(-limit)}`;
@@ -87297,7 +87366,7 @@ function buildAdvisorContext(filePath) {
87297
87366
  const stat6 = statSync6(filePath);
87298
87367
  if (!stat6.isFile())
87299
87368
  throw new Error("--file must name a regular file.");
87300
- const content = readFileSync32(filePath, "utf8");
87369
+ const content = readFileSync33(filePath, "utf8");
87301
87370
  context.file = {
87302
87371
  path: filePath,
87303
87372
  content: tail(redactAdvisorText(content, isDotenvPath(filePath)), FILE_LIMIT)
@@ -87323,19 +87392,19 @@ var init_advisor_context = __esm({
87323
87392
 
87324
87393
  // dist/lib/advisor-runs.js
87325
87394
  import { randomBytes as randomBytes7, randomUUID as randomUUID7 } from "node:crypto";
87326
- import { chmodSync as chmodSync4, existsSync as existsSync31, mkdirSync as mkdirSync16, readFileSync as readFileSync33, renameSync as renameSync5, writeFileSync as writeFileSync21 } from "node:fs";
87327
- import { join as join36 } from "node:path";
87395
+ import { chmodSync as chmodSync4, existsSync as existsSync32, mkdirSync as mkdirSync17, readFileSync as readFileSync34, renameSync as renameSync6, writeFileSync as writeFileSync22 } from "node:fs";
87396
+ import { join as join37 } from "node:path";
87328
87397
  function path2(id) {
87329
87398
  if (!/^[a-f0-9-]{36}$/i.test(id))
87330
87399
  throw Error("Invalid Advisor request ID.");
87331
- return join36(directory(), id + ".json");
87400
+ return join37(directory(), id + ".json");
87332
87401
  }
87333
87402
  function save(record3) {
87334
- mkdirSync16(directory(), { recursive: true, mode: 448 });
87403
+ mkdirSync17(directory(), { recursive: true, mode: 448 });
87335
87404
  chmodSync4(directory(), 448);
87336
87405
  const target = path2(record3.request_id), temporary = target + "." + randomUUID7() + ".tmp";
87337
- writeFileSync21(temporary, JSON.stringify(record3), { mode: 384, flag: "wx" });
87338
- renameSync5(temporary, target);
87406
+ writeFileSync22(temporary, JSON.stringify(record3), { mode: 384, flag: "wx" });
87407
+ renameSync6(temporary, target);
87339
87408
  chmodSync4(target, 384);
87340
87409
  }
87341
87410
  function payloadDeadline(record3) {
@@ -87358,9 +87427,9 @@ function expiredResult(record3) {
87358
87427
  return { run_id: record3.run_id, request_id: record3.request_id, status: record3.provider_settled ? "settled" : "delivery_expired", payload_expired: true, payload_expires_at: payloadDeadline(record3), error: "ADVISOR_PAYLOAD_EXPIRED", incomplete: true, next_step: record3.provider_settled ? "none" : "status" };
87359
87428
  }
87360
87429
  function load(id) {
87361
- if (!existsSync31(path2(id)))
87430
+ if (!existsSync32(path2(id)))
87362
87431
  throw Error("Advisor request was not found in this CLI configuration.");
87363
- const record3 = JSON.parse(readFileSync33(path2(id), "utf8"));
87432
+ const record3 = JSON.parse(readFileSync34(path2(id), "utf8"));
87364
87433
  prune(record3);
87365
87434
  save(record3);
87366
87435
  return record3;
@@ -87466,7 +87535,7 @@ var init_advisor_runs = __esm({
87466
87535
  init_config();
87467
87536
  init_http();
87468
87537
  init_advisor_context();
87469
- directory = /* @__PURE__ */ __name(() => join36(cliConfigDir(), "advisor-runs"), "directory");
87538
+ directory = /* @__PURE__ */ __name(() => join37(cliConfigDir(), "advisor-runs"), "directory");
87470
87539
  __name(path2, "path");
87471
87540
  __name(save, "save");
87472
87541
  PAYLOAD_RETENTION_MS = 24 * 60 * 60 * 1e3;
@@ -87484,8 +87553,8 @@ var init_advisor_runs = __esm({
87484
87553
 
87485
87554
  // dist/lib/advisor-app.js
87486
87555
  import { createHash as createHash8 } from "node:crypto";
87487
- import { existsSync as existsSync32, mkdirSync as mkdirSync17, readFileSync as readFileSync34, rmSync as rmSync13, writeFileSync as writeFileSync22 } from "node:fs";
87488
- import { join as join37 } from "node:path";
87556
+ import { existsSync as existsSync33, mkdirSync as mkdirSync18, readFileSync as readFileSync35, rmSync as rmSync14, writeFileSync as writeFileSync23 } from "node:fs";
87557
+ import { join as join38 } from "node:path";
87489
87558
  async function gatherAdvisorApp(client, ref) {
87490
87559
  const project = await client.call("GET", `/projects/${encodeURIComponent(ref)}`);
87491
87560
  if (typeof project.id !== "string" || project.deleted === true)
@@ -87519,7 +87588,7 @@ async function gatherAdvisorApp(client, ref) {
87519
87588
  }
87520
87589
  function loadAdvisorTurns(dir, projectId, account, now2 = Date.now()) {
87521
87590
  try {
87522
- const saved = JSON.parse(readFileSync34(join37(dir, FILE), "utf8"));
87591
+ const saved = JSON.parse(readFileSync35(join38(dir, FILE), "utf8"));
87523
87592
  if (saved.project_id !== projectId || saved.owner !== ownerOf(account) || !Array.isArray(saved.turns))
87524
87593
  return [];
87525
87594
  const last = saved.turns.at(-1);
@@ -87529,25 +87598,25 @@ function loadAdvisorTurns(dir, projectId, account, now2 = Date.now()) {
87529
87598
  }
87530
87599
  }
87531
87600
  function saveAdvisorTurn(dir, projectId, account, earlier, turn) {
87532
- mkdirSync17(join37(dir, DIR), { recursive: true, mode: 448 });
87533
- writeFileSync22(join37(dir, FILE), JSON.stringify({ project_id: projectId, owner: ownerOf(account), turns: [...earlier, { question: turn.question.slice(0, 2e3), answer: turn.answer.slice(0, 3e3), at: turn.at }].slice(-3) }) + "\n", { mode: 384 });
87601
+ mkdirSync18(join38(dir, DIR), { recursive: true, mode: 448 });
87602
+ writeFileSync23(join38(dir, FILE), JSON.stringify({ project_id: projectId, owner: ownerOf(account), turns: [...earlier, { question: turn.question.slice(0, 2e3), answer: turn.answer.slice(0, 3e3), at: turn.at }].slice(-3) }) + "\n", { mode: 384 });
87534
87603
  ensureAdvisorStateIgnored(dir);
87535
87604
  }
87536
87605
  function clearAdvisorTurns(dir) {
87537
- if (existsSync32(join37(dir, FILE)))
87538
- rmSync13(join37(dir, FILE), { force: true });
87606
+ if (existsSync33(join38(dir, FILE)))
87607
+ rmSync14(join38(dir, FILE), { force: true });
87539
87608
  }
87540
87609
  function ensureAdvisorStateIgnored(dir) {
87541
- const path3 = join37(dir, ".gitignore");
87610
+ const path3 = join38(dir, ".gitignore");
87542
87611
  const covered = [".somewhere/", ".somewhere", "/.somewhere/", "/.somewhere", ".somewhere/advisor-conversation.json"];
87543
- if (!existsSync32(path3)) {
87544
- writeFileSync22(path3, "# somewhere: local CLI state (Advisor follow-ups, test users)\n.somewhere/\n");
87612
+ if (!existsSync33(path3)) {
87613
+ writeFileSync23(path3, "# somewhere: local CLI state (Advisor follow-ups, test users)\n.somewhere/\n");
87545
87614
  return;
87546
87615
  }
87547
- const text = readFileSync34(path3, "utf8");
87616
+ const text = readFileSync35(path3, "utf8");
87548
87617
  if (text.split(/\r?\n/).map((l) => l.trim()).some((l) => covered.includes(l)))
87549
87618
  return;
87550
- writeFileSync22(path3, `${text}${text.endsWith("\n") || !text ? "" : "\n"}
87619
+ writeFileSync23(path3, `${text}${text.endsWith("\n") || !text ? "" : "\n"}
87551
87620
  # somewhere: local CLI state (Advisor follow-ups, test users)
87552
87621
  .somewhere/
87553
87622
  `);
@@ -87558,7 +87627,7 @@ var init_advisor_app = __esm({
87558
87627
  "use strict";
87559
87628
  __name(gatherAdvisorApp, "gatherAdvisorApp");
87560
87629
  DIR = ".somewhere";
87561
- FILE = join37(DIR, "advisor-conversation.json");
87630
+ FILE = join38(DIR, "advisor-conversation.json");
87562
87631
  IDLE_MS = 30 * 6e4;
87563
87632
  ownerOf = /* @__PURE__ */ __name((account) => createHash8("sha256").update(`advisor:${account}`).digest("hex"), "ownerOf");
87564
87633
  __name(loadAdvisorTurns, "loadAdvisorTurns");
@@ -87717,12 +87786,32 @@ __export(docs_exports, {
87717
87786
  registerDocs: () => registerDocs,
87718
87787
  renderDocsIndex: () => renderDocsIndex,
87719
87788
  renderPublicDocsView: () => renderPublicDocsView,
87720
- searchPublicDocs: () => searchPublicDocs,
87721
87789
  writeResponseBodyToStdout: () => writeResponseBodyToStdout
87722
87790
  });
87723
- import { existsSync as existsSync33 } from "node:fs";
87724
- import { join as join38 } from "node:path";
87725
87791
  import { once } from "node:events";
87792
+ function docsVersion(value) {
87793
+ return typeof value === "string" && /^[a-f0-9]{16}$/.test(value) ? value : void 0;
87794
+ }
87795
+ async function warnIfLocalDocsOlder(platformVersion) {
87796
+ try {
87797
+ const local = localDocsVersion();
87798
+ if (!local)
87799
+ return;
87800
+ if (!platformVersion) {
87801
+ const response = await fetchWithProxy(DOCS_BASE2 + PUBLIC_MANIFEST_PATH, { method: "HEAD" });
87802
+ if (!response.ok)
87803
+ throw new Error(`HTTP ${response.status}`);
87804
+ platformVersion = docsVersion(response.headers.get("etag")?.replace(/^(?:W\/)?"|"$/g, ""));
87805
+ }
87806
+ if (!platformVersion)
87807
+ throw new Error("the platform did not return a docs version");
87808
+ if (local !== platformVersion) {
87809
+ console.error(`The Markdown copy in .somewhere/docs/ is from an older version (${local}). Current platform docs: ${platformVersion}. Refresh with ${cliInvocation()} docs pull.`);
87810
+ }
87811
+ } catch (cause) {
87812
+ console.error(`Could not check the local Markdown version (${cause instanceof Error ? cause.message : String(cause)}). Refresh with ${cliInvocation()} docs pull.`);
87813
+ }
87814
+ }
87726
87815
  function closestMatches(wanted, candidates) {
87727
87816
  const query = wanted.trim().toLowerCase();
87728
87817
  const distance = /* @__PURE__ */ __name((candidate) => {
@@ -87769,7 +87858,7 @@ function renderPublicDocsView(page, view) {
87769
87858
  if (view.kind === "full")
87770
87859
  return { content: renderPublicPage(page), view: "full", complete: true };
87771
87860
  if (view.kind === "default") {
87772
- return page.summary ? { content: withNewline(page.summary), view: "summary", complete: page.summary_complete === true } : { content: renderPublicPage(page), view: "full", complete: true };
87861
+ return page.summary ? { content: page.summary_complete === true ? withNewline(page.summary) : topicSummary(page.summary, page.id, page.body.length), view: "summary", complete: page.summary_complete === true } : { content: renderPublicPage(page), view: "full", complete: true };
87773
87862
  }
87774
87863
  const sections = parseSections(page.sections, page.body.length);
87775
87864
  const fail5 = /* @__PURE__ */ __name((failure2) => ({
@@ -87834,9 +87923,6 @@ function parseDocsStatusLine(content) {
87834
87923
  function normalizeSectionHeading(value) {
87835
87924
  return value.trim().replace(/^#+\s*/, "").replace(/`([^`]*)`/g, "$1").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/\*([^*]+)\*/g, "$1").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").toLowerCase().replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").slice(0, 80);
87836
87925
  }
87837
- function headingText(section) {
87838
- return section.heading.replace(/^#+\s*/, "").trim();
87839
- }
87840
87926
  function withNewline(value) {
87841
87927
  return value.endsWith("\n") ? value : `${value}
87842
87928
  `;
@@ -87913,14 +87999,12 @@ async function fetchPublicManifestWithGroups() {
87913
87999
  }
87914
88000
  try {
87915
88001
  const body = await res.json();
87916
- return { pages: parsePublicDocsManifest(body), groups: parsePublicDocsGroups(body), aliases: parsePublicDocsAliases(body) };
88002
+ const version2 = body && typeof body === "object" && "sourceHash" in body ? docsVersion(body.sourceHash) : void 0;
88003
+ return { pages: parsePublicDocsManifest(body), groups: parsePublicDocsGroups(body), aliases: parsePublicDocsAliases(body), version: version2 };
87917
88004
  } catch (cause) {
87918
88005
  throw new Error(`Could not read ${DOCS_BASE2}${PUBLIC_MANIFEST_PATH}: ${cause instanceof Error ? cause.message : String(cause)}`);
87919
88006
  }
87920
88007
  }
87921
- async function fetchPublicManifest() {
87922
- return (await fetchPublicManifestWithGroups()).pages;
87923
- }
87924
88008
  function renderDocsIndex(pages, groups) {
87925
88009
  const byId = new Map(pages.map((page) => [page.id, page]));
87926
88010
  const listed = /* @__PURE__ */ new Set();
@@ -87957,49 +88041,31 @@ function renderDocsIndex(pages, groups) {
87957
88041
  lines.push("", "Quick links:");
87958
88042
  for (const [name, entry] of Object.entries(TOPICS))
87959
88043
  lines.push(` ${name.padEnd(10)} ${entry.blurb}`);
87960
- lines.push("", `Open a topic: ${cliInvocation()} docs <topic> (summary with its section ids)`, `Open a section: ${cliInvocation()} docs <topic> --section <id>`, `Whole topic: ${cliInvocation()} docs <topic> --full`, `Search all docs: ${cliInvocation()} docs search <term>`, `Full manual: ${cliInvocation()} docs --full (very large)`);
88044
+ lines.push("", `Open a topic: ${cliInvocation()} docs <topic> (full when piped or redirected)`, `Open a section: ${cliInvocation()} docs <topic> --section <id>`, `Whole topic: ${cliInvocation()} docs <topic> --full`, `Search all docs: ${cliInvocation()} docs --search "<words>"`, `Download Markdown: ${cliInvocation()} docs pull`, `Full manual: ${cliInvocation()} docs --full (very large)`);
87961
88045
  return lines.join("\n") + "\n";
87962
88046
  }
87963
- function searchPublicDocs(pages, query) {
87964
- const words = query.toLowerCase().split(/\s+/).filter(Boolean);
87965
- if (!words.length)
87966
- return [];
87967
- const scored = [];
87968
- for (const page of pages) {
87969
- const sections = parseSections(page.sections, page.body.length) ?? [];
87970
- const lower = page.body.toLowerCase();
87971
- const starts = [.../* @__PURE__ */ new Set([0, ...sections.map((section) => section.start)])].sort((a, b2) => a - b2);
87972
- const seen2 = /* @__PURE__ */ new Set();
87973
- for (let index = 0; index < starts.length; index++) {
87974
- const start = starts[index];
87975
- const end = starts[index + 1] ?? page.body.length;
87976
- const span2 = lower.slice(start, end);
87977
- if (!words.every((word) => span2.includes(word)))
87978
- continue;
87979
- const innermost = sections.filter((section) => section.start <= start && section.end >= end).sort((a, b2) => a.end - a.start - (b2.end - b2.start))[0];
87980
- const key = innermost?.id ?? "";
87981
- if (seen2.has(key))
87982
- continue;
87983
- seen2.add(key);
87984
- const at2 = start + span2.indexOf(words[0]);
87985
- const from = Math.max(0, at2 - SNIPPET_RADIUS);
87986
- const to2 = Math.min(page.body.length, at2 + words[0].length + SNIPPET_RADIUS);
87987
- const snippet = `${from > 0 ? "\u2026" : ""}${page.body.slice(from, to2).replace(/\s+/g, " ").trim()}${to2 < page.body.length ? "\u2026" : ""}`;
87988
- const heading = innermost ? headingText(innermost) : null;
87989
- const occurrences = words.reduce((count2, word) => count2 + span2.split(word).length - 1, 0);
87990
- const titleHit = words.every((word) => `${page.id} ${page.title} ${heading ?? ""}`.toLowerCase().includes(word));
87991
- scored.push({
87992
- topic: page.id,
87993
- title: page.title,
87994
- section: innermost?.id ?? null,
87995
- heading,
87996
- snippet,
87997
- open: innermost ? `${cliInvocation()} docs ${commandArg(page.id)} --section ${commandArg(innermost.id)}` : `${cliInvocation()} docs ${commandArg(page.id)} --full`,
87998
- score: (titleHit ? 1e3 : 0) + occurrences
87999
- });
88000
- }
88047
+ async function fetchDocsSearch(query, topic) {
88048
+ const params = new URLSearchParams({ q: query });
88049
+ if (topic)
88050
+ params.set("topic", topic);
88051
+ const res = await fetchWithProxy(`${DOCS_BASE2}${DOCS_SEARCH_PATH}?${params}`, {
88052
+ headers: { "User-Agent": "somewhere-cli" }
88053
+ });
88054
+ if (!res.ok) {
88055
+ if (topic && res.status === 404)
88056
+ throw new Error(`Unknown docs topic "${topic}". Run ${cliInvocation()} docs for the topic index.`);
88057
+ throw new Error(`Could not search docs at ${DOCS_BASE2} (HTTP ${res.status}).`);
88001
88058
  }
88002
- return scored.sort((a, b2) => b2.score - a.score || (a.topic < b2.topic ? -1 : a.topic > b2.topic ? 1 : 0)).slice(0, DOCS_SEARCH_LIMIT).map(({ score: _score, ...result }) => result);
88059
+ const { results, total, version: version2 } = await res.json();
88060
+ return {
88061
+ results: results.map(({ content, ...match }) => ({
88062
+ ...match,
88063
+ snippet: content,
88064
+ open: match.section ? `${cliInvocation()} docs ${commandArg(match.topic)} --section ${commandArg(match.section)}` : `${cliInvocation()} docs ${commandArg(match.topic)} --full`
88065
+ })),
88066
+ total,
88067
+ version: docsVersion(version2)
88068
+ };
88003
88069
  }
88004
88070
  function warnIfDocsNewerThanCli() {
88005
88071
  if (process.env.CI || process.env.SOMEWHERE_NO_NOTIFICATIONS)
@@ -88035,27 +88101,20 @@ async function writeResponseBodyToStdout(res) {
88035
88101
  reader.releaseLock();
88036
88102
  }
88037
88103
  }
88038
- function bundledDocsPath(topic) {
88039
- if (topic !== void 0 && !/^[a-z0-9][a-z0-9.-]*$/i.test(topic))
88040
- return void 0;
88041
- const path3 = topic === void 0 ? BUNDLED_DOCS_DIR : join38(BUNDLED_DOCS_DIR, topic + ".md");
88042
- return existsSync33(path3) ? path3 : void 0;
88043
- }
88044
- function printDocsHint(topic, view, complete) {
88045
- const path3 = bundledDocsPath(topic) ?? bundledDocsPath();
88046
- if (view === "summary" && complete === false) {
88047
- const read = `Run ${cliInvocation()} docs ${commandArg(topic)} --full for the whole topic or --section <id> for one section.`;
88048
- console.error(path3 ? `${read} Search installed Markdown in ${path3}.` : read);
88049
- } else if (path3) {
88050
- console.error(`Search installed Markdown in ${path3}.`);
88051
- }
88104
+ function topicSummary(content, topic, full) {
88105
+ const command = `${cliInvocation()} docs ${commandArg(topic)}`;
88106
+ return `${content.trimEnd()}
88107
+
88108
+ Full topic (${full} characters): ${command} --full
88109
+ `;
88052
88110
  }
88053
88111
  function registerDocs(program2) {
88054
- program2.command("docs [topic] [terms...]").description(`Read platform docs. No login needed \u2014 every topic is public. With no topic, prints the topic index. Search with \`${cliInvocation()} docs <topic> <term>\` or \`${cliInvocation()} docs search <term>\`. Quick topics: ` + Object.keys(TOPICS).join(", ") + `. Example manual topic: \`${cliInvocation()} docs sw.db\`.`).option("--list", `List available topics (the same index bare \`${cliInvocation()} docs\` prints)`).option("--full", "Print the complete topic instead of its summary; with no topic, the full manual").option("--section <id>", "Print one section of a topic (ids are listed in the summary)").option("--json", "Print the selected document in a JSON envelope").addHelpText("after", `
88112
+ program2.command("docs [topic] [terms...]").description(`Read platform docs. No login needed \u2014 every topic is public. With no topic, prints the topic index. Search with \`${cliInvocation()} docs --search "<words>"\`. Quick topics: ` + Object.keys(TOPICS).join(", ") + `. Example manual topic: \`${cliInvocation()} docs sw.db\`.`).option("--list", `List available topics (the same index bare \`${cliInvocation()} docs\` prints)`).option("--full", "Print the complete topic in a terminal; with no topic, the full manual").option("--search <words>", "Search matching sections across all live docs topics").option("--section <id>", "Print one section of a topic (ids are listed in the summary)").option("--json", "Print the selected document in a JSON envelope").addHelpText("after", `
88055
88113
  Examples:
88056
88114
  ${cliInvocation()} docs # topic index
88057
- ${cliInvocation()} docs search magic link # matching sections across every topic
88058
- ${cliInvocation()} docs sw.auth # topic summary with section ids
88115
+ ${cliInvocation()} docs --search "magic link" # matching sections across every topic
88116
+ ${cliInvocation()} docs pull # download Markdown into .somewhere/docs/
88117
+ ${cliInvocation()} docs sw.auth # full when piped or redirected
88059
88118
  ${cliInvocation()} docs sw.auth setRoles # search within this topic
88060
88119
  ${cliInvocation()} docs sw.auth --section <id> # one section
88061
88120
  ${cliInvocation()} docs --full # the whole manual (very large)
@@ -88067,39 +88126,73 @@ Examples:
88067
88126
  process.exitCode = 1;
88068
88127
  return;
88069
88128
  }
88070
- const searching = terms.length > 0;
88071
- const within = topic && topic !== "search" ? ALIASES[topic] ?? topic : void 0;
88072
88129
  warnIfDocsNewerThanCli();
88130
+ if (topic === "pull") {
88131
+ if (terms.length || opts.list || opts.full || opts.section !== void 0 || opts.search !== void 0) {
88132
+ error("docs pull accepts only --json.");
88133
+ process.exitCode = 1;
88134
+ return;
88135
+ }
88136
+ try {
88137
+ const { pages, version: version2 } = await fetchPublicManifestWithGroups();
88138
+ if (!version2 || !pages.length)
88139
+ throw new Error("The platform did not return a versioned docs collection.");
88140
+ const files = /* @__PURE__ */ new Map();
88141
+ const names = /* @__PURE__ */ new Set(["readme"]);
88142
+ for (const page of pages) {
88143
+ const name = page.id.toLowerCase();
88144
+ if (!/^[a-z0-9][a-z0-9.-]*$/.test(name) || names.has(name)) {
88145
+ throw new Error(`Invalid docs topic ID ${JSON.stringify(page.id)}.`);
88146
+ }
88147
+ names.add(name);
88148
+ files.set(page.id + ".md", renderPublicPage(page));
88149
+ }
88150
+ const path3 = saveLocalDocs(version2, files);
88151
+ if (opts.json)
88152
+ printJson({ path: path3, version: version2, count: files.size });
88153
+ else
88154
+ console.log(path3);
88155
+ } catch (e) {
88156
+ error(e instanceof Error ? e.message : String(e), e);
88157
+ process.exitCode = 1;
88158
+ }
88159
+ return;
88160
+ }
88161
+ const searching = opts.search !== void 0 || terms.length > 0;
88162
+ const within = topic && topic !== "search" ? ALIASES[topic] ?? topic : void 0;
88073
88163
  if (searching) {
88074
- if (opts.full || opts.section !== void 0 || opts.list) {
88075
- error("docs search takes only a term (and --json).");
88164
+ if (opts.full || opts.section !== void 0 || opts.list || opts.search !== void 0 && topic !== void 0) {
88165
+ error('Use docs --search "<words>" with optional --json.');
88166
+ process.exitCode = 1;
88167
+ return;
88168
+ }
88169
+ const query = (opts.search ?? terms.join(" ")).trim();
88170
+ if (!/[a-z0-9]/i.test(query) || query.length > 200) {
88171
+ error("Enter search words of up to 200 characters.");
88076
88172
  process.exitCode = 1;
88077
88173
  return;
88078
88174
  }
88079
- const query = terms.join(" ");
88080
88175
  try {
88081
- const pages = await fetchPublicManifest();
88082
- if (within && !pages.some((page) => page.id === within)) {
88083
- error(`Unknown docs topic "${within}". Run: ${cliInvocation()} docs`);
88084
- process.exitCode = 1;
88085
- return;
88086
- }
88087
- const results = searchPublicDocs(within ? pages.filter((page) => page.id === within) : pages, query);
88176
+ const { results, total, version: version2 } = await fetchDocsSearch(query, within);
88177
+ await warnIfLocalDocsOlder(version2);
88088
88178
  if (opts.json) {
88089
- printJson({ query, ...within ? { topic: within } : {}, count: results.length, results });
88179
+ printJson({ query, ...within ? { topic: within } : {}, count: results.length, total, results });
88090
88180
  return;
88091
88181
  }
88092
88182
  if (!results.length) {
88093
- console.log(`No docs sections${within ? ` in ${within}` : ""} mention "${query}". Search all topics: ${cliInvocation()} docs search ${query}`);
88183
+ console.log(`No docs sections${within ? ` in ${within}` : ""} match ${JSON.stringify(query)}.`);
88094
88184
  return;
88095
88185
  }
88096
88186
  for (const result of results) {
88097
88187
  console.log(`${result.topic}${result.section ? ` \u203A ${result.section}` : ""} ${dim(result.heading ?? result.title)}`);
88098
- console.log(` ${result.snippet}`);
88099
- console.log(` ${dim(result.open)}`);
88188
+ console.log(`
88189
+ ${result.snippet}
88190
+
88191
+ ${dim(result.open)}
88192
+ `);
88100
88193
  }
88101
- if (results.length === DOCS_SEARCH_LIMIT) {
88102
- console.log(dim(`Showing the first ${DOCS_SEARCH_LIMIT} matches; add a word to narrow the search.`));
88194
+ if (results.length < total) {
88195
+ console.log(dim(`Showing ${results.length} of ${total} matches. Add a word to narrow the search.`));
88103
88196
  }
88104
88197
  } catch (e) {
88105
88198
  error(e instanceof Error ? e.message : String(e), e);
@@ -88107,10 +88200,11 @@ Examples:
88107
88200
  }
88108
88201
  return;
88109
88202
  }
88110
- const view = opts.section !== void 0 ? { kind: "section", id: opts.section } : opts.full ? { kind: "full" } : { kind: "default" };
88203
+ const view = opts.section !== void 0 ? { kind: "section", id: opts.section } : opts.full || topic !== void 0 && !process.stdout.isTTY ? { kind: "full" } : { kind: "default" };
88111
88204
  if (opts.list || topic === void 0 && view.kind === "default") {
88112
88205
  try {
88113
- const { pages, groups } = await fetchPublicManifestWithGroups();
88206
+ const { pages, groups, version: version2 } = await fetchPublicManifestWithGroups();
88207
+ await warnIfLocalDocsOlder(version2);
88114
88208
  const quickLinks = Object.entries(TOPICS).map(([name, entry2]) => ({
88115
88209
  name,
88116
88210
  path: entry2.path,
@@ -88129,9 +88223,6 @@ Examples:
88129
88223
  return;
88130
88224
  }
88131
88225
  process.stdout.write(renderDocsIndex(pages, groups));
88132
- const docs = bundledDocsPath();
88133
- if (docs)
88134
- console.log("\nSearch installed Markdown in " + docs + ".");
88135
88226
  console.log(`
88136
88227
  ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
88137
88228
  } catch (e) {
@@ -88158,29 +88249,32 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
88158
88249
  let authenticatedFailure = null;
88159
88250
  if (hasUsableCredential()) {
88160
88251
  try {
88161
- const content = await callPlatformHelpTool("docs", {
88252
+ let content = await callPlatformHelpTool("docs", {
88162
88253
  topic: resolvedTopic,
88163
88254
  ...view.kind === "full" ? { detail: "full" } : {},
88164
88255
  ...view.kind === "section" ? { section: view.id } : {}
88165
88256
  });
88166
88257
  const status = parseDocsStatusLine(content);
88167
- if (/^Topic "[^\n]*" not found\./.test(content) || view.kind === "section" && (status.view !== "section" || /(?:^|\n)No section "/.test(content))) {
88258
+ const first = content.split("\n", 1)[0];
88259
+ const full = /\bfull=(\d+)/.exec(first)?.[1];
88260
+ if (/^Topic "[^\n]*" not found\./.test(content) || view.kind === "full" && status.complete === false || status.view === "summary" && status.complete === false && !full || view.kind === "section" && (status.view !== "section" || /(?:^|\n)No section "/.test(content))) {
88168
88261
  throw new Error("Authenticated docs did not return the requested view; trying the public index.");
88169
88262
  }
88263
+ if (status.view === "summary" && status.complete === false)
88264
+ content = topicSummary(content, resolvedTopic, Number(full));
88265
+ await warnIfLocalDocsOlder();
88170
88266
  if (opts.json)
88171
88267
  printJson({ topic: requestedTopic, ...status, content });
88172
- else {
88268
+ else
88173
88269
  process.stdout.write(withNewline(content));
88174
- if (view.kind === "default")
88175
- printDocsHint(resolvedTopic, status.view, status.complete);
88176
- }
88177
88270
  return;
88178
88271
  } catch (e) {
88179
88272
  authenticatedFailure = e instanceof Error ? e.message : String(e);
88180
88273
  }
88181
88274
  }
88182
88275
  try {
88183
- const { pages, aliases } = await fetchPublicManifestWithGroups();
88276
+ const { pages, aliases, version: version2 } = await fetchPublicManifestWithGroups();
88277
+ await warnIfLocalDocsOlder(version2);
88184
88278
  const page = findPublicDocsPage(pages, aliases, resolvedTopic);
88185
88279
  if (page) {
88186
88280
  const rendered = renderPublicDocsView(page, view);
@@ -88198,8 +88292,6 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
88198
88292
  });
88199
88293
  } else {
88200
88294
  process.stdout.write(rendered.content);
88201
- if (view.kind === "default")
88202
- printDocsHint(page.id, rendered.view, rendered.complete);
88203
88295
  }
88204
88296
  return;
88205
88297
  }
@@ -88225,6 +88317,7 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
88225
88317
  error(`Could not fetch ${DOCS_BASE2}${entry.path} (HTTP ${res.status}). Try again shortly, or open it in a browser.`);
88226
88318
  process.exit(1);
88227
88319
  }
88320
+ await warnIfLocalDocsOlder();
88228
88321
  if (opts.json) {
88229
88322
  printJson({
88230
88323
  topic: key,
@@ -88234,21 +88327,19 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
88234
88327
  return;
88235
88328
  }
88236
88329
  await writeResponseBodyToStdout(res);
88237
- if (view.kind === "default")
88238
- printDocsHint(key ?? requestedTopic);
88239
88330
  } catch (e) {
88240
88331
  error(`Could not reach ${DOCS_BASE2} \u2014 check your connection. (${e instanceof Error ? e.message : String(e)})`, e);
88241
88332
  process.exit(1);
88242
88333
  }
88243
88334
  });
88244
88335
  }
88245
- var DOCS_BASE2, TOPICS, ALIASES, PUBLIC_MANIFEST_PATH, DOCS_SECTION_MAX_CHARS, DOCS_SEARCH_LIMIT, SNIPPET_RADIUS, BUNDLED_DOCS_DIR;
88336
+ var DOCS_BASE2, TOPICS, ALIASES, PUBLIC_MANIFEST_PATH, DOCS_SEARCH_PATH, DOCS_SECTION_MAX_CHARS;
88246
88337
  var init_docs = __esm({
88247
88338
  "dist/commands/docs.js"() {
88248
88339
  "use strict";
88249
- init_package_root();
88250
88340
  init_cli_invocation();
88251
88341
  init_http();
88342
+ init_local_docs();
88252
88343
  init_config();
88253
88344
  init_output();
88254
88345
  init_update();
@@ -88291,6 +88382,9 @@ var init_docs = __esm({
88291
88382
  schema: "declared-data"
88292
88383
  };
88293
88384
  PUBLIC_MANIFEST_PATH = "/docs-manifest.json";
88385
+ DOCS_SEARCH_PATH = "/docs-search.json";
88386
+ __name(docsVersion, "docsVersion");
88387
+ __name(warnIfLocalDocsOlder, "warnIfLocalDocsOlder");
88294
88388
  DOCS_SECTION_MAX_CHARS = 12e3;
88295
88389
  __name(closestMatches, "closestMatches");
88296
88390
  __name(commandArg, "commandArg");
@@ -88299,24 +88393,18 @@ var init_docs = __esm({
88299
88393
  __name(renderPublicDocsView, "renderPublicDocsView");
88300
88394
  __name(parseDocsStatusLine, "parseDocsStatusLine");
88301
88395
  __name(normalizeSectionHeading, "normalizeSectionHeading");
88302
- __name(headingText, "headingText");
88303
88396
  __name(withNewline, "withNewline");
88304
88397
  __name(parsePublicDocsManifest, "parsePublicDocsManifest");
88305
88398
  __name(parsePublicDocsGroups, "parsePublicDocsGroups");
88306
88399
  __name(parsePublicDocsAliases, "parsePublicDocsAliases");
88307
88400
  __name(findPublicDocsPage, "findPublicDocsPage");
88308
88401
  __name(fetchPublicManifestWithGroups, "fetchPublicManifestWithGroups");
88309
- __name(fetchPublicManifest, "fetchPublicManifest");
88310
88402
  __name(renderDocsIndex, "renderDocsIndex");
88311
- DOCS_SEARCH_LIMIT = 20;
88312
- SNIPPET_RADIUS = 90;
88313
- __name(searchPublicDocs, "searchPublicDocs");
88403
+ __name(fetchDocsSearch, "fetchDocsSearch");
88314
88404
  __name(warnIfDocsNewerThanCli, "warnIfDocsNewerThanCli");
88315
88405
  __name(renderPublicPage, "renderPublicPage");
88316
88406
  __name(writeResponseBodyToStdout, "writeResponseBodyToStdout");
88317
- BUNDLED_DOCS_DIR = join38(CLI_PACKAGE_ROOT, "dist", "docs");
88318
- __name(bundledDocsPath, "bundledDocsPath");
88319
- __name(printDocsHint, "printDocsHint");
88407
+ __name(topicSummary, "topicSummary");
88320
88408
  __name(registerDocs, "registerDocs");
88321
88409
  }
88322
88410
  });
@@ -88873,7 +88961,7 @@ var init_envfile_write = __esm({
88873
88961
  });
88874
88962
 
88875
88963
  // dist/commands/env.js
88876
- import { existsSync as existsSync34, readFileSync as readFileSync35, writeFileSync as writeFileSync23 } from "node:fs";
88964
+ import { existsSync as existsSync34, readFileSync as readFileSync36, writeFileSync as writeFileSync24 } from "node:fs";
88877
88965
  import { resolve as resolve19 } from "node:path";
88878
88966
  function resolveProjectId(explicit) {
88879
88967
  if (explicit)
@@ -88943,7 +89031,7 @@ function registerEnv(program2) {
88943
89031
  process.exit(1);
88944
89032
  }
88945
89033
  if (existsSync34(outPath) && !opts.force) {
88946
- const existing = readFileSync35(outPath, "utf-8");
89034
+ const existing = readFileSync36(outPath, "utf-8");
88947
89035
  const hasValues = existing.split("\n").some((l) => /^[^#=]+=.+/.test(l.trim()));
88948
89036
  const { ok } = await (0, import_prompts9.default)({
88949
89037
  type: "confirm",
@@ -88956,7 +89044,7 @@ function registerEnv(program2) {
88956
89044
  return;
88957
89045
  }
88958
89046
  }
88959
- writeFileSync23(outPath, buildEnvTemplate(keys, { projectId: pid }));
89047
+ writeFileSync24(outPath, buildEnvTemplate(keys, { projectId: pid }));
88960
89048
  if (opts.json) {
88961
89049
  printJson(result);
88962
89050
  return;
@@ -88996,7 +89084,7 @@ function registerEnv(program2) {
88996
89084
  if (inputNote && !opts.json)
88997
89085
  process.stderr.write(`Note: ${inputNote}
88998
89086
  `);
88999
- const value = opts.stdin ? readFileSync35(0, "utf8").replace(/\r?\n$/, "") : positionalValue;
89087
+ const value = opts.stdin ? readFileSync36(0, "utf8").replace(/\r?\n$/, "") : positionalValue;
89000
89088
  const client = new ApiClient(getToken());
89001
89089
  const pid = resolveProjectId(opts.project);
89002
89090
  try {
@@ -89065,7 +89153,7 @@ var init_env = __esm({
89065
89153
  });
89066
89154
 
89067
89155
  // dist/commands/run.js
89068
- import { existsSync as existsSync35, readFileSync as readFileSync36 } from "node:fs";
89156
+ import { existsSync as existsSync35, readFileSync as readFileSync37 } from "node:fs";
89069
89157
  import { isAbsolute as isAbsolute6, resolve as resolve20 } from "node:path";
89070
89158
  import { createRequire as createRequire8 } from "node:module";
89071
89159
  function parseArgs(values) {
@@ -89136,7 +89224,7 @@ function registerRun(program2) {
89136
89224
  error(`File not found: ${script}`);
89137
89225
  process.exit(1);
89138
89226
  }
89139
- const code = readFileSync36(absPath, "utf-8");
89227
+ const code = readFileSync37(absPath, "utf-8");
89140
89228
  if (!code.trim()) {
89141
89229
  error(`${script} is empty \u2014 nothing to run.`);
89142
89230
  process.exit(1);
@@ -89815,7 +89903,7 @@ var init_preview_jobs = __esm({
89815
89903
 
89816
89904
  // dist/commands/dev.js
89817
89905
  import { randomUUID as randomUUID8 } from "node:crypto";
89818
- import { existsSync as existsSync36, readFileSync as readFileSync37 } from "node:fs";
89906
+ import { existsSync as existsSync36, readFileSync as readFileSync38 } from "node:fs";
89819
89907
  import { join as join40, relative as relative11 } from "node:path";
89820
89908
  function previewFinishedReason(err) {
89821
89909
  if (!(err instanceof CliApiError) || err.code !== "DRAFT_SESSION_TERMINAL")
@@ -90804,11 +90892,11 @@ async function deployBatch(client, projectId, cwd, changed, deleted, draftId, ex
90804
90892
  continue;
90805
90893
  const { kind, key } = classifyKey(rel);
90806
90894
  if (kind === "function")
90807
- updateFunctions[key] = readFileSync37(abs, "utf-8");
90895
+ updateFunctions[key] = readFileSync38(abs, "utf-8");
90808
90896
  else if (kind === "binary")
90809
- updateBinary[key] = readFileSync37(abs).toString("base64");
90897
+ updateBinary[key] = readFileSync38(abs).toString("base64");
90810
90898
  else
90811
- updateFiles[key] = readFileSync37(abs, "utf-8");
90899
+ updateFiles[key] = readFileSync38(abs, "utf-8");
90812
90900
  }
90813
90901
  for (const rel of deleted)
90814
90902
  deleteKeys.push(classifyKey(rel).key);
@@ -131574,7 +131662,7 @@ var require_dist15 = __commonJS({
131574
131662
 
131575
131663
  // dist/lib/update-security.js
131576
131664
  import { createHash as createHash9, timingSafeEqual } from "node:crypto";
131577
- import { mkdirSync as mkdirSync18, readFileSync as readFileSync38, statSync as statSync7 } from "node:fs";
131665
+ import { mkdirSync as mkdirSync19, readFileSync as readFileSync39, statSync as statSync7 } from "node:fs";
131578
131666
  import { join as join43 } from "node:path";
131579
131667
  import { Readable as Readable2 } from "node:stream";
131580
131668
  import { pipeline as pipeline3 } from "node:stream/promises";
@@ -131923,7 +132011,7 @@ async function extractArtifactSnapshot(artifact, extractionDir, filter) {
131923
132011
  await pipeline3(Readable2.from([artifact]), So({ cwd: extractionDir, strip: 1, strict: true, filter }));
131924
132012
  }
131925
132013
  async function verifyLockedArtifact(artifact, extractionDir, release2) {
131926
- mkdirSync18(extractionDir, { recursive: true, mode: 448 });
132014
+ mkdirSync19(extractionDir, { recursive: true, mode: 448 });
131927
132015
  const allowed = /* @__PURE__ */ new Map([
131928
132016
  ["package/package.json", MAX_MANIFEST_BYTES],
131929
132017
  ["package/npm-shrinkwrap.json", MAX_LOCKFILE_BYTES]
@@ -131947,8 +132035,8 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
131947
132035
  try {
131948
132036
  if (statSync7(lockPath).size > MAX_LOCKFILE_BYTES)
131949
132037
  throw new Error("lockfile too large");
131950
- manifest = JSON.parse(readFileSync38(manifestPath, "utf8"));
131951
- lock = JSON.parse(readFileSync38(lockPath, "utf8"));
132038
+ manifest = JSON.parse(readFileSync39(manifestPath, "utf8"));
132039
+ lock = JSON.parse(readFileSync39(lockPath, "utf8"));
131952
132040
  } catch (cause) {
131953
132041
  throw new Error(`the verified artifact has no readable npm-shrinkwrap dependency lock: ${message(cause)}`);
131954
132042
  }
@@ -131986,7 +132074,7 @@ async function verifyLockedArtifact(artifact, extractionDir, release2) {
131986
132074
  let bundledManifest;
131987
132075
  try {
131988
132076
  const bundledPath = join43(extractionDir, ...lockPath2.split("/"), "package.json");
131989
- bundledManifest = JSON.parse(readFileSync38(bundledPath, "utf8"));
132077
+ bundledManifest = JSON.parse(readFileSync39(bundledPath, "utf8"));
131990
132078
  } catch (cause) {
131991
132079
  throw new Error(`the verified artifact has an unreadable bundled dependency ${lockPath2}: ${message(cause)}`);
131992
132080
  }
@@ -132056,7 +132144,7 @@ ${GITHUB_REPOSITORY_ID}`,
132056
132144
  // dist/commands/update.js
132057
132145
  import { spawn as spawn6 } from "node:child_process";
132058
132146
  import { randomBytes as randomBytes8 } from "node:crypto";
132059
- import { closeSync as closeSync5, constants as constants2, fstatSync, mkdtempSync as mkdtempSync3, openSync as openSync5, readFileSync as readFileSync39, readSync, rmSync as rmSync14, unlinkSync as unlinkSync5, writeFileSync as writeFileSync24 } from "node:fs";
132147
+ import { closeSync as closeSync5, constants as constants2, fstatSync, mkdtempSync as mkdtempSync4, openSync as openSync5, readFileSync as readFileSync40, readSync, rmSync as rmSync15, unlinkSync as unlinkSync5, writeFileSync as writeFileSync25 } from "node:fs";
132060
132148
  import { createServer } from "node:http";
132061
132149
  import { tmpdir as tmpdir2 } from "node:os";
132062
132150
  import { join as join44 } from "node:path";
@@ -132067,7 +132155,7 @@ function refuse2(cause) {
132067
132155
  }
132068
132156
  function currentVersion2() {
132069
132157
  try {
132070
- const pkg = JSON.parse(readFileSync39(join44(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
132158
+ const pkg = JSON.parse(readFileSync40(join44(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
132071
132159
  return pkg.version;
132072
132160
  } catch {
132073
132161
  return "0.0.0";
@@ -132210,8 +132298,8 @@ async function installVerifiedTarball(tarballPath, tempDir, release2) {
132210
132298
  const cacheDir = join44(tempDir, "empty-cache");
132211
132299
  const userConfigPath = join44(tempDir, "user-npmrc");
132212
132300
  const globalConfigPath = join44(tempDir, "global-npmrc");
132213
- writeFileSync24(userConfigPath, "", { mode: 384 });
132214
- writeFileSync24(globalConfigPath, "", { mode: 384 });
132301
+ writeFileSync25(userConfigPath, "", { mode: 384 });
132302
+ writeFileSync25(globalConfigPath, "", { mode: 384 });
132215
132303
  const artifact = snapshotAuthenticatedArtifact(tarballPath);
132216
132304
  let artifactServer;
132217
132305
  try {
@@ -132281,9 +132369,9 @@ async function runUpdate(opts, dependencies = {}) {
132281
132369
  const provenance = await fetchJson(fetchImpl, release2.attestationUrl, "the official npm provenance endpoint");
132282
132370
  await (dependencies.verifyProvenance ?? verifyPublishedProvenance)(provenance, release2);
132283
132371
  const tarball = await downloadTarball(fetchImpl, release2);
132284
- tempDir = mkdtempSync3(join44(tmpdir2(), "somewhere-update-"));
132372
+ tempDir = mkdtempSync4(join44(tmpdir2(), "somewhere-update-"));
132285
132373
  const tarballPath = join44(tempDir, `cli-${release2.version}.tgz`);
132286
- writeFileSync24(tarballPath, tarball, { mode: 384 });
132374
+ writeFileSync25(tarballPath, tarball, { mode: 384 });
132287
132375
  info(`Cryptographically verified provenance and integrity for ${CLI_PACKAGE}@${release2.version}.`);
132288
132376
  info(`Updating ${CLI_PACKAGE} from its authenticated dependency lock \u2026`);
132289
132377
  await (dependencies.install ?? installVerifiedTarball)(tarballPath, tempDir, release2);
@@ -132291,7 +132379,7 @@ async function runUpdate(opts, dependencies = {}) {
132291
132379
  return refuse2(cause);
132292
132380
  } finally {
132293
132381
  if (tempDir)
132294
- rmSync14(tempDir, { recursive: true, force: true });
132382
+ rmSync15(tempDir, { recursive: true, force: true });
132295
132383
  }
132296
132384
  success(`Updated to ${release2.version}. Run ${teal(`${cliInvocation()} --version`)} to confirm.`);
132297
132385
  info(PROJECT_PIN_NOTE);
@@ -132414,7 +132502,7 @@ var init_upgrade = __esm({
132414
132502
  });
132415
132503
 
132416
132504
  // dist/commands/call.js
132417
- import { readFileSync as readFileSync40 } from "node:fs";
132505
+ import { readFileSync as readFileSync41 } from "node:fs";
132418
132506
  function parseArguments(value, file) {
132419
132507
  if (value === void 0)
132420
132508
  return {};
@@ -132438,7 +132526,7 @@ function readCallArguments(jsonArgs, file) {
132438
132526
  }
132439
132527
  let text;
132440
132528
  try {
132441
- text = readFileSync40(file, "utf8");
132529
+ text = readFileSync41(file, "utf8");
132442
132530
  } catch (err) {
132443
132531
  const code = err?.code;
132444
132532
  throw new Error(`Could not read --file ${file}${code ? ` (${code})` : ""}. The requested tool was not called.`);
@@ -134756,7 +134844,7 @@ var init_test_response_capture = __esm({
134756
134844
  import { randomUUID as randomUUID11 } from "node:crypto";
134757
134845
  import { setDefaultResultOrder } from "node:dns";
134758
134846
  import { lookup } from "node:dns/promises";
134759
- import { existsSync as existsSync38, mkdirSync as mkdirSync19, readFileSync as readFileSync41, writeFileSync as writeFileSync25 } from "node:fs";
134847
+ import { existsSync as existsSync38, mkdirSync as mkdirSync20, readFileSync as readFileSync42, writeFileSync as writeFileSync26 } from "node:fs";
134760
134848
  import { basename as basename9, dirname as dirname14, join as join45, relative as relative12, resolve as resolve24 } from "node:path";
134761
134849
  function launchOptions(extra = {}) {
134762
134850
  return { ...extra, args: ["--disable-features=AsyncDns", ...extra.args ?? []] };
@@ -134810,7 +134898,7 @@ function undeployedChanges(root, projectId, preview = false) {
134810
134898
  const path3 = join45(root, ".somewhere", "base-files.json");
134811
134899
  if (!existsSync38(path3))
134812
134900
  return null;
134813
- base = JSON.parse(readFileSync41(path3, "utf8"));
134901
+ base = JSON.parse(readFileSync42(path3, "utf8"));
134814
134902
  }
134815
134903
  if (base.project_id !== projectId || !base.files)
134816
134904
  return null;
@@ -135162,8 +135250,8 @@ page ${i + 1}: ${state}`).join("");
135162
135250
  }
135163
135251
  const passed = this.checks.filter((check) => check.ok).length;
135164
135252
  const failed = this.checks.filter((check) => !check.ok && !check.skipped).length;
135165
- mkdirSync19(dirname14(this.resultsPath), { recursive: true });
135166
- writeFileSync25(this.resultsPath, JSON.stringify({
135253
+ mkdirSync20(dirname14(this.resultsPath), { recursive: true });
135254
+ writeFileSync26(this.resultsPath, JSON.stringify({
135167
135255
  identity: this.identity(),
135168
135256
  origin: this.origin,
135169
135257
  environment: this.control.environment,
@@ -135182,7 +135270,7 @@ page ${i + 1}: ${state}`).join("");
135182
135270
  const resultFile = relative12(this.root, this.resultsPath);
135183
135271
  const handOver = process.env.SW_TEST_REPORT;
135184
135272
  if (handOver)
135185
- writeFileSync25(handOver, JSON.stringify({ checks: reported, resultFile }) + "\n");
135273
+ writeFileSync26(handOver, JSON.stringify({ checks: reported, resultFile }) + "\n");
135186
135274
  else {
135187
135275
  const verbose = process.argv.includes("--verbose") || process.env.SW_TEST_VERBOSE === "1";
135188
135276
  const script = process.argv[1] ? relative12(this.root, resolve24(process.argv[1])) : "this script";
@@ -135497,7 +135585,7 @@ var init_test_session = __esm({
135497
135585
 
135498
135586
  // dist/lib/prepared-actor-session.js
135499
135587
  import { createHash as createHash10 } from "node:crypto";
135500
- import { closeSync as closeSync6, openSync as openSync6, rmSync as rmSync15 } from "node:fs";
135588
+ import { closeSync as closeSync6, openSync as openSync6, rmSync as rmSync16 } from "node:fs";
135501
135589
  import { setTimeout as delay } from "node:timers/promises";
135502
135590
  async function preparedActorSession(root, target, name) {
135503
135591
  const read = /* @__PURE__ */ __name(() => preparedActorState(root, target, name), "read");
@@ -135533,7 +135621,7 @@ async function preparedActorSession(root, target, name) {
135533
135621
  return token;
135534
135622
  } finally {
135535
135623
  closeSync6(fd);
135536
- rmSync15(lock, { force: true });
135624
+ rmSync16(lock, { force: true });
135537
135625
  }
135538
135626
  }
135539
135627
  throw new Error(`Another command is refreshing test user ${name}. Wait for it to finish, or clean up and prepare the test users again.`);
@@ -135640,7 +135728,7 @@ var init_reference_check_note = __esm({
135640
135728
 
135641
135729
  // dist/lib/test-scripts.js
135642
135730
  import { createRequire as createRequire10 } from "node:module";
135643
- import { existsSync as existsSync39, mkdirSync as mkdirSync20, readFileSync as readFileSync42, readdirSync as readdirSync8, rmSync as rmSync16, statSync as statSync8, writeFileSync as writeFileSync26 } from "node:fs";
135731
+ import { existsSync as existsSync39, mkdirSync as mkdirSync21, readFileSync as readFileSync43, readdirSync as readdirSync8, rmSync as rmSync17, statSync as statSync8, writeFileSync as writeFileSync27 } from "node:fs";
135644
135732
  import { dirname as dirname15, join as join46, relative as relative13, resolve as resolve25 } from "node:path";
135645
135733
  import { spawn as spawn7, spawnSync as spawnSync5 } from "node:child_process";
135646
135734
  function hasSpecFiles(root) {
@@ -135711,8 +135799,8 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
135711
135799
  const started = performance.now();
135712
135800
  let output = "";
135713
135801
  const handOver = join46(root, ".somewhere", "tests", `report-${results.length}.json`);
135714
- mkdirSync20(dirname15(handOver), { recursive: true });
135715
- rmSync16(handOver, { force: true });
135802
+ mkdirSync21(dirname15(handOver), { recursive: true });
135803
+ rmSync17(handOver, { force: true });
135716
135804
  const askedForBrowserLog = /(^|,)\s*(pw:browser|pw:\*|\*)\s*(,|$)/.test(env.DEBUG ?? "");
135717
135805
  const childEnv = { ...env, SW_TEST_REPORT: handOver, DEBUG: askedForBrowserLog ? env.DEBUG : [env.DEBUG, "pw:browser"].filter(Boolean).join(",") };
135718
135806
  const child = spawn7(process.execPath, [script, ...extraArgs], { cwd: root, env: childEnv, stdio: ["inherit", "pipe", "pipe"] });
@@ -135740,11 +135828,11 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
135740
135828
  stderrLines("", true);
135741
135829
  let report2 = null;
135742
135830
  try {
135743
- report2 = existsSync39(handOver) ? JSON.parse(readFileSync42(handOver, "utf8")) : null;
135831
+ report2 = existsSync39(handOver) ? JSON.parse(readFileSync43(handOver, "utf8")) : null;
135744
135832
  } catch {
135745
135833
  report2 = null;
135746
135834
  }
135747
- rmSync16(handOver, { force: true });
135835
+ rmSync17(handOver, { force: true });
135748
135836
  results.push({
135749
135837
  script,
135750
135838
  ok: exitCode === 0,
@@ -135777,16 +135865,16 @@ function lastFailedScripts(root) {
135777
135865
  if (!existsSync39(path3))
135778
135866
  return [];
135779
135867
  try {
135780
- return (JSON.parse(readFileSync42(path3, "utf8")).results ?? []).filter((r) => !r.ok).map((r) => r.script);
135868
+ return (JSON.parse(readFileSync43(path3, "utf8")).results ?? []).filter((r) => !r.ok).map((r) => r.script);
135781
135869
  } catch {
135782
135870
  return [];
135783
135871
  }
135784
135872
  }
135785
135873
  function recordScriptResults(root, results, rerunOnly) {
135786
- const previous = rerunOnly && existsSync39(join46(root, LAST)) ? JSON.parse(readFileSync42(join46(root, LAST), "utf8")).results ?? [] : [];
135874
+ const previous = rerunOnly && existsSync39(join46(root, LAST)) ? JSON.parse(readFileSync43(join46(root, LAST), "utf8")).results ?? [] : [];
135787
135875
  const merged = [...previous.filter((p2) => !results.some((r) => r.script === p2.script)), ...results];
135788
- mkdirSync20(join46(root, ".somewhere", "tests"), { recursive: true });
135789
- writeFileSync26(join46(root, LAST), JSON.stringify({ finished: (/* @__PURE__ */ new Date()).toISOString(), results: merged }, null, 2) + "\n");
135876
+ mkdirSync21(join46(root, ".somewhere", "tests"), { recursive: true });
135877
+ writeFileSync27(join46(root, LAST), JSON.stringify({ finished: (/* @__PURE__ */ new Date()).toISOString(), results: merged }, null, 2) + "\n");
135790
135878
  }
135791
135879
  var BROWSER_CRASH, BROWSER_CRASH_REASON, isScript, LAST;
135792
135880
  var init_test_scripts = __esm({
@@ -135899,7 +135987,7 @@ var init_test = __esm({
135899
135987
  });
135900
135988
 
135901
135989
  // dist/commands/test-users.js
135902
- import { existsSync as existsSync40, readFileSync as readFileSync43, rmSync as rmSync17 } from "node:fs";
135990
+ import { existsSync as existsSync40, readFileSync as readFileSync44, rmSync as rmSync18 } from "node:fs";
135903
135991
  import { basename as basename10, join as join47 } from "node:path";
135904
135992
  import { randomBytes as randomBytes9 } from "node:crypto";
135905
135993
  async function resolveTarget(projectOpt, originOpt) {
@@ -136168,7 +136256,7 @@ function registerTestUsers(program2) {
136168
136256
  if (left.length)
136169
136257
  writeManifest(target.root, { ...manifest, actors: left, status: "partial" });
136170
136258
  else
136171
- rmSync17(join47(stateDir(target.root), MANIFEST_FILE), { force: true });
136259
+ rmSync18(join47(stateDir(target.root), MANIFEST_FILE), { force: true });
136172
136260
  if (opts.json) {
136173
136261
  printJson(receipt);
136174
136262
  if (left.length)
@@ -136415,7 +136503,7 @@ var init_skills = __esm({
136415
136503
  });
136416
136504
 
136417
136505
  // dist/commands/ai.js
136418
- import { readFileSync as readFileSync44 } from "node:fs";
136506
+ import { readFileSync as readFileSync45 } from "node:fs";
136419
136507
  function fail4(message3) {
136420
136508
  error(message3);
136421
136509
  process.exit(1);
@@ -136436,7 +136524,7 @@ async function readKey(stdin) {
136436
136524
  if (stdin) {
136437
136525
  if (process.stdin.isTTY)
136438
136526
  fail4("Pipe the key into --stdin, or leave out --stdin to type it into a hidden prompt.");
136439
- raw = readFileSync44(0, "utf8");
136527
+ raw = readFileSync45(0, "utf8");
136440
136528
  } else {
136441
136529
  if (!process.stdin.isTTY)
136442
136530
  fail4("Pass --stdin to read the key from a pipe. Nothing was sent.");
@@ -136583,13 +136671,13 @@ var init_startup_notice = __esm({
136583
136671
  });
136584
136672
 
136585
136673
  // dist/lib/last-run.js
136586
- import { lstatSync as lstatSync5, mkdirSync as mkdirSync21, renameSync as renameSync6, unlinkSync as unlinkSync6, writeFileSync as writeFileSync27 } from "node:fs";
136674
+ import { lstatSync as lstatSync6, mkdirSync as mkdirSync22, renameSync as renameSync7, unlinkSync as unlinkSync6, writeFileSync as writeFileSync28 } from "node:fs";
136587
136675
  import { join as join49 } from "node:path";
136588
136676
  function removeStaleRunRecord(dir = cliConfigDir()) {
136589
136677
  for (const name of RUN_RECORD_FILES) {
136590
136678
  const path3 = join49(dir, name);
136591
136679
  try {
136592
- if (lstatSync5(path3).isDirectory()) {
136680
+ if (lstatSync6(path3).isDirectory()) {
136593
136681
  process.stderr.write(`Could not remove ${path3}: it is a directory, not this CLI's run record. Check it yourself.
136594
136682
  `);
136595
136683
  continue;
@@ -136618,7 +136706,7 @@ function recordLastRun(cliVersion) {
136618
136706
  process.once("exit", (exitCode) => {
136619
136707
  try {
136620
136708
  const dir = cliConfigDir();
136621
- mkdirSync21(dir, { recursive: true, mode: 448 });
136709
+ mkdirSync22(dir, { recursive: true, mode: 448 });
136622
136710
  const record3 = {
136623
136711
  // A usage error never reaches a command: no command and no options.
136624
136712
  command: invocation?.command ?? "",
@@ -136629,8 +136717,8 @@ function recordLastRun(cliVersion) {
136629
136717
  };
136630
136718
  const path3 = join49(dir, "last-run.json");
136631
136719
  const temporary = join49(dir, "last-run.json.tmp");
136632
- writeFileSync27(temporary, JSON.stringify(record3) + "\n", { mode: 384 });
136633
- renameSync6(temporary, path3);
136720
+ writeFileSync28(temporary, JSON.stringify(record3) + "\n", { mode: 384 });
136721
+ renameSync7(temporary, path3);
136634
136722
  } catch {
136635
136723
  }
136636
136724
  });
@@ -136666,7 +136754,7 @@ __export(dist_exports, {
136666
136754
  runCli: () => runCli
136667
136755
  });
136668
136756
  import { spawnSync as spawnSync6 } from "node:child_process";
136669
- import { readFileSync as readFileSync45 } from "node:fs";
136757
+ import { readFileSync as readFileSync46 } from "node:fs";
136670
136758
  import { join as join50 } from "node:path";
136671
136759
  async function runCli() {
136672
136760
  const pinned = decidePin(process.cwd(), CLI_VERSION, process.argv, process.env);
@@ -136695,7 +136783,7 @@ async function runCli() {
136695
136783
  process.exit(child.status ?? 1);
136696
136784
  }
136697
136785
  removeStaleRunRecord();
136698
- const pkg = JSON.parse(readFileSync45(join50(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
136786
+ const pkg = JSON.parse(readFileSync46(join50(CLI_PACKAGE_ROOT, "package.json"), "utf8"));
136699
136787
  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);
136700
136788
  recordLastRun(pkg.version);
136701
136789
  const jsonOutputRequested = process.argv.includes("--json");