@gadicc/loom 1.37.0 → 2.0.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 (834) hide show
  1. package/.loom-source-manifest.json +97 -0
  2. package/README.md +113 -31
  3. package/db/databaseTls.js +6 -3
  4. package/db/databaseUrl.js +3 -2
  5. package/db/drizzle-config.js +14 -16
  6. package/db/fixtures.d.ts +1 -3
  7. package/db/fixtures.js +4 -7
  8. package/esm/bin/loom.d.ts +2 -1
  9. package/esm/bin/loom.d.ts.map +1 -1
  10. package/esm/bin/loom.js +37 -10
  11. package/esm/bin/loom.js.map +1 -0
  12. package/esm/mod.d.ts +0 -1
  13. package/esm/mod.d.ts.map +1 -1
  14. package/esm/mod.js +1 -1
  15. package/esm/mod.js.map +1 -0
  16. package/esm/src/apiKeys/authorize.d.ts.map +1 -1
  17. package/esm/src/apiKeys/authorize.js +15 -14
  18. package/esm/src/apiKeys/authorize.js.map +1 -0
  19. package/esm/src/apiKeys/betterAuth.d.ts.map +1 -1
  20. package/esm/src/apiKeys/betterAuth.js +1 -0
  21. package/esm/src/apiKeys/betterAuth.js.map +1 -0
  22. package/esm/src/apiKeys/country.d.ts.map +1 -1
  23. package/esm/src/apiKeys/country.js +1 -0
  24. package/esm/src/apiKeys/country.js.map +1 -0
  25. package/esm/src/apiKeys/credentials.d.ts.map +1 -1
  26. package/esm/src/apiKeys/credentials.js +3 -1
  27. package/esm/src/apiKeys/credentials.js.map +1 -0
  28. package/esm/src/apiKeys/fingerprint.d.ts.map +1 -1
  29. package/esm/src/apiKeys/fingerprint.js +1 -0
  30. package/esm/src/apiKeys/fingerprint.js.map +1 -0
  31. package/esm/src/apiKeys/lifecycle.d.ts.map +1 -1
  32. package/esm/src/apiKeys/lifecycle.js +1 -0
  33. package/esm/src/apiKeys/lifecycle.js.map +1 -0
  34. package/esm/src/apiKeys/limits.d.ts.map +1 -1
  35. package/esm/src/apiKeys/limits.js +10 -10
  36. package/esm/src/apiKeys/limits.js.map +1 -0
  37. package/esm/src/apiKeys/mod.d.ts +0 -1
  38. package/esm/src/apiKeys/mod.d.ts.map +1 -1
  39. package/esm/src/apiKeys/mod.js +1 -1
  40. package/esm/src/apiKeys/mod.js.map +1 -0
  41. package/esm/src/apiKeys/permissions.d.ts.map +1 -1
  42. package/esm/src/apiKeys/permissions.js +1 -0
  43. package/esm/src/apiKeys/permissions.js.map +1 -0
  44. package/esm/src/apiKeys/policy.d.ts.map +1 -1
  45. package/esm/src/apiKeys/policy.js +1 -0
  46. package/esm/src/apiKeys/policy.js.map +1 -0
  47. package/esm/src/apiKeys/retention.d.ts.map +1 -1
  48. package/esm/src/apiKeys/retention.js +1 -0
  49. package/esm/src/apiKeys/retention.js.map +1 -0
  50. package/esm/src/apiKeys/types.d.ts.map +1 -1
  51. package/esm/src/apiKeys/types.js +1 -0
  52. package/esm/src/apiKeys/types.js.map +1 -0
  53. package/esm/src/cli/atomicText.d.ts +3 -0
  54. package/esm/src/cli/atomicText.d.ts.map +1 -0
  55. package/esm/src/cli/atomicText.js +33 -0
  56. package/esm/src/cli/atomicText.js.map +1 -0
  57. package/esm/src/cli/bunLocalDev.d.ts +65 -0
  58. package/esm/src/cli/bunLocalDev.d.ts.map +1 -0
  59. package/esm/src/cli/bunLocalDev.js +459 -0
  60. package/esm/src/cli/bunLocalDev.js.map +1 -0
  61. package/esm/src/cli/bunProject.d.ts +30 -0
  62. package/esm/src/cli/bunProject.d.ts.map +1 -0
  63. package/esm/src/cli/bunProject.js +309 -0
  64. package/esm/src/cli/bunProject.js.map +1 -0
  65. package/esm/src/cli/cliBootstrap.d.ts +83 -0
  66. package/esm/src/cli/cliBootstrap.d.ts.map +1 -0
  67. package/esm/src/cli/cliBootstrap.js +186 -0
  68. package/esm/src/cli/cliBootstrap.js.map +1 -0
  69. package/esm/src/cli/externalSkills.d.ts.map +1 -1
  70. package/esm/src/cli/externalSkills.js +9 -5
  71. package/esm/src/cli/externalSkills.js.map +1 -0
  72. package/esm/src/cli/filesR2Policy.d.ts.map +1 -1
  73. package/esm/src/cli/filesR2Policy.js +18 -11
  74. package/esm/src/cli/filesR2Policy.js.map +1 -0
  75. package/esm/src/cli/generatedBuild.d.ts +42 -0
  76. package/esm/src/cli/generatedBuild.d.ts.map +1 -0
  77. package/esm/src/cli/generatedBuild.js +259 -0
  78. package/esm/src/cli/generatedBuild.js.map +1 -0
  79. package/esm/src/cli/generatedCleanup.d.ts +7 -0
  80. package/esm/src/cli/generatedCleanup.d.ts.map +1 -0
  81. package/esm/src/cli/generatedCleanup.js +67 -0
  82. package/esm/src/cli/generatedCleanup.js.map +1 -0
  83. package/esm/src/cli/generatedDevLease.d.ts +8 -0
  84. package/esm/src/cli/generatedDevLease.d.ts.map +1 -0
  85. package/esm/src/cli/generatedDevLease.js +39 -0
  86. package/esm/src/cli/generatedDevLease.js.map +1 -0
  87. package/esm/src/cli/generatedInstall.d.ts +64 -0
  88. package/esm/src/cli/generatedInstall.d.ts.map +1 -0
  89. package/esm/src/cli/generatedInstall.js +466 -0
  90. package/esm/src/cli/generatedInstall.js.map +1 -0
  91. package/esm/src/cli/generatedWorkflow.d.ts +34 -0
  92. package/esm/src/cli/generatedWorkflow.d.ts.map +1 -0
  93. package/esm/src/cli/generatedWorkflow.js +85 -0
  94. package/esm/src/cli/generatedWorkflow.js.map +1 -0
  95. package/esm/src/cli/legacyManagedOutputs.d.ts.map +1 -1
  96. package/esm/src/cli/legacyManagedOutputs.js +1 -0
  97. package/esm/src/cli/legacyManagedOutputs.js.map +1 -0
  98. package/esm/src/cli/localDb.d.ts.map +1 -1
  99. package/esm/src/cli/localDb.js +35 -30
  100. package/esm/src/cli/localDb.js.map +1 -0
  101. package/esm/src/cli/localDevLock.d.ts +9 -0
  102. package/esm/src/cli/localDevLock.d.ts.map +1 -1
  103. package/esm/src/cli/localDevLock.js +54 -13
  104. package/esm/src/cli/localDevLock.js.map +1 -0
  105. package/esm/src/cli/localDevPackage.d.ts +6 -11
  106. package/esm/src/cli/localDevPackage.d.ts.map +1 -1
  107. package/esm/src/cli/localDevPackage.js +51 -48
  108. package/esm/src/cli/localDevPackage.js.map +1 -0
  109. package/esm/src/cli/managedFiles.d.ts.map +1 -1
  110. package/esm/src/cli/managedFiles.js +34 -18
  111. package/esm/src/cli/managedFiles.js.map +1 -0
  112. package/esm/src/cli/migrationEnv.d.ts +16 -3
  113. package/esm/src/cli/migrationEnv.d.ts.map +1 -1
  114. package/esm/src/cli/migrationEnv.js +9 -6
  115. package/esm/src/cli/migrationEnv.js.map +1 -0
  116. package/esm/src/cli/mod.d.ts +20 -7
  117. package/esm/src/cli/mod.d.ts.map +1 -1
  118. package/esm/src/cli/mod.js +2148 -730
  119. package/esm/src/cli/mod.js.map +1 -0
  120. package/esm/src/cli/packageTreeSignature.d.ts +8 -0
  121. package/esm/src/cli/packageTreeSignature.d.ts.map +1 -0
  122. package/esm/src/cli/packageTreeSignature.js +60 -0
  123. package/esm/src/cli/packageTreeSignature.js.map +1 -0
  124. package/esm/src/cli/processIdentity.d.ts +7 -0
  125. package/esm/src/cli/processIdentity.d.ts.map +1 -0
  126. package/esm/src/cli/processIdentity.js +39 -0
  127. package/esm/src/cli/processIdentity.js.map +1 -0
  128. package/esm/src/cli/projectSkills.d.ts +1 -1
  129. package/esm/src/cli/projectSkills.d.ts.map +1 -1
  130. package/esm/src/cli/projectSkills.js +31 -23
  131. package/esm/src/cli/projectSkills.js.map +1 -0
  132. package/esm/src/cli/projectTooling.d.ts +6 -3
  133. package/esm/src/cli/projectTooling.d.ts.map +1 -1
  134. package/esm/src/cli/projectTooling.js +86 -41
  135. package/esm/src/cli/projectTooling.js.map +1 -0
  136. package/esm/src/cli/releaseConfig.d.ts.map +1 -1
  137. package/esm/src/cli/releaseConfig.js +5 -3
  138. package/esm/src/cli/releaseConfig.js.map +1 -0
  139. package/esm/src/cli/releaseCredentials.d.ts.map +1 -1
  140. package/esm/src/cli/releaseCredentials.js +19 -31
  141. package/esm/src/cli/releaseCredentials.js.map +1 -0
  142. package/esm/src/cli/releaseTrust.d.ts.map +1 -1
  143. package/esm/src/cli/releaseTrust.js +11 -4
  144. package/esm/src/cli/releaseTrust.js.map +1 -0
  145. package/esm/src/cli/releaseTrustCommand.d.ts.map +1 -1
  146. package/esm/src/cli/releaseTrustCommand.js +6 -4
  147. package/esm/src/cli/releaseTrustCommand.js.map +1 -0
  148. package/esm/src/cli/sourceConfig.d.ts +3 -0
  149. package/esm/src/cli/sourceConfig.d.ts.map +1 -0
  150. package/esm/src/cli/sourceConfig.js +91 -0
  151. package/esm/src/cli/sourceConfig.js.map +1 -0
  152. package/esm/src/cli/sourceDev.d.ts +77 -0
  153. package/esm/src/cli/sourceDev.d.ts.map +1 -0
  154. package/esm/src/cli/sourceDev.js +974 -0
  155. package/esm/src/cli/sourceDev.js.map +1 -0
  156. package/esm/src/cli/vercelBuildEnv.d.ts.map +1 -1
  157. package/esm/src/cli/vercelBuildEnv.js +44 -21
  158. package/esm/src/cli/vercelBuildEnv.js.map +1 -0
  159. package/esm/src/cli/vercelEnvMask.d.ts +38 -0
  160. package/esm/src/cli/vercelEnvMask.d.ts.map +1 -0
  161. package/esm/src/cli/vercelEnvMask.js +140 -0
  162. package/esm/src/cli/vercelEnvMask.js.map +1 -0
  163. package/esm/src/cli/vercelProjectRelease.d.ts.map +1 -1
  164. package/esm/src/cli/vercelProjectRelease.js +47 -24
  165. package/esm/src/cli/vercelProjectRelease.js.map +1 -0
  166. package/esm/src/cli/vercelPulledEnv.d.ts +65 -0
  167. package/esm/src/cli/vercelPulledEnv.d.ts.map +1 -0
  168. package/esm/src/cli/vercelPulledEnv.js +133 -0
  169. package/esm/src/cli/vercelPulledEnv.js.map +1 -0
  170. package/esm/src/clientData/identity.d.ts.map +1 -1
  171. package/esm/src/clientData/identity.js +1 -0
  172. package/esm/src/clientData/identity.js.map +1 -0
  173. package/esm/src/clientData/mod.d.ts +0 -1
  174. package/esm/src/clientData/mod.d.ts.map +1 -1
  175. package/esm/src/clientData/mod.js +1 -0
  176. package/esm/src/clientData/mod.js.map +1 -0
  177. package/esm/src/files/client.d.ts +1 -1
  178. package/esm/src/files/client.d.ts.map +1 -1
  179. package/esm/src/files/client.js +3 -4
  180. package/esm/src/files/client.js.map +1 -0
  181. package/esm/src/files/errors.d.ts.map +1 -1
  182. package/esm/src/files/errors.js +3 -12
  183. package/esm/src/files/errors.js.map +1 -0
  184. package/esm/src/files/hash.d.ts +1 -1
  185. package/esm/src/files/hash.d.ts.map +1 -1
  186. package/esm/src/files/hash.js +1 -0
  187. package/esm/src/files/hash.js.map +1 -0
  188. package/esm/src/files/memory.d.ts.map +1 -1
  189. package/esm/src/files/memory.js +2 -1
  190. package/esm/src/files/memory.js.map +1 -0
  191. package/esm/src/files/metadata.d.ts.map +1 -1
  192. package/esm/src/files/metadata.js +11 -18
  193. package/esm/src/files/metadata.js.map +1 -0
  194. package/esm/src/files/mod.d.ts +0 -1
  195. package/esm/src/files/mod.d.ts.map +1 -1
  196. package/esm/src/files/mod.js +1 -1
  197. package/esm/src/files/mod.js.map +1 -0
  198. package/esm/src/files/s3.d.ts.map +1 -1
  199. package/esm/src/files/s3.js +6 -4
  200. package/esm/src/files/s3.js.map +1 -0
  201. package/esm/src/files/service.d.ts.map +1 -1
  202. package/esm/src/files/service.js +3 -4
  203. package/esm/src/files/service.js.map +1 -0
  204. package/esm/src/files/types.d.ts.map +1 -1
  205. package/esm/src/files/types.js +1 -0
  206. package/esm/src/files/types.js.map +1 -0
  207. package/esm/src/jobs/catalog.d.ts.map +1 -1
  208. package/esm/src/jobs/catalog.js +5 -1
  209. package/esm/src/jobs/catalog.js.map +1 -0
  210. package/esm/src/jobs/controller.d.ts +1 -1
  211. package/esm/src/jobs/controller.d.ts.map +1 -1
  212. package/esm/src/jobs/controller.js +11 -55
  213. package/esm/src/jobs/controller.js.map +1 -0
  214. package/esm/src/jobs/direct.d.ts.map +1 -1
  215. package/esm/src/jobs/direct.js +3 -3
  216. package/esm/src/jobs/direct.js.map +1 -0
  217. package/esm/src/jobs/events.d.ts.map +1 -1
  218. package/esm/src/jobs/events.js +1 -0
  219. package/esm/src/jobs/events.js.map +1 -0
  220. package/esm/src/jobs/format.d.ts +5 -5
  221. package/esm/src/jobs/format.d.ts.map +1 -1
  222. package/esm/src/jobs/format.js +2 -1
  223. package/esm/src/jobs/format.js.map +1 -0
  224. package/esm/src/jobs/http.d.ts +3 -3
  225. package/esm/src/jobs/http.d.ts.map +1 -1
  226. package/esm/src/jobs/http.js +1 -0
  227. package/esm/src/jobs/http.js.map +1 -0
  228. package/esm/src/jobs/log.d.ts.map +1 -1
  229. package/esm/src/jobs/log.js +1 -0
  230. package/esm/src/jobs/log.js.map +1 -0
  231. package/esm/src/jobs/mod.d.ts.map +1 -1
  232. package/esm/src/jobs/mod.js +1 -0
  233. package/esm/src/jobs/mod.js.map +1 -0
  234. package/esm/src/jobs/run.d.ts.map +1 -1
  235. package/esm/src/jobs/run.js +1 -0
  236. package/esm/src/jobs/run.js.map +1 -0
  237. package/esm/src/jobs/sanitize.d.ts.map +1 -1
  238. package/esm/src/jobs/sanitize.js +1 -0
  239. package/esm/src/jobs/sanitize.js.map +1 -0
  240. package/esm/src/jobs/types.d.ts +1 -0
  241. package/esm/src/jobs/types.d.ts.map +1 -1
  242. package/esm/src/jobs/types.js +1 -0
  243. package/esm/src/jobs/types.js.map +1 -0
  244. package/esm/src/mail/errors.d.ts.map +1 -1
  245. package/esm/src/mail/errors.js +8 -42
  246. package/esm/src/mail/errors.js.map +1 -0
  247. package/esm/src/mail/memory.d.ts +1 -1
  248. package/esm/src/mail/memory.d.ts.map +1 -1
  249. package/esm/src/mail/memory.js +10 -14
  250. package/esm/src/mail/memory.js.map +1 -0
  251. package/esm/src/mail/mod.d.ts +0 -1
  252. package/esm/src/mail/mod.d.ts.map +1 -1
  253. package/esm/src/mail/mod.js +1 -1
  254. package/esm/src/mail/mod.js.map +1 -0
  255. package/esm/src/mail/postal.d.ts +1 -2
  256. package/esm/src/mail/postal.d.ts.map +1 -1
  257. package/esm/src/mail/postal.js +22 -18
  258. package/esm/src/mail/postal.js.map +1 -0
  259. package/esm/src/mail/retry.d.ts.map +1 -1
  260. package/esm/src/mail/retry.js +1 -0
  261. package/esm/src/mail/retry.js.map +1 -0
  262. package/esm/src/mail/sender.d.ts.map +1 -1
  263. package/esm/src/mail/sender.js +1 -0
  264. package/esm/src/mail/sender.js.map +1 -0
  265. package/esm/src/mail/service.d.ts.map +1 -1
  266. package/esm/src/mail/service.js +6 -7
  267. package/esm/src/mail/service.js.map +1 -0
  268. package/esm/src/mail/types.d.ts.map +1 -1
  269. package/esm/src/mail/types.js +1 -0
  270. package/esm/src/mail/types.js.map +1 -0
  271. package/esm/src/mui/apiKeys.d.ts +10 -11
  272. package/esm/src/mui/apiKeys.d.ts.map +1 -1
  273. package/esm/src/mui/apiKeys.js +83 -214
  274. package/esm/src/mui/apiKeys.js.map +1 -0
  275. package/esm/src/mui/apiKeysView.d.ts +1 -1
  276. package/esm/src/mui/apiKeysView.d.ts.map +1 -1
  277. package/esm/src/mui/apiKeysView.js +11 -9
  278. package/esm/src/mui/apiKeysView.js.map +1 -0
  279. package/esm/src/mui/confirm.d.ts +2 -2
  280. package/esm/src/mui/confirm.d.ts.map +1 -1
  281. package/esm/src/mui/confirm.js +3 -7
  282. package/esm/src/mui/confirm.js.map +1 -0
  283. package/esm/src/mui/mail.d.ts +4 -4
  284. package/esm/src/mui/mail.d.ts.map +1 -1
  285. package/esm/src/mui/mail.js +11 -71
  286. package/esm/src/mui/mail.js.map +1 -0
  287. package/esm/src/mui/mailView.d.ts +1 -1
  288. package/esm/src/mui/mailView.d.ts.map +1 -1
  289. package/esm/src/mui/mailView.js +1 -0
  290. package/esm/src/mui/mailView.js.map +1 -0
  291. package/esm/src/mui/mod.d.ts +0 -1
  292. package/esm/src/mui/mod.d.ts.map +1 -1
  293. package/esm/src/mui/mod.js +1 -0
  294. package/esm/src/mui/mod.js.map +1 -0
  295. package/esm/src/next/apiKeys/mod.d.ts +2 -3
  296. package/esm/src/next/apiKeys/mod.d.ts.map +1 -1
  297. package/esm/src/next/apiKeys/mod.js +6 -5
  298. package/esm/src/next/apiKeys/mod.js.map +1 -0
  299. package/esm/src/next/auth/client.d.ts +0 -1
  300. package/esm/src/next/auth/client.d.ts.map +1 -1
  301. package/esm/src/next/auth/client.js +1 -0
  302. package/esm/src/next/auth/client.js.map +1 -0
  303. package/esm/src/next/auth/config.d.ts.map +1 -1
  304. package/esm/src/next/auth/config.js +11 -17
  305. package/esm/src/next/auth/config.js.map +1 -0
  306. package/esm/src/next/auth/localTestLogin.d.ts.map +1 -1
  307. package/esm/src/next/auth/localTestLogin.js +13 -9
  308. package/esm/src/next/auth/localTestLogin.js.map +1 -0
  309. package/esm/src/next/auth/mod.d.ts.map +1 -1
  310. package/esm/src/next/auth/mod.js +1 -0
  311. package/esm/src/next/auth/mod.js.map +1 -0
  312. package/esm/src/next/auth/server.d.ts +2 -2
  313. package/esm/src/next/auth/server.d.ts.map +1 -1
  314. package/esm/src/next/auth/server.js +1 -0
  315. package/esm/src/next/auth/server.js.map +1 -0
  316. package/esm/src/next/files/mod.d.ts +0 -1
  317. package/esm/src/next/files/mod.d.ts.map +1 -1
  318. package/esm/src/next/files/mod.js +1 -1
  319. package/esm/src/next/files/mod.js.map +1 -0
  320. package/esm/src/next/files/route.d.ts +1 -1
  321. package/esm/src/next/files/route.d.ts.map +1 -1
  322. package/esm/src/next/files/route.js +11 -11
  323. package/esm/src/next/files/route.js.map +1 -0
  324. package/esm/src/next/jobs/list.d.ts +5 -5
  325. package/esm/src/next/jobs/list.d.ts.map +1 -1
  326. package/esm/src/next/jobs/list.js +15 -19
  327. package/esm/src/next/jobs/list.js.map +1 -0
  328. package/esm/src/next/jobs/mod.d.ts.map +1 -1
  329. package/esm/src/next/jobs/mod.js +1 -0
  330. package/esm/src/next/jobs/mod.js.map +1 -0
  331. package/esm/src/next/jobs/paths.d.ts +2 -2
  332. package/esm/src/next/jobs/paths.d.ts.map +1 -1
  333. package/esm/src/next/jobs/paths.js +1 -0
  334. package/esm/src/next/jobs/paths.js.map +1 -0
  335. package/esm/src/next/jobs/route.d.ts +2 -2
  336. package/esm/src/next/jobs/route.d.ts.map +1 -1
  337. package/esm/src/next/jobs/route.js +4 -4
  338. package/esm/src/next/jobs/route.js.map +1 -0
  339. package/esm/src/next/jobs/run.d.ts +2 -2
  340. package/esm/src/next/jobs/run.d.ts.map +1 -1
  341. package/esm/src/next/jobs/run.js +68 -132
  342. package/esm/src/next/jobs/run.js.map +1 -0
  343. package/esm/src/next/jobs/runRequest.d.ts +1 -1
  344. package/esm/src/next/jobs/runRequest.d.ts.map +1 -1
  345. package/esm/src/next/jobs/runRequest.js +3 -4
  346. package/esm/src/next/jobs/runRequest.js.map +1 -0
  347. package/esm/src/next/jobs/stream.d.ts.map +1 -1
  348. package/esm/src/next/jobs/stream.js +1 -0
  349. package/esm/src/next/jobs/stream.js.map +1 -0
  350. package/esm/src/next/mail/mod.d.ts +0 -1
  351. package/esm/src/next/mail/mod.d.ts.map +1 -1
  352. package/esm/src/next/mail/mod.js +1 -1
  353. package/esm/src/next/mail/mod.js.map +1 -0
  354. package/esm/src/next/mail/route.d.ts +2 -2
  355. package/esm/src/next/mail/route.d.ts.map +1 -1
  356. package/esm/src/next/mail/route.js +1 -0
  357. package/esm/src/next/mail/route.js.map +1 -0
  358. package/esm/src/next/pwa/mod.d.ts +0 -4
  359. package/esm/src/next/pwa/mod.d.ts.map +1 -1
  360. package/esm/src/next/pwa/mod.js +32 -16
  361. package/esm/src/next/pwa/mod.js.map +1 -0
  362. package/esm/src/next/pwa/worker.d.ts +0 -1
  363. package/esm/src/next/pwa/worker.d.ts.map +1 -1
  364. package/esm/src/next/pwa/worker.js +1 -0
  365. package/esm/src/next/pwa/worker.js.map +1 -0
  366. package/esm/src/next/secrets/constants.d.ts +3 -0
  367. package/esm/src/next/secrets/constants.d.ts.map +1 -0
  368. package/esm/src/next/secrets/constants.js +3 -0
  369. package/esm/src/next/secrets/constants.js.map +1 -0
  370. package/esm/src/next/secrets/mod.d.ts +1 -3
  371. package/esm/src/next/secrets/mod.d.ts.map +1 -1
  372. package/esm/src/next/secrets/mod.js +6 -7
  373. package/esm/src/next/secrets/mod.js.map +1 -0
  374. package/esm/src/next/sourceDev.d.ts +6 -0
  375. package/esm/src/next/sourceDev.d.ts.map +1 -0
  376. package/esm/src/next/sourceDev.js +41 -0
  377. package/esm/src/next/sourceDev.js.map +1 -0
  378. package/esm/src/secrets/encoding.d.ts.map +1 -1
  379. package/esm/src/secrets/encoding.js +1 -0
  380. package/esm/src/secrets/encoding.js.map +1 -0
  381. package/esm/src/secrets/errors.d.ts.map +1 -1
  382. package/esm/src/secrets/errors.js +3 -7
  383. package/esm/src/secrets/errors.js.map +1 -0
  384. package/esm/src/secrets/fingerprint.d.ts.map +1 -1
  385. package/esm/src/secrets/fingerprint.js +1 -0
  386. package/esm/src/secrets/fingerprint.js.map +1 -0
  387. package/esm/src/secrets/frame.d.ts.map +1 -1
  388. package/esm/src/secrets/frame.js +4 -3
  389. package/esm/src/secrets/frame.js.map +1 -0
  390. package/esm/src/secrets/keyring.d.ts.map +1 -1
  391. package/esm/src/secrets/keyring.js +6 -6
  392. package/esm/src/secrets/keyring.js.map +1 -0
  393. package/esm/src/secrets/legacy.d.ts +0 -1
  394. package/esm/src/secrets/legacy.d.ts.map +1 -1
  395. package/esm/src/secrets/legacy.js +13 -10
  396. package/esm/src/secrets/legacy.js.map +1 -0
  397. package/esm/src/secrets/maintenance.d.ts +0 -1
  398. package/esm/src/secrets/maintenance.d.ts.map +1 -1
  399. package/esm/src/secrets/maintenance.js +9 -24
  400. package/esm/src/secrets/maintenance.js.map +1 -0
  401. package/esm/src/secrets/mod.d.ts +0 -1
  402. package/esm/src/secrets/mod.d.ts.map +1 -1
  403. package/esm/src/secrets/mod.js +1 -1
  404. package/esm/src/secrets/mod.js.map +1 -0
  405. package/esm/src/secrets/secrets.d.ts.map +1 -1
  406. package/esm/src/secrets/secrets.js +38 -30
  407. package/esm/src/secrets/secrets.js.map +1 -0
  408. package/package.json +111 -135
  409. package/skills/loom/SKILL.md +40 -5
  410. package/skills/loom/references/dependency-upgrades.md +4 -0
  411. package/skills/loom/references/esm-package.md +35 -0
  412. package/skills/loom/references/local-development.md +261 -29
  413. package/skills/loom/references/release-safety.md +10 -3
  414. package/skills/loom-auth/references/secrets-and-rotation.md +2 -1
  415. package/skills/loom-mail/SKILL.md +1 -0
  416. package/skills/loom-scaffold/references/greenfield-workflow.md +2 -1
  417. package/skills/upgrade-deps/SKILL.md +4 -2
  418. package/source/bin/loom.ts +50 -0
  419. package/source/mod.ts +10 -0
  420. package/source/src/apiKeys/authorize.ts +294 -0
  421. package/source/src/apiKeys/betterAuth.ts +253 -0
  422. package/source/src/apiKeys/country.ts +7 -0
  423. package/source/src/apiKeys/credentials.ts +171 -0
  424. package/source/src/apiKeys/fingerprint.ts +10 -0
  425. package/{script/src/apiKeys/lifecycle.d.ts → source/src/apiKeys/lifecycle.ts} +21 -23
  426. package/source/src/apiKeys/limits.ts +372 -0
  427. package/source/src/apiKeys/mod.ts +11 -0
  428. package/source/src/apiKeys/permissions.ts +153 -0
  429. package/source/src/apiKeys/policy.ts +189 -0
  430. package/source/src/apiKeys/retention.ts +136 -0
  431. package/source/src/apiKeys/types.ts +288 -0
  432. package/source/src/cli/atomicText.ts +38 -0
  433. package/source/src/cli/bunLocalDev.ts +646 -0
  434. package/source/src/cli/bunProject.ts +433 -0
  435. package/source/src/cli/cliBootstrap.ts +313 -0
  436. package/source/src/cli/externalSkills.ts +315 -0
  437. package/source/src/cli/filesR2Policy.ts +212 -0
  438. package/source/src/cli/generatedBuild.ts +380 -0
  439. package/source/src/cli/generatedCleanup.ts +87 -0
  440. package/source/src/cli/generatedDevLease.ts +52 -0
  441. package/source/src/cli/generatedInstall.ts +630 -0
  442. package/source/src/cli/generatedWorkflow.ts +135 -0
  443. package/{script/src/cli/legacyManagedOutputs.js → source/src/cli/legacyManagedOutputs.ts} +36 -30
  444. package/source/src/cli/localDb.ts +548 -0
  445. package/source/src/cli/localDevLock.ts +462 -0
  446. package/source/src/cli/localDevPackage.ts +754 -0
  447. package/source/src/cli/managedFiles.ts +688 -0
  448. package/source/src/cli/migrationEnv.ts +267 -0
  449. package/source/src/cli/mod.ts +26788 -0
  450. package/source/src/cli/packageTreeSignature.ts +65 -0
  451. package/source/src/cli/processIdentity.ts +38 -0
  452. package/source/src/cli/projectSkills.ts +1102 -0
  453. package/source/src/cli/projectTooling.ts +1140 -0
  454. package/source/src/cli/releaseConfig.ts +36 -0
  455. package/source/src/cli/releaseCredentials.ts +642 -0
  456. package/source/src/cli/releaseTrust.ts +194 -0
  457. package/source/src/cli/releaseTrustCommand.ts +210 -0
  458. package/source/src/cli/sourceConfig.ts +106 -0
  459. package/source/src/cli/sourceDev.ts +1279 -0
  460. package/source/src/cli/vercelBuildEnv.ts +714 -0
  461. package/source/src/cli/vercelEnvMask.ts +182 -0
  462. package/source/src/cli/vercelProjectRelease.ts +807 -0
  463. package/source/src/cli/vercelPulledEnv.ts +174 -0
  464. package/source/src/clientData/identity.ts +229 -0
  465. package/source/src/clientData/mod.ts +1 -0
  466. package/source/src/files/client.ts +75 -0
  467. package/source/src/files/errors.ts +69 -0
  468. package/source/src/files/hash.ts +109 -0
  469. package/source/src/files/memory.ts +158 -0
  470. package/source/src/files/metadata.ts +251 -0
  471. package/source/src/files/mod.ts +8 -0
  472. package/source/src/files/s3.ts +182 -0
  473. package/source/src/files/service.ts +210 -0
  474. package/source/src/files/types.ts +171 -0
  475. package/source/src/jobs/catalog.ts +303 -0
  476. package/source/src/jobs/controller.ts +156 -0
  477. package/source/src/jobs/direct.ts +177 -0
  478. package/source/src/jobs/events.ts +74 -0
  479. package/source/src/jobs/format.ts +233 -0
  480. package/source/src/jobs/http.ts +83 -0
  481. package/source/src/jobs/log.ts +10 -0
  482. package/source/src/jobs/mod.ts +10 -0
  483. package/source/src/jobs/run.ts +141 -0
  484. package/source/src/jobs/sanitize.ts +142 -0
  485. package/source/src/jobs/types.ts +43 -0
  486. package/source/src/mail/errors.ts +77 -0
  487. package/source/src/mail/memory.ts +451 -0
  488. package/source/src/mail/mod.ts +5 -0
  489. package/source/src/mail/postal.ts +363 -0
  490. package/source/src/mail/retry.ts +30 -0
  491. package/source/src/mail/sender.ts +57 -0
  492. package/source/src/mail/service.ts +252 -0
  493. package/source/src/mail/types.ts +229 -0
  494. package/source/src/mui/apiKeys.tsx +1044 -0
  495. package/source/src/mui/apiKeysView.ts +535 -0
  496. package/source/src/mui/confirm.tsx +138 -0
  497. package/source/src/mui/mail.tsx +279 -0
  498. package/source/src/mui/mailView.ts +50 -0
  499. package/source/src/mui/mod.ts +3 -0
  500. package/source/src/next/apiKeys/mod.ts +393 -0
  501. package/{script/src/next/auth/client.d.ts → source/src/next/auth/client.ts} +19 -5
  502. package/source/src/next/auth/config.ts +207 -0
  503. package/source/src/next/auth/localTestLogin.ts +412 -0
  504. package/source/src/next/auth/mod.ts +3 -0
  505. package/source/src/next/auth/server.ts +94 -0
  506. package/source/src/next/files/mod.ts +1 -0
  507. package/source/src/next/files/route.ts +621 -0
  508. package/source/src/next/jobs/list.tsx +90 -0
  509. package/source/src/next/jobs/mod.ts +5 -0
  510. package/source/src/next/jobs/paths.ts +70 -0
  511. package/source/src/next/jobs/route.ts +207 -0
  512. package/source/src/next/jobs/run.tsx +888 -0
  513. package/source/src/next/jobs/runRequest.ts +92 -0
  514. package/source/src/next/jobs/stream.ts +33 -0
  515. package/source/src/next/mail/mod.ts +1 -0
  516. package/source/src/next/mail/route.ts +75 -0
  517. package/source/src/next/pwa/mod.tsx +453 -0
  518. package/source/src/next/pwa/worker.ts +59 -0
  519. package/source/src/next/secrets/constants.ts +2 -0
  520. package/source/src/next/secrets/mod.ts +319 -0
  521. package/source/src/next/sourceDev.ts +50 -0
  522. package/source/src/secrets/encoding.ts +102 -0
  523. package/source/src/secrets/errors.ts +58 -0
  524. package/source/src/secrets/fingerprint.ts +132 -0
  525. package/source/src/secrets/frame.ts +119 -0
  526. package/source/src/secrets/keyring.ts +225 -0
  527. package/source/src/secrets/legacy.ts +244 -0
  528. package/source/src/secrets/maintenance.ts +517 -0
  529. package/source/src/secrets/mod.ts +38 -0
  530. package/source/src/secrets/secrets.ts +926 -0
  531. package/db/databaseTls.test.ts +0 -171
  532. package/db/databaseUrl.test.ts +0 -72
  533. package/db/neonEndpoint.test.ts +0 -51
  534. package/db/testing.test.ts +0 -28
  535. package/deno.json +0 -3
  536. package/esm/_dnt.polyfills.d.ts +0 -166
  537. package/esm/_dnt.polyfills.d.ts.map +0 -1
  538. package/esm/_dnt.polyfills.js +0 -177
  539. package/esm/_dnt.shims.d.ts +0 -2
  540. package/esm/_dnt.shims.d.ts.map +0 -1
  541. package/esm/_dnt.shims.js +0 -57
  542. package/esm/package.json +0 -3
  543. package/script/_dnt.polyfills.d.ts +0 -166
  544. package/script/_dnt.polyfills.d.ts.map +0 -1
  545. package/script/_dnt.polyfills.js +0 -180
  546. package/script/_dnt.shims.d.ts +0 -2
  547. package/script/_dnt.shims.d.ts.map +0 -1
  548. package/script/_dnt.shims.js +0 -60
  549. package/script/bin/loom.d.ts +0 -2
  550. package/script/bin/loom.d.ts.map +0 -1
  551. package/script/bin/loom.js +0 -17
  552. package/script/mod.d.ts +0 -12
  553. package/script/mod.d.ts.map +0 -1
  554. package/script/mod.js +0 -27
  555. package/script/package.json +0 -3
  556. package/script/src/apiKeys/authorize.d.ts +0 -4
  557. package/script/src/apiKeys/authorize.d.ts.map +0 -1
  558. package/script/src/apiKeys/authorize.js +0 -258
  559. package/script/src/apiKeys/betterAuth.d.ts +0 -123
  560. package/script/src/apiKeys/betterAuth.d.ts.map +0 -1
  561. package/script/src/apiKeys/betterAuth.js +0 -169
  562. package/script/src/apiKeys/country.d.ts +0 -3
  563. package/script/src/apiKeys/country.d.ts.map +0 -1
  564. package/script/src/apiKeys/country.js +0 -10
  565. package/script/src/apiKeys/credentials.d.ts +0 -39
  566. package/script/src/apiKeys/credentials.d.ts.map +0 -1
  567. package/script/src/apiKeys/credentials.js +0 -121
  568. package/script/src/apiKeys/fingerprint.d.ts +0 -3
  569. package/script/src/apiKeys/fingerprint.d.ts.map +0 -1
  570. package/script/src/apiKeys/fingerprint.js +0 -8
  571. package/script/src/apiKeys/lifecycle.d.ts.map +0 -1
  572. package/script/src/apiKeys/lifecycle.js +0 -7
  573. package/script/src/apiKeys/limits.d.ts +0 -132
  574. package/script/src/apiKeys/limits.d.ts.map +0 -1
  575. package/script/src/apiKeys/limits.js +0 -254
  576. package/script/src/apiKeys/mod.d.ts +0 -13
  577. package/script/src/apiKeys/mod.d.ts.map +0 -1
  578. package/script/src/apiKeys/mod.js +0 -28
  579. package/script/src/apiKeys/permissions.d.ts +0 -56
  580. package/script/src/apiKeys/permissions.d.ts.map +0 -1
  581. package/script/src/apiKeys/permissions.js +0 -136
  582. package/script/src/apiKeys/policy.d.ts +0 -61
  583. package/script/src/apiKeys/policy.d.ts.map +0 -1
  584. package/script/src/apiKeys/policy.js +0 -94
  585. package/script/src/apiKeys/retention.d.ts +0 -55
  586. package/script/src/apiKeys/retention.d.ts.map +0 -1
  587. package/script/src/apiKeys/retention.js +0 -70
  588. package/script/src/apiKeys/types.d.ts +0 -242
  589. package/script/src/apiKeys/types.d.ts.map +0 -1
  590. package/script/src/apiKeys/types.js +0 -2
  591. package/script/src/cli/externalSkills.d.ts +0 -39
  592. package/script/src/cli/externalSkills.d.ts.map +0 -1
  593. package/script/src/cli/externalSkills.js +0 -204
  594. package/script/src/cli/filesR2Policy.d.ts +0 -33
  595. package/script/src/cli/filesR2Policy.d.ts.map +0 -1
  596. package/script/src/cli/filesR2Policy.js +0 -135
  597. package/script/src/cli/legacyManagedOutputs.d.ts +0 -33
  598. package/script/src/cli/legacyManagedOutputs.d.ts.map +0 -1
  599. package/script/src/cli/localDb.d.ts +0 -28
  600. package/script/src/cli/localDb.d.ts.map +0 -1
  601. package/script/src/cli/localDb.js +0 -370
  602. package/script/src/cli/localDevLock.d.ts +0 -97
  603. package/script/src/cli/localDevLock.d.ts.map +0 -1
  604. package/script/src/cli/localDevLock.js +0 -320
  605. package/script/src/cli/localDevPackage.d.ts +0 -172
  606. package/script/src/cli/localDevPackage.d.ts.map +0 -1
  607. package/script/src/cli/localDevPackage.js +0 -635
  608. package/script/src/cli/managedFiles.d.ts +0 -131
  609. package/script/src/cli/managedFiles.d.ts.map +0 -1
  610. package/script/src/cli/managedFiles.js +0 -536
  611. package/script/src/cli/migrationEnv.d.ts +0 -63
  612. package/script/src/cli/migrationEnv.d.ts.map +0 -1
  613. package/script/src/cli/migrationEnv.js +0 -217
  614. package/script/src/cli/mod.d.ts +0 -581
  615. package/script/src/cli/mod.d.ts.map +0 -1
  616. package/script/src/cli/mod.js +0 -16850
  617. package/script/src/cli/projectSkills.d.ts +0 -109
  618. package/script/src/cli/projectSkills.d.ts.map +0 -1
  619. package/script/src/cli/projectSkills.js +0 -749
  620. package/script/src/cli/projectTooling.d.ts +0 -164
  621. package/script/src/cli/projectTooling.d.ts.map +0 -1
  622. package/script/src/cli/projectTooling.js +0 -847
  623. package/script/src/cli/releaseConfig.d.ts +0 -10
  624. package/script/src/cli/releaseConfig.d.ts.map +0 -1
  625. package/script/src/cli/releaseConfig.js +0 -26
  626. package/script/src/cli/releaseCredentials.d.ts +0 -32
  627. package/script/src/cli/releaseCredentials.d.ts.map +0 -1
  628. package/script/src/cli/releaseCredentials.js +0 -392
  629. package/script/src/cli/releaseTrust.d.ts +0 -39
  630. package/script/src/cli/releaseTrust.d.ts.map +0 -1
  631. package/script/src/cli/releaseTrust.js +0 -130
  632. package/script/src/cli/releaseTrustCommand.d.ts +0 -18
  633. package/script/src/cli/releaseTrustCommand.d.ts.map +0 -1
  634. package/script/src/cli/releaseTrustCommand.js +0 -145
  635. package/script/src/cli/vercelBuildEnv.d.ts +0 -62
  636. package/script/src/cli/vercelBuildEnv.d.ts.map +0 -1
  637. package/script/src/cli/vercelBuildEnv.js +0 -401
  638. package/script/src/cli/vercelProjectRelease.d.ts +0 -38
  639. package/script/src/cli/vercelProjectRelease.d.ts.map +0 -1
  640. package/script/src/cli/vercelProjectRelease.js +0 -607
  641. package/script/src/clientData/identity.d.ts +0 -89
  642. package/script/src/clientData/identity.d.ts.map +0 -1
  643. package/script/src/clientData/identity.js +0 -134
  644. package/script/src/clientData/mod.d.ts +0 -3
  645. package/script/src/clientData/mod.d.ts.map +0 -1
  646. package/script/src/clientData/mod.js +0 -18
  647. package/script/src/files/client.d.ts +0 -29
  648. package/script/src/files/client.d.ts.map +0 -1
  649. package/script/src/files/client.js +0 -45
  650. package/script/src/files/errors.d.ts +0 -37
  651. package/script/src/files/errors.d.ts.map +0 -1
  652. package/script/src/files/errors.js +0 -76
  653. package/script/src/files/hash.d.ts +0 -15
  654. package/script/src/files/hash.d.ts.map +0 -1
  655. package/script/src/files/hash.js +0 -89
  656. package/script/src/files/memory.d.ts +0 -29
  657. package/script/src/files/memory.d.ts.map +0 -1
  658. package/script/src/files/memory.js +0 -113
  659. package/script/src/files/metadata.d.ts +0 -10
  660. package/script/src/files/metadata.d.ts.map +0 -1
  661. package/script/src/files/metadata.js +0 -189
  662. package/script/src/files/mod.d.ts +0 -10
  663. package/script/src/files/mod.d.ts.map +0 -1
  664. package/script/src/files/mod.js +0 -25
  665. package/script/src/files/s3.d.ts +0 -29
  666. package/script/src/files/s3.d.ts.map +0 -1
  667. package/script/src/files/s3.js +0 -110
  668. package/script/src/files/service.d.ts +0 -27
  669. package/script/src/files/service.d.ts.map +0 -1
  670. package/script/src/files/service.js +0 -139
  671. package/script/src/files/types.d.ts +0 -134
  672. package/script/src/files/types.d.ts.map +0 -1
  673. package/script/src/files/types.js +0 -2
  674. package/script/src/jobs/catalog.d.ts +0 -32
  675. package/script/src/jobs/catalog.d.ts.map +0 -1
  676. package/script/src/jobs/catalog.js +0 -223
  677. package/script/src/jobs/controller.d.ts +0 -41
  678. package/script/src/jobs/controller.d.ts.map +0 -1
  679. package/script/src/jobs/controller.js +0 -151
  680. package/script/src/jobs/direct.d.ts +0 -36
  681. package/script/src/jobs/direct.d.ts.map +0 -1
  682. package/script/src/jobs/direct.js +0 -128
  683. package/script/src/jobs/events.d.ts +0 -23
  684. package/script/src/jobs/events.d.ts.map +0 -1
  685. package/script/src/jobs/events.js +0 -50
  686. package/script/src/jobs/format.d.ts +0 -16
  687. package/script/src/jobs/format.d.ts.map +0 -1
  688. package/script/src/jobs/format.js +0 -193
  689. package/script/src/jobs/http.d.ts +0 -22
  690. package/script/src/jobs/http.d.ts.map +0 -1
  691. package/script/src/jobs/http.js +0 -50
  692. package/script/src/jobs/log.d.ts +0 -2
  693. package/script/src/jobs/log.d.ts.map +0 -1
  694. package/script/src/jobs/log.js +0 -13
  695. package/script/src/jobs/mod.d.ts +0 -11
  696. package/script/src/jobs/mod.d.ts.map +0 -1
  697. package/script/src/jobs/mod.js +0 -26
  698. package/script/src/jobs/run.d.ts +0 -39
  699. package/script/src/jobs/run.d.ts.map +0 -1
  700. package/script/src/jobs/run.js +0 -86
  701. package/script/src/jobs/sanitize.d.ts +0 -30
  702. package/script/src/jobs/sanitize.d.ts.map +0 -1
  703. package/script/src/jobs/sanitize.js +0 -97
  704. package/script/src/jobs/types.d.ts +0 -31
  705. package/script/src/jobs/types.d.ts.map +0 -1
  706. package/script/src/jobs/types.js +0 -2
  707. package/script/src/mail/errors.d.ts +0 -33
  708. package/script/src/mail/errors.d.ts.map +0 -1
  709. package/script/src/mail/errors.js +0 -97
  710. package/script/src/mail/memory.d.ts +0 -30
  711. package/script/src/mail/memory.d.ts.map +0 -1
  712. package/script/src/mail/memory.js +0 -345
  713. package/script/src/mail/mod.d.ts +0 -7
  714. package/script/src/mail/mod.d.ts.map +0 -1
  715. package/script/src/mail/mod.js +0 -22
  716. package/script/src/mail/postal.d.ts +0 -57
  717. package/script/src/mail/postal.d.ts.map +0 -1
  718. package/script/src/mail/postal.js +0 -251
  719. package/script/src/mail/retry.d.ts +0 -9
  720. package/script/src/mail/retry.d.ts.map +0 -1
  721. package/script/src/mail/retry.js +0 -22
  722. package/script/src/mail/sender.d.ts +0 -5
  723. package/script/src/mail/sender.d.ts.map +0 -1
  724. package/script/src/mail/sender.js +0 -52
  725. package/script/src/mail/service.d.ts +0 -23
  726. package/script/src/mail/service.d.ts.map +0 -1
  727. package/script/src/mail/service.js +0 -191
  728. package/script/src/mail/types.d.ts +0 -176
  729. package/script/src/mail/types.d.ts.map +0 -1
  730. package/script/src/mail/types.js +0 -2
  731. package/script/src/mui/apiKeys.d.ts +0 -171
  732. package/script/src/mui/apiKeys.d.ts.map +0 -1
  733. package/script/src/mui/apiKeys.js +0 -470
  734. package/script/src/mui/apiKeysView.d.ts +0 -193
  735. package/script/src/mui/apiKeysView.d.ts.map +0 -1
  736. package/script/src/mui/apiKeysView.js +0 -331
  737. package/script/src/mui/confirm.d.ts +0 -12
  738. package/script/src/mui/confirm.d.ts.map +0 -1
  739. package/script/src/mui/confirm.js +0 -85
  740. package/script/src/mui/mail.d.ts +0 -29
  741. package/script/src/mui/mail.d.ts.map +0 -1
  742. package/script/src/mui/mail.js +0 -159
  743. package/script/src/mui/mailView.d.ts +0 -20
  744. package/script/src/mui/mailView.d.ts.map +0 -1
  745. package/script/src/mui/mailView.js +0 -32
  746. package/script/src/mui/mod.d.ts +0 -5
  747. package/script/src/mui/mod.d.ts.map +0 -1
  748. package/script/src/mui/mod.js +0 -20
  749. package/script/src/next/apiKeys/mod.d.ts +0 -71
  750. package/script/src/next/apiKeys/mod.d.ts.map +0 -1
  751. package/script/src/next/apiKeys/mod.js +0 -227
  752. package/script/src/next/auth/client.d.ts.map +0 -1
  753. package/script/src/next/auth/client.js +0 -39
  754. package/script/src/next/auth/config.d.ts +0 -62
  755. package/script/src/next/auth/config.d.ts.map +0 -1
  756. package/script/src/next/auth/config.js +0 -178
  757. package/script/src/next/auth/localTestLogin.d.ts +0 -75
  758. package/script/src/next/auth/localTestLogin.d.ts.map +0 -1
  759. package/script/src/next/auth/localTestLogin.js +0 -291
  760. package/script/src/next/auth/mod.d.ts +0 -4
  761. package/script/src/next/auth/mod.d.ts.map +0 -1
  762. package/script/src/next/auth/mod.js +0 -19
  763. package/script/src/next/auth/server.d.ts +0 -44
  764. package/script/src/next/auth/server.d.ts.map +0 -1
  765. package/script/src/next/auth/server.js +0 -39
  766. package/script/src/next/files/mod.d.ts +0 -3
  767. package/script/src/next/files/mod.d.ts.map +0 -1
  768. package/script/src/next/files/mod.js +0 -18
  769. package/script/src/next/files/route.d.ts +0 -99
  770. package/script/src/next/files/route.d.ts.map +0 -1
  771. package/script/src/next/files/route.js +0 -353
  772. package/script/src/next/jobs/list.d.ts +0 -25
  773. package/script/src/next/jobs/list.d.ts.map +0 -1
  774. package/script/src/next/jobs/list.js +0 -48
  775. package/script/src/next/jobs/mod.d.ts +0 -6
  776. package/script/src/next/jobs/mod.d.ts.map +0 -1
  777. package/script/src/next/jobs/mod.js +0 -21
  778. package/script/src/next/jobs/paths.d.ts +0 -14
  779. package/script/src/next/jobs/paths.d.ts.map +0 -1
  780. package/script/src/next/jobs/paths.js +0 -47
  781. package/script/src/next/jobs/route.d.ts +0 -48
  782. package/script/src/next/jobs/route.d.ts.map +0 -1
  783. package/script/src/next/jobs/route.js +0 -105
  784. package/script/src/next/jobs/run.d.ts +0 -58
  785. package/script/src/next/jobs/run.d.ts.map +0 -1
  786. package/script/src/next/jobs/run.js +0 -592
  787. package/script/src/next/jobs/runRequest.d.ts +0 -19
  788. package/script/src/next/jobs/runRequest.d.ts.map +0 -1
  789. package/script/src/next/jobs/runRequest.js +0 -81
  790. package/script/src/next/jobs/stream.d.ts +0 -3
  791. package/script/src/next/jobs/stream.d.ts.map +0 -1
  792. package/script/src/next/jobs/stream.js +0 -28
  793. package/script/src/next/mail/mod.d.ts +0 -3
  794. package/script/src/next/mail/mod.d.ts.map +0 -1
  795. package/script/src/next/mail/mod.js +0 -18
  796. package/script/src/next/mail/route.d.ts +0 -12
  797. package/script/src/next/mail/route.d.ts.map +0 -1
  798. package/script/src/next/mail/route.js +0 -46
  799. package/script/src/next/pwa/mod.d.ts +0 -112
  800. package/script/src/next/pwa/mod.d.ts.map +0 -1
  801. package/script/src/next/pwa/mod.js +0 -303
  802. package/script/src/next/pwa/worker.d.ts +0 -27
  803. package/script/src/next/pwa/worker.d.ts.map +0 -1
  804. package/script/src/next/pwa/worker.js +0 -33
  805. package/script/src/next/secrets/mod.d.ts +0 -108
  806. package/script/src/next/secrets/mod.d.ts.map +0 -1
  807. package/script/src/next/secrets/mod.js +0 -218
  808. package/script/src/secrets/encoding.d.ts +0 -32
  809. package/script/src/secrets/encoding.d.ts.map +0 -1
  810. package/script/src/secrets/encoding.js +0 -95
  811. package/script/src/secrets/errors.d.ts +0 -45
  812. package/script/src/secrets/errors.d.ts.map +0 -1
  813. package/script/src/secrets/errors.js +0 -45
  814. package/script/src/secrets/fingerprint.d.ts +0 -43
  815. package/script/src/secrets/fingerprint.d.ts.map +0 -1
  816. package/script/src/secrets/fingerprint.js +0 -92
  817. package/script/src/secrets/frame.d.ts +0 -34
  818. package/script/src/secrets/frame.d.ts.map +0 -1
  819. package/script/src/secrets/frame.js +0 -91
  820. package/script/src/secrets/keyring.d.ts +0 -62
  821. package/script/src/secrets/keyring.d.ts.map +0 -1
  822. package/script/src/secrets/keyring.js +0 -202
  823. package/script/src/secrets/legacy.d.ts +0 -60
  824. package/script/src/secrets/legacy.d.ts.map +0 -1
  825. package/script/src/secrets/legacy.js +0 -186
  826. package/script/src/secrets/maintenance.d.ts +0 -173
  827. package/script/src/secrets/maintenance.d.ts.map +0 -1
  828. package/script/src/secrets/maintenance.js +0 -323
  829. package/script/src/secrets/mod.d.ts +0 -6
  830. package/script/src/secrets/mod.d.ts.map +0 -1
  831. package/script/src/secrets/mod.js +0 -24
  832. package/script/src/secrets/secrets.d.ts +0 -192
  833. package/script/src/secrets/secrets.d.ts.map +0 -1
  834. package/script/src/secrets/secrets.js +0 -532
