@superwall/cli 1.7.0 → 2.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 (229) hide show
  1. package/README.md +192 -52
  2. package/dist/{setup-Bxj22rYi.js → apple-CSzNTGHM.js} +82 -76
  3. package/dist/auth.d.ts +4 -19
  4. package/dist/auth.js +4 -2
  5. package/dist/{actions-B7ym3oVS.js → billing-C3Q8DBU2.js} +98 -28
  6. package/dist/{bind-YrJvuRF9.js → bind-BumHTi9O.js} +38 -33
  7. package/dist/{build-DLoCW5Ri.js → build-Bpviiclc.js} +20 -26
  8. package/dist/client-BL0f_yGf.js +176 -0
  9. package/dist/{asc-Bf7zBbyS.js → client-BZ1UbpXz.js} +16 -15
  10. package/dist/config-BO1Y87kV.js +105 -0
  11. package/dist/create-BSfvpWoD.js +19 -0
  12. package/dist/{create-pkANt1Gs.js → create-BUcVG4Ab.js} +195 -169
  13. package/dist/{notification-url-DuKF2659.js → create-CfK3PeKA.js} +235 -539
  14. package/dist/doctor-BWqIYcMn.js +83 -0
  15. package/dist/{drivers-Qx9LxmRN.js → drivers-CPhdPkW5.js} +185 -172
  16. package/dist/entry.d.ts +0 -5
  17. package/dist/entry.js +28072 -1134
  18. package/dist/environment-eBXjELoN.js +58 -0
  19. package/dist/{existing-AVEfZu2A.js → existing-BltvQiX5.js} +12 -6
  20. package/dist/held-CPve03KJ.js +16 -0
  21. package/dist/held-DgnTFMl3.js +1112 -0
  22. package/dist/input-vi0bou04.js +42 -0
  23. package/dist/{integrate-brmhPG-S.js → integrate-BRsqoe01.js} +277 -254
  24. package/dist/log-NVhVe_oe.js +62 -0
  25. package/dist/login-BCEH5q0U.js +53 -0
  26. package/dist/login-BPOONe7n.js +16 -0
  27. package/dist/{login-Do4wFuLv.js → login-BbTIrCFT.js} +118 -55
  28. package/dist/lookup-rr1AkCJA.js +71 -0
  29. package/dist/migrate-C9X2Vz81.js +274 -0
  30. package/dist/notification-url-CV86qiKP.js +100 -0
  31. package/dist/{open-studio-DOw-6ydc.js → open-CcpXotHG.js} +34 -43
  32. package/dist/org-BQQDo7wm.js +35 -0
  33. package/dist/output-Ggzq5_-t.js +122 -0
  34. package/dist/paths-CRlU72cq.js +29 -0
  35. package/dist/playbook-DVMXN7fh.js +53 -0
  36. package/dist/{asc-products-9JXtDxI4.js → products-DH_fK9tY.js} +6 -6
  37. package/dist/promote-Da8xctzy.js +91 -0
  38. package/dist/push-BV-grvQg.js +22 -0
  39. package/dist/push-D6R9icWN.js +495 -0
  40. package/dist/registry-BYVD-_h6.js +10385 -0
  41. package/dist/{reports-CfJqoava.js → reports-D_qbl7_u.js} +7 -6
  42. package/dist/{resources-Bf9O1JNM.js → resources-DLON3-61.js} +162 -55
  43. package/dist/{run-DsVZ5snL.js → run-Co-BwhOg.js} +16 -22
  44. package/dist/scan-B88OlWOt.js +4 -0
  45. package/dist/{scan-zKsddO72.js → scan-CKuk-_6W.js} +48 -37
  46. package/dist/scope-DV22_Ufm.js +198 -0
  47. package/dist/screenshot-file-tVBfUEIi.js +16 -0
  48. package/dist/{selection-CxZoX4NT.js → selection-C2_KbLuo.js} +100 -51
  49. package/dist/server-C4f6ccUr.js +22 -0
  50. package/dist/{dev-DmB3XqaJ.js → server-D0d2oP-5.js} +86 -94
  51. package/dist/session-B-Uz0cQ7.js +40 -0
  52. package/dist/session-BuvArt1j.js +6 -0
  53. package/dist/session-C4rbE3VS.js +796 -0
  54. package/dist/skills/animate-onboarding/SKILL.md +467 -0
  55. package/dist/skills/animate-onboarding/references/engine.md +494 -0
  56. package/dist/skills/animate-onboarding/references/framework/Question.tsx +71 -0
  57. package/dist/skills/animate-onboarding/references/framework/README.md +40 -0
  58. package/dist/skills/animate-onboarding/references/framework/answers.ts +19 -0
  59. package/dist/skills/animate-onboarding/references/framework/flow.ts +80 -0
  60. package/dist/skills/animate-onboarding/references/framework/handoffs.ts +869 -0
  61. package/dist/skills/animate-onboarding/references/framework/layout.tsx +113 -0
  62. package/dist/skills/animate-onboarding/references/framework/motion.css +559 -0
  63. package/dist/skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
  64. package/dist/skills/animate-onboarding/references/handoffs.md +375 -0
  65. package/dist/skills/animate-onboarding/references/imageReady.ts +92 -0
  66. package/dist/skills/animate-onboarding/references/morphFrame.ts +356 -0
  67. package/dist/skills/animate-onboarding/references/performance.md +41 -0
  68. package/dist/skills/animate-onboarding/references/web-runtime/README.md +17 -0
  69. package/dist/skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
  70. package/dist/skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
  71. package/dist/skills/index.json +37 -0
  72. package/dist/skills/mobile-design/SKILL.md +447 -0
  73. package/dist/skills/mobile-design/references/responsive.md +162 -0
  74. package/dist/skills/onboarding-questions/SKILL.md +231 -0
  75. package/dist/skills/onboarding-questions/references/arpu-questions.md +139 -0
  76. package/dist/skills/onboarding-questions/references/craft.md +142 -0
  77. package/dist/skills/onboarding-questions/references/example-reflective.md +117 -0
  78. package/dist/skills/superwall/SKILL.md +82 -9
  79. package/dist/skills/superwall/references/api.md +153 -37
  80. package/dist/skills/superwall/references/apple-setup.md +316 -0
  81. package/dist/skills/superwall/references/asc.md +74 -38
  82. package/dist/skills/superwall/references/data-analytics.md +55 -21
  83. package/dist/skills/superwall/workflows/dashboard/playbook.md +3 -3
  84. package/dist/skills/superwall/workflows/dashboard/setup.md +8 -8
  85. package/dist/skills/superwall/workflows/migrate/adapty.md +6 -6
  86. package/dist/skills/superwall/workflows/migrate/playbook.md +4 -4
  87. package/dist/skills/superwall/workflows/migrate/qonversion.md +5 -5
  88. package/dist/skills/superwall/workflows/migrate/revenuecat.md +6 -6
  89. package/dist/skills/superwall/workflows/placements/android.md +2 -2
  90. package/dist/skills/superwall/workflows/placements/expo.md +2 -2
  91. package/dist/skills/superwall/workflows/placements/flutter.md +2 -2
  92. package/dist/skills/superwall/workflows/placements/ios.md +2 -2
  93. package/dist/skills/superwall/workflows/placements/playbook.md +2 -2
  94. package/dist/skills/superwall/workflows/placements/react-native.md +2 -2
  95. package/dist/skills/superwall/workflows/placements/strategy.md +2 -2
  96. package/dist/skills/superwall/workflows/review/playbook.md +1 -1
  97. package/dist/skills/superwall-editor/SKILL.md +61 -0
  98. package/dist/skills/superwall-editor/references/cli.md +135 -0
  99. package/dist/skills/superwall-editor/references/design.md +51 -0
  100. package/dist/skills/superwall-editor/references/native-elements.md +171 -0
  101. package/dist/skills/superwall-editor/references/workflow.md +65 -0
  102. package/dist/skills/superwall-editor/scripts/sw-editor.sh +662 -0
  103. package/dist/skills/superwall-framework/SKILL.md +85 -31
  104. package/dist/skills/superwall-framework/references/cli.md +58 -27
  105. package/dist/skills/superwall-framework/references/examples.md +4 -3
  106. package/dist/skills/superwall-framework/references/layout.md +64 -9
  107. package/dist/skills/superwall-framework/references/migrate-from-editor.md +1 -1
  108. package/dist/skills/superwall-framework/references/onboarding-state.md +245 -0
  109. package/dist/skills/wwdc/SKILL.md +22 -0
  110. package/dist/skills/wwdc/references/docs.md +52 -0
  111. package/dist/skills/wwdc/scripts/wwdc.sh +266 -0
  112. package/dist/skills-CLGJuMnF.js +14 -0
  113. package/dist/{skills-DPzlnfCK.js → skills-CZcpnEnG.js} +100 -122
  114. package/dist/{spawn-DSoTXy_j.js → spawn-DmmmHIP-.js} +14 -12
  115. package/dist/spinner-C2U6QBJ9.js +294 -0
  116. package/dist/storage-6h9vyiAz.js +31 -0
  117. package/dist/storage-CerJ5KLP.d.ts +16 -0
  118. package/dist/storekit-CK9JmM2D.js +16 -0
  119. package/dist/storekit-CinJra3V.js +47 -0
  120. package/dist/telemetry-DKyDhURo.js +56 -0
  121. package/dist/theme-DUsCh-Vd.js +25 -0
  122. package/dist/timing-BVxPrYq3.js +5 -0
  123. package/dist/{token-C0it-Xh7.js → token-DaxQgQkv.js} +6 -38
  124. package/dist/tools-skills/animate-onboarding/SKILL.md +467 -0
  125. package/dist/tools-skills/animate-onboarding/references/engine.md +494 -0
  126. package/dist/tools-skills/animate-onboarding/references/framework/Question.tsx +71 -0
  127. package/dist/tools-skills/animate-onboarding/references/framework/README.md +40 -0
  128. package/dist/tools-skills/animate-onboarding/references/framework/answers.ts +19 -0
  129. package/dist/tools-skills/animate-onboarding/references/framework/flow.ts +80 -0
  130. package/dist/tools-skills/animate-onboarding/references/framework/handoffs.ts +869 -0
  131. package/dist/tools-skills/animate-onboarding/references/framework/layout.tsx +113 -0
  132. package/dist/tools-skills/animate-onboarding/references/framework/motion.css +559 -0
  133. package/dist/tools-skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
  134. package/dist/tools-skills/animate-onboarding/references/handoffs.md +375 -0
  135. package/dist/tools-skills/animate-onboarding/references/imageReady.ts +92 -0
  136. package/dist/tools-skills/animate-onboarding/references/morphFrame.ts +356 -0
  137. package/dist/tools-skills/animate-onboarding/references/performance.md +41 -0
  138. package/dist/tools-skills/animate-onboarding/references/web-runtime/README.md +17 -0
  139. package/dist/tools-skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
  140. package/dist/tools-skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
  141. package/dist/tools-skills/mobile-design/SKILL.md +447 -0
  142. package/dist/tools-skills/mobile-design/references/responsive.md +162 -0
  143. package/dist/tools-skills/onboarding-questions/SKILL.md +231 -0
  144. package/dist/tools-skills/onboarding-questions/references/arpu-questions.md +139 -0
  145. package/dist/tools-skills/onboarding-questions/references/craft.md +142 -0
  146. package/dist/tools-skills/onboarding-questions/references/example-reflective.md +117 -0
  147. package/dist/tools-skills/superwall/SKILL.md +263 -0
  148. package/dist/tools-skills/superwall/references/api.md +303 -0
  149. package/dist/tools-skills/superwall/references/asa.md +166 -0
  150. package/dist/tools-skills/superwall/references/asc.md +95 -0
  151. package/dist/tools-skills/superwall/references/dashboard-links.md +57 -0
  152. package/dist/tools-skills/superwall/references/data-analytics.md +896 -0
  153. package/dist/tools-skills/superwall/references/docs.md +51 -0
  154. package/dist/tools-skills/superwall/references/sdk-integration.md +104 -0
  155. package/dist/tools-skills/superwall/references/sdk-source.md +18 -0
  156. package/dist/tools-skills/superwall/workflows/dashboard/playbook.md +76 -0
  157. package/dist/tools-skills/superwall/workflows/dashboard/setup.md +100 -0
  158. package/dist/tools-skills/superwall/workflows/integrate/android.md +292 -0
  159. package/dist/tools-skills/superwall/workflows/integrate/expo.md +272 -0
  160. package/dist/tools-skills/superwall/workflows/integrate/flutter.md +285 -0
  161. package/dist/tools-skills/superwall/workflows/integrate/ios.md +314 -0
  162. package/dist/tools-skills/superwall/workflows/integrate/playbook.md +83 -0
  163. package/dist/tools-skills/superwall/workflows/integrate/react-native.md +246 -0
  164. package/dist/tools-skills/superwall/workflows/migrate/adapty.md +229 -0
  165. package/dist/tools-skills/superwall/workflows/migrate/playbook.md +78 -0
  166. package/dist/tools-skills/superwall/workflows/migrate/qonversion.md +227 -0
  167. package/dist/tools-skills/superwall/workflows/migrate/revenuecat.md +414 -0
  168. package/dist/tools-skills/superwall/workflows/placements/android.md +175 -0
  169. package/dist/tools-skills/superwall/workflows/placements/expo.md +161 -0
  170. package/dist/tools-skills/superwall/workflows/placements/flutter.md +139 -0
  171. package/dist/tools-skills/superwall/workflows/placements/ios.md +165 -0
  172. package/dist/tools-skills/superwall/workflows/placements/playbook.md +69 -0
  173. package/dist/tools-skills/superwall/workflows/placements/react-native.md +145 -0
  174. package/dist/tools-skills/superwall/workflows/placements/strategy.md +222 -0
  175. package/dist/tools-skills/superwall/workflows/review/android.md +120 -0
  176. package/dist/tools-skills/superwall/workflows/review/expo.md +100 -0
  177. package/dist/tools-skills/superwall/workflows/review/flutter.md +99 -0
  178. package/dist/tools-skills/superwall/workflows/review/ios.md +108 -0
  179. package/dist/tools-skills/superwall/workflows/review/playbook.md +70 -0
  180. package/dist/tools-skills/superwall/workflows/review/react-native.md +100 -0
  181. package/dist/tools-skills/superwall-editor/SKILL.md +113 -0
  182. package/dist/tools-skills/superwall-editor/references/cli.md +135 -0
  183. package/dist/tools-skills/superwall-editor/references/design.md +51 -0
  184. package/dist/tools-skills/superwall-editor/references/native-elements.md +171 -0
  185. package/dist/tools-skills/superwall-editor/references/workflow.md +65 -0
  186. package/dist/tools-skills/superwall-editor/scripts/sw-editor.sh +662 -0
  187. package/dist/tools-skills/wwdc/SKILL.md +22 -0
  188. package/dist/tools-skills/wwdc/references/docs.md +52 -0
  189. package/dist/tools-skills/wwdc/scripts/wwdc.sh +266 -0
  190. package/dist/tools.d.ts +96 -0
  191. package/dist/tools.js +11360 -0
  192. package/dist/ui-D_qf3Gvw.js +53 -0
  193. package/dist/upgrade-DPo0a4Es.js +117 -0
  194. package/dist/upgrade-ffseQDMx.js +7 -0
  195. package/package.json +10 -5
  196. package/dist/api-CZzirVMj.js +0 -151
  197. package/dist/api-output-aJNw7Syy.js +0 -20
  198. package/dist/app-DH6U8yuI.js +0 -190
  199. package/dist/asa-C-sQzPPn.js +0 -1194
  200. package/dist/asc-1ZBJ6DwS.js +0 -778
  201. package/dist/auth-YRhlV3DE.js +0 -140
  202. package/dist/billing-CCYHdApx.js +0 -80
  203. package/dist/bundle-id-CKxl_026.js +0 -121
  204. package/dist/command-CMIz81Da.js +0 -301
  205. package/dist/dev-DZy6pOnB.js +0 -22
  206. package/dist/doctor-H-hf-Yww.js +0 -88
  207. package/dist/feedback-CKf-rpBW.js +0 -152
  208. package/dist/hosted-CXe9TrWx.js +0 -32
  209. package/dist/migrate-C9ERDR6y.js +0 -284
  210. package/dist/org-sj7uyvp-.js +0 -40
  211. package/dist/output-C4o2gJ1K.js +0 -146
  212. package/dist/params-l3CrvRtR.js +0 -51
  213. package/dist/pipeline-BqzqZhX1.js +0 -977
  214. package/dist/print-skill-ZojRSybs.js +0 -74
  215. package/dist/promote-BG8X4Nv_.js +0 -88
  216. package/dist/publish-sxLh-G4G.js +0 -35
  217. package/dist/push-bQ6Vxtg8.js +0 -35
  218. package/dist/query-_FbybaH-.js +0 -53
  219. package/dist/resource-CGIwSd29.js +0 -323
  220. package/dist/revenue-provider-ebsRINY8.js +0 -100
  221. package/dist/scope-BvzD-kO4.js +0 -223
  222. package/dist/skills-D_R-lEsK.js +0 -64
  223. package/dist/spinner-TWa0hia6.js +0 -18
  224. package/dist/storekit-Cj9Cpjcz.js +0 -29
  225. package/dist/telemetry-DeA1mvnT.js +0 -169
  226. package/dist/ui-Dy0b-9L8.js +0 -27738
  227. package/dist/update-B2fWIc4q.js +0 -59
  228. package/dist/upgrade-BmzkTKrh.js +0 -72
  229. /package/dist/{devtools-8EgLo86w.js → devtools-pBl_vt03.js} +0 -0
