@prisma/cli-engine 0.0.7 → 0.0.9

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,4 +1,4 @@
1
- import { i as NextAction, n as CliStructuredError, r as Diagnostic, s as Result } from "./protocol-CpZLdxML.js";
1
+ import { i as NextAction, n as CliStructuredError, r as Diagnostic, s as Result } from "./protocol-YjqPCCOG.js";
2
2
  import { ManagementApiClient, TokenStorage } from "@prisma/management-api-sdk";
3
3
 
4
4
  //#region src/args.d.ts
@@ -439,6 +439,34 @@ interface Presentations {
439
439
  readonly json?: () => unknown;
440
440
  readonly next?: () => readonly NextAction[];
441
441
  }
442
+ /**
443
+ * What happened: it selects the glyph (✔ ✘ ⚠ ℹ) and carries a default
444
+ * Tone of the same name. Separate from Tone because a failure can be
445
+ * painted in a colour that is not `error` — a tree node in its branch
446
+ * lane's hue, say — and a colour can be chosen where nothing happened.
447
+ */
448
+ type Status = "ok" | "error" | "warn" | "info";
449
+ /**
450
+ * What colour to paint, and nothing else. Semantic names and indexed
451
+ * colours in one union: a command asks for meaning where it has one and
452
+ * for a distinguishable colour where it does not. The indexed colours
453
+ * are for telling adjacent things apart — one per branch lane in a
454
+ * graph, say — and deliberately exclude red so no series member reads
455
+ * as an error.
456
+ */
457
+ type Tone = "ok" | "warn" | "error" | "info" | "heading" | "identifier" | "ref" | "placeholder" | "link" | "emphasis" | "muted" | "structure" | "highlight" | "color-1" | "color-2" | "color-3" | "color-4" | "color-5" | "color-6";
458
+ /**
459
+ * A run of text and the meaning of its colour. A handler never emits
460
+ * escape sequences: the engine measures width from `text`, so colour
461
+ * cannot break alignment, and the same spans can be re-themed or
462
+ * stripped without re-rendering.
463
+ */
464
+ interface Span {
465
+ readonly text: string;
466
+ readonly tone?: Tone;
467
+ }
468
+ /** Display text anywhere a block or Ui takes it. A bare string is untoned. */
469
+ type Text = string | readonly Span[];
442
470
  /**
443
471
  * Deliberately small; grows by the same evidence rule as events.
444
472
  * Recorded findings are NOT a Block — they are the outcome's
@@ -447,35 +475,64 @@ interface Presentations {
447
475
  */
448
476
  type Block = {
449
477
  readonly kind: "summary";
450
- readonly tone: "ok" | "error" | "warn" | "info";
451
- readonly text: string;
478
+ readonly status: Status; /** Overrides the colour the status implies. Never the glyph. */
479
+ readonly tone?: Tone;
480
+ readonly text: Text;
452
481
  } | {
482
+ /** A key/value card: the engine pads the keys so every value
483
+ * starts in the same column. */
453
484
  readonly kind: "fields";
454
485
  readonly rows: ReadonlyArray<{
455
- readonly label: string;
456
- readonly value: string;
486
+ readonly label: Text;
487
+ readonly value: Text;
457
488
  readonly sensitive?: boolean;
458
489
  }>;
490
+ /** Draws the dim `│` rail down the left of the card. A command
491
+ * knows whether it is drawing a header card or a plain one, so
492
+ * this is per block rather than a global setting. */
493
+ readonly rail?: boolean;
459
494
  } | {
460
- readonly kind: "table";
461
- readonly columns: readonly string[];
462
- readonly rows: ReadonlyArray<readonly string[]>;
495
+ /** The engine sizes every column to its widest cell. */readonly kind: "table";
496
+ readonly columns: readonly Text[];
497
+ readonly rows: ReadonlyArray<readonly Text[]>;
463
498
  } | {
464
499
  readonly kind: "list";
465
- readonly items: readonly string[];
500
+ readonly items: readonly Text[];
466
501
  } | {
467
502
  readonly kind: "tree";
468
503
  readonly roots: readonly TreeNode[];
504
+ } | {
505
+ /**
506
+ * Lines of spans, rendered verbatim — no layout, no reflow, no
507
+ * truncation. For output whose two-dimensional structure the
508
+ * engine cannot derive, such as a migration graph's lane gutter,
509
+ * where the same hue has to reach the gutter cell, the node glyph
510
+ * and the label alike.
511
+ */
512
+ readonly kind: "drawing";
513
+ readonly lines: readonly Text[];
469
514
  };