@@ -0,0 +1,754 @@
1
+ import { createHash } from "node:crypto";
2
+ import type { Stats } from "node:fs";
3
+ import { readdir, readFile, stat } from "node:fs/promises";
4
+ import { join } from "node:path";
5
+
6
+ /**
7
+ * Loom repository paths whose content can change the generated npm package.
8
+ * Release equivalence (`git diff`) and local build fingerprints share this list.
9
+ * It includes every script `scripts/build_npm.ts` imports.
10
+ */
11
+ export const LOOM_PACKAGE_RELEVANT_PATHS: readonly string[] = [
12
+ "LICENSE",
13
+ "NOTICE",
14
+ "README.md",
15
+ "THIRD_PARTY_NOTICES.md",
16
+ "bin",
17
+ "deno.json",
18
+ "deno.lock",
19
+ "mod.ts",
20
+ "package.json",
21
+ "bun.lock",
22
+ "tsconfig.bun.json",
23
+ "runtime",
24
+ "scripts/browser_entrypoints.ts",
25
+ "scripts/build_npm.ts",
26
+ "scripts/build_protocol.json",
27
+ "scripts/build_dependencies.ts",
28
+ "scripts/esm_build.ts",
29
+ "scripts/npm_metadata.ts",
30
+ "scripts/git_visible_copy.ts",
31
+ "scripts/node_check_dependencies.ts",
32
+ "scripts/npm_package.ts",
33
+ "skills",
34
+ "src",
35
+ ];
36
+
37
+ /**
38
+ * Build stamp written into Loom's `npm/` output by `scripts/build_npm.ts`.
39
+ * The build excludes it from the packed package, so it never reaches npm or a
40
+ * consumer's `node_modules`.
41
+ */
42
+ export const LOOM_BUILD_STAMP_FILE = ".loom-build.json";
43
+
44
+ /** Content identity and provenance of one local Loom npm build. */
45
+ export type LoomBuildStamp = {
46
+ /** Package version the build wrote into `npm/package.json`. */
47
+ packageVersion?: string;
48
+ /**
49
+ * Git HEAD of the Loom checkout when the build started, or null when git
50
+ * could not tell. Absent from stamps written before builds recorded it.
51
+ */
52
+ sourceCommit?: string | null;
53
+ /**
54
+ * Whether that checkout had tracked changes or untracked files git does
55
+ * not ignore when the build started; null when git could not tell. Absent
56
+ * from stamps written before builds recorded it.
57
+ */
58
+ sourceDirty?: boolean | null;
59
+ /**
60
+ * Written by `loom dev sync`, never by a build: the source fingerprint (as
61
+ * the syncing Loom computes it) of a fresh build that still produced no
62
+ * provenance, because the checkout's own build script predates it. Until
63
+ * the fingerprint changes, sync judges staleness by it alone instead of
64
+ * rebuilding on every run.
65
+ */
66
+ legacyBuildFingerprint?: string;
67
+ /**
68
+ * Digest of the packed output the build produced; see
69
+ * {@link computePackageContentDigest}. Absent from stamps written before
70
+ * builds recorded it.
71
+ */
72
+ packageDigest?: string;
73
+ /**
74
+ * Fingerprint of the package-relevant source content when the build
75
+ * started; see {@link computeLoomSourceFingerprint}.
76
+ */
77
+ sourceFingerprint: string;
78
+ version: 1;
79
+ };
80
+
81
+ /** What git reported about a Loom checkout when a build started. */
82
+ export type LoomSourceProvenance = {
83
+ sourceCommit: string | null;
84
+ sourceDirty: boolean | null;
85
+ };
86
+
87
+ /**
88
+ * Asks git for a checkout's HEAD commit and whether its working tree differs
89
+ * from it: tracked changes, untracked files that are not ignored (listed
90
+ * individually, whatever `status.showUntrackedFiles` says), or files marked
91
+ * skip-worktree or assume-unchanged, whose changes `git status` hides.
92
+ * `git` runs one git command in the checkout and returns its stdout, or null
93
+ * when it failed (git missing, not a repository). Whatever git cannot answer
94
+ * is null.
95
+ */
96
+ export function readLoomSourceProvenance(
97
+ git: (args: string[]) => string | null,
98
+ ): LoomSourceProvenance {
99
+ const head = git(["rev-parse", "HEAD"])?.trim() ?? "";
100
+ if (!/^[0-9a-f]{40,64}$/.test(head)) {
101
+ return { sourceCommit: null, sourceDirty: null };
102
+ }
103
+ const status = git(["status", "--porcelain", "--untracked-files=all"]);
104
+ // `ls-files -v` tags skip-worktree files S and assume-unchanged files with
105
+ // a lowercase letter.
106
+ const tags = status === null ? null : git(["ls-files", "-v"]);
107
+ return {
108
+ sourceCommit: head,
109
+ sourceDirty:
110
+ status === null || tags === null
111
+ ? null
112
+ : status.trim() !== "" ||
113
+ tags.split("\n").some((line) => /^(?:S|[a-z]) /.test(line)),
114
+ };
115
+ }
116
+
117
+ /**
118
+ * Settles a build's provenance from what git reported when the build started
119
+ * and when it finished. Any change in between (a commit, a checkout, an
120
+ * edit, which `sourcesChanged` reports from the source fingerprints, or git
121
+ * becoming unable to tell) means the output may mix two states, so the build
122
+ * is stamped dirty, which `loom dev published` refuses; the starting commit
123
+ * is kept. A start git could not read stays unknown.
124
+ */
125
+ export function settleLoomBuildProvenance(
126
+ start: LoomSourceProvenance,
127
+ end: LoomSourceProvenance,
128
+ sourcesChanged: boolean,
129
+ ) {
130
+ const changedDuringBuild =
131
+ sourcesChanged ||
132
+ end.sourceCommit !== start.sourceCommit ||
133
+ end.sourceDirty !== start.sourceDirty;
134
+ const provenance: LoomSourceProvenance =
135
+ changedDuringBuild && start.sourceCommit !== null
136
+ ? { sourceCommit: start.sourceCommit, sourceDirty: true }
137
+ : start;
138
+ return { changedDuringBuild, provenance };
139
+ }
140
+
141
+ /**
142
+ * Whether a stamp records the build's provenance and output digest. Stamps
143
+ * from older build scripts lack them.
144
+ */
145
+ export function hasLoomBuildProvenance(stamp: LoomBuildStamp) {
146
+ return (
147
+ stamp.sourceCommit !== undefined &&
148
+ stamp.sourceDirty !== undefined &&
149
+ typeof stamp.packageDigest === "string"
150
+ );
151
+ }
152
+
153
+ const SOURCE_FINGERPRINT_SKIPPED_DIRS = new Set([
154
+ ".git",
155
+ "coverage",
156
+ "node_modules",
157
+ "npm",
158
+ ]);
159
+ // The compiler graph excludes tests, so test-only edits cannot change output.
160
+ const SOURCE_FINGERPRINT_SKIPPED_FILE = /\.test\.[cm]?[jt]sx?$/;
161
+
162
+ function compareNames(left: string, right: string) {
163
+ return left < right ? -1 : left > right ? 1 : 0;
164
+ }
165
+
166
+ function isMissingPathError(error: unknown) {
167
+ const code = (error as { code?: unknown } | null)?.code;
168
+ return code === "ENOENT" || code === "ENOTDIR";
169
+ }
170
+
171
+ async function statIfExists(path: string) {
172
+ try {
173
+ return await stat(path);
174
+ } catch (error) {
175
+ if (isMissingPathError(error)) return null;
176
+ throw error;
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Lists the package-relevant source files of a Loom checkout in fingerprint
182
+ * order, with their stats. Test files and build outputs are skipped.
183
+ */
184
+ async function listLoomSourceFiles(sourceRoot: string) {
185
+ const files: Array<{ path: string; stat: Stats }> = [];
186
+ const visit = async (relativePath: string) => {
187
+ const pathStat = await statIfExists(join(sourceRoot, relativePath));
188
+ if (!pathStat) return;
189
+ if (pathStat.isDirectory()) {
190
+ const entries = (await readdir(join(sourceRoot, relativePath))).sort(
191
+ compareNames,
192
+ );
193
+ for (const name of entries) {
194
+ if (SOURCE_FINGERPRINT_SKIPPED_DIRS.has(name)) continue;
195
+ await visit(`${relativePath}/${name}`);
196
+ }
197
+ return;
198
+ }
199
+ if (
200
+ pathStat.isFile() &&
201
+ !SOURCE_FINGERPRINT_SKIPPED_FILE.test(relativePath)
202
+ ) {
203
+ files.push({ path: relativePath, stat: pathStat });
204
+ }
205
+ };
206
+ for (const path of [...LOOM_PACKAGE_RELEVANT_PATHS].sort(compareNames)) {
207
+ await visit(path);
208
+ }
209
+ return files;
210
+ }
211
+
212
+ /**
213
+ * Hashes the content of every package-relevant file in a Loom checkout.
214
+ * Unlike modification times, the result changes exactly when a rebuild could
215
+ * produce a different package, including after checkouts that restore older
216
+ * timestamps and edits made while a build is running.
217
+ */
218
+ export async function computeLoomSourceFingerprint(sourceRoot: string) {
219
+ const hash = createHash("sha256");
220
+ hash.update("loom-source-fingerprint:1\n");
221
+ for (const { path } of await listLoomSourceFiles(sourceRoot)) {
222
+ const content = await readFile(join(sourceRoot, path));
223
+ hash.update(`${path}\0${content.length}\0`);
224
+ hash.update(content);
225
+ hash.update("\0");
226
+ }
227
+ return `sha256:${hash.digest("hex")}`;
228
+ }
229
+
230
+ /** Size and modification time of each package-relevant source file. */
231
+ export type LoomSourceSnapshot = Map<string, { mtimeMs: number; size: number }>;
232
+
233
+ /** Records {@link LoomSourceSnapshot} for a Loom checkout. */
234
+ export async function snapshotLoomSources(
235
+ sourceRoot: string,
236
+ ): Promise<LoomSourceSnapshot> {
237
+ return new Map(
238
+ (await listLoomSourceFiles(sourceRoot)).map(({ path, stat }) => [
239
+ path,
240
+ { mtimeMs: stat.mtimeMs, size: stat.size },
241
+ ]),
242
+ );
243
+ }
244
+
245
+ /**
246
+ * How far before a build's start a whole-second modification time still
247
+ * counts as possibly written during it: FAT stores even seconds, and
248
+ * timestamps are rounded down to the filesystem's granularity.
249
+ */
250
+ const COARSE_MTIME_MARGIN_MS = 2_500;
251
+
252
+ /**
253
+ * Whether any package-relevant source file was written while a build ran,
254
+ * from snapshots taken when it started (at `startedAtMs`) and when it
255
+ * finished. Content alone misses an edit that was reverted before the build
256
+ * finished, but the revert rewrites the file:
257
+ * - a file added, removed, resized or with a new modification time counts;
258
+ * - so does one modified at or after the start;
259
+ * - on filesystems with coarse timestamps (a whole-second modification time)
260
+ * an edit can keep the old value, so a file modified shortly before the
261
+ * start counts as well.
262
+ */
263
+ export function loomSourcesWrittenDuringBuild(
264
+ start: LoomSourceSnapshot,
265
+ end: LoomSourceSnapshot,
266
+ startedAtMs: number,
267
+ ) {
268
+ if (start.size !== end.size) return true;
269
+ for (const [path, after] of end) {
270
+ const before = start.get(path);
271
+ if (
272
+ !before ||
273
+ before.size !== after.size ||
274
+ before.mtimeMs !== after.mtimeMs ||
275
+ after.mtimeMs >= startedAtMs
276
+ ) {
277
+ return true;
278
+ }
279
+ if (
280
+ after.mtimeMs % 1000 === 0 &&
281
+ after.mtimeMs >= startedAtMs - COARSE_MTIME_MARGIN_MS
282
+ ) {
283
+ return true;
284
+ }
285
+ }
286
+ return false;
287
+ }
288
+
289
+ /** Serializes the build stamp that `scripts/build_npm.ts` writes. */
290
+ export function formatLoomBuildStamp(stamp: Omit<LoomBuildStamp, "version">) {
291
+ const value: LoomBuildStamp = { version: 1, ...stamp };
292
+ return `${JSON.stringify(value, null, 2)}\n`;
293
+ }
294
+
295
+ /** Reads a build stamp, returning null when it is absent or unrecognized. */
296
+ export async function readLoomBuildStamp(
297
+ packagePath: string,
298
+ ): Promise<LoomBuildStamp | null> {
299
+ let text: string;
300
+ try {
301
+ text = await readFile(join(packagePath, LOOM_BUILD_STAMP_FILE), "utf8");
302
+ } catch (error) {
303
+ if (isMissingPathError(error)) return null;
304
+ throw error;
305
+ }
306
+ try {
307
+ const stamp = JSON.parse(text) as Partial<LoomBuildStamp>;
308
+ const commitOk =
309
+ stamp.sourceCommit === undefined ||
310
+ stamp.sourceCommit === null ||
311
+ typeof stamp.sourceCommit === "string";
312
+ const dirtyOk =
313
+ stamp.sourceDirty === undefined ||
314
+ stamp.sourceDirty === null ||
315
+ typeof stamp.sourceDirty === "boolean";
316
+ const digestOk =
317
+ stamp.packageDigest === undefined ||
318
+ typeof stamp.packageDigest === "string";
319
+ const legacyOk =
320
+ stamp.legacyBuildFingerprint === undefined ||
321
+ typeof stamp.legacyBuildFingerprint === "string";
322
+ return stamp.version === 1 &&
323
+ typeof stamp.sourceFingerprint === "string" &&
324
+ commitOk &&
325
+ dirtyOk &&
326
+ digestOk &&
327
+ legacyOk
328
+ ? (stamp as LoomBuildStamp)
329
+ : null;
330
+ } catch {
331
+ return null;
332
+ }
333
+ }
334
+
335
+ /** Names npm packing, and so pnpm's directory import, always leaves out. */
336
+ const ALWAYS_UNPACKED_NAMES = new Set([
337
+ "CVS",
338
+ "config.gypi",
339
+ "node_modules",
340
+ "npm-debug.log",
341
+ "package-lock.json",
342
+ ]);
343
+
344
+ /** Literal ignore rules a package's root ignore file applies when packing. */
345
+ type PackExclusions = {
346
+ /** Names excluded at any depth, such as `yarn.lock`. */
347
+ anyDepth: Set<string>;
348
+ /** Top-level names excluded by root-anchored patterns, such as `/src/`. */
349
+ topLevel: Set<string>;
350
+ };
351
+
352
+ async function readTextOrNull(path: string) {
353
+ try {
354
+ return await readFile(path, "utf8");
355
+ } catch (error) {
356
+ if (isMissingPathError(error)) return null;
357
+ throw error;
358
+ }
359
+ }
360
+
361
+ /**
362
+ * Reads the root ignore rules npm packing applies to a package directory
363
+ * (`.npmignore`, else `.gitignore`). Only literal names are understood, which
364
+ * covers the generated `.npmignore`; globs, nested paths, negations, and a
365
+ * `files` allowlist return null so callers fall back to a weaker comparison.
366
+ */
367
+ async function readPackExclusions(
368
+ root: string,
369
+ ): Promise<PackExclusions | null> {
370
+ try {
371
+ const packageJson = JSON.parse(
372
+ (await readTextOrNull(join(root, "package.json"))) ?? "{}",
373
+ ) as { files?: unknown };
374
+ if (packageJson.files !== undefined) return null;
375
+ } catch {
376
+ return null;
377
+ }
378
+ const ignoreText =
379
+ (await readTextOrNull(join(root, ".npmignore"))) ??
380
+ (await readTextOrNull(join(root, ".gitignore"))) ??
381
+ "";
382
+ const exclusions: PackExclusions = {
383
+ anyDepth: new Set(),
384
+ topLevel: new Set(),
385
+ };
386
+ for (const rawLine of ignoreText.split(/\r?\n/)) {
387
+ const line = rawLine.trim();
388
+ if (line === "" || line.startsWith("#")) continue;
389
+ if (line.startsWith("!")) return null;
390
+ const anchored = line.startsWith("/");
391
+ const name = line.replace(/^\/+/, "").replace(/\/+$/, "");
392
+ if (name === "") continue;
393
+ if (/[*?[\]\\/]/.test(name)) return null;
394
+ (anchored ? exclusions.topLevel : exclusions.anyDepth).add(name);
395
+ }
396
+ return exclusions;
397
+ }
398
+
399
+ function isPackedEntry(name: string, anyDepthExclusions: Set<string>) {
400
+ // Dot entries cover npm's other always-ignored names (.git, .npmrc, ...)
401
+ // and the ignore files themselves.
402
+ return (
403
+ !name.startsWith(".") &&
404
+ !ALWAYS_UNPACKED_NAMES.has(name) &&
405
+ !name.endsWith(".orig") &&
406
+ !anyDepthExclusions.has(name)
407
+ );
408
+ }
409
+
410
+ async function collectPackageFiles(
411
+ root: string,
412
+ includeTopLevel: (name: string) => boolean,
413
+ anyDepthExclusions: Set<string>,
414
+ ) {
415
+ const files = new Map<
416
+ string,
417
+ { ino: number; mtimeMs: number; size: number }
418
+ >();
419
+ let nestedIgnoreFile = false;
420
+ const visit = async (relativePath: string) => {
421
+ const directory = relativePath ? join(root, relativePath) : root;
422
+ const entries = (await readdir(directory, { withFileTypes: true })).sort(
423
+ (left, right) => compareNames(left.name, right.name),
424
+ );
425
+ for (const entry of entries) {
426
+ if (
427
+ relativePath &&
428
+ (entry.name === ".npmignore" || entry.name === ".gitignore")
429
+ ) {
430
+ nestedIgnoreFile = true;
431
+ }
432
+ if (!isPackedEntry(entry.name, anyDepthExclusions)) continue;
433
+ if (!relativePath && !includeTopLevel(entry.name)) continue;
434
+ const childPath = relativePath
435
+ ? `${relativePath}/${entry.name}`
436
+ : entry.name;
437
+ let isDirectory = entry.isDirectory();
438
+ let isFile = entry.isFile();
439
+ let fileStat = { ino: 0, mtimeMs: 0, size: 0 };
440
+ if (entry.isSymbolicLink() || isFile) {
441
+ const childStat = await statIfExists(join(root, childPath));
442
+ if (!childStat) continue;
443
+ isDirectory = childStat.isDirectory();
444
+ isFile = childStat.isFile();
445
+ fileStat = {
446
+ ino: childStat.ino,
447
+ mtimeMs: childStat.mtimeMs,
448
+ size: childStat.size,
449
+ };
450
+ }
451
+ if (isDirectory) {
452
+ await visit(childPath);
453
+ } else if (isFile) {
454
+ files.set(childPath, fileStat);
455
+ }
456
+ }
457
+ };
458
+ await visit("");
459
+ return { files, nestedIgnoreFile };
460
+ }
461
+
462
+ /**
463
+ * Digest of a built package's files by path and content, filtered as
464
+ * {@link findPackageTreeDifference} filters them: its root ignore rules,
465
+ * npm's always-ignored names, and every dot entry, which Loom's packing
466
+ * approximation treats as unpacked although npm would pack some. The build
467
+ * stamp records it, so any later edit to those files shows.
468
+ */
469
+ export async function computePackageContentDigest(root: string) {
470
+ let exclusions = await readPackExclusions(root);
471
+ const collect = () =>
472
+ collectPackageFiles(
473
+ root,
474
+ (name) => !exclusions?.topLevel.has(name),
475
+ exclusions?.anyDepth ?? new Set(),
476
+ );
477
+ let collected = await collect();
478
+ if (exclusions && collected.nestedIgnoreFile) {
479
+ // As in findPackageTreeDifference: nested rules are not applied.
480
+ exclusions = null;
481
+ collected = await collect();
482
+ }
483
+ const hash = createHash("sha256");
484
+ hash.update("loom-package-digest:1\n");
485
+ for (const path of [...collected.files.keys()].sort(compareNames)) {
486
+ const content = await readFile(join(root, path));
487
+ hash.update(`${path}\0${content.length}\0`);
488
+ hash.update(content);
489
+ hash.update("\0");
490
+ }
491
+ return `sha256:${hash.digest("hex")}`;
492
+ }
493
+
494
+ /**
495
+ * Compares a built package directory with the copy a package manager
496
+ * installed from it, by file list and byte content. Returns a short
497
+ * description of the first difference, or null when the installed copy
498
+ * matches.
499
+ *
500
+ * Both trees are filtered by the build's packing rules (its root
501
+ * `.npmignore` plus npm's always-ignored names), so a build that only adds a
502
+ * new top-level entry is still detected. When those rules cannot be read
503
+ * literally, top-level build entries absent from the installed copy are
504
+ * skipped instead, unless `requireKnownPackingRules` requests a fail-closed
505
+ * comparison for a manager whose refresh relies on complete file parity.
506
+ */
507
+ export async function findPackageTreeDifference(
508
+ builtRoot: string,
509
+ installedRoot: string,
510
+ options: { requireKnownPackingRules?: boolean } = {},
511
+ ): Promise<string | null> {
512
+ const installedTopLevel = await readdir(installedRoot).catch((error) => {
513
+ if (isMissingPathError(error)) return null;
514
+ throw error;
515
+ });
516
+ if (!installedTopLevel?.includes("package.json")) {
517
+ return "the package is not installed";
518
+ }
519
+ const installedNames = new Set(installedTopLevel);
520
+ const collect = (exclusions: PackExclusions | null) => {
521
+ const includeTopLevel = exclusions
522
+ ? (name: string) => !exclusions.topLevel.has(name)
523
+ : (name: string) => installedNames.has(name);
524
+ const anyDepth = exclusions?.anyDepth ?? new Set<string>();
525
+ return Promise.all([
526
+ collectPackageFiles(builtRoot, includeTopLevel, anyDepth),
527
+ collectPackageFiles(installedRoot, includeTopLevel, anyDepth),
528
+ ]);
529
+ };
530
+ let exclusions = await readPackExclusions(builtRoot);
531
+ let [built, installed] = await collect(exclusions);
532
+ if (
533
+ options.requireKnownPackingRules &&
534
+ (!exclusions || built.nestedIgnoreFile)
535
+ ) {
536
+ throw new Error(
537
+ "Managed Bun local development requires literal root packing rules without a files allowlist or nested ignore files; this package layout is not supported.",
538
+ );
539
+ }
540
+ if (exclusions && built.nestedIgnoreFile) {
541
+ // Nested ignore files add rules this reader does not apply.
542
+ exclusions = null;
543
+ [built, installed] = await collect(exclusions);
544
+ }
545
+ const builtFiles = built.files;
546
+ const installedFiles = installed.files;
547
+ for (const path of builtFiles.keys()) {
548
+ if (!installedFiles.has(path)) return `${path} is not installed`;
549
+ }
550
+ for (const path of installedFiles.keys()) {
551
+ if (!builtFiles.has(path)) return `${path} is no longer built`;
552
+ }
553
+ for (const [path, { size }] of builtFiles) {
554
+ if (installedFiles.get(path)?.size !== size) return `${path} differs`;
555
+ }
556
+ for (const path of builtFiles.keys()) {
557
+ const [builtContent, installedContent] = await Promise.all([
558
+ readFile(join(builtRoot, path)),
559
+ readFile(join(installedRoot, path)),
560
+ ]);
561
+ if (!builtContent.equals(installedContent)) return `${path} differs`;
562
+ }
563
+ return null;
564
+ }
565
+
566
+ // Preserve the established export while the bin loads only the pure identity
567
+ // helper, without caching this module's build/provenance behavior beforehand.
568
+ export { computePackageTreeSignature } from "./packageTreeSignature.ts";
569
+
570
+ function unquoteYamlScalar(value: string) {
571
+ const trimmed = value.trim();
572
+ if (trimmed.startsWith("'") && trimmed.endsWith("'") && trimmed.length > 1) {
573
+ return trimmed.slice(1, -1).replaceAll("''", "'");
574
+ }
575
+ if (trimmed.startsWith('"') && trimmed.endsWith('"') && trimmed.length > 1) {
576
+ try {
577
+ return JSON.parse(trimmed) as string;
578
+ } catch {
579
+ return trimmed.slice(1, -1);
580
+ }
581
+ }
582
+ return trimmed;
583
+ }
584
+
585
+ /** Splits `key: value` YAML mapping lines at the given indentation. */
586
+ function parseYamlMappingLine(line: string, indent: number) {
587
+ const prefix = " ".repeat(indent);
588
+ if (!line.startsWith(prefix) || line[indent] === " ") return null;
589
+ const body = line.slice(indent);
590
+ if (body.startsWith("#")) return null;
591
+ const match = body.match(
592
+ /^(?:'((?:[^']|'')*)'|"((?:[^"\\]|\\.)*)"|([^\s'"#][^\s]*?)):(?:\s+(.*))?$/,
593
+ );
594
+ if (!match) return null;
595
+ const key =
596
+ match[1] !== undefined
597
+ ? match[1].replaceAll("''", "'")
598
+ : match[2] !== undefined
599
+ ? unquoteYamlScalar(`"${match[2]}"`)
600
+ : match[3];
601
+ return { key, value: match[4] === undefined ? "" : match[4] };
602
+ }
603
+
604
+ /**
605
+ * Returns the project document of a lockfile. With `configDependencies`,
606
+ * pnpm 11 writes a multi-document lockfile whose first document locks the
607
+ * config-dependency environment and has its own importers and snapshots;
608
+ * the project document, which carries `settings:`, comes last.
609
+ */
610
+ function getMainLockfileDocument(lockfileText: string) {
611
+ const documents = lockfileText
612
+ .replace(/\r\n/g, "\n")
613
+ .split(/^---[ \t]*$/m)
614
+ .filter((document) => document.trim() !== "");
615
+ if (documents.length <= 1) return documents[0] ?? "";
616
+ for (let index = documents.length - 1; index >= 0; index -= 1) {
617
+ if (/^settings:/m.test(documents[index])) return documents[index];
618
+ }
619
+ return documents[documents.length - 1];
620
+ }
621
+
622
+ /** Returns the lines of a top-level section of a pnpm lockfile. */
623
+ function getLockfileSection(lockfileText: string, section: string) {
624
+ const lines = getMainLockfileDocument(lockfileText).split("\n");
625
+ const start = lines.indexOf(`${section}:`);
626
+ if (start === -1) return [];
627
+ const body: string[] = [];
628
+ for (const line of lines.slice(start + 1)) {
629
+ if (line !== "" && !line.startsWith(" ") && !line.startsWith("#")) break;
630
+ body.push(line);
631
+ }
632
+ return body;
633
+ }
634
+
635
+ /**
636
+ * Reads the override pnpm recorded for a package in the lockfile's top-level
637
+ * `overrides:` map. pnpm records the override map it actually applied, so
638
+ * this proves whether an override took effect.
639
+ */
640
+ export function getLockfileOverride(lockfileText: string, name: string) {
641
+ for (const line of getLockfileSection(lockfileText, "overrides")) {
642
+ const entry = parseYamlMappingLine(line, 2);
643
+ if (entry?.key === name) return unquoteYamlScalar(entry.value);
644
+ }
645
+ return null;
646
+ }
647
+
648
+ /** The root importer's lockfile entry for one direct dependency. */
649
+ export type LockfileImporterDependency = {
650
+ specifier?: string;
651
+ version?: string;
652
+ };
653
+
654
+ /** Reads a direct dependency of the root importer (`.`) from a lockfile. */
655
+ export function getLockfileRootImporterDependency(
656
+ lockfileText: string,
657
+ name: string,
658
+ ): LockfileImporterDependency | null {
659
+ let inRootImporter = false;
660
+ let inDependency = false;
661
+ const result: LockfileImporterDependency = {};
662
+ for (const line of getLockfileSection(lockfileText, "importers")) {
663
+ const importer = parseYamlMappingLine(line, 2);
664
+ if (importer) {
665
+ if (inDependency) break;
666
+ inRootImporter = importer.key === ".";
667
+ continue;
668
+ }
669
+ if (!inRootImporter) continue;
670
+ if (parseYamlMappingLine(line, 4)) {
671
+ if (inDependency) break;
672
+ continue;
673
+ }
674
+ const dependency = parseYamlMappingLine(line, 6);
675
+ if (dependency) {
676
+ if (inDependency) break;
677
+ inDependency = dependency.key === name;
678
+ continue;
679
+ }
680
+ const field = inDependency ? parseYamlMappingLine(line, 8) : null;
681
+ if (field?.key === "specifier") {
682
+ result.specifier = unquoteYamlScalar(field.value);
683
+ } else if (field?.key === "version") {
684
+ result.version = unquoteYamlScalar(field.value);
685
+ }
686
+ }
687
+ return result.specifier !== undefined || result.version !== undefined
688
+ ? result
689
+ : null;
690
+ }
691
+
692
+ /**
693
+ * Groups lockfile snapshot keys by `name@version`, collecting the peer (and
694
+ * patch) suffix of each variant, for example `(react@19.2.0)`.
695
+ */
696
+ export function getLockfileSnapshotVariants(lockfileText: string) {
697
+ const variants = new Map<string, Set<string>>();
698
+ const section = getLockfileSection(lockfileText, "snapshots");
699
+ // Lockfile v6 and older kept peer variants in `packages:` with a `/` prefix.
700
+ const lines = section.length
701
+ ? section
702
+ : getLockfileSection(lockfileText, "packages");
703
+ for (const line of lines) {
704
+ const entry = parseYamlMappingLine(line, 2);
705
+ if (!entry) continue;
706
+ const key = entry.key.replace(/^\//, "");
707
+ const versionSeparator = key.indexOf("@", key.startsWith("@") ? 1 : 0);
708
+ if (versionSeparator <= 0) continue;
709
+ const suffixStart = key.indexOf("(", versionSeparator);
710
+ const base = suffixStart === -1 ? key : key.slice(0, suffixStart);
711
+ const suffix = suffixStart === -1 ? "" : key.slice(suffixStart);
712
+ const set = variants.get(base) ?? new Set<string>();
713
+ set.add(suffix);
714
+ variants.set(base, set);
715
+ }
716
+ return variants;
717
+ }
718
+
719
+ /** A package version whose number of lockfile peer variants grew. */
720
+ export type PeerVariantDuplicate = {
721
+ after: number;
722
+ before: number;
723
+ /** `name@version`. */
724
+ packageVersion: string;
725
+ };
726
+
727
+ /**
728
+ * Lists `name@version` entries that have more than one peer variant after a
729
+ * lockfile change and more variants than before it. Pre-existing duplicates
730
+ * are ignored so warnings point only at what the change introduced.
731
+ */
732
+ export function findNewPeerVariantDuplicates(
733
+ beforeLockfileText: string | null,
734
+ afterLockfileText: string,
735
+ ): PeerVariantDuplicate[] {
736
+ const before = beforeLockfileText
737
+ ? getLockfileSnapshotVariants(beforeLockfileText)
738
+ : new Map<string, Set<string>>();
739
+ const after = getLockfileSnapshotVariants(afterLockfileText);
740
+ const duplicates: PeerVariantDuplicate[] = [];
741
+ for (const [packageVersion, variants] of after) {
742
+ const beforeCount = before.get(packageVersion)?.size ?? 0;
743
+ if (variants.size > 1 && variants.size > beforeCount) {
744
+ duplicates.push({
745
+ after: variants.size,
746
+ before: beforeCount,
747
+ packageVersion,
748
+ });
749
+ }
750
+ }
751
+ return duplicates.sort((left, right) =>
752
+ compareNames(left.packageVersion, right.packageVersion),
753
+ );
754
+ }