padrone 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +115 -0
- package/README.md +108 -283
- package/dist/args-Cnq0nwSM.mjs +272 -0
- package/dist/args-Cnq0nwSM.mjs.map +1 -0
- package/dist/codegen/index.d.mts +28 -3
- package/dist/codegen/index.d.mts.map +1 -1
- package/dist/codegen/index.mjs +169 -19
- package/dist/codegen/index.mjs.map +1 -1
- package/dist/commands-B_gufyR9.mjs +514 -0
- package/dist/commands-B_gufyR9.mjs.map +1 -0
- package/dist/{completion.mjs → completion-BEuflbDO.mjs} +86 -108
- package/dist/completion-BEuflbDO.mjs.map +1 -0
- package/dist/docs/index.d.mts +22 -2
- package/dist/docs/index.d.mts.map +1 -1
- package/dist/docs/index.mjs +92 -7
- package/dist/docs/index.mjs.map +1 -1
- package/dist/errors-CL63UOzt.mjs +137 -0
- package/dist/errors-CL63UOzt.mjs.map +1 -0
- package/dist/{formatter-ClUK5hcQ.d.mts → formatter-DrvhDMrq.d.mts} +35 -6
- package/dist/formatter-DrvhDMrq.d.mts.map +1 -0
- package/dist/help-B5Kk83of.mjs +849 -0
- package/dist/help-B5Kk83of.mjs.map +1 -0
- package/dist/index-BaU3X6dY.d.mts +1178 -0
- package/dist/index-BaU3X6dY.d.mts.map +1 -0
- package/dist/index.d.mts +763 -36
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3608 -1534
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-BM-d0nZi.mjs +377 -0
- package/dist/mcp-BM-d0nZi.mjs.map +1 -0
- package/dist/serve-Bk0JUlCj.mjs +402 -0
- package/dist/serve-Bk0JUlCj.mjs.map +1 -0
- package/dist/stream-DC4H8YTx.mjs +77 -0
- package/dist/stream-DC4H8YTx.mjs.map +1 -0
- package/dist/test.d.mts +5 -8
- package/dist/test.d.mts.map +1 -1
- package/dist/test.mjs +5 -27
- package/dist/test.mjs.map +1 -1
- package/dist/{update-check-EbNDkzyV.mjs → update-check-CZ2VqjnV.mjs} +16 -17
- package/dist/update-check-CZ2VqjnV.mjs.map +1 -0
- package/dist/zod.d.mts +32 -0
- package/dist/zod.d.mts.map +1 -0
- package/dist/zod.mjs +50 -0
- package/dist/zod.mjs.map +1 -0
- package/package.json +20 -9
- package/src/cli/completions.ts +14 -11
- package/src/cli/docs.ts +13 -16
- package/src/cli/doctor.ts +213 -24
- package/src/cli/index.ts +28 -82
- package/src/cli/init.ts +12 -10
- package/src/cli/link.ts +22 -18
- package/src/cli/wrap.ts +14 -11
- package/src/codegen/discovery.ts +80 -28
- package/src/codegen/index.ts +2 -1
- package/src/codegen/parsers/bash.ts +179 -0
- package/src/codegen/schema-to-code.ts +2 -1
- package/src/core/args.ts +296 -0
- package/src/core/commands.ts +373 -0
- package/src/core/create.ts +268 -0
- package/src/{runtime.ts → core/default-runtime.ts} +70 -135
- package/src/{errors.ts → core/errors.ts} +22 -0
- package/src/core/exec.ts +259 -0
- package/src/core/interceptors.ts +302 -0
- package/src/{parse.ts → core/parse.ts} +36 -89
- package/src/core/program-methods.ts +301 -0
- package/src/core/results.ts +229 -0
- package/src/core/runtime.ts +246 -0
- package/src/core/validate.ts +247 -0
- package/src/docs/index.ts +124 -11
- package/src/extension/auto-output.ts +95 -0
- package/src/extension/color.ts +38 -0
- package/src/extension/completion.ts +49 -0
- package/src/extension/config.ts +262 -0
- package/src/extension/env.ts +101 -0
- package/src/extension/help.ts +192 -0
- package/src/extension/index.ts +43 -0
- package/src/extension/ink.ts +93 -0
- package/src/extension/interactive.ts +106 -0
- package/src/extension/logger.ts +214 -0
- package/src/extension/man.ts +51 -0
- package/src/extension/mcp.ts +52 -0
- package/src/extension/progress-renderer.ts +338 -0
- package/src/extension/progress.ts +299 -0
- package/src/extension/repl.ts +94 -0
- package/src/extension/serve.ts +48 -0
- package/src/extension/signal.ts +87 -0
- package/src/extension/stdin.ts +62 -0
- package/src/extension/suggestions.ts +114 -0
- package/src/extension/timing.ts +81 -0
- package/src/extension/tracing.ts +175 -0
- package/src/extension/update-check.ts +77 -0
- package/src/extension/utils.ts +51 -0
- package/src/extension/version.ts +63 -0
- package/src/{completion.ts → feature/completion.ts} +130 -57
- package/src/{interactive.ts → feature/interactive.ts} +47 -6
- package/src/feature/mcp.ts +387 -0
- package/src/{repl-loop.ts → feature/repl-loop.ts} +26 -16
- package/src/feature/serve.ts +438 -0
- package/src/feature/test.ts +262 -0
- package/src/{update-check.ts → feature/update-check.ts} +16 -16
- package/src/{wrap.ts → feature/wrap.ts} +27 -27
- package/src/index.ts +120 -11
- package/src/output/colorizer.ts +154 -0
- package/src/{formatter.ts → output/formatter.ts} +281 -135
- package/src/{help.ts → output/help.ts} +62 -15
- package/src/{zod.d.ts → schema/zod.d.ts} +1 -1
- package/src/schema/zod.ts +50 -0
- package/src/test.ts +2 -285
- package/src/types/args-meta.ts +151 -0
- package/src/types/builder.ts +697 -0
- package/src/types/command.ts +157 -0
- package/src/types/index.ts +59 -0
- package/src/types/interceptor.ts +296 -0
- package/src/types/preferences.ts +83 -0
- package/src/types/result.ts +71 -0
- package/src/types/schema.ts +19 -0
- package/src/util/dotenv.ts +244 -0
- package/src/{shell-utils.ts → util/shell-utils.ts} +26 -9
- package/src/util/stream.ts +101 -0
- package/src/{type-helpers.ts → util/type-helpers.ts} +23 -16
- package/src/{type-utils.ts → util/type-utils.ts} +99 -37
- package/src/util/utils.ts +51 -0
- package/src/zod.ts +1 -0
- package/dist/args-CVDbyyzG.mjs +0 -199
- package/dist/args-CVDbyyzG.mjs.map +0 -1
- package/dist/chunk-y_GBKt04.mjs +0 -5
- package/dist/completion.d.mts +0 -64
- package/dist/completion.d.mts.map +0 -1
- package/dist/completion.mjs.map +0 -1
- package/dist/formatter-ClUK5hcQ.d.mts.map +0 -1
- package/dist/help-CcBe91bV.mjs +0 -1254
- package/dist/help-CcBe91bV.mjs.map +0 -1
- package/dist/types-DjIdJN5G.d.mts +0 -1059
- package/dist/types-DjIdJN5G.d.mts.map +0 -1
- package/dist/update-check-EbNDkzyV.mjs.map +0 -1
- package/src/args.ts +0 -461
- package/src/colorizer.ts +0 -41
- package/src/command-utils.ts +0 -532
- package/src/create.ts +0 -1477
- package/src/types.ts +0 -1109
- package/src/utils.ts +0 -140
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PadroneBuilder, PadroneProgram } from '../types/builder.ts';
|
|
2
|
+
import type { AnyPadroneCommand, PadroneCommand } from '../types/index.ts';
|
|
3
|
+
import type { PadroneSchema } from '../types/schema.ts';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Use this type instead of `any` when you intend to fix it later
|
|
@@ -36,9 +38,9 @@ export type OrAsync<TExisting extends boolean, TSchema> = TExisting extends true
|
|
|
36
38
|
* Detects whether argument meta contains interactive or optionalInteractive configuration.
|
|
37
39
|
* When either is `true` or a `string[]`, the command requires async execution for prompting.
|
|
38
40
|
*/
|
|
39
|
-
export type HasInteractive<TMeta> = TMeta extends { interactive: true | string[] }
|
|
41
|
+
export type HasInteractive<TMeta> = TMeta extends { interactive: true | readonly string[] }
|
|
40
42
|
? true
|
|
41
|
-
: TMeta extends { optionalInteractive: true | string[] }
|
|
43
|
+
: TMeta extends { optionalInteractive: true | readonly string[] }
|
|
42
44
|
? true
|
|
43
45
|
: false;
|
|
44
46
|
|
|
@@ -52,14 +54,38 @@ export type OrAsyncMeta<TExisting extends boolean, TMeta> = TExisting extends tr
|
|
|
52
54
|
? true
|
|
53
55
|
: false;
|
|
54
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Unwraps a result type by resolving Promises and collecting iterables into arrays.
|
|
59
|
+
* - `AsyncIterable<U>` → `U[]`
|
|
60
|
+
* - `Iterable<U>` (excluding strings) → `U[]`
|
|
61
|
+
* - `Promise<U>` → `Drained<U>` (recursively unwraps)
|
|
62
|
+
* - `T` → `T`
|
|
63
|
+
*/
|
|
64
|
+
export type Drained<T> =
|
|
65
|
+
T extends Promise<infer U>
|
|
66
|
+
? Drained<U>
|
|
67
|
+
: T extends AsyncIterable<infer U>
|
|
68
|
+
? U[]
|
|
69
|
+
: T extends string
|
|
70
|
+
? T
|
|
71
|
+
: T extends Iterable<infer U>
|
|
72
|
+
? U[]
|
|
73
|
+
: T;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A sync value augmented with Promise-like methods (.then, .catch, .finally).
|
|
77
|
+
* Unlike a real Promise, properties of T are accessible synchronously.
|
|
78
|
+
*/
|
|
79
|
+
export type Thenable<T> = T & PromiseLike<T> & { catch: Promise<T>['catch']; finally: Promise<T>['finally'] };
|
|
80
|
+
|
|
55
81
|
/**
|
|
56
82
|
* Conditionally wraps a type in Promise based on the TAsync flag.
|
|
57
83
|
* - `true` → `Promise<T>`
|
|
58
|
-
* - `false` → `T &
|
|
84
|
+
* - `false` → `T & Thenable<T>` (thenable: supports `.then()`, `.catch()`, `.finally()`, and `await`)
|
|
59
85
|
* - `boolean` (union of true|false) → `Promise<T>` (safe default when async-ness is uncertain)
|
|
60
86
|
* - `any` → `T` (for generic/any typed commands like AnyPadroneCommand)
|
|
61
87
|
*/
|
|
62
|
-
export type MaybePromise<T, TAsync> = IsAny<TAsync> extends true ? T : true extends TAsync ? Promise<T> :
|
|
88
|
+
export type MaybePromise<T, TAsync> = IsAny<TAsync> extends true ? T : true extends TAsync ? Promise<T> : Thenable<T>;
|
|
63
89
|
|
|
64
90
|
type SplitString<TName extends string, TSplitBy extends string = ' '> = TName extends `${infer FirstPart}${TSplitBy}${infer RestParts}`
|
|
65
91
|
? [FirstPart, ...SplitString<RestParts, TSplitBy>]
|
|
@@ -113,40 +139,76 @@ type GetCommandPathsAndAliases<TCommand extends AnyPadroneCommand> = TCommand['~
|
|
|
113
139
|
/**
|
|
114
140
|
* Find a direct child command in a tuple by name.
|
|
115
141
|
* Unlike PickCommandByName, this does NOT flatten — it only checks direct children by their `name` field.
|
|
142
|
+
* Uses indexed access (O(1) depth) instead of recursive tuple walking.
|
|
116
143
|
*/
|
|
117
|
-
export type FindDirectChild<TCommands extends AnyPadroneCommand[], TName extends string> =
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
? First['~types']['name'] extends TName
|
|
122
|
-
? First
|
|
123
|
-
: FindDirectChild<Rest, TName>
|
|
124
|
-
: never;
|
|
144
|
+
export type FindDirectChild<TCommands extends AnyPadroneCommand[], TName extends string> = Extract<
|
|
145
|
+
TCommands[number],
|
|
146
|
+
{ '~types': { name: TName } }
|
|
147
|
+
>;
|
|
125
148
|
|
|
126
149
|
/**
|
|
127
150
|
* Replace a command in a tuple by name, or append if not found.
|
|
128
151
|
* Used by `.command()` override semantics: re-registering a name replaces that entry.
|
|
152
|
+
* Uses mapped type (O(1) depth) instead of recursive tuple walking.
|
|
129
153
|
*/
|
|
130
154
|
export type ReplaceOrAppendCommand<TCommands extends [...AnyPadroneCommand[]], TName extends string, TNew extends AnyPadroneCommand> =
|
|
131
155
|
HasDirectChild<TCommands, TName> extends true ? ReplaceInTuple<TCommands, TName, TNew> : [...TCommands, TNew];
|
|
132
156
|
|
|
133
|
-
type HasDirectChild<TCommands extends AnyPadroneCommand[], TName extends string> =
|
|
134
|
-
|
|
135
|
-
...infer Rest extends AnyPadroneCommand[],
|
|
136
|
-
]
|
|
137
|
-
? First['~types']['name'] extends TName
|
|
138
|
-
? true
|
|
139
|
-
: HasDirectChild<Rest, TName>
|
|
157
|
+
type HasDirectChild<TCommands extends AnyPadroneCommand[], TName extends string> = TName extends TCommands[number]['~types']['name']
|
|
158
|
+
? true
|
|
140
159
|
: false;
|
|
141
160
|
|
|
142
|
-
type ReplaceInTuple<TCommands extends AnyPadroneCommand[], TName extends string, TNew extends AnyPadroneCommand> =
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
161
|
+
type ReplaceInTuple<TCommands extends AnyPadroneCommand[], TName extends string, TNew extends AnyPadroneCommand> = {
|
|
162
|
+
[K in keyof TCommands]: TCommands[K] extends AnyPadroneCommand
|
|
163
|
+
? TCommands[K]['~types']['name'] extends TName
|
|
164
|
+
? TNew
|
|
165
|
+
: TCommands[K]
|
|
166
|
+
: TCommands[K];
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Utility type for extensions that add a command to a builder/program.
|
|
171
|
+
* Replaces the boilerplate `With*<T>` pattern used across all extension files.
|
|
172
|
+
*/
|
|
173
|
+
export type WithCommand<T, TName extends string, TCmd extends AnyPadroneCommand> = T extends {
|
|
174
|
+
'~types': {
|
|
175
|
+
programName: infer PN extends string;
|
|
176
|
+
name: infer N extends string;
|
|
177
|
+
parentName: infer PaN extends string;
|
|
178
|
+
argsSchema: infer A extends PadroneSchema;
|
|
179
|
+
result: infer R;
|
|
180
|
+
commands: infer C extends [...AnyPadroneCommand[]];
|
|
181
|
+
async: infer AS extends boolean;
|
|
182
|
+
context: infer CTX;
|
|
183
|
+
contextProvided: infer CTXP;
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
? T extends { run: any }
|
|
187
|
+
? PadroneProgram<PN, N, PaN, A, R, ReplaceOrAppendCommand<C, TName, TCmd>, any, AS, CTX, CTXP>
|
|
188
|
+
: PadroneBuilder<PN, N, PaN, A, R, ReplaceOrAppendCommand<C, TName, TCmd>, any, AS, CTX, CTXP>
|
|
189
|
+
: T;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Utility type for extensions that register a context-providing interceptor.
|
|
193
|
+
* Extends `TContextProvided` with `TProvides` while preserving all other builder/program type params.
|
|
194
|
+
*/
|
|
195
|
+
export type WithInterceptor<T, TProvides> = T extends {
|
|
196
|
+
'~types': {
|
|
197
|
+
programName: infer PN extends string;
|
|
198
|
+
name: infer N extends string;
|
|
199
|
+
parentName: infer PaN extends string;
|
|
200
|
+
argsSchema: infer A extends PadroneSchema;
|
|
201
|
+
result: infer R;
|
|
202
|
+
commands: infer C extends [...AnyPadroneCommand[]];
|
|
203
|
+
async: infer AS extends boolean;
|
|
204
|
+
context: infer CTX;
|
|
205
|
+
contextProvided: infer CTXP;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
? T extends { run: any }
|
|
209
|
+
? PadroneProgram<PN, N, PaN, A, R, C, any, AS, CTX, CTXP & TProvides>
|
|
210
|
+
: PadroneBuilder<PN, N, PaN, A, R, C, any, AS, CTX, CTXP & TProvides>
|
|
211
|
+
: T;
|
|
150
212
|
|
|
151
213
|
export type PickCommandByName<
|
|
152
214
|
TCommands extends AnyPadroneCommand[],
|
|
@@ -163,13 +225,13 @@ export type PickCommandByName<
|
|
|
163
225
|
|
|
164
226
|
export type FlattenCommands<TCommands extends AnyPadroneCommand[]> = TCommands extends []
|
|
165
227
|
? never
|
|
166
|
-
:
|
|
167
|
-
?
|
|
168
|
-
| (RestCommands extends AnyPadroneCommand[] ? FlattenCommands<RestCommands> : never)
|
|
169
|
-
| (FirstCommand extends AnyPadroneCommand ? FlattenCommands<FirstCommand['~types']['commands']> | FirstCommand : never)
|
|
170
|
-
: IsAny<TCommands[number]> extends true
|
|
228
|
+
: number extends TCommands['length']
|
|
229
|
+
? IsAny<TCommands[number]> extends true
|
|
171
230
|
? never
|
|
172
|
-
: TCommands[number]
|
|
231
|
+
: TCommands[number]
|
|
232
|
+
: TCommands[number] extends infer Cmd extends AnyPadroneCommand
|
|
233
|
+
? Cmd | FlattenCommands<Cmd['~types']['commands']>
|
|
234
|
+
: never;
|
|
173
235
|
|
|
174
236
|
/**
|
|
175
237
|
* Get all command paths including alias paths for all commands.
|
|
@@ -234,9 +296,9 @@ type RepathCommand<TCommand extends AnyPadroneCommand, TNewParentName extends st
|
|
|
234
296
|
TCommand['~types']['result'],
|
|
235
297
|
RepathCommands<TCommand['~types']['commands'], FullCommandName<TCommand['~types']['name'], TNewParentName>>,
|
|
236
298
|
TCommand['~types']['aliases'],
|
|
237
|
-
TCommand['~types']['
|
|
238
|
-
TCommand['~types']['
|
|
239
|
-
TCommand['~types']['
|
|
299
|
+
TCommand['~types']['async'],
|
|
300
|
+
TCommand['~types']['context'],
|
|
301
|
+
TCommand['~types']['contextProvided']
|
|
240
302
|
>;
|
|
241
303
|
|
|
242
304
|
export type PickCommandByPossibleCommands<
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { AnyPadroneCommand } from '../types/index.ts';
|
|
2
|
+
|
|
3
|
+
export function getRootCommand(cmd: AnyPadroneCommand): AnyPadroneCommand {
|
|
4
|
+
let current = cmd;
|
|
5
|
+
while (current.parent) current = current.parent;
|
|
6
|
+
return current;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async function readVersionFromPackageJson(): Promise<string> {
|
|
10
|
+
try {
|
|
11
|
+
const fs = await import('node:fs');
|
|
12
|
+
const path = await import('node:path');
|
|
13
|
+
let dir = process.cwd();
|
|
14
|
+
|
|
15
|
+
// Walk up the directory tree looking for package.json
|
|
16
|
+
for (let i = 0; i < 10; i++) {
|
|
17
|
+
const pkgPath = path.join(dir, 'package.json');
|
|
18
|
+
if (fs.existsSync(pkgPath)) {
|
|
19
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
20
|
+
if (pkg.version) return pkg.version;
|
|
21
|
+
}
|
|
22
|
+
const parentDir = path.dirname(dir);
|
|
23
|
+
if (parentDir === dir) break; // Reached root
|
|
24
|
+
dir = parentDir;
|
|
25
|
+
}
|
|
26
|
+
} catch {
|
|
27
|
+
// Ignore errors (e.g., fs not available in browser)
|
|
28
|
+
}
|
|
29
|
+
return '0.0.0';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Attempts to get the version from various sources:
|
|
34
|
+
* 1. Explicit version set on the command
|
|
35
|
+
* 2. npm_package_version environment variable (set by npm/yarn/pnpm when running scripts)
|
|
36
|
+
* 3. package.json in current or parent directories
|
|
37
|
+
*
|
|
38
|
+
* Returns synchronously when an explicit version or env var is available.
|
|
39
|
+
* Falls back to async package.json discovery otherwise.
|
|
40
|
+
*/
|
|
41
|
+
export function getVersion(explicitVersion?: string): string | Promise<string> {
|
|
42
|
+
if (explicitVersion) return explicitVersion;
|
|
43
|
+
|
|
44
|
+
if (typeof process !== 'undefined' && process.env?.npm_package_version) {
|
|
45
|
+
return process.env.npm_package_version;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (typeof process !== 'undefined') return readVersionFromPackageJson();
|
|
49
|
+
|
|
50
|
+
return '0.0.0';
|
|
51
|
+
}
|
package/src/zod.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { jsonCodec, zodAsyncStream } from './schema/zod.ts';
|
package/dist/args-CVDbyyzG.mjs
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
//#region src/args.ts
|
|
2
|
-
/**
|
|
3
|
-
* Convert a camelCase string to kebab-case.
|
|
4
|
-
* Returns null if the string has no uppercase letters (no conversion needed).
|
|
5
|
-
*/
|
|
6
|
-
function camelToKebab(str) {
|
|
7
|
-
if (!/[A-Z]/.test(str)) return null;
|
|
8
|
-
return str.replace(/[A-Z]/g, (ch) => `-${ch.toLowerCase()}`);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Normalizes stdin config into its explicit form.
|
|
12
|
-
*/
|
|
13
|
-
function parseStdinConfig(stdin) {
|
|
14
|
-
if (typeof stdin === "string") return {
|
|
15
|
-
field: stdin,
|
|
16
|
-
as: "text"
|
|
17
|
-
};
|
|
18
|
-
return {
|
|
19
|
-
field: stdin.field,
|
|
20
|
-
as: stdin.as ?? "text"
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Parse positional configuration to extract names and variadic info.
|
|
25
|
-
*/
|
|
26
|
-
function parsePositionalConfig(positional) {
|
|
27
|
-
return positional.map((p) => {
|
|
28
|
-
const isVariadic = p.startsWith("...");
|
|
29
|
-
return {
|
|
30
|
-
name: isVariadic ? p.slice(3) : p,
|
|
31
|
-
variadic: isVariadic
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
function addEntries(target, key, items, filter) {
|
|
36
|
-
const list = typeof items === "string" ? [items] : items;
|
|
37
|
-
for (const item of list) if (typeof item === "string" && item && item !== key && !(item in target) && (!filter || filter(item))) target[item] = key;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Extract all arg metadata from schema and meta in a single pass.
|
|
41
|
-
* Returns flags (single-char, stackable) and aliases (multi-char, long names) separately.
|
|
42
|
-
* When `autoAlias` is true (default), camelCase property names automatically get kebab-case aliases.
|
|
43
|
-
*/
|
|
44
|
-
function extractSchemaMetadata(schema, meta, autoAlias) {
|
|
45
|
-
const flags = {};
|
|
46
|
-
const aliases = {};
|
|
47
|
-
if (meta) for (const [key, value] of Object.entries(meta)) {
|
|
48
|
-
if (!value) continue;
|
|
49
|
-
if (value.flags) addEntries(flags, key, value.flags, (item) => item.length === 1);
|
|
50
|
-
if (value.alias) addEntries(aliases, key, value.alias, (item) => item.length > 1);
|
|
51
|
-
}
|
|
52
|
-
try {
|
|
53
|
-
const jsonSchema = schema["~standard"].jsonSchema.input({ target: "draft-2020-12" });
|
|
54
|
-
if (jsonSchema.type === "object" && jsonSchema.properties) for (const [propertyName, propertySchema] of Object.entries(jsonSchema.properties)) {
|
|
55
|
-
if (!propertySchema) continue;
|
|
56
|
-
const propFlags = propertySchema.flags;
|
|
57
|
-
if (propFlags) addEntries(flags, propertyName, propFlags, (item) => item.length === 1);
|
|
58
|
-
const propAlias = propertySchema.alias;
|
|
59
|
-
if (propAlias) {
|
|
60
|
-
const list = typeof propAlias === "string" ? [propAlias] : propAlias;
|
|
61
|
-
if (Array.isArray(list)) addEntries(aliases, propertyName, list, (item) => item.length > 1);
|
|
62
|
-
}
|
|
63
|
-
if (autoAlias !== false) {
|
|
64
|
-
const kebab = camelToKebab(propertyName);
|
|
65
|
-
if (kebab && !(kebab in aliases)) aliases[kebab] = propertyName;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
} catch {}
|
|
69
|
-
return {
|
|
70
|
-
flags,
|
|
71
|
-
aliases
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function preprocessMappings(data, mappings) {
|
|
75
|
-
const result = { ...data };
|
|
76
|
-
for (const [mappedKey, fullArgName] of Object.entries(mappings)) if (mappedKey in data && mappedKey !== fullArgName) {
|
|
77
|
-
const mappedValue = data[mappedKey];
|
|
78
|
-
if (!(fullArgName in result)) result[fullArgName] = mappedValue;
|
|
79
|
-
delete result[mappedKey];
|
|
80
|
-
}
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Apply values directly to arguments.
|
|
85
|
-
* CLI values take precedence over the provided values.
|
|
86
|
-
*/
|
|
87
|
-
function applyValues(data, values) {
|
|
88
|
-
const result = { ...data };
|
|
89
|
-
for (const [key, value] of Object.entries(values)) {
|
|
90
|
-
if (key in result && result[key] !== void 0) continue;
|
|
91
|
-
if (value !== void 0) result[key] = value;
|
|
92
|
-
}
|
|
93
|
-
return result;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Combined preprocessing of arguments with all features.
|
|
97
|
-
* Precedence order (highest to lowest): CLI args > stdin > env vars > config file
|
|
98
|
-
*/
|
|
99
|
-
function preprocessArgs(data, ctx) {
|
|
100
|
-
let result = { ...data };
|
|
101
|
-
if (ctx.flags && Object.keys(ctx.flags).length > 0) result = preprocessMappings(result, ctx.flags);
|
|
102
|
-
if (ctx.aliases && Object.keys(ctx.aliases).length > 0) result = preprocessMappings(result, ctx.aliases);
|
|
103
|
-
if (ctx.stdinData) result = applyValues(result, ctx.stdinData);
|
|
104
|
-
if (ctx.envData) result = applyValues(result, ctx.envData);
|
|
105
|
-
if (ctx.configData) result = applyValues(result, ctx.configData);
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Auto-coerce CLI string values to match the expected schema types.
|
|
110
|
-
* Handles: string → number, string → boolean for primitive schema fields.
|
|
111
|
-
* Arrays of primitives are also coerced element-wise.
|
|
112
|
-
*/
|
|
113
|
-
function coerceArgs(data, schema) {
|
|
114
|
-
let properties;
|
|
115
|
-
try {
|
|
116
|
-
const jsonSchema = schema["~standard"].jsonSchema.input({ target: "draft-2020-12" });
|
|
117
|
-
if (jsonSchema.type !== "object" || !jsonSchema.properties) return data;
|
|
118
|
-
properties = jsonSchema.properties;
|
|
119
|
-
} catch {
|
|
120
|
-
return data;
|
|
121
|
-
}
|
|
122
|
-
const result = { ...data };
|
|
123
|
-
for (const [key, value] of Object.entries(result)) {
|
|
124
|
-
const prop = properties[key];
|
|
125
|
-
if (!prop) continue;
|
|
126
|
-
const targetType = prop.type;
|
|
127
|
-
if (targetType === "number" || targetType === "integer") {
|
|
128
|
-
if (typeof value === "string") {
|
|
129
|
-
const num = Number(value);
|
|
130
|
-
if (!Number.isNaN(num)) result[key] = num;
|
|
131
|
-
}
|
|
132
|
-
} else if (targetType === "boolean") {
|
|
133
|
-
if (typeof value === "string") {
|
|
134
|
-
if (value === "true" || value === "1") result[key] = true;
|
|
135
|
-
else if (value === "false" || value === "0") result[key] = false;
|
|
136
|
-
}
|
|
137
|
-
} else if (targetType === "array") {
|
|
138
|
-
const arr = Array.isArray(value) ? value : [value];
|
|
139
|
-
const itemType = prop.items?.type;
|
|
140
|
-
if (itemType === "number" || itemType === "integer") result[key] = arr.map((v) => {
|
|
141
|
-
if (typeof v === "string") {
|
|
142
|
-
const num = Number(v);
|
|
143
|
-
return Number.isNaN(num) ? v : num;
|
|
144
|
-
}
|
|
145
|
-
return v;
|
|
146
|
-
});
|
|
147
|
-
else if (itemType === "boolean") result[key] = arr.map((v) => {
|
|
148
|
-
if (typeof v === "string") {
|
|
149
|
-
if (v === "true" || v === "1") return true;
|
|
150
|
-
if (v === "false" || v === "0") return false;
|
|
151
|
-
}
|
|
152
|
-
return v;
|
|
153
|
-
});
|
|
154
|
-
else if (!Array.isArray(value)) result[key] = arr;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return result;
|
|
158
|
-
}
|
|
159
|
-
/** Keys consumed by the CLI framework that are not user-defined args. */
|
|
160
|
-
const frameworkReservedKeys = new Set(["config", "c"]);
|
|
161
|
-
/**
|
|
162
|
-
* Detect unknown keys in the args that don't match any schema property.
|
|
163
|
-
* Returns an array of { key, suggestion? } for each unknown key.
|
|
164
|
-
* Framework-reserved keys (--config, -c) are always allowed.
|
|
165
|
-
*/
|
|
166
|
-
function detectUnknownArgs(data, schema, flags, aliases, suggestFn) {
|
|
167
|
-
let properties;
|
|
168
|
-
let isLoose = false;
|
|
169
|
-
try {
|
|
170
|
-
const jsonSchema = schema["~standard"].jsonSchema.input({ target: "draft-2020-12" });
|
|
171
|
-
if (jsonSchema.type !== "object" || !jsonSchema.properties) return [];
|
|
172
|
-
properties = jsonSchema.properties;
|
|
173
|
-
if (jsonSchema.additionalProperties !== void 0 && jsonSchema.additionalProperties !== false) isLoose = true;
|
|
174
|
-
} catch {
|
|
175
|
-
return [];
|
|
176
|
-
}
|
|
177
|
-
if (isLoose) return [];
|
|
178
|
-
const knownKeys = new Set([
|
|
179
|
-
...Object.keys(properties),
|
|
180
|
-
...Object.keys(flags),
|
|
181
|
-
...Object.values(flags),
|
|
182
|
-
...Object.keys(aliases),
|
|
183
|
-
...Object.values(aliases)
|
|
184
|
-
]);
|
|
185
|
-
const propertyNames = Object.keys(properties);
|
|
186
|
-
const unknowns = [];
|
|
187
|
-
for (const key of Object.keys(data)) if (!knownKeys.has(key) && !frameworkReservedKeys.has(key)) {
|
|
188
|
-
const suggestion = suggestFn(key, propertyNames);
|
|
189
|
-
unknowns.push({
|
|
190
|
-
key,
|
|
191
|
-
suggestion
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
return unknowns;
|
|
195
|
-
}
|
|
196
|
-
//#endregion
|
|
197
|
-
export { parsePositionalConfig as a, extractSchemaMetadata as i, coerceArgs as n, parseStdinConfig as o, detectUnknownArgs as r, preprocessArgs as s, camelToKebab as t };
|
|
198
|
-
|
|
199
|
-
//# sourceMappingURL=args-CVDbyyzG.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"args-CVDbyyzG.mjs","names":[],"sources":["../src/args.ts"],"sourcesContent":["import type { StandardJSONSchemaV1 } from '@standard-schema/spec';\n\ntype Letter =\n | 'a'\n | 'b'\n | 'c'\n | 'd'\n | 'e'\n | 'f'\n | 'g'\n | 'h'\n | 'i'\n | 'j'\n | 'k'\n | 'l'\n | 'm'\n | 'n'\n | 'o'\n | 'p'\n | 'q'\n | 'r'\n | 's'\n | 't'\n | 'u'\n | 'v'\n | 'w'\n | 'x'\n | 'y'\n | 'z';\n\n/** A single letter character, valid as a short CLI flag (e.g. `'v'`, `'n'`, `'V'`). */\nexport type SingleChar = Letter | Uppercase<Letter>;\n\nexport interface PadroneFieldMeta {\n description?: string;\n /** Single-character short flags (stackable: `-abc` = `-a -b -c`). Used with single dash. */\n flags?: SingleChar[] | SingleChar;\n /** Multi-character alternative long names. Used with double dash (e.g. `--dry-run` for `--dryRun`). */\n alias?: string[] | string;\n deprecated?: boolean | string;\n hidden?: boolean;\n examples?: unknown[];\n}\n\ntype PositionalArgs<TObj> =\n TObj extends Record<string, any>\n ? {\n [K in keyof TObj]: NonNullable<TObj[K]> extends Array<any> ? `...${K & string}` | (K & string) : K & string;\n }[keyof TObj]\n : string;\n\n/**\n * Meta configuration for arguments, including positional arguments.\n * The `positional` array defines which arguments are positional and their order.\n * Use '...name' prefix to indicate variadic (rest) arguments, matching JS/TS rest syntax.\n *\n * @example\n * ```ts\n * .arguments(schema, {\n * positional: ['source', '...files', 'dest'], // '...files' is variadic\n * })\n * ```\n */\n/**\n * Configuration for reading from stdin and mapping it to an argument field.\n */\nexport type StdinConfig<TObj = Record<string, any>> =\n | (keyof TObj & string)\n | {\n /** The argument field to populate with stdin data. */\n field: keyof TObj & string;\n /**\n * How to consume stdin:\n * - `'text'` (default): read all stdin as a single string.\n * - `'lines'`: read stdin as an array of lines (string[]).\n */\n as?: 'text' | 'lines';\n };\n\nexport interface PadroneArgsSchemaMeta<TObj = Record<string, any>> {\n /**\n * Array of argument names that should be treated as positional arguments.\n * Order in array determines position. Use '...name' prefix for variadic args.\n * @example ['source', '...files', 'dest'] - 'files' captures multiple values\n */\n positional?: PositionalArgs<TObj>[];\n /**\n * Per-argument metadata.\n */\n fields?: { [K in keyof TObj]?: PadroneFieldMeta };\n /**\n * Automatically generate kebab-case aliases for camelCase option names.\n * For example, `dryRun` automatically gets `--dry-run` as an alias.\n * Defaults to `true`. Set to `false` to disable.\n *\n * @default true\n * @example\n * ```ts\n * // Auto-aliases enabled (default): --dry-run → dryRun\n * .arguments(z.object({ dryRun: z.boolean() }))\n *\n * // Disable auto-aliases\n * .arguments(z.object({ dryRun: z.boolean() }), { autoAlias: false })\n * ```\n */\n autoAlias?: boolean;\n /**\n * Read from stdin and inject the data into the specified argument field.\n * Only reads when stdin is piped (not a TTY) and the field wasn't already provided via CLI flags.\n *\n * - `string`: shorthand for `{ field: name, as: 'text' }` — read all stdin as a string.\n * - `{ field, as }`: explicit form. `as: 'text'` reads all stdin as a string,\n * `as: 'lines'` reads stdin as an array of line strings.\n *\n * Precedence: CLI flags > stdin > env vars > config file > schema defaults.\n *\n * @example\n * ```ts\n * // Shorthand: read all stdin as text into 'data' field\n * .arguments(z.object({ data: z.string() }), { stdin: 'data' })\n *\n * // Explicit: read stdin lines into 'lines' field\n * .arguments(z.object({ lines: z.string().array() }), {\n * stdin: { field: 'lines', as: 'lines' },\n * })\n * ```\n */\n stdin?: StdinConfig<TObj>;\n /**\n * Fields to interactively prompt for when their values are missing after CLI/env/config resolution.\n * - `true`: prompt for all required fields that are missing.\n * - `string[]`: prompt for these specific fields if missing.\n *\n * Interactive prompting only occurs in `cli()` when the runtime has `interactive: true`.\n * Setting this makes `parse()` and `cli()` return Promises.\n *\n * @example\n * ```ts\n * .arguments(schema, {\n * interactive: true, // prompt all missing required fields\n * interactive: ['name', 'template'], // prompt only these fields\n * })\n * ```\n */\n interactive?: true | (keyof TObj & string)[];\n /**\n * Optional fields offered after required interactive prompts.\n * Users are shown a multi-select to choose which of these fields to configure.\n * - `true`: offer all optional fields that are missing.\n * - `string[]`: offer these specific fields.\n *\n * @example\n * ```ts\n * .arguments(schema, {\n * interactive: ['name'],\n * optionalInteractive: ['typescript', 'eslint', 'prettier'],\n * })\n * ```\n */\n optionalInteractive?: true | (keyof TObj & string)[];\n}\n\n/**\n * Convert a camelCase string to kebab-case.\n * Returns null if the string has no uppercase letters (no conversion needed).\n */\nexport function camelToKebab(str: string): string | null {\n if (!/[A-Z]/.test(str)) return null;\n return str.replace(/[A-Z]/g, (ch) => `-${ch.toLowerCase()}`);\n}\n\n/**\n * Normalizes stdin config into its explicit form.\n */\nexport function parseStdinConfig(stdin: StdinConfig): { field: string; as: 'text' | 'lines' } {\n if (typeof stdin === 'string') return { field: stdin, as: 'text' };\n return { field: stdin.field as string, as: stdin.as ?? 'text' };\n}\n\n/**\n * Parse positional configuration to extract names and variadic info.\n */\nexport function parsePositionalConfig(positional: string[]): { name: string; variadic: boolean }[] {\n return positional.map((p) => {\n const isVariadic = p.startsWith('...');\n const name = isVariadic ? p.slice(3) : p;\n return { name, variadic: isVariadic };\n });\n}\n\n/**\n * Result type for extractSchemaMetadata function.\n */\ninterface SchemaMetadataResult {\n /** Single-char flags: maps flag char → full arg name (e.g. `{ v: 'verbose' }`) */\n flags: Record<string, string>;\n /** Multi-char aliases: maps alias → full arg name (e.g. `{ 'dry-run': 'dryRun' }`) */\n aliases: Record<string, string>;\n}\n\nfunction addEntries(target: Record<string, string>, key: string, items: string | string[], filter?: (item: string) => boolean) {\n const list = typeof items === 'string' ? [items] : items;\n for (const item of list) {\n if (typeof item === 'string' && item && item !== key && !(item in target) && (!filter || filter(item))) {\n target[item] = key;\n }\n }\n}\n\n/**\n * Extract all arg metadata from schema and meta in a single pass.\n * Returns flags (single-char, stackable) and aliases (multi-char, long names) separately.\n * When `autoAlias` is true (default), camelCase property names automatically get kebab-case aliases.\n */\nexport function extractSchemaMetadata(\n schema: StandardJSONSchemaV1,\n meta?: Record<string, PadroneFieldMeta | undefined>,\n autoAlias?: boolean,\n): SchemaMetadataResult {\n const flags: Record<string, string> = {};\n const aliases: Record<string, string> = {};\n\n // Extract from meta object\n if (meta) {\n for (const [key, value] of Object.entries(meta)) {\n if (!value) continue;\n\n if (value.flags) {\n addEntries(flags, key, value.flags, (item) => item.length === 1);\n }\n if (value.alias) {\n addEntries(aliases, key, value.alias, (item) => item.length > 1);\n }\n }\n }\n\n // Extract from JSON schema properties\n try {\n const jsonSchema = schema['~standard'].jsonSchema.input({ target: 'draft-2020-12' }) as Record<string, any>;\n if (jsonSchema.type === 'object' && jsonSchema.properties) {\n for (const [propertyName, propertySchema] of Object.entries(jsonSchema.properties as Record<string, any>)) {\n if (!propertySchema) continue;\n\n // Extract flags from schema `.meta({ flags: ... })`\n const propFlags = propertySchema.flags;\n if (propFlags) {\n addEntries(flags, propertyName, propFlags, (item) => item.length === 1);\n }\n\n // Extract aliases from schema `.meta({ alias: ... })`\n const propAlias = propertySchema.alias;\n if (propAlias) {\n const list = typeof propAlias === 'string' ? [propAlias] : propAlias;\n if (Array.isArray(list)) {\n addEntries(aliases, propertyName, list, (item) => item.length > 1);\n }\n }\n\n // Auto-generate kebab-case alias for camelCase property names\n if (autoAlias !== false) {\n const kebab = camelToKebab(propertyName);\n if (kebab && !(kebab in aliases)) {\n aliases[kebab] = propertyName;\n }\n }\n }\n }\n } catch {\n // Ignore errors from JSON schema generation\n }\n\n return { flags, aliases };\n}\n\nfunction preprocessMappings(data: Record<string, unknown>, mappings: Record<string, string>): Record<string, unknown> {\n const result = { ...data };\n\n for (const [mappedKey, fullArgName] of Object.entries(mappings)) {\n if (mappedKey in data && mappedKey !== fullArgName) {\n const mappedValue = data[mappedKey];\n // Prefer full arg name if it exists\n if (!(fullArgName in result)) result[fullArgName] = mappedValue;\n delete result[mappedKey];\n }\n }\n\n return result;\n}\n\ninterface ParseArgsContext {\n flags?: Record<string, string>;\n aliases?: Record<string, string>;\n stdinData?: Record<string, unknown>;\n envData?: Record<string, unknown>;\n configData?: Record<string, unknown>;\n}\n\n/**\n * Apply values directly to arguments.\n * CLI values take precedence over the provided values.\n */\nfunction applyValues(data: Record<string, unknown>, values: Record<string, unknown>): Record<string, unknown> {\n const result = { ...data };\n\n for (const [key, value] of Object.entries(values)) {\n // Only apply value if arg wasn't already set\n if (key in result && result[key] !== undefined) continue;\n if (value !== undefined) {\n result[key] = value;\n }\n }\n\n return result;\n}\n\n/**\n * Combined preprocessing of arguments with all features.\n * Precedence order (highest to lowest): CLI args > stdin > env vars > config file\n */\nexport function preprocessArgs(data: Record<string, unknown>, ctx: ParseArgsContext): Record<string, unknown> {\n let result = { ...data };\n\n // 1. Apply flags and aliases first\n if (ctx.flags && Object.keys(ctx.flags).length > 0) {\n result = preprocessMappings(result, ctx.flags);\n }\n if (ctx.aliases && Object.keys(ctx.aliases).length > 0) {\n result = preprocessMappings(result, ctx.aliases);\n }\n\n // 2. Apply stdin data (higher precedence than env)\n // Only applies if CLI didn't set the arg\n if (ctx.stdinData) {\n result = applyValues(result, ctx.stdinData);\n }\n\n // 3. Apply environment variables (higher precedence than config)\n // These only apply if CLI/stdin didn't set the arg\n if (ctx.envData) {\n result = applyValues(result, ctx.envData);\n }\n\n // 4. Apply config file values (lowest precedence)\n // These only apply if neither CLI, stdin, nor env set the arg\n if (ctx.configData) {\n result = applyValues(result, ctx.configData);\n }\n\n return result;\n}\n\n/**\n * Auto-coerce CLI string values to match the expected schema types.\n * Handles: string → number, string → boolean for primitive schema fields.\n * Arrays of primitives are also coerced element-wise.\n */\nexport function coerceArgs(data: Record<string, unknown>, schema: StandardJSONSchemaV1): Record<string, unknown> {\n let properties: Record<string, any>;\n try {\n const jsonSchema = schema['~standard'].jsonSchema.input({ target: 'draft-2020-12' }) as Record<string, any>;\n if (jsonSchema.type !== 'object' || !jsonSchema.properties) return data;\n properties = jsonSchema.properties;\n } catch {\n return data;\n }\n\n const result = { ...data };\n\n for (const [key, value] of Object.entries(result)) {\n const prop = properties[key];\n if (!prop) continue;\n\n const targetType = prop.type as string | undefined;\n\n if (targetType === 'number' || targetType === 'integer') {\n if (typeof value === 'string') {\n const num = Number(value);\n if (!Number.isNaN(num)) result[key] = num;\n }\n } else if (targetType === 'boolean') {\n if (typeof value === 'string') {\n if (value === 'true' || value === '1') result[key] = true;\n else if (value === 'false' || value === '0') result[key] = false;\n }\n } else if (targetType === 'array') {\n // Coerce single items to array\n const arr = Array.isArray(value) ? value : [value];\n const itemType = prop.items?.type as string | undefined;\n if (itemType === 'number' || itemType === 'integer') {\n result[key] = arr.map((v) => {\n if (typeof v === 'string') {\n const num = Number(v);\n return Number.isNaN(num) ? v : num;\n }\n return v;\n });\n } else if (itemType === 'boolean') {\n result[key] = arr.map((v) => {\n if (typeof v === 'string') {\n if (v === 'true' || v === '1') return true;\n if (v === 'false' || v === '0') return false;\n }\n return v;\n });\n } else if (!Array.isArray(value)) {\n result[key] = arr;\n }\n }\n }\n\n return result;\n}\n\n/** Keys consumed by the CLI framework that are not user-defined args. */\nconst frameworkReservedKeys = new Set(['config', 'c']);\n\n/**\n * Detect unknown keys in the args that don't match any schema property.\n * Returns an array of { key, suggestion? } for each unknown key.\n * Framework-reserved keys (--config, -c) are always allowed.\n */\nexport function detectUnknownArgs(\n data: Record<string, unknown>,\n schema: StandardJSONSchemaV1,\n flags: Record<string, string>,\n aliases: Record<string, string>,\n suggestFn: (input: string, candidates: string[]) => string,\n): { key: string; suggestion: string }[] {\n let properties: Record<string, any>;\n let isLoose = false;\n try {\n const jsonSchema = schema['~standard'].jsonSchema.input({ target: 'draft-2020-12' }) as Record<string, any>;\n if (jsonSchema.type !== 'object' || !jsonSchema.properties) return [];\n properties = jsonSchema.properties;\n // If additionalProperties is set (true, {}, or a schema), the schema allows extra keys\n if (jsonSchema.additionalProperties !== undefined && jsonSchema.additionalProperties !== false) isLoose = true;\n } catch {\n return [];\n }\n\n if (isLoose) return [];\n\n const knownKeys = new Set<string>([\n ...Object.keys(properties),\n ...Object.keys(flags),\n ...Object.values(flags),\n ...Object.keys(aliases),\n ...Object.values(aliases),\n ]);\n const propertyNames = Object.keys(properties);\n const unknowns: { key: string; suggestion: string }[] = [];\n\n for (const key of Object.keys(data)) {\n if (!knownKeys.has(key) && !frameworkReservedKeys.has(key)) {\n const suggestion = suggestFn(key, propertyNames);\n unknowns.push({ key, suggestion });\n }\n }\n\n return unknowns;\n}\n"],"mappings":";;;;;AAsKA,SAAgB,aAAa,KAA4B;AACvD,KAAI,CAAC,QAAQ,KAAK,IAAI,CAAE,QAAO;AAC/B,QAAO,IAAI,QAAQ,WAAW,OAAO,IAAI,GAAG,aAAa,GAAG;;;;;AAM9D,SAAgB,iBAAiB,OAA6D;AAC5F,KAAI,OAAO,UAAU,SAAU,QAAO;EAAE,OAAO;EAAO,IAAI;EAAQ;AAClE,QAAO;EAAE,OAAO,MAAM;EAAiB,IAAI,MAAM,MAAM;EAAQ;;;;;AAMjE,SAAgB,sBAAsB,YAA6D;AACjG,QAAO,WAAW,KAAK,MAAM;EAC3B,MAAM,aAAa,EAAE,WAAW,MAAM;AAEtC,SAAO;GAAE,MADI,aAAa,EAAE,MAAM,EAAE,GAAG;GACxB,UAAU;GAAY;GACrC;;AAaJ,SAAS,WAAW,QAAgC,KAAa,OAA0B,QAAoC;CAC7H,MAAM,OAAO,OAAO,UAAU,WAAW,CAAC,MAAM,GAAG;AACnD,MAAK,MAAM,QAAQ,KACjB,KAAI,OAAO,SAAS,YAAY,QAAQ,SAAS,OAAO,EAAE,QAAQ,YAAY,CAAC,UAAU,OAAO,KAAK,EACnG,QAAO,QAAQ;;;;;;;AAUrB,SAAgB,sBACd,QACA,MACA,WACsB;CACtB,MAAM,QAAgC,EAAE;CACxC,MAAM,UAAkC,EAAE;AAG1C,KAAI,KACF,MAAK,MAA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AW;CAC7C,MAAM,WAAkD,EAAE;AAE1D,MAAK,MAAM,OAAO,OAAO,KAAK,KAAK,CACjC,KAAI,CAAC,UAAU,IAAI,IAAI,IAAI,CAAC,sBAAsB,IAAI,IAAI,EAAE;EAC1D,MAAM,aAAa,UAAU,KAAK,cAAc;AAChD,WAAS,KAAK;GAAE;GAAK;GAAY,CAAC;;AAItC,QAAO"}
|
package/dist/chunk-y_GBKt04.mjs
DELETED
package/dist/completion.d.mts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { n as AnyPadroneCommand } from "./types-DjIdJN5G.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/shell-utils.d.ts
|
|
4
|
-
type ShellType = 'bash' | 'zsh' | 'fish' | 'powershell';
|
|
5
|
-
/**
|
|
6
|
-
* Detects the current shell from environment variables and process info.
|
|
7
|
-
* @returns The detected shell type, or undefined if unknown
|
|
8
|
-
*/
|
|
9
|
-
declare function detectShell(): ShellType | undefined;
|
|
10
|
-
declare function getRcFile(shell: ShellType, home?: string): string | null;
|
|
11
|
-
declare function escapeRegExp(str: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Writes a snippet to a shell config file using begin/end markers for idempotency.
|
|
14
|
-
* If a block with the same begin marker exists, it is replaced. Otherwise the snippet is appended.
|
|
15
|
-
*/
|
|
16
|
-
declare function writeToRcFile(rcFile: string, snippet: string, beginMarker: string, endMarker: string): {
|
|
17
|
-
file: string;
|
|
18
|
-
updated: boolean;
|
|
19
|
-
};
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/completion.d.ts
|
|
22
|
-
/**
|
|
23
|
-
* Generates a Bash completion script for the program.
|
|
24
|
-
*/
|
|
25
|
-
declare function generateBashCompletion(program: AnyPadroneCommand): string;
|
|
26
|
-
/**
|
|
27
|
-
* Generates a Zsh completion script for the program.
|
|
28
|
-
*/
|
|
29
|
-
declare function generateZshCompletion(program: AnyPadroneCommand): string;
|
|
30
|
-
/**
|
|
31
|
-
* Generates a Fish completion script for the program.
|
|
32
|
-
*/
|
|
33
|
-
declare function generateFishCompletion(program: AnyPadroneCommand): string;
|
|
34
|
-
/**
|
|
35
|
-
* Generates a PowerShell completion script for the program.
|
|
36
|
-
*/
|
|
37
|
-
declare function generatePowerShellCompletion(program: AnyPadroneCommand): string;
|
|
38
|
-
/**
|
|
39
|
-
* Generates a completion script for the specified shell.
|
|
40
|
-
*/
|
|
41
|
-
declare function generateCompletion(program: AnyPadroneCommand, shell: ShellType): string;
|
|
42
|
-
/**
|
|
43
|
-
* Gets the installation instructions for a shell completion script.
|
|
44
|
-
*/
|
|
45
|
-
declare function getCompletionInstallInstructions(programName: string, shell: ShellType): string;
|
|
46
|
-
/**
|
|
47
|
-
* Generates the completion output with automatic shell detection.
|
|
48
|
-
* If shell is not specified, detects the current shell and provides instructions.
|
|
49
|
-
*/
|
|
50
|
-
declare function generateCompletionOutput(program: AnyPadroneCommand, shell?: ShellType): string;
|
|
51
|
-
interface SetupCompletionsResult {
|
|
52
|
-
/** The file that was written to. */
|
|
53
|
-
file: string;
|
|
54
|
-
/** Whether an existing completion block was replaced (true) or a new one was appended (false). */
|
|
55
|
-
updated: boolean;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Sets up shell completions by writing an eval snippet to the appropriate shell config file.
|
|
59
|
-
* Uses marker comments for idempotency — re-running replaces the existing block.
|
|
60
|
-
*/
|
|
61
|
-
declare function setupCompletions(programName: string, shell: ShellType): SetupCompletionsResult;
|
|
62
|
-
//#endregion
|
|
63
|
-
export { SetupCompletionsResult, type ShellType, detectShell, escapeRegExp, generateBashCompletion, generateCompletion, generateCompletionOutput, generateFishCompletion, generatePowerShellCompletion, generateZshCompletion, getCompletionInstallInstructions, getRcFile, setupCompletions, writeToRcFile };
|
|
64
|
-
//# sourceMappingURL=completion.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"completion.d.mts","names":[],"sources":["../src/shell-utils.ts","../src/completion.ts"],"mappings":";;;KAAY,SAAA;;;AAAZ;;iBAMgB,WAAA,CAAA,GAAe,SAAA;AAAA,iBAmCf,SAAA,CAAU,KAAA,EAAO,SAAA,EAAW,IAAA;AAAA,iBAkB5B,YAAA,CAAa,GAAA;AArD7B;;;;AAAA,iBA6DgB,aAAA,CAAc,MAAA,UAAgB,OAAA,UAAiB,WAAA,UAAqB,SAAA;EAAsB,IAAA;EAAc,OAAA;AAAA;;;AAnExH;;;AAAA,iBCgEgB,sBAAA,CAAuB,OAAA,EAAS,iBAAA;;AD1DhD;;iBCgJgB,qBAAA,CAAsB,OAAA,EAAS,iBAAA;;;AD7G/C;iBCyLgB,sBAAA,CAAuB,OAAA,EAAS,iBAAA;;;;iBAuDhC,4BAAA,CAA6B,OAAA,EAAS,iBAAA;;;;iBAmCtC,kBAAA,CAAmB,OAAA,EAAS,iBAAA,EAAmB,KAAA,EAAO,SAAA;;;;iBAkBtD,gCAAA,CAAiC,WAAA,UAAqB,KAAA,EAAO,SAAA;AD3Q7E;;;;AAAA,iBC6SgB,wBAAA,CAAyB,OAAA,EAAS,iBAAA,EAAmB,KAAA,GAAQ,SAAA;AAAA,UA0C5D,sBAAA;EDvV8C;ECyV7D,IAAA;EDzVwG;EC2VxG,OAAA;AAAA;;;;;iBAOc,gBAAA,CAAiB,WAAA,UAAqB,KAAA,EAAO,SAAA,GAAY,sBAAA"}
|
package/dist/completion.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"completion.mjs","names":[],"sources":["../src/shell-utils.ts","../src/completion.ts"],"sourcesContent":["export type ShellType = 'bash' | 'zsh' | 'fish' | 'powershell';\n\n/**\n * Detects the current shell from environment variables and process info.\n * @returns The detected shell type, or undefined if unknown\n */\nexport function detectShell(): ShellType | undefined {\n if (typeof process === 'undefined') return undefined;\n\n // Method 1: Check SHELL environment variable (most common)\n const shellEnv = process.env.SHELL || '';\n if (shellEnv.includes('zsh')) return 'zsh';\n if (shellEnv.includes('bash')) return 'bash';\n if (shellEnv.includes('fish')) return 'fish';\n\n // Method 2: Check Windows-specific shells\n if (process.env.PSModulePath || process.env.POWERSHELL_DISTRIBUTION_CHANNEL) {\n return 'powershell';\n }\n\n // Method 3: Check parent process on Unix-like systems\n try {\n const ppid = process.ppid;\n if (ppid) {\n const { execSync } = require('node:child_process') as typeof import('node:child_process');\n const processName = execSync(`ps -p ${ppid} -o comm=`, {\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'ignore'],\n }).trim();\n\n if (processName.includes('zsh')) return 'zsh';\n if (processName.includes('bash')) return 'bash';\n if (processName.includes('fish')) return 'fish';\n }\n } catch {\n // Ignore errors (e.g., ps not available)\n }\n\n return undefined;\n}\n\nexport function getRcFile(shell: ShellType, home?: string): string | null {\n const { homedir } = require('node:os') as typeof import('node:os');\n const { join } = require('node:path') as typeof import('node:path');\n const h = home ?? homedir();\n switch (shell) {\n case 'bash':\n return join(h, '.bashrc');\n case 'zsh':\n return join(h, '.zshrc');\n case 'fish':\n return join(h, '.config', 'fish', 'config.fish');\n case 'powershell':\n return process.env.PROFILE || join(h, 'Documents', 'PowerShell', 'Microsoft.PowerShell_profile.ps1');\n default:\n return null;\n }\n}\n\nexport function escapeRegExp(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/**\n * Writes a snippet to a shell config file using begin/end markers for idempotency.\n * If a block with the same begin marker exists, it is replaced. Otherwise the snippet is appended.\n */\nexport function writeToRcFile(rcFile: string, snippet: string, beginMarker: string, endMarker: string): { file: string; updated: boolean } {\n const { existsSync, mkdirSync, readFileSync, writeFileSync } = require('node:fs') as typeof import('node:fs');\n const { dirname } = require('node:path') as typeof import('node:path');\n const existing = existsSync(rcFile) ? readFileSync(rcFile, 'utf-8') : '';\n\n if (existing.includes(beginMarker)) {\n const pattern = new RegExp(`${escapeRegExp(beginMarker)}[\\\\s\\\\S]*?${escapeRegExp(endMarker)}`);\n writeFileSync(rcFile, existing.replace(pattern, snippet));\n return { file: rcFile, updated: true };\n }\n\n mkdirSync(dirname(rcFile), { recursive: true });\n const separator = existing.length > 0 && !existing.endsWith('\\n') ? '\\n' : '';\n writeFileSync(rcFile, `${existing}${separator}\\n${snippet}\\n`);\n return { file: rcFile, updated: false };\n}\n","import { extractSchemaMetadata } from './args.ts';\nimport { detectShell, getRcFile, type ShellType, writeToRcFile } from './shell-utils.ts';\nimport type { AnyPadroneCommand } from './types.ts';\n\nexport { detectShell, escapeRegExp, getRcFile, type ShellType, writeToRcFile } from './shell-utils.ts';\n\n/**\n * Collects all commands from a program recursively.\n */\nfunction collectAllCommands(cmd: AnyPadroneCommand): AnyPadroneCommand[] {\n const result: AnyPadroneCommand[] = [];\n\n if (cmd.commands) {\n for (const subcmd of cmd.commands) {\n if (!subcmd.hidden) {\n result.push(subcmd);\n result.push(...collectAllCommands(subcmd));\n }\n }\n }\n\n return result;\n}\n\n/**\n * Extracts all argument names from a command's schema.\n */\nfunction extractArguments(cmd: AnyPadroneCommand): { name: string; alias?: string; isBoolean: boolean }[] {\n const argList: { name: string; alias?: string; isBoolean: boolean }[] = [];\n\n if (!cmd.argsSchema) return argList;\n\n try {\n const argsMeta = cmd.meta?.fields;\n const { aliases } = extractSchemaMetadata(cmd.argsSchema, argsMeta, cmd.meta?.autoAlias);\n\n // Reverse aliases map (alias -> arg name)\n const aliasToArgument: Record<string, string> = {};\n for (const [arg, alias] of Object.entries(aliases)) {\n aliasToArgument[alias] = arg;\n }\n\n const jsonSchema = cmd.argsSchema['~standard'].jsonSchema.input({ target: 'draft-2020-12' }) as Record<string, any>;\n\n if (jsonSchema.type === 'object' && jsonSchema.properties) {\n for (const [key, prop] of Object.entries(jsonSchema.properties as Record<string, any>)) {\n const alias = Object.entries(aliases).find(([arg]) => arg === key)?.[1];\n argList.push({\n name: key,\n alias: alias,\n isBoolean: prop?.type === 'boolean',\n });\n }\n }\n } catch {\n // Ignore schema parsing errors\n }\n\n return argList;\n}\n\n/**\n * Generates a Bash completion script for the program.\n */\nexport function generateBashCompletion(program: AnyPadroneCommand): string {\n const programName = program.name;\n const commands = collectAllCommands(program);\n const commandNames = commands.map((c) => c.name).join(' ');\n\n // Collect all args from all commands\n const allArguments = new Set<string>();\n allArguments.add('--help');\n allArguments.add('--version');\n\n for (const cmd of [program, ...commands]) {\n for (const arg of extractArguments(cmd)) {\n allArguments.add(`--${arg.name}`);\n if (arg.alias) allArguments.add(`-${arg.alias}`);\n }\n }\n\n const argsList = Array.from(allArguments).join(' ');\n\n return `###-begin-${programName}-completion-###\n#\n# ${programName} command completion script\n#\n# Installation: ${programName} completion >> ~/.bashrc (or ~/.zshrc)\n# Or, maybe: ${programName} completion > /usr/local/etc/bash_completion.d/${programName}\n#\n\nif type complete &>/dev/null; then\n _${programName}_completion() {\n local cur prev words cword\n if type _get_comp_words_by_ref &>/dev/null; then\n _get_comp_words_by_ref -n = -n @ -n : -w words -i cword\n else\n cword=\"$COMP_CWORD\"\n words=(\"\\${COMP_WORDS[@]}\")\n fi\n\n cur=\"\\${words[cword]}\"\n prev=\"\\${words[cword-1]}\"\n\n local commands=\"${commandNames}\"\n local args=\"${argsList}\"\n\n # Complete args when current word starts with -\n if [[ \"$cur\" == -* ]]; then\n COMPREPLY=($(compgen -W \"$args\" -- \"$cur\"))\n return 0\n fi\n\n # Complete commands\n COMPREPLY=($(compgen -W \"$commands\" -- \"$cur\"))\n }\n complete -o bashdefault -o default -o nospace -F _${programName}_completion ${programName}\nelif type compdef &>/dev/null; then\n _${programName}_completion() {\n local si=$IFS\n local commands=\"${commandNames}\"\n local args=\"${argsList}\"\n\n if [[ \"\\${words[CURRENT]}\" == -* ]]; then\n compadd -- \\${=args}\n else\n compadd -- \\${=commands}\n fi\n IFS=$si\n }\n compdef _${programName}_completion ${programName}\nelif type compctl &>/dev/null; then\n _${programName}_completion() {\n local commands=\"${commandNames}\"\n local args=\"${argsList}\"\n\n if [[ \"\\${words[CURRENT]}\" == -* ]]; then\n reply=(\\${=args})\n else\n reply=(\\${=commands})\n fi\n }\n compctl -K _${programName}_completion ${programName}\nfi\n###-end-${programName}-completion-###`;\n}\n\n/**\n * Generates a Zsh completion script for the program.\n */\nexport function generateZshCompletion(program: AnyPadroneCommand): string {\n const programName = program.name;\n const commands = collectAllCommands(program);\n\n // Generate command completions with descriptions\n const commandCompletions = commands\n .map((cmd) => {\n const desc = cmd.description || cmd.title || '';\n const escapedDesc = desc.replace(/'/g, \"'\\\\''\").replace(/:/g, '\\\\:');\n return ` '${cmd.name}:${escapedDesc}'`;\n })\n .join('\\n');\n\n // Collect all args with descriptions\n const argumentCompletions: string[] = [];\n argumentCompletions.push(\" '--help[Show help information]'\");\n argumentCompletions.push(\" '--version[Show version number]'\");\n\n const seenArgs = new Set<string>(['help', 'version']);\n\n for (const cmd of [program, ...commands]) {\n for (const arg of extractArguments(cmd)) {\n if (seenArgs.has(arg.name)) continue;\n seenArgs.add(arg.name);\n\n const desc = cmd.meta?.fields?.[arg.name]?.description || '';\n const escapedDesc = desc.replace(/'/g, \"'\\\\''\").replace(/\\[/g, '\\\\[').replace(/\\]/g, '\\\\]');\n\n if (arg.alias) {\n argumentCompletions.push(` {-${arg.alias},--${arg.name}}'[${escapedDesc}]'`);\n } else {\n argumentCompletions.push(` '--${arg.name}[${escapedDesc}]'`);\n }\n }\n }\n\n return `#compdef ${programName}\n###-begin-${programName}-completion-###\n#\n# ${programName} command completion script for Zsh\n#\n# Installation: ${programName} completion >> ~/.zshrc\n# Or: ${programName} completion > ~/.zsh/completions/_${programName}\n#\n\n_${programName}() {\n local -a commands\n local -a args\n\n commands=(\n${commandCompletions}\n )\n\n args=(\n${argumentCompletions.join('\\n')}\n )\n\n _arguments -s \\\\\n $args \\\\\n '1: :->command' \\\\\n '*::arg:->args'\n\n case \"$state\" in\n command)\n _describe 'command' commands\n ;;\n esac\n}\n\n_${programName}\n###-end-${programName}-completion-###`;\n}\n\n/**\n * Generates a Fish completion script for the program.\n */\nexport function generateFishCompletion(program: AnyPadroneCommand): string {\n const programName = program.name;\n const commands = collectAllCommands(program);\n\n const lines: string[] = [\n `###-begin-${programName}-completion-###`,\n '#',\n `# ${programName} command completion script for Fish`,\n '#',\n `# Installation: ${programName} completion > ~/.config/fish/completions/${programName}.fish`,\n '#',\n '',\n `# Clear existing completions`,\n `complete -c ${programName} -e`,\n '',\n '# Commands',\n ];\n\n for (const cmd of commands) {\n const desc = cmd.description || cmd.title || '';\n const escapedDesc = desc.replace(/'/g, \"\\\\'\");\n lines.push(`complete -c ${programName} -n \"__fish_use_subcommand\" -a \"${cmd.name}\" -d '${escapedDesc}'`);\n }\n\n lines.push('');\n lines.push('# Global arguments');\n lines.push(`complete -c ${programName} -l help -d 'Show help information'`);\n lines.push(`complete -c ${programName} -l version -d 'Show version number'`);\n\n const seenArgs = new Set<string>(['help', 'version']);\n\n for (const cmd of [program, ...commands]) {\n for (const arg of extractArguments(cmd)) {\n if (seenArgs.has(arg.name)) continue;\n seenArgs.add(arg.name);\n\n const desc = cmd.meta?.fields?.[arg.name]?.description || '';\n const escapedDesc = desc.replace(/'/g, \"\\\\'\");\n\n if (arg.alias) {\n lines.push(`complete -c ${programName} -s ${arg.alias} -l ${arg.name} -d '${escapedDesc}'`);\n } else {\n lines.push(`complete -c ${programName} -l ${arg.name} -d '${escapedDesc}'`);\n }\n }\n }\n\n lines.push(`###-end-${programName}-completion-###`);\n\n return lines.join('\\n');\n}\n\n/**\n * Generates a PowerShell completion script for the program.\n */\nexport function generatePowerShellCompletion(program: AnyPadroneCommand): string {\n const programName = program.name;\n const commands = collectAllCommands(program);\n\n const commandNames = commands.map((c) => `'${c.name}'`).join(', ');\n\n return `###-begin-${programName}-completion-###\n#\n# ${programName} command completion script for PowerShell\n#\n# Installation: ${programName} completion >> $PROFILE\n#\n\nRegister-ArgumentCompleter -Native -CommandName ${programName} -ScriptBlock {\n param($wordToComplete, $commandAst, $cursorPosition)\n\n $commands = @(${commandNames})\n $args = @('--help', '--version')\n\n if ($wordToComplete -like '-*') {\n $args | Where-Object { $_ -like \"$wordToComplete*\" } | ForEach-Object {\n [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)\n }\n } else {\n $commands | Where-Object { $_ -like \"$wordToComplete*\" } | ForEach-Object {\n [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)\n }\n }\n}\n###-end-${programName}-completion-###`;\n}\n\n/**\n * Generates a completion script for the specified shell.\n */\nexport function generateCompletion(program: AnyPadroneCommand, shell: ShellType): string {\n switch (shell) {\n case 'bash':\n return generateBashCompletion(program);\n case 'zsh':\n return generateZshCompletion(program);\n case 'fish':\n return generateFishCompletion(program);\n case 'powershell':\n return generatePowerShellCompletion(program);\n default:\n throw new Error(`Unsupported shell: ${shell}`);\n }\n}\n\n/**\n * Gets the installation instructions for a shell completion script.\n */\nexport function getCompletionInstallInstructions(programName: string, shell: ShellType): string {\n switch (shell) {\n case 'bash':\n return `# Add to ~/.bashrc:\n${programName} completion bash >> ~/.bashrc\n\n# Or install system-wide:\n${programName} completion bash > /usr/local/etc/bash_completion.d/${programName}`;\n\n case 'zsh':\n return `# Add to ~/.zshrc:\n${programName} completion zsh >> ~/.zshrc\n\n# Or add to completions directory:\n${programName} completion zsh > ~/.zsh/completions/_${programName}`;\n\n case 'fish':\n return `# Install to Fish completions:\n${programName} completion fish > ~/.config/fish/completions/${programName}.fish`;\n\n case 'powershell':\n return `# Add to PowerShell profile:\n${programName} completion powershell >> $PROFILE`;\n\n default:\n return `# Run: ${programName} completion <shell>\n# Supported shells: bash, zsh, fish, powershell`;\n }\n}\n\n/**\n * Generates the completion output with automatic shell detection.\n * If shell is not specified, detects the current shell and provides instructions.\n */\nexport function generateCompletionOutput(program: AnyPadroneCommand, shell?: ShellType): string {\n const programName = program.name;\n\n if (shell) {\n return generateCompletion(program, shell);\n }\n\n // Auto-detect shell and provide instructions\n const detectedShell = detectShell();\n\n if (detectedShell) {\n const instructions = getCompletionInstallInstructions(programName, detectedShell);\n const script = generateCompletion(program, detectedShell);\n\n return `# Detected shell: ${detectedShell}\n#\n${instructions}\n#\n# Or evaluate directly (temporary, for current session only):\n# eval \"$(${programName} completion ${detectedShell})\"\n\n${script}`;\n }\n\n // Could not detect shell - provide usage info\n return `# Shell auto-detection failed.\n#\n# Usage: ${programName} completion <shell>\n#\n# Supported shells:\n# bash - Bash completion script\n# zsh - Zsh completion script\n# fish - Fish completion script\n# powershell - PowerShell completion script\n#\n# Example:\n# ${programName} completion bash >> ~/.bashrc\n# ${programName} completion zsh >> ~/.zshrc\n# ${programName} completion fish > ~/.config/fish/completions/${programName}.fish\n# ${programName} completion powershell >> $PROFILE`;\n}\n\nexport interface SetupCompletionsResult {\n /** The file that was written to. */\n file: string;\n /** Whether an existing completion block was replaced (true) or a new one was appended (false). */\n updated: boolean;\n}\n\n/**\n * Sets up shell completions by writing an eval snippet to the appropriate shell config file.\n * Uses marker comments for idempotency — re-running replaces the existing block.\n */\nexport function setupCompletions(programName: string, shell: ShellType): SetupCompletionsResult {\n const { existsSync, mkdirSync, writeFileSync } = require('node:fs') as typeof import('node:fs');\n const { join } = require('node:path') as typeof import('node:path');\n const { homedir } = require('node:os') as typeof import('node:os');\n\n const beginMarker = `###-begin-${programName}-completion-###`;\n const endMarker = `###-end-${programName}-completion-###`;\n const snippet = buildSetupSnippet(programName, shell, beginMarker, endMarker);\n\n if (shell === 'fish') {\n const completionsDir = join(homedir(), '.config', 'fish', 'completions');\n const filePath = join(completionsDir, `${programName}.fish`);\n mkdirSync(completionsDir, { recursive: true });\n const existed = existsSync(filePath);\n writeFileSync(filePath, `${snippet}\\n`);\n return { file: filePath, updated: existed };\n }\n\n const rcFile = getRcFile(shell);\n if (!rcFile) {\n throw new Error(`Could not determine config file for ${shell}.`);\n }\n\n return writeToRcFile(rcFile, snippet, beginMarker, endMarker);\n}\n\nfunction buildSetupSnippet(programName: string, shell: ShellType, beginMarker: string, endMarker: string): string {\n const evalCmd = `${programName} completion ${shell}`;\n\n switch (shell) {\n case 'bash':\n case 'zsh':\n return `${beginMarker}\\neval \"$(${evalCmd})\"\\n${endMarker}`;\n case 'fish':\n return `${beginMarker}\\n${evalCmd} | source\\n${endMarker}`;\n case 'powershell':\n return `${beginMarker}\\n${evalCmd} | Invoke-Expression\\n${endMarker}`;\n }\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,cAAqC;AACnD,KAAI,OAAO,YAAY,YAAa,QAAO,KAAA;CAG3C,MAAM,WAAW,QAAQ,IAAI,SAAS;AACtC,KAAI,SAAS,SAAS,MAAM,CAAE,QAAO;AACrC,KAAI,SAAS,SAAS,OAAO,CAAE,QAAO;AACtC,KAAI,SAAS,SAAS,OAAO,CAAE,QAAO;AAGtC,KAAI,QAAQ,IAAI,gBAAgB,QAAQ,IAAI,gCAC1C,QAAO;AAIT,KAAI;EACF,MAAM,OAAO,QAAQ;AACrB,MAAI,MAAM;GACR,MAAM,EAAE,aAAA,UAAqB,qBAAqB;GAClD,MAAM,cAAc,SAAS,SAAS,KAAK,YAAY;IACrD,UAAU;IACV,OAAO;KAAC;KAAQ;KAAQ;KAAS;IAClC,CAAC,CAAC,MAAM;AAET,OAAI,YAAY,SAAS,MAAM,CAAE,QAAO;AACxC,OAAI,YAAY,SAAS,OAAO,CAAE,QAAO;AACzC,OAAI,YAAY,SAAS,OAAO,CAAE,QAAO;;SAErC;;AAOV,SAAgB,UAAU,OAAkB,MAA8B;CACxE,MAAM,EAAE,YAAA,UAAoB,UAAU;CACtC,MAAM,EAAE,SAAA,UAAiB,YAAY;CACrC,MAAM,IAAI,QAAQ,SAAS;AAC3B,SAAQ,OAAR;EACE,KAAK,OACH,QAAO,KAAK,GAAG,UAAU;EAC3B,KAAK,MACH,QAAO,KAAK,GAAG,SAAS;EAC1B,KAAK,OACH,QAAO,KAAK,GAAG,WAAW,QAAQ,cAAc;EAClD,KAAK,aACH,QAAO,QAAQ,IAAI,WAAW,KAAK,GAAG,aAAa,cAAc,mCAAmC;EACtG,QACE,QAAO;;;AAIb,SAAgB,aAAa,KAAqB;AAChD,QA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