@prisma/cli-engine 0.2.1 → 0.2.3

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.
@@ -346,60 +346,11 @@ function camelCase(typed) {
346
346
  return typed.replace(/-([a-zA-Z0-9])/g, (_, char) => char.toUpperCase());
347
347
  }
348
348
  //#endregion
349
- //#region src/spawn.ts
350
- const CHILD_STATUS = Symbol.for("@prisma/cli-engine.childStatus");
351
- /** Signal numbers shared by Linux, macOS and the BSDs. Numbers that
352
- * differ by platform (SIGBUS, SIGUSR1, SIGUSR2, …) are deliberately
353
- * absent — a wrong 128+n is worse than the unknown-signal fallback. */
354
- const SIGNAL_NUMBERS = {
355
- SIGHUP: 1,
356
- SIGINT: 2,
357
- SIGQUIT: 3,
358
- SIGILL: 4,
359
- SIGTRAP: 5,
360
- SIGABRT: 6,
361
- SIGFPE: 8,
362
- SIGKILL: 9,
363
- SIGSEGV: 11,
364
- SIGPIPE: 13,
365
- SIGALRM: 14,
366
- SIGTERM: 15
367
- };
368
- /** A signal-killed child settles 128 + the signal number; otherwise the
369
- * child's own exit code, verbatim. Unknown is never success: a signal
370
- * outside the portable table, or an adapter that cannot say how the
371
- * child ended (exitCode and signal both null), settles 1. */
372
- function childExitCode(child) {
373
- if (child.signal === null) return child.exitCode ?? 1;
374
- const signalNumber = SIGNAL_NUMBERS[child.signal];
375
- return signalNumber === void 0 ? 1 : 128 + signalNumber;
376
- }
377
- /**
378
- * Settles the run with the status of the child the run spawned — the
379
- * one `ctx.lastChild()` reports. The handler names no child and no
380
- * code: this is how a real child's status reaches the exit code, not
381
- * how a handler picks one, so a run that spawned nothing is a
382
- * construction error at settlement.
383
- *
384
- * A signal-killed child overrules everything the caller asked for: it
385
- * settles 128 + the signal number with no `nextActions`, because the
386
- * user stopped the run and there is nothing to reproduce.
387
- */
388
- function exitWithChildStatus(options) {
389
- return Object.freeze({
390
- [CHILD_STATUS]: true,
391
- nextActions: Object.freeze([...options?.nextActions ?? []])
392
- });
393
- }
394
- function isChildStatusSettlement(value) {
395
- return typeof value === "object" && value !== null && value[CHILD_STATUS] === true;
396
- }
397
- //#endregion
398
349
  //#region src/ci.ts
399
350
  /**
400
351
  * ci-info's provider table. Its `isCI` export is unusable — it reads
401
352
  * the real `process.env` at import; the engine reads only host-injected
402
- * env. The table is inlined into the build (tsdown `noExternal`): the
353
+ * env. The table is inlined into the build (tsdown `deps.alwaysBundle`): the
403
354
  * file is CJS-owned by ci-info, and loading it as ESM at runtime breaks
404
355
  * hosts that also require ci-info (Bun's dual registry; composer#234).
405
356
  * Pinned by tests/no-esm-json-import-in-dist.test.ts.
@@ -779,6 +730,55 @@ function resolveIsCI(host) {
779
730
  return host.isCIOverride ?? detectCI(host.env);
780
731
  }
781
732
  //#endregion
733
+ //#region src/spawn.ts
734
+ const CHILD_STATUS = Symbol.for("@prisma/cli-engine.childStatus");
735
+ /** Signal numbers shared by Linux, macOS and the BSDs. Numbers that
736
+ * differ by platform (SIGBUS, SIGUSR1, SIGUSR2, …) are deliberately
737
+ * absent — a wrong 128+n is worse than the unknown-signal fallback. */
738
+ const SIGNAL_NUMBERS = {
739
+ SIGHUP: 1,
740
+ SIGINT: 2,
741
+ SIGQUIT: 3,
742
+ SIGILL: 4,
743
+ SIGTRAP: 5,
744
+ SIGABRT: 6,
745
+ SIGFPE: 8,
746
+ SIGKILL: 9,
747
+ SIGSEGV: 11,
748
+ SIGPIPE: 13,
749
+ SIGALRM: 14,
750
+ SIGTERM: 15
751
+ };
752
+ /** A signal-killed child settles 128 + the signal number; otherwise the
753
+ * child's own exit code, verbatim. Unknown is never success: a signal
754
+ * outside the portable table, or an adapter that cannot say how the
755
+ * child ended (exitCode and signal both null), settles 1. */
756
+ function childExitCode(child) {
757
+ if (child.signal === null) return child.exitCode ?? 1;
758
+ const signalNumber = SIGNAL_NUMBERS[child.signal];
759
+ return signalNumber === void 0 ? 1 : 128 + signalNumber;
760
+ }
761
+ /**
762
+ * Settles the run with the status of the child the run spawned — the
763
+ * one `ctx.lastChild()` reports. The handler names no child and no
764
+ * code: this is how a real child's status reaches the exit code, not
765
+ * how a handler picks one, so a run that spawned nothing is a
766
+ * construction error at settlement.
767
+ *
768
+ * A signal-killed child overrules everything the caller asked for: it
769
+ * settles 128 + the signal number with no `nextActions`, because the
770
+ * user stopped the run and there is nothing to reproduce.
771
+ */
772
+ function exitWithChildStatus(options) {
773
+ return Object.freeze({
774
+ [CHILD_STATUS]: true,
775
+ nextActions: Object.freeze([...options?.nextActions ?? []])
776
+ });
777
+ }
778
+ function isChildStatusSettlement(value) {
779
+ return typeof value === "object" && value !== null && value[CHILD_STATUS] === true;
780
+ }
781
+ //#endregion
782
782
  //#region src/telemetry/endpoint.ts
