@hop-top/kit 0.5.0-alpha.2 → 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 (188) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/LICENSE +1 -1
  3. package/README.md +48 -480
  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-DgOEOsPB.d.ts → cli-8rfITnv4.d.ts} +13 -4
  46. package/dist/cli.d.ts +4 -3
  47. package/dist/cli.js +50 -1056
  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-Do8Qji43.d.ts +231 -0
  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--C7Mtsmm.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 -13
  59. package/dist/index.js +40 -5792
  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-VFFLqor9.d.ts → output-CjZWmL8s.d.ts} +29 -130
  75. package/dist/output.d.ts +2 -1
  76. package/dist/output.js +137 -958
  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-D8yWMrTc.d.ts +646 -0
  88. package/dist/serve.d.ts +3 -0
  89. package/dist/serve.js +75 -0
  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 -4
  94. package/dist/tui/index.js +17 -373
  95. package/dist/upgrade.js +6 -114
  96. package/dist/xdg.js +14 -128
  97. package/package.json +135 -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 +3 -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 +167 -1
  158. package/src/output/formatters/README.md +50 -0
  159. package/src/output.ts +26 -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.test.ts +1257 -0
  170. package/src/serve.ts +1665 -0
  171. package/src/telemetry/README.md +48 -0
  172. package/src/telemetry/client.ts +5 -5
  173. package/src/toolspec.test.ts +2 -2
  174. package/src/triton/README.md +34 -0
  175. package/src/tui/README.md +42 -0
  176. package/src/wizard.test.ts +7 -7
  177. package/test/llm/conformance-helpers.ts +100 -0
  178. package/test/output/dispatch.test.ts +1 -2
  179. package/test/output/error.test.ts +38 -2
  180. package/test/output/smoke-capture.ts +2 -2
  181. package/test/output/smoke.test.ts +2 -2
  182. package/test/output/taxonomy-contract.test.ts +148 -0
  183. package/test/setup-env.ts +16 -0
  184. package/tsconfig.json +3 -1
  185. package/tsconfig.test.json +10 -0
  186. package/vitest.config.ts +9 -0
  187. package/dist/llm-B5XUWH8T.d.ts +0 -231
  188. package/dist/routellm-PGSt2D1y.d.ts +0 -75
package/dist/tui/index.js CHANGED
@@ -1,384 +1,28 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
19
2
 
20
- // src/tui/index.ts
21
- var tui_exports = {};
22
- __export(tui_exports, {
23
- anim: () => anim,
24
- badge: () => badge,
25
- clamp01: () => clamp01,
26
- confirm: () => confirm,
27
- list: () => list,
28
- makeGradient: () => makeGradient,
29
- pills: () => pills,
30
- progress: () => progress,
31
- renderBarPlain: () => renderBarPlain,
32
- spinner: () => spinner,
33
- status: () => status
34
- });
35
- module.exports = __toCommonJS(tui_exports);
36
3
 
37
- // src/tui/badge.ts
38
- function badge(theme, text, opts) {
39
- const bg = opts?.color ?? theme.accent;
40
- const [r, g, b] = hexToRgb(bg);
41
- const bgOpen = `\x1B[48;2;${r};${g};${b}m`;
42
- const fgOpen = `\x1B[38;2;255;255;255m`;
43
- const reset = `\x1B[0m`;
44
- return `${bgOpen}${fgOpen} ${text} ${reset}`;
45
- }
46
- function hexToRgb(hex) {
47
- const h = hex.replace("#", "");
48
- return [
49
- parseInt(h.slice(0, 2), 16),
50
- parseInt(h.slice(2, 4), 16),
51
- parseInt(h.slice(4, 6), 16)
52
- ];
53
- }
54
4
 
