@hop-top/kit 0.5.0-alpha.1 → 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 (285) hide show
  1. package/CHANGELOG.md +251 -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 -945
  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 +17 -381
  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 +192 -24
  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 +120 -31
  271. package/src/tui/parity.ts +58 -7
  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
  285. package/src/tui/parity.json +0 -74
package/dist/cli.js CHANGED
@@ -1,945 +1,70 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/cli.ts
31
- var cli_exports = {};
32
- __export(cli_exports, {
33
- Dark: () => Dark,
34
- HintSet: () => HintSet,
35
- Neon: () => Neon,
36
- active: () => active,
37
- applyHelpTheme: () => applyHelpTheme,
38
- buildTheme: () => buildTheme,
39
- channel: () => channel,
40
- createCLI: () => createCLI,
41
- getCommandGroup: () => getCommandGroup,
42
- getStreamDefs: () => getStreamDefs,
43
- hintsEnabled: () => hintsEnabled,
44
- registerStream: () => registerStream,
45
- registerUpgradeHints: () => registerUpgradeHints,
46
- registerVersionHints: () => registerVersionHints,
47
- renderHints: () => renderHints,
48
- setCommandGroup: () => setCommandGroup,
49
- verboseCount: () => verboseCount
50
- });
51
- module.exports = __toCommonJS(cli_exports);
52
- var import_commander = require("commander");
53
-
54
- // src/tui/parity.json
55
- var parity_default = {
56
- $schema: "https://json-schema.org/draft/2020-12/schema",
57
- $id: "https://hop.top/kit/go/console/tui/parity.json",
58
- description: "Cross-language TUI parity constants. All language implementations MUST load values from here.",
59
- status: {
60
- description: "Prefix symbols for status lines. Mirrors Go's InfoType constants in tui/status.go.",
61
- symbols: {
62
- info: "\u2139",
63
- success: "\u2713",
64
- error: "\u25CF",
65
- warn: "\u25B2"
66
- }
67
- },
68
- spinner: {
69
- description: "Braille dot spinner frames and timing.",
70
- frames: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"],
71
- interval_ms: 80
72
- },
73
- anim: {
74
- description: "Gradient character-scramble animation constants.",
75
- runes: "0123456789abcdefABCDEF~!@#$%^&*()+=_",
76
- interval_ms: 100,
77
- default_width: 10
78
- },
79
- help: {
80
- description: "Root --help layout contract. Fang is canonical; TS and Python mirror it.",
81
- section_order: ["commands", "flags"],
82
- sections: {
83
- usage: { title: "USAGE" },
84
- commands: { title: "COMMANDS" },
85
- flags: { title: "FLAGS" },
86
- "global flags": { title: "GLOBAL FLAGS" },
87
- arguments: { title: "ARGUMENTS" },
88
- aliases: { title: "ALIASES" },
89
- examples: { title: "EXAMPLES" },
90
- streams: { title: "STREAMS" }
91
- }
92
- },
93
- verbosity: {
94
- description: "Stackable -V flag maps count to log level. --quiet overrides to warn.",
95
- flag: "-V",
96
- levels: {
97
- "0": "info",
98
- "1": "debug",
99
- "2": "trace"
100
- },
101
- quiet_override: "warn"
102
- },
103
- streams: {
104
- description: "Per-command named output streams toggled via --stream flag.",
105
- flag: "--stream",
106
- label_format: "[{name}]",
107
- output: "stderr"
108
- },
109
- table: {
110
- description: "Styled-table contract for the output package. Plain tabwriter is the default; callers opt in to the lipgloss-backed renderer via WithTableStyle. The styled path is gated on writer-is-TTY so non-TTY writers (pipes, files, tests) always emit ANSI-free, diff-friendly output.",
111
- render_option: "WithTableStyle",
112
- tty_only: true,
113
- row_emphasis_kinds: ["none", "primary", "secondary", "muted"],
114
- row_emphasis_option: "RowEmphasis",
115
- border_default: "normal"
116
- },
117
- extends: [
118
- "scope-defaults.json"
119
- ]
120
- };
121
-
122
- // src/tui/parity.ts
123
- var parity = parity_default;
124
-
125
- // src/output/registry.ts
126
- var Registry = class {
127
- constructor() {
128
- this.byKey = /* @__PURE__ */ new Map();
129
- }
130
- /**
131
- * Adds f to the registry. Throws Error on duplicate key or empty key.
132
- * Use `override` to intentionally replace.
133
- */
134
- register(f) {
135
- if (f.key === "") {
136
- throw new Error("output: formatter key is empty");
137
- }
138
- if (this.byKey.has(f.key)) {
139
- throw new Error(
140
- `output: formatter "${f.key}" already registered (use override to replace)`
141
- );
142
- }
143
- this.byKey.set(f.key, f);
144
- }
145
- /** Replaces (or registers) the formatter for f.key. */
146
- override(f) {
147
- if (f.key === "") {
148
- throw new Error("output: formatter key is empty");
149
- }
150
- this.byKey.set(f.key, f);
151
- }
152
- /** Returns the formatter registered under key, if any. */
153
- lookup(key) {
154
- return this.byKey.get(key);
155
- }
156
- /** Returns all registered format keys, sorted alphabetically. */
157
- keys() {
158
- return [...this.byKey.keys()].sort();
159
- }
160
- /** Returns all registered formatters in key order. */
161
- formatters() {
162
- return this.keys().map((k) => this.byKey.get(k));
163
- }
164
- /**
165
- * Returns extension→key mappings (e.g. ".csv" → "csv") across all
166
- * registered formatters. Later registrations win on collision; iteration
167
- * is in sorted-key order so resolution is deterministic.
168
- */
169
- extensionMap() {
170
- const out = /* @__PURE__ */ new Map();
171
- for (const k of this.keys()) {
172
- const f = this.byKey.get(k);
173
- if (!f) continue;
174
- for (const ext of f.extensions) {
175
- out.set(ext.toLowerCase(), k);
176
- }
177
- }
178
- return out;
179
- }
180
- };
181
- var defaultRegistry = new Registry();
182
-
183
- // src/output/flags.ts
184
- var registryStash = /* @__PURE__ */ new WeakMap();
185
- function registerOutputFlags(program, opts = {}) {
186
- const registry = opts.registry ?? defaultRegistry;
187
- const d = opts.disable ?? {};
188
- if (registry !== defaultRegistry) {
189
- registryStash.set(program, registry);
190
- }
191
- if (!d.format) {
192
- program.option(
193
- "--format <fmt>",
194
- `Output format (${registry.keys().join(", ")})`,
195
- "table"
196
- );
197
- }
198
- if (!d.formatOpt) {
199
- const opt = program.createOption(
200
- "--format-opt <kv...>",
201
- "Per-format option as key=value (repeatable; bool keys may omit =value)"
202
- ).default([]).argParser(collectKv);
203
- opt.hidden = true;
204
- program.addOption(opt);
205
- }
206
- if (!d.formatHelp) {
207
- const opt = program.createOption(
208
- "--format-help [fmt]",
209
- "Show available formats and their options (use --format-help <key> for one)"
210
- );
211
- opt.hidden = true;
212
- program.addOption(opt);
213
- }
214
- if (!d.cols) {
215
- const colsOpt = program.createOption("--cols <cols...>", "Restrict columns to this comma-separated list (repeatable)").default([]).argParser(collectCols);
216
- colsOpt.hidden = true;
217
- program.addOption(colsOpt);
218
- const columnsOpt = program.createOption("--columns <cols...>", "Alias for --cols").default([]).argParser(collectCols);
219
- columnsOpt.hidden = true;
220
- program.addOption(columnsOpt);
221
- }
222
- if (!d.template) {
223
- const opt = program.createOption(
224
- "--template <tpl>",
225
- "eta template applied to results (mutually exclusive with --cols)"
226
- );
227
- opt.hidden = true;
228
- program.addOption(opt);
229
- }
230
- if (!d.output) {
231
- const opt = program.createOption("-o, --output <path>", "Write output to path (use - or empty for stdout)").default("");
232
- opt.hidden = true;
233
- program.addOption(opt);
234
- }
235
- }
236
- function collectKv(value, prev) {
237
- return [...prev, value];
238
- }
239
- function collectCols(value, prev) {
240
- return [...prev, ...value.split(",")];
241
- }
242
-
243
- // src/output/formatters/json.ts
244
- var jsonFormatter = {
245
- key: "json",
246
- extensions: [".json"],
247
- options: [
248
- { name: "indent", type: "int", default: 2, usage: "spaces per indent level" }
249
- ],
250
- render(out, data, opts, cols) {
251
- const indent = opts["indent"] ?? 2;
252
- const value = projectForJson(data, cols);
253
- out.write(JSON.stringify(value, null, indent) + "\n");
254
- }
255
- };
256
- function projectForJson(data, cols) {
257
- if (cols.length === 0) return data;
258
- if (Array.isArray(data)) {
259
- return data.map((row) => projectRow(row, cols));
260
- }
261
- return projectRow(data, cols);
262
- }
263
- function projectRow(row, cols) {
264
- if (row === null || typeof row !== "object") return row;
265
- const r = row;
266
- const out = {};
267
- for (const c of cols) out[c] = r[c];
268
- return out;
269
- }
270
-
271
- // src/output/formatters/yaml.ts
272
- var yaml = __toESM(require("js-yaml"));
273
- var yamlFormatter = {
274
- key: "yaml",
275
- extensions: [".yaml", ".yml"],
276
- options: [
277
- {
278
- name: "flow-level",
279
- type: "int",
280
- default: -1,
281
- usage: "level at which to switch from block to flow style"
282
- }
283
- ],
284
- render(out, data, opts, cols) {
285
- const flowLevel = opts["flow-level"] ?? -1;
286
- const value = projectForYaml(data, cols);
287
- out.write(yaml.dump(value, { flowLevel }));
288
- }
289
- };
290
- function projectForYaml(data, cols) {
291
- if (cols.length === 0) return data;
292
- if (Array.isArray(data)) {
293
- return data.map((row) => projectRow2(row, cols));
294
- }
295
- return projectRow2(data, cols);
296
- }
297
- function projectRow2(row, cols) {
298
- if (row === null || typeof row !== "object") return row;
299
- const r = row;
300
- const out = {};
301
- for (const c of cols) out[c] = r[c];
302
- return out;
303
- }
304
-
305
- // src/output/formatters/table.ts
306
- var tableFormatter = {
307
- key: "table",
308
- extensions: [],
309
- options: [],
310
- render(out, data, _opts, cols) {
311
- const rows = normalise(data);
312
- if (rows.length === 0) return;
313
- const allHeaders = Object.keys(rows[0] ?? {});
314
- const headers = cols.length > 0 ? cols.filter((c) => allHeaders.includes(c)) : allHeaders;
315
- if (headers.length === 0) return;
316
- const cells = rows.map(
317
- (row) => headers.map((h) => String(row[h] ?? ""))
318
- );
319
- const widths = headers.map(
320
- (h, ci) => Math.max(h.length, ...cells.map((r) => r[ci].length))
321
- );
322
- const pad = (s, w) => s + " ".repeat(w - s.length);
323
- const line = (parts) => parts.map((c, i) => pad(c, widths[i])).join(" ");
324
- out.write(line(headers) + "\n");
325
- for (const row of cells) {
326
- out.write(line(row) + "\n");
327
- }
328
- }
329
- };
330
- function normalise(v) {
331
- if (Array.isArray(v)) return v;
332
- return [v];
333
- }
334
-
335
- // src/output/formatters/csv.ts
336
- var import_sync = require("csv-stringify/sync");
337
- var csvFormatter = {
338
- key: "csv",
339
- extensions: [".csv"],
340
- options: [
341
- { name: "delimiter", type: "string", default: ",", usage: "field delimiter" },
342
- { name: "no-header", type: "bool", default: false, usage: "omit header row" },
343
- {
344
- name: "quote-all",
345
- type: "bool",
346
- default: false,
347
- usage: "quote every field, not just those needing it"
348
- },
349
- {
350
- name: "crlf",
351
- type: "bool",
352
- default: false,
353
- usage: "use CRLF line endings (default LF)"
354
- }
355
- ],
356
- render(out, data, opts, cols) {
357
- const rows = normalise2(data);
358
- if (rows.length === 0) return;
359
- const allHeaders = Object.keys(rows[0] ?? {});
360
- const headers = cols.length > 0 ? cols.filter((c) => allHeaders.includes(c)) : allHeaders;
361
- if (headers.length === 0) return;
362
- const delimiter = opts["delimiter"] ?? ",";
363
- const noHeader = opts["no-header"] ?? false;
364
- const quoteAll = opts["quote-all"] ?? false;
365
- const crlf = opts["crlf"] ?? false;
366
- if (delimiter.length !== 1) {
367
- throw new Error(`option "delimiter": delimiter must be exactly one character`);
368
- }
369
- const records = rows.map((r) => headers.map((h) => stringify_cell(r[h])));
370
- const csvRows = noHeader ? records : [headers, ...records];
371
- const text = (0, import_sync.stringify)(csvRows, {
372
- delimiter,
373
- record_delimiter: crlf ? "windows" : "unix",
374
- quoted: quoteAll
375
- // No `header: true` — we already prepend headers ourselves to keep
376
- // row layout uniform with csv format and to make `no-header` toggle
377
- // a single decision point.
378
- });
379
- out.write(text);
380
- }
381
- };
382
- function normalise2(v) {
383
- if (Array.isArray(v)) return v;
384
- return [v];
385
- }
386
- function stringify_cell(v) {
387
- if (v === null || v === void 0) return "";
388
- return String(v);
389
- }
390
-
391
- // src/output/formatters/text.ts
392
- var STYLE_KV = "kv";
393
- var STYLE_LINES = "lines";
394
- var STYLE_PARAGRAPH = "paragraph";
395
- var textFormatter = {
396
- key: "text",
397
- extensions: [".txt"],
398
- options: [
399
- {
400
- name: "style",
401
- type: "enum",
402
- default: STYLE_KV,
403
- enum: [STYLE_KV, STYLE_LINES, STYLE_PARAGRAPH],
404
- usage: "output style"
405
- },
406
- {
407
- name: "separator",
408
- type: "string",
409
- default: "=",
410
- usage: "kv separator (kv style only)"
411
- }
412
- ],
413
- render(out, data, opts, cols) {
414
- const rows = normalise3(data);
415
- if (rows.length === 0) return;
416
- const allHeaders = Object.keys(rows[0] ?? {});
417
- const headers = cols.length > 0 ? cols.filter((c) => allHeaders.includes(c)) : allHeaders;
418
- if (headers.length === 0) return;
419
- const style = opts["style"] || STYLE_KV;
420
- const sep = opts["separator"] || "=";
421
- switch (style) {
422
- case STYLE_KV:
423
- return renderKV(out, rows, headers, sep);
424
- case STYLE_LINES:
425
- return renderLines(out, rows, headers);
426
- case STYLE_PARAGRAPH:
427
- return renderParagraph(out, rows, headers);
428
- }
429
- }
430
- };
431
- function normalise3(v) {
432
- if (Array.isArray(v)) return v;
433
- return [v];
434
- }
435
- function fmt(v) {
436
- if (v === null || v === void 0) return "";
437
- return String(v);
438
- }
439
- function renderKV(out, rows, headers, sep) {
440
- rows.forEach((r, i) => {
441
- if (i > 0) out.write("\n");
442
- for (const h of headers) {
443
- out.write(`${h}${sep}${fmt(r[h])}
444
- `);
445
- }
446
- });
447
- }
448
- function renderLines(out, rows, headers) {
449
- for (const r of rows) {
450
- out.write(headers.map((h) => fmt(r[h])).join(" ") + "\n");
451
- }
452
- }
453
- function renderParagraph(out, rows, headers) {
454
- rows.forEach((r, i) => {
455
- if (i > 0) out.write("\n");
456
- out.write(`Record ${i + 1}:
457
- `);
458
- for (const h of headers) {
459
- out.write(` ${h}: ${fmt(r[h])}
460
- `);
461
- }
462
- });
463
- }
464
-
465
- // src/output/builtins.ts
466
- var registered = false;
467
- function registerBuiltins() {
468
- if (registered) return;
469
- defaultRegistry.register(jsonFormatter);
470
- defaultRegistry.register(yamlFormatter);
471
- defaultRegistry.register(tableFormatter);
472
- defaultRegistry.register(csvFormatter);
473
- defaultRegistry.register(textFormatter);
474
- registered = true;
475
- }
476
- registerBuiltins();
477
-
478
- // src/hint.ts
479
- var HintSet = class {
480
- constructor() {
481
- this.m = /* @__PURE__ */ new Map();
482
- }
483
- /** Add one or more hints for the given command name. */
484
- register(cmd, ...hints) {
485
- const existing = this.m.get(cmd) ?? [];
486
- this.m.set(cmd, [...existing, ...hints]);
487
- }
488
- /**
489
- * Return a copy of the hints registered for cmd.
490
- * Returns an empty array when none are registered.
491
- */
492
- lookup(cmd) {
493
- return [...this.m.get(cmd) ?? []];
494
- }
495
- };
496
- function active(hints) {
497
- return hints.filter((h) => h.condition === void 0 || h.condition());
498
- }
499
- function hintsEnabled(opts) {
500
- if (opts.noHints) return false;
501
- if (opts.hintsEnabled === false) return false;
502
- if (opts.quiet) return false;
503
- const env = process.env["HOP_QUIET_HINTS"];
504
- if (env === "1" || env === "true" || env === "yes") return false;
505
- return true;
506
- }
507
- function renderHints(w, hints, format, opts, muted) {
508
- if (format !== "table") return;
509
- if (!hintsEnabled(opts)) return;
510
- const isTTY = w.isTTY === true;
511
- if (!isTTY) return;
512
- const visible = active(hints);
513
- if (visible.length === 0) return;
514
- const noColor = process.env["NO_COLOR"] !== void 0 || process.argv.includes("--no-color");
515
- w.write("\n");
516
- for (const h of visible) {
517
- const text = `\u2192 ${h.message}`;
518
- if (noColor) {
519
- w.write(text + "\n");
520
- } else {
521
- const hex = muted.replace("#", "");
522
- const r = parseInt(hex.slice(0, 2), 16);
523
- const g = parseInt(hex.slice(2, 4), 16);
524
- const b = parseInt(hex.slice(4, 6), 16);
525
- w.write(`\x1B[38;2;${r};${g};${b}m${text}\x1B[0m
526
- `);
527
- }
528
- }
529
- }
530
- function registerUpgradeHints(hints, binary, upgraded) {
531
- hints.register("upgrade", {
532
- message: `Run \`${binary} version\` to verify.`,
533
- condition: upgraded
534
- });
535
- }
536
- function registerVersionHints(hints, binary, updateAvail) {
537
- hints.register("version", {
538
- message: `Run \`${binary} upgrade\` to get latest.`,
539
- condition: updateAvail
540
- });
541
- }
542
-
543
- // src/cli.ts
544
- var verboseCountMap = /* @__PURE__ */ new WeakMap();
545
- function verboseCount(cmd) {
546
- let c = cmd;
547
- while (c) {
548
- const v = verboseCountMap.get(c);
549
- if (v !== void 0) return v;
550
- c = c.parent ?? null;
551
- }
552
- return 0;
553
- }
554
- var streamDefsMap = /* @__PURE__ */ new WeakMap();
555
- function registerStream(cmd, name, description) {
556
- let defs = streamDefsMap.get(cmd);
557
- if (!defs) {
558
- defs = [];
559
- streamDefsMap.set(cmd, defs);
560
- cmd.option(
561
- "--stream <names>",
562
- "Enable diagnostic streams (comma-separated)"
563
- );
564
- }
565
- defs.push({ name, description });
566
- }
567
- function getStreamDefs(cmd) {
568
- return streamDefsMap.get(cmd) ?? [];
569
- }
570
- var noopWriter = { write(_s) {
571
- return true;
572
- } };
573
- function channel(cmd, name) {
574
- const opts = cmd.opts();
575
- const enabled = typeof opts.stream === "string" ? opts.stream.split(",").map((s) => s.trim()).includes(name) : false;
576
- if (!enabled) return noopWriter;
577
- return {
578
- write(s) {
579
- const lines = s.split("\n");
580
- for (const line of lines) {
581
- if (line) process.stderr.write(`[${name}] ${line}
582
- `);
583
- }
584
- return true;
585
- }
586
- };
587
- }
588
- var Neon = {
589
- command: "#7ED957",
590
- // grass green
591
- flag: "#FF00FF"
592
- // vivid neon pink
593
- };
594
- var Dark = {
595
- command: "#C1FF72",
596
- // lime
597
- flag: "#FF66C4"
598
- // pink
599
- };
600
- function buildTheme(accent) {
601
- const palette = { ...Neon };
602
- if (accent) {
603
- palette.command = accent;
604
- }
605
- return {
606
- palette,
607
- accent: palette.command,
608
- secondary: palette.flag,
609
- muted: "#858183",
610
- // CharmTone Squid
611
- error: "#ED4A5E",
612
- // CharmTone Cherry
613
- success: "#52CF84",
614
- // CharmTone Guac
615
- title: "#FFFFFF",
616
- // fang ColorScheme.Title
617
- argument: "#B5E89B",
618
- // fang ColorScheme.Argument
619
- dimmedArgument: "#8ABF6E"
620
- // fang ColorScheme.DimmedArgument
621
- };
622
- }
623
- var commandGroupMap = /* @__PURE__ */ new WeakMap();
624
- function setCommandGroup(cmd, groupId) {
625
- commandGroupMap.set(cmd, groupId);
626
- }
627
- function getCommandGroup(cmd) {
628
- return commandGroupMap.get(cmd);
629
- }
630
- function hexToRgb(hex) {
631
- const h = hex.replace("#", "");
632
- return [
633
- parseInt(h.slice(0, 2), 16),
634
- parseInt(h.slice(2, 4), 16),
635
- parseInt(h.slice(4, 6), 16)
636
- ];
637
- }
638
- function ansi(hex, text) {
639
- const [r, g, b] = hexToRgb(hex);
640
- return `\x1B[38;2;${r};${g};${b}m${text}\x1B[0m`;
641
- }
642
- function ansiBold(hex, text) {
643
- const [r, g, b] = hexToRgb(hex);
644
- return `\x1B[1;38;2;${r};${g};${b}m${text}\x1B[0m`;
645
- }
646
- function applyHelpTheme(program, theme, noColor, sectionOrder, showAliases, groups) {
647
- const isNoColor = () => noColor || process.argv.includes("--no-color") || process.env["NO_COLOR"] !== void 0;
648
- program.configureOutput({
649
- ...program._outputConfiguration ?? {},
650
- getOutHasColors: () => !isNoColor(),
651
- getErrHasColors: () => !isNoColor()
652
- });
653
- program.configureHelp({
654
- // --- V14 style hooks: delegate coloring here ---
655
- styleTitle(str) {
656
- return isNoColor() ? str : ansiBold(theme.title, str);
657
- },
658
- styleUsage(str) {
659
- if (isNoColor()) return str;
660
- return str.split(" ").map((word) => {
661
- if (word === "[options]" || word === "[--flags]")
662
- return ansi(theme.dimmedArgument, word);
663
- if (word[0] === "[" || word[0] === "<")
664
- return ansi(theme.argument, word);
665
- return ansi(theme.accent, word);
666
- }).join(" ");
667
- },
668
- styleCommandText(str) {
669
- return isNoColor() ? str : ansi(theme.accent, str);
670
- },
671
- styleSubcommandText(str) {
672
- return isNoColor() ? str : ansi(theme.accent, str);
673
- },
674
- styleOptionText(str) {
675
- return isNoColor() ? str : ansi(theme.secondary, str);
676
- },
677
- styleArgumentText(str) {
678
- return isNoColor() ? str : ansi(theme.argument, str);
679
- },
680
- styleDescriptionText(str) {
681
- return isNoColor() ? str : ansi(theme.muted, str);
682
- },
683
- // Color each part of option term separately (short, long, arg).
684
- styleOptionTerm(str) {
685
- if (isNoColor()) return str;
686
- return str.split(" ").map((word) => {
687
- if (word === ",") return word;
688
- if (word.startsWith("<") || word.startsWith("["))
689
- return ansi(theme.argument, word);
690
- if (word.endsWith(","))
691
- return ansi(theme.secondary, word.slice(0, -1)) + ",";
692
- return ansi(theme.secondary, word);
693
- }).join(" ");
694
- },
695
- // Color subcommand term parts: name in accent, args dimmed.
696
- styleSubcommandTerm(str) {
697
- if (isNoColor()) return str;
698
- const words = str.split(" ");
699
- return words.map((word, i) => {
700
- if (i === 0) return ansi(theme.accent, word);
701
- if (word.startsWith("<") || word.startsWith("["))
702
- return ansi(theme.dimmedArgument, word);
703
- return ansi(theme.accent, word);
704
- }).join(" ");
705
- },
706
- // --- Term overrides ---
707
- subcommandTerm(cmd) {
708
- const args = cmd.registeredArguments.map((a) => a.required ? `<${a.name()}>` : `[${a.name()}]`).join(" ");
709
- const hasSubcmds = cmd.commands.length > 0;
710
- let term = cmd.name();
711
- if (args) term += " " + args;
712
- if (hasSubcmds) term += " [command]";
713
- else if (cmd.options.length) term += " [--flags]";
714
- return term;
715
- },
716
- // --- Custom formatHelp for group partitioning + section ordering ---
717
- formatHelp(cmd, helper) {
718
- const termWidth = helper.padWidth(cmd, helper);
719
- function callFormatItem(term, description) {
720
- return helper.formatItem(term, termWidth, description, helper);
721
- }
722
- const output = [];
723
- output.push(
724
- `${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`
725
- );
726
- output.push("");
727
- const desc = helper.commandDescription(cmd);
728
- if (desc) {
729
- output.push(helper.styleCommandDescription(desc));
730
- output.push("");
731
- }
732
- const helpSections = [];
733
- const helpAll = process.argv.includes("--help-all");
734
- let helpGroupFilter;
735
- for (const arg of process.argv) {
736
- const m = arg.match(/^--help-(.+)$/);
737
- if (m && m[1] !== "all") {
738
- helpGroupFilter = m[1];
739
- break;
740
- }
741
- }
742
- const groupDefs = /* @__PURE__ */ new Map();
743
- for (const g of groups ?? []) {
744
- groupDefs.set(g.id, { title: g.title, hidden: g.hidden ?? false });
745
- }
746
- const allCmds = helper.visibleCommands(cmd).filter((sc) => sc.name() !== "help");
747
- const defaultCmds = [];
748
- const groupedCmds = /* @__PURE__ */ new Map();
749
- for (const sc of allCmds) {
750
- const gid = getCommandGroup(sc);
751
- if (gid && groupDefs.has(gid)) {
752
- let arr = groupedCmds.get(gid);
753
- if (!arr) {
754
- arr = [];
755
- groupedCmds.set(gid, arr);
756
- }
757
- arr.push(sc);
758
- } else {
759
- defaultCmds.push(sc);
760
- }
761
- }
762
- const buildCmdItems = (cmds) => {
763
- return cmds.map((sc) => {
764
- let descr = helper.subcommandDescription(sc);
765
- if (showAliases && sc.aliases().length > 0) {
766
- descr += ` (aliases: ${sc.aliases().join(", ")})`;
767
- }
768
- return callFormatItem(
769
- helper.styleSubcommandTerm(helper.subcommandTerm(sc)),
770
- helper.styleSubcommandDescription(descr)
771
- );
772
- });
773
- };
774
- if (defaultCmds.length > 0 && !helpGroupFilter) {
775
- helpSections.push({
776
- name: "commands",
777
- items: buildCmdItems(defaultCmds)
778
- });
779
- }
780
- for (const [gid, cmds] of groupedCmds) {
781
- if (helpGroupFilter && gid !== helpGroupFilter) continue;
782
- const def = groupDefs.get(gid);
783
- if (!helpGroupFilter && def.hidden && !helpAll) continue;
784
- if (cmds.length > 0) {
785
- helpSections.push({ name: gid, items: buildCmdItems(cmds) });
786
- }
787
- }
788
- const opts = helper.visibleOptions(cmd);
789
- if (opts.length > 0) {
790
- const flagItems = opts.map(
791
- (o) => callFormatItem(
792
- helper.styleOptionTerm(helper.optionTerm(o)),
793
- helper.styleOptionDescription(helper.optionDescription(o))
794
- )
795
- );
796
- helpSections.push({ name: "flags", items: flagItems });
797
- }
798
- const sectionMap = new Map(helpSections.map((s) => [s.name, s]));
799
- const effectiveOrder = sectionOrder && sectionOrder.length > 0 ? sectionOrder : parity.help.section_order;
800
- const sectionTitles = parity.help.sections ?? {};
801
- const resolveTitle = (name) => {
802
- const gdef = groupDefs.get(name);
803
- if (gdef) return gdef.title;
804
- return sectionTitles[name]?.title ?? name.charAt(0).toUpperCase() + name.slice(1);
805
- };
806
- for (const name of effectiveOrder) {
807
- if (name === "flags") continue;
808
- const sec = sectionMap.get(name);
809
- if (!sec) continue;
810
- output.push(helper.styleTitle(`${resolveTitle(name)}:`));
811
- output.push(...sec.items);
812
- output.push("");
813
- }
814
- for (const sec of helpSections) {
815
- if (sec.name === "flags") continue;
816
- if (effectiveOrder.includes(sec.name)) continue;
817
- output.push(helper.styleTitle(`${resolveTitle(sec.name)}:`));
818
- output.push(...sec.items);
819
- output.push("");
820
- }
821
- const flagsSec = sectionMap.get("flags");
822
- if (flagsSec) {
823
- output.push(helper.styleTitle(`${resolveTitle("flags")}:`));
824
- output.push(...flagsSec.items);
825
- output.push("");
826
- }
827
- const defs = getStreamDefs(cmd);
828
- if (defs.length > 0) {
829
- const styleTerm = helper.styleOptionTerm?.bind(helper) ?? ((s) => s);
830
- const styleDesc = helper.styleDescriptionText?.bind(helper) ?? ((s) => s);
831
- output.push(helper.styleTitle("STREAMS:"));
832
- for (const d of defs) {
833
- output.push(callFormatItem(styleTerm(d.name), styleDesc(d.description)));
834
- }
835
- output.push("");
836
- }
837
- return output.join("\n") + "\n";
838
- }
839
- });
840
- }
841
- function createCLI(cfg) {
842
- const theme = buildTheme(cfg.accent);
843
- const desc = cfg.help?.disclaimer ? `${cfg.description}
844
-
845
- ${cfg.help.disclaimer}` : cfg.description;
846
- const normalizedVersion = cfg.version.startsWith("v") ? cfg.version : `v${cfg.version}`;
847
- const versionOutput = `${cfg.name} ${normalizedVersion}`;
848
- const program = new import_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);
849
- if (!cfg.disable?.format) {
850
- registerOutputFlags(program);
851
- }
852
- if (!cfg.disable?.quiet) {
853
- program.option("--quiet", "Suppress non-essential output", false);
854
- }
855
- if (!cfg.disable?.noColor) {
856
- program.option("--no-color", "Disable ANSI colour", false);
857
- }
858
- if (!cfg.disable?.hints) {
859
- program.option("--no-hints", "Suppress next-step hints after command output", false);
860
- }
861
- program.option(
862
- "-V, --verbose",
863
- "Increase verbosity",
864
- (_, prev) => prev + 1,
865
- 0
866
- );
867
- program.hook("preAction", (thisCmd) => {
868
- const opts = thisCmd.opts();
869
- const count = opts.quiet ? 0 : opts.verbose ?? 0;
870
- verboseCountMap.set(thisCmd, count);
871
- });
872
- if (cfg.groups?.some((g) => g.hidden)) {
873
- program.option("--help-all", "Show all commands including hidden groups");
874
- program.on("option:help-all", () => {
875
- program.help();
876
- });
877
- }
878
- for (const g of cfg.groups ?? []) {
879
- program.option(`--help-${g.id}`, `Show ${g.title} commands`);
880
- program.on(`option:help-${g.id}`, () => {
881
- program.help();
882
- });
883
- }
884
- if (cfg.groups && cfg.groups.length > 0) {
885
- const groupIds = cfg.groups.map((g) => g.id);
886
- const helpCmd = program.command("help [group]").description("Show help for a command group").action((group) => {
887
- if (group === "all") {
888
- process.argv.push("--help-all");
889
- program.help();
890
- } else if (group && groupIds.includes(group)) {
891
- process.argv.push(`--help-${group}`);
892
- program.help();
893
- } else {
894
- program.help();
895
- }
896
- });
897
- helpCmd.hideHelp = true;
898
- helpCmd._hidden = true;
899
- }
900
- for (const g of cfg.globals ?? []) {
901
- const flag = g.short ? `-${g.short}, --${g.name} <value>` : `--${g.name} <value>`;
902
- program.option(flag, g.usage, g.default ?? "");
903
- }
904
- applyHelpTheme(
905
- program,
906
- theme,
907
- false,
908
- cfg.help?.sectionOrder,
909
- cfg.help?.showAliases,
910
- cfg.groups
911
- );
912
- const existing = program._outputConfiguration ?? {};
913
- program.configureOutput({
914
- ...existing,
915
- outputError(str, write) {
916
- const nc = process.argv.includes("--no-color") || process.env["NO_COLOR"] !== void 0;
917
- if (nc) {
918
- write(str);
919
- } else {
920
- write(ansi(theme.error, str));
921
- }
922
- }
923
- });
924
- return { program, theme };
925
- }
926
- // Annotate the CommonJS export names for ESM import in node:
927
- 0 && (module.exports = {
928
- Dark,
929
- HintSet,
930
- Neon,
931
- active,
932
- applyHelpTheme,
933
- buildTheme,
934
- channel,
935
- createCLI,
936
- getCommandGroup,
937
- getStreamDefs,
938
- hintsEnabled,
939
- registerStream,
940
- registerUpgradeHints,
941
- registerVersionHints,
942
- renderHints,
943
- setCommandGroup,
944
- verboseCount
945
- });
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+ var _chunkGHPJJV5Ljs = require('./chunk-GHPJJV5L.js');
26
+ require('./chunk-72XZWQX7.js');
27
+ require('./chunk-POR5L2DG.js');
28
+ require('./chunk-QPUCXQXT.js');
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+ var _chunkKVG7YCTSjs = require('./chunk-KVG7YCTS.js');
37
+ require('./chunk-JZ22ZUFA.js');
38
+ require('./chunk-JKMQSAJP.js');
39
+ require('./chunk-R5U7XKVJ.js');
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+ exports.Dark = _chunkGHPJJV5Ljs.Dark; exports.ErrOffline = _chunkKVG7YCTSjs.ErrOffline; exports.HintSet = _chunkGHPJJV5Ljs.HintSet; exports.Neon = _chunkGHPJJV5Ljs.Neon; exports.OfflineError = _chunkKVG7YCTSjs.OfflineError; exports.active = _chunkGHPJJV5Ljs.active; exports.applyHelpTheme = _chunkGHPJJV5Ljs.applyHelpTheme; exports.buildTheme = _chunkGHPJJV5Ljs.buildTheme; exports.channel = _chunkGHPJJV5Ljs.channel; exports.createCLI = _chunkGHPJJV5Ljs.createCLI; exports.getCommandGroup = _chunkGHPJJV5Ljs.getCommandGroup; exports.getStreamDefs = _chunkGHPJJV5Ljs.getStreamDefs; exports.guardFetch = _chunkKVG7YCTSjs.guardFetch; exports.hintsEnabled = _chunkGHPJJV5Ljs.hintsEnabled; exports.isOffline = _chunkKVG7YCTSjs.isOffline; exports.isOfflineError = _chunkKVG7YCTSjs.isOfflineError; exports.isQuiet = _chunkGHPJJV5Ljs.isQuiet; exports.registerStream = _chunkGHPJJV5Ljs.registerStream; exports.registerUpgradeHints = _chunkGHPJJV5Ljs.registerUpgradeHints; exports.registerVersionHints = _chunkGHPJJV5Ljs.registerVersionHints; exports.renderHints = _chunkGHPJJV5Ljs.renderHints; exports.setCommandGroup = _chunkGHPJJV5Ljs.setCommandGroup; exports.streamFlagName = _chunkGHPJJV5Ljs.streamFlagName; exports.streamLabel = _chunkGHPJJV5Ljs.streamLabel; exports.streamOutput = _chunkGHPJJV5Ljs.streamOutput; exports.verboseCount = _chunkGHPJJV5Ljs.verboseCount; exports.verbosityFlagSpec = _chunkGHPJJV5Ljs.verbosityFlagSpec; exports.verbosityShorthand = _chunkGHPJJV5Ljs.verbosityShorthand; exports.withOffline = _chunkKVG7YCTSjs.withOffline;