@prisma-next/cli 0.16.0-dev.3 → 0.16.0-dev.31

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 (173) hide show
  1. package/README.md +44 -45
  2. package/dist/cli.mjs +13 -13
  3. package/dist/{client-KuBQftxz.mjs → client-B1UjQc_x.mjs} +50 -58
  4. package/dist/client-B1UjQc_x.mjs.map +1 -0
  5. package/dist/{command-helpers-Cpq44aVa.mjs → command-helpers-D-jBl0Qt.mjs} +16 -8
  6. package/dist/command-helpers-D-jBl0Qt.mjs.map +1 -0
  7. package/dist/commands/contract-emit.mjs +1 -1
  8. package/dist/commands/contract-infer.mjs +1 -1
  9. package/dist/commands/db-init.d.mts.map +1 -1
  10. package/dist/commands/db-init.mjs +8 -6
  11. package/dist/commands/db-init.mjs.map +1 -1
  12. package/dist/commands/db-schema.mjs +3 -3
  13. package/dist/commands/db-sign.d.mts.map +1 -1
  14. package/dist/commands/db-sign.mjs +11 -12
  15. package/dist/commands/db-sign.mjs.map +1 -1
  16. package/dist/commands/db-update.d.mts.map +1 -1
  17. package/dist/commands/db-update.mjs +14 -15
  18. package/dist/commands/db-update.mjs.map +1 -1
  19. package/dist/commands/db-verify.mjs +1 -1
  20. package/dist/commands/migrate.d.mts +1 -1
  21. package/dist/commands/migrate.d.mts.map +1 -1
  22. package/dist/commands/migrate.mjs +13 -13
  23. package/dist/commands/migrate.mjs.map +1 -1
  24. package/dist/commands/migration-check.d.mts +4 -2
  25. package/dist/commands/migration-check.d.mts.map +1 -1
  26. package/dist/commands/migration-check.mjs +1 -1
  27. package/dist/commands/migration-graph.d.mts +1 -1
  28. package/dist/commands/migration-graph.mjs +4 -4
  29. package/dist/commands/migration-list.d.mts +1 -1
  30. package/dist/commands/migration-list.d.mts.map +1 -1
  31. package/dist/commands/migration-list.mjs +1 -1
  32. package/dist/commands/migration-log.d.mts +1 -1
  33. package/dist/commands/migration-log.mjs +1 -1
  34. package/dist/commands/migration-new.d.mts.map +1 -1
  35. package/dist/commands/migration-new.mjs +16 -40
  36. package/dist/commands/migration-new.mjs.map +1 -1
  37. package/dist/commands/migration-plan.d.mts +3 -4
  38. package/dist/commands/migration-plan.d.mts.map +1 -1
  39. package/dist/commands/migration-plan.mjs +1 -1
  40. package/dist/commands/migration-show.mjs +5 -5
  41. package/dist/commands/migration-show.mjs.map +1 -1
  42. package/dist/commands/migration-status.d.mts +1 -1
  43. package/dist/commands/migration-status.d.mts.map +1 -1
  44. package/dist/commands/migration-status.mjs +1 -1
  45. package/dist/commands/ref.d.mts +1 -1
  46. package/dist/commands/ref.d.mts.map +1 -1
  47. package/dist/commands/ref.mjs +13 -18
  48. package/dist/commands/ref.mjs.map +1 -1
  49. package/dist/commands/telemetry/index.mjs +1 -1
  50. package/dist/contract-at-errors-DvZ_DzJK.mjs +36 -0
  51. package/dist/contract-at-errors-DvZ_DzJK.mjs.map +1 -0
  52. package/dist/{contract-emit-CgnXSANN.mjs → contract-emit-BT46Mu8Q.mjs} +3 -3
  53. package/dist/{contract-emit-CgnXSANN.mjs.map → contract-emit-BT46Mu8Q.mjs.map} +1 -1
  54. package/dist/{contract-emit-cJQBlvGb.mjs → contract-emit-hVdlaF2U.mjs} +6 -7
  55. package/dist/{contract-emit-cJQBlvGb.mjs.map → contract-emit-hVdlaF2U.mjs.map} +1 -1
  56. package/dist/{contract-enrichment-gn9sWbPw.mjs → contract-enrichment-JUhLv-BX.mjs} +8 -8
  57. package/dist/{contract-enrichment-gn9sWbPw.mjs.map → contract-enrichment-JUhLv-BX.mjs.map} +1 -1
  58. package/dist/{contract-infer-Cg8evbeg.mjs → contract-infer-DpqTQECL.mjs} +3 -3
  59. package/dist/{contract-infer-Cg8evbeg.mjs.map → contract-infer-DpqTQECL.mjs.map} +1 -1
  60. package/dist/{contract-space-aggregate-loader-D_3VeHVb.mjs → contract-space-aggregate-loader-CNd-ZB6C.mjs} +14 -14
  61. package/dist/contract-space-aggregate-loader-CNd-ZB6C.mjs.map +1 -0
  62. package/dist/{db-verify-BEclUzki.mjs → db-verify-FEN6k1m7.mjs} +10 -8
  63. package/dist/db-verify-FEN6k1m7.mjs.map +1 -0
  64. package/dist/exports/control-api.d.mts +4 -4
  65. package/dist/exports/control-api.d.mts.map +1 -1
  66. package/dist/exports/control-api.mjs +3 -3
  67. package/dist/exports/index.d.mts +2 -1
  68. package/dist/exports/index.d.mts.map +1 -1
  69. package/dist/exports/index.mjs +61 -21
  70. package/dist/exports/index.mjs.map +1 -1
  71. package/dist/exports/init-output.d.mts.map +1 -1
  72. package/dist/exports/init-output.mjs +1 -1
  73. package/dist/{format-DAUAZqPt.mjs → format-DI5qVr22.mjs} +8 -7
  74. package/dist/format-DI5qVr22.mjs.map +1 -0
  75. package/dist/{framework-components-CnbUbiJw.mjs → framework-components-C4XACYNB.mjs} +3 -3
  76. package/dist/framework-components-C4XACYNB.mjs.map +1 -0
  77. package/dist/{init-C3JhkHg-.mjs → init-ClrRkbwd.mjs} +77 -67
  78. package/dist/init-ClrRkbwd.mjs.map +1 -0
  79. package/dist/{inspect-live-schema-CX7EA5C3.mjs → inspect-live-schema-C0Rgdtw_.mjs} +4 -4
  80. package/dist/{inspect-live-schema-CX7EA5C3.mjs.map → inspect-live-schema-C0Rgdtw_.mjs.map} +1 -1
  81. package/dist/{migration-check-MHT3w7_v.mjs → migration-check-zEkHpPDT.mjs} +58 -30
  82. package/dist/migration-check-zEkHpPDT.mjs.map +1 -0
  83. package/dist/{migration-command-scaffold-CRyYrHZ9.mjs → migration-command-scaffold-CkNsp9g1.mjs} +4 -4
  84. package/dist/{migration-command-scaffold-CRyYrHZ9.mjs.map → migration-command-scaffold-CkNsp9g1.mjs.map} +1 -1
  85. package/dist/{migration-graph-command-render-B83xrnNy.mjs → migration-graph-command-render-DEwFpx-w.mjs} +5 -4
  86. package/dist/migration-graph-command-render-DEwFpx-w.mjs.map +1 -0
  87. package/dist/{migration-list-BAKujUjh.mjs → migration-list-BkafFVXS.mjs} +6 -6
  88. package/dist/migration-list-BkafFVXS.mjs.map +1 -0
  89. package/dist/{migration-log-C_xam2HZ.mjs → migration-log-BxhAtbhA.mjs} +5 -5
  90. package/dist/{migration-log-C_xam2HZ.mjs.map → migration-log-BxhAtbhA.mjs.map} +1 -1
  91. package/dist/{migration-path-target-DpPTsRCg.mjs → migration-path-target-B5HkjSTO.mjs} +2 -2
  92. package/dist/{migration-path-target-DpPTsRCg.mjs.map → migration-path-target-B5HkjSTO.mjs.map} +1 -1
  93. package/dist/{migration-plan-CreSVtWZ.mjs → migration-plan-Bk2pbPQH.mjs} +64 -74
  94. package/dist/migration-plan-Bk2pbPQH.mjs.map +1 -0
  95. package/dist/{migration-status-YgEvXf-u.mjs → migration-status-BzlARseq.mjs} +13 -12
  96. package/dist/migration-status-BzlARseq.mjs.map +1 -0
  97. package/dist/{output-mEQ74_nd.mjs → output-DWNYqZGc.mjs} +5 -6
  98. package/dist/output-DWNYqZGc.mjs.map +1 -0
  99. package/dist/{ref-advancement-BkXlikCA.mjs → ref-advancement-BCz7X7qJ.mjs} +13 -6
  100. package/dist/ref-advancement-BCz7X7qJ.mjs.map +1 -0
  101. package/dist/{telemetry-DVr6RFnq.mjs → telemetry-BbniBUbP.mjs} +2 -2
  102. package/dist/{telemetry-DVr6RFnq.mjs.map → telemetry-BbniBUbP.mjs.map} +1 -1
  103. package/dist/{types-D4r_HI9-.d.mts → types-DgXprE3w.d.mts} +3 -3
  104. package/dist/types-DgXprE3w.d.mts.map +1 -0
  105. package/dist/{verify-CgDVZjhc.mjs → verify-BSaNeaSL.mjs} +2 -2
  106. package/dist/{verify-CgDVZjhc.mjs.map → verify-BSaNeaSL.mjs.map} +1 -1
  107. package/package.json +21 -21
  108. package/src/commands/db-init.ts +5 -3
  109. package/src/commands/db-sign.ts +9 -7
  110. package/src/commands/db-update.ts +18 -9
  111. package/src/commands/db-verify.ts +4 -4
  112. package/src/commands/format.ts +1 -1
  113. package/src/commands/init/hygiene-gitattributes.ts +37 -21
  114. package/src/commands/init/init.ts +6 -6
  115. package/src/commands/init/output.ts +4 -5
  116. package/src/commands/init/probe-db.ts +9 -2
  117. package/src/commands/init/reinit-cleanup.ts +16 -17
  118. package/src/commands/init/templates/render.ts +2 -1
  119. package/src/commands/inspect-live-schema.ts +1 -1
  120. package/src/commands/migrate.ts +6 -5
  121. package/src/commands/migration-check.ts +72 -34
  122. package/src/commands/migration-list.ts +1 -5
  123. package/src/commands/migration-log.ts +1 -1
  124. package/src/commands/migration-new.ts +17 -41
  125. package/src/commands/migration-plan.ts +64 -88
  126. package/src/commands/migration-show.ts +2 -2
  127. package/src/commands/migration-status.ts +6 -7
  128. package/src/commands/ref.ts +19 -14
  129. package/src/control-api/client.ts +43 -25
  130. package/src/control-api/contract-enrichment.ts +7 -7
  131. package/src/control-api/operations/contract-emit.ts +2 -3
  132. package/src/control-api/operations/db-init.ts +3 -3
  133. package/src/control-api/operations/db-run.ts +8 -7
  134. package/src/control-api/operations/db-update.ts +2 -2
  135. package/src/control-api/operations/db-verify.ts +4 -4
  136. package/src/control-api/operations/format.ts +5 -4
  137. package/src/control-api/operations/migrate.ts +6 -5
  138. package/src/control-api/operations/run-migration.ts +2 -1
  139. package/src/control-api/types.ts +1 -1
  140. package/src/load-ts-contract.ts +81 -16
  141. package/src/utils/cli-errors.ts +15 -7
  142. package/src/utils/combine-verify-results.ts +2 -1
  143. package/src/utils/command-helpers.ts +15 -5
  144. package/src/utils/contract-at-errors.ts +13 -22
  145. package/src/utils/contract-space-aggregate-loader.ts +8 -8
  146. package/src/utils/contract-space-seed-phase.ts +11 -9
  147. package/src/utils/extension-pack-inputs.ts +8 -8
  148. package/src/utils/formatters/migration-graph-grid-layout.ts +2 -1
  149. package/src/utils/formatters/migration-graph-labels.ts +1 -2
  150. package/src/utils/formatters/migration-list-data-column.ts +1 -2
  151. package/src/utils/framework-components.ts +9 -9
  152. package/src/utils/integrity-violation-to-check-failure.ts +3 -3
  153. package/src/utils/migration-command-scaffold.ts +1 -1
  154. package/src/utils/plan-resolution.ts +7 -10
  155. package/src/utils/ref-advancement.ts +22 -3
  156. package/dist/client-KuBQftxz.mjs.map +0 -1
  157. package/dist/command-helpers-Cpq44aVa.mjs.map +0 -1
  158. package/dist/contract-at-errors-D9gEjYtg.mjs +0 -42
  159. package/dist/contract-at-errors-D9gEjYtg.mjs.map +0 -1
  160. package/dist/contract-space-aggregate-loader-D_3VeHVb.mjs.map +0 -1
  161. package/dist/db-verify-BEclUzki.mjs.map +0 -1
  162. package/dist/format-DAUAZqPt.mjs.map +0 -1
  163. package/dist/framework-components-CnbUbiJw.mjs.map +0 -1
  164. package/dist/init-C3JhkHg-.mjs.map +0 -1
  165. package/dist/migration-check-MHT3w7_v.mjs.map +0 -1
  166. package/dist/migration-graph-command-render-B83xrnNy.mjs.map +0 -1
  167. package/dist/migration-list-BAKujUjh.mjs.map +0 -1
  168. package/dist/migration-plan-CreSVtWZ.mjs.map +0 -1
  169. package/dist/migration-status-YgEvXf-u.mjs.map +0 -1
  170. package/dist/output-mEQ74_nd.mjs.map +0 -1
  171. package/dist/ref-advancement-BkXlikCA.mjs.map +0 -1
  172. package/dist/types-D4r_HI9-.d.mts.map +0 -1
  173. package/src/control-api/errors.ts +0 -9
