@rebasepro/cli 0.30.0 → 0.31.0-canary.g902a0ce

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 (285) hide show
  1. package/README.md +8 -7
  2. package/dist/{agent-setup-0uyfC7VX.js → agent-setup-DqAcoDcn.js} +10 -5
  3. package/dist/{agent-setup-0uyfC7VX.js.map → agent-setup-DqAcoDcn.js.map} +1 -1
  4. package/dist/{api-keys-Dfw5-9s1.js → api-keys-eIUjMqWn.js} +8 -7
  5. package/dist/api-keys-eIUjMqWn.js.map +1 -0
  6. package/dist/{apps-MKQbgDtN.js → apps-DExO4PEl.js} +8 -7
  7. package/dist/apps-DExO4PEl.js.map +1 -0
  8. package/dist/{project-CasK56vN.js → args-CaCcrYE1.js} +2 -351
  9. package/dist/args-CaCcrYE1.js.map +1 -0
  10. package/dist/{atlas-dev-database-BODqdCWt.js → atlas-dev-database-DOCKk6ht.js} +2 -2
  11. package/dist/{atlas-dev-database-BODqdCWt.js.map → atlas-dev-database-DOCKk6ht.js.map} +1 -1
  12. package/dist/{auth-Bv0rTbQX.js → auth-CyADghFQ.js} +7 -6
  13. package/dist/{auth-Bv0rTbQX.js.map → auth-CyADghFQ.js.map} +1 -1
  14. package/dist/backend-guard-C0mVkXBw.js +162 -0
  15. package/dist/backend-guard-C0mVkXBw.js.map +1 -0
  16. package/dist/{branch-pointer-BQUF6lYa.js → branch-pointer-DMPyvZoK.js} +1 -1
  17. package/dist/{build-BuKTnec8.js → build-CA5R07tw.js} +29 -9
  18. package/dist/build-CA5R07tw.js.map +1 -0
  19. package/dist/{bundle-BAH4FCju.js → bundle-DgILeA5b.js} +112 -138
  20. package/dist/bundle-DgILeA5b.js.map +1 -0
  21. package/dist/bundle.d.ts +35 -12
  22. package/dist/cli.d.ts +2 -2
  23. package/dist/{cloud-Cj5ey3l_.js → cloud-CYMk92iG.js} +217 -104
  24. package/dist/cloud-CYMk92iG.js.map +1 -0
  25. package/dist/cms-directories-BK3vcswg.js +33 -0
  26. package/dist/cms-directories-BK3vcswg.js.map +1 -0
  27. package/dist/codemod/collections-to-tables/ast.d.ts +135 -0
  28. package/dist/codemod/collections-to-tables/backend.d.ts +38 -0
  29. package/dist/codemod/collections-to-tables/command.d.ts +35 -0
  30. package/dist/codemod/collections-to-tables/comments.d.ts +45 -0
  31. package/dist/codemod/collections-to-tables/customization.d.ts +47 -0
  32. package/dist/codemod/collections-to-tables/dynamic-props.d.ts +34 -0
  33. package/dist/codemod/collections-to-tables/export-changes.d.ts +83 -0
  34. package/dist/codemod/collections-to-tables/firestore.d.ts +11 -0
  35. package/dist/codemod/collections-to-tables/helper-hooks.d.ts +41 -0
  36. package/dist/codemod/collections-to-tables/hooks.d.ts +44 -0
  37. package/dist/codemod/collections-to-tables/journal.d.ts +10 -0
  38. package/dist/codemod/collections-to-tables/legacy-shims.d.ts +52 -0
  39. package/dist/codemod/collections-to-tables/load-legacy.d.ts +81 -0
  40. package/dist/codemod/collections-to-tables/migrate.d.ts +20 -0
  41. package/dist/codemod/collections-to-tables/modules.d.ts +127 -0
  42. package/dist/codemod/collections-to-tables/moved-imports.d.ts +70 -0
  43. package/dist/codemod/collections-to-tables/moved-symbols.generated.d.ts +12 -0
  44. package/dist/codemod/collections-to-tables/own.d.ts +10 -0
  45. package/dist/codemod/collections-to-tables/path-aliases.d.ts +26 -0
  46. package/dist/codemod/collections-to-tables/plan-context.d.ts +49 -0
  47. package/dist/codemod/collections-to-tables/print-js.d.ts +44 -0
  48. package/dist/codemod/collections-to-tables/project-files.d.ts +144 -0
  49. package/dist/codemod/collections-to-tables/repoint.d.ts +50 -0
  50. package/dist/codemod/collections-to-tables/row-hands.d.ts +7 -0
  51. package/dist/codemod/collections-to-tables/sdk-calls.d.ts +88 -0
  52. package/dist/codemod/collections-to-tables/skills-step.d.ts +13 -0
  53. package/dist/codemod/collections-to-tables/split-constants.d.ts +42 -0
  54. package/dist/codemod/collections-to-tables/storage-paths.d.ts +28 -0
  55. package/dist/codemod/collections-to-tables/types.d.ts +164 -0
  56. package/dist/codemod/collections-to-tables/verify.d.ts +27 -0
  57. package/dist/codemod/collections-to-tables/vocabulary.d.ts +40 -0
  58. package/dist/command-D5lhW_-B.js +9984 -0
  59. package/dist/command-D5lhW_-B.js.map +1 -0
  60. package/dist/commands/agent-setup.d.ts +6 -2
  61. package/dist/commands/cloud/auth.d.ts +2 -0
  62. package/dist/commands/cloud/context.d.ts +1 -1
  63. package/dist/commands/cloud/init.d.ts +2 -2
  64. package/dist/commands/cloud/login-flow.d.ts +30 -1
  65. package/dist/commands/console.d.ts +1 -2
  66. package/dist/commands/db.d.ts +5 -6
  67. package/dist/commands/dev.d.ts +18 -17
  68. package/dist/commands/doctor.d.ts +4 -5
  69. package/dist/commands/eject.d.ts +17 -13
  70. package/dist/commands/generate-view.d.ts +20 -9
  71. package/dist/commands/generate_sdk.d.ts +27 -27
  72. package/dist/commands/init.d.ts +21 -8
  73. package/dist/commands/migrate.d.ts +24 -0
  74. package/dist/commands/schema-reconcile.d.ts +1 -1
  75. package/dist/commands/skills.d.ts +8 -0
  76. package/dist/commands/verify-cms.d.ts +28 -0
  77. package/dist/commands/verify.d.ts +14 -9
  78. package/dist/{consent-BD7F29T3.js → consent-BXLIrMl8.js} +2 -2
  79. package/dist/{consent-BD7F29T3.js.map → consent-BXLIrMl8.js.map} +1 -1
  80. package/dist/{console-CdwIYOMV.js → console-CMjhgMUE.js} +14 -14
  81. package/dist/console-CMjhgMUE.js.map +1 -0
  82. package/dist/{context-AXdAh-q8.js → context--JwaHaZp.js} +6 -5
  83. package/dist/context--JwaHaZp.js.map +1 -0
  84. package/dist/{daemon-Cp7oNXth.js → daemon-w30PsdwV.js} +2 -2
  85. package/dist/{daemon-Cp7oNXth.js.map → daemon-w30PsdwV.js.map} +1 -1
  86. package/dist/{db-DBbKpjYX.js → db-A7XDCIIO.js} +51 -51
  87. package/dist/db-A7XDCIIO.js.map +1 -0
  88. package/dist/{derive-ae9UOoOB.js → derive-C3ezmY-p.js} +105 -133
  89. package/dist/derive-C3ezmY-p.js.map +1 -0
  90. package/dist/dev-db/attver.d.ts +11 -0
  91. package/dist/{dev-preflight-Cxv3TiD1.js → dev-preflight-DjvcV6SK.js} +5 -5
  92. package/dist/dev-preflight-DjvcV6SK.js.map +1 -0
  93. package/dist/{dev-server-OJsUGZEB.js → dev-server-BLxCbQEP.js} +2 -2
  94. package/dist/{dev-server-OJsUGZEB.js.map → dev-server-BLxCbQEP.js.map} +1 -1
  95. package/dist/{dev-C93d4QIv.js → dev-tWwPyWkQ.js} +142 -84
  96. package/dist/dev-tWwPyWkQ.js.map +1 -0
  97. package/dist/{doctor-BBPQUO2g.js → doctor-BBM0dWvZ.js} +39 -62
  98. package/dist/doctor-BBM0dWvZ.js.map +1 -0
  99. package/dist/doctor-environment.d.ts +6 -6
  100. package/dist/{eject-DABcDnPN.js → eject-Bhzd6hgb.js} +25 -16
  101. package/dist/eject-Bhzd6hgb.js.map +1 -0
  102. package/dist/{fold-static-BWzxNn06.js → fold-static-CKewnAPX.js} +5 -3
  103. package/dist/fold-static-CKewnAPX.js.map +1 -0
  104. package/dist/{generate-view-IFwCADvb.js → generate-view-CTOluXvH.js} +160 -89
  105. package/dist/generate-view-CTOluXvH.js.map +1 -0
  106. package/dist/{generate_sdk-DNmNuFuW.js → generate_sdk-De-aLC1L.js} +120 -137
  107. package/dist/generate_sdk-De-aLC1L.js.map +1 -0
  108. package/dist/import-schema-module-Df67TIWj.js +51 -0
  109. package/dist/import-schema-module-Df67TIWj.js.map +1 -0
  110. package/dist/index.es.js +64 -51
  111. package/dist/index.es.js.map +1 -1
  112. package/dist/{init-vL1DWOeC.js → init-Dtl-IcXf.js} +83 -80
  113. package/dist/init-Dtl-IcXf.js.map +1 -0
  114. package/dist/last-dev-database-Dc8cP01o.js +2 -0
  115. package/dist/{manifest-BtzDy7KQ.js → manifest-C3uLDrrJ.js} +115 -40
  116. package/dist/manifest-C3uLDrrJ.js.map +1 -0
  117. package/dist/manifest.d.ts +79 -24
  118. package/dist/migrate-VrKoi3nB.js +138 -0
  119. package/dist/migrate-VrKoi3nB.js.map +1 -0
  120. package/dist/{normalize-imports-Bd5Y4yLp.js → normalize-imports-DwxqEMYq.js} +3 -3
  121. package/dist/{normalize-imports-Bd5Y4yLp.js.map → normalize-imports-DwxqEMYq.js.map} +1 -1
  122. package/dist/path-flags-7O5uPBcQ.js +139 -0
  123. package/dist/path-flags-7O5uPBcQ.js.map +1 -0
  124. package/dist/{prepare-CTw9NEkh.js → prepare-Ccxspoj-.js} +4 -4
  125. package/dist/{prepare-CTw9NEkh.js.map → prepare-Ccxspoj-.js.map} +1 -1
  126. package/dist/project-CLcF5i8c.js +360 -0
  127. package/dist/project-CLcF5i8c.js.map +1 -0
  128. package/dist/project-schema-CsSOG2gE.js +30 -0
  129. package/dist/project-schema-CsSOG2gE.js.map +1 -0
  130. package/dist/{pull-DDMpsZ5r.js → pull-D9WvpDYY.js} +189 -1
  131. package/dist/pull-D9WvpDYY.js.map +1 -0
  132. package/dist/resolve-BY7bSFRT.js +2 -0
  133. package/dist/resources/derive.d.ts +19 -13
  134. package/dist/{resources-CPSC5Kcu.js → resources-Dpfs2y8P.js} +5 -4
  135. package/dist/{resources-CPSC5Kcu.js.map → resources-Dpfs2y8P.js.map} +1 -1
  136. package/dist/{schema-DtLPsXbT.js → schema-DwFDI1iU.js} +41 -39
  137. package/dist/schema-DwFDI1iU.js.map +1 -0
  138. package/dist/schema-dir-Cd1kvYbf.js +98 -0
  139. package/dist/schema-dir-Cd1kvYbf.js.map +1 -0
  140. package/dist/schema-reconcile-Tto54Qbv.js +2 -0
  141. package/dist/schema-text-CpNrsuMe.js +73 -0
  142. package/dist/schema-text-CpNrsuMe.js.map +1 -0
  143. package/dist/{skills-CbwV6vw_.js → skills-CXjA9TWw.js} +54 -10
  144. package/dist/skills-CXjA9TWw.js.map +1 -0
  145. package/dist/{start-YOr3X5Zm.js → start-Bwbtt2W5.js} +7 -10
  146. package/dist/{start-YOr3X5Zm.js.map → start-Bwbtt2W5.js.map} +1 -1
  147. package/dist/{status-BREvtzJm.js → status-DQ_PPz4C.js} +12 -12
  148. package/dist/status-DQ_PPz4C.js.map +1 -0
  149. package/dist/{storage-CO9ouK76.js → storage-iTqj5-Av.js} +12 -11
  150. package/dist/storage-iTqj5-Av.js.map +1 -0
  151. package/dist/{telemetry-DwK5RQJl.js → telemetry-BP_1Cl9r.js} +4 -4
  152. package/dist/{telemetry-DwK5RQJl.js.map → telemetry-BP_1Cl9r.js.map} +1 -1
  153. package/dist/{telemetry-CgwJPVMO.js → telemetry-M3HjlyhZ.js} +2 -2
  154. package/dist/{telemetry-CgwJPVMO.js.map → telemetry-M3HjlyhZ.js.map} +1 -1
  155. package/dist/{upgrade-B7sVwL8S.js → upgrade-oZzJ13jM.js} +5 -4
  156. package/dist/{upgrade-B7sVwL8S.js.map → upgrade-oZzJ13jM.js.map} +1 -1
  157. package/dist/utils/backend-guard.d.ts +47 -0
  158. package/dist/utils/cms-directories.d.ts +6 -0
  159. package/dist/utils/dev-preflight.d.ts +2 -2
  160. package/dist/utils/import-schema-module.d.ts +16 -0
  161. package/dist/utils/path-flags.d.ts +35 -16
  162. package/dist/utils/project-schema.d.ts +40 -0
  163. package/dist/utils/project.d.ts +8 -2
  164. package/dist/utils/schema-dir.d.ts +32 -0
  165. package/dist/utils/schema-drift.d.ts +6 -0
  166. package/dist/utils/schema-text.d.ts +24 -0
  167. package/dist/verify-DkJqhYPI.js +1160 -0
  168. package/dist/verify-DkJqhYPI.js.map +1 -0
  169. package/package.json +11 -8
  170. package/runtime/dev-server.mjs +5 -1
  171. package/templates/eject/Dockerfile +1 -4
  172. package/templates/eject/backend/src/env.ts +1 -1
  173. package/templates/eject/backend/src/index.ts +53 -40
  174. package/templates/eject/docker-compose.custom.yml +1 -1
  175. package/templates/overlays/baas/README.md +39 -12
  176. package/templates/overlays/baas/ai-instructions.md +8 -8
  177. package/templates/overlays/baas/{config → backend}/storage.ts +3 -4
  178. package/templates/overlays/baas/backend/tsconfig.json +10 -12
  179. package/templates/overlays/baas/package.json +1 -2
  180. package/templates/overlays/baas/pnpm-workspace.yaml +0 -1
  181. package/templates/presets/blank/backend/schema/index.ts +19 -0
  182. package/templates/presets/blank/frontend/src/App.tsx +56 -0
  183. package/templates/presets/ecommerce/backend/schema/categories.ts +12 -0
  184. package/templates/presets/ecommerce/backend/schema/index.ts +23 -0
  185. package/templates/presets/ecommerce/backend/schema/orders.ts +13 -0
  186. package/templates/presets/ecommerce/backend/schema/products.ts +18 -0
  187. package/templates/presets/ecommerce/frontend/src/App.tsx +59 -0
  188. package/templates/presets/ecommerce/frontend/src/cms/categories.tsx +12 -0
  189. package/templates/presets/ecommerce/frontend/src/cms/orders.tsx +38 -0
  190. package/templates/presets/ecommerce/frontend/src/cms/products.tsx +27 -0
  191. package/templates/resource-graphs/blank.json +2 -2
  192. package/templates/resource-graphs/blog.json +5 -5
  193. package/templates/resource-graphs/ecommerce.json +5 -5
  194. package/templates/resource-graphs/headless.json +1 -1
  195. package/templates/template/.claude/hooks/post-edit-collection.sh +27 -23
  196. package/templates/template/.cursorrules +2 -2
  197. package/templates/template/.env.example +6 -17
  198. package/templates/template/.github/copilot-instructions.md +2 -2
  199. package/templates/template/.windsurfrules +2 -2
  200. package/templates/template/AGENTS.md +2 -2
  201. package/templates/template/CLAUDE.md +2 -2
  202. package/templates/template/README.md +47 -13
  203. package/templates/template/ai-instructions.md +15 -14
  204. package/templates/template/backend/functions/hello.ts +1 -1
  205. package/templates/template/backend/package.json +0 -2
  206. package/templates/template/{config → backend}/resources.ts +3 -3
  207. package/templates/template/backend/schema/authors.ts +11 -0
  208. package/templates/template/backend/schema/index.ts +29 -0
  209. package/templates/template/backend/schema/posts.ts +29 -0
  210. package/templates/template/backend/schema/tags.ts +9 -0
  211. package/templates/template/backend/schema/users.ts +32 -0
  212. package/templates/template/{config → backend}/storage.ts +4 -4
  213. package/templates/template/backend/tsconfig.json +15 -20
  214. package/templates/template/docker-compose.yml +3 -3
  215. package/templates/template/frontend/package.json +0 -2
  216. package/templates/template/frontend/src/App.tsx +10 -4
  217. package/templates/template/frontend/src/cms/authors.tsx +7 -0
  218. package/templates/template/frontend/src/cms/posts.tsx +27 -0
  219. package/templates/template/frontend/src/cms/tags.tsx +11 -0
  220. package/templates/template/frontend/src/cms/ui-config.json +3 -0
  221. package/templates/template/frontend/src/cms/users.tsx +54 -0
  222. package/templates/template/frontend/src/{virtual.d.ts → vite-env.d.ts} +0 -4
  223. package/templates/template/frontend/vite.config.ts +6 -2
  224. package/templates/template/gitignore +1 -1
  225. package/templates/template/package.json +1 -2
  226. package/templates/template/pnpm-workspace.yaml +0 -1
  227. package/templates/template/scripts/example.ts +3 -3
  228. package/templates/template/tsconfig.json +1 -1
  229. package/templates/views/AppView.tsx.tmpl +4 -4
  230. package/templates/views/EntityView.tsx.tmpl +3 -4
  231. package/dist/api-keys-Dfw5-9s1.js.map +0 -1
  232. package/dist/apps-MKQbgDtN.js.map +0 -1
  233. package/dist/build-BuKTnec8.js.map +0 -1
  234. package/dist/bundle-BAH4FCju.js.map +0 -1
  235. package/dist/cloud-Cj5ey3l_.js.map +0 -1
  236. package/dist/collection-drift-BKj_BoMq.js +0 -106
  237. package/dist/collection-drift-BKj_BoMq.js.map +0 -1
  238. package/dist/collections-dir-DlvDhime.js +0 -69
  239. package/dist/collections-dir-DlvDhime.js.map +0 -1
  240. package/dist/console-CdwIYOMV.js.map +0 -1
  241. package/dist/context-AXdAh-q8.js.map +0 -1
  242. package/dist/db-DBbKpjYX.js.map +0 -1
  243. package/dist/derive-ae9UOoOB.js.map +0 -1
  244. package/dist/dev-C93d4QIv.js.map +0 -1
  245. package/dist/dev-preflight-Cxv3TiD1.js.map +0 -1
  246. package/dist/doctor-BBPQUO2g.js.map +0 -1
  247. package/dist/eject-DABcDnPN.js.map +0 -1
  248. package/dist/fold-static-BWzxNn06.js.map +0 -1
  249. package/dist/generate-view-IFwCADvb.js.map +0 -1
  250. package/dist/generate_sdk-DNmNuFuW.js.map +0 -1
  251. package/dist/init-vL1DWOeC.js.map +0 -1
  252. package/dist/last-dev-database-DpW5dfoX.js +0 -2
  253. package/dist/manifest-BtzDy7KQ.js.map +0 -1
  254. package/dist/path-flags-DNvtEi2-.js +0 -92
  255. package/dist/path-flags-DNvtEi2-.js.map +0 -1
  256. package/dist/project-CasK56vN.js.map +0 -1
  257. package/dist/pull-DDMpsZ5r.js.map +0 -1
  258. package/dist/resolve-D647F1LA.js +0 -2
  259. package/dist/schema-DtLPsXbT.js.map +0 -1
  260. package/dist/schema-reconcile-DkArN9jF.js +0 -2
  261. package/dist/skills-CbwV6vw_.js.map +0 -1
  262. package/dist/status-BREvtzJm.js.map +0 -1
  263. package/dist/storage-CO9ouK76.js.map +0 -1
  264. package/dist/utils/collection-drift.d.ts +0 -27
  265. package/dist/utils/collections-dir.d.ts +0 -14
  266. package/dist/verify-Y3rWSgfA.js +0 -730
  267. package/dist/verify-Y3rWSgfA.js.map +0 -1
  268. package/templates/overlays/baas/config/index.ts +0 -24
  269. package/templates/overlays/baas/config/package.json +0 -30
  270. package/templates/template/config/cms.d.ts +0 -15
  271. package/templates/template/config/collections/authors.ts +0 -47
  272. package/templates/template/config/collections/index.ts +0 -44
  273. package/templates/template/config/collections/posts.ts +0 -94
  274. package/templates/template/config/collections/presets/blank/index.ts +0 -5
  275. package/templates/template/config/collections/presets/ecommerce/categories.ts +0 -42
  276. package/templates/template/config/collections/presets/ecommerce/index.ts +0 -31
  277. package/templates/template/config/collections/presets/ecommerce/orders.ts +0 -78
  278. package/templates/template/config/collections/presets/ecommerce/products.ts +0 -73
  279. package/templates/template/config/collections/tags.ts +0 -27
  280. package/templates/template/config/collections/users.ts +0 -149
  281. package/templates/template/config/frontend-assets.d.ts +0 -17
  282. package/templates/template/config/index.ts +0 -12
  283. package/templates/template/config/package.json +0 -30
  284. package/templates/template/config/tsconfig.json +0 -35
  285. /package/templates/eject/{config → backend}/resources.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-DwFDI1iU.js","names":[],"sources":["../src/commands/schema-reconcile.ts","../src/commands/schema.ts"],"sourcesContent":["/**\n * CLI command: rebase schema reconcile\n *\n * The reviewed step for what boot will not do. Boot only ever adds, so a\n * column made nullable keeps its NOT NULL, and a column removed from a table\n * leaves it behind, with its data, and blocking inserts if it was\n * required. This asks the running backend for the plan that fixes both, prints\n * it, and applies it only once confirmed.\n *\n * Through the backend rather than a database URL, because on Rebase Cloud the\n * backend is the one thing that can reach the database — and because it plans\n * against the tables it actually runs, not the ones in this checkout.\n * Columns are dropped only when named with `--drop`; the confirmation sends\n * the plan's digest, so the server runs exactly the statements printed here.\n */\nimport arg from \"arg\";\nimport chalk from \"chalk\";\nimport readline from \"node:readline/promises\";\nimport { RebaseApiError } from \"@rebasepro/client\";\nimport type { SchemaReconcilePlan } from \"@rebasepro/types\";\nimport { requireProjectRoot, readEnvFile } from \"../utils/project\";\nimport { UsageError } from \"../utils/args\";\nimport { cliUserAgent } from \"../utils/version\";\nimport { describeFailure, requireBackendUrl } from \"./api-keys\";\n\nexport const RECONCILE_USAGE = \"rebase schema reconcile [--drop <table>.<column>]... [--yes]\";\n\nexport function parseReconcileArgs(rawArgs: string[]): { drop: string[]; yes: boolean } {\n const flags = arg({ \"--drop\": [String], \"--yes\": Boolean, \"-y\": \"--yes\" }, { argv: rawArgs.slice(2) });\n if (flags._.length > 0) throw new UsageError(`Unexpected argument \"${flags._[0]}\". Usage: ${RECONCILE_USAGE}`);\n return { drop: flags[\"--drop\"] ?? [], yes: flags[\"--yes\"] === true };\n}\n\n/** The plan, as a person reviews it. Returned as lines so it can be tested. */\nexport function describeReconcilePlan(plan: SchemaReconcilePlan): string[] {\n const lines: string[] = [];\n for (const r of plan.relaxed) {\n const why = r.undeclared\n ? `\"${r.collection}\" does not declare it, and every insert fails on it; its data stays`\n : `nullable in \"${r.collection}\", NOT NULL in the database`;\n lines.push(` ${chalk.cyan(\"relax\")} ${r.table}.${r.column} ${chalk.gray(why)}`);\n }\n for (const d of plan.dropped) {\n const rows = d.rowsWithValue === undefined ? \"\" : `${d.rowsWithValue.toLocaleString(\"en-US\")} row(s) hold a value`;\n lines.push(` ${chalk.red(\"drop\")} ${d.table}.${d.column} ${chalk.red(rows)}`);\n }\n const kept = plan.undeclared.filter(u =>\n !plan.dropped.some(d => d.table === u.table && d.column === u.column)\n && !plan.relaxed.some(r => r.undeclared && r.table === u.table && r.column === u.column));\n for (const u of kept) {\n const note = u.blocksInserts\n ? chalk.yellow(\"NOT NULL with no default: every insert fails until it is dropped or relaxed\")\n : chalk.gray(\"no table declares it; kept\");\n lines.push(` ${chalk.gray(\"keep\")} ${u.table}.${u.column} ${note}`);\n }\n return lines;\n}\n\ninterface Backend {\n baseUrl: string;\n post<T>(path: string, body: unknown): Promise<T>;\n}\n\n/** The project's backend, holding the service key. */\nfunction connect(): Backend {\n const projectRoot = requireProjectRoot();\n const env = readEnvFile(projectRoot);\n const serviceKey = env.SERVICE_KEY || env.REBASE_SERVICE_KEY;\n if (!serviceKey) {\n console.error(chalk.red(\"✗ REBASE_SERVICE_KEY not found in .env — required to change the database's schema.\"));\n process.exit(1);\n }\n const baseUrl = requireBackendUrl(env, projectRoot).replace(/\\/+$/, \"\");\n return {\n baseUrl,\n async post<T>(path: string, body: unknown): Promise<T> {\n let response: Response;\n try {\n response = await fetch(`${baseUrl}/api/admin/schema/reconcile${path}`, {\n method: \"POST\",\n headers: {\n \"Authorization\": `Bearer ${serviceKey}`,\n \"Accept\": \"application/json\",\n \"Content-Type\": \"application/json\",\n \"User-Agent\": cliUserAgent()\n },\n body: JSON.stringify(body)\n });\n } catch (error: unknown) {\n throw new RebaseApiError(error instanceof Error ? error.message : String(error), { status: 0, code: \"NETWORK_ERROR\" });\n }\n const answer: unknown = await response.json().catch(() => undefined);\n if (!response.ok) {\n const error = answer && typeof answer === \"object\" && \"error\" in answer && answer.error && typeof answer.error === \"object\"\n ? answer.error as { message?: unknown; code?: unknown; details?: unknown }\n : undefined;\n throw new RebaseApiError(\n typeof error?.message === \"string\" ? error.message : `The server answered ${response.status}.`,\n { status: response.status, code: typeof error?.code === \"string\" ? error.code : undefined, details: error?.details }\n );\n }\n return answer as T;\n }\n };\n}\n\nfunction fail(action: string, error: unknown, baseUrl: string): never {\n for (const line of describeFailure(action, error, baseUrl)) {\n console.error(line.startsWith(\"✗\") ? chalk.red(line) : chalk.gray(line));\n }\n if (error instanceof RebaseApiError && error.status === 404) {\n console.error(chalk.gray(\" This backend has no reconcile route: it needs a runtime that has `rebase schema reconcile`.\"));\n }\n process.exit(1);\n}\n\nexport async function schemaReconcileCommand(rawArgs: string[]): Promise<void> {\n const { drop, yes } = parseReconcileArgs(rawArgs);\n const backend = connect();\n\n let plan: SchemaReconcilePlan;\n try {\n plan = await backend.post<SchemaReconcilePlan>(\"/plan\", { drop });\n } catch (error) {\n fail(\"Failed to plan the reconcile\", error, backend.baseUrl);\n }\n\n console.log(chalk.bold(`\\nSchema reconcile for ${backend.baseUrl}\\n`));\n const described = describeReconcilePlan(plan);\n if (described.length > 0) console.log(described.join(\"\\n\"));\n\n if (plan.problems.length > 0) {\n console.error(chalk.red(\"\\n✗ This plan cannot be applied:\"));\n for (const problem of plan.problems) console.error(chalk.red(` • ${problem}`));\n process.exit(1);\n }\n if (plan.statements.length === 0) {\n console.log(chalk.green(\"✓ Nothing to do: the database already matches what the tables declare.\"));\n }\n if (plan.undeclared.length > plan.dropped.length) {\n console.log(chalk.gray(\" To drop a column no table declares, name it: --drop <table>.<column>\"));\n }\n if (plan.statements.length === 0) return;\n\n console.log(chalk.bold(\"\\nStatements\"));\n for (const statement of plan.statements) console.log(` ${statement}`);\n if (plan.dropped.length > 0) {\n console.log(chalk.red(\"\\n Dropping a column destroys its data. Back the database up first if you may want it back.\"));\n }\n\n if (!yes) {\n if (!process.stdin.isTTY) {\n console.error(chalk.red(\"\\n✗ Not applied: confirming needs a terminal. Re-run with --yes once you have read the plan.\"));\n process.exit(1);\n }\n const rl = readline.createInterface({ input: process.stdin, output: process.stdout });\n const answer = (await rl.question(`\\nApply ${plan.statements.length} statement(s)? Type \"yes\" to continue: `)).trim();\n rl.close();\n if (answer !== \"yes\") {\n console.log(chalk.gray(\"Aborted. Nothing was changed.\"));\n return;\n }\n }\n\n try {\n const result = await backend.post<{ applied: string[] }>(\"/apply\", { drop, confirm: plan.digest });\n console.log(chalk.green(`✓ Applied ${result.applied.length} statement(s).`));\n } catch (error) {\n if (error instanceof RebaseApiError && error.code === \"SCHEMA_RECONCILE_STALE\") {\n console.error(chalk.red(\"✗ Not applied: the database or the tables changed since this plan was made. Run it again to review the new plan.\"));\n process.exit(1);\n }\n fail(\"Failed to apply the reconcile\", error, backend.baseUrl);\n }\n}\n","/**\n * CLI command: rebase schema <action>\n */\nimport arg from \"arg\";\nimport chalk from \"chalk\";\nimport { ensureDockerDatabase, spawnDriverCli } from \"./db\";\nimport {\n requireProjectRoot,\n requireBackendDir,\n getActiveBackendPlugin,\n resolvePluginCliScript,\n resolveTsx,\n findEnvFile,\n exitDependenciesNotInstalled\n} from \"../utils/project\";\nimport { recordEvent } from \"../telemetry\";\nimport { wantsHelp } from \"../utils/args\";\nimport { reportSpawnFailure } from \"../utils/spawn-error\";\nimport { argsFromCommand } from \"../utils/command-words\";\nimport { unknownCommand } from \"../utils/unknown-command\";\nimport { DEV_DATABASE_KIND_ENV, devDatabaseKind, managedNotices, prepareDatabaseEnv } from \"../dev-db/prepare\";\nimport { absolutizeLocalPathArgs } from \"./db\";\nimport { SCHEMA_DIR_FLAG_HELP, refuseMissingSchemaDir, refuseRemovedCollectionsFlag } from \"../utils/path-flags\";\nimport { schemaDirArgs } from \"../utils/schema-dir\";\nimport { RECONCILE_USAGE } from \"./schema-reconcile\";\n\n/**\n * The line handed to the driver, its paths resolved from where the command was\n * run (the driver runs in `backend/`). `--schema` is left alone: on\n * `introspect` it names a Postgres schema, not a file.\n */\nexport function schemaDriverArgs(rawArgs: string[], cwd: string): string[] {\n return absolutizeLocalPathArgs(argsFromCommand(rawArgs, \"schema\"), cwd, [\"--schema-dir\", \"--output\", \"-o\", \"--out\"]);\n}\n\nexport async function schemaCommand(subcommand: string | undefined, rawArgs: string[]): Promise<void> {\n // `--help` is answered here, before `requireProjectRoot` and before the\n // driver is spawned — the same shape `db.ts` already uses, and for the same\n // reason.\n //\n // `cli.ts` rewrites the subcommand to `\"--help\"` only when the user named\n // none, so `rebase schema --help` was covered and `rebase schema generate\n // --help` was not: the flag travelled into `rawArgs.slice(2)` and reached\n // the driver, whose own `schemaCommand` has no `--help` case. It *ran the\n // generator* — overwriting `src/schema.generated.ts` — for a flag whose\n // entire job is to print text. Worse, the first thing it hit outside a\n // project was `requireProjectRoot`, so `rebase schema introspect --help` in\n // an empty directory exited 1 with \"Could not find a Rebase project root\":\n // help you cannot read until you already have a project is help for nobody.\n if (!subcommand || subcommand === \"--help\" || wantsHelp(rawArgs)) {\n printSchemaHelp(subcommand === \"--help\" ? undefined : subcommand);\n return;\n }\n\n // A typo is answered here, in the same words every other family uses.\n //\n // It used to travel to the driver, which said the bare line `Unknown schema\n // command.` — no list, no pointer, no did-you-mean, for a family with three\n // subcommands. The set comes from the help table, so what a typo is measured\n // against and what `--help` prints cannot drift apart.\n if (!SCHEMA_ACTION_HELP[subcommand]) {\n unknownCommand(subcommand, Object.keys(SCHEMA_ACTION_HELP), \"schema\");\n }\n\n // Before anything else runs.\n refuseRemovedCollectionsFlag(rawArgs.slice(2), `schema ${subcommand}`);\n\n const projectRoot = requireProjectRoot();\n\n // Talks to the running backend, not the driver: on Rebase Cloud the\n // backend is the only thing that reaches the database.\n if (subcommand === \"reconcile\") {\n void recordEvent(\"cli.schema\", { subcommand }, { projectRoot });\n const { schemaReconcileCommand } = await import(\"./schema-reconcile\");\n await schemaReconcileCommand(rawArgs);\n return;\n }\n\n // Fire-and-forget, and a no-op unless the developer opted in. Never awaited:\n // the command is what the user is waiting for, and a slow collector must not\n // sit in front of it.\n void recordEvent(\"cli.schema\", { subcommand: subcommand ?? \"none\" }, { projectRoot });\n const backendDir = requireBackendDir(projectRoot);\n\n const activePlugin = getActiveBackendPlugin(backendDir);\n if (!activePlugin) {\n console.error(chalk.red(\"✗ Could not detect an active database plugin.\"));\n console.error(chalk.gray(\" Make sure a package like @rebasepro/server-postgres is installed in backend/package.json.\"));\n process.exit(1);\n }\n\n const pluginCli = resolvePluginCliScript(backendDir, activePlugin);\n if (!pluginCli) {\n exitDependenciesNotInstalled(projectRoot);\n }\n\n // Set up environment with DOTENV_CONFIG_PATH\n const envFile = findEnvFile(projectRoot);\n const env: Record<string, string> = { ...process.env as Record<string, string> };\n if (envFile) {\n env.DOTENV_CONFIG_PATH = envFile;\n }\n // Which database this project is on, so the driver's closing line does not\n // recommend a command that database refuses. A pure decision — nothing is\n // started, which matters here above all: `schema generate` reads the\n // schema directory and writes one file, and booting a database to run it would be a\n // side effect nobody asked for.\n env[DEV_DATABASE_KIND_ENV] = devDatabaseKind(projectRoot) ?? \"\";\n\n refuseMissingSchemaDir(rawArgs, process.cwd(), backendDir);\n\n // `introspect` is the one schema command that reads a database, and it\n // reads the project's — resolved the way every `db` command resolves it,\n // started if that is what it takes. It used to pass `.env` and nothing\n // else, so on the managed database or after `rebase dev --docker` (with\n // the scaffold's DATABASE_URL commented out, on purpose) it said\n // \"DATABASE_URL is not set\", and `--docker` and `--database-url` passed the\n // flag check only to be ignored.\n if (subcommand === \"introspect\") {\n const flags = arg(\n { \"--database-url\": String, \"--docker\": Boolean },\n { argv: rawArgs.slice(2), permissive: true }\n );\n await ensureDockerDatabase(projectRoot, rawArgs);\n const prepared = await prepareDatabaseEnv(projectRoot, {\n flagUrl: flags[\"--database-url\"] ?? null,\n flagDocker: flags[\"--docker\"] === true,\n onProgress: (message) => console.log(chalk.gray(` ${message}`))\n });\n Object.assign(env, prepared.env);\n env[DEV_DATABASE_KIND_ENV] = prepared.database.kind;\n for (const line of managedNotices(prepared)) console.log(chalk.gray(` ${line}`));\n }\n\n try {\n // The one spawn, shared with `db`. This file used to carry its own copy\n // of the tsx-or-node decision; three copies of that rule existed and two\n // were fixed while the third went on spawning plain node.\n const driverArgs = schemaDriverArgs(rawArgs, process.cwd());\n await spawnDriverCli(\n { projectRoot, backendDir, pluginCli, env },\n [...driverArgs, ...schemaDirArgs(projectRoot, driverArgs)]\n );\n } catch (error) {\n // A child that ran and exited non-zero already printed its diagnostics\n // through inherited stdio; a child that never started (ENOENT on tsx,\n // EACCES on the script) printed nothing at all, and this used to exit 1\n // in silence.\n reportSpawnFailure(error);\n process.exit(1);\n }\n}\n\n/** One page per subcommand, so `rebase schema <action> --help` says something. */\nconst SCHEMA_ACTION_HELP: Record<string, { usage: string; summary: string; notes?: string[] }> = {\n generate: {\n usage: \"rebase schema generate [--schema-dir <dir>] [--output <file>] [--watch]\",\n summary: \"Generate the Drizzle schema from the tables in backend/schema.\",\n notes: [\"--watch regenerates on every change to a schema file.\", `--schema-dir <dir>: ${SCHEMA_DIR_FLAG_HELP}.`]\n },\n introspect: {\n usage: \"rebase schema introspect [--schema-dir <dir>] [--schema <name>] [--force] [--data-inference | --no-data-inference]\",\n summary: \"Read an existing database and write its tables as defineTable modules into backend/schema.\",\n notes: [\n \"--force overwrites table modules that are already there.\",\n `--schema-dir <dir>: where the tables are written — ${SCHEMA_DIR_FLAG_HELP}.`,\n \"--data-inference samples up to 100 rows per table to detect formats, constraints and UI settings; \"\n + \"--no-data-inference reads the structure only. Without either it asks, and without a terminal \"\n + \"it reads the structure only.\",\n \"Reads this project's database, the one `rebase db url` prints: --database-url <url> names another; \"\n + \"--docker uses the compose one, starting it if needed.\"\n ]\n },\n reconcile: {\n usage: RECONCILE_USAGE,\n summary: \"Relax and drop what boot will not: NOT NULL on columns made nullable, and columns no table declares.\",\n notes: [\n \"Plans on the running backend (the one `.env` and the cloud link point at), prints the plan, and applies it once you type yes.\",\n \"A column is dropped only when named: --drop voice_cache.wav. Each drop shows how many rows hold a value.\",\n \"--yes skips the prompt, for a plan already read. Needs REBASE_SERVICE_KEY in .env.\"\n ]\n },\n stale: {\n usage: \"rebase schema stale [--schema-dir <dir>] [--output <file>] [--fix]\",\n summary: \"Report generated schema files that no longer match the tables.\",\n notes: [\"--fix regenerates them instead of only reporting.\"]\n }\n};\n\n/** Every subcommand the family dispatches — the help table's keys. */\nexport const SCHEMA_SUBCOMMANDS = Object.keys(SCHEMA_ACTION_HELP);\n\nfunction printSchemaHelp(action?: string) {\n const entry = action ? SCHEMA_ACTION_HELP[action] : undefined;\n if (entry) {\n console.log(`\n${chalk.bold(`rebase schema ${action}`)}\n\n ${entry.summary}\n\n${chalk.green.bold(\"Usage\")}\n ${chalk.blue(entry.usage)}\n${entry.notes?.length ? `\\n${chalk.green.bold(\"Notes\")}\\n${entry.notes.map(n => ` ${chalk.gray(`• ${n}`)}`).join(\"\\n\")}\\n` : \"\"}\n${chalk.gray(\"Run `rebase schema --help` for every subcommand.\")}\n`);\n return;\n }\n\n console.log(`\n${chalk.bold(\"rebase schema\")} — Schema management commands\n\n${chalk.green.bold(\"Usage\")}\n rebase schema ${chalk.blue(\"<command>\")} [options]\n\n${chalk.green.bold(\"Commands\")}\n ${chalk.gray(\"(Commands are provided by your active database driver plugin)\")}\n ${chalk.blue.bold(\"generate\")} Generate the Drizzle schema from the tables in backend/schema\n ${chalk.blue.bold(\"introspect\")} Introspect an existing database into defineTable modules in backend/schema\n ${chalk.blue.bold(\"stale\")} Report generated schema files that no longer match the tables\n ${chalk.blue.bold(\"reconcile\")} Relax NOT NULL and drop columns the tables no longer declare, after review\n\n${chalk.green.bold(\"generate / stale Options\")}\n ${chalk.blue(\"--schema-dir\")} ${SCHEMA_DIR_FLAG_HELP}\n ${chalk.blue(\"--output, -o\")} Output path for generated schema\n ${chalk.blue(\"--watch, -w\")} Watch for changes and regenerate automatically\n\n${chalk.green.bold(\"introspect Options\")}\n ${chalk.blue(\"--schema-dir\")} Where the tables are written ${chalk.gray(\"(default: backend/schema)\")}\n ${chalk.blue(\"--schema\")} Postgres schema to read (default: public)\n ${chalk.blue(\"--force, -f\")} Overwrite table modules that already exist\n ${chalk.blue(\"--database-url\")} Read this database instead of the project's own\n ${chalk.blue(\"--docker\")} Read the compose database, starting it if needed\n ${chalk.blue(\"--data-inference\")} Sample rows to detect formats and constraints ${chalk.gray(\"(asked when omitted)\")}\n ${chalk.blue(\"--no-data-inference\")} Read the structure only, without asking\n\n${chalk.green.bold(\"stale Options\")}\n ${chalk.blue(\"--fix\")} Regenerate the stale files instead of only reporting them\n`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,kBAAkB;AAE/B,SAAgB,mBAAmB,SAAqD;CACpF,MAAM,QAAQ,IAAI;EAAE,UAAU,CAAC,MAAM;EAAG,SAAS;EAAS,MAAM;CAAQ,GAAG,EAAE,MAAM,QAAQ,MAAM,CAAC,EAAE,CAAC;CACrG,IAAI,MAAM,EAAE,SAAS,GAAG,MAAM,IAAI,WAAW,wBAAwB,MAAM,EAAE,GAAG,YAAY,iBAAiB;CAC7G,OAAO;EAAE,MAAM,MAAM,aAAa,CAAC;EAAG,KAAK,MAAM,aAAa;CAAK;AACvE;;AAGA,SAAgB,sBAAsB,MAAqC;CACvE,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,KAAK,KAAK,SAAS;EAC1B,MAAM,MAAM,EAAE,aACR,IAAI,EAAE,WAAW,uEACjB,gBAAgB,EAAE,WAAW;EACnC,MAAM,KAAK,KAAK,MAAM,KAAK,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,EAAE,OAAO,IAAI,MAAM,KAAK,GAAG,GAAG;CACrF;CACA,KAAK,MAAM,KAAK,KAAK,SAAS;EAC1B,MAAM,OAAO,EAAE,kBAAkB,KAAA,IAAY,KAAK,GAAG,EAAE,cAAc,eAAe,OAAO,EAAE;EAC7F,MAAM,KAAK,KAAK,MAAM,IAAI,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,EAAE,OAAO,IAAI,MAA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g.js";
