@prisma/cli-engine 0.0.5 → 0.0.6

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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as ActiveCredential, A as OpenUrlOutcome, B as exitWithChildStatus, C as InputStream, D as Runtime, E as PRISMA_CONFIG_VERSION, F as ExitWithChildStatusOptions, G as Presentations, H as Format, I as SpawnChild, J as Ui, K as PresentedResult, L as SpawnOptions, M as PromptSurface, N as ChildResult, O as BrowserWaitRequest, P as ChildStatusSettlement, Q as StreamMeta, R as SpawnRequest, S as HostProcess, T as OutputStream, U as Outcome, V as Block, W as PRESENTED, X as Severity, Y as EngineEvent, Z as StreamEvent, _ as SessionCommandDefinition, _t as FlagSpec, a as defineCommandFamily, at as Session, b as defineServerCommand, bt as positional, c as CommandHandler, ct as ManagementApiClientConfig, d as CompletedEnvelope, dt as SectionValidation, et as Credential, f as ErroredEnvelope, ft as defineConfigSection, g as ServerCommandDefinition, gt as CommandArgs, h as NeedsSpec, ht as Char, i as MountedTree, it as SERVICE_TOKEN_ENV_VAR, j as OpenUrlRequest, k as CommandContext, l as CommandHelp, lt as TokenStorage, m as HelpSpec, mt as ArgsSpec, n as RunSummary, nt as CredentialManager, o as AnyCommand, ot as StoredSessions, p as Handler, pt as Args, q as TreeNode, r as CommandFamily, rt as CredentialOrigin, s as CommandDefinition, st as ManagementApiClient, t as EngineCommandSnapshot, tt as CredentialIdentity, u as CommandNeeds, ut as ConfigSection, v as SpawnDeclarations, vt as PositionalSpec, w as LoadedConfig, x as defineSessionCommand, y as defineCommand, yt as flag, z as SpawnedChild } from "./run-summary-CLpl1gmC.js";
1
+ import { $ as StreamEvent, A as BrowserWaitRequest, B as SpawnRequest, C as defineSessionCommand, D as OutputStream, E as LoadedConfig, F as ChildResult, G as Outcome, H as exitWithChildStatus, I as ChildStatusSettlement, J as PresentedResult, K as PRESENTED, L as ExitWithChildStatusOptions, M as OpenUrlOutcome, N as OpenUrlRequest, O as PRISMA_CONFIG_VERSION, P as PromptSurface, Q as Severity, R as SpawnChild, S as defineServerCommand, St as positional, T as InputStream, U as Block, V as SpawnedChild, W as Format, X as Ui, Y as TreeNode, Z as EngineEvent, _ as NeedsSpec, _t as Char, a as MountedTree, at as CredentialOrigin, b as SpawnDeclarations, bt as PositionalSpec, c as AnyCommand, ct as StoredSessions, d as CommandHelp, dt as TokenStorage, et as StreamMeta, f as CommandNeeds, ft as ConfigSection, g as HelpSpec, gt as ArgsSpec, h as Handler, ht as Args, i as CommandRedirect, it as CredentialManager, j as CommandContext, k as Runtime, l as CommandDefinition, lt as ManagementApiClient, m as ErroredEnvelope, mt as defineConfigSection, n as RunSummary, nt as Credential, o as RedirectSpec, ot as SERVICE_TOKEN_ENV_VAR, p as CompletedEnvelope, pt as SectionValidation, q as Presentations, r as CommandFamily, rt as CredentialIdentity, s as defineCommandFamily, st as Session, t as EngineCommandSnapshot, tt as ActiveCredential, u as CommandHandler, ut as ManagementApiClientConfig, v as ServerCommandDefinition, vt as CommandArgs, w as HostProcess, x as defineCommand, xt as flag, y as SessionCommandDefinition, yt as FlagSpec, z as SpawnOptions } from "./run-summary-CNL0TNZu.js";
2
2
  import { n as CliStructuredError } from "./protocol-CpZLdxML.js";
