@hop-top/kit 0.5.0-alpha.7 → 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 +38 -0
- package/dist/alias-D9_qFlyP.d.ts +174 -0
- package/dist/alias.d.ts +1 -1
- package/dist/alias.js +8 -2
- package/dist/{chunk-263IZ6Z6.js → chunk-B4ULGCCN.js} +43 -154
- package/dist/{chunk-DIDN4X5C.js → chunk-BLS2OBIQ.js} +99 -20
- package/dist/{chunk-JTMPNXVQ.js → chunk-P6GRX4RV.js} +486 -83
- package/dist/chunk-UZ65A27P.js +147 -0
- package/dist/{completion-sDKVXPUL.d.ts → completion-csVun6SP.d.ts} +4 -1
- package/dist/completion.d.ts +1 -1
- package/dist/{index-B-pqGHhU.d.ts → index-CaOXdl38.d.ts} +337 -24
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -4
- 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/alias.conformance.test.ts +250 -0
- package/src/alias.test.ts +96 -1
- package/src/alias.ts +179 -19
- package/src/completion.ts +4 -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/dist/alias-BsJ2jGqQ.d.ts +0 -96
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/toolspec-internal.ts
|
|
2
|
+
function annotationsOf(cmd) {
|
|
3
|
+
return _nullishCoalesce(cmd.annotations, () => ( {}));
|
|
4
|
+
}
|
|
5
|
+
function splitCSV(s) {
|
|
6
|
+
if (!s) return void 0;
|
|
7
|
+
const out = s.split(",").map((p) => p.trim()).filter((p) => p !== "");
|
|
8
|
+
return out.length > 0 ? out : void 0;
|
|
9
|
+
}
|
|
10
|
+
function declaredArgs(cmd) {
|
|
11
|
+
return cmd.registeredArguments.map(
|
|
12
|
+
(a) => a.required ? { name: a.name(), required: true } : { name: a.name() }
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
function takesNoValue(opt) {
|
|
16
|
+
return !opt.required && !opt.optional;
|
|
17
|
+
}
|
|
18
|
+
function isRunnable(cmd) {
|
|
19
|
+
return cmd._actionHandler != null;
|
|
20
|
+
}
|
|
21
|
+
function isHidden(cmd, parent) {
|
|
22
|
+
return !parent.createHelp().visibleCommands(parent).includes(cmd);
|
|
23
|
+
}
|
|
24
|
+
var BUILTIN_NAMES = /* @__PURE__ */ new Set([
|
|
25
|
+
"help",
|
|
26
|
+
"completion",
|
|
27
|
+
"man",
|
|
28
|
+
"__complete",
|
|
29
|
+
"__completeNoDesc"
|
|
30
|
+
]);
|
|
31
|
+
function isBuiltin(cmd, parent) {
|
|
32
|
+
return BUILTIN_NAMES.has(cmd.name()) || parent.name() === "completion";
|
|
33
|
+
}
|
|
34
|
+
function byName(a, b) {
|
|
35
|
+
const x = a.name();
|
|
36
|
+
const y = b.name();
|
|
37
|
+
return x < y ? -1 : x > y ? 1 : 0;
|
|
38
|
+
}
|
|
39
|
+
function goQuote(s) {
|
|
40
|
+
return JSON.stringify(s).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
41
|
+
}
|
|
42
|
+
function reindentRaw(raw, depth) {
|
|
43
|
+
JSON.parse(raw);
|
|
44
|
+
let out = "";
|
|
45
|
+
let level = depth;
|
|
46
|
+
let needIndent = false;
|
|
47
|
+
const nl = (lvl) => "\n" + " ".repeat(lvl);
|
|
48
|
+
for (let i = 0; i < raw.length; i++) {
|
|
49
|
+
const c = raw[i];
|
|
50
|
+
if (c === " " || c === " " || c === "\n" || c === "\r") continue;
|
|
51
|
+
if (needIndent && c !== "]" && c !== "}") {
|
|
52
|
+
out += nl(level);
|
|
53
|
+
needIndent = false;
|
|
54
|
+
}
|
|
55
|
+
if (c === '"') {
|
|
56
|
+
let j = i + 1;
|
|
57
|
+
while (raw[j] !== '"') j += raw[j] === "\\" ? 2 : 1;
|
|
58
|
+
out += goQuote(JSON.parse(raw.slice(i, j + 1)));
|
|
59
|
+
i = j;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
switch (c) {
|
|
63
|
+
case "{":
|
|
64
|
+
case "[":
|
|
65
|
+
out += c;
|
|
66
|
+
level++;
|
|
67
|
+
needIndent = true;
|
|
68
|
+
break;
|
|
69
|
+
case "}":
|
|
70
|
+
case "]":
|
|
71
|
+
level--;
|
|
72
|
+
if (needIndent) needIndent = false;
|
|
73
|
+
else out += nl(level);
|
|
74
|
+
out += c;
|
|
75
|
+
break;
|
|
76
|
+
case ",":
|
|
77
|
+
out += c + nl(level);
|
|
78
|
+
break;
|
|
79
|
+
case ":":
|
|
80
|
+
out += ": ";
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
out += c;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
function encodeGoJSON(v, depth, rawKeys, key) {
|
|
89
|
+
if (key !== void 0 && rawKeys.has(key) && typeof v === "string") {
|
|
90
|
+
return reindentRaw(v, depth);
|
|
91
|
+
}
|
|
92
|
+
if (typeof v === "string") return goQuote(v);
|
|
93
|
+
if (typeof v === "boolean" || typeof v === "number") return JSON.stringify(v);
|
|
94
|
+
if (Array.isArray(v)) {
|
|
95
|
+
if (v.length === 0) return "[]";
|
|
96
|
+
const pad = " ".repeat(depth + 1);
|
|
97
|
+
const items = v.map((x) => pad + encodeGoJSON(x, depth + 1, rawKeys));
|
|
98
|
+
return "[\n" + items.join(",\n") + "\n" + " ".repeat(depth) + "]";
|
|
99
|
+
}
|
|
100
|
+
if (v && typeof v === "object") {
|
|
101
|
+
const entries = Object.entries(v).filter(([, x]) => x !== void 0);
|
|
102
|
+
if (entries.length === 0) return "{}";
|
|
103
|
+
const pad = " ".repeat(depth + 1);
|
|
104
|
+
const items = entries.map(
|
|
105
|
+
([k, x]) => pad + goQuote(k) + ": " + encodeGoJSON(x, depth + 1, rawKeys, k)
|
|
106
|
+
);
|
|
107
|
+
return "{\n" + items.join(",\n") + "\n" + " ".repeat(depth) + "}";
|
|
108
|
+
}
|
|
109
|
+
return "null";
|
|
110
|
+
}
|
|
111
|
+
function walkCommands(program, reserved, visit) {
|
|
112
|
+
const reservedSet = new Set(_nullishCoalesce(reserved, () => ( [])));
|
|
113
|
+
const walk = (cmd, parent, path, depthOne, reservedTree) => {
|
|
114
|
+
const inReserved = reservedTree || annotationsOf(cmd)["kit/reserved"] === "true";
|
|
115
|
+
visit(cmd, parent, path, inReserved || reservedSet.has(depthOne));
|
|
116
|
+
for (const child of [...cmd.commands].sort(byName)) {
|
|
117
|
+
if (child.name() === "") continue;
|
|
118
|
+
walk(child, cmd, [...path, child.name()], depthOne, inReserved);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
for (const child of [...program.commands].sort(byName)) {
|
|
122
|
+
if (child.name() === "") continue;
|
|
123
|
+
walk(child, program, [program.name(), child.name()], child.name(), false);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
var pflagTypes = /* @__PURE__ */ new WeakMap();
|
|
127
|
+
function goFormat0(x) {
|
|
128
|
+
const floor = Math.floor(x);
|
|
129
|
+
const diff = x - floor;
|
|
130
|
+
let r = diff > 0.5 ? floor + 1 : diff < 0.5 ? floor : floor % 2 === 0 ? floor : floor + 1;
|
|
131
|
+
if (Object.is(r, -0)) r = 0;
|
|
132
|
+
return String(r);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
exports.annotationsOf = annotationsOf; exports.splitCSV = splitCSV; exports.declaredArgs = declaredArgs; exports.takesNoValue = takesNoValue; exports.isRunnable = isRunnable; exports.isHidden = isHidden; exports.isBuiltin = isBuiltin; exports.encodeGoJSON = encodeGoJSON; exports.walkCommands = walkCommands; exports.pflagTypes = pflagTypes; exports.goFormat0 = goFormat0;
|
|
@@ -64,7 +64,10 @@ declare function bindArgs(cmd: Command, completer: Completer): void;
|
|
|
64
64
|
/**
|
|
65
65
|
* Records `name` as a root-level alias of the command at `target` (a
|
|
66
66
|
* space-separated path), so root argument completion offers it as
|
|
67
|
-
* `name<TAB>alias for <target
|
|
67
|
+
* `name<TAB>alias for <target>`, and a root subcommand named `name`
|
|
68
|
+
* completes as a flagless stand-in. `bridgeAliases` calls this for
|
|
69
|
+
* every alias but a visible or custom-dispatch proxy, which completes
|
|
70
|
+
* as an ordinary subcommand.
|
|
68
71
|
*/
|
|
69
72
|
declare function registerRootAlias(root: Command, name: string, target: string): void;
|
|
70
73
|
/** Where a request writes. */
|
package/dist/completion.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'commander';
|
|
2
2
|
import './completion-values-By-mnjNt.js';
|
|
3
|
-
export { C as CompletionIO, N as NO_DESC_REQUEST_CMD, R as REQUEST_CMD, S as SHELLS, a as Shell, b as bindArgs, d as bindFlag, e as completeRequest, f as completionCommand, g as generateBashCompletion, h as generateFishCompletion, i as generatePowerShellCompletion, j as generateZshCompletion, k as installCompletionRequest, r as registerRootAlias, l as renderCompletionScript } from './completion-
|
|
3
|
+
export { C as CompletionIO, N as NO_DESC_REQUEST_CMD, R as REQUEST_CMD, S as SHELLS, a as Shell, b as bindArgs, d as bindFlag, e as completeRequest, f as completionCommand, g as generateBashCompletion, h as generateFishCompletion, i as generatePowerShellCompletion, j as generateZshCompletion, k as installCompletionRequest, r as registerRootAlias, l as renderCompletionScript } from './completion-csVun6SP.js';
|