@@ -1,11 +1,13 @@
1
- import { F as CliStructuredError, _ as createTerminalUI, b as formatErrorJson, x as formatErrorOutput } from "./command-helpers-Cpq44aVa.mjs";
1
+ import { F as CliStructuredError$1, _ as createTerminalUI, b as formatErrorJson, x as formatErrorOutput } from "./command-helpers-D-jBl0Qt.mjs";
2
2
  import { a as starterSchema, c as version, i as schemaSample, n as dbFile, o as targetLabel, r as defaultSchemaPath, s as targetPackageName, t as configFile } from "./cli.mjs";
3
- import { i as renderInitOutro, n as buildNextSteps, r as formatInitJson, t as InitOutputSchema } from "./output-mEQ74_nd.mjs";
3
+ import { i as renderInitOutro, n as buildNextSteps, r as formatInitJson, t as InitOutputSchema } from "./output-DWNYqZGc.mjs";
4
4
  import { createRequire } from "node:module";
5
+ import { CliStructuredError } from "@prisma-next/errors/control";
5
6
  import { basename, dirname, extname, isAbsolute, join, normalize } from "pathe";
6
7
  import { blindCast } from "@prisma-next/utils/casts";
7
8
  import * as clack from "@clack/prompts";
8
9
  import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
10
+ import { InternalError } from "@prisma-next/utils/internal-error";
9
11
  import { execFile } from "node:child_process";