3
3
 
4
4
  //#region src/cli.d.ts
@@ -135,4 +135,4 @@ declare function claimedExpiresAt(token: string): Date | undefined;
135
135
  */
136
136
  declare function claimedIdentity(token: string): CredentialIdentity | undefined;
137
137
  //#endregion
138
- export { 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 CompletedEnvelope, type ConfigSection, type Credential, type CredentialIdentity, type CredentialManager, type CredentialOrigin, type CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, 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 PositionalSpec, type Presentations, type PresentedResult, type PromptSurface, type RunSummary, type Runtime, SERVICE_TOKEN_ENV_VAR, type SectionValidation, type ServerCommandDefinition, type Session, type SessionCommandDefinition, type Severity, type SpawnChild, type SpawnDeclarations, type SpawnOptions, type SpawnRequest, type SpawnedChild, type StoredSessions, type StreamEvent, type StreamMeta, type TokenStorage, type TreeNode, type Ui, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfig, defineConfigSection, defineServerCommand, defineSessionCommand, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional };
138
+ export { 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 CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, 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 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 SpawnChild, type SpawnDeclarations, type SpawnOptions, type SpawnRequest, type SpawnedChild, type StoredSessions, type StreamEvent, type StreamMeta, type TokenStorage, type TreeNode, type Ui, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfig, defineConfigSection, defineServerCommand, defineSessionCommand, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as PRESENTED, b as positional, c as PRISMA_CONFIG_VERSION, d as authServiceError, f as credentialRejectedError, g as noSessionForWorkspaceError, h as emptyServiceTokenError, i as buildEngine, l as SERVICE_TOKEN_ENV_VAR, m as credentialsRequiredError, n as claimedIdentity, o as defineConfig, p as credentialWorkspaceMismatchError, r as credentialWorkspaceId, s as loadConfig, t as claimedExpiresAt, u as WORKSPACE_ID_ENV_VAR, v as exitWithChildStatus, y as flag } from "./token-claims-Bpb1vA2N.js";
1
+ import { _ as PRESENTED, b as positional, c as PRISMA_CONFIG_VERSION, d as authServiceError, f as credentialRejectedError, g as noSessionForWorkspaceError, h as emptyServiceTokenError, i as buildEngine, l as SERVICE_TOKEN_ENV_VAR, m as credentialsRequiredError, n as claimedIdentity, o as defineConfig, p as credentialWorkspaceMismatchError, r as credentialWorkspaceId, s as loadConfig, t as claimedExpiresAt, u as WORKSPACE_ID_ENV_VAR, v as exitWithChildStatus, y as flag } from "./token-claims-B6V7E0NS.js";
2
2
  import { t as CliStructuredError } from "./protocol-C1JQcGl9.js";
3
3
  //#region src/cli.ts