55
- // ../../contracts/parity/parity.json
56
- var parity_default = {
57
- $schema: "https://json-schema.org/draft/2020-12/schema",
58
- $id: "https://hop.top/kit/go/console/tui/parity.json",
59
- description: "Cross-language TUI parity constants. All language implementations MUST load values from here.",
60
- status: {
61
- description: "Prefix symbols for status lines. Mirrors Go's InfoType constants in tui/status.go.",
62
- symbols: {
63
- info: "\u2139",
64
- success: "\u2713",
65
- error: "\u25CF",
66
- warn: "\u25B2"
67
- }
68
- },
69
- spinner: {
70
- description: "Braille dot spinner frames and timing.",
71
- frames: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"],
72
- interval_ms: 80
73
- },
74
- anim: {
75
- description: "Gradient character-scramble animation constants.",
76
- runes: "0123456789abcdefABCDEF~!@#$%^&*()+=_",
77
- interval_ms: 100,
78
- default_width: 10
79
- },
80
- help: {
81
- description: "Root --help layout contract. Fang is canonical; TS and Python mirror it.",
82
- section_order: ["commands", "flags"],
83
- sections: {
84
- usage: { title: "USAGE" },
85
- commands: { title: "COMMANDS" },
86
- flags: { title: "FLAGS" },
87
- "global flags": { title: "GLOBAL FLAGS" },
88
- arguments: { title: "ARGUMENTS" },
89
- aliases: { title: "ALIASES" },
90
- examples: { title: "EXAMPLES" },
91
- streams: { title: "STREAMS" }
92
- }
93
- },
94
- verbosity: {
95
- description: "Stackable -V flag maps count to log level. --quiet overrides to warn.",
96
- flag: "-V",
97
- levels: {
98
- "0": "info",
99
- "1": "debug",
100
- "2": "trace"
101
- },
102
- quiet_override: "warn"
103
- },
104
- streams: {
105
- description: "Per-command named output streams toggled via --stream flag.",
106
- flag: "--stream",
107
- label_format: "[{name}]",
108
- output: "stderr"
109
- },
110
- extends: [
111
- "scope-defaults.json"
112
- ]
113
- };
114
5
 
115
- // src/tui/parity.ts
116
- var parity = parity_default;
117
6
 
118
- // src/tui/status.ts
119
- var _symbols = parity.status.symbols;
120
- function status(theme, text, kind = "info") {
121
- const { symbol, color } = resolveKind(theme, kind);
122
- const indicator = colorize(color, symbol);
123
- const message = colorize(color, text);
124
- return `${indicator} ${message}`;
125
- }
126
- function resolveKind(theme, kind) {
127
- switch (kind) {
128
- case "success":
129
- return { symbol: _symbols.success, color: theme.success };
130
- case "error":
131
- return { symbol: _symbols.error, color: theme.error };
132
- case "warn":
133
- return { symbol: _symbols.warn, color: theme.secondary };
134
- default:
135
- return { symbol: _symbols.info, color: theme.accent };
136
- }
137
- }
138
- function colorize(hex, text) {
139
- const h = hex.replace("#", "");
140
- const r = parseInt(h.slice(0, 2), 16);
141
- const g = parseInt(h.slice(2, 4), 16);
142
- const b = parseInt(h.slice(4, 6), 16);
143
- return `\x1B[38;2;${r};${g};${b}m${text}\x1B[0m`;
144
- }
145
7
 
146
- // src/tui/pills.ts
147
- function pills(theme, items) {
148
- if (items.length === 0) return "";
149
- return items.map((item) => renderPill(theme.secondary, item)).join(" ");
150
- }
151
- function renderPill(hex, text) {
152
- const h = hex.replace("#", "");
153
- const r = parseInt(h.slice(0, 2), 16);
154
- const g = parseInt(h.slice(2, 4), 16);
155
- const b = parseInt(h.slice(4, 6), 16);
156
- return `\x1B[38;2;${r};${g};${b}m ${text} \x1B[0m`;
157
- }
158
8
 
