pruff-skills 0.1.0

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.
@@ -0,0 +1,332 @@
1
+ import { __toESM } from "../../rolldown-runtime.mjs";
2
+ import { LD, SD, _D, dD, fD, require_picocolors, require_src } from "./core.mjs";
3
+ import { stripVTControlCharacters } from "node:util";
4
+ import y from "node:process";
5
+ var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
6
+ var import_src = require_src();
7
+ function ce() {
8
+ return y.platform !== "win32" ? y.env.TERM !== "linux" : !!y.env.CI || !!y.env.WT_SESSION || !!y.env.TERMINUS_SUBLIME || y.env.ConEmuTask === "{cmd::Cmder}" || y.env.TERM_PROGRAM === "Terminus-Sublime" || y.env.TERM_PROGRAM === "vscode" || y.env.TERM === "xterm-256color" || y.env.TERM === "alacritty" || y.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
9
+ }
10
+ const V = ce(), u = (t, n) => V ? t : n, le = u("◆", "*"), L = u("■", "x"), W = u("▲", "x"), C = u("◇", "o"), ue = u("┌", "T"), o = u("│", "|"), d = u("└", "—"), k = u("●", ">"), P = u("○", " "), A = u("◻", "[•]"), T = u("◼", "[+]"), F = u("◻", "[ ]"), _ = u("─", "-"), me = u("╮", "+"), de = u("├", "+"), pe = u("╯", "+"), q = u("●", "•"), D = u("◆", "*"), U = u("▲", "!"), K = u("■", "x"), b = (t) => {
11
+ switch (t) {
12
+ case "initial":
13
+ case "active": return import_picocolors.default.cyan(le);
14
+ case "cancel": return import_picocolors.default.red(L);
15
+ case "error": return import_picocolors.default.yellow(W);
16
+ case "submit": return import_picocolors.default.green(C);
17
+ }
18
+ }, G = (t) => {
19
+ const { cursor: n, options: r, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a = Math.min(c, Math.max(s, 5));
20
+ let l = 0;
21
+ n >= l + a - 3 ? l = Math.max(Math.min(n - a + 3, r.length - a), 0) : n < l + 2 && (l = Math.max(n - 2, 0));
22
+ const $ = a < r.length && l > 0, g = a < r.length && l + a < r.length;
23
+ return r.slice(l, l + a).map((p, v, f) => {
24
+ const j = v === 0 && $, E = v === f.length - 1 && g;
25
+ return j || E ? import_picocolors.default.dim("...") : i(p, v + l === n);
26
+ });
27
+ }, ye = (t) => {
28
+ const n = t.active ?? "Yes", r = t.inactive ?? "No";
29
+ return new dD({
30
+ active: n,
31
+ inactive: r,
32
+ initialValue: t.initialValue ?? !0,
33
+ render() {
34
+ const i = `${import_picocolors.default.gray(o)}
35
+ ${b(this.state)} ${t.message}
36
+ `, s = this.value ? n : r;
37
+ switch (this.state) {
38
+ case "submit": return `${i}${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(s)}`;
39
+ case "cancel": return `${i}${import_picocolors.default.gray(o)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}
40
+ ${import_picocolors.default.gray(o)}`;
41
+ default: return `${i}${import_picocolors.default.cyan(o)} ${this.value ? `${import_picocolors.default.green(k)} ${n}` : `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(n)}`} ${import_picocolors.default.dim("/")} ${this.value ? `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(r)}` : `${import_picocolors.default.green(k)} ${r}`}
42
+ ${import_picocolors.default.cyan(d)}
43
+ `;
44
+ }
45
+ }
46
+ }).prompt();
47
+ }, ve = (t) => {
48
+ const n = (r, i) => {
49
+ const s = r.label ?? String(r.value);
50
+ switch (i) {
51
+ case "selected": return `${import_picocolors.default.dim(s)}`;
52
+ case "active": return `${import_picocolors.default.green(k)} ${s} ${r.hint ? import_picocolors.default.dim(`(${r.hint})`) : ""}`;
53
+ case "cancelled": return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}`;
54
+ default: return `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(s)}`;
55
+ }
56
+ };
57
+ return new LD({
58
+ options: t.options,
59
+ initialValue: t.initialValue,
60
+ render() {
61
+ const r = `${import_picocolors.default.gray(o)}
62
+ ${b(this.state)} ${t.message}
63
+ `;
64
+ switch (this.state) {
65
+ case "submit": return `${r}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
66
+ case "cancel": return `${r}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
67
+ ${import_picocolors.default.gray(o)}`;
68
+ default: return `${r}${import_picocolors.default.cyan(o)} ${G({
69
+ cursor: this.cursor,
70
+ options: this.options,
71
+ maxItems: t.maxItems,
72
+ style: (i, s) => n(i, s ? "active" : "inactive")
73
+ }).join(`
74
+ ${import_picocolors.default.cyan(o)} `)}
75
+ ${import_picocolors.default.cyan(d)}
76
+ `;
77
+ }
78
+ }
79
+ }).prompt();
80
+ }, fe = (t) => {
81
+ const n = (r, i) => {
82
+ const s = r.label ?? String(r.value);
83
+ return i === "active" ? `${import_picocolors.default.cyan(A)} ${s} ${r.hint ? import_picocolors.default.dim(`(${r.hint})`) : ""}` : i === "selected" ? `${import_picocolors.default.green(T)} ${import_picocolors.default.dim(s)} ${r.hint ? import_picocolors.default.dim(`(${r.hint})`) : ""}` : i === "cancelled" ? `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}` : i === "active-selected" ? `${import_picocolors.default.green(T)} ${s} ${r.hint ? import_picocolors.default.dim(`(${r.hint})`) : ""}` : i === "submitted" ? `${import_picocolors.default.dim(s)}` : `${import_picocolors.default.dim(F)} ${import_picocolors.default.dim(s)}`;
84
+ };
85
+ return new SD({
86
+ options: t.options,
87
+ initialValues: t.initialValues,
88
+ required: t.required ?? !0,
89
+ cursorAt: t.cursorAt,
90
+ validate(r) {
91
+ if (this.required && r.length === 0) return `Please select at least one option.
92
+ ${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
93
+ },
94
+ render() {
95
+ const r = `${import_picocolors.default.gray(o)}
96
+ ${b(this.state)} ${t.message}
97
+ `, i = (s, c) => {
98
+ const a = this.value.includes(s.value);
99
+ return c && a ? n(s, "active-selected") : a ? n(s, "selected") : n(s, c ? "active" : "inactive");
100
+ };
101
+ switch (this.state) {
102
+ case "submit": return `${r}${import_picocolors.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "submitted")).join(import_picocolors.default.dim(", ")) || import_picocolors.default.dim("none")}`;
103
+ case "cancel": {
104
+ const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(import_picocolors.default.dim(", "));
105
+ return `${r}${import_picocolors.default.gray(o)} ${s.trim() ? `${s}
106
+ ${import_picocolors.default.gray(o)}` : ""}`;
107
+ }
108
+ case "error": {
109
+ const s = this.error.split(`
110
+ `).map((c, a) => a === 0 ? `${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(c)}` : ` ${c}`).join(`
111
+ `);
112
+ return `${r + import_picocolors.default.yellow(o)} ${G({
113
+ options: this.options,
114
+ cursor: this.cursor,
115
+ maxItems: t.maxItems,
116
+ style: i
117
+ }).join(`
118
+ ${import_picocolors.default.yellow(o)} `)}
119
+ ${s}
120
+ `;
121
+ }
122
+ default: return `${r}${import_picocolors.default.cyan(o)} ${G({
123
+ options: this.options,
124
+ cursor: this.cursor,
125
+ maxItems: t.maxItems,
126
+ style: i
127
+ }).join(`
128
+ ${import_picocolors.default.cyan(o)} `)}
129
+ ${import_picocolors.default.cyan(d)}
130
+ `;
131
+ }
132
+ }
133
+ }).prompt();
134
+ }, be = (t) => {
135
+ const { selectableGroups: n = !0 } = t, r = (i, s, c = []) => {
136
+ const a = i.label ?? String(i.value), l = typeof i.group == "string", $ = l && (c[c.indexOf(i) + 1] ?? { group: !0 }), g = l && $.group === !0, p = l ? n ? `${g ? d : o} ` : " " : "";
137
+ if (s === "active") return `${import_picocolors.default.dim(p)}${import_picocolors.default.cyan(A)} ${a} ${i.hint ? import_picocolors.default.dim(`(${i.hint})`) : ""}`;
138
+ if (s === "group-active") return `${p}${import_picocolors.default.cyan(A)} ${import_picocolors.default.dim(a)}`;
139
+ if (s === "group-active-selected") return `${p}${import_picocolors.default.green(T)} ${import_picocolors.default.dim(a)}`;
140
+ if (s === "selected") {
141
+ const f = l || n ? import_picocolors.default.green(T) : "";
142
+ return `${import_picocolors.default.dim(p)}${f} ${import_picocolors.default.dim(a)} ${i.hint ? import_picocolors.default.dim(`(${i.hint})`) : ""}`;
143
+ }
144
+ if (s === "cancelled") return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(a))}`;
145
+ if (s === "active-selected") return `${import_picocolors.default.dim(p)}${import_picocolors.default.green(T)} ${a} ${i.hint ? import_picocolors.default.dim(`(${i.hint})`) : ""}`;
146
+ if (s === "submitted") return `${import_picocolors.default.dim(a)}`;
147
+ const v = l || n ? import_picocolors.default.dim(F) : "";
148
+ return `${import_picocolors.default.dim(p)}${v} ${import_picocolors.default.dim(a)}`;
149
+ };
150
+ return new _D({
151
+ options: t.options,
152
+ initialValues: t.initialValues,
153
+ required: t.required ?? !0,
154
+ cursorAt: t.cursorAt,
155
+ selectableGroups: n,
156
+ validate(i) {
157
+ if (this.required && i.length === 0) return `Please select at least one option.
158
+ ${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
159
+ },
160
+ render() {
161
+ const i = `${import_picocolors.default.gray(o)}
162
+ ${b(this.state)} ${t.message}
163
+ `;
164
+ switch (this.state) {
165
+ case "submit": return `${i}${import_picocolors.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => r(s, "submitted")).join(import_picocolors.default.dim(", "))}`;
166
+ case "cancel": {
167
+ const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => r(c, "cancelled")).join(import_picocolors.default.dim(", "));
168
+ return `${i}${import_picocolors.default.gray(o)} ${s.trim() ? `${s}
169
+ ${import_picocolors.default.gray(o)}` : ""}`;
170
+ }
171
+ case "error": {
172
+ const s = this.error.split(`
173
+ `).map((c, a) => a === 0 ? `${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(c)}` : ` ${c}`).join(`
174
+ `);
175
+ return `${i}${import_picocolors.default.yellow(o)} ${this.options.map((c, a, l) => {
176
+ const $ = this.value.includes(c.value) || c.group === !0 && this.isGroupSelected(`${c.value}`), g = a === this.cursor;
177
+ return !g && typeof c.group == "string" && this.options[this.cursor].value === c.group ? r(c, $ ? "group-active-selected" : "group-active", l) : g && $ ? r(c, "active-selected", l) : $ ? r(c, "selected", l) : r(c, g ? "active" : "inactive", l);
178
+ }).join(`
179
+ ${import_picocolors.default.yellow(o)} `)}
180
+ ${s}
181
+ `;
182
+ }
183
+ default: return `${i}${import_picocolors.default.cyan(o)} ${this.options.map((s, c, a) => {
184
+ const l = this.value.includes(s.value) || s.group === !0 && this.isGroupSelected(`${s.value}`), $ = c === this.cursor;
185
+ return !$ && typeof s.group == "string" && this.options[this.cursor].value === s.group ? r(s, l ? "group-active-selected" : "group-active", a) : $ && l ? r(s, "active-selected", a) : l ? r(s, "selected", a) : r(s, $ ? "active" : "inactive", a);
186
+ }).join(`
187
+ ${import_picocolors.default.cyan(o)} `)}
188
+ ${import_picocolors.default.cyan(d)}
189
+ `;
190
+ }
191
+ }
192
+ }).prompt();
193
+ }, Me = (t = "", n = "") => {
194
+ const r = `
195
+ ${t}
196
+ `.split(`
197
+ `), i = stripVTControlCharacters(n).length, s = Math.max(r.reduce((a, l) => {
198
+ const $ = stripVTControlCharacters(l);
199
+ return $.length > a ? $.length : a;
200
+ }, 0), i) + 2, c = r.map((a) => `${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(a)}${" ".repeat(s - stripVTControlCharacters(a).length)}${import_picocolors.default.gray(o)}`).join(`
201
+ `);
202
+ process.stdout.write(`${import_picocolors.default.gray(o)}
203
+ ${import_picocolors.default.green(C)} ${import_picocolors.default.reset(n)} ${import_picocolors.default.gray(_.repeat(Math.max(s - i - 1, 1)) + me)}
204
+ ${c}
205
+ ${import_picocolors.default.gray(de + _.repeat(s + 2) + pe)}
206
+ `);
207
+ }, xe = (t = "") => {
208
+ process.stdout.write(`${import_picocolors.default.gray(d)} ${import_picocolors.default.red(t)}
209
+
210
+ `);
211
+ }, Ie = (t = "") => {
212
+ process.stdout.write(`${import_picocolors.default.gray(ue)} ${t}
213
+ `);
214
+ }, Se = (t = "") => {
215
+ process.stdout.write(`${import_picocolors.default.gray(o)}
216
+ ${import_picocolors.default.gray(d)} ${t}
217
+
218
+ `);
219
+ }, M = {
220
+ message: (t = "", { symbol: n = import_picocolors.default.gray(o) } = {}) => {
221
+ const r = [`${import_picocolors.default.gray(o)}`];
222
+ if (t) {
223
+ const [i, ...s] = t.split(`
224
+ `);
225
+ r.push(`${n} ${i}`, ...s.map((c) => `${import_picocolors.default.gray(o)} ${c}`));
226
+ }
227
+ process.stdout.write(`${r.join(`
228
+ `)}
229
+ `);
230
+ },
231
+ info: (t) => {
232
+ M.message(t, { symbol: import_picocolors.default.blue(q) });
233
+ },
234
+ success: (t) => {
235
+ M.message(t, { symbol: import_picocolors.default.green(D) });
236
+ },
237
+ step: (t) => {
238
+ M.message(t, { symbol: import_picocolors.default.green(C) });
239
+ },
240
+ warn: (t) => {
241
+ M.message(t, { symbol: import_picocolors.default.yellow(U) });
242
+ },
243
+ warning: (t) => {
244
+ M.warn(t);
245
+ },
246
+ error: (t) => {
247
+ M.message(t, { symbol: import_picocolors.default.red(K) });
248
+ }
249
+ }, J = `${import_picocolors.default.gray(o)} `, x = {
250
+ message: async (t, { symbol: n = import_picocolors.default.gray(o) } = {}) => {
251
+ process.stdout.write(`${import_picocolors.default.gray(o)}
252
+ ${n} `);
253
+ let r = 3;
254
+ for await (let i of t) {
255
+ i = i.replace(/\n/g, `
256
+ ${J}`), i.includes(`
257
+ `) && (r = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
258
+ `))).length);
259
+ const s = stripVTControlCharacters(i).length;
260
+ r + s < process.stdout.columns ? (r += s, process.stdout.write(i)) : (process.stdout.write(`
261
+ ${J}${i.trimStart()}`), r = 3 + stripVTControlCharacters(i.trimStart()).length);
262
+ }
263
+ process.stdout.write(`
264
+ `);
265
+ },
266
+ info: (t) => x.message(t, { symbol: import_picocolors.default.blue(q) }),
267
+ success: (t) => x.message(t, { symbol: import_picocolors.default.green(D) }),
268
+ step: (t) => x.message(t, { symbol: import_picocolors.default.green(C) }),
269
+ warn: (t) => x.message(t, { symbol: import_picocolors.default.yellow(U) }),
270
+ warning: (t) => x.warn(t),
271
+ error: (t) => x.message(t, { symbol: import_picocolors.default.red(K) })
272
+ }, Y = ({ indicator: t = "dots" } = {}) => {
273
+ const n = V ? [
274
+ "◒",
275
+ "◐",
276
+ "◓",
277
+ "◑"
278
+ ] : [
279
+ "•",
280
+ "o",
281
+ "O",
282
+ "0"
283
+ ], r = V ? 80 : 120, i = process.env.CI === "true";
284
+ let s, c, a = !1, l = "", $, g = performance.now();
285
+ const p = (m) => {
286
+ a && N(m > 1 ? "Something went wrong" : "Canceled", m);
287
+ }, v = () => p(2), f = () => p(1), j = () => {
288
+ process.on("uncaughtExceptionMonitor", v), process.on("unhandledRejection", v), process.on("SIGINT", f), process.on("SIGTERM", f), process.on("exit", p);
289
+ }, E = () => {
290
+ process.removeListener("uncaughtExceptionMonitor", v), process.removeListener("unhandledRejection", v), process.removeListener("SIGINT", f), process.removeListener("SIGTERM", f), process.removeListener("exit", p);
291
+ }, B = () => {
292
+ if ($ === void 0) return;
293
+ i && process.stdout.write(`
294
+ `);
295
+ const m = $.split(`
296
+ `);
297
+ process.stdout.write(import_src.cursor.move(-999, m.length - 1)), process.stdout.write(import_src.erase.down(m.length));
298
+ }, R = (m) => m.replace(/\.+$/, ""), O = (m) => {
299
+ const h = (performance.now() - m) / 1e3, w = Math.floor(h / 60), I = Math.floor(h % 60);
300
+ return w > 0 ? `[${w}m ${I}s]` : `[${I}s]`;
301
+ }, H = (m = "") => {
302
+ a = !0, s = fD(), l = R(m), g = performance.now(), process.stdout.write(`${import_picocolors.default.gray(o)}
303
+ `);
304
+ let h = 0, w = 0;
305
+ j(), c = setInterval(() => {
306
+ if (i && l === $) return;
307
+ B(), $ = l;
308
+ const I = import_picocolors.default.magenta(n[h]);
309
+ if (i) process.stdout.write(`${I} ${l}...`);
310
+ else if (t === "timer") process.stdout.write(`${I} ${l} ${O(g)}`);
311
+ else {
312
+ const z = ".".repeat(Math.floor(w)).slice(0, 3);
313
+ process.stdout.write(`${I} ${l}${z}`);
314
+ }
315
+ h = h + 1 < n.length ? h + 1 : 0, w = w < n.length ? w + .125 : 0;
316
+ }, r);
317
+ }, N = (m = "", h = 0) => {
318
+ a = !1, clearInterval(c), B();
319
+ const w = h === 0 ? import_picocolors.default.green(C) : h === 1 ? import_picocolors.default.red(L) : import_picocolors.default.red(W);
320
+ l = R(m ?? l), t === "timer" ? process.stdout.write(`${w} ${l} ${O(g)}
321
+ `) : process.stdout.write(`${w} ${l}
322
+ `), E(), s();
323
+ };
324
+ return {
325
+ start: H,
326
+ stop: N,
327
+ message: (m = "") => {
328
+ l = R(m ?? l);
329
+ }
330
+ };
331
+ };
332
+ export { Ie, M, Me, Se, Y, be, fe, ve, xe, ye };