4
4
  /**
@@ -13,11 +13,20 @@ function createCli(spec) {
13
13
  }
14
14
  //#endregion
15
15
  //#region src/command-family.ts
16
+ function normalizeRedirect(spec) {
17
+ return Object.freeze({
18
+ from: spec.from,
19
+ flag: spec.flag,
20
+ replacement: spec.replacement,
21
+ reason: spec.reason
22
+ });
23
+ }
16
24
  function defineCommandFamily(spec) {
17
25
  return Object.freeze({
18
26
  configSection: spec.configSection,
19
27
  commands: spec.commands,
20
- docsBaseUrl: spec.docsBaseUrl
28
+ docsBaseUrl: spec.docsBaseUrl,
29
+ redirects: (spec.redirects ?? []).map(normalizeRedirect)
21
30
  });
22
31
  }
23
32
  //#endregion
@@ -1118,6 +1118,41 @@ interface ErroredEnvelope {
1118
1118
  }
1119
1119
  //#endregion
1120
1120
  //#region src/command-family.d.ts
1121
+ /**
1122
+ * A retired invocation and the invocation that replaced it. Redirects
1123
+ * are metadata, never commands: they stay out of help and out of the
1124
+ * command tree, and are consulted only when an invocation fails to
1125
+ * resolve.
1126
+ */
1127
+ interface RedirectSpec {
1128
+ /**
1129
+ * The retired invocation as the user types it: a space-separated
1130
+ * absolute path in the mounted tree, the same convention as
1131
+ * MountedTree keys.
1132
+ */
1133
+ readonly from: string;
1134
+ /**
1135
+ * When present, a retired FLAG on a live command: `from` names the
1136
+ * live command's path and this the retired flag's camelCase name
1137
+ * (rendered --kebab-case, as flag declarations are).
1138
+ */
1139
+ readonly flag?: string;
1140
+ /**
1141
+ * The replacement invocation, written the way help examples are
1142
+ * written: no binary name, `{bin}` available when the name has to sit
1143
+ * mid-string. Placeholder arguments use angle brackets (`<ref>`).
1144
+ */
1145
+ readonly replacement: string;
1146
+ /** One sentence of context, surfaced as the error's `why`. */
1147
+ readonly reason?: string;
1148
+ }
1149
+ /** The normalized redirect a command family carries. */
1150
+ interface CommandRedirect {
1151
+ readonly from: string;
1152
+ readonly flag: string | undefined;
1153
+ readonly replacement: string;
1154
+ readonly reason: string | undefined;
1155
+ }
1121
1156
  /**
1122
1157
  * The unit of contribution and ownership a package exports for CLI
1123
1158
  * purposes: its config section (declared once — a family-level fact)
@@ -1133,11 +1168,14 @@ interface CommandFamily {
1133
1168
  * diagnostic's docs link from base + code.
1134
1169
  */
1135
1170
  readonly docsBaseUrl: string | undefined;
1171
+ /** The invocations this family retired. */
1172
+ readonly redirects: readonly CommandRedirect[];
1136
1173
  }
1137
1174
  declare function defineCommandFamily(spec: {
1138
1175
  readonly configSection?: ConfigSection<unknown>;
1139
1176
  readonly commands: Readonly<Record<string, AnyCommand>>;
1140
1177
  readonly docsBaseUrl?: string;
1178
+ readonly redirects?: readonly RedirectSpec[];
1141
1179
  }): CommandFamily;
1142
1180
  /** What the shell builds: commands by PATH (space-separated, 'db migrate'). */
1143
1181
  type MountedTree = Readonly<Record<string, AnyCommand>>;
@@ -1190,4 +1228,4 @@ interface RunSummary {
1190
1228
  readonly snapshot: EngineCommandSnapshot;
1191
1229
  }
1192
1230
  //#endregion
