@hop-top/kit 0.5.0-alpha.10 → 0.5.0-alpha.11
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 +24 -0
- package/README.md +4 -4
- package/dist/alias.js +3 -3
- package/dist/{chunk-T46YPHKN.js → chunk-4FMALWYB.js} +45 -45
- package/dist/{chunk-WWUKGJB5.js → chunk-4GPCWBBA.js} +60 -7
- package/dist/{chunk-JZ22ZUFA.js → chunk-65VPWMPV.js} +4 -1
- package/dist/{chunk-YGYQUFGY.js → chunk-BXJ2J27B.js} +10 -10
- package/dist/chunk-CXBZTONY.js +65 -0
- package/dist/{chunk-K7VCKJ27.js → chunk-EE4M2UOF.js} +8 -4
- package/dist/{chunk-72XZWQX7.js → chunk-GFRAYYRD.js} +475 -162
- package/dist/{chunk-2JV3A7OP.js → chunk-IVQHLI56.js} +6 -10
- package/dist/{chunk-NLMS7HGP.js → chunk-IZ6Q4SE3.js} +3 -3
- package/dist/chunk-MFVUENZR.js +1549 -0
- package/dist/{chunk-BLS2OBIQ.js → chunk-ML7D5DWY.js} +2 -2
- package/dist/{chunk-GGWJRWWA.js → chunk-RYKLVOVK.js} +7 -7
- package/dist/{chunk-QPUCXQXT.js → chunk-T6OZMPPV.js} +2 -1
- package/dist/{chunk-MUIQVU6E.js → chunk-VGOA5Y7S.js} +11 -11
- package/dist/{chunk-ABQSE7AI.js → chunk-VWGP4NVJ.js} +38 -38
- package/dist/cli-RSRk1M36.d.ts +707 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +60 -5
- package/dist/completion.js +2 -2
- package/dist/{index-DCe1boBz.d.ts → index-CGE5yLBj.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +22 -22
- package/dist/llm-anthropic.js +5 -5
- package/dist/llm-openai.js +5 -5
- package/dist/llm.js +3 -3
- package/dist/log.js +3 -3
- package/dist/mcp/index.js +3 -2
- package/dist/output.js +2 -4
- package/dist/routellm.js +6 -6
- package/dist/toolspec.js +4 -4
- package/dist/tui/index.d.ts +2 -2
- package/dist/tui/index.js +3 -3
- package/dist/{upgrade-p_zh3pvV.d.ts → upgrade-C3RWGwRi.d.ts} +23 -0
- package/dist/upgrade.d.ts +1 -1
- package/dist/upgrade.js +2 -2
- package/package.json +1 -1
- package/src/cli.root.conformance.test.ts +166 -0
- package/src/cli.ts +39 -0
- package/src/completion.conformance.test.ts +3 -2
- package/src/completion.test.ts +12 -0
- package/src/completion.ts +8 -3
- package/src/delegation.test.ts +299 -0
- package/src/delegation.ts +807 -0
- package/src/mcp/bridge.test.ts +28 -0
- package/src/mcp/bridge.ts +5 -10
- package/src/plan.ts +89 -0
- package/src/policy.ts +472 -0
- package/src/sideeffect.ts +105 -0
- package/src/toolspec-manifest.ts +7 -2
- package/src/upgrade.test.ts +291 -0
- package/src/upgrade.ts +116 -7
- package/dist/chunk-GHPJJV5L.js +0 -613
- package/dist/chunk-IXVQ62NZ.js +0 -334
- package/dist/cli-C5B5tnpA.d.ts +0 -400
- package/dist/{chunk-PSFYJGDG.js → chunk-K7E34Q3A.js} +2 -2
package/dist/chunk-GHPJJV5L.js
DELETED
|
@@ -1,613 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
|
-
|
|
3
|
-
var _chunk72XZWQX7js = require('./chunk-72XZWQX7.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkPOR5L2DGjs = require('./chunk-POR5L2DG.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunkQPUCXQXTjs = require('./chunk-QPUCXQXT.js');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var _chunkKVG7YCTSjs = require('./chunk-KVG7YCTS.js');
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var _chunkJZ22ZUFAjs = require('./chunk-JZ22ZUFA.js');
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
|
|
26
|
-
|
|
27
|
-
// src/cli.ts
|
|
28
|
-
var cli_exports = {};
|
|
29
|
-
_chunkR5U7XKVJjs.__export.call(void 0, cli_exports, {
|
|
30
|
-
Dark: () => Dark,
|
|
31
|
-
ErrOffline: () => _chunkKVG7YCTSjs.ErrOffline,
|
|
32
|
-
HintSet: () => HintSet,
|
|
33
|
-
Neon: () => Neon,
|
|
34
|
-
OfflineError: () => _chunkKVG7YCTSjs.OfflineError,
|
|
35
|
-
active: () => active,
|
|
36
|
-
applyHelpTheme: () => applyHelpTheme,
|
|
37
|
-
buildTheme: () => buildTheme,
|
|
38
|
-
channel: () => channel,
|
|
39
|
-
createCLI: () => createCLI,
|
|
40
|
-
getCommandGroup: () => getCommandGroup,
|
|
41
|
-
getStreamDefs: () => getStreamDefs,
|
|
42
|
-
guardFetch: () => _chunkKVG7YCTSjs.guardFetch,
|
|
43
|
-
hintsEnabled: () => hintsEnabled,
|
|
44
|
-
isOffline: () => _chunkKVG7YCTSjs.isOffline,
|
|
45
|
-
isOfflineError: () => _chunkKVG7YCTSjs.isOfflineError,
|
|
46
|
-
isQuiet: () => isQuiet,
|
|
47
|
-
registerStream: () => registerStream,
|
|
48
|
-
registerUpgradeHints: () => registerUpgradeHints,
|
|
49
|
-
registerVersionHints: () => registerVersionHints,
|
|
50
|
-
renderHints: () => renderHints,
|
|
51
|
-
setCommandGroup: () => setCommandGroup,
|
|
52
|
-
streamFlagName: () => streamFlagName,
|
|
53
|
-
streamLabel: () => streamLabel,
|
|
54
|
-
streamOutput: () => streamOutput,
|
|
55
|
-
verboseCount: () => verboseCount,
|
|
56
|
-
verbosityFlagSpec: () => verbosityFlagSpec,
|
|
57
|
-
verbosityShorthand: () => verbosityShorthand,
|
|
58
|
-
withOffline: () => _chunkKVG7YCTSjs.withOffline
|
|
59
|
-
});
|
|
60
|
-
var _commander = require('commander');
|
|
61
|
-
|
|
62
|
-
// src/hint.ts
|
|
63
|
-
var HintSet = class {
|
|
64
|
-
constructor() {
|
|
65
|
-
this.m = /* @__PURE__ */ new Map();
|
|
66
|
-
}
|
|
67
|
-
/** Add one or more hints for the given command name. */
|
|
68
|
-
register(cmd, ...hints) {
|
|
69
|
-
const existing = _nullishCoalesce(this.m.get(cmd), () => ( []));
|
|
70
|
-
this.m.set(cmd, [...existing, ...hints]);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Return a copy of the hints registered for cmd.
|
|
74
|
-
* Returns an empty array when none are registered.
|
|
75
|
-
*/
|
|
76
|
-
lookup(cmd) {
|
|
77
|
-
return [..._nullishCoalesce(this.m.get(cmd), () => ( []))];
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
function active(hints) {
|
|
81
|
-
return hints.filter((h) => h.condition === void 0 || h.condition());
|
|
82
|
-
}
|
|
83
|
-
function hintsEnabled(opts) {
|
|
84
|
-
if (opts.noHints) return false;
|
|
85
|
-
if (opts.hintsEnabled === false) return false;
|
|
86
|
-
if (opts.quiet) return false;
|
|
87
|
-
const env = process.env["HOP_QUIET_HINTS"];
|
|
88
|
-
if (env === "1" || env === "true" || env === "yes") return false;
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
function renderHints(w, hints, format, opts, muted) {
|
|
92
|
-
if (format !== "table") return;
|
|
93
|
-
if (!hintsEnabled(opts)) return;
|
|
94
|
-
const isTTY = w.isTTY === true;
|
|
95
|
-
if (!isTTY) return;
|
|
96
|
-
const visible = active(hints);
|
|
97
|
-
if (visible.length === 0) return;
|
|
98
|
-
const noColor = process.env["NO_COLOR"] !== void 0 || process.argv.includes("--no-color");
|
|
99
|
-
w.write("\n");
|
|
100
|
-
for (const h of visible) {
|
|
101
|
-
const text = `\u2192 ${h.message}`;
|
|
102
|
-
if (noColor) {
|
|
103
|
-
w.write(text + "\n");
|
|
104
|
-
} else {
|
|
105
|
-
const hex = muted.replace("#", "");
|
|
106
|
-
const r = parseInt(hex.slice(0, 2), 16);
|
|
107
|
-
const g = parseInt(hex.slice(2, 4), 16);
|
|
108
|
-
const b = parseInt(hex.slice(4, 6), 16);
|
|
109
|
-
w.write(`\x1B[38;2;${r};${g};${b}m${text}\x1B[0m
|
|
110
|
-
`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function registerUpgradeHints(hints, binary, upgraded) {
|
|
115
|
-
hints.register("upgrade", {
|
|
116
|
-
message: `Run \`${binary} version\` to verify.`,
|
|
117
|
-
condition: upgraded
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
function registerVersionHints(hints, binary, updateAvail) {
|
|
121
|
-
hints.register("version", {
|
|
122
|
-
message: `Run \`${binary} upgrade\` to get latest.`,
|
|
123
|
-
condition: updateAvail
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// src/cli.ts
|
|
128
|
-
var verboseCountMap = /* @__PURE__ */ new WeakMap();
|
|
129
|
-
var quietMap = /* @__PURE__ */ new WeakMap();
|
|
130
|
-
function verbosityShorthand(d) {
|
|
131
|
-
const s = (_nullishCoalesce(_optionalChain([d, 'access', _2 => _2.verbosity, 'optionalAccess', _3 => _3.flag]), () => ( ""))).replace(/^-+/, "");
|
|
132
|
-
return s.length === 1 ? s : "V";
|
|
133
|
-
}
|
|
134
|
-
function verbosityFlagSpec(d) {
|
|
135
|
-
return `-${verbosityShorthand(d)}, --verbose`;
|
|
136
|
-
}
|
|
137
|
-
function verboseCount(cmd) {
|
|
138
|
-
let c = cmd;
|
|
139
|
-
while (c) {
|
|
140
|
-
const v = verboseCountMap.get(c);
|
|
141
|
-
if (v !== void 0) return v;
|
|
142
|
-
c = _nullishCoalesce(c.parent, () => ( null));
|
|
143
|
-
}
|
|
144
|
-
return 0;
|
|
145
|
-
}
|
|
146
|
-
function isQuiet(cmd) {
|
|
147
|
-
let c = cmd;
|
|
148
|
-
while (c) {
|
|
149
|
-
const q = quietMap.get(c);
|
|
150
|
-
if (q !== void 0) return q;
|
|
151
|
-
c = _nullishCoalesce(c.parent, () => ( null));
|
|
152
|
-
}
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
var streamDefsMap = /* @__PURE__ */ new WeakMap();
|
|
156
|
-
function streamFlagName(d) {
|
|
157
|
-
const name = (_nullishCoalesce(_optionalChain([d, 'access', _4 => _4.streams, 'optionalAccess', _5 => _5.flag]), () => ( ""))).replace(/^-+/, "");
|
|
158
|
-
return name === "" ? "stream" : name;
|
|
159
|
-
}
|
|
160
|
-
function streamLabel(d, name) {
|
|
161
|
-
const format = _optionalChain([d, 'access', _6 => _6.streams, 'optionalAccess', _7 => _7.label_format]) || "[{name}]";
|
|
162
|
-
return format.split("{name}").join(name) + " ";
|
|
163
|
-
}
|
|
164
|
-
function streamOutput(d) {
|
|
165
|
-
return _optionalChain([d, 'access', _8 => _8.streams, 'optionalAccess', _9 => _9.output]) === "stdout" ? process.stdout : process.stderr;
|
|
166
|
-
}
|
|
167
|
-
function registerStream(cmd, name, description) {
|
|
168
|
-
let defs = streamDefsMap.get(cmd);
|
|
169
|
-
if (!defs) {
|
|
170
|
-
defs = [];
|
|
171
|
-
streamDefsMap.set(cmd, defs);
|
|
172
|
-
cmd.option(
|
|
173
|
-
`--${streamFlagName(_chunkQPUCXQXTjs.parity)} <names>`,
|
|
174
|
-
"Enable diagnostic streams (comma-separated)"
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
defs.push({ name, description });
|
|
178
|
-
}
|
|
179
|
-
function getStreamDefs(cmd) {
|
|
180
|
-
return _nullishCoalesce(streamDefsMap.get(cmd), () => ( []));
|
|
181
|
-
}
|
|
182
|
-
var noopWriter = { write(_s) {
|
|
183
|
-
return true;
|
|
184
|
-
} };
|
|
185
|
-
function optionKey(flagName) {
|
|
186
|
-
return flagName.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
187
|
-
}
|
|
188
|
-
function channel(cmd, name) {
|
|
189
|
-
const opts = cmd.opts();
|
|
190
|
-
const raw = opts[optionKey(streamFlagName(_chunkQPUCXQXTjs.parity))];
|
|
191
|
-
const enabled = typeof raw === "string" ? raw.split(",").map((s) => s.trim()).includes(name) : false;
|
|
192
|
-
if (!enabled) return noopWriter;
|
|
193
|
-
const prefix = streamLabel(_chunkQPUCXQXTjs.parity, name);
|
|
194
|
-
const w = streamOutput(_chunkQPUCXQXTjs.parity);
|
|
195
|
-
return {
|
|
196
|
-
write(s) {
|
|
197
|
-
const lines = s.split("\n");
|
|
198
|
-
for (const line of lines) {
|
|
199
|
-
if (line) w.write(`${prefix}${line}
|
|
200
|
-
`);
|
|
201
|
-
}
|
|
202
|
-
return true;
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
var Neon = {
|
|
207
|
-
command: "#7ED957",
|
|
208
|
-
// grass green
|
|
209
|
-
flag: "#FF00FF"
|
|
210
|
-
// vivid neon pink
|
|
211
|
-
};
|
|
212
|
-
var Dark = {
|
|
213
|
-
command: "#C1FF72",
|
|
214
|
-
// lime
|
|
215
|
-
flag: "#FF66C4"
|
|
216
|
-
// pink
|
|
217
|
-
};
|
|
218
|
-
function buildTheme(accent) {
|
|
219
|
-
const palette = { ...Neon };
|
|
220
|
-
if (accent) {
|
|
221
|
-
palette.command = accent;
|
|
222
|
-
}
|
|
223
|
-
return {
|
|
224
|
-
palette,
|
|
225
|
-
accent: palette.command,
|
|
226
|
-
secondary: palette.flag,
|
|
227
|
-
muted: "#858183",
|
|
228
|
-
// CharmTone Squid
|
|
229
|
-
error: "#ED4A5E",
|
|
230
|
-
// CharmTone Cherry
|
|
231
|
-
success: "#52CF84",
|
|
232
|
-
// CharmTone Guac
|
|
233
|
-
title: "#FFFFFF",
|
|
234
|
-
// fang ColorScheme.Title
|
|
235
|
-
argument: "#B5E89B",
|
|
236
|
-
// fang ColorScheme.Argument
|
|
237
|
-
dimmedArgument: "#8ABF6E"
|
|
238
|
-
// fang ColorScheme.DimmedArgument
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
var commandGroupMap = /* @__PURE__ */ new WeakMap();
|
|
242
|
-
function setCommandGroup(cmd, groupId) {
|
|
243
|
-
commandGroupMap.set(cmd, groupId);
|
|
244
|
-
}
|
|
245
|
-
function getCommandGroup(cmd) {
|
|
246
|
-
return commandGroupMap.get(cmd);
|
|
247
|
-
}
|
|
248
|
-
function hexToRgb(hex) {
|
|
249
|
-
const h = hex.replace("#", "");
|
|
250
|
-
return [
|
|
251
|
-
parseInt(h.slice(0, 2), 16),
|
|
252
|
-
parseInt(h.slice(2, 4), 16),
|
|
253
|
-
parseInt(h.slice(4, 6), 16)
|
|
254
|
-
];
|
|
255
|
-
}
|
|
256
|
-
function ansi(hex, text) {
|
|
257
|
-
const [r, g, b] = hexToRgb(hex);
|
|
258
|
-
return `\x1B[38;2;${r};${g};${b}m${text}\x1B[0m`;
|
|
259
|
-
}
|
|
260
|
-
function ansiBold(hex, text) {
|
|
261
|
-
const [r, g, b] = hexToRgb(hex);
|
|
262
|
-
return `\x1B[1;38;2;${r};${g};${b}m${text}\x1B[0m`;
|
|
263
|
-
}
|
|
264
|
-
function applyHelpTheme(program, theme, noColor, sectionOrder, showAliases, groups) {
|
|
265
|
-
const isNoColor = () => noColor || process.argv.includes("--no-color") || process.env["NO_COLOR"] !== void 0;
|
|
266
|
-
program.configureOutput({
|
|
267
|
-
..._nullishCoalesce(program._outputConfiguration, () => ( {})),
|
|
268
|
-
getOutHasColors: () => !isNoColor(),
|
|
269
|
-
getErrHasColors: () => !isNoColor()
|
|
270
|
-
});
|
|
271
|
-
program.configureHelp({
|
|
272
|
-
// --- V14 style hooks: delegate coloring here ---
|
|
273
|
-
styleTitle(str) {
|
|
274
|
-
return isNoColor() ? str : ansiBold(theme.title, str);
|
|
275
|
-
},
|
|
276
|
-
styleUsage(str) {
|
|
277
|
-
if (isNoColor()) return str;
|
|
278
|
-
return str.split(" ").map((word) => {
|
|
279
|
-
if (word === "[options]" || word === "[--flags]")
|
|
280
|
-
return ansi(theme.dimmedArgument, word);
|
|
281
|
-
if (word[0] === "[" || word[0] === "<")
|
|
282
|
-
return ansi(theme.argument, word);
|
|
283
|
-
return ansi(theme.accent, word);
|
|
284
|
-
}).join(" ");
|
|
285
|
-
},
|
|
286
|
-
styleCommandText(str) {
|
|
287
|
-
return isNoColor() ? str : ansi(theme.accent, str);
|
|
288
|
-
},
|
|
289
|
-
styleSubcommandText(str) {
|
|
290
|
-
return isNoColor() ? str : ansi(theme.accent, str);
|
|
291
|
-
},
|
|
292
|
-
styleOptionText(str) {
|
|
293
|
-
return isNoColor() ? str : ansi(theme.secondary, str);
|
|
294
|
-
},
|
|
295
|
-
styleArgumentText(str) {
|
|
296
|
-
return isNoColor() ? str : ansi(theme.argument, str);
|
|
297
|
-
},
|
|
298
|
-
styleDescriptionText(str) {
|
|
299
|
-
return isNoColor() ? str : ansi(theme.muted, str);
|
|
300
|
-
},
|
|
301
|
-
// Color each part of option term separately (short, long, arg).
|
|
302
|
-
styleOptionTerm(str) {
|
|
303
|
-
if (isNoColor()) return str;
|
|
304
|
-
return str.split(" ").map((word) => {
|
|
305
|
-
if (word === ",") return word;
|
|
306
|
-
if (word.startsWith("<") || word.startsWith("["))
|
|
307
|
-
return ansi(theme.argument, word);
|
|
308
|
-
if (word.endsWith(","))
|
|
309
|
-
return ansi(theme.secondary, word.slice(0, -1)) + ",";
|
|
310
|
-
return ansi(theme.secondary, word);
|
|
311
|
-
}).join(" ");
|
|
312
|
-
},
|
|
313
|
-
// Color subcommand term parts: name in accent, args dimmed.
|
|
314
|
-
styleSubcommandTerm(str) {
|
|
315
|
-
if (isNoColor()) return str;
|
|
316
|
-
const words = str.split(" ");
|
|
317
|
-
return words.map((word, i) => {
|
|
318
|
-
if (i === 0) return ansi(theme.accent, word);
|
|
319
|
-
if (word.startsWith("<") || word.startsWith("["))
|
|
320
|
-
return ansi(theme.dimmedArgument, word);
|
|
321
|
-
return ansi(theme.accent, word);
|
|
322
|
-
}).join(" ");
|
|
323
|
-
},
|
|
324
|
-
// --- Term overrides ---
|
|
325
|
-
subcommandTerm(cmd) {
|
|
326
|
-
const args = cmd.registeredArguments.map((a) => a.required ? `<${a.name()}>` : `[${a.name()}]`).join(" ");
|
|
327
|
-
const hasSubcmds = cmd.commands.length > 0;
|
|
328
|
-
let term = cmd.name();
|
|
329
|
-
if (args) term += " " + args;
|
|
330
|
-
if (hasSubcmds) term += " [command]";
|
|
331
|
-
else if (cmd.options.length) term += " [--flags]";
|
|
332
|
-
return term;
|
|
333
|
-
},
|
|
334
|
-
// --- Custom formatHelp for group partitioning + section ordering ---
|
|
335
|
-
formatHelp(cmd, helper) {
|
|
336
|
-
const termWidth = helper.padWidth(cmd, helper);
|
|
337
|
-
function callFormatItem(term, description) {
|
|
338
|
-
return helper.formatItem(term, termWidth, description, helper);
|
|
339
|
-
}
|
|
340
|
-
const output = [];
|
|
341
|
-
output.push(
|
|
342
|
-
`${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`
|
|
343
|
-
);
|
|
344
|
-
output.push("");
|
|
345
|
-
const desc = helper.commandDescription(cmd);
|
|
346
|
-
if (desc) {
|
|
347
|
-
output.push(helper.styleCommandDescription(desc));
|
|
348
|
-
output.push("");
|
|
349
|
-
}
|
|
350
|
-
const argList = helper.visibleArguments(cmd);
|
|
351
|
-
if (argList.length > 0) {
|
|
352
|
-
const title = _nullishCoalesce(_optionalChain([_chunkQPUCXQXTjs.parity, 'access', _10 => _10.help, 'access', _11 => _11.sections, 'optionalAccess', _12 => _12["arguments"], 'optionalAccess', _13 => _13.title]), () => ( "ARGUMENTS"));
|
|
353
|
-
output.push(helper.styleTitle(`${title}:`));
|
|
354
|
-
for (const a of argList) {
|
|
355
|
-
output.push(callFormatItem(
|
|
356
|
-
helper.styleArgumentTerm(helper.argumentTerm(a)),
|
|
357
|
-
helper.styleArgumentDescription(helper.argumentDescription(a))
|
|
358
|
-
));
|
|
359
|
-
}
|
|
360
|
-
output.push("");
|
|
361
|
-
}
|
|
362
|
-
const helpSections = [];
|
|
363
|
-
const helpAll = process.argv.includes("--help-all");
|
|
364
|
-
let helpGroupFilter;
|
|
365
|
-
for (const arg of process.argv) {
|
|
366
|
-
const m = arg.match(/^--help-(.+)$/);
|
|
367
|
-
if (m && m[1] !== "all") {
|
|
368
|
-
helpGroupFilter = m[1];
|
|
369
|
-
break;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
const groupDefs = /* @__PURE__ */ new Map();
|
|
373
|
-
for (const g of _nullishCoalesce(groups, () => ( []))) {
|
|
374
|
-
groupDefs.set(g.id, { title: g.title, hidden: _nullishCoalesce(g.hidden, () => ( false)) });
|
|
375
|
-
}
|
|
376
|
-
const allCmds = helper.visibleCommands(cmd).filter((sc) => sc.name() !== "help");
|
|
377
|
-
const defaultCmds = [];
|
|
378
|
-
const groupedCmds = /* @__PURE__ */ new Map();
|
|
379
|
-
for (const sc of allCmds) {
|
|
380
|
-
const gid = getCommandGroup(sc);
|
|
381
|
-
if (gid && groupDefs.has(gid)) {
|
|
382
|
-
let arr = groupedCmds.get(gid);
|
|
383
|
-
if (!arr) {
|
|
384
|
-
arr = [];
|
|
385
|
-
groupedCmds.set(gid, arr);
|
|
386
|
-
}
|
|
387
|
-
arr.push(sc);
|
|
388
|
-
} else {
|
|
389
|
-
defaultCmds.push(sc);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
const buildCmdItems = (cmds) => {
|
|
393
|
-
return cmds.map((sc) => {
|
|
394
|
-
let descr = helper.subcommandDescription(sc);
|
|
395
|
-
if (showAliases && sc.aliases().length > 0) {
|
|
396
|
-
descr += ` (aliases: ${sc.aliases().join(", ")})`;
|
|
397
|
-
}
|
|
398
|
-
return callFormatItem(
|
|
399
|
-
helper.styleSubcommandTerm(helper.subcommandTerm(sc)),
|
|
400
|
-
helper.styleSubcommandDescription(descr)
|
|
401
|
-
);
|
|
402
|
-
});
|
|
403
|
-
};
|
|
404
|
-
if (defaultCmds.length > 0 && !helpGroupFilter) {
|
|
405
|
-
helpSections.push({
|
|
406
|
-
name: "commands",
|
|
407
|
-
items: buildCmdItems(defaultCmds)
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
for (const [gid, cmds] of groupedCmds) {
|
|
411
|
-
if (helpGroupFilter && gid !== helpGroupFilter) continue;
|
|
412
|
-
const def = groupDefs.get(gid);
|
|
413
|
-
if (!helpGroupFilter && def.hidden && !helpAll) continue;
|
|
414
|
-
if (cmds.length > 0) {
|
|
415
|
-
helpSections.push({ name: gid, items: buildCmdItems(cmds) });
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
const opts = helper.visibleOptions(cmd);
|
|
419
|
-
if (opts.length > 0) {
|
|
420
|
-
const flagItems = opts.map(
|
|
421
|
-
(o) => callFormatItem(
|
|
422
|
-
helper.styleOptionTerm(helper.optionTerm(o)),
|
|
423
|
-
helper.styleOptionDescription(helper.optionDescription(o))
|
|
424
|
-
)
|
|
425
|
-
);
|
|
426
|
-
helpSections.push({ name: "flags", items: flagItems });
|
|
427
|
-
}
|
|
428
|
-
const sectionMap = new Map(helpSections.map((s) => [s.name, s]));
|
|
429
|
-
const effectiveOrder = sectionOrder && sectionOrder.length > 0 ? sectionOrder : _chunkQPUCXQXTjs.parity.help.section_order;
|
|
430
|
-
const sectionTitles = _nullishCoalesce(_chunkQPUCXQXTjs.parity.help.sections, () => ( {}));
|
|
431
|
-
const resolveTitle = (name) => {
|
|
432
|
-
const gdef = groupDefs.get(name);
|
|
433
|
-
if (gdef) return gdef.title;
|
|
434
|
-
return _nullishCoalesce(_optionalChain([sectionTitles, 'access', _14 => _14[name], 'optionalAccess', _15 => _15.title]), () => ( name.charAt(0).toUpperCase() + name.slice(1)));
|
|
435
|
-
};
|
|
436
|
-
for (const name of effectiveOrder) {
|
|
437
|
-
if (name === "flags") continue;
|
|
438
|
-
const sec = sectionMap.get(name);
|
|
439
|
-
if (!sec) continue;
|
|
440
|
-
output.push(helper.styleTitle(`${resolveTitle(name)}:`));
|
|
441
|
-
output.push(...sec.items);
|
|
442
|
-
output.push("");
|
|
443
|
-
}
|
|
444
|
-
for (const sec of helpSections) {
|
|
445
|
-
if (sec.name === "flags") continue;
|
|
446
|
-
if (effectiveOrder.includes(sec.name)) continue;
|
|
447
|
-
output.push(helper.styleTitle(`${resolveTitle(sec.name)}:`));
|
|
448
|
-
output.push(...sec.items);
|
|
449
|
-
output.push("");
|
|
450
|
-
}
|
|
451
|
-
const flagsSec = sectionMap.get("flags");
|
|
452
|
-
if (flagsSec) {
|
|
453
|
-
output.push(helper.styleTitle(`${resolveTitle("flags")}:`));
|
|
454
|
-
output.push(...flagsSec.items);
|
|
455
|
-
output.push("");
|
|
456
|
-
}
|
|
457
|
-
const defs = getStreamDefs(cmd);
|
|
458
|
-
if (defs.length > 0) {
|
|
459
|
-
const styleTerm = _nullishCoalesce(_optionalChain([helper, 'access', _16 => _16.styleOptionTerm, 'optionalAccess', _17 => _17.bind, 'call', _18 => _18(helper)]), () => ( ((s) => s)));
|
|
460
|
-
const styleDesc = _nullishCoalesce(_optionalChain([helper, 'access', _19 => _19.styleDescriptionText, 'optionalAccess', _20 => _20.bind, 'call', _21 => _21(helper)]), () => ( ((s) => s)));
|
|
461
|
-
output.push(helper.styleTitle("STREAMS:"));
|
|
462
|
-
for (const d of defs) {
|
|
463
|
-
output.push(callFormatItem(styleTerm(d.name), styleDesc(d.description)));
|
|
464
|
-
}
|
|
465
|
-
output.push("");
|
|
466
|
-
}
|
|
467
|
-
return output.join("\n") + "\n";
|
|
468
|
-
}
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
function findHelpTarget(root, operands) {
|
|
472
|
-
let cmd;
|
|
473
|
-
let scope = root;
|
|
474
|
-
for (const word of operands) {
|
|
475
|
-
cmd = scope.commands.find((c) => c.name() === word || c.aliases().includes(word));
|
|
476
|
-
if (!cmd) return void 0;
|
|
477
|
-
scope = cmd;
|
|
478
|
-
}
|
|
479
|
-
return cmd;
|
|
480
|
-
}
|
|
481
|
-
function createCLI(cfg) {
|
|
482
|
-
const theme = buildTheme(cfg.accent);
|
|
483
|
-
const desc = _optionalChain([cfg, 'access', _22 => _22.help, 'optionalAccess', _23 => _23.disclaimer]) ? `${cfg.description}
|
|
484
|
-
|
|
485
|
-
${cfg.help.disclaimer}` : cfg.description;
|
|
486
|
-
const normalizedVersion = cfg.version.startsWith("v") ? cfg.version : `v${cfg.version}`;
|
|
487
|
-
const versionOutput = `${cfg.name} ${normalizedVersion}`;
|
|
488
|
-
const program = new (0, _commander.Command)(cfg.name).description(desc).version(versionOutput, "-v, --version", `Print ${cfg.name} version and exit`).helpOption("-h, --help", "Display help").addHelpCommand(false).showHelpAfterError(true);
|
|
489
|
-
if (!_optionalChain([cfg, 'access', _24 => _24.disable, 'optionalAccess', _25 => _25.format])) {
|
|
490
|
-
_chunk72XZWQX7js.registerOutputFlags.call(void 0, program);
|
|
491
|
-
}
|
|
492
|
-
if (!_optionalChain([cfg, 'access', _26 => _26.disable, 'optionalAccess', _27 => _27.quiet])) {
|
|
493
|
-
program.option("--quiet", "Suppress non-essential output", false);
|
|
494
|
-
}
|
|
495
|
-
if (!_optionalChain([cfg, 'access', _28 => _28.disable, 'optionalAccess', _29 => _29.noColor])) {
|
|
496
|
-
program.option("--no-color", "Disable ANSI colour", false);
|
|
497
|
-
}
|
|
498
|
-
if (!_optionalChain([cfg, 'access', _30 => _30.disable, 'optionalAccess', _31 => _31.hints])) {
|
|
499
|
-
program.option("--no-hints", "Suppress next-step hints after command output", false);
|
|
500
|
-
}
|
|
501
|
-
if (!_optionalChain([cfg, 'access', _32 => _32.disable, 'optionalAccess', _33 => _33.offline])) {
|
|
502
|
-
program.option("--offline", "Disable network access", false);
|
|
503
|
-
_chunkKVG7YCTSjs.install.call(void 0, );
|
|
504
|
-
const stamp = (thisCmd) => {
|
|
505
|
-
_chunkKVG7YCTSjs.setProcessOffline.call(void 0, thisCmd.opts()["offline"] === true);
|
|
506
|
-
};
|
|
507
|
-
program.hook("preSubcommand", (thisCmd) => stamp(thisCmd));
|
|
508
|
-
program.hook("preAction", (thisCmd) => stamp(thisCmd));
|
|
509
|
-
}
|
|
510
|
-
program.option(
|
|
511
|
-
verbosityFlagSpec(_chunkQPUCXQXTjs.parity),
|
|
512
|
-
"Increase verbosity",
|
|
513
|
-
(_, prev) => prev + 1,
|
|
514
|
-
0
|
|
515
|
-
);
|
|
516
|
-
program.hook("preAction", (thisCmd) => {
|
|
517
|
-
const opts = thisCmd.opts();
|
|
518
|
-
const quiet = opts.quiet === true;
|
|
519
|
-
quietMap.set(thisCmd, quiet);
|
|
520
|
-
verboseCountMap.set(thisCmd, quiet ? 0 : _nullishCoalesce(opts.verbose, () => ( 0)));
|
|
521
|
-
});
|
|
522
|
-
if (_optionalChain([cfg, 'access', _34 => _34.groups, 'optionalAccess', _35 => _35.some, 'call', _36 => _36((g) => g.hidden)])) {
|
|
523
|
-
program.option("--help-all", "Show all commands including hidden groups");
|
|
524
|
-
program.on("option:help-all", () => {
|
|
525
|
-
program.help();
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
for (const g of _nullishCoalesce(cfg.groups, () => ( []))) {
|
|
529
|
-
program.option(`--help-${g.id}`, `Show ${g.title} commands`);
|
|
530
|
-
program.on(`option:help-${g.id}`, () => {
|
|
531
|
-
program.help();
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
if (cfg.groups && cfg.groups.length > 0) {
|
|
535
|
-
const groupIds = cfg.groups.map((g) => g.id);
|
|
536
|
-
const helpCmd = program.command("help [operands...]").description("Show help for a command or command group").action((operands) => {
|
|
537
|
-
if (operands.length === 0) {
|
|
538
|
-
program.help();
|
|
539
|
-
}
|
|
540
|
-
if (operands.length === 1 && operands[0] === "all") {
|
|
541
|
-
process.argv.push("--help-all");
|
|
542
|
-
program.help();
|
|
543
|
-
}
|
|
544
|
-
const target = findHelpTarget(program, operands);
|
|
545
|
-
if (target) {
|
|
546
|
-
target.help();
|
|
547
|
-
}
|
|
548
|
-
if (operands.length === 1 && groupIds.includes(operands[0])) {
|
|
549
|
-
process.argv.push(`--help-${operands[0]}`);
|
|
550
|
-
program.help();
|
|
551
|
-
}
|
|
552
|
-
program.error(
|
|
553
|
-
`error: unknown help topic '${operands.join(" ")}' for '${program.name()}'`,
|
|
554
|
-
{ exitCode: _chunkPOR5L2DGjs.EXIT_USAGE, code: "commander.unknownCommand" }
|
|
555
|
-
);
|
|
556
|
-
});
|
|
557
|
-
helpCmd.hideHelp = true;
|
|
558
|
-
helpCmd._hidden = true;
|
|
559
|
-
}
|
|
560
|
-
for (const g of _nullishCoalesce(cfg.globals, () => ( []))) {
|
|
561
|
-
const flag = g.short ? `-${g.short}, --${g.name} <value>` : `--${g.name} <value>`;
|
|
562
|
-
program.option(flag, g.usage, _nullishCoalesce(g.default, () => ( "")));
|
|
563
|
-
}
|
|
564
|
-
_chunkJZ22ZUFAjs.installCompletionRequest.call(void 0, program);
|
|
565
|
-
applyHelpTheme(
|
|
566
|
-
program,
|
|
567
|
-
theme,
|
|
568
|
-
false,
|
|
569
|
-
_optionalChain([cfg, 'access', _37 => _37.help, 'optionalAccess', _38 => _38.sectionOrder]),
|
|
570
|
-
_optionalChain([cfg, 'access', _39 => _39.help, 'optionalAccess', _40 => _40.showAliases]),
|
|
571
|
-
cfg.groups
|
|
572
|
-
);
|
|
573
|
-
const existing = _nullishCoalesce(program._outputConfiguration, () => ( {}));
|
|
574
|
-
program.configureOutput({
|
|
575
|
-
...existing,
|
|
576
|
-
outputError(str, write) {
|
|
577
|
-
const nc = process.argv.includes("--no-color") || process.env["NO_COLOR"] !== void 0;
|
|
578
|
-
if (nc) {
|
|
579
|
-
write(str);
|
|
580
|
-
} else {
|
|
581
|
-
write(ansi(theme.error, str));
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
});
|
|
585
|
-
return { program, theme };
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
exports.HintSet = HintSet; exports.active = active; exports.hintsEnabled = hintsEnabled; exports.renderHints = renderHints; exports.registerUpgradeHints = registerUpgradeHints; exports.registerVersionHints = registerVersionHints; exports.verbosityShorthand = verbosityShorthand; exports.verbosityFlagSpec = verbosityFlagSpec; exports.verboseCount = verboseCount; exports.isQuiet = isQuiet; exports.streamFlagName = streamFlagName; exports.streamLabel = streamLabel; exports.streamOutput = streamOutput; exports.registerStream = registerStream; exports.getStreamDefs = getStreamDefs; exports.channel = channel; exports.Neon = Neon; exports.Dark = Dark; exports.buildTheme = buildTheme; exports.setCommandGroup = setCommandGroup; exports.getCommandGroup = getCommandGroup; exports.applyHelpTheme = applyHelpTheme; exports.createCLI = createCLI; exports.cli_exports = cli_exports;
|