@superwall/cli 2.6.0-beta.2 → 2.6.1

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 (152) hide show
  1. package/README.md +47 -16
  2. package/dist/{apple-Dc5pOPms.js → apple-BE1GBJFP.js} +17 -19
  3. package/dist/{approve-BSbdmOez.js → approve-yRZmvkCj.js} +9 -11
  4. package/dist/{assets-C_RjojkK.js → assets-DTAgbWw0.js} +3 -3
  5. package/dist/auth.d.ts +11 -4
  6. package/dist/auth.js +4 -5
  7. package/dist/base-zc1wl_9b.js +82 -0
  8. package/dist/{billing-B6HK-F_a.js → billing-C1LV4-BN.js} +3 -3
  9. package/dist/{build-DK88pTMW.js → build-CQd-pf7O.js} +35 -16
  10. package/dist/{client-x08fpvay.js → config-DCqRQTJ4.js} +162 -15
  11. package/dist/create-CSHGZDfB.js +18 -0
  12. package/dist/{create-kpqEhqkk.js → create-Costu6UT.js} +9 -9
  13. package/dist/{create-B6-Dr3GZ.js → create-wlCp83IH.js} +41 -41
  14. package/dist/{doctor-DYbm8IKQ.js → doctor-Bd9ffg51.js} +50 -10
  15. package/dist/entry.js +45 -40
  16. package/dist/{environment-BFNzLLPN.js → environment-Dn7irhZr.js} +1 -1
  17. package/dist/{drivers-Dyi-y9Jn.js → existing-BQMB_2AG.js} +305 -8
  18. package/dist/framework-DW5fqjh4.js +65 -0
  19. package/dist/{source-BccdO4aL.js → git-Hf9Wc7Hp.js} +34 -92
  20. package/dist/{held-sKq3xrsT.js → held-D5wSX2Mf.js} +9 -9
  21. package/dist/held-Dmf5SR3p.js +15 -0
  22. package/dist/{install-DsIsif39.js → install-CxyqfKFe.js} +15 -17
  23. package/dist/{integrate-B8eA676b.js → integrate-MkyDDzI5.js} +33 -38
  24. package/dist/{login-BlpfYapG.js → login-B7IqDafm.js} +3 -3
  25. package/dist/{login-Blhxi20A.js → login-BMHDhxAx.js} +8 -9
  26. package/dist/login-Cp0-BgDZ.js +13 -0
  27. package/dist/{lookup-Dg55W9S7.js → lookup-DkcT4E-5.js} +28 -4
  28. package/dist/{migrate-DoRb9jmA.js → migrate-CdFoZipj.js} +66 -45
  29. package/dist/{notification-url-D82msWF5.js → notification-url-D6KKeXnk.js} +4 -4
  30. package/dist/{open-BAqLpTSI.js → open-COJE6ryI.js} +2 -2
  31. package/dist/{org-C4G7WjTV.js → org-BV8wwxwc.js} +4 -4
  32. package/dist/{organization-CmuQwcKN.js → organization-9R_1PJKk.js} +4 -4
  33. package/dist/{orgs-1OzwUtpT.js → orgs-ltP8H0Nl.js} +1 -2
  34. package/dist/{paths-gBbqgkS7.js → paths-Cb1RfjaX.js} +1 -1
  35. package/dist/{playbook-BKqlv77S.js → playbook-CVGolez9.js} +10 -14
  36. package/dist/{products-Cqq59DBQ.js → products-CJq_iXv5.js} +1 -1
  37. package/dist/{promote-D0i8A0CO.js → promote-B_HnFEbX.js} +27 -28
  38. package/dist/{pull-DgQ_UmGv.js → pull-DF4KYVcP.js} +72 -26
  39. package/dist/pull-JxiMyRwY.js +30 -0
  40. package/dist/{pull-CiIrJ5ik.js → pull-lYRULo4v.js} +33 -39
  41. package/dist/push-B5py7h5y.js +29 -0
  42. package/dist/{push-7N4XIVtg.js → push-BZN1Qpkq.js} +23 -12
  43. package/dist/{push-BWsXO7FN.js → push-BnllH2Rd.js} +8 -7
  44. package/dist/push-DHlUMkbf.js +21 -0
  45. package/dist/registry-BGEYCWyD.js +22 -0
  46. package/dist/{registry-aAR_8VOw.js → registry-CqePfigB.js} +1287 -902
  47. package/dist/{resolve-CcOpO_5s.js → resolve-B4bd3Qjl.js} +4 -4
  48. package/dist/{resources-DNwvf8rg.js → resources-BaURbSpY.js} +15 -2
  49. package/dist/{run-tVYJ3V5j.js → run-Bme4Egyl.js} +15 -17
  50. package/dist/{scan-dv0rrY4C.js → scan-DugxddUU.js} +1 -1
  51. package/dist/scan-J2DILUNE.js +4 -0
  52. package/dist/{scope-ehZ7L1nj.js → scope-Cg1AdAfO.js} +33 -3
  53. package/dist/{scope-BXoQo30_.js → scope-DDYLQeZw.js} +24 -18
  54. package/dist/screenshot-file-Dix2Qynm.js +127 -0
  55. package/dist/{sdk-DEfQttek.js → sdk-BFunw4Hc.js} +1 -1
  56. package/dist/{framework-JFLjmD5Y.js → selection-C439nEhn.js} +4 -54
  57. package/dist/{series-D2ZpZ8cx.js → series-B8NJK4yS.js} +1 -1
  58. package/dist/{server-CcZGdYjE.js → server-C_aMxzvS.js} +40 -18
  59. package/dist/server-Cif9w5lM.js +33 -0
  60. package/dist/{session-dHBtgSN0.js → session-B7frlXXQ.js} +1 -1
  61. package/dist/{base-83ZTv6up.js → session-CfG3gzko.js} +8 -83
  62. package/dist/session-DvaPyOuH.js +5 -0
  63. package/dist/{migration-BUedsREQ.js → setup-DQEasPhx.js} +290 -28
  64. package/dist/skills/index.json +5 -0
  65. package/dist/skills/superwall/SKILL.md +37 -10
  66. package/dist/skills/superwall/references/api.md +66 -21
  67. package/dist/skills/superwall/references/asa.md +109 -64
  68. package/dist/skills/superwall/references/dashboard-links.md +65 -28
  69. package/dist/skills/superwall/references/data-analytics.md +1 -1
  70. package/dist/skills/superwall/workflows/dashboard/setup.md +15 -5
  71. package/dist/skills/superwall/workflows/integrate/flutter.md +9 -7
  72. package/dist/skills/superwall-framework/SKILL.md +248 -36
  73. package/dist/skills/superwall-framework/references/cli.md +98 -7
  74. package/dist/skills/superwall-framework/references/examples.md +2 -2
  75. package/dist/skills/superwall-framework/references/layout.md +30 -2
  76. package/dist/skills/superwall-framework/references/migrate-from-editor.md +5 -0
  77. package/dist/skills/superwall-framework/references/migrate-from-native.md +5 -0
  78. package/dist/skills/teleport/SKILL.md +154 -0
  79. package/dist/skills/teleport/references/experiments.md +328 -0
  80. package/dist/skills/teleport/references/setup.md +157 -0
  81. package/dist/{skills-Q7xB784d.js → skills-DnegE1A6.js} +139 -9
  82. package/dist/{skills-Bqz2l_bx.js → skills-MmF7IyTg.js} +8 -12
  83. package/dist/source-DQs6iLtC.js +82 -0
  84. package/dist/{source-push-CG948HrX.js → source-push-MbJjh4Ki.js} +38 -14
  85. package/dist/{spinner-IA6hV8nI.js → spinner-Dcr-Dqdi.js} +7 -5
  86. package/dist/{starter-BtUUQWhd.js → starter-BlJ_InZJ.js} +2 -2
  87. package/dist/{status-CB_MrFu5.js → status-DHRxg1ZA.js} +9 -11
  88. package/dist/{output-Ggzq5_-t.js → storage-DdIAHolY.js} +40 -1
  89. package/dist/storekit-De998QOt.js +203 -0
  90. package/dist/storekit-iBCWmeKn.js +15 -0
  91. package/dist/{bind-DcWIIPgk.js → theme-BrUrye-c.js} +29 -6
  92. package/dist/token-CKCBQ4I8.js +100 -0
  93. package/dist/tools-skills/animate-onboarding/SKILL.md +1 -1
  94. package/dist/tools-skills/mobile-design/SKILL.md +1 -1
  95. package/dist/tools-skills/onboarding-questions/SKILL.md +1 -1
  96. package/dist/tools-skills/superwall/SKILL.md +43 -17
  97. package/dist/tools-skills/superwall/references/api.md +74 -24
  98. package/dist/tools-skills/superwall/references/asa.md +109 -64
  99. package/dist/tools-skills/superwall/references/dashboard-links.md +65 -28
  100. package/dist/tools-skills/superwall/references/data-analytics.md +1 -1
  101. package/dist/tools-skills/superwall/workflows/dashboard/playbook.md +4 -3
  102. package/dist/tools-skills/superwall/workflows/dashboard/setup.md +21 -8
  103. package/dist/tools-skills/superwall/workflows/integrate/flutter.md +9 -7
  104. package/dist/tools-skills/superwall/workflows/migrate/adapty.md +4 -3
  105. package/dist/tools-skills/superwall/workflows/migrate/playbook.md +2 -2
  106. package/dist/tools-skills/superwall/workflows/migrate/qonversion.md +4 -3
  107. package/dist/tools-skills/superwall/workflows/migrate/revenuecat.md +4 -3
  108. package/dist/tools-skills/superwall-editor/SKILL.md +2 -3
  109. package/dist/tools-skills/teleport/SKILL.md +154 -0
  110. package/dist/tools-skills/teleport/references/experiments.md +328 -0
  111. package/dist/tools-skills/teleport/references/setup.md +157 -0
  112. package/dist/tools.d.ts +1 -1
  113. package/dist/tools.js +1232 -746
  114. package/dist/{try-CS3jLyoP.js → try-C8QQbG0b.js} +17 -19
  115. package/dist/{lock-DgSx-p8Y.js → types-Dc9U_4kp.js} +86 -80
  116. package/dist/upgrade-CYFdpVpi.js +27 -0
  117. package/dist/upgrade-D0thxCA4.js +348 -0
  118. package/package.json +11 -3
  119. package/dist/config-CGcG7GOt.js +0 -113
  120. package/dist/create-Du8Fx7W5.js +0 -20
  121. package/dist/existing-WQ3pz94o.js +0 -97
  122. package/dist/held-DmOhszHR.js +0 -17
  123. package/dist/log-C0MDCfA2.js +0 -62
  124. package/dist/login-D9jfRO8w.js +0 -17
  125. package/dist/pull-CO5HlqBe.js +0 -36
  126. package/dist/push-BIhGDNpL.js +0 -30
  127. package/dist/push-BgqTddLA.js +0 -22
  128. package/dist/run-B-YoyB-a.js +0 -100
  129. package/dist/scan-BU41gcQY.js +0 -4
  130. package/dist/screenshot-file-XAS0Xy0e.js +0 -16
  131. package/dist/server-BemmM1FV.js +0 -29
  132. package/dist/session-4aITGsF1.js +0 -6
  133. package/dist/setup-m94dpT3t.js +0 -217
  134. package/dist/spawn-DmmmHIP-.js +0 -71
  135. package/dist/storage-pR0Wb0d9.js +0 -41
  136. package/dist/storekit-BMxyYAHj.js +0 -17
  137. package/dist/storekit-CQnwlpKV.js +0 -47
  138. package/dist/telemetry-DU56L7Cy.js +0 -56
  139. package/dist/theme-DUsCh-Vd.js +0 -25
  140. package/dist/token-BbUeExGJ.js +0 -70
  141. package/dist/upgrade-CKn88PZD.js +0 -206
  142. package/dist/upgrade-DfD3-ClG.js +0 -7
  143. /package/dist/{browser-Bp3yRKlU.js → browser-BVjaf98V.js} +0 -0
  144. /package/dist/{client-BJQXl62Q.js → client-BwYhzITp.js} +0 -0
  145. /package/dist/{design-lint-CiFc78aM.js → design-lint-mgO-2SGS.js} +0 -0
  146. /package/dist/{devtools-ByZ6XYnn.js → devtools-B6Vp6HMy.js} +0 -0
  147. /package/dist/{input-MDd67UIp.js → input-DOT_2Zvb.js} +0 -0
  148. /package/dist/{project-NoMtbMyl.js → project-BomArwSj.js} +0 -0
  149. /package/dist/{reports-HYVp169R.js → reports-hbxsd3Zo.js} +0 -0
  150. /package/dist/{storage-Bdz5AmqS.d.ts → storage-Bh3wT1Rn.d.ts} +0 -0
  151. /package/dist/{timing-Ca0TXY-A.js → timing-BKEEIBij.js} +0 -0
  152. /package/dist/{ui-D_qf3Gvw.js → ui-hFgji1e8.js} +0 -0