1193
- export { ActiveCredential as $, OpenUrlOutcome as A, exitWithChildStatus as B, InputStream as C, Runtime as D, PRISMA_CONFIG_VERSION as E, ExitWithChildStatusOptions as F, Presentations as G, Format as H, SpawnChild as I, Ui as J, PresentedResult as K, SpawnOptions as L, PromptSurface as M, ChildResult as N, BrowserWaitRequest as O, ChildStatusSettlement as P, StreamMeta as Q, SpawnRequest as R, HostProcess as S, OutputStream as T, Outcome as U, Block as V, PRESENTED as W, Severity as X, EngineEvent as Y, StreamEvent as Z, SessionCommandDefinition as _, FlagSpec as _t, defineCommandFamily as a, Session as at, defineServerCommand as b, positional as bt, CommandHandler as c, ManagementApiClientConfig as ct, CompletedEnvelope as d, SectionValidation as dt, Credential as et, ErroredEnvelope as f, defineConfigSection as ft, ServerCommandDefinition as g, CommandArgs as gt, NeedsSpec as h, Char as ht, MountedTree as i, SERVICE_TOKEN_ENV_VAR as it, OpenUrlRequest as j, CommandContext as k, CommandHelp as l, TokenStorage$1 as lt, HelpSpec as m, ArgsSpec as mt, RunSummary as n, CredentialManager as nt, AnyCommand as o, StoredSessions as ot, Handler as p, Args as pt, TreeNode as q, CommandFamily as r, CredentialOrigin as rt, CommandDefinition as s, ManagementApiClient$1 as st, EngineCommandSnapshot as t, CredentialIdentity as tt, CommandNeeds as u, ConfigSection as ut, SpawnDeclarations as v, PositionalSpec as vt, LoadedConfig as w, defineSessionCommand as x, defineCommand as y, flag as yt, SpawnedChild as z };
1231
+ export { StreamEvent as $, BrowserWaitRequest as A, SpawnRequest as B, defineSessionCommand as C, OutputStream as D, LoadedConfig as E, ChildResult as F, Outcome as G, exitWithChildStatus as H, ChildStatusSettlement as I, PresentedResult as J, PRESENTED as K, ExitWithChildStatusOptions as L, OpenUrlOutcome as M, OpenUrlRequest as N, PRISMA_CONFIG_VERSION as O, PromptSurface as P, Severity as Q, SpawnChild as R, defineServerCommand as S, positional as St, InputStream as T, Block as U, SpawnedChild as V, Format as W, Ui as X, TreeNode as Y, EngineEvent as Z, NeedsSpec as _, Char as _t, MountedTree as a, CredentialOrigin as at, SpawnDeclarations as b, PositionalSpec as bt, AnyCommand as c, StoredSessions as ct, CommandHelp as d, TokenStorage$1 as dt, StreamMeta as et, CommandNeeds as f, ConfigSection as ft, HelpSpec as g, ArgsSpec as gt, Handler as h, Args as ht, CommandRedirect as i, CredentialManager as it, CommandContext as j, Runtime as k, CommandDefinition as l, ManagementApiClient$1 as lt, ErroredEnvelope as m, defineConfigSection as mt, RunSummary as n, Credential as nt, RedirectSpec as o, SERVICE_TOKEN_ENV_VAR as ot, CompletedEnvelope as p, SectionValidation as pt, Presentations as q, CommandFamily as r, CredentialIdentity as rt, defineCommandFamily as s, Session as st, EngineCommandSnapshot as t, ActiveCredential as tt, CommandHandler as u, ManagementApiClientConfig as ut, ServerCommandDefinition as v, CommandArgs as vt, HostProcess as w, defineCommand as x, flag as xt, SessionCommandDefinition as y, FlagSpec as yt, SpawnOptions as z };
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as ActiveCredential, D as Runtime, I as SpawnChild, K as PresentedResult, N as ChildResult, R as SpawnRequest, Y as EngineEvent, Z as StreamEvent, at as Session, ct as ManagementApiClientConfig, et as Credential, i as MountedTree, lt as TokenStorage, n as RunSummary, nt as CredentialManager, ot as StoredSessions, r as CommandFamily, st as ManagementApiClient } from "./run-summary-CLpl1gmC.js";
1
+ import { $ as StreamEvent, B as SpawnRequest, F as ChildResult, J as PresentedResult, R as SpawnChild, Z as EngineEvent, a as MountedTree, ct as StoredSessions, dt as TokenStorage, it as CredentialManager, k as Runtime, lt as ManagementApiClient, n as RunSummary, nt as Credential, r as CommandFamily, st as Session, tt as ActiveCredential, ut as ManagementApiClientConfig } from "./run-summary-CNL0TNZu.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 { g as noSessionForWorkspaceError, i as buildEngine, m as credentialsRequiredError, n as claimedIdentity, p as credentialWorkspaceMismatchError, r as credentialWorkspaceId, t as claimedExpiresAt } from "./token-claims-Bpb1vA2N.js";
1
+ import { g as noSessionForWorkspaceError, i as buildEngine, m as credentialsRequiredError, n as claimedIdentity, p as credentialWorkspaceMismatchError, r as credentialWorkspaceId, t as claimedExpiresAt } from "./token-claims-B6V7E0NS.js";
2
2
  import { Buffer } from "node:buffer";