159
- // src/tui/spinner.ts
160
- var FRAMES = parity.spinner.frames;
161
- var INTERVAL_MS = parity.spinner.interval_ms;
162
- function spinner(theme) {
163
- const [r, g, b] = hexToRgb2(theme.accent);
164
- const accentOpen = `\x1B[38;2;${r};${g};${b}m`;
165
- const reset = `\x1B[0m`;
166
- let timer = null;
167
- let frameIdx = 0;
168
- let currentMsg = "";
169
- function render() {
170
- const frame = FRAMES[frameIdx % FRAMES.length];
171
- const line = `\r${accentOpen}${frame}${reset} ${currentMsg}`;
172
- process.stderr.write(line);
173
- frameIdx++;
174
- }
175
- return {
176
- start(msg = "") {
177
- if (timer !== null) return;
178
- currentMsg = msg;
179
- frameIdx = 0;
180
- render();
181
- timer = setInterval(render, INTERVAL_MS);
182
- },
183
- stop(msg) {
184
- if (timer !== null) {
185
- clearInterval(timer);
186
- timer = null;
187
- }
188
- process.stderr.write("\r\x1B[K");
189
- if (msg !== void 0) {
190
- process.stderr.write(`${msg}
191
- `);
192
- }
193
- },
194
- message(msg) {
195
- currentMsg = msg;
196
- }
197
- };
198
- }
199
- function hexToRgb2(hex) {
200
- const h = hex.replace("#", "");
201
- return [
202
- parseInt(h.slice(0, 2), 16),
203
- parseInt(h.slice(2, 4), 16),
204
- parseInt(h.slice(4, 6), 16)
205
- ];
206
- }
207
9
 
208
- // src/tui/progress.ts
209
- var BAR_WIDTH = 30;
210
- var FILL_CHAR = "\u2588";
211
- var EMPTY_CHAR = "\u2591";
212
- function progress(theme, _total) {
213
- const [ar, ag, ab] = hexToRgb3(theme.accent);
214
- const [mr, mg, mb] = hexToRgb3(theme.muted);
215
- const accentOpen = `\x1B[38;2;${ar};${ag};${ab}m`;
216
- const mutedOpen = `\x1B[38;2;${mr};${mg};${mb}m`;
217
- const reset = `\x1B[0m`;
218
- let currentValue = 0;
219
- let currentMsg = "";
220
- let running = false;
221
- function renderBar(value) {
222
- const clamped = clamp01(value);
223
- const filled = Math.round(clamped * BAR_WIDTH);
224
- const empty = BAR_WIDTH - filled;
225
- const bar = accentOpen + FILL_CHAR.repeat(filled) + reset + mutedOpen + EMPTY_CHAR.repeat(empty) + reset;
226
- const pct = Math.round(clamped * 100);
227
- return `\r${bar} ${pct}%${currentMsg ? " " + currentMsg : ""}`;
228
- }
229
- return {
230
- start(msg = "") {
231
- running = true;
232
- currentMsg = msg;
233
- currentValue = 0;
234
- process.stderr.write(renderBar(0));
235
- },
236
- update(value, msg) {
237
- currentValue = clamp01(value);
238
- if (msg !== void 0) currentMsg = msg;
239
- if (running) {
240
- process.stderr.write(renderBar(currentValue));
241
- }
242
- },
243
- stop(msg) {
244
- running = false;
245
- process.stderr.write("\r\x1B[K");
246
- if (msg !== void 0) {
247
- process.stderr.write(`${msg}
248
- `);
249
- }
250
- }
251
- };
252
- }
253
- function clamp01(v) {
254
- if (v < 0) return 0;
255
- if (v > 1) return 1;
256
- return v;
257
- }
258
- function renderBarPlain(value) {
259
- const clamped = clamp01(value);
260
- const filled = Math.round(clamped * BAR_WIDTH);
261
- const empty = BAR_WIDTH - filled;
262
- return FILL_CHAR.repeat(filled) + EMPTY_CHAR.repeat(empty);
263
- }
264
- function hexToRgb3(hex) {
265
- const h = hex.replace("#", "");
266
- return [
267
- parseInt(h.slice(0, 2), 16),
268
- parseInt(h.slice(2, 4), 16),
269
- parseInt(h.slice(4, 6), 16)
270
- ];
271
- }
272
10
 