@@ -1,12 +1,61 @@
1
- import { t as getOAuthAccessToken } from "./token-BbUeExGJ.js";
2
- import { t as API_HOST, x as VERSION } from "./environment-BFNzLLPN.js";
3
- import { n as readSession } from "./storage-pR0Wb0d9.js";
4
- import { n as readVersion, r as spawnStream, t as onPath } from "./spawn-DmmmHIP-.js";
1
+ import { t as getOAuthAccessToken } from "./token-CKCBQ4I8.js";
2
+ import { n as readSession } from "./storage-DdIAHolY.js";
3
+ import { d as DASHBOARD_URL, h as Integration, t as API_HOST, x as VERSION } from "./environment-Dn7irhZr.js";
4
+ import { _ as readVersion, g as onPath, v as spawnStream } from "./skills-DnegE1A6.js";
5
+ import { i as readPackageJson, r as allDeps } from "./scan-DugxddUU.js";
6
+ import { O as field } from "./resources-BaURbSpY.js";
7
+ import { n as fg$1, t as THEME } from "./theme-BrUrye-c.js";
8
+ import { i as packagedDir } from "./paths-Cb1RfjaX.js";
9
+ import { createRequire } from "node:module";
10
+ import { spawn } from "node:child_process";
11
+ import { readFileSync } from "node:fs";
5
12
  import { tmpdir } from "node:os";