3
3
  //#region src/in-memory-credential-manager.ts
4
4
  /**
@@ -1,6 +1,6 @@
1
1
  import { i as okVoid, n as notOk, t as CliStructuredError } from "./protocol-C1JQcGl9.js";
2
2
  import { createRequire } from "node:module";
3
- import { buildApplication, buildCommand, buildRouteMap, run, text_en } from "@stricli/core";
3
+ import { FlagNotFoundError, buildApplication, buildCommand, buildRouteMap, run, text_en } from "@stricli/core";
4
4
  import { existsSync, realpathSync } from "node:fs";
5
5
  import { dirname, join, resolve } from "node:path";
6
6
  import { Readable, Writable } from "node:stream";
@@ -95,6 +95,14 @@ const positional = {
95
95
  });
96
96
  }
97
97
  };
98
+ /** The two directions of one rule: a flag key is camelCase in code and
99
+ * --kebab-case on the CLI. */
100
+ function kebabCase(key) {
101
+ return key.replace(/[A-Z]/g, (upper) => `-${upper.toLowerCase()}`);
102
+ }
103
+ function camelCase(typed) {
104
+ return typed.replace(/-([a-zA-Z0-9])/g, (_, char) => char.toUpperCase());
105
+ }
98
106
  //#endregion
99
107
  //#region src/spawn.ts
100
108
  const CHILD_STATUS = Symbol.for("@prisma/cli-engine.childStatus");
@@ -1045,6 +1053,64 @@ function buildCommandTree(spec) {
1045
1053
  }
1046
1054
  return root;
1047
1055
  }