273
- // src/tui/anim.ts
274
- var ANIM_RUNES = parity.anim.runes;
275
- var DEFAULT_WIDTH = parity.anim.default_width;
276
- var INTERVAL_MS2 = parity.anim.interval_ms;
277
- function anim(theme, opts) {
278
- const width = opts?.width ?? DEFAULT_WIDTH;
279
- let label = opts?.label ?? "";
280
- const gradient = makeGradient(theme.accent, theme.secondary, width);
281
- const reset = `\x1B[0m`;
282
- let timer = null;
283
- function randomChar() {
284
- return ANIM_RUNES[Math.floor(Math.random() * ANIM_RUNES.length)];
285
- }
286
- function render() {
287
- let line = "\r";
288
- for (let i = 0; i < width; i++) {
289
- const [r, g, b] = gradient[i];
290
- line += `\x1B[38;2;${r};${g};${b}m${randomChar()}${reset}`;
291
- }
292
- if (label) {
293
- line += " " + label;
294
- }
295
- process.stderr.write(line);
296
- }
297
- return {
298
- start() {
299
- if (timer !== null) return;
300
- render();
301
- timer = setInterval(render, INTERVAL_MS2);
302
- },
303
- stop() {
304
- if (timer !== null) {
305
- clearInterval(timer);
306
- timer = null;
307
- }
308
- process.stderr.write("\r\x1B[K");
309
- },
310
- setLabel(newLabel) {
311
- label = newLabel;
312
- }
313
- };
314
- }
315
- function makeGradient(hexA, hexB, steps) {
316
- if (steps <= 0) return [];
317
- const [ar, ag, ab] = hexToRgb4(hexA);
318
- const [br, bg, bb] = hexToRgb4(hexB);
319
- const result = [];
320
- for (let i = 0; i < steps; i++) {
321
- const t = steps === 1 ? 0 : i / (steps - 1);
322
- result.push([
323
- Math.round(ar + (br - ar) * t),
324
- Math.round(ag + (bg - ag) * t),
325
- Math.round(ab + (bb - ab) * t)
326
- ]);
327
- }
328
- return result;
329
- }
330
- function hexToRgb4(hex) {
331
- const h = hex.replace("#", "");
332
- return [
333
- parseInt(h.slice(0, 2), 16),
334
- parseInt(h.slice(2, 4), 16),
335
- parseInt(h.slice(4, 6), 16)
336
- ];
337
- }
338
11
 
339
- // src/tui/confirm.ts
340
- var import_prompts = require("@clack/prompts");
341
- async function confirm(_theme, message, opts) {
342
- const result = await (0, import_prompts.confirm)({
343
- message,
344
- initialValue: opts?.initial
345
- });
346
- if ((0, import_prompts.isCancel)(result)) {
347
- throw new Error("cancelled");
348
- }
349
- return result;
350
- }
351
12
 
352
- // src/tui/list.ts
353
- var import_prompts2 = require("@clack/prompts");
354
- async function list(_theme, message, items, opts) {
355
- const options = items.map((item) => ({
356
- label: item.label,
357
- value: item.value,
358
- hint: item.hint
359
- }));
360
- const initialValue = opts?.initial;
361
- const result = await (0, import_prompts2.select)({
362
- message,
363
- options,
364
- initialValue
365
- });
366
- if ((0, import_prompts2.isCancel)(result)) {
367
- throw new Error("cancelled");
368
- }
369
- return result;
370
- }
371
- // Annotate the CommonJS export names for ESM import in node:
372
- 0 && (module.exports = {
373
- anim,
374
- badge,
375
- clamp01,
376
- confirm,
377
- list,
378
- makeGradient,
379
- pills,
380
- progress,
381
- renderBarPlain,
382
- spinner,
383
- status
384
- });
13
+ var _chunkGGWJRWWAjs = require('../chunk-GGWJRWWA.js');
14
+ require('../chunk-QPUCXQXT.js');
15
+ require('../chunk-R5U7XKVJ.js');
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+ exports.anim = _chunkGGWJRWWAjs.anim; exports.badge = _chunkGGWJRWWAjs.badge; exports.clamp01 = _chunkGGWJRWWAjs.clamp01; exports.confirm = _chunkGGWJRWWAjs.confirm; exports.list = _chunkGGWJRWWAjs.list; exports.makeGradient = _chunkGGWJRWWAjs.makeGradient; exports.pills = _chunkGGWJRWWAjs.pills; exports.progress = _chunkGGWJRWWAjs.progress; exports.renderBarPlain = _chunkGGWJRWWAjs.renderBarPlain; exports.spinner = _chunkGGWJRWWAjs.spinner; exports.status = _chunkGGWJRWWAjs.status;
package/dist/upgrade.js CHANGED
@@ -1,115 +1,7 @@
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);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
29
2
 
