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