@prisma/cli-engine 0.2.3 → 0.4.0

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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  The execution engine of the unified Prisma CLI: it owns the path from argv to exit code — parsing, execution, rendering, and error handling.
4
4
 
5
+ Every command describes its output once, as blocks, and the engine renders it in one of three formats chosen by `--format`: `human` for a person at a terminal (padded, aligned, coloured, on stderr, with the machine-usable data lines on stdout), `json` for a program (a stream of frames ending in a result envelope on stdout), and `markdown` for an agent that reads the output as text (plain Markdown with every value labelled, everything on stdout, nothing on stderr). A terminal gets `human` and a pipe gets `json` unless a format is named; `markdown` is only ever explicit.
6
+
5
7
  ## Entry points
6
8
 
7
9
  - `@prisma/cli-engine` — the engine: command definitions, context, and the runner.
@@ -1777,18 +1777,51 @@ function versionFlagGiven(argv) {
1777
1777
  function configFlagGivenNoValue(argv) {
1778
1778
  return flagTokens$1(argv).includes("--config=");
1779
1779
  }
1780
+ const FORMATS = [
1781
+ "human",
1782
+ "json",
1783
+ "markdown"
1784
+ ];
1785
+ function isFormat(value) {
1786
+ return value !== void 0 && FORMATS.includes(value);
1787
+ }
1788
+ /** argv with the format-selection tokens removed: `--json`,
1789
+ * `--format=<value>`, and `--format` with the value after it, only
1790
+ * when the value is a recognised format. Nothing after a bare `--` is
1791
+ * a flag, so the scan stops there and keeps the rest. */
1792
+ function withoutFormatFlags(argv) {
1793
+ const terminator = argv.indexOf("--");
1794
+ const tokens = terminator === -1 ? argv : argv.slice(0, terminator);
1795
+ const rest = terminator === -1 ? [] : argv.slice(terminator);
1796
+ const kept = [];
1797
+ for (let index = 0; index < tokens.length; index += 1) {
1798
+ const token = tokens[index];
1799
+ if (token === "--json") continue;
1800
+ if (token.startsWith("--format=") && isFormat(token.slice(9))) continue;
1801
+ if (token === "--format" && isFormat(tokens[index + 1])) {
1802
+ index += 1;
1803
+ continue;
1804
+ }
1805
+ kept.push(token);
1806
+ }
1807
+ return [...kept, ...rest];
1808
+ }
1780
1809
  /** The format requested by --json / --format / --format=<value>, if
1781
- * any. */
1810
+ * any. An explicit `--format` wins over `--json` whichever comes
1811
+ * first, as applySharedFlags decides it after parsing. */
1782
1812
  function formatFlagGiven(argv) {
1783
1813
  const tokens = flagTokens$1(argv);
1784
1814
  for (const [index, token] of tokens.entries()) {
1785
- if (token === "--json" || token === "--format=json") return "json";
1786
- if (token === "--format=human") return "human";
1815
+ if (token.startsWith("--format=")) {
1816
+ const value = token.slice(9);
1817
+ if (isFormat(value)) return value;
1818
+ }
1787
1819
  if (token === "--format") {
1788
1820
  const value = tokens[index + 1];
1789
- if (value === "json" || value === "human") return value;
1821
+ if (isFormat(value)) return value;
1790
1822
  }
1791
1823
  }
1824
+ return tokens.includes("--json") ? "json" : void 0;
1792
1825
  }
1793
1826
  //#endregion
1794
1827
  //#region src/execution/shared-flags.ts
@@ -1818,7 +1851,11 @@ const RESERVED_ALIASES = new Set([
1818
1851
  const SHARED_FLAG_PARAMETERS = {
1819
1852
  format: {
1820
1853
  kind: "enum",
1821
- values: ["human", "json"],
1854
+ values: [
1855
+ "human",
1856
+ "json",
1857
+ "markdown"
1858
+ ],
1822
1859
  optional: true,
1823
1860
  brief: "Output format"
1824
1861
  },
@@ -1916,7 +1953,7 @@ function applySharedFlags(state, shared, runtime) {
1916
1953
  state.confirmValues = [...shared.confirm ?? []];
1917
1954
  state.interactive = shared.interactive ?? defaultInteractive(runtime);
1918
1955
  state.logLevel = resolveLogLevel(shared);
1919
- state.colorEnabled = resolveColorEnabled(shared, runtime);
1956
+ state.colorEnabled = state.format === "markdown" ? false : resolveColorEnabled(shared, runtime);
1920
1957
  state.configPath = shared.config;
1921
1958
  }
1922
1959
  /**
@@ -2240,16 +2277,21 @@ function renderEventHuman(invocation, event) {
2240
2277
  return;
2241
2278
  case "remediation": return;
2242
2279
  case "endpoint":
2243
- stderr.write(`${event.name}: ${event.url}\n`);
2244
- return;
2245
2280
  case "status":
2246
- stderr.write(`${event.subject}: ${event.from === void 0 ? "" : `${event.from} → `}${event.status}\n`);
2247
- return;
2248
2281
  case "artifact":
2249
- stderr.write(`${event.path}${event.description === void 0 ? "" : ` — ${event.description}`}\n`);
2282
+ stderr.write(`${commentaryLine(event)}\n`);
2250
2283
  return;
2251
2284
  }
2252
2285
  }
2286
+ /** The one line an endpoint, status, or artifact event prints, in
2287
+ * every text format. */
2288
+ function commentaryLine(event) {
2289
+ switch (event.kind) {
2290
+ case "endpoint": return `${event.name}: ${event.url}`;
2291
+ case "status": return `${event.subject}: ${event.from === void 0 ? "" : `${event.from} → `}${event.status}`;
2292
+ case "artifact": return `${event.path}${event.description === void 0 ? "" : ` — ${event.description}`}`;
2293
+ }
2294
+ }
2253
2295
  /**
2254
2296
  * The four Status glyphs. The step-outcome map above and the
2255
2297
  * diagnostic-severity map below answer different questions, but the
@@ -2334,7 +2376,7 @@ function toned(text, tone) {
2334
2376
  function writeFields(rows, rail, paint, write) {
2335
2377
  const cells = rows.map((row) => ({
2336
2378
  label: toned(extend(row.label, ":"), "heading"),
2337
- value: row.sensitive === true ? MASK : orPlaceholder(row.value)
2379
+ value: row.sensitive === true ? MASK : orPlaceholder$1(row.value)
2338
2380
  }));
2339
2381
  const width = Math.max(0, ...cells.map((cell) => textWidth(cell.label)));
2340
2382
  const prefix = rail ? `${paint("structure", RAIL$1)}${COLUMN_GAP}` : "";
@@ -2351,17 +2393,16 @@ function sentenceCase(text) {
2351
2393
  if (typeof text !== "string" || text === "") return text;
2352
2394
  return `${text[0].toUpperCase()}${text.slice(1)}`;
2353
2395
  }
2354
- const PLACEHOLDER = "—";
2355
2396
  /** An absent value renders as a dim em dash rather than invented prose
2356
2397
  * ("none", "n/a") in data tone. */
2357
- function orPlaceholder(cell) {
2398
+ function orPlaceholder$1(cell) {
2358
2399
  return cell === "" || typeof cell !== "string" && textWidth(cell) === 0 ? [{
2359
- text: PLACEHOLDER,
2400
+ text: "—",
2360
2401
  tone: "placeholder"
2361
2402
  }] : cell;
2362
2403
  }
2363
2404
  function writeTable(columns, rows, paint, write) {
2364
- const all = [columns.map((column) => toned(sentenceCase(column), "heading")), ...rows.map((row) => row.map(orPlaceholder))];
2405
+ const all = [columns.map((column) => toned(sentenceCase(column), "heading")), ...rows.map((row) => row.map(orPlaceholder$1))];
2365
2406
  const widths = [];
2366
2407
  for (const row of all) for (const [index, cell] of row.entries()) widths[index] = Math.max(widths[index] ?? 0, textWidth(cell));
2367
2408
  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, ""));
@@ -2463,6 +2504,184 @@ function renderCompletedHuman(invocation, presented) {
2463
2504
  writeSections(sections, runtime.stderr);
2464
2505
  if (!(runtime.isTty.stdout && runtime.isTty.stderr && runtime.outputStreamsShareDevice !== false)) for (const line of presented.presentation.stdout) runtime.stdout.write(`${line}\n`);
2465
2506
  }
2507
+ //#endregion
2508
+ //#region src/execution/markdown.ts
2509
+ const BACKSLASH = /\\/g;
2510
+ const PIPE = /\|/g;
2511
+ const NEWLINE = /\n/g;
2512
+ const BACKTICK_RUN = /`+/g;
2513
+ function longestBacktickRun(text) {
2514
+ let longest = 0;
2515
+ for (const run of text.match(BACKTICK_RUN) ?? []) longest = Math.max(longest, run.length);
2516
+ return longest;
2517
+ }
2518
+ /** An inline code span whose delimiter is one backtick longer than any
2519
+ * run inside it, padded when the content starts or ends with one. */
2520
+ function codeSpan(text) {
2521
+ const delimiter = "`".repeat(longestBacktickRun(text) + 1);
2522
+ return `${delimiter}${text.startsWith("`") || text.endsWith("`") ? ` ${text} ` : text}${delimiter}`;
2523
+ }
2524
+ /** A fenced block whose fence is one backtick longer than any run in
2525
+ * its lines, and at least three. */
2526
+ function fenced(lines, language = "") {
2527
+ const longest = Math.max(0, ...lines.map(longestBacktickRun));
2528
+ const delimiter = "`".repeat(Math.max(3, longest + 1));
2529
+ return [
2530
+ `${delimiter}${language}`,
2531
+ ...lines,
2532
+ delimiter
2533
+ ];
2534
+ }
2535
+ function orPlaceholder(text) {
2536
+ const plain = plainText(text);
2537
+ return plain === "" ? "—" : plain;
2538
+ }
2539
+ /**
2540
+ * Plain Markdown, for a reader that is a model rather than a terminal:
2541
+ * every value labelled, nothing padded, wrapped, aligned, or coloured.
2542
+ */
2543
+ function renderBlockMarkdown(block) {
2544
+ switch (block.kind) {
2545
+ case "summary": return [`[${block.status}] ${plainText(block.text)}`];
2546
+ case "fields": return block.rows.map((row) => `${plainText(row.label)}: ${row.sensitive === true ? MASK : orPlaceholder(row.value)}`);
2547
+ case "table": return renderTable(block.columns, block.rows);
2548
+ case "list": return block.items.map((item) => `- ${plainText(item)}`);
2549
+ case "tree": return block.roots.flatMap((root) => renderTreeNode(root, 0));
2550
+ case "drawing": return fenced(block.lines.map(plainText));
2551
+ }
2552
+ }
2553
+ function escapeCell(text) {
2554
+ return text.replace(BACKSLASH, "\\\\").replace(PIPE, "\\|").replace(NEWLINE, " ");
2555
+ }
2556
+ function cell(text) {
2557
+ return escapeCell(orPlaceholder(text));
2558
+ }
2559
+ function pipeRow(cells) {
2560
+ return `| ${cells.join(" | ")} |`;
2561
+ }
2562
+ function renderTable(columns, rows) {
2563
+ const lines = [
2564
+ pipeRow(columns.map((column) => cell(sentenceCase(column)))),
2565
+ pipeRow(columns.map(() => "---")),
2566
+ ...rows.map((row) => pipeRow(row.map(cell)))
2567
+ ];
2568
+ return rows.length === 0 ? [...lines, "(no rows)"] : lines;
2569
+ }
2570
+ function renderTreeNode(node, depth) {
2571
+ const indent = " ".repeat(depth);
2572
+ const label = plainText(node.label);
2573
+ return [node.status === void 0 ? `${indent}- ${label}` : `${indent}- [${node.status}] ${label}`, ...(node.children ?? []).flatMap((child) => renderTreeNode(child, depth + 1))];
2574
+ }
2575
+ function renderNextActionMarkdown(action) {
2576
+ const target = action.command ?? action.url;
2577
+ if (target === void 0 && action.commands !== void 0) return [`- ${action.label}`, ...action.commands.map((command) => ` - ${codeSpan(command)}`)];
2578
+ if (target === void 0 || target === action.label) return [action.command !== void 0 ? `- ${codeSpan(action.label)}` : `- ${action.label}`];
2579
+ return [action.command !== void 0 ? `- ${action.label}: ${codeSpan(target)}` : `- ${action.label}: ${target}`];
2580
+ }
2581
+ function whereLine(where) {
2582
+ if (where === void 0) return;
2583
+ if (where.path !== void 0 && where.line !== void 0) return `where: ${where.path}:${where.line}`;
2584
+ if (where.path !== void 0) return `where: ${where.path}`;
2585
+ if (where.line !== void 0) return `where: line ${where.line}`;
2586
+ }
2587
+ function renderDiagnosticMarkdown(diagnostic) {
2588
+ const lines = [`[${diagnostic.severity}] ${diagnostic.code}: ${diagnostic.summary}`];
2589
+ if (diagnostic.why !== void 0) lines.push(`why: ${diagnostic.why}`);
2590
+ const where = whereLine(diagnostic.where);
2591
+ if (where !== void 0) lines.push(where);
2592
+ for (const action of diagnostic.nextActions) lines.push(...renderNextActionMarkdown(action));
2593
+ if (diagnostic.docsUrl !== void 0) lines.push(`docs: ${diagnostic.docsUrl}`);
2594
+ return lines;
2595
+ }
2596
+ /** Joins sections with one blank line each, dropping empty ones, and
2597
+ * ends with exactly one newline; nothing when there is nothing. */
2598
+ function joinSections(sections) {
2599
+ const kept = sections.filter((section) => section.length > 0);
2600
+ if (kept.length === 0) return "";
2601
+ return `${kept.map((section) => section.join("\n")).join("\n\n")}\n`;
2602
+ }
2603
+ function diagnosticsSection(diagnostics) {
2604
+ if (diagnostics.length === 0) return [];
2605
+ return ["### Diagnostics", ...diagnostics.flatMap((diagnostic, index) => [...index === 0 ? [] : [""], ...renderDiagnosticMarkdown(diagnostic)])];
2606
+ }
2607
+ /** Everything on stdout: the blocks, then `### Next`, then
2608
+ * `### Diagnostics`. The `stdout` presentation lines are never
2609
+ * printed; the table already carries them. */
2610
+ function renderCompletedMarkdown(invocation, presented) {
2611
+ const { runtime, state } = invocation;
2612
+ const sections = presented.presentation.human.map(renderBlockMarkdown);
2613
+ if (presented.presentation.next.length > 0) sections.push(["### Next", ...presented.presentation.next.flatMap(renderNextActionMarkdown)]);
2614
+ sections.push(diagnosticsSection(presented.diagnostics.map((diagnostic) => withDocsUrl(state, diagnostic))));
2615
+ runtime.stdout.write(joinSections(sections));
2616
+ }
2617
+ /** The error in the diagnostic shape, then the accompanying findings
2618
+ * under `### Diagnostics`. The envelope's top-level `nextActions`
2619
+ * duplicate the error's and are not printed again. */
2620
+ function renderErroredMarkdown(invocation, envelope) {
2621
+ invocation.runtime.stdout.write(joinSections([renderDiagnosticMarkdown(envelope.error), diagnosticsSection(envelope.diagnostics)]));
2622
+ }
2623
+ /** Config-section warnings of an OK run, ahead of whatever the run
2624
+ * prints next, with one blank line between. */
2625
+ function renderWarningsMarkdown(invocation, diagnostics) {
2626
+ const section = joinSections(diagnostics.map(renderDiagnosticMarkdown));
2627
+ if (section !== "") invocation.runtime.stdout.write(`${section}\n`);
2628
+ }
2629
+ function renderChildNextActionsMarkdown(invocation, actions) {
2630
+ invocation.runtime.stdout.write(joinSections([actions.flatMap(renderNextActionMarkdown)]));
2631
+ }
2632
+ /** One line per event on stdout as it happens. A step starting, its
2633
+ * progress, and a remediation are not printed. */
2634
+ function renderEventMarkdown(invocation, event) {
2635
+ const { stdout } = invocation.runtime;
2636
+ switch (event.kind) {
2637
+ case "message":
2638
+ stdout.write(`${event.text}\n`);
2639
+ return;
2640
+ case "output":
2641
+ stdout.write(`${event.line}\n`);
2642
+ return;
2643
+ case "step-finished":
2644
+ stdout.write(`[${event.outcome}] ${event.step}\n`);
2645
+ return;
2646
+ case "endpoint":
2647
+ case "status":
2648
+ case "artifact":
2649
+ stdout.write(`${commentaryLine(event)}\n`);
2650
+ return;
2651
+ case "step-started":
2652
+ case "progress":
2653
+ case "remediation": return;
2654
+ }
2655
+ }
2656
+ function parenthesized(suffix) {
2657
+ return suffix.startsWith("(") ? suffix : `(${suffix})`;
2658
+ }
2659
+ function helpTable(headers, rows) {
2660
+ return [
2661
+ pipeRow(headers),
2662
+ pipeRow(["---", "---"]),
2663
+ ...rows.map((row) => pipeRow([escapeCell(codeSpan(row.name.trimStart())), escapeCell(row.suffix === void 0 || row.suffix === "" ? row.brief : `${row.brief} ${parenthesized(row.suffix)}`)]))
2664
+ ];
2665
+ }
2666
+ function helpSection(heading, headers, rows) {
2667
+ return rows.length === 0 ? [] : [[`## ${heading}`], helpTable(headers, rows)];
2668
+ }
2669
+ /** The help card as Markdown: headings, paragraphs, pipe tables, and
2670
+ * bash fences, one blank line between everything. */
2671
+ function renderHelpMarkdown(card) {
2672
+ const sections = [[`# ${card.name}`]];
2673
+ if (card.tagline !== void 0 && card.tagline !== "") sections.push([card.tagline]);
2674
+ if (card.usage !== void 0) sections.push(["## Usage"], fenced([card.usage], "bash"));
2675
+ if (card.description !== void 0) sections.push([card.description]);
2676
+ sections.push(...helpSection("Commands", ["Command", "Description"], card.commands), ...helpSection("Workflow", ["Run", "Purpose"], card.workflow.map((step) => ({
2677
+ name: step.run,
2678
+ brief: step.brief
2679
+ }))), ...helpSection("Arguments", ["Argument", "Description"], card.arguments), ...helpSection("Options", ["Flag", "Description"], card.options), ...helpSection("Global options", ["Flag", "Description"], card.globalOptions));
2680
+ if (card.note !== void 0) sections.push([card.note]);
2681
+ if (card.examples.length > 0) sections.push(["## Examples"], fenced(card.examples, "bash"));
2682
+ if (card.docsUrl !== void 0) sections.push([`Docs: ${card.docsUrl}`]);
2683
+ return joinSections(sections);
2684
+ }
2466
2685
  const SEVERITY_RANK = {
2467
2686
  error: 0,
2468
2687
  warn: 1,
@@ -2509,6 +2728,10 @@ function reportEvent(invocation, event) {
2509
2728
  });
2510
2729
  return;
2511
2730
  }
2731
+ if (state.format === "markdown") {
2732
+ renderEventMarkdown(invocation, event);
2733
+ return;
2734
+ }
2512
2735
  renderEventHuman(invocation, event);
2513
2736
  }
2514
2737
  function flushBufferedEvents(invocation, terminal) {
@@ -2695,10 +2918,12 @@ function validateConfigSection(section, loaded, invocation, configFile) {
2695
2918
  * or the envelope. */
2696
2919
  function writeSectionWarnings(invocation, diagnostics) {
2697
2920
  const state = invocation.state;
2698
- for (const diagnostic of diagnostics) {
2699
- if (SEVERITY_RANK[diagnostic.severity] > SEVERITY_RANK[state.logLevel]) continue;
2700
- writeDiagnostic(invocation.runtime.stderr, withDocsUrl(state, diagnostic), makePaint(state.colorEnabled));
2921
+ const shown = diagnostics.filter((diagnostic) => SEVERITY_RANK[diagnostic.severity] <= SEVERITY_RANK[state.logLevel]).map((diagnostic) => withDocsUrl(state, diagnostic));
2922
+ if (state.format === "markdown") {
2923
+ renderWarningsMarkdown(invocation, shown);
2924
+ return;
2701
2925
  }
2926
+ for (const diagnostic of shown) writeDiagnostic(invocation.runtime.stderr, diagnostic, makePaint(state.colorEnabled));
2702
2927
  }
2703
2928
  function dependencyResolvable(specifier, cwd) {
2704
2929
  try {
@@ -3543,10 +3768,18 @@ function availableWidth(stream) {
3543
3768
  * are stderr's. `width` is a getter because the contract reads it per
3544
3769
  * render rather than caching it. */
3545
3770
  function makeUi(colorEnabled, stderr) {
3771
+ return uiWith(colorEnabled, () => availableWidth(stderr));
3772
+ }
3773
+ /** Markdown is read as text, never on a terminal: no colour, no
3774
+ * width. */
3775
+ function unboundedUi() {
3776
+ return uiWith(false, () => Number.POSITIVE_INFINITY);
3777
+ }
3778
+ function uiWith(colorEnabled, width) {
3546
3779
  const paint = makePaint(colorEnabled);
3547
3780
  return {
3548
3781
  get width() {
3549
- return availableWidth(stderr);
3782
+ return width();
3550
3783
  },
3551
3784
  emphasize: (text) => paint("emphasis", text),
3552
3785
  dim: (text) => paint("muted", text),
@@ -3582,6 +3815,12 @@ function materializePresentation(state, ui, presentations) {
3582
3815
  json: presentations.json(),
3583
3816
  next: presentations.next?.() ?? []
3584
3817
  };
3818
+ if (state.format === "markdown") return {
3819
+ human: presentations.human(ui),
3820
+ stdout: [],
3821
+ json: void 0,
3822
+ next: presentations.next?.() ?? []
3823
+ };
3585
3824
  return {
3586
3825
  human: presentations.human(ui),
3587
3826
  stdout: presentations.stdout?.() ?? [],
@@ -3591,7 +3830,7 @@ function materializePresentation(state, ui, presentations) {
3591
3830
  }
3592
3831
  function makeContext(invocation, def, config, capabilities) {
3593
3832
  const state = invocation.state;
3594
- const ui = makeUi(state.colorEnabled, invocation.runtime.stderr);
3833
+ const ui = state.format === "markdown" ? unboundedUi() : makeUi(state.colorEnabled, invocation.runtime.stderr);
3595
3834
  const present = (outcome, presentations) => {
3596
3835
  if (state.delegatedTerminal !== void 0) throw constructionError(`command '${state.commandId}' called ctx.present while a child owned the terminal`);
3597
3836
  const exitCode = outcome.exitCode ?? 0;
@@ -3939,6 +4178,7 @@ function helpFlagGiven(argv) {
3939
4178
  * render through this; applySharedFlags re-resolves once a command
3940
4179
  * actually parses. */
3941
4180
  function preParseColorEnabled(argv, runtime, stream) {
4181
+ if (formatFlagGiven(argv) === "markdown") return false;
3942
4182
  const tokens = flagTokens(argv);
3943
4183
  if (tokens.includes("--no-color")) return false;
3944
4184
  if (tokens.includes("--color")) return true;
@@ -3986,27 +4226,123 @@ function resolveTarget(root, segments) {
3986
4226
  * is a help request; anything carrying flags or extra tokens is not —
3987
4227
  * `cli --unknown` and `cli project --frobnicate` must reach routing
3988
4228
  * and usage validation, not exit 0 with a help card. A bare leaf is a
3989
- * command run and is left alone. */
3990
- function bareGroupInvocation(root, argv) {
4229
+ * command run and is left alone. The format-selection flags do not
4230
+ * count: `cli project --format markdown` asks for the group's help in
4231
+ * Markdown. */
4232
+ function bareGroupInvocation(root, rawArgv) {
4233
+ const argv = withoutFormatFlags(rawArgv);
3991
4234
  const segments = helpPath(argv);
3992
4235
  if (segments.length !== argv.length) return false;
3993
4236
  if (segments.length === 0) return true;
3994
4237
  const { target, path } = resolveTarget(root, segments);
3995
4238
  return target.kind === "node" && path.length === segments.length;
3996
4239
  }
3997
- function renderHelp(spec, root, argv, colorEnabled, out) {
3998
- const paint = makePaint(colorEnabled);
4240
+ function renderHelp(spec, root, argv, options, out) {
4241
+ const card = helpCard(spec, root, argv);
4242
+ if (options.format === "markdown") {
4243
+ out.write(renderHelpMarkdown(card));
4244
+ return;
4245
+ }
4246
+ out.write(renderHelpTerminal(card, makePaint(options.colorEnabled)));
4247
+ }
4248
+ function helpCard(spec, root, argv) {
3999
4249
  const { target, path } = resolveTarget(root, helpPath(argv));
4250
+ return target.kind === "leaf" ? leafCard(spec, target.entry, path) : nodeCard(spec, target.node, path);
4251
+ }
4252
+ function nodeCard(spec, node, path) {
4253
+ const atRoot = path.length === 0;
4254
+ const groupPath = path.join(" ");
4255
+ const group = spec.groups[groupPath];
4256
+ return {
4257
+ kind: atRoot ? "root" : "group",
4258
+ name: [spec.name, ...path].join(" "),
4259
+ tagline: atRoot ? spec.help?.tagline : group?.brief,
4260
+ usage: void 0,
4261
+ description: atRoot ? spec.help?.description : group?.description,
4262
+ commands: nodeRows(spec, node, path),
4263
+ workflow: resolvedSteps((atRoot ? spec.help?.workflow : group?.workflow) ?? [], spec.name),
4264
+ arguments: [],
4265
+ options: [],
4266
+ globalOptions: atRoot ? sharedFlagRows() : [],
4267
+ note: atRoot ? void 0 : `Run '${spec.name} ${groupPath} <command> --help' for details on a command.`,
4268
+ examples: resolvedExamples(atRoot ? spec.help?.examples : [], spec.name),
4269
+ docsUrl: atRoot ? spec.help?.docsUrl : void 0
4270
+ };
4271
+ }
4272
+ function leafCard(spec, entry, path) {
4273
+ const def = entry.def;
4274
+ const usage = [
4275
+ spec.name,
4276
+ ...path,
4277
+ requiredFlagUsage(def),
4278
+ "[options]",
4279
+ positionalUsage(def)
4280
+ ].filter((part) => part !== "").join(" ");
4281
+ const sharedNames = Object.keys(SHARED_FLAG_PARAMETERS).map((key) => `--${kebabCase(key)}`).join(", ");
4282
+ return {
4283
+ kind: "leaf",
4284
+ name: [spec.name, ...path].join(" "),
4285
+ tagline: def.help.summary,
4286
+ usage,
4287
+ description: def.help.description,
4288
+ commands: [],
4289
+ workflow: [],
4290
+ arguments: Object.values(def.args.positionals).map((spec) => positionalRuntime(spec)).map((runtime) => ({
4291
+ name: runtime.placeholder,
4292
+ brief: runtime.brief,
4293
+ suffix: runtime.type === "optionalString" ? "(optional)" : void 0
4294
+ })),
4295
+ options: declaredFlagRows(def),
4296
+ globalOptions: [],
4297
+ note: def.kind === "server-command" ? void 0 : `Global options also apply: ${sharedNames}. Run '${spec.name} --help' for details.`,
4298
+ examples: resolvedExamples(def.help.examples, spec.name),
4299
+ docsUrl: entry.docsBaseUrl
4300
+ };
4301
+ }
4302
+ function resolvedSteps(steps, cliName) {
4303
+ return steps.map((step) => ({
4304
+ run: resolveExample(step.run, cliName),
4305
+ brief: step.brief
4306
+ }));
4307
+ }
4308
+ function resolvedExamples(examples, cliName) {
4309
+ return (examples ?? []).map((example) => resolveExample(example, cliName));
4310
+ }
4311
+ function renderHelpTerminal(card, paint) {
4000
4312
  const lines = [];
4001
- if (target.kind === "leaf") renderLeafHelp(spec, target.entry, path, paint, lines);
4002
- else renderNodeHelp(spec, target.node, path, paint, lines);
4003
- out.write(`${lines.join("\n")}\n`);
4313
+ lines.push(header(card, paint));
4314
+ lines.push("");
4315
+ if (card.kind === "leaf") {
4316
+ lines.push(sectionLabel(paint, "Usage"));
4317
+ lines.push(rail(paint, `${GAP}${paint("muted", "$")} ${paint("emphasis", card.usage ?? "")}`));
4318
+ } else railRows(card.commands, paint, lines);
4319
+ if (card.description !== void 0) {
4320
+ lines.push(rail(paint));
4321
+ proseLines(card.description, paint, lines);
4322
+ }
4323
+ workflowLines(card.workflow, paint, lines);
4324
+ rowSection("Arguments", card.arguments, paint, lines);
4325
+ rowSection("Options", card.options, paint, lines);
4326
+ if (card.kind === "root") {
4327
+ lines.push(rail(paint));
4328
+ lines.push(sectionLabel(paint, "Global options"));
4329
+ railRows(card.globalOptions, paint, lines);
4330
+ }
4331
+ if (card.note !== void 0) {
4332
+ lines.push(rail(paint));
4333
+ if (card.kind === "leaf") proseLines(card.note, paint, lines, "muted");
4334
+ else lines.push(rail(paint, paint("muted", card.note)));
4335
+ }
4336
+ exampleLines(card.examples, paint, lines);
4337
+ docsLine(card.docsUrl, paint, lines);
4338
+ lines.push("");
4339
+ return `${lines.join("\n")}\n`;
4004
4340
  }
4005
4341
  /** `prisma-cli project → Manage and inspect your Prisma projects` */
4006
- function header(spec, path, tagline, paint) {
4007
- const name = paint("emphasis", [spec.name, ...path].join(" "));
4008
- if (tagline === void 0 || tagline === "") return name;
4009
- return `${name} ${paint("muted", `→ ${tagline}`)}`;
4342
+ function header(card, paint) {
4343
+ const name = paint("emphasis", card.name);
4344
+ if (card.tagline === void 0 || card.tagline === "") return name;
4345
+ return `${name} ${paint("muted", `→ ${card.tagline}`)}`;
4010
4346
  }
4011
4347
  function rail(paint, rest = "") {
4012
4348
  return rest === "" ? paint("structure", RAIL) : `${paint("structure", RAIL)}${GAP}${rest}`;
@@ -4014,6 +4350,12 @@ function rail(paint, rest = "") {
4014
4350
  function sectionLabel(paint, label) {
4015
4351
  return rail(paint, paint("muted", label));
4016
4352
  }
4353
+ function rowSection(label, rows, paint, lines) {
4354
+ if (rows.length === 0) return;
4355
+ lines.push(rail(paint));
4356
+ lines.push(sectionLabel(paint, label));
4357
+ railRows(rows, paint, lines);
4358
+ }
4017
4359
  /** Two-column rows under the rail: name in the accent, brief plain. */
4018
4360
  function railRows(rows, paint, lines) {
4019
4361
  const width = Math.max(0, ...rows.map((row) => textWidth(row.name)));
@@ -4042,11 +4384,23 @@ function wrap(text, width) {
4042
4384
  function proseLines(text, paint, lines, tone = "plain") {
4043
4385
  for (const line of wrap(text, WRAP_WIDTH)) lines.push(rail(paint, tone === "muted" ? paint("muted", line) : line));
4044
4386
  }
4045
- function exampleLines(examples, cliName, paint, lines) {
4387
+ function exampleLines(examples, paint, lines) {
4046
4388
  if (examples.length === 0) return;
4047
4389
  lines.push(rail(paint));
4048
4390
  lines.push(sectionLabel(paint, "Examples"));
4049
- for (const example of examples) lines.push(rail(paint, `${GAP}${paint("muted", "$")} ${resolveExample(example, cliName)}`));
4391
+ for (const example of examples) lines.push(rail(paint, `${GAP}${paint("muted", "$")} ${example}`));
4392
+ }
4393
+ /** The group's common path: `$`-prefixed copy-pastable steps in mount
4394
+ * order, purpose column muted, aligned like every other row block. */
4395
+ function workflowLines(steps, paint, lines) {
4396
+ if (steps.length === 0) return;
4397
+ lines.push(rail(paint));
4398
+ lines.push(sectionLabel(paint, "Workflow"));
4399
+ const width = Math.max(...steps.map((step) => textWidth(step.run)));
4400
+ for (const step of steps) {
4401
+ const pad = " ".repeat(width - textWidth(step.run));
4402
+ lines.push(rail(paint, `${GAP}${paint("muted", "$")} ${step.run}${pad}${GAP}${paint("muted", step.brief)}`));
4403
+ }
4050
4404
  }
4051
4405
  function docsLine(url, paint, lines) {
4052
4406
  if (url === void 0) return;
@@ -4147,78 +4501,12 @@ function nodeRows(spec, node, path) {
4147
4501
  }
4148
4502
  return rows;
4149
4503
  }
4150
- function renderNodeHelp(spec, node, path, paint, lines) {
4151
- const atRoot = path.length === 0;
4152
- const groupPath = path.join(" ");
4153
- const tagline = atRoot ? spec.help?.tagline : spec.groups[groupPath]?.brief;
4154
- lines.push(header(spec, path, tagline, paint));
4155
- lines.push("");
4156
- railRows(nodeRows(spec, node, path), paint, lines);
4157
- const description = atRoot ? spec.help?.description : spec.groups[groupPath]?.description;
4158
- if (description !== void 0) {
4159
- lines.push(rail(paint));
4160
- proseLines(description, paint, lines);
4161
- }
4162
- if (atRoot) {
4163
- lines.push(rail(paint));
4164
- lines.push(sectionLabel(paint, "Global options"));
4165
- railRows(sharedFlagRows(), paint, lines);
4166
- exampleLines(spec.help?.examples ?? [], spec.name, paint, lines);
4167
- docsLine(spec.help?.docsUrl, paint, lines);
4168
- } else {
4169
- lines.push(rail(paint));
4170
- lines.push(rail(paint, paint("muted", `Run '${spec.name} ${groupPath} <command> --help' for details on a command.`)));
4171
- }
4172
- lines.push("");
4173
- }
4174
4504
  /** `link [id-or-name]` — the row a group lists for a leaf: name plus
4175
4505
  * positional shape, briefs carry the rest. */
4176
4506
  function usageName(name, def) {
4177
4507
  const positionals = positionalUsage(def);
4178
4508
  return positionals === "" ? name : `${name} ${positionals}`;
4179
4509
  }
4180
- function renderLeafHelp(spec, entry, path, paint, lines) {
4181
- const def = entry.def;
4182
- lines.push(header(spec, path, def.help.summary, paint));
4183
- lines.push("");
4184
- const usageParts = [
4185
- spec.name,
4186
- ...path,
4187
- requiredFlagUsage(def),
4188
- "[options]",
4189
- positionalUsage(def)
4190
- ].filter((part) => part !== "");
4191
- lines.push(sectionLabel(paint, "Usage"));
4192
- lines.push(rail(paint, `${GAP}${paint("muted", "$")} ${paint("emphasis", usageParts.join(" "))}`));
4193
- if (def.help.description !== void 0) {
4194
- lines.push(rail(paint));
4195
- proseLines(def.help.description, paint, lines);
4196
- }
4197
- const positionalEntries = Object.values(def.args.positionals).map((spec) => positionalRuntime(spec));
4198
- if (positionalEntries.length > 0) {
4199
- lines.push(rail(paint));
4200
- lines.push(sectionLabel(paint, "Arguments"));
4201
- railRows(positionalEntries.map((runtime) => ({
4202
- name: runtime.placeholder,
4203
- brief: runtime.brief,
4204
- suffix: runtime.type === "optionalString" ? "(optional)" : void 0
4205
- })), paint, lines);
4206
- }
4207
- const flagRows = declaredFlagRows(def);
4208
- if (flagRows.length > 0) {
4209
- lines.push(rail(paint));
4210
- lines.push(sectionLabel(paint, "Options"));
4211
- railRows(flagRows, paint, lines);
4212
- }
4213
- if (def.kind !== "server-command") {
4214
- const sharedNames = [...Object.keys(SHARED_FLAG_PARAMETERS).map((key) => `--${kebabCase(key)}`)].join(", ");
4215
- lines.push(rail(paint));
4216
- proseLines(`Global options also apply: ${sharedNames}. Run '${spec.name} --help' for details.`, paint, lines, "muted");
4217
- }
4218
- exampleLines(def.help.examples, spec.name, paint, lines);
4219
- docsLine(entry.docsBaseUrl, paint, lines);
4220
- lines.push("");
4221
- }
4222
4510
  //#endregion
4223
4511
  //#region src/execution/settlement.ts
4224
4512
  function undocumentedExitCode(def, exitCode) {
@@ -4256,6 +4544,10 @@ function settleCompleted(invocation, def, presented) {
4256
4544
  });
4257
4545
  return;
4258
4546
  }
4547
+ if (state.format === "markdown") {
4548
+ renderCompletedMarkdown(invocation, presented);
4549
+ return;
4550
+ }
4259
4551
  renderCompletedHuman(invocation, presented);
4260
4552
  }
4261
4553
  function diagnosticOf(error) {
@@ -4365,9 +4657,17 @@ function settleChildStatus(invocation, def, settlement) {
4365
4657
  settleStructuredChildStatus(invocation, settlement, child, exitCode);
4366
4658
  return;
4367
4659
  }
4368
- if (child.signal === null) for (const action of settlement.nextActions) invocation.runtime.stderr.write(`${renderNextAction(action, makePaint(invocation.state.colorEnabled))}\n`);
4660
+ if (child.signal === null) renderChildNextActions(invocation, settlement.nextActions);
4369
4661
  settleVerbatimExitCode(invocation, exitCode);
4370
4662
  }
4663
+ function renderChildNextActions(invocation, actions) {
4664
+ if (invocation.state.format === "markdown") {
4665
+ renderChildNextActionsMarkdown(invocation, actions);
4666
+ return;
4667
+ }
4668
+ const paint = makePaint(invocation.state.colorEnabled);
4669
+ for (const action of actions) invocation.runtime.stderr.write(`${renderNextAction(action, paint)}\n`);
4670
+ }
4371
4671
  function settleStructuredChildStatus(invocation, settlement, child, exitCode) {
4372
4672
  settleVerbatimExitCode(invocation, exitCode);
4373
4673
  const nextActions = child.signal === null ? settlement.nextActions : [];
@@ -4461,6 +4761,10 @@ function emitErrored(invocation, raw) {
4461
4761
  });
4462
4762
  return;
4463
4763
  }
4764
+ if (state.format === "markdown") {
4765
+ renderErroredMarkdown(invocation, envelope);
4766
+ return;
4767
+ }
4464
4768
  const paint = makePaint(invocation.state.colorEnabled);
4465
4769
  writeSections([envelope.error, ...envelope.diagnostics].map((diagnostic) => diagnosticSection(diagnostic, paint)), invocation.runtime.stderr);
4466
4770
  }
@@ -4468,7 +4772,7 @@ function emitErrored(invocation, raw) {
4468
4772
  * version travels as the run's single result frame. */
4469
4773
  function settleVersion(spec, invocation) {
4470
4774
  const { runtime, state } = invocation;
4471
- if (state.format === "human") {
4775
+ if (state.format !== "json") {
4472
4776
  runtime.stdout.write(`${spec.version}\n`);
4473
4777
  return 0;
4474
4778
  }
@@ -4707,14 +5011,17 @@ var EngineImpl = class {
4707
5011
  /** Help prose follows stricli's channel rule: stdout in human
4708
5012
  * mode, stderr in json mode so stdout stays a clean frame
4709
5013
  * stream. Never fires telemetry, like --version. */
4710
- const stream = format === "human" ? runtime.stdout : runtime.stderr;
4711
- renderHelp(this.spec, this.tree, argv, preParseColorEnabled(argv, runtime, format === "human" ? "stdout" : "stderr"), stream);
5014
+ const stream = format === "json" ? runtime.stderr : runtime.stdout;
5015
+ renderHelp(this.spec, this.tree, argv, {
5016
+ format,
5017
+ colorEnabled: preParseColorEnabled(argv, runtime, format === "json" ? "stderr" : "stdout")
5018
+ }, stream);
4712
5019
  return 0;
4713
5020
  }
4714
5021
  const stricliProcess = {
4715
5022
  /** stricli writes only help text here. In json mode stdout carries
4716
5023
  * exactly the frame stream, so help prose goes to stderr instead. */
4717
- stdout: { write: (text) => (state.format === "human" ? runtime.stdout : runtime.stderr).write(text) },
5024
+ stdout: { write: (text) => (state.format === "json" ? runtime.stderr : runtime.stdout).write(text) },
4718
5025
  stderr: { write: (text) => {
4719
5026
  state.stricliStderr += text;
4720
5027
  } },
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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";
1
+ import { $ as PRISMA_CONFIG_VERSION, A as Format, At as CredentialOrigin, B as Ui, C as defineSessionCommand, Ct as flag, D as OpenUrlRequest, Dt as Credential, E as OpenUrlOutcome, Et as ActiveCredential, F as Span, Ft as CredentialRefresher, G as ConfigSection, H as Severity, I as Status, It as ManagementApiClient, J as Host, K as SectionValidation, L as Text, Lt as ManagementApiClientConfig, M as PRESENTED, Mt as Session, N as Presentations, Nt as StoredSessions, O as PromptSurface, Ot as CredentialIdentity, P as PresentedResult, Pt as CredentialRefreshResult, Q as OutputStream, R as Tone, Rt as TokenStorage, S as defineServerCommand, St as PositionalSpec, T as CommandContext, Tt as ActiveAccessTokenOptions, U as StreamEvent, V as EngineEvent, W as StreamMeta, X as InputStream, Y as HostProcess, Z as LoadedConfig, _ as ServerCommandDefinition, _t as Args, a as RedirectSpec, at as ChildStatusSettlement, b as WorkflowStep, bt as CommandArgs, c as CommandDefinition, ct as SpawnOptions, d as CommandNeeds, dt as exitWithChildStatus, et as Runtime, f as CompletedEnvelope, ft as PackageManagerId, g as NeedsSpec, gt as PackageOperations, h as HelpSpec, ht as PackageManagerRunner, i as MountedTree, it as ChildResult, j as Outcome, jt as SERVICE_TOKEN_ENV_VAR, k as Block, kt as CredentialManager, l as CommandHandler, lt as SpawnRequest, m as Handler, mt as PackageManagerRunResult, n as CommandFamily, nt as EngineCommandSnapshot, o as defineCommandFamily, ot as ExitWithChildStatusOptions, p as ErroredEnvelope, pt as PackageManagerRunRequest, q as defineConfigSection, r as CommandRedirect, rt as RunSummary, s as AnyCommand, st as SpawnChild, t as TelemetryDeclaration, tt as TelemetryPayload, u as CommandHelp, ut as SpawnedChild, v as SessionCommandDefinition, vt as ArgsSpec, w as BrowserWaitRequest, wt as positional, x as defineCommand, xt as FlagSpec, y as SpawnDeclarations, yt as Char, z as TreeNode } from "./report-DNdnCXuq.js";
2
2
  import { n as CliStructuredError } from "./protocol-YjqPCCOG.js";
3
3
 
4
4
  //#region src/active-access-token.d.ts
@@ -48,12 +48,14 @@ declare function createCli(spec: {
48
48
  readonly commandFamilies: readonly CommandFamily[];
49
49
  readonly groups: Readonly<Record<string, {
50
50
  readonly brief: string;
51
- readonly description?: string;
51
+ readonly description?: string; /** The group's common path, rendered as a `Workflow` section. */
52
+ readonly workflow?: readonly WorkflowStep[];
52
53
  }>>;
53
54
  readonly commands: MountedTree; /** Words for the root help card; the engine formats. */
54
55
  readonly help?: {
55
56
  readonly tagline?: string;
56
- readonly description?: string;
57
+ readonly description?: string; /** The CLI's common path, rendered as a `Workflow` section. */
58
+ readonly workflow?: readonly WorkflowStep[];
57
59
  readonly examples?: readonly string[];
58
60
  readonly docsUrl?: string;
59
61
  };
@@ -213,4 +215,4 @@ declare function claimedExpiresAt(token: string): Date | undefined;
213
215
  */
214
216
  declare function claimedIdentity(token: string): CredentialIdentity | undefined;
215
217
  //#endregion
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 };
218
+ 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, type WorkflowStep, 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 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";
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-DSn58puQ.js";
3
3
  //#region src/cli.ts
4
4
  /**
5
5
  * Shell-side construction. Group help is declared with the mount.
@@ -300,7 +300,7 @@ function consentPresentations(line, json) {
300
300
  const telemetryStatusCommand = defineCommand({
301
301
  help: {
302
302
  summary: "Show whether anonymous CLI telemetry is enabled and why",
303
- description: "Reports whether telemetry is currently enabled or disabled and the reason\n(default-on, stored opt-out, environment opt-out, or CI), the path to your\nuser-level config file, and whether an installation ID has been stored.\nRead-only: never sends an event, never mints an ID, never writes anything.",
303
+ description: "Reports whether telemetry is currently enabled or disabled and the reason (default-on, stored opt-out, environment opt-out, or CI), the path to your user-level config file, and whether an installation ID has been stored. Read-only: never sends an event, never mints an ID, never writes anything.",
304
304
  examples: ["telemetry status", "telemetry status --json"]
305
305
  },
306
306
  handler: async (_args, ctx) => {
@@ -317,7 +317,7 @@ const telemetryStatusCommand = defineCommand({
317
317
  const telemetryEnableCommand = defineCommand({
318
318
  help: {
319
319
  summary: "Enable anonymous CLI telemetry",
320
- description: "Stores \"enableTelemetry\": true in your user-level config and mints an\ninstallation ID if one is not already stored.",
320
+ description: "Stores \"enableTelemetry\": true in your user-level config and mints an installation ID if one is not already stored.",
321
321
  examples: ["telemetry enable"]
322
322
  },
323
323
  handler: async (_args, ctx) => {
@@ -334,7 +334,7 @@ const telemetryEnableCommand = defineCommand({
334
334
  const telemetryDisableCommand = defineCommand({
335
335
  help: {
336
336
  summary: "Disable anonymous CLI telemetry",
337
- description: "Stores \"enableTelemetry\": false in your user-level config. No installation\nID is minted and no event is sent.",
337
+ description: "Stores \"enableTelemetry\": false in your user-level config. No installation ID is minted and no event is sent.",
338
338
  examples: ["telemetry disable"]
339
339
  },
340
340
  handler: async (_args, ctx) => {
@@ -858,7 +858,7 @@ interface StreamMeta {
858
858
  }
859
859
  //#endregion
860
860
  //#region src/presentation.d.ts
861
- type Format = "human" | "json";
861
+ type Format = "human" | "json" | "markdown";
862
862
  /**
863
863
  * What a command concluded, stated at the return site. `exitCode` is
864
864
  * required at every return site iff the command documents exit codes,
@@ -1229,6 +1229,16 @@ interface PromptSurface {
1229
1229
  * field is always present, with empty collections and explicit
1230
1230
  * undefined instead of conditional properties.
1231
1231
  */
1232
+ /**
1233
+ * One step of a group's common path, rendered under a `Workflow`
1234
+ * heading on the group's help card. `run` follows the example
1235
+ * convention: no binary name, `{bin}` substituted at render time.
1236
+ */
1237
+ interface WorkflowStep {
1238
+ readonly run: string;
1239
+ /** Short purpose column shown beside the invocation. */
1240
+ readonly brief: string;
1241
+ }
1232
1242
  /** The help SPI: words only — the engine formats. */
1233
1243
  interface HelpSpec {
1234
1244
  /** One line, imperative, shown in listings. */
@@ -1544,4 +1554,4 @@ interface TelemetryDeclaration {
1544
1554
  readonly docsUrl: string;
1545
1555
  }
1546
1556
  //#endregion
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 };
1557
+ export { PRISMA_CONFIG_VERSION as $, Format as A, CredentialOrigin as At, Ui as B, defineSessionCommand as C, flag as Ct, OpenUrlRequest as D, Credential as Dt, OpenUrlOutcome as E, ActiveCredential as Et, Span as F, CredentialRefresher as Ft, ConfigSection as G, Severity as H, Status as I, ManagementApiClient$1 as It, Host as J, SectionValidation as K, Text as L, ManagementApiClientConfig as Lt, PRESENTED as M, Session as Mt, Presentations as N, StoredSessions as Nt, PromptSurface as O, CredentialIdentity as Ot, PresentedResult as P, CredentialRefreshResult as Pt, OutputStream as Q, Tone as R, TokenStorage$1 as Rt, defineServerCommand as S, PositionalSpec as St, CommandContext as T, ActiveAccessTokenOptions as Tt, StreamEvent as U, EngineEvent as V, StreamMeta as W, InputStream as X, HostProcess as Y, LoadedConfig as Z, ServerCommandDefinition as _, Args as _t, RedirectSpec as a, ChildStatusSettlement as at, WorkflowStep as b, CommandArgs as bt, CommandDefinition as c, SpawnOptions as ct, CommandNeeds as d, exitWithChildStatus as dt, Runtime as et, CompletedEnvelope as f, PackageManagerId as ft, NeedsSpec as g, PackageOperations as gt, HelpSpec as h, PackageManagerRunner as ht, MountedTree as i, ChildResult as it, Outcome as j, SERVICE_TOKEN_ENV_VAR as jt, Block as k, CredentialManager as kt, CommandHandler as l, SpawnRequest as lt, Handler as m, PackageManagerRunResult as mt, CommandFamily as n, EngineCommandSnapshot as nt, defineCommandFamily as o, ExitWithChildStatusOptions as ot, ErroredEnvelope as p, PackageManagerRunRequest as pt, defineConfigSection as q, CommandRedirect as r, RunSummary as rt, AnyCommand as s, SpawnChild as st, TelemetryDeclaration as t, TelemetryPayload as tt, CommandHelp as u, SpawnedChild as ut, SessionCommandDefinition as v, ArgsSpec as vt, BrowserWaitRequest as w, positional as wt, defineCommand as x, FlagSpec as xt, SpawnDeclarations as y, Char as yt, TreeNode as z };
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
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";
1
+ import { Dt as Credential, Et as ActiveCredential, Ft as CredentialRefresher, It as ManagementApiClient, J as Host, Lt as ManagementApiClientConfig, Mt as Session, Nt as StoredSessions, P as PresentedResult, Rt as TokenStorage, Tt as ActiveAccessTokenOptions, U as StreamEvent, V as EngineEvent, b as WorkflowStep, et as Runtime, ft as PackageManagerId, ht as PackageManagerRunner, i as MountedTree, it as ChildResult, kt as CredentialManager, lt as SpawnRequest, n as CommandFamily, rt as RunSummary, st as SpawnChild, t as TelemetryDeclaration, tt as TelemetryPayload } from "./report-DNdnCXuq.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
@@ -174,7 +174,16 @@ declare function createTestCli(spec: {
174
174
  readonly commands: MountedTree;
175
175
  readonly groups?: Readonly<Record<string, {
176
176
  readonly brief: string;
177
- }>>;
177
+ readonly description?: string;
178
+ readonly workflow?: readonly WorkflowStep[];
179
+ }>>; /** Words for the root help card, exactly as `createCli` takes them. */
180
+ readonly help?: {
181
+ readonly tagline?: string;
182
+ readonly description?: string;
183
+ readonly workflow?: readonly WorkflowStep[];
184
+ readonly examples?: readonly string[];
185
+ readonly docsUrl?: string;
186
+ };
178
187
  /** Seeds the sections the config file would have held. The engine
179
188
  * asks for them only when the command declares a config section, and
180
189
  * checks them as it would a real file's: a section name no mounted
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
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";
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-DSn58puQ.js";
2
2
  import { Buffer } from "node:buffer";
3
3
  //#region src/in-memory-credential-manager.ts
4
4
  /**
@@ -384,6 +384,7 @@ function createTestCli(spec) {
384
384
  commandFamilies: spec.commandFamilies ?? [],
385
385
  groups: spec.groups ?? {},
386
386
  commands: spec.commands,
387
+ help: spec.help,
387
388
  telemetry: spec.telemetry
388
389
  },
389
390
  /** Waiting is instant under test: browserWait's polling is driven
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/cli-engine",
3
- "version": "0.2.3",
3
+ "version": "0.4.0",
4
4
  "description": "The execution engine of the unified Prisma CLI.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -41,16 +41,19 @@
41
41
  "license": "Apache-2.0",
42
42
  "dependencies": {
43
43
  "@clack/prompts": "1.5.0",
44
- "@prisma/management-api-sdk": "1.55.0",
45
44
  "@stricli/core": "1.3.0",
46
45
  "c12": "3.3.4",
47
46
  "colorette": "^2.0.20",
48
47
  "package-manager-detector": "1.8.0",
49
48
  "string-width": "^8.2.1"
50
49
  },
50
+ "peerDependencies": {
51
+ "@prisma/management-api-sdk": "^1.55.0"
52
+ },
51
53
  "devDependencies": {
52
- "@repo/cli-conformance": "8.0.0-rc.9-dev.79",
53
- "@repo/tsconfig": "8.0.0-rc.9-dev.79",
54
+ "@prisma/management-api-sdk": "1.69.0",
55
+ "@repo/cli-conformance": "8.0.0-rc.14-dev.102",
56
+ "@repo/tsconfig": "8.0.0-rc.14-dev.102",
54
57
  "@types/node": "^22.19.19",
55
58
  "ci-info": "^4.3.1",
56
59
  "tsdown": "^0.21.10",