30
- // src/upgrade.ts
31
- var upgrade_exports = {};
32
- __export(upgrade_exports, {
33
- createChecker: () => createChecker
34
- });
35
- module.exports = __toCommonJS(upgrade_exports);
36
- var fs = __toESM(require("fs"));
37
- var os = __toESM(require("os"));
38
- var path = __toESM(require("path"));
39
- var import_semver = __toESM(require("semver"));
40
- function createChecker(opts) {
41
- const {
42
- name,
43
- currentVersion,
44
- owner,
45
- repo,
46
- cacheTTL = 24 * 60 * 60 * 1e3,
47
- stateDir = os.tmpdir(),
48
- timeout = 1e4
49
- } = opts;
50
- const cacheFile = path.join(stateDir, `.upgrade-${name}-cache.json`);
51
- const releaseURL = `https://api.github.com/repos/${owner}/${repo}/releases/latest`;
52
- const releasesPageURL = `https://github.com/${owner}/${repo}/releases/latest`;
53
- function readCache() {
54
- try {
55
- const raw = fs.readFileSync(cacheFile, "utf8");
56
- const parsed = JSON.parse(raw);
57
- if (typeof parsed.version === "string" && typeof parsed.checkedAt === "number") {
58
- return parsed;
59
- }
60
- } catch {
61
- }
62
- return null;
63
- }
64
- function writeCache(version) {
65
- try {
66
- const entry = { version, checkedAt: Date.now() };
67
- fs.writeFileSync(cacheFile, JSON.stringify(entry), "utf8");
68
- } catch {
69
- }
70
- }
71
- async function fetchLatestVersion() {
72
- const controller = new AbortController();
73
- const timer = setTimeout(() => controller.abort(), timeout);
74
- try {
75
- const res = await fetch(releaseURL, {
76
- signal: controller.signal,
77
- headers: { Accept: "application/vnd.github+json" }
78
- });
79
- if (!res.ok) return null;
80
- const body = await res.json();
81
- const tag = body.tag_name;
82
- if (typeof tag !== "string") return null;
83
- return tag.replace(/^v/, "");
84
- } finally {
85
- clearTimeout(timer);
86
- }
87
- }
88
- async function notifyIfAvailable(out) {
89
- try {
90
- let latestVersion = null;
91
- const cached = readCache();
92
- if (cached !== null && Date.now() - cached.checkedAt < cacheTTL) {
93
- latestVersion = cached.version;
94
- } else {
95
- latestVersion = await fetchLatestVersion();
96
- if (latestVersion !== null) {
97
- writeCache(latestVersion);
98
- }
99
- }
100
- if (latestVersion === null) return;
101
- if (!import_semver.default.gt(latestVersion, currentVersion)) return;
102
- const notice = `
103
- A new release of ${name} is available: v${currentVersion} \u2192 v${latestVersion}
104
- ${releasesPageURL}
105
- `;
106
- out.write(notice);
107
- } catch {
108
- }
109
- }
110
- return { notifyIfAvailable };
111
- }
112
- // Annotate the CommonJS export names for ESM import in node:
113
- 0 && (module.exports = {
114
- createChecker
115
- });
3
+ var _chunkWWUKGJB5js = require('./chunk-WWUKGJB5.js');
4
+ require('./chunk-R5U7XKVJ.js');
5
+
6
+
7
+ exports.createChecker = _chunkWWUKGJB5js.createChecker;
package/dist/xdg.js CHANGED
@@ -1,129 +1,15 @@
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);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
29
2
 
