@karmaniverous/get-dotenv 6.0.0-0 → 6.0.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.
Files changed (93) hide show
  1. package/README.md +86 -334
  2. package/dist/cli.d.ts +569 -0
  3. package/dist/cli.mjs +18788 -0
  4. package/dist/cliHost.d.ts +548 -253
  5. package/dist/cliHost.mjs +1990 -1458
  6. package/dist/config.d.ts +192 -14
  7. package/dist/config.mjs +256 -81
  8. package/dist/env-overlay.d.ts +226 -18
  9. package/dist/env-overlay.mjs +181 -22
  10. package/dist/getdotenv.cli.mjs +18166 -3437
  11. package/dist/index.d.ts +729 -136
  12. package/dist/index.mjs +18207 -3457
  13. package/dist/plugins-aws.d.ts +289 -104
  14. package/dist/plugins-aws.mjs +2462 -350
  15. package/dist/plugins-batch.d.ts +355 -105
  16. package/dist/plugins-batch.mjs +2595 -420
  17. package/dist/plugins-cmd.d.ts +287 -118
  18. package/dist/plugins-cmd.mjs +2661 -839
  19. package/dist/plugins-init.d.ts +272 -100
  20. package/dist/plugins-init.mjs +2152 -37
  21. package/dist/plugins.d.ts +323 -140
  22. package/dist/plugins.mjs +18006 -2025
  23. package/dist/templates/cli/index.ts +26 -0
  24. package/dist/templates/cli/plugins/hello.ts +43 -0
  25. package/dist/templates/config/js/getdotenv.config.js +20 -0
  26. package/dist/templates/config/json/local/getdotenv.config.local.json +7 -0
  27. package/dist/templates/config/json/public/getdotenv.config.json +9 -0
  28. package/dist/templates/config/public/getdotenv.config.json +8 -0
  29. package/dist/templates/config/ts/getdotenv.config.ts +28 -0
  30. package/dist/templates/config/yaml/local/getdotenv.config.local.yaml +7 -0
  31. package/dist/templates/config/yaml/public/getdotenv.config.yaml +7 -0
  32. package/dist/templates/getdotenv.config.js +20 -0
  33. package/dist/templates/getdotenv.config.json +9 -0
  34. package/dist/templates/getdotenv.config.local.json +7 -0
  35. package/dist/templates/getdotenv.config.local.yaml +7 -0
  36. package/dist/templates/getdotenv.config.ts +28 -0
  37. package/dist/templates/getdotenv.config.yaml +7 -0
  38. package/dist/templates/hello.ts +43 -0
  39. package/dist/templates/index.ts +26 -0
  40. package/dist/templates/js/getdotenv.config.js +20 -0
  41. package/dist/templates/json/local/getdotenv.config.local.json +7 -0
  42. package/dist/templates/json/public/getdotenv.config.json +9 -0
  43. package/dist/templates/local/getdotenv.config.local.json +7 -0
  44. package/dist/templates/local/getdotenv.config.local.yaml +7 -0
  45. package/dist/templates/plugins/hello.ts +43 -0
  46. package/dist/templates/public/getdotenv.config.json +9 -0
  47. package/dist/templates/public/getdotenv.config.yaml +7 -0
  48. package/dist/templates/ts/getdotenv.config.ts +28 -0
  49. package/dist/templates/yaml/local/getdotenv.config.local.yaml +7 -0
  50. package/dist/templates/yaml/public/getdotenv.config.yaml +7 -0
  51. package/getdotenv.config.json +1 -19
  52. package/package.json +52 -89
  53. package/templates/cli/index.ts +26 -0
  54. package/templates/cli/plugins/hello.ts +43 -0
  55. package/templates/config/js/getdotenv.config.js +9 -4
  56. package/templates/config/json/public/getdotenv.config.json +0 -3
  57. package/templates/config/public/getdotenv.config.json +0 -5
  58. package/templates/config/ts/getdotenv.config.ts +17 -5
  59. package/templates/config/yaml/public/getdotenv.config.yaml +0 -3
  60. package/dist/cliHost.cjs +0 -2078
  61. package/dist/cliHost.d.cts +0 -451
  62. package/dist/cliHost.d.mts +0 -451
  63. package/dist/config.cjs +0 -252
  64. package/dist/config.d.cts +0 -55
  65. package/dist/config.d.mts +0 -55
  66. package/dist/env-overlay.cjs +0 -163
  67. package/dist/env-overlay.d.cts +0 -50
  68. package/dist/env-overlay.d.mts +0 -50
  69. package/dist/index.cjs +0 -4077
  70. package/dist/index.d.cts +0 -318
  71. package/dist/index.d.mts +0 -318
  72. package/dist/plugins-aws.cjs +0 -666
  73. package/dist/plugins-aws.d.cts +0 -158
  74. package/dist/plugins-aws.d.mts +0 -158
  75. package/dist/plugins-batch.cjs +0 -658
  76. package/dist/plugins-batch.d.cts +0 -181
  77. package/dist/plugins-batch.d.mts +0 -181
  78. package/dist/plugins-cmd.cjs +0 -1112
  79. package/dist/plugins-cmd.d.cts +0 -178
  80. package/dist/plugins-cmd.d.mts +0 -178
  81. package/dist/plugins-demo.cjs +0 -352
  82. package/dist/plugins-demo.d.cts +0 -158
  83. package/dist/plugins-demo.d.mts +0 -158
  84. package/dist/plugins-demo.d.ts +0 -158
  85. package/dist/plugins-demo.mjs +0 -350
  86. package/dist/plugins-init.cjs +0 -289
  87. package/dist/plugins-init.d.cts +0 -162
  88. package/dist/plugins-init.d.mts +0 -162
  89. package/dist/plugins.cjs +0 -2327
  90. package/dist/plugins.d.cts +0 -211
  91. package/dist/plugins.d.mts +0 -211
  92. package/templates/cli/ts/index.ts +0 -9
  93. package/templates/cli/ts/plugins/hello.ts +0 -17
package/dist/cliHost.d.ts CHANGED
@@ -1,312 +1,510 @@
1
- import { Command, Option } from 'commander';
2
- import { ZodType } from 'zod';
1
+ import { OptionValues, Command, InferCommandArguments, Option, CommandUnknownOpts } from '@commander-js/extra-typings';
2
+ import { z, ZodObject } from 'zod';
3
+ export { z } from 'zod';
3
4
 
4
5
  /**
5
6
  * Minimal root options shape shared by CLI and generator layers.
6
7
  * Keep keys optional to respect exactOptionalPropertyTypes semantics.
8
+ *
9
+ * @public
7
10
  */
