@prisma/cli-engine 0.0.9 → 8.0.0-rc.2

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.
@@ -1,6 +1,7 @@
1
1
  import { a as okVoid, r as notOk, t as CliStructuredError } from "./protocol-D1CRNkhv.js";
2
2
  import { createRequire } from "node:module";
3
3
  import { FlagNotFoundError, buildApplication, buildCommand, buildRouteMap, run, text_en } from "@stricli/core";
4
+ import vendors from "ci-info/vendors.json" with { type: "json" };
4
5
  import { randomUUID } from "node:crypto";
5
6
  import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, writeFileSync } from "node:fs";
6
7
  import { dirname, join, resolve } from "node:path";
@@ -56,6 +57,17 @@ const flag = {
56
57
  ...spec
57
58
  });
58
59
  },
60
+ /**
61
+ * A boolean the user can leave unsaid: `--flag`, `--no-flag`, or
62
+ * neither, which arrives as undefined. Use it when absence means
63
+ * something of its own — "ask me" rather than "no".
64
+ */
65
+ optionalBoolean(spec) {
66
+ return brandFlag({
67
+ type: "optionalBoolean",
68
+ ...spec
69
+ });
70
+ },
59
71
  enum(spec) {
60
72
  return brandFlag({
61
73
  type: "enum",
@@ -157,6 +169,67 @@ function isChildStatusSettlement(value) {
157
169
  return typeof value === "object" && value !== null && value[CHILD_STATUS] === true;
158
170
  }
159
171
  //#endregion
172
+ //#region src/ci.ts
173
+ /**
174
+ * ci-info's own list of CI providers, read from the installed package
175
+ * rather than copied here, so upgrading ci-info is what teaches the
176
+ * engine a new provider. Its `isCI` export cannot be used instead: that
177
+ * module evaluates against the real `process.env` the moment it is
178
+ * imported, and the engine may only read the environment its host
179
+ * injected.
180
+ */
181
+ const VENDORS = vendors;
182
+ /**
183
+ * The variables ci-info checks outside the vendor table, catching CI
184
+ * systems that set a conventional variable but have no table entry.
185
+ * These are cross-vendor conventions rather than per-vendor facts,
186
+ * which is why this list holds still while the table grows.
187
+ */
188
+ const CONVENTIONAL_CI_VARS = [
189
+ "BUILD_ID",
190
+ "BUILD_NUMBER",
191
+ "CI",
192
+ "CI_APP_ID",
193
+ "CI_BUILD_ID",
194
+ "CI_BUILD_NUMBER",
195
+ "CI_NAME",
196
+ "CONTINUOUS_INTEGRATION",
197
+ "RUN_ID"
198
+ ];
199
+ function isSet(value) {
200
+ return value !== void 0 && value !== "";
201
+ }
202
+ function checkMatches(check, env) {
203
+ if (typeof check === "string") return isSet(env[check]);
204
+ const { env: variable, includes, any } = check;
205
+ if (typeof variable === "string" && typeof includes === "string") return env[variable]?.includes(includes) === true;
206
+ if (Array.isArray(any)) return any.some((name) => isSet(env[String(name)]));
207
+ return Object.entries(check).every(([name, value]) => env[name] === value);
208
+ }
209
+ function vendorMatches(vendor, env) {
210
+ return (Array.isArray(vendor.env) ? vendor.env : [vendor.env]).every((check) => checkMatches(check, env));
211
+ }
212
+ /**
213
+ * Whether this environment is a CI environment, by ci-info's rules
214
+ * applied to the environment the host injected rather than to
215
+ * `process.env`. `CI=false` is an explicit denial that stops every
216
+ * other check, exactly as ci-info treats it.
217
+ */
218
+ function detectCI(env) {
219
+ if (env.CI === "false") return false;
220
+ if (CONVENTIONAL_CI_VARS.some((name) => isSet(env[name]))) return true;
221
+ return VENDORS.some((vendor) => vendorMatches(vendor, env));
222
+ }
223
+ /**
224
+ * The engine's one answer to "is this run in CI", read by telemetry
225
+ * gating, `ctx.isCI` and the default interactivity decision. A host
226
+ * that says nothing gets detection, so forgetting to answer cannot turn
227
+ * a CI run into a reporting one.
228
+ */
229
+ function resolveIsCI(host) {
230
+ return host.isCIOverride ?? detectCI(host.env);
231
+ }
232
+ //#endregion
160
233
  //#region src/telemetry/endpoint.ts
161
234
  /**
162
235
  * Production endpoint pinned to the deployed Prisma Compute backend.
@@ -466,7 +539,7 @@ function reportCommandStart(inputs) {
466
539
  if (!resolveGating({
467
540
  env: host.env,
468
541
  config,
469
- inCI: host.isCI
542
+ inCI: resolveIsCI(host)
470
543
  }).enabled) return;
471
544
  const stored = config.installationId;
472
545
  const installationId = typeof stored === "string" && stored.length > 0 ? stored : discloseAndMint(inputs);
@@ -787,6 +860,26 @@ function buildManagementApiClient(invocation) {
787
860
  };
788
861
  } });
789
862
  }
863
+ /**
864
+ * Loads the SDK, surviving a Node ESM resolver fault observed in the
865
+ * wild: the resolver can return the package's un-realpathed pnpm
866
+ * symlink URL (instead of the .pnpm real path), from which the SDK's
867
+ * own 'openapi-fetch' import cannot resolve. The fault is
868
+ * state-dependent — two fstatSync calls at process start reliably
869
+ * provoke it, and a module-loader hook masks it — so nothing here can
870
+ * rule it out. The fallback resolves through CJS require, which
871
+ * realpaths, and imports the real location directly; it never fires
872
+ * when the normal import works.
873
+ */
874
+ async function importManagementApiSdk() {
875
+ try {
876
+ return await import("@prisma/management-api-sdk");
877
+ } catch {
878
+ const { createRequire } = await import("node:module");
879
+ const { pathToFileURL } = await import("node:url");
880
+ return await import(pathToFileURL(createRequire(import.meta.url).resolve("@prisma/management-api-sdk")).href);
881
+ }
882
+ }
790
883
  async function constructClient(invocation, debug, probe) {
791
884
  const manager = invocation.runtime.credentialManager;
792
885
  if (manager === void 0) throw credentialsRequiredError();
@@ -795,7 +888,7 @@ async function constructClient(invocation, debug, probe) {
795
888
  const config = invocation.runtime.managementApiClientConfig;
796
889
  if (config === void 0) throw new Error("@prisma/cli-engine: ctx.api requires Runtime.managementApiClientConfig when a credentialManager is wired");
797
890
  const storage = observedTokenStorage(await manager.activeCredentialStorage(), active, debug, probe);
798
- const { createManagementApiSdk } = await import("@prisma/management-api-sdk");
891
+ const { createManagementApiSdk } = await importManagementApiSdk();
799
892
  return {
800
893
  client: createManagementApiSdk({
801
894
  clientId: config.clientId,
@@ -1013,14 +1106,17 @@ function reservedConfigSectionName(name) {
1013
1106
  * top-level key names a config section, and the recognised section
1014
1107
  * names are exactly the ones the CLI's command families declare. Never
1015
1108
  * throws — bad section values are the section validator's problem, not
1016
- * defineConfig's.
1109
+ * definePrismaConfig's.
1017
1110
  */
1018
- function defineConfig(config) {
1111
+ function definePrismaConfig(config) {
1019
1112
  return Object.freeze({
1020
1113
  ...config,
1021
1114
  $prismaConfig: 1
1022
1115
  });
1023
1116
  }
1117
+ /** @deprecated Renamed to {@link definePrismaConfig}: every family's
1118
+ * config helper carries a unique name, so none needs an import alias. */
1119
+ const defineConfig = definePrismaConfig;
1024
1120
  function hasVersionMarker(value) {
1025
1121
  return typeof value === "object" && value !== null && typeof value[MARKER_KEY] === "number";
1026
1122
  }
@@ -1039,10 +1135,10 @@ function missingMarkerDiagnostic(path) {
1039
1135
  code: "CLI.CONFIG_MISSING_MARKER",
1040
1136
  severity: "error",
1041
1137
  summary: `${path} was not written for this version of the Prisma CLI, so it cannot be used.`,
1042
- why: "Configs for this CLI are created with defineConfig, which records a version marker on the exported object. This file's default export has no marker — it is most likely a Prisma 7 config, which uses the same filename — and the CLI stops rather than misread it.",
1138
+ why: "Configs for this CLI are created with definePrismaConfig, which records a version marker on the exported object. This file's default export has no marker — it is most likely a Prisma 7 config, which uses the same filename — and the CLI stops rather than misread it.",
1043
1139
  nextActions: [{
1044
1140
  kind: "user-choice",
1045
- label: "Migrate the file: wrap the exported object in defineConfig from @prisma/cli-engine and export the result as the default export."
1141
+ label: "Migrate the file: wrap the exported object in definePrismaConfig from @prisma/cli-engine and export the result as the default export."
1046
1142
  }],
1047
1143
  where: { path }
1048
1144
  };
@@ -1058,7 +1154,7 @@ function unsupportedVersionDiagnostic(path, found) {
1058
1154
  summary: `${path} declares config version ${found}, but this CLI supports only version 1.`,
1059
1155
  nextActions: [{
1060
1156
  kind: "user-choice",
1061
- label: "Regenerate the config with a defineConfig matching this CLI, or update the CLI to a version that supports the declared config version."
1157
+ label: "Regenerate the config with a definePrismaConfig matching this CLI, or update the CLI to a version that supports the declared config version."
1062
1158
  }],
1063
1159
  where: { path }
1064
1160
  };
@@ -1181,12 +1277,12 @@ async function loadConfig(cwd, configPath) {
1181
1277
  }
1182
1278
  //#endregion
1183
1279
  //#region src/execution/pre-parse-argv.ts
1184
- function flagTokens(argv) {
1280
+ function flagTokens$1(argv) {
1185
1281
  const terminator = argv.indexOf("--");
1186
1282
  return terminator === -1 ? argv : argv.slice(0, terminator);
1187
1283
  }
1188
1284
  function versionFlagGiven(argv) {
1189
- return flagTokens(argv).includes("--version");
1285
+ return flagTokens$1(argv).includes("--version");
1190
1286
  }
1191
1287
  /**
1192
1288
  * The one malformed `--config` shape the parser cannot see. stricli
@@ -1204,12 +1300,12 @@ function versionFlagGiven(argv) {
1204
1300
  * data, and `--` remains the way to pass it.
1205
1301
  */
1206
1302
  function configFlagGivenNoValue(argv) {
1207
- return flagTokens(argv).includes("--config=");
1303
+ return flagTokens$1(argv).includes("--config=");
1208
1304
  }
1209
1305
  /** The format requested by --json / --format / --format=<value>, if
1210
1306
  * any. */
1211
1307
  function formatFlagGiven(argv) {
1212
- const tokens = flagTokens(argv);
1308
+ const tokens = flagTokens$1(argv);
1213
1309
  for (const [index, token] of tokens.entries()) {
1214
1310
  if (token === "--json" || token === "--format=json") return "json";
1215
1311
  if (token === "--format=human") return "human";
@@ -1363,9 +1459,13 @@ function resolveColorEnabled(shared, runtime) {
1363
1459
  * --no-interactive override in either direction. Format never decides
1364
1460
  * interactivity (operator ruling, 2026-08-09): an interactive json run
1365
1461
  * may prompt — the prompt UI writes to stderr, so stdout stays a clean
1366
- * frame stream. */
1462
+ * frame stream.
1463
+ *
1464
+ * This asks the engine's CI detection rather than testing `CI` for
1465
+ * being set at all: a Jenkins, TeamCity or Azure Pipelines job sets no
1466
+ * `CI` variable, and used to be offered a prompt no one could answer. */
1367
1467
  function defaultInteractive(runtime) {
1368
- return runtime.isTty.stdin && runtime.env.CI === void 0;
1468
+ return runtime.isTty.stdin && !resolveIsCI(runtime);
1369
1469
  }
1370
1470
  function resolveAutoFormat(shared, runtime) {
1371
1471
  if (shared.json === true) return "json";
@@ -1603,9 +1703,9 @@ const TONE_VERB = {
1603
1703
  "color-6": "green"
1604
1704
  };
1605
1705
  const COLORED = createColors({ useColor: true });
1606
- const PLAIN = createColors({ useColor: false });
1706
+ const PLAIN$1 = createColors({ useColor: false });
1607
1707
  function makePaint(colorEnabled) {
1608
- const colors = colorEnabled ? COLORED : PLAIN;
1708
+ const colors = colorEnabled ? COLORED : PLAIN$1;
1609
1709
  return (tone, text) => colors[TONE_VERB[tone]](text);
1610
1710
  }
1611
1711
  function renderText(text, paint) {
@@ -1689,7 +1789,7 @@ const STATUS_SYMBOL = {
1689
1789
  };
1690
1790
  const MASK = "********";
1691
1791
  const COLUMN_GAP = " ";
1692
- const RAIL = "│";
1792
+ const RAIL$1 = "│";
1693
1793
  const BRANCH = "├─";
1694
1794
  const LAST_BRANCH = "└─";
1695
1795
  const TRAILING_SPACES = / +$/;
@@ -1759,10 +1859,10 @@ function toned(text, tone) {
1759
1859
  function writeFields(rows, rail, paint, write) {
1760
1860
  const cells = rows.map((row) => ({
1761
1861
  label: toned(extend(row.label, ":"), "heading"),
1762
- value: row.sensitive === true ? MASK : row.value
1862
+ value: row.sensitive === true ? MASK : orPlaceholder(row.value)
1763
1863
  }));
1764
1864
  const width = Math.max(0, ...cells.map((cell) => textWidth(cell.label)));
1765
- const prefix = rail ? `${paint("structure", RAIL)}${COLUMN_GAP}` : "";
1865
+ const prefix = rail ? `${paint("structure", RAIL$1)}${COLUMN_GAP}` : "";
1766
1866
  for (const cell of cells) write(`${prefix}${renderText(padTo(cell.label, width), paint)}${COLUMN_GAP}${renderText(cell.value, paint)}`);
1767
1867
  }
1768
1868
  /**
@@ -1770,8 +1870,23 @@ function writeFields(rows, rail, paint, write) {
1770
1870
  * than the bytes so colour cannot shift a column. The last column is
1771
1871
  * never padded, so no line carries trailing whitespace.
1772
1872
  */
1873
+ /** One header convention for every table: plain-string headers are
1874
+ * normalized to sentence case, so casing is not a per-command choice. */
1875
+ function sentenceCase(text) {
1876
+ if (typeof text !== "string" || text === "") return text;
1877
+ return `${text[0].toUpperCase()}${text.slice(1)}`;
1878
+ }
1879
+ const PLACEHOLDER = "—";
1880
+ /** An absent value renders as a dim em dash rather than invented prose
1881
+ * ("none", "n/a") in data tone. */
1882
+ function orPlaceholder(cell) {
1883
+ return cell === "" || typeof cell !== "string" && textWidth(cell) === 0 ? [{
1884
+ text: PLACEHOLDER,
1885
+ tone: "placeholder"
1886
+ }] : cell;
1887
+ }
1773
1888
  function writeTable(columns, rows, paint, write) {
1774
- const all = [columns.map((column) => toned(column, "heading")), ...rows];
1889
+ const all = [columns.map((column) => toned(sentenceCase(column), "heading")), ...rows.map((row) => row.map(orPlaceholder))];
1775
1890
  const widths = [];
1776
1891
  for (const row of all) for (const [index, cell] of row.entries()) widths[index] = Math.max(widths[index] ?? 0, textWidth(cell));
1777
1892
  for (const row of all) write(row.map((cell, index) => renderText(index === row.length - 1 ? cell : padTo(cell, widths[index]), paint)).join(COLUMN_GAP).replace(TRAILING_SPACES, ""));
@@ -1782,7 +1897,7 @@ function writeBranches(nodes, prefix, paint, write) {
1782
1897
  for (const [index, node] of nodes.entries()) {
1783
1898
  const last = index === nodes.length - 1;
1784
1899
  write(`${prefix}${paint("structure", last ? LAST_BRANCH : BRANCH)} ${treeLabel(node, paint)}`);
1785
- const continuation = last ? " " : `${paint("structure", RAIL)}${COLUMN_GAP}`;
1900
+ const continuation = last ? " " : `${paint("structure", RAIL$1)}${COLUMN_GAP}`;
1786
1901
  writeBranches(node.children ?? [], `${prefix}${continuation}`, paint, write);
1787
1902
  }
1788
1903
  }
@@ -1797,21 +1912,27 @@ const DIAGNOSTIC_SYMBOL = {
1797
1912
  warn: "⚠",
1798
1913
  info: "ℹ"
1799
1914
  };
1800
- function writeDiagnostic(stream, diagnostic) {
1801
- stream.write(`${DIAGNOSTIC_SYMBOL[diagnostic.severity]} [${diagnostic.code}] ${diagnostic.summary}\n`);
1802
- if (diagnostic.why !== void 0) stream.write(` why: ${diagnostic.why}\n`);
1803
- for (const action of diagnostic.nextActions) stream.write(`${renderNextAction(action)}\n`);
1804
- if (diagnostic.docsUrl !== void 0) stream.write(` docs: ${diagnostic.docsUrl}\n`);
1915
+ const PLAIN = makePaint(false);
1916
+ function writeDiagnostic(stream, diagnostic, paint = PLAIN) {
1917
+ const glyph = paint(diagnostic.severity, DIAGNOSTIC_SYMBOL[diagnostic.severity]);
1918
+ const code = paint("muted", `[${diagnostic.code}]`);
1919
+ stream.write(`${glyph} ${code} ${diagnostic.summary}\n`);
1920
+ if (diagnostic.why !== void 0) stream.write(` ${paint("muted", `why: ${diagnostic.why}`)}\n`);
1921
+ for (const action of diagnostic.nextActions) stream.write(`${renderNextAction(action, paint)}\n`);
1922
+ if (diagnostic.docsUrl !== void 0) stream.write(` ${paint("muted", "docs:")} ${paint("link", diagnostic.docsUrl)}\n`);
1805
1923
  }
1806
1924
  /** `label` is required, so a mapper building an action out of a bare
1807
1925
  * command string — a legacy error's follow-up step, with no prose
1808
1926
  * beside it — has nothing to put in the label but the command itself.
1809
1927
  * Only the renderer sees both fields, so only it can tell they are the
1810
1928
  * same string and print it once. */
1811
- function renderNextAction(action) {
1929
+ function renderNextAction(action, paint = PLAIN) {
1812
1930
  const target = action.command ?? action.url;
1813
1931
  const repeatsTheLabel = target === void 0 || target === action.label;
1814
- return `→ ${action.label}${repeatsTheLabel ? "" : `: ${target}`}`;
1932
+ const arrow = paint("heading", "→");
1933
+ if (repeatsTheLabel) return `${arrow} ${action.command !== void 0 ? paint("identifier", action.label) : action.label}`;
1934
+ const painted = action.command !== void 0 ? paint("identifier", target) : paint("link", target);
1935
+ return `${arrow} ${action.label}: ${painted}`;
1815
1936
  }
1816
1937
  /** Populates docsUrl from the owning family's docsBaseUrl (base + code)
1817
1938
  * when the diagnostic does not carry its own — a per-raise docsUrl wins. */
@@ -1823,6 +1944,27 @@ function withDocsUrl(state, diagnostic) {
1823
1944
  docsUrl: `${base}${diagnostic.code}`
1824
1945
  };
1825
1946
  }
1947
+ const TRAILING_NEWLINE = /\n$/;
1948
+ function diagnosticSection(diagnostic, paint) {
1949
+ const lines = [];
1950
+ writeDiagnostic({ write: (text) => lines.push(...text.replace(TRAILING_NEWLINE, "").split("\n")) }, diagnostic, paint);
1951
+ return {
1952
+ lines,
1953
+ compact: lines.length === 1
1954
+ };
1955
+ }
1956
+ /** A blank line between sections wherever a multi-line one is involved,
1957
+ * so a card, a table and the next actions each read as their own
1958
+ * paragraph; adjacent compact sections keep hugging. */
1959
+ function writeSections(sections, stream) {
1960
+ let previous;
1961
+ for (const section of sections) {
1962
+ if (section.lines.length === 0) continue;
1963
+ if (previous !== void 0 && !(previous.compact && section.compact)) stream.write("\n");
1964
+ for (const line of section.lines) stream.write(`${line}\n`);
1965
+ previous = section;
1966
+ }
1967
+ }
1826
1968
  /** Channel discipline (operator ruling, 2026-08-09): human Blocks,
1827
1969
  * next-action lines, and diagnostics are presentation prose on stderr;
1828
1970
  * the materialized `stdout` presentation lines are the machine-usable
@@ -1830,10 +1972,21 @@ function withDocsUrl(state, diagnostic) {
1830
1972
  function renderCompletedHuman(invocation, presented) {
1831
1973
  const { runtime, state } = invocation;
1832
1974
  const paint = makePaint(state.colorEnabled);
1833
- for (const block of presented.presentation.human) renderBlock(block, paint, (line) => runtime.stderr.write(`${line}\n`));
1834
- for (const action of presented.presentation.next) runtime.stderr.write(`${renderNextAction(action)}\n`);
1835
- for (const diagnostic of presented.diagnostics) writeDiagnostic(runtime.stderr, withDocsUrl(state, diagnostic));
1836
- for (const line of presented.presentation.stdout) runtime.stdout.write(`${line}\n`);
1975
+ const sections = presented.presentation.human.map((block) => {
1976
+ const lines = [];
1977
+ renderBlock(block, paint, (line) => lines.push(line));
1978
+ return {
1979
+ lines,
1980
+ compact: block.kind === "summary"
1981
+ };
1982
+ });
1983
+ if (presented.presentation.next.length > 0) sections.push({
1984
+ lines: presented.presentation.next.map((action) => renderNextAction(action, paint)),
1985
+ compact: true
1986
+ });
1987
+ for (const diagnostic of presented.diagnostics) sections.push(diagnosticSection(withDocsUrl(state, diagnostic), paint));
1988
+ writeSections(sections, runtime.stderr);
1989
+ if (!(runtime.isTty.stdout && runtime.isTty.stderr && runtime.outputStreamsShareDevice !== false)) for (const line of presented.presentation.stdout) runtime.stdout.write(`${line}\n`);
1837
1990
  }
1838
1991
  const SEVERITY_RANK = {
1839
1992
  error: 0,
@@ -2065,7 +2218,7 @@ function writeSectionWarnings(invocation, diagnostics) {
2065
2218
  const state = invocation.state;
2066
2219
  for (const diagnostic of diagnostics) {
2067
2220
  if (SEVERITY_RANK[diagnostic.severity] > SEVERITY_RANK[state.logLevel]) continue;
2068
- writeDiagnostic(invocation.runtime.stderr, withDocsUrl(state, diagnostic));
2221
+ writeDiagnostic(invocation.runtime.stderr, withDocsUrl(state, diagnostic), makePaint(state.colorEnabled));
2069
2222
  }
2070
2223
  }
2071
2224
  function dependencyResolvable(specifier, cwd) {
@@ -2914,12 +3067,31 @@ function makeUi(colorEnabled, stderr) {
2914
3067
  };
2915
3068
  }
2916
3069
  /** Materializes ONLY the active format's presentation functions, at the
2917
- * return site: human → human + stdout + next; json → json + next. */
3070
+ * return site: human → human + stdout + next; json → json + next.
3071
+ *
3072
+ * `stdout` and `next` may be absent at runtime, so both are called with
3073
+ * `?.()`. `Presentations` requires all four, so no command compiled
3074
+ * against this engine can omit one — but `@prisma/orm-toolchain` is
3075
+ * built against engine `0.0.9`, where three of the four were optional,
3076
+ * and its published commands took that up: `migration list` declares
3077
+ * `human` and `json` and neither of the others. Calling them
3078
+ * unconditionally makes it exit 2 — `stdout` in human mode, `next` in
3079
+ * both.
3080
+ *
3081
+ * `json` is called unconditionally, and stays that way: a missing json
3082
+ * presentation is the defect this change removes, and every ORM command
3083
+ * already declares one.
3084
+ *
3085
+ * This is version skew in our own code, not a foreign contract. The fix
3086
+ * is in prisma/prisma: declare the missing presentations in the ORM
3087
+ * commands and build orm-toolchain against this engine, where the type
3088
+ * refuses to compile without them. Delete both `?.()` when that
3089
+ * version is pinned here. */
2918
3090
  function materializePresentation(state, ui, presentations) {
2919
3091
  if (state.format === "json") return {
2920
3092
  human: [],
2921
3093
  stdout: [],
2922
- json: presentations.json?.(),
3094
+ json: presentations.json(),
2923
3095
  next: presentations.next?.() ?? []
2924
3096
  };
2925
3097
  return {
@@ -2962,7 +3134,8 @@ function makeContext(invocation, def, config, capabilities) {
2962
3134
  signal: invocation.signal,
2963
3135
  cwd: invocation.runtime.cwd,
2964
3136
  env: invocation.runtime.env,
2965
- isCI: invocation.runtime.isCI,
3137
+ host: invocation.runtime.host,
3138
+ isCI: resolveIsCI(invocation.runtime),
2966
3139
  requireDependency: async (specifier) => {
2967
3140
  if (dependencyResolvable(specifier, invocation.runtime.cwd)) return okVoid();
2968
3141
  return notOk(missingDependencyError(specifier, await resolvePackageManager({
@@ -3092,6 +3265,12 @@ function stricliFlagParameter(spec) {
3092
3265
  brief: spec.brief,
3093
3266
  default: false
3094
3267
  };
3268
+ case "optionalBoolean": return {
3269
+ kind: "boolean",
3270
+ brief: spec.brief,
3271
+ optional: true,
3272
+ withNegated: true
3273
+ };
3095
3274
  case "enum": return {
3096
3275
  kind: "enum",
3097
3276
  brief: spec.brief,
@@ -3256,6 +3435,315 @@ function usageErrorCode(stricliExitCode) {
3256
3435
  if (stricliExitCode === -4) return "CLI.INVALID_ARGUMENTS";
3257
3436
  }
3258
3437
  //#endregion
3438
+ //#region src/execution/help.ts
3439
+ /**
3440
+ * Engine-rendered help: the command tree drawn with the same tones the
3441
+ * block renderer uses, so help is themed like every other surface.
3442
+ * stricli's text_en renderer is never consulted — root and group help
3443
+ * list `name brief` rows, and full signatures appear only on the leaf
3444
+ * that owns them.
3445
+ */
3446
+ const RAIL = "│";
3447
+ const GAP = " ";
3448
+ const WRAP_WIDTH = 76;
3449
+ function flagTokens(argv) {
3450
+ const terminator = argv.indexOf("--");
3451
+ return terminator === -1 ? argv : argv.slice(0, terminator);
3452
+ }
3453
+ function helpFlagGiven(argv) {
3454
+ return flagTokens(argv).some((token) => token === "-h" || token === "--help" || token === "--help-all");
3455
+ }
3456
+ /** The colour decision available before the shared flags are parsed,
3457
+ * read from raw argv: explicit flag, then NO_COLOR, then the TTY of
3458
+ * the stream about to be written. Help and pre-mount failures both
3459
+ * render through this; applySharedFlags re-resolves once a command
3460
+ * actually parses. */
3461
+ function preParseColorEnabled(argv, runtime, stream) {
3462
+ const tokens = flagTokens(argv);
3463
+ if (tokens.includes("--no-color")) return false;
3464
+ if (tokens.includes("--color")) return true;
3465
+ if (runtime.env.NO_COLOR !== void 0) return false;
3466
+ return runtime.isTty[stream];
3467
+ }
3468
+ /** The command path the user asked help for: the leading non-flag
3469
+ * tokens, resolved as far as the tree recognizes them. */
3470
+ function helpPath(argv) {
3471
+ const segments = [];
3472
+ for (const token of argv) {
3473
+ if (token.startsWith("-")) break;
3474
+ segments.push(token);
3475
+ }
3476
+ return segments;
3477
+ }
3478
+ /** Walks as far as the segments stay recognized; help for `project
3479
+ * frobnicate` is project's help, not a dead end. */
3480
+ function resolveTarget(root, segments) {
3481
+ let node = root;
3482
+ const path = [];
3483
+ for (const segment of segments) {
3484
+ const entry = node.commands.get(segment);
3485
+ if (entry !== void 0) return {
3486
+ target: {
3487
+ kind: "leaf",
3488
+ entry
3489
+ },
3490
+ path: [...path, segment]
3491
+ };
3492
+ const child = node.children.get(segment);
3493
+ if (child === void 0) break;
3494
+ node = child;
3495
+ path.push(segment);
3496
+ }
3497
+ return {
3498
+ target: {
3499
+ kind: "node",
3500
+ node
3501
+ },
3502
+ path
3503
+ };
3504
+ }
3505
+ /** A BARE group invocation (`prisma-cli project`, or no argv at all)
3506
+ * is a help request; anything carrying flags or extra tokens is not —
3507
+ * `cli --unknown` and `cli project --frobnicate` must reach routing
3508
+ * and usage validation, not exit 0 with a help card. A bare leaf is a
3509
+ * command run and is left alone. */
3510
+ function bareGroupInvocation(root, argv) {
3511
+ const segments = helpPath(argv);
3512
+ if (segments.length !== argv.length) return false;
3513
+ if (segments.length === 0) return true;
3514
+ const { target, path } = resolveTarget(root, segments);
3515
+ return target.kind === "node" && path.length === segments.length;
3516
+ }
3517
+ function renderHelp(spec, root, argv, colorEnabled, out) {
3518
+ const paint = makePaint(colorEnabled);
3519
+ const { target, path } = resolveTarget(root, helpPath(argv));
3520
+ const lines = [];
3521
+ if (target.kind === "leaf") renderLeafHelp(spec, target.entry, path, paint, lines);
3522
+ else renderNodeHelp(spec, target.node, path, paint, lines);
3523
+ out.write(`${lines.join("\n")}\n`);
3524
+ }
3525
+ /** `prisma-cli project → Manage and inspect your Prisma projects` */
3526
+ function header(spec, path, tagline, paint) {
3527
+ const name = paint("emphasis", [spec.name, ...path].join(" "));
3528
+ if (tagline === void 0 || tagline === "") return name;
3529
+ return `${name} ${paint("muted", `→ ${tagline}`)}`;
3530
+ }
3531
+ function rail(paint, rest = "") {
3532
+ return rest === "" ? paint("structure", RAIL) : `${paint("structure", RAIL)}${GAP}${rest}`;
3533
+ }
3534
+ function sectionLabel(paint, label) {
3535
+ return rail(paint, paint("muted", label));
3536
+ }
3537
+ /** Two-column rows under the rail: name in the accent, brief plain. */
3538
+ function railRows(rows, paint, lines) {
3539
+ const width = Math.max(0, ...rows.map((row) => textWidth(row.name)));
3540
+ for (const row of rows) {
3541
+ const pad = " ".repeat(width - textWidth(row.name));
3542
+ const suffix = row.suffix === void 0 || row.suffix === "" ? "" : ` ${paint("muted", row.suffix)}`;
3543
+ lines.push(rail(paint, `${paint("identifier", row.name)}${pad}${GAP}${row.brief}${suffix}`));
3544
+ }
3545
+ }
3546
+ function wrap(text, width) {
3547
+ const lines = [];
3548
+ for (const paragraph of text.split("\n")) {
3549
+ if (paragraph === "") {
3550
+ lines.push("");
3551
+ continue;
3552
+ }
3553
+ let line = "";
3554
+ for (const word of paragraph.split(" ")) if (line !== "" && line.length + 1 + word.length > width) {
3555
+ lines.push(line);
3556
+ line = word;
3557
+ } else line = line === "" ? word : `${line} ${word}`;
3558
+ if (line !== "") lines.push(line);
3559
+ }
3560
+ return lines;
3561
+ }
3562
+ function proseLines(text, paint, lines, tone = "plain") {
3563
+ for (const line of wrap(text, WRAP_WIDTH)) lines.push(rail(paint, tone === "muted" ? paint("muted", line) : line));
3564
+ }
3565
+ function exampleLines(examples, cliName, paint, lines) {
3566
+ if (examples.length === 0) return;
3567
+ lines.push(rail(paint));
3568
+ lines.push(sectionLabel(paint, "Examples"));
3569
+ for (const example of examples) lines.push(rail(paint, `${GAP}${paint("muted", "$")} ${resolveExample(example, cliName)}`));
3570
+ }
3571
+ function docsLine(url, paint, lines) {
3572
+ if (url === void 0) return;
3573
+ lines.push(rail(paint));
3574
+ lines.push(rail(paint, `${paint("muted", "Docs")}${GAP}${paint("link", url)}`));
3575
+ }
3576
+ /** `--interactive/--no-interactive`, `-q, --quiet`, `--config <path>` —
3577
+ * one spelling rule for shared and declared flags alike. */
3578
+ function flagLabel(key, spec) {
3579
+ const kebab = kebabCase(key);
3580
+ return `${spec.alias === void 0 ? " " : `-${spec.alias},`} --${kebab}${spec.withNegated === true ? `/--no-${kebab}` : ""}${spec.placeholder === void 0 ? "" : ` <${spec.placeholder}>`}${spec.variadic === true ? "..." : ""}`;
3581
+ }
3582
+ function sharedFlagRows() {
3583
+ const aliasByKey = new Map(Object.entries(SHARED_ALIASES).map(([alias, key]) => [key, alias]));
3584
+ return [
3585
+ ...Object.entries(SHARED_FLAG_PARAMETERS).map(([key, spec]) => {
3586
+ const record = spec;
3587
+ return {
3588
+ name: flagLabel(key, {
3589
+ ...record,
3590
+ alias: aliasByKey.get(key)
3591
+ }),
3592
+ brief: record.brief,
3593
+ suffix: record.values === void 0 ? void 0 : record.values.join("|")
3594
+ };
3595
+ }),
3596
+ {
3597
+ name: `-h, --help`,
3598
+ brief: "Print help for a command"
3599
+ },
3600
+ {
3601
+ name: ` --version`,
3602
+ brief: "Print the CLI version and exit"
3603
+ }
3604
+ ];
3605
+ }
3606
+ function declaredFlagRows(def) {
3607
+ return Object.entries(def.args.flags).map(([key, spec]) => {
3608
+ const runtime = flagRuntime(spec);
3609
+ return {
3610
+ name: flagLabel(key, {
3611
+ alias: runtime.alias,
3612
+ placeholder: runtime.type === "boolean" || runtime.type === "optionalBoolean" ? void 0 : runtime.placeholder ?? "value",
3613
+ withNegated: runtime.type === "optionalBoolean",
3614
+ variadic: runtime.type === "repeated"
3615
+ }),
3616
+ brief: runtime.brief,
3617
+ suffix: flagSuffix(runtime)
3618
+ };
3619
+ });
3620
+ }
3621
+ function flagSuffix(runtime) {
3622
+ const parts = [];
3623
+ if (runtime.values !== void 0 && runtime.values.length > 0) parts.push(runtime.values.join("|"));
3624
+ if (runtime.type === "requiredString") parts.push("required");
3625
+ if (runtime.default !== void 0) parts.push(`default: ${String(runtime.default)}`);
3626
+ return parts.length === 0 ? void 0 : `(${parts.join("; ")})`;
3627
+ }
3628
+ function positionalUsage(def) {
3629
+ return Object.values(def.args.positionals).map((spec) => {
3630
+ const runtime = positionalRuntime(spec);
3631
+ if (runtime.type === "optionalString") return `[${runtime.placeholder}]`;
3632
+ if (runtime.type === "variadic") return `[${runtime.placeholder}...]`;
3633
+ return `<${runtime.placeholder}>`;
3634
+ }).join(" ");
3635
+ }
3636
+ function requiredFlagUsage(def) {
3637
+ return Object.entries(def.args.flags).flatMap(([key, spec]) => {
3638
+ const runtime = flagRuntime(spec);
3639
+ return runtime.type === "requiredString" ? [`--${kebabCase(key)} <${runtime.placeholder ?? "value"}>`] : [];
3640
+ }).join(" ");
3641
+ }
3642
+ /** Mount order, not map-partition order: a leaf and a group list in
3643
+ * the order their first command was mounted. */
3644
+ function nodeRows(spec, node, path) {
3645
+ const groupPath = path.join(" ");
3646
+ const depth = path.length;
3647
+ const seen = /* @__PURE__ */ new Set();
3648
+ const rows = [];
3649
+ for (const mounted of Object.keys(spec.commands)) {
3650
+ const segments = mounted.split(" ");
3651
+ if (segments.length <= depth || segments.slice(0, depth).join(" ") !== groupPath) continue;
3652
+ const name = segments[depth];
3653
+ if (seen.has(name)) continue;
3654
+ seen.add(name);
3655
+ const entry = node.commands.get(name);
3656
+ if (entry !== void 0) rows.push({
3657
+ name: usageName(name, entry.def),
3658
+ brief: entry.def.help.summary
3659
+ });
3660
+ else if (node.children.has(name)) {
3661
+ const childPath = depth === 0 ? name : `${groupPath} ${name}`;
3662
+ rows.push({
3663
+ name,
3664
+ brief: spec.groups[childPath]?.brief ?? ""
3665
+ });
3666
+ }
3667
+ }
3668
+ return rows;
3669
+ }
3670
+ function renderNodeHelp(spec, node, path, paint, lines) {
3671
+ const atRoot = path.length === 0;
3672
+ const groupPath = path.join(" ");
3673
+ const tagline = atRoot ? spec.help?.tagline : spec.groups[groupPath]?.brief;
3674
+ lines.push(header(spec, path, tagline, paint));
3675
+ lines.push("");
3676
+ railRows(nodeRows(spec, node, path), paint, lines);
3677
+ const description = atRoot ? spec.help?.description : spec.groups[groupPath]?.description;
3678
+ if (description !== void 0) {
3679
+ lines.push(rail(paint));
3680
+ proseLines(description, paint, lines);
3681
+ }
3682
+ if (atRoot) {
3683
+ lines.push(rail(paint));
3684
+ lines.push(sectionLabel(paint, "Global options"));
3685
+ railRows(sharedFlagRows(), paint, lines);
3686
+ exampleLines(spec.help?.examples ?? [], spec.name, paint, lines);
3687
+ docsLine(spec.help?.docsUrl, paint, lines);
3688
+ } else {
3689
+ lines.push(rail(paint));
3690
+ lines.push(rail(paint, paint("muted", `Run '${spec.name} ${groupPath} <command> --help' for details on a command.`)));
3691
+ }
3692
+ lines.push("");
3693
+ }
3694
+ /** `link [id-or-name]` — the row a group lists for a leaf: name plus
3695
+ * positional shape, briefs carry the rest. */
3696
+ function usageName(name, def) {
3697
+ const positionals = positionalUsage(def);
3698
+ return positionals === "" ? name : `${name} ${positionals}`;
3699
+ }
3700
+ function renderLeafHelp(spec, entry, path, paint, lines) {
3701
+ const def = entry.def;
3702
+ lines.push(header(spec, path, def.help.summary, paint));
3703
+ lines.push("");
3704
+ const usageParts = [
3705
+ spec.name,
3706
+ ...path,
3707
+ requiredFlagUsage(def),
3708
+ "[options]",
3709
+ positionalUsage(def)
3710
+ ].filter((part) => part !== "");
3711
+ lines.push(sectionLabel(paint, "Usage"));
3712
+ lines.push(rail(paint, `${GAP}${paint("muted", "$")} ${paint("emphasis", usageParts.join(" "))}`));
3713
+ if (def.help.description !== void 0) {
3714
+ lines.push(rail(paint));
3715
+ proseLines(def.help.description, paint, lines);
3716
+ }
3717
+ if (def.maySpawn) {
3718
+ lines.push(rail(paint));
3719
+ lines.push(rail(paint, paint("muted", NO_JSON_NOTE)));
3720
+ }
3721
+ const positionalEntries = Object.values(def.args.positionals).map((spec) => positionalRuntime(spec));
3722
+ if (positionalEntries.length > 0) {
3723
+ lines.push(rail(paint));
3724
+ lines.push(sectionLabel(paint, "Arguments"));
3725
+ railRows(positionalEntries.map((runtime) => ({
3726
+ name: runtime.placeholder,
3727
+ brief: runtime.brief,
3728
+ suffix: runtime.type === "optionalString" ? "(optional)" : void 0
3729
+ })), paint, lines);
3730
+ }
3731
+ const flagRows = declaredFlagRows(def);
3732
+ if (flagRows.length > 0) {
3733
+ lines.push(rail(paint));
3734
+ lines.push(sectionLabel(paint, "Options"));
3735
+ railRows(flagRows, paint, lines);
3736
+ }
3737
+ if (def.kind !== "server-command") {
3738
+ const sharedNames = [...Object.keys(SHARED_FLAG_PARAMETERS).map((key) => `--${kebabCase(key)}`)].join(", ");
3739
+ lines.push(rail(paint));
3740
+ proseLines(`Global options also apply: ${sharedNames}. Run '${spec.name} --help' for details.`, paint, lines, "muted");
3741
+ }
3742
+ exampleLines(def.help.examples, spec.name, paint, lines);
3743
+ docsLine(entry.docsBaseUrl, paint, lines);
3744
+ lines.push("");
3745
+ }
3746
+ //#endregion
3259
3747
  //#region src/execution/settlement.ts
3260
3748
  function undocumentedExitCode(def, exitCode) {
3261
3749
  if (exitCode === 0) return;
@@ -3282,7 +3770,7 @@ function settleCompleted(invocation, def, presented) {
3282
3770
  envelope: {
3283
3771
  ok: true,
3284
3772
  commandId: state.commandId,
3285
- result: presented.presentation.json === void 0 ? presented.data : presented.presentation.json,
3773
+ result: presented.presentation.json,
3286
3774
  exitCode,
3287
3775
  diagnostics: presented.diagnostics.map((diagnostic) => withDocsUrl(state, diagnostic)),
3288
3776
  nextActions: presented.presentation.next
@@ -3397,7 +3885,7 @@ function settleChildStatus(invocation, def, settlement) {
3397
3885
  if (!def.maySpawn) throw new Error(`@prisma/cli-engine: command '${invocation.state.commandId}' returned exitWithChildStatus without declaring maySpawn — only a command that hands the terminal to another program may settle with that program's status`);
3398
3886
  const child = invocation.state.lastChild;
3399
3887
  if (child === void 0) throw new Error(`@prisma/cli-engine: command '${invocation.state.commandId}' returned exitWithChildStatus without a child having run — that settlement reports the status of a child ctx.spawn started, and this run started none`);
3400
- if (child.signal === null) for (const action of settlement.nextActions) invocation.runtime.stderr.write(`${renderNextAction(action)}\n`);
3888
+ if (child.signal === null) for (const action of settlement.nextActions) invocation.runtime.stderr.write(`${renderNextAction(action, makePaint(invocation.state.colorEnabled))}\n`);
3401
3889
  settleVerbatimExitCode(invocation, childExitCode(child));
3402
3890
  }
3403
3891
  /** A session command that returned ok shut down cleanly: no
@@ -3456,9 +3944,8 @@ function emitErrored(invocation, raw) {
3456
3944
  });
3457
3945
  return;
3458
3946
  }
3459
- const stderr = invocation.runtime.stderr;
3460
- writeDiagnostic(stderr, envelope.error);
3461
- for (const diagnostic of envelope.diagnostics) writeDiagnostic(stderr, diagnostic);
3947
+ const paint = makePaint(invocation.state.colorEnabled);
3948
+ writeSections([envelope.error, ...envelope.diagnostics].map((diagnostic) => diagnosticSection(diagnostic, paint)), invocation.runtime.stderr);
3462
3949
  }
3463
3950
  /** `--version` prints createCli's version and exits 0. In json mode the
3464
3951
  * version travels as the run's single result frame. */
@@ -3535,21 +4022,63 @@ function settleUnhandled(spec, invocation, stricliExitCode) {
3535
4022
  const full = captured.length > 0 ? captured : "The command failed unexpectedly";
3536
4023
  const summary = firstLine(full);
3537
4024
  const remainder = full.slice(full.indexOf("\n") + 1).trim();
4025
+ const code = usageErrorCode(raw) ?? "CLI.INTERNAL_ERROR";
4026
+ const nextActions = code === "CLI.UNKNOWN_COMMAND" ? unknownCommandActions(spec, state) : [];
3538
4027
  emitErrored(invocation, {
3539
4028
  ok: false,
3540
4029
  commandId: segments.join("."),
3541
4030
  error: {
3542
- code: usageErrorCode(raw) ?? "CLI.INTERNAL_ERROR",
4031
+ code,
3543
4032
  severity: "error",
3544
4033
  summary,
3545
4034
  ...usage && full.includes("\n") && remainder.length > 0 ? { why: remainder } : {},
3546
- nextActions: []
4035
+ nextActions
3547
4036
  },
3548
4037
  diagnostics: [],
3549
- nextActions: []
4038
+ nextActions
3550
4039
  });
3551
4040
  return usage ? 2 : 1;
3552
4041
  }
4042
+ function editDistance(a, b) {
4043
+ const rows = a.length + 1;
4044
+ const cols = b.length + 1;
4045
+ const d = Array.from({ length: rows * cols }, () => 0);
4046
+ for (let i = 0; i < rows; i += 1) d[i * cols] = i;
4047
+ for (let j = 0; j < cols; j += 1) d[j] = j;
4048
+ for (let i = 1; i < rows; i += 1) for (let j = 1; j < cols; j += 1) {
4049
+ const substitution = a[i - 1] === b[j - 1] ? 0 : 1;
4050
+ d[i * cols + j] = Math.min(d[(i - 1) * cols + j] + 1, d[i * cols + j - 1] + 1, d[(i - 1) * cols + j - 1] + substitution);
4051
+ }
4052
+ return d[rows * cols - 1];
4053
+ }
4054
+ /** A misspelling is close (edit distance ≤ 2, and short paths tighter);
4055
+ * anything further is not a suggestion worth making. Every unknown
4056
+ * command at least learns where the command list is. */
4057
+ function unknownCommandActions(spec, state) {
4058
+ const attempted = [];
4059
+ for (const token of state.argv) {
4060
+ if (token.startsWith("-")) break;
4061
+ attempted.push(token);
4062
+ }
4063
+ const typed = attempted.join(" ");
4064
+ const candidates = new Set(Object.keys(spec.commands));
4065
+ for (const path of Object.keys(spec.commands)) {
4066
+ const segments = path.split(" ");
4067
+ for (let depth = 1; depth < segments.length; depth += 1) candidates.add(segments.slice(0, depth).join(" "));
4068
+ }
4069
+ return [...[...candidates].map((path) => ({
4070
+ path,
4071
+ distance: editDistance(typed, path)
4072
+ })).filter(({ path, distance }) => distance <= Math.max(path.length >= 8 ? 3 : 1, Math.min(2, path.length - 1))).sort((a, b) => a.distance - b.distance).slice(0, 3).map(({ path }) => ({
4073
+ kind: "run-command",
4074
+ label: "Did you mean",
4075
+ command: `${spec.name} ${path}`
4076
+ })), {
4077
+ kind: "run-command",
4078
+ label: "List every command",
4079
+ command: `${spec.name} --help`
4080
+ }];
4081
+ }
3553
4082
  //#endregion
3554
4083
  //#region src/execution/engine.ts
3555
4084
  function buildEngine(spec, options) {
@@ -3571,6 +4100,7 @@ function waitFor(ms, signal) {
3571
4100
  }
3572
4101
  var EngineImpl = class {
3573
4102
  spec;
4103
+ tree;
3574
4104
  root;
3575
4105
  redirects;
3576
4106
  now;
@@ -3581,20 +4111,25 @@ var EngineImpl = class {
3581
4111
  this.now = now;
3582
4112
  this.delay = delay;
3583
4113
  this.configSections = declaredConfigSections(spec);
3584
- this.root = buildRoutes(spec, buildCommandTree(spec), "", (invocation, entry, flags, values) => this.executeMounted(invocation, entry, flags, values));
4114
+ this.tree = buildCommandTree(spec);
4115
+ this.root = buildRoutes(spec, this.tree, "", (invocation, entry, flags, values) => this.executeMounted(invocation, entry, flags, values));
3585
4116
  this.redirects = buildRedirectTable(spec);
3586
4117
  }
3587
4118
  async execute(argv, runtime, hooks) {
4119
+ const format = sniffFormat(argv, runtime);
3588
4120
  const state = {
3589
4121
  commandId: "",
3590
4122
  docsBaseUrl: void 0,
3591
4123
  prefix: [],
3592
- format: sniffFormat(argv, runtime),
4124
+ format,
3593
4125
  logLevel: "info",
3594
4126
  yes: false,
3595
4127
  confirmValues: [],
3596
4128
  interactive: defaultInteractive(runtime),
3597
- colorEnabled: false,
4129
+ /** Pre-parse resolution so a run that never mounts a command — an
4130
+ * unknown command, a parse failure — still colours its
4131
+ * diagnostics; applySharedFlags re-resolves after parsing. */
4132
+ colorEnabled: preParseColorEnabled(argv, runtime, "stderr"),
3598
4133
  configPath: void 0,
3599
4134
  resolved: false,
3600
4135
  settledExitCode: void 0,
@@ -3650,6 +4185,15 @@ var EngineImpl = class {
3650
4185
  settleErrored(invocation, configFlagGivenNoValueError());
3651
4186
  return 2;
3652
4187
  }
4188
+ if (helpFlagGiven(argv) || bareGroupInvocation(this.tree, argv)) {
4189
+ unsubscribe();
4190
+ /** Help prose follows stricli's channel rule: stdout in human
4191
+ * mode, stderr in json mode so stdout stays a clean frame
4192
+ * stream. Never fires telemetry, like --version. */
4193
+ const stream = format === "human" ? runtime.stdout : runtime.stderr;
4194
+ renderHelp(this.spec, this.tree, argv, preParseColorEnabled(argv, runtime, format === "human" ? "stdout" : "stderr"), stream);
4195
+ return 0;
4196
+ }
3653
4197
  const stricliProcess = {
3654
4198
  /** stricli writes only help text here. In json mode stdout carries
3655
4199
  * exactly the frame stream, so help prose goes to stderr instead. */
@@ -4014,4 +4558,4 @@ function claimedIdentity(token) {
4014
4558
  };
4015
4559
  }
4016
4560
  //#endregion
4017
- export { flag as C, exitWithChildStatus as S, PRESENTED as _, CONFIG_FILE_NAME as a, writeUserConfig as b, PRISMA_CONFIG_VERSION as c, authServiceError as d, credentialRejectedError as f, noSessionForWorkspaceError as g, emptyServiceTokenError as h, buildEngine as i, SERVICE_TOKEN_ENV_VAR as l, credentialsRequiredError as m, claimedIdentity as n, defineConfig as o, credentialWorkspaceMismatchError as p, credentialWorkspaceId as r, loadConfig as s, claimedExpiresAt as t, WORKSPACE_ID_ENV_VAR as u, readUserConfig as v, positional as w, resolveGating as x, userConfigPath as y };
4561
+ export { exitWithChildStatus as C, resolveGating as S, positional as T, noSessionForWorkspaceError as _, CONFIG_FILE_NAME as a, userConfigPath as b, loadConfig as c, WORKSPACE_ID_ENV_VAR as d, authServiceError as f, emptyServiceTokenError as g, credentialsRequiredError as h, buildEngine as i, PRISMA_CONFIG_VERSION as l, credentialWorkspaceMismatchError as m, claimedIdentity as n, defineConfig as o, credentialRejectedError as p, credentialWorkspaceId as r, definePrismaConfig as s, claimedExpiresAt as t, SERVICE_TOKEN_ENV_VAR as u, PRESENTED as v, flag as w, writeUserConfig as x, readUserConfig as y };