politty 0.4.15 → 0.5.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/dist/{arg-registry-Dw0f11Zc.d.ts → arg-registry--NRaNFJM.d.cts} +238 -6
- package/dist/arg-registry--NRaNFJM.d.cts.map +1 -0
- package/dist/{arg-registry-CB5gGtzp.d.cts → arg-registry-6E0WHOh_.d.ts} +238 -6
- package/dist/arg-registry-6E0WHOh_.d.ts.map +1 -0
- package/dist/augment.d.cts +1 -1
- package/dist/augment.d.cts.map +1 -1
- package/dist/augment.d.ts +1 -1
- package/dist/augment.d.ts.map +1 -1
- package/dist/completion/index.cjs +2 -1
- package/dist/completion/index.d.cts +3 -2
- package/dist/completion/index.d.ts +3 -2
- package/dist/completion/index.js +2 -2
- package/dist/completion-BA5JMvVG.js +4067 -0
- package/dist/completion-BA5JMvVG.js.map +1 -0
- package/dist/completion-Cqs1Ja7C.cjs +4169 -0
- package/dist/completion-Cqs1Ja7C.cjs.map +1 -0
- package/dist/docs/index.cjs +89 -29
- package/dist/docs/index.cjs.map +1 -1
- package/dist/docs/index.d.cts +1 -1
- package/dist/docs/index.d.cts.map +1 -1
- package/dist/docs/index.d.ts +1 -1
- package/dist/docs/index.d.ts.map +1 -1
- package/dist/docs/index.js +92 -31
- package/dist/docs/index.js.map +1 -1
- package/dist/{index-C1gGgUeB.d.cts → index-DBMfKZ34.d.ts} +189 -17
- package/dist/index-DBMfKZ34.d.ts.map +1 -0
- package/dist/{index-Dg9Fpz0R.d.ts → index-DJp8k5Bq.d.cts} +189 -17
- package/dist/index-DJp8k5Bq.d.cts.map +1 -0
- package/dist/index.cjs +12 -10
- package/dist/index.d.cts +36 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +36 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/log-collector-Cd2_mv87.cjs.map +1 -1
- package/dist/log-collector-Cu6MCtAx.js.map +1 -1
- package/dist/prompt/clack/index.cjs.map +1 -1
- package/dist/prompt/clack/index.d.cts +1 -1
- package/dist/prompt/clack/index.d.cts.map +1 -1
- package/dist/prompt/clack/index.d.ts +1 -1
- package/dist/prompt/clack/index.d.ts.map +1 -1
- package/dist/prompt/clack/index.js.map +1 -1
- package/dist/prompt/index.d.cts +1 -1
- package/dist/prompt/index.d.cts.map +1 -1
- package/dist/prompt/index.d.ts +1 -1
- package/dist/prompt/index.d.ts.map +1 -1
- package/dist/prompt/inquirer/index.cjs.map +1 -1
- package/dist/prompt/inquirer/index.d.cts +1 -1
- package/dist/prompt/inquirer/index.d.cts.map +1 -1
- package/dist/prompt/inquirer/index.d.ts +1 -1
- package/dist/prompt/inquirer/index.d.ts.map +1 -1
- package/dist/prompt/inquirer/index.js.map +1 -1
- package/dist/prompt-BKHqGrFw.js.map +1 -1
- package/dist/prompt-aXfSf27y.cjs.map +1 -1
- package/dist/{runner-DKAQBNNh.js → runner-BmSEiD9A.js} +319 -52
- package/dist/runner-BmSEiD9A.js.map +1 -0
- package/dist/{runner-CriXJlm4.cjs → runner-CRZ_7Y9i.cjs} +366 -87
- package/dist/runner-CRZ_7Y9i.cjs.map +1 -0
- package/dist/{subcommand-router-ENeCymvX.js → schema-extractor-C50R-1re.js} +175 -137
- package/dist/schema-extractor-C50R-1re.js.map +1 -0
- package/dist/{subcommand-router-CqZX3orq.cjs → schema-extractor-SLPgBNgZ.cjs} +174 -136
- package/dist/schema-extractor-SLPgBNgZ.cjs.map +1 -0
- package/package.json +16 -16
- package/dist/arg-registry-CB5gGtzp.d.cts.map +0 -1
- package/dist/arg-registry-Dw0f11Zc.d.ts.map +0 -1
- package/dist/completion-B5fgnUGm.cjs +0 -1940
- package/dist/completion-B5fgnUGm.cjs.map +0 -1
- package/dist/completion-Ca5ESJlG.js +0 -1844
- package/dist/completion-Ca5ESJlG.js.map +0 -1
- package/dist/index-C1gGgUeB.d.cts.map +0 -1
- package/dist/index-Dg9Fpz0R.d.ts.map +0 -1
- package/dist/runner-CriXJlm4.cjs.map +0 -1
- package/dist/runner-DKAQBNNh.js.map +0 -1
- package/dist/subcommand-router-CqZX3orq.cjs.map +0 -1
- package/dist/subcommand-router-ENeCymvX.js.map +0 -1
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as AnyCommand, d as ResolvedExpandCandidate, h as DynamicCompletionResolver, q as ResolvedFieldMeta, u as ExpandCompletion, v as ArgsSchema, x as Command } from "./arg-registry-6E0WHOh_.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/completion/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A single resolved entry in an "expand" lookup table.
|
|
7
|
+
*
|
|
8
|
+
* `key` is the tuple of `dependsOn` values that triggers this entry, in the
|
|
9
|
+
* same order as the originating `dependsOn` array. `candidates` is the
|
|
10
|
+
* (already deduplicated) list returned by the user's `enumerate` callback
|
|
11
|
+
* for that combination.
|
|
12
|
+
*/
|
|
13
|
+
interface ExpandTableEntry {
|
|
14
|
+
readonly key: readonly string[];
|
|
15
|
+
readonly candidates: readonly ResolvedExpandCandidate[];
|
|
16
|
+
}
|
|
5
17
|
/**
|
|
6
18
|
* Supported shell types for completion
|
|
7
19
|
*/
|
|
@@ -20,21 +32,68 @@ interface CompletionOptions {
|
|
|
20
32
|
includeDescriptions?: boolean;
|
|
21
33
|
/** Global args schema for deriving global options in completion */
|
|
22
34
|
globalArgsSchema?: ArgsSchema;
|
|
35
|
+
/**
|
|
36
|
+
* Path to the binary whose mtime is the freshness signature.
|
|
37
|
+
* Defaults to `process.argv[1]`.
|
|
38
|
+
*/
|
|
39
|
+
binPath?: string;
|
|
40
|
+
/** Program version to embed in the script header. */
|
|
41
|
+
programVersion?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Cache directory for the loader to write the regenerated script into.
|
|
44
|
+
* Defaults to `${XDG_CACHE_HOME:-$HOME/.cache}/<programName>` at runtime.
|
|
45
|
+
* Setting this hardcodes the location into the generated loader.
|
|
46
|
+
*/
|
|
47
|
+
cacheDir?: string;
|
|
23
48
|
}
|
|
24
49
|
/**
|
|
25
|
-
* Value completion specification for shell scripts
|
|
50
|
+
* Value completion specification for shell scripts.
|
|
51
|
+
*
|
|
52
|
+
* Discriminated by `type`. The `dynamic` variant carries a JS resolver that
|
|
53
|
+
* the static shell scripts delegate to via `<program> __complete`. All
|
|
54
|
+
* variants share the same optional metadata fields (left undefined where
|
|
55
|
+
* inapplicable) so consumers can read `vc.choices`/`vc.extensions`/etc.
|
|
56
|
+
* without narrowing first.
|
|
26
57
|
*/
|
|
27
|
-
type ValueCompletion = {
|
|
58
|
+
type ValueCompletion = ({
|
|
28
59
|
/** Completion type */type: "choices" | "file" | "directory" | "command" | "none"; /** List of valid choices (for "choices" type) */
|
|
29
60
|
choices?: string[]; /** Shell command for dynamic completion (for "command" type) */
|
|
30
61
|
shellCommand?: string;
|
|
62
|
+
resolve?: never;
|
|
63
|
+
dependsOn?: never;
|
|
64
|
+
table?: never;
|
|
31
65
|
} & ({
|
|
32
66
|
extensions?: string[];
|
|
33
67
|
matcher?: never;
|
|
34
68
|
} | {
|
|
35
69
|
/** Glob patterns for file matching (for "file" type) */matcher?: string[];
|
|
36
70
|
extensions?: never;
|
|
37
|
-
})
|
|
71
|
+
})) | {
|
|
72
|
+
/** In-process dynamic completion via JS callback. */type: "dynamic";
|
|
73
|
+
resolve: DynamicCompletionResolver;
|
|
74
|
+
choices?: never;
|
|
75
|
+
shellCommand?: never;
|
|
76
|
+
extensions?: never;
|
|
77
|
+
matcher?: never;
|
|
78
|
+
dependsOn?: never;
|
|
79
|
+
table?: never;
|
|
80
|
+
} | {
|
|
81
|
+
/**
|
|
82
|
+
* Pre-enumerated completion baked into the generated shell script.
|
|
83
|
+
* The `table` is the cartesian product of the `dependsOn` arg values
|
|
84
|
+
* (each having a static `choices` or enum schema). At completion time
|
|
85
|
+
* the shell dispatches on the runtime values of those args — no Node
|
|
86
|
+
* is spawned.
|
|
87
|
+
*/
|
|
88
|
+
type: "expand";
|
|
89
|
+
dependsOn: readonly string[];
|
|
90
|
+
table: readonly ExpandTableEntry[];
|
|
91
|
+
choices?: never;
|
|
92
|
+
shellCommand?: never;
|
|
93
|
+
resolve?: never;
|
|
94
|
+
extensions?: never;
|
|
95
|
+
matcher?: never;
|
|
96
|
+
};
|
|
38
97
|
/**
|
|
39
98
|
* Information about a completable option
|
|
40
99
|
*/
|
|
@@ -48,8 +107,31 @@ interface CompletableOption {
|
|
|
48
107
|
* 1-char entries are short (`-v`); multi-char entries are long (`--to-be`).
|
|
49
108
|
*/
|
|
50
109
|
alias?: string[] | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Negation name to advertise in shell completions (no `--` prefix),
|
|
112
|
+
* or `undefined` to hide the negation. Mirrors `ResolvedFieldMeta.negationDisplay`.
|
|
113
|
+
*/
|
|
114
|
+
negation?: string | undefined;
|
|
115
|
+
/** Description for the negation option (when distinct from the main description) */
|
|
116
|
+
negationDescription?: string | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* Whether the runtime parser accepts the implicit `--no-<cliName>` (and
|
|
119
|
+
* camelCase) form for this boolean option. False when the user set
|
|
120
|
+
* `negation: false` (suppressed) or `negation: <custom name>` (only the
|
|
121
|
+
* custom name is accepted). Used by the completion context parser so
|
|
122
|
+
* dynamic resolvers see the same `parsedArgs` state the runtime would
|
|
123
|
+
* compute.
|
|
124
|
+
*/
|
|
125
|
+
defaultNegationAccepted?: boolean;
|
|
51
126
|
/** Description for completion */
|
|
52
127
|
description?: string | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* True when this option originates from a `globalArgsSchema` and was
|
|
130
|
+
* propagated into every subcommand frame. The runtime parser keeps
|
|
131
|
+
* global values visible across subcommand descent, so shell generators
|
|
132
|
+
* must keep their tracker buckets separate from per-frame state.
|
|
133
|
+
*/
|
|
134
|
+
isGlobal?: boolean;
|
|
53
135
|
/** Whether this option takes a value */
|
|
54
136
|
takesValue: boolean;
|
|
55
137
|
/** Type of value expected */
|
|
@@ -155,15 +237,31 @@ interface CompletionContext {
|
|
|
155
237
|
usedOptions: Set<string>;
|
|
156
238
|
/** Number of positional arguments already provided */
|
|
157
239
|
providedPositionalCount: number;
|
|
240
|
+
/**
|
|
241
|
+
* Best-effort parsed values for the CURRENT command, keyed by camelCase
|
|
242
|
+
* field name. Includes positionals (single value or string[] for variadic
|
|
243
|
+
* positionals) and options (string for scalars, string[] for array
|
|
244
|
+
* options). Zod validation is NOT applied — values are raw strings.
|
|
245
|
+
*/
|
|
246
|
+
parsedArgs: Record<string, unknown>;
|
|
247
|
+
/**
|
|
248
|
+
* Values already supplied for the option/positional currently being
|
|
249
|
+
* completed (for de-duplicating array options and oneof exclusivity in
|
|
250
|
+
* dynamic resolvers).
|
|
251
|
+
*/
|
|
252
|
+
previousValues: string[];
|
|
158
253
|
}
|
|
159
254
|
/**
|
|
160
255
|
* Parse completion context from command line arguments
|
|
161
256
|
*
|
|
162
257
|
* @param argv - Arguments after the program name (e.g., ["build", "--fo"])
|
|
163
258
|
* @param rootCommand - The root command
|
|
259
|
+
* @param globalArgsSchema - Optional global args. When provided, options
|
|
260
|
+
* derived from this schema are merged into every command level so dynamic
|
|
261
|
+
* resolvers attached to global options can be reached from any subcommand.
|
|
164
262
|
* @returns Completion context
|
|
165
263
|
*/
|
|
166
|
-
declare function parseCompletionContext(argv: string[], rootCommand: AnyCommand): CompletionContext;
|
|
264
|
+
declare function parseCompletionContext(argv: string[], rootCommand: AnyCommand, globalArgsSchema?: ArgsSchema): CompletionContext;
|
|
167
265
|
//#endregion
|
|
168
266
|
//#region src/completion/dynamic/candidate-generator.d.ts
|
|
169
267
|
/**
|
|
@@ -204,9 +302,27 @@ interface CandidateResult {
|
|
|
204
302
|
fileMatchers?: string[] | undefined;
|
|
205
303
|
}
|
|
206
304
|
/**
|
|
207
|
-
*
|
|
305
|
+
* Options for candidate generation.
|
|
306
|
+
*/
|
|
307
|
+
interface GenerateCandidatesOptions {
|
|
308
|
+
/**
|
|
309
|
+
* Target shell. Forwarded to dynamic resolvers so they can vary output
|
|
310
|
+
* (e.g. include descriptions only for shells that render them).
|
|
311
|
+
*/
|
|
312
|
+
shell: ShellType;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Generate completion candidates based on context.
|
|
316
|
+
*
|
|
317
|
+
* Async because dynamic resolvers may return promises. Sync completion
|
|
318
|
+
* sources (choices/file/directory/command/none, subcommand, option name)
|
|
319
|
+
* still resolve synchronously and the await is a no-op for them.
|
|
320
|
+
*
|
|
321
|
+
* Inline option-value prefixes (`--field=foo`) on the option-value path
|
|
322
|
+
* are stripped here so resolvers and post-processing always see the
|
|
323
|
+
* value portion regardless of whether the caller pre-normalized.
|
|
208
324
|
*/
|
|
209
|
-
declare function generateCandidates(context: CompletionContext): CandidateResult
|
|
325
|
+
declare function generateCandidates(context: CompletionContext, options: GenerateCandidatesOptions): Promise<CandidateResult>;
|
|
210
326
|
//#endregion
|
|
211
327
|
//#region src/completion/dynamic/complete-command.d.ts
|
|
212
328
|
/**
|
|
@@ -226,9 +342,12 @@ type CompleteArgs = z.infer<typeof completeArgsSchema>;
|
|
|
226
342
|
*
|
|
227
343
|
* @param rootCommand - The root command to generate completions for
|
|
228
344
|
* @param programName - The program name (optional, defaults to rootCommand.name)
|
|
345
|
+
* @param globalArgsSchema - Global args schema. Forwarded to
|
|
346
|
+
* `parseCompletionContext` so resolvers attached to global options remain
|
|
347
|
+
* reachable at every subcommand level.
|
|
229
348
|
* @returns A command that outputs completion candidates
|
|
230
349
|
*/
|
|
231
|
-
declare function createDynamicCompleteCommand(rootCommand: AnyCommand, _programName?: string): Command<typeof completeArgsSchema, CompleteArgs, any>;
|
|
350
|
+
declare function createDynamicCompleteCommand(rootCommand: AnyCommand, _programName?: string, globalArgsSchema?: ArgsSchema): Command<typeof completeArgsSchema, CompleteArgs, any>;
|
|
232
351
|
/**
|
|
233
352
|
* Check if a command tree contains the __complete command
|
|
234
353
|
*/
|
|
@@ -269,6 +388,18 @@ declare function extractPositionals(command: AnyCommand): ResolvedFieldMeta[];
|
|
|
269
388
|
declare function extractCompletionData(command: AnyCommand, programName: string, globalArgsSchema?: ArgsSchema): CompletionData;
|
|
270
389
|
//#endregion
|
|
271
390
|
//#region src/completion/value-completion-resolver.d.ts
|
|
391
|
+
/**
|
|
392
|
+
* Sentinel returned when a field uses `completion.custom.expand`. The static
|
|
393
|
+
* extractor recognises this and replaces it with a fully resolved
|
|
394
|
+
* `{ type: "expand", ... }` ValueCompletion after sibling args' static
|
|
395
|
+
* values are known. Internal: never assigned onto `CompletableOption` /
|
|
396
|
+
* `CompletablePositional` directly; callers stash it in a side map keyed by
|
|
397
|
+
* field name and patch the resolved spec in afterwards.
|
|
398
|
+
*/
|
|
399
|
+
interface PendingExpandValueCompletion {
|
|
400
|
+
type: "pending-expand";
|
|
401
|
+
spec: ExpandCompletion;
|
|
402
|
+
}
|
|
272
403
|
/**
|
|
273
404
|
* Minimal field interface needed for resolving value completion.
|
|
274
405
|
* Both ResolvedFieldMeta and inline context-parser types satisfy this.
|
|
@@ -279,6 +410,8 @@ interface ValueCompletionField {
|
|
|
279
410
|
custom?: {
|
|
280
411
|
choices?: string[];
|
|
281
412
|
shellCommand?: string;
|
|
413
|
+
resolve?: DynamicCompletionResolver;
|
|
414
|
+
expand?: ExpandCompletion;
|
|
282
415
|
};
|
|
283
416
|
} & ({
|
|
284
417
|
extensions?: string[];
|
|
@@ -288,16 +421,23 @@ interface ValueCompletionField {
|
|
|
288
421
|
extensions?: never;
|
|
289
422
|
})) | undefined;
|
|
290
423
|
enumValues?: string[] | undefined;
|
|
424
|
+
/** Field name surfaced in error messages when custom variants are mixed. */
|
|
425
|
+
name?: string;
|
|
291
426
|
}
|
|
292
427
|
/**
|
|
293
|
-
* Resolve value completion from field metadata
|
|
428
|
+
* Resolve value completion from field metadata.
|
|
294
429
|
*
|
|
295
|
-
* Priority:
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
430
|
+
* Priority (within `custom`): `expand` > `resolve` > `choices` > `shellCommand`.
|
|
431
|
+
* Specifying more than one of these on the same field throws so the
|
|
432
|
+
* misconfiguration surfaces at command-definition time rather than at
|
|
433
|
+
* completion time. The `expand` variant returns a sentinel — the extractor
|
|
434
|
+
* resolves it against sibling fields and replaces the sentinel with a
|
|
435
|
+
* `{ type: "expand", table, dependsOn }` entry.
|
|
436
|
+
*
|
|
437
|
+
* Outside `custom`: explicit `type` (file/directory/none) > auto-detected
|
|
438
|
+
* enum values from the schema.
|
|
299
439
|
*/
|
|
300
|
-
declare function resolveValueCompletion(field: ValueCompletionField): ValueCompletion | undefined;
|
|
440
|
+
declare function resolveValueCompletion(field: ValueCompletionField): ValueCompletion | PendingExpandValueCompletion | undefined;
|
|
301
441
|
//#endregion
|
|
302
442
|
//#region src/completion/index.d.ts
|
|
303
443
|
/**
|
|
@@ -322,8 +462,18 @@ declare const completionArgsSchema: z.ZodObject<{
|
|
|
322
462
|
fish: "fish";
|
|
323
463
|
}>>;
|
|
324
464
|
instructions: z.ZodDefault<z.ZodBoolean>;
|
|
465
|
+
loader: z.ZodDefault<z.ZodBoolean>;
|
|
466
|
+
install: z.ZodDefault<z.ZodBoolean>;
|
|
325
467
|
}, z.core.$strip>;
|
|
326
468
|
type CompletionArgs = z.infer<typeof completionArgsSchema>;
|
|
469
|
+
declare const refreshArgsSchema: z.ZodObject<{
|
|
470
|
+
shell: z.ZodEnum<{
|
|
471
|
+
bash: "bash";
|
|
472
|
+
zsh: "zsh";
|
|
473
|
+
fish: "fish";
|
|
474
|
+
}>;
|
|
475
|
+
}, z.core.$strip>;
|
|
476
|
+
type RefreshArgs = z.infer<typeof refreshArgsSchema>;
|
|
327
477
|
/**
|
|
328
478
|
* Create a completion subcommand for your CLI
|
|
329
479
|
*
|
|
@@ -339,7 +489,20 @@ type CompletionArgs = z.infer<typeof completionArgsSchema>;
|
|
|
339
489
|
* });
|
|
340
490
|
* ```
|
|
341
491
|
*/
|
|
342
|
-
declare function createCompletionCommand(rootCommand: AnyCommand, programName?: string, globalArgsSchema?: ArgsSchema
|
|
492
|
+
declare function createCompletionCommand(rootCommand: AnyCommand, programName?: string, globalArgsSchema?: ArgsSchema, extra?: {
|
|
493
|
+
cacheDir?: string;
|
|
494
|
+
programVersion?: string;
|
|
495
|
+
}): Command<typeof completionArgsSchema, CompletionArgs, any>;
|
|
496
|
+
/**
|
|
497
|
+
* Hidden subcommand that the runMain background hook spawns. It does
|
|
498
|
+
* the same stat-compare + atomic rewrite as the rc loader, but in a
|
|
499
|
+
* detached child process so it's invisible to the user.
|
|
500
|
+
*/
|
|
501
|
+
declare function createRefreshCompletionCommand(rootCommand: AnyCommand, programName: string, extra?: {
|
|
502
|
+
cacheDir?: string;
|
|
503
|
+
programVersion?: string;
|
|
504
|
+
globalArgsSchema?: ArgsSchema;
|
|
505
|
+
}): Command<typeof refreshArgsSchema, RefreshArgs, any>;
|
|
343
506
|
/**
|
|
344
507
|
* Options for withCompletionCommand
|
|
345
508
|
*/
|
|
@@ -348,6 +511,15 @@ interface WithCompletionOptions {
|
|
|
348
511
|
programName?: string;
|
|
349
512
|
/** Global args schema for deriving global options in completion */
|
|
350
513
|
globalArgsSchema?: ArgsSchema;
|
|
514
|
+
/**
|
|
515
|
+
* Hardcode the cache directory used by the rc loader and the
|
|
516
|
+
* background refresh. When omitted, the loader derives
|
|
517
|
+
* `${XDG_CACHE_HOME:-$HOME/.cache}/<programName>` at runtime, which
|
|
518
|
+
* is the right answer for almost every CLI.
|
|
519
|
+
*/
|
|
520
|
+
cacheDir?: string;
|
|
521
|
+
/** Program version embedded in the script header. */
|
|
522
|
+
programVersion?: string;
|
|
351
523
|
}
|
|
352
524
|
/**
|
|
353
525
|
* Wrap a command with a completion subcommand
|
|
@@ -371,5 +543,5 @@ interface WithCompletionOptions {
|
|
|
371
543
|
*/
|
|
372
544
|
declare function withCompletionCommand<T extends AnyCommand>(command: T, options?: string | WithCompletionOptions): T;
|
|
373
545
|
//#endregion
|
|
374
|
-
export {
|
|
375
|
-
//# sourceMappingURL=index-
|
|
546
|
+
export { CompletableOption as C, CompletionOptions as D, CompletionGenerator as E, CompletionResult as O, parseCompletionContext as S, CompletionData as T, CompletionCandidate as _, generateCompletion as a, CompletionContext as b, ValueCompletionField as c, extractPositionals as d, ShellFormatOptions as f, CandidateResult as g, hasCompleteCommand as h, detectShell as i, ShellType as k, resolveValueCompletion as l, createDynamicCompleteCommand as m, createCompletionCommand as n, getSupportedShells as o, formatForShell as p, createRefreshCompletionCommand as r, withCompletionCommand as s, WithCompletionOptions as t, extractCompletionData as u, CompletionDirective as v, CompletableSubcommand as w, CompletionType as x, generateCandidates as y };
|
|
547
|
+
//# sourceMappingURL=index-DBMfKZ34.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DBMfKZ34.d.ts","names":[],"sources":["../src/completion/types.ts","../src/completion/dynamic/context-parser.ts","../src/completion/dynamic/candidate-generator.ts","../src/completion/dynamic/complete-command.ts","../src/completion/dynamic/shell-formatter.ts","../src/completion/extractor.ts","../src/completion/value-completion-resolver.ts","../src/completion/index.ts"],"mappings":";;;;;;;;;;AAkBuD;AAMvD;UARiB,gBAAA;EAAA,SACN,GAAA;EAAA,SACA,UAAA,WAAqB,uBAAuB;AAAA;AAWvD;;;AAAA,KALY,SAAA;;;;UAKK,iBAAA;EAQf;EANA,KAAA,EAAO,SAAA;EAQY;EANnB,WAAA;EAaA;EAXA,kBAAA;EAiBQ;EAfR,mBAAA;EA2BU;EAzBV,gBAAA,GAAmB,UAAU;;;;;EAK7B,OAAA;EA4BI;EA1BJ,cAAA;EA4BI;;;;;EAtBJ,QAAA;AAAA;;;;;;;;;;KAYU,eAAA;EAuCU,sBApChB,IAAA,yDAsCA;EApCA,OAAA,aAsCA;EApCA,YAAA;EACA,OAAA;EACA,SAAA;EACA,KAAA;AAAA;EAEoD,UAAA;EAAuB,OAAA;AAAA;EA0C/E,wDAxCiE,OAA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ANa,iBOyEG,uBAAA,CACd,WAAA,EAAa,UAAA,EACb,WAAA,WACA,gBAAA,GAAmB,UAAA,EACnB,KAAA;EAAS,QAAA;EAAmB,cAAA;AAAA,IAE3B,OAAA,QAAe,oBAAA,EAAsB,cAAA;AP/BL;AAMnC;;;;AANmC,iBOmJnB,8BAAA,CACd,WAAA,EAAa,UAAA,EACb,WAAA,UACA,KAAA;EAAS,QAAA;EAAmB,cAAA;EAAyB,gBAAA,GAAmB,UAAA;AAAA,IAEvE,OAAA,QAAe,iBAAA,EAAmB,WAAA;;;;UAcpB,qBAAA;EPlJkB;EOoJjC,WAAA;EP9IoC;EOgJpC,gBAAA,GAAmB,UAAU;EPxIhB;;;;;;EO+Ib,QAAA;EPjJA;EOmJA,cAAA;AAAA;;;;;;AP7IkC;AAMpC;;;;;;;;;;AAMkC;AAMlC;;;iBOkJgB,qBAAA,WAAgC,UAAA,CAAA,CAC9C,OAAA,EAAS,CAAA,EACT,OAAA,YAAmB,qBAAA,GAClB,CAAA"}
|
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as AnyCommand, d as ResolvedExpandCandidate, h as DynamicCompletionResolver, q as ResolvedFieldMeta, u as ExpandCompletion, v as ArgsSchema, x as Command } from "./arg-registry--NRaNFJM.cjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/completion/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A single resolved entry in an "expand" lookup table.
|
|
7
|
+
*
|
|
8
|
+
* `key` is the tuple of `dependsOn` values that triggers this entry, in the
|
|
9
|
+
* same order as the originating `dependsOn` array. `candidates` is the
|
|
10
|
+
* (already deduplicated) list returned by the user's `enumerate` callback
|
|
11
|
+
* for that combination.
|
|
12
|
+
*/
|
|
13
|
+
interface ExpandTableEntry {
|
|
14
|
+
readonly key: readonly string[];
|
|
15
|
+
readonly candidates: readonly ResolvedExpandCandidate[];
|
|
16
|
+
}
|
|
5
17
|
/**
|
|
6
18
|
* Supported shell types for completion
|
|
7
19
|
*/
|
|
@@ -20,21 +32,68 @@ interface CompletionOptions {
|
|
|
20
32
|
includeDescriptions?: boolean;
|
|
21
33
|
/** Global args schema for deriving global options in completion */
|
|
22
34
|
globalArgsSchema?: ArgsSchema;
|
|
35
|
+
/**
|
|
36
|
+
* Path to the binary whose mtime is the freshness signature.
|
|
37
|
+
* Defaults to `process.argv[1]`.
|
|
38
|
+
*/
|
|
39
|
+
binPath?: string;
|
|
40
|
+
/** Program version to embed in the script header. */
|
|
41
|
+
programVersion?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Cache directory for the loader to write the regenerated script into.
|
|
44
|
+
* Defaults to `${XDG_CACHE_HOME:-$HOME/.cache}/<programName>` at runtime.
|
|
45
|
+
* Setting this hardcodes the location into the generated loader.
|
|
46
|
+
*/
|
|
47
|
+
cacheDir?: string;
|
|
23
48
|
}
|
|
24
49
|
/**
|
|
25
|
-
* Value completion specification for shell scripts
|
|
50
|
+
* Value completion specification for shell scripts.
|
|
51
|
+
*
|
|
52
|
+
* Discriminated by `type`. The `dynamic` variant carries a JS resolver that
|
|
53
|
+
* the static shell scripts delegate to via `<program> __complete`. All
|
|
54
|
+
* variants share the same optional metadata fields (left undefined where
|
|
55
|
+
* inapplicable) so consumers can read `vc.choices`/`vc.extensions`/etc.
|
|
56
|
+
* without narrowing first.
|
|
26
57
|
*/
|
|
27
|
-
type ValueCompletion = {
|
|
58
|
+
type ValueCompletion = ({
|
|
28
59
|
/** Completion type */type: "choices" | "file" | "directory" | "command" | "none"; /** List of valid choices (for "choices" type) */
|
|
29
60
|
choices?: string[]; /** Shell command for dynamic completion (for "command" type) */
|
|
30
61
|
shellCommand?: string;
|
|
62
|
+
resolve?: never;
|
|
63
|
+
dependsOn?: never;
|
|
64
|
+
table?: never;
|
|
31
65
|
} & ({
|
|
32
66
|
extensions?: string[];
|
|
33
67
|
matcher?: never;
|
|
34
68
|
} | {
|
|
35
69
|
/** Glob patterns for file matching (for "file" type) */matcher?: string[];
|
|
36
70
|
extensions?: never;
|
|
37
|
-
})
|
|
71
|
+
})) | {
|
|
72
|
+
/** In-process dynamic completion via JS callback. */type: "dynamic";
|
|
73
|
+
resolve: DynamicCompletionResolver;
|
|
74
|
+
choices?: never;
|
|
75
|
+
shellCommand?: never;
|
|
76
|
+
extensions?: never;
|
|
77
|
+
matcher?: never;
|
|
78
|
+
dependsOn?: never;
|
|
79
|
+
table?: never;
|
|
80
|
+
} | {
|
|
81
|
+
/**
|
|
82
|
+
* Pre-enumerated completion baked into the generated shell script.
|
|
83
|
+
* The `table` is the cartesian product of the `dependsOn` arg values
|
|
84
|
+
* (each having a static `choices` or enum schema). At completion time
|
|
85
|
+
* the shell dispatches on the runtime values of those args — no Node
|
|
86
|
+
* is spawned.
|
|
87
|
+
*/
|
|
88
|
+
type: "expand";
|
|
89
|
+
dependsOn: readonly string[];
|
|
90
|
+
table: readonly ExpandTableEntry[];
|
|
91
|
+
choices?: never;
|
|
92
|
+
shellCommand?: never;
|
|
93
|
+
resolve?: never;
|
|
94
|
+
extensions?: never;
|
|
95
|
+
matcher?: never;
|
|
96
|
+
};
|
|
38
97
|
/**
|
|
39
98
|
* Information about a completable option
|
|
40
99
|
*/
|
|
@@ -48,8 +107,31 @@ interface CompletableOption {
|
|
|
48
107
|
* 1-char entries are short (`-v`); multi-char entries are long (`--to-be`).
|
|
49
108
|
*/
|
|
50
109
|
alias?: string[] | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Negation name to advertise in shell completions (no `--` prefix),
|
|
112
|
+
* or `undefined` to hide the negation. Mirrors `ResolvedFieldMeta.negationDisplay`.
|
|
113
|
+
*/
|
|
114
|
+
negation?: string | undefined;
|
|
115
|
+
/** Description for the negation option (when distinct from the main description) */
|
|
116
|
+
negationDescription?: string | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* Whether the runtime parser accepts the implicit `--no-<cliName>` (and
|
|
119
|
+
* camelCase) form for this boolean option. False when the user set
|
|
120
|
+
* `negation: false` (suppressed) or `negation: <custom name>` (only the
|
|
121
|
+
* custom name is accepted). Used by the completion context parser so
|
|
122
|
+
* dynamic resolvers see the same `parsedArgs` state the runtime would
|
|
123
|
+
* compute.
|
|
124
|
+
*/
|
|
125
|
+
defaultNegationAccepted?: boolean;
|
|
51
126
|
/** Description for completion */
|
|
52
127
|
description?: string | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* True when this option originates from a `globalArgsSchema` and was
|
|
130
|
+
* propagated into every subcommand frame. The runtime parser keeps
|
|
131
|
+
* global values visible across subcommand descent, so shell generators
|
|
132
|
+
* must keep their tracker buckets separate from per-frame state.
|
|
133
|
+
*/
|
|
134
|
+
isGlobal?: boolean;
|
|
53
135
|
/** Whether this option takes a value */
|
|
54
136
|
takesValue: boolean;
|
|
55
137
|
/** Type of value expected */
|
|
@@ -155,15 +237,31 @@ interface CompletionContext {
|
|
|
155
237
|
usedOptions: Set<string>;
|
|
156
238
|
/** Number of positional arguments already provided */
|
|
157
239
|
providedPositionalCount: number;
|
|
240
|
+
/**
|
|
241
|
+
* Best-effort parsed values for the CURRENT command, keyed by camelCase
|
|
242
|
+
* field name. Includes positionals (single value or string[] for variadic
|
|
243
|
+
* positionals) and options (string for scalars, string[] for array
|
|
244
|
+
* options). Zod validation is NOT applied — values are raw strings.
|
|
245
|
+
*/
|
|
246
|
+
parsedArgs: Record<string, unknown>;
|
|
247
|
+
/**
|
|
248
|
+
* Values already supplied for the option/positional currently being
|
|
249
|
+
* completed (for de-duplicating array options and oneof exclusivity in
|
|
250
|
+
* dynamic resolvers).
|
|
251
|
+
*/
|
|
252
|
+
previousValues: string[];
|
|
158
253
|
}
|
|
159
254
|
/**
|
|
160
255
|
* Parse completion context from command line arguments
|
|
161
256
|
*
|
|
162
257
|
* @param argv - Arguments after the program name (e.g., ["build", "--fo"])
|
|
163
258
|
* @param rootCommand - The root command
|
|
259
|
+
* @param globalArgsSchema - Optional global args. When provided, options
|
|
260
|
+
* derived from this schema are merged into every command level so dynamic
|
|
261
|
+
* resolvers attached to global options can be reached from any subcommand.
|
|
164
262
|
* @returns Completion context
|
|
165
263
|
*/
|
|
166
|
-
declare function parseCompletionContext(argv: string[], rootCommand: AnyCommand): CompletionContext;
|
|
264
|
+
declare function parseCompletionContext(argv: string[], rootCommand: AnyCommand, globalArgsSchema?: ArgsSchema): CompletionContext;
|
|
167
265
|
//#endregion
|
|
168
266
|
//#region src/completion/dynamic/candidate-generator.d.ts
|
|
169
267
|
/**
|
|
@@ -204,9 +302,27 @@ interface CandidateResult {
|
|
|
204
302
|
fileMatchers?: string[] | undefined;
|
|
205
303
|
}
|
|
206
304
|
/**
|
|
207
|
-
*
|
|
305
|
+
* Options for candidate generation.
|
|
306
|
+
*/
|
|
307
|
+
interface GenerateCandidatesOptions {
|
|
308
|
+
/**
|
|
309
|
+
* Target shell. Forwarded to dynamic resolvers so they can vary output
|
|
310
|
+
* (e.g. include descriptions only for shells that render them).
|
|
311
|
+
*/
|
|
312
|
+
shell: ShellType;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Generate completion candidates based on context.
|
|
316
|
+
*
|
|
317
|
+
* Async because dynamic resolvers may return promises. Sync completion
|
|
318
|
+
* sources (choices/file/directory/command/none, subcommand, option name)
|
|
319
|
+
* still resolve synchronously and the await is a no-op for them.
|
|
320
|
+
*
|
|
321
|
+
* Inline option-value prefixes (`--field=foo`) on the option-value path
|
|
322
|
+
* are stripped here so resolvers and post-processing always see the
|
|
323
|
+
* value portion regardless of whether the caller pre-normalized.
|
|
208
324
|
*/
|
|
209
|
-
declare function generateCandidates(context: CompletionContext): CandidateResult
|
|
325
|
+
declare function generateCandidates(context: CompletionContext, options: GenerateCandidatesOptions): Promise<CandidateResult>;
|
|
210
326
|
//#endregion
|
|
211
327
|
//#region src/completion/dynamic/complete-command.d.ts
|
|
212
328
|
/**
|
|
@@ -226,9 +342,12 @@ type CompleteArgs = z.infer<typeof completeArgsSchema>;
|
|
|
226
342
|
*
|
|
227
343
|
* @param rootCommand - The root command to generate completions for
|
|
228
344
|
* @param programName - The program name (optional, defaults to rootCommand.name)
|
|
345
|
+
* @param globalArgsSchema - Global args schema. Forwarded to
|
|
346
|
+
* `parseCompletionContext` so resolvers attached to global options remain
|
|
347
|
+
* reachable at every subcommand level.
|
|
229
348
|
* @returns A command that outputs completion candidates
|
|
230
349
|
*/
|
|
231
|
-
declare function createDynamicCompleteCommand(rootCommand: AnyCommand, _programName?: string): Command<typeof completeArgsSchema, CompleteArgs, any>;
|
|
350
|
+
declare function createDynamicCompleteCommand(rootCommand: AnyCommand, _programName?: string, globalArgsSchema?: ArgsSchema): Command<typeof completeArgsSchema, CompleteArgs, any>;
|
|
232
351
|
/**
|
|
233
352
|
* Check if a command tree contains the __complete command
|
|
234
353
|
*/
|
|
@@ -269,6 +388,18 @@ declare function extractPositionals(command: AnyCommand): ResolvedFieldMeta[];
|
|
|
269
388
|
declare function extractCompletionData(command: AnyCommand, programName: string, globalArgsSchema?: ArgsSchema): CompletionData;
|
|
270
389
|
//#endregion
|
|
271
390
|
//#region src/completion/value-completion-resolver.d.ts
|
|
391
|
+
/**
|
|
392
|
+
* Sentinel returned when a field uses `completion.custom.expand`. The static
|
|
393
|
+
* extractor recognises this and replaces it with a fully resolved
|
|
394
|
+
* `{ type: "expand", ... }` ValueCompletion after sibling args' static
|
|
395
|
+
* values are known. Internal: never assigned onto `CompletableOption` /
|
|
396
|
+
* `CompletablePositional` directly; callers stash it in a side map keyed by
|
|
397
|
+
* field name and patch the resolved spec in afterwards.
|
|
398
|
+
*/
|
|
399
|
+
interface PendingExpandValueCompletion {
|
|
400
|
+
type: "pending-expand";
|
|
401
|
+
spec: ExpandCompletion;
|
|
402
|
+
}
|
|
272
403
|
/**
|
|
273
404
|
* Minimal field interface needed for resolving value completion.
|
|
274
405
|
* Both ResolvedFieldMeta and inline context-parser types satisfy this.
|
|
@@ -279,6 +410,8 @@ interface ValueCompletionField {
|
|
|
279
410
|
custom?: {
|
|
280
411
|
choices?: string[];
|
|
281
412
|
shellCommand?: string;
|
|
413
|
+
resolve?: DynamicCompletionResolver;
|
|
414
|
+
expand?: ExpandCompletion;
|
|
282
415
|
};
|
|
283
416
|
} & ({
|
|
284
417
|
extensions?: string[];
|
|
@@ -288,16 +421,23 @@ interface ValueCompletionField {
|
|
|
288
421
|
extensions?: never;
|
|
289
422
|
})) | undefined;
|
|
290
423
|
enumValues?: string[] | undefined;
|
|
424
|
+
/** Field name surfaced in error messages when custom variants are mixed. */
|
|
425
|
+
name?: string;
|
|
291
426
|
}
|
|
292
427
|
/**
|
|
293
|
-
* Resolve value completion from field metadata
|
|
428
|
+
* Resolve value completion from field metadata.
|
|
294
429
|
*
|
|
295
|
-
* Priority:
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
430
|
+
* Priority (within `custom`): `expand` > `resolve` > `choices` > `shellCommand`.
|
|
431
|
+
* Specifying more than one of these on the same field throws so the
|
|
432
|
+
* misconfiguration surfaces at command-definition time rather than at
|
|
433
|
+
* completion time. The `expand` variant returns a sentinel — the extractor
|
|
434
|
+
* resolves it against sibling fields and replaces the sentinel with a
|
|
435
|
+
* `{ type: "expand", table, dependsOn }` entry.
|
|
436
|
+
*
|
|
437
|
+
* Outside `custom`: explicit `type` (file/directory/none) > auto-detected
|
|
438
|
+
* enum values from the schema.
|
|
299
439
|
*/
|
|
300
|
-
declare function resolveValueCompletion(field: ValueCompletionField): ValueCompletion | undefined;
|
|
440
|
+
declare function resolveValueCompletion(field: ValueCompletionField): ValueCompletion | PendingExpandValueCompletion | undefined;
|
|
301
441
|
//#endregion
|
|
302
442
|
//#region src/completion/index.d.ts
|
|
303
443
|
/**
|
|
@@ -322,8 +462,18 @@ declare const completionArgsSchema: z.ZodObject<{
|
|
|
322
462
|
fish: "fish";
|
|
323
463
|
}>>;
|
|
324
464
|
instructions: z.ZodDefault<z.ZodBoolean>;
|
|
465
|
+
loader: z.ZodDefault<z.ZodBoolean>;
|
|
466
|
+
install: z.ZodDefault<z.ZodBoolean>;
|
|
325
467
|
}, z.core.$strip>;
|
|
326
468
|
type CompletionArgs = z.infer<typeof completionArgsSchema>;
|
|
469
|
+
declare const refreshArgsSchema: z.ZodObject<{
|
|
470
|
+
shell: z.ZodEnum<{
|
|
471
|
+
bash: "bash";
|
|
472
|
+
zsh: "zsh";
|
|
473
|
+
fish: "fish";
|
|
474
|
+
}>;
|
|
475
|
+
}, z.core.$strip>;
|
|
476
|
+
type RefreshArgs = z.infer<typeof refreshArgsSchema>;
|
|
327
477
|
/**
|
|
328
478
|
* Create a completion subcommand for your CLI
|
|
329
479
|
*
|
|
@@ -339,7 +489,20 @@ type CompletionArgs = z.infer<typeof completionArgsSchema>;
|
|
|
339
489
|
* });
|
|
340
490
|
* ```
|
|
341
491
|
*/
|
|
342
|
-
declare function createCompletionCommand(rootCommand: AnyCommand, programName?: string, globalArgsSchema?: ArgsSchema
|
|
492
|
+
declare function createCompletionCommand(rootCommand: AnyCommand, programName?: string, globalArgsSchema?: ArgsSchema, extra?: {
|
|
493
|
+
cacheDir?: string;
|
|
494
|
+
programVersion?: string;
|
|
495
|
+
}): Command<typeof completionArgsSchema, CompletionArgs, any>;
|
|
496
|
+
/**
|
|
497
|
+
* Hidden subcommand that the runMain background hook spawns. It does
|
|
498
|
+
* the same stat-compare + atomic rewrite as the rc loader, but in a
|
|
499
|
+
* detached child process so it's invisible to the user.
|
|
500
|
+
*/
|
|
501
|
+
declare function createRefreshCompletionCommand(rootCommand: AnyCommand, programName: string, extra?: {
|
|
502
|
+
cacheDir?: string;
|
|
503
|
+
programVersion?: string;
|
|
504
|
+
globalArgsSchema?: ArgsSchema;
|
|
505
|
+
}): Command<typeof refreshArgsSchema, RefreshArgs, any>;
|
|
343
506
|
/**
|
|
344
507
|
* Options for withCompletionCommand
|
|
345
508
|
*/
|
|
@@ -348,6 +511,15 @@ interface WithCompletionOptions {
|
|
|
348
511
|
programName?: string;
|
|
349
512
|
/** Global args schema for deriving global options in completion */
|
|
350
513
|
globalArgsSchema?: ArgsSchema;
|
|
514
|
+
/**
|
|
515
|
+
* Hardcode the cache directory used by the rc loader and the
|
|
516
|
+
* background refresh. When omitted, the loader derives
|
|
517
|
+
* `${XDG_CACHE_HOME:-$HOME/.cache}/<programName>` at runtime, which
|
|
518
|
+
* is the right answer for almost every CLI.
|
|
519
|
+
*/
|
|
520
|
+
cacheDir?: string;
|
|
521
|
+
/** Program version embedded in the script header. */
|
|
522
|
+
programVersion?: string;
|
|
351
523
|
}
|
|
352
524
|
/**
|
|
353
525
|
* Wrap a command with a completion subcommand
|
|
@@ -371,5 +543,5 @@ interface WithCompletionOptions {
|
|
|
371
543
|
*/
|
|
372
544
|
declare function withCompletionCommand<T extends AnyCommand>(command: T, options?: string | WithCompletionOptions): T;
|
|
373
545
|
//#endregion
|
|
374
|
-
export {
|
|
375
|
-
//# sourceMappingURL=index-
|
|
546
|
+
export { CompletableOption as C, CompletionOptions as D, CompletionGenerator as E, CompletionResult as O, parseCompletionContext as S, CompletionData as T, CompletionCandidate as _, generateCompletion as a, CompletionContext as b, ValueCompletionField as c, extractPositionals as d, ShellFormatOptions as f, CandidateResult as g, hasCompleteCommand as h, detectShell as i, ShellType as k, resolveValueCompletion as l, createDynamicCompleteCommand as m, createCompletionCommand as n, getSupportedShells as o, formatForShell as p, createRefreshCompletionCommand as r, withCompletionCommand as s, WithCompletionOptions as t, extractCompletionData as u, CompletionDirective as v, CompletableSubcommand as w, CompletionType as x, generateCandidates as y };
|
|
547
|
+
//# sourceMappingURL=index-DJp8k5Bq.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DJp8k5Bq.d.cts","names":[],"sources":["../src/completion/types.ts","../src/completion/dynamic/context-parser.ts","../src/completion/dynamic/candidate-generator.ts","../src/completion/dynamic/complete-command.ts","../src/completion/dynamic/shell-formatter.ts","../src/completion/extractor.ts","../src/completion/value-completion-resolver.ts","../src/completion/index.ts"],"mappings":";;;;;;;;;;AA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