470
515
  interface TreeNode {
471
- readonly label: string;
516
+ readonly label: Text;
517
+ /** Renders its glyph before the label. */
518
+ readonly status?: Status;
519
+ /** Colours the glyph and the label; defaults to the status. */
520
+ readonly tone?: Tone;
472
521
  readonly children?: readonly TreeNode[];
473
522
  }
474
523
  /** Styling helpers usable inside block text; no direct writing. */
475
524
  interface Ui {
525
+ /**
526
+ * How much room the command has: stderr's terminal width, or
527
+ * Number.POSITIVE_INFINITY when stderr is not a terminal. Only the
528
+ * command knows what to sacrifice, so the engine hands over the number
529
+ * and prints an overrun unmodified.
530
+ */
531
+ readonly width: number;
476
532
  readonly emphasize: (text: string) => string;
477
533
  readonly dim: (text: string) => string;
478
534
  readonly code: (text: string) => string;
535
+ readonly tone: (tone: Tone, text: string) => string;
479
536
  }
480
537
  //#endregion
481
538
  //#region src/spawn.d.ts
@@ -647,6 +704,14 @@ interface CommandContext<TConfig = undefined, TCode extends number = never> {
647
704
  * via ctx.env, never process.env.
648
705
  */
649
706
  readonly env: Readonly<Record<string, string | undefined>>;
707
+ /**
708
+ * The host's answer to "is this CI", from Runtime.isCI — what
709
+ * telemetry gates on. Not the engine's interactivity decision, which
710
+ * is its own thing (stdin a TTY, no CI in the environment,
711
+ * --interactive/--no-interactive), so prompts and spinners follow
712
+ * ctx.prompt and the engine's interaction handling, not this.
713
+ */
714
+ readonly isCI: boolean;
650
715
  /**
651
716
  * Conditional optional-dependency need. Resolves when the
652
717
  * optional peer dependency is importable from the user's project;
@@ -743,10 +808,148 @@ interface PromptSurface {
743
808
  readonly browserWait: (request: BrowserWaitRequest) => Promise<void>;
744
809
  }
745
810
  //#endregion
811
+ //#region src/package-manager.d.ts
812
+ /** The package managers the engine knows how to drive. */
813
+ type PackageManagerId = "npm" | "pnpm" | "yarn" | "bun" | "deno";
814
+ /**
815
+ * ctx.packages: what a command declaring `installsPackages` may do to
816
+ * the user's project. Both operations resolve — a manager that failed
817
+ * is a value, not a throw — except under cancellation, which throws the
818
+ * abort reason so the run settles the way Ctrl-C settles everywhere
819
+ * else. Neither may be called while the other is still running.
820
+ *
821
+ * Success carries nothing back: the command line stays with the engine,
822
+ * which announces it, streams the manager's output under it, and puts
823
+ * the redacted spelling on a failure's next action.
824
+ */
825
+ interface PackageOperations {
826
+ /** Adds dependencies to the project. */
827
+ install(request: {
828
+ /** Specifiers as the user would type them, e.g. "prisma@latest". */readonly packages: readonly string[];
829
+ readonly dev?: boolean; /** Defaults to ctx.cwd. */
830
+ readonly cwd?: string; /** Overrides detection, so a caller can retry with another manager. */
831
+ readonly manager?: PackageManagerId;
832
+ }): Promise<Result<void, CliStructuredError>>;
833
+ /** Runs a package's bin once, without adding a dependency. */
834
+ run(request: {
835
+ /** The package whose bin to execute, e.g. "skills". */readonly package: string;
836
+ readonly args: readonly string[]; /** Defaults to ctx.cwd. */
837
+ readonly cwd?: string; /** Overrides detection, so a caller can retry with another manager. */
838
+ readonly manager?: PackageManagerId;
839
+ }): Promise<Result<void, CliStructuredError>>;
840
+ }
841
+ /** One package-manager execution, handed to the host to spawn. */
842
+ interface PackageManagerRunRequest {
843
+ readonly file: string;
844
+ readonly args: readonly string[];
845
+ readonly cwd: string;
846
+ readonly signal: AbortSignal;
847
+ /** Called with each chunk as the child writes it, so the engine can
848
+ * emit `output` events while the operation runs. */
849
+ readonly onOutput: (channel: "data" | "diagnostic", chunk: string) => void;
850
+ }
851
+ /** What the child produced: its exit code — non-zero covers a manager
852
+ * that failed and an executable that was not there — and its stderr,
853
+ * bounded to the last 64 KiB. */
854
+ interface PackageManagerRunResult {
855
+ readonly exitCode: number;
856
+ readonly stderr: string;
857
+ }
858
+ /** Spawns a package manager on the engine's behalf. A manager that
859
+ * fails is a resolved result, never a rejection. */
860
+ type PackageManagerRunner = (request: PackageManagerRunRequest) => Promise<PackageManagerRunResult>;
861
+ //#endregion
862
+ //#region src/run-summary.d.ts
863
+ /**
864
+ * The value-free command snapshot the engine records at parse time.
865
+ * The engine's own telemetry composes its payload from it at command
866
+ * start, and it rides along on the RunSummary a bin may observe.
867
+ * Carries NO user data — command-path segments, flag names with their
868
+ * value source, and a bare count of positionals. Flag values,
869
+ * positional values, and raw argv never appear here.
870
+ */
871
+ interface EngineCommandSnapshot {
872
+ /** Mount-path segments of the executed command ('telemetry status'
873
+ * → ['telemetry', 'status']). Never includes the binary name. */
874
+ readonly commandPath: readonly string[];
875
+ /**
876
+ * One entry per flag the command accepts (the engine-injected shared
877
+ * family first, then the command's own declarations), named in the
878
+ * user-facing kebab-case spelling. `source` is what the engine knows
879
+ * at parse time: flags explicitly present on argv are 'cli'; the
880
+ * engine reads no flags from the environment today, so everything
881
+ * else is 'default'. 'env' is reserved for a future env-sourced
882
+ * flag mechanism.
883
+ */
884
+ readonly flags: ReadonlyArray<{
885
+ readonly name: string;
886
+ readonly source: "cli" | "env" | "default";
887
+ }>;
888
+ /** How many positional arguments the run supplied — a count only. */
889
+ readonly positionalCount: number;
890
+ }
891
+ /**
892
+ * What `RunHooks.onSettled` receives, exactly once per run, after the
893
+ * run has settled (exit code determined, terminal output written).
894
+ * Never fired for `--help` or `--version`, and never for a run that
895
+ * failed before a mounted command was reached (nothing executed, so
896
+ * there is no snapshot to report). `durationMs` comes from the
897
+ * engine's injectable clock.
898
+ */
899
+ interface RunSummary {
900
+ /** The mounted command's dotted id ('telemetry.status'). Derived
901
+ * from the same mount entry as `snapshot.commandPath` — it always
902
+ * equals `snapshot.commandPath.join('.')`. Both are kept: consumers
903
+ * addressing the command use the id; the snapshot is the value-free
904
+ * wire projection. */
905
+ readonly commandId: string;
906
+ readonly exitCode: number;
907
+ readonly durationMs: number;
908
+ readonly snapshot: EngineCommandSnapshot;
909
+ }
910
+ //#endregion
911
+ //#region src/telemetry/payload.d.ts
912
+ /**
913
+ * The payload the engine composes at command start and hands to
914
+ * `Runtime.spawnTelemetry`. The host forwards it to its own sender,
915
+ * which probes its process (runtime/os/arch, package manager, ts
916
+ * version, agent) for the rest of the event and POSTs it.
917
+ *
918
+ * Both sides version-couple on this shape: the carrier is Node's
919
+ * structured clone over IPC, so there is no on-wire compat to maintain.
920
+ */
921
+ interface TelemetryPayload {
922
+ readonly installationId: string;
923
+ readonly version: string;
924
+ /** The command path joined with spaces — `postgres create`. */
925
+ readonly command: string;
926
+ /** Names only, of the flags the user typed. Never values. */
927
+ readonly flags: readonly string[];
928
+ /**
929
+ * Absolute path of the user's project. The sender reads
930
+ * `<projectRoot>/package.json` for `tsVersion`.
931
+ */
932
+ readonly projectRoot: string;
933
+ /** Resolved endpoint URL (already includes the `/events` path). */
934
+ readonly endpoint: string;
935
+ /**
936
+ * Kept for wire compatibility with the ORM CLI's first-`init` flow,
937
+ * where the chosen target is known before the config file exists. The
938
+ * engine never populates it; the wire-format event keeps `null` as its
939
+ * "no target known" marker, but this channel needs only two states so
940
+ * the field is `string | undefined`.
941
+ */
942
+ readonly databaseTarget?: string;
943
+ }
944
+ //#endregion
746
945
  //#region src/runtime.d.ts
747
946
  /** Minimal structural stream types; no NodeJS.* in the public surface. */
748
947
  interface OutputStream {
749
948
  write(text: string): void;
949
+ /** The stream's terminal width, absent when it is not a terminal.
950
+ * The engine reads it at render time rather than caching it, so a
951
+ * terminal resized mid-run is respected by the next thing drawn. */
952
+ readonly columns?: number;
750
953
  }
751
954
  /**
752
955
  * Byte-oriented, so server commands can implement byte-counted
@@ -768,6 +971,13 @@ interface Runtime {
768
971
  readonly stdout: boolean;
769
972
  readonly stderr: boolean;
770
973
  };
974
+ /**
975
+ * True when this process runs in CI, where telemetry never reports.
976
+ * The bin wires `ci-info`; the engine detects CI no more than it
977
+ * detects a TTY. Required, not optional: a host that forgot it would
978
+ * silently report from CI.
979
+ */
980
+ readonly isCI: boolean;
771
981
  /**
772
982
  * Ends the process. The bin passes process.exit; the engine is the
773
983
  * only caller (second-signal force exit, 130/143).
@@ -819,15 +1029,33 @@ interface Runtime {
819
1029
  * handler run, so ctx.spawn is never reached.
820
1030
  */
821
1031
  readonly spawn?: SpawnChild;
1032
+ /**
1033
+ * Fire-and-forget delivery of one composed telemetry payload. The bin
1034
+ * owns the process work and the detachment, which is why the engine
1035
+ * imports no child_process and performs no network I/O for telemetry.
1036
+ * Absent means this host reports nothing — not an error, and the whole
1037
+ * sequence is skipped rather than only the delivery: no config read,
1038
+ * no disclosure, no mint.
1039
+ */
1040
+ readonly spawnTelemetry?: (payload: TelemetryPayload) => void;
822
1041
  /** Management API endpoint config; the bin derives baseUrl from env. */
823
1042
  readonly managementApi: {
824
1043
  readonly baseUrl: string;
825
1044
  };
826
1045
  /**
827
- * Used by the ENGINE to phrase install commands (handlers never do —
828
- * see needs.dependencies and ctx.requireDependency).
1046
+ * A host that knows its user's package manager better than detection
1047
+ * does. Absent — the normal case — means the engine detects it from
1048
+ * the project at cwd.
1049
+ */
1050
+ readonly packageManager?: PackageManagerId;
1051
+ /**
1052
+ * Spawns the package manager the engine composed. The engine never
1053
+ * imports child_process; this is the only way a manager runs. It is
1054
+ * optional so a harness can exercise the no-runner path — every
1055
+ * shipped host wires it, and a host without it can run no package
1056
+ * operation at all.
829
1057
  */
830
- readonly packageManager: "npm" | "pnpm" | "yarn" | "bun" | "unknown";
1058
+ readonly runPackageManager?: PackageManagerRunner;
831
1059
  }