10
12
  import { promisify } from "node:util";
11
13
  import { detect, getUserAgent } from "package-manager-detector/detect";
@@ -182,7 +184,7 @@ function stripQuotes(value) {
182
184
  * the user was never given the choice — `--force` is the contract.
183
185
  */
184
186
  function errorInitReinitNeedsForce() {
185
- return new CliStructuredError("CLI.INIT_REINIT_NEEDS_FORCE", "Project is already initialized", {
187
+ return new CliStructuredError$1("CLI.INIT_REINIT_NEEDS_FORCE", "Project is already initialized", {
186
188
  why: "A `prisma-next.config.ts` already exists in this directory. Re-running `init` would overwrite the scaffolded files; in non-interactive mode `init` will not do that without `--force`.",
187
189
  fix: "Pass `--force` to overwrite the existing scaffold, or run `init` interactively to confirm.",
188
190
  docsUrl: "https://prisma-next.dev/docs/cli/init"
@@ -207,7 +209,7 @@ function errorInitMissingFlags(options) {
207
209
  default: return `--${flag} <value>`;
208
210
  }
209
211
  }).join(" ");
210
- return new CliStructuredError("CLI.INIT_MISSING_FLAGS", "Missing required flags", {
212
+ return new CliStructuredError$1("CLI.INIT_MISSING_FLAGS", "Missing required flags", {
211
213
  why: `${options.why} Missing required flag(s): ${flagList}.`,
212
214
  fix: `Re-run with the missing flag(s) supplied, e.g. \`prisma-next init --yes ${fixList}\`. Use \`prisma-next init --help\` to see every flag.`,
213
215
  docsUrl: "https://prisma-next.dev/docs/cli/init",
@@ -219,7 +221,7 @@ function errorInitMissingFlags(options) {
219
221
  * allowed values in `meta` for machine-readable consumption.
220
222
  */
221
223
  function errorInitInvalidFlagValue(options) {
222
- return new CliStructuredError("CLI.INIT_INVALID_FLAG_VALUE", `Invalid value for --${options.flag}`, {
224
+ return new CliStructuredError$1("CLI.INIT_INVALID_FLAG_VALUE", `Invalid value for --${options.flag}`, {
223
225
  why: `\`--${options.flag} ${options.value}\` is not one of: ${options.allowed.join(", ")}.`,
224
226
  fix: `Use one of: ${options.allowed.map((v) => `--${options.flag} ${v}`).join(", ")}.`,
225
227
  docsUrl: "https://prisma-next.dev/docs/cli/init",
@@ -237,7 +239,7 @@ function errorInitInvalidFlagValue(options) {
237
239
  */
238
240
  function errorInitAuthoringSchemaPathMismatch(options) {
239
241
  const expectedAuthoring = options.expectedExtension === ".ts" ? "typescript" : "psl";
240
- return new CliStructuredError("CLI.INIT_AUTHORING_SCHEMA_PATH_MISMATCH", "Authoring and schema path do not match", {
242
+ return new CliStructuredError$1("CLI.INIT_AUTHORING_SCHEMA_PATH_MISMATCH", "Authoring and schema path do not match", {
241
243
  why: `\`--authoring ${options.authoring}\` requires a schema file ending in ${options.expectedExtension}, but \`--schema-path ${options.schemaPath}\` ends in ${options.actualExtension}.`,
242
244
  fix: `Use a matching pair, for example \`--authoring ${expectedAuthoring} --schema-path <path>${options.expectedExtension}\`, or change \`--authoring\` to match the path you supplied. You can also omit \`--schema-path\` to use the default for the chosen authoring.`,
243
245
  docsUrl: "https://prisma-next.dev/docs/cli/init",
@@ -257,7 +259,7 @@ function errorInitAuthoringSchemaPathMismatch(options) {
257
259
  * 3 (USER_ABORTED).
258
260
  */
259
261
  function errorInitUserAborted() {
260
- return new CliStructuredError("CLI.INIT_USER_ABORTED", "Init cancelled", {
262
+ return new CliStructuredError$1("CLI.INIT_USER_ABORTED", "Init cancelled", {
261
263
  why: "The interactive prompt was cancelled before all required inputs were supplied. No files were modified.",
262
264
  fix: "Re-run `prisma-next init` and complete the prompts, or pass the required inputs as flags (see `--help`) for a non-interactive run.",
263
265
  severity: "info"
@@ -272,7 +274,7 @@ function errorInitUserAborted() {
272
274
  * mode is supposed to prevent.
273
275
  */
274
276
  function errorInitStrictProbeWithoutProbe() {
275
- return new CliStructuredError("CLI.INIT_STRICT_PROBE_WITHOUT_PROBE", "`--strict-probe` requires `--probe-db`", {
277
+ return new CliStructuredError$1("CLI.INIT_STRICT_PROBE_WITHOUT_PROBE", "`--strict-probe` requires `--probe-db`", {
276
278
  why: "`--strict-probe` only changes how a *failed* probe is reported; without `--probe-db` no probe is attempted in the first place. (`init` is offline-by-default — it never opens a connection to your database without explicit consent.)",
277
279
  fix: "Add `--probe-db` to opt in to the probe, or drop `--strict-probe` if you do not need the version check.",
278
280
  docsUrl: "https://prisma-next.dev/docs/cli/init"
@@ -287,7 +289,7 @@ function errorInitStrictProbeWithoutProbe() {
287
289
  */
288
290
  function errorInitInstallFailed(options) {
289
291
  const trimmed = options.stderrLines.map((s) => s.trim()).filter(Boolean);
290
- return new CliStructuredError("CLI.INIT_INSTALL_FAILED", "Failed to install dependencies", {
292
+ return new CliStructuredError$1("CLI.INIT_INSTALL_FAILED", "Failed to install dependencies", {
291
293
  why: trimmed.length === 0 ? "The package manager exited with an error and no recoverable fallback applied." : `The package manager exited with: ${trimmed[0]}`,
292
294
  fix: `Install manually:\n ${options.addCommand}\n ${options.addDevCommand}\nThen run \`${options.emitCommand}\` to emit the contract.`,
293
295
  docsUrl: "https://prisma-next.dev/docs/cli/init",
@@ -309,7 +311,7 @@ function errorInitInstallFailed(options) {
309
311
  * and re-run.
310
312
  */
311
313
  function errorInitInvalidManifest(options) {
312
- return new CliStructuredError("CLI.INIT_INVALID_MANIFEST", `Failed to parse ${options.path}`, {
314
+ return new CliStructuredError$1("CLI.INIT_INVALID_MANIFEST", `Failed to parse ${options.path}`, {
313
315
  why: `\`${options.path}\` is not valid JSON: ${options.cause}`,
314
316
  fix: `Fix the JSON syntax in \`${options.path}\` (a missing comma or unbalanced brace is the most common cause), then re-run \`prisma-next init\`.`,
315
317
  docsUrl: "https://prisma-next.dev/docs/cli/init",
@@ -334,7 +336,7 @@ function errorInitInvalidManifest(options) {
334
336
  * re-run.
335
337
  */
336
338
  function errorInitInvalidTsconfig(options) {
337
- return new CliStructuredError("CLI.INIT_INVALID_TSCONFIG", `Failed to parse ${options.path}`, {
339
+ return new CliStructuredError$1("CLI.INIT_INVALID_TSCONFIG", `Failed to parse ${options.path}`, {
338
340
  why: `\`${options.path}\` is not valid JSON or JSONC: ${options.cause}`,
339
341
  fix: `Fix the syntax in \`${options.path}\` and re-run \`prisma-next init\`. \`init\` accepts JSONC (comments and trailing commas) but cannot recover from unbalanced braces or missing commas.`,
340
342
  docsUrl: "https://prisma-next.dev/docs/cli/init",
@@ -359,7 +361,7 @@ function errorInitInvalidTsconfig(options) {
359
361
  * carries `filesWritten` so a follow-up agent can resume manually.
360
362
  */
361
363
  function errorInitProbeFailed(options) {
362
- return new CliStructuredError("CLI.INIT_PROBE_FAILED", "Database probe failed", {
364
+ return new CliStructuredError$1("CLI.INIT_PROBE_FAILED", "Database probe failed", {
363
365
  why: `\`--probe-db\` could not complete and \`--strict-probe\` was set: ${options.cause}`,
364
366
  fix: "Confirm `DATABASE_URL` points at a reachable server, or drop `--strict-probe` to treat probe failures as warnings.",
365
367
  docsUrl: "https://prisma-next.dev/docs/cli/init",
@@ -376,7 +378,7 @@ function errorInitProbeFailed(options) {
376
378
  * `5 = EMIT_FAILED`.
377
379
  */
378
380
  function errorInitEmitFailed(options) {
379
- return new CliStructuredError("CLI.INIT_EMIT_FAILED", "Failed to emit contract", {
381
+ return new CliStructuredError$1("CLI.INIT_EMIT_FAILED", "Failed to emit contract", {
380
382
  why: `\`prisma-next contract emit\` failed: ${options.cause}`,
381
383
  fix: `Inspect your contract file, fix the underlying issue, then re-run \`${options.emitCommand}\`. Pass \`-v\` for the full error envelope.`,
382
384
  docsUrl: "https://prisma-next.dev/docs/cli/contract-emit",
@@ -398,7 +400,7 @@ function errorInitEmitFailed(options) {
398
400
  * semantics. Maps to exit code `6 = SKILL_INSTALL_FAILED`.
399
401
  */
400
402
  function errorInitSkillInstallFailed(options) {
401
- return new CliStructuredError("CLI.INIT_SKILL_INSTALL_FAILED", "Failed to install Prisma Next skills", {
403
+ return new CliStructuredError$1("CLI.INIT_SKILL_INSTALL_FAILED", "Failed to install Prisma Next skills", {
402
404
  why: `\`${options.skillInstallCommand}\` exited with an error: ${options.cause}`,
403
405
  fix: `Either:
404
406
  - Re-run \`prisma-next init --no-skill${options.filesWritten.length > 0 ? " --force" : ""}\` to skip the skill install for this run, or\n - Fix the underlying issue (network, npm registry, \`npx skills\` on PATH) and install manually:\n ${options.skillInstallCommand}`,
@@ -413,50 +415,59 @@ function errorInitSkillInstallFailed(options) {
413
415
  //#endregion
414
416
  //#region src/commands/init/hygiene-gitattributes.ts
415
417
  /**
416
- * The schema-relative `.gitattributes` entries written for a freshly
417
- * initialised project (FR3.4). Mirrors the relevant subset of the
418
- * repo-root [`.gitattributes`](../../../../../../../../.gitattributes):
418
+ * The `.gitattributes` entries written for a freshly initialised project
419
+ * (FR3.4). Mirrors the relevant subset of the repo-root
420
+ * [`.gitattributes`](../../../../../../../../.gitattributes):
419
421
  *
420
422
  * - **Today**: `contract.json`, `contract.d.ts` are emitted on every
421
423
  * `prisma-next contract emit`. Marking them `linguist-generated`
422
424
  * keeps GitHub's diff stats honest and collapses the file in code
423
425
  * review by default.
424
- * - **Forward-looking**: `end-contract.*`, `start-contract.*`, `ops.json`,
425
- * `migration.json` are not yet emitted by `init` flows but will be
426
- * produced by adjacent commands (lower / migration tooling). Adding
427
- * them now matches Decision 5 (forward-looking subset) so the file
428
- * does not need to be amended every time a new artefact lands.
429
- *
430
- * Patterns are written relative to the schema directory so a user
431
- * who runs `init --schema-path db/contract.prisma` gets
432
- * `db/contract.json linguist-generated` — not the workspace-glob form
433
- * `<glob>/contract.json` (which would over-match any unrelated
426
+ * - **Forward-looking**: `ops.json`, `migration.json` are not yet emitted
427
+ * by `init` flows but will be produced by adjacent commands (lower /
428
+ * migration tooling). Adding them now matches Decision 5
429
+ * (forward-looking subset) so the file does not need to be amended
430
+ * every time a new artifact lands.
431
+ *
432
+ * `ARTIFACT_FILENAMES` entries are written relative to the schema
433
+ * directory so a user who runs `init --schema-path db/contract.prisma`
434
+ * gets `db/contract.json linguist-generated` — not the workspace-glob
435
+ * form `<glob>/contract.json` (which would over-match any unrelated
434
436
  * `contract.json` the user has elsewhere) and not the absolute
435
- * `DEFAULT_CONTRACT_SOURCE_DIR/contract.json` (which would silently break for a non-default
436
- * schema path).
437
+ * `DEFAULT_CONTRACT_SOURCE_DIR/contract.json` (which would silently
438
+ * break for a non-default schema path).
439
+ *
440
+ * The migration contract snapshot store (`migrations/snapshots/<hex>/`)
441
+ * is anchored to the migrations root instead, not the schema directory:
442
+ * migration package depth under `migrations/` varies (`app/<pkg>`,
443
+ * `<space>/<pkg>`, or a bare `<pkg>` in extension source repos), so no
444
+ * single schema-dir-relative pattern can reach every snapshot. See
445
+ * `STORE_GITATTRIBUTES_LINES` below.
437
446
  */
438
- const ARTEFACT_FILENAMES$1 = [
447
+ const ARTIFACT_FILENAMES$1 = [
439
448
  "contract.json",
440
449
  "contract.d.ts",
441
- "end-contract.json",
442
- "end-contract.d.ts",
443
- "start-contract.json",
444
- "start-contract.d.ts",
445
450
  "ops.json",
446
451
  "migration.json"
447
452
  ];
448
453
  const ATTRIBUTE = "linguist-generated";
449
454
  /**
455
+ * Full `.gitattributes` lines for the migration contract snapshot store,
456
+ * already anchored to the migrations root — unlike `ARTIFACT_FILENAMES`,
457
+ * these are not combined with the schema-relative prefix.
458
+ */
459
+ const STORE_GITATTRIBUTES_LINES = [`migrations/snapshots/**/contract.json ${ATTRIBUTE}`, `migrations/snapshots/**/contract.d.ts ${ATTRIBUTE}`];
460
+ /**
450
461
  * Computes the `.gitattributes` lines this scaffold expects to own. Each
451
462
  * line has the shape `<path> linguist-generated`. The `target` parameter
452
463
  * is currently unused but accepted for symmetry with the other hygiene
453
464
  * helpers and to leave room for target-specific entries (e.g. a future
454
- * Mongo-only artefact) without a signature break.
465
+ * family-specific artifact) without a signature break.
455
466
  */
456
467
  function requiredGitattributesLines(schemaDir, _target) {
457
468
  const dir = schemaDir === "." ? "" : schemaDir.replace(/\/+$/, "");
458
469
  const prefix = dir === "" ? "" : `${dir}/`;
459
- return ARTEFACT_FILENAMES$1.map((file) => `${prefix}${file} ${ATTRIBUTE}`);
470
+ return [...ARTIFACT_FILENAMES$1.map((file) => `${prefix}${file} ${ATTRIBUTE}`), ...STORE_GITATTRIBUTES_LINES];
460
471
  }
461
472
  /**
462
473
  * Idempotent `.gitattributes` merge (FR3.4 / FR9.3). Returns the new file
@@ -999,7 +1010,7 @@ async function defaultProbePostgres(databaseUrl, baseDir, overrides) {
999
1010
  */
1000
1011
  function parsePostgresVersion(versionString) {
1001
1012
  const match = versionString.match(/PostgreSQL\s+(\d+(?:\.\d+)?)/i);
1002
- if (match === null || match[1] === void 0) throw new Error(`Could not parse PostgreSQL version from \`${versionString}\``);
1013
+ if (match === null || match[1] === void 0) throw new CliStructuredError("CLI.INIT_PROBE_FAILED", `Could not parse PostgreSQL version from \`${versionString}\``);
1003
1014
  return match[1];
1004
1015
  }
1005
1016
  async function defaultProbeMongo(databaseUrl, baseDir, overrides) {
@@ -1008,7 +1019,7 @@ async function defaultProbeMongo(databaseUrl, baseDir, overrides) {
1008
1019
  try {
1009
1020
  const buildInfo = await client.db().admin().command({ buildInfo: 1 });
1010
1021
  const versionString = String(buildInfo.version ?? "");
1011
- if (versionString.length === 0) throw new Error("buildInfo did not include a `version` field");
1022
+ if (versionString.length === 0) throw new CliStructuredError("CLI.INIT_PROBE_FAILED", "buildInfo did not include a `version` field");
1012
1023
  return { serverVersion: versionString };
1013
1024
  } finally {
1014
1025
  await client.close().catch(() => void 0);
@@ -1037,40 +1048,39 @@ function requirePeer(moduleId, baseDir, overrides) {
1037
1048
  /**
1038
1049
  * Filenames the contract pipeline emits next to the user's schema source
1039
1050
  * (`<schemaDir>/contract.json`, `<schemaDir>/contract.d.ts`, …). Mirrors
1040
- * `ARTEFACT_FILENAMES` in `hygiene-gitattributes.ts`; kept as a separate
1041
- * constant here because the cleanup contract is target-agnostic and we
1042
- * deliberately do not want a stale `start-contract.json` from a previous
1043
- * target lingering after a re-init.
1044
- *
1045
- * If a future emit pipeline produces an additional artefact, add it here
1046
- * **and** to the gitattributes list — the two stay in lockstep so the
1047
- * file `init` advertises as `linguist-generated` is exactly the file
1048
- * `init` is willing to delete on re-init.
1049
- */
1050
- const ARTEFACT_FILENAMES = [
1051
+ * the schema-dir-relative `ARTIFACT_FILENAMES` in `hygiene-gitattributes.ts`
1052
+ * (not that file's migrations-root-anchored store lines, which are outside
1053
+ * this command's scope reinit only ever touches `schemaDir`); kept as a
1054
+ * separate constant here because the cleanup contract is target-agnostic
1055
+ * and we deliberately do not want a stale artifact from a previous target
1056
+ * lingering after a re-init.
1057
+ *
1058
+ * If a future emit pipeline produces an additional schema-dir artifact,
1059
+ * add it here **and** to `ARTIFACT_FILENAMES` in `hygiene-gitattributes.ts`
1060
+ * — the two stay in lockstep so the file `init` advertises as
1061
+ * `linguist-generated` is exactly the file `init` is willing to delete on
1062
+ * re-init.
1063
+ */
1064
+ const ARTIFACT_FILENAMES = [
1051
1065
  "contract.json",
1052
1066
  "contract.d.ts",
1053
- "end-contract.json",
1054
- "end-contract.d.ts",
1055
- "start-contract.json",
1056
- "start-contract.d.ts",
1057
1067
  "ops.json",
1058
1068
  "migration.json"
1059
1069
  ];
1060
1070
  /**
1061
- * Returns the schema-relative paths of stale contract artefacts the
1071
+ * Returns the schema-relative paths of stale contract artifacts the
1062
1072
  * previous `init` run (or a `contract emit`) left behind in `schemaDir`.
1063
1073
  * Paths are returned relative to `baseDir` so the caller can plumb them
1064
1074
  * into `filesWritten`-style logging without re-deriving the path.
1065
1075
  *
1066
1076
  * Pure function: no filesystem mutation. Used by `runInit`'s precondition
1067
1077
  * phase (FR6.2 / NFR3 atomicity) so a downstream parse failure leaves
1068
- * the artefacts on disk and the project byte-identical to its pre-init
1078
+ * the artifacts on disk and the project byte-identical to its pre-init
1069
1079
  * state.
1070
1080
  */
1071
- function findStaleArtefacts(baseDir, schemaDir) {
1081
+ function findStaleArtifacts(baseDir, schemaDir) {
1072
1082
  const result = [];
1073
- for (const filename of ARTEFACT_FILENAMES) {
1083
+ for (const filename of ARTIFACT_FILENAMES) {
1074
1084
  const rel = join(schemaDir, filename);
1075
1085
  if (existsSync(join(baseDir, rel))) result.push(rel);
1076
1086
  }
@@ -1370,7 +1380,7 @@ function renderTemplate(templateFile, variableNames, vars) {
1370
1380
  let result = readFileSync(join(import.meta.dirname, templateFile), "utf-8");
1371
1381
  for (const key of variableNames) {
1372
1382
  const value = vars[key];
1373
- if (value === void 0) throw new Error(`Template variable '${key}' is not defined`);
1383
+ if (value === void 0) throw new InternalError(`Template variable '${key}' is not defined`);
1374
1384
  result = result.replaceAll(`{{${key}}}`, value);
1375
1385
  }
1376
1386
  return result;
@@ -1640,7 +1650,7 @@ async function runInit(baseDir, runOptions) {
1640
1650
  canPrompt
1641
1651
  });
1642
1652
  } catch (error) {
1643
- if (CliStructuredError.is(error)) return emitError(ui, flags, error);
1653
+ if (CliStructuredError$1.is(error)) return emitError(ui, flags, error);
1644
1654
  throw error;
1645
1655
  }
1646
1656
  const pm = await detectPackageManager(baseDir);
@@ -1669,7 +1679,7 @@ async function runInit(baseDir, runOptions) {
1669
1679
  content: envExampleContent(inputs.target)
1670
1680
  }
1671
1681
  ];
1672
- const filesToDelete = inputs.reinit ? [...findStaleArtefacts(baseDir, schemaDir)] : [];
1682
+ const filesToDelete = inputs.reinit ? [...findStaleArtifacts(baseDir, schemaDir)] : [];
1673
1683
  if (existsSync(join(baseDir, ".agents/skills/prisma-next/SKILL.md"))) filesToDelete.push(LEGACY_SKILL_FILE);
1674
1684
  if (inputs.writeEnv) if (!existsSync(join(baseDir, ".env"))) filesToWrite.push({
1675
1685
  path: ".env",
@@ -1790,7 +1800,7 @@ async function runInit(baseDir, runOptions) {
1790
1800
  hasTypesNode: parsedPackageJson !== null ? hasDirectDep(parsedPackageJson, "@types/node") : false
1791
1801
  });
1792
1802
  } catch (error) {
1793
- if (CliStructuredError.is(error)) return emitError(ui, flags, error);
1803
+ if (CliStructuredError$1.is(error)) return emitError(ui, flags, error);
1794
1804
  throw error;
1795
1805
  }
1796
1806
  warnings.push(...install.warnings);
@@ -1804,7 +1814,7 @@ async function runInit(baseDir, runOptions) {
1804
1814
  });
1805
1815
  contractEmitted = true;
1806
1816
  } catch (error) {
1807
- if (CliStructuredError.is(error)) return emitError(ui, flags, error);
1817
+ if (CliStructuredError$1.is(error)) return emitError(ui, flags, error);
1808
1818
  throw error;
1809
1819
  }
1810
1820
  if (inputs.probeDb) {
@@ -1841,7 +1851,7 @@ async function runInit(baseDir, runOptions) {
1841
1851
  skillRegistered = true;
1842
1852
  } catch (error) {
1843
1853
  spinner.stop("Agent-skill install failed");
1844
- if (CliStructuredError.is(error)) return emitError(ui, flags, error);
1854
+ if (CliStructuredError$1.is(error)) return emitError(ui, flags, error);
1845
1855
  throw error;
1846
1856
  }
1847
1857
  }
@@ -1868,7 +1878,7 @@ async function runInit(baseDir, runOptions) {
1868
1878
  warnings
1869
1879
  };
1870
1880
  const validated = InitOutputSchema(output);
1871
- if (validated instanceof Error || validated.problems !== void 0) return emitError(ui, flags, new CliStructuredError("CLI.INIT_INVALID_OUTPUT_DOCUMENT", "Init produced an invalid output document", {
1881
+ if (validated instanceof Error || validated.problems !== void 0) return emitError(ui, flags, new CliStructuredError$1("CLI.INIT_INVALID_OUTPUT_DOCUMENT", "Init produced an invalid output document", {
1872
1882
  why: `The success document failed schema validation: ${String(validated)}`,
1873
1883
  fix: "This is a bug in prisma-next. Please report it with the full `-v` output.",
1874
1884
  docsUrl: "https://prisma-next.dev/docs/cli/init"
@@ -2081,7 +2091,7 @@ function formatCatalogWarning(workspaceFile, entries) {
2081
2091
  /**
2082
2092
  * Recognised pnpm error signatures that justify a fallback to npm.
2083
2093
  *
2084
- * These patterns indicate the published artefact itself is at fault
2094
+ * These patterns indicate the published artifact itself is at fault
2085
2095
  * (a leaked `workspace:*` or `catalog:` specifier), not the user's
2086
2096
  * environment — pnpm is faithfully reporting "I cannot resolve this
2087
2097
  * registry version", and npm is willing to install it because npm
@@ -2140,7 +2150,7 @@ async function runEmit(ctx) {
2140
2150
  const spinner = ctx.ui.spinner();
2141
2151
  spinner.start("Emitting contract...");
2142
2152
  try {
2143
- const { executeContractEmit } = await import("./contract-emit-cJQBlvGb.mjs").then((n) => n.t);
2153
+ const { executeContractEmit } = await import("./contract-emit-hVdlaF2U.mjs").then((n) => n.t);
2144
2154
  await executeContractEmit({ configPath: join(ctx.baseDir, "prisma-next.config.ts") });
2145
2155
  spinner.stop("Contract emitted");
2146
2156
  } catch (err) {
@@ -2193,4 +2203,4 @@ function sanitisePackageName(raw) {
2193
2203
  //#endregion
2194
2204
  export { runInit };
2195
2205
 
2196
- //# sourceMappingURL=init-C3JhkHg-.mjs.map
2206
+ //# sourceMappingURL=init-ClrRkbwd.mjs.map