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

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