@hop-top/kit 0.5.0-alpha.8 → 0.5.0-alpha.9
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 +22 -0
- package/dist/{chunk-263IZ6Z6.js → chunk-B4ULGCCN.js} +43 -154
- package/dist/{chunk-JTMPNXVQ.js → chunk-P6GRX4RV.js} +486 -83
- package/dist/chunk-UZ65A27P.js +147 -0
- package/dist/{index-B-pqGHhU.d.ts → index-CaOXdl38.d.ts} +337 -24
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -3
- package/dist/mcp/index.d.ts +2 -1
- package/dist/mcp/index.js +31 -2
- package/dist/{toolspec-UrWnoJ3Y.d.ts → toolspec-96rkLfsh.d.ts} +7 -2
- package/dist/toolspec.d.ts +1 -1
- package/dist/toolspec.js +3 -2
- package/package.json +1 -1
- package/src/mcp/README.md +6 -0
- package/src/mcp/args-separator.test.ts +164 -0
- package/src/mcp/args.test.ts +223 -0
- package/src/mcp/args.ts +160 -0
- package/src/mcp/audit.test.ts +520 -0
- package/src/mcp/audit.ts +70 -0
- package/src/mcp/bridge.test.ts +72 -0
- package/src/mcp/bridge.ts +50 -5
- package/src/mcp/conformance.test.ts +1 -1
- package/src/mcp/dispatch.ts +48 -2
- package/src/mcp/index.ts +33 -1
- package/src/mcp/legacy-notify.test.ts +59 -0
- package/src/mcp/legacy.ts +55 -15
- package/src/mcp/modern-confirm.ts +42 -10
- package/src/mcp/modern.ts +99 -35
- package/src/mcp/stdio.test.ts +313 -0
- package/src/mcp/stdio.ts +254 -0
- package/src/mcp/toolname.test.ts +147 -0
- package/src/mcp/types.ts +125 -18
- package/src/toolspec-internal.ts +24 -0
- package/src/toolspec-manifest.test.ts +25 -0
- package/src/toolspec-manifest.ts +5 -1
- package/src/toolspec.from-command.test.ts +51 -0
- package/src/toolspec.ts +29 -15
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,28 @@ All notable changes to `@hop-top/kit` are documented in this file.
|
|
|
4
4
|
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/);
|
|
5
5
|
versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.5.0-alpha.9](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.8...kit-ts/v0.5.0-alpha.9) (2026-10-30)
|
|
8
|
+
|
|
9
|
+
The hop-top team is happy to announce Kit's TS SDK 0.5.0-alpha.9. This release includes new features and bug fixes.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **mcp:** toolNameSeparator mount option in ts sdk ([0d0111c](https://github.com/hop-top/poly-kit/commit/0d0111c4600f7ac6be7fe013f96f757230f90467))
|
|
15
|
+
* **ts/mcp:** audit mount hook for refusals ([1f63a5f](https://github.com/hop-top/poly-kit/commit/1f63a5f89cd7ba8c25345ed9478a4a753f5bef28))
|
|
16
|
+
* **ts/mcp:** serveStdio transport ([7ab69a6](https://github.com/hop-top/poly-kit/commit/7ab69a622cc1f3c07b7fb6e51234235a5a992b2f))
|
|
17
|
+
* **ts/toolspec:** skip builtins, includeHidden in toolSpecFromCommand ([2962a7c](https://github.com/hop-top/poly-kit/commit/2962a7cfac4244d5c3bcdc40bceba24dac92f694))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **mcp:** no reply to notifications; ping returns {} ([f24c097](https://github.com/hop-top/poly-kit/commit/f24c09796642894a2329a6170a160283a15c38af))
|
|
23
|
+
* **ts/mcp:** negated, repeatable option types and default/enum in bridge schema ([863a448](https://github.com/hop-top/poly-kit/commit/863a448e899fc8e6d66f675604fc9427ce6d9b80))
|
|
24
|
+
* **ts/mcp:** publish positional args as the Go "args" array ([c47db88](https://github.com/hop-top/poly-kit/commit/c47db88b6f3e7e2594ee103cd87375d19f518e13))
|
|
25
|
+
* **ts/toolspec:** negatable flags typed bool ([79cfeb4](https://github.com/hop-top/poly-kit/commit/79cfeb4cc0b31d449b2b23487949dffce518f63d))
|
|
26
|
+
|
|
27
|
+
Full diff: [kit-ts/v0.5.0-alpha.8...kit-ts/v0.5.0-alpha.9](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.8...kit-ts/v0.5.0-alpha.9)
|
|
28
|
+
|
|
7
29
|
## [0.5.0-alpha.8](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.7...kit-ts/v0.5.0-alpha.8) (2026-10-29)
|
|
8
30
|
|
|
9
31
|
The hop-top team is happy to announce Kit's TS SDK 0.5.0-alpha.8. This release includes new features and bug fixes.
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _chunkUZ65A27Pjs = require('./chunk-UZ65A27P.js');
|
|
14
|
+
|
|
15
|
+
|
|
3
16
|
var _chunkIXVQ62NZjs = require('./chunk-IXVQ62NZ.js');
|
|
4
17
|
|
|
5
18
|
|
|
@@ -30,132 +43,6 @@ _chunkR5U7XKVJjs.__export.call(void 0, toolspec_exports, {
|
|
|
30
43
|
var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
|
|
31
44
|
var _jsyaml = require('js-yaml'); var yaml2 = _interopRequireWildcard(_jsyaml); var yaml = _interopRequireWildcard(_jsyaml);
|
|
32
45
|
|
|
33
|
-
// src/toolspec-internal.ts
|
|
34
|
-
function annotationsOf(cmd) {
|
|
35
|
-
return _nullishCoalesce(cmd.annotations, () => ( {}));
|
|
36
|
-
}
|
|
37
|
-
function splitCSV(s) {
|
|
38
|
-
if (!s) return void 0;
|
|
39
|
-
const out = s.split(",").map((p) => p.trim()).filter((p) => p !== "");
|
|
40
|
-
return out.length > 0 ? out : void 0;
|
|
41
|
-
}
|
|
42
|
-
function isRunnable(cmd) {
|
|
43
|
-
return cmd._actionHandler != null;
|
|
44
|
-
}
|
|
45
|
-
function isHidden(cmd, parent) {
|
|
46
|
-
return !parent.createHelp().visibleCommands(parent).includes(cmd);
|
|
47
|
-
}
|
|
48
|
-
var BUILTIN_NAMES = /* @__PURE__ */ new Set([
|
|
49
|
-
"help",
|
|
50
|
-
"completion",
|
|
51
|
-
"man",
|
|
52
|
-
"__complete",
|
|
53
|
-
"__completeNoDesc"
|
|
54
|
-
]);
|
|
55
|
-
function isBuiltin(cmd, parent) {
|
|
56
|
-
return BUILTIN_NAMES.has(cmd.name()) || parent.name() === "completion";
|
|
57
|
-
}
|
|
58
|
-
function byName(a, b) {
|
|
59
|
-
const x = a.name();
|
|
60
|
-
const y = b.name();
|
|
61
|
-
return x < y ? -1 : x > y ? 1 : 0;
|
|
62
|
-
}
|
|
63
|
-
function goQuote(s) {
|
|
64
|
-
return JSON.stringify(s).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
65
|
-
}
|
|
66
|
-
function reindentRaw(raw, depth) {
|
|
67
|
-
JSON.parse(raw);
|
|
68
|
-
let out = "";
|
|
69
|
-
let level = depth;
|
|
70
|
-
let needIndent = false;
|
|
71
|
-
const nl = (lvl) => "\n" + " ".repeat(lvl);
|
|
72
|
-
for (let i = 0; i < raw.length; i++) {
|
|
73
|
-
const c = raw[i];
|
|
74
|
-
if (c === " " || c === " " || c === "\n" || c === "\r") continue;
|
|
75
|
-
if (needIndent && c !== "]" && c !== "}") {
|
|
76
|
-
out += nl(level);
|
|
77
|
-
needIndent = false;
|
|
78
|
-
}
|
|
79
|
-
if (c === '"') {
|
|
80
|
-
let j = i + 1;
|
|
81
|
-
while (raw[j] !== '"') j += raw[j] === "\\" ? 2 : 1;
|
|
82
|
-
out += goQuote(JSON.parse(raw.slice(i, j + 1)));
|
|
83
|
-
i = j;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
switch (c) {
|
|
87
|
-
case "{":
|
|
88
|
-
case "[":
|
|
89
|
-
out += c;
|
|
90
|
-
level++;
|
|
91
|
-
needIndent = true;
|
|
92
|
-
break;
|
|
93
|
-
case "}":
|
|
94
|
-
case "]":
|
|
95
|
-
level--;
|
|
96
|
-
if (needIndent) needIndent = false;
|
|
97
|
-
else out += nl(level);
|
|
98
|
-
out += c;
|
|
99
|
-
break;
|
|
100
|
-
case ",":
|
|
101
|
-
out += c + nl(level);
|
|
102
|
-
break;
|
|
103
|
-
case ":":
|
|
104
|
-
out += ": ";
|
|
105
|
-
break;
|
|
106
|
-
default:
|
|
107
|
-
out += c;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return out;
|
|
111
|
-
}
|
|
112
|
-
function encodeGoJSON(v, depth, rawKeys, key) {
|
|
113
|
-
if (key !== void 0 && rawKeys.has(key) && typeof v === "string") {
|
|
114
|
-
return reindentRaw(v, depth);
|
|
115
|
-
}
|
|
116
|
-
if (typeof v === "string") return goQuote(v);
|
|
117
|
-
if (typeof v === "boolean" || typeof v === "number") return JSON.stringify(v);
|
|
118
|
-
if (Array.isArray(v)) {
|
|
119
|
-
if (v.length === 0) return "[]";
|
|
120
|
-
const pad = " ".repeat(depth + 1);
|
|
121
|
-
const items = v.map((x) => pad + encodeGoJSON(x, depth + 1, rawKeys));
|
|
122
|
-
return "[\n" + items.join(",\n") + "\n" + " ".repeat(depth) + "]";
|
|
123
|
-
}
|
|
124
|
-
if (v && typeof v === "object") {
|
|
125
|
-
const entries = Object.entries(v).filter(([, x]) => x !== void 0);
|
|
126
|
-
if (entries.length === 0) return "{}";
|
|
127
|
-
const pad = " ".repeat(depth + 1);
|
|
128
|
-
const items = entries.map(
|
|
129
|
-
([k, x]) => pad + goQuote(k) + ": " + encodeGoJSON(x, depth + 1, rawKeys, k)
|
|
130
|
-
);
|
|
131
|
-
return "{\n" + items.join(",\n") + "\n" + " ".repeat(depth) + "}";
|
|
132
|
-
}
|
|
133
|
-
return "null";
|
|
134
|
-
}
|
|
135
|
-
function walkCommands(program, reserved, visit) {
|
|
136
|
-
const reservedSet = new Set(_nullishCoalesce(reserved, () => ( [])));
|
|
137
|
-
const walk = (cmd, parent, path, depthOne, reservedTree) => {
|
|
138
|
-
const inReserved = reservedTree || annotationsOf(cmd)["kit/reserved"] === "true";
|
|
139
|
-
visit(cmd, parent, path, inReserved || reservedSet.has(depthOne));
|
|
140
|
-
for (const child of [...cmd.commands].sort(byName)) {
|
|
141
|
-
if (child.name() === "") continue;
|
|
142
|
-
walk(child, cmd, [...path, child.name()], depthOne, inReserved);
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
for (const child of [...program.commands].sort(byName)) {
|
|
146
|
-
if (child.name() === "") continue;
|
|
147
|
-
walk(child, program, [program.name(), child.name()], child.name(), false);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
var pflagTypes = /* @__PURE__ */ new WeakMap();
|
|
151
|
-
function goFormat0(x) {
|
|
152
|
-
const floor = Math.floor(x);
|
|
153
|
-
const diff = x - floor;
|
|
154
|
-
let r = diff > 0.5 ? floor + 1 : diff < 0.5 ? floor : floor % 2 === 0 ? floor : floor + 1;
|
|
155
|
-
if (Object.is(r, -0)) r = 0;
|
|
156
|
-
return String(r);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
46
|
// src/toolspec-manifest.ts
|
|
160
47
|
var SCHEMA_VERSION_ENV = "KIT_TOOLSPEC_SCHEMA";
|
|
161
48
|
var LATEST_SCHEMA_VERSION = "1.1";
|
|
@@ -260,13 +147,14 @@ function dryRunSupported(ann) {
|
|
|
260
147
|
}
|
|
261
148
|
function flagTypeAndDefault(opt) {
|
|
262
149
|
const def = opt.defaultValue;
|
|
263
|
-
const declared = pflagTypes.get(opt);
|
|
150
|
+
const declared = _chunkUZ65A27Pjs.pflagTypes.get(opt);
|
|
264
151
|
if (declared) return [declared, def === void 0 ? "" : String(def)];
|
|
265
|
-
if (opt.isBoolean()) return ["bool", def === void 0 ? "false" : String(def)];
|
|
266
152
|
if (opt.variadic) {
|
|
267
153
|
const items = def === void 0 ? [] : Array.isArray(def) ? def : [def];
|
|
268
154
|
return ["stringSlice", `[${items.map(String).join(",")}]`];
|
|
269
155
|
}
|
|
156
|
+
if (opt.negate) return ["bool", "false"];
|
|
157
|
+
if (_chunkUZ65A27Pjs.takesNoValue.call(void 0, opt)) return ["bool", def === void 0 ? "false" : String(def)];
|
|
270
158
|
return ["string", def === void 0 ? "" : String(def)];
|
|
271
159
|
}
|
|
272
160
|
function manifestFlags(cmd, ann, withHelp) {
|
|
@@ -298,7 +186,7 @@ function manifestFlags(cmd, ann, withHelp) {
|
|
|
298
186
|
return flags.length > 0 ? flags : void 0;
|
|
299
187
|
}
|
|
300
188
|
function manifestArgs(cmd, ann) {
|
|
301
|
-
const declared = splitCSV(ann["kit/args"]);
|
|
189
|
+
const declared = _chunkUZ65A27Pjs.splitCSV.call(void 0, ann["kit/args"]);
|
|
302
190
|
const args = declared ? declared.map(
|
|
303
191
|
(n) => n.endsWith("?") ? { name: n.slice(0, -1) } : { name: n, required: true }
|
|
304
192
|
) : cmd.registeredArguments.map(
|
|
@@ -307,7 +195,7 @@ function manifestArgs(cmd, ann) {
|
|
|
307
195
|
return args.length > 0 ? args : void 0;
|
|
308
196
|
}
|
|
309
197
|
function manifestCommand(cmd, path, hidden, reserved, invoked) {
|
|
310
|
-
const ann = annotationsOf(cmd);
|
|
198
|
+
const ann = _chunkUZ65A27Pjs.annotationsOf.call(void 0, cmd);
|
|
311
199
|
const summary = cmd.summary();
|
|
312
200
|
const short = summary || cmd.description();
|
|
313
201
|
const long = summary ? cmd.description() : "";
|
|
@@ -321,7 +209,7 @@ function manifestCommand(cmd, path, hidden, reserved, invoked) {
|
|
|
321
209
|
if (args) out.args = args;
|
|
322
210
|
const flags = manifestFlags(cmd, ann, invoked);
|
|
323
211
|
if (flags) out.flags = flags;
|
|
324
|
-
const exitCodes = splitCSV(ann["kit/exit-codes"]);
|
|
212
|
+
const exitCodes = _chunkUZ65A27Pjs.splitCSV.call(void 0, ann["kit/exit-codes"]);
|
|
325
213
|
if (exitCodes) out.exit_codes = exitCodes;
|
|
326
214
|
const deprecatedSince = _nullishCoalesce(ann["kit/deprecated-since"], () => ( ""));
|
|
327
215
|
const removalTarget = _nullishCoalesce(ann["kit/removal-target"], () => ( ""));
|
|
@@ -368,19 +256,19 @@ function buildManifest(program, schemaVersion, opts = {}) {
|
|
|
368
256
|
schema_version: schemaVersion,
|
|
369
257
|
commands: []
|
|
370
258
|
};
|
|
371
|
-
walkCommands(program, opts.reserved, (cmd, parent, path, reserved) => {
|
|
372
|
-
const ann = annotationsOf(cmd);
|
|
259
|
+
_chunkUZ65A27Pjs.walkCommands.call(void 0, program, opts.reserved, (cmd, parent, path, reserved) => {
|
|
260
|
+
const ann = _chunkUZ65A27Pjs.annotationsOf.call(void 0, cmd);
|
|
373
261
|
const deprecated = !!(ann["kit/deprecated-since"] || ann["kit/removal-target"]);
|
|
374
|
-
if (!isRunnable(cmd) || isBuiltin(cmd, parent)) return;
|
|
262
|
+
if (!_chunkUZ65A27Pjs.isRunnable.call(void 0, cmd) || _chunkUZ65A27Pjs.isBuiltin.call(void 0, cmd, parent)) return;
|
|
375
263
|
if (deprecated && !opts.includeDeprecated) return;
|
|
376
264
|
m.commands.push(
|
|
377
|
-
manifestCommand(cmd, path, isHidden(cmd, parent), reserved, cmd === opts.invokedCommand)
|
|
265
|
+
manifestCommand(cmd, path, _chunkUZ65A27Pjs.isHidden.call(void 0, cmd, parent), reserved, cmd === opts.invokedCommand)
|
|
378
266
|
);
|
|
379
267
|
});
|
|
380
268
|
return m;
|
|
381
269
|
}
|
|
382
270
|
function renderManifestJSON(m) {
|
|
383
|
-
return encodeGoJSON(m, 0, /* @__PURE__ */ new Set(["output_schema"])) + "\n";
|
|
271
|
+
return _chunkUZ65A27Pjs.encodeGoJSON.call(void 0, m, 0, /* @__PURE__ */ new Set(["output_schema"])) + "\n";
|
|
384
272
|
}
|
|
385
273
|
|
|
386
274
|
// src/toolspec-spec.ts
|
|
@@ -456,7 +344,7 @@ function registerSpecCommand(program, schemaVersion, opts = {}) {
|
|
|
456
344
|
if (local.version || versionForwarded) {
|
|
457
345
|
const vf = format === "" ? "json" : format;
|
|
458
346
|
if (vf === "json") {
|
|
459
|
-
out(encodeGoJSON({ schema_version: resolved }, 0, /* @__PURE__ */ new Set()) + "\n");
|
|
347
|
+
out(_chunkUZ65A27Pjs.encodeGoJSON.call(void 0, { schema_version: resolved }, 0, /* @__PURE__ */ new Set()) + "\n");
|
|
460
348
|
} else if (vf === "yaml") {
|
|
461
349
|
out(toYAML({ schema_version: resolved }));
|
|
462
350
|
} else {
|
|
@@ -578,9 +466,9 @@ function coverageOf(program, opts = {}) {
|
|
|
578
466
|
};
|
|
579
467
|
const unannotated = [];
|
|
580
468
|
const malformed = [];
|
|
581
|
-
walkCommands(program, opts.reserved, (cmd, parent, path, reserved) => {
|
|
582
|
-
const ann = annotationsOf(cmd);
|
|
583
|
-
if (!isRunnable(cmd) || isBuiltin(cmd, parent) || reserved) return;
|
|
469
|
+
_chunkUZ65A27Pjs.walkCommands.call(void 0, program, opts.reserved, (cmd, parent, path, reserved) => {
|
|
470
|
+
const ann = _chunkUZ65A27Pjs.annotationsOf.call(void 0, cmd);
|
|
471
|
+
if (!_chunkUZ65A27Pjs.isRunnable.call(void 0, cmd) || _chunkUZ65A27Pjs.isBuiltin.call(void 0, cmd, parent) || reserved) return;
|
|
584
472
|
if (ann[SPEC_COMMAND_ANNOTATION] === "true") return;
|
|
585
473
|
rep.total++;
|
|
586
474
|
const p = path.join(" ");
|
|
@@ -635,7 +523,7 @@ function registerCoverageCommand(spec, program, reserved) {
|
|
|
635
523
|
}
|
|
636
524
|
return n;
|
|
637
525
|
}).default(0);
|
|
638
|
-
pflagTypes.set(min, "float64");
|
|
526
|
+
_chunkUZ65A27Pjs.pflagTypes.set(min, "float64");
|
|
639
527
|
const cmd = new (0, _commander.Command)("coverage").summary("Report kit/side-effect annotation coverage").description(
|
|
640
528
|
"Report how many of this tool's commands declare a kit/side-effect class, list the ones that do not, and exit non-zero when coverage falls below --min.\n\nAn unannotated command is not a read-only command: it is one kit knows nothing about, and every safety gate that consumes the manifest must fail closed on it. This report is how an adopter finds and closes that gap, and how CI keeps it closed."
|
|
641
529
|
).addOption(min);
|
|
@@ -655,11 +543,11 @@ function registerCoverageCommand(spec, program, reserved) {
|
|
|
655
543
|
const rep = coverageOf(program, { reserved });
|
|
656
544
|
const [given, changed] = formatFlag(this);
|
|
657
545
|
const format = changed && given !== "" ? given : "json";
|
|
658
|
-
const text = format === "json" ? encodeGoJSON(rep, 0, /* @__PURE__ */ new Set()) + "\n" : captureRender(format, rep);
|
|
546
|
+
const text = format === "json" ? _chunkUZ65A27Pjs.encodeGoJSON.call(void 0, rep, 0, /* @__PURE__ */ new Set()) + "\n" : captureRender(format, rep);
|
|
659
547
|
this.configureOutput().writeOut(text);
|
|
660
548
|
const threshold = this.opts().min;
|
|
661
549
|
if (coverageMeets(rep, threshold)) return;
|
|
662
|
-
const message = !rep.measurable ? `annotation coverage unmeasurable: no reflectable commands in ${JSON.stringify(rep.tool)} (--min ${goFormat0(threshold)}% cannot be evaluated)` : `annotation coverage ${goFormat0(coveragePercent(rep))}% (${rep.annotated}/${rep.total}) is below --min ${goFormat0(threshold)}%; unannotated: ` + (_nullishCoalesce(rep.unannotated_paths, () => ( []))).join(", ");
|
|
550
|
+
const message = !rep.measurable ? `annotation coverage unmeasurable: no reflectable commands in ${JSON.stringify(rep.tool)} (--min ${_chunkUZ65A27Pjs.goFormat0.call(void 0, threshold)}% cannot be evaluated)` : `annotation coverage ${_chunkUZ65A27Pjs.goFormat0.call(void 0, coveragePercent(rep))}% (${rep.annotated}/${rep.total}) is below --min ${_chunkUZ65A27Pjs.goFormat0.call(void 0, threshold)}%; unannotated: ` + (_nullishCoalesce(rep.unannotated_paths, () => ( []))).join(", ");
|
|
663
551
|
this.error(message, { exitCode: _chunkPOR5L2DGjs.EXIT_CONFLICT, code: "kit.spec.coverageBelowMin" });
|
|
664
552
|
});
|
|
665
553
|
spec.addCommand(cmd);
|
|
@@ -829,21 +717,24 @@ function findCommand(spec, name) {
|
|
|
829
717
|
return void 0;
|
|
830
718
|
}
|
|
831
719
|
function toolSpecFromCommand(program, opts = {}) {
|
|
832
|
-
const
|
|
720
|
+
const ctx = {
|
|
721
|
+
annotations: _nullishCoalesce(opts.annotations, () => ( {})),
|
|
722
|
+
includeHidden: _nullishCoalesce(opts.includeHidden, () => ( false))
|
|
723
|
+
};
|
|
833
724
|
const spec = {
|
|
834
725
|
name: program.name(),
|
|
835
726
|
schemaVersion: _nullishCoalesce(opts.schemaVersion, () => ( "1")),
|
|
836
|
-
commands: projectChildren(program, [],
|
|
727
|
+
commands: projectChildren(program, [], ctx)
|
|
837
728
|
};
|
|
838
729
|
const flags = projectFlags(program);
|
|
839
730
|
if (flags) spec.flags = flags;
|
|
840
731
|
return spec;
|
|
841
732
|
}
|
|
842
|
-
function projectChildren(cmd, path,
|
|
733
|
+
function projectChildren(cmd, path, ctx) {
|
|
843
734
|
const visible = cmd.createHelp().visibleCommands(cmd);
|
|
844
|
-
return
|
|
735
|
+
return cmd.commands.filter((c) => c.name() !== "").filter((c) => ctx.includeHidden || visible.includes(c)).filter((c) => !_chunkUZ65A27Pjs.isBuiltin.call(void 0, c, cmd)).filter((c) => kitAnnotations(c)["kit/spec-command"] !== "true").map((c) => projectCommand(c, [...path, c.name()], ctx));
|
|
845
736
|
}
|
|
846
|
-
function projectCommand(cmd, path,
|
|
737
|
+
function projectCommand(cmd, path, ctx) {
|
|
847
738
|
const out = { name: cmd.name() };
|
|
848
739
|
const short = cmd.summary() || cmd.description();
|
|
849
740
|
if (short) out.short = short;
|
|
@@ -851,15 +742,13 @@ function projectCommand(cmd, path, annotations) {
|
|
|
851
742
|
if (aliases.length > 0) out.aliases = [...aliases];
|
|
852
743
|
const flags = projectFlags(cmd);
|
|
853
744
|
if (flags) out.flags = flags;
|
|
854
|
-
const args =
|
|
855
|
-
(a) => a.required ? { name: a.name(), required: true } : { name: a.name() }
|
|
856
|
-
);
|
|
745
|
+
const args = _chunkUZ65A27Pjs.declaredArgs.call(void 0, cmd);
|
|
857
746
|
if (args.length > 0) out.args = args;
|
|
858
747
|
const exitCodes = splitCSV2(kitAnnotations(cmd)["kit/exit-codes"]);
|
|
859
748
|
if (exitCodes) out.exitCodes = exitCodes;
|
|
860
|
-
const children = projectChildren(cmd, path,
|
|
749
|
+
const children = projectChildren(cmd, path, ctx);
|
|
861
750
|
if (children.length > 0) out.children = children;
|
|
862
|
-
const ann = annotations[path.join(" ")];
|
|
751
|
+
const ann = ctx.annotations[path.join(" ")];
|
|
863
752
|
if (ann) {
|
|
864
753
|
for (const [k, v] of Object.entries(ann)) {
|
|
865
754
|
if (v !== void 0) out[k] = v;
|
|
@@ -891,8 +780,8 @@ function projectFlags(cmd) {
|
|
|
891
780
|
return out.length > 0 ? out : void 0;
|
|
892
781
|
}
|
|
893
782
|
function flagType(opt) {
|
|
894
|
-
if (opt.isBoolean()) return "bool";
|
|
895
783
|
if (opt.variadic) return "stringSlice";
|
|
784
|
+
if (_chunkUZ65A27Pjs.takesNoValue.call(void 0, opt)) return "bool";
|
|
896
785
|
return "string";
|
|
897
786
|
}
|
|
898
787
|
|