1056
+ function flagRedirectKey(commandPath, flag) {
1057
+ return `${commandPath} --${flag}`;
1058
+ }
1059
+ /** Where a path sits in the mounted tree; a group is a path some
1060
+ * command mounts under. */
1061
+ function mountedAs(spec, path) {
1062
+ if (spec.commands[path] !== void 0) return "command";
1063
+ const groupPrefix = `${path} `;
1064
+ return Object.keys(spec.commands).some((mounted) => mounted.startsWith(groupPrefix)) ? "command group" : void 0;
1065
+ }
1066
+ /** Engine-injected shared flags count: a command answers them whether
1067
+ * or not it declared them, so a redirect for one could never fire. */
1068
+ function acceptsFlag(def, flag) {
1069
+ if (def.args.flags[flag] !== void 0) return true;
1070
+ return def.kind !== "server-command" && RESERVED_FLAG_NAMES.has(flag);
1071
+ }
1072
+ function addVerbRedirect(spec, table, redirect) {
1073
+ const mounted = mountedAs(spec, redirect.from);
1074
+ if (mounted !== void 0) throw constructionError(`redirect '${redirect.from}' collides with a mounted ${mounted}`);
1075
+ if (table.has(redirect.from)) throw constructionError(`redirect '${redirect.from}' is declared twice`);
1076
+ table.set(redirect.from, redirect);
1077
+ }
1078
+ function addFlagRedirect(spec, table, redirect, flag) {
1079
+ if (!CAMEL_CASE.test(flag)) throw constructionError(`redirect for flag '${flag}' on '${redirect.from}' must name the flag in camelCase (it transliterates to --kebab-case on the CLI)`);
1080
+ const def = spec.commands[redirect.from];
1081
+ if (def === void 0) throw constructionError(`redirect for flag '${flag}' names '${redirect.from}', which is not a mounted command`);
1082
+ if (acceptsFlag(def, flag)) throw constructionError(`redirect for flag '${flag}' on '${redirect.from}' names a flag that command still accepts`);
1083
+ const key = flagRedirectKey(redirect.from, flag);
1084
+ if (table.has(key)) throw constructionError(`redirect for flag '${flag}' on '${redirect.from}' is declared twice`);
1085
+ table.set(key, redirect);
1086
+ }
1087
+ function buildRedirectTable(spec) {
1088
+ const byPath = /* @__PURE__ */ new Map();
1089
+ const byFlag = /* @__PURE__ */ new Map();
1090
+ for (const commandFamily of spec.commandFamilies) for (const redirect of commandFamily.redirects) if (redirect.flag === void 0) addVerbRedirect(spec, byPath, redirect);
1091
+ else addFlagRedirect(spec, byFlag, redirect, redirect.flag);
1092
+ return {
1093
+ byPath,
1094
+ byFlag
1095
+ };
1096
+ }
1097
+ /** Longest match wins, since one retired path may prefix another.
1098
+ * Segments match exactly: a redirect is never a spelling suggestion. */
1099
+ function matchVerbRedirect(table, segments) {
1100
+ for (let length = segments.length; length > 0; length -= 1) {
1101
+ const redirect = table.byPath.get(segments.slice(0, length).join(" "));
1102
+ if (redirect !== void 0) return redirect;
1103
+ }
1104
+ }
1105
+ /** `typedFlags` are spelled as the user typed them, without the leading
1106
+ * dashes; the scanner accepts kebab for camel, so both spellings
1107
+ * resolve to the declared camelCase name. */
1108
+ function matchFlagRedirect(table, commandPath, typedFlags) {
1109
+ for (const typed of typedFlags) {
1110
+ const redirect = table.byFlag.get(flagRedirectKey(commandPath, camelCase(typed)));
1111
+ if (redirect !== void 0) return redirect;
1112
+ }
1113
+ }
1048
1114
  //#endregion
1049
1115
  //#region src/execution/rendering.ts