8
- type RootOptionsShape = {
11
+ interface RootOptionsShape {
12
+ /** Target environment (dotenv-expanded). */
9
13
  env?: string;
14
+ /** Explicit variable overrides (dotenv-expanded). */
10
15
  vars?: string;
16
+ /** Command to execute (dotenv-expanded). */
11
17
  command?: string;
18
+ /** Output path for the consolidated environment file (dotenv-expanded). */
12
19
  outputPath?: string;
20
+ /**
21
+ * Shell execution strategy.
22
+ * - `true`: use default OS shell.
23
+ * - `false`: use plain execution (no shell).
24
+ * - string: use specific shell path.
25
+ */
13
26
  shell?: string | boolean;
27
+ /** Whether to load variables into `process.env`. */
14
28
  loadProcess?: boolean;
29
+ /** Exclude all variables from loading. */
15
30
  excludeAll?: boolean;
31
+ /** Exclude dynamic variables. */
16
32
  excludeDynamic?: boolean;
33
+ /** Exclude environment-specific variables. */
17
34
  excludeEnv?: boolean;
35
+ /** Exclude global variables. */
18
36
  excludeGlobal?: boolean;
37
+ /** Exclude private variables. */
19
38
  excludePrivate?: boolean;
39
+ /** Exclude public variables. */
20
40
  excludePublic?: boolean;
41
+ /** Enable console logging of loaded variables. */
21
42
  log?: boolean;
43
+ /** Enable debug logging to stderr. */
22
44
  debug?: boolean;
45
+ /** Capture child process stdio (useful for tests/CI). */
23
46
  capture?: boolean;
47
+ /** Fail on validation errors (schema/requiredKeys). */
24
48
  strict?: boolean;
49
+ /** Enable presentation-time redaction of secret-like keys. */
25
50
  redact?: boolean;
51
+ /** Enable entropy warnings for high-entropy values. */
26
52
  warnEntropy?: boolean;
53
+ /** Entropy threshold (bits/char) for warnings (default 3.8). */
27
54
  entropyThreshold?: number;
55
+ /** Minimum string length to check for entropy (default 16). */
28
56
  entropyMinLength?: number;
29
- entropyWhitelist?: string[];
57
+ /** Regex patterns for keys to exclude from entropy checks. */
58
+ entropyWhitelist?: ReadonlyArray<string>;
59
+ /** Additional regex patterns for keys to redact. */
30
60
  redactPatterns?: string[];
61
+ /** Default target environment when not specified. */
31
62
  defaultEnv?: string;
63
+ /** Token indicating a dotenv file (default: ".env"). */
32
64
  dotenvToken?: string;
65
+ /** Path to dynamic variables module (default: undefined). */
33
66
  dynamicPath?: string;
67
+ /**
68
+ * Emit diagnostics for child env composition.
69
+ * - `true`: trace all keys.
70
+ * - `string[]`: trace selected keys.
71
+ */
34
72
  trace?: boolean | string[];
73
+ /** Paths to search for dotenv files (space-delimited string or array). */
35
74
  paths?: string;
75
+ /** Delimiter for paths string (default: space). */
36
76
  pathsDelimiter?: string;
77
+ /** Regex pattern for paths delimiter. */
37
78
  pathsDelimiterPattern?: string;
79
+ /** Token indicating private variables (default: "local"). */
38
80
  privateToken?: string;
81
+ /** Delimiter for vars string (default: space). */
39
82
  varsDelimiter?: string;
83
+ /** Regex pattern for vars delimiter. */
40
84
  varsDelimiterPattern?: string;
85
+ /** Assignment operator for vars (default: "="). */
41
86
  varsAssignor?: string;
87
+ /** Regex pattern for vars assignment operator. */
42
88
  varsAssignorPattern?: string;
89
+ /** Table of named scripts for execution. */
43
90
  scripts?: ScriptsTable;
44
- };
91
+ }
45
92
  /**
46
- * Scripts table shape (configurable shell type).
93
+ * Definition for a single script entry.
47
94
  */
