@politty/loculus 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +65 -2
- package/bin/cli.mjs +3 -0
- package/dist/agent.d.ts +2 -0
- package/dist/agent.js +1 -0
- package/dist/argv-parser-BRSUT6IV.js +1 -0
- package/dist/cli-main-CoQp6CjD.js +1 -0
- package/dist/cli-main-D4rJTFFd.js +2 -0
- package/dist/cli-run-DABESHM4.js +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +2 -0
- package/dist/command-BXsTrIgI.js +1 -0
- package/dist/compile-cache-6u9hgeWu.js +1 -0
- package/dist/compile-cache.d.ts +80 -0
- package/dist/compile-cache.js +1 -0
- package/dist/completion-BGidlN43.js +1 -0
- package/dist/completion-Cyw4RN-l.js +116 -0
- package/dist/completion.d.ts +333 -0
- package/dist/completion.js +1 -0
- package/dist/detect-agent-D7KSeWMh.js +3 -0
- package/dist/detect-agent-EHaSY1KW.d.ts +49 -0
- package/dist/docs.d.ts +770 -0
- package/dist/docs.js +94 -0
- package/dist/dynamic-BbeRdUqR.js +1 -0
- package/dist/dynamic-Hg5BDHzz.js +6 -0
- package/dist/import-meta-resolve-DgKm4LYW.js +3 -0
- package/dist/index.d.ts +1088 -0
- package/dist/index.js +1 -0
- package/dist/log-collector-uhRWYT-z.js +1 -0
- package/dist/logger-CoeDrmRr.js +1 -0
- package/dist/prompt-clack.d.ts +15 -0
- package/dist/prompt-clack.js +1 -0
- package/dist/prompt-fl79dWPz.js +1 -0
- package/dist/prompt-inquirer.d.ts +15 -0
- package/dist/prompt-inquirer.js +1 -0
- package/dist/prompt.d.ts +106 -0
- package/dist/prompt.js +1 -0
- package/dist/register-Ceh-HlVN.js +1 -0
- package/dist/registry-BEz5iex_.js +1 -0
- package/dist/runner-D-n1xa2K.js +33 -0
- package/dist/runner-nPWQnqQ3.js +1 -0
- package/dist/schema--6eHVfwR.js +1 -0
- package/dist/schema-extractor-DFawzmtj.js +1 -0
- package/dist/skill.d.ts +581 -0
- package/dist/skill.js +2 -0
- package/dist/subcommand-router-iqmWGZyU.js +2 -0
- package/dist/types-Dhar1ua6.d.ts +1125 -0
- package/dist/with-completion-command-CARvhYvv.d.ts +384 -0
- package/dist/with-completion-command-yg7HB6Zu.js +3 -0
- package/package.json +101 -3
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { $ as DynamicCompletionCandidate, I as ResolvedFieldMeta, Q as CompletionDirectiveMask, X as ExpandCompletion, a as ArgsSchema, c as Command, et as DynamicCompletionContext, nt as DynamicCompletionResult, r as AnyCommand, tt as DynamicCompletionResolver } from "./types-Dhar1ua6.js";
|
|
2
|
+
import { _ as CompletionResult, a as bundledWorkerShellExtension, b as InferInternalArgs, c as validateBundledWorkerFile, d as CompletablePositional, f as CompletableSubcommand, g as CompletionOptions, h as CompletionMode, i as GenerateBundledCompletionWorkerResult, l as BundledWorkerOptions, m as CompletionGenerator, n as withCompletionCommand, o as defaultBundledWorkerOutputPath, p as CompletionData, r as GenerateBundledCompletionWorkerOptions, s as generateBundledCompletionWorker, t as WithCompletionOptions, u as CompletableOption, v as ShellType, x as InternalArgsSchema, y as ValueCompletion } from "./with-completion-command-CARvhYvv.js";
|
|
3
|
+
//#region ../core/src/completion/schemas.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Schema for the completion command arguments
|
|
6
|
+
*/
|
|
7
|
+
declare const completionArgsSchema: InternalArgsSchema<{
|
|
8
|
+
shell: "bash" | "fish" | "zsh" | undefined;
|
|
9
|
+
instructions: boolean;
|
|
10
|
+
loader: boolean;
|
|
11
|
+
install: boolean;
|
|
12
|
+
static: boolean;
|
|
13
|
+
dispatcher: boolean;
|
|
14
|
+
worker: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
type CompletionArgs = InferInternalArgs<typeof completionArgsSchema>;
|
|
17
|
+
declare const refreshArgsSchema: InternalArgsSchema<{
|
|
18
|
+
shell: "bash" | "fish" | "zsh";
|
|
19
|
+
target: string | undefined;
|
|
20
|
+
static: boolean;
|
|
21
|
+
worker: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
type RefreshArgs = InferInternalArgs<typeof refreshArgsSchema>;
|
|
24
|
+
declare const workerPathArgsSchema: InternalArgsSchema<{
|
|
25
|
+
shell: "bash" | "fish" | "zsh";
|
|
26
|
+
}>;
|
|
27
|
+
type WorkerPathArgs = InferInternalArgs<typeof workerPathArgsSchema>;
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region ../core/src/completion/dynamic/context-parser.d.ts
|
|
30
|
+
/**
|
|
31
|
+
* Completion type indicates what kind of completion is expected
|
|
32
|
+
*/
|
|
33
|
+
type CompletionType = "subcommand" | "option-name" | "option-value" | "positional";
|
|
34
|
+
/**
|
|
35
|
+
* Context for completion at current cursor position
|
|
36
|
+
*/
|
|
37
|
+
interface CompletionContext {
|
|
38
|
+
/** Subcommand path from root (e.g., ["plugin", "add"]) */
|
|
39
|
+
subcommandPath: string[];
|
|
40
|
+
/** The resolved command at current path */
|
|
41
|
+
currentCommand: AnyCommand;
|
|
42
|
+
/** Current word being typed (may be partial) */
|
|
43
|
+
currentWord: string;
|
|
44
|
+
/** Previous word (useful for option value detection) */
|
|
45
|
+
previousWord: string;
|
|
46
|
+
/** What type of completion is expected */
|
|
47
|
+
completionType: CompletionType;
|
|
48
|
+
/** Target option when completing option value */
|
|
49
|
+
targetOption?: CompletableOption | undefined;
|
|
50
|
+
/** Positional index when completing positional argument */
|
|
51
|
+
positionalIndex?: number | undefined;
|
|
52
|
+
/** Available options for current command */
|
|
53
|
+
options: CompletableOption[];
|
|
54
|
+
/** Available subcommands */
|
|
55
|
+
subcommands: string[];
|
|
56
|
+
/** Available positionals */
|
|
57
|
+
positionals: CompletablePositional[];
|
|
58
|
+
/** Options already used (to avoid duplicates) */
|
|
59
|
+
usedOptions: Set<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Whether any option has been typed anywhere in this invocation so far,
|
|
62
|
+
* including before a subcommand descent that reset `usedOptions`. Unlike
|
|
63
|
+
* `usedOptions`, this is never cleared.
|
|
64
|
+
*
|
|
65
|
+
* Optional (not just because it defaults to `false`): `CompletionContext`
|
|
66
|
+
* is public API, constructible by hand for `generateCandidates` without
|
|
67
|
+
* going through `parseCompletionContext`, so a new required member would
|
|
68
|
+
* break existing callers. Treat an omitted value the same as `false`.
|
|
69
|
+
*/
|
|
70
|
+
hasAnyOptionBeenUsed?: boolean;
|
|
71
|
+
/** Number of positional arguments already provided */
|
|
72
|
+
providedPositionalCount: number;
|
|
73
|
+
/**
|
|
74
|
+
* Best-effort parsed values for the CURRENT command, keyed by camelCase
|
|
75
|
+
* field name. Includes positionals (single value or string[] for variadic
|
|
76
|
+
* positionals) and options (string for scalars, string[] for array
|
|
77
|
+
* options). Zod validation is NOT applied — values are raw strings.
|
|
78
|
+
*/
|
|
79
|
+
parsedArgs: Record<string, unknown>;
|
|
80
|
+
/**
|
|
81
|
+
* Values already supplied for the option/positional currently being
|
|
82
|
+
* completed (for de-duplicating array options and oneof exclusivity in
|
|
83
|
+
* dynamic resolvers).
|
|
84
|
+
*/
|
|
85
|
+
previousValues: string[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Parse completion context from command line arguments
|
|
89
|
+
*
|
|
90
|
+
* @param argv - Arguments after the program name (e.g., ["build", "--fo"])
|
|
91
|
+
* @param rootCommand - The root command
|
|
92
|
+
* @param globalArgsSchema - Optional global args. When provided, options
|
|
93
|
+
* derived from this schema are merged into every command level so dynamic
|
|
94
|
+
* resolvers attached to global options can be reached from any subcommand.
|
|
95
|
+
* @returns Completion context
|
|
96
|
+
*/
|
|
97
|
+
export declare function parseCompletionContext(argv: string[], rootCommand: AnyCommand, globalArgsSchema?: ArgsSchema): CompletionContext;
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region ../core/src/completion/dynamic/candidate-generator.d.ts
|
|
100
|
+
/**
|
|
101
|
+
* Completion directive flags (bitwise)
|
|
102
|
+
*/
|
|
103
|
+
export declare const CompletionDirective: {
|
|
104
|
+
/** Default completion behavior */
|
|
105
|
+
readonly Default: 0;
|
|
106
|
+
/** Don't add space after completion */
|
|
107
|
+
readonly NoSpace: 1;
|
|
108
|
+
/** Don't offer file completion (even if no other completions) */
|
|
109
|
+
readonly NoFileCompletion: 2;
|
|
110
|
+
/** Filter completions using current word as prefix */
|
|
111
|
+
readonly FilterPrefix: 4;
|
|
112
|
+
/** Keep the order of completions */
|
|
113
|
+
readonly KeepOrder: 8;
|
|
114
|
+
/** Trigger file completion */
|
|
115
|
+
readonly FileCompletion: 16;
|
|
116
|
+
/** Trigger directory completion */
|
|
117
|
+
readonly DirectoryCompletion: 32;
|
|
118
|
+
/** Error occurred during completion */
|
|
119
|
+
readonly Error: 64;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* A completion candidate
|
|
123
|
+
*/
|
|
124
|
+
interface CompletionCandidate {
|
|
125
|
+
/** The completion value */
|
|
126
|
+
value: string;
|
|
127
|
+
/** Optional description */
|
|
128
|
+
description?: string | undefined;
|
|
129
|
+
/** Type hint for display purposes */
|
|
130
|
+
type?: "option" | "subcommand" | "value" | "file" | "directory";
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Result of candidate generation
|
|
134
|
+
*/
|
|
135
|
+
interface CandidateResult {
|
|
136
|
+
/** Completion candidates */
|
|
137
|
+
candidates: CompletionCandidate[];
|
|
138
|
+
/** Directive flags for shell behavior */
|
|
139
|
+
directive: number;
|
|
140
|
+
/** File extensions for shell-native filtering (e.g., ["json", "yaml"]) */
|
|
141
|
+
fileExtensions?: string[] | undefined;
|
|
142
|
+
/** Glob patterns for shell-native file matching (e.g., [".env.*"]) */
|
|
143
|
+
fileMatchers?: string[] | undefined;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Options for candidate generation.
|
|
147
|
+
*/
|
|
148
|
+
interface GenerateCandidatesOptions {
|
|
149
|
+
/**
|
|
150
|
+
* Target shell. Forwarded to dynamic resolvers so they can vary output
|
|
151
|
+
* (e.g. include descriptions only for shells that render them).
|
|
152
|
+
*/
|
|
153
|
+
shell: ShellType;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Generate completion candidates based on context.
|
|
157
|
+
*
|
|
158
|
+
* Async because dynamic resolvers may return promises. Sync completion
|
|
159
|
+
* sources (choices/file/directory/command/none, subcommand, option name)
|
|
160
|
+
* still resolve synchronously and the await is a no-op for them.
|
|
161
|
+
*
|
|
162
|
+
* Inline option-value prefixes (`--field=foo`) on the option-value path
|
|
163
|
+
* are stripped here so resolvers and post-processing always see the
|
|
164
|
+
* value portion regardless of whether the caller pre-normalized.
|
|
165
|
+
*/
|
|
166
|
+
export declare function generateCandidates(context: CompletionContext, options: GenerateCandidatesOptions): Promise<CandidateResult>;
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region ../core/src/completion/dynamic/schema.d.ts
|
|
169
|
+
declare const completeArgsSchema: InternalArgsSchema<{
|
|
170
|
+
shell: "bash" | "fish" | "zsh";
|
|
171
|
+
args: string[];
|
|
172
|
+
}>;
|
|
173
|
+
type CompleteArgs = InferInternalArgs<typeof completeArgsSchema>;
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region ../core/src/completion/dynamic/complete-command.d.ts
|
|
176
|
+
/**
|
|
177
|
+
* Create the dynamic completion command
|
|
178
|
+
*
|
|
179
|
+
* @param rootCommand - The root command to generate completions for
|
|
180
|
+
* @param programName - The program name (optional, defaults to rootCommand.name)
|
|
181
|
+
* @param globalArgsSchema - Global args schema. Forwarded to
|
|
182
|
+
* `parseCompletionContext` so resolvers attached to global options remain
|
|
183
|
+
* reachable at every subcommand level.
|
|
184
|
+
* @returns A command that outputs completion candidates
|
|
185
|
+
*/
|
|
186
|
+
export declare function createDynamicCompleteCommand(rootCommand: AnyCommand, _programName?: string, globalArgsSchema?: ArgsSchema): Command<typeof completeArgsSchema, CompleteArgs, any>;
|
|
187
|
+
/**
|
|
188
|
+
* Check if a command tree contains the __complete command
|
|
189
|
+
*/
|
|
190
|
+
export declare function hasCompleteCommand(command: AnyCommand): boolean;
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region ../core/src/completion/dynamic/shell-formatter.d.ts
|
|
193
|
+
/**
|
|
194
|
+
* Options for shell-specific formatting
|
|
195
|
+
*/
|
|
196
|
+
interface ShellFormatOptions {
|
|
197
|
+
/** Target shell type */
|
|
198
|
+
shell: ShellType;
|
|
199
|
+
/** Current word being completed (used for prefix filtering) */
|
|
200
|
+
currentWord: string;
|
|
201
|
+
/** For bash: the prefix before '=' in --opt=value completions */
|
|
202
|
+
inlinePrefix?: string | undefined;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Format completion candidates for the specified shell
|
|
206
|
+
*
|
|
207
|
+
* @returns Shell-ready output string (lines separated by newline, last line is :directive)
|
|
208
|
+
*/
|
|
209
|
+
export declare function formatForShell(result: CandidateResult, options: ShellFormatOptions): string;
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region ../core/src/completion/extractor.d.ts
|
|
212
|
+
/**
|
|
213
|
+
* Extract positional arguments from a command
|
|
214
|
+
*/
|
|
215
|
+
export declare function extractPositionals(command: AnyCommand): ResolvedFieldMeta[];
|
|
216
|
+
/**
|
|
217
|
+
* Extract completion data from a command tree
|
|
218
|
+
*
|
|
219
|
+
* @param command - The root command
|
|
220
|
+
* @param programName - Program name for completion scripts
|
|
221
|
+
* @param globalArgsSchema - Optional global args schema. When provided, global options
|
|
222
|
+
* are derived from this schema instead of the root command's options.
|
|
223
|
+
*/
|
|
224
|
+
export declare function extractCompletionData(command: AnyCommand, programName: string, globalArgsSchema?: ArgsSchema, validateOnly?: boolean): CompletionData;
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region ../core/src/completion/value-completion-resolver.d.ts
|
|
227
|
+
/**
|
|
228
|
+
* Sentinel returned when a field uses `completion.custom.expand`. The static
|
|
229
|
+
* extractor recognises this and replaces it with a fully resolved
|
|
230
|
+
* `{ type: "expand", ... }` ValueCompletion after sibling args' static
|
|
231
|
+
* values are known. Internal: never assigned onto `CompletableOption` /
|
|
232
|
+
* `CompletablePositional` directly; callers stash it in a side map keyed by
|
|
233
|
+
* field name and patch the resolved spec in afterwards.
|
|
234
|
+
*/
|
|
235
|
+
interface PendingExpandValueCompletion {
|
|
236
|
+
type: "pending-expand";
|
|
237
|
+
spec: ExpandCompletion;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Minimal field interface needed for resolving value completion.
|
|
241
|
+
* Both ResolvedFieldMeta and inline context-parser types satisfy this.
|
|
242
|
+
*/
|
|
243
|
+
interface ValueCompletionField {
|
|
244
|
+
completion?: ({
|
|
245
|
+
type?: string;
|
|
246
|
+
custom?: {
|
|
247
|
+
choices?: string[];
|
|
248
|
+
shellCommand?: string;
|
|
249
|
+
resolve?: DynamicCompletionResolver;
|
|
250
|
+
expand?: ExpandCompletion;
|
|
251
|
+
};
|
|
252
|
+
} & ({
|
|
253
|
+
extensions?: string[];
|
|
254
|
+
matcher?: never;
|
|
255
|
+
} | {
|
|
256
|
+
matcher?: string[];
|
|
257
|
+
extensions?: never;
|
|
258
|
+
})) | undefined;
|
|
259
|
+
enumValues?: string[] | undefined;
|
|
260
|
+
/** Field name surfaced in error messages when custom variants are mixed. */
|
|
261
|
+
name?: string;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Resolve value completion from field metadata.
|
|
265
|
+
*
|
|
266
|
+
* Priority (within `custom`): `expand` > `resolve` > `choices` > `shellCommand`.
|
|
267
|
+
* Specifying more than one of these on the same field throws so the
|
|
268
|
+
* misconfiguration surfaces at command-definition time rather than at
|
|
269
|
+
* completion time. The `expand` variant returns a sentinel — the extractor
|
|
270
|
+
* resolves it against sibling fields and replaces the sentinel with a
|
|
271
|
+
* `{ type: "expand", table, dependsOn }` entry.
|
|
272
|
+
*
|
|
273
|
+
* Outside `custom`: explicit `type` (file/directory/none) > auto-detected
|
|
274
|
+
* enum values from the schema.
|
|
275
|
+
*/
|
|
276
|
+
export declare function resolveValueCompletion(field: ValueCompletionField): ValueCompletion | PendingExpandValueCompletion | undefined;
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region ../core/src/completion/detect-shell.d.ts
|
|
279
|
+
/**
|
|
280
|
+
* Detect the current shell from environment.
|
|
281
|
+
*
|
|
282
|
+
* Split out from `index.ts` so `with-completion-command.ts` can detect the
|
|
283
|
+
* shell for the runMain background-refresh hook without statically pulling
|
|
284
|
+
* in the bash/zsh/fish generators.
|
|
285
|
+
*/
|
|
286
|
+
export declare function detectShell(): ShellType | null;
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region ../core/src/completion/index.d.ts
|
|
289
|
+
/**
|
|
290
|
+
* Generate completion script for the specified shell
|
|
291
|
+
*/
|
|
292
|
+
export declare function generateCompletion(command: AnyCommand, options: CompletionOptions): CompletionResult;
|
|
293
|
+
/**
|
|
294
|
+
* Get the list of supported shells
|
|
295
|
+
*/
|
|
296
|
+
export declare function getSupportedShells(): ShellType[];
|
|
297
|
+
/**
|
|
298
|
+
* Create a completion subcommand for your CLI
|
|
299
|
+
*
|
|
300
|
+
* This creates a ready-to-use subcommand that generates completion scripts.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```typescript
|
|
304
|
+
* const mainCommand = defineCommand({
|
|
305
|
+
* name: "mycli",
|
|
306
|
+
* subCommands: {
|
|
307
|
+
* completion: createCompletionCommand(mainCommand)
|
|
308
|
+
* }
|
|
309
|
+
* });
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
export declare function createCompletionCommand(rootCommand: AnyCommand, programName?: string, globalArgsSchema?: ArgsSchema, extra?: {
|
|
313
|
+
cacheDir?: string;
|
|
314
|
+
programVersion?: string;
|
|
315
|
+
bundledWorker?: BundledWorkerOptions;
|
|
316
|
+
}): Command<typeof completionArgsSchema, CompletionArgs, any>;
|
|
317
|
+
/**
|
|
318
|
+
* Hidden subcommand that the runMain background hook spawns. It does
|
|
319
|
+
* the same stat-compare + atomic rewrite as the rc loader, but in a
|
|
320
|
+
* detached child process so it's invisible to the user.
|
|
321
|
+
*/
|
|
322
|
+
export declare function createRefreshCompletionCommand(rootCommand: AnyCommand, programName: string, extra?: {
|
|
323
|
+
cacheDir?: string;
|
|
324
|
+
programVersion?: string;
|
|
325
|
+
globalArgsSchema?: ArgsSchema;
|
|
326
|
+
bundledWorker?: BundledWorkerOptions;
|
|
327
|
+
}): Command<typeof refreshArgsSchema, RefreshArgs, any>;
|
|
328
|
+
export declare function createCompletionWorkerPathCommand(programName: string, extra?: {
|
|
329
|
+
binPath?: string;
|
|
330
|
+
bundledWorker?: BundledWorkerOptions;
|
|
331
|
+
}): Command<typeof workerPathArgsSchema, WorkerPathArgs, any>;
|
|
332
|
+
//#endregion
|
|
333
|
+
export { type BundledWorkerOptions, type CandidateResult, type CompletableOption, type CompletableSubcommand, type CompletionCandidate, type CompletionContext, type CompletionData, type CompletionDirectiveMask, type CompletionGenerator, type CompletionMode, type CompletionOptions, type CompletionResult, type CompletionType, type DynamicCompletionCandidate, type DynamicCompletionContext, type DynamicCompletionResolver, type DynamicCompletionResult, type GenerateBundledCompletionWorkerOptions, type GenerateBundledCompletionWorkerResult, type ShellFormatOptions, type ShellType, type ValueCompletionField, type WithCompletionOptions, bundledWorkerShellExtension, defaultBundledWorkerOutputPath, generateBundledCompletionWorker, validateBundledWorkerFile, withCompletionCommand };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e,t}from"./with-completion-command-yg7HB6Zu.js";import"./register-Ceh-HlVN.js";import{a as n,i as r,n as i,o as a,r as o,s,t as c}from"./dynamic-Hg5BDHzz.js";import{a as l,c as u,d,i as f,l as p,n as m,o as h,r as g,s as _,t as v,u as y}from"./completion-Cyw4RN-l.js";export{r as CompletionDirective,h as bundledWorkerShellExtension,v as createCompletionCommand,m as createCompletionWorkerPathCommand,c as createDynamicCompleteCommand,g as createRefreshCompletionCommand,_ as defaultBundledWorkerOutputPath,e as detectShell,y as extractCompletionData,d as extractPositionals,o as formatForShell,u as generateBundledCompletionWorker,n as generateCandidates,f as generateCompletion,l as getSupportedShells,i as hasCompleteCommand,a as parseCompletionContext,s as resolveValueCompletion,p as validateBundledWorkerFile,t as withCompletionCommand};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{existsSync as e}from"node:fs";const t=[`cursor`,`cursor-cli`,`kimi`,`grok`,`gemini_cli`,`cline`,`codex_cli`,`antigravity`,`augment-cli`,`open_code`,`goose`,`junie`,`pi`,`cowork`,`claude_code`,`replit`,`github-copilot`,`kiro`,`openclaw`,`devin`];var n=`AI_AGENT`;
|
|
2
|
+
/*! Agent detection data from vercel/detect-agent (https://github.com/vercel/detect-agent), Copyright Vercel, Inc., Apache-2.0 (http://www.apache.org/licenses/LICENSE-2.0) */
|
|
3
|
+
const r=[{key:`CURSOR`,name:`cursor`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`CURSOR_TRACE_ID`}]}},{key:`CURSOR_CLI`,name:`cursor-cli`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`CURSOR_AGENT`},{type:`env_value`,name:`CURSOR_EXTENSION_HOST_ROLE`,value:`agent-exec`}]}},{key:`KIMI`,name:`kimi`,description:`Kimi Code plugin hooks. KIMI_CODE_HOME may be configured outside an active Kimi session, so detection uses the plugin-scoped KIMI_PLUGIN_ROOT marker.`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`KIMI_PLUGIN_ROOT`}]}},{key:`GROK`,name:`grok`,description:`Grok Build plugin hooks. Evaluated before Claude Code because Grok supports Claude Code plugins and may expose compatibility markers.`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`GROK_PLUGIN_ROOT`},{type:`env_set`,name:`GROK_PLUGIN_DATA`}]}},{key:`GEMINI`,name:`gemini_cli`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`GEMINI_CLI`}]}},{key:`CLINE`,name:`cline`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`CLINE_ACTIVE`}]}},{key:`CODEX`,name:`codex_cli`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`CODEX_SANDBOX`},{type:`env_set`,name:`CODEX_CI`},{type:`env_set`,name:`CODEX_THREAD_ID`},{type:`env_set`,name:`CODEX_SANDBOX_NETWORK_DISABLED`}]}},{key:`ANTIGRAVITY`,name:`antigravity`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`ANTIGRAVITY_AGENT`},{type:`env_set`,name:`ANTIGRAVITY_CLI_ALIAS`}]}},{key:`AUGMENT_CLI`,name:`augment-cli`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`AUGMENT_AGENT`}]}},{key:`OPENCODE`,name:`open_code`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`OPENCODE_CLIENT`},{type:`env_set`,name:`OPENCODE`}]}},{key:`GOOSE`,name:`goose`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`GOOSE_PROVIDER`}]}},{key:`JUNIE`,name:`junie`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`JUNIE_DATA`},{type:`env_set`,name:`JUNIE_SHIM_PATH`}]}},{key:`PI`,name:`pi`,description:`Matches when the PATH contains a '.pi/agent' (or '.pi\\\\agent') segment.`,match:{type:`anyOf`,conditions:[{type:`env_matches`,name:`PATH`,pattern:`\\.pi[\\\\/]agent`}]}},{key:`COWORK`,name:`cowork`,description:"Claude Cowork. Evaluated before `claude_code` so the more specific COWORK marker wins. Requires CLAUDE_CODE_IS_COWORK plus a Claude Code marker.",match:{type:`allOf`,conditions:[{type:`env_set`,name:`CLAUDE_CODE_IS_COWORK`},{type:`anyOf`,conditions:[{type:`env_set`,name:`CLAUDECODE`},{type:`env_set`,name:`CLAUDE_CODE`}]}]}},{key:`CLAUDE`,name:`claude_code`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`CLAUDECODE`},{type:`env_set`,name:`CLAUDE_CODE`}]}},{key:`REPLIT`,name:`replit`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`REPL_ID`}]}},{key:`GITHUB_COPILOT`,name:`github-copilot`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`COPILOT_MODEL`},{type:`env_set`,name:`COPILOT_ALLOW_ALL`},{type:`env_set`,name:`COPILOT_GITHUB_TOKEN`}]}},{key:`KIRO`,name:`kiro`,description:`AWS Kiro. TERM_PROGRAM=kiro is set by both the IDE terminal and the CLI agent, so gate on no_tty to avoid misdetecting a human at the integrated terminal.`,match:{type:`allOf`,conditions:[{type:`env_matches`,name:`TERM_PROGRAM`,pattern:`kiro`},{type:`no_tty`}]}},{key:`OPENCLAW`,name:`openclaw`,match:{type:`anyOf`,conditions:[{type:`env_set`,name:`OPENCLAW_SHELL`}]}},{key:`DEVIN`,name:`devin`,match:{type:`anyOf`,conditions:[{type:`file_exists`,path:`/opt/.devin`}]}}],i=new Set(t);function a(e){return i.has(e)}function o(e,t,n){switch(e.type){case`env_set`:return!!t[e.name];case`env_value`:return t[e.name]===e.value;case`env_matches`:{let n=t[e.name];if(!n)return!1;try{return new RegExp(e.pattern).test(n)}catch{return!1}}case`no_tty`:return!n.isTTY;case`file_exists`:try{return n.fileExists(e.path)}catch{return!1}case`anyOf`:return e.conditions.some(e=>o(e,t,n));case`allOf`:return e.conditions.every(e=>o(e,t,n));default:return!1}}function s(t=process.env,i={}){try{if(t.POLITTY_NO_AGENT)return;let s=t[n]?.trim();if(s&&a(s))return{id:s,rawId:s};let c={isTTY:i.isTTY??process.stdout?.isTTY??!1,fileExists:i.fileExists??e},l=r.find(e=>o(e.match,t,c))?.name??s;return l?{id:l,rawId:s||l}:void 0}catch{return}}export{s as t};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region ../core/src/agent/known-agent-ids.d.ts
|
|
2
|
+
declare const KNOWN_AGENT_IDS: readonly ["cursor", "cursor-cli", "kimi", "grok", "gemini_cli", "cline", "codex_cli", "antigravity", "augment-cli", "open_code", "goose", "junie", "pi", "cowork", "claude_code", "replit", "github-copilot", "kiro", "openclaw", "devin"];
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region ../core/src/agent/detect-agent.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Agent name defined by the detect-agent spec (e.g. `"claude_code"`,
|
|
7
|
+
* `"codex_cli"`). Names follow upstream and may change with it.
|
|
8
|
+
*/
|
|
9
|
+
type KnownAgentId = (typeof KNOWN_AGENT_IDS)[number];
|
|
10
|
+
/**
|
|
11
|
+
* An AI coding agent detected from the environment.
|
|
12
|
+
*/
|
|
13
|
+
interface AgentInfo {
|
|
14
|
+
/**
|
|
15
|
+
* The spec's name for the agent: `AI_AGENT` when it is a known name,
|
|
16
|
+
* otherwise the first spec agent whose markers match, falling back to the
|
|
17
|
+
* custom `AI_AGENT` value when none does.
|
|
18
|
+
*/
|
|
19
|
+
id: KnownAgentId | (string & {});
|
|
20
|
+
/**
|
|
21
|
+
* The id as the detect-agent spec reports it: the trimmed `AI_AGENT` value
|
|
22
|
+
* when non-empty (e.g. `"claude-code_2-1-284_agent"`), otherwise the same as
|
|
23
|
+
* `id`.
|
|
24
|
+
*/
|
|
25
|
+
rawId: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Overrides for the non-env inputs of {@link detectAgent}, mainly for tests.
|
|
29
|
+
*/
|
|
30
|
+
interface DetectAgentOptions {
|
|
31
|
+
/** Whether stdout is a TTY (default: `process.stdout.isTTY`) */
|
|
32
|
+
isTTY?: boolean | undefined;
|
|
33
|
+
/** File existence check (default: `fs.existsSync`) */
|
|
34
|
+
fileExists?: ((path: string) => boolean) | undefined;
|
|
35
|
+
}
|
|
36
|
+
type Env = Readonly<Record<string, string | undefined>>;
|
|
37
|
+
/**
|
|
38
|
+
* Detect whether the process runs under an AI coding agent, following the
|
|
39
|
+
* [detect-agent](https://github.com/vercel/detect-agent) spec: a non-empty
|
|
40
|
+
* `AI_AGENT` (trimmed) wins as `rawId`, then the spec's agents are checked in
|
|
41
|
+
* order. `id` normalizes the result to a spec name when possible.
|
|
42
|
+
* `POLITTY_NO_AGENT` (any non-empty value) disables detection. Never throws.
|
|
43
|
+
*
|
|
44
|
+
* @param env - Environment to inspect (default: `process.env`)
|
|
45
|
+
* @returns The detected agent, or `undefined`
|
|
46
|
+
*/
|
|
47
|
+
declare function detectAgent(env?: Env, options?: DetectAgentOptions): AgentInfo | undefined;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { detectAgent as i, DetectAgentOptions as n, KnownAgentId as r, AgentInfo as t };
|