@hop-top/kit 0.5.0-alpha.3 → 0.5.0-alpha.5

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.
Files changed (188) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/LICENSE +1 -1
  3. package/README.md +47 -575
  4. package/dist/{aim-CTp-kJW2.d.ts → aim-DZHwwiIc.d.ts} +1 -1
  5. package/dist/aim.d.ts +1 -1
  6. package/dist/aim.js +13 -414
  7. package/dist/{alias-dhhr08Ei.d.ts → alias-BOj0-VAr.d.ts} +1 -1
  8. package/dist/alias.d.ts +1 -1
  9. package/dist/alias.js +18 -206
  10. package/dist/{api-miiso81x.d.ts → api-DAexsu2H.d.ts} +1 -1
  11. package/dist/api.d.ts +1 -1
  12. package/dist/api.js +10 -164
  13. package/dist/auth.js +6 -40
  14. package/dist/chunk-3FIKGFKI.js +54 -0
  15. package/dist/chunk-4UE5TCMQ.js +104 -0
  16. package/dist/chunk-6HFAEZ52.js +29 -0
  17. package/dist/chunk-6SVOHNIC.js +17 -0
  18. package/dist/chunk-72XZWQX7.js +504 -0
  19. package/dist/chunk-ABQSE7AI.js +513 -0
  20. package/dist/chunk-BDNNPRX6.js +41 -0
  21. package/dist/chunk-BRNEKPWX.js +37 -0
  22. package/dist/chunk-CSJWB6D3.js +151 -0
  23. package/dist/chunk-GGWJRWWA.js +309 -0
  24. package/dist/chunk-IQXEISMC.js +142 -0
  25. package/dist/chunk-IXVQ62NZ.js +334 -0
  26. package/dist/chunk-JTMPNXVQ.js +1491 -0
  27. package/dist/chunk-KVG7YCTS.js +115 -0
  28. package/dist/chunk-L23O2FFE.js +51 -0
  29. package/dist/chunk-MQXYDYRD.js +968 -0
  30. package/dist/chunk-MUIQVU6E.js +251 -0
  31. package/dist/chunk-POR5L2DG.js +247 -0
  32. package/dist/chunk-PSFYJGDG.js +1445 -0
  33. package/dist/chunk-QJVSKKRQ.js +369 -0
  34. package/dist/chunk-QPUCXQXT.js +67 -0
  35. package/dist/chunk-R5U7XKVJ.js +16 -0
  36. package/dist/chunk-S45UHXQF.js +182 -0
  37. package/dist/chunk-T46YPHKN.js +669 -0
  38. package/dist/chunk-UKZIAQA7.js +26 -0
  39. package/dist/chunk-WBVO43HU.js +355 -0
  40. package/dist/chunk-WUOAQVOA.js +86 -0
  41. package/dist/chunk-WWUKGJB5.js +90 -0
  42. package/dist/chunk-YGYQUFGY.js +219 -0
  43. package/dist/chunk-YOBAUCVN.js +583 -0
  44. package/dist/chunk-ZC5TZYZJ.js +609 -0
  45. package/dist/{cli-DLygZLi9.d.ts → cli-8rfITnv4.d.ts} +13 -4
  46. package/dist/cli.d.ts +4 -4
  47. package/dist/cli.js +51 -1057
  48. package/dist/{config-BUY7_W2n.d.ts → config-Bm9fBXch.d.ts} +35 -4
  49. package/dist/config.d.ts +1 -1
  50. package/dist/config.js +6 -78
  51. package/dist/errcorrect.js +8 -68
  52. package/dist/{error-DISJKeDu.d.ts → error-Do8Qji43.d.ts} +88 -1
  53. package/dist/id/index.d.ts +1 -1
  54. package/dist/id/index.js +14 -65
  55. package/dist/{index-MLrRDvEG.d.ts → index-B-pqGHhU.d.ts} +113 -19
  56. package/dist/{index-Bc5c7Ty5.d.ts → index-DEyjGoo2.d.ts} +1 -1
  57. package/dist/{index-QSffbLnj.d.ts → index-VLDcI5NF.d.ts} +3 -2
  58. package/dist/index.d.ts +18 -15
  59. package/dist/index.js +39 -6722
  60. package/dist/llm-DYuR7_uX.d.ts +1069 -0
  61. package/dist/llm-anthropic-Cd_I2xXB.d.ts +67 -0
  62. package/dist/llm-anthropic.d.ts +2 -0
  63. package/dist/llm-anthropic.js +13 -0
  64. package/dist/llm-openai-DyFrucmV.d.ts +87 -0
  65. package/dist/llm-openai.d.ts +2 -0
  66. package/dist/llm-openai.js +19 -0
  67. package/dist/llm.d.ts +1 -1
  68. package/dist/llm.js +101 -356
  69. package/dist/mcp/index.d.ts +2 -1
  70. package/dist/mcp/index.js +155 -1453
  71. package/dist/{netpolicy-asvCfwi8.d.ts → netpolicy-Brx5XZUB.d.ts} +16 -3
  72. package/dist/netpolicy.d.ts +1 -1
  73. package/dist/netpolicy.js +25 -118
  74. package/dist/{output-4aXs91GY.d.ts → output-CjZWmL8s.d.ts} +28 -4
  75. package/dist/output.d.ts +2 -2
  76. package/dist/output.js +137 -971
  77. package/dist/progress.js +6 -55
  78. package/dist/provenance.js +6 -31
  79. package/dist/routellm-B0nv59mH.d.ts +111 -0
  80. package/dist/routellm.d.ts +2 -2
  81. package/dist/routellm.js +13 -255
  82. package/dist/{rpc-D5xLEf8V.d.ts → rpc-D31Lg0Kc.d.ts} +1 -1
  83. package/dist/rpc.d.ts +2 -2
  84. package/dist/rpc.js +4 -98
  85. package/dist/safety.js +6 -43
  86. package/dist/scope.js +20 -377
  87. package/dist/{serve-DE-jscpb.d.ts → serve-D8yWMrTc.d.ts} +2 -2
  88. package/dist/serve.d.ts +2 -2
  89. package/dist/serve.js +75 -1019
  90. package/dist/sqlstore.js +6 -39
  91. package/dist/stream.js +8 -51
  92. package/dist/telemetry/index.js +24 -608
  93. package/dist/tui/index.d.ts +5 -5
  94. package/dist/tui/index.js +17 -374
  95. package/dist/upgrade.js +6 -114
  96. package/dist/xdg.js +14 -128
  97. package/package.json +130 -25
  98. package/src/README.md +15 -0
  99. package/src/cli.help-command.test.ts +105 -0
  100. package/src/cli.test.ts +95 -1
  101. package/src/cli.ts +78 -13
  102. package/src/completion-values.test.ts +10 -10
  103. package/src/compliance.test.ts +196 -2
  104. package/src/compliance.ts +440 -20
  105. package/src/config.test.ts +187 -1
  106. package/src/config.ts +173 -7
  107. package/src/gen/crud_pb.ts +7 -7
  108. package/src/id/README.md +38 -0
  109. package/src/id/contract.test.ts +1 -1
  110. package/src/id/index.test.ts +1 -1
  111. package/src/id/index.ts +3 -2
  112. package/src/index.test.ts +12 -0
  113. package/src/index.ts +2 -0
  114. package/src/llm-anthropic.conformance.test.ts +1135 -0
  115. package/src/llm-anthropic.test.ts +152 -0
  116. package/src/llm-anthropic.ts +940 -0
  117. package/src/llm-choice-hermetic.test.ts +335 -0
  118. package/src/llm-config.test.ts +232 -0
  119. package/src/llm-config.ts +106 -0
  120. package/src/llm-endpoint.ts +254 -0
  121. package/src/llm-error.ts +17 -0
  122. package/src/llm-errors.ts +152 -0
  123. package/src/llm-file.ts +126 -0
  124. package/src/llm-http.ts +317 -0
  125. package/src/llm-keys.ts +167 -0
  126. package/src/llm-media.conformance.test.ts +87 -0
  127. package/src/llm-media.test.ts +279 -0
  128. package/src/llm-media.ts +322 -0
  129. package/src/llm-openai.conformance.test.ts +407 -0
  130. package/src/llm-openai.test.ts +510 -0
  131. package/src/llm-openai.ts +708 -0
  132. package/src/llm-payload.ts +155 -0
  133. package/src/llm-quote.ts +46 -0
  134. package/src/llm-routellm.conformance.test.ts +44 -0
  135. package/src/llm-toolnames.conformance.test.ts +112 -0
  136. package/src/llm-toolnames.test.ts +132 -0
  137. package/src/llm-toolnames.ts +298 -0
  138. package/src/llm-uri.ts +99 -0
  139. package/src/llm.test.ts +43 -15
  140. package/src/llm.toolcall.test.ts +175 -0
  141. package/src/llm.ts +602 -190
  142. package/src/mcp/README.md +57 -0
  143. package/src/mcp/conformance.test.ts +24 -3
  144. package/src/mcp/dispatch.ts +4 -4
  145. package/src/mcp/identity.test.ts +166 -0
  146. package/src/mcp/identity.ts +72 -0
  147. package/src/mcp/index.ts +6 -0
  148. package/src/mcp/legacy.ts +21 -8
  149. package/src/mcp/mcp.test.ts +14 -4
  150. package/src/mcp/modern-confirm.ts +1 -1
  151. package/src/mcp/modern.ts +12 -11
  152. package/src/mcp/tasks.ts +1 -1
  153. package/src/mcp/types.ts +80 -8
  154. package/src/netpolicy.test.ts +78 -0
  155. package/src/netpolicy.ts +28 -3
  156. package/src/output/README.md +46 -0
  157. package/src/output/builtins.ts +5 -5
  158. package/src/output/error.ts +144 -1
  159. package/src/output/formatters/README.md +50 -0
  160. package/src/output.ts +24 -1
  161. package/src/published-types.test.ts +115 -0
  162. package/src/routellm.test.ts +209 -28
  163. package/src/routellm.toolcall.test.ts +521 -0
  164. package/src/routellm.ts +213 -177
  165. package/src/router/README.md +44 -0
  166. package/src/router/server.test.ts +41 -0
  167. package/src/router/server.ts +11 -0
  168. package/src/safety.test.ts +19 -9
  169. package/src/scope-defaults.json +29 -29
  170. package/src/serve.ts +1 -1
  171. package/src/telemetry/README.md +48 -0
  172. package/src/telemetry/client.ts +5 -5
  173. package/src/toolspec.test.ts +2 -2
  174. package/src/triton/README.md +34 -0
  175. package/src/tui/README.md +42 -0
  176. package/src/wizard.test.ts +7 -7
  177. package/test/llm/conformance-helpers.ts +100 -0
  178. package/test/output/dispatch.test.ts +1 -2
  179. package/test/output/error.test.ts +33 -2
  180. package/test/output/smoke-capture.ts +2 -2
  181. package/test/output/smoke.test.ts +2 -2
  182. package/test/output/taxonomy-contract.test.ts +148 -0
  183. package/test/setup-env.ts +16 -0
  184. package/tsconfig.json +3 -1
  185. package/tsconfig.test.json +10 -0
  186. package/vitest.config.ts +9 -0
  187. package/dist/llm-B5XUWH8T.d.ts +0 -231
  188. package/dist/routellm-PGSt2D1y.d.ts +0 -75
