anhedral 0.13.0 → 0.16.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 (360) hide show
  1. package/README.md +23 -229
  2. package/assets/patches/audit-deps.mjs +12 -2
  3. package/assets/stack/ai-schema.ts.txt +5 -0
  4. package/assets/stack/ai.ts.txt +30 -0
  5. package/assets/stack/api-index.ts.txt +15 -0
  6. package/assets/stack/auth-features.ts.txt +4 -0
  7. package/assets/stack/auth-journal.json.txt +13 -0
  8. package/assets/stack/auth-migration.sql.txt +53 -0
  9. package/assets/stack/auth-routes.ts.txt +11 -0
  10. package/assets/stack/auth-schema.ts.txt +64 -0
  11. package/assets/stack/auth-snapshot.json.txt +346 -0
  12. package/assets/stack/auth.ts.txt +32 -0
  13. package/assets/stack/billing-mode.ts.txt +8 -0
  14. package/assets/stack/billing-schema.ts.txt +11 -0
  15. package/assets/stack/desktop.rs.txt +21 -0
  16. package/assets/stack/entitlement-guard.ts.txt +32 -0
  17. package/assets/stack/entitlements.ts.txt +8 -0
  18. package/assets/stack/events-schema.ts.txt +12 -0
  19. package/assets/stack/events.ts.txt +59 -0
  20. package/assets/stack/mobile-auth.ts.txt +25 -0
  21. package/assets/stack/mobile-billing.tsx.txt +63 -0
  22. package/assets/stack/mobile-session.tsx.txt +83 -0
  23. package/assets/stack/native-button.tsx.txt +108 -0
  24. package/assets/stack/native-global.css.txt +4 -0
  25. package/assets/stack/native-lib-utils.ts.txt +5 -0
  26. package/assets/stack/native-metro.config.js.txt +6 -0
  27. package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
  28. package/assets/stack/native-tailwind.config.js.txt +73 -0
  29. package/assets/stack/native-text.tsx.txt +89 -0
  30. package/assets/stack/purchases.ts.txt +65 -0
  31. package/assets/stack/revenuecat.ts.txt +88 -0
  32. package/assets/stack/rtc-schema.ts.txt +10 -0
  33. package/assets/stack/rtc.ts.txt +122 -0
  34. package/assets/stack/security.ts.txt +31 -0
  35. package/assets/stack/storage.ts.txt +36 -0
  36. package/assets/stack/stripe.ts.txt +126 -0
  37. package/assets/stack/web-sign-in.tsx.txt +51 -0
  38. package/assets/ui/LICENSE.react-native-reusables +21 -0
  39. package/assets/ui/LICENSE.shadcn +21 -0
  40. package/assets/ui/UPSTREAM.json +39 -0
  41. package/assets/ui/catalog.json +891 -0
  42. package/assets/ui/extensions/registry.json +6 -0
  43. package/assets/ui/native/_controls.tsx +521 -0
  44. package/assets/ui/native/_core.tsx +118 -0
  45. package/assets/ui/native/_data.tsx +200 -0
  46. package/assets/ui/native/_display.tsx +453 -0
  47. package/assets/ui/native/_feedback.tsx +242 -0
  48. package/assets/ui/native/_legacy-dialog.tsx +38 -0
  49. package/assets/ui/native/_motion.tsx +520 -0
  50. package/assets/ui/native/_overlay.tsx +402 -0
  51. package/assets/ui/native/_selection.tsx +366 -0
  52. package/assets/ui/native/accordion.tsx +1 -0
  53. package/assets/ui/native/alert-dialog.tsx +11 -0
  54. package/assets/ui/native/alert.tsx +1 -0
  55. package/assets/ui/native/aspect-ratio.tsx +1 -0
  56. package/assets/ui/native/attachment.tsx +8 -0
  57. package/assets/ui/native/avatar.tsx +8 -0
  58. package/assets/ui/native/badge.tsx +1 -0
  59. package/assets/ui/native/breadcrumb.tsx +9 -0
  60. package/assets/ui/native/bubble.tsx +1 -0
  61. package/assets/ui/native/button-group.tsx +1 -0
  62. package/assets/ui/native/button.tsx +86 -0
  63. package/assets/ui/native/calendar.tsx +170 -0
  64. package/assets/ui/native/card.tsx +44 -0
  65. package/assets/ui/native/carousel.tsx +1 -0
  66. package/assets/ui/native/chart.tsx +193 -0
  67. package/assets/ui/native/checkbox.tsx +1 -0
  68. package/assets/ui/native/code-block.tsx +137 -0
  69. package/assets/ui/native/collapsible.tsx +1 -0
  70. package/assets/ui/native/combobox.tsx +1 -0
  71. package/assets/ui/native/command.tsx +11 -0
  72. package/assets/ui/native/context-menu.tsx +16 -0
  73. package/assets/ui/native/data-table.tsx +1 -0
  74. package/assets/ui/native/date-picker.tsx +43 -0
  75. package/assets/ui/native/dialog.tsx +15 -0
  76. package/assets/ui/native/direction.tsx +1 -0
  77. package/assets/ui/native/drawer.tsx +10 -0
  78. package/assets/ui/native/dropdown-menu.tsx +16 -0
  79. package/assets/ui/native/empty.tsx +8 -0
  80. package/assets/ui/native/field.tsx +13 -0
  81. package/assets/ui/native/hover-card.tsx +1 -0
  82. package/assets/ui/native/input-group.tsx +8 -0
  83. package/assets/ui/native/input-otp.tsx +1 -0
  84. package/assets/ui/native/input.tsx +28 -0
  85. package/assets/ui/native/item.tsx +12 -0
  86. package/assets/ui/native/kbd.tsx +1 -0
  87. package/assets/ui/native/label.tsx +4 -0
  88. package/assets/ui/native/layout.tsx +26 -0
  89. package/assets/ui/native/marker.tsx +1 -0
  90. package/assets/ui/native/menubar.tsx +17 -0
  91. package/assets/ui/native/message-scroller.tsx +6 -0
  92. package/assets/ui/native/message.tsx +10 -0
  93. package/assets/ui/native/native-select.tsx +1 -0
  94. package/assets/ui/native/navigation-menu.tsx +10 -0
  95. package/assets/ui/native/pagination.tsx +9 -0
  96. package/assets/ui/native/popover.tsx +1 -0
  97. package/assets/ui/native/progress.tsx +1 -0
  98. package/assets/ui/native/questionnaire.tsx +130 -0
  99. package/assets/ui/native/radio-group.tsx +1 -0
  100. package/assets/ui/native/registry.json +1103 -0
  101. package/assets/ui/native/resizable.tsx +1 -0
  102. package/assets/ui/native/scroll-area.tsx +1 -0
  103. package/assets/ui/native/select.tsx +11 -0
  104. package/assets/ui/native/separator.tsx +1 -0
  105. package/assets/ui/native/sheet.tsx +10 -0
  106. package/assets/ui/native/sidebar.tsx +22 -0
  107. package/assets/ui/native/skeleton.tsx +1 -0
  108. package/assets/ui/native/slider.tsx +1 -0
  109. package/assets/ui/native/spinner.tsx +1 -0
  110. package/assets/ui/native/switch.tsx +1 -0
  111. package/assets/ui/native/table.tsx +10 -0
  112. package/assets/ui/native/tabs.tsx +1 -0
  113. package/assets/ui/native/text.tsx +20 -0
  114. package/assets/ui/native/textarea.tsx +1 -0
  115. package/assets/ui/native/theme-switcher.tsx +22 -0
  116. package/assets/ui/native/toast.tsx +11 -0
  117. package/assets/ui/native/toggle-group.tsx +1 -0
  118. package/assets/ui/native/toggle.tsx +1 -0
  119. package/assets/ui/native/tooltip.tsx +1 -0
  120. package/assets/ui/native/trace.tsx +20 -0
  121. package/assets/ui/native/typography.tsx +15 -0
  122. package/assets/ui/theme-storage.ts +25 -0
  123. package/assets/ui/theme.tsx +66 -0
  124. package/assets/ui/web/button.tsx +59 -0
  125. package/assets/ui/web/input.tsx +21 -0
  126. package/assets/ui/web/label.tsx +19 -0
  127. package/dist/bin.js +7 -12
  128. package/dist/capabilities.d.ts +4 -33
  129. package/dist/capabilities.js +2 -84
  130. package/dist/capability-catalog.d.ts +83 -0
  131. package/dist/capability-catalog.js +121 -0
  132. package/dist/capability-command.d.ts +3 -0
  133. package/dist/capability-command.js +188 -0
  134. package/dist/capability-editor.d.ts +17 -0
  135. package/dist/capability-editor.js +97 -0
  136. package/dist/capability-recipes.d.ts +4 -0
  137. package/dist/capability-recipes.js +520 -0
  138. package/dist/capability-references.d.ts +4 -0
  139. package/dist/capability-references.js +7 -0
  140. package/dist/cli-commands.d.ts +1 -2
  141. package/dist/cli-commands.js +10 -104
  142. package/dist/cli-output.d.ts +1 -2
  143. package/dist/cli-output.js +6 -251
  144. package/dist/command-schema.js +40 -374
  145. package/dist/dependencies.d.ts +34 -62
  146. package/dist/dependencies.js +112 -199
  147. package/dist/index.d.ts +1 -45
  148. package/dist/index.js +1 -30
  149. package/dist/platforms/mobile.js +29 -139
  150. package/dist/platforms/web.d.ts +3 -0
  151. package/dist/platforms/web.js +251 -0
  152. package/dist/project-config.d.ts +2 -13
  153. package/dist/project-config.js +10 -83
  154. package/dist/registry/context.js +0 -1
  155. package/dist/registry/options.js +6 -40
  156. package/dist/registry/resolve.d.ts +3 -4
  157. package/dist/registry/resolve.js +18 -108
  158. package/dist/registry/types.d.ts +1 -7
  159. package/dist/registry/usage.js +3 -9
  160. package/dist/runtime-policy.d.ts +0 -2
  161. package/dist/runtime-policy.js +0 -16
  162. package/dist/scaffold/backend.d.ts +0 -4
  163. package/dist/scaffold/backend.js +1 -189
  164. package/dist/scaffold/bootstrap.d.ts +2 -3
  165. package/dist/scaffold/bootstrap.js +37 -43
  166. package/dist/scaffold/compose.js +2 -14
  167. package/dist/scaffold/database.d.ts +1 -1
  168. package/dist/scaffold/database.js +19 -126
  169. package/dist/scaffold/documentation.d.ts +0 -1
  170. package/dist/scaffold/documentation.js +82 -84
  171. package/dist/scaffold/expo-runtime.d.ts +2 -2
  172. package/dist/scaffold/expo-runtime.js +9 -101
  173. package/dist/scaffold/native-ui.d.ts +2 -0
  174. package/dist/scaffold/native-ui.js +74 -0
  175. package/dist/scaffold/stack-documentation.d.ts +0 -1
  176. package/dist/scaffold/stack-documentation.js +3 -49
  177. package/dist/scaffold/storage.d.ts +2 -0
  178. package/dist/scaffold/storage.js +21 -0
  179. package/dist/scaffold/styling.d.ts +1 -1
  180. package/dist/scaffold/styling.js +20 -28
  181. package/dist/scaffold/workspace.js +63 -199
  182. package/dist/stack-registry.d.ts +2 -58
  183. package/dist/stack-registry.js +22 -446
  184. package/dist/standard.js +7 -24
  185. package/dist/ui-catalog.d.ts +26 -0
  186. package/dist/ui-catalog.js +31 -0
  187. package/dist/ui-command.d.ts +3 -0
  188. package/dist/ui-command.js +219 -0
  189. package/dist/ui-project.d.ts +22 -0
  190. package/dist/ui-project.js +110 -0
  191. package/dist/version.d.ts +1 -1
  192. package/dist/version.js +1 -1
  193. package/docs/anhedral-stack.md +4 -119
  194. package/docs/capabilities.md +110 -0
  195. package/docs/native-ui.md +102 -0
  196. package/docs/software-factory.md +16 -577
  197. package/docs/stack-standard.md +11 -307
  198. package/docs/ui.md +33 -0
  199. package/docs/verification.md +511 -0
  200. package/package.json +26 -27
  201. package/dist/access.d.ts +0 -10
  202. package/dist/access.js +0 -93
  203. package/dist/auth-schema-snapshot.d.ts +0 -346
  204. package/dist/auth-schema-snapshot.js +0 -347
  205. package/dist/auth-schema.d.ts +0 -1
  206. package/dist/auth-schema.js +0 -57
  207. package/dist/capability-contract.d.ts +0 -47
  208. package/dist/capability-contract.js +0 -168
  209. package/dist/catalog-model.d.ts +0 -24
  210. package/dist/catalog-model.js +0 -1
  211. package/dist/catalog-registration.d.ts +0 -16
  212. package/dist/catalog-registration.js +0 -22
  213. package/dist/catalog-snapshot.d.ts +0 -5
  214. package/dist/catalog-snapshot.js +0 -97
  215. package/dist/cli-delivery.d.ts +0 -3
  216. package/dist/cli-delivery.js +0 -172
  217. package/dist/cloudflare.d.ts +0 -25
  218. package/dist/cloudflare.js +0 -226
  219. package/dist/delivery-evidence.d.ts +0 -62
  220. package/dist/delivery-evidence.js +0 -186
  221. package/dist/delivery.d.ts +0 -88
  222. package/dist/delivery.js +0 -570
  223. package/dist/inspector-model.d.ts +0 -123
  224. package/dist/inspector-model.js +0 -1
  225. package/dist/integration-service-readers.d.ts +0 -13
  226. package/dist/integration-service-readers.js +0 -173
  227. package/dist/lifecycle-model.d.ts +0 -15
  228. package/dist/lifecycle-model.js +0 -20
  229. package/dist/lifecycle.d.ts +0 -11
  230. package/dist/lifecycle.js +0 -91
  231. package/dist/management.d.ts +0 -3
  232. package/dist/management.js +0 -47
  233. package/dist/mobile-delivery.d.ts +0 -77
  234. package/dist/mobile-delivery.js +0 -366
  235. package/dist/neon-service-data.d.ts +0 -8
  236. package/dist/neon-service-data.js +0 -117
  237. package/dist/platforms/desktop.d.ts +0 -2
  238. package/dist/platforms/desktop.js +0 -415
  239. package/dist/platforms/extension.d.ts +0 -2
  240. package/dist/platforms/extension.js +0 -328
  241. package/dist/project-catalog.d.ts +0 -41
  242. package/dist/project-catalog.js +0 -288
  243. package/dist/project-inspector.d.ts +0 -4
  244. package/dist/project-inspector.js +0 -702
  245. package/dist/project-lifecycle.d.ts +0 -25
  246. package/dist/project-lifecycle.js +0 -57
  247. package/dist/project-state.d.ts +0 -49
  248. package/dist/project-state.js +0 -563
  249. package/dist/provider-auth.d.ts +0 -41
  250. package/dist/provider-auth.js +0 -215
  251. package/dist/provider-readiness.d.ts +0 -30
  252. package/dist/provider-readiness.js +0 -104
  253. package/dist/providers/adapters.d.ts +0 -17
  254. package/dist/providers/adapters.js +0 -278
  255. package/dist/providers/api.d.ts +0 -29
  256. package/dist/providers/api.js +0 -253
  257. package/dist/providers/config.d.ts +0 -15
  258. package/dist/providers/config.js +0 -182
  259. package/dist/providers/definitions.d.ts +0 -318
  260. package/dist/providers/definitions.js +0 -127
  261. package/dist/providers/provision.d.ts +0 -24
  262. package/dist/providers/provision.js +0 -76
  263. package/dist/providers/receipts.d.ts +0 -20
  264. package/dist/providers/receipts.js +0 -66
  265. package/dist/providers/recovery-verification.d.ts +0 -7
  266. package/dist/providers/recovery-verification.js +0 -112
  267. package/dist/providers/recovery.d.ts +0 -30
  268. package/dist/providers/recovery.js +0 -34
  269. package/dist/providers/runtime.d.ts +0 -10
  270. package/dist/providers/runtime.js +0 -265
  271. package/dist/providers/schema.d.ts +0 -28
  272. package/dist/providers/schema.js +0 -49
  273. package/dist/providers/state.d.ts +0 -55
  274. package/dist/providers/state.js +0 -289
  275. package/dist/provision.d.ts +0 -55
  276. package/dist/provision.js +0 -284
  277. package/dist/r2-service-data.d.ts +0 -2
  278. package/dist/r2-service-data.js +0 -136
  279. package/dist/readiness.d.ts +0 -23
  280. package/dist/readiness.js +0 -122
  281. package/dist/registry/add.d.ts +0 -24
  282. package/dist/registry/add.js +0 -270
  283. package/dist/registry/bootstrap.d.ts +0 -2
  284. package/dist/registry/bootstrap.js +0 -14
  285. package/dist/registry/commands.d.ts +0 -3
  286. package/dist/registry/commands.js +0 -85
  287. package/dist/registry/presets.d.ts +0 -4
  288. package/dist/registry/presets.js +0 -41
  289. package/dist/registry/preview.d.ts +0 -11
  290. package/dist/registry/preview.js +0 -91
  291. package/dist/registry/receipt.d.ts +0 -3
  292. package/dist/registry/receipt.js +0 -68
  293. package/dist/repository.d.ts +0 -24
  294. package/dist/repository.js +0 -96
  295. package/dist/scaffold/auth.d.ts +0 -3
  296. package/dist/scaffold/auth.js +0 -151
  297. package/dist/scaffold/billing-config.d.ts +0 -1
  298. package/dist/scaffold/billing-config.js +0 -73
  299. package/dist/scaffold/billing-contracts.d.ts +0 -2
  300. package/dist/scaffold/billing-contracts.js +0 -48
  301. package/dist/scaffold/billing-providers.d.ts +0 -1
  302. package/dist/scaffold/billing-providers.js +0 -249
  303. package/dist/scaffold/billing-schema.d.ts +0 -1
  304. package/dist/scaffold/billing-schema.js +0 -34
  305. package/dist/scaffold/billing-security.d.ts +0 -1
  306. package/dist/scaffold/billing-security.js +0 -46
  307. package/dist/scaffold/billing-server.d.ts +0 -1
  308. package/dist/scaffold/billing-server.js +0 -139
  309. package/dist/scaffold/billing-store.d.ts +0 -1
  310. package/dist/scaffold/billing-store.js +0 -72
  311. package/dist/scaffold/billing.d.ts +0 -2
  312. package/dist/scaffold/billing.js +0 -216
  313. package/dist/scaffold/cloudflare-services.d.ts +0 -8
  314. package/dist/scaffold/cloudflare-services.js +0 -198
  315. package/dist/scaffold/expo-auth.d.ts +0 -3
  316. package/dist/scaffold/expo-auth.js +0 -192
  317. package/dist/scaffold/expo-billing.d.ts +0 -3
  318. package/dist/scaffold/expo-billing.js +0 -292
  319. package/dist/scaffold/integrations.d.ts +0 -4
  320. package/dist/scaffold/integrations.js +0 -12
  321. package/dist/scaffold/lint.d.ts +0 -4
  322. package/dist/scaffold/lint.js +0 -56
  323. package/dist/scaffold/neon-realtime.d.ts +0 -2
  324. package/dist/scaffold/neon-realtime.js +0 -97
  325. package/dist/scaffold/services.d.ts +0 -5
  326. package/dist/scaffold/services.js +0 -108
  327. package/dist/scaffold/stream.d.ts +0 -2
  328. package/dist/scaffold/stream.js +0 -114
  329. package/dist/scaffold/void.d.ts +0 -4
  330. package/dist/scaffold/void.js +0 -264
  331. package/dist/scaffold/web.d.ts +0 -2
  332. package/dist/scaffold/web.js +0 -130
  333. package/dist/service-deletion.d.ts +0 -29
  334. package/dist/service-deletion.js +0 -195
  335. package/dist/service-descriptor.d.ts +0 -10
  336. package/dist/service-descriptor.js +0 -78
  337. package/dist/service-model.d.ts +0 -49
  338. package/dist/service-model.js +0 -8
  339. package/dist/service-operations.d.ts +0 -29
  340. package/dist/service-operations.js +0 -78
  341. package/dist/service-readers.d.ts +0 -8
  342. package/dist/service-readers.js +0 -247
  343. package/dist/services-command.d.ts +0 -39
  344. package/dist/services-command.js +0 -102
  345. package/dist/ship.d.ts +0 -348
  346. package/dist/ship.js +0 -239
  347. package/dist/vercel-project.d.ts +0 -101
  348. package/dist/vercel-project.js +0 -305
  349. package/dist/vercel.d.ts +0 -67
  350. package/dist/vercel.js +0 -581
  351. package/dist/vinext.d.ts +0 -2
  352. package/dist/vinext.js +0 -86
  353. package/dist/void-execution.d.ts +0 -10
  354. package/dist/void-execution.js +0 -94
  355. package/dist/void-migrations.d.ts +0 -6
  356. package/dist/void-migrations.js +0 -110
  357. package/dist/void-state.d.ts +0 -16
  358. package/dist/void-state.js +0 -65
  359. package/dist/void.d.ts +0 -3
  360. package/dist/void.js +0 -5