1050
1116
  function firstLine(text) {
@@ -2045,12 +2111,6 @@ function makeContext(invocation, def, config, managesCredentials) {
2045
2111
  * only for WHICH flag names appear, never for values), and the parsed
2046
2112
  * positional slots (reduced to a count on the spot).
2047
2113
  */
2048
- function kebabCase(key) {
2049
- return key.replace(/[A-Z]/g, (upper) => `-${upper.toLowerCase()}`);
2050
- }
2051
- function camelCase(raw) {
2052
- return raw.replace(/-([a-zA-Z0-9])/g, (_, char) => char.toUpperCase());
2053
- }
2054
2114
  function declaredFlagKeys(def) {
2055
2115
  const own = Object.keys(def.args.flags);
2056
2116
  if (def.kind === "server-command") return own;
@@ -2221,7 +2281,8 @@ function commandParameters(def) {
2221
2281
  }
2222
2282
  /** Help examples never contain the binary name (operator ruling,
2223
2283
  * 2026-08-09): `{bin}` is substituted with the CLI name; an example
2224
- * without `{bin}` gets the name prepended. */
2284
+ * without `{bin}` gets the name prepended. A redirect's replacement is
2285
+ * written the same way and rendered by the same rule. */
2225
2286
  function resolveExample(example, cliName) {
2226
2287
  return example.includes("{bin}") ? example.replaceAll("{bin}", cliName) : `${cliName} ${example}`;
2227
2288
  }
@@ -2273,6 +2334,7 @@ function capturingText(state) {
2273
2334
  return {
2274
2335
  ...text_en,
2275
2336
  exceptionWhileParsingArguments(exc, ansiColor) {
2337
+ if (exc instanceof FlagNotFoundError) state.unresolvedFlagNames.push(exc.input);
2276
2338
  const message = text_en.exceptionWhileParsingArguments.call(text_en, exc, ansiColor);
2277
2339
  state.usageErrorText = message;
2278
2340
  return message;
@@ -2514,6 +2576,43 @@ function settleVersion(spec, invocation) {
2514
2576
  });
2515
2577
  return 0;
2516
2578
  }
2579
+ /** What the user typed that no longer exists: a retired path, or a
2580
+ * retired flag on a command that still exists. */
2581
+ function retiredInvocation(redirect) {
2582
+ if (redirect.flag === void 0) return `\`${redirect.from}\``;
2583
+ return `\`--${kebabCase(redirect.flag)}\` on \`${redirect.from}\``;
2584
+ }
2585
+ /** A retired invocation the redirect table claims: the run names its
2586
+ * replacement instead of failing as an unknown command or flag. A
2587
+ * retired flag can name a server command, whose stdout belongs to a
2588
+ * foreign client — so this settlement renders to stderr for the same
2589
+ * reason settleUnhandled does. */
2590
+ function settleCommandMoved(spec, invocation, redirect, commandId) {
2591
+ if (spec.commands[redirect.from]?.kind === "server-command") invocation.state.format = "human";
2592
+ const useReplacement = {
2593
+ kind: "run-command",
2594
+ label: "Use the replacement",
2595
+ command: resolveExample(redirect.replacement, spec.name)
2596
+ };
2597
+ emitErrored(invocation, {
2598
+ ok: false,
2599
+ commandId,
2600
+ error: {
2601
+ code: "CLI.COMMAND_MOVED",
2602
+ severity: "error",
2603
+ summary: `${retiredInvocation(redirect)} has been replaced`,
2604
+ ...redirect.reason === void 0 ? {} : { why: redirect.reason },
2605
+ nextActions: [useReplacement]
2606
+ },
2607
+ diagnostics: [],
2608
+ nextActions: [useReplacement]
2609
+ });
2610
+ return 2;
2611
+ }
2612
+ /** The command path stricli resolved, without the binary name. */
2613
+ function commandSegments(spec, prefix) {
2614
+ return prefix[0] === spec.name ? prefix.slice(1) : prefix;
2615
+ }
2517
2616
  /** Maps stricli's own settlement (parse/route failures, framework bugs)
2518
2617
  * onto the engine protocol when the pipeline never settled. A failure
2519
2618
  * addressed at a server command renders to stderr — a foreign client on
@@ -2522,7 +2621,7 @@ function settleUnhandled(spec, invocation, stricliExitCode) {
2522
2621
  const state = invocation.state;
2523
2622
  const raw = typeof stricliExitCode === "number" ? stricliExitCode : 0;
2524
2623
  if (raw === 0) return 0;
2525
- const segments = state.prefix[0] === spec.name ? state.prefix.slice(1) : state.prefix;
2624
+ const segments = commandSegments(spec, state.prefix);
2526
2625
  if (spec.commands[segments.join(" ")]?.kind === "server-command") state.format = "human";
2527
2626
  const usage = usageErrorCode(raw) !== void 0;
2528
2627
  const captured = usage ? state.stricliStderr.trim() : state.usageErrorText ?? state.internalErrorText ?? state.stricliStderr.trim();
@@ -2566,6 +2665,7 @@ function waitFor(ms, signal) {
2566
2665
  var EngineImpl = class {
2567
2666
  spec;
2568
2667
  root;
2668
+ redirects;
2569
2669
  now;
2570
2670
  delay;
2571
2671
  configSections;
@@ -2575,6 +2675,7 @@ var EngineImpl = class {
2575
2675
  this.delay = delay;
2576
2676
  this.configSections = declaredConfigSections(spec);
2577
2677
  this.root = buildRoutes(spec, buildCommandTree(spec), "", (invocation, entry, flags, values) => this.executeMounted(invocation, entry, flags, values));
2678
+ this.redirects = buildRedirectTable(spec);
2578
2679
  }
2579
2680
  async execute(argv, runtime, hooks) {
2580
2681
  const state = {
@@ -2595,6 +2696,7 @@ var EngineImpl = class {
2595
2696
  stricliStderr: "",
2596
2697
  stdinIterator: void 0,
2597
2698
  argv,
2699
+ unresolvedFlagNames: [],
2598
2700
  snapshot: void 0,
2599
2701
  delegatedTerminal: void 0,
2600
2702
  activePrompts: 0,
@@ -2675,11 +2777,36 @@ var EngineImpl = class {
2675
2777
  unsubscribe();
2676
2778
  await state.stdinIterator?.return?.();
2677
2779
  }
2678
- const exitCode = state.settledExitCode !== void 0 ? state.settledExitCode : settleUnhandled(this.spec, invocation, stricliProcess.exitCode);
2780
+ const exitCode = state.settledExitCode !== void 0 ? state.settledExitCode : this.settleRouting(invocation, stricliProcess.exitCode);
2679
2781
  this.fireOnSettled(invocation, exitCode, startedAtMs);
2680
2782
  if (state.pendingForceExit !== void 0) runtime.exit(state.pendingForceExit === "SIGTERM" ? 143 : 130);
2681
2783
  return exitCode;
2682
2784
  }
2785
+ /** stricli routed or parsed nothing runnable. When the redirect table
2786
+ * claims the invocation the user typed, the run names its
2787
+ * replacement; otherwise it settles as the usage error it is. */
2788
+ settleRouting(invocation, stricliExitCode) {
2789
+ const matched = this.matchRedirect(invocation.state, stricliExitCode);
2790
+ if (matched === void 0) return settleUnhandled(this.spec, invocation, stricliExitCode);
2791
+ return settleCommandMoved(this.spec, invocation, matched.redirect, matched.commandId);
2792
+ }
2793
+ matchRedirect(state, stricliExitCode) {
2794
+ const failure = typeof stricliExitCode === "number" ? usageErrorCode(stricliExitCode) : void 0;
2795
+ if (failure === "CLI.UNKNOWN_COMMAND") {
2796
+ const redirect = matchVerbRedirect(this.redirects, attemptedPath(state.argv));
2797
+ return redirect === void 0 ? void 0 : {
2798
+ redirect,
2799
+ commandId: redirect.from.replaceAll(" ", ".")
2800
+ };
2801
+ }
2802
+ if (failure !== "CLI.INVALID_ARGUMENTS") return;
2803
+ const segments = commandSegments(this.spec, state.prefix);
2804
+ const redirect = matchFlagRedirect(this.redirects, segments.join(" "), state.unresolvedFlagNames);
2805
+ return redirect === void 0 ? void 0 : {
2806
+ redirect,
2807
+ commandId: segments.join(".")
2808
+ };
2809
+ }
2683
2810
  /** The onSettled delivery: once per run, after the exit code is
2684
2811
  * final, only for runs that mounted a command (--help, --version,
2685
2812
  * and pre-mount usage errors leave no snapshot and fire nothing).
@@ -2829,6 +2956,16 @@ var EngineImpl = class {
2829
2956
  }
2830
2957
  }
2831
2958
  };
2959
+ /** The path the user typed, for argv that routed to no command: the
2960
+ * leading tokens up to the first flag or argument escape. */
2961
+ function attemptedPath(argv) {
2962
+ const segments = [];
2963
+ for (const token of argv) {
2964
+ if (token.startsWith("-")) break;
2965
+ segments.push(token);
2966
+ }
2967
+ return segments;
2968
+ }
2832
2969
  /** The closed set of config section names. Every mounted command
2833
2970
  * contributes the section it needs, whether it reaches the tree
2834
2971
  * through a command family or on its own — the shell mounts its own
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/cli-engine",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "The execution engine of the unified Prisma CLI.",
5
5
  "type": "module",
6
6
  "exports": {