politty 0.11.6 → 0.11.8

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 (50) hide show
  1. package/README.md +30 -1
  2. package/dist/augment.d.ts +1 -16
  3. package/dist/augment.js +2 -0
  4. package/dist/cli-run-DGe88d0G.js +14 -0
  5. package/dist/cli.d.ts +1 -1
  6. package/dist/cli.js +13 -9
  7. package/dist/compile-cache.d.ts +1 -79
  8. package/dist/compile-cache.js +2 -2
  9. package/dist/completion.d.ts +1 -0
  10. package/dist/completion.js +3 -0
  11. package/dist/docs.d.ts +1 -0
  12. package/dist/docs.js +3 -0
  13. package/dist/index.d.ts +10 -814
  14. package/dist/index.js +17 -8
  15. package/dist/prompt-clack.d.ts +1 -0
  16. package/dist/prompt-clack.js +3 -0
  17. package/dist/prompt-inquirer.d.ts +1 -0
  18. package/dist/prompt-inquirer.js +3 -0
  19. package/dist/prompt.d.ts +1 -0
  20. package/dist/prompt.js +3 -0
  21. package/dist/skill.d.ts +1 -0
  22. package/dist/skill.js +3 -0
  23. package/package.json +18 -45
  24. package/dist/arg-registry-SrNIsq-d.d.ts +0 -981
  25. package/dist/cli-main.d.ts +0 -1
  26. package/dist/cli-main.js +0 -86
  27. package/dist/command-B4yA4LXX.js +0 -43
  28. package/dist/compile-cache-NnTkjJMV.js +0 -101
  29. package/dist/completion/index.d.ts +0 -3
  30. package/dist/completion/index.js +0 -3
  31. package/dist/completion-D9SKGJad.js +0 -5610
  32. package/dist/docs/index.d.ts +0 -771
  33. package/dist/docs/index.js +0 -3024
  34. package/dist/index-qqwo5WZT.d.ts +0 -673
  35. package/dist/log-collector-DK32-73m.js +0 -115
  36. package/dist/logger-DbDkjdfO.js +0 -134
  37. package/dist/prompt/clack/index.d.ts +0 -17
  38. package/dist/prompt/clack/index.js +0 -32
  39. package/dist/prompt/index.d.ts +0 -107
  40. package/dist/prompt/index.js +0 -3
  41. package/dist/prompt/inquirer/index.d.ts +0 -17
  42. package/dist/prompt/inquirer/index.js +0 -47
  43. package/dist/prompt-Cc8Tfmdv.js +0 -172
  44. package/dist/runner-BGs_QMJM.js +0 -3
  45. package/dist/runner-xN7248Ph.js +0 -2966
  46. package/dist/schema-extractor-wzJ1cGon.js +0 -488
  47. package/dist/skill/index.d.ts +0 -584
  48. package/dist/skill/index.js +0 -1756
  49. package/dist/src-BiCtSNrn.js +0 -193
  50. package/dist/subcommand-router-CTzHPGzF.js +0 -135
