@prisma/cli-engine 0.0.8 → 0.1.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.
@@ -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
@@ -40,6 +40,15 @@ declare const flag: {
40
40
  brief: string;
41
41
  alias?: A & Char<A>;
42
42
  }): FlagSpec<boolean>;
43
+ /**
44
+ * A boolean the user can leave unsaid: `--flag`, `--no-flag`, or
45
+ * neither, which arrives as undefined. Use it when absence means
46
+ * something of its own — "ask me" rather than "no".
47
+ */
48
+ optionalBoolean<A extends string = never>(spec: {
49
+ brief: string;
50
+ alias?: A & Char<A>;
51
+ }): FlagSpec<boolean | undefined>;
43
52
  enum<const T extends readonly string[], A extends string = never>(spec: {
44
53
  brief: string;
45
54
  values: T;
@@ -415,9 +424,8 @@ interface PresentedResult<T> {
415
424
  readonly diagnostics: readonly Diagnostic[];
416
425
  /**
417
426
  * Only the active format's presentation is materialized; the other
418
- * format's fields are normalized to empty. `json` stays undefined
419
- * when the handler supplied no json presentation — the envelope's
420
- * `result` then falls back to `data`.
427
+ * format's fields are normalized to empty. In human mode `json` is
428
+ * undefined because the json presentation was never invoked.
421
429
  */
422
430
  readonly presentation: {
423
431
  readonly human: readonly Block[];
@@ -428,16 +436,19 @@ interface PresentedResult<T> {
428
436
  }
429
437
  /**
430
438
  * The per-format presentation functions a handler supplies to
431
- * ctx.present. Only the active format's functions are invoked, at the
432
- * return site. `human` composes engine primitives, rendered to stderr;
433
- * `stdout` is the machine-consumable data lines — what a pipe
434
- * receives, the human mode's only stdout writes.
439
+ * ctx.present. Every one is required: a command states each output
440
+ * surface it publishes rather than inheriting one by omission. Only the
441
+ * active format's functions are invoked, at the return site. `human`
442
+ * composes engine primitives, rendered to stderr; `stdout` is the
443
+ * machine-consumable data lines — what a pipe receives, the human
444
+ * mode's only stdout writes; `json` is the `--json` envelope's
445
+ * `result`; `next` is the suggested follow-up actions.
435
446
  */
436
447
  interface Presentations {
437
448
  readonly human: (ui: Ui) => readonly Block[];
438
- readonly stdout?: () => readonly string[];
439
- readonly json?: () => unknown;
440
- readonly next?: () => readonly NextAction[];
449
+ readonly stdout: () => readonly string[];
450
+ readonly json: () => unknown;
451
+ readonly next: () => readonly NextAction[];
441
452
  }
442
453
  /**
443
454
  * What happened: it selects the glyph (✔ ✘ ⚠ ℹ) and carries a default
@@ -535,6 +546,57 @@ interface Ui {
535
546
  readonly tone: (tone: Tone, text: string) => string;
536
547
  }
537
548
  //#endregion
549
+ //#region src/package-manager.d.ts
550
+ /** The package managers the engine knows how to drive. */
551
+ type PackageManagerId = "npm" | "pnpm" | "yarn" | "bun" | "deno";
552
+ /**
553
+ * ctx.packages: what a command declaring `installsPackages` may do to
554
+ * the user's project. Both operations resolve — a manager that failed
555
+ * is a value, not a throw — except under cancellation, which throws the
556
+ * abort reason so the run settles the way Ctrl-C settles everywhere
557
+ * else. Neither may be called while the other is still running.
558
+ *
559
+ * Success carries nothing back: the command line stays with the engine,
560
+ * which announces it, streams the manager's output under it, and puts
561
+ * the redacted spelling on a failure's next action.
562
+ */
563
+ interface PackageOperations {
564
+ /** Adds dependencies to the project. */
565
+ install(request: {
566
+ /** Specifiers as the user would type them, e.g. "prisma@latest". */readonly packages: readonly string[];
567
+ readonly dev?: boolean; /** Defaults to ctx.cwd. */
568
+ readonly cwd?: string; /** Overrides detection, so a caller can retry with another manager. */
569
+ readonly manager?: PackageManagerId;
570
+ }): Promise<Result<void, CliStructuredError>>;
571
+ /** Runs a package's bin once, without adding a dependency. */
572
+ run(request: {
573
+ /** The package whose bin to execute, e.g. "skills". */readonly package: string;
574
+ readonly args: readonly string[]; /** Defaults to ctx.cwd. */
575
+ readonly cwd?: string; /** Overrides detection, so a caller can retry with another manager. */
576
+ readonly manager?: PackageManagerId;
577
+ }): Promise<Result<void, CliStructuredError>>;
578
+ }
579
+ /** One package-manager execution, handed to the host to spawn. */
580
+ interface PackageManagerRunRequest {
581
+ readonly file: string;
582
+ readonly args: readonly string[];
583
+ readonly cwd: string;
584
+ readonly signal: AbortSignal;
585
+ /** Called with each chunk as the child writes it, so the engine can
586
+ * emit `output` events while the operation runs. */
587
+ readonly onOutput: (channel: "data" | "diagnostic", chunk: string) => void;
588
+ }
589
+ /** What the child produced: its exit code — non-zero covers a manager
590
+ * that failed and an executable that was not there — and its stderr,
591
+ * bounded to the last 64 KiB. */
592
+ interface PackageManagerRunResult {
593
+ readonly exitCode: number;
594
+ readonly stderr: string;
595
+ }
596
+ /** Spawns a package manager on the engine's behalf. A manager that
597
+ * fails is a resolved result, never a rejection. */
598
+ type PackageManagerRunner = (request: PackageManagerRunRequest) => Promise<PackageManagerRunResult>;
599
+ //#endregion
538
600
  //#region src/spawn.d.ts
539
601
  /** A fully composed child invocation. `env` is the child's COMPLETE
540
602
  * environment: the engine has already merged the invocation
@@ -611,6 +673,302 @@ interface ExitWithChildStatusOptions {
611
673
  */
612
674
  declare function exitWithChildStatus(options?: ExitWithChildStatusOptions): ChildStatusSettlement;
613
675
  //#endregion
676
+ //#region src/run-summary.d.ts
677
+ /**
678
+ * The value-free command snapshot the engine records at parse time.
679
+ * The engine's own telemetry composes its payload from it at command
680
+ * start, and it rides along on the RunSummary a bin may observe.
681
+ * Carries NO user data — command-path segments, flag names with their
682
+ * value source, and a bare count of positionals. Flag values,
683
+ * positional values, and raw argv never appear here.
684
+ */
685
+ interface EngineCommandSnapshot {
686
+ /** Mount-path segments of the executed command ('telemetry status'
687
+ * → ['telemetry', 'status']). Never includes the binary name. */
688
+ readonly commandPath: readonly string[];
689
+ /**
690
+ * One entry per flag the command accepts (the engine-injected shared
691
+ * family first, then the command's own declarations), named in the
692
+ * user-facing kebab-case spelling. `source` is what the engine knows
693
+ * at parse time: flags explicitly present on argv are 'cli'; the
694
+ * engine reads no flags from the environment today, so everything
695
+ * else is 'default'. 'env' is reserved for a future env-sourced
696
+ * flag mechanism.
697
+ */
698
+ readonly flags: ReadonlyArray<{
699
+ readonly name: string;
700
+ readonly source: "cli" | "env" | "default";
701
+ }>;
702
+ /** How many positional arguments the run supplied — a count only. */
703
+ readonly positionalCount: number;
704
+ }
705
+ /**
706
+ * What `RunHooks.onSettled` receives, exactly once per run, after the
707
+ * run has settled (exit code determined, terminal output written).
708
+ * Never fired for `--help` or `--version`, and never for a run that
709
+ * failed before a mounted command was reached (nothing executed, so
710
+ * there is no snapshot to report). `durationMs` comes from the
711
+ * engine's injectable clock.
712
+ */
713
+ interface RunSummary {
714
+ /** The mounted command's dotted id ('telemetry.status'). Derived
715
+ * from the same mount entry as `snapshot.commandPath` — it always
716
+ * equals `snapshot.commandPath.join('.')`. Both are kept: consumers
717
+ * addressing the command use the id; the snapshot is the value-free
718
+ * wire projection. */
719
+ readonly commandId: string;
720
+ readonly exitCode: number;
721
+ readonly durationMs: number;
722
+ readonly snapshot: EngineCommandSnapshot;
723
+ }
724
+ //#endregion
725
+ //#region src/telemetry/payload.d.ts
726
+ /**
727
+ * The payload the engine composes at command start and hands to
728
+ * `Runtime.spawnTelemetry`. The host forwards it to its own sender,
729
+ * which probes its process (runtime/os/arch, package manager, ts
730
+ * version, agent) for the rest of the event and POSTs it.
731
+ *
732
+ * Both sides version-couple on this shape: the carrier is Node's
733
+ * structured clone over IPC, so there is no on-wire compat to maintain.
734
+ */
735
+ interface TelemetryPayload {
736
+ readonly installationId: string;
737
+ readonly version: string;
738
+ /** The command path joined with spaces — `postgres create`. */
739
+ readonly command: string;
740
+ /** Names only, of the flags the user typed. Never values. */
741
+ readonly flags: readonly string[];
742
+ /**
743
+ * Absolute path of the user's project. The sender reads
744
+ * `<projectRoot>/package.json` for `tsVersion`.
745
+ */
746
+ readonly projectRoot: string;
747
+ /** Resolved endpoint URL (already includes the `/events` path). */
748
+ readonly endpoint: string;
749
+ /**
750
+ * Kept for wire compatibility with the ORM CLI's first-`init` flow,
751
+ * where the chosen target is known before the config file exists. The
752
+ * engine never populates it; the wire-format event keeps `null` as its
753
+ * "no target known" marker, but this channel needs only two states so
754
+ * the field is `string | undefined`.
755
+ */
756
+ readonly databaseTarget?: string;
757
+ }
758
+ //#endregion
759
+ //#region src/runtime.d.ts
760
+ /** Minimal structural stream types; no NodeJS.* in the public surface. */
761
+ interface OutputStream {
762
+ write(text: string): void;
763
+ /** The stream's terminal width, absent when it is not a terminal.
764
+ * The engine reads it at render time rather than caching it, so a
765
+ * terminal resized mid-run is respected by the next thing drawn. */
766
+ readonly columns?: number;
767
+ }
768
+ /**
769
+ * Byte-oriented, so server commands can implement byte-counted
770
+ * protocols (lsp's Content-Length framing). setRawMode is present
771
+ * where the platform supports keypress input.
772
+ */
773
+ interface InputStream extends AsyncIterable<Uint8Array> {
774
+ readonly setRawMode?: (enabled: boolean) => void;
775
+ }
776
+ /** Everything environmental, injected once by the bin (or by a test). */
777
+ interface Runtime {
778
+ readonly stdout: OutputStream;
779
+ readonly stderr: OutputStream;
780
+ readonly stdin: InputStream;
781
+ readonly cwd: string;
782
+ readonly env: Readonly<Record<string, string | undefined>>;
783
+ readonly isTty: {
784
+ readonly stdin: boolean;
785
+ readonly stdout: boolean;
786
+ readonly stderr: boolean;
787
+ };
788
+ /**
789
+ * Whether stdout and stderr are the same open device — the case where
790
+ * human blocks and the machine stdout mirror would draw on one screen
791
+ * as visible duplication. Consulted only when both streams are TTYs:
792
+ * `false` there means two separate terminals, so the mirror is kept
793
+ * for whatever is reading stdout. Absent means the host cannot tell,
794
+ * which is treated as "same" — the overwhelmingly common case for two
795
+ * TTYs is one terminal.
796
+ */
797
+ readonly outputStreamsShareDevice?: boolean;
798
+ /**
799
+ * Forces the answer to "is this CI", where telemetry never reports.
800
+ * Absent — the normal case — means the engine detects CI from `env`
801
+ * using ci-info's vendor table, which is why no host has to answer:
802
+ * unlike a TTY, CI-ness is derivable from the environment the host
803
+ * already injects, and every host computing the same boolean was the
804
+ * same detection table forked N ways. Set it only where detection
805
+ * cannot be right — an exotic platform, or a test that needs both
806
+ * sides of the branch. Absence means detected, never false, so a host
807
+ * that says nothing still stays silent in CI.
808
+ */
809
+ readonly isCIOverride?: boolean;
810
+ /**
811
+ * Ends the process. The bin passes process.exit; the engine is the
812
+ * only caller (second-signal force exit, 130/143).
813
+ */
814
+ readonly exit: (code: number) => never;
815
+ /**
816
+ * Subscribes to delivered SIGINT/SIGTERM; returns the unsubscribe.
817
+ * The bin is dumb wiring — the engine owns the whole signal policy:
818
+ * the first signal aborts ctx.signal and awaits teardown; a second
819
+ * calls exit(130|143) immediately.
820
+ */
821
+ readonly onSignal: (cb: (signal: "SIGINT" | "SIGTERM") => void) => () => void;
822
+ /**
823
+ * Reads prisma.config.ts, on demand. The engine calls it only when
824
+ * the command it is about to run declares a config section, so a run
825
+ * that needs no config never touches the file. `configPath` is the
826
+ * file `--config` named: the loader resolves it against the runtime's
827
+ * cwd and reports its absence. Absent means look for prisma.config.ts
828
+ * in cwd, where absence is not an error. The bin wires the real disk
829
+ * loader; tests hand in fixtures.
830
+ */
831
+ readonly loadConfig: (configPath?: string) => Promise<LoadedConfig>;
832
+ /**
833
+ * The credential manager the bin wires. It is the only source of
834
+ * the needs check, ctx.activeCredential, and ctx.api; absent means
835
+ * this host has no credentials at all, and every command that needs
836
+ * them fails as signed out.
837
+ */
838
+ readonly credentialManager?: CredentialManager;
839
+ /**
840
+ * SDK client construction config the bin injects beside the
841
+ * manager; the engine builds ctx.api from it. Required whenever a
842
+ * credentialManager is wired.
843
+ */
844
+ readonly managementApiClientConfig?: ManagementApiClientConfig;
845
+ /**
846
+ * Opens a URL in the user's browser, wired by the bin (the login
847
+ * flow's opener). The engine calls it only for interactive sessions,
848
+ * treats a throw as "did not open", and never fails a command over
849
+ * it. Absent means this host cannot open a browser: the engine
850
+ * announces the URL instead.
851
+ */
852
+ readonly openUrl?: (url: string) => Promise<void> | void;
853
+ /**
854
+ * Starts a child process with inherited stdio, wired by the bin (a
855
+ * node:child_process adapter) so the engine never imports it. Absent
856
+ * means this host cannot hand the terminal to a child: a maySpawn
857
+ * command is refused as an internal error before its needs check and
858
+ * handler run, so ctx.spawn is never reached.
859
+ */
860
+ readonly spawn?: SpawnChild;
861
+ /**
862
+ * Fire-and-forget delivery of one composed telemetry payload. The bin
863
+ * owns the process work and the detachment, which is why the engine
864
+ * imports no child_process and performs no network I/O for telemetry.
865
+ * Absent means this host reports nothing — not an error, and the whole
866
+ * sequence is skipped rather than only the delivery: no config read,
867
+ * no disclosure, no mint.
868
+ */
869
+ readonly spawnTelemetry?: (payload: TelemetryPayload) => void;
870
+ /** Management API endpoint config; the bin derives baseUrl from env. */
871
+ readonly managementApi: {
872
+ readonly baseUrl: string;
873
+ };
874
+ /**
875
+ * A host that knows its user's package manager better than detection
876
+ * does. Absent — the normal case — means the engine detects it from
877
+ * the project at cwd.
878
+ */
879
+ readonly packageManager?: PackageManagerId;
880
+ /**
881
+ * Spawns the package manager the engine composed. The engine never
882
+ * imports child_process; this is the only way a manager runs. It is
883
+ * optional so a harness can exercise the no-runner path — every
884
+ * shipped host wires it, and a host without it can run no package
885
+ * operation at all.
886
+ */
887
+ readonly runPackageManager?: PackageManagerRunner;
888
+ /** What this process is running on. The bin reads it once; commands
889
+ * take it from ctx.host rather than from process. */
890
+ readonly host: Host;
891
+ }
892
+ /**
893
+ * The facts a command may legitimately need about the machine it runs
894
+ * on: what to put in a bug report, and the rare genuine behavioural
895
+ * difference (symlinks need a privilege on Windows).
896
+ *
897
+ * Deliberately not node-shaped. Products are runtime-agnostic (R4), so
898
+ * the runtime names itself rather than the field naming it.
899
+ */
900
+ interface Host {
901
+ readonly runtime: {
902
+ readonly name: string;
903
+ readonly version: string;
904
+ };
905
+ readonly platform: string;
906
+ readonly arch: string;
907
+ }
908
+ /**
909
+ * The minimal process surface a bin adapts a Runtime from — Node's
910
+ * `process` satisfies it structurally. The engine never reads it; it
911
+ * exists so bins and their tests share one adapter shape.
912
+ */
913
+ interface HostProcess {
914
+ readonly argv: readonly string[];
915
+ readonly env: Readonly<Record<string, string | undefined>>;
916
+ readonly version: string;
917
+ readonly versions: Readonly<Record<string, string | undefined>>;
918
+ readonly platform: string;
919
+ readonly arch: string;
920
+ cwd(): string;
921
+ readonly stdout: {
922
+ write(text: string): unknown;
923
+ isTTY?: boolean;
924
+ };
925
+ readonly stderr: {
926
+ write(text: string): unknown;
927
+ isTTY?: boolean;
928
+ columns?: number;
929
+ };
930
+ readonly stdin: {
931
+ isTTY?: boolean;
932
+ setRawMode?(enabled: boolean): unknown;
933
+ [Symbol.asyncIterator](): AsyncIterator<Uint8Array>;
934
+ };
935
+ on(event: "SIGINT" | "SIGTERM", listener: () => void): unknown;
936
+ off(event: "SIGINT" | "SIGTERM", listener: () => void): unknown;
937
+ exit(code: number): never;
938
+ }
939
+ interface LoadedConfig {
940
+ /**
941
+ * The file this config came from, absolute: the one `--config` named,
942
+ * or prisma.config.ts in cwd. A loader that found no file still names
943
+ * the file it looked for — with no file there are no sections, and
944
+ * the engine reads the path only to name the file when it reports a
945
+ * top-level key that is not one of the CLI's sections.
946
+ */
947
+ readonly path: string;
948
+ /**
949
+ * Raw section values by name; validation happens per command via its
950
+ * command family's section token. The engine, not the loader, checks
951
+ * these names against the sections the CLI declares, so the closed
952
+ * set holds whatever loader a host wires.
953
+ */
954
+ readonly sections: Readonly<Record<string, unknown>>;
955
+ /**
956
+ * File-level problems (unevaluable module, missing version marker)
957
+ * carry section: null and fail only commands with a needs.config
958
+ * section; commands with no config need run normally.
959
+ */
960
+ readonly diagnostics: ReadonlyArray<{
961
+ readonly section: string | null;
962
+ readonly diagnostic: Diagnostic;
963
+ }>;
964
+ }
965
+ /**
966
+ * The config contract version defineConfig writes as the structural
967
+ * `$prismaConfig` marker; the loader checks it before interpreting
968
+ * anything.
969
+ */
970
+ declare const PRISMA_CONFIG_VERSION = 1;
971
+ //#endregion
614
972
  //#region src/context.d.ts
615
973
  /** The handler context — the whole world arrives as one argument. */
616
974
  interface CommandContext<TConfig = undefined, TCode extends number = never> {
@@ -704,6 +1062,22 @@ interface CommandContext<TConfig = undefined, TCode extends number = never> {
704
1062
  * via ctx.env, never process.env.
705
1063
  */
706
1064
  readonly env: Readonly<Record<string, string | undefined>>;
1065
+ /**
1066
+ * What this process runs on, from Runtime.host. Handlers read the
1067
+ * runtime version, platform and architecture here — never from
1068
+ * `process` — so a bug-report payload and the occasional real
1069
+ * platform difference do not each reinvent the lookup.
1070
+ */
1071
+ readonly host: Host;
1072
+ /**
1073
+ * Whether this run is in CI: detected from the environment the host
1074
+ * injected, or forced by Runtime.isCIOverride. This is what telemetry
1075
+ * gates on. It is one input to the engine's interactivity decision
1076
+ * rather than the whole of it (which also weighs a TTY stdin and
1077
+ * --interactive/--no-interactive), so prompts and spinners follow
1078
+ * ctx.prompt and the engine's interaction handling, not this.
1079
+ */
1080
+ readonly isCI: boolean;
707
1081
  /**
708
1082
  * Conditional optional-dependency need. Resolves when the
709
1083
  * optional peer dependency is importable from the user's project;
@@ -800,156 +1174,6 @@ interface PromptSurface {
800
1174
  readonly browserWait: (request: BrowserWaitRequest) => Promise<void>;
801
1175
  }
802
1176
  //#endregion
803
- //#region src/runtime.d.ts
804
- /** Minimal structural stream types; no NodeJS.* in the public surface. */
805
- interface OutputStream {
806
- write(text: string): void;
807
- /** The stream's terminal width, absent when it is not a terminal.
808
- * The engine reads it at render time rather than caching it, so a
809
- * terminal resized mid-run is respected by the next thing drawn. */
810
- readonly columns?: number;
811
- }
812
- /**
813
- * Byte-oriented, so server commands can implement byte-counted
814
- * protocols (lsp's Content-Length framing). setRawMode is present
815
- * where the platform supports keypress input.
816
- */
817
- interface InputStream extends AsyncIterable<Uint8Array> {
818
- readonly setRawMode?: (enabled: boolean) => void;
819
- }
820
- /** Everything environmental, injected once by the bin (or by a test). */
821
- interface Runtime {
822
- readonly stdout: OutputStream;
823
- readonly stderr: OutputStream;
824
- readonly stdin: InputStream;
825
- readonly cwd: string;
826
- readonly env: Readonly<Record<string, string | undefined>>;
827
- readonly isTty: {
828
- readonly stdin: boolean;
829
- readonly stdout: boolean;
830
- readonly stderr: boolean;
831
- };
832
- /**
833
- * Ends the process. The bin passes process.exit; the engine is the
834
- * only caller (second-signal force exit, 130/143).
835
- */
836
- readonly exit: (code: number) => never;
837
- /**
838
- * Subscribes to delivered SIGINT/SIGTERM; returns the unsubscribe.
839
- * The bin is dumb wiring — the engine owns the whole signal policy:
840
- * the first signal aborts ctx.signal and awaits teardown; a second
841
- * calls exit(130|143) immediately.
842
- */
843
- readonly onSignal: (cb: (signal: "SIGINT" | "SIGTERM") => void) => () => void;
844
- /**
845
- * Reads prisma.config.ts, on demand. The engine calls it only when
846
- * the command it is about to run declares a config section, so a run
847
- * that needs no config never touches the file. `configPath` is the
848
- * file `--config` named: the loader resolves it against the runtime's
849
- * cwd and reports its absence. Absent means look for prisma.config.ts
850
- * in cwd, where absence is not an error. The bin wires the real disk
851
- * loader; tests hand in fixtures.
852
- */
853
- readonly loadConfig: (configPath?: string) => Promise<LoadedConfig>;
854
- /**
855
- * The credential manager the bin wires. It is the only source of
856
- * the needs check, ctx.activeCredential, and ctx.api; absent means
857
- * this host has no credentials at all, and every command that needs
858
- * them fails as signed out.
859
- */
860
- readonly credentialManager?: CredentialManager;
861
- /**
862
- * SDK client construction config the bin injects beside the
863
- * manager; the engine builds ctx.api from it. Required whenever a
864
- * credentialManager is wired.
865
- */
866
- readonly managementApiClientConfig?: ManagementApiClientConfig;
867
- /**
868
- * Opens a URL in the user's browser, wired by the bin (the login
869
- * flow's opener). The engine calls it only for interactive sessions,
870
- * treats a throw as "did not open", and never fails a command over
871
- * it. Absent means this host cannot open a browser: the engine
872
- * announces the URL instead.
873
- */
874
- readonly openUrl?: (url: string) => Promise<void> | void;
875
- /**
876
- * Starts a child process with inherited stdio, wired by the bin (a
877
- * node:child_process adapter) so the engine never imports it. Absent
878
- * means this host cannot hand the terminal to a child: a maySpawn
879
- * command is refused as an internal error before its needs check and
880
- * handler run, so ctx.spawn is never reached.
881
- */
882
- readonly spawn?: SpawnChild;
883
- /** Management API endpoint config; the bin derives baseUrl from env. */
884
- readonly managementApi: {
885
- readonly baseUrl: string;
886
- };
887
- /**
888
- * Used by the ENGINE to phrase install commands (handlers never do —
889
- * see needs.dependencies and ctx.requireDependency).
890
- */
891
- readonly packageManager: "npm" | "pnpm" | "yarn" | "bun" | "unknown";
892
- }
893
- /**
894
- * The minimal process surface a bin adapts a Runtime from — Node's
895
- * `process` satisfies it structurally. The engine never reads it; it
896
- * exists so bins and their tests share one adapter shape.
897
- */
898
- interface HostProcess {
899
- readonly argv: readonly string[];
900
- readonly env: Readonly<Record<string, string | undefined>>;
901
- cwd(): string;
902
- readonly stdout: {
903
- write(text: string): unknown;
904
- isTTY?: boolean;
905
- };
906
- readonly stderr: {
907
- write(text: string): unknown;
908
- isTTY?: boolean;
909
- columns?: number;
910
- };
911
- readonly stdin: {
912
- isTTY?: boolean;
913
- setRawMode?(enabled: boolean): unknown;
914
- [Symbol.asyncIterator](): AsyncIterator<Uint8Array>;
915
- };
916
- on(event: "SIGINT" | "SIGTERM", listener: () => void): unknown;
917
- off(event: "SIGINT" | "SIGTERM", listener: () => void): unknown;
918
- exit(code: number): never;
919
- }
920
- interface LoadedConfig {
921
- /**
922
- * The file this config came from, absolute: the one `--config` named,
923
- * or prisma.config.ts in cwd. A loader that found no file still names
924
- * the file it looked for — with no file there are no sections, and
925
- * the engine reads the path only to name the file when it reports a
926
- * top-level key that is not one of the CLI's sections.
927
- */
928
- readonly path: string;
929
- /**
930
- * Raw section values by name; validation happens per command via its
931
- * command family's section token. The engine, not the loader, checks
932
- * these names against the sections the CLI declares, so the closed
933
- * set holds whatever loader a host wires.
934
- */
935
- readonly sections: Readonly<Record<string, unknown>>;
936
- /**
937
- * File-level problems (unevaluable module, missing version marker)
938
- * carry section: null and fail only commands with a needs.config
939
- * section; commands with no config need run normally.
940
- */
941
- readonly diagnostics: ReadonlyArray<{
942
- readonly section: string | null;
943
- readonly diagnostic: Diagnostic;
944
- }>;
945
- }
946
- /**
947
- * The config contract version defineConfig writes as the structural
948
- * `$prismaConfig` marker; the loader checks it before interpreting
949
- * anything.
950
- */
951
- declare const PRISMA_CONFIG_VERSION = 1;
952
- //#endregion
953
1177
  //#region src/commands.d.ts
954
1178
  /**
955
1179
  * Command definitions carry no mount path and are runtime-discriminated
@@ -1038,7 +1262,7 @@ interface CommandNeeds<TConfig> {
1038
1262
  interface SpawnDeclarations {
1039
1263
  readonly maySpawn?: boolean;
1040
1264
  }
1041
- 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> {
1265
+ 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> {
1042
1266
  readonly kind: "result-command";
1043
1267
  readonly help: CommandHelp;
1044
1268
  readonly args: CommandArgs<TFlags, TPositionals>;
@@ -1060,6 +1284,12 @@ interface CommandDefinition<TFlags extends Record<string, FlagSpec<unknown>> = R
1060
1284
  readonly managesCredentials: TManagesCredentials;
1061
1285
  /** See SpawnDeclarations. */
1062
1286
  readonly maySpawn: boolean;
1287
+ /**
1288
+ * A CAPABILITY, not a need: when true, ctx.packages appears on the
1289
+ * context and the command may run the user's package manager in the
1290
+ * user's project. Declaring it never fails a run.
1291
+ */
1292
+ readonly installsPackages: TInstallsPackages;
1063
1293
  /**
1064
1294
  * The handler function, referenced directly — never a dynamic import
1065
1295
  * (operator ruling, 2026-08-09). A handler that needs heavy
@@ -1067,28 +1297,24 @@ interface CommandDefinition<TFlags extends Record<string, FlagSpec<unknown>> = R
1067
1297
  * handler defined in another file is imported statically and
1068
1298
  * annotated CommandHandler<typeof def>.
1069
1299
  */
1070
- readonly handler: Handler<TFlags, TPositionals, TConfig, TCode, TManagesCredentials>;
1300
+ readonly handler: Handler<TFlags, TPositionals, TConfig, TCode, TManagesCredentials, TInstallsPackages>;
1071
1301
  }
1072
- 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 ? {
1302
+ 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 ? {
1073
1303
  readonly credentialManager: CredentialManager;
1304
+ } : unknown) & (TInstallsPackages extends true ? {
1305
+ readonly packages: PackageOperations;
1074
1306
  } : unknown)) => Promise<Result<PresentedResult<unknown> | ChildStatusSettlement, CliStructuredError>>;
1075
1307
  /** For impl files: `const run: CommandHandler<typeof migrateCommand> = …` */
1076
- type CommandHandler<D> = D extends CommandDefinition<infer F, infer P, infer C, infer K, infer M> ? Handler<F, P, C, K, M> : never;
1077
- 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: {
1078
- readonly help: HelpSpec;
1079
- readonly args?: ArgsSpec<TFlags, TPositionals>;
1080
- readonly needs?: NeedsSpec<TConfig>;
1081
- readonly exitCodes?: Readonly<Record<TCode, string>>;
1082
- readonly managesCredentials: true;
1083
- readonly handler: Handler<TFlags, TPositionals, TConfig, TCode, true>;
1084
- } & SpawnDeclarations): CommandDefinition<TFlags, TPositionals, TConfig, TCode, true>;
1085
- 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: {
1308
+ 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;
1309
+ 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: {
1086
1310
  readonly help: HelpSpec;
1087
1311
  readonly args?: ArgsSpec<TFlags, TPositionals>;
1088
1312
  readonly needs?: NeedsSpec<TConfig>;
1089
1313
  readonly exitCodes?: Readonly<Record<TCode, string>>;
1090
- readonly handler: Handler<TFlags, TPositionals, TConfig, TCode>;
1091
- } & SpawnDeclarations): CommandDefinition<TFlags, TPositionals, TConfig, TCode>;
1314
+ readonly managesCredentials?: TManagesCredentials;
1315
+ readonly installsPackages?: TInstallsPackages;
1316
+ readonly handler: Handler<TFlags, TPositionals, TConfig, TCode, TManagesCredentials, TInstallsPackages>;
1317
+ } & SpawnDeclarations): CommandDefinition<TFlags, TPositionals, TConfig, TCode, TManagesCredentials, TInstallsPackages>;
1092
1318
  /**
1093
1319
  * A session command (dev, log tail): runs until the signal fires,
1094
1320
  * speaks entirely through events, returns Result<void>. No
@@ -1155,7 +1381,7 @@ declare function defineServerCommand<TFlags extends Record<string, FlagSpec<unkn
1155
1381
  * concrete types travel through each definition's generics, not through
1156
1382
  * this union.
1157
1383
  */
1158
- type AnyCommand = (Omit<CommandDefinition<Record<string, FlagSpec<unknown>>, Record<string, PositionalSpec<unknown>>, unknown, number, boolean>, "handler"> & {
1384
+ type AnyCommand = (Omit<CommandDefinition<Record<string, FlagSpec<unknown>>, Record<string, PositionalSpec<unknown>>, unknown, number, boolean, boolean>, "handler"> & {
1159
1385
  readonly handler: unknown;
1160
1386
  }) | (Omit<SessionCommandDefinition<Record<string, FlagSpec<unknown>>, Record<string, PositionalSpec<unknown>>, unknown>, "handler"> & {
1161
1387
  readonly handler: unknown;
@@ -1263,52 +1489,16 @@ declare function defineCommandFamily(spec: {
1263
1489
  /** What the shell builds: commands by PATH (space-separated, 'db migrate'). */
1264
1490
  type MountedTree = Readonly<Record<string, AnyCommand>>;
1265
1491
  //#endregion
1266
- //#region src/run-summary.d.ts
1492
+ //#region src/telemetry/report.d.ts
1267
1493
  /**
1268
- * The value-free command snapshot the engine records at parse time and
1269
- * hands to `RunHooks.onSettled`. Consumed by the shell's telemetry
1270
- * wiring; carries NO user data — command-path segments, flag names
1271
- * with their value source, and a bare count of positionals. Flag
1272
- * values, positional values, and raw argv never appear here.
1494
+ * What a CLI declares to report. One field: the endpoint, the opt-out
1495
+ * variable names, the config path and the disclosure wording are Prisma
1496
+ * constants the engine owns. Omitting the declaration means the CLI
1497
+ * reports nothing at all.
1273
1498
  */
1274
- interface EngineCommandSnapshot {
1275
- /** Mount-path segments of the executed command ('telemetry status'
1276
- * → ['telemetry', 'status']). Never includes the binary name. */
1277
- readonly commandPath: readonly string[];
1278
- /**
1279
- * One entry per flag the command accepts (the engine-injected shared
1280
- * family first, then the command's own declarations), named in the
1281
- * user-facing kebab-case spelling. `source` is what the engine knows
1282
- * at parse time: flags explicitly present on argv are 'cli'; the
1283
- * engine reads no flags from the environment today, so everything
1284
- * else is 'default'. 'env' is reserved for a future env-sourced
1285
- * flag mechanism.
1286
- */
1287
- readonly flags: ReadonlyArray<{
1288
- readonly name: string;
1289
- readonly source: "cli" | "env" | "default";
1290
- }>;
1291
- /** How many positional arguments the run supplied — a count only. */
1292
- readonly positionalCount: number;
1293
- }
1294
- /**
1295
- * What `RunHooks.onSettled` receives, exactly once per run, after the
1296
- * run has settled (exit code determined, terminal output written).
1297
- * Never fired for `--help` or `--version`, and never for a run that
1298
- * failed before a mounted command was reached (nothing executed, so
1299
- * there is no snapshot to report). `durationMs` comes from the
1300
- * engine's injectable clock.
1301
- */
1302
- interface RunSummary {
1303
- /** The mounted command's dotted id ('telemetry.status'). Derived
1304
- * from the same mount entry as `snapshot.commandPath` — it always
1305
- * equals `snapshot.commandPath.join('.')`. Both are kept: consumers
1306
- * addressing the command use the id; the snapshot is the value-free
1307
- * wire projection. */
1308
- readonly commandId: string;
1309
- readonly exitCode: number;
1310
- readonly durationMs: number;
1311
- readonly snapshot: EngineCommandSnapshot;
1499
+ interface TelemetryDeclaration {
1500
+ /** Named in the first-run disclosure as where to read what is collected. */
1501
+ readonly docsUrl: string;
1312
1502
  }
1313
1503
  //#endregion
1314
- export { TreeNode as $, BrowserWaitRequest as A, SpawnRequest as B, defineSessionCommand as C, FlagSpec as Ct, OutputStream as D, LoadedConfig as E, positional as Et, 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, Tone as Q, SpawnChild as R, defineServerCommand as S, CommandArgs as St, InputStream as T, flag as Tt, Block as U, SpawnedChild as V, Format as W, Status as X, Span as Y, Text as Z, NeedsSpec as _, SectionValidation as _t, MountedTree as a, ActiveCredential as at, SpawnDeclarations as b, ArgsSpec as bt, AnyCommand as c, CredentialManager as ct, CommandHelp as d, Session as dt, Ui as et, CommandNeeds as f, StoredSessions as ft, HelpSpec as g, ConfigSection as gt, Handler as h, TokenStorage$1 as ht, CommandRedirect as i, StreamMeta as it, CommandContext as j, Runtime as k, CommandDefinition as l, CredentialOrigin as lt, ErroredEnvelope as m, ManagementApiClientConfig as mt, RunSummary as n, Severity as nt, RedirectSpec as o, Credential as ot, CompletedEnvelope as p, ManagementApiClient$1 as pt, Presentations as q, CommandFamily as r, StreamEvent as rt, defineCommandFamily as s, CredentialIdentity as st, EngineCommandSnapshot as t, EngineEvent as tt, CommandHandler as u, SERVICE_TOKEN_ENV_VAR as ut, ServerCommandDefinition as v, defineConfigSection as vt, HostProcess as w, PositionalSpec as wt, defineCommand as x, Char as xt, SessionCommandDefinition as y, Args as yt, SpawnOptions as z };
1504
+ export { Outcome as $, InputStream as A, CommandArgs as At, ExitWithChildStatusOptions as B, BrowserWaitRequest as C, TokenStorage$1 as Ct, PromptSurface as D, Args as Dt, OpenUrlRequest as E, defineConfigSection as Et, TelemetryPayload as F, exitWithChildStatus as G, SpawnOptions as H, EngineCommandSnapshot as I, PackageManagerRunResult as J, PackageManagerId as K, RunSummary as L, OutputStream as M, PositionalSpec as Mt, PRISMA_CONFIG_VERSION as N, flag as Nt, Host as O, ArgsSpec as Ot, Runtime as P, positional as Pt, Format as Q, ChildResult as R, defineSessionCommand as S, ManagementApiClientConfig as St, OpenUrlOutcome as T, SectionValidation as Tt, SpawnRequest as U, SpawnChild as V, SpawnedChild as W, PackageOperations as X, PackageManagerRunner as Y, Block as Z, ServerCommandDefinition as _, CredentialOrigin as _t, RedirectSpec as a, Text as at, defineCommand as b, StoredSessions as bt, CommandDefinition as c, Ui as ct, CommandNeeds as d, StreamEvent as dt, PRESENTED as et, CompletedEnvelope as f, StreamMeta as ft, NeedsSpec as g, CredentialManager as gt, HelpSpec as h, CredentialIdentity as ht, MountedTree as i, Status as it, LoadedConfig as j, FlagSpec as jt, HostProcess as k, Char as kt, CommandHandler as l, EngineEvent as lt, Handler as m, Credential as mt, CommandFamily as n, PresentedResult as nt, defineCommandFamily as o, Tone as ot, ErroredEnvelope as p, ActiveCredential as pt, PackageManagerRunRequest as q, CommandRedirect as r, Span as rt, AnyCommand as s, TreeNode as st, TelemetryDeclaration as t, Presentations as tt, CommandHelp as u, Severity as ut, SessionCommandDefinition as v, SERVICE_TOKEN_ENV_VAR as vt, CommandContext as w, ConfigSection as wt, defineServerCommand as x, ManagementApiClient$1 as xt, SpawnDeclarations as y, Session as yt, ChildStatusSettlement as z };