@superwall/cli 1.1.0

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 (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +201 -0
  3. package/dist/actions-MB-eBY64.js +140 -0
  4. package/dist/api-BF7-toqM.js +151 -0
  5. package/dist/api-output-B5hh0q4V.js +20 -0
  6. package/dist/app-K6j9Es7h.js +189 -0
  7. package/dist/asc-CArSwo5D.js +539 -0
  8. package/dist/asc-products-YQ6Oc6YO.js +93 -0
  9. package/dist/auth-CY2cO_NF.js +139 -0
  10. package/dist/auth.d.ts +30 -0
  11. package/dist/auth.js +4 -0
  12. package/dist/billing-DWyfEQ6l.js +80 -0
  13. package/dist/bind-hslFhcTR.js +213 -0
  14. package/dist/chunk-DQxbwPpZ.js +30 -0
  15. package/dist/command-Kwx4ekbo.js +283 -0
  16. package/dist/create-Bbi8BOO1.js +410 -0
  17. package/dist/dev-D0lQDCQI.js +397 -0
  18. package/dist/devtools-8EgLo86w.js +3638 -0
  19. package/dist/doctor-ByeRdMcl.js +88 -0
  20. package/dist/drivers-DVAZgone.js +413 -0
  21. package/dist/entry.d.ts +9 -0
  22. package/dist/entry.js +495 -0
  23. package/dist/existing-CcJrIIAU.js +88 -0
  24. package/dist/feedback-Z0Wk7VC5.js +73 -0
  25. package/dist/git-3OX9u3xE.js +433 -0
  26. package/dist/hosted-CHwaUqLd.js +32 -0
  27. package/dist/integrate-DqOAqK7J.js +863 -0
  28. package/dist/json-C3hPIMkI.js +7 -0
  29. package/dist/login-Dr8UN_Gx.js +290 -0
  30. package/dist/migrate-D92bJTg6.js +114 -0
  31. package/dist/org-B2gy9Pmu.js +40 -0
  32. package/dist/params-Bvq0iqQK.js +52 -0
  33. package/dist/pipeline-CHHIg6BU.js +1056 -0
  34. package/dist/print-skill-BnZAk7dV.js +74 -0
  35. package/dist/promote-CRe9170G.js +88 -0
  36. package/dist/publish-DsODvrOD.js +35 -0
  37. package/dist/push-BDkZUC0v.js +35 -0
  38. package/dist/query-DIllrSnk.js +53 -0
  39. package/dist/resource-CdP1MDla.js +483 -0
  40. package/dist/resources-CVrWwA1K.js +233 -0
  41. package/dist/run-cGGBUMs5.js +89 -0
  42. package/dist/scan-BQexuUPO.js +236 -0
  43. package/dist/skills-DhuUs28u.js +64 -0
  44. package/dist/skills-xrfXt9u0.js +205 -0
  45. package/dist/spawn-DSoTXy_j.js +69 -0
  46. package/dist/spinner-gOxIMz-V.js +18 -0
  47. package/dist/storekit-Ddvs4Ynw.js +29 -0
  48. package/dist/telemetry-CcfrtXdf.js +204 -0
  49. package/dist/token-DHRH8cxi.js +102 -0
  50. package/dist/ui-C4ncRJqd.js +27703 -0
  51. package/dist/update-BiVeR024.js +137 -0
  52. package/dist/upgrade-DYWspApv.js +72 -0
  53. package/package.json +87 -0
  54. package/prompts/actions/dashboard-setup.xml +10 -0
  55. package/prompts/actions/integrate.xml +5 -0
  56. package/prompts/actions/migrate.xml +11 -0
  57. package/prompts/actions/placements-implement.xml +20 -0
  58. package/prompts/actions/placements-review.xml +18 -0
  59. package/prompts/actions/review-fix.xml +18 -0
  60. package/prompts/actions/review.xml +18 -0
  61. package/prompts/commandments.xml +17 -0
  62. package/prompts/context.xml +9 -0
  63. package/skills/README.md +118 -0
  64. package/skills/superwall-dashboard/SKILL.md +81 -0
  65. package/skills/superwall-dashboard/references/setup.md +101 -0
  66. package/skills/superwall-integrate/SKILL.md +76 -0
  67. package/skills/superwall-integrate/references/expo.md +269 -0
  68. package/skills/superwall-integrate/references/flutter.md +285 -0
  69. package/skills/superwall-integrate/references/ios.md +314 -0
  70. package/skills/superwall-integrate/references/react-native.md +245 -0
  71. package/skills/superwall-migrate/SKILL.md +83 -0
  72. package/skills/superwall-migrate/references/adapty.md +229 -0
  73. package/skills/superwall-migrate/references/qonversion.md +227 -0
  74. package/skills/superwall-migrate/references/revenuecat.md +414 -0
  75. package/skills/superwall-placements/SKILL.md +73 -0
  76. package/skills/superwall-placements/references/expo.md +161 -0
  77. package/skills/superwall-placements/references/flutter.md +139 -0
  78. package/skills/superwall-placements/references/ios.md +165 -0
  79. package/skills/superwall-placements/references/react-native.md +145 -0
  80. package/skills/superwall-placements/references/strategy.md +221 -0
  81. package/skills/superwall-review/SKILL.md +75 -0
  82. package/skills/superwall-review/references/expo.md +100 -0
  83. package/skills/superwall-review/references/flutter.md +99 -0
  84. package/skills/superwall-review/references/ios.md +108 -0
  85. package/skills/superwall-review/references/react-native.md +100 -0
@@ -0,0 +1,233 @@
1
+ //#region src/core/api/resources.ts
2
+ const RESOURCES = {
3
+ products: "/v2/products",
4
+ campaigns: "/v2/campaigns",
5
+ paywalls: "/v2/paywalls",
6
+ entitlements: "/v2/entitlements"
7
+ };
8
+ const RESOURCE_SCOPE = {
9
+ products: "project",
10
+ entitlements: "project",
11
+ campaigns: "application",
12
+ paywalls: "application"
13
+ };
14
+ function isAppScoped(name) {
15
+ return RESOURCE_SCOPE[name] === "application";
16
+ }
17
+ function titleCase(s) {
18
+ return s ? s[0].toUpperCase() + s.slice(1).toLowerCase() : s;
19
+ }
20
+ function platformLabel(platform) {
21
+ switch ((platform ?? "").toLowerCase()) {
22
+ case "ios": return "iOS";
23
+ case "android": return "Android";
24
+ case "flutter": return "Flutter";
25
+ case "react_native":
26
+ case "react-native": return "React Native";
27
+ case "web": return "Web";
28
+ default: return platform ? platform[0].toUpperCase() + platform.slice(1) : "?";
29
+ }
30
+ }
31
+ async function listProjects(api) {
32
+ const org = api.org?.id;
33
+ return api.list(org ? `/v2/projects?organization_id=${encodeURIComponent(org)}` : "/v2/projects");
34
+ }
35
+ async function listApplications(api) {
36
+ return (await listProjects(api)).flatMap((p) => p.applications ?? []);
37
+ }
38
+ async function listResource(api, name, scope) {
39
+ if (RESOURCE_SCOPE[name] === "application") {
40
+ if (!scope.applicationId) throw new Error("This project has no application yet.");
41
+ return api.list(`${RESOURCES[name]}?application_id=${scope.applicationId}`);
42
+ }
43
+ return api.list(`${RESOURCES[name]}?project_id=${scope.projectId}`);
44
+ }
45
+ function createEntitlement(api, scope, identifier) {
46
+ return api.post("/v2/entitlements", {
47
+ project_id: scope.projectId,
48
+ identifier
49
+ });
50
+ }
51
+ function createProduct(api, scope, identifier, opts = {}) {
52
+ return api.post("/v2/products", {
53
+ project_id: scope.projectId,
54
+ identifier,
55
+ ...opts.name ? { name: opts.name } : {},
56
+ ...opts.price ? { price: opts.price } : {},
57
+ ...opts.subscription ? { subscription: opts.subscription } : {},
58
+ ...opts.entitlements?.length ? { entitlements: opts.entitlements } : {}
59
+ });
60
+ }
61
+ async function listOrganizations(api) {
62
+ return (await api.get("/v2/me/organizations")).data ?? [];
63
+ }
64
+ function createProject(api, name) {
65
+ const orgId = api.org.id;
66
+ if (!orgId) throw new Error("No organization selected - run `superwall orgs use <id|name>` first.");
67
+ return api.post("/v2/projects", {
68
+ name,
69
+ organization_id: Number(orgId)
70
+ });
71
+ }
72
+ function createApplication(api, scope, opts) {
73
+ return api.post(`/v2/projects/${scope.projectId}/applications`, {
74
+ name: opts.name,
75
+ platform: opts.platform,
76
+ ...opts.bundleId ? { bundle_id: opts.bundleId } : {}
77
+ });
78
+ }
79
+ function createCampaign(api, scope, description, placement) {
80
+ if (!scope.applicationId) throw new Error("This project has no application to create a campaign in.");
81
+ return api.post("/v2/campaigns", {
82
+ application_id: scope.applicationId,
83
+ description,
84
+ placements: [{ event_name: placement }],
85
+ audiences: [{ variants: [{
86
+ type: "holdout",
87
+ percentage: 100,
88
+ paywall: null
89
+ }] }]
90
+ });
91
+ }
92
+ function addPlacement(api, campaignId, placement) {
93
+ return api.post(`/v2/campaigns/${campaignId}/placements`, { event_name: placement });
94
+ }
95
+ function rowName(row) {
96
+ for (const key of [
97
+ "name",
98
+ "identifier",
99
+ "product_identifier",
100
+ "title",
101
+ "description",
102
+ "id"
103
+ ]) {
104
+ const v = row[key];
105
+ if (typeof v === "string" && v) return v;
106
+ if (typeof v === "number") return String(v);
107
+ }
108
+ return String(row.id ?? " - ");
109
+ }
110
+ async function listAppPaywalls(api, applicationId, options = {}) {
111
+ return (await api.list(`/v2/paywalls?application_id=${encodeURIComponent(applicationId)}` + (options.archived ? "&archived=true" : ""))).map((row) => {
112
+ const metadata = {};
113
+ if (typeof row.metadata === "object" && row.metadata !== null) {
114
+ for (const [key, value] of Object.entries(row.metadata)) if (typeof value === "string") metadata[key] = value;
115
+ }
116
+ return {
117
+ id: String(row.id),
118
+ identifier: typeof row.identifier === "string" ? row.identifier : void 0,
119
+ archived: options.archived === true,
120
+ metadata
121
+ };
122
+ });
123
+ }
124
+ async function getPaywall(api, paywallId) {
125
+ const row = await api.get(`/v2/paywalls/${encodeURIComponent(paywallId)}`);
126
+ const metadata = {};
127
+ if (typeof row.metadata === "object" && row.metadata !== null) {
128
+ for (const [key, value] of Object.entries(row.metadata)) if (typeof value === "string") metadata[key] = value;
129
+ }
130
+ const applicationId = row.application_id;
131
+ return {
132
+ id: String(row.id ?? paywallId),
133
+ identifier: typeof row.identifier === "string" ? row.identifier : void 0,
134
+ name: typeof row.name === "string" ? row.name : void 0,
135
+ archived: row.archived === true,
136
+ metadata,
137
+ applicationId: typeof applicationId === "string" || typeof applicationId === "number" ? String(applicationId) : void 0,
138
+ version: typeof row.version === "number" ? row.version : void 0,
139
+ url: typeof row.paywall_url === "string" ? row.paywall_url : void 0
140
+ };
141
+ }
142
+ const SNAPSHOT_IN_URL = /([a-f0-9]{64})\.html/;
143
+ async function livePaywall(api, paywallId) {
144
+ return getPaywall(api, paywallId).then((paywall) => ({
145
+ version: paywall.version,
146
+ snapshotId: paywall.url?.match(SNAPSHOT_IN_URL)?.[1]
147
+ }), () => ({}));
148
+ }
149
+ async function livePaywallVersion(api, paywallId) {
150
+ return livePaywall(api, paywallId).then((live) => live.version);
151
+ }
152
+ async function getPaywallApplicationId(api, paywallId) {
153
+ const { applicationId } = await getPaywall(api, paywallId);
154
+ if (applicationId !== void 0) return applicationId;
155
+ throw new Error(`Superwall returned no application for paywall ${paywallId}.`);
156
+ }
157
+ async function createHeadlessPaywall(api, opts) {
158
+ const row = await api.post("/v2/paywalls", {
159
+ application_id: opts.applicationId,
160
+ name: opts.name,
161
+ identifier: opts.identifier,
162
+ headless: true
163
+ });
164
+ return {
165
+ id: String(row.id),
166
+ identifier: opts.identifier,
167
+ archived: false,
168
+ metadata: {}
169
+ };
170
+ }
171
+ const versionProducts = (products, platform) => Object.entries(products ?? {}).map(([reference, identifier]) => ({
172
+ store: /^(test|live):price_[^:]+/.test(identifier) ? "stripe" : platform === "android" ? "play-store" : "app-store",
173
+ identifier,
174
+ reference_name: reference
175
+ }));
176
+ function pushPaywallVersion(api, paywallId, opts) {
177
+ return api.post(`/v2/paywalls/${encodeURIComponent(paywallId)}/versions`, {
178
+ html: opts.html,
179
+ ...opts.surface ? { surface: opts.surface } : {},
180
+ ...opts.assets && opts.assets.length > 0 ? { assets: opts.assets } : {},
181
+ ...opts.products && opts.products.length > 0 ? { products: opts.products } : {},
182
+ ...opts.settings ?? {}
183
+ });
184
+ }
185
+ const ASSET_MANIFEST_CHUNK = 100;
186
+ async function pushPaywallAssets(api, paywallId, assets) {
187
+ const resolved = [];
188
+ for (let at = 0; at < assets.length; at += ASSET_MANIFEST_CHUNK) {
189
+ const rows = (await api.post(`/v2/paywalls/${encodeURIComponent(paywallId)}/assets`, { assets: assets.slice(at, at + ASSET_MANIFEST_CHUNK) })).assets;
190
+ if (!Array.isArray(rows)) throw new Error("The assets endpoint returned no asset list.");
191
+ for (const row of rows) {
192
+ if (typeof row !== "object" || row === null) continue;
193
+ const sha256 = Reflect.get(row, "sha256");
194
+ const url = Reflect.get(row, "url");
195
+ const uploadUrl = Reflect.get(row, "upload_url");
196
+ if (typeof sha256 !== "string" || typeof url !== "string") continue;
197
+ resolved.push({
198
+ sha256,
199
+ url,
200
+ ...typeof uploadUrl === "string" ? { uploadUrl } : {}
201
+ });
202
+ }
203
+ }
204
+ return resolved;
205
+ }
206
+ async function mintSourceAccess(api, paywallId) {
207
+ const row = await api.post(`/v2/paywalls/${encodeURIComponent(paywallId)}/source-access`, {});
208
+ const text = (key) => {
209
+ const value = row[key];
210
+ if (typeof value !== "string" || value === "") throw new Error(`Superwall returned no ${key} for the source repo.`);
211
+ return value;
212
+ };
213
+ return {
214
+ repo: text("repo"),
215
+ remote: text("remote"),
216
+ branch: text("branch"),
217
+ token: text("token"),
218
+ tokenId: text("token_id")
219
+ };
220
+ }
221
+ async function linkSourceCommit(api, paywallId, version, opts) {
222
+ const row = await api.post(`/v2/paywalls/${encodeURIComponent(paywallId)}/versions/${version}/source-commit`, {
223
+ commit_sha: opts.commitSha,
224
+ ...opts.tokenId ? { token_id: opts.tokenId } : {}
225
+ });
226
+ return { commitSha: typeof row.commit_sha === "string" ? row.commit_sha : opts.commitSha };
227
+ }
228
+ function promotePaywallVersion(api, paywallId, opts = {}) {
229
+ return api.post(`/v2/paywalls/${encodeURIComponent(paywallId)}/promote`, { ...opts.version !== void 0 ? { version: opts.version } : {} });
230
+ }
231
+
232
+ //#endregion
233
+ export { rowName as C, pushPaywallVersion as S, versionProducts as T, livePaywallVersion as _, createHeadlessPaywall as a, promotePaywallVersion as b, getPaywallApplicationId as c, listAppPaywalls as d, listApplications as f, livePaywall as g, listResource as h, createEntitlement as i, isAppScoped as l, listProjects as m, createApplication as n, createProduct as o, listOrganizations as p, createCampaign as r, createProject as s, addPlacement as t, linkSourceCommit as u, mintSourceAccess as v, titleCase as w, pushPaywallAssets as x, platformLabel as y };
@@ -0,0 +1,89 @@
1
+ import { C as DASHBOARD_URL } from "./telemetry-CcfrtXdf.js";
2
+ import { s as packagedDir } from "./skills-xrfXt9u0.js";
3
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
+ import { join } from "node:path";
5
+
6
+ //#region src/core/state/reports.ts
7
+ function dir(appPath) {
8
+ return join(appPath, ".superwall");
9
+ }
10
+ function path(appPath, id) {
11
+ return join(dir(appPath), `${id}.md`);
12
+ }
13
+ function saveReport(appPath, id, text) {
14
+ try {
15
+ mkdirSync(dir(appPath), { recursive: true });
16
+ writeFileSync(path(appPath, id), text, "utf8");
17
+ } catch {}
18
+ }
19
+ function loadReport(appPath, id) {
20
+ try {
21
+ const p = path(appPath, id);
22
+ return existsSync(p) ? readFileSync(p, "utf8") : void 0;
23
+ } catch {
24
+ return;
25
+ }
26
+ }
27
+
28
+ //#endregion
29
+ //#region src/core/agent/prompt.ts
30
+ const cache = /* @__PURE__ */ new Map();
31
+ /**
32
+ * Load a prompt from prompts/ and interpolate it.
33
+ * `{{#var}}…{{/var}}` blocks are kept only when `vars[var]` is non-empty;
34
+ * `{{var}}` is a plain substitution and throws when the variable is missing.
35
+ */
36
+ function loadPrompt(rel, vars = {}) {
37
+ let raw = cache.get(rel);
38
+ if (raw === void 0) {
39
+ raw = readFileSync(join(packagedDir("prompts"), rel), "utf8");
40
+ cache.set(rel, raw);
41
+ }
42
+ return raw.replace(/\{\{#(\w+)\}\}([\s\S]*?)\{\{\/\1\}\}/g, (_m, key, body) => vars[key] ? body : "").replace(/\{\{(\w+)\}\}/g, (_m, key) => {
43
+ const value = vars[key];
44
+ if (value === void 0) throw new Error(`Missing prompt variable "${key}" in ${rel}`);
45
+ return value;
46
+ }).replace(/\n{3,}/g, "\n\n").trim();
47
+ }
48
+ function getCommandments() {
49
+ return loadPrompt("commandments.xml");
50
+ }
51
+ function buildActionPrompt(action, ctx) {
52
+ return `${loadPrompt("context.xml", {
53
+ platform: `${ctx.app.framework.name}${ctx.app.details ? ` (${ctx.app.details})` : ""}`,
54
+ app_dir: ctx.app.path,
55
+ api_key: ctx.apiKey || "(not provided)",
56
+ sdk_installed: ctx.existing.sdkInstalled ? "yes" : "no",
57
+ configure_present: ctx.existing.configureFound ? "yes" : "no",
58
+ docs_url: ctx.app.framework.docsUrl,
59
+ dashboard_url: DASHBOARD_URL
60
+ })}\n\n${loadPrompt(`actions/${action.id}.xml`, action.vars(ctx))}`;
61
+ }
62
+ function buildCopyPrompt(action, ctx) {
63
+ return buildActionPrompt(action, ctx).split("\n").filter((line) => !line.includes("[STATUS]")).join("\n").trimEnd();
64
+ }
65
+
66
+ //#endregion
67
+ //#region src/core/agent/run.ts
68
+ async function runAction(opts) {
69
+ return runWithDriverFallback([opts.driver, ...opts.fallbackDrivers ?? []], {
70
+ prompt: buildActionPrompt(opts.action, opts.ctx),
71
+ cwd: opts.ctx.app.path,
72
+ systemAppend: getCommandments(),
73
+ capabilities: opts.action.capabilities,
74
+ onEvent: opts.onEvent,
75
+ signal: opts.signal
76
+ });
77
+ }
78
+ async function runWithDriverFallback(drivers, options) {
79
+ if (drivers.length === 0) throw new Error("No agent driver available.");
80
+ let result = { ok: false };
81
+ for (const driver of drivers) {
82
+ result = await driver.run(options);
83
+ if (result.ok || result.failureReason !== "usage-limit") return result;
84
+ }
85
+ return result;
86
+ }
87
+
88
+ //#endregion
89
+ export { saveReport as i, buildCopyPrompt as n, loadReport as r, runAction as t };
@@ -0,0 +1,236 @@
1
+ import { T as Integration } from "./telemetry-CcfrtXdf.js";
2
+ import { existsSync, readFileSync } from "node:fs";
3
+ import { basename, dirname, join, relative, sep } from "node:path";
4
+ import fg from "fast-glob";
5
+
6
+ //#region src/core/project/frameworks.ts
7
+ const frameworkByIntegration = {
8
+ [Integration.swift]: {
9
+ integration: Integration.swift,
10
+ name: "Swift (iOS)",
11
+ supported: true,
12
+ sdkPackage: "https://github.com/superwall/Superwall-iOS",
13
+ docsUrl: "https://superwall.com/docs/ios/quickstart/install"
14
+ },
15
+ [Integration.expo]: {
16
+ integration: Integration.expo,
17
+ name: "Expo (React Native)",
18
+ supported: true,
19
+ sdkPackage: "expo-superwall",
20
+ docsUrl: "https://superwall.com/docs/expo"
21
+ },
22
+ [Integration.reactNative]: {
23
+ integration: Integration.reactNative,
24
+ name: "React Native",
25
+ supported: true,
26
+ sdkPackage: "expo-superwall",
27
+ docsUrl: "https://superwall.com/docs/expo/guides/using-expo-sdk-in-bare-react-native"
28
+ },
29
+ [Integration.flutter]: {
30
+ integration: Integration.flutter,
31
+ name: "Flutter",
32
+ supported: true,
33
+ sdkPackage: "superwallkit_flutter",
34
+ docsUrl: "https://superwall.com/docs/flutter"
35
+ },
36
+ [Integration.web]: {
37
+ integration: Integration.web,
38
+ name: "Web",
39
+ supported: false,
40
+ sdkPackage: "@superwall/web",
41
+ docsUrl: "https://superwall.com/docs/web"
42
+ }
43
+ };
44
+ const supportedNames = Object.values(frameworkByIntegration).filter((f) => f.supported).map((f) => f.name);
45
+ const SUPPORTED_LABEL = supportedNames.length > 1 ? `${supportedNames.slice(0, -1).join(", ")}, or ${supportedNames.at(-1)}` : supportedNames[0] ?? "";
46
+
47
+ //#endregion
48
+ //#region src/util/fs.ts
49
+ function readPackageJson(dir) {
50
+ try {
51
+ return JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
52
+ } catch {
53
+ return null;
54
+ }
55
+ }
56
+ function allDeps(pkg) {
57
+ if (!pkg) return {};
58
+ return {
59
+ ...pkg.dependencies ?? {},
60
+ ...pkg.devDependencies ?? {}
61
+ };
62
+ }
63
+
64
+ //#endregion
65
+ //#region src/core/project/scan.ts
66
+ const IGNORE = [
67
+ "**/node_modules/**",
68
+ "**/.git/**",
69
+ "**/.build/**",
70
+ "**/DerivedData/**",
71
+ "**/Pods/**",
72
+ "**/build/**",
73
+ "**/dist/**",
74
+ "**/.next/**",
75
+ "**/.expo/**",
76
+ "**/vendor/**",
77
+ "**/.turbo/**"
78
+ ];
79
+ const SCAN_DEPTH = 6;
80
+ const FRONTEND_DEPS = [
81
+ "next",
82
+ "nuxt",
83
+ "astro",
84
+ "@sveltejs/kit",
85
+ "@angular/core",
86
+ "@remix-run/react",
87
+ "@tanstack/react-start",
88
+ "gatsby",
89
+ "vite",
90
+ "react-dom",
91
+ "vue",
92
+ "svelte",
93
+ "solid-js",
94
+ "preact"
95
+ ];
96
+ function classifyJs(dir) {
97
+ const pkg = readPackageJson(dir);
98
+ if (!pkg) return null;
99
+ const deps = allDeps(pkg);
100
+ if ("expo" in deps) return {
101
+ integration: Integration.expo,
102
+ details: `Expo ${deps.expo}`,
103
+ score: .96
104
+ };
105
+ if ("react-native" in deps) return {
106
+ integration: Integration.reactNative,
107
+ details: deps["react-native"],
108
+ score: .9
109
+ };
110
+ const fe = FRONTEND_DEPS.find((d) => d in deps);
111
+ if (fe) return {
112
+ integration: Integration.web,
113
+ details: fe,
114
+ score: .7
115
+ };
116
+ return null;
117
+ }
118
+ function swiftUiKind(dir) {
119
+ const files = fg.sync("**/*.swift", {
120
+ cwd: dir,
121
+ ignore: IGNORE,
122
+ absolute: true,
123
+ deep: 6
124
+ });
125
+ let swiftui = false;
126
+ let uikit = false;
127
+ for (const f of files.slice(0, 300)) {
128
+ try {
129
+ const c = readFileSync(f, "utf8");
130
+ if (c.includes("import SwiftUI")) swiftui = true;
131
+ else if (c.includes("import UIKit")) uikit = true;
132
+ } catch {}
133
+ if (swiftui) break;
134
+ }
135
+ if (swiftui) return "SwiftUI";
136
+ if (uikit) return "UIKit";
137
+ return "Swift";
138
+ }
139
+ function isGeneratedNative(swiftDir, jsRoots) {
140
+ const segs = swiftDir.split(sep);
141
+ if (!segs.includes("ios") && !segs.includes("android")) return false;
142
+ let cur = swiftDir;
143
+ while (true) {
144
+ const parent = dirname(cur);
145
+ if (parent === cur) break;
146
+ if (jsRoots.has(parent)) return true;
147
+ cur = parent;
148
+ }
149
+ return false;
150
+ }
151
+ function isLibraryPath(dir) {
152
+ return dir.includes(`${sep}packages${sep}`) || dir.includes(`${sep}libs${sep}`) || dir.includes(`${sep}node_modules${sep}`);
153
+ }
154
+ function makeApp(root, dir, c) {
155
+ const rel = relative(root, dir) || ".";
156
+ return {
157
+ path: dir,
158
+ relPath: rel,
159
+ name: rel === "." ? basename(root) : basename(dir),
160
+ framework: frameworkByIntegration[c.integration],
161
+ integration: c.integration,
162
+ details: c.details,
163
+ score: c.score
164
+ };
165
+ }
166
+ function looksLikeMonorepoRoot(root) {
167
+ return existsSync(join(root, "turbo.json")) || existsSync(join(root, "pnpm-workspace.yaml")) || existsSync(join(root, "nx.json")) || existsSync(join(root, "lerna.json")) || Array.isArray((readPackageJson(root) ?? {}).workspaces) || typeof (readPackageJson(root) ?? {}).workspaces === "object";
168
+ }
169
+ async function scanProject(root) {
170
+ const opts = {
171
+ cwd: root,
172
+ ignore: IGNORE,
173
+ deep: SCAN_DEPTH
174
+ };
175
+ const [pkgPaths, xcodeProjects, packageSwifts, tuistProjects, pubspecs] = await Promise.all([
176
+ fg("**/package.json", opts),
177
+ fg("**/*.xcodeproj", {
178
+ ...opts,
179
+ onlyDirectories: true
180
+ }),
181
+ fg("**/Package.swift", opts),
182
+ fg("**/Project.swift", opts),
183
+ fg("**/pubspec.yaml", opts)
184
+ ]);
185
+ const jsRoots = pkgPaths.map((p) => dirname(join(root, p)));
186
+ const jsRootSet = new Set(jsRoots);
187
+ const apps = [];
188
+ const skipped = [];
189
+ for (const dir of jsRoots) {
190
+ if (isLibraryPath(dir)) continue;
191
+ const c = classifyJs(dir);
192
+ if (c) apps.push(makeApp(root, dir, c));
193
+ else if (dir !== root) skipped.push(basename(dir));
194
+ }
195
+ const swiftDirs = /* @__PURE__ */ new Set();
196
+ for (const x of xcodeProjects) swiftDirs.add(dirname(join(root, x)));
197
+ for (const s of packageSwifts) {
198
+ const dir = dirname(join(root, s));
199
+ if (basename(dir) === "Tuist") continue;
200
+ swiftDirs.add(dir);
201
+ }
202
+ for (const t of tuistProjects) swiftDirs.add(dirname(join(root, t)));
203
+ for (const dir of swiftDirs) {
204
+ if (isGeneratedNative(dir, jsRootSet)) continue;
205
+ apps.push(makeApp(root, dir, {
206
+ integration: Integration.swift,
207
+ details: swiftUiKind(dir),
208
+ score: .95
209
+ }));
210
+ }
211
+ for (const p of pubspecs) {
212
+ const dir = dirname(join(root, p));
213
+ apps.push(makeApp(root, dir, {
214
+ integration: Integration.flutter,
215
+ score: .9
216
+ }));
217
+ }
218
+ const byPath = /* @__PURE__ */ new Map();
219
+ for (const app of apps) {
220
+ const prev = byPath.get(app.path);
221
+ if (!prev || app.score > prev.score) byPath.set(app.path, app);
222
+ }
223
+ const deduped = [...byPath.values()].sort((a, b) => b.score - a.score);
224
+ const supported = deduped.filter((a) => a.framework.supported);
225
+ const unsupported = deduped.filter((a) => !a.framework.supported);
226
+ return {
227
+ root,
228
+ isMonorepo: looksLikeMonorepoRoot(root) || deduped.length > 1,
229
+ apps: supported,
230
+ unsupported,
231
+ skipped: [...new Set(skipped)]
232
+ };
233
+ }
234
+
235
+ //#endregion
236
+ export { SUPPORTED_LABEL as i, allDeps as n, readPackageJson as r, scanProject as t };
@@ -0,0 +1,64 @@
1
+ import "./telemetry-CcfrtXdf.js";
2
+ import "./json-C3hPIMkI.js";
3
+ import "./update-BiVeR024.js";
4
+ import "./token-DHRH8cxi.js";
5
+ import { t as defineCommand } from "./command-Kwx4ekbo.js";
6
+ import { n as ui } from "./ui-C4ncRJqd.js";
7
+ import { a as skillsOutOfDate, o as syncSkills, r as fetchPublicSkills, t as SUPERWALL_SKILLS_SOURCE } from "./skills-xrfXt9u0.js";
8
+ import "./spawn-DSoTXy_j.js";
9
+ import { t as withSpinner } from "./spinner-gOxIMz-V.js";
10
+
11
+ //#region src/commands/account/skills.ts
12
+ const runSkills = defineCommand({
13
+ name: "skills",
14
+ async run(ctx) {
15
+ ui.intro("Superwall agent skills");
16
+ let skills = normalizeList(ctx.argv.skill);
17
+ const { dryRun } = ctx;
18
+ const force = Boolean(ctx.argv.force);
19
+ const yes = Boolean(ctx.argv.yes);
20
+ const interactive = ctx.interactive && !yes;
21
+ if (!skills && !dryRun && !force) {
22
+ if (!await withSpinner("Checking your skills", skillsOutOfDate)) {
23
+ ui.success("Your Superwall skills are already up to date.");
24
+ ui.outro("Run `superwall skills --force` to reinstall.");
25
+ return;
26
+ }
27
+ }
28
+ if (!skills && !dryRun && interactive) {
29
+ const available = await withSpinner(`Fetching skills from ${SUPERWALL_SKILLS_SOURCE}`, fetchPublicSkills);
30
+ const picked = await ui.multiselect({
31
+ message: `Which skills from ${SUPERWALL_SKILLS_SOURCE}? (installs globally)`,
32
+ options: available.map((s) => ({
33
+ value: s.name,
34
+ label: s.name,
35
+ hint: s.summary
36
+ })),
37
+ initialValues: available.map((s) => s.name)
38
+ });
39
+ if (picked === null || picked.length === 0) {
40
+ ui.warn("Nothing selected.");
41
+ return;
42
+ }
43
+ skills = picked.length === available.length ? void 0 : picked;
44
+ } else if (skills?.length) ui.info(`Installing \`${skills.join("`, `")}\` from ${SUPERWALL_SKILLS_SOURCE}`);
45
+ else ui.info(`Installing every skill from ${SUPERWALL_SKILLS_SOURCE}`);
46
+ const spin = ui.spinner();
47
+ spin.start(dryRun ? "Resolving" : "Installing skills globally");
48
+ const { ok, commands } = await syncSkills({
49
+ skills,
50
+ dryRun
51
+ });
52
+ spin.stop(dryRun ? "Dry run" : ok ? "Skills installed for every detected agent" : "Install failed");
53
+ if (dryRun) for (const command of commands) ui.info(command);
54
+ ui.outro(ok ? `**Done.** Try: ask your agent to "review my Superwall setup".` : "Something went wrong - try again, or check that `npx` is available.");
55
+ if (!ok) throw new Error("Skill installation failed. Check that `npx` is available and try again.");
56
+ }
57
+ });
58
+ function normalizeList(v) {
59
+ if (Array.isArray(v)) return v.map(String);
60
+ if (typeof v === "string") return [v];
61
+ }
62
+
63
+ //#endregion
64
+ export { runSkills };