@@ -1,673 +0,0 @@
1
- import { S as Command, Y as ResolvedFieldMeta, _ as AnyCommand, d as ResolvedExpandCandidate, h as DynamicCompletionResolver, u as ExpandCompletion, y as ArgsSchema } from "./arg-registry-SrNIsq-d.js";
2
- import { z } from "zod";
3
- //#region src/completion/types.d.ts
4
- /**
5
- * A single resolved entry in an "expand" lookup table.
6
- *
7
- * `key` is the tuple of `dependsOn` values that triggers this entry, in the
8
- * same order as the originating `dependsOn` array. `candidates` is the
9
- * (already deduplicated) list returned by the user's `enumerate` callback
10
- * for that combination.
11
- */
12
- interface ExpandTableEntry {
13
- readonly key: readonly string[];
14
- readonly candidates: readonly ResolvedExpandCandidate[];
15
- }
16
- /**
17
- * Supported shell types for completion
18
- */
19
- type ShellType = "bash" | "zsh" | "fish";
20
- /**
21
- * Completion script generation mode.
22
- *
23
- * - `dispatcher`: small runtime script that resolves the executable visible on
24
- * PATH at TAB time and delegates to its `__complete` command.
25
- * - `static`: self-contained script with command metadata baked in at
26
- * generation time.
27
- */
28
- type CompletionMode = "dispatcher" | "static";
29
- /**
30
- * Optional published worker artifact lookup.
31
- *
32
- * Paths are resolved relative to the visible executable's real directory.
33
- * Templates may include `{shell}`, `{ext}`, and `{program}`.
34
- */
35
- interface BundledWorkerOptions {
36
- /** Disable bundled-worker lookup while keeping cache/dynamic fallbacks. */
37
- disabled?: boolean | undefined;
38
- /** Shell-specific worker paths relative to the executable directory. */
39
- relativePaths?: Partial<Record<ShellType, readonly string[]>> | undefined;
40
- /**
41
- * Let dispatcher scripts ask the CLI for `__completion-worker-path <shell>`
42
- * when package-relative lookup misses. Disabled by default because it starts
43
- * the CLI process on that miss path.
44
- */
45
- queryCommand?: boolean | undefined;
46
- }
47
- /**
48
- * Options for completion generation
49
- */
50
- interface CompletionOptions {
51
- /** The shell type to generate completion for */
52
- shell: ShellType;
53
- /** The command name as it will be invoked */
54
- programName: string;
55
- /** Include subcommand completions (default: true) */
56
- includeSubcommands?: boolean;
57
- /** Include description in completions where supported (default: true) */
58
- includeDescriptions?: boolean;
59
- /**
60
- * Completion script mode.
61
- *
62
- * `generateCompletion` defaults to `static` when this is omitted. The
63
- * `completion <shell>` subcommand passes `dispatcher` explicitly by default.
64
- */
65
- mode?: CompletionMode;
66
- /** Global args schema for deriving global options in completion */
67
- globalArgsSchema?: ArgsSchema;
68
- /**
69
- * Path to the binary whose mtime is the freshness signature.
70
- * Defaults to `process.argv[1]`.
71
- */
72
- binPath?: string;
73
- /** Program version to embed in the script header. */
74
- programVersion?: string;
75
- /**
76
- * Cache directory for the loader to write the regenerated script into.
77
- * Defaults to `${XDG_CACHE_HOME:-$HOME/.cache}/<programName>` at runtime.
78
- * Setting this hardcodes the location into the generated loader.
79
- */
80
- cacheDir?: string;
81
- /**
82
- * Internal static-worker generation hook used by dispatcher caches.
83
- * Worker scripts define suffixed functions and skip shell registration.
84
- */
85
- staticWorker?: {
86
- functionSuffix: string;
87
- };
88
- /** Published static-worker artifact lookup used by dispatcher mode. */
89
- bundledWorker?: BundledWorkerOptions | undefined;
90
- }
91
- /**
92
- * Value completion specification for shell scripts.
93
- *
94
- * Discriminated by `type`. The `dynamic` variant carries a JS resolver that
95
- * the static shell scripts delegate to via `<program> __complete`. All
96
- * variants share the same optional metadata fields (left undefined where
97
- * inapplicable) so consumers can read `vc.choices`/`vc.extensions`/etc.
98
- * without narrowing first.
99
- */
100
- type ValueCompletion = ({
101
- /** Completion type */
102
- type: "choices" | "file" | "directory" | "command" | "none";
103
- /** List of valid choices (for "choices" type) */
104
- choices?: string[];
105
- /** Shell command for dynamic completion (for "command" type) */
106
- shellCommand?: string;
107
- resolve?: never;
108
- dependsOn?: never;
109
- table?: never;
110
- } & ({
111
- extensions?: string[];
112
- matcher?: never;
113
- } | {
114
- /** Glob patterns for file matching (for "file" type) */ matcher?: string[];
115
- extensions?: never;
116
- })) | {
117
- /** In-process dynamic completion via JS callback. */
118
- type: "dynamic";
119
- resolve: DynamicCompletionResolver;
120
- choices?: never;
121
- shellCommand?: never;
122
- extensions?: never;
123
- matcher?: never;
124
- dependsOn?: never;
125
- table?: never;
126
- } | {
127
- /**
128
- * Pre-enumerated completion baked into the generated shell script.
129
- * The `table` is the cartesian product of the `dependsOn` arg values
130
- * (each having a static `choices` or enum schema). At completion time
131
- * the shell dispatches on the runtime values of those args — no Node
132
- * is spawned.
133
- */
134
- type: "expand";
135
- dependsOn: readonly string[];
136
- table: readonly ExpandTableEntry[];
137
- choices?: never;
138
- shellCommand?: never;
139
- resolve?: never;
140
- extensions?: never;
141
- matcher?: never;
142
- } | {
143
- /**
144
- * Runtime form of `completion.custom.expand` used by `__complete`.
145
- * The dispatcher invokes `__complete` at TAB time, so it can call the
146
- * user's `enumerate` function against the already typed dependency
147
- * values instead of baking a table into the shell script.
148
- */
149
- type: "runtime-expand";
150
- dependsOn: readonly string[];
151
- enumerate: (deps: Readonly<Record<string, string>>) => ReadonlyArray<string | {
152
- value: string;
153
- description?: string;
154
- }>;
155
- choices?: never;
156
- shellCommand?: never;
157
- resolve?: never;
158
- extensions?: never;
159
- matcher?: never;
160
- table?: never;
161
- };
162
- /**
163
- * Information about a completable option
164
- */
165
- interface CompletableOption {
166
- /** Long option name (e.g., "verbose") */
167
- name: string;
168
- /** CLI name (kebab-case, e.g., "dry-run") */
169
- cliName: string;
170
- /**
171
- * Aliases for this option (both short and long).
172
- * 1-char entries are short (`-v`); multi-char entries are long (`--to-be`).
173
- */
174
- alias?: string[] | undefined;
175
- /**
176
- * Negation name to advertise in shell completions (no `--` prefix),
177
- * or `undefined` to hide the negation. Mirrors `ResolvedFieldMeta.negationDisplay`.
178
- */
179
- negation?: string | undefined;
180
- /** Description for the negation option (when distinct from the main description) */
181
- negationDescription?: string | undefined;
182
- /**
183
- * Whether the runtime parser accepts the default `--no-<cliName>` (and
184
- * camelCase) form for this boolean option. True only when the user set
185
- * `negation: true`; false when unset, `negation: false`, or
186
- * `negation: <custom name>`. Used by the completion context parser so
187
- * dynamic resolvers see the same `parsedArgs` state the runtime would compute.
188
- */
189
- defaultNegationAccepted?: boolean;
190
- /** Description for completion */
191
- description?: string | undefined;
192
- /**
193
- * True when this option originates from a `globalArgsSchema` and was
194
- * propagated into every subcommand frame. The runtime parser keeps
195
- * global values visible across subcommand descent, so shell generators
196
- * must keep their tracker buckets separate from per-frame state.
197
- */
198
- isGlobal?: boolean;
199
- /** Whether this option takes a value */
200
- takesValue: boolean;
201
- /** Type of value expected */
202
- valueType: "string" | "number" | "boolean" | "array" | "unknown";
203
- /** Whether the option is required */
204
- required: boolean;
205
- /** Value completion specification */
206
- valueCompletion?: ValueCompletion | undefined;
207
- }
208
- /**
209
- * Information about a positional argument for completion
210
- */
211
- interface CompletablePositional {
212
- /** Field name */
213
- name: string;
214
- /** CLI name (kebab-case) */
215
- cliName: string;
216
- /** Position index (0-based) */
217
- position: number;
218
- /** Description */
219
- description?: string | undefined;
220
- /** Whether required */
221
- required: boolean;
222
- /** Whether this positional accepts multiple values (array type) */
223
- variadic?: boolean | undefined;
224
- /** Value completion specification */
225
- valueCompletion?: ValueCompletion | undefined;
226
- }
227
- /**
228
- * Information about a subcommand for completion
229
- */
230
- interface CompletableSubcommand {
231
- /** Subcommand name */
232
- name: string;
233
- /** Subcommand description */
234
- description?: string | undefined;
235
- /** Alternative names (aliases) for this subcommand */
236
- aliases?: string[] | undefined;
237
- /** Nested subcommands */
238
- subcommands: CompletableSubcommand[];
239
- /** Options for this subcommand */
240
- options: CompletableOption[];
241
- /** Positional arguments */
242
- positionals: CompletablePositional[];
243
- }
244
- /**
245
- * Extracted completion data from a command
246
- */
247
- interface CompletionData {
248
- /** The root command */
249
- command: CompletableSubcommand;
250
- /** Program name */
251
- programName: string;
252
- /** Global options (available to all subcommands) */
253
- globalOptions: CompletableOption[];
254
- }
255
- /**
256
- * Result of completion generation
257
- */
258
- interface CompletionResult {
259
- /** The generated completion script */
260
- script: string;
261
- /** The shell type this script is for */
262
- shell: ShellType;
263
- /** Instructions for installing the completion */
264
- installInstructions: string;
265
- }
266
- /**
267
- * Generator function type for shell completions
268
- */
269
- type CompletionGenerator = (command: AnyCommand, options: CompletionOptions) => CompletionResult;
270
- //#endregion
271
- //#region src/completion/dynamic/context-parser.d.ts
272
- /**
273
- * Completion type indicates what kind of completion is expected
274
- */
275
- type CompletionType = "subcommand" | "option-name" | "option-value" | "positional";
276
- /**
277
- * Context for completion at current cursor position
278
- */
279
- interface CompletionContext {
280
- /** Subcommand path from root (e.g., ["plugin", "add"]) */
281
- subcommandPath: string[];
282
- /** The resolved command at current path */
283
- currentCommand: AnyCommand;
284
- /** Current word being typed (may be partial) */
285
- currentWord: string;
286
- /** Previous word (useful for option value detection) */
287
- previousWord: string;
288
- /** What type of completion is expected */
289
- completionType: CompletionType;
290
- /** Target option when completing option value */
291
- targetOption?: CompletableOption | undefined;
292
- /** Positional index when completing positional argument */
293
- positionalIndex?: number | undefined;
294
- /** Available options for current command */
295
- options: CompletableOption[];
296
- /** Available subcommands */
297
- subcommands: string[];
298
- /** Available positionals */
299
- positionals: CompletablePositional[];
300
- /** Options already used (to avoid duplicates) */
301
- usedOptions: Set<string>;
302
- /** Number of positional arguments already provided */
303
- providedPositionalCount: number;
304
- /**
305
- * Best-effort parsed values for the CURRENT command, keyed by camelCase
306
- * field name. Includes positionals (single value or string[] for variadic
307
- * positionals) and options (string for scalars, string[] for array
308
- * options). Zod validation is NOT applied — values are raw strings.
309
- */
310
- parsedArgs: Record<string, unknown>;
311
- /**
312
- * Values already supplied for the option/positional currently being
313
- * completed (for de-duplicating array options and oneof exclusivity in
314
- * dynamic resolvers).
315
- */
316
- previousValues: string[];
317
- }
318
- /**
319
- * Parse completion context from command line arguments
320
- *
321
- * @param argv - Arguments after the program name (e.g., ["build", "--fo"])
322
- * @param rootCommand - The root command
323
- * @param globalArgsSchema - Optional global args. When provided, options
324
- * derived from this schema are merged into every command level so dynamic
325
- * resolvers attached to global options can be reached from any subcommand.
326
- * @returns Completion context
327
- */
328
- declare function parseCompletionContext(argv: string[], rootCommand: AnyCommand, globalArgsSchema?: ArgsSchema): CompletionContext;
329
- //#endregion
330
- //#region src/completion/dynamic/candidate-generator.d.ts
331
- /**
332
- * Completion directive flags (bitwise)
333
- */
334
- declare const CompletionDirective: {
335
- /** Default completion behavior */
336
- readonly Default: 0;
337
- /** Don't add space after completion */
338
- readonly NoSpace: 1;
339
- /** Don't offer file completion (even if no other completions) */
340
- readonly NoFileCompletion: 2;
341
- /** Filter completions using current word as prefix */
342
- readonly FilterPrefix: 4;
343
- /** Keep the order of completions */
344
- readonly KeepOrder: 8;
345
- /** Trigger file completion */
346
- readonly FileCompletion: 16;
347
- /** Trigger directory completion */
348
- readonly DirectoryCompletion: 32;
349
- /** Error occurred during completion */
350
- readonly Error: 64;
351
- };
352
- /**
353
- * A completion candidate
354
- */
355
- interface CompletionCandidate {
356
- /** The completion value */
357
- value: string;
358
- /** Optional description */
359
- description?: string | undefined;
360
- /** Type hint for display purposes */
361
- type?: "option" | "subcommand" | "value" | "file" | "directory";
362
- }
363
- /**
364
- * Result of candidate generation
365
- */
366
- interface CandidateResult {
367
- /** Completion candidates */
368
- candidates: CompletionCandidate[];
369
- /** Directive flags for shell behavior */
370
- directive: number;
371
- /** File extensions for shell-native filtering (e.g., ["json", "yaml"]) */
372
- fileExtensions?: string[] | undefined;
373
- /** Glob patterns for shell-native file matching (e.g., [".env.*"]) */
374
- fileMatchers?: string[] | undefined;
375
- }
376
- /**
377
- * Options for candidate generation.
378
- */
379
- interface GenerateCandidatesOptions {
380
- /**
381
- * Target shell. Forwarded to dynamic resolvers so they can vary output
382
- * (e.g. include descriptions only for shells that render them).
383
- */
384
- shell: ShellType;
385
- }
386
- /**
387
- * Generate completion candidates based on context.
388
- *
389
- * Async because dynamic resolvers may return promises. Sync completion
390
- * sources (choices/file/directory/command/none, subcommand, option name)
391
- * still resolve synchronously and the await is a no-op for them.
392
- *
393
- * Inline option-value prefixes (`--field=foo`) on the option-value path
394
- * are stripped here so resolvers and post-processing always see the
395
- * value portion regardless of whether the caller pre-normalized.
396
- */
397
- declare function generateCandidates(context: CompletionContext, options: GenerateCandidatesOptions): Promise<CandidateResult>;
398
- //#endregion
399
- //#region src/completion/dynamic/complete-command.d.ts
400
- /**
401
- * Schema for the __complete command
402
- */
403
- declare const completeArgsSchema: z.ZodObject<{
404
- shell: z.ZodEnum<{
405
- bash: "bash";
406
- fish: "fish";
407
- zsh: "zsh";
408
- }>;
409
- args: z.ZodDefault<z.ZodArray<z.ZodString>>;
410
- }, z.core.$strip>;
411
- type CompleteArgs = z.infer<typeof completeArgsSchema>;
412
- /**
413
- * Create the dynamic completion command
414
- *
415
- * @param rootCommand - The root command to generate completions for
416
- * @param programName - The program name (optional, defaults to rootCommand.name)
417
- * @param globalArgsSchema - Global args schema. Forwarded to
418
- * `parseCompletionContext` so resolvers attached to global options remain
419
- * reachable at every subcommand level.
420
- * @returns A command that outputs completion candidates
421
- */
422
- declare function createDynamicCompleteCommand(rootCommand: AnyCommand, _programName?: string, globalArgsSchema?: ArgsSchema): Command<typeof completeArgsSchema, CompleteArgs, any>;
423
- /**
424
- * Check if a command tree contains the __complete command
425
- */
426
- declare function hasCompleteCommand(command: AnyCommand): boolean;
427
- //#endregion
428
- //#region src/completion/dynamic/shell-formatter.d.ts
429
- /**
430
- * Options for shell-specific formatting
431
- */
432
- interface ShellFormatOptions {
433
- /** Target shell type */
434
- shell: ShellType;
435
- /** Current word being completed (used for prefix filtering) */
436
- currentWord: string;
437
- /** For bash: the prefix before '=' in --opt=value completions */
438
- inlinePrefix?: string | undefined;
439
- }
440
- /**
441
- * Format completion candidates for the specified shell
442
- *
443
- * @returns Shell-ready output string (lines separated by newline, last line is :directive)
444
- */
445
- declare function formatForShell(result: CandidateResult, options: ShellFormatOptions): string;
446
- //#endregion
447
- //#region src/completion/extractor.d.ts
448
- /**
449
- * Extract positional arguments from a command
450
- */
451
- declare function extractPositionals(command: AnyCommand): ResolvedFieldMeta[];
452
- /**
453
- * Extract completion data from a command tree
454
- *
455
- * @param command - The root command
456
- * @param programName - Program name for completion scripts
457
- * @param globalArgsSchema - Optional global args schema. When provided, global options
458
- * are derived from this schema instead of the root command's options.
459
- */
460
- declare function extractCompletionData(command: AnyCommand, programName: string, globalArgsSchema?: ArgsSchema, validateOnly?: boolean): CompletionData;
461
- //#endregion
462
- //#region src/completion/bundled-worker.d.ts
463
- interface GenerateBundledCompletionWorkerOptions {
464
- /** CLI binary or built JS entry file to invoke. */
465
- bin: string;
466
- /** Program name embedded in completion metadata. */
467
- programName: string;
468
- /** Shell worker to generate. */
469
- shell: ShellType;
470
- /** Output path. Defaults to `dist/completion/<shell>-worker.<ext>`. */
471
- outputPath?: string | undefined;
472
- /** Verify that `__completion-worker-path <shell>` resolves to the generated file. */
473
- verify?: boolean | undefined;
474
- /** Working directory used for relative paths. Defaults to `process.cwd()`. */
475
- cwd?: string | undefined;
476
- /** Extra environment passed to the target binary. */
477
- env?: Readonly<Record<string, string | undefined>> | undefined;
478
- /** Suppress the success message. */
479
- quiet?: boolean | undefined;
480
- }
481
- interface GenerateBundledCompletionWorkerResult {
482
- /** Absolute generated worker path. */
483
- outputPath: string;
484
- /** Generated file size in bytes. */
485
- size: number;
486
- /** Absolute path reported by `__completion-worker-path`, when verified. */
487
- reportedPath?: string | undefined;
488
- }
489
- declare function bundledWorkerShellExtension(shell: ShellType): string;
490
- declare function defaultBundledWorkerOutputPath(shell: ShellType): string;
491
- declare function validateBundledWorkerFile(path: string, programName: string, shell: ShellType): void;
492
- declare function generateBundledCompletionWorker(options: GenerateBundledCompletionWorkerOptions): Promise<GenerateBundledCompletionWorkerResult>;
493
- //#endregion
494
- //#region src/completion/value-completion-resolver.d.ts
495
- /**
496
- * Sentinel returned when a field uses `completion.custom.expand`. The static
497
- * extractor recognises this and replaces it with a fully resolved
498
- * `{ type: "expand", ... }` ValueCompletion after sibling args' static
499
- * values are known. Internal: never assigned onto `CompletableOption` /
500
- * `CompletablePositional` directly; callers stash it in a side map keyed by
501
- * field name and patch the resolved spec in afterwards.
502
- */
503
- interface PendingExpandValueCompletion {
504
- type: "pending-expand";
505
- spec: ExpandCompletion;
506
- }
507
- /**
508
- * Minimal field interface needed for resolving value completion.
509
- * Both ResolvedFieldMeta and inline context-parser types satisfy this.
510
- */
511
- interface ValueCompletionField {
512
- completion?: ({
513
- type?: string;
514
- custom?: {
515
- choices?: string[];
516
- shellCommand?: string;
517
- resolve?: DynamicCompletionResolver;
518
- expand?: ExpandCompletion;
519
- };
520
- } & ({
521
- extensions?: string[];
522
- matcher?: never;
523
- } | {
524
- matcher?: string[];
525
- extensions?: never;
526
- })) | undefined;
527
- enumValues?: string[] | undefined;
528
- /** Field name surfaced in error messages when custom variants are mixed. */
529
- name?: string;
530
- }
531
- /**
532
- * Resolve value completion from field metadata.
533
- *
534
- * Priority (within `custom`): `expand` > `resolve` > `choices` > `shellCommand`.
535
- * Specifying more than one of these on the same field throws so the
536
- * misconfiguration surfaces at command-definition time rather than at
537
- * completion time. The `expand` variant returns a sentinel — the extractor
538
- * resolves it against sibling fields and replaces the sentinel with a
539
- * `{ type: "expand", table, dependsOn }` entry.
540
- *
541
- * Outside `custom`: explicit `type` (file/directory/none) > auto-detected
542
- * enum values from the schema.
543
- */
544
- declare function resolveValueCompletion(field: ValueCompletionField): ValueCompletion | PendingExpandValueCompletion | undefined;
545
- //#endregion
546
- //#region src/completion/index.d.ts
547
- /**
548
- * Generate completion script for the specified shell
549
- */
550
- declare function generateCompletion(command: AnyCommand, options: CompletionOptions): CompletionResult;
551
- /**
552
- * Get the list of supported shells
553
- */
554
- declare function getSupportedShells(): ShellType[];
555
- /**
556
- * Detect the current shell from environment
557
- */
558
- declare function detectShell(): ShellType | null;
559
- /**
560
- * Schema for the completion command arguments
561
- */
562
- declare const completionArgsSchema: z.ZodObject<{
563
- shell: z.ZodOptional<z.ZodEnum<{
564
- bash: "bash";
565
- fish: "fish";
566
- zsh: "zsh";
567
- }>>;
568
- instructions: z.ZodDefault<z.ZodBoolean>;
569
- loader: z.ZodDefault<z.ZodBoolean>;
570
- install: z.ZodDefault<z.ZodBoolean>;
571
- static: z.ZodDefault<z.ZodBoolean>;
572
- dispatcher: z.ZodDefault<z.ZodBoolean>;
573
- worker: z.ZodDefault<z.ZodBoolean>;
574
- }, z.core.$strip>;
575
- type CompletionArgs = z.infer<typeof completionArgsSchema>;
576
- declare const refreshArgsSchema: z.ZodObject<{
577
- shell: z.ZodEnum<{
578
- bash: "bash";
579
- fish: "fish";
580
- zsh: "zsh";
581
- }>;
582
- target: z.ZodOptional<z.ZodString>;
583
- static: z.ZodDefault<z.ZodBoolean>;
584
- worker: z.ZodDefault<z.ZodBoolean>;
585
- }, z.core.$strip>;
586
- type RefreshArgs = z.infer<typeof refreshArgsSchema>;
587
- declare const workerPathArgsSchema: z.ZodObject<{
588
- shell: z.ZodEnum<{
589
- bash: "bash";
590
- fish: "fish";
591
- zsh: "zsh";
592
- }>;
593
- }, z.core.$strip>;
594
- type WorkerPathArgs = z.infer<typeof workerPathArgsSchema>;
595
- /**
596
- * Create a completion subcommand for your CLI
597
- *
598
- * This creates a ready-to-use subcommand that generates completion scripts.
599
- *
600
- * @example
601
- * ```typescript
602
- * const mainCommand = defineCommand({
603
- * name: "mycli",
604
- * subCommands: {
605
- * completion: createCompletionCommand(mainCommand)
606
- * }
607
- * });
608
- * ```
609
- */
610
- declare function createCompletionCommand(rootCommand: AnyCommand, programName?: string, globalArgsSchema?: ArgsSchema, extra?: {
611
- cacheDir?: string;
612
- programVersion?: string;
613
- bundledWorker?: BundledWorkerOptions;
614
- }): Command<typeof completionArgsSchema, CompletionArgs, any>;
615
- /**
616
- * Hidden subcommand that the runMain background hook spawns. It does
617
- * the same stat-compare + atomic rewrite as the rc loader, but in a
618
- * detached child process so it's invisible to the user.
619
- */
620
- declare function createRefreshCompletionCommand(rootCommand: AnyCommand, programName: string, extra?: {
621
- cacheDir?: string;
622
- programVersion?: string;
623
- globalArgsSchema?: ArgsSchema;
624
- bundledWorker?: BundledWorkerOptions;
625
- }): Command<typeof refreshArgsSchema, RefreshArgs, any>;
626
- declare function createCompletionWorkerPathCommand(programName: string, extra?: {
627
- binPath?: string;
628
- bundledWorker?: BundledWorkerOptions;
629
- }): Command<typeof workerPathArgsSchema, WorkerPathArgs, any>;
630
- /**
631
- * Options for withCompletionCommand
632
- */
633
- interface WithCompletionOptions {
634
- /** Override the program name (defaults to command.name) */
635
- programName?: string;
636
- /** Global args schema for deriving global options in completion */
637
- globalArgsSchema?: ArgsSchema;
638
- /**
639
- * Hardcode the cache directory used by the rc loader and the
640
- * background refresh. When omitted, the loader derives
641
- * `${XDG_CACHE_HOME:-$HOME/.cache}/<programName>` at runtime, which
642
- * is the right answer for almost every CLI.
643
- */
644
- cacheDir?: string;
645
- /** Program version embedded in the script header. */
646
- programVersion?: string;
647
- /** Published worker artifact lookup used by dispatcher mode. */
648
- bundledWorker?: BundledWorkerOptions;
649
- }
650
- /**
651
- * Wrap a command with a completion subcommand
652
- *
653
- * This avoids circular references that occur when a command references itself
654
- * in its subCommands (e.g., for completion generation).
655
- *
656
- * @param command - The command to wrap
657
- * @param options - Options including programName
658
- * @returns A new command with the completion subcommand added
659
- *
660
- * @example
661
- * ```typescript
662
- * const mainCommand = withCompletionCommand(
663
- * defineCommand({
664
- * name: "mycli",
665
- * subCommands: { ... },
666
- * }),
667
- * );
668
- * ```
669
- */
670
- declare function withCompletionCommand<T extends AnyCommand>(command: T, options?: string | WithCompletionOptions): T;
671
- //#endregion
672
- export { BundledWorkerOptions as A, CandidateResult as C, CompletionContext as D, generateCandidates as E, CompletionMode as F, CompletionOptions as I, CompletionResult as L, CompletableSubcommand as M, CompletionData as N, CompletionType as O, CompletionGenerator as P, ShellType as R, hasCompleteCommand as S, CompletionDirective as T, extractCompletionData as _, detectShell as a, formatForShell as b, withCompletionCommand as c, GenerateBundledCompletionWorkerOptions as d, GenerateBundledCompletionWorkerResult as f, validateBundledWorkerFile as g, generateBundledCompletionWorker as h, createRefreshCompletionCommand as i, CompletableOption as j, parseCompletionContext as k, ValueCompletionField as l, defaultBundledWorkerOutputPath as m, createCompletionCommand as n, generateCompletion as o, bundledWorkerShellExtension as p, createCompletionWorkerPathCommand as r, getSupportedShells as s, WithCompletionOptions as t, resolveValueCompletion as u, extractPositionals as v, CompletionCandidate as w, createDynamicCompleteCommand as x, ShellFormatOptions as y };
673
- //# sourceMappingURL=index-qqwo5WZT.d.ts.map