@@ -0,0 +1,662 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ DEFAULT_BASE_URL="https://mcp.superwall.com"
5
+ BASE_URL="${SUPERWALL_EDITOR_BASE_URL:-$DEFAULT_BASE_URL}"
6
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7
+ SKILL_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
8
+ LOCAL_ENV_FILE="${SKILL_ROOT}/.env"
9
+ SIBLING_SUPERWALL_ENV_FILE="${SKILL_ROOT}/../superwall/.env"
10
+ GLOBAL_ENV_FILE="${HOME}/.superwall-cli/.env"
11
+ if [[ -n "${SUPERWALL_EDITOR_WEB_URL:-}" ]]; then
12
+ EDITOR_WEB_URL="$SUPERWALL_EDITOR_WEB_URL"
13
+ else
14
+ EDITOR_WEB_URL="https://superwall.com/editor/"
15
+ fi
16
+ STATE_DIR="${SUPERWALL_STATE_DIR:-$PWD/.superwall}"
17
+ STATE_FILE="${STATE_DIR}/state.json"
18
+
19
+ usage() {
20
+ cat <<'EOF'
21
+ sw-editor.sh - drive a live Superwall paywall editor session from the CLI.
22
+
23
+ Commands:
24
+ attach <pairing-code> --agent-name <name>
25
+ Attach to the editor session whose pairing code is shown in the UI.
26
+ Writes session state to .superwall/state.json in the current directory.
27
+
28
+ expose --application-id <id> --paywall-id <id> --agent-name <name> [--open] [--wait]
29
+ Create an editor launch URL through the API. Opening the URL auto-exposes
30
+ the browser editor session and lets this CLI attach without a pairing code.
31
+
32
+ wait-expose <launch-id> [--timeout <seconds>]
33
+ Poll an expose launch until the browser has opened and the CLI is attached.
34
+
35
+ tools
36
+ List every tool the browser currently exposes. Call this first before
37
+ invoking an unfamiliar tool because the list is dynamic and reflects the
38
+ browser build that is connected right now.
39
+
40
+ call <tool-name> [--args '<json>']
41
+ Invoke a tool. Args must be valid JSON. Prints the tool result.
42
+ Exits non-zero when the tool reports isError: true.
43
+
44
+ status
45
+ Print the current session status (browser connectivity, metadata).
46
+
47
+ release
48
+ Detach from the editor session and drop local state.
49
+
50
+ whoami
51
+ Print the current attachment info (without leaking sessionId or token).
52
+
53
+ Env:
54
+ SUPERWALL_EDITOR_BASE_URL Default: https://mcp.superwall.com
55
+ SUPERWALL_EDITOR_WEB_URL Default: https://superwall.com/editor/
56
+ SUPERWALL_API_KEY Org API key for expose/wait-expose
57
+ SUPERWALL_STATE_DIR Default: $PWD/.superwall
58
+ EOF
59
+ }
60
+
61
+ require_cmd() {
62
+ if ! command -v "$1" >/dev/null 2>&1; then
63
+ echo "Error: '$1' is required" >&2
64
+ exit 1
65
+ fi
66
+ }
67
+
68
+ require_cmd curl
69
+ require_cmd jq
70
+
71
+ ensure_state_dir() {
72
+ mkdir -p "$STATE_DIR"
73
+ chmod 700 "$STATE_DIR" 2>/dev/null || true
74
+ [[ -f "$STATE_DIR/.gitignore" ]] || printf '*\n' > "$STATE_DIR/.gitignore"
75
+ }
76
+
77
+ write_state() {
78
+ ensure_state_dir
79
+ printf '%s' "$1" > "$STATE_FILE"
80
+ chmod 600 "$STATE_FILE" 2>/dev/null || true
81
+ }
82
+
83
+ require_state() {
84
+ if [[ ! -f "$STATE_FILE" ]]; then
85
+ echo "Error: not attached. Run 'sw-editor.sh attach <pairing-code> --agent-name <name>' first." >&2
86
+ exit 1
87
+ fi
88
+ }
89
+
90
+ state_field() {
91
+ jq -r --arg field "$1" '.[$field] // empty' "$STATE_FILE"
92
+ }
93
+
94
+ load_env_file() {
95
+ local env_file="$1"
96
+
97
+ [[ -f "$env_file" ]] || return 1
98
+
99
+ local line
100
+ while IFS= read -r line || [[ -n "$line" ]]; do
101
+ line="${line#"${line%%[![:space:]]*}"}"
102
+ [[ -z "$line" || "$line" == \#* ]] && continue
103
+ if [[ "$line" =~ ^SUPERWALL_API_KEY=(.*)$ ]]; then
104
+ SUPERWALL_API_KEY="${BASH_REMATCH[1]}"
105
+ SUPERWALL_API_KEY="${SUPERWALL_API_KEY%\"}"
106
+ SUPERWALL_API_KEY="${SUPERWALL_API_KEY#\"}"
107
+ SUPERWALL_API_KEY="${SUPERWALL_API_KEY%\'}"
108
+ SUPERWALL_API_KEY="${SUPERWALL_API_KEY#\'}"
109
+ export SUPERWALL_API_KEY
110
+ return 0
111
+ fi
112
+ done < "$env_file"
113
+
114
+ return 1
115
+ }
116
+
117
+ resolve_api_key() {
118
+ if [[ -n "${SUPERWALL_API_KEY:-}" ]]; then
119
+ return 0
120
+ fi
121
+
122
+ load_env_file "$LOCAL_ENV_FILE" && return 0
123
+ load_env_file "$SIBLING_SUPERWALL_ENV_FILE" && return 0
124
+ load_env_file "$GLOBAL_ENV_FILE" && return 0
125
+ return 1
126
+ }
127
+
128
+ require_api_key() {
129
+ if ! resolve_api_key; then
130
+ cat >&2 <<EOF
131
+ Error: SUPERWALL_API_KEY is required for this command.
132
+
133
+ Set SUPERWALL_API_KEY in the environment, or use manual pairing instead:
134
+ sw-editor.sh attach <pairing-code> --agent-name <name>
135
+ EOF
136
+ exit 1
137
+ fi
138
+ }
139
+
140
+ _request() {
141
+ local method="$1" path="$2" body="${3:-}"
142
+ local state_base
143
+ state_base="$(state_field baseUrl)"
144
+ local url="${state_base:-$BASE_URL}${path}"
145
+ local token
146
+ token="$(state_field controllerToken)"
147
+
148
+ local args=(-sS -X "$method" -w '\n%{http_code}')
149
+ if [[ -n "$token" ]]; then
150
+ args+=(-H "Authorization: Bearer $token")
151
+ fi
152
+ if [[ -n "$body" ]]; then
153
+ args+=(-H "Content-Type: application/json" -d "$body")
154
+ fi
155
+
156
+ local response
157
+ response="$(curl "${args[@]}" "$url")"
158
+
159
+ HTTP_STATUS="${response##*$'\n'}"
160
+ HTTP_BODY="${response%$'\n'*}"
161
+ }
162
+
163
+ _request_api() {
164
+ local method="$1" path="$2" body="${3:-}"
165
+ local url="${BASE_URL}${path}"
166
+
167
+ local args=(-sS -X "$method" -w '\n%{http_code}' -H "Authorization: Bearer ${SUPERWALL_API_KEY}")
168
+ if [[ -n "$body" ]]; then
169
+ args+=(-H "Content-Type: application/json" -d "$body")
170
+ fi
171
+
172
+ local response
173
+ response="$(curl "${args[@]}" "$url")"
174
+
175
+ HTTP_STATUS="${response##*$'\n'}"
176
+ HTTP_BODY="${response%$'\n'*}"
177
+ }
178
+
179
+ _request_anon() {
180
+ local path="$1" body="$2"
181
+ local url="${BASE_URL}${path}"
182
+
183
+ local response
184
+ response="$(curl -sS -X POST -H "Content-Type: application/json" \
185
+ -d "$body" -w '\n%{http_code}' "$url")"
186
+
187
+ HTTP_STATUS="${response##*$'\n'}"
188
+ HTTP_BODY="${response%$'\n'*}"
189
+ }
190
+
191
+ fail_on_non_2xx() {
192
+ if [[ "$HTTP_STATUS" != 2* ]]; then
193
+ local msg
194
+ msg="$(echo "$HTTP_BODY" | jq -r '.error // .message // empty' 2>/dev/null || true)"
195
+ if [[ -z "$msg" ]]; then
196
+ msg="HTTP $HTTP_STATUS"
197
+ fi
198
+
199
+ if [[ "$msg" == session_expired* || "$msg" == session_not_found* || "$msg" == session_terminated* || "$msg" == unauthorized* ]]; then
200
+ if [[ -f "$STATE_FILE" ]]; then
201
+ rm -f "$STATE_FILE"
202
+ rmdir "$STATE_DIR" 2>/dev/null || true
203
+ echo "Error: $msg" >&2
204
+ echo "Local state cleared. Run 'sw-editor.sh attach <pairing-code> --agent-name <name>' to reattach." >&2
205
+ exit 1
206
+ fi
207
+ fi
208
+
209
+ echo "Error: $msg" >&2
210
+ exit 1
211
+ fi
212
+ }
213
+
214
+ fail_on_non_2xx_api() {
215
+ if [[ "$HTTP_STATUS" != 2* ]]; then
216
+ local msg
217
+ msg="$(echo "$HTTP_BODY" | jq -r '.error // .message // empty' 2>/dev/null || true)"
218
+ if [[ -z "$msg" ]]; then
219
+ msg="HTTP $HTTP_STATUS"
220
+ fi
221
+ echo "Error: $msg" >&2
222
+ exit 1
223
+ fi
224
+ }
225
+
226
+ VALID_AGENTS="superwall claude codex cursor opencode windsurf kilocode chatgpt openwebui other"
227
+
228
+ resolve_agent_name() {
229
+ local input
230
+ input="$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')"
231
+ case "$input" in
232
+ superwall|"superwall agent") echo "Superwall Agent" ;;
233
+ claude|"claude code") echo "Claude Code" ;;
234
+ codex) echo "Codex" ;;
235
+ cursor) echo "Cursor" ;;
236
+ opencode) echo "OpenCode" ;;
237
+ windsurf) echo "Windsurf" ;;
238
+ kilocode) echo "Kilocode" ;;
239
+ chatgpt|"chatgpt") echo "ChatGPT" ;;
240
+ openwebui|"open webui") echo "Open WebUI" ;;
241
+ other) echo "Other" ;;
242
+ *) echo "" ;;
243
+ esac
244
+ }
245
+
246
+ cmd_attach() {
247
+ local pairing_code="" agent_name=""
248
+ while [[ $# -gt 0 ]]; do
249
+ case "$1" in
250
+ --agent-name)
251
+ agent_name="$2"; shift 2 ;;
252
+ --agent-name=*)
253
+ agent_name="${1#*=}"; shift ;;
254
+ --help|-h)
255
+ usage; exit 0 ;;
256
+ -*)
257
+ echo "Unknown flag: $1" >&2; exit 1 ;;
258
+ *)
259
+ if [[ -z "$pairing_code" ]]; then pairing_code="$1"
260
+ else echo "Unexpected arg: $1" >&2; exit 1
261
+ fi
262
+ shift ;;
263
+ esac
264
+ done
265
+
266
+ if [[ -z "$pairing_code" ]]; then
267
+ echo "Usage: sw-editor.sh attach <pairing-code> --agent-name <name>" >&2
268
+ exit 1
269
+ fi
270
+
271
+ if [[ -z "$agent_name" ]]; then
272
+ echo "Error: --agent-name is required. Valid: ${VALID_AGENTS}" >&2
273
+ exit 1
274
+ fi
275
+
276
+ local resolved_agent
277
+ resolved_agent="$(resolve_agent_name "$agent_name")"
278
+ if [[ -z "$resolved_agent" ]]; then
279
+ echo "Error: unknown agent '${agent_name}'. Valid: ${VALID_AGENTS}" >&2
280
+ exit 1
281
+ fi
282
+
283
+ local transport_session_id
284
+ transport_session_id="cli-$(jq -nr 'now | tostring | @base64' 2>/dev/null || date +%s)-$$"
285
+
286
+ local body
287
+ body="$(jq -n \
288
+ --arg pairingCode "$pairing_code" \
289
+ --arg transportSessionId "$transport_session_id" \
290
+ --arg agentName "$resolved_agent" \
291
+ '{
292
+ pairingCode: $pairingCode,
293
+ controllerTransportSessionId: $transportSessionId,
294
+ agentSessionId: $transportSessionId,
295
+ agentName: $agentName,
296
+ clientName: "sw-editor-cli",
297
+ clientVersion: "1.0.0"
298
+ }')"
299
+
300
+ _request_anon "/editor-sessions/claim" "$body"
301
+ fail_on_non_2xx
302
+
303
+ local session_id token
304
+ session_id="$(echo "$HTTP_BODY" | jq -r '.status.sessionId')"
305
+ token="$(echo "$HTTP_BODY" | jq -r '.controllerToken')"
306
+
307
+ if [[ -z "$session_id" || "$session_id" == "null" || -z "$token" || "$token" == "null" ]]; then
308
+ echo "Error: claim response missing session or token" >&2
309
+ echo "$HTTP_BODY" >&2
310
+ exit 1
311
+ fi
312
+
313
+ local attached_at
314
+ attached_at="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
315
+
316
+ local state_json
317
+ state_json="$(jq -n \
318
+ --arg sessionId "$session_id" \
319
+ --arg controllerToken "$token" \
320
+ --arg baseUrl "$BASE_URL" \
321
+ --arg transportSessionId "$transport_session_id" \
322
+ --arg attachedAt "$attached_at" \
323
+ '{sessionId: $sessionId, controllerToken: $controllerToken, baseUrl: $baseUrl, transportSessionId: $transportSessionId, attachedAt: $attachedAt}')"
324
+ write_state "$state_json"
325
+
326
+ local tool_count
327
+ tool_count="$(echo "$HTTP_BODY" | jq '.toolDefinitions | length')"
328
+ echo "Attached. Browser exposes $tool_count tools. Run 'sw-editor.sh tools' to list them."
329
+ }
330
+
331
+ write_state_from_launch_status() {
332
+ local status_body="$1"
333
+ local session_id token transport_session_id
334
+ session_id="$(echo "$status_body" | jq -r '.editorSessionId // empty')"
335
+ token="$(echo "$status_body" | jq -r '.controllerToken // empty')"
336
+ transport_session_id="$(echo "$status_body" | jq -r '.controllerTransportSessionId // empty')"
337
+
338
+ if [[ -z "$session_id" || -z "$token" || -z "$transport_session_id" ]]; then
339
+ echo "Error: launch is ready but response is missing session attachment data" >&2
340
+ echo "$status_body" >&2
341
+ exit 1
342
+ fi
343
+
344
+ local attached_at
345
+ attached_at="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
346
+
347
+ local state_json
348
+ state_json="$(jq -n \
349
+ --arg sessionId "$session_id" \
350
+ --arg controllerToken "$token" \
351
+ --arg baseUrl "$BASE_URL" \
352
+ --arg transportSessionId "$transport_session_id" \
353
+ --arg attachedAt "$attached_at" \
354
+ '{sessionId: $sessionId, controllerToken: $controllerToken, baseUrl: $baseUrl, transportSessionId: $transportSessionId, attachedAt: $attachedAt}')"
355
+ write_state "$state_json"
356
+ }
357
+
358
+ open_url() {
359
+ local url="$1"
360
+ if command -v open >/dev/null 2>&1; then
361
+ open "$url" >/dev/null 2>&1 || true
362
+ elif command -v xdg-open >/dev/null 2>&1; then
363
+ xdg-open "$url" >/dev/null 2>&1 || true
364
+ else
365
+ echo "No browser opener found. Open the URL manually." >&2
366
+ fi
367
+ }
368
+
369
+ wait_for_launch() {
370
+ local launch_id="$1" timeout_seconds="$2"
371
+ local deadline=$((SECONDS + timeout_seconds))
372
+
373
+ while (( SECONDS < deadline )); do
374
+ _request_api GET "/editor-session-launches/${launch_id}"
375
+ fail_on_non_2xx_api
376
+
377
+ local status
378
+ status="$(echo "$HTTP_BODY" | jq -r '.status // empty')"
379
+
380
+ case "$status" in
381
+ ready)
382
+ write_state_from_launch_status "$HTTP_BODY"
383
+ local tool_count
384
+ tool_count="$(echo "$HTTP_BODY" | jq -r '.toolCount // 0')"
385
+ echo "Attached. Browser exposes $tool_count tools. Run 'sw-editor.sh tools' to list them."
386
+ return 0
387
+ ;;
388
+ failed|expired)
389
+ local msg
390
+ msg="$(echo "$HTTP_BODY" | jq -r '.error // "launch failed"')"
391
+ echo "Error: $msg" >&2
392
+ exit 1
393
+ ;;
394
+ esac
395
+
396
+ sleep 2
397
+ done
398
+
399
+ echo "Error: timed out waiting for the editor launch to connect." >&2
400
+ echo "Launch ID: ${launch_id}" >&2
401
+ exit 1
402
+ }
403
+
404
+ cmd_expose() {
405
+ local application_id="" paywall_id="" agent_name=""
406
+ local should_open=false should_wait=false timeout_seconds=600
407
+
408
+ while [[ $# -gt 0 ]]; do
409
+ case "$1" in
410
+ --application-id)
411
+ application_id="$2"; shift 2 ;;
412
+ --application-id=*)
413
+ application_id="${1#*=}"; shift ;;
414
+ --paywall-id)
415
+ paywall_id="$2"; shift 2 ;;
416
+ --paywall-id=*)
417
+ paywall_id="${1#*=}"; shift ;;
418
+ --agent-name)
419
+ agent_name="$2"; shift 2 ;;
420
+ --agent-name=*)
421
+ agent_name="${1#*=}"; shift ;;
422
+ --timeout)
423
+ timeout_seconds="$2"; shift 2 ;;
424
+ --timeout=*)
425
+ timeout_seconds="${1#*=}"; shift ;;
426
+ --open)
427
+ should_open=true; shift ;;
428
+ --wait)
429
+ should_wait=true; shift ;;
430
+ --help|-h)
431
+ usage; exit 0 ;;
432
+ -*)
433
+ echo "Unknown flag: $1" >&2; exit 1 ;;
434
+ *)
435
+ if [[ -z "$application_id" ]]; then application_id="$1"
436
+ elif [[ -z "$paywall_id" ]]; then paywall_id="$1"
437
+ else echo "Unexpected arg: $1" >&2; exit 1
438
+ fi
439
+ shift ;;
440
+ esac
441
+ done
442
+
443
+ if [[ -z "$application_id" || -z "$paywall_id" ]]; then
444
+ echo "Usage: sw-editor.sh expose --application-id <id> --paywall-id <id> --agent-name <name> [--open] [--wait]" >&2
445
+ exit 1
446
+ fi
447
+
448
+ if [[ -z "$agent_name" ]]; then
449
+ echo "Error: --agent-name is required. Valid: ${VALID_AGENTS}" >&2
450
+ exit 1
451
+ fi
452
+
453
+ if ! [[ "$application_id" =~ ^[0-9]+$ && "$paywall_id" =~ ^[0-9]+$ ]]; then
454
+ echo "Error: application id and paywall id must be numbers" >&2
455
+ exit 1
456
+ fi
457
+
458
+ local resolved_agent
459
+ resolved_agent="$(resolve_agent_name "$agent_name")"
460
+ if [[ -z "$resolved_agent" ]]; then
461
+ echo "Error: unknown agent '${agent_name}'. Valid: ${VALID_AGENTS}" >&2
462
+ exit 1
463
+ fi
464
+
465
+ require_api_key
466
+
467
+ local transport_session_id
468
+ transport_session_id="cli-launch-$(jq -nr 'now | tostring | @base64' 2>/dev/null || date +%s)-$$"
469
+
470
+ local body
471
+ body="$(jq -n \
472
+ --argjson applicationId "$application_id" \
473
+ --argjson paywallId "$paywall_id" \
474
+ --arg agentName "$resolved_agent" \
475
+ --arg transportSessionId "$transport_session_id" \
476
+ --arg editorBaseUrl "$EDITOR_WEB_URL" \
477
+ '{
478
+ applicationId: $applicationId,
479
+ paywallId: $paywallId,
480
+ agentName: $agentName,
481
+ agentSessionId: $transportSessionId,
482
+ controllerTransportSessionId: $transportSessionId,
483
+ clientName: "sw-editor-cli",
484
+ clientVersion: "1.0.0",
485
+ editorBaseUrl: $editorBaseUrl
486
+ }')"
487
+
488
+ _request_api POST "/editor-session-launches" "$body"
489
+ fail_on_non_2xx_api
490
+
491
+ local launch_id launch_url
492
+ launch_url="$(echo "$HTTP_BODY" | jq -r '.launchUrl')"
493
+ launch_id="${launch_url#*sw_editor_launch=}"
494
+ launch_id="${launch_id%%[&#]*}"
495
+
496
+ if [[ -z "$launch_url" || "$launch_url" == "null" || -z "$launch_id" || "$launch_id" == "$launch_url" ]]; then
497
+ echo "Error: launch response missing launchUrl" >&2
498
+ echo "$HTTP_BODY" >&2
499
+ exit 1
500
+ fi
501
+
502
+ echo "Open this editor URL to expose the session:"
503
+ echo "$launch_url"
504
+
505
+ if [[ "$should_open" == true ]]; then
506
+ open_url "$launch_url"
507
+ fi
508
+
509
+ if [[ "$should_wait" == true ]]; then
510
+ wait_for_launch "$launch_id" "$timeout_seconds"
511
+ else
512
+ echo "After opening it, run: sw-editor.sh wait-expose ${launch_id}"
513
+ fi
514
+ }
515
+
516
+ cmd_wait_expose() {
517
+ local launch_id="" timeout_seconds=600
518
+
519
+ while [[ $# -gt 0 ]]; do
520
+ case "$1" in
521
+ --timeout)
522
+ timeout_seconds="$2"; shift 2 ;;
523
+ --timeout=*)
524
+ timeout_seconds="${1#*=}"; shift ;;
525
+ --help|-h)
526
+ usage; exit 0 ;;
527
+ -*)
528
+ echo "Unknown flag: $1" >&2; exit 1 ;;
529
+ *)
530
+ if [[ -z "$launch_id" ]]; then launch_id="$1"
531
+ else echo "Unexpected arg: $1" >&2; exit 1
532
+ fi
533
+ shift ;;
534
+ esac
535
+ done
536
+
537
+ if [[ -z "$launch_id" ]]; then
538
+ echo "Usage: sw-editor.sh wait-expose <launch-id> [--timeout <seconds>]" >&2
539
+ exit 1
540
+ fi
541
+
542
+ require_api_key
543
+ wait_for_launch "$launch_id" "$timeout_seconds"
544
+ }
545
+
546
+ cmd_tools() {
547
+ require_state
548
+ local session_id
549
+ session_id="$(state_field sessionId)"
550
+ _request GET "/editor-sessions/${session_id}/tools"
551
+ fail_on_non_2xx
552
+ echo "$HTTP_BODY" | jq '.'
553
+ }
554
+
555
+ cmd_call() {
556
+ require_state
557
+
558
+ local tool_name="" args_json="{}"
559
+ while [[ $# -gt 0 ]]; do
560
+ case "$1" in
561
+ --args)
562
+ args_json="$2"; shift 2 ;;
563
+ --args=*)
564
+ args_json="${1#*=}"; shift ;;
565
+ --help|-h)
566
+ usage; exit 0 ;;
567
+ -*)
568
+ echo "Unknown flag: $1" >&2; exit 1 ;;
569
+ *)
570
+ if [[ -z "$tool_name" ]]; then tool_name="$1"
571
+ else echo "Unexpected arg: $1" >&2; exit 1
572
+ fi
573
+ shift ;;
574
+ esac
575
+ done
576
+
577
+ if [[ -z "$tool_name" ]]; then
578
+ echo "Usage: sw-editor.sh call <tool-name> [--args '<json>']" >&2
579
+ exit 1
580
+ fi
581
+
582
+ if ! echo "$args_json" | jq empty >/dev/null 2>&1; then
583
+ echo "Error: --args must be valid JSON" >&2
584
+ exit 1
585
+ fi
586
+
587
+ local body
588
+ body="$(jq -n --arg toolName "$tool_name" --argjson args "$args_json" '{toolName: $toolName, args: $args}')"
589
+
590
+ local session_id
591
+ session_id="$(state_field sessionId)"
592
+ _request POST "/editor-sessions/${session_id}/call-tool" "$body"
593
+ fail_on_non_2xx
594
+
595
+ echo "$HTTP_BODY" | jq '.'
596
+
597
+ local is_error
598
+ is_error="$(echo "$HTTP_BODY" | jq -r '.isError // false')"
599
+ if [[ "$is_error" == "true" ]]; then
600
+ exit 1
601
+ fi
602
+ }
603
+
604
+ cmd_status() {
605
+ require_state
606
+ local session_id
607
+ session_id="$(state_field sessionId)"
608
+ _request GET "/editor-sessions/${session_id}/status"
609
+ fail_on_non_2xx
610
+ echo "$HTTP_BODY" | jq 'del(.sessionId, .controllerTransportSessionId, .controllerInfo.transportSessionId, .controllerInfo.agentSessionId)'
611
+ }
612
+
613
+ cmd_release() {
614
+ require_state
615
+ local session_id transport_session_id
616
+ session_id="$(state_field sessionId)"
617
+ transport_session_id="$(state_field transportSessionId)"
618
+ local body
619
+ body="$(jq -n --arg transportSessionId "$transport_session_id" '{controllerTransportSessionId: $transportSessionId}')"
620
+ _request POST "/editor-sessions/${session_id}/release" "$body"
621
+ rm -f "$STATE_FILE"
622
+ rmdir "$STATE_DIR" 2>/dev/null || true
623
+
624
+ if [[ "$HTTP_STATUS" != 2* ]]; then
625
+ echo "Detached locally. Server reported: HTTP $HTTP_STATUS" >&2
626
+ else
627
+ echo "Detached."
628
+ fi
629
+ }
630
+
631
+ cmd_whoami() {
632
+ if [[ ! -f "$STATE_FILE" ]]; then
633
+ echo '{"attached": false}'
634
+ return
635
+ fi
636
+ jq '{attached: true, baseUrl: .baseUrl, attachedAt: .attachedAt}' "$STATE_FILE"
637
+ }
638
+
639
+ main() {
640
+ if [[ $# -eq 0 ]]; then
641
+ usage; exit 0
642
+ fi
643
+
644
+ local cmd="$1"; shift
645
+ case "$cmd" in
646
+ attach) cmd_attach "$@" ;;
647
+ expose) cmd_expose "$@" ;;
648
+ wait-expose) cmd_wait_expose "$@" ;;
649
+ tools) cmd_tools "$@" ;;
650
+ call) cmd_call "$@" ;;
651
+ status) cmd_status "$@" ;;
652
+ release) cmd_release "$@" ;;
653
+ whoami) cmd_whoami "$@" ;;
654
+ --help|-h|help) usage ;;
655
+ *)
656
+ echo "Unknown command: $cmd" >&2
657
+ usage
658
+ exit 1 ;;
659
+ esac
660
+ }
661
+
662
+ main "$@"
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: wwdc
3
+ description: "Use this skill whenever the user asks about WWDC sessions, Apple Developer videos, WWDC transcripts, session IDs, technologies announced at WWDC, or wants an agent to find, compare, cite, summarize, or navigate WWDC session content. Fetch current docs from wwdc.ai via llms.txt and page markdown. Maintained by Superwall.com: the quickest way to add in-app subscriptions and paywalls to your app."
4
+ ---
5
+
6
+ # WWDC
7
+
8
+ Use WWDC.ai markdown pages as the first stop for concise session summaries and Apple source links. If the markdown summary is missing or not detailed enough, use transcript text without timestamps.
9
+
10
+ ## Helpers
11
+
12
+ Run the bundled script when it is useful:
13
+
14
+ ```bash
15
+ scripts/wwdc.sh llms
16
+ scripts/wwdc.sh summary 2026 389
17
+ scripts/wwdc.sh transcript 2026 309
18
+ ```
19
+
20
+ `summary` returns the WWDC.ai markdown page. `transcript` returns plain transcript text with no timestamps. URL/JSON helpers exist for source inspection.
21
+
22
+ For endpoint details and examples, see [references/docs.md](references/docs.md).