48
- type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<string, string | {
95
+ interface ScriptDef<TShell extends string | boolean = string | boolean> {
96
+ /** The command string to execute. */
49
97
  cmd: string;
50
- shell?: TShell;
51
- }>;
98
+ /** Shell override for this script. */
99
+ shell?: TShell | undefined;
100
+ }
101
+ /**
102
+ * Scripts table shape.
103
+ */
104
+ type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<string, string | ScriptDef<TShell>>;
105
+ /**
106
+ * Identity helper to define a scripts table while preserving a concrete TShell
107
+ * type parameter in downstream inference.
108
+ */
109
+ declare const defineScripts: <TShell extends string | boolean>() => <T extends ScriptsTable<TShell>>(t: T) => T;
110
+ /**
111
+ * Per-invocation context shared with plugins and actions.
112
+ *
113
+ * @public
114
+ */
115
+ interface GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> {
116
+ optionsResolved: TOptions;
117
+ dotenv: ProcessEnv;
118
+ plugins?: Record<string, unknown>;
119
+ pluginConfigs?: Record<string, unknown>;
120
+ }
121
+ /**
122
+ * Options for branding the CLI.
123
+ *
124
+ * @public
125
+ */
126
+ interface BrandOptions {
127
+ /** CLI name. */
128
+ name?: string;
129
+ /** CLI description. */
130
+ description?: string;
131
+ /** CLI version string. */
132
+ version?: string;
133
+ /** Import URL for resolving package version. */
134
+ importMetaUrl?: string;
135
+ /** Custom help header text. */
136
+ helpHeader?: string;
137
+ }
138
+
139
+ /**
140
+ * Resolved CLI options schema.
141
+ * For the current step this mirrors the RAW schema; later stages may further
142
+ * narrow types post-resolution in the host pipeline.
143
+ */
144
+ declare const getDotenvCliOptionsSchemaResolved: z.ZodObject<{
145
+ defaultEnv: z.ZodOptional<z.ZodString>;
146
+ dotenvToken: z.ZodOptional<z.ZodString>;
147
+ dynamicPath: z.ZodOptional<z.ZodString>;
148
+ dynamic: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
149
+ env: z.ZodOptional<z.ZodString>;
150
+ excludeDynamic: z.ZodOptional<z.ZodBoolean>;
151
+ excludeEnv: z.ZodOptional<z.ZodBoolean>;
152
+ excludeGlobal: z.ZodOptional<z.ZodBoolean>;
153
+ excludePrivate: z.ZodOptional<z.ZodBoolean>;
154
+ excludePublic: z.ZodOptional<z.ZodBoolean>;
155
+ loadProcess: z.ZodOptional<z.ZodBoolean>;
156
+ log: z.ZodOptional<z.ZodBoolean>;
157
+ logger: z.ZodDefault<z.ZodUnknown>;
158
+ outputPath: z.ZodOptional<z.ZodString>;
159
+ privateToken: z.ZodOptional<z.ZodString>;
160
+ debug: z.ZodOptional<z.ZodBoolean>;
161
+ strict: z.ZodOptional<z.ZodBoolean>;
162
+ capture: z.ZodOptional<z.ZodBoolean>;
163
+ trace: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
164
+ redact: z.ZodOptional<z.ZodBoolean>;
165
+ warnEntropy: z.ZodOptional<z.ZodBoolean>;
166
+ entropyThreshold: z.ZodOptional<z.ZodNumber>;
167
+ entropyMinLength: z.ZodOptional<z.ZodNumber>;
168
+ entropyWhitelist: z.ZodOptional<z.ZodArray<z.ZodString>>;
169
+ redactPatterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
170
+ paths: z.ZodOptional<z.ZodString>;
171
+ pathsDelimiter: z.ZodOptional<z.ZodString>;
172
+ pathsDelimiterPattern: z.ZodOptional<z.ZodString>;
173
+ scripts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
174
+ shell: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
175
+ vars: z.ZodOptional<z.ZodString>;
176
+ varsAssignor: z.ZodOptional<z.ZodString>;
177
+ varsAssignorPattern: z.ZodOptional<z.ZodString>;
178
+ varsDelimiter: z.ZodOptional<z.ZodString>;
179
+ varsDelimiterPattern: z.ZodOptional<z.ZodString>;
180
+ }, z.core.$strip>;
181
+
182
+ /**
183
+ * Resolved programmatic options schema (post-inheritance).
184
+ * For now, this mirrors the RAW schema; future stages may materialize defaults
185
+ * and narrow shapes as resolution is wired into the host.
186
+ */
187
+ declare const getDotenvOptionsSchemaResolved: z.ZodObject<{
188
+ defaultEnv: z.ZodOptional<z.ZodString>;
189
+ dotenvToken: z.ZodOptional<z.ZodString>;
190
+ dynamicPath: z.ZodOptional<z.ZodString>;
191
+ dynamic: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
192
+ env: z.ZodOptional<z.ZodString>;
193
+ excludeDynamic: z.ZodOptional<z.ZodBoolean>;
194
+ excludeEnv: z.ZodOptional<z.ZodBoolean>;
195
+ excludeGlobal: z.ZodOptional<z.ZodBoolean>;
196
+ excludePrivate: z.ZodOptional<z.ZodBoolean>;
197
+ excludePublic: z.ZodOptional<z.ZodBoolean>;
198
+ loadProcess: z.ZodOptional<z.ZodBoolean>;
199
+ log: z.ZodOptional<z.ZodBoolean>;
200
+ logger: z.ZodDefault<z.ZodUnknown>;
201
+ outputPath: z.ZodOptional<z.ZodString>;
202
+ paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
203
+ privateToken: z.ZodOptional<z.ZodString>;
204
+ vars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>;
205
+ }, z.core.$strip>;
206
+
207
+ /**
208
+ * Canonical programmatic options and helpers for get-dotenv.
209
+ *
210
+ * Requirements addressed:
211
+ * - GetDotenvOptions derives from the Zod schema output (single source of truth).
212
+ * - Removed deprecated/compat flags from the public shape (e.g., useConfigLoader).
213
+ * - Provide Vars-aware defineDynamic and a typed config builder defineGetDotenvConfig\<Vars, Env\>().
214
+ * - Preserve existing behavior for defaults resolution and compat converters.
215
+ */
52
216
 
53
217
  /**
54
218
  * A minimal representation of an environment key/value mapping.
55
- * Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
219
+ * Values may be `undefined` to represent "unset".
220
+ */
221
+ type ProcessEnv = Record<string, string | undefined>;
56
222
  /**
57
223
  * Dynamic variable function signature. Receives the current expanded variables
58
224
  * and the selected environment (if any), and returns either a string to set
59
225
  * or `undefined` to unset/skip the variable.
60
226
  */
61
227
  type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | undefined;
228
+ /**
229
+ * A map of dynamic variable definitions.
230
+ * Keys are variable names; values are either literal strings or functions.
231
+ */
62
232
  type GetDotenvDynamic = Record<string, GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>>;
233
+ /**
234
+ * Logger interface compatible with `console` or a subset thereof.
235
+ */
63
236
  type Logger = Record<string, (...args: unknown[]) => void> | typeof console;
64
237
  /**
65
- * Options passed programmatically to `getDotenv`.
238
+ * Canonical programmatic options type (schema-derived).
239
+ * This type is the single source of truth for programmatic options.
66
240
  */
67
- interface GetDotenvOptions {
68
- /**
69
- * default target environment (used if `env` is not provided)
70
- */
71
- defaultEnv?: string;
72
- /**
73
- * token indicating a dotenv file
74
- */
75
- dotenvToken: string;
241
+ type GetDotenvOptions = z.output<typeof getDotenvOptionsSchemaResolved> & {
76
242
  /**
77
- * path to JS/TS module default-exporting an object keyed to dynamic variable functions
243
+ * Compile-time overlay: narrowed logger for DX (schema stores unknown).
78
244
  */
79
- dynamicPath?: string;
245
+ logger: Logger;
80
246
  /**
81
- * Programmatic dynamic variables map. When provided, this takes precedence
82
- * over {@link GetDotenvOptions.dynamicPath}.
247
+ * Compile-time overlay: narrowed dynamic map for DX (schema stores unknown).
83
248
  */
84
249
  dynamic?: GetDotenvDynamic;
85
- /**
86
- * target environment
87
- */
88
- env?: string;
89
- /**
90
- * exclude dynamic variables from loading
91
- */
92
- excludeDynamic?: boolean;
93
- /**
94
- * exclude environment-specific variables from loading
95
- */
96
- excludeEnv?: boolean;
97
- /**
98
- * exclude global variables from loading
99
- */
100
- excludeGlobal?: boolean;
101
- /**
102
- * exclude private variables from loading
103
- */
104
- excludePrivate?: boolean;
105
- /**
106
- * exclude public variables from loading
107
- */
108
- excludePublic?: boolean;
109
- /**
110
- * load dotenv variables to `process.env`
111
- */
112
- loadProcess?: boolean;
113
- /**
114
- * log loaded dotenv variables to `logger`
115
- */
116
- log?: boolean;
117
- /**
118
- * logger object (defaults to console)
119
- */
120
- logger?: Logger;
121
- /**
122
- * if populated, writes consolidated dotenv file to this path (follows dotenvExpand rules)
123
- */
124
- outputPath?: string;
125
- /**
126
- * array of input directory paths
127
- */
128
- paths?: string[];
129
- /**
130
- * filename token indicating private variables
131
- */
132
- privateToken?: string;
133
- /**
134
- * explicit variables to include
135
- */
136
- vars?: ProcessEnv;
137
- /**
138
- * Reserved: config loader flag (no-op).
139
- * The plugin-first host and generator paths already use the config
140
- * loader/overlay pipeline unconditionally (no-op when no config files
141
- * are present). This flag is accepted for forward compatibility but
142
- * currently has no effect.
143
- */
144
- useConfigLoader?: boolean;
145
- }
250
+ };
146
251
 