@@ -0,0 +1,609 @@
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 _chunkQPUCXQXTjs = require('./chunk-QPUCXQXT.js');
4
+
5
+
6
+ var _chunk72XZWQX7js = require('./chunk-72XZWQX7.js');
7
+
8
+
9
+ var _chunkPOR5L2DGjs = require('./chunk-POR5L2DG.js');
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+ var _chunkKVG7YCTSjs = require('./chunk-KVG7YCTS.js');
20
+
21
+
22
+ var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
23
+
24
+ // src/cli.ts
25
+ var cli_exports = {};
26
+ _chunkR5U7XKVJjs.__export.call(void 0, cli_exports, {
27
+ Dark: () => Dark,
28
+ ErrOffline: () => _chunkKVG7YCTSjs.ErrOffline,
29
+ HintSet: () => HintSet,
30
+ Neon: () => Neon,
31
+ OfflineError: () => _chunkKVG7YCTSjs.OfflineError,
32
+ active: () => active,
33
+ applyHelpTheme: () => applyHelpTheme,
34
+ buildTheme: () => buildTheme,
35
+ channel: () => channel,
36
+ createCLI: () => createCLI,
37
+ getCommandGroup: () => getCommandGroup,
38
+ getStreamDefs: () => getStreamDefs,
39
+ guardFetch: () => _chunkKVG7YCTSjs.guardFetch,
40
+ hintsEnabled: () => hintsEnabled,
41
+ isOffline: () => _chunkKVG7YCTSjs.isOffline,
42
+ isOfflineError: () => _chunkKVG7YCTSjs.isOfflineError,
43
+ isQuiet: () => isQuiet,
44
+ registerStream: () => registerStream,
45
+ registerUpgradeHints: () => registerUpgradeHints,
46
+ registerVersionHints: () => registerVersionHints,
47
+ renderHints: () => renderHints,
48
+ setCommandGroup: () => setCommandGroup,
49
+ streamFlagName: () => streamFlagName,
50
+ streamLabel: () => streamLabel,
51
+ streamOutput: () => streamOutput,
52
+ verboseCount: () => verboseCount,
53
+ verbosityFlagSpec: () => verbosityFlagSpec,
54
+ verbosityShorthand: () => verbosityShorthand,
55
+ withOffline: () => _chunkKVG7YCTSjs.withOffline
56
+ });
57
+ var _commander = require('commander');
58
+
59
+ // src/hint.ts
60
+ var HintSet = class {
61
+ constructor() {
62
+ this.m = /* @__PURE__ */ new Map();
63
+ }
64
+ /** Add one or more hints for the given command name. */
65
+ register(cmd, ...hints) {
66
+ const existing = _nullishCoalesce(this.m.get(cmd), () => ( []));
67
+ this.m.set(cmd, [...existing, ...hints]);
68
+ }
69
+ /**
70
+ * Return a copy of the hints registered for cmd.
71
+ * Returns an empty array when none are registered.
72
+ */
73
+ lookup(cmd) {
74
+ return [..._nullishCoalesce(this.m.get(cmd), () => ( []))];
75
+ }
76
+ };
77
+ function active(hints) {
78
+ return hints.filter((h) => h.condition === void 0 || h.condition());
79
+ }
80
+ function hintsEnabled(opts) {
81
+ if (opts.noHints) return false;
82
+ if (opts.hintsEnabled === false) return false;
83
+ if (opts.quiet) return false;
84
+ const env = process.env["HOP_QUIET_HINTS"];
85
+ if (env === "1" || env === "true" || env === "yes") return false;
86
+ return true;
87
+ }
88
+ function renderHints(w, hints, format, opts, muted) {
89
+ if (format !== "table") return;
90
+ if (!hintsEnabled(opts)) return;
91
+ const isTTY = w.isTTY === true;
92
+ if (!isTTY) return;
93
+ const visible = active(hints);
94
+ if (visible.length === 0) return;
95
+ const noColor = process.env["NO_COLOR"] !== void 0 || process.argv.includes("--no-color");
96
+ w.write("\n");
97
+ for (const h of visible) {
98
+ const text = `\u2192 ${h.message}`;
99
+ if (noColor) {
100
+ w.write(text + "\n");
101
+ } else {
102
+ const hex = muted.replace("#", "");
103
+ const r = parseInt(hex.slice(0, 2), 16);
104
+ const g = parseInt(hex.slice(2, 4), 16);
105
+ const b = parseInt(hex.slice(4, 6), 16);
106
+ w.write(`\x1B[38;2;${r};${g};${b}m${text}\x1B[0m
107
+ `);
108
+ }
109
+ }
110
+ }
111
+ function registerUpgradeHints(hints, binary, upgraded) {
112
+ hints.register("upgrade", {
113
+ message: `Run \`${binary} version\` to verify.`,
114
+ condition: upgraded
115
+ });
116
+ }
117
+ function registerVersionHints(hints, binary, updateAvail) {
118
+ hints.register("version", {
119
+ message: `Run \`${binary} upgrade\` to get latest.`,
120
+ condition: updateAvail
121
+ });
122
+ }
123
+
124
+ // src/cli.ts
125
+ var verboseCountMap = /* @__PURE__ */ new WeakMap();
126
+ var quietMap = /* @__PURE__ */ new WeakMap();
127
+ function verbosityShorthand(d) {
128
+ const s = (_nullishCoalesce(_optionalChain([d, 'access', _2 => _2.verbosity, 'optionalAccess', _3 => _3.flag]), () => ( ""))).replace(/^-+/, "");
129
+ return s.length === 1 ? s : "V";
130
+ }
131
+ function verbosityFlagSpec(d) {
132
+ return `-${verbosityShorthand(d)}, --verbose`;
133
+ }
134
+ function verboseCount(cmd) {
135
+ let c = cmd;
136
+ while (c) {
137
+ const v = verboseCountMap.get(c);
138
+ if (v !== void 0) return v;
139
+ c = _nullishCoalesce(c.parent, () => ( null));
140
+ }
141
+ return 0;
142
+ }
143
+ function isQuiet(cmd) {
144
+ let c = cmd;
145
+ while (c) {
146
+ const q = quietMap.get(c);
147
+ if (q !== void 0) return q;
148
+ c = _nullishCoalesce(c.parent, () => ( null));
149
+ }
150
+ return false;
151
+ }
152
+ var streamDefsMap = /* @__PURE__ */ new WeakMap();
153
+ function streamFlagName(d) {
154
+ const name = (_nullishCoalesce(_optionalChain([d, 'access', _4 => _4.streams, 'optionalAccess', _5 => _5.flag]), () => ( ""))).replace(/^-+/, "");
155
+ return name === "" ? "stream" : name;
156
+ }
157
+ function streamLabel(d, name) {
158
+ const format = _optionalChain([d, 'access', _6 => _6.streams, 'optionalAccess', _7 => _7.label_format]) || "[{name}]";
159
+ return format.split("{name}").join(name) + " ";
160
+ }
161
+ function streamOutput(d) {
162
+ return _optionalChain([d, 'access', _8 => _8.streams, 'optionalAccess', _9 => _9.output]) === "stdout" ? process.stdout : process.stderr;
163
+ }
164
+ function registerStream(cmd, name, description) {
165
+ let defs = streamDefsMap.get(cmd);
166
+ if (!defs) {
167
+ defs = [];
168
+ streamDefsMap.set(cmd, defs);
169
+ cmd.option(
170
+ `--${streamFlagName(_chunkQPUCXQXTjs.parity)} <names>`,
171
+ "Enable diagnostic streams (comma-separated)"
172
+ );
173
+ }
174
+ defs.push({ name, description });
175
+ }
176
+ function getStreamDefs(cmd) {
177
+ return _nullishCoalesce(streamDefsMap.get(cmd), () => ( []));
178
+ }
179
+ var noopWriter = { write(_s) {
180
+ return true;
181
+ } };
182
+ function optionKey(flagName) {
183
+ return flagName.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
184
+ }
185
+ function channel(cmd, name) {
186
+ const opts = cmd.opts();
187
+ const raw = opts[optionKey(streamFlagName(_chunkQPUCXQXTjs.parity))];
188
+ const enabled = typeof raw === "string" ? raw.split(",").map((s) => s.trim()).includes(name) : false;
189
+ if (!enabled) return noopWriter;
190
+ const prefix = streamLabel(_chunkQPUCXQXTjs.parity, name);
191
+ const w = streamOutput(_chunkQPUCXQXTjs.parity);
192
+ return {
193
+ write(s) {
194
+ const lines = s.split("\n");
195
+ for (const line of lines) {
196
+ if (line) w.write(`${prefix}${line}
197
+ `);
198
+ }
199
+ return true;
200
+ }
201
+ };
202
+ }
203
+ var Neon = {
204
+ command: "#7ED957",
205
+ // grass green
206
+ flag: "#FF00FF"
207
+ // vivid neon pink
208
+ };
209
+ var Dark = {
210
+ command: "#C1FF72",
211
+ // lime
212
+ flag: "#FF66C4"
213
+ // pink
214
+ };
215
+ function buildTheme(accent) {
216
+ const palette = { ...Neon };
217
+ if (accent) {
218
+ palette.command = accent;
219
+ }
220
+ return {
221
+ palette,
222
+ accent: palette.command,
223
+ secondary: palette.flag,
224
+ muted: "#858183",
225
+ // CharmTone Squid
226
+ error: "#ED4A5E",
227
+ // CharmTone Cherry
228
+ success: "#52CF84",
229
+ // CharmTone Guac
230
+ title: "#FFFFFF",
231
+ // fang ColorScheme.Title
232
+ argument: "#B5E89B",
233
+ // fang ColorScheme.Argument
234
+ dimmedArgument: "#8ABF6E"
235
+ // fang ColorScheme.DimmedArgument
236
+ };
237
+ }
238
+ var commandGroupMap = /* @__PURE__ */ new WeakMap();
239
+ function setCommandGroup(cmd, groupId) {
240
+ commandGroupMap.set(cmd, groupId);
241
+ }
242
+ function getCommandGroup(cmd) {
243
+ return commandGroupMap.get(cmd);
244
+ }
245
+ function hexToRgb(hex) {
246
+ const h = hex.replace("#", "");
247
+ return [
248
+ parseInt(h.slice(0, 2), 16),
249
+ parseInt(h.slice(2, 4), 16),
250
+ parseInt(h.slice(4, 6), 16)
251
+ ];
252
+ }
253
+ function ansi(hex, text) {
254
+ const [r, g, b] = hexToRgb(hex);
255
+ return `\x1B[38;2;${r};${g};${b}m${text}\x1B[0m`;
256
+ }
257
+ function ansiBold(hex, text) {
258
+ const [r, g, b] = hexToRgb(hex);
259
+ return `\x1B[1;38;2;${r};${g};${b}m${text}\x1B[0m`;
260
+ }
261
+ function applyHelpTheme(program, theme, noColor, sectionOrder, showAliases, groups) {
262
+ const isNoColor = () => noColor || process.argv.includes("--no-color") || process.env["NO_COLOR"] !== void 0;
263
+ program.configureOutput({
264
+ ..._nullishCoalesce(program._outputConfiguration, () => ( {})),
265
+ getOutHasColors: () => !isNoColor(),
266
+ getErrHasColors: () => !isNoColor()
267
+ });
268
+ program.configureHelp({
269
+ // --- V14 style hooks: delegate coloring here ---
270
+ styleTitle(str) {
271
+ return isNoColor() ? str : ansiBold(theme.title, str);
272
+ },
273
+ styleUsage(str) {
274
+ if (isNoColor()) return str;
275
+ return str.split(" ").map((word) => {
276
+ if (word === "[options]" || word === "[--flags]")
277
+ return ansi(theme.dimmedArgument, word);
278
+ if (word[0] === "[" || word[0] === "<")
279
+ return ansi(theme.argument, word);
280
+ return ansi(theme.accent, word);
281
+ }).join(" ");
282
+ },
283
+ styleCommandText(str) {
284
+ return isNoColor() ? str : ansi(theme.accent, str);
285
+ },
286
+ styleSubcommandText(str) {
287
+ return isNoColor() ? str : ansi(theme.accent, str);
288
+ },
289
+ styleOptionText(str) {
290
+ return isNoColor() ? str : ansi(theme.secondary, str);
291
+ },
292
+ styleArgumentText(str) {
293
+ return isNoColor() ? str : ansi(theme.argument, str);
294
+ },
295
+ styleDescriptionText(str) {
296
+ return isNoColor() ? str : ansi(theme.muted, str);
297
+ },
298
+ // Color each part of option term separately (short, long, arg).
299
+ styleOptionTerm(str) {
300
+ if (isNoColor()) return str;
301
+ return str.split(" ").map((word) => {
302
+ if (word === ",") return word;
303
+ if (word.startsWith("<") || word.startsWith("["))
304
+ return ansi(theme.argument, word);
305
+ if (word.endsWith(","))
306
+ return ansi(theme.secondary, word.slice(0, -1)) + ",";
307
+ return ansi(theme.secondary, word);
308
+ }).join(" ");
309
+ },
310
+ // Color subcommand term parts: name in accent, args dimmed.
311
+ styleSubcommandTerm(str) {
312
+ if (isNoColor()) return str;
313
+ const words = str.split(" ");
314
+ return words.map((word, i) => {
315
+ if (i === 0) return ansi(theme.accent, word);
316
+ if (word.startsWith("<") || word.startsWith("["))
317
+ return ansi(theme.dimmedArgument, word);
318
+ return ansi(theme.accent, word);
319
+ }).join(" ");
320
+ },
321
+ // --- Term overrides ---
322
+ subcommandTerm(cmd) {
323
+ const args = cmd.registeredArguments.map((a) => a.required ? `<${a.name()}>` : `[${a.name()}]`).join(" ");
324
+ const hasSubcmds = cmd.commands.length > 0;
325
+ let term = cmd.name();
326
+ if (args) term += " " + args;
327
+ if (hasSubcmds) term += " [command]";
328
+ else if (cmd.options.length) term += " [--flags]";
329
+ return term;
330
+ },
331
+ // --- Custom formatHelp for group partitioning + section ordering ---
332
+ formatHelp(cmd, helper) {
333
+ const termWidth = helper.padWidth(cmd, helper);
334
+ function callFormatItem(term, description) {
335
+ return helper.formatItem(term, termWidth, description, helper);
336
+ }
337
+ const output = [];
338
+ output.push(
339
+ `${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`
340
+ );
341
+ output.push("");
342
+ const desc = helper.commandDescription(cmd);
343
+ if (desc) {
344
+ output.push(helper.styleCommandDescription(desc));
345
+ output.push("");
346
+ }
347
+ const argList = helper.visibleArguments(cmd);
348
+ if (argList.length > 0) {
349
+ const title = _nullishCoalesce(_optionalChain([_chunkQPUCXQXTjs.parity, 'access', _10 => _10.help, 'access', _11 => _11.sections, 'optionalAccess', _12 => _12["arguments"], 'optionalAccess', _13 => _13.title]), () => ( "ARGUMENTS"));
350
+ output.push(helper.styleTitle(`${title}:`));
351
+ for (const a of argList) {
352
+ output.push(callFormatItem(
353
+ helper.styleArgumentTerm(helper.argumentTerm(a)),
354
+ helper.styleArgumentDescription(helper.argumentDescription(a))
355
+ ));
356
+ }
357
+ output.push("");
358
+ }
359
+ const helpSections = [];
360
+ const helpAll = process.argv.includes("--help-all");
361
+ let helpGroupFilter;
362
+ for (const arg of process.argv) {
363
+ const m = arg.match(/^--help-(.+)$/);
364
+ if (m && m[1] !== "all") {
365
+ helpGroupFilter = m[1];
366
+ break;
367
+ }
368
+ }
369
+ const groupDefs = /* @__PURE__ */ new Map();
370
+ for (const g of _nullishCoalesce(groups, () => ( []))) {
371
+ groupDefs.set(g.id, { title: g.title, hidden: _nullishCoalesce(g.hidden, () => ( false)) });
372
+ }
373
+ const allCmds = helper.visibleCommands(cmd).filter((sc) => sc.name() !== "help");
374
+ const defaultCmds = [];
375
+ const groupedCmds = /* @__PURE__ */ new Map();
376
+ for (const sc of allCmds) {
377
+ const gid = getCommandGroup(sc);
378
+ if (gid && groupDefs.has(gid)) {
379
+ let arr = groupedCmds.get(gid);
380
+ if (!arr) {
381
+ arr = [];
382
+ groupedCmds.set(gid, arr);
383
+ }
384
+ arr.push(sc);
385
+ } else {
386
+ defaultCmds.push(sc);
387
+ }
388
+ }
389
+ const buildCmdItems = (cmds) => {
390
+ return cmds.map((sc) => {
391
+ let descr = helper.subcommandDescription(sc);
392
+ if (showAliases && sc.aliases().length > 0) {
393
+ descr += ` (aliases: ${sc.aliases().join(", ")})`;
394
+ }
395
+ return callFormatItem(
396
+ helper.styleSubcommandTerm(helper.subcommandTerm(sc)),
397
+ helper.styleSubcommandDescription(descr)
398
+ );
399
+ });
400
+ };
401
+ if (defaultCmds.length > 0 && !helpGroupFilter) {
402
+ helpSections.push({
403
+ name: "commands",
404
+ items: buildCmdItems(defaultCmds)
405
+ });
406
+ }
407
+ for (const [gid, cmds] of groupedCmds) {
408
+ if (helpGroupFilter && gid !== helpGroupFilter) continue;
409
+ const def = groupDefs.get(gid);
410
+ if (!helpGroupFilter && def.hidden && !helpAll) continue;
411
+ if (cmds.length > 0) {
412
+ helpSections.push({ name: gid, items: buildCmdItems(cmds) });
413
+ }
414
+ }
415
+ const opts = helper.visibleOptions(cmd);
416
+ if (opts.length > 0) {
417
+ const flagItems = opts.map(
418
+ (o) => callFormatItem(
419
+ helper.styleOptionTerm(helper.optionTerm(o)),
420
+ helper.styleOptionDescription(helper.optionDescription(o))
421
+ )
422
+ );
423
+ helpSections.push({ name: "flags", items: flagItems });
424
+ }
425
+ const sectionMap = new Map(helpSections.map((s) => [s.name, s]));
426
+ const effectiveOrder = sectionOrder && sectionOrder.length > 0 ? sectionOrder : _chunkQPUCXQXTjs.parity.help.section_order;
427
+ const sectionTitles = _nullishCoalesce(_chunkQPUCXQXTjs.parity.help.sections, () => ( {}));
428
+ const resolveTitle = (name) => {
429
+ const gdef = groupDefs.get(name);
430
+ if (gdef) return gdef.title;
431
+ return _nullishCoalesce(_optionalChain([sectionTitles, 'access', _14 => _14[name], 'optionalAccess', _15 => _15.title]), () => ( name.charAt(0).toUpperCase() + name.slice(1)));
432
+ };
433
+ for (const name of effectiveOrder) {
434
+ if (name === "flags") continue;
435
+ const sec = sectionMap.get(name);
436
+ if (!sec) continue;
437
+ output.push(helper.styleTitle(`${resolveTitle(name)}:`));
438
+ output.push(...sec.items);
439
+ output.push("");
440
+ }
441
+ for (const sec of helpSections) {
442
+ if (sec.name === "flags") continue;
443
+ if (effectiveOrder.includes(sec.name)) continue;
444
+ output.push(helper.styleTitle(`${resolveTitle(sec.name)}:`));
445
+ output.push(...sec.items);
446
+ output.push("");
447
+ }
448
+ const flagsSec = sectionMap.get("flags");
449
+ if (flagsSec) {
450
+ output.push(helper.styleTitle(`${resolveTitle("flags")}:`));
451
+ output.push(...flagsSec.items);
452
+ output.push("");
453
+ }
454
+ const defs = getStreamDefs(cmd);
455
+ if (defs.length > 0) {
456
+ const styleTerm = _nullishCoalesce(_optionalChain([helper, 'access', _16 => _16.styleOptionTerm, 'optionalAccess', _17 => _17.bind, 'call', _18 => _18(helper)]), () => ( ((s) => s)));
457
+ const styleDesc = _nullishCoalesce(_optionalChain([helper, 'access', _19 => _19.styleDescriptionText, 'optionalAccess', _20 => _20.bind, 'call', _21 => _21(helper)]), () => ( ((s) => s)));
458
+ output.push(helper.styleTitle("STREAMS:"));
459
+ for (const d of defs) {
460
+ output.push(callFormatItem(styleTerm(d.name), styleDesc(d.description)));
461
+ }
462
+ output.push("");
463
+ }
464
+ return output.join("\n") + "\n";
465
+ }
466
+ });
467
+ }
468
+ function findHelpTarget(root, operands) {
469
+ let cmd;
470
+ let scope = root;
471
+ for (const word of operands) {
472
+ cmd = scope.commands.find((c) => c.name() === word || c.aliases().includes(word));
473
+ if (!cmd) return void 0;
474
+ scope = cmd;
475
+ }
476
+ return cmd;
477
+ }
478
+ function createCLI(cfg) {
479
+ const theme = buildTheme(cfg.accent);
480
+ const desc = _optionalChain([cfg, 'access', _22 => _22.help, 'optionalAccess', _23 => _23.disclaimer]) ? `${cfg.description}
481
+
482
+ ${cfg.help.disclaimer}` : cfg.description;
483
+ const normalizedVersion = cfg.version.startsWith("v") ? cfg.version : `v${cfg.version}`;
484
+ const versionOutput = `${cfg.name} ${normalizedVersion}`;
485
+ 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);
486
+ if (!_optionalChain([cfg, 'access', _24 => _24.disable, 'optionalAccess', _25 => _25.format])) {
487
+ _chunk72XZWQX7js.registerOutputFlags.call(void 0, program);
488
+ }
489
+ if (!_optionalChain([cfg, 'access', _26 => _26.disable, 'optionalAccess', _27 => _27.quiet])) {
490
+ program.option("--quiet", "Suppress non-essential output", false);
491
+ }
492
+ if (!_optionalChain([cfg, 'access', _28 => _28.disable, 'optionalAccess', _29 => _29.noColor])) {
493
+ program.option("--no-color", "Disable ANSI colour", false);
494
+ }
495
+ if (!_optionalChain([cfg, 'access', _30 => _30.disable, 'optionalAccess', _31 => _31.hints])) {
496
+ program.option("--no-hints", "Suppress next-step hints after command output", false);
497
+ }
498
+ if (!_optionalChain([cfg, 'access', _32 => _32.disable, 'optionalAccess', _33 => _33.offline])) {
499
+ program.option("--offline", "Disable network access", false);
500
+ _chunkKVG7YCTSjs.install.call(void 0, );
501
+ const stamp = (thisCmd) => {
502
+ _chunkKVG7YCTSjs.setProcessOffline.call(void 0, thisCmd.opts()["offline"] === true);
503
+ };
504
+ program.hook("preSubcommand", (thisCmd) => stamp(thisCmd));
505
+ program.hook("preAction", (thisCmd) => stamp(thisCmd));
506
+ }
507
+ program.option(
508
+ verbosityFlagSpec(_chunkQPUCXQXTjs.parity),
509
+ "Increase verbosity",
510
+ (_, prev) => prev + 1,
511
+ 0
512
+ );
513
+ program.hook("preAction", (thisCmd) => {
514
+ const opts = thisCmd.opts();
515
+ const quiet = opts.quiet === true;
516
+ quietMap.set(thisCmd, quiet);
517
+ verboseCountMap.set(thisCmd, quiet ? 0 : _nullishCoalesce(opts.verbose, () => ( 0)));
518
+ });
519
+ if (_optionalChain([cfg, 'access', _34 => _34.groups, 'optionalAccess', _35 => _35.some, 'call', _36 => _36((g) => g.hidden)])) {
520
+ program.option("--help-all", "Show all commands including hidden groups");
521
+ program.on("option:help-all", () => {
522
+ program.help();
523
+ });
524
+ }
525
+ for (const g of _nullishCoalesce(cfg.groups, () => ( []))) {
526
+ program.option(`--help-${g.id}`, `Show ${g.title} commands`);
527
+ program.on(`option:help-${g.id}`, () => {
528
+ program.help();
529
+ });
530
+ }
531
+ if (cfg.groups && cfg.groups.length > 0) {
532
+ const groupIds = cfg.groups.map((g) => g.id);
533
+ const helpCmd = program.command("help [operands...]").description("Show help for a command or command group").action((operands) => {
534
+ if (operands.length === 0) {
535
+ program.help();
536
+ }
537
+ if (operands.length === 1 && operands[0] === "all") {
538
+ process.argv.push("--help-all");
539
+ program.help();
540
+ }
541
+ const target = findHelpTarget(program, operands);
542
+ if (target) {
543
+ target.help();
544
+ }
545
+ if (operands.length === 1 && groupIds.includes(operands[0])) {
546
+ process.argv.push(`--help-${operands[0]}`);
547
+ program.help();
548
+ }
549
+ program.error(
550
+ `error: unknown help topic '${operands.join(" ")}' for '${program.name()}'`,
551
+ { exitCode: _chunkPOR5L2DGjs.EXIT_USAGE, code: "commander.unknownCommand" }
552
+ );
553
+ });
554
+ helpCmd.hideHelp = true;
555
+ helpCmd._hidden = true;
556
+ }
557
+ for (const g of _nullishCoalesce(cfg.globals, () => ( []))) {
558
+ const flag = g.short ? `-${g.short}, --${g.name} <value>` : `--${g.name} <value>`;
559
+ program.option(flag, g.usage, _nullishCoalesce(g.default, () => ( "")));
560
+ }
561
+ applyHelpTheme(
562
+ program,
563
+ theme,
564
+ false,
565
+ _optionalChain([cfg, 'access', _37 => _37.help, 'optionalAccess', _38 => _38.sectionOrder]),
566
+ _optionalChain([cfg, 'access', _39 => _39.help, 'optionalAccess', _40 => _40.showAliases]),
567
+ cfg.groups
568
+ );
569
+ const existing = _nullishCoalesce(program._outputConfiguration, () => ( {}));
570
+ program.configureOutput({
571
+ ...existing,
572
+ outputError(str, write) {
573
+ const nc = process.argv.includes("--no-color") || process.env["NO_COLOR"] !== void 0;
574
+ if (nc) {
575
+ write(str);
576
+ } else {
577
+ write(ansi(theme.error, str));
578
+ }
579
+ }
580
+ });
581
+ return { program, theme };
582
+ }
583
+
584
+
585
+
586
+
587
+
588
+
589
+
590
+
591
+
592
+
593
+
594
+
595
+
596
+
597
+
598
+
599
+
600
+
601
+
602
+
603
+
604
+
605
+
606
+
607
+
608
+
609
+ 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;
@@ -1,7 +1,7 @@
1
1
  import { Command } from 'commander';