30
- // src/xdg.ts
31
- var xdg_exports = {};
32
- __export(xdg_exports, {
33
- cacheDir: () => cacheDir,
34
- configDir: () => configDir,
35
- dataDir: () => dataDir,
36
- mustEnsure: () => mustEnsure,
37
- stateDir: () => stateDir
38
- });
39
- module.exports = __toCommonJS(xdg_exports);
40
- var os = __toESM(require("os"));
41
- var path = __toESM(require("path"));
42
- var fs = __toESM(require("fs"));
43
- function platform(override) {
44
- return override ?? process.platform;
45
- }
46
- function configDir(tool, plt) {
47
- const xdg = process.env["XDG_CONFIG_HOME"];
48
- if (xdg) return path.join(xdg, tool);
49
- const p = platform(plt);
50
- const home = os.homedir();
51
- switch (p) {
52
- case "darwin":
53
- return path.join(home, "Library", "Preferences", tool);
54
- case "win32": {
55
- const appdata = process.env["APPDATA"];
56
- if (!appdata) throw new Error("%APPDATA% is not set");
57
- return path.join(appdata, tool);
58
- }
59
- default:
60
- return path.join(home, ".config", tool);
61
- }
62
- }
63
- function dataDir(tool, plt) {
64
- const xdg = process.env["XDG_DATA_HOME"];
65
- if (xdg) return path.join(xdg, tool);
66
- const p = platform(plt);
67
- const home = os.homedir();
68
- switch (p) {
69
- case "darwin":
70
- return path.join(home, "Library", "Application Support", tool);
71
- case "win32": {
72
- const local = process.env["LocalAppData"];
73
- if (!local) throw new Error("%LocalAppData% is not set");
74
- return path.win32.join(local, tool);
75
- }
76
- default:
77
- return path.join(home, ".local", "share", tool);
78
- }
79
- }
80
- function cacheDir(tool, plt) {
81
- const xdg = process.env["XDG_CACHE_HOME"];
82
- if (xdg) return path.join(xdg, tool);
83
- const p = platform(plt);
84
- const home = os.homedir();
85
- switch (p) {
86
- case "darwin":
87
- return path.join(home, "Library", "Caches", tool);
88
- case "win32": {
89
- const local = process.env["LocalAppData"];
90
- if (!local) throw new Error("%LocalAppData% is not set");
91
- return path.win32.join(local, tool, "cache");
92
- }
93
- default:
94
- return path.join(home, ".cache", tool);
95
- }
96
- }
97
- function stateDir(tool, plt) {
98
- const xdg = process.env["XDG_STATE_HOME"];
99
- if (xdg) return path.join(xdg, tool);
100
- const p = platform(plt);
101
- const home = os.homedir();
102
- switch (p) {
103
- case "darwin":
104
- return path.join(home, "Library", "Application Support", tool, "state");
105
- case "win32": {
106
- const local = process.env["LocalAppData"];
107
- if (!local) throw new Error("%LocalAppData% is not set");
108
- return path.win32.join(local, tool, "state");
109
- }
110
- default:
111
- return path.join(home, ".local", "state", tool);
112
- }
113
- }
114
- function mustEnsure(dir) {
115
- fs.mkdirSync(dir, { recursive: true, mode: 488 });
116
- const stat = fs.statSync(dir);
117
- if (!stat.isDirectory()) {
118
- throw new Error(`mustEnsure: path exists but is not a directory: ${dir}`);
119
- }
120
- return dir;
121
- }
122
- // Annotate the CommonJS export names for ESM import in node:
123
- 0 && (module.exports = {
124
- cacheDir,
125
- configDir,
126
- dataDir,
127
- mustEnsure,
128
- stateDir
129
- });
3
+
4
+
5
+
6
+
7
+ var _chunk4UE5TCMQjs = require('./chunk-4UE5TCMQ.js');
8
+ require('./chunk-R5U7XKVJ.js');
9
+
10
+
11
+
12
+
13
+
14
+
15
+ exports.cacheDir = _chunk4UE5TCMQjs.cacheDir; exports.configDir = _chunk4UE5TCMQjs.configDir; exports.dataDir = _chunk4UE5TCMQjs.dataDir; exports.mustEnsure = _chunk4UE5TCMQjs.mustEnsure; exports.stateDir = _chunk4UE5TCMQjs.stateDir;