832
1060
  /**
833
1061
  * The minimal process surface a bin adapts a Runtime from — Node's
@@ -845,6 +1073,7 @@ interface HostProcess {
845
1073
  readonly stderr: {
846
1074
  write(text: string): unknown;
847
1075
  isTTY?: boolean;
1076
+ columns?: number;
848
1077
  };
849
1078
  readonly stdin: {
850
1079
  isTTY?: boolean;
@@ -976,7 +1205,7 @@ interface CommandNeeds<TConfig> {
976
1205
  interface SpawnDeclarations {
977
1206
  readonly maySpawn?: boolean;
978
1207
  }
979
- interface CommandDefinition<TFlags extends Record<string, FlagSpec<unknown>> = Record<never, FlagSpec<unknown>>, TPositionals extends Record<string, PositionalSpec<unknown>> = Record<never, PositionalSpec<unknown>>, TConfig = undefined, TCode extends number = never, TManagesCredentials extends boolean = false> {
1208
+ interface CommandDefinition<TFlags extends Record<string, FlagSpec<unknown>> = Record<never, FlagSpec<unknown>>, TPositionals extends Record<string, PositionalSpec<unknown>> = Record<never, PositionalSpec<unknown>>, TConfig = undefined, TCode extends number = never, TManagesCredentials extends boolean = false, TInstallsPackages extends boolean = false> {
980
1209
  readonly kind: "result-command";
981
1210
  readonly help: CommandHelp;
982
1211
  readonly args: CommandArgs<TFlags, TPositionals>;
@@ -998,6 +1227,12 @@ interface CommandDefinition<TFlags extends Record<string, FlagSpec<unknown>> = R
998
1227
  readonly managesCredentials: TManagesCredentials;
999
1228
  /** See SpawnDeclarations. */
