@hop-top/kit 0.5.0-alpha.0 → 0.5.0-alpha.10

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 (284) hide show
  1. package/CHANGELOG.md +262 -0
  2. package/LICENSE +1 -1
  3. package/LICENSE-cobra.txt +174 -0
  4. package/NOTICE +15 -0
  5. package/README.md +55 -259
  6. package/dist/aim-DZHwwiIc.d.ts +139 -0
  7. package/dist/aim.d.ts +1 -116
  8. package/dist/aim.js +13 -414
  9. package/dist/alias-D9_qFlyP.d.ts +174 -0
  10. package/dist/alias.d.ts +2 -73
  11. package/dist/alias.js +27 -207
  12. package/dist/api-DAexsu2H.d.ts +77 -0
  13. package/dist/api.d.ts +1 -62
  14. package/dist/api.js +10 -164
  15. package/dist/auth-2-jfgiHn.d.ts +34 -0
  16. package/dist/auth.d.ts +1 -26
  17. package/dist/auth.js +6 -40
  18. package/dist/chunk-2JV3A7OP.js +1894 -0
  19. package/dist/chunk-3FIKGFKI.js +54 -0
  20. package/dist/chunk-4UE5TCMQ.js +104 -0
  21. package/dist/chunk-6HFAEZ52.js +29 -0
  22. package/dist/chunk-6SVOHNIC.js +17 -0
  23. package/dist/chunk-72XZWQX7.js +504 -0
  24. package/dist/chunk-ABQSE7AI.js +513 -0
  25. package/dist/chunk-BDNNPRX6.js +41 -0
  26. package/dist/chunk-BLS2OBIQ.js +263 -0
  27. package/dist/chunk-BRNEKPWX.js +37 -0
  28. package/dist/chunk-CSJWB6D3.js +151 -0
  29. package/dist/chunk-GGWJRWWA.js +309 -0
  30. package/dist/chunk-GHPJJV5L.js +613 -0
  31. package/dist/chunk-IXVQ62NZ.js +334 -0
  32. package/dist/chunk-JKMQSAJP.js +174 -0
  33. package/dist/chunk-JZ22ZUFA.js +1131 -0
  34. package/dist/chunk-K7VCKJ27.js +814 -0
  35. package/dist/chunk-KVG7YCTS.js +115 -0
  36. package/dist/chunk-L23O2FFE.js +51 -0
  37. package/dist/chunk-MQXYDYRD.js +968 -0
  38. package/dist/chunk-MUIQVU6E.js +251 -0
  39. package/dist/chunk-NLMS7HGP.js +178 -0
  40. package/dist/chunk-POR5L2DG.js +247 -0
  41. package/dist/chunk-PSFYJGDG.js +1445 -0
  42. package/dist/chunk-QJVSKKRQ.js +369 -0
  43. package/dist/chunk-QPUCXQXT.js +67 -0
  44. package/dist/chunk-QQQYCWSC.js +240 -0
  45. package/dist/chunk-R5U7XKVJ.js +16 -0
  46. package/dist/chunk-SNVGDYX7.js +187 -0
  47. package/dist/chunk-T46YPHKN.js +669 -0
  48. package/dist/chunk-UKZIAQA7.js +26 -0
  49. package/dist/chunk-WBVO43HU.js +355 -0
  50. package/dist/chunk-WUOAQVOA.js +86 -0
  51. package/dist/chunk-WWUKGJB5.js +90 -0
  52. package/dist/chunk-XJTRY453.js +868 -0
  53. package/dist/chunk-YGYQUFGY.js +219 -0
  54. package/dist/chunk-YOBAUCVN.js +583 -0
  55. package/dist/cli-C5B5tnpA.d.ts +400 -0
  56. package/dist/cli.d.ts +7 -309
  57. package/dist/cli.js +70 -885
  58. package/dist/completion-csVun6SP.d.ts +112 -0
  59. package/dist/completion-values-By-mnjNt.d.ts +142 -0
  60. package/dist/completion-values.d.ts +1 -0
  61. package/dist/completion-values.js +29 -0
  62. package/dist/completion.d.ts +3 -0
  63. package/dist/completion.js +34 -0
  64. package/dist/compliance-AxFf-uMy.d.ts +60 -0
  65. package/dist/compliance.d.ts +1 -0
  66. package/dist/compliance.js +17 -0
  67. package/dist/config-CaK60ByQ.d.ts +241 -0
  68. package/dist/config.d.ts +1 -97
  69. package/dist/config.js +8 -78
  70. package/dist/errcorrect-BcX1Ft0K.d.ts +44 -0
  71. package/dist/errcorrect.d.ts +1 -37
  72. package/dist/errcorrect.js +8 -68
  73. package/dist/error-Do8Qji43.d.ts +231 -0
  74. package/dist/id/index.d.ts +2 -83
  75. package/dist/id/index.js +14 -65
  76. package/dist/index-BKJZClJx.d.ts +1486 -0
  77. package/dist/index-C3Zw4wDJ.d.ts +359 -0
  78. package/dist/index-DCe1boBz.d.ts +328 -0
  79. package/dist/index-VLDcI5NF.d.ts +95 -0
  80. package/dist/index.d.ts +37 -0
  81. package/dist/index.js +132 -0
  82. package/dist/llm-DYuR7_uX.d.ts +1069 -0
  83. package/dist/llm-anthropic-Cd_I2xXB.d.ts +67 -0
  84. package/dist/llm-anthropic.d.ts +2 -0
  85. package/dist/llm-anthropic.js +13 -0
  86. package/dist/llm-openai-DyFrucmV.d.ts +87 -0
  87. package/dist/llm-openai.d.ts +2 -0
  88. package/dist/llm-openai.js +19 -0
  89. package/dist/llm.d.ts +1 -188
  90. package/dist/llm.js +101 -356
  91. package/dist/log-CkaxMX3U.d.ts +115 -0
  92. package/dist/log.d.ts +2 -0
  93. package/dist/log.js +14 -0
  94. package/dist/mcp/index.d.ts +4 -0
  95. package/dist/mcp/index.js +184 -0
  96. package/dist/netpolicy-Brx5XZUB.d.ts +151 -0
  97. package/dist/netpolicy.d.ts +1 -0
  98. package/dist/netpolicy.js +25 -0
  99. package/dist/output-CjZWmL8s.d.ts +420 -0
  100. package/dist/output.d.ts +3 -213
  101. package/dist/output.js +137 -447
  102. package/dist/parity-CvMuYcVI.d.ts +61 -0
  103. package/dist/progress-CAzyxeWl.d.ts +38 -0
  104. package/dist/progress.d.ts +1 -30
  105. package/dist/progress.js +6 -55
  106. package/dist/provenance-SMFHm5gx.d.ts +30 -0
  107. package/dist/provenance.d.ts +1 -24
  108. package/dist/provenance.js +6 -31
  109. package/dist/routellm-B0nv59mH.d.ts +111 -0
  110. package/dist/routellm.d.ts +2 -64
  111. package/dist/routellm.js +13 -255
  112. package/dist/rpc-D31Lg0Kc.d.ts +32 -0
  113. package/dist/rpc.d.ts +2 -25
  114. package/dist/rpc.js +4 -98
  115. package/dist/safety-CUaYEjZc.d.ts +30 -0
  116. package/dist/safety.d.ts +1 -24
  117. package/dist/safety.js +6 -43
  118. package/dist/scope-BrhYB4ij.d.ts +141 -0
  119. package/dist/scope.d.ts +1 -121
  120. package/dist/scope.js +20 -377
  121. package/dist/serve-D8yWMrTc.d.ts +646 -0
  122. package/dist/serve.d.ts +3 -0
  123. package/dist/serve.js +75 -0
  124. package/dist/sqlstore.js +6 -39
  125. package/dist/stream-CrjeCp0M.d.ts +44 -0
  126. package/dist/stream.d.ts +1 -35
  127. package/dist/stream.js +8 -51
  128. package/dist/telemetry/index.d.ts +1 -315
  129. package/dist/telemetry/index.js +26 -599
  130. package/dist/toolspec-DcPwwoAZ.d.ts +368 -0
  131. package/dist/toolspec.d.ts +2 -0
  132. package/dist/toolspec.js +37 -0
  133. package/dist/tui/index.d.ts +6 -298
  134. package/dist/tui/index.js +18 -322
  135. package/dist/upgrade-p_zh3pvV.d.ts +102 -0
  136. package/dist/upgrade.d.ts +1 -95
  137. package/dist/upgrade.js +6 -114
  138. package/dist/xdg-DB7Shoib.d.ts +179 -0
  139. package/dist/xdg.d.ts +1 -169
  140. package/dist/xdg.js +14 -128
  141. package/package.json +236 -46
  142. package/src/README.md +15 -0
  143. package/src/alias.conformance.test.ts +250 -0
  144. package/src/alias.test.ts +206 -2
  145. package/src/alias.ts +196 -21
  146. package/src/cli.help-command.test.ts +105 -0
  147. package/src/cli.offline.test.ts +93 -0
  148. package/src/cli.parity.test.ts +192 -0
  149. package/src/cli.test.ts +95 -1
  150. package/src/cli.ts +195 -25
  151. package/src/completion-scripts.ts +16 -0
  152. package/src/completion-values.test.ts +76 -16
  153. package/src/completion-values.ts +170 -66
  154. package/src/completion.conformance.test.ts +297 -0
  155. package/src/completion.test.ts +256 -145
  156. package/src/completion.ts +767 -121
  157. package/src/compliance.test.ts +196 -2
  158. package/src/compliance.ts +440 -20
  159. package/src/config-merge.test.ts +425 -0
  160. package/src/config.test.ts +228 -1
  161. package/src/config.ts +429 -16
  162. package/src/gen/crud_pb.ts +7 -7
  163. package/src/id/README.md +38 -0
  164. package/src/id/contract.test.ts +1 -1
  165. package/src/id/index.test.ts +1 -1
  166. package/src/id/index.ts +3 -2
  167. package/src/index.test.ts +71 -0
  168. package/src/index.ts +46 -0
  169. package/src/llm-anthropic.conformance.test.ts +1135 -0
  170. package/src/llm-anthropic.test.ts +152 -0
  171. package/src/llm-anthropic.ts +940 -0
  172. package/src/llm-choice-hermetic.test.ts +335 -0
  173. package/src/llm-config.test.ts +232 -0
  174. package/src/llm-config.ts +106 -0
  175. package/src/llm-endpoint.ts +254 -0
  176. package/src/llm-error.ts +17 -0
  177. package/src/llm-errors.ts +152 -0
  178. package/src/llm-file.ts +126 -0
  179. package/src/llm-http.ts +317 -0
  180. package/src/llm-keys.ts +167 -0
  181. package/src/llm-media.conformance.test.ts +87 -0
  182. package/src/llm-media.test.ts +279 -0
  183. package/src/llm-media.ts +322 -0
  184. package/src/llm-openai.conformance.test.ts +407 -0
  185. package/src/llm-openai.test.ts +510 -0
  186. package/src/llm-openai.ts +708 -0
  187. package/src/llm-payload.ts +155 -0
  188. package/src/llm-quote.ts +46 -0
  189. package/src/llm-routellm.conformance.test.ts +44 -0
  190. package/src/llm-toolnames.conformance.test.ts +112 -0
  191. package/src/llm-toolnames.test.ts +132 -0
  192. package/src/llm-toolnames.ts +298 -0
  193. package/src/llm-uri.ts +99 -0
  194. package/src/llm.test.ts +43 -15
  195. package/src/llm.toolcall.test.ts +175 -0
  196. package/src/llm.ts +602 -190
  197. package/src/log.parity.test.ts +105 -0
  198. package/src/log.test.ts +270 -1
  199. package/src/log.ts +228 -49
  200. package/src/mcp/README.md +63 -0
  201. package/src/mcp/args-separator.test.ts +164 -0
  202. package/src/mcp/args.test.ts +223 -0
  203. package/src/mcp/args.ts +160 -0
  204. package/src/mcp/audit.test.ts +520 -0
  205. package/src/mcp/audit.ts +70 -0
  206. package/src/mcp/bridge.test.ts +222 -0
  207. package/src/mcp/bridge.ts +291 -0
  208. package/src/mcp/conformance.test.ts +357 -0
  209. package/src/mcp/dispatch.ts +359 -0
  210. package/src/mcp/identity.test.ts +166 -0
  211. package/src/mcp/identity.ts +72 -0
  212. package/src/mcp/index.ts +176 -0
  213. package/src/mcp/legacy-notify.test.ts +59 -0
  214. package/src/mcp/legacy.ts +367 -0
  215. package/src/mcp/mcp.test.ts +707 -0
  216. package/src/mcp/modern-confirm.test.ts +520 -0
  217. package/src/mcp/modern-confirm.ts +484 -0
  218. package/src/mcp/modern.ts +788 -0
  219. package/src/mcp/stdio.test.ts +313 -0
  220. package/src/mcp/stdio.ts +254 -0
  221. package/src/mcp/tasks.ts +82 -0
  222. package/src/mcp/testtree.ts +250 -0
  223. package/src/mcp/toolname.test.ts +147 -0
  224. package/src/mcp/types.ts +689 -0
  225. package/src/netpolicy.test.ts +280 -0
  226. package/src/netpolicy.ts +256 -0
  227. package/src/output/README.md +46 -0
  228. package/src/output/builtins.ts +5 -5
  229. package/src/output/dispatch.ts +10 -2
  230. package/src/output/error.ts +459 -0
  231. package/src/output/formatter.ts +29 -5
  232. package/src/output/formatters/README.md +50 -0
  233. package/src/output/formatters/csv.ts +48 -12
  234. package/src/output/formatters/json.ts +4 -25
  235. package/src/output/formatters/project.ts +34 -0
  236. package/src/output/formatters/table.ts +8 -6
  237. package/src/output/formatters/text.ts +7 -3
  238. package/src/output/formatters/yaml.ts +5 -22
  239. package/src/output/projection.test.ts +298 -0
  240. package/src/output/projection.ts +33 -59
  241. package/src/output/template.ts +11 -21
  242. package/src/output.surface.test.ts +41 -0
  243. package/src/output.ts +64 -3
  244. package/src/published-types.test.ts +133 -0
  245. package/src/routellm.test.ts +209 -28
  246. package/src/routellm.toolcall.test.ts +521 -0
  247. package/src/routellm.ts +213 -177
  248. package/src/router/README.md +44 -0
  249. package/src/router/server.test.ts +41 -0
  250. package/src/router/server.ts +11 -0
  251. package/src/safety.test.ts +19 -9
  252. package/src/scope-defaults.json +29 -29
  253. package/src/serve.test.ts +1257 -0
  254. package/src/serve.ts +1665 -0
  255. package/src/telemetry/README.md +48 -0
  256. package/src/telemetry/client.test.ts +31 -0
  257. package/src/telemetry/client.ts +12 -6
  258. package/src/telemetry/offline.test.ts +64 -0
  259. package/src/toolspec-internal.ts +279 -0
  260. package/src/toolspec-manifest.test.ts +167 -0
  261. package/src/toolspec-manifest.ts +410 -0
  262. package/src/toolspec-spec-schemas.ts +12 -0
  263. package/src/toolspec-spec.test.ts +273 -0
  264. package/src/toolspec-spec.ts +458 -0
  265. package/src/toolspec.from-command.test.ts +350 -0
  266. package/src/toolspec.test.ts +2 -2
  267. package/src/toolspec.ts +222 -0
  268. package/src/triton/README.md +34 -0
  269. package/src/tui/README.md +42 -0
  270. package/src/tui/parity.test.ts +142 -0
  271. package/src/tui/parity.ts +59 -13
  272. package/src/wizard.test.ts +7 -7
  273. package/test/llm/conformance-helpers.ts +100 -0
  274. package/test/output/csv.test.ts +164 -0
  275. package/test/output/dispatch.test.ts +1 -2
  276. package/test/output/error.test.ts +277 -0
  277. package/test/output/smoke-capture.ts +2 -2
  278. package/test/output/smoke.test.ts +2 -2
  279. package/test/output/taxonomy-contract.test.ts +148 -0
  280. package/test/setup-env.ts +16 -0
  281. package/test/toolspec/fixture.ts +79 -0
  282. package/tsconfig.json +3 -1
  283. package/tsconfig.test.json +10 -0
  284. package/vitest.config.ts +9 -0
@@ -0,0 +1,613 @@
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;