783
783
  /**
784
784
  * Production endpoint pinned to the deployed Prisma Compute backend.
@@ -1605,6 +1605,44 @@ function missingNamedFileDiagnostic(path) {
1605
1605
  where: { path }
1606
1606
  };
1607
1607
  }
1608
+ /** jiti reports an unresolvable import as "Cannot find module", Node's
1609
+ * own resolver as "Cannot find package"; either can appear in the
1610
+ * evaluation error chain depending on how the file is loaded. Node's
1611
+ * ESM resolver names only the package, not the subpath — a missing
1612
+ * `import "prisma/config"` reads "Cannot find package 'prisma'" — and
1613
+ * the closing quote keeps a package like 'prisma-x' from matching. */
1614
+ const MISSING_PRISMA_CONFIG_MESSAGES = [
1615
+ "Cannot find module 'prisma/config'",
1616
+ "Cannot find package 'prisma/config'",
1617
+ "Cannot find package 'prisma'"
1618
+ ];
1619
+ /** The walk is depth-limited so a cyclic `cause` chain terminates. */
1620
+ const CAUSE_CHAIN_LIMIT = 10;
1621
+ function importsMissingPrismaPackage(cause) {
1622
+ let error = cause;
1623
+ for (let depth = 0; depth < CAUSE_CHAIN_LIMIT && error instanceof Error; depth += 1, error = error.cause) {
1624
+ const message = error.message;
1625
+ if (MISSING_PRISMA_CONFIG_MESSAGES.some((text) => message.includes(text))) return true;
1626
+ }
1627
+ return false;
1628
+ }
1629
+ /** A plain `npm install prisma` would fetch `latest`, which can be the
1630
+ * too-old version the `why` warns about — the example names the exact
1631
+ * version, or is dropped when the host supplied none. */
1632
+ function prismaConfigUnresolvedDiagnostic(path, cliVersion) {
1633
+ const example = cliVersion === void 0 ? "" : ` (for example: npm install --save-dev prisma@${cliVersion})`;
1634
+ return {
1635
+ code: "CLI.CONFIG_UNREADABLE",
1636
+ severity: "error",
1637
+ summary: `${path} could not be evaluated: the 'prisma/config' entry point could not be resolved from this project.`,
1638
+ why: "The config file imports definePrismaConfig from the prisma npm package's 'prisma/config' entry point, which resolves from the project's node_modules. The package may be missing there — running the CLI through npx installs nothing into the project — or an installed version may be too old to provide the entry point.",
1639
+ nextActions: [{
1640
+ kind: "user-choice",
1641
+ label: `Install the prisma package matching this CLI's version as a dev dependency${example}, then run the command again.`
1642
+ }],
1643
+ where: { path }
1644
+ };
1645
+ }
1608
1646
  function unreadableDiagnostic(path, cause) {
1609
1647
  return {
1610
1648
  code: "CLI.CONFIG_UNREADABLE",
@@ -1684,9 +1722,13 @@ function fileToRead(cwd, configPath) {
1684
1722
  }
1685
1723
  /**
1686
1724
  * The real-disk loader behind Runtime.loadConfig. The bin binds it to
1687
- * the process cwd; tests hand in fixtures.
1725
+ * the process cwd and its own version; tests hand in fixtures.
1726
+ * `cliVersion` names the exact prisma version in the install guidance
1727
+ * when the 'prisma/config' entry point cannot be resolved; absent, the
1728
+ * guidance names no version rather than an example that installs the
1729
+ * wrong one.
1688
1730
  */
1689
- async function loadConfig(cwd, configPath) {
1731
+ async function loadConfig(cwd, configPath, cliVersion) {
1690
1732
  const path = fileToRead(cwd, configPath);
1691
1733
  if (!existsSync(path)) return configPath === void 0 ? {
1692
1734
  path,
@@ -1697,7 +1739,7 @@ async function loadConfig(cwd, configPath) {
1697
1739
  try {
1698
1740
  exported = await evaluateConfigFile(path);
1699
1741
  } catch (cause) {
1700
- return fileLevelConfig(path, unreadableDiagnostic(path, cause));
1742
+ return fileLevelConfig(path, importsMissingPrismaPackage(cause) ? prismaConfigUnresolvedDiagnostic(path, cliVersion) : unreadableDiagnostic(path, cause));
1701
1743
  }
1702
1744
  if (!hasVersionMarker(exported)) return fileLevelConfig(path, missingMarkerDiagnostic(path));
1703
1745
  const version = exported[MARKER_KEY];
@@ -4947,4 +4989,4 @@ function distributePositionals(def, values) {
4947
4989
  return positionals;
4948
4990
  }
4949
4991
  //#endregion
4950
- export { credentialWorkspaceMismatchError as C, noSessionForWorkspaceError as E, credentialRejectedError as S, emptyServiceTokenError as T, readActiveAccessToken as _, loadConfig as a, credentialWorkspaceId as b, WORKSPACE_ID_ENV_VAR as c, userConfigPath as d, writeUserConfig as f, positional as g, flag as h, definePrismaConfig as i, PRESENTED as l, exitWithChildStatus as m, CONFIG_FILE_NAME as n, PRISMA_CONFIG_VERSION as o, resolveGating as p, defineConfig as r, SERVICE_TOKEN_ENV_VAR as s, buildEngine as t, readUserConfig as u, claimedExpiresAt as v, credentialsRequiredError as w, authServiceError as x, claimedIdentity as y };
4992
+ export { credentialRejectedError as C, noSessionForWorkspaceError as D, emptyServiceTokenError as E, authServiceError as S, credentialsRequiredError as T, positional as _, loadConfig as a, claimedIdentity as b, WORKSPACE_ID_ENV_VAR as c, userConfigPath as d, writeUserConfig as f, flag as g, detectCI as h, definePrismaConfig as i, PRESENTED as l, exitWithChildStatus as m, CONFIG_FILE_NAME as n, PRISMA_CONFIG_VERSION as o, resolveGating as p, defineConfig as r, SERVICE_TOKEN_ENV_VAR as s, buildEngine as t, readUserConfig as u, readActiveAccessToken as v, credentialWorkspaceMismatchError as w, credentialWorkspaceId as x, claimedExpiresAt as y };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,20 @@
1
- import { $ as Outcome, A as InputStream, At as SERVICE_TOKEN_ENV_VAR, B as ExitWithChildStatusOptions, C as BrowserWaitRequest, Ct as positional, D as PromptSurface, Dt as CredentialIdentity, E as OpenUrlRequest, Et as Credential, F as TelemetryPayload, Ft as ManagementApiClient, G as exitWithChildStatus, H as SpawnOptions, I as EngineCommandSnapshot, It as ManagementApiClientConfig, J as PackageManagerRunResult, K as PackageManagerId, L as RunSummary, Lt as TokenStorage, M as OutputStream, Mt as StoredSessions, N as PRISMA_CONFIG_VERSION, Nt as CredentialRefreshResult, O as Host, Ot as CredentialManager, P as Runtime, Pt as CredentialRefresher, Q as Format, R as ChildResult, S as defineSessionCommand, St as flag, T as OpenUrlOutcome, Tt as ActiveCredential, U as SpawnRequest, V as SpawnChild, W as SpawnedChild, X as PackageOperations, Y as PackageManagerRunner, Z as Block, _ as ServerCommandDefinition, _t as ArgsSpec, a as RedirectSpec, at as Text, b as defineCommand, bt as FlagSpec, c as CommandDefinition, ct as Ui, d as CommandNeeds, dt as StreamEvent, et as PRESENTED, f as CompletedEnvelope, ft as StreamMeta, g as NeedsSpec, gt as Args, h as HelpSpec, ht as defineConfigSection, i as MountedTree, it as Status, j as LoadedConfig, jt as Session, k as HostProcess, kt as CredentialOrigin, l as CommandHandler, lt as EngineEvent, m as Handler, mt as SectionValidation, n as CommandFamily, nt as PresentedResult, o as defineCommandFamily, ot as Tone, p as ErroredEnvelope, pt as ConfigSection, q as PackageManagerRunRequest, r as CommandRedirect, rt as Span, s as AnyCommand, st as TreeNode, t as TelemetryDeclaration, tt as Presentations, u as CommandHelp, ut as Severity, v as SessionCommandDefinition, vt as Char, w as CommandContext, wt as ActiveAccessTokenOptions, x as defineServerCommand, xt as PositionalSpec, y as SpawnDeclarations, yt as CommandArgs, z as ChildStatusSettlement } from "./report-BpE5F1IH.js";
1
+ import { $ as Runtime, A as Outcome, At as SERVICE_TOKEN_ENV_VAR, B as EngineEvent, C as BrowserWaitRequest, Ct as positional, D as PromptSurface, Dt as CredentialIdentity, E as OpenUrlRequest, Et as Credential, F as Status, Ft as ManagementApiClient, G as SectionValidation, H as StreamEvent, I as Text, It as ManagementApiClientConfig, J as HostProcess, K as defineConfigSection, L as Tone, Lt as TokenStorage, M as Presentations, Mt as StoredSessions, N as PresentedResult, Nt as CredentialRefreshResult, O as Block, Ot as CredentialManager, P as Span, Pt as CredentialRefresher, Q as PRISMA_CONFIG_VERSION, R as TreeNode, S as defineSessionCommand, St as flag, T as OpenUrlOutcome, Tt as ActiveCredential, U as StreamMeta, V as Severity, W as ConfigSection, X as LoadedConfig, Y as InputStream, Z as OutputStream, _ as ServerCommandDefinition, _t as ArgsSpec, a as RedirectSpec, at as ExitWithChildStatusOptions, b as defineCommand, bt as FlagSpec, c as CommandDefinition, ct as SpawnRequest, d as CommandNeeds, dt as PackageManagerId, et as TelemetryPayload, f as CompletedEnvelope, ft as PackageManagerRunRequest, g as NeedsSpec, gt as Args, h as HelpSpec, ht as PackageOperations, i as MountedTree, it as ChildStatusSettlement, j as PRESENTED, jt as Session, k as Format, kt as CredentialOrigin, l as CommandHandler, lt as SpawnedChild, m as Handler, mt as PackageManagerRunner, n as CommandFamily, nt as RunSummary, o as defineCommandFamily, ot as SpawnChild, p as ErroredEnvelope, pt as PackageManagerRunResult, q as Host, r as CommandRedirect, rt as ChildResult, s as AnyCommand, st as SpawnOptions, t as TelemetryDeclaration, tt as EngineCommandSnapshot, u as CommandHelp, ut as exitWithChildStatus, v as SessionCommandDefinition, vt as Char, w as CommandContext, wt as ActiveAccessTokenOptions, x as defineServerCommand, xt as PositionalSpec, y as SpawnDeclarations, yt as CommandArgs, z as Ui } from "./report-DR2h7YIG.js";
2
2
  import { n as CliStructuredError } from "./protocol-YjqPCCOG.js";
3
3
 
4
4
  //#region src/active-access-token.d.ts
5
5
  /** Shared implementation used by every CredentialManager. */
6
6
  declare function readActiveAccessToken(storage: TokenStorage, refreshCredential: CredentialRefresher | undefined, options: ActiveAccessTokenOptions): Promise<string | null>;
7
7
  //#endregion
8
+ //#region src/ci.d.ts
9
+ type Env = Readonly<Record<string, string | undefined>>;
10
+ /**
11
+ * Whether this environment is a CI environment, by ci-info's rules
12
+ * applied to the environment the host injected rather than to
13
+ * `process.env`. `CI=false` is an explicit denial that stops every
14
+ * other check, exactly as ci-info treats it.
15
+ */
16
+ declare function detectCI(env: Env): boolean;
17
+ //#endregion
8
18
  //#region src/cli.d.ts
9
19
  /**
10
20
  * The observation hooks a bin may attach to a run. Deliberately
@@ -74,9 +84,13 @@ declare function definePrismaConfig<T extends Record<string, unknown>>(config: T
74
84
  declare const defineConfig: typeof definePrismaConfig;
75
85
  /**
76
86
  * The real-disk loader behind Runtime.loadConfig. The bin binds it to
77
- * the process cwd; tests hand in fixtures.
87
+ * the process cwd and its own version; tests hand in fixtures.
88
+ * `cliVersion` names the exact prisma version in the install guidance
89
+ * when the 'prisma/config' entry point cannot be resolved; absent, the
90
+ * guidance names no version rather than an example that installs the
91
+ * wrong one.
78
92
  */
79
- declare function loadConfig(cwd: string, configPath?: string): Promise<LoadedConfig>;
93
+ declare function loadConfig(cwd: string, configPath?: string, cliVersion?: string): Promise<LoadedConfig>;
80
94
  //#endregion
81
95
  //#region src/credential-errors.d.ts
82
96
  type CredentialsRequiredReason = "unauthenticated" | "expired" | "expiring-soon" | "session-ended" | "sessions-held-none-selected";
@@ -199,4 +213,4 @@ declare function claimedExpiresAt(token: string): Date | undefined;
199
213
  */
200
214
  declare function claimedIdentity(token: string): CredentialIdentity | undefined;
201
215
  //#endregion
202
- export { type ActiveAccessTokenOptions, type ActiveCredential, type AnyCommand, type Args, type ArgsSpec, type Block, type BrowserWaitRequest, type Char, type ChildResult, type ChildStatusSettlement, type Cli, type CliRunHooks, type CommandArgs, type CommandContext, type CommandDefinition, type CommandFamily, type CommandHandler, type CommandHelp, type CommandNeeds, type CommandRedirect, type CompletedEnvelope, type ConfigSection, type Credential, type CredentialIdentity, type CredentialManager, type CredentialOrigin, type CredentialRefreshResult, type CredentialRefresher, type CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, type Host, type HostProcess, type InputStream, type LoadedConfig, type ManagementApiClient, type ManagementApiClientConfig, type MountedTree, type NeedsSpec, type OpenUrlOutcome, type OpenUrlRequest, type Outcome, type OutputStream, PRESENTED, PRISMA_CONFIG_VERSION, type PackageManagerId, type PackageManagerRunRequest, type PackageManagerRunResult, type PackageManagerRunner, type PackageOperations, type PositionalSpec, type Presentations, type PresentedResult, type PromptSurface, type RedirectSpec, type RunSummary, type Runtime, SERVICE_TOKEN_ENV_VAR, type SectionValidation, type ServerCommandDefinition, type Session, type SessionCommandDefinition, type Severity, type Span, type SpawnChild, type SpawnDeclarations, type SpawnOptions, type SpawnRequest, type SpawnedChild, type Status, type StoredSessions, type StreamEvent, type StreamMeta, type TelemetryDeclaration, type TelemetryPayload, type TelemetryStatus, type TelemetryStatusReason, type Text, type TokenStorage, type Tone, type TreeNode, type Ui, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfig, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, telemetryCommandGroup };
216
+ export { type ActiveAccessTokenOptions, type ActiveCredential, type AnyCommand, type Args, type ArgsSpec, type Block, type BrowserWaitRequest, type Char, type ChildResult, type ChildStatusSettlement, type Cli, type CliRunHooks, type CommandArgs, type CommandContext, type CommandDefinition, type CommandFamily, type CommandHandler, type CommandHelp, type CommandNeeds, type CommandRedirect, type CompletedEnvelope, type ConfigSection, type Credential, type CredentialIdentity, type CredentialManager, type CredentialOrigin, type CredentialRefreshResult, type CredentialRefresher, type CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, type Host, type HostProcess, type InputStream, type LoadedConfig, type ManagementApiClient, type ManagementApiClientConfig, type MountedTree, type NeedsSpec, type OpenUrlOutcome, type OpenUrlRequest, type Outcome, type OutputStream, PRESENTED, PRISMA_CONFIG_VERSION, type PackageManagerId, type PackageManagerRunRequest, type PackageManagerRunResult, type PackageManagerRunner, type PackageOperations, type PositionalSpec, type Presentations, type PresentedResult, type PromptSurface, type RedirectSpec, type RunSummary, type Runtime, SERVICE_TOKEN_ENV_VAR, type SectionValidation, type ServerCommandDefinition, type Session, type SessionCommandDefinition, type Severity, type Span, type SpawnChild, type SpawnDeclarations, type SpawnOptions, type SpawnRequest, type SpawnedChild, type Status, type StoredSessions, type StreamEvent, type StreamMeta, type TelemetryDeclaration, type TelemetryPayload, type TelemetryStatus, type TelemetryStatusReason, type Text, type TokenStorage, type Tone, type TreeNode, type Ui, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfig, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, telemetryCommandGroup };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i as ok, r as notOk, t as CliStructuredError } from "./protocol-TtNVkeVS.js";
2
- import { C as credentialWorkspaceMismatchError, E as noSessionForWorkspaceError, S as credentialRejectedError, T as emptyServiceTokenError, _ as readActiveAccessToken, a as loadConfig, b as credentialWorkspaceId, c as WORKSPACE_ID_ENV_VAR, d as userConfigPath, f as writeUserConfig, g as positional, h as flag, i as definePrismaConfig, l as PRESENTED, m as exitWithChildStatus, o as PRISMA_CONFIG_VERSION, p as resolveGating, r as defineConfig, s as SERVICE_TOKEN_ENV_VAR, t as buildEngine, u as readUserConfig, v as claimedExpiresAt, w as credentialsRequiredError, x as authServiceError, y as claimedIdentity } from "./engine-DJYd4aGn.js";
2
+ import { C as credentialRejectedError, D as noSessionForWorkspaceError, E as emptyServiceTokenError, S as authServiceError, T as credentialsRequiredError, _ as positional, a as loadConfig, b as claimedIdentity, c as WORKSPACE_ID_ENV_VAR, d as userConfigPath, f as writeUserConfig, g as flag, h as detectCI, i as definePrismaConfig, l as PRESENTED, m as exitWithChildStatus, o as PRISMA_CONFIG_VERSION, p as resolveGating, r as defineConfig, s as SERVICE_TOKEN_ENV_VAR, t as buildEngine, u as readUserConfig, v as readActiveAccessToken, w as credentialWorkspaceMismatchError, x as credentialWorkspaceId, y as claimedExpiresAt } from "./engine-CPLGpHh5.js";
3
3
  //#region src/cli.ts
4
4
  /**
5
5
  * Shell-side construction. Group help is declared with the mount.
@@ -378,4 +378,4 @@ Telemetry is on by default (opt-out); see ${options.docsUrl}\nfor what is collec
378
378
  };
379
379
  }
380
380
  //#endregion
381
- export { EnvironmentCredentialManager, PRESENTED, PRISMA_CONFIG_VERSION, SERVICE_TOKEN_ENV_VAR, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfig, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, telemetryCommandGroup };
381
+ export { EnvironmentCredentialManager, PRESENTED, PRISMA_CONFIG_VERSION, SERVICE_TOKEN_ENV_VAR, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfig, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, telemetryCommandGroup };
@@ -304,283 +304,6 @@ interface Args<TFlags extends Record<string, FlagSpec<unknown>>, TPositionals ex
304
304
  readonly positionals: { readonly [K in keyof TPositionals]: TPositionals[K] extends PositionalSpec<infer T> ? T : never };
305
305
  }
306
306
  //#endregion
307
- //#region src/config-section.d.ts
308
- /**
309
- * A command family's named slice of prisma.config.ts. The token couples
310
- * the section name, its validated type, and its total validator. The
311
- * validator owns absence: its input is the raw section value, or
312
- * undefined when the config file has no such section. It returns
313
- * findings; it never throws.
314
- */
315
- interface ConfigSection<T> {
316
- readonly name: string;
317
- readonly validate: (raw: unknown | undefined) => SectionValidation<T>;
318
- }
319
- /**
320
- * Diagnostics on an OK validation are warnings: the engine writes them
321
- * to stderr as commentary (log-level filtered, human and json alike);
322
- * they never enter the stream or the envelope.
323
- */
324
- type SectionValidation<T> = {
325
- readonly ok: true;
326
- readonly value: T;
327
- readonly diagnostics: readonly Diagnostic[];
328
- } | {
329
- readonly ok: false;
330
- readonly diagnostics: readonly Diagnostic[];
331
- };
332
- declare function defineConfigSection<T>(spec: {
333
- readonly name: string;
334
- readonly validate: (raw: unknown | undefined) => SectionValidation<T>;
335
- }): ConfigSection<T>;
336
- //#endregion
337
- //#region src/events.d.ts
338
- /**
339
- * The commentary severity scale; also the log-level axis. Distinct from
340
- * Diagnostic severity: 'verbose' grades commentary, which never enters
341
- * the envelope.
342
- */
343
- type Severity = "error" | "warn" | "info" | "verbose";
344
- /**
345
- * The engine event envelope. `kind`-specific fields are the common
346
- * vocabulary the engine renders (human mode) and streams (json mode);
347
- * `data` is the command family's extension, passed through untouched.
348
- * Events are transcript, never aggregated into any envelope. Follow-ups
349
- * are handler-owned: completed via `presentations.next`, errored via the
350
- * error's own `nextActions`.
351
- */
352
- type EngineEvent = {
353
- readonly kind: "step-started";
354
- readonly step: string;
355
- readonly id?: string;
356
- readonly parentId?: string;
357
- readonly data?: unknown;
358
- } | {
359
- readonly kind: "step-finished";
360
- readonly step: string;
361
- readonly id?: string;
362
- readonly outcome: "ok" | "failed" | "skipped" | "warning";
363
- readonly data?: unknown;
364
- } | {
365
- readonly kind: "progress";
366
- readonly step?: string;
367
- readonly completed: number;
368
- readonly total?: number;
369
- readonly data?: unknown;
370
- }
371
- /**
372
- * Commentary at a severity; display-filtered by log level. 'error' is
373
- * not valid here: fatal problems are the Result's error;
374
- * envelope-worthy findings are diagnostics.
375
- */
376
- | {
377
- readonly kind: "message";
378
- readonly severity: Exclude<Severity, "error">;
379
- readonly text: string;
380
- readonly data?: unknown;
381
- } | {
382
- readonly kind: "output";
383
- readonly source: string;
384
- readonly channel: "data" | "diagnostic";
385
- readonly line: string;
386
- readonly data?: unknown;
387
- }
388
- /**
389
- * Transcript-only: framed in json mode, never rendered in human mode,
390
- * never aggregated into any envelope.
391
- */
392
- | {
393
- readonly kind: "remediation";
394
- readonly action: NextAction;
395
- readonly data?: unknown;
396
- } | {
397
- readonly kind: "endpoint";
398
- readonly name: string;
399
- readonly url: string;
400
- readonly data?: unknown;
401
- } | {
402
- readonly kind: "status";
403
- readonly subject: string;
404
- readonly status: string;
405
- readonly from?: string;
406
- readonly data?: unknown;
407
- } | {
408
- readonly kind: "artifact";
409
- readonly path: string;
410
- readonly description?: string;
411
- readonly data?: unknown;
412
- };
413
- /**
414
- * json mode emits one StreamEvent per line: the handler's events,
415
- * flattened with the stream metadata, then exactly one terminal
416
- * 'result' member carrying the envelope.
417
- */
418
- type StreamEvent = (EngineEvent & StreamMeta) | ({
419
- readonly kind: "result";
420
- readonly envelope: CompletedEnvelope | ErroredEnvelope;
421
- } & StreamMeta);
422
- interface StreamMeta {
423
- readonly commandId: string;
424
- /** ISO 8601 UTC. Injectable clock in tests. */
425
- readonly timestamp: string;
426
- }
427
- //#endregion
428
- //#region src/presentation.d.ts
429
- type Format = "human" | "json";
430
- /**
431
- * What a command concluded, stated at the return site. `exitCode` is
432
- * required at every return site iff the command documents exit codes,
433
- * and forbidden otherwise. `diagnostics` may be omitted at the call
434
- * site; the presented result always carries an array.
435
- */
436
- type Outcome<T, TCode extends number = never> = [TCode] extends [never] ? {
437
- readonly data: T;
438
- readonly diagnostics?: readonly Diagnostic[];
439
- } : {
440
- readonly data: T;
441
- readonly exitCode: TCode | 0;
442
- readonly diagnostics?: readonly Diagnostic[];
443
- };
444
- declare const PRESENTED: unique symbol;
445
- /**
446
- * What a completed command's handler returns inside `ok(...)`: the
447
- * outcome plus the presentation the active format already materialized.
448
- * Built exclusively by ctx.present — the brand makes hand-construction
449
- * a type error. Human rendering writes the blocks, next-action lines,
450
- * and diagnostics to stderr and the `stdout` lines to stdout — human
451
- * mode is pipe-clean (operator ruling, 2026-08-09).
452
- */
453
- interface PresentedResult<T> {
454
- readonly [PRESENTED]: true;
455
- readonly data: T;
456
- /** 0 unless the outcome selected a documented code. */
457
- readonly exitCode: number;
458
- /** Never undefined; empty when the outcome recorded no findings. */
459
- readonly diagnostics: readonly Diagnostic[];
460
- /**
461
- * Only the active format's presentation is materialized; the other
462
- * format's fields are normalized to empty. In human mode `json` is
463
- * undefined because the json presentation was never invoked.
464
- */
465
- readonly presentation: {
466
- readonly human: readonly Block[];
467
- readonly stdout: readonly string[];
468
- readonly json: unknown;
469
- readonly next: readonly NextAction[];
470
- };
471
- }
472
- /**
473
- * The per-format presentation functions a handler supplies to
474
- * ctx.present. Every one is required: a command states each output
475
- * surface it publishes rather than inheriting one by omission. Only the
476
- * active format's functions are invoked, at the return site. `human`
477
- * composes engine primitives, rendered to stderr; `stdout` is the
478
- * machine-consumable data lines — what a pipe receives, the human
479
- * mode's only stdout writes; `json` is the `--json` envelope's
480
- * `result`; `next` is the suggested follow-up actions.
481
- */
482
- interface Presentations {
483
- readonly human: (ui: Ui) => readonly Block[];
484
- readonly stdout: () => readonly string[];
485
- readonly json: () => unknown;
486
- readonly next: () => readonly NextAction[];
487
- }
488
- /**
489
- * What happened: it selects the glyph (✔ ✘ ⚠ ℹ) and carries a default
490
- * Tone of the same name. Separate from Tone because a failure can be
491
- * painted in a colour that is not `error` — a tree node in its branch
492
- * lane's hue, say — and a colour can be chosen where nothing happened.
493
- */
494
- type Status = "ok" | "error" | "warn" | "info";
495
- /**
496
- * What colour to paint, and nothing else. Semantic names and indexed
497
- * colours in one union: a command asks for meaning where it has one and
498
- * for a distinguishable colour where it does not. The indexed colours
499
- * are for telling adjacent things apart — one per branch lane in a
500
- * graph, say — and deliberately exclude red so no series member reads
501
- * as an error.
502
- */
503
- type Tone = "ok" | "warn" | "error" | "info" | "heading" | "identifier" | "ref" | "placeholder" | "link" | "emphasis" | "muted" | "structure" | "highlight" | "color-1" | "color-2" | "color-3" | "color-4" | "color-5" | "color-6";
504
- /**
505
- * A run of text and the meaning of its colour. A handler never emits
506
- * escape sequences: the engine measures width from `text`, so colour
507
- * cannot break alignment, and the same spans can be re-themed or
508
- * stripped without re-rendering.
509
- */
510
- interface Span {
511
- readonly text: string;
512
- readonly tone?: Tone;
513
- }
514
- /** Display text anywhere a block or Ui takes it. A bare string is untoned. */
515
- type Text = string | readonly Span[];
516
- /**
517
- * Deliberately small; grows by the same evidence rule as events.
518
- * Recorded findings are NOT a Block — they are the outcome's
519
- * diagnostics; the engine renders them and carries them into the
520
- * envelope, so the two surfaces cannot diverge.
521
- */
522
- type Block = {
523
- readonly kind: "summary";
524
- readonly status: Status; /** Overrides the colour the status implies. Never the glyph. */
525
- readonly tone?: Tone;
526
- readonly text: Text;
527
- } | {
528
- /** A key/value card: the engine pads the keys so every value
529
- * starts in the same column. */
530
- readonly kind: "fields";
531
- readonly rows: ReadonlyArray<{
532
- readonly label: Text;
533
- readonly value: Text;
534
- readonly sensitive?: boolean;
535
- }>;
536
- /** Draws the dim `│` rail down the left of the card. A command
537
- * knows whether it is drawing a header card or a plain one, so
538
- * this is per block rather than a global setting. */
539
- readonly rail?: boolean;
540
- } | {
541
- /** The engine sizes every column to its widest cell. */readonly kind: "table";
542
- readonly columns: readonly Text[];
543
- readonly rows: ReadonlyArray<readonly Text[]>;
544
- } | {
545
- readonly kind: "list";
546
- readonly items: readonly Text[];
547
- } | {
548
- readonly kind: "tree";
549
- readonly roots: readonly TreeNode[];
550
- } | {
551
- /**
552
- * Lines of spans, rendered verbatim — no layout, no reflow, no
553
- * truncation. For output whose two-dimensional structure the
554
- * engine cannot derive, such as a migration graph's lane gutter,
555
- * where the same hue has to reach the gutter cell, the node glyph
556
- * and the label alike.
557
- */
558
- readonly kind: "drawing";
559
- readonly lines: readonly Text[];
560
- };
561
- interface TreeNode {
562
- readonly label: Text;
563
- /** Renders its glyph before the label. */
564
- readonly status?: Status;
565
- /** Colours the glyph and the label; defaults to the status. */
566
- readonly tone?: Tone;
567
- readonly children?: readonly TreeNode[];
568
- }
569
- /** Styling helpers usable inside block text; no direct writing. */
570
- interface Ui {
571
- /**
572
- * How much room the command has: stderr's terminal width, or
573
- * Number.POSITIVE_INFINITY when stderr is not a terminal. Only the
574
- * command knows what to sacrifice, so the engine hands over the number
575
- * and prints an overrun unmodified.
576
- */
577
- readonly width: number;
578
- readonly emphasize: (text: string) => string;
579
- readonly dim: (text: string) => string;
580
- readonly code: (text: string) => string;
581
- readonly tone: (tone: Tone, text: string) => string;
582
- }
583
- //#endregion
584
307
  //#region src/package-manager.d.ts
585
308
  /** The package managers the engine knows how to drive. */
586
309
  type PackageManagerId = "npm" | "pnpm" | "yarn" | "bun" | "deno";
@@ -903,115 +626,392 @@ interface Runtime {
903
626
  */
904
627
  readonly spawn?: SpawnChild;
905
628
  /**
906
- * Fire-and-forget delivery of one composed telemetry payload. The bin
907
- * owns the process work and the detachment, which is why the engine
908
- * imports no child_process and performs no network I/O for telemetry.
909
- * Absent means this host reports nothing — not an error, and the whole
910
- * sequence is skipped rather than only the delivery: no config read,
911
- * no disclosure, no mint.
629
+ * Fire-and-forget delivery of one composed telemetry payload. The bin
630
+ * owns the process work and the detachment, which is why the engine
631
+ * imports no child_process and performs no network I/O for telemetry.
632
+ * Absent means this host reports nothing — not an error, and the whole
633
+ * sequence is skipped rather than only the delivery: no config read,
634
+ * no disclosure, no mint.
635
+ */
636
+ readonly spawnTelemetry?: (payload: TelemetryPayload) => void;
637
+ /** Management API endpoint config; the bin derives baseUrl from env. */
638
+ readonly managementApi: {
639
+ readonly baseUrl: string;
640
+ };
641
+ /**
642
+ * A host that knows its user's package manager better than detection
643
+ * does. Absent — the normal case — means the engine detects it from
644
+ * the project at cwd.
645
+ */
646
+ readonly packageManager?: PackageManagerId;
647
+ /**
648
+ * Spawns the package manager the engine composed. The engine never
649
+ * imports child_process; this is the only way a manager runs. It is
650
+ * optional so a harness can exercise the no-runner path — every
651
+ * shipped host wires it, and a host without it can run no package
652
+ * operation at all.
653
+ */
654
+ readonly runPackageManager?: PackageManagerRunner;
655
+ /** What this process is running on. The bin reads it once; commands
656
+ * take it from ctx.host rather than from process. */
657
+ readonly host: Host;
658
+ }
659
+ /**
660
+ * The facts a command may legitimately need about the machine it runs
661
+ * on: what to put in a bug report, and the rare genuine behavioural
662
+ * difference (symlinks need a privilege on Windows).
663
+ *
664
+ * Deliberately not node-shaped. Products are runtime-agnostic (R4), so
665
+ * the runtime names itself rather than the field naming it.
666
+ */
667
+ interface Host {
668
+ readonly runtime: {
669
+ readonly name: string;
670
+ readonly version: string;
671
+ };
672
+ readonly platform: string;
673
+ readonly arch: string;
674
+ }
675
+ /**
676
+ * The minimal process surface a bin adapts a Runtime from — Node's
677
+ * `process` satisfies it structurally. The engine never reads it; it
678
+ * exists so bins and their tests share one adapter shape.
679
+ */
680
+ interface HostProcess {
681
+ readonly argv: readonly string[];
682
+ readonly env: Readonly<Record<string, string | undefined>>;
683
+ readonly version: string;
684
+ readonly versions: Readonly<Record<string, string | undefined>>;
685
+ readonly platform: string;
686
+ readonly arch: string;
687
+ cwd(): string;
688
+ readonly stdout: {
689
+ write(text: string): unknown;
690
+ isTTY?: boolean;
691
+ };
692
+ readonly stderr: {
693
+ write(text: string): unknown;
694
+ isTTY?: boolean;
695
+ columns?: number;
696
+ };
697
+ readonly stdin: {
698
+ isTTY?: boolean;
699
+ setRawMode?(enabled: boolean): unknown;
700
+ [Symbol.asyncIterator](): AsyncIterator<Uint8Array>;
701
+ };
702
+ on(event: "SIGINT" | "SIGTERM", listener: () => void): unknown;
703
+ off(event: "SIGINT" | "SIGTERM", listener: () => void): unknown;
704
+ exit(code: number): never;
705
+ }
706
+ interface LoadedConfig {
707
+ /**
708
+ * The file this config came from, absolute: the one `--config` named,
709
+ * or prisma.config.ts in cwd. A loader that found no file still names
710
+ * the file it looked for — with no file there are no sections, and
711
+ * the engine reads the path only to name the file when it reports a
712
+ * top-level key that is not one of the CLI's sections.
713
+ */
714
+ readonly path: string;
715
+ /**
716
+ * Raw section values by name; validation happens per command via its
717
+ * command family's section token. The engine, not the loader, checks
718
+ * these names against the sections the CLI declares, so the closed
719
+ * set holds whatever loader a host wires.
720
+ */
721
+ readonly sections: Readonly<Record<string, unknown>>;
722
+ /**
723
+ * File-level problems (unevaluable module, missing version marker)
724
+ * carry section: null and fail only commands with a needs.config
725
+ * section; commands with no config need run normally.
726
+ */
727
+ readonly diagnostics: ReadonlyArray<{
728
+ readonly section: string | null;
729
+ readonly diagnostic: Diagnostic;
730
+ }>;
731
+ }
732
+ /**
733
+ * The config contract version defineConfig writes as the structural
734
+ * `$prismaConfig` marker; the loader checks it before interpreting
735
+ * anything.
736
+ */
737
+ declare const PRISMA_CONFIG_VERSION = 1;
738
+ //#endregion
739
+ //#region src/config-section.d.ts
740
+ /**
741
+ * A command family's named slice of prisma.config.ts. The token couples
742
+ * the section name, its validated type, and its total validator. The
743
+ * validator owns absence: its input is the raw section value, or
744
+ * undefined when the config file has no such section. It returns
745
+ * findings; it never throws.
746
+ */
747
+ interface ConfigSection<T> {
748
+ readonly name: string;
749
+ readonly validate: (raw: unknown | undefined) => SectionValidation<T>;
750
+ }
751
+ /**
752
+ * Diagnostics on an OK validation are warnings: the engine writes them
753
+ * to stderr as commentary (log-level filtered, human and json alike);
754
+ * they never enter the stream or the envelope.
755
+ */
756
+ type SectionValidation<T> = {
757
+ readonly ok: true;
758
+ readonly value: T;
759
+ readonly diagnostics: readonly Diagnostic[];
760
+ } | {
761
+ readonly ok: false;
762
+ readonly diagnostics: readonly Diagnostic[];
763
+ };
764
+ declare function defineConfigSection<T>(spec: {
765
+ readonly name: string;
766
+ readonly validate: (raw: unknown | undefined) => SectionValidation<T>;
767
+ }): ConfigSection<T>;
768
+ //#endregion
769
+ //#region src/events.d.ts
770
+ /**
771
+ * The commentary severity scale; also the log-level axis. Distinct from
772
+ * Diagnostic severity: 'verbose' grades commentary, which never enters
773
+ * the envelope.
774
+ */
775
+ type Severity = "error" | "warn" | "info" | "verbose";
776
+ /**
777
+ * The engine event envelope. `kind`-specific fields are the common
778
+ * vocabulary the engine renders (human mode) and streams (json mode);
779
+ * `data` is the command family's extension, passed through untouched.
780
+ * Events are transcript, never aggregated into any envelope. Follow-ups
781
+ * are handler-owned: completed via `presentations.next`, errored via the
782
+ * error's own `nextActions`.
783
+ */
784
+ type EngineEvent = {
785
+ readonly kind: "step-started";
786
+ readonly step: string;
787
+ readonly id?: string;
788
+ readonly parentId?: string;
789
+ readonly data?: unknown;
790
+ } | {
791
+ readonly kind: "step-finished";
792
+ readonly step: string;
793
+ readonly id?: string;
794
+ readonly outcome: "ok" | "failed" | "skipped" | "warning";
795
+ readonly data?: unknown;
796
+ } | {
797
+ readonly kind: "progress";
798
+ readonly step?: string;
799
+ readonly completed: number;
800
+ readonly total?: number;
801
+ readonly data?: unknown;
802
+ }
803
+ /**
804
+ * Commentary at a severity; display-filtered by log level. 'error' is
805
+ * not valid here: fatal problems are the Result's error;
806
+ * envelope-worthy findings are diagnostics.
807
+ */
808
+ | {
809
+ readonly kind: "message";
810
+ readonly severity: Exclude<Severity, "error">;
811
+ readonly text: string;
812
+ readonly data?: unknown;
813
+ } | {
814
+ readonly kind: "output";
815
+ readonly source: string;
816
+ readonly channel: "data" | "diagnostic";
817
+ readonly line: string;
818
+ readonly data?: unknown;
819
+ }
820
+ /**
821
+ * Transcript-only: framed in json mode, never rendered in human mode,
822
+ * never aggregated into any envelope.
823
+ */
824
+ | {
825
+ readonly kind: "remediation";
826
+ readonly action: NextAction;
827
+ readonly data?: unknown;
828
+ } | {
829
+ readonly kind: "endpoint";
830
+ readonly name: string;
831
+ readonly url: string;
832
+ readonly data?: unknown;
833
+ } | {
834
+ readonly kind: "status";
835
+ readonly subject: string;
836
+ readonly status: string;
837
+ readonly from?: string;
838
+ readonly data?: unknown;
839
+ } | {
840
+ readonly kind: "artifact";
841
+ readonly path: string;
842
+ readonly description?: string;
843
+ readonly data?: unknown;
844
+ };
845
+ /**
846
+ * json mode emits one StreamEvent per line: the handler's events,
847
+ * flattened with the stream metadata, then exactly one terminal
848
+ * 'result' member carrying the envelope.
849
+ */
850
+ type StreamEvent = (EngineEvent & StreamMeta) | ({
851
+ readonly kind: "result";
852
+ readonly envelope: CompletedEnvelope | ErroredEnvelope;
853
+ } & StreamMeta);
854
+ interface StreamMeta {
855
+ readonly commandId: string;
856
+ /** ISO 8601 UTC. Injectable clock in tests. */
857
+ readonly timestamp: string;
858
+ }
859
+ //#endregion
860
+ //#region src/presentation.d.ts
861
+ type Format = "human" | "json";
862
+ /**
863
+ * What a command concluded, stated at the return site. `exitCode` is
864
+ * required at every return site iff the command documents exit codes,
865
+ * and forbidden otherwise. `diagnostics` may be omitted at the call
866
+ * site; the presented result always carries an array.
867
+ */
868
+ type Outcome<T, TCode extends number = never> = [TCode] extends [never] ? {
869
+ readonly data: T;
870
+ readonly diagnostics?: readonly Diagnostic[];
871
+ } : {
872
+ readonly data: T;
873
+ readonly exitCode: TCode | 0;
874
+ readonly diagnostics?: readonly Diagnostic[];
875
+ };
876
+ declare const PRESENTED: unique symbol;
877
+ /**
878
+ * What a completed command's handler returns inside `ok(...)`: the
879
+ * outcome plus the presentation the active format already materialized.
880
+ * Built exclusively by ctx.present — the brand makes hand-construction
881
+ * a type error. Human rendering writes the blocks, next-action lines,
882
+ * and diagnostics to stderr and the `stdout` lines to stdout — human
883
+ * mode is pipe-clean (operator ruling, 2026-08-09).
884
+ */
885
+ interface PresentedResult<T> {
886
+ readonly [PRESENTED]: true;
887
+ readonly data: T;
888
+ /** 0 unless the outcome selected a documented code. */
889
+ readonly exitCode: number;
890
+ /** Never undefined; empty when the outcome recorded no findings. */
891
+ readonly diagnostics: readonly Diagnostic[];
892
+ /**
893
+ * Only the active format's presentation is materialized; the other
894
+ * format's fields are normalized to empty. In human mode `json` is
895
+ * undefined because the json presentation was never invoked.
912
896
  */
913
- readonly spawnTelemetry?: (payload: TelemetryPayload) => void;
914
- /** Management API endpoint config; the bin derives baseUrl from env. */
915
- readonly managementApi: {
916
- readonly baseUrl: string;
897
+ readonly presentation: {
898
+ readonly human: readonly Block[];
899
+ readonly stdout: readonly string[];
900
+ readonly json: unknown;
901
+ readonly next: readonly NextAction[];
917
902
  };
918
- /**
919
- * A host that knows its user's package manager better than detection
920
- * does. Absent — the normal case — means the engine detects it from
921
- * the project at cwd.
922
- */
923
- readonly packageManager?: PackageManagerId;
924
- /**
925
- * Spawns the package manager the engine composed. The engine never
926
- * imports child_process; this is the only way a manager runs. It is
927
- * optional so a harness can exercise the no-runner path — every
928
- * shipped host wires it, and a host without it can run no package
929
- * operation at all.
930
- */
931
- readonly runPackageManager?: PackageManagerRunner;
932
- /** What this process is running on. The bin reads it once; commands
933
- * take it from ctx.host rather than from process. */
934
- readonly host: Host;
935
903
  }
936
904
  /**
937
- * The facts a command may legitimately need about the machine it runs
938
- * on: what to put in a bug report, and the rare genuine behavioural
939
- * difference (symlinks need a privilege on Windows).
940
- *
941
- * Deliberately not node-shaped. Products are runtime-agnostic (R4), so
942
- * the runtime names itself rather than the field naming it.
905
+ * The per-format presentation functions a handler supplies to
906
+ * ctx.present. Every one is required: a command states each output
907
+ * surface it publishes rather than inheriting one by omission. Only the
908
+ * active format's functions are invoked, at the return site. `human`
909
+ * composes engine primitives, rendered to stderr; `stdout` is the
910
+ * machine-consumable data lines — what a pipe receives, the human
911
+ * mode's only stdout writes; `json` is the `--json` envelope's
912
+ * `result`; `next` is the suggested follow-up actions.
943
913
  */
944
- interface Host {
945
- readonly runtime: {
946
- readonly name: string;
947
- readonly version: string;
948
- };
949
- readonly platform: string;
950
- readonly arch: string;
914
+ interface Presentations {
915
+ readonly human: (ui: Ui) => readonly Block[];
916
+ readonly stdout: () => readonly string[];
917
+ readonly json: () => unknown;
918
+ readonly next: () => readonly NextAction[];
951
919
  }
952
920
  /**
953
- * The minimal process surface a bin adapts a Runtime from — Node's
954
- * `process` satisfies it structurally. The engine never reads it; it
955
- * exists so bins and their tests share one adapter shape.
921
+ * What happened: it selects the glyph (✔ ✘ ⚠ ℹ) and carries a default
922
+ * Tone of the same name. Separate from Tone because a failure can be
923
+ * painted in a colour that is not `error` — a tree node in its branch
924
+ * lane's hue, say — and a colour can be chosen where nothing happened.
956
925
  */
957
- interface HostProcess {
958
- readonly argv: readonly string[];
959
- readonly env: Readonly<Record<string, string | undefined>>;
960
- readonly version: string;
961
- readonly versions: Readonly<Record<string, string | undefined>>;
962
- readonly platform: string;
963
- readonly arch: string;
964
- cwd(): string;
965
- readonly stdout: {
966
- write(text: string): unknown;
967
- isTTY?: boolean;
968
- };
969
- readonly stderr: {
970
- write(text: string): unknown;
971
- isTTY?: boolean;
972
- columns?: number;
973
- };
974
- readonly stdin: {
975
- isTTY?: boolean;
976
- setRawMode?(enabled: boolean): unknown;
977
- [Symbol.asyncIterator](): AsyncIterator<Uint8Array>;
978
- };
979
- on(event: "SIGINT" | "SIGTERM", listener: () => void): unknown;
980
- off(event: "SIGINT" | "SIGTERM", listener: () => void): unknown;
981
- exit(code: number): never;
926
+ type Status = "ok" | "error" | "warn" | "info";
927
+ /**
928
+ * What colour to paint, and nothing else. Semantic names and indexed
929
+ * colours in one union: a command asks for meaning where it has one and
930
+ * for a distinguishable colour where it does not. The indexed colours
931
+ * are for telling adjacent things apart — one per branch lane in a
932
+ * graph, say — and deliberately exclude red so no series member reads
933
+ * as an error.
934
+ */
935
+ type Tone = "ok" | "warn" | "error" | "info" | "heading" | "identifier" | "ref" | "placeholder" | "link" | "emphasis" | "muted" | "structure" | "highlight" | "color-1" | "color-2" | "color-3" | "color-4" | "color-5" | "color-6";
936
+ /**
937
+ * A run of text and the meaning of its colour. A handler never emits
938
+ * escape sequences: the engine measures width from `text`, so colour
939
+ * cannot break alignment, and the same spans can be re-themed or
940
+ * stripped without re-rendering.
941
+ */
942
+ interface Span {
943
+ readonly text: string;
944
+ readonly tone?: Tone;
982
945
  }
983
- interface LoadedConfig {
984
- /**
985
- * The file this config came from, absolute: the one `--config` named,
986
- * or prisma.config.ts in cwd. A loader that found no file still names
987
- * the file it looked for — with no file there are no sections, and
988
- * the engine reads the path only to name the file when it reports a
989
- * top-level key that is not one of the CLI's sections.
990
- */
991
- readonly path: string;
946
+ /** Display text anywhere a block or Ui takes it. A bare string is untoned. */
947
+ type Text = string | readonly Span[];
948
+ /**
949
+ * Deliberately small; grows by the same evidence rule as events.
950
+ * Recorded findings are NOT a Block — they are the outcome's
951
+ * diagnostics; the engine renders them and carries them into the
952
+ * envelope, so the two surfaces cannot diverge.
953
+ */
954
+ type Block = {
955
+ readonly kind: "summary";
956
+ readonly status: Status; /** Overrides the colour the status implies. Never the glyph. */
957
+ readonly tone?: Tone;
958
+ readonly text: Text;
959
+ } | {
960
+ /** A key/value card: the engine pads the keys so every value
961
+ * starts in the same column. */
962
+ readonly kind: "fields";
963
+ readonly rows: ReadonlyArray<{
964
+ readonly label: Text;
965
+ readonly value: Text;
966
+ readonly sensitive?: boolean;
967
+ }>;
968
+ /** Draws the dim `│` rail down the left of the card. A command
969
+ * knows whether it is drawing a header card or a plain one, so
970
+ * this is per block rather than a global setting. */
971
+ readonly rail?: boolean;
972
+ } | {
973
+ /** The engine sizes every column to its widest cell. */readonly kind: "table";
974
+ readonly columns: readonly Text[];
975
+ readonly rows: ReadonlyArray<readonly Text[]>;
976
+ } | {
977
+ readonly kind: "list";
978
+ readonly items: readonly Text[];
979
+ } | {
980
+ readonly kind: "tree";
981
+ readonly roots: readonly TreeNode[];
982
+ } | {
992
983
  /**
993
- * Raw section values by name; validation happens per command via its
994
- * command family's section token. The engine, not the loader, checks
995
- * these names against the sections the CLI declares, so the closed
996
- * set holds whatever loader a host wires.
984
+ * Lines of spans, rendered verbatim — no layout, no reflow, no
985
+ * truncation. For output whose two-dimensional structure the
986
+ * engine cannot derive, such as a migration graph's lane gutter,
987
+ * where the same hue has to reach the gutter cell, the node glyph
988
+ * and the label alike.
997
989
  */
998
- readonly sections: Readonly<Record<string, unknown>>;
990
+ readonly kind: "drawing";
991
+ readonly lines: readonly Text[];
992
+ };
993
+ interface TreeNode {
994
+ readonly label: Text;
995
+ /** Renders its glyph before the label. */
996
+ readonly status?: Status;
997
+ /** Colours the glyph and the label; defaults to the status. */
998
+ readonly tone?: Tone;
999
+ readonly children?: readonly TreeNode[];
1000
+ }
1001
+ /** Styling helpers usable inside block text; no direct writing. */
1002
+ interface Ui {
999
1003
  /**
1000
- * File-level problems (unevaluable module, missing version marker)
1001
- * carry section: null and fail only commands with a needs.config
1002
- * section; commands with no config need run normally.
1004
+ * How much room the command has: stderr's terminal width, or
1005
+ * Number.POSITIVE_INFINITY when stderr is not a terminal. Only the
1006
+ * command knows what to sacrifice, so the engine hands over the number
1007
+ * and prints an overrun unmodified.
1003
1008
  */
1004
- readonly diagnostics: ReadonlyArray<{
1005
- readonly section: string | null;
1006
- readonly diagnostic: Diagnostic;
1007
- }>;
1009
+ readonly width: number;
1010
+ readonly emphasize: (text: string) => string;
1011
+ readonly dim: (text: string) => string;
1012
+ readonly code: (text: string) => string;
1013
+ readonly tone: (tone: Tone, text: string) => string;
1008
1014
  }
1009
- /**
1010
- * The config contract version defineConfig writes as the structural
1011
- * `$prismaConfig` marker; the loader checks it before interpreting
1012
- * anything.
1013
- */
1014
- declare const PRISMA_CONFIG_VERSION = 1;
1015
1015
  //#endregion
1016
1016
  //#region src/context.d.ts
1017
1017
  /** The handler context — the whole world arrives as one argument. */
@@ -1544,4 +1544,4 @@ interface TelemetryDeclaration {
1544
1544
  readonly docsUrl: string;
1545
1545
  }
1546
1546
  //#endregion
1547
- export { Outcome as $, InputStream as A, SERVICE_TOKEN_ENV_VAR as At, ExitWithChildStatusOptions as B, BrowserWaitRequest as C, positional as Ct, PromptSurface as D, CredentialIdentity as Dt, OpenUrlRequest as E, Credential as Et, TelemetryPayload as F, ManagementApiClient$1 as Ft, exitWithChildStatus as G, SpawnOptions as H, EngineCommandSnapshot as I, ManagementApiClientConfig as It, PackageManagerRunResult as J, PackageManagerId as K, RunSummary as L, TokenStorage$1 as Lt, OutputStream as M, StoredSessions as Mt, PRISMA_CONFIG_VERSION as N, CredentialRefreshResult as Nt, Host as O, CredentialManager as Ot, Runtime as P, CredentialRefresher as Pt, Format as Q, ChildResult as R, defineSessionCommand as S, flag as St, OpenUrlOutcome as T, ActiveCredential as Tt, SpawnRequest as U, SpawnChild as V, SpawnedChild as W, PackageOperations as X, PackageManagerRunner as Y, Block as Z, ServerCommandDefinition as _, ArgsSpec as _t, RedirectSpec as a, Text as at, defineCommand as b, FlagSpec as bt, CommandDefinition as c, Ui as ct, CommandNeeds as d, StreamEvent as dt, PRESENTED as et, CompletedEnvelope as f, StreamMeta as ft, NeedsSpec as g, Args as gt, HelpSpec as h, defineConfigSection as ht, MountedTree as i, Status as it, LoadedConfig as j, Session as jt, HostProcess as k, CredentialOrigin as kt, CommandHandler as l, EngineEvent as lt, Handler as m, SectionValidation as mt, CommandFamily as n, PresentedResult as nt, defineCommandFamily as o, Tone as ot, ErroredEnvelope as p, ConfigSection as pt, PackageManagerRunRequest as q, CommandRedirect as r, Span as rt, AnyCommand as s, TreeNode as st, TelemetryDeclaration as t, Presentations as tt, CommandHelp as u, Severity as ut, SessionCommandDefinition as v, Char as vt, CommandContext as w, ActiveAccessTokenOptions as wt, defineServerCommand as x, PositionalSpec as xt, SpawnDeclarations as y, CommandArgs as yt, ChildStatusSettlement as z };
1547
+ export { Runtime as $, Outcome as A, SERVICE_TOKEN_ENV_VAR as At, EngineEvent as B, BrowserWaitRequest as C, positional as Ct, PromptSurface as D, CredentialIdentity as Dt, OpenUrlRequest as E, Credential as Et, Status as F, ManagementApiClient$1 as Ft, SectionValidation as G, StreamEvent as H, Text as I, ManagementApiClientConfig as It, HostProcess as J, defineConfigSection as K, Tone as L, TokenStorage$1 as Lt, Presentations as M, StoredSessions as Mt, PresentedResult as N, CredentialRefreshResult as Nt, Block as O, CredentialManager as Ot, Span as P, CredentialRefresher as Pt, PRISMA_CONFIG_VERSION as Q, TreeNode as R, defineSessionCommand as S, flag as St, OpenUrlOutcome as T, ActiveCredential as Tt, StreamMeta as U, Severity as V, ConfigSection as W, LoadedConfig as X, InputStream as Y, OutputStream as Z, ServerCommandDefinition as _, ArgsSpec as _t, RedirectSpec as a, ExitWithChildStatusOptions as at, defineCommand as b, FlagSpec as bt, CommandDefinition as c, SpawnRequest as ct, CommandNeeds as d, PackageManagerId as dt, TelemetryPayload as et, CompletedEnvelope as f, PackageManagerRunRequest as ft, NeedsSpec as g, Args as gt, HelpSpec as h, PackageOperations as ht, MountedTree as i, ChildStatusSettlement as it, PRESENTED as j, Session as jt, Format as k, CredentialOrigin as kt, CommandHandler as l, SpawnedChild as lt, Handler as m, PackageManagerRunner as mt, CommandFamily as n, RunSummary as nt, defineCommandFamily as o, SpawnChild as ot, ErroredEnvelope as p, PackageManagerRunResult as pt, Host as q, CommandRedirect as r, ChildResult as rt, AnyCommand as s, SpawnOptions as st, TelemetryDeclaration as t, EngineCommandSnapshot as tt, CommandHelp as u, exitWithChildStatus as ut, SessionCommandDefinition as v, Char as vt, CommandContext as w, ActiveAccessTokenOptions as wt, defineServerCommand as x, PositionalSpec as xt, SpawnDeclarations as y, CommandArgs as yt, Ui as z };
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Et as Credential, F as TelemetryPayload, Ft as ManagementApiClient, It as ManagementApiClientConfig, K as PackageManagerId, L as RunSummary, Lt as TokenStorage, Mt as StoredSessions, O as Host, Ot as CredentialManager, P as Runtime, Pt as CredentialRefresher, R as ChildResult, Tt as ActiveCredential, U as SpawnRequest, V as SpawnChild, Y as PackageManagerRunner, dt as StreamEvent, i as MountedTree, jt as Session, lt as EngineEvent, n as CommandFamily, nt as PresentedResult, t as TelemetryDeclaration, wt as ActiveAccessTokenOptions } from "./report-BpE5F1IH.js";
1
+ import { $ as Runtime, B as EngineEvent, Et as Credential, Ft as ManagementApiClient, H as StreamEvent, It as ManagementApiClientConfig, Lt as TokenStorage, Mt as StoredSessions, N as PresentedResult, Ot as CredentialManager, Pt as CredentialRefresher, Tt as ActiveCredential, ct as SpawnRequest, dt as PackageManagerId, et as TelemetryPayload, i as MountedTree, jt as Session, mt as PackageManagerRunner, n as CommandFamily, nt as RunSummary, ot as SpawnChild, q as Host, rt as ChildResult, t as TelemetryDeclaration, wt as ActiveAccessTokenOptions } from "./report-DR2h7YIG.js";
2
2
 
3
3
  //#region src/in-memory-credential-manager.d.ts
4
4
  /** A stored session with its credential material — what the manager
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as credentialWorkspaceMismatchError, E as noSessionForWorkspaceError, _ as readActiveAccessToken, b as credentialWorkspaceId, t as buildEngine, v as claimedExpiresAt, w as credentialsRequiredError, y as claimedIdentity } from "./engine-DJYd4aGn.js";
1
+ import { D as noSessionForWorkspaceError, T as credentialsRequiredError, b as claimedIdentity, t as buildEngine, v as readActiveAccessToken, w as credentialWorkspaceMismatchError, x as credentialWorkspaceId, y as claimedExpiresAt } from "./engine-CPLGpHh5.js";
2
2
  import { Buffer } from "node:buffer";
3
3
  //#region src/in-memory-credential-manager.ts
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/cli-engine",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "The execution engine of the unified Prisma CLI.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -49,8 +49,8 @@
49
49
  "string-width": "^8.2.1"
50
50
  },
51
51
  "devDependencies": {
52
- "@repo/cli-conformance": "8.0.0-rc.9-dev.74",
53
- "@repo/tsconfig": "8.0.0-rc.9-dev.74",
52
+ "@repo/cli-conformance": "8.0.0-rc.9-dev.79",
53
+ "@repo/tsconfig": "8.0.0-rc.9-dev.79",
54
54
  "@types/node": "^22.19.19",
55
55
  "ci-info": "^4.3.1",
56
56
  "tsdown": "^0.21.10",