2
- import { E as ErrOffline, O as OfflineError, g as guardFetch, a as isOffline, b as isOfflineError, w as withOffline } from './netpolicy-asvCfwi8.js';
2
+ import { E as ErrOffline, O as OfflineError, g as guardFetch, i as isOffline, a as isOfflineError, w as withOffline } from './netpolicy-Brx5XZUB.js';
3
3
  import { Writable } from 'node:stream';
4
- import { F as Format } from './output-4aXs91GY.js';
4
+ import { F as Format } from './output-CjZWmL8s.js';
5
5
 
6
6
  /**
7
7
  * @module tui/parity
@@ -192,6 +192,14 @@ declare function verbosityShorthand(d: ParityData): string;
192
192
  declare function verbosityFlagSpec(d: ParityData): string;
193
193
  /** Read the accumulated -V count for a parsed command tree. */
194
194
  declare function verboseCount(cmd: Command): number;
195
+ /**
196
+ * Report whether `--quiet` is in effect for a parsed command tree.
197
+ *
198
+ * `--quiet` wins over `-V`: when set, `verboseCount` reads 0 and the
199
+ * logger level is the contract's `verbosity.quiet_override`. False before
200
+ * parsing and when `disable.quiet` drops the flag.
201
+ */
202
+ declare function isQuiet(cmd: Command): boolean;
195
203
  interface StreamDef {
196
204
  name: string;
197
205
  description: string;
@@ -431,6 +439,7 @@ declare const cli_guardFetch: typeof guardFetch;
431
439
  declare const cli_hintsEnabled: typeof hintsEnabled;
432
440
  declare const cli_isOffline: typeof isOffline;
433
441
  declare const cli_isOfflineError: typeof isOfflineError;
442
+ declare const cli_isQuiet: typeof isQuiet;
434
443
  declare const cli_registerStream: typeof registerStream;
435
444
  declare const cli_registerUpgradeHints: typeof registerUpgradeHints;
436
445
  declare const cli_registerVersionHints: typeof registerVersionHints;
@@ -444,7 +453,7 @@ declare const cli_verbosityFlagSpec: typeof verbosityFlagSpec;
444
453
  declare const cli_verbosityShorthand: typeof verbosityShorthand;
445
454
  declare const cli_withOffline: typeof withOffline;
446
455
  declare namespace cli {
447
- export { type cli_CLIConfig as CLIConfig, type cli_CLIResult as CLIResult, cli_Dark as Dark, cli_ErrOffline as ErrOffline, type cli_Hint as Hint, type cli_HintOptions as HintOptions, cli_HintSet as HintSet, cli_Neon as Neon, cli_OfflineError as OfflineError, type cli_Palette as Palette, type cli_Theme as Theme, cli_active as active, cli_applyHelpTheme as applyHelpTheme, cli_buildTheme as buildTheme, cli_channel as channel, cli_createCLI as createCLI, cli_getCommandGroup as getCommandGroup, cli_getStreamDefs as getStreamDefs, cli_guardFetch as guardFetch, cli_hintsEnabled as hintsEnabled, cli_isOffline as isOffline, cli_isOfflineError as isOfflineError, cli_registerStream as registerStream, cli_registerUpgradeHints as registerUpgradeHints, cli_registerVersionHints as registerVersionHints, cli_renderHints as renderHints, cli_setCommandGroup as setCommandGroup, cli_streamFlagName as streamFlagName, cli_streamLabel as streamLabel, cli_streamOutput as streamOutput, cli_verboseCount as verboseCount, cli_verbosityFlagSpec as verbosityFlagSpec, cli_verbosityShorthand as verbosityShorthand, cli_withOffline as withOffline };
456
+ export { type cli_CLIConfig as CLIConfig, type cli_CLIResult as CLIResult, cli_Dark as Dark, cli_ErrOffline as ErrOffline, type cli_Hint as Hint, type cli_HintOptions as HintOptions, cli_HintSet as HintSet, cli_Neon as Neon, cli_OfflineError as OfflineError, type cli_Palette as Palette, type cli_Theme as Theme, cli_active as active, cli_applyHelpTheme as applyHelpTheme, cli_buildTheme as buildTheme, cli_channel as channel, cli_createCLI as createCLI, cli_getCommandGroup as getCommandGroup, cli_getStreamDefs as getStreamDefs, cli_guardFetch as guardFetch, cli_hintsEnabled as hintsEnabled, cli_isOffline as isOffline, cli_isOfflineError as isOfflineError, cli_isQuiet as isQuiet, cli_registerStream as registerStream, cli_registerUpgradeHints as registerUpgradeHints, cli_registerVersionHints as registerVersionHints, cli_renderHints as renderHints, cli_setCommandGroup as setCommandGroup, cli_streamFlagName as streamFlagName, cli_streamLabel as streamLabel, cli_streamOutput as streamOutput, cli_verboseCount as verboseCount, cli_verbosityFlagSpec as verbosityFlagSpec, cli_verbosityShorthand as verbosityShorthand, cli_withOffline as withOffline };
448
457
  }
449
458
 
450
- export { type CLIConfig as C, Dark as D, type Hint as H, Neon as N, type Palette as P, type Theme as T, type CLIResult as a, type HintOptions as b, HintSet as c, active as d, applyHelpTheme as e, buildTheme as f, channel as g, cli as h, createCLI as i, getCommandGroup as j, getStreamDefs as k, hintsEnabled as l, registerUpgradeHints as m, registerVersionHints as n, renderHints as o, streamFlagName as p, streamLabel as q, registerStream as r, setCommandGroup as s, streamOutput as t, verbosityFlagSpec as u, verboseCount as v, verbosityShorthand as w };
459
+ export { type CLIConfig as C, Dark as D, type Hint as H, Neon as N, type Palette as P, type Theme as T, type CLIResult as a, type HintOptions as b, cli as c, HintSet as d, active as e, applyHelpTheme as f, buildTheme as g, channel as h, createCLI as i, getCommandGroup as j, getStreamDefs as k, hintsEnabled as l, isQuiet as m, registerUpgradeHints as n, registerVersionHints as o, renderHints as p, streamFlagName as q, registerStream as r, setCommandGroup as s, streamLabel as t, streamOutput as u, verboseCount as v, verbosityFlagSpec as w, verbosityShorthand as x };
package/dist/cli.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'commander';
2
- export { C as CLIConfig, a as CLIResult, D as Dark, H as Hint, b as HintOptions, c as HintSet, N as Neon, P as Palette, T as Theme, d as active, e as applyHelpTheme, f as buildTheme, g as channel, i as createCLI, j as getCommandGroup, k as getStreamDefs, l as hintsEnabled, r as registerStream, m as registerUpgradeHints, n as registerVersionHints, o as renderHints, s as setCommandGroup, p as streamFlagName, q as streamLabel, t as streamOutput, v as verboseCount, u as verbosityFlagSpec, w as verbosityShorthand } from './cli-DLygZLi9.js';
3
- export { E as ErrOffline, O as OfflineError, g as guardFetch, a as isOffline, b as isOfflineError, w as withOffline } from './netpolicy-asvCfwi8.js';
2
+ export { C as CLIConfig, a as CLIResult, D as Dark, H as Hint, b as HintOptions, d as HintSet, N as Neon, P as Palette, T as Theme, e as active, f as applyHelpTheme, g as buildTheme, h as channel, i as createCLI, j as getCommandGroup, k as getStreamDefs, l as hintsEnabled, m as isQuiet, r as registerStream, n as registerUpgradeHints, o as registerVersionHints, p as renderHints, s as setCommandGroup, q as streamFlagName, t as streamLabel, u as streamOutput, v as verboseCount, w as verbosityFlagSpec, x as verbosityShorthand } from './cli-8rfITnv4.js';
3
+ export { E as ErrOffline, O as OfflineError, g as guardFetch, i as isOffline, a as isOfflineError, w as withOffline } from './netpolicy-Brx5XZUB.js';
4
4
  import 'node:stream';
5
- import './output-4aXs91GY.js';
6
- import './error-DISJKeDu.js';
5
+ import './output-CjZWmL8s.js';
6
+ import './error-Do8Qji43.js';