147
- type Scripts = Record<string, string | {
148
- cmd: string;
149
- shell?: string | boolean;
150
- }>;
151
252
  /**
152
- * Options passed programmatically to `getDotenvCli`.
253
+ * Unify Scripts via the generic ScriptsTable<TShell> so shell types propagate.
153
254
  */
154
- interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
155
- /**
156
- * Logs CLI internals when true.
157
- */
158
- debug?: boolean;
159
- /**
160
- * Strict mode: fail the run when env validation issues are detected
161
- * (schema or requiredKeys). Warns by default when false or unset.
162
- */
163
- strict?: boolean;
164
- /**
165
- * Redaction (presentation): mask secret-like values in logs/trace.
166
- */
167
- redact?: boolean;
168
- /**
169
- * Entropy warnings (presentation): emit once-per-key warnings for high-entropy values.
170
- */
171
- warnEntropy?: boolean;
172
- entropyThreshold?: number;
173
- entropyMinLength?: number;
174
- entropyWhitelist?: string[];
175
- redactPatterns?: string[];
255
+ type Scripts = ScriptsTable;
256
+ /**
257
+ * Canonical CLI options type derived from the Zod schema output.
258
+ * Includes CLI-only flags (debug/strict/capture/trace/redaction/entropy),
259
+ * stringly paths/vars, and inherited programmatic fields (minus normalized
260
+ * shapes that are handled by resolution).
261
+ */
262
+ type GetDotenvCliOptions = z.output<typeof getDotenvCliOptionsSchemaResolved> & {
176
263
  /**
177
- * When true, capture child stdout/stderr and re-emit after completion.
178
- * Useful for tests/CI. Default behavior is streaming via stdio: 'inherit'.
264
+ * Compile-only overlay for DX: logger narrowed from unknown.
179
265
  */
180
- capture?: boolean;
266
+ logger: Logger;
181
267
  /**
182
- * A delimited string of paths to dotenv files.
268
+ * Compile-only overlay for DX: scripts narrowed from Record\<string, unknown\>.
183
269
  */
184
- paths?: string;
270
+ scripts?: Scripts;
271
+ };
272
+ /**
273
+ * Base CLI options derived from the shared root option defaults.
274
+ * Used for type-safe initialization of CLI options bags.
275
+ */
276
+ declare const baseGetDotenvCliOptions: Partial<GetDotenvCliOptions>;
277
+
278
+ /**
279
+ * Configuration context used for generating dynamic help descriptions.
280
+ * Contains merged CLI options and plugin configuration slices.
281
+ *
282
+ * @public
283
+ */
284
+ type ResolvedHelpConfig = Partial<GetDotenvCliOptions> & {
185
285
  /**
186
- * A delimiter string with which to split `paths`. Only used if
187
- * `pathsDelimiterPattern` is not provided.
286
+ * Per‑plugin configuration slices keyed by realized mount path
287
+ * (e.g., `"aws"` or `"aws/whoami"`), used for dynamic help text.
188
288
  */
189
- pathsDelimiter?: string;
289
+ plugins: Record<string, unknown>;
290
+ };
291
+ /**
292
+ * Build a help-time configuration bag for dynamic option descriptions.
293
+ * Centralizes construction and reduces inline casts at call sites.
294
+ */
295
+ declare const toHelpConfig: (merged: Partial<GetDotenvCliOptions> | Partial<RootOptionsShape>, plugins: Record<string, unknown> | undefined) => ResolvedHelpConfig;
296
+
297
+ /** src/cliHost/definePlugin/contracts.ts
298
+ * Public contracts for plugin authoring (types only).
299
+ * - No runtime logic or state.
300
+ * - Safe to import broadly without introducing cycles.
301
+ */
302
+
303
+ /**
304
+ * Options for resolving and loading the configuration.
305
+ *
306
+ * @public
307
+ */
308
+ interface ResolveAndLoadOptions {
190
309
  /**
191
- * A regular expression pattern with which to split `paths`. Supersedes
192
- * `pathsDelimiter`.
310
+ * When false, skips running plugin afterResolve hooks.
311
+ * Useful for top-level help rendering to avoid long-running side-effects
312
+ * while still evaluating dynamic help text.
313
+ *
314
+ * @default true
193
315
  */
194
- pathsDelimiterPattern?: string;
316
+ runAfterResolve?: boolean;
317
+ }
318
+ /**
319
+ * Structural public interface for the host exposed to plugins.
320
+ * - Extends Commander.Command so plugins can attach options/commands/hooks.
321
+ * - Adds host-specific helpers used by built-in plugins.
322
+ *
323
+ * Purpose: remove nominal class identity (private fields) from the plugin seam
324
+ * to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
325
+ */
326
+ interface GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> extends Command<TArgs, TOpts, TGlobal> {
327
+ /**
328
+ * Create a namespaced child command with argument inference.
329
+ * Mirrors Commander generics so downstream chaining remains fully typed.
330
+ */
331
+ ns<Usage extends string>(name: Usage): GetDotenvCliPublic<TOptions, [
332
+ ...TArgs,
333
+ ...InferCommandArguments<Usage>
334
+ ], {}, TOpts & TGlobal>;
335
+ /** Return the current context; throws if not yet resolved. */
336
+ getCtx(): GetDotenvCliCtx<TOptions>;
337
+ /** Check whether a context has been resolved (non-throwing). */
338
+ hasCtx(): boolean;
339
+ resolveAndLoad(customOptions?: Partial<TOptions>, opts?: ResolveAndLoadOptions): Promise<GetDotenvCliCtx<TOptions>>;
340
+ setOptionGroup(opt: Option, group: string): void;
341
+ /**
342
+ * Create a dynamic option whose description is computed at help time
343
+ * from the resolved configuration.
344
+ */
345
+ createDynamicOption<Usage extends string>(flags: Usage, desc: (cfg: ResolvedHelpConfig) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option<Usage>;
346
+ createDynamicOption<Usage extends string, TValue = unknown>(flags: Usage, desc: (cfg: ResolvedHelpConfig) => string, parser: (value: string, previous?: TValue) => TValue, defaultValue?: TValue): Option<Usage>;
347
+ }
348
+ /**
349
+ * Optional overrides for plugin composition.
350
+ *
351
+ * @public
352
+ */
353
+ interface PluginNamespaceOverride {
195
354
  /**
196
- * Scripts that can be executed from the CLI, either individually or via the batch subcommand.
355
+ * Override the default namespace for this plugin instance.
197
356
  */
198
- scripts?: Scripts;
357
+ ns?: string;
358
+ }
359
+ /**
360
+ * An entry in the plugin children array.
361
+ *
362
+ * @public
363
+ */
364
+ interface PluginChildEntry<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> {
365
+ /** The child plugin instance to mount under this parent. */
366
+ plugin: GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>;
199
367
  /**
200
- * Determines how commands and scripts are executed. If `false` or
201
- * `undefined`, commands are executed as plain Javascript using the default
202
- * execa parser. If `true`, commands are executed using the default OS shell
203
- * parser. Otherwise the user may provide a specific shell string (e.g.
204
- * `/bin/bash`)
368
+ * Optional namespace override for the child when mounted under the parent.
369
+ * When provided, this name is used instead of the child's default `ns`.
205
370
  */
206
- shell?: string | boolean;
371
+ override: PluginNamespaceOverride | undefined;
372
+ }
373
+ /** Public plugin contract used by the GetDotenv CLI host. */
374
+ interface GetDotenvCliPlugin<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> {
375
+ /** Namespace (required): the command name where this plugin is mounted. */
376
+ ns: string;
207
377
  /**
208
- * A delimited string of key-value pairs declaratively specifying variables &
209
- * values to be loaded in addition to any dotenv files.
378
+ * Setup phase: register commands and wiring on the provided mount.
379
+ * Runs parent children (pre-order). Return nothing (void).
210
380
  */
211
- vars?: string;
381
+ setup: (cli: GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal>) => void | Promise<void>;
212
382
  /**
213
- * A string with which to split keys from values in `vars`. Only used if
214
- * `varsDelimiterPattern` is not provided.
383
+ * After the dotenv context is resolved, initialize any clients/secrets
384
+ * or attach per-plugin state under ctx.plugins (by convention).
385
+ * Runs parent → children (pre-order).
215
386
  */
216
- varsAssignor?: string;
387
+ afterResolve?: (cli: GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal>, ctx: GetDotenvCliCtx<TOptions>) => void | Promise<void>;
388
+ /** Zod schema for this plugin's config slice (from config.plugins[…]). */
389
+ configSchema?: ZodObject;
217
390
  /**
218
- * A regular expression pattern with which to split variable names from values
219
- * in `vars`. Supersedes `varsAssignor`.
391
+ * Compositional children, with optional per-child overrides (e.g., ns).
392
+ * Installed after the parent per pre-order.
220
393
  */
221
- varsAssignorPattern?: string;
394
+ children: Array<PluginChildEntry<TOptions, TArgs, TOpts, TGlobal>>;
222
395
  /**
223
- * A string with which to split `vars` into key-value pairs. Only used if
224
- * `varsDelimiterPattern` is not provided.
396
+ * Compose a child plugin with optional override (ns). Returns the parent
397
+ * to enable chaining.
225
398
  */
226
- varsDelimiter?: string;
399
+ use: (child: GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>, override?: PluginNamespaceOverride) => GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>;
400
+ }
401
+ /**
402
+ * Compile-time helper type: the plugin object returned by definePlugin always
403
+ * includes the instance-bound helpers as required members. Keeping the public
404
+ * interface optional preserves compatibility for ad-hoc/test plugins, while
405
+ * return types from definePlugin provide stronger DX for shipped/typed plugins.
406
+ */
407
+ interface PluginWithInstanceHelpers<TOptions extends GetDotenvOptions = GetDotenvOptions, TConfig = unknown, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> extends GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal> {
408
+ readConfig<TCfg = TConfig>(cli: GetDotenvCliPublic<TOptions, unknown[], OptionValues, OptionValues>): Readonly<TCfg>;
409
+ createPluginDynamicOption<TCfg = TConfig, Usage extends string = string>(cli: GetDotenvCliPublic<TOptions, unknown[], OptionValues, OptionValues>, flags: Usage, desc: (cfg: ResolvedHelpConfig, pluginCfg: Readonly<TCfg>) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option<Usage>;
410
+ }
411
+ /**
412
+ * Public spec type for defining a plugin with compositional helpers.
413
+ */
414
+ type DefineSpec<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> = Omit<GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>, 'children' | 'use' | 'setup'> & {
227
415
  /**
228
- * A regular expression pattern with which to split `vars` into key-value
229
- * pairs. Supersedes `varsDelimiter`.
416
+ * Required namespace and setup function. The host creates the mount and
417
+ * passes it into setup; return void | Promise<void>.
230
418
  */
231
- varsDelimiterPattern?: string;
232
- }
419
+ ns: string;
420
+ setup: (cli: GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal>) => void | Promise<void>;
421
+ };
422
+ /**
423
+ * Helper to infer the configuration type from a `PluginWithInstanceHelpers` type.
424
+ */
425
+ type InferPluginConfig<P> = P extends PluginWithInstanceHelpers<GetDotenvOptions, infer C> ? Readonly<C> : never;
233
426
 
234
- /** src/cliHost/definePlugin.ts
235
- * Plugin contracts for the GetDotenv CLI host.
427
+ /**
428
+ * Define a GetDotenv CLI plugin with compositional helpers.
236
429
  *
237
- * This module exposes a structural public interface for the host that plugins
238
- * should use (GetDotenvCliPublic). Using a structural type at the seam avoids
239
- * nominal class identity issues (private fields) in downstream consumers.
430
+ * @example
431
+ * const p = definePlugin(\{ ns: 'aws', setup(cli) \{ /* wire subcommands *\/ \} \})
432
+ * .use(child, \{ ns: 'whoami' \});
240
433
  */
434
+ declare function definePlugin<TOptions extends GetDotenvOptions, Schema extends ZodObject>(spec: Omit<DefineSpec<TOptions>, 'configSchema'> & {
435
+ configSchema: Schema;
436
+ }): PluginWithInstanceHelpers<TOptions, z.output<Schema>>;
437
+ declare function definePlugin<TOptions extends GetDotenvOptions>(spec: DefineSpec<TOptions>): PluginWithInstanceHelpers<TOptions, {}>;
241
438
 
242
439
  /**
243
- * Structural public interface for the host exposed to plugins.
244
- * - Extends Commander.Command so plugins can attach options/commands/hooks.
245
- * - Adds host-specific helpers used by built-in plugins.
440
+ * Options for runCommandResult (buffered execution).
246
441
  *
247
- * Purpose: remove nominal class identity (private fields) from the plugin seam
248
- * to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
442
+ * @public
249
443
  */
250
- type GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions> = Command & {
251
- ns: (name: string) => Command;
252
- getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
253
- resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
254
- };
255
- /** Public plugin contract used by the GetDotenv CLI host. */
256
- interface GetDotenvCliPlugin {
257
- id?: string;
444
+ interface RunCommandResultOptions {
258
445
  /**
259
- * Setup phase: register commands and wiring on the provided CLI instance.
260
- * Runs parent → children (pre-order).
446
+ * Working directory for the child process.
261
447
  */
262
- setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
448
+ cwd?: string | URL;
263
449
  /**
264
- * After the dotenv context is resolved, initialize any clients/secrets
265
- * or attach per-plugin state under ctx.plugins (by convention).
266
- * Runs parent → children (pre-order).
450
+ * Environment variables for the child process. Undefined values are dropped.
267
451
  */
268
- afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
452
+ env?: NodeJS.ProcessEnv;
453
+ /**
454
+ * Optional timeout (ms). Kills the child with SIGKILL on expiry.
455
+ */
456
+ timeoutMs?: number;
457
+ }
458
+ /**
459
+ * Options for runCommand (execution with optional inherit/pipe).
460
+ *
461
+ * @public
462
+ */
463
+ interface RunCommandOptions {
269
464
  /**
270
- * Optional Zod schema for this plugin's config slice (from config.plugins[id]).
271
- * When provided, the host validates the merged config under the guarded loader path.
465
+ * Working directory for the child process.
272
466
  */
273
- configSchema?: ZodType;
467
+ cwd?: string | URL;
274
468
  /**
275
- * Compositional children. Installed after the parent per pre-order.
469
+ * Environment variables for the child process. Undefined values are dropped.
276
470
  */
277
- children: GetDotenvCliPlugin[];
471
+ env?: NodeJS.ProcessEnv;
278
472
  /**
279
- * Compose a child plugin. Returns the parent to enable chaining.
473
+ * Stdio strategy for the child process.
280
474
  */
281
- use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
475
+ stdio?: 'inherit' | 'pipe';
282
476
  }
283
477
  /**
284
- * Public spec type for defining a plugin with optional children.
285
- * Exported to ensure TypeDoc links and navigation resolve correctly.
478
+ * Execute a command and capture stdout/stderr (buffered).
479
+ * - Preserves plain vs shell behavior and argv/string normalization.
480
+ * - Never re-emits stdout/stderr to parent; returns captured buffers.
481
+ * - Supports optional timeout (ms).
286
482
  */
287
- type DefineSpec = Omit<GetDotenvCliPlugin, 'children' | 'use'> & {
288
- children?: GetDotenvCliPlugin[];
289
- };
290
- /**
291
- * Define a GetDotenv CLI plugin with compositional helpers.
292
- *
293
- * @example
294
- * const parent = definePlugin(\{ id: 'p', setup(cli) \{ /* ... *\/ \} \})
295
- * .use(childA)
296
- * .use(childB);
483
+ declare function runCommandResult(command: readonly string[], shell: false, opts?: RunCommandResultOptions): Promise<{
484
+ exitCode: number;
485
+ stdout: string;
486
+ stderr: string;
487
+ }>;
488
+ declare function runCommandResult(command: string | readonly string[], shell: string | boolean | URL, opts?: RunCommandResultOptions): Promise<{
489
+ exitCode: number;
490
+ stdout: string;
491
+ stderr: string;
492
+ }>;
493
+ declare function runCommand(command: readonly string[], shell: false, opts: RunCommandOptions): Promise<number>;
494
+ declare function runCommand(command: string | readonly string[], shell: string | boolean | URL, opts: RunCommandOptions): Promise<number>;
495
+
496
+ /** src/cliHost/GetDotenvCli.ts
497
+ * Plugin-first CLI host for get-dotenv with Commander generics preserved.
498
+ * Public surface implements GetDotenvCliPublic and provides:
499
+ * - attachRootOptions (builder-only; no public override wiring)
500
+ * - resolveAndLoad (strict resolve + context compute)
501
+ * - getCtx/hasCtx accessors
502
+ * - ns() for typed subcommand creation with duplicate-name guard
503
+ * - grouped help rendering with dynamic option descriptions
297
504
  */
298
- declare const definePlugin: (spec: DefineSpec) => GetDotenvCliPlugin;
299
505
 
300
- type ResolvedHelpConfig = Partial<GetDotenvOptions> & {
301
- plugins: Record<string, unknown>;
302
- };
303
- /** * Per-invocation context shared with plugins and actions. */
304
- type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
305
- optionsResolved: TOptions;
306
- dotenv: ProcessEnv;
307
- plugins?: Record<string, unknown>;
308
- pluginConfigs?: Record<string, unknown>;
309
- };
506
+ declare const CTX_SYMBOL: unique symbol;
507
+ declare const OPTS_SYMBOL: unique symbol;
310
508
  declare const HELP_HEADER_SYMBOL: unique symbol;
311
509
  /**
312
510
  * Plugin-first CLI host for get-dotenv. Extends Commander.Command.
@@ -316,23 +514,30 @@ declare const HELP_HEADER_SYMBOL: unique symbol;
316
514
  * - Expose a stable accessor for the current context (getCtx).
317
515
  * - Provide a namespacing helper (ns).
318
516
  * - Support composable plugins with parent → children install and afterResolve.
319
- *
320
- * NOTE: This host is additive and does not alter the legacy CLI.
321
517
  */
322
- declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
323
- #private;
518
+ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> extends Command<TArgs, TOpts, TGlobal> implements GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal> {
324
519
  /** Registered top-level plugins (composition happens via .use()) */
325
520
  private _plugins;
326
521
  /** One-time installation guard */
327
522
  private _installed;
523
+ /** In-flight installation promise to guard against concurrent installs */
524
+ private _installing?;
328
525
  /** Optional header line to prepend in help output */
329
526
  private [HELP_HEADER_SYMBOL];
527
+ /** Context/options stored under symbols (typed) */
528
+ private [CTX_SYMBOL]?;
529
+ private [OPTS_SYMBOL]?;
330
530
  /**
331
531
  * Create a subcommand using the same subclass, preserving helpers like
332
532
  * dynamicOption on children.
333
533
  */
334
- createCommand(name?: string): Command;
534
+ createCommand(name?: string): GetDotenvCli<TOptions>;
335
535
  constructor(alias?: string);
536
+ /**
537
+ * Attach legacy/base root flags to this CLI instance.
538
+ * Delegates to the pure builder in attachRootOptions.ts.
539
+ */
540
+ attachRootOptions(defaults?: Partial<RootOptionsShape>): this;
336
541
  /**
337
542
  * Resolve options (strict) and compute dotenv context.
338
543
  * Stores the context on the instance under a symbol.
@@ -342,34 +547,30 @@ declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOption
342
547
  * afterResolve hooks. Useful for top-level help rendering to avoid
343
548
  * long-running side-effects while still evaluating dynamic help text.
344
549
  */
345
- resolveAndLoad(customOptions?: Partial<TOptions>, opts?: {
346
- runAfterResolve?: boolean;
347
- }): Promise<GetDotenvCliCtx<TOptions>>;
550
+ resolveAndLoad(customOptions?: Partial<TOptions>, opts?: ResolveAndLoadOptions): Promise<GetDotenvCliCtx<TOptions>>;
348
551
  /**
349
552
  * Create a Commander Option that computes its description at help time.
350
553
  * The returned Option may be configured (conflicts, default, parser) and
351
554
  * added via addOption().
352
555
  */
353
- createDynamicOption<TPlugins = Record<string, unknown>>(flags: string, desc: (cfg: ResolvedHelpConfig & {
354
- plugins: TPlugins;
355
- }) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option;
356
- /**
357
- * Chainable helper mirroring .option(), but with a dynamic description.
358
- * Equivalent to addOption(createDynamicOption(...)).
359
- */
360
- dynamicOption<TPlugins = Record<string, unknown>>(flags: string, desc: (cfg: ResolvedHelpConfig & {
361
- plugins: TPlugins;
362
- }) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): this;
556
+ createDynamicOption<Usage extends string>(flags: Usage, desc: (cfg: ResolvedHelpConfig) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option<Usage>;
557
+ createDynamicOption<Usage extends string, TValue = unknown>(flags: Usage, desc: (cfg: ResolvedHelpConfig) => string, parser: (value: string, previous?: TValue) => TValue, defaultValue?: TValue): Option<Usage>;
363
558
  /**
364
559
  * Evaluate dynamic descriptions for this command and all descendants using
365
560
  * the provided resolved configuration. Mutates the Option.description in
366
561
  * place so Commander help renders updated text.
367
562
  */
368
563
  evaluateDynamicOptions(resolved: ResolvedHelpConfig): void;
564
+ /** Internal: climb to the true root (host) command. */
565
+ private _root;
369
566
  /**
370
567
  * Retrieve the current invocation context (if any).
371
568
  */
372
- getCtx(): GetDotenvCliCtx<TOptions> | undefined;
569
+ getCtx(): GetDotenvCliCtx<TOptions>;
570
+ /**
571
+ * Check whether a context has been resolved (non-throwing guard).
572
+ */
573
+ hasCtx(): boolean;
373
574
  /**
374
575
  * Retrieve the merged root CLI options bag (if set by passOptions()).
375
576
  * Downstream-safe: no generics required.
@@ -377,36 +578,39 @@ declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOption
377
578
  getOptions(): GetDotenvCliOptions | undefined;
378
579
  /** Internal: set the merged root options bag for this run. */
379
580
  _setOptionsBag(bag: GetDotenvCliOptions): void;
380
- /** * Convenience helper to create a namespaced subcommand.
581
+ /**
582
+ * Convenience helper to create a namespaced subcommand with argument inference.
583
+ * This mirrors Commander generics so downstream chaining stays fully typed.
381
584
  */
382
- ns(name: string): Command;
585
+ ns<Usage extends string>(name: Usage): GetDotenvCliPublic<TOptions, [
586
+ ...TArgs,
587
+ ...InferCommandArguments<Usage>
588
+ ], {}, TOpts & TGlobal>;
383
589
  /**
384
590
  * Tag options added during the provided callback as 'app' for grouped help.
385
591
  * Allows downstream apps to demarcate their root-level options.
386
592
  */
387
- tagAppOptions<T>(fn: (root: Command) => T): T;
593
+ tagAppOptions<T>(fn: (root: CommandUnknownOpts) => T): T;
388
594
  /**
389
595
  * Branding helper: set CLI name/description/version and optional help header.
390
596
  * If version is omitted and importMetaUrl is provided, attempts to read the
391
597
  * nearest package.json version (best-effort; non-fatal on failure).
392
598
  */
393
- brand(args: {
394
- name?: string;
395
- description?: string;
396
- version?: string;
397
- importMetaUrl?: string;
398
- helpHeader?: string;
399
- }): Promise<this>;
599
+ brand(args: BrandOptions): Promise<this>;
400
600
  /**
401
601
  * Insert grouped plugin/app options between "Options" and "Commands" for
402
602
  * hybrid ordering. Applies to root and any parent command.
403
603
  */
404
604
  helpInformation(): string;
605
+ /**
606
+ * Public: tag an Option with a display group for help (root/app/plugin:<id>).
607
+ */
608
+ setOptionGroup(opt: Option, group: string): void;
405
609
  /**
406
610
  * Register a plugin for installation (parent level).
407
611
  * Installation occurs on first resolveAndLoad() (or explicit install()).
408
612
  */
409
- use(plugin: GetDotenvCliPlugin): this;
613
+ use(plugin: GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>, override?: PluginNamespaceOverride): this;
410
614
  /**
411
615
  * Install all registered plugins in parent → children (pre-order).
412
616
  * Runs only once per CLI instance.
@@ -418,34 +622,125 @@ declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOption
418
622
  private _runAfterResolve;
419
623
  }
420
624
 
625
+ /** src/cliHost/getRootCommand.ts
626
+ * Typed helper to retrieve the true root command (host) starting from any mount.
627
+ */
628
+
629
+ /**
630
+ * Return the top-level root command for a given mount or action's thisCommand.
631
+ *
632
+ * @param cmd - any command (mount or thisCommand inside an action)
633
+ * @returns the root command instance
634
+ */
635
+ declare const getRootCommand: (cmd: CommandUnknownOpts) => CommandUnknownOpts;
636
+
637
+ /** src/cliHost/invoke.ts
638
+ * Shared helpers for composing child env overlays and preserving argv for Node -e.
639
+ */
640
+
641
+ /**
642
+ * Compose a child-process env overlay from dotenv and the merged CLI options bag.
643
+ * Returns a shallow object including getDotenvCliOptions when serializable.
644
+ */
645
+ declare function composeNestedEnv(merged: GetDotenvCliOptions | Record<string, unknown>, dotenv: Record<string, string | undefined>): Record<string, string>;
646
+ /**
647
+ * Strip one layer of symmetric outer quotes (single or double) from a string.
648
+ *
649
+ * @param s - Input string.
650
+ */
651
+ declare const stripOne: (s: string) => string;
652
+ /**
653
+ * Preserve argv array for Node -e/--eval payloads under shell-off and
654
+ * peel one symmetric outer quote layer from the code argument.
655
+ */
656
+ declare function maybePreserveNodeEvalArgv(args: string[]): string[];
657
+
658
+ /** src/cliHost/paths.ts
659
+ * Helpers for realized mount paths and plugin tree flattening.
660
+ */
661
+
662
+ /**
663
+ * A flattened plugin entry with its realized path.
664
+ *
665
+ * @public
666
+ */
667
+ interface PluginFlattenedEntry<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> {
668
+ /** The plugin instance for this entry in the flattened tree. */
669
+ plugin: GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>;
670
+ /**
671
+ * The realized mount path for this plugin (root alias excluded), e.g. "aws/whoami".
672
+ */
673
+ path: string;
674
+ }
675
+
676
+ /**
677
+ * Retrieve the merged root options bag from the current command context.
678
+ * Climbs to the root `GetDotenvCli` instance to access the persisted options.
679
+ *
680
+ * @param cmd - The current command instance (thisCommand).
681
+ * @throws Error if the root is not a GetDotenvCli or options are missing.
682
+ */
683
+ declare const readMergedOptions: (cmd: CommandUnknownOpts) => GetDotenvCliOptions;
684
+
421
685
  /**
422
- * GetDotenvCli with root helpers as real class methods.
423
- * - attachRootOptions: installs legacy/base root flags on the command.
424
- * - passOptions: merges flags (parent \< current), computes dotenv context once,
425
- * runs validation, and persists merged options for nested flows.
686
+ * Batch services (neutral): resolve command and shell settings.
687
+ * Shared by the generator path and the batch plugin to avoid circular deps.
426
688
  */
427
- declare class GetDotenvCli extends GetDotenvCli$1 {
689
+
690
+ /**
691
+ * Resolve a command string from the {@link ScriptsTable} table.
692
+ * A script may be expressed as a string or an object with a `cmd` property.
693
+ *
694
+ * @param scripts - Optional scripts table.
695
+ * @param command - User-provided command name or string.
696
+ * @returns Resolved command string (falls back to the provided command).
697
+ */
698
+ declare const resolveCommand: (scripts: ScriptsTable | undefined, command: string) => string;
699
+ /**
700
+ * Resolve the shell setting for a given command:
701
+ * - If the script entry is an object, prefer its `shell` override.
702
+ * - Otherwise use the provided `shell` (string | boolean).
703
+ *
704
+ * @param scripts - Optional scripts table.
705
+ * @param command - User-provided command name or string.
706
+ * @param shell - Global shell preference (string | boolean).
707
+ */
708
+ declare const resolveShell: <TShell extends string | boolean>(scripts: ScriptsTable<TShell> | undefined, command: string, shell: TShell | undefined) => TShell | false;
709
+
710
+ /**
711
+ * Result of CLI option resolution.
712
+ */
713
+ interface ResolveCliOptionsResult<T> {
428
714
  /**
429
- * Attach legacy root flags to this CLI instance. Defaults come from
430
- * baseRootOptionDefaults when none are provided.
715
+ * The merged options object after applying defaults, inherited parent
716
+ * values, and the current CLI flags. This bag is used as the effective
717
+ * root options for the current invocation.
431
718
  */
432
- attachRootOptions(defaults?: Partial<RootOptionsShape>, opts?: {
433
- includeCommandOption?: boolean;
434
- }): this;
719
+ merged: T;
435
720
  /**
436
- * Install preSubcommand/preAction hooks that:
437
- * - Merge options (parent round-trip + current invocation) using resolveCliOptions.
438
- * - Persist the merged bag on the current command and on the host (for ergonomics).
439
- * - Compute the dotenv context once via resolveAndLoad(serviceOptions).
440
- * - Validate the composed env against discovered config (warn or --strict fail).
721
+ * Positional command (string) resolved for invokers that accept a command
722
+ * payload (e.g., batch parent or cmd alias). When absent, no command is set.
441
723
  */
442
- passOptions(defaults?: Partial<RootOptionsShape>): this;
724
+ command?: string;
443
725
  }
444
726
  /**
445
- * Helper to retrieve the merged root options bag from any action handler
446
- * that only has access to thisCommand. Avoids structural casts.
727
+ * Merge and normalize raw Commander options (current + parent + defaults)
728
+ * into a GetDotenvCliOptions-like object. Types are intentionally wide to
729
+ * avoid cross-layer coupling; callers may cast as needed.
730
+ */
731
+ declare const resolveCliOptions: <T extends Partial<RootOptionsShape> & {
732
+ scripts?: ScriptsTable;
733
+ }>(rawCliOptions: unknown, defaults: Partial<T>, parentJson?: string) => ResolveCliOptionsResult<T>;
734
+
735
+ /**
736
+ * Build a sanitized environment object for spawning child processes.
737
+ * Merges `base` and `overlay`, drops undefined values, and handles platform-specific
738
+ * normalization (e.g. case-insensitivity on Windows).
739
+ *
740
+ * @param base - Base environment (usually `process.env`).
741
+ * @param overlay - Environment variables to overlay.
447
742
  */
448
- declare const readMergedOptions: (cmd: Command) => GetDotenvCliOptions | undefined;
743
+ declare const buildSpawnEnv: (base?: NodeJS.ProcessEnv, overlay?: Record<string, string | undefined>) => NodeJS.ProcessEnv;
449
744
 
450
- export { GetDotenvCli, definePlugin, readMergedOptions };
451
- export type { DefineSpec, GetDotenvCliCtx, GetDotenvCliOptions, GetDotenvCliPlugin, GetDotenvCliPublic, ScriptsTable };
745
+ export { GetDotenvCli, baseGetDotenvCliOptions, buildSpawnEnv, composeNestedEnv, definePlugin, defineScripts, getRootCommand, maybePreserveNodeEvalArgv, readMergedOptions, resolveCliOptions, resolveCommand, resolveShell, runCommand, runCommandResult, stripOne, toHelpConfig };
746
+ export type { BrandOptions, DefineSpec, GetDotenvCliCtx, GetDotenvCliOptions, GetDotenvCliPlugin, GetDotenvCliPublic, InferPluginConfig, PluginChildEntry, PluginFlattenedEntry, PluginNamespaceOverride, PluginWithInstanceHelpers, ResolveAndLoadOptions, ResolveCliOptionsResult, ResolvedHelpConfig, RootOptionsShape, RunCommandOptions, RunCommandResultOptions, ScriptDef, Scripts, ScriptsTable };