1000
1229
  readonly maySpawn: boolean;
1230
+ /**
1231
+ * A CAPABILITY, not a need: when true, ctx.packages appears on the
1232
+ * context and the command may run the user's package manager in the
1233
+ * user's project. Declaring it never fails a run.
1234
+ */
1235
+ readonly installsPackages: TInstallsPackages;
1001
1236
  /**
1002
1237
  * The handler function, referenced directly — never a dynamic import
1003
1238
  * (operator ruling, 2026-08-09). A handler that needs heavy
@@ -1005,28 +1240,24 @@ interface CommandDefinition<TFlags extends Record<string, FlagSpec<unknown>> = R
1005
1240
  * handler defined in another file is imported statically and
1006
1241
  * annotated CommandHandler<typeof def>.
1007
1242
  */
1008
- readonly handler: Handler<TFlags, TPositionals, TConfig, TCode, TManagesCredentials>;
1243
+ readonly handler: Handler<TFlags, TPositionals, TConfig, TCode, TManagesCredentials, TInstallsPackages>;
1009
1244
  }
1010
- type Handler<TFlags extends Record<string, FlagSpec<unknown>>, TPositionals extends Record<string, PositionalSpec<unknown>>, TConfig, TCode extends number = never, TManagesCredentials extends boolean = false> = (args: Args<TFlags, TPositionals>, ctx: CommandContext<TConfig, TCode> & (TManagesCredentials extends true ? {
1245
+ type Handler<TFlags extends Record<string, FlagSpec<unknown>>, TPositionals extends Record<string, PositionalSpec<unknown>>, TConfig, TCode extends number = never, TManagesCredentials extends boolean = false, TInstallsPackages extends boolean = false> = (args: Args<TFlags, TPositionals>, ctx: CommandContext<TConfig, TCode> & (TManagesCredentials extends true ? {
1011
1246
  readonly credentialManager: CredentialManager;
1247
+ } : unknown) & (TInstallsPackages extends true ? {
1248
+ readonly packages: PackageOperations;
1012
1249
  } : unknown)) => Promise<Result<PresentedResult<unknown> | ChildStatusSettlement, CliStructuredError>>;
1013
1250
  /** For impl files: `const run: CommandHandler<typeof migrateCommand> = …` */
1014
- type CommandHandler<D> = D extends CommandDefinition<infer F, infer P, infer C, infer K, infer M> ? Handler<F, P, C, K, M> : never;
1015
- declare function defineCommand<TFlags extends Record<string, FlagSpec<unknown>> = Record<never, FlagSpec<unknown>>, TPositionals extends Record<string, PositionalSpec<unknown>> = Record<never, PositionalSpec<unknown>>, TConfig = undefined, TCode extends number = never>(def: {
1016
- readonly help: HelpSpec;
1017
- readonly args?: ArgsSpec<TFlags, TPositionals>;
1018
- readonly needs?: NeedsSpec<TConfig>;
1019
- readonly exitCodes?: Readonly<Record<TCode, string>>;
1020
- readonly managesCredentials: true;
1021
- readonly handler: Handler<TFlags, TPositionals, TConfig, TCode, true>;
1022
- } & SpawnDeclarations): CommandDefinition<TFlags, TPositionals, TConfig, TCode, true>;
1023
- declare function defineCommand<TFlags extends Record<string, FlagSpec<unknown>> = Record<never, FlagSpec<unknown>>, TPositionals extends Record<string, PositionalSpec<unknown>> = Record<never, PositionalSpec<unknown>>, TConfig = undefined, TCode extends number = never>(def: {
1251
+ type CommandHandler<D> = D extends CommandDefinition<infer F, infer P, infer C, infer K, infer M, infer I> ? Handler<F, P, C, K, M, I> : never;
1252
+ declare function defineCommand<TFlags extends Record<string, FlagSpec<unknown>> = Record<never, FlagSpec<unknown>>, TPositionals extends Record<string, PositionalSpec<unknown>> = Record<never, PositionalSpec<unknown>>, TConfig = undefined, TCode extends number = never, TManagesCredentials extends boolean = false, TInstallsPackages extends boolean = false>(def: {
1024
1253
  readonly help: HelpSpec;
1025
1254
  readonly args?: ArgsSpec<TFlags, TPositionals>;
1026
1255
  readonly needs?: NeedsSpec<TConfig>;
1027
1256
  readonly exitCodes?: Readonly<Record<TCode, string>>;
1028
- readonly handler: Handler<TFlags, TPositionals, TConfig, TCode>;
1029
- } & SpawnDeclarations): CommandDefinition<TFlags, TPositionals, TConfig, TCode>;
1257
+ readonly managesCredentials?: TManagesCredentials;
1258
+ readonly installsPackages?: TInstallsPackages;
1259
+ readonly handler: Handler<TFlags, TPositionals, TConfig, TCode, TManagesCredentials, TInstallsPackages>;
1260
+ } & SpawnDeclarations): CommandDefinition<TFlags, TPositionals, TConfig, TCode, TManagesCredentials, TInstallsPackages>;
1030
1261
  /**
1031
1262
  * A session command (dev, log tail): runs until the signal fires,
1032
1263
  * speaks entirely through events, returns Result<void>. No
@@ -1093,7 +1324,7 @@ declare function defineServerCommand<TFlags extends Record<string, FlagSpec<unkn
1093
1324
  * concrete types travel through each definition's generics, not through
1094
1325
  * this union.
1095
1326
  */
1096
- type AnyCommand = (Omit<CommandDefinition<Record<string, FlagSpec<unknown>>, Record<string, PositionalSpec<unknown>>, unknown, number, boolean>, "handler"> & {
1327
+ type AnyCommand = (Omit<CommandDefinition<Record<string, FlagSpec<unknown>>, Record<string, PositionalSpec<unknown>>, unknown, number, boolean, boolean>, "handler"> & {
1097
1328
  readonly handler: unknown;
1098
1329
  }) | (Omit<SessionCommandDefinition<Record<string, FlagSpec<unknown>>, Record<string, PositionalSpec<unknown>>, unknown>, "handler"> & {
1099
1330
  readonly handler: unknown;
@@ -1201,52 +1432,16 @@ declare function defineCommandFamily(spec: {
1201
1432
  /** What the shell builds: commands by PATH (space-separated, 'db migrate'). */
1202
1433
  type MountedTree = Readonly<Record<string, AnyCommand>>;
1203
1434
  //#endregion
1204
- //#region src/run-summary.d.ts
1435
+ //#region src/telemetry/report.d.ts
1205
1436
  /**
1206
- * The value-free command snapshot the engine records at parse time and
1207
- * hands to `RunHooks.onSettled`. Consumed by the shell's telemetry
1208
- * wiring; carries NO user data — command-path segments, flag names
1209
- * with their value source, and a bare count of positionals. Flag
1210
- * values, positional values, and raw argv never appear here.
1437
+ * What a CLI declares to report. One field: the endpoint, the opt-out
1438
+ * variable names, the config path and the disclosure wording are Prisma
1439
+ * constants the engine owns. Omitting the declaration means the CLI
1440
+ * reports nothing at all.
1211
1441
  */
1212
- interface EngineCommandSnapshot {
1213
- /** Mount-path segments of the executed command ('telemetry status'
1214
- * → ['telemetry', 'status']). Never includes the binary name. */
1215
- readonly commandPath: readonly string[];
1216
- /**
1217
- * One entry per flag the command accepts (the engine-injected shared
1218
- * family first, then the command's own declarations), named in the
1219
- * user-facing kebab-case spelling. `source` is what the engine knows
1220
- * at parse time: flags explicitly present on argv are 'cli'; the
1221
- * engine reads no flags from the environment today, so everything
1222
- * else is 'default'. 'env' is reserved for a future env-sourced
1223
- * flag mechanism.
1224
- */
1225
- readonly flags: ReadonlyArray<{
1226
- readonly name: string;
1227
- readonly source: "cli" | "env" | "default";
1228
- }>;
1229
- /** How many positional arguments the run supplied — a count only. */
1230
- readonly positionalCount: number;
1231
- }
1232
- /**
1233
- * What `RunHooks.onSettled` receives, exactly once per run, after the
1234
- * run has settled (exit code determined, terminal output written).
1235
- * Never fired for `--help` or `--version`, and never for a run that
1236
- * failed before a mounted command was reached (nothing executed, so
1237
- * there is no snapshot to report). `durationMs` comes from the
1238
- * engine's injectable clock.
1239
- */
1240
- interface RunSummary {
1241
- /** The mounted command's dotted id ('telemetry.status'). Derived
1242
- * from the same mount entry as `snapshot.commandPath` — it always
1243
- * equals `snapshot.commandPath.join('.')`. Both are kept: consumers
1244
- * addressing the command use the id; the snapshot is the value-free
1245
- * wire projection. */
1246
- readonly commandId: string;
1247
- readonly exitCode: number;
1248
- readonly durationMs: number;
1249
- readonly snapshot: EngineCommandSnapshot;
1442
+ interface TelemetryDeclaration {
1443
+ /** Named in the first-run disclosure as where to read what is collected. */
1444
+ readonly docsUrl: string;
1250
1445
  }
1251
1446
  //#endregion
1252
- export { StreamEvent as $, BrowserWaitRequest as A, SpawnRequest as B, defineSessionCommand as C, OutputStream as D, LoadedConfig as E, ChildResult as F, Outcome as G, exitWithChildStatus as H, ChildStatusSettlement as I, PresentedResult as J, PRESENTED as K, ExitWithChildStatusOptions as L, OpenUrlOutcome as M, OpenUrlRequest as N, PRISMA_CONFIG_VERSION as O, PromptSurface as P, Severity as Q, SpawnChild as R, defineServerCommand as S, positional as St, InputStream as T, Block as U, SpawnedChild as V, Format as W, Ui as X, TreeNode as Y, EngineEvent as Z, NeedsSpec as _, Char as _t, MountedTree as a, CredentialOrigin as at, SpawnDeclarations as b, PositionalSpec as bt, AnyCommand as c, StoredSessions as ct, CommandHelp as d, TokenStorage$1 as dt, StreamMeta as et, CommandNeeds as f, ConfigSection as ft, HelpSpec as g, ArgsSpec as gt, Handler as h, Args as ht, CommandRedirect as i, CredentialManager as it, CommandContext as j, Runtime as k, CommandDefinition as l, ManagementApiClient$1 as lt, ErroredEnvelope as m, defineConfigSection as mt, RunSummary as n, Credential as nt, RedirectSpec as o, SERVICE_TOKEN_ENV_VAR as ot, CompletedEnvelope as p, SectionValidation as pt, Presentations as q, CommandFamily as r, CredentialIdentity as rt, defineCommandFamily as s, Session as st, EngineCommandSnapshot as t, ActiveCredential as tt, CommandHandler as u, ManagementApiClientConfig as ut, ServerCommandDefinition as v, CommandArgs as vt, HostProcess as w, defineCommand as x, flag as xt, SessionCommandDefinition as y, FlagSpec as yt, SpawnOptions as z };
1447
+ export { PRESENTED as $, EngineCommandSnapshot as A, FlagSpec as At, OpenUrlRequest as B, HostProcess as C, ConfigSection as Ct, PRISMA_CONFIG_VERSION as D, ArgsSpec as Dt, OutputStream as E, Args as Et, PackageManagerRunner as F, SpawnChild as G, ChildResult as H, PackageOperations as I, SpawnedChild as J, SpawnOptions as K, BrowserWaitRequest as L, PackageManagerId as M, flag as Mt, PackageManagerRunRequest as N, positional as Nt, Runtime as O, Char as Ot, PackageManagerRunResult as P, Outcome as Q, CommandContext as R, defineSessionCommand as S, TokenStorage$1 as St, LoadedConfig as T, defineConfigSection as Tt, ChildStatusSettlement as U, PromptSurface as V, ExitWithChildStatusOptions as W, Block as X, exitWithChildStatus as Y, Format as Z, ServerCommandDefinition as _, SERVICE_TOKEN_ENV_VAR as _t, RedirectSpec as a, Tone as at, defineCommand as b, ManagementApiClient$1 as bt, CommandDefinition as c, EngineEvent as ct, CommandNeeds as d, StreamMeta as dt, Presentations as et, CompletedEnvelope as f, ActiveCredential as ft, NeedsSpec as g, CredentialOrigin as gt, HelpSpec as h, CredentialManager as ht, MountedTree as i, Text as it, RunSummary as j, PositionalSpec as jt, TelemetryPayload as k, CommandArgs as kt, CommandHandler as l, Severity as lt, Handler as m, CredentialIdentity as mt, CommandFamily as n, Span as nt, defineCommandFamily as o, TreeNode as ot, ErroredEnvelope as p, Credential as pt, SpawnRequest as q, CommandRedirect as r, Status as rt, AnyCommand as s, Ui as st, TelemetryDeclaration as t, PresentedResult as tt, CommandHelp as u, StreamEvent as ut, SessionCommandDefinition as v, Session as vt, InputStream as w, SectionValidation as wt, defineServerCommand as x, ManagementApiClientConfig as xt, SpawnDeclarations as y, StoredSessions as yt, OpenUrlOutcome as z };
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as StreamEvent, B as SpawnRequest, F as ChildResult, J as PresentedResult, R as SpawnChild, Z as EngineEvent, a as MountedTree, ct as StoredSessions, dt as TokenStorage, it as CredentialManager, k as Runtime, lt as ManagementApiClient, n as RunSummary, nt as Credential, r as CommandFamily, st as Session, tt as ActiveCredential, ut as ManagementApiClientConfig } from "./run-summary-DQx6CRvB.js";
1
+ import { F as PackageManagerRunner, G as SpawnChild, H as ChildResult, M as PackageManagerId, O as Runtime, St as TokenStorage, bt as ManagementApiClient, ct as EngineEvent, ft as ActiveCredential, ht as CredentialManager, i as MountedTree, j as RunSummary, k as TelemetryPayload, n as CommandFamily, pt as Credential, q as SpawnRequest, t as TelemetryDeclaration, tt as PresentedResult, ut as StreamEvent, vt as Session, xt as ManagementApiClientConfig, yt as StoredSessions } from "./report-Bh6-ntIa.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
@@ -130,7 +130,15 @@ interface TestCli {
130
130
  stdout?: boolean;
131
131
  stderr?: boolean;
132
132
  };
133
+ /** Terminal width, as the stream would report it. Absent means
134
+ * not a terminal, which is what ui.width reads as unbounded. */
135
+ readonly columns?: {
136
+ stderr?: number;
137
+ };
133
138
  readonly env?: Readonly<Record<string, string | undefined>>;
139
+ /** Overrides the CLI-level seed, so one harness can assert both
140
+ * sides of the CI branch. */
141
+ readonly isCI?: boolean;
134
142
  }): Promise<{
135
143
  readonly exitCode: number;
136
144
  readonly stdout: string;
@@ -143,6 +151,10 @@ interface TestCli {
143
151
  */
144
152
  readonly presented: PresentedResult<unknown> | undefined; /** Every ctx.spawn the run made, in order. */
145
153
  readonly spawns: readonly SpawnRecord[];
154
+ /** Every telemetry payload the run handed to the seam, in order.
155
+ * Empty when the CLI declared no telemetry, when gating disabled
156
+ * the run, or when the harness wired no seam. */
157
+ readonly telemetry: readonly TelemetryPayload[];
146
158
  }>;
147
159
  }
148
160
  /**
@@ -185,7 +197,14 @@ declare function createTestCli(spec: {
185
197
  readonly baseUrl?: string;
186
198
  readonly client?: ManagementApiClient;
187
199
  };
188
- readonly packageManager?: "npm" | "pnpm" | "yarn" | "bun" | "unknown";
200
+ /** Overrides detection, the same way a host's Runtime does; absent
201
+ * means the engine detects from the run's cwd. */
202
+ readonly packageManager?: PackageManagerId;
203
+ /** The scripted stand-in for the shipped bin's spawner: assert the
204
+ * composed file/args/cwd, script exit codes and stderr, drive
205
+ * onOutput. Absent means this host has no runner, which is the
206
+ * failure every package operation then takes. */
207
+ readonly packageManagerRunner?: PackageManagerRunner;
189
208
  /** Fixed clock for deterministic stream timestamps; a clock that
190
209
  * advances also drives prompt.browserWait's timeout. */
191
210
  readonly now?: () => Date;
@@ -202,6 +221,16 @@ declare function createTestCli(spec: {
202
221
  * how the engine package itself never imports one. */
203
222
  readonly spawn?: SpawnChild; /** Scripts the built-in fake child. Defaults to one that exits 0. */
204
223
  readonly spawnScript?: ScriptedChildProgram;
224
+ /** Declares telemetry, exactly as `createCli` does. Absent means this
225
+ * CLI reports nothing, which is what every test that says nothing
226
+ * about telemetry gets. */
227
+ readonly telemetry?: TelemetryDeclaration;
228
+ /** The seam behind Runtime.spawnTelemetry. Payloads are recorded on
229
+ * the run result either way; pass a spy to assert ordering, a
230
+ * thrower to exercise failure isolation, or `null` to model a host
231
+ * that wires no seam at all. */
232
+ readonly telemetrySpawner?: ((payload: TelemetryPayload) => void) | null; /** Seeds Runtime.isCI for every run; `run({ isCI })` overrides it. */
233
+ readonly isCI?: boolean;
205
234
  }): TestCli;
206
235
  //#endregion
207
236
  export { InMemoryCredentialManager, type InMemoryCredentialManagerSeed, type InMemoryCredentialManagerState, type ScriptedChildProgram, type SessionRecord, type SpawnRecord, type TestCli, createTestCli, mintTestJwt };