@hop-top/kit 0.5.0-alpha.6 → 0.5.0-alpha.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.
- package/CHANGELOG.md +52 -0
- package/LICENSE-cobra.txt +174 -0
- package/NOTICE +15 -0
- package/README.md +3 -3
- package/dist/alias-D9_qFlyP.d.ts +174 -0
- package/dist/alias.d.ts +1 -1
- package/dist/alias.js +10 -2
- package/dist/chunk-263IZ6Z6.js +915 -0
- package/dist/{chunk-S45UHXQF.js → chunk-BLS2OBIQ.js} +106 -25
- package/dist/{chunk-7FDIN5KE.js → chunk-GHPJJV5L.js} +8 -4
- package/dist/chunk-JKMQSAJP.js +174 -0
- package/dist/chunk-JZ22ZUFA.js +1131 -0
- package/dist/{chunk-GAZPYCQD.js → chunk-NLMS7HGP.js} +93 -35
- package/dist/chunk-QQQYCWSC.js +240 -0
- package/dist/chunk-XJTRY453.js +868 -0
- package/dist/cli.js +6 -4
- package/dist/completion-csVun6SP.d.ts +112 -0
- package/dist/completion-values-By-mnjNt.d.ts +142 -0
- package/dist/completion-values.d.ts +1 -0
- package/dist/completion-values.js +29 -0
- package/dist/completion.d.ts +2 -1
- package/dist/completion.js +23 -2
- package/dist/compliance-AxFf-uMy.d.ts +60 -0
- package/dist/compliance.d.ts +1 -0
- package/dist/compliance.js +17 -0
- package/dist/config-CaK60ByQ.d.ts +241 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.js +4 -2
- package/dist/index.d.ts +7 -5
- package/dist/index.js +26 -18
- package/dist/log-CkaxMX3U.d.ts +115 -0
- package/dist/log.d.ts +1 -1
- package/dist/log.js +2 -2
- package/dist/toolspec-UrWnoJ3Y.d.ts +336 -0
- package/dist/toolspec.d.ts +2 -1
- package/dist/toolspec.js +27 -2
- package/package.json +19 -3
- package/src/alias.conformance.test.ts +250 -0
- package/src/alias.test.ts +206 -2
- package/src/alias.ts +196 -21
- package/src/cli.ts +5 -0
- package/src/completion-scripts.ts +16 -0
- package/src/completion-values.test.ts +70 -10
- package/src/completion-values.ts +170 -66
- package/src/completion.conformance.test.ts +297 -0
- package/src/completion.test.ts +256 -145
- package/src/completion.ts +767 -121
- package/src/config-merge.test.ts +425 -0
- package/src/config.test.ts +41 -0
- package/src/config.ts +265 -18
- package/src/index.test.ts +2 -1
- package/src/index.ts +5 -1
- package/src/log.test.ts +270 -1
- package/src/log.ts +172 -44
- package/src/published-types.test.ts +18 -0
- package/src/toolspec-internal.ts +197 -0
- package/src/toolspec-manifest.test.ts +82 -0
- package/src/toolspec-manifest.ts +404 -0
- package/src/toolspec-spec-schemas.ts +12 -0
- package/src/toolspec-spec.test.ts +273 -0
- package/src/toolspec-spec.ts +458 -0
- package/src/toolspec.from-command.test.ts +216 -0
- package/src/toolspec.ts +159 -0
- package/test/toolspec/fixture.ts +73 -0
- package/dist/alias-BOj0-VAr.d.ts +0 -88
- package/dist/chunk-6RFRV4VP.js +0 -128
- package/dist/chunk-IQXEISMC.js +0 -142
- package/dist/chunk-W7ERKNSQ.js +0 -171
- package/dist/completion-CVnPcWMZ.d.ts +0 -32
- package/dist/config-Bm9fBXch.d.ts +0 -134
- package/dist/log-uKjHsK-c.d.ts +0 -62
- package/dist/toolspec-DPBr18Ub.d.ts +0 -106
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { Command as Command$1 } from 'commander';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Port of Go's `toolspec.Manifest` and `BuildManifest`
|
|
5
|
+
* (go/ai/toolspec/spec.go, go/ai/toolspec/cli/spec_command.go): the
|
|
6
|
+
* flat, snake_case capability manifest a `<tool> spec` command emits,
|
|
7
|
+
* projected from a commander tree carrying kit/* annotations.
|
|
8
|
+
*
|
|
9
|
+
* Byte parity with Go is pinned by
|
|
10
|
+
* sdk/tests/cross-lang/fixtures/toolspec-manifest*.json.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Env var a harness sets to request a manifest schema version. */
|
|
14
|
+
declare const SCHEMA_VERSION_ENV = "KIT_TOOLSPEC_SCHEMA";
|
|
15
|
+
/** Newest manifest schema version kit emits. */
|
|
16
|
+
declare const LATEST_SCHEMA_VERSION = "1.1";
|
|
17
|
+
/** Value side_effect / idempotent carry when nothing was declared. */
|
|
18
|
+
declare const SIDE_EFFECT_UNKNOWN = "unknown";
|
|
19
|
+
declare const IDEMPOTENT_UNKNOWN = "unknown";
|
|
20
|
+
interface ManifestArg {
|
|
21
|
+
name: string;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface ManifestFlag {
|
|
25
|
+
name: string;
|
|
26
|
+
short?: string;
|
|
27
|
+
type?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
default?: string;
|
|
30
|
+
since_version?: string;
|
|
31
|
+
}
|
|
32
|
+
interface ManifestExample {
|
|
33
|
+
title: string;
|
|
34
|
+
command: string;
|
|
35
|
+
output?: string;
|
|
36
|
+
}
|
|
37
|
+
interface ManifestNextStep {
|
|
38
|
+
when?: string;
|
|
39
|
+
suggest: string;
|
|
40
|
+
reason?: string;
|
|
41
|
+
}
|
|
42
|
+
/** One invocable command. Field order is the Go struct order. */
|
|
43
|
+
interface ManifestCommand {
|
|
44
|
+
path: string[];
|
|
45
|
+
short: string;
|
|
46
|
+
side_effect: string;
|
|
47
|
+
idempotent: string;
|
|
48
|
+
args?: ManifestArg[];
|
|
49
|
+
flags?: ManifestFlag[];
|
|
50
|
+
exit_codes?: string[];
|
|
51
|
+
deprecated?: boolean;
|
|
52
|
+
deprecated_since?: string;
|
|
53
|
+
removal_target?: string;
|
|
54
|
+
since_version?: string;
|
|
55
|
+
long?: string;
|
|
56
|
+
retryable: boolean;
|
|
57
|
+
/** Raw JSON Schema text, embedded verbatim (Go RawJSON). */
|
|
58
|
+
output_schema?: string;
|
|
59
|
+
output_schema_version?: string;
|
|
60
|
+
examples?: ManifestExample[];
|
|
61
|
+
next_steps?: ManifestNextStep[];
|
|
62
|
+
top_level_verb?: boolean;
|
|
63
|
+
hierarchical?: boolean;
|
|
64
|
+
passthrough?: boolean;
|
|
65
|
+
destructive_token_required?: boolean;
|
|
66
|
+
dry_run_supported: boolean;
|
|
67
|
+
dry_run_rationale?: string;
|
|
68
|
+
reserved?: boolean;
|
|
69
|
+
hidden?: boolean;
|
|
70
|
+
}
|
|
71
|
+
interface Manifest {
|
|
72
|
+
tool: string;
|
|
73
|
+
version: string;
|
|
74
|
+
schema_version: string;
|
|
75
|
+
commands: ManifestCommand[];
|
|
76
|
+
}
|
|
77
|
+
interface BuildManifestOptions {
|
|
78
|
+
/** Include deprecated commands (Go --include-deprecated). */
|
|
79
|
+
includeDeprecated?: boolean;
|
|
80
|
+
/** Depth-1 verbs the tool reserves (Go Root.IsReserved). */
|
|
81
|
+
reserved?: Iterable<string>;
|
|
82
|
+
/**
|
|
83
|
+
* The command being executed, if any. It gets the -h/--help flag
|
|
84
|
+
* cobra adds to the executing command, as a live Go run lists.
|
|
85
|
+
*/
|
|
86
|
+
invokedCommand?: Command$1;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Resolve the emitted schema_version (Go NegotiateSchemaVersion):
|
|
90
|
+
* declared is a floor; a well-formed request raises it to the highest
|
|
91
|
+
* known version not above the request; nothing is ever refused.
|
|
92
|
+
*/
|
|
93
|
+
declare function negotiateSchemaVersion(declared: string, requested: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Project a commander tree into the Go-shaped Manifest (Go
|
|
96
|
+
* BuildManifest). Lists every runnable command except framework
|
|
97
|
+
* builtins (help, completion, man) and, unless includeDeprecated,
|
|
98
|
+
* deprecated ones; hidden and reserved commands stay listed and say
|
|
99
|
+
* so. Children are visited in name order and flags sorted by name,
|
|
100
|
+
* as cobra and pflag do by default.
|
|
101
|
+
*/
|
|
102
|
+
declare function buildManifest(program: Command$1, schemaVersion: string, opts?: BuildManifestOptions): Manifest;
|
|
103
|
+
/**
|
|
104
|
+
* Render a Manifest exactly as Go's `output.Render(w, "json", m)`:
|
|
105
|
+
* two-space indent, HTML-escaped strings, trailing newline, fields
|
|
106
|
+
* in Go struct order with omitempty applied.
|
|
107
|
+
*/
|
|
108
|
+
declare function renderManifestJSON(m: Manifest): string;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Port of Go's `<tool> spec` subcommand and `spec coverage`
|
|
112
|
+
* (go/ai/toolspec/cli/spec_command.go, coverage.go,
|
|
113
|
+
* coverage_command.go). Output bytes for json / kit-manifest are
|
|
114
|
+
* pinned against Go by sdk/tests/cross-lang/fixtures/toolspec-spec*.json.
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
/** Annotation marking kit's spec subcommands (Go specCommandAnnotation). */
|
|
118
|
+
declare const SPEC_COMMAND_ANNOTATION = "kit/spec-command";
|
|
119
|
+
interface RegisterSpecOptions {
|
|
120
|
+
/** Depth-1 verbs the tool reserves; "spec" is always added. */
|
|
121
|
+
reserved?: Iterable<string>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Attach a `spec` subcommand emitting the tool's capability manifest
|
|
125
|
+
* (Go RegisterSpecCommand). Call once after registering every
|
|
126
|
+
* command.
|
|
127
|
+
*
|
|
128
|
+
* - `--format`: `kit-manifest` (default; aliases `kit`, `manifest`)
|
|
129
|
+
* and `json` emit Go-identical JSON; `yaml` emits the same document
|
|
130
|
+
* as YAML; `table`/`csv`/`text` emit nothing, as Go does today.
|
|
131
|
+
* The program's global `--format` is used when it has one,
|
|
132
|
+
* otherwise spec adds its own.
|
|
133
|
+
* - `--version`: print only the schema version.
|
|
134
|
+
* - `--include-deprecated`: list deprecated commands too.
|
|
135
|
+
*
|
|
136
|
+
* schemaVersion is a floor: each run resolves the emitted version
|
|
137
|
+
* against KIT_TOOLSPEC_SCHEMA (negotiateSchemaVersion).
|
|
138
|
+
*
|
|
139
|
+
* commander parses a program's own options anywhere on the line, so
|
|
140
|
+
* a program-level `--version` (commander `.version()`, which
|
|
141
|
+
* createCLI sets) would answer `spec --version` with the tool
|
|
142
|
+
* version. The program's version listener is wrapped so a literal
|
|
143
|
+
* `--version` is forwarded to spec when spec is the command being
|
|
144
|
+
* executed; `tool --version`, `-v`, and `--version` on any other
|
|
145
|
+
* command keep commander's behaviour. See forwardVersionToSpec.
|
|
146
|
+
*/
|
|
147
|
+
declare function registerSpecCommand(program: Command$1, schemaVersion: string, opts?: RegisterSpecOptions): Command$1;
|
|
148
|
+
/** Go CoverageReport: annotation coverage over a command tree. */
|
|
149
|
+
interface CoverageReport {
|
|
150
|
+
tool: string;
|
|
151
|
+
total: number;
|
|
152
|
+
annotated: number;
|
|
153
|
+
unannotated: number;
|
|
154
|
+
inferred: number;
|
|
155
|
+
malformed: number;
|
|
156
|
+
unannotated_paths?: string[];
|
|
157
|
+
malformed_paths?: string[];
|
|
158
|
+
measurable: boolean;
|
|
159
|
+
}
|
|
160
|
+
interface CoverageOptions {
|
|
161
|
+
/** Depth-1 verbs the tool reserves (not measured). */
|
|
162
|
+
reserved?: Iterable<string>;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Measure kit/side-effect annotation coverage (Go CoverageOf):
|
|
166
|
+
* runnable commands, excluding framework builtins, reserved verbs and
|
|
167
|
+
* kit's spec commands. Deprecated and hidden commands count.
|
|
168
|
+
*/
|
|
169
|
+
declare function coverageOf(program: Command$1, opts?: CoverageOptions): CoverageReport;
|
|
170
|
+
|
|
171
|
+
type SafetyLevel = "safe" | "caution" | "dangerous";
|
|
172
|
+
interface Contract {
|
|
173
|
+
idempotent: boolean;
|
|
174
|
+
sideEffects?: string[];
|
|
175
|
+
retryable: boolean;
|
|
176
|
+
preConditions?: string[];
|
|
177
|
+
}
|
|
178
|
+
interface Safety {
|
|
179
|
+
level: SafetyLevel;
|
|
180
|
+
requiresConfirmation?: boolean;
|
|
181
|
+
permissions?: string[];
|
|
182
|
+
}
|
|
183
|
+
interface OutputSchema {
|
|
184
|
+
format?: string;
|
|
185
|
+
fields?: string[];
|
|
186
|
+
example?: string;
|
|
187
|
+
}
|
|
188
|
+
interface StateIntrospection {
|
|
189
|
+
configCommands?: string[];
|
|
190
|
+
envVars?: string[];
|
|
191
|
+
authCommands?: string[];
|
|
192
|
+
}
|
|
193
|
+
interface Provenance {
|
|
194
|
+
source?: string;
|
|
195
|
+
retrievedAt?: string;
|
|
196
|
+
confidence?: number;
|
|
197
|
+
}
|
|
198
|
+
interface Intent {
|
|
199
|
+
domain?: string;
|
|
200
|
+
category?: string;
|
|
201
|
+
tags?: string[];
|
|
202
|
+
}
|
|
203
|
+
interface Flag {
|
|
204
|
+
name: string;
|
|
205
|
+
short?: string;
|
|
206
|
+
type?: string;
|
|
207
|
+
description?: string;
|
|
208
|
+
/** Flag must be supplied (commander `makeOptionMandatory`). */
|
|
209
|
+
required?: boolean;
|
|
210
|
+
deprecated?: boolean;
|
|
211
|
+
replacedBy?: string;
|
|
212
|
+
}
|
|
213
|
+
/** A declared positional argument (mirrors Go toolspec.Arg). */
|
|
214
|
+
interface Arg {
|
|
215
|
+
name: string;
|
|
216
|
+
/** False/absent for an optional argument. */
|
|
217
|
+
required?: boolean;
|
|
218
|
+
}
|
|
219
|
+
interface Command {
|
|
220
|
+
name: string;
|
|
221
|
+
/** One-line summary of the command. */
|
|
222
|
+
short?: string;
|
|
223
|
+
aliases?: string[];
|
|
224
|
+
flags?: Flag[];
|
|
225
|
+
/** Declared positional arguments, in order. */
|
|
226
|
+
args?: Arg[];
|
|
227
|
+
/** Command takes positional arguments it does not declare. */
|
|
228
|
+
undeclaredArgs?: boolean;
|
|
229
|
+
/** Exit-code symbols the command may produce (kit/exit-codes). */
|
|
230
|
+
exitCodes?: string[];
|
|
231
|
+
children?: Command[];
|
|
232
|
+
contract?: Contract;
|
|
233
|
+
safety?: Safety;
|
|
234
|
+
previewModes?: string[];
|
|
235
|
+
outputSchema?: OutputSchema;
|
|
236
|
+
deprecated?: boolean;
|
|
237
|
+
deprecatedSince?: string;
|
|
238
|
+
replacedBy?: string;
|
|
239
|
+
intent?: Intent;
|
|
240
|
+
suggestedNext?: string[];
|
|
241
|
+
}
|
|
242
|
+
interface ErrorPattern {
|
|
243
|
+
pattern: string;
|
|
244
|
+
fix: string;
|
|
245
|
+
source?: string;
|
|
246
|
+
cause?: string;
|
|
247
|
+
fixes?: string[];
|
|
248
|
+
confidence?: number;
|
|
249
|
+
provenance?: Provenance;
|
|
250
|
+
}
|
|
251
|
+
interface Workflow {
|
|
252
|
+
name: string;
|
|
253
|
+
steps: string[];
|
|
254
|
+
after?: Record<string, string[]>;
|
|
255
|
+
provenance?: Provenance;
|
|
256
|
+
}
|
|
257
|
+
interface ToolSpec {
|
|
258
|
+
name: string;
|
|
259
|
+
schemaVersion: string;
|
|
260
|
+
commands: Command[];
|
|
261
|
+
flags?: Flag[];
|
|
262
|
+
errorPatterns?: ErrorPattern[];
|
|
263
|
+
workflows?: Workflow[];
|
|
264
|
+
stateIntrospection?: StateIntrospection;
|
|
265
|
+
}
|
|
266
|
+
/** Parse a YAML toolspec file into a ToolSpec object. */
|
|
267
|
+
declare function loadToolSpec(yamlPath: string): ToolSpec;
|
|
268
|
+
/** Validate a ToolSpec, returning a list of error strings. */
|
|
269
|
+
declare function validateToolSpec(spec: ToolSpec): string[];
|
|
270
|
+
/** BFS search for a command by name (mirrors Go FindCommand). */
|
|
271
|
+
declare function findCommand(spec: ToolSpec, name: string): Command | undefined;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Per-command fields merged over what the commander tree yields.
|
|
275
|
+
* Structural fields (name, aliases, flags, args, children) always
|
|
276
|
+
* come from the tree.
|
|
277
|
+
*/
|
|
278
|
+
type CommandAnnotation = Omit<Partial<Command>, "name" | "aliases" | "flags" | "args" | "children">;
|
|
279
|
+
interface FromCommandOptions {
|
|
280
|
+
/** Annotations keyed by space-joined path below the root, e.g. "mission list". */
|
|
281
|
+
annotations?: Record<string, CommandAnnotation>;
|
|
282
|
+
/** Defaults to "1", the version the YAML toolspecs declare. */
|
|
283
|
+
schemaVersion?: string;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Build a ToolSpec from a constructed commander tree, so CLIs with
|
|
287
|
+
* dynamically registered subcommands need no hand-synced YAML.
|
|
288
|
+
* Mirrors Go's WalkCobra projection: hidden commands and options are
|
|
289
|
+
* omitted, flag names are undashed, root options become spec.flags.
|
|
290
|
+
*/
|
|
291
|
+
declare function toolSpecFromCommand(program: Command$1, opts?: FromCommandOptions): ToolSpec;
|
|
292
|
+
|
|
293
|
+
type toolspec_Arg = Arg;
|
|
294
|
+
type toolspec_BuildManifestOptions = BuildManifestOptions;
|
|
295
|
+
type toolspec_Command = Command;
|
|
296
|
+
type toolspec_CommandAnnotation = CommandAnnotation;
|
|
297
|
+
type toolspec_Contract = Contract;
|
|
298
|
+
type toolspec_CoverageOptions = CoverageOptions;
|
|
299
|
+
type toolspec_CoverageReport = CoverageReport;
|
|
300
|
+
type toolspec_ErrorPattern = ErrorPattern;
|
|
301
|
+
type toolspec_Flag = Flag;
|
|
302
|
+
type toolspec_FromCommandOptions = FromCommandOptions;
|
|
303
|
+
declare const toolspec_IDEMPOTENT_UNKNOWN: typeof IDEMPOTENT_UNKNOWN;
|
|
304
|
+
type toolspec_Intent = Intent;
|
|
305
|
+
declare const toolspec_LATEST_SCHEMA_VERSION: typeof LATEST_SCHEMA_VERSION;
|
|
306
|
+
type toolspec_Manifest = Manifest;
|
|
307
|
+
type toolspec_ManifestArg = ManifestArg;
|
|
308
|
+
type toolspec_ManifestCommand = ManifestCommand;
|
|
309
|
+
type toolspec_ManifestExample = ManifestExample;
|
|
310
|
+
type toolspec_ManifestFlag = ManifestFlag;
|
|
311
|
+
type toolspec_ManifestNextStep = ManifestNextStep;
|
|
312
|
+
type toolspec_OutputSchema = OutputSchema;
|
|
313
|
+
type toolspec_Provenance = Provenance;
|
|
314
|
+
type toolspec_RegisterSpecOptions = RegisterSpecOptions;
|
|
315
|
+
declare const toolspec_SCHEMA_VERSION_ENV: typeof SCHEMA_VERSION_ENV;
|
|
316
|
+
declare const toolspec_SIDE_EFFECT_UNKNOWN: typeof SIDE_EFFECT_UNKNOWN;
|
|
317
|
+
declare const toolspec_SPEC_COMMAND_ANNOTATION: typeof SPEC_COMMAND_ANNOTATION;
|
|
318
|
+
type toolspec_Safety = Safety;
|
|
319
|
+
type toolspec_SafetyLevel = SafetyLevel;
|
|
320
|
+
type toolspec_StateIntrospection = StateIntrospection;
|
|
321
|
+
type toolspec_ToolSpec = ToolSpec;
|
|
322
|
+
type toolspec_Workflow = Workflow;
|
|
323
|
+
declare const toolspec_buildManifest: typeof buildManifest;
|
|
324
|
+
declare const toolspec_coverageOf: typeof coverageOf;
|
|
325
|
+
declare const toolspec_findCommand: typeof findCommand;
|
|
326
|
+
declare const toolspec_loadToolSpec: typeof loadToolSpec;
|
|
327
|
+
declare const toolspec_negotiateSchemaVersion: typeof negotiateSchemaVersion;
|
|
328
|
+
declare const toolspec_registerSpecCommand: typeof registerSpecCommand;
|
|
329
|
+
declare const toolspec_renderManifestJSON: typeof renderManifestJSON;
|
|
330
|
+
declare const toolspec_toolSpecFromCommand: typeof toolSpecFromCommand;
|
|
331
|
+
declare const toolspec_validateToolSpec: typeof validateToolSpec;
|
|
332
|
+
declare namespace toolspec {
|
|
333
|
+
export { type toolspec_Arg as Arg, type toolspec_BuildManifestOptions as BuildManifestOptions, type toolspec_Command as Command, type toolspec_CommandAnnotation as CommandAnnotation, type toolspec_Contract as Contract, type toolspec_CoverageOptions as CoverageOptions, type toolspec_CoverageReport as CoverageReport, type toolspec_ErrorPattern as ErrorPattern, type toolspec_Flag as Flag, type toolspec_FromCommandOptions as FromCommandOptions, toolspec_IDEMPOTENT_UNKNOWN as IDEMPOTENT_UNKNOWN, type toolspec_Intent as Intent, toolspec_LATEST_SCHEMA_VERSION as LATEST_SCHEMA_VERSION, type toolspec_Manifest as Manifest, type toolspec_ManifestArg as ManifestArg, type toolspec_ManifestCommand as ManifestCommand, type toolspec_ManifestExample as ManifestExample, type toolspec_ManifestFlag as ManifestFlag, type toolspec_ManifestNextStep as ManifestNextStep, type toolspec_OutputSchema as OutputSchema, type toolspec_Provenance as Provenance, type toolspec_RegisterSpecOptions as RegisterSpecOptions, toolspec_SCHEMA_VERSION_ENV as SCHEMA_VERSION_ENV, toolspec_SIDE_EFFECT_UNKNOWN as SIDE_EFFECT_UNKNOWN, toolspec_SPEC_COMMAND_ANNOTATION as SPEC_COMMAND_ANNOTATION, type toolspec_Safety as Safety, type toolspec_SafetyLevel as SafetyLevel, type toolspec_StateIntrospection as StateIntrospection, type toolspec_ToolSpec as ToolSpec, type toolspec_Workflow as Workflow, toolspec_buildManifest as buildManifest, toolspec_coverageOf as coverageOf, toolspec_findCommand as findCommand, toolspec_loadToolSpec as loadToolSpec, toolspec_negotiateSchemaVersion as negotiateSchemaVersion, toolspec_registerSpecCommand as registerSpecCommand, toolspec_renderManifestJSON as renderManifestJSON, toolspec_toolSpecFromCommand as toolSpecFromCommand, toolspec_validateToolSpec as validateToolSpec };
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export { type Arg as A, type BuildManifestOptions as B, type Command as C, type ErrorPattern as E, type Flag as F, IDEMPOTENT_UNKNOWN as I, LATEST_SCHEMA_VERSION as L, type Manifest as M, type OutputSchema as O, type Provenance as P, type RegisterSpecOptions as R, SCHEMA_VERSION_ENV as S, type ToolSpec as T, type Workflow as W, type CommandAnnotation as a, type Contract as b, type CoverageOptions as c, type CoverageReport as d, type FromCommandOptions as e, type Intent as f, type ManifestArg as g, type ManifestCommand as h, type ManifestExample as i, type ManifestFlag as j, type ManifestNextStep as k, SIDE_EFFECT_UNKNOWN as l, SPEC_COMMAND_ANNOTATION as m, type Safety as n, type SafetyLevel as o, type StateIntrospection as p, buildManifest as q, coverageOf as r, findCommand as s, toolspec as t, loadToolSpec as u, negotiateSchemaVersion as v, registerSpecCommand as w, renderManifestJSON as x, toolSpecFromCommand as y, validateToolSpec as z };
|
package/dist/toolspec.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import 'commander';
|
|
2
|
+
export { A as Arg, B as BuildManifestOptions, C as Command, a as CommandAnnotation, b as Contract, c as CoverageOptions, d as CoverageReport, E as ErrorPattern, F as Flag, e as FromCommandOptions, I as IDEMPOTENT_UNKNOWN, f as Intent, L as LATEST_SCHEMA_VERSION, M as Manifest, g as ManifestArg, h as ManifestCommand, i as ManifestExample, j as ManifestFlag, k as ManifestNextStep, O as OutputSchema, P as Provenance, R as RegisterSpecOptions, S as SCHEMA_VERSION_ENV, l as SIDE_EFFECT_UNKNOWN, m as SPEC_COMMAND_ANNOTATION, n as Safety, o as SafetyLevel, p as StateIntrospection, T as ToolSpec, W as Workflow, q as buildManifest, r as coverageOf, s as findCommand, u as loadToolSpec, v as negotiateSchemaVersion, w as registerSpecCommand, x as renderManifestJSON, y as toolSpecFromCommand, z as validateToolSpec } from './toolspec-UrWnoJ3Y.js';
|
package/dist/toolspec.js
CHANGED
|
@@ -2,10 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var _chunk263IZ6Z6js = require('./chunk-263IZ6Z6.js');
|
|
17
|
+
require('./chunk-IXVQ62NZ.js');
|
|
18
|
+
require('./chunk-72XZWQX7.js');
|
|
19
|
+
require('./chunk-POR5L2DG.js');
|
|
6
20
|
require('./chunk-R5U7XKVJ.js');
|
|
7
21
|
|
|
8
22
|
|
|
9
23
|
|
|
10
24
|
|
|
11
|
-
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
exports.IDEMPOTENT_UNKNOWN = _chunk263IZ6Z6js.IDEMPOTENT_UNKNOWN; exports.LATEST_SCHEMA_VERSION = _chunk263IZ6Z6js.LATEST_SCHEMA_VERSION; exports.SCHEMA_VERSION_ENV = _chunk263IZ6Z6js.SCHEMA_VERSION_ENV; exports.SIDE_EFFECT_UNKNOWN = _chunk263IZ6Z6js.SIDE_EFFECT_UNKNOWN; exports.SPEC_COMMAND_ANNOTATION = _chunk263IZ6Z6js.SPEC_COMMAND_ANNOTATION; exports.buildManifest = _chunk263IZ6Z6js.buildManifest; exports.coverageOf = _chunk263IZ6Z6js.coverageOf; exports.findCommand = _chunk263IZ6Z6js.findCommand; exports.loadToolSpec = _chunk263IZ6Z6js.loadToolSpec; exports.negotiateSchemaVersion = _chunk263IZ6Z6js.negotiateSchemaVersion; exports.registerSpecCommand = _chunk263IZ6Z6js.registerSpecCommand; exports.renderManifestJSON = _chunk263IZ6Z6js.renderManifestJSON; exports.toolSpecFromCommand = _chunk263IZ6Z6js.toolSpecFromCommand; exports.validateToolSpec = _chunk263IZ6Z6js.validateToolSpec;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hop-top/kit",
|
|
3
|
-
"version": "0.5.0-alpha.
|
|
3
|
+
"version": "0.5.0-alpha.8",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/hop-top/poly-kit.git",
|
|
@@ -165,6 +165,16 @@
|
|
|
165
165
|
"types": "./dist/toolspec.d.ts",
|
|
166
166
|
"require": "./dist/toolspec.js",
|
|
167
167
|
"default": "./dist/toolspec.js"
|
|
168
|
+
},
|
|
169
|
+
"./completion-values": {
|
|
170
|
+
"types": "./dist/completion-values.d.ts",
|
|
171
|
+
"require": "./dist/completion-values.js",
|
|
172
|
+
"default": "./dist/completion-values.js"
|
|
173
|
+
},
|
|
174
|
+
"./compliance": {
|
|
175
|
+
"types": "./dist/compliance.d.ts",
|
|
176
|
+
"require": "./dist/compliance.js",
|
|
177
|
+
"default": "./dist/compliance.js"
|
|
168
178
|
}
|
|
169
179
|
},
|
|
170
180
|
"typesVersions": {
|
|
@@ -258,6 +268,12 @@
|
|
|
258
268
|
],
|
|
259
269
|
"toolspec": [
|
|
260
270
|
"./dist/toolspec.d.ts"
|
|
271
|
+
],
|
|
272
|
+
"completion-values": [
|
|
273
|
+
"./dist/completion-values.d.ts"
|
|
274
|
+
],
|
|
275
|
+
"compliance": [
|
|
276
|
+
"./dist/compliance.d.ts"
|
|
261
277
|
]
|
|
262
278
|
}
|
|
263
279
|
},
|
|
@@ -278,7 +294,7 @@
|
|
|
278
294
|
"@modelcontextprotocol/core": "2.3.1",
|
|
279
295
|
"@modelcontextprotocol/server": "2.3.1",
|
|
280
296
|
"better-sqlite3": "^12.11.1",
|
|
281
|
-
"commander": "
|
|
297
|
+
"commander": "15.0.0",
|
|
282
298
|
"csv-stringify": "^6.9.0",
|
|
283
299
|
"eta": "^4.6.0",
|
|
284
300
|
"hono": "^4.13.13",
|
|
@@ -308,7 +324,7 @@
|
|
|
308
324
|
},
|
|
309
325
|
"license": "MIT",
|
|
310
326
|
"scripts": {
|
|
311
|
-
"build": "tsup src/index.ts src/alias.ts src/cli.ts src/output.ts src/xdg.ts src/config.ts src/sqlstore.ts src/upgrade.ts src/llm.ts src/llm-anthropic.ts src/llm-openai.ts src/routellm.ts src/tui/index.ts src/errcorrect.ts src/safety.ts src/provenance.ts src/stream.ts src/progress.ts src/auth.ts src/api.ts src/rpc.ts src/aim.ts src/netpolicy.ts src/scope.ts src/serve.ts src/telemetry/index.ts src/id/index.ts src/mcp/index.ts src/log.ts src/completion.ts src/toolspec.ts --format cjs --splitting --dts",
|
|
327
|
+
"build": "tsup src/index.ts src/alias.ts src/cli.ts src/output.ts src/xdg.ts src/config.ts src/sqlstore.ts src/upgrade.ts src/llm.ts src/llm-anthropic.ts src/llm-openai.ts src/routellm.ts src/tui/index.ts src/errcorrect.ts src/safety.ts src/provenance.ts src/stream.ts src/progress.ts src/auth.ts src/api.ts src/rpc.ts src/aim.ts src/netpolicy.ts src/scope.ts src/serve.ts src/telemetry/index.ts src/id/index.ts src/mcp/index.ts src/log.ts src/completion.ts src/toolspec.ts src/completion-values.ts src/compliance.ts --format cjs --splitting --dts",
|
|
312
328
|
"lint": "eslint src/",
|
|
313
329
|
"lint:fix": "eslint src/ --fix",
|
|
314
330
|
"typecheck": "tsc --noEmit -p tsconfig.json && tsc -p tsconfig.test.json",
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// Runs the shared alias corpus in contracts/alias-v1. The vectors are
|
|
2
|
+
// the source of truth: a failure means this port drifted from the
|
|
3
|
+
// contract, not that a vector should be edited to fit.
|
|
4
|
+
//
|
|
5
|
+
// Strict: unknown fields fail, `version` must be `v1` and every JSON
|
|
6
|
+
// file in the corpus must have a runner here.
|
|
7
|
+
|
|
8
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
import { Command, CommanderError } from 'commander';
|
|
11
|
+
import { describe, expect, it } from 'vitest';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
AliasNameError, type AliasMap, type BridgeOptions,
|
|
15
|
+
bridgeAliases, detectCycles, findCommand, validateAliasName,
|
|
16
|
+
} from './alias';
|
|
17
|
+
import { completeRequest } from './completion';
|
|
18
|
+
|
|
19
|
+
const PORT = 'ts';
|
|
20
|
+
const CORPUS = join(__dirname, '..', '..', '..', 'contracts', 'alias-v1');
|
|
21
|
+
const FILES = ['bridge.json', 'cycles.json', 'validate.json'];
|
|
22
|
+
|
|
23
|
+
function strictKeys(o: object, allowed: string[], where: string): void {
|
|
24
|
+
for (const k of Object.keys(o)) {
|
|
25
|
+
if (!allowed.includes(k)) throw new Error(`${where}: unknown field ${k}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function load<T>(name: string, top: string[]): T {
|
|
30
|
+
for (const n of readdirSync(CORPUS)) {
|
|
31
|
+
if (n.endsWith('.json') && !FILES.includes(n)) {
|
|
32
|
+
throw new Error(`${n} has no runner`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const f = JSON.parse(readFileSync(join(CORPUS, name), 'utf8'));
|
|
36
|
+
strictKeys(f, ['version', 'description', 'cases', ...top], name);
|
|
37
|
+
if (f.version !== 'v1') throw new Error(`${name}: version ${f.version}`);
|
|
38
|
+
if (!Array.isArray(f.cases) || f.cases.length === 0) {
|
|
39
|
+
throw new Error(`${name}: cases section is empty`);
|
|
40
|
+
}
|
|
41
|
+
return f as T;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ── validate.json ───────────────────────────────────────────
|
|
45
|
+
|
|
46
|
+
interface ValidateCase {
|
|
47
|
+
name: string; alias: string; builtins?: string[];
|
|
48
|
+
existing?: AliasMap; expect: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
describe('alias-v1 validate', () => {
|
|
52
|
+
const f = load<{ cases: ValidateCase[] }>('validate.json', []);
|
|
53
|
+
for (const c of f.cases) {
|
|
54
|
+
it(c.name, () => {
|
|
55
|
+
strictKeys(c, ['name', 'alias', 'builtins', 'existing', 'expect'], c.name);
|
|
56
|
+
let got = 'ok';
|
|
57
|
+
try {
|
|
58
|
+
validateAliasName(c.alias, { builtins: c.builtins, existing: c.existing });
|
|
59
|
+
} catch (e) {
|
|
60
|
+
expect(e).toBeInstanceOf(AliasNameError);
|
|
61
|
+
got = (e as AliasNameError).kind;
|
|
62
|
+
}
|
|
63
|
+
expect(got).toBe(c.expect);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// ── cycles.json ─────────────────────────────────────────────
|
|
69
|
+
|
|
70
|
+
describe('alias-v1 cycles', () => {
|
|
71
|
+
const f = load<{ cases: { name: string; aliases: AliasMap; cycles: string[][] }[] }>(
|
|
72
|
+
'cycles.json', [],
|
|
73
|
+
);
|
|
74
|
+
for (const c of f.cases) {
|
|
75
|
+
it(c.name, () => {
|
|
76
|
+
strictKeys(c, ['name', 'aliases', 'cycles'], c.name);
|
|
77
|
+
expect(detectCycles(c.aliases)).toEqual(c.cycles);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// ── bridge.json ─────────────────────────────────────────────
|
|
83
|
+
|
|
84
|
+
interface Node {
|
|
85
|
+
name: string; description: string;
|
|
86
|
+
flags?: { name: string; default: string }[];
|
|
87
|
+
commands?: Node[];
|
|
88
|
+
}
|
|
89
|
+
interface Entry { kind: string; hidden?: boolean; description?: string }
|
|
90
|
+
interface Run {
|
|
91
|
+
ran: string; path?: string; env?: string | null; args?: string[];
|
|
92
|
+
name?: string; target?: string;
|
|
93
|
+
}
|
|
94
|
+
interface Check {
|
|
95
|
+
alias?: string; argv?: string[]; entry?: Entry; run?: Run; help?: string;
|
|
96
|
+
complete?: string[]; candidates?: string[];
|
|
97
|
+
by_port?: Record<string, Partial<Check>>;
|
|
98
|
+
}
|
|
99
|
+
interface BridgeCase {
|
|
100
|
+
name: string; aliases: AliasMap;
|
|
101
|
+
options?: { hidden?: boolean; describe?: boolean; help?: string; dispatch?: string };
|
|
102
|
+
skip?: Record<string, string>;
|
|
103
|
+
proxy_flags?: { name: string; short: string }[];
|
|
104
|
+
checks: Check[];
|
|
105
|
+
}
|
|
106
|
+
interface BridgeFile {
|
|
107
|
+
tree: Node; describe_template: string; cases: BridgeCase[];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// What a target or handler saw.
|
|
111
|
+
interface Seen {
|
|
112
|
+
ran: string; path?: string; env?: string | null; args?: string[];
|
|
113
|
+
name?: string; target?: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function build(
|
|
117
|
+
parent: Command, nodes: Node[], prefix: string, rec: { r: Seen },
|
|
118
|
+
descs: Map<string, string>,
|
|
119
|
+
): void {
|
|
120
|
+
for (const n of nodes) {
|
|
121
|
+
strictKeys(n, ['name', 'description', 'flags', 'commands'], n.name);
|
|
122
|
+
const path = `${prefix} ${n.name}`.trim();
|
|
123
|
+
descs.set(path, n.description);
|
|
124
|
+
const c = parent.command(n.name).description(n.description);
|
|
125
|
+
const hasEnv = (n.flags ?? []).some(fl => fl.name === 'env');
|
|
126
|
+
for (const fl of n.flags ?? []) c.option(`--${fl.name} <v>`, '', fl.default);
|
|
127
|
+
if (!n.commands?.length) {
|
|
128
|
+
c.argument('[args...]').action((args: string[], opts: Record<string, string>) => {
|
|
129
|
+
rec.r = { ran: 'target', path, env: hasEnv ? opts.env : null, args };
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
build(c, n.commands ?? [], path, rec, descs);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function bridgeOptions(f: BridgeFile, c: BridgeCase, rec: { r: Seen }): BridgeOptions | undefined {
|
|
137
|
+
const o = c.options;
|
|
138
|
+
if (!o) return undefined;
|
|
139
|
+
strictKeys(o, ['hidden', 'describe', 'help', 'dispatch'], c.name);
|
|
140
|
+
const opts: BridgeOptions = {};
|
|
141
|
+
if (o.hidden !== undefined) opts.hidden = o.hidden;
|
|
142
|
+
if (o.describe) {
|
|
143
|
+
opts.describe = (name, target) =>
|
|
144
|
+
f.describe_template.replace('{name}', name).replace('{target}', target);
|
|
145
|
+
}
|
|
146
|
+
if (o.help === 'own') opts.helpOption = true;
|
|
147
|
+
else if (o.help === 'passthrough') opts.helpOption = false;
|
|
148
|
+
else if (o.help !== undefined) throw new Error(`unknown help ${o.help}`);
|
|
149
|
+
if (o.dispatch === 'handler') {
|
|
150
|
+
opts.dispatch = (name, target, cmd) => {
|
|
151
|
+
rec.r = { ran: 'handler', name, target, args: [...cmd.args] };
|
|
152
|
+
};
|
|
153
|
+
} else if (o.dispatch === 'register-only') {
|
|
154
|
+
opts.dispatch = false;
|
|
155
|
+
} else if (o.dispatch !== undefined) {
|
|
156
|
+
throw new Error(`unknown dispatch ${o.dispatch}`);
|
|
157
|
+
}
|
|
158
|
+
return opts;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
describe('alias-v1 bridge', () => {
|
|
162
|
+
const f = load<BridgeFile>('bridge.json', ['tree', 'describe_template']);
|
|
163
|
+
|
|
164
|
+
function setup(c: BridgeCase) {
|
|
165
|
+
const rec: { r: Seen } = { r: { ran: 'none' } };
|
|
166
|
+
const descs = new Map<string, string>();
|
|
167
|
+
let out = '';
|
|
168
|
+
const program = new Command(f.tree.name)
|
|
169
|
+
.exitOverride()
|
|
170
|
+
.configureOutput({ writeOut: s => { out += s; }, writeErr: s => { out += s; } });
|
|
171
|
+
build(program, f.tree.commands ?? [], '', rec, descs);
|
|
172
|
+
const sorted = Object.fromEntries(Object.entries(c.aliases).sort(([a], [b]) => (a < b ? -1 : 1)));
|
|
173
|
+
bridgeAliases(program, sorted, bridgeOptions(f, c, rec));
|
|
174
|
+
for (const fl of c.proxy_flags ?? []) {
|
|
175
|
+
strictKeys(fl, ['name', 'short'], c.name);
|
|
176
|
+
for (const alias of Object.keys(c.aliases)) {
|
|
177
|
+
const proxy = program.commands.find(x => x.name() === alias);
|
|
178
|
+
if (!proxy) throw new Error(`${c.name}: ${alias} has no proxy`);
|
|
179
|
+
proxy.option(`-${fl.short}, --${fl.name} <v>`, fl.name);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return { program, rec, descs, output: () => out };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
for (const c of f.cases) {
|
|
186
|
+
const skip = c.skip?.[PORT];
|
|
187
|
+
(skip ? it.skip : it)(skip ? `${c.name} (${skip})` : c.name, async () => {
|
|
188
|
+
strictKeys(c, ['name', 'aliases', 'options', 'skip', 'proxy_flags', 'checks'], c.name);
|
|
189
|
+
for (const raw of c.checks) {
|
|
190
|
+
strictKeys(
|
|
191
|
+
raw, ['alias', 'argv', 'entry', 'run', 'help', 'complete', 'candidates', 'by_port'], c.name,
|
|
192
|
+
);
|
|
193
|
+
const chk: Check = { ...raw, ...(raw.by_port?.[PORT] ?? {}) };
|
|
194
|
+
const { program, rec, descs, output } = setup(c);
|
|
195
|
+
|
|
196
|
+
if (chk.entry) {
|
|
197
|
+
const alias = chk.alias!;
|
|
198
|
+
const proxy = program.commands.find(x => x.name() === alias);
|
|
199
|
+
if (proxy) {
|
|
200
|
+
expect(chk.entry.kind, alias).toBe('proxy');
|
|
201
|
+
if (chk.entry.hidden !== undefined) {
|
|
202
|
+
expect((proxy as unknown as { _hidden: boolean })._hidden, alias)
|
|
203
|
+
.toBe(chk.entry.hidden);
|
|
204
|
+
}
|
|
205
|
+
if (chk.entry.description !== undefined) {
|
|
206
|
+
expect(proxy.description(), alias).toBe(chk.entry.description);
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
const target = findCommand(program, c.aliases[alias]);
|
|
210
|
+
expect(target?.aliases().includes(alias) ? 'native' : 'missing', alias)
|
|
211
|
+
.toBe(chk.entry.kind);
|
|
212
|
+
}
|
|
213
|
+
} else if (chk.run) {
|
|
214
|
+
await program.parseAsync(chk.argv!, { from: 'user' });
|
|
215
|
+
const r = rec.r;
|
|
216
|
+
expect(r.ran, chk.argv!.join(' ')).toBe(chk.run.ran);
|
|
217
|
+
if (chk.run.ran === 'target') {
|
|
218
|
+
expect({ path: r.path, env: r.env, args: r.args })
|
|
219
|
+
.toEqual({ path: chk.run.path, env: chk.run.env, args: chk.run.args });
|
|
220
|
+
} else if (chk.run.ran === 'handler') {
|
|
221
|
+
expect({ name: r.name, target: r.target, args: r.args })
|
|
222
|
+
.toEqual({ name: chk.run.name, target: chk.run.target, args: chk.run.args });
|
|
223
|
+
}
|
|
224
|
+
} else if (chk.help) {
|
|
225
|
+
const err = await program.parseAsync(chk.argv!, { from: 'user' })
|
|
226
|
+
.then(() => undefined, (e: unknown) => e);
|
|
227
|
+
expect(err, chk.argv!.join(' ')).toBeInstanceOf(CommanderError);
|
|
228
|
+
expect((err as CommanderError).code).toBe('commander.helpDisplayed');
|
|
229
|
+
const alias = chk.argv![0];
|
|
230
|
+
const text = output();
|
|
231
|
+
const proxy = program.commands.find(x => x.name() === alias);
|
|
232
|
+
let got = 'unknown';
|
|
233
|
+
if (text.includes(descs.get(c.aliases[alias])!)) got = 'target';
|
|
234
|
+
else if (proxy && text.includes(proxy.description())) got = 'alias';
|
|
235
|
+
expect(got, text).toBe(chk.help);
|
|
236
|
+
expect(rec.r.ran).toBe('none');
|
|
237
|
+
} else if (chk.complete) {
|
|
238
|
+
let out = '';
|
|
239
|
+
await completeRequest(program, chk.complete, true, {
|
|
240
|
+
out: s => { out += s; }, err: () => {},
|
|
241
|
+
});
|
|
242
|
+
const got = out.split('\n').filter(l => l !== '' && !l.startsWith(':')).sort();
|
|
243
|
+
expect(got, chk.complete.join(' ')).toEqual([...chk.candidates!].sort());
|
|
244
|
+
} else {
|
|
245
|
+
throw new Error(`${c.name}: check has no observable`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
});
|