2
+ import { C as resolveBackendPaths, _ as findBackendApp, a as DEFAULT_TABLES_DIR, b as loadManifest } from "./manifest-C3uLDrrJ.js";
3
+ import path from "path";
4
+ //#region src/utils/schema-dir.ts
5
+ /**
6
+ * Where this project's tables are declared: one answer for every command.
7
+ *
8
+ * `rebase.json`'s `apps.<backend>.tables` names the directory whose `index.ts`
9
+ * exports the tables (default `backend/schema`). Every command that reads the
10
+ * schema — the dev runtime and watcher, `rebase build`, `verify`, `doctor`,
11
+ * `generate-sdk`, `generate view`, `console`, and the driver's `db` / `schema`
12
+ * commands — asks here, so a project that moves the directory moves it for all
13
+ * of them. The previous layout had one resolver too, and still grew five
14
+ * commands that hardcoded `config/collections` beside it; this module is the
15
+ * only place the default is spelled.
16
+ *
17
+ * A directory typed on the command line still wins wherever a command takes
18
+ * one; this is only the default.
19
+ */
20
+ var schema_dir_exports = /* @__PURE__ */ __exportAll({
21
+ SCHEMA_DIR_FLAG: () => SCHEMA_DIR_FLAG,
22
+ resolveSchemaDir: () => resolveSchemaDir,
23
+ resolveTablesDir: () => resolveTablesDir,
24
+ schemaDirArgs: () => schemaDirArgs,
25
+ schemaDirFlag: () => schemaDirFlag
26
+ });
27
+ /**
28
+ * The flag that hands the driver CLI (`@rebasepro/server-postgres`) the schema
29
+ * directory, as an absolute path.
30
+ *
31
+ * The receiving end is the driver's own argument spec: when the driver slice
32
+ * renames its flag, this constant and {@link schemaDirFlag} are the only CLI
33
+ * lines that change.
34
+ */
35
+ var SCHEMA_DIR_FLAG = "--schema-dir";
36
+ /** The tables directory, relative to the project root, as the backend app declares it. */
37
+ function resolveTablesDir(projectRoot) {
38
+ try {
39
+ const backend = findBackendApp(loadManifest(projectRoot).manifest);
40
+ if (backend) return resolveBackendPaths(backend.app, projectRoot).tables;
41
+ } catch {}
42
+ return DEFAULT_TABLES_DIR;
43
+ }
44
+ /** The tables directory, absolute. */
45
+ function resolveSchemaDir(projectRoot) {
46
+ return path.join(projectRoot, resolveTablesDir(projectRoot));
47
+ }
48
+ /**
49
+ * The driver argv naming `dir` as the schema directory: `["--schema-dir", dir]`.
50
+ *
51
+ * The whole CLI → driver contract for this flag, in one function. `dir` is
52
+ * absolute — the driver runs with `cwd: backend/`, so a relative path would be
53
+ * resolved from a directory the user never typed it in.
54
+ */
55
+ function schemaDirFlag(dir) {
56
+ return [SCHEMA_DIR_FLAG, dir];
57
+ }
58
+ /** Whether a command line already names a schema directory. */
59
+ function namesSchemaDir(args) {
60
+ return args.some((arg) => arg === "--schema-dir" || arg.startsWith(`--schema-dir=`));
61
+ }
62
+ /**
63
+ * The driver commands that read the schema directory. Keyed as the driver's
64
+ * argv starts: domain, then subcommand (or the bare command for the
65
+ * single-word ones).
66
+ */
67
+ var DRIVER_COMMANDS_READING_SCHEMA = /* @__PURE__ */ new Set([
68
+ "db push",
69
+ "db generate",
70
+ "db migrate",
71
+ "schema generate",
72
+ "schema introspect",
73
+ "schema stale",
74
+ "doctor",
75
+ "console"
76
+ ]);
77
+ /**
78
+ * {@link schemaDirFlag} for a driver command line, or nothing.
79
+ *
80
+ * `driverArgs` is the line as the driver gets it (`["db", "push", …]`,
81
+ * `["doctor", …]`). Nothing for a command that does not read the schema,
82
+ * nothing when the line already names a directory, and nothing when the
83
+ * project keeps its tables at the default — the driver's own default is
84
+ * `backend/schema` (`schema` from its `cwd`), so a conventional project's
85
+ * command lines stay as short as they were.
86
+ */
87
+ function schemaDirArgs(projectRoot, driverArgs) {
88
+ const command = DRIVER_COMMANDS_READING_SCHEMA.has(driverArgs[0]) ? driverArgs[0] : `${driverArgs[0]} ${driverArgs[1]}`;
89
+ if (!DRIVER_COMMANDS_READING_SCHEMA.has(command)) return [];
90
+ if (namesSchemaDir(driverArgs)) return [];
91
+ const dir = resolveSchemaDir(projectRoot);
92
+ if (dir === path.join(projectRoot, "backend/schema")) return [];
93
+ return schemaDirFlag(dir);
94
+ }
95
+ //#endregion
96
+ export { schema_dir_exports as i, resolveSchemaDir as n, schemaDirArgs as r, SCHEMA_DIR_FLAG as t };
97
+
98
+ //# sourceMappingURL=schema-dir-Cd1kvYbf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-dir-Cd1kvYbf.js","names":[],"sources":["../src/utils/schema-dir.ts"],"sourcesContent":["/**\n * Where this project's tables are declared: one answer for every command.\n *\n * `rebase.json`'s `apps.<backend>.tables` names the directory whose `index.ts`\n * exports the tables (default `backend/schema`). Every command that reads the\n * schema — the dev runtime and watcher, `rebase build`, `verify`, `doctor`,\n * `generate-sdk`, `generate view`, `console`, and the driver's `db` / `schema`\n * commands — asks here, so a project that moves the directory moves it for all\n * of them. The previous layout had one resolver too, and still grew five\n * commands that hardcoded `config/collections` beside it; this module is the\n * only place the default is spelled.\n *\n * A directory typed on the command line still wins wherever a command takes\n * one; this is only the default.\n */\nimport path from \"path\";\nimport { DEFAULT_TABLES_DIR, findBackendApp, loadManifest, resolveBackendPaths } from \"../manifest\";\n\n/**\n * The flag that hands the driver CLI (`@rebasepro/server-postgres`) the schema\n * directory, as an absolute path.\n *\n * The receiving end is the driver's own argument spec: when the driver slice\n * renames its flag, this constant and {@link schemaDirFlag} are the only CLI\n * lines that change.\n */\nexport const SCHEMA_DIR_FLAG = \"--schema-dir\";\n\n/** The tables directory, relative to the project root, as the backend app declares it. */\nexport function resolveTablesDir(projectRoot: string): string {\n try {\n const backend = findBackendApp(loadManifest(projectRoot).manifest);\n if (backend) return resolveBackendPaths(backend.app, projectRoot).tables;\n } catch {\n // A malformed rebase.json is reported by the commands that own it; the\n // conventional layout is the answer until then.\n }\n return DEFAULT_TABLES_DIR;\n}\n\n/** The tables directory, absolute. */\nexport function resolveSchemaDir(projectRoot: string): string {\n return path.join(projectRoot, resolveTablesDir(projectRoot));\n}\n\n/**\n * The driver argv naming `dir` as the schema directory: `[\"--schema-dir\", dir]`.\n *\n * The whole CLI → driver contract for this flag, in one function. `dir` is\n * absolute — the driver runs with `cwd: backend/`, so a relative path would be\n * resolved from a directory the user never typed it in.\n */\nexport function schemaDirFlag(dir: string): string[] {\n return [SCHEMA_DIR_FLAG, dir];\n}\n\n/** Whether a command line already names a schema directory. */\nfunction namesSchemaDir(args: readonly string[]): boolean {\n return args.some(arg => arg === SCHEMA_DIR_FLAG || arg.startsWith(`${SCHEMA_DIR_FLAG}=`));\n}\n\n/**\n * The driver commands that read the schema directory. Keyed as the driver's\n * argv starts: domain, then subcommand (or the bare command for the\n * single-word ones).\n */\nconst DRIVER_COMMANDS_READING_SCHEMA = new Set([\n \"db push\",\n \"db generate\",\n // It stamps the policies the migration created as the tables' rules make them.\n \"db migrate\",\n \"schema generate\",\n // It writes the introspected tables there.\n \"schema introspect\",\n \"schema stale\",\n \"doctor\",\n \"console\"\n]);\n\n/**\n * {@link schemaDirFlag} for a driver command line, or nothing.\n *\n * `driverArgs` is the line as the driver gets it (`[\"db\", \"push\", …]`,\n * `[\"doctor\", …]`). Nothing for a command that does not read the schema,\n * nothing when the line already names a directory, and nothing when the\n * project keeps its tables at the default — the driver's own default is\n * `backend/schema` (`schema` from its `cwd`), so a conventional project's\n * command lines stay as short as they were.\n */\nexport function schemaDirArgs(projectRoot: string, driverArgs: readonly string[]): string[] {\n const command = DRIVER_COMMANDS_READING_SCHEMA.has(driverArgs[0])\n ? driverArgs[0]\n : `${driverArgs[0]} ${driverArgs[1]}`;\n if (!DRIVER_COMMANDS_READING_SCHEMA.has(command)) return [];\n if (namesSchemaDir(driverArgs)) return [];\n const dir = resolveSchemaDir(projectRoot);\n if (dir === path.join(projectRoot, DEFAULT_TABLES_DIR)) return [];\n return schemaDirFlag(dir);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAa,kBAAkB;;AAG/B,SAAgB,iBAAiB,aAA6B;CAC1D,IAAI;EACA,MAAM,UAAU,eAAe,aAAa,WAAW,CAAC,CAAC,QAAQ;EACjE,IAAI,SAAS,OAAO,oBAAoB,QAAQ,KAAK,WAAW,CAAC,CAAC;CACtE,QAAQ,CAGR;CACA,OAAO;AACX;;AAGA,SAAgB,iBAAiB,aAA6B;CAC1D,OAAO,KAAK,KAAK,aAAa,iBAAiB,WAAW,CAAC;AAC/D;;;;;;;;AASA,SAAgB,cAAc,KAAuB;CACjD,OAAO,CAAC,iBAAiB,GAAG;AAChC;;AAGA,SAAS,eAAe,MAAkC;CACtD,OAAO,KAAK,MAAK,QAAO,QAAA,kBAA2B,IAAI,WAAW,eAAqB,CAAC;AAC5F;;;;;;AAOA,IAAM,iDAAiC,IAAI,IAAI;CAC3C;CACA;CAEA;CACA;CAEA;CACA;CACA;CACA;AACJ,CAAC;;;;;;;;;;;AAYD,SAAgB,cAAc,aAAqB,YAAyC;CACxF,MAAM,UAAU,+BAA+B,IAAI,WAAW,EAAE,IAC1D,WAAW,KACX,GAAG,WAAW,GAAG,GAAG,WAAW;CACrC,IAAI,CAAC,+BAA+B,IAAI,OAAO,GAAG,OAAO,CAAC;CAC1D,IAAI,eAAe,UAAU,GAAG,OAAO,CAAC;CACxC,MAAM,MAAM,iBAAiB,WAAW;CACxC,IAAI,QAAQ,KAAK,KAAK,aAAA,gBAA+B,GAAG,OAAO,CAAC;CAChE,OAAO,cAAc,GAAG;AAC5B"}
@@ -0,0 +1,2 @@
1
+ import { i as schemaReconcileCommand } from "./schema-DwFDI1iU.js";
2
+ export { schemaReconcileCommand };
@@ -0,0 +1,73 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ //#region src/utils/schema-text.ts
4
+ /**
5
+ * The tables a schema directory declares, read as text — never imported.
6
+ *
7
+ * For the commands that must not run a project's code to answer a question
8
+ * about its files: `rebase doctor` (two tables claiming one slug) and `rebase
9
+ * generate view --collection` (does that table exist, before writing a view
10
+ * for it). A schema file may import anything the project depends on; reading
11
+ * it is enough to see each `defineTable("name", …)`.
12
+ */
13
+ /**
14
+ * Every module under the schema directory, depth first and sorted: what the
15
+ * loader would import. Tests, declaration files, dotfiles and `node_modules`
16
+ * are not modules of the schema.
17
+ */
18
+ function schemaModules(dir) {
19
+ const out = [];
20
+ const walk = (current) => {
21
+ let entries;
22
+ try {
23
+ entries = fs.readdirSync(current, { withFileTypes: true });
24
+ } catch {
25
+ return;
26
+ }
27
+ for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
28
+ if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
29
+ const full = path.join(current, entry.name);
30
+ if (entry.isDirectory()) walk(full);
31
+ else if (/\.(ts|js|mts|mjs)$/.test(entry.name) && !/\.(d|test|spec)\./.test(entry.name)) out.push(full);
32
+ }
33
+ };
34
+ walk(dir);
35
+ return out;
36
+ }
37
+ /**
38
+ * The slug of every table one schema file's source declares.
39
+ *
40
+ * Each `defineTable("name", …)` / `defineAuthTable` / `defineView` call is a
41
+ * table whose slug is its name, unless a `slug: "…"` appears before the next
42
+ * definition. A computed name or slug is simply not seen, which is the right
43
+ * failure for checks that only ever report or refuse.
44
+ */
45
+ function declaredTableSlugs(source) {
46
+ const calls = [...source.matchAll(/\bdefine(?:Auth)?(?:Table|View)\s*(?:<[^>]*>)?\(\s*["'`]([^"'`]+)["'`]/g)];
47
+ return calls.map((call, i) => {
48
+ const end = i + 1 < calls.length ? calls[i + 1].index : source.length;
49
+ const body = source.slice(call.index + call[0].length, end);
50
+ return /\bslug:\s*["'`]([^"'`]+)["'`]/.exec(body)?.[1] ?? call[1];
51
+ });
52
+ }
53
+ /** Every table the schema directory's files declare, in file order. */
54
+ function declaredTables(schemaDir) {
55
+ const tables = [];
56
+ for (const file of schemaModules(schemaDir)) {
57
+ let source;
58
+ try {
59
+ source = fs.readFileSync(file, "utf-8");
60
+ } catch {
61
+ continue;
62
+ }
63
+ for (const slug of declaredTableSlugs(source)) tables.push({
64
+ slug,
65
+ file
66
+ });
67
+ }
68
+ return tables;
69
+ }
70
+ //#endregion
71
+ export { declaredTables as t };
72
+
73
+ //# sourceMappingURL=schema-text-CpNrsuMe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-text-CpNrsuMe.js","names":[],"sources":["../src/utils/schema-text.ts"],"sourcesContent":["/**\n * The tables a schema directory declares, read as text — never imported.\n *\n * For the commands that must not run a project's code to answer a question\n * about its files: `rebase doctor` (two tables claiming one slug) and `rebase\n * generate view --collection` (does that table exist, before writing a view\n * for it). A schema file may import anything the project depends on; reading\n * it is enough to see each `defineTable(\"name\", …)`.\n */\nimport fs from \"fs\";\nimport path from \"path\";\n\n/** A table one schema file declares. */\nexport interface DeclaredTable {\n /** The API slug: the definition's name, or its `slug: \"…\"` override. */\n slug: string;\n /** The file it is declared in, absolute. */\n file: string;\n}\n\n/**\n * Every module under the schema directory, depth first and sorted: what the\n * loader would import. Tests, declaration files, dotfiles and `node_modules`\n * are not modules of the schema.\n */\nexport function schemaModules(dir: string): string[] {\n const out: string[] = [];\n const walk = (current: string): void => {\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(current, { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n if (entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue;\n const full = path.join(current, entry.name);\n if (entry.isDirectory()) walk(full);\n else if (/\\.(ts|js|mts|mjs)$/.test(entry.name) && !/\\.(d|test|spec)\\./.test(entry.name)) out.push(full);\n }\n };\n walk(dir);\n return out;\n}\n\n/**\n * The slug of every table one schema file's source declares.\n *\n * Each `defineTable(\"name\", …)` / `defineAuthTable` / `defineView` call is a\n * table whose slug is its name, unless a `slug: \"…\"` appears before the next\n * definition. A computed name or slug is simply not seen, which is the right\n * failure for checks that only ever report or refuse.\n */\nexport function declaredTableSlugs(source: string): string[] {\n const calls = [...source.matchAll(/\\bdefine(?:Auth)?(?:Table|View)\\s*(?:<[^>]*>)?\\(\\s*[\"'`]([^\"'`]+)[\"'`]/g)];\n return calls.map((call, i) => {\n const end = i + 1 < calls.length ? calls[i + 1].index : source.length;\n const body = source.slice(call.index + call[0].length, end);\n return /\\bslug:\\s*[\"'`]([^\"'`]+)[\"'`]/.exec(body)?.[1] ?? call[1];\n });\n}\n\n/** Every table the schema directory's files declare, in file order. */\nexport function declaredTables(schemaDir: string): DeclaredTable[] {\n const tables: DeclaredTable[] = [];\n for (const file of schemaModules(schemaDir)) {\n let source: string;\n try {\n source = fs.readFileSync(file, \"utf-8\");\n } catch {\n continue;\n }\n for (const slug of declaredTableSlugs(source)) tables.push({ slug, file });\n }\n return tables;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,SAAgB,cAAc,KAAuB;CACjD,MAAM,MAAgB,CAAC;CACvB,MAAM,QAAQ,YAA0B;EACpC,IAAI;EACJ,IAAI;GACA,UAAU,GAAG,YAAY,SAAS,EAAE,eAAe,KAAK,CAAC;EAC7D,QAAQ;GACJ;EACJ;EACA,KAAK,MAAM,SAAS,QAAQ,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC,GAAG;GACtE,IAAI,MAAM,KAAK,WAAW,GAAG,KAAK,MAAM,SAAS,gBAAgB;GACjE,MAAM,OAAO,KAAK,KAAK,SAAS,MAAM,IAAI;GAC1C,IAAI,MAAM,YAAY,GAAG,KAAK,IAAI;QAC7B,IAAI,qBAAqB,KAAK,MAAM,IAAI,KAAK,CAAC,oBAAoB,KAAK,MAAM,IAAI,GAAG,IAAI,KAAK,IAAI;EAC1G;CACJ;CACA,KAAK,GAAG;CACR,OAAO;AACX;;;;;;;;;AAUA,SAAgB,mBAAmB,QAA0B;CACzD,MAAM,QAAQ,CAAC,GAAG,OAAO,SAAS,yEAAyE,CAAC;CAC5G,OAAO,MAAM,KAAK,MAAM,MAAM;EAC1B,MAAM,MAAM,IAAI,IAAI,MAAM,SAAS,MAAM,IAAI,EAAE,CAAC,QAAQ,OAAO;EAC/D,MAAM,OAAO,OAAO,MAAM,KAAK,QAAQ,KAAK,EAAE,CAAC,QAAQ,GAAG;EAC1D,OAAO,gCAAgC,KAAK,IAAI,CAAC,GAAG,MAAM,KAAK;CACnE,CAAC;AACL;;AAGA,SAAgB,eAAe,WAAoC;CAC/D,MAAM,SAA0B,CAAC;CACjC,KAAK,MAAM,QAAQ,cAAc,SAAS,GAAG;EACzC,IAAI;EACJ,IAAI;GACA,SAAS,GAAG,aAAa,MAAM,OAAO;EAC1C,QAAQ;GACJ;EACJ;EACA,KAAK,MAAM,QAAQ,mBAAmB,MAAM,GAAG,OAAO,KAAK;GAAE;GAAM;EAAK,CAAC;CAC7E;CACA,OAAO;AACX"}
@@ -1,4 +1,6 @@
1
- import { E as unknownCommand, b as UsageError, c as findProjectRoot, w as wantsHelp, x as parseCommandArgs } from "./project-CasK56vN.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ import { a as wantsHelp, n as parseCommandArgs, s as unknownCommand, t as UsageError } from "./args-CaCcrYE1.js";
3
+ import { c as findProjectRoot } from "./project-CLcF5i8c.js";
2
4
  import chalk from "chalk";
3
5
  import fs from "fs";
4
6
  import os from "os";
@@ -152,6 +154,25 @@ function writeRootPointers(projectDir, templateDir) {
152
154
  }
153
155
  //#endregion
154
156
  //#region src/commands/skills.ts
157
+ var skills_exports = /* @__PURE__ */ __exportAll({
158
+ AGENTS: () => AGENTS,
159
+ AGENT_KEYS: () => AGENT_KEYS,
160
+ RETIRED_SKILLS: () => RETIRED_SKILLS,
161
+ SKILLS_MANIFEST: () => SKILLS_MANIFEST,
162
+ SKILLS_SUBCOMMANDS: () => SKILLS_SUBCOMMANDS,
163
+ detectAgents: () => detectAgents,
164
+ detectInstalledAgents: () => detectInstalledAgents,
165
+ installForAgent: () => installForAgent,
166
+ installSkills: () => installSkills,
167
+ isAgentKey: () => isAgentKey,
168
+ loadBundledSkills: () => loadBundledSkills,
169
+ loadSkills: () => loadSkills,
170
+ parseSkillsInstallLine: () => parseSkillsInstallLine,
171
+ renderSkillIndex: () => renderSkillIndex,
172
+ reportRootPointers: () => reportRootPointers,
173
+ resolveAgentNames: () => resolveAgentNames,
174
+ skillsCommand: () => skillsCommand
175
+ });
155
176
  var require = createRequire(import.meta.url);
156
177
  /**
157
178
  * Supported agent environments and their target directories.
@@ -405,15 +426,15 @@ function renderSkillIndex(skills, agentKey) {
405
426
  "",
406
427
  `This project uses [Rebase](https://rebase.pro). ${skills.length} reference skills are`,
407
428
  "installed beside this file. **Read the one that covers the task before writing",
408
- "code** — they are the difference between a collection that compiles and one that",
409
- "does not.",
429
+ "code** — they are the difference between a table the server accepts and one it",
430
+ "refuses.",
410
431
  "",
411
432
  "| Skill | Covers | Read |",
412
433
  "|---|---|---|",
413
434
  rows,
414
435
  "",
415
436
  "Start with `rebase-basics` if you are not sure: it opens with the recipes for",
416
- "adding a collection, a function and an RLS rule, and names the commands.",
437
+ "adding a table, a function and an RLS rule, and names the commands.",
417
438
  ""
418
439
  ].join("\n");
419
440
  }
@@ -496,6 +517,14 @@ function detectInstalledAgents(home = os.homedir()) {
496
517
  * as a rule.
497
518
  */
498
519
  var SKILLS_MANIFEST = ".rebase-skills.json";
520
+ /**
521
+ * Skills the bundle once shipped under these names and no longer does. An
522
+ * install with a manifest removes them by its record; this list reaches the
523
+ * installs made before manifests existed, which recorded nothing.
524
+ * `rebase-collections` became `rebase-tables` when the schema moved to
525
+ * `defineTable` (0.31).
526
+ */
527
+ var RETIRED_SKILLS = ["rebase-collections"];
499
528
  function sha256(bytes) {
500
529
  return createHash("sha256").update(bytes).digest("hex");
501
530
  }
@@ -582,6 +611,21 @@ function installForAgent(agentKey, skills, projectDir, options = {}) {
582
611
  fs.rmdirSync(dir);
583
612
  }
584
613
  }
614
+ const shipped = new Set(skills.map((skill) => skill.name));
615
+ for (const retired of RETIRED_SKILLS) {
616
+ if (shipped.has(retired)) continue;
617
+ const relPath = agent.transformFile(retired, "").fileName;
618
+ if (relPath in (previous?.files ?? {})) continue;
619
+ const target = path.join(targetBase, relPath);
620
+ if (!fs.existsSync(target)) continue;
621
+ if (/^name:[ \t]*["']?([\w-]+)["']?[ \t]*$/m.exec(fs.readFileSync(target, "utf-8").split("---")[1] ?? "")?.[1] !== retired) continue;
622
+ fs.rmSync(target);
623
+ removed.push(relPath);
624
+ for (let dir = path.dirname(target); dir.startsWith(targetBase + path.sep); dir = path.dirname(dir)) {
625
+ if (fs.readdirSync(dir).length > 0) break;
626
+ fs.rmdirSync(dir);
627
+ }
628
+ }
585
629
  fs.writeFileSync(path.join(targetBase, SKILLS_MANIFEST), JSON.stringify({
586
630
  version: 1,
587
631
  files: recorded
@@ -660,13 +704,13 @@ async function skillsHooks(rawArgs) {
660
704
  * one line per file.
661
705
  */
662
706
  async function installHooksAndReport(projectDir, force) {
663
- const { installAgentHooks, AGENT_HOOK_SCRIPT } = await import("./agent-setup-0uyfC7VX.js");
707
+ const { installAgentHooks, AGENT_HOOK_SCRIPT } = await import("./agent-setup-DqAcoDcn.js");
664
708
  const shown = (file) => path.relative(process.cwd(), path.join(projectDir, file)) || file;
665
709
  for (const { file, status } of installAgentHooks(projectDir, { force })) if (status === "added" || status === "replaced") console.log(` ${chalk.green("✓")} ${status === "added" ? "Wrote" : "Replaced"} ${chalk.gray(shown(file))}`);
666
710
  else if (status === "present") console.log(` ${chalk.green("✓")} ${chalk.gray(shown(file))} already in place`);
667
711
  else if (status === "kept") console.log(chalk.yellow(` ! ${shown(file)} was edited, so it was kept — pass --force to replace it with the shipped hook.`));
668
712
  else console.log(chalk.yellow(` ! ${shown(file)} is not plain JSON, so it was left alone — register ${AGENT_HOOK_SCRIPT} as a PostToolUse hook (matcher "Edit|MultiEdit|Write") by hand.`));
669
- console.log(chalk.gray(" Claude Code now runs `rebase verify --quiet` after each edit under config/collections/."));
713
+ console.log(chalk.gray(" Claude Code now runs `rebase verify --quiet` after each edit under backend/schema/ or frontend/src/cms/."));
670
714
  }
671
715
  /** `rebase skills install`'s whole line: the agents it names, `--mcp`, `--hooks` and `--force`. */
672
716
  function parseSkillsInstallLine(rawArgs) {
@@ -763,7 +807,7 @@ async function skillsInstall(rawArgs = []) {
763
807
  console.log(chalk.yellow(" Edited files were left as they are. To replace them with the bundle's copy:"));
764
808
  console.log(` ${chalk.cyan("rebase skills install --force")}`);
765
809
  }
766
- const { MCP_SERVER_NAME, ensureMcpDependency, mcpDependencyNote, mcpServerRegistered, writeMcpConfig, cliPackageRoot } = await import("./agent-setup-0uyfC7VX.js");
810
+ const { MCP_SERVER_NAME, ensureMcpDependency, mcpDependencyNote, mcpServerRegistered, writeMcpConfig, cliPackageRoot } = await import("./agent-setup-DqAcoDcn.js");
767
811
  const { detectPackageManager } = await import("./package-manager-DSEOwTqM.js").then((n) => n.r);
768
812
  const shownFile = (file) => path.relative(process.cwd(), path.join(projectDir, file)) || file;
769
813
  if (withMcp) {
@@ -818,7 +862,7 @@ ${chalk.green.bold("Options")}
818
862
  Servers already in the file are kept.
819
863
  ${chalk.blue("--hooks")} Also install the Claude Code guardrail: a PostToolUse hook in
820
864
  .claude/settings.json that runs ${chalk.cyan("rebase verify --quiet")} after each edit
821
- under config/collections/ and hands any problem back to the agent.
865
+ under backend/schema/ or frontend/src/cms/ and hands any problem back.
822
866
  ${chalk.cyan("rebase skills --hooks")} installs the hook alone.
823
867
  ${chalk.blue("--agent, -a")} Agent(s) to install for, skipping detection and the prompt.
824
868
  Repeat the flag or pass a comma-separated list, or ${chalk.bold("all")}.
@@ -845,6 +889,6 @@ function reportRootPointers(result) {
845
889
  if (result.refused !== null) console.log(chalk.gray(` No Rebase rules at the repository root: ${result.refused}.`));
846
890
  }
847
891
  //#endregion
848
- export { AGENTS, AGENT_KEYS, SKILLS_SUBCOMMANDS, detectInstalledAgents, installSkills, loadBundledSkills, reportRootPointers, resolveAgentNames, skillsCommand, writeRootPointers as t };
892
+ export { installSkills as a, reportRootPointers as c, writeRootPointers as d, detectInstalledAgents as i, resolveAgentNames as l, AGENT_KEYS as n, isAgentKey as o, SKILLS_MANIFEST as r, loadBundledSkills as s, AGENTS as t, skills_exports as u };
849
893
 
850
- //# sourceMappingURL=skills-CbwV6vw_.js.map
894
+ //# sourceMappingURL=skills-CXjA9TWw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills-CXjA9TWw.js","names":[],"sources":["../src/utils/root-pointer.ts","../src/commands/skills.ts"],"sourcesContent":["/**\n * The note a Rebase project leaves at the root of the repository it sits in.\n *\n * A project's `CLAUDE.md`, `AGENTS.md` and the rest are loaded by an assistant\n * started in the project's own directory. One started at the root of a larger\n * repository — `my-app/` holding the site, with the Rebase project in\n * `my-app/cloud/` — loads none of them, and opens none of the files they point\n * to unless something sends it there. That is how an agent building a game on\n * Rebase came to make twelve tables with `CREATE TABLE` in a function: every\n * rule against it was in `cloud/`, and the agent never went there.\n *\n * So `rebase init` and `rebase skills install` write a marked block into the\n * repository root's `CLAUDE.md` and `AGENTS.md`: where the project is, and the\n * scaffold's \"Before you write any code\" rules, read from the template so there\n * is one copy to keep true. A file that is not there is created; one that is\n * gets the block appended, or replaced between its markers on a later run.\n * `REBASE_ROOT_RULES=0` (any off spelling `parseEnvBoolean` reads) turns it\n * off, for a root whose agent files are kept by hand — and for this package's\n * tests, which scaffold inside this repository.\n *\n * Nothing is written at the home directory or above it: a dotfiles repository\n * at `~` makes `~` the root of every project below it, and an assistant loads\n * `~/CLAUDE.md` in every session it starts under home. Nor where the repository\n * ignores the project, which is then not part of it.\n */\nimport fs from \"fs\";\nimport os from \"os\";\nimport path from \"path\";\nimport { spawnSync } from \"child_process\";\nimport { parseEnvBoolean } from \"@rebasepro/types\";\n\nexport const ROOT_POINTER_START = \"<!-- rebase:project -->\";\nexport const ROOT_POINTER_END = \"<!-- /rebase:project -->\";\nexport const ROOT_POINTER_FILES = [\"CLAUDE.md\", \"AGENTS.md\"] as const;\n\nconst RULES_HEADING = \"## Before you write any code\";\n\n/**\n * The repository root above a project, or null when the project is the root\n * itself or is in no repository. The project's own directory is not a candidate:\n * there its own files already load.\n */\nexport function enclosingRepositoryRoot(projectDir: string): string | null {\n let dir = path.dirname(path.resolve(projectDir));\n const top = path.parse(dir).root;\n while (true) {\n if (fs.existsSync(path.join(dir, \".git\"))) return dir;\n if (dir === top) return null;\n dir = path.dirname(dir);\n }\n}\n\n/** The rules block from the scaffold's `CLAUDE.md`, heading included. */\nexport function scaffoldRules(templateDir: string): string {\n const text = fs.readFileSync(path.join(templateDir, \"CLAUDE.md\"), \"utf8\");\n const at = text.indexOf(RULES_HEADING);\n if (at === -1) throw new Error(`${path.join(templateDir, \"CLAUDE.md\")} has no \"${RULES_HEADING}\" block`);\n return text.slice(at).trim();\n}\n\n/** The marked block for a project at `relativeDir` from the repository root. */\nexport function rootPointerBlock(relativeDir: string, rules: string): string {\n const dir = relativeDir.split(path.sep).join(\"/\");\n return [\n ROOT_POINTER_START,\n \"<!-- Written by `rebase init` and `rebase skills install`: edits between these markers are overwritten. -->\",\n \"## Rebase project\",\n \"\",\n `\\`${dir}/\\` is a Rebase project. Before you change anything in it, read \\`${dir}/ai-instructions.md\\`; the rules below hold even before you do. Their paths are relative to \\`${dir}/\\`.`,\n \"\",\n rules.replace(RULES_HEADING, `### Before you write any code in \\`${dir}/\\``),\n ROOT_POINTER_END\n ].join(\"\\n\");\n}\n\nfunction occurrences(text: string, marker: string): number {\n return text.split(marker).length - 1;\n}\n\n/**\n * `text` with the block in it: replaced between its markers, or appended.\n * Null when the markers cannot say where the block is — one of them alone, more\n * than one of either, or the end before the start: replacing from an orphan\n * start to a new end would take whatever the user wrote in between with it.\n * The block takes the file's line ending, so a CRLF file stays CRLF and a\n * second run finds it unchanged.\n */\nexport function withRootPointer(text: string, block: string): string | null {\n const eol = text.includes(\"\\r\\n\") ? \"\\r\\n\" : \"\\n\";\n const lines = block.replace(/\\r?\\n/g, eol);\n const starts = occurrences(text, ROOT_POINTER_START);\n const ends = occurrences(text, ROOT_POINTER_END);\n if (starts === 0 && ends === 0) {\n if (text.trim() === \"\") return lines + eol;\n return text.replace(/\\s*$/, eol + eol) + lines + eol;\n }\n const start = text.indexOf(ROOT_POINTER_START);\n const end = text.indexOf(ROOT_POINTER_END);\n if (starts !== 1 || ends !== 1 || end < start) return null;\n return text.slice(0, start) + lines + text.slice(end + ROOT_POINTER_END.length);\n}\n\n/**\n * Why the block may not go into `root`, or null when it may: `root` is the home\n * directory or above it, or the repository ignores the project.\n */\nexport function rootPointerRefusal(root: string, projectDir: string): string | null {\n const home = path.resolve(os.homedir());\n const fromRoot = path.relative(root, home);\n if (fromRoot === \"\" || (!fromRoot.startsWith(\"..\") && !path.isAbsolute(fromRoot))) {\n return `${root} is the home directory or above it, and its agent files load in every session there`;\n }\n // Exit 0: ignored. 1: not ignored. Anything else (no git, not a real\n // repository) says nothing about the project, and the block is written.\n const relative = path.relative(root, path.resolve(projectDir));\n const ignored = spawnSync(\"git\", [\"-C\", root, \"check-ignore\", \"-q\", \"--\", relative], { stdio: \"ignore\" });\n if (ignored.status === 0) return `${root} ignores ${relative}/, so the project is not part of that repository`;\n return null;\n}\n\nexport interface RootPointerResult {\n /** The files that changed, as absolute paths. */\n changed: string[];\n /** Files left as they were, each with the reason, for the user to fix by hand. */\n untouched: { file: string; reason: string }[];\n /** Why the repository root above the project got nothing, when it was refused. */\n refused: string | null;\n}\n\n/**\n * Write the block into the repository root's agent files when the project is\n * below that root.\n */\nexport function writeRootPointers(projectDir: string, templateDir: string): RootPointerResult {\n const result: RootPointerResult = { changed: [], untouched: [], refused: null };\n if (parseEnvBoolean(process.env.REBASE_ROOT_RULES) === false) return result;\n const root = enclosingRepositoryRoot(projectDir);\n if (!root) return result;\n result.refused = rootPointerRefusal(root, projectDir);\n if (result.refused !== null) return result;\n const block = rootPointerBlock(path.relative(root, path.resolve(projectDir)), scaffoldRules(templateDir));\n for (const name of ROOT_POINTER_FILES) {\n const file = path.join(root, name);\n const before = fs.existsSync(file) ? fs.readFileSync(file, \"utf8\") : \"\";\n const after = withRootPointer(before, block);\n if (after === null) {\n result.untouched.push({\n file,\n reason: `its ${ROOT_POINTER_START} and ${ROOT_POINTER_END} markers are not one start followed by one end`\n });\n continue;\n }\n if (after === before) continue;\n fs.writeFileSync(file, after);\n result.changed.push(file);\n }\n return result;\n}\n","import chalk from \"chalk\";\nimport { createHash } from \"crypto\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport inquirer from \"inquirer\";\nimport { createRequire } from \"module\";\nimport os from \"os\";\nimport { findProjectRoot } from \"../utils/project\";\nimport { type RootPointerResult, writeRootPointers } from \"../utils/root-pointer\";\nimport { parseCommandArgs, UsageError, wantsHelp } from \"../utils/args\";\nimport { unknownCommand } from \"../utils/unknown-command\";\n\nconst require = createRequire(import.meta.url);\n\n/**\n * Supported agent environments and their target directories.\n *\n * Every agent `rebase init` writes a pointer file for has an entry here. That\n * was not true: `rebase init` writes `CLAUDE.md`, `AGENTS.md`, `.cursorrules`,\n * `.windsurfrules` and `.github/copilot-instructions.md`, and the installer\n * covered four of the five — so a Codex or Copilot user was told, by a file in\n * their own repository, to run an installer that had nothing to offer them.\n *\n * `flatLayout` marks the agents whose rules directory is loaded *whole*, into\n * every request. Writing 21 skills there put ~84,000 characters of always-on\n * context in front of every question a person asked Cursor — more than the task\n * itself, on every turn, most of it about parts of Rebase they were not\n * touching. Those agents get one short index rule instead, and the skill bodies\n * go in per-skill subdirectories the index names, which the agent reads when it\n * needs one. `indexFile` is the name of that rule.\n *\n * A subdirectory layout has no such problem: the rule file already sits beside\n * its own assets, so `references/x.md` resolves as written and nothing is\n * loaded until it is opened.\n *\n * `homeMarkers` are the directories under `~` that say the assistant is\n * installed on this machine. They answer a different question from\n * `detectDir`: a fresh scaffold has no `.claude/skills` of its own, so `rebase init`\n * asks the machine which assistants the developer has and pre-selects those.\n *\n * `mcp` is where the assistant reads a *project-level* MCP server list, and in\n * which shape — see `agent-setup.ts`. `projectDir` is what `REBASE_PROJECT_DIR`\n * is set to: `\".\"` where the server is spawned in the project, the editor's own\n * workspace variable where it may not be. `null` means there is no project\n * file to write: Windsurf reads only a user-level config, and one entry there\n * cannot name every project on the machine.\n */\nexport const AGENTS = {\n cursor: {\n label: \"Cursor\",\n detectDir: \".cursor\",\n homeMarkers: [\".cursor\"],\n targetDir: \".cursor/rules\",\n flatLayout: true,\n indexFile: \"rebase.mdc\",\n mcp: {\n file: \".cursor/mcp.json\",\n format: \"mcpServers\",\n projectDir: \"${workspaceFolder}\"\n },\n /** The body is not a rule file here — `indexFile` is. */\n transformFile: (skillName: string, content: string) => ({\n fileName: path.join(skillName, \"SKILL.md\"),\n content\n })\n },\n claude: {\n label: \"Claude Code\",\n // Not `.claude`: every scaffold ships `.claude/settings.json` and the\n // `rebase verify` hook, so the directory says nothing about who uses\n // Claude Code. `.claude/skills` is there only once someone installed\n // Claude skills into the project.\n detectDir: \".claude/skills\",\n homeMarkers: [\".claude\"],\n targetDir: \".claude/skills\",\n flatLayout: false,\n // The scaffold already ships this file; writing it is then a no-op.\n mcp: {\n file: \".mcp.json\",\n format: \"mcpServers\",\n projectDir: \".\"\n },\n /** Claude Code uses the standard SKILL.md format in subdirectories. */\n transformFile: (skillName: string, content: string) => ({\n fileName: path.join(skillName, \"SKILL.md\"),\n content\n })\n },\n windsurf: {\n label: \"Windsurf\",\n detectDir: \".windsurf\",\n homeMarkers: [\".codeium/windsurf\", \".windsurf\"],\n targetDir: \".windsurf/rules\",\n flatLayout: true,\n indexFile: \"rebase.md\",\n mcp: null,\n /** The body is not a rule file here — `indexFile` is. */\n transformFile: (skillName: string, content: string) => ({\n fileName: path.join(skillName, \"SKILL.md\"),\n content\n })\n },\n gemini: {\n label: \"Gemini CLI / Antigravity\",\n detectDir: \".agents\",\n homeMarkers: [\".gemini\"],\n targetDir: \".agents/skills\",\n flatLayout: false,\n mcp: {\n file: \".gemini/settings.json\",\n format: \"mcpServers\",\n projectDir: \".\"\n },\n /** Gemini uses the standard SKILL.md format in subdirectories. */\n transformFile: (skillName: string, content: string) => ({\n fileName: path.join(skillName, \"SKILL.md\"),\n content\n })\n },\n codex: {\n label: \"Codex CLI\",\n detectDir: \".codex\",\n homeMarkers: [\".codex\"],\n // Codex reads repository skills from `.agents/skills` — every directory\n // from the working directory up to the repository root — and nothing\n // under `.codex/`. This entry used to write `.codex/skills`, so `--agent\n // codex` reported 21 skills installed into a directory Codex never\n // opens. It shares the directory with Gemini; the installer writes it\n // once.\n targetDir: \".agents/skills\",\n flatLayout: false,\n // Project-scoped, and read only once the developer trusts the project.\n mcp: {\n file: \".codex/config.toml\",\n format: \"codexToml\",\n projectDir: \".\"\n },\n /** Codex uses the standard SKILL.md format in subdirectories. */\n transformFile: (skillName: string, content: string) => ({\n fileName: path.join(skillName, \"SKILL.md\"),\n content\n })\n },\n kiro: {\n label: \"Kiro\",\n detectDir: \".kiro\",\n homeMarkers: [\".kiro\"],\n targetDir: \".kiro/steering\",\n flatLayout: true,\n indexFile: \"rebase.md\",\n mcp: {\n file: \".kiro/settings/mcp.json\",\n format: \"mcpServers\",\n projectDir: \".\"\n },\n /** The body is not a rule file here — `indexFile` is. */\n transformFile: (skillName: string, content: string) => ({\n fileName: path.join(skillName, \"SKILL.md\"),\n content\n })\n },\n copilot: {\n label: \"GitHub Copilot\",\n // Deliberately undetectable. `.github/` is the one directory in this\n // table that is not evidence of an assistant: `rebase init` writes\n // `.github/copilot-instructions.md` into every scaffold, and half the\n // repositories on the internet have a `.github/` for workflows and\n // issue templates. Listing it made bare `rebase skills install` resolve\n // to `[copilot]` in every project — so a Claude Code user who ran the\n // command `rebase init` printed got a success message and nothing in\n // `.claude/skills`. Copilot is `--agent copilot`.\n detectDir: null,\n // Same reasoning on the machine: Copilot lives inside VS Code or a\n // JetBrains IDE, and neither's directory says the extension is there.\n homeMarkers: [],\n targetDir: \".github/instructions\",\n flatLayout: true,\n indexFile: \"rebase.instructions.md\",\n mcp: {\n file: \".vscode/mcp.json\",\n format: \"vscode\",\n projectDir: \"${workspaceFolder}\"\n },\n /** The body is not a rule file here — `indexFile` is. */\n transformFile: (skillName: string, content: string) => ({\n fileName: path.join(skillName, \"SKILL.md\"),\n content\n })\n }\n} as const;\n\nexport type AgentKey = keyof typeof AGENTS;\n\n/** Narrows a string to an agent name, by the table's own keys. */\nexport function isAgentKey(value: string): value is AgentKey {\n return Object.hasOwn(AGENTS, value);\n}\n\n/** Every agent, in table order. */\nexport const AGENT_KEYS: AgentKey[] = Object.keys(AGENTS).filter(isAgentKey);\n\n/**\n * Resolve the path to the skills directory from @rebasepro/agent-skills.\n * Works in both workspace (symlink) and published (real files) layouts.\n */\nfunction getSkillsSourceDir(): string {\n const pkgJsonPath = require.resolve(\"@rebasepro/agent-skills/package.json\");\n const pkgRoot = path.dirname(pkgJsonPath);\n const skillsDir = path.join(pkgRoot, \"skills\");\n\n if (!fs.existsSync(skillsDir)) {\n throw new Error(\n `Skills directory not found at ${skillsDir}. ` +\n \"Make sure @rebasepro/agent-skills is installed.\"\n );\n }\n\n return skillsDir;\n}\n\nexport interface LoadedSkill {\n name: string;\n /** Absolute path of the skill's source directory. */\n dir: string;\n content: string;\n /** Every file the skill ships besides SKILL.md, relative to `dir`. */\n assets: string[];\n}\n\n/**\n * Everything a skill ships alongside its SKILL.md — the `references/` tree the\n * Agent Skills format uses for progressive disclosure.\n *\n * These used to be dropped on install, because the installer read exactly\n * `<skill>/SKILL.md` and nothing else. That left `rebase-design-language`\n * telling the agent three separate times to read `references/view-patterns.md`\n * — 379 lines of view skeletons — in a project where the file had never\n * landed, and the instruction it carries is \"extend an existing pattern; do not\n * invent a layout\".\n */\nfunction loadSkillAssets(skillDir: string): string[] {\n const found: string[] = [];\n\n const walk = (dir: string, prefix: string) => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n // Dotfiles are bookkeeping — `.gitkeep` is what holds the empty\n // `references/` directories in git — and install nothing.\n if (entry.name.startsWith(\".\")) continue;\n const rel = prefix ? path.join(prefix, entry.name) : entry.name;\n if (entry.isDirectory()) walk(path.join(dir, entry.name), rel);\n else if (rel !== \"SKILL.md\") found.push(rel);\n }\n };\n\n walk(skillDir, \"\");\n return found.sort();\n}\n\n/** Read all skill directories and return their names, content and assets. */\nexport function loadSkills(skillsDir: string): LoadedSkill[] {\n const entries = fs.readdirSync(skillsDir, { withFileTypes: true });\n const skills: LoadedSkill[] = [];\n\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n const skillDir = path.join(skillsDir, entry.name);\n const skillMdPath = path.join(skillDir, \"SKILL.md\");\n if (!fs.existsSync(skillMdPath)) continue;\n skills.push({\n name: entry.name,\n dir: skillDir,\n content: fs.readFileSync(skillMdPath, \"utf-8\"),\n assets: loadSkillAssets(skillDir)\n });\n }\n\n return skills;\n}\n\n/**\n * The skills this CLI ships, from its own `@rebasepro/agent-skills`.\n *\n * Throws rather than exiting, so `rebase init` can report a missing bundle as a\n * warning and still finish the scaffold.\n */\nexport function loadBundledSkills(): LoadedSkill[] {\n const skillsDir = getSkillsSourceDir();\n const skills = loadSkills(skillsDir);\n if (skills.length === 0) throw new Error(`No skills found in ${skillsDir}`);\n return skills;\n}\n\n/**\n * The one always-on rule a flat-layout agent gets, in place of every skill.\n *\n * Cursor and Windsurf load their whole rules directory into each request. With\n * a rule file per skill that was ~84,000 characters of Rebase reference in\n * front of every question, whether or not the question was about Rebase — and\n * an instruction an assistant skims is an instruction it does not follow.\n *\n * So the always-on part is this: a table of what exists and where to read it.\n * `alwaysApply: true` because knowing the skills are there costs a few hundred\n * characters and is the whole point; the bodies stay on disk until the agent\n * opens one.\n */\nexport function renderSkillIndex(skills: LoadedSkill[], agentKey: AgentKey): string {\n const agent = AGENTS[agentKey];\n const bodyPath = (name: string) => agent.transformFile(name, \"\").fileName.split(path.sep).join(\"/\");\n const rows = skills\n .map((skill) => `| \\`${skill.name}\\` | ${describe(skill)} | \\`${bodyPath(skill.name)}\\` |`)\n .join(\"\\n\");\n\n return [\n \"---\",\n \"description: Rebase — the skills index. Read the file named for the task before writing Rebase code.\",\n \"alwaysApply: true\",\n \"---\",\n \"\",\n \"# Rebase skills\",\n \"\",\n `This project uses [Rebase](https://rebase.pro). ${skills.length} reference skills are`,\n \"installed beside this file. **Read the one that covers the task before writing\",\n \"code** — they are the difference between a table the server accepts and one it\",\n \"refuses.\",\n \"\",\n \"| Skill | Covers | Read |\",\n \"|---|---|---|\",\n rows,\n \"\",\n \"Start with `rebase-basics` if you are not sure: it opens with the recipes for\",\n \"adding a table, a function and an RLS rule, and names the commands.\",\n \"\"\n ].join(\"\\n\");\n}\n\n/**\n * The body of a YAML block scalar, given the offset of its `description:` line.\n *\n * Everything indented more than the key belongs to the value; the first line\n * that is not blank and not indented ends it.\n */\nfunction blockScalarBody(frontMatter: string, keyOffset: number): string {\n const lines = frontMatter.slice(keyOffset).split(\"\\n\").slice(1);\n const body: string[] = [];\n for (const line of lines) {\n if (line.trim() === \"\") { body.push(\"\"); continue; }\n if (!/^[ \\t]/.test(line)) break;\n body.push(line.trim());\n }\n return body.join(\" \");\n}\n\n/**\n * A skill's one-line summary, from its own front matter.\n *\n * Read rather than written here so a new skill needs no edit in this file, and\n * truncated because the index is only worth having while it stays short.\n */\nfunction describe(skill: LoadedSkill): string {\n const frontMatter = skill.content.split(\"---\")[1] ?? \"\";\n const described = /^description:[ \\t]*(.*)$/m.exec(frontMatter);\n // `description: |` (or `>`) is a YAML block scalar: the value is the\n // indented lines that follow, and capturing the line itself captured the\n // `|`. That rendered an empty \"Covers\" cell for `rebase-design-language`,\n // the one skill whose description says agents MUST read it.\n const raw = /^[|>][-+]?$/.test((described?.[1] ?? \"\").trim())\n ? blockScalarBody(frontMatter, described?.index ?? 0)\n : (described?.[1] ?? \"\");\n const text = raw.trim().replace(/\\s+/g, \" \").replace(/\\|/g, \"\\\\|\");\n const firstSentence = /^.*?\\.(?:\\s|$)/.exec(text)?.[0]?.trim() ?? text;\n const fallback = skill.name.replace(/^rebase-/, \"\").replace(/-/g, \" \");\n if (!firstSentence) return fallback;\n if (firstSentence.length <= 140) return firstSentence;\n // Cut at a word boundary. A description sliced mid-word (\"using the collect\")\n // reads as a corrupted file rather than as a summary.\n const cut = firstSentence.slice(0, 140);\n return `${cut.slice(0, cut.lastIndexOf(\" \")).replace(/[,;:]$/, \"\")}…`;\n}\n\n/**\n * Detect which agent environments already exist in the project.\n *\n * A `detectDir` has to be evidence *the user* created, not something a scaffold\n * ships. An agent whose only marker fails that test declares `detectDir: null`\n * and is reachable by `--agent` alone; guessing wrong here is worse than not\n * guessing, because the wrong guess installs 21 files and reports success.\n */\nexport function detectAgents(projectDir: string): AgentKey[] {\n return AGENT_KEYS.filter((key) => {\n const { detectDir } = AGENTS[key];\n return detectDir !== null && fs.existsSync(path.join(projectDir, detectDir));\n });\n}\n\n/** What `detectInstalledAgents` found for one assistant. */\nexport interface InstalledAgent {\n key: AgentKey;\n label: string;\n /** The home directory checked, as `~/…` — the one found, else the first. */\n marker: string | null;\n found: boolean;\n}\n\n/**\n * Which assistants are installed on this machine, from their home directories.\n *\n * The question `rebase init` needs answered, and one `detectAgents` cannot: a\n * project that does not exist yet has no `.claude/` in it. What the machine has\n * is only a default — the developer confirms it — so a false positive costs an\n * unticked box, not 21 files nobody asked for.\n */\nexport function detectInstalledAgents(home: string = os.homedir()): InstalledAgent[] {\n return AGENT_KEYS.map((key) => {\n const agent = AGENTS[key];\n const markers: readonly string[] = agent.homeMarkers;\n const hit = markers.find((m) => fs.existsSync(path.join(home, m)));\n const shown = hit ?? markers[0];\n return {\n key,\n label: agent.label,\n marker: shown === undefined ? null : `~/${shown}`,\n found: hit !== undefined\n };\n });\n}\n\n/** Install skills for a specific agent into the project directory. */\n/**\n * The file in each target directory that records what the installer wrote:\n * relative path → sha256 of the bytes written. A dotfile, so no agent loads it\n * as a rule.\n */\nexport const SKILLS_MANIFEST = \".rebase-skills.json\";\n\n/**\n * Skills the bundle once shipped under these names and no longer does. An\n * install with a manifest removes them by its record; this list reaches the\n * installs made before manifests existed, which recorded nothing.\n * `rebase-collections` became `rebase-tables` when the schema moved to\n * `defineTable` (0.31).\n */\nexport const RETIRED_SKILLS: readonly string[] = [\"rebase-collections\"];\n\ninterface SkillsManifest {\n version: 1;\n files: Record<string, string>;\n}\n\nfunction sha256(bytes: Buffer | string): string {\n return createHash(\"sha256\").update(bytes).digest(\"hex\");\n}\n\n/**\n * Whether a manifest path names a file inside the target directory.\n *\n * The manifest is committed with the project, so whoever wrote the repository\n * wrote it too, and the retired-file sweep below deletes what it lists — with\n * `--force`, whatever it holds. A path that climbs out (`../../.bashrc`) or is\n * absolute was never written by an install, and is not this command's to touch.\n */\nfunction insideTarget(targetBase: string, relPath: string): boolean {\n const relative = path.relative(targetBase, path.resolve(targetBase, relPath));\n return relative !== \"\" && !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n}\n\nfunction readManifest(targetBase: string): SkillsManifest | null {\n try {\n const parsed: unknown = JSON.parse(fs.readFileSync(path.join(targetBase, SKILLS_MANIFEST), \"utf-8\"));\n if (parsed && typeof parsed === \"object\" && \"files\" in parsed) {\n const files = (parsed as { files: unknown }).files;\n if (files && typeof files === \"object\") {\n const entries = Object.entries(files)\n .filter((e): e is [string, string] => typeof e[1] === \"string\" && insideTarget(targetBase, e[0]));\n return { version: 1, files: Object.fromEntries(entries) };\n }\n }\n } catch {\n // No manifest, or one that is not ours: the first install, or one made\n // before manifests existed.\n }\n return null;\n}\n\n/** What one agent's install did. */\nexport interface AgentInstallResult {\n skills: number;\n assets: number;\n /** Files left as they are because they were edited since the last install (relative to the target dir). */\n kept: string[];\n /** Files of skills the bundle no longer ships, removed because nobody edited them. */\n removed: string[];\n}\n\nexport function installForAgent(\n agentKey: AgentKey,\n skills: LoadedSkill[],\n projectDir: string,\n options: { force?: boolean } = {}\n): AgentInstallResult {\n const agent = AGENTS[agentKey];\n const targetBase = path.join(projectDir, agent.targetDir);\n\n // Ensure the target directory exists\n fs.mkdirSync(targetBase, { recursive: true });\n\n // A re-run used to overwrite every file unconditionally and never remove\n // one: a note a team appended to an installed skill and committed — as\n // the command tells them to — vanished on the next `skills install`, and a\n // skill a release retired stayed installed beside its replacement. The\n // manifest records what was written, so an edit is told apart from an\n // older bundle's copy. A file with no record (an install from before\n // manifests) is overwritten, as before.\n const previous = readManifest(targetBase);\n const recorded: Record<string, string> = {};\n const kept: string[] = [];\n\n const place = (relPath: string, bytes: Buffer | string) => {\n const target = path.join(targetBase, relPath);\n const wanted = sha256(bytes);\n const last = previous?.files[relPath];\n if (fs.existsSync(target)) {\n const current = sha256(fs.readFileSync(target));\n if (current === wanted) {\n recorded[relPath] = wanted;\n return;\n }\n if (last !== undefined && current !== last && !options.force) {\n // Edited since it was installed: left alone, and still recorded\n // as what was installed, so the next run says so again.\n kept.push(relPath);\n recorded[relPath] = last;\n return;\n }\n }\n fs.mkdirSync(path.dirname(target), { recursive: true });\n fs.writeFileSync(target, bytes);\n recorded[relPath] = wanted;\n };\n\n let count = 0;\n let assetCount = 0;\n for (const skill of skills) {\n // Every layout now writes the body into a per-skill subdirectory, so a\n // link the skill spells `references/x.md` resolves as written and no\n // rewriting is needed. What differs is whether that file is also the\n // agent's *rule* file (subdirectory layouts) or something the index\n // points at (flat ones).\n const { fileName, content } = agent.transformFile(skill.name, skill.content);\n place(fileName, content);\n count++;\n\n // A skill's assets always land in a directory named after the skill,\n // whatever the rule file's layout, so two skills' `references/` trees\n // cannot collide in a flat target directory.\n for (const asset of skill.assets) {\n place(path.join(skill.name, asset), fs.readFileSync(path.join(skill.dir, asset)));\n assetCount++;\n }\n }\n\n if (agent.flatLayout && agent.indexFile) {\n place(agent.indexFile, renderSkillIndex(skills, agentKey));\n }\n\n // Retired files: removed when they are exactly what was installed, kept\n // (and reported) when someone edited them.\n const removed: string[] = [];\n for (const [relPath, last] of Object.entries(previous?.files ?? {})) {\n if (relPath in recorded) continue;\n const target = path.join(targetBase, relPath);\n if (!fs.existsSync(target)) continue;\n if (sha256(fs.readFileSync(target)) !== last && !options.force) {\n kept.push(relPath);\n continue;\n }\n fs.rmSync(target);\n removed.push(relPath);\n // Empty directories the removal leaves behind, up to the target dir.\n for (let dir = path.dirname(target); dir.startsWith(targetBase + path.sep); dir = path.dirname(dir)) {\n if (fs.readdirSync(dir).length > 0) break;\n fs.rmdirSync(dir);\n }\n }\n\n // Retired skills an install from before manifests left behind: nothing\n // records them, so the sweep above cannot see them. A body is removed only\n // when its front matter still names the retired skill — the file Rebase\n // wrote, not a directory of the same name someone made — and, as for any\n // unrecorded file, an earlier install would have overwritten it anyway.\n const shipped = new Set(skills.map((skill) => skill.name));\n for (const retired of RETIRED_SKILLS) {\n if (shipped.has(retired)) continue;\n const relPath = agent.transformFile(retired, \"\").fileName;\n if (relPath in (previous?.files ?? {})) continue;\n const target = path.join(targetBase, relPath);\n if (!fs.existsSync(target)) continue;\n const named = /^name:[ \\t]*[\"']?([\\w-]+)[\"']?[ \\t]*$/m.exec(fs.readFileSync(target, \"utf-8\").split(\"---\")[1] ?? \"\");\n if (named?.[1] !== retired) continue;\n fs.rmSync(target);\n removed.push(relPath);\n for (let dir = path.dirname(target); dir.startsWith(targetBase + path.sep); dir = path.dirname(dir)) {\n if (fs.readdirSync(dir).length > 0) break;\n fs.rmdirSync(dir);\n }\n }\n\n fs.writeFileSync(\n path.join(targetBase, SKILLS_MANIFEST),\n JSON.stringify({ version: 1, files: recorded } satisfies SkillsManifest, null, 2) + \"\\n\",\n \"utf-8\"\n );\n\n return { skills: count, assets: assetCount, kept, removed };\n}\n\n/** What `installSkills` did for one agent. */\nexport interface SkillsInstallResult extends AgentInstallResult {\n agent: AgentKey;\n /** An earlier agent in the same run that already wrote this directory. */\n sharedWith?: AgentKey;\n}\n\n/**\n * Install for several agents, writing each target directory once.\n *\n * Gemini and Codex both read `.agents/skills`; installing twice would write the\n * same 21 files twice and report two installs of one directory.\n */\nexport function installSkills(\n agents: readonly AgentKey[],\n skills: LoadedSkill[],\n projectDir: string,\n options: { force?: boolean } = {}\n): SkillsInstallResult[] {\n const written = new Map<string, SkillsInstallResult>();\n return agents.map((agent) => {\n const earlier = written.get(AGENTS[agent].targetDir);\n if (earlier) return { ...earlier, agent, sharedWith: earlier.agent };\n const result = { agent, ...installForAgent(agent, skills, projectDir, options) };\n written.set(AGENTS[agent].targetDir, result);\n return result;\n });\n}\n\n/** Everything the switch below dispatches, for the did-you-mean. */\nexport const SKILLS_SUBCOMMANDS = [\"install\"] as const;\n\nexport async function skillsCommand(subcommand: string | undefined, rawArgs: string[]) {\n // `--help` cannot reach `skillsInstall`. `cli.ts` only rewrites the\n // subcommand to `\"--help\"` when none was named, so `rebase skills install\n // --help` used to run the install: it detected the agents and overwrote\n // `.claude/skills/*/SKILL.md`, `.cursor/rules/*.mdc` and the rest. A flag\n // that prints text must not write files.\n if (wantsHelp(rawArgs)) {\n printSkillsHelp();\n return;\n }\n\n switch (subcommand) {\n case \"install\":\n await skillsInstall(rawArgs);\n break;\n case \"--help\":\n case undefined:\n // `rebase skills --hooks`: the Claude Code guardrail on its own,\n // for a project scaffolded before `rebase init` shipped it.\n if (subcommand === undefined && rawArgs.includes(\"--hooks\")) {\n await skillsHooks(rawArgs);\n break;\n }\n printSkillsHelp();\n break;\n default:\n unknownCommand(subcommand, SKILLS_SUBCOMMANDS, \"skills\");\n }\n}\n\n/** `rebase skills --hooks [--force]`: install the guardrail hook and nothing else. */\nasync function skillsHooks(rawArgs: string[]): Promise<void> {\n const { flags } = parseCommandArgs({\n spec: { \"--hooks\": Boolean, \"--force\": Boolean },\n rawArgs,\n commandWords: 1,\n command: \"skills\",\n maxPositionals: 0\n });\n const projectDir = findProjectRoot() ?? process.cwd();\n console.log(\"\");\n await installHooksAndReport(projectDir, flags[\"--force\"] === true);\n console.log(\"\");\n}\n\n/**\n * Install the Claude Code guardrail (`installAgentHooks`) and say what it did,\n * one line per file.\n */\nasync function installHooksAndReport(projectDir: string, force: boolean): Promise<void> {\n const { installAgentHooks, AGENT_HOOK_SCRIPT } = await import(\"./agent-setup\");\n const shown = (file: string) => path.relative(process.cwd(), path.join(projectDir, file)) || file;\n for (const { file, status } of installAgentHooks(projectDir, { force })) {\n if (status === \"added\" || status === \"replaced\") {\n console.log(` ${chalk.green(\"✓\")} ${status === \"added\" ? \"Wrote\" : \"Replaced\"} ${chalk.gray(shown(file))}`);\n } else if (status === \"present\") {\n console.log(` ${chalk.green(\"✓\")} ${chalk.gray(shown(file))} already in place`);\n } else if (status === \"kept\") {\n console.log(chalk.yellow(` ! ${shown(file)} was edited, so it was kept — pass --force to replace it with the shipped hook.`));\n } else {\n console.log(chalk.yellow(` ! ${shown(file)} is not plain JSON, so it was left alone — register ${AGENT_HOOK_SCRIPT} as a PostToolUse hook (matcher \"Edit|MultiEdit|Write\") by hand.`));\n }\n }\n console.log(chalk.gray(\" Claude Code now runs `rebase verify --quiet` after each edit under backend/schema/ or frontend/src/cms/.\"));\n}\n\n/**\n * Agents named explicitly on the command line, e.g. `--agent claude --agent cursor`\n * (also accepts a comma-separated list, and `all`). Returns null when none were\n * given.\n */\nexport function parseAgentFlags(rawArgs: string[]): AgentKey[] | null {\n return parseSkillsInstallLine(rawArgs).agents;\n}\n\n/** `rebase skills install`'s whole line: the agents it names, `--mcp`, `--hooks` and `--force`. */\nexport function parseSkillsInstallLine(rawArgs: string[]): { agents: AgentKey[] | null; mcp: boolean; hooks: boolean; force: boolean } {\n // Strict, and before anything is written. This used to scan `rawArgs` for\n // `--agent` and ignore every other token, so `rebase skills install\n // --frobnicate --agent claude` exited 0 after writing 21 files — the CLI's\n // other families reject an unknown flag, and an installer is the last place\n // to guess what the person meant.\n const { flags } = parseCommandArgs({\n spec: { \"--agent\": [String], \"-a\": \"--agent\", \"--mcp\": Boolean, \"--hooks\": Boolean, \"--force\": Boolean },\n rawArgs,\n commandWords: 2,\n command: \"skills install\",\n maxPositionals: 0\n });\n\n return {\n agents: resolveAgentNames(flags[\"--agent\"] ?? []),\n mcp: flags[\"--mcp\"] === true,\n hooks: flags[\"--hooks\"] === true,\n force: flags[\"--force\"] === true\n };\n}\n\n/**\n * The agents a list of `--agent` values names, or null when it names none.\n *\n * Shared by `rebase skills install` and `rebase init`, so both accept the same\n * spellings. Throws a UsageError on a name that is not an agent.\n */\nexport function resolveAgentNames(values: readonly string[]): AgentKey[] | null {\n const requested = values\n .flatMap(value => value.split(\",\").map(v => v.trim()))\n .filter(Boolean);\n if (requested.length === 0) return null;\n\n // `all` exists for the non-interactive case. Detection cannot help there: a\n // scaffolded project ships `.cursorrules`, `CLAUDE.md`, `.windsurfrules`,\n // `AGENTS.md` and `.github/copilot-instructions.md` all at once, so every\n // pointer file is present and none of them says which assistant the\n // developer actually uses. Guessing from them would install several agents'\n // skills unasked; refusing leaves a scripted setup with no way through.\n // Naming `all` is the developer saying it out loud.\n if (requested.includes(\"all\")) return [...AGENT_KEYS];\n\n const unknown = requested.filter(a => !isAgentKey(a));\n if (unknown.length > 0) {\n throw new UsageError(`Unknown agent(s): ${unknown.join(\", \")}. Available: ${AGENT_KEYS.join(\", \")}, all`);\n }\n // Deduplicated, in the order given: `--agent claude,claude` is one install.\n return [...new Set(requested.filter(isAgentKey))];\n}\n\nasync function skillsInstall(rawArgs: string[] = []) {\n // Parse the line before anything else touches the disk: a bad flag must\n // cost nothing, and everything below this writes or resolves paths.\n const { agents: namedAgents, mcp: withMcp, hooks: withHooks, force } = parseSkillsInstallLine(rawArgs);\n\n // The project root, not the cwd. Agent skills belong beside the repository's\n // other agent configuration — `.claude/`, `.cursor/` — which is both what\n // `detectAgents` looks for and where an assistant reads them from. Resolving\n // against wherever the command happened to be typed put them in\n // `backend/.claude/skills` when run from `backend/`, detected no agent\n // there, and left the skills somewhere nothing would look. Outside a project\n // the cwd is still the honest answer: this command is useful in a repository\n // that is not a Rebase one.\n const projectDir = findProjectRoot() ?? process.cwd();\n\n // 1. Load skills from @rebasepro/agent-skills\n let skills: LoadedSkill[];\n try {\n skills = loadBundledSkills();\n } catch (err) {\n console.error(`${chalk.red.bold(\"ERROR\")} ${err instanceof Error ? err.message : String(err)}`);\n process.exit(1);\n }\n\n // 2. Explicit --agent wins; otherwise detect existing agent environments\n let agents = namedAgents ?? detectAgents(projectDir);\n\n // 3. If none detected, ask the user\n if (agents.length === 0) {\n // A scaffolded project ships `.cursorrules`, `CLAUDE.md`, `AGENTS.md`\n // and `.github/copilot-instructions.md`, but none of the *directories*\n // detectAgents looks for, so a fresh project always lands here — which\n // is correct: those files say what `rebase init` writes, not what the\n // developer uses. On a non-TTY that used to abort with a raw\n // ExitPromptError.\n if (!process.stdin.isTTY) {\n console.error(chalk.red(\"Cannot prompt: this is a non-interactive terminal (no TTY).\"));\n console.error(chalk.yellow(` Name the agents explicitly, e.g. rebase skills install --agent ${Object.keys(AGENTS)[0]}`));\n console.error(chalk.yellow(\" Or install for every supported agent: rebase skills install --agent all\"));\n console.error(chalk.gray(` Available: ${Object.keys(AGENTS).join(\", \")}`));\n process.exit(1);\n }\n\n // The project says nothing, but the machine may: pre-tick the agents\n // whose home directory exists, as `rebase init` does.\n const installed = detectInstalledAgents();\n const choices = installed.map(({ key, label, found }) => ({\n name: label,\n value: key,\n checked: found\n }));\n\n const { selectedAgents } = await inquirer.prompt([{\n type: \"checkbox\",\n name: \"selectedAgents\",\n message: \"No AI agent configuration in this project. Which agents do you use?\",\n choices,\n validate: (input: readonly unknown[]) => {\n if (input.length === 0) return \"Please select at least one agent.\";\n return true;\n }\n }]);\n\n agents = AGENT_KEYS.filter(key => selectedAgents.includes(key));\n }\n\n // 4. Install skills for each agent\n console.log(\"\");\n console.log(chalk.gray(` Found ${chalk.white(skills.length)} Rebase skills`));\n console.log(\"\");\n\n let anyKept = false;\n for (const result of installSkills(agents, skills, projectDir, { force })) {\n const agent = AGENTS[result.agent];\n // Relative to where the command was typed, now that the destination is\n // the project root rather than the cwd — otherwise `.claude/skills`\n // names a directory that is not the one it wrote to.\n const shown = path.relative(process.cwd(), path.join(projectDir, agent.targetDir)) || agent.targetDir;\n if (result.sharedWith) {\n console.log(` ${chalk.green(\"✓\")} ${chalk.bold(agent.label)} — reads the same ${chalk.gray(shown)} as ${AGENTS[result.sharedWith].label}`);\n continue;\n }\n const withAssets = result.assets > 0 ? ` (+ ${result.assets} reference file${result.assets === 1 ? \"\" : \"s\"})` : \"\";\n console.log(` ${chalk.green(\"✓\")} ${chalk.bold(agent.label)} — ${result.skills} skills installed${withAssets} to ${chalk.gray(shown)}`);\n for (const file of result.removed) {\n console.log(chalk.gray(` − removed ${path.join(shown, file)} (no longer in the bundle)`));\n }\n for (const file of result.kept) {\n anyKept = true;\n console.log(chalk.yellow(` ! kept ${path.join(shown, file)}: edited since it was installed`));\n }\n }\n if (anyKept) {\n console.log(chalk.yellow(\" Edited files were left as they are. To replace them with the bundle's copy:\"));\n console.log(` ${chalk.cyan(\"rebase skills install --force\")}`);\n }\n\n // The MCP server, as `rebase init --agent` registers it. Imported here\n // rather than at the top: agent-setup imports this module.\n const {\n MCP_SERVER_NAME, ensureMcpDependency, mcpDependencyNote, mcpServerRegistered, writeMcpConfig, cliPackageRoot\n } = await import(\"./agent-setup\");\n const { detectPackageManager } = await import(\"../utils/package-manager\");\n const shownFile = (file: string) => path.relative(process.cwd(), path.join(projectDir, file)) || file;\n if (withMcp) {\n console.log(\"\");\n const pm = detectPackageManager(projectDir);\n let registered = false;\n for (const agentKey of agents) {\n const agent = AGENTS[agentKey];\n const result = writeMcpConfig(agentKey, projectDir, pm);\n if (result && result.status !== \"unreadable\") registered = true;\n if (!result) {\n console.log(chalk.gray(` · ${agent.label} has no project-level MCP config — add @rebasepro/mcp in its MCP settings.`));\n } else if (result.status === \"added\") {\n console.log(` ${chalk.green(\"✓\")} ${chalk.bold(agent.label)} — MCP server in ${chalk.gray(shownFile(result.file))}`);\n } else if (result.status === \"present\") {\n console.log(` ${chalk.green(\"✓\")} ${chalk.bold(agent.label)} — MCP server already in ${chalk.gray(shownFile(result.file))}`);\n } else {\n console.log(chalk.yellow(` ! ${agent.label}: ${shownFile(result.file)} is not plain JSON, so it was left alone — add the \"${MCP_SERVER_NAME}\" server by hand.`));\n }\n }\n // The configs run the project's own copy of the server.\n const note = registered ? mcpDependencyNote(ensureMcpDependency(projectDir), pm) : undefined;\n if (note) console.log(chalk.yellow(` ${note}`));\n }\n\n if (withHooks) {\n console.log(\"\");\n await installHooksAndReport(projectDir, force);\n }\n\n // A project below its repository's root: an assistant started at that root\n // loads none of the project's own files, so the rules go there too.\n // Only for a Rebase project: this command also runs in repositories that are not one.\n if (findProjectRoot(projectDir) === projectDir) {\n reportRootPointers(writeRootPointers(projectDir, path.join(cliPackageRoot(), \"templates\", \"template\")));\n }\n\n console.log(\"\");\n console.log(chalk.gray(\" Skills are project-local. Commit them to share with your team.\"));\n // The skills ship inside the CLI's own pinned `@rebasepro/agent-skills`,\n // so a re-run reinstalls that version; newer ones come with a newer CLI.\n console.log(chalk.gray(\" Re-run this command to restore them. Upgrade @rebasepro/cli for newer skills.\"));\n if (!withMcp) {\n // Only the agents whose config does not have the server yet: on a\n // project `init --agent` set up, a refresh says nothing about it.\n const missing = agents.filter(agentKey => mcpServerRegistered(agentKey, projectDir) === false);\n if (missing.length > 0) {\n console.log(chalk.gray(\" To register the Rebase MCP server for them too, as `rebase init --agent` does:\"));\n console.log(` ${chalk.cyan(`rebase skills install --agent ${missing.join(\",\")} --mcp`)}`);\n }\n }\n console.log(\"\");\n}\n\nfunction printSkillsHelp() {\n console.log(`\n${chalk.bold(\"rebase skills\")} — Manage AI agent skills\n\n${chalk.green.bold(\"Usage\")}\n rebase skills ${chalk.blue(\"<subcommand>\")}\n\n${chalk.green.bold(\"Subcommands\")}\n ${chalk.blue.bold(\"install\")} Install Rebase agent skills for your AI coding assistant\n Supports: ${Object.values(AGENTS).map(a => a.label).join(\", \")}\n\n${chalk.green.bold(\"Options\")}\n ${chalk.blue(\"--force\")} Replace installed skill files you edited, and remove edited files of\n skills the bundle no longer ships. Without it, edits are kept.\n ${chalk.blue(\"--mcp\")} Also register the Rebase MCP server in each agent's project config\n (.mcp.json, .cursor/mcp.json, …), as ${chalk.cyan(\"rebase init --agent\")} does.\n Servers already in the file are kept.\n ${chalk.blue(\"--hooks\")} Also install the Claude Code guardrail: a PostToolUse hook in\n .claude/settings.json that runs ${chalk.cyan(\"rebase verify --quiet\")} after each edit\n under backend/schema/ or frontend/src/cms/ and hands any problem back.\n ${chalk.cyan(\"rebase skills --hooks\")} installs the hook alone.\n ${chalk.blue(\"--agent, -a\")} Agent(s) to install for, skipping detection and the prompt.\n Repeat the flag or pass a comma-separated list, or ${chalk.bold(\"all\")}.\n Required without a TTY: detection looks for an agent's own\n directory (${Object.values(AGENTS).filter(a => a.detectDir).map(a => a.detectDir).join(\", \")}),\n and a fresh scaffold has none. GitHub Copilot is never detected\n — ${chalk.gray(\".github/\")} is not evidence anyone uses it — so name it.\n Available: ${Object.keys(AGENTS).join(\", \")}, all\n\n${chalk.green.bold(\"Examples\")}\n ${chalk.cyan(\"rebase skills install\")}\n ${chalk.cyan(\"rebase skills install --agent claude\")}\n ${chalk.cyan(\"rebase skills install --agent claude,cursor\")}\n ${chalk.cyan(\"rebase skills install --agent cursor --mcp\")} ${chalk.gray(\"# skills + the MCP server\")}\n ${chalk.cyan(\"rebase skills install --agent all\")} ${chalk.gray(\"# scripted / CI\")}\n ${chalk.cyan(\"rebase skills --hooks\")} ${chalk.gray(\"# the Claude Code guardrail hook only\")}\n`);\n}\n\n/** One line per repository-root agent file the project's rules were written into, or left alone. */\nexport function reportRootPointers(result: RootPointerResult): void {\n const shown = (file: string) => path.relative(process.cwd(), file) || file;\n for (const file of result.changed) {\n console.log(` ${chalk.green(\"✓\")} Rebase rules in ${chalk.gray(shown(file))}, for an assistant started at the repository root`);\n }\n for (const { file, reason } of result.untouched) {\n console.warn(` ${chalk.yellow(\"!\")} Left ${chalk.gray(shown(file))} as it is: ${reason}. Fix or remove them and run ${chalk.cyan(\"rebase skills install\")} again.`);\n }\n if (result.refused !== null) {\n console.log(chalk.gray(` No Rebase rules at the repository root: ${result.refused}.`));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAa,qBAAqB;AAClC,IAAa,mBAAmB;AAChC,IAAa,qBAAqB,CAAC,aAAa,WAAW;AAE3D,IAAM,gBAAgB;;;;;;AAOtB,SAAgB,wBAAwB,YAAmC;CACvE,IAAI,MAAM,KAAK,QAAQ,KAAK,QAAQ,UAAU,CA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AAQ,KAAK,KAAK,MAAM,OAAO,GAAG,EAAE,QAAQ,MAAM,KAAK,MAAM,IAAI,CAAC,EAAE,aAAa,OAAO,+BAA+B,MAAM,KAAK,uBAAuB,EAAE,QAAQ;CAEvK,IAAI,OAAO,YAAY,MACnB,QAAQ,IAAI,MAAM,KAAK,6CAA6C,OAAO,QAAQ,EAAE,CAAC;AAE9F"}
@@ -1,6 +1,7 @@
1
1
  import { n as getPMCommands, t as detectPackageManager } from "./package-manager-DSEOwTqM.js";
2
- import { c as findProjectRoot, d as readEnvFile, o as findEnvFile, p as requireProjectRoot, w as wantsHelp, x as parseCommandArgs } from "./project-CasK56vN.js";
3
- import { t as DEFAULT_BUNDLE_DIR } from "./bundle-BAH4FCju.js";
2
+ import { a as wantsHelp, n as parseCommandArgs } from "./args-CaCcrYE1.js";
3
+ import { c as findProjectRoot, d as readEnvFile, o as findEnvFile, p as requireProjectRoot } from "./project-CLcF5i8c.js";
4
+ import { n as DEFAULT_BUNDLE_DIR } from "./bundle-DgILeA5b.js";
4
5
  import { t as invokedRebaseCommand } from "./invoked-command-CG_rIa_o.js";
5
6
  import chalk from "chalk";
6
7
  import fs from "fs";
@@ -220,14 +221,14 @@ async function startCommand(rawArgs = []) {
220
221
  quiet: true
221
222
  });
222
223
  if (!process.env.DATABASE_URL?.trim()) {
223
- const { devDatabaseKind } = await import("./prepare-CTw9NEkh.js");
224
+ const { devDatabaseKind } = await import("./prepare-Ccxspoj-.js");
224
225
  const missing = missingDatabaseUrl(process.env, devDatabaseKind(projectRoot), getPMCommands(detectPackageManager(projectRoot)));
225
226
  if (missing) {
226
227
  for (const line of missing) console.error(line);
227
228
  process.exit(1);
228
229
  }
229
230
  }
230
- const { findRunningDaemon } = await import("./daemon-Cp7oNXth.js").then((n) => n.t);
231
+ const { findRunningDaemon } = await import("./daemon-w30PsdwV.js").then((n) => n.t);
231
232
  const managedEnv = managedDatabaseRuntimeEnv(process.env.DATABASE_URL, await findRunningDaemon(projectRoot), process.env);
232
233
  if (managedEnv.REBASE_DB_POOL_MAX) {
233
234
  Object.assign(process.env, managedEnv);
@@ -264,11 +265,7 @@ async function startCommand(rawArgs = []) {
264
265
  function ensureBundleDependencies(projectRoot, bundleDir) {
265
266
  const target = path.join(bundleDir, "node_modules");
266
267
  if (fs.existsSync(target)) return;
267
- const sources = [
268
- "backend/node_modules",
269
- "config/node_modules",
270
- "node_modules"
271
- ].map((relative) => path.join(projectRoot, relative)).filter((dir) => fs.existsSync(dir));
268
+ const sources = ["backend/node_modules", "node_modules"].map((relative) => path.join(projectRoot, relative)).filter((dir) => fs.existsSync(dir));
272
269
  if (sources.length === 0) return;
273
270
  let linked = 0;
274
271
  fs.mkdirSync(target, { recursive: true });
@@ -316,4 +313,4 @@ async function startWorkspaceBackend(projectRoot, env) {
316
313
  //#endregion
317
314
  export { startCommand };
318
315
 
319
- //# sourceMappingURL=start-YOr3X5Zm.js.map
316
+ //# sourceMappingURL=start-Bwbtt2W5.js.map