@@ -1,136 +0,0 @@
1
- import { createHash, createHmac } from 'node:crypto';
2
- const hash = (value) => createHash('sha256').update(value).digest('hex');
3
- const hmac = (key, value) => createHmac('sha256', key).update(value).digest();
4
- const encode = (value) => encodeURIComponent(value).replace(/[!'()*]/g, (char) => '%' + char.charCodeAt(0).toString(16).toUpperCase());
5
- function xmlValue(value) {
6
- return value.replace(/&(?:amp|lt|gt|quot|apos);/g, (entity) => ({ '&amp;': '&', '&lt;': '<', '&gt;': '>', '&quot;': '"', '&apos;': "'" })[entity]);
7
- }
8
- export async function browseR2Objects(service, cursor, env = process.env, send = fetch) {
9
- if (service.kind !== 'r2' ||
10
- !/^[a-f0-9]{32}$/.test(service.accountId) ||
11
- !service.name ||
12
- !/^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/.test(service.name) ||
13
- (cursor !== undefined && (cursor.length > 4096 || /[\x00-\x1f\x7f]/.test(cursor))))
14
- throw new Error('Choose a supported R2 bucket and cursor.');
15
- const key = env[`ANHEDRAL_R2_ACCESS_KEY_ID_${service.accountId.toUpperCase()}`] ??
16
- env.ANHEDRAL_R2_ACCESS_KEY_ID;
17
- const secret = env[`ANHEDRAL_R2_SECRET_ACCESS_KEY_${service.accountId.toUpperCase()}`] ??
18
- env.ANHEDRAL_R2_SECRET_ACCESS_KEY;
19
- if (!key ||
20
- !secret ||
21
- !/^[a-zA-Z0-9_-]{8,128}$/.test(key) ||
22
- !/^[\x21-\x7e]{8,256}$/.test(secret))
23
- throw new Error('Provide scoped read-only R2 S3 credentials for metadata browsing.');
24
- const host = `${service.accountId}.r2.cloudflarestorage.com`;
25
- const pathname = `/${service.name}`;
26
- const params = {
27
- 'list-type': '2',
28
- 'max-keys': '25',
29
- ...(cursor ? { 'continuation-token': cursor } : {}),
30
- };
31
- const query = Object.entries(params)
32
- .sort(([a], [b]) => a.localeCompare(b))
33
- .map(([name, value]) => `${encode(name)}=${encode(value)}`)
34
- .join('&');
35
- const timestamp = new Date().toISOString().replace(/[-:]/g, '').slice(0, 15) + 'Z';
36
- const date = timestamp.slice(0, 8);
37
- const payloadHash = hash('');
38
- const headers = `host:${host}\nx-amz-content-sha256:${payloadHash}\nx-amz-date:${timestamp}\n`;
39
- const signed = 'host;x-amz-content-sha256;x-amz-date';
40
- const scope = `${date}/auto/s3/aws4_request`;
41
- const canonical = `GET\n${pathname}\n${query}\n${headers}\n${signed}\n${payloadHash}`;
42
- const signingKey = hmac(hmac(hmac(hmac('AWS4' + secret, date), 'auto'), 's3'), 'aws4_request');
43
- const signature = createHmac('sha256', signingKey)
44
- .update(`AWS4-HMAC-SHA256\n${timestamp}\n${scope}\n${hash(canonical)}`)
45
- .digest('hex');
46
- const controller = new AbortController();
47
- const timer = setTimeout(() => controller.abort(), 10000);
48
- try {
49
- const response = await send(`https://${host}${pathname}?${query}`, {
50
- method: 'GET',
51
- redirect: 'error',
52
- signal: controller.signal,
53
- headers: {
54
- Authorization: `AWS4-HMAC-SHA256 Credential=${key}/${scope}, SignedHeaders=${signed}, Signature=${signature}`,
55
- 'x-amz-date': timestamp,
56
- 'x-amz-content-sha256': payloadHash,
57
- },
58
- });
59
- if (!response.ok) {
60
- void response.body?.cancel();
61
- throw new Error('R2 metadata read requires scoped access and provider availability.');
62
- }
63
- const reader = response.body?.getReader();
64
- if (!reader)
65
- throw new Error('Empty R2 metadata response.');
66
- const abort = () => {
67
- void reader.cancel();
68
- };
69
- controller.signal.addEventListener('abort', abort, { once: true });
70
- const chunks = [];
71
- let bytes = 0;
72
- try {
73
- for (;;) {
74
- const chunk = await reader.read();
75
- if (chunk.done)
76
- break;
77
- bytes += chunk.value.length;
78
- if (bytes > 2 * 1024 * 1024 || controller.signal.aborted)
79
- throw new Error('R2 metadata exceeded its limits.');
80
- chunks.push(chunk.value);
81
- }
82
- }
83
- catch (error) {
84
- void reader.cancel().catch(() => undefined);
85
- throw error;
86
- }
87
- finally {
88
- controller.signal.removeEventListener('abort', abort);
89
- reader.releaseLock();
90
- }
91
- if (controller.signal.aborted)
92
- throw new Error('R2 metadata request timed out.');
93
- const xml = Buffer.concat(chunks).toString('utf8');
94
- if (/<!DOCTYPE|<!ENTITY/i.test(xml) ||
95
- !/<ListBucketResult(?:\s[^>]*)?>/.test(xml) ||
96
- !xml.includes('</ListBucketResult>') ||
97
- !/<IsTruncated>(?:true|false)<\/IsTruncated>/.test(xml) ||
98
- xmlValue(xml.match(/<Name>([^<]*)<\/Name>/)?.[1] ?? '') !== service.name)
99
- throw new Error('R2 metadata does not match the selected bucket.');
100
- const contents = [...xml.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)];
101
- if (contents.length > 25)
102
- throw new Error('R2 metadata page exceeded its limit.');
103
- const rows = contents.map((entry) => {
104
- const value = entry[1];
105
- const key = xmlValue(value.match(/<Key>([^<]*)<\/Key>/)?.[1] ?? '');
106
- const size = Number(value.match(/<Size>(\d+)<\/Size>/)?.[1]);
107
- const modified = value.match(/<LastModified>([^<]*)<\/LastModified>/)?.[1];
108
- if (!key ||
109
- !Number.isSafeInteger(size) ||
110
- size < 0 ||
111
- !modified ||
112
- !Number.isFinite(Date.parse(modified)))
113
- throw new Error('Unsupported object metadata.');
114
- return [key.slice(0, 1000), size, modified];
115
- });
116
- const nextCursor = xmlValue(xml.match(/<NextContinuationToken>([^<]*)<\/NextContinuationToken>/)?.[1] ?? '');
117
- const hasMore = xml.includes('<IsTruncated>true</IsTruncated>');
118
- if (hasMore && (!nextCursor || nextCursor.length > 4096))
119
- throw new Error('R2 cursor is unavailable.');
120
- return {
121
- fetchedAt: new Date().toISOString(),
122
- columns: ['Object key', 'Size (bytes)', 'Last modified'],
123
- rows,
124
- offset: 0,
125
- hasMore,
126
- masked: false,
127
- ...(hasMore ? { nextCursor } : {}),
128
- };
129
- }
130
- catch {
131
- throw new Error('R2 metadata could not be read. Check selected bucket, read-only S3 credentials, permissions, and response limits.');
132
- }
133
- finally {
134
- clearTimeout(timer);
135
- }
136
- }
@@ -1,23 +0,0 @@
1
- import type { ResolvedStackRegistry } from './registry/resolve.js';
2
- import { type StandardProduct } from './stack-registry.js';
3
- export declare function inspectProject(root: string): {
4
- schemaVersion: number;
5
- root: string;
6
- checks: {
7
- id: string;
8
- ok: boolean;
9
- detail: string;
10
- }[];
11
- localReady: boolean;
12
- providerVerification: string;
13
- productionReady: boolean;
14
- };
15
- export declare function validateSetupPlan(plan: unknown): asserts plan is {
16
- schemaVersion: 1;
17
- cliVersion: string;
18
- registryVersion: 1;
19
- products: StandardProduct[];
20
- hosting: 'cloudflare' | 'vercel';
21
- name?: string;
22
- registry: ResolvedStackRegistry;
23
- };
package/dist/readiness.js DELETED
@@ -1,122 +0,0 @@
1
- import { readProjectSection } from './project-config.js';
2
- import { existsSync } from 'node:fs';
3
- import path from 'node:path';
4
- import { isDeepStrictEqual } from 'node:util';
5
- import { inspectWorkspaceGraph } from './workspace-graph.js';
6
- import { resolveStackRegistry, resolveStandardProducts } from './registry/resolve.js';
7
- import { CAPABILITY_REGISTRY } from './capabilities.js';
8
- import { STANDARD_PRODUCTS } from './stack-registry.js';
9
- export function inspectProject(root) {
10
- const checks = [];
11
- const record = (id, ok, detail) => checks.push({ id, ok, detail });
12
- record('workspace', existsSync(path.join(root, 'pnpm-workspace.yaml')), 'pnpm workspace manifest');
13
- record('lockfile', existsSync(path.join(root, 'pnpm-lock.yaml')), 'Committed dependency resolution required');
14
- try {
15
- const plan = readProjectSection(root, 'setup');
16
- const recordedVersion = plan?.cliVersion;
17
- const current = recordedVersion === CAPABILITY_REGISTRY.cliVersion;
18
- record('cli-version', current, `Project configuration must be generated by anhedral@${CAPABILITY_REGISTRY.cliVersion}.`);
19
- validateSetupPlan(plan);
20
- const standard = readProjectSection(root, 'standard');
21
- record('setup-plan', true, `Requirements recorded by CLI ${plan.cliVersion}`);
22
- try {
23
- const installed = readProjectSection(root, 'registry');
24
- const { status, workspaces: _workspaces, files: _files, configuration: _configuration, resourcesProvisioned, ...snapshot } = installed;
25
- if (status !== 'scaffolded' ||
26
- resourcesProvisioned !== false ||
27
- !isDeepStrictEqual(snapshot, plan.registry))
28
- throw new Error('Registry provenance differs from the setup plan.');
29
- for (const item of plan.registry.items)
30
- for (const target of item.targets) {
31
- if (!existsSync(path.join(root, target)))
32
- throw new Error(`Registry target missing: ${item.name}.`);
33
- }
34
- record('stack-registry', true, 'Registry provenance and resolved targets match the setup plan');
35
- }
36
- catch {
37
- record('stack-registry', false, 'Missing registry provenance or targets; inspect before regenerating');
38
- }
39
- try {
40
- const workspaces = inspectWorkspaceGraph(root);
41
- record('workspace-graph', workspaces.length > 0, 'Workspace names and dependencies resolve without cycles');
42
- }
43
- catch {
44
- record('workspace-graph', false, 'Invalid workspace manifests, references or dependency cycles');
45
- }
46
- record('selection', standard.schemaVersion === 1 &&
47
- JSON.stringify(standard.products) === JSON.stringify(plan.products) &&
48
- standard.hosting ===
49
- (plan.products.includes('next') ||
50
- plan.products.includes('vinext') ||
51
- plan.products.includes('expo')
52
- ? plan.hosting
53
- : null), 'Setup plan matches project selection');
54
- }
55
- catch {
56
- record('setup-plan', false, 'Missing, invalid or unsupported setup plan; inspect the project before changing it');
57
- }
58
- return {
59
- schemaVersion: 1,
60
- root,
61
- checks,
62
- localReady: checks.every((check) => check.ok),
63
- providerVerification: 'unverified',
64
- productionReady: false,
65
- };
66
- }
67
- export function validateSetupPlan(plan) {
68
- if (!plan || typeof plan !== 'object')
69
- throw new Error('Invalid setup plan.');
70
- const value = plan;
71
- if (value.schemaVersion !== 1 ||
72
- value.registryVersion !== 1 ||
73
- typeof value.cliVersion !== 'string')
74
- throw new Error('Unsupported setup plan version.');
75
- if (value.cliVersion !== CAPABILITY_REGISTRY.cliVersion)
76
- throw new Error(`Project configuration must be generated by anhedral@${CAPABILITY_REGISTRY.cliVersion}.`);
77
- if (!Array.isArray(value.products) ||
78
- !value.products.length ||
79
- !value.products.every((id) => STANDARD_PRODUCTS.includes(id)))
80
- throw new Error('Unknown setup capabilities.');
81
- if (value.hosting !== 'cloudflare' && value.hosting !== 'vercel')
82
- throw new Error('Invalid hosting.');
83
- validateRequirements(value.setup, value.products);
84
- const selected = new Set(value.products);
85
- resolveStandardProducts(selected, value.hosting, false, false);
86
- if (selected.size !== value.products.length)
87
- throw new Error('Invalid or incomplete setup selection.');
88
- if (value.name !== undefined && typeof value.name !== 'string')
89
- throw new Error('Invalid setup project name.');
90
- if (!isDeepStrictEqual(value.registry, resolveStackRegistry({
91
- products: value.products,
92
- hosting: value.hosting,
93
- name: value.name,
94
- })))
95
- throw new Error('Invalid or inconsistent stack registry.');
96
- }
97
- function validateRequirements(setup, products) {
98
- if (!setup || typeof setup !== 'object')
99
- throw new Error('Missing setup requirements.');
100
- const value = setup;
101
- if (value.resourcesProvisioned !== false ||
102
- !Array.isArray(value.capabilities) ||
103
- value.capabilities.length !== products.length)
104
- throw new Error('Invalid capability requirements.');
105
- const ids = value.capabilities.map((item) => validateCapability(item));
106
- if (new Set(ids).size !== products.length || !products.every((id) => ids.includes(id)))
107
- throw new Error('Capability selection mismatch.');
108
- }
109
- function validateCapability(item) {
110
- if (!item || typeof item !== 'object')
111
- throw new Error('Invalid capability.');
112
- const value = item;
113
- if (typeof value.id !== 'string' ||
114
- typeof value.purpose !== 'string' ||
115
- !['planned', 'starter'].includes(String(value.status)))
116
- throw new Error('Invalid capability metadata.');
117
- for (const key of ['tools', 'access', 'credentials', 'resources', 'verify']) {
118
- if (!Array.isArray(value[key]) || !value[key].every((entry) => typeof entry === 'string'))
119
- throw new Error('Invalid requirement fields.');
120
- }
121
- return value.id;
122
- }
@@ -1,24 +0,0 @@
1
- import type { StandardRunner } from './types.js';
2
- import { type SourcePreview } from './preview.js';
3
- export interface AddRequest {
4
- items: string[];
5
- dryRun?: boolean;
6
- skipInstall?: boolean;
7
- preview?: {
8
- mode: 'diff' | 'view';
9
- path?: string;
10
- };
11
- }
12
- /** Add recipes to an initialized workspace, refusing edits to customer-owned source. */
13
- export declare function addStackItems(root: string, request: AddRequest, run?: StandardRunner): Promise<{
14
- previews?: SourcePreview[] | undefined;
15
- schemaVersion: number;
16
- root: string;
17
- dryRun: boolean;
18
- items: string[];
19
- bootstrapRequired: boolean;
20
- filesChecked: boolean;
21
- targets: string[];
22
- files: string[];
23
- conflicts: string[];
24
- }>;
@@ -1,270 +0,0 @@
1
- import { scaffoldCloudflareServiceContext } from '../scaffold/cloudflare-services.js';
2
- import { PROJECT_CONFIG_FILE, readProjectSection, writeProjectSection, hasProjectSection, } from '../project-config.js';
3
- import { scaffoldExpoRuntime } from '../scaffold/expo-runtime.js';
4
- import { scaffoldWebBackend } from '../scaffold/backend.js';
5
- import { configureDependencyPatches } from '../dependency-patches.js';
6
- import { readBoundedFile, MAX_PROJECT_JSON_BYTES } from '../bounded-file.js';
7
- import { bootstrapWorkspace, assertWorkspaceRuntime } from '../scaffold/bootstrap.js';
8
- import { registerApplication } from '../project-state.js';
9
- import { registerVercelApplication } from '../vercel.js';
10
- import { existsSync, lstatSync, readFileSync, realpathSync, rmSync } from 'node:fs';
11
- import path from 'node:path';
12
- import { isDeepStrictEqual } from 'node:util';
13
- import { applyEdits, modify, parse } from 'jsonc-parser';
14
- import { STANDARD_PRODUCTS, getStackDefinition, installStackItem } from '../stack-registry.js';
15
- import { inspectProject, validateSetupPlan } from '../readiness.js';
16
- import { GENERATOR_VERSION } from '../version.js';
17
- import { runStagedTransaction } from '../transaction.js';
18
- import { inspectWorkspaceGraph } from '../workspace-graph.js';
19
- import { execFile } from '../util.js';
20
- import { supportsVoidRuntime, usesVoidSelection } from '../runtime-policy.js';
21
- import { put } from '../scaffold/files.js';
22
- import { writeStandardRoot } from '../scaffold/workspace.js';
23
- import { configureVoidDelivery, refreshVoidEnvironment } from '../scaffold/void.js';
24
- import { createRecipeContext } from './context.js';
25
- import { resolveBillingProducts, resolveStackRegistry, resolveStandardProducts, } from './resolve.js';
26
- import { sourceFiles, configurationFingerprints } from './receipt.js';
27
- import { sourcePreview, validatePreviewPath, MAX_PREVIEW_TOTAL_BYTES, } from './preview.js';
28
- /** Add recipes to an initialized workspace, refusing edits to customer-owned source. */
29
- export async function addStackItems(root, request, run = execFile) {
30
- for (const key of Object.keys(request))
31
- if (!['items', 'dryRun', 'skipInstall', 'preview'].includes(key))
32
- throw new Error(`Unknown add option: ${key}. Only bundled registry items are supported.`);
33
- if (request.preview) {
34
- if (!request.dryRun ||
35
- !['diff', 'view'].includes(request.preview.mode) ||
36
- Object.keys(request.preview).some((key) => !['mode', 'path'].includes(key)))
37
- throw new Error('Source previews require dry-run and one mode: diff or view.');
38
- if (request.preview.path !== undefined)
39
- validatePreviewPath(request.preview.path);
40
- }
41
- if (!request.dryRun)
42
- assertWorkspaceRuntime(run);
43
- root = realpathSync(root);
44
- if (!request.items.length)
45
- throw new Error('Select at least one registry item.');
46
- const plan = readProjectSection(root, 'setup');
47
- if (Array.isArray(plan?.registry?.items) &&
48
- plan.registry.items.some((item) => item.name === 'stripe' && item.package))
49
- throw new Error('This project uses the legacy billing SDK recipe. Use its pinned CLI or perform a reviewed billing migration before adding capabilities.');
50
- validateSetupPlan(plan);
51
- if (plan.cliVersion !== GENERATOR_VERSION)
52
- throw new Error('Use the project CLI version before adding recipes.');
53
- if (!inspectProject(root).localReady)
54
- throw new Error('Run doctor and resolve project provenance or workspace errors before add.');
55
- const receipt = readProjectSection(root, 'registry');
56
- if (!receipt.files || typeof receipt.files !== 'object' || Array.isArray(receipt.files))
57
- throw new Error('Add requires current scaffold fingerprints.');
58
- const baseline = receipt.files;
59
- if (!receipt.configuration ||
60
- typeof receipt.configuration !== 'object' ||
61
- Array.isArray(receipt.configuration))
62
- throw new Error('Add requires current configuration fingerprints.');
63
- const originalConfiguration = configurationFingerprints(root);
64
- const selected = new Set(plan.products);
65
- for (const id of request.items) {
66
- if (!STANDARD_PRODUCTS.includes(id))
67
- throw new Error(`Unknown stack product: ${id}.`);
68
- selected.add(id);
69
- }
70
- const existingServerFeatures = plan.products.some((id) => Boolean(getStackDefinition(id).runtime));
71
- if (!existingServerFeatures &&
72
- request.items.some((id) => Boolean(getStackDefinition(id).runtime)))
73
- selected.add('hono');
74
- if (request.items.some((id) => ['stripe', 'revenuecat'].includes(id) && !plan.products.includes(id)))
75
- resolveBillingProducts(selected);
76
- if (['queues', 'basin', 'expo', 'images', 'analytics-engine'].some((id) => selected.has(id)) &&
77
- hasProjectSection(root, 'cloudflare') &&
78
- readProjectSection(root, 'cloudflare').deliveryEngine === 'void')
79
- throw new Error('Expo web, Queues, Basin, Images and Analytics Engine require Wrangler delivery. They cannot be added to a Void project.');
80
- resolveStandardProducts(selected, plan.hosting, false, false);
81
- const voidSelected = usesVoidSelection([...selected], plan.hosting);
82
- if (!request.dryRun &&
83
- voidSelected &&
84
- run === execFile &&
85
- !supportsVoidRuntime(process.versions.node))
86
- throw new Error('Cloudflare workspaces using Void require Node.js 24.21.0 or newer.');
87
- const options = {
88
- root,
89
- name: plan.name ?? path.basename(root),
90
- products: [...selected].sort(),
91
- hosting: plan.hosting,
92
- skipInstall: !!request.skipInstall,
93
- dryRun: false,
94
- json: true,
95
- initializeGit: false,
96
- };
97
- if (plan.products.includes('hono') &&
98
- !existsSync(path.join(root, 'packages/contracts/package.json')) &&
99
- (request.items.some((id) => ['vinext', 'next'].includes(id) && !plan.products.some((existing) => existing === id)) ||
100
- (request.items.includes('better-auth') &&
101
- !plan.products.includes('better-auth') &&
102
- plan.products.some((id) => ['vinext', 'next'].includes(id)))))
103
- throw new Error('This API predates shared contracts. Migrate its contracts and API endpoints explicitly before adding web/auth wiring.');
104
- const registry = resolveStackRegistry(options);
105
- const oldItems = new Map(plan.registry.items.map((item) => [item.name, item]));
106
- const recipes = registry.items.filter((item) => item.installer === 'recipe' && !isDeepStrictEqual(oldItems.get(item.name), item));
107
- // Relocating auth, database or service ownership requires a migration, not an additive scaffold.
108
- for (const item of registry.items) {
109
- const before = oldItems.get(item.name);
110
- if (before && before.targets.some((target) => !item.targets.includes(target)))
111
- throw new Error(`Adding this selection relocates ${item.name}; additions must preserve existing runtime ownership.`);
112
- }
113
- const before = sourceFiles(root);
114
- const receiptText = readBoundedFile(path.join(root, PROJECT_CONFIG_FILE), MAX_PROJECT_JSON_BYTES).toString('utf8');
115
- const commitPaths = [];
116
- const conflicts = [];
117
- const result = {
118
- schemaVersion: 1,
119
- root,
120
- dryRun: !!request.dryRun,
121
- items: registry.items
122
- .filter((item) => !isDeepStrictEqual(oldItems.get(item.name), item))
123
- .map((item) => item.name),
124
- bootstrapRequired: recipes.some((item) => ['vinext', 'next'].includes(item.name)) &&
125
- !existsSync(path.join(root, 'apps/web/package.json')),
126
- filesChecked: true,
127
- targets: recipes.flatMap((item) => item.targets),
128
- files: commitPaths,
129
- conflicts,
130
- ...(request.preview ? { previews: [] } : {}),
131
- };
132
- // The upstream web generator requires network access and executes package scripts.
133
- // A preview reports the resolved selection without invoking that generator.
134
- if (request.dryRun && result.bootstrapRequired) {
135
- result.filesChecked = false;
136
- if (request.preview)
137
- throw new Error('Source preview requires a new web bootstrap and cannot run offline. Use add --dry-run for the selection plan.');
138
- return result;
139
- }
140
- await runStagedTransaction(root, {
141
- dryRun: !!request.dryRun,
142
- commitPaths,
143
- seedPaths: [...before.keys(), PROJECT_CONFIG_FILE],
144
- build: async (stage) => {
145
- const context = createRecipeContext(stage, options);
146
- context.updating = true;
147
- for (const item of registry.items)
148
- Object.assign(context.bindings, item.bindings);
149
- if (recipes.some((item) => ['vinext', 'next'].includes(item.name)) &&
150
- !existsSync(path.join(stage, 'apps/web/package.json')))
151
- bootstrapWorkspace(stage, options.name, run, true);
152
- for (const item of recipes) {
153
- if (item.name === 'expo' && plan.products.includes('expo')) {
154
- scaffoldExpoRuntime(context);
155
- }
156
- else
157
- await installStackItem(item, context);
158
- }
159
- // Connect a newly introduced backend without regenerating customer UI.
160
- if (!plan.products.includes('hono') && selected.has('hono')) {
161
- if (plan.products.includes('expo'))
162
- scaffoldExpoRuntime(context);
163
- if (plan.products.includes('next') || plan.products.includes('vinext'))
164
- scaffoldWebBackend(context);
165
- }
166
- // Configuration items affect the existing runtime without regenerating its application source.
167
- const configurationItems = registry.items.filter((item) => !isDeepStrictEqual(oldItems.get(item.name), item) && item.bindings);
168
- if (configurationItems.length) {
169
- const directory = `apps/${context.runtimeApp}`;
170
- const file = `${directory}/${existsSync(path.join(stage, directory, 'anhedral.cloudflare.json')) ? 'anhedral.cloudflare.json' : 'wrangler.jsonc'}`;
171
- let content = readFileSync(path.join(stage, file), 'utf8');
172
- const config = parse(content);
173
- for (const item of configurationItems)
174
- for (const [key, value] of Object.entries(item.bindings)) {
175
- if (config[key] !== undefined && !isDeepStrictEqual(config[key], value))
176
- throw new Error(`Existing ${key} configuration conflicts with ${item.name}; configure it explicitly.`);
177
- content = applyEdits(content, modify(content, [key], value, {
178
- formattingOptions: { insertSpaces: true, tabSize: 2 },
179
- }));
180
- }
181
- put(stage, file, content);
182
- }
183
- scaffoldCloudflareServiceContext(context);
184
- writeStandardRoot(stage, options, registry, true);
185
- if (voidSelected) {
186
- configureVoidDelivery(stage);
187
- refreshVoidEnvironment(stage);
188
- }
189
- if (options.products.includes('next') && options.hosting === 'vercel')
190
- registerVercelApplication(stage);
191
- if ([...sourceFiles(stage).keys()].some((file) => /^apps\/[^/]+\/(?:wrangler\.jsonc|anhedral\.cloudflare\.json)$/.test(file)))
192
- registerApplication(stage, true);
193
- if (!request.dryRun)
194
- run('pnpm', ['install', '--lockfile-only', '--no-frozen-lockfile', '--ignore-scripts'], stage);
195
- if (!request.dryRun && configureDependencyPatches(stage))
196
- run('pnpm', ['install', '--lockfile-only', '--no-frozen-lockfile', '--ignore-scripts'], stage);
197
- const after = sourceFiles(stage);
198
- const files = { ...baseline };
199
- for (const [file, hash] of after) {
200
- if (before.get(file) === hash)
201
- continue;
202
- if (before.has(file) && baseline[file] !== before.get(file))
203
- conflicts.push(file);
204
- commitPaths.push(file);
205
- files[file] = hash;
206
- }
207
- const configuration = configurationFingerprints(stage);
208
- for (const [section, hash] of Object.entries(originalConfiguration)) {
209
- // Hosting registration preserves existing user fields while adding new targets.
210
- if (section !== 'cloudflare' &&
211
- hash !== receipt.configuration[section] &&
212
- configuration[section] !== hash)
213
- conflicts.push(`${PROJECT_CONFIG_FILE} (${section})`);
214
- }
215
- // Never delete preexisting source as a side effect of an addition.
216
- for (const file of before.keys())
217
- if (!after.has(file))
218
- conflicts.push(file);
219
- if (conflicts.length && !request.dryRun)
220
- throw new Error(`Addition conflicts with edited or untracked source: ${conflicts.join(', ')}. No files were installed.`);
221
- writeProjectSection(stage, 'registry', {
222
- ...registry,
223
- status: 'scaffolded',
224
- resourcesProvisioned: false,
225
- workspaces: inspectWorkspaceGraph(stage),
226
- files,
227
- configuration,
228
- });
229
- commitPaths.push(PROJECT_CONFIG_FILE);
230
- if (request.preview && result.previews) {
231
- const preview = request.preview;
232
- const selected = [...commitPaths]
233
- .filter((file) => !preview.path || preview.path === file)
234
- .sort();
235
- if (preview.path && !selected.length)
236
- throw new Error('Requested path is not a changed generated source file.');
237
- let total = 0;
238
- for (const file of selected) {
239
- const content = sourcePreview(root, stage, file, preview.mode);
240
- total += Buffer.byteLength(JSON.stringify(content));
241
- if (total > MAX_PREVIEW_TOTAL_BYTES)
242
- throw new Error('Source preview exceeds 1 MiB. Select a single file with --diff <path> or --view <path>.');
243
- result.previews.push(content);
244
- }
245
- }
246
- // Detect concurrent changes even to source that this addition would otherwise preserve.
247
- if (!isDeepStrictEqual(sourceFiles(root), before) ||
248
- readBoundedFile(path.join(root, PROJECT_CONFIG_FILE), MAX_PROJECT_JSON_BYTES).toString('utf8') !== receiptText)
249
- throw new Error('Workspace changed during addition; retry after reviewing source.');
250
- },
251
- afterCommit: () => {
252
- if (request.skipInstall)
253
- return;
254
- const lockPath = path.join(root, 'pnpm-lock.yaml');
255
- const lock = readBoundedFile(lockPath, 16 * 1024 * 1024);
256
- const modules = path.join(root, 'node_modules');
257
- const metadata = lstatSync(modules, { throwIfNoEntry: false });
258
- if (metadata && (!metadata.isDirectory() || metadata.isSymbolicLink()))
259
- throw new Error('Dependency installation requires a real project node_modules directory.');
260
- // pnpm 10 can retain skipped optional packages after a new recipe makes
261
- // them required. Rebuild generated links from the reviewed lock while
262
- // retaining the separate content-addressed package store.
263
- rmSync(modules, { recursive: true, force: true });
264
- run('pnpm', ['install', '--frozen-lockfile'], root);
265
- if (!readBoundedFile(lockPath, 16 * 1024 * 1024).equals(lock))
266
- throw new Error('Frozen dependency installation changed the reviewed lockfile; review it before continuing.');
267
- },
268
- });
269
- return result;
270
- }
@@ -1,2 +0,0 @@
1
- export declare const BOOTSTRAP_COMMAND: readonly ["pnpm", "dlx", "shadcn@4.21.4", "init", "--monorepo", "--template", "next"];
2
- export declare function bootstrapArguments(name: string, cwd: string): string[];
@@ -1,14 +0,0 @@
1
- import { SHADCN_VERSION } from '../dependencies.js';
2
- const SHADCN_PACKAGE = `shadcn@${SHADCN_VERSION}`;
3
- export const BOOTSTRAP_COMMAND = [
4
- 'pnpm',
5
- 'dlx',
6
- SHADCN_PACKAGE,
7
- 'init',
8
- '--monorepo',
9
- '--template',
10
- 'next',
11
- ];
12
- export function bootstrapArguments(name, cwd) {
13
- return [...BOOTSTRAP_COMMAND.slice(1), '--defaults', '--name', name, '--cwd', cwd];
14
- }
@@ -1,3 +0,0 @@
1
- import { type OutputOptions } from '../cli-output.js';
2
- export declare function runRegistry(args: string[], json: boolean, output?: OutputOptions): Promise<void>;
3
- export declare function runAdd(args: string[], output?: OutputOptions): Promise<void>;