6
13
  import { basename, join } from "node:path";
14
+ import { pathToFileURL } from "node:url";
15
+ import pc from "picocolors";
7
16
  import { readFile, rm } from "node:fs/promises";
8
- import { query } from "@anthropic-ai/claude-agent-sdk";
17
+ import { link } from "ansi-escapes";
18
+ import wrapAnsi from "wrap-ansi";
19
+ import fg from "fast-glob";
9
20
 
21
+ //#region src/ui/clipboard.ts
22
+ async function copyToClipboard(text) {
23
+ const cmd = resolveClipboardCommand();
24
+ return new Promise((resolve$1) => {
25
+ try {
26
+ const child = spawn(cmd.command, cmd.args, { stdio: [
27
+ "pipe",
28
+ "ignore",
29
+ "ignore"
30
+ ] });
31
+ child.on("error", () => resolve$1(false));
32
+ child.on("close", (code) => resolve$1(code === 0));
33
+ child.stdin.on("error", () => resolve$1(false));
34
+ child.stdin.write(text);
35
+ child.stdin.end();
36
+ } catch {
37
+ resolve$1(false);
38
+ }
39
+ });
40
+ }
41
+ function resolveClipboardCommand() {
42
+ switch (process.platform) {
43
+ case "darwin": return {
44
+ command: "pbcopy",
45
+ args: []
46
+ };
47
+ case "win32": return {
48
+ command: "clip",
49
+ args: []
50
+ };
51
+ default: return {
52
+ command: "xclip",
53
+ args: ["-selection", "clipboard"]
54
+ };
55
+ }
56
+ }
57
+
58
+ //#endregion
10
59
  //#region src/core/workflows/agent/drivers/capabilities.ts
11
60
  function toolsForCapabilities(capabilities) {
12
61
  const tools = [
@@ -273,6 +322,9 @@ async function selectHostedStatus() {
273
322
  //#endregion
274
323
  //#region src/core/workflows/agent/drivers/superwall.ts
275
324
  const SDK_MODEL_ALIAS = "claude-sonnet-5";
325
+ const AGENT_SDK_PACKAGE = "@anthropic-ai/claude-agent-sdk";
326
+ const AGENT_SDK_VERSION = "0.3.201";
327
+ const AGENT_SDK_INSTALL_MESSAGE = `The bundled Superwall Agent needs ${AGENT_SDK_PACKAGE}. Install it with \`npm install ${AGENT_SDK_PACKAGE}@${AGENT_SDK_VERSION}\`, or use Claude Code or Codex.`;
276
328
  function resultText(message) {
277
329
  if ("result" in message && typeof message.result === "string") return message.result;
278
330
  if ("errors" in message && Array.isArray(message.errors)) return message.errors.join("\n");
@@ -313,11 +365,44 @@ async function resolveRunAuth() {
313
365
  token
314
366
  };
315
367
  }
316
- function createSuperwallDriver(runQuery) {
368
+ const MISSING_MODULE_CODES = new Set(["ERR_MODULE_NOT_FOUND", "MODULE_NOT_FOUND"]);
369
+ function isRunQuery(value) {
370
+ return typeof value === "function";
371
+ }
372
+ function queryOf(module) {
373
+ const query = field(module, "query");
374
+ return isRunQuery(query) ? query : null;
375
+ }
376
+ function isMissingModule(error) {
377
+ const code = field(error, "code");
378
+ return typeof code === "string" && MISSING_MODULE_CODES.has(code);
379
+ }
380
+ async function importIfInstalled(importModule, specifier) {
381
+ try {
382
+ return queryOf(await importModule(specifier()));
383
+ } catch (error) {
384
+ if (isMissingModule(error)) return void 0;
385
+ throw error;
386
+ }
387
+ }
388
+ function createSdkLoader(cwd = () => process.cwd(), importModule = (specifier) => import(specifier)) {
389
+ let loaded;
390
+ const fromProject = () => pathToFileURL(createRequire(join(cwd(), "package.json")).resolve(AGENT_SDK_PACKAGE)).href;
391
+ return () => {
392
+ loaded ??= (async () => {
393
+ const beside = await importIfInstalled(importModule, () => AGENT_SDK_PACKAGE);
394
+ if (beside !== void 0) return beside;
395
+ return await importIfInstalled(importModule, fromProject) ?? null;
396
+ })();
397
+ return loaded;
398
+ };
399
+ }
400
+ function createSuperwallDriver(loadQuery) {
317
401
  return {
318
402
  id: "superwall",
319
403
  displayName: "Superwall Agent",
320
404
  async detect() {
405
+ if (!await loadQuery()) return null;
321
406
  return {
322
407
  id: "superwall",
323
408
  displayName: "Superwall Agent",
@@ -325,6 +410,17 @@ function createSuperwallDriver(runQuery) {
325
410
  };
326
411
  },
327
412
  async run(opts) {
413
+ const runQuery = await loadQuery();
414
+ if (!runQuery) {
415
+ opts.onEvent?.({
416
+ type: "error",
417
+ message: AGENT_SDK_INSTALL_MESSAGE
418
+ });
419
+ return {
420
+ ok: false,
421
+ finalText: AGENT_SDK_INSTALL_MESSAGE
422
+ };
423
+ }
328
424
  const auth = await resolveRunAuth();
329
425
  if (!auth.ok) {
330
426
  opts.onEvent?.({
@@ -404,7 +500,7 @@ function createSuperwallDriver(runQuery) {
404
500
  }
405
501
  };
406
502
  }
407
- const superwallDriver = createSuperwallDriver(query);
503
+ const superwallDriver = createSuperwallDriver(createSdkLoader());
408
504
 
409
505
  //#endregion
410
506
  //#region src/core/workflows/agent/drivers/index.ts
@@ -423,4 +519,205 @@ async function detectDrivers() {
423
519
  }
424
520
 
425
521
  //#endregion
426
- export { selectHostedStatus as n, detectDrivers as t };
522
+ //#region src/core/workflows/agent/prompt.ts
523
+ const cache = /* @__PURE__ */ new Map();
524
+ function readPrompt(rel, vars = {}) {
525
+ let raw = cache.get(rel);
526
+ if (raw === void 0) {
527
+ raw = readFileSync(join(packagedDir("prompts"), rel), "utf8");
528
+ cache.set(rel, raw);
529
+ }
530
+ return raw.replace(/\{\{#(\w+)\}\}([\s\S]*?)\{\{\/\1\}\}/g, (_m, key, body) => vars[key] ? body : "").replace(/\{\{(\w+)\}\}/g, (_m, key) => {
531
+ const value = vars[key];
532
+ if (value === void 0) throw new Error(`Missing prompt variable "${key}" in ${rel}`);
533
+ return value;
534
+ }).replace(/\n{3,}/g, "\n\n").trim();
535
+ }
536
+ function readCommandments() {
537
+ return readPrompt("commandments.xml");
538
+ }
539
+ function buildActionPrompt(action, ctx) {
540
+ return `${readPrompt("context.xml", {
541
+ platform: `${ctx.app.framework.name}${ctx.app.details ? ` (${ctx.app.details})` : ""}`,
542
+ app_dir: ctx.app.path,
543
+ api_key: ctx.apiKey || "(not provided)",
544
+ sdk_installed: ctx.existing.sdkInstalled ? "yes" : "no",
545
+ configure_present: ctx.existing.configureFound ? "yes" : "no",
546
+ docs_url: ctx.app.framework.docsUrl,
547
+ dashboard_url: DASHBOARD_URL
548
+ })}\n\n${readPrompt(`actions/${action.id}.xml`, action.vars(ctx))}`;
549
+ }
550
+ function buildCopyPrompt(action, ctx) {
551
+ return buildActionPrompt(action, ctx).split("\n").filter((line) => !line.includes("[STATUS]")).join("\n").trimEnd();
552
+ }
553
+
554
+ //#endregion
555
+ //#region src/core/workflows/agent/run.ts
556
+ async function runAction(opts) {
557
+ return runWithDriverFallback([opts.driver, ...opts.fallbackDrivers ?? []], {
558
+ prompt: buildActionPrompt(opts.action, opts.ctx),
559
+ cwd: opts.ctx.app.path,
560
+ systemAppend: readCommandments(),
561
+ capabilities: opts.action.capabilities,
562
+ onEvent: opts.onEvent,
563
+ signal: opts.signal
564
+ });
565
+ }
566
+ async function runWithDriverFallback(drivers, options) {
567
+ if (drivers.length === 0) throw new Error("No agent driver available.");
568
+ let result = { ok: false };
569
+ for (const driver of drivers) {
570
+ result = await driver.run(options);
571
+ if (result.ok || result.failureReason !== "usage-limit") return result;
572
+ }
573
+ return result;
574
+ }
575
+
576
+ //#endregion
577
+ //#region src/ui/log.ts
578
+ function brand(text) {
579
+ return fg$1(THEME.primary, text);
580
+ }
581
+ function stripReport(raw) {
582
+ const lines = raw.replace(/\r/g, "").split("\n").filter((l) => !/^\s*\[STATUS\]/i.test(l));
583
+ while (lines[0]?.trim() === "") lines.shift();
584
+ while (lines.at(-1)?.trim() === "") lines.pop();
585
+ return lines.join("\n");
586
+ }
587
+ function styleMarkdown(text) {
588
+ return text.split("\n").map((line) => styleMarkdownLine(line)).join("\n");
589
+ }
590
+ function styleMarkdownLine(line, opts = {}) {
591
+ const heading = line.match(/^\s*(#{1,6})\s+(.*)$/)?.[2];
592
+ if (heading !== void 0) return brand(pc.bold(styleInline(heading, opts.hyperlinks ?? false)));
593
+ return styleInline(line, opts.hyperlinks ?? false);
594
+ }
595
+ function wrapReportLine(line, columns) {
596
+ const prefix = line.match(/^(\s*(?:(?:[-*+])|(?:\d+[.)]))\s+)/)?.[1] ?? "";
597
+ const content = prefix ? line.slice(prefix.length) : line;
598
+ const width = Math.max(12, columns - prefix.length);
599
+ return wrapAnsi(styleMarkdownLine(content, { hyperlinks: true }), width, {
600
+ hard: true,
601
+ trim: false
602
+ }).split("\n").map((part, index) => `${index === 0 ? prefix : " ".repeat(prefix.length)}${part}`);
603
+ }
604
+ function styleInline(line, hyperlinks) {
605
+ const re = /\[([^\]]+)]\(([^)]+)\)|\*\*(.+?)\*\*|`([^`]+)`|(https?:\/\/[^\s]+)/g;
606
+ let out = "";
607
+ let last = 0;
608
+ let match;
609
+ while (match = re.exec(line)) {
610
+ out += line.slice(last, match.index);
611
+ if (match[1] != null && match[2] != null) {
612
+ const label = match[1];
613
+ const target = match[2];
614
+ out += hyperlinks ? link(brand(pc.underline(label)), terminalLinkTarget(target)) : `${label} (${target})`;
615
+ } else if (match[3] != null) out += pc.bold(match[3]);
616
+ else if (match[4] != null) out += brand(match[4]);
617
+ else if (match[5] != null) out += hyperlinks ? link(brand(pc.underline(match[5])), match[5]) : match[5];
618
+ last = re.lastIndex;
619
+ }
620
+ out += line.slice(last);
621
+ return out;
622
+ }
623
+ function terminalLinkTarget(target) {
624
+ const local = target.match(/^(\/.*?)(?::(\d+))?$/);
625
+ const file = local?.[1];
626
+ if (file === void 0) return target;
627
+ const url = pathToFileURL(file).href;
628
+ return local?.[2] ? `${url}#L${local[2]}` : url;
629
+ }
630
+
631
+ //#endregion
632
+ //#region src/core/codebase/existing.ts
633
+ const JS_SDK_PACKAGES = {
634
+ [Integration.expo]: ["expo-superwall"],
635
+ [Integration.reactNative]: ["@superwall/react-native-superwall", "react-native-superwall"],
636
+ [Integration.web]: ["@superwall/web", "superwall-js"]
637
+ };
638
+ const PK_RE = /pk_[A-Za-z0-9._-]{6,}/;
639
+ const CONFIGURE_RE = /Superwall\.(shared\.)?configure|configureSuperwall|SuperwallProvider|\.configure\(\s*apiKey/;
640
+ const SDK_REF_RE = /Superwall-iOS|SuperwallKit|superwallkit_flutter|expo-superwall|superwall/i;
641
+ const SOURCE_GLOBS = [
642
+ "**/*.{swift,ts,tsx,js,jsx,kt,dart}",
643
+ "**/.env*",
644
+ "**/*.xcconfig"
645
+ ];
646
+ const IGNORE = [
647
+ "**/node_modules/**",
648
+ "**/.git/**",
649
+ "**/Pods/**",
650
+ "**/build/**",
651
+ "**/.build/**",
652
+ "**/DerivedData/**",
653
+ "**/dist/**",
654
+ "**/.next/**"
655
+ ];
656
+ const MAX_FILES = 600;
657
+ function sdkInstalledFor(app) {
658
+ const jsPkgs = JS_SDK_PACKAGES[app.integration];
659
+ if (jsPkgs) {
660
+ const deps = allDeps(readPackageJson(app.path));
661
+ if (jsPkgs.some((p) => p in deps)) return true;
662
+ }
663
+ const manifests = fg.sync([
664
+ "**/Package.resolved",
665
+ "**/project.pbxproj",
666
+ "**/Podfile",
667
+ "**/pubspec.yaml",
668
+ "**/pubspec.lock",
669
+ "**/build.gradle",
670
+ "**/build.gradle.kts",
671
+ "**/libs.versions.toml"
672
+ ], {
673
+ cwd: app.path,
674
+ ignore: IGNORE,
675
+ absolute: true,
676
+ deep: 5
677
+ });
678
+ for (const f of manifests) {
679
+ let content;
680
+ try {
681
+ content = readFileSync(f, "utf8");
682
+ } catch {
683
+ continue;
684
+ }
685
+ if (SDK_REF_RE.test(content)) return true;
686
+ }
687
+ return false;
688
+ }
689
+ function detectExisting(app) {
690
+ const sdkInstalled = sdkInstalledFor(app);
691
+ let configureFound = false;
692
+ let apiKey;
693
+ const files = fg.sync(SOURCE_GLOBS, {
694
+ cwd: app.path,
695
+ ignore: IGNORE,
696
+ absolute: true,
697
+ deep: 6,
698
+ dot: true
699
+ });
700
+ for (const f of files.slice(0, MAX_FILES)) {
701
+ let content;
702
+ try {
703
+ content = readFileSync(f, "utf8");
704
+ } catch {
705
+ continue;
706
+ }
707
+ if (!configureFound && CONFIGURE_RE.test(content)) configureFound = true;
708
+ if (!apiKey) {
709
+ const m = content.match(PK_RE);
710
+ if (m) apiKey = m[0];
711
+ }
712
+ if (configureFound && apiKey) break;
713
+ }
714
+ return {
715
+ sdkInstalled,
716
+ configureFound,
717
+ apiKey,
718
+ fullyIntegrated: sdkInstalled && configureFound
719
+ };
720
+ }
721
+
722
+ //#endregion
723
+ export { runAction as a, readPrompt as c, superwallDriver as d, selectHostedStatus as f, wrapReportLine as i, detectDrivers as l, stripReport as n, runWithDriverFallback as o, copyToClipboard as p, styleMarkdown as r, buildCopyPrompt as s, detectExisting as t, AGENT_SDK_INSTALL_MESSAGE as u };
@@ -0,0 +1,65 @@
1
+ import { createRequire } from "node:module";
2
+ import { existsSync, readFileSync } from "node:fs";
3
+ import { dirname, join, resolve } from "node:path";
4
+ import { pathToFileURL } from "node:url";
5
+
6
+ //#region src/core/paywalls/project/framework.ts
7
+ const IGNORE_WORKSPACE_INSTALL = "pnpm install --ignore-workspace";
8
+ function pnpmWorkspaceAbove(dir) {
9
+ let current = dirname(resolve(dir));
10
+ while (!existsSync(join(current, "pnpm-workspace.yaml"))) {
11
+ const parent = dirname(current);
12
+ if (parent === current) return false;
13
+ current = parent;
14
+ }
15
+ return true;
16
+ }
17
+ var FrameworkNotFoundError = class extends Error {
18
+ constructor(dir) {
19
+ const project = existsSync(join(dir, "superwall", "package.json")) ? join(dir, "superwall") : dir;
20
+ super(`No superwall framework found from ${dir}.\nInstall it in the project (\`npm i superwall\` / \`bun add superwall\`) and make sure you run this inside a project with a superwall/ directory.` + (pnpmWorkspaceAbove(project) ? `\nA pnpm workspace above ${project} skips a project it does not list: run \`${IGNORE_WORKSPACE_INSTALL}\` there.` : ""));
21
+ }
22
+ };
23
+ async function importSubpath(packageDir, subpath) {
24
+ return import(pathToFileURL(createRequire(join(packageDir, "package.json")).resolve(subpath)).href);
25
+ }
26
+ function fn(mod, name, subpath) {
27
+ const candidate = mod[name];
28
+ if (typeof candidate !== "function") throw new Error(`This project's superwall version does not export ${name} from ${subpath} — update the project's superwall dependency.`);
29
+ return candidate;
30
+ }
31
+ function resolveFrameworkDir(cwd) {
32
+ for (const anchor of [join(cwd, "superwall", "package.json"), join(cwd, "package.json")]) try {
33
+ return join(createRequire(anchor).resolve("superwall/package.json"), "..");
34
+ } catch {
35
+ continue;
36
+ }
37
+ throw new FrameworkNotFoundError(cwd);
38
+ }
39
+ function frameworkVersion(cwd) {
40
+ try {
41
+ const { version } = JSON.parse(readFileSync(join(resolveFrameworkDir(cwd), "package.json"), "utf8"));
42
+ if (typeof version === "string" && version !== "") return version;
43
+ } catch {
44
+ return "unknown";
45
+ }
46
+ return "unknown";
47
+ }
48
+ async function resolveFramework(cwd) {
49
+ const dir = resolveFrameworkDir(cwd);
50
+ const [discover, build, preview] = await Promise.all([
51
+ importSubpath(dir, "superwall/discover"),
52
+ importSubpath(dir, "superwall/build"),
53
+ importSubpath(dir, "superwall/preview")
54
+ ]);
55
+ const studioProject = typeof preview.buildStudioProject === "function" ? preview.buildStudioProject : void 0;
56
+ return {
57
+ discoverProject: fn(discover, "discoverProject", "superwall/discover"),
58
+ buildSnapshot: fn(build, "buildSnapshot", "superwall/build"),
59
+ startPreviewServer: fn(preview, "startPreviewServer", "superwall/preview"),
60
+ studioProject
61
+ };
62
+ }
63
+
64
+ //#endregion
65
+ export { resolveFramework as i, frameworkVersion as n, pnpmWorkspaceAbove as r, IGNORE_WORKSPACE_INSTALL as t };
@@ -1,12 +1,11 @@
1
- import { n as ui } from "./ui-D_qf3Gvw.js";
2
- import { i as formatSharedLock, v as TYPES_FILE } from "./lock-DgSx-p8Y.js";
3
- import { a as classifyPath, c as isSurfaceRoot, i as LOCK_FILE$1, l as mergeLockText, o as derivedFilesOf, r as DERIVED_FILES, s as isOtherSurfaceDir } from "./scope-ehZ7L1nj.js";
1
+ import { n as ui } from "./ui-hFgji1e8.js";
2
+ import { t as TYPES_FILE } from "./types-Dc9U_4kp.js";
3
+ import { a as classifyPath, c as isSurfaceRoot, i as LOCK_FILE, l as mergeLockText, o as derivedFilesOf, r as DERIVED_FILES, s as isOtherSurfaceDir } from "./scope-Cg1AdAfO.js";
4
4
  import { execFile } from "node:child_process";
5
5
  import * as fs from "node:fs";
6
6
  import * as os$1 from "node:os";
7
7
  import * as path from "node:path";
8
8
  import { promisify } from "node:util";
9
- import fg from "fast-glob";
10
9
 
11
10
  //#region src/core/paywalls/source/commit.ts
12
11
  const noteBody = (note) => {
@@ -88,11 +87,15 @@ const ISOLATION = [
88
87
  "-c",
89
88
  "core.autocrlf=false"
90
89
  ];
90
+ const englishEnv = (env = process.env) => ({
91
+ ...Object.fromEntries(Object.entries(env).filter(([key]) => key !== "LANGUAGE")),
92
+ LC_ALL: "C"
93
+ });
91
94
  async function git(args, options = {}) {
92
95
  try {
93
96
  const { stdout } = await run("git", [...ISOLATION, ...args], {
94
97
  cwd: options.cwd,
95
- env: options.env,
98
+ env: englishEnv(options.env),
96
99
  maxBuffer: 64 * 1024 * 1024,
97
100
  timeout: GIT_TIMEOUT_MS
98
101
  });
@@ -159,8 +162,14 @@ function materializeSourceTree(dir, files, scope, options = {}) {
159
162
  for (const file of files) {
160
163
  if (classifyPath(file.path, scope) === "other") continue;
161
164
  if (file.content.byteLength > LARGE_FILE_BYTES) large.push(file.path);
162
- if (file.path === LOCK_FILE$1 && scope.kind !== "artifact") write(file.path, mergeLockText(theirs.get(LOCK_FILE$1)?.toString("utf8"), file.content.toString("utf8"), scope, { replaceUnreadable: options.overwrite }));
163
- else write(file.path, file.content);
165
+ if (file.path === LOCK_FILE && scope.kind !== "artifact") {
166
+ const repoLock = theirs.get(LOCK_FILE)?.toString("utf8");
167
+ write(file.path, mergeLockText(repoLock, file.content.toString("utf8"), scope, {
168
+ replaceUnreadable: options.overwrite,
169
+ base: keepShared ? void 0 : repoLock,
170
+ application: options.application
171
+ }));
172
+ } else write(file.path, file.content);
164
173
  theirs.delete(file.path);
165
174
  }
166
175
  for (const [derived, content] of theirs) write(derived, content);
@@ -252,6 +261,7 @@ async function pushSourceTree(input) {
252
261
  kind: input.message.kind,
253
262
  id: input.message.surface
254
263
  };
264
+ const application = input.message.kind === "artifact" ? void 0 : input.message.applicationId;
255
265
  const head = await revParse("HEAD");
256
266
  const base = input.base && head && !input.overwrite ? await revParse(input.base) : void 0;
257
267
  if (base && base !== head) await run$1([
@@ -267,7 +277,8 @@ async function pushSourceTree(input) {
267
277
  const unsynced = onRemote && scope.kind === "project";
268
278
  materializeSourceTree(dir, input.files, scope, {
269
279
  onRemote: onRemote && scope.kind !== "artifact",
270
- overwrite: input.overwrite
280
+ overwrite: input.overwrite,
281
+ application
271
282
  });
272
283
  await run$1(["add", "-A"]);
273
284
  const dirty = (await run$1(["status", "--porcelain"])).trim();
@@ -345,7 +356,9 @@ async function pushSourceTree(input) {
345
356
  committing,
346
357
  dir,
347
358
  own,
348
- scope
359
+ scope,
360
+ base,
361
+ application
349
362
  });
350
363
  await confirmIncoming(parent ?? own, upstream);
351
364
  }
@@ -467,7 +480,7 @@ async function cloneSource(access, dir, options) {
467
480
  }
468
481
  throw first;
469
482
  }
470
- async function mergeUpstream(upstream, messageFile, { run: run$1, committing, dir, own, scope }) {
483
+ async function mergeUpstream(upstream, messageFile, { run: run$1, committing, dir, own, scope, base, application }) {
471
484
  let failure;
472
485
  await run$1([
473
486
  "merge",
@@ -500,11 +513,15 @@ async function mergeUpstream(upstream, messageFile, { run: run$1, committing, di
500
513
  if (!merging) return;
501
514
  const show = (ref, file) => run$1(["show", `${ref}:${file}`]).then((text) => text, () => void 0);
502
515
  if (scope.kind !== "artifact") {
503
- const theirsLock = await show(upstream, LOCK_FILE$1);
504
- const mineLock = await show(own, LOCK_FILE$1);
505
- await settle(run$1, dir, LOCK_FILE$1, mineLock === void 0 ? theirsLock : mergeLockText(theirsLock, mineLock, scope));
516
+ const theirsLock = await show(upstream, LOCK_FILE);
517
+ const mineLock = await show(own, LOCK_FILE);
518
+ const baseLock = base === void 0 ? void 0 : await show(base, LOCK_FILE);
519
+ await settle(run$1, dir, LOCK_FILE, mineLock === void 0 ? theirsLock : mergeLockText(theirsLock, mineLock, scope, {
520
+ base: baseLock,
521
+ application
522
+ }));
506
523
  }
507
- for (const file of derived) if (file !== LOCK_FILE$1) await settle(run$1, dir, file, await show(own, file));
524
+ for (const file of derived) if (file !== LOCK_FILE) await settle(run$1, dir, file, await show(own, file));
508
525
  await run$1([
509
526
  "commit",
510
527
  "--quiet",
@@ -665,7 +682,8 @@ async function pullSourceTree(input) {
665
682
  status: "pulled",
666
683
  head,
667
684
  changes,
668
- lock: await shown(LOCK_FILE$1),
685
+ lock: await shown(LOCK_FILE),
686
+ baseLock: base ? await run$1(["show", `${base}:${LOCK_FILE}`]).then((text) => text, () => void 0) : void 0,
669
687
  types: await shown(TYPES_FILE)
670
688
  };
671
689
  } finally {
@@ -690,80 +708,4 @@ function replaceTree(dir, files) {
690
708
  const isRejected = (error) => error instanceof GitError && /rejected|non-fast-forward|fetch first|stale info|failed to push some refs/i.test(error.message);
691
709
 
692
710
  //#endregion
693
- //#region src/core/paywalls/source/source.ts
694
- const HARD_EXCLUDES = [
695
- ".superwall/**",
696
- "**/node_modules/**",
697
- ".git/**",
698
- "**/.env*",
699
- "**/.DS_Store",
700
- "**/.npmrc",
701
- "**/.netrc",
702
- "**/*.pem",
703
- "**/*.p8",
704
- "**/*.p12",
705
- "**/*.key",
706
- "**/*.keystore",
707
- "**/*.jks",
708
- "**/google-services.json",
709
- "**/GoogleService-Info.plist"
710
- ];
711
- const LOCK_FILE = "superwall.lock";
712
- const SOURCE_LIMIT_BYTES = 250 * 1024 * 1024;
713
- const LARGEST_SHOWN = 3;
714
- const megabytes = (bytes) => `${(bytes / 1024 / 1024).toFixed(1)} MB`;
715
- function gitignoreExcludes(superwallDir) {
716
- let text;
717
- try {
718
- text = fs.readFileSync(path.join(superwallDir, ".gitignore"), "utf8");
719
- } catch {
720
- return [];
721
- }
722
- const excludes = [];
723
- for (const raw of text.split("\n")) {
724
- const line = raw.trim();
725
- if (line === "" || line.startsWith("#") || line.startsWith("!")) continue;
726
- const anchored = line.startsWith("/");
727
- const body = (anchored ? line.slice(1) : line).replace(/\/+$/, "");
728
- if (body === "") continue;
729
- const base = anchored || body.includes("/") ? body : `**/${body}`;
730
- excludes.push(base, `${base}/**`);
731
- }
732
- return excludes;
733
- }
734
- const readFramework = (superwallDir, relative$1) => relative$1 === LOCK_FILE ? Buffer.from(formatSharedLock(superwallDir)) : fs.readFileSync(path.join(superwallDir, relative$1));
735
- async function collectSourceFiles(superwallDir, read = readFramework) {
736
- const entries = await fg("**/*", {
737
- cwd: superwallDir,
738
- dot: true,
739
- onlyFiles: true,
740
- followSymbolicLinks: false,
741
- ignore: [...HARD_EXCLUDES, ...gitignoreExcludes(superwallDir)]
742
- });
743
- if (entries.length === 0) return {
744
- ok: false,
745
- reason: `No source files found in ${superwallDir}.`
746
- };
747
- const sizes = entries.map((relative$1) => ({
748
- path: relative$1,
749
- bytes: fs.statSync(path.join(superwallDir, relative$1)).size
750
- }));
751
- const total = sizes.reduce((sum, entry) => sum + entry.bytes, 0);
752
- if (total > SOURCE_LIMIT_BYTES) {
753
- const largest = sizes.sort((a, b) => b.bytes - a.bytes).slice(0, LARGEST_SHOWN).map((entry) => `${entry.path} (${megabytes(entry.bytes)})`).join(", ");
754
- return {
755
- ok: false,
756
- reason: `The source in ${superwallDir} is ${megabytes(total)}, over the ${SOURCE_LIMIT_BYTES / 1024 / 1024} MB limit. Largest: ${largest}. Add what doesn't belong to .gitignore, then push again.`
757
- };
758
- }
759
- return {
760
- ok: true,
761
- files: entries.sort().map((relative$1) => ({
762
- path: relative$1,
763
- content: read(superwallDir, relative$1)
764
- }))
765
- };
766
- }
767
-
768
- //#endregion
769
- export { statIfPresent as a, pushSourceTree as i, gitAvailable as n, pullSourceTree as r, collectSourceFiles as t };
711
+ export { statIfPresent as i, pullSourceTree as n, pushSourceTree as r, gitAvailable as t };
@@ -1,11 +1,11 @@
1
- import { l as readJson, o as cache } from "./output-Ggzq5_-t.js";
2
- import { t as ApiError } from "./client-x08fpvay.js";
3
- import { d as readInput, t as apiCall } from "./spinner-IA6hV8nI.js";
4
- import { A as listField, M as textField, O as field, c as createProject, k as isRecord, m as listProjects, r as createApplication } from "./resources-DNwvf8rg.js";
5
- import { n as orgForNewProject } from "./org-C4G7WjTV.js";
6
- import { n as findApplication } from "./lookup-Dg55W9S7.js";
7
- import { r as pickOrganization } from "./scope-BXoQo30_.js";
8
- import { a as listAscConfigs, c as replaceAppPurchaseKey, l as replaceAscConfig, r as createAscConfig, s as replaceAppAscKey, t as ascProxy } from "./client-BJQXl62Q.js";
1
+ import { h as cache, v as readJson } from "./storage-DdIAHolY.js";
2
+ import { y as ApiError } from "./config-DCqRQTJ4.js";
3
+ import { A as listField, M as textField, O as field, c as createProject, k as isRecord, m as listProjects, r as createApplication } from "./resources-BaURbSpY.js";
4
+ import { d as readInput, t as apiCall } from "./spinner-Dcr-Dqdi.js";
5
+ import { n as orgForNewProject } from "./org-BV8wwxwc.js";
6
+ import { n as findApplication } from "./lookup-DkcT4E-5.js";
7
+ import { r as pickOrganization } from "./scope-DDYLQeZw.js";
8
+ import { a as listAscConfigs, c as replaceAppPurchaseKey, l as replaceAscConfig, r as createAscConfig, s as replaceAppAscKey, t as ascProxy } from "./client-BwYhzITp.js";
9
9
 
10
10
  //#region src/core/app-store-connect/api/spec.ts
11
11
  const REFRESH_TTL_MS = 10080 * 60 * 1e3;
@@ -669,7 +669,7 @@ async function sendAscRequest(ctx, verb, path, options) {
669
669
  }
670
670
  }
671
671
  const teamId = await resolveAscTeam(ctx, api, options.team);
672
- return apiCall(ctx, `${verb.toUpperCase()} ${path}`, () => ascProxy(api, teamId, verb, path, body));
672
+ return await apiCall(ctx, `${verb.toUpperCase()} ${path}`, () => ascProxy(api, teamId, verb, path, body)) ?? { ok: true };
673
673
  }
674
674
 
675
675
  //#endregion
@@ -0,0 +1,15 @@
1
+ import "./token-CKCBQ4I8.js";
2
+ import "./storage-DdIAHolY.js";
3
+ import "./environment-Dn7irhZr.js";
4
+ import "./config-DCqRQTJ4.js";
5
+ import { t as upsertHeldKey } from "./held-D5wSX2Mf.js";
6
+ import "./resources-BaURbSpY.js";
7
+ import "./orgs-ltP8H0Nl.js";
8
+ import "./ui-hFgji1e8.js";
9
+ import "./spinner-Dcr-Dqdi.js";
10
+ import "./org-BV8wwxwc.js";
11
+ import "./lookup-DkcT4E-5.js";
12
+ import "./scope-DDYLQeZw.js";
13
+ import "./client-BwYhzITp.js";
14
+
15
+ export { upsertHeldKey };