@taskless/cli 0.0.2

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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -0
  3. package/dist/index.js +821 -0
  4. package/package.json +31 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Taskless
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # @taskless/cli
2
+
3
+ > A Work in Progress
4
+
5
+ CLI companion for [Taskless](https://taskless.io). Designed to be invoked by skills via `npx` or `pnpm dlx`. Useful for agents, and works for humans too.
6
+
7
+ ## Usage
8
+
9
+ ```bash
10
+ # npm
11
+ npx @taskless/cli@latest info
12
+
13
+ # pnpm
14
+ pnpm dlx @taskless/cli@latest info
15
+ ```
16
+
17
+ ## Commands
18
+
19
+ ### `taskless info`
20
+
21
+ Outputs CLI version as JSON to stdout:
22
+
23
+ ```json
24
+ { "version": "0.0.1" }
25
+ ```
26
+
27
+ ### `taskless --help`
28
+
29
+ Lists available subcommands.
30
+
31
+ ## For skill authors
32
+
33
+ Skills should detect the package manager by checking for lock files and invoke the CLI accordingly:
34
+
35
+ 1. If `pnpm-lock.yaml` exists, use `pnpm dlx @taskless/cli@latest <command>`
36
+ 2. Otherwise, use `npx @taskless/cli@latest <command>`
37
+
38
+ All commands output structured JSON to stdout by default. Parse with `JSON.parse()` and handle non-zero exit codes as errors.
package/dist/index.js ADDED
@@ -0,0 +1,821 @@
1
+ #!/usr/bin/env node
2
+ import * as O from "node:tty";
3
+ const g = {
4
+ fatal: 0,
5
+ error: 0,
6
+ warn: 1,
7
+ log: 2,
8
+ info: 3,
9
+ success: 3,
10
+ fail: 3,
11
+ debug: 4,
12
+ trace: 5,
13
+ verbose: Number.POSITIVE_INFINITY
14
+ }, j = {
15
+ // Silent
16
+ silent: {
17
+ level: -1
18
+ },
19
+ // Level 0
20
+ fatal: {
21
+ level: g.fatal
22
+ },
23
+ error: {
24
+ level: g.error
25
+ },
26
+ // Level 1
27
+ warn: {
28
+ level: g.warn
29
+ },
30
+ // Level 2
31
+ log: {
32
+ level: g.log
33
+ },
34
+ // Level 3
35
+ info: {
36
+ level: g.info
37
+ },
38
+ success: {
39
+ level: g.success
40
+ },
41
+ fail: {
42
+ level: g.fail
43
+ },
44
+ ready: {
45
+ level: g.info
46
+ },
47
+ start: {
48
+ level: g.info
49
+ },
50
+ box: {
51
+ level: g.info
52
+ },
53
+ // Level 4
54
+ debug: {
55
+ level: g.debug
56
+ },
57
+ // Level 5
58
+ trace: {
59
+ level: g.trace
60
+ },
61
+ // Verbose
62
+ verbose: {
63
+ level: g.verbose
64
+ }
65
+ };
66
+ function S(t) {
67
+ if (t === null || typeof t != "object")
68
+ return !1;
69
+ const e = Object.getPrototypeOf(t);
70
+ return e !== null && e !== Object.prototype && Object.getPrototypeOf(e) !== null || Symbol.iterator in t ? !1 : Symbol.toStringTag in t ? Object.prototype.toString.call(t) === "[object Module]" : !0;
71
+ }
72
+ function M(t, e, o = ".", r) {
73
+ if (!S(e))
74
+ return M(t, {}, o);
75
+ const n = Object.assign({}, e);
76
+ for (const s in t) {
77
+ if (s === "__proto__" || s === "constructor")
78
+ continue;
79
+ const l = t[s];
80
+ l != null && (Array.isArray(l) && Array.isArray(n[s]) ? n[s] = [...l, ...n[s]] : S(l) && S(n[s]) ? n[s] = M(
81
+ l,
82
+ n[s],
83
+ (o ? `${o}.` : "") + s.toString()
84
+ ) : n[s] = l);
85
+ }
86
+ return n;
87
+ }
88
+ function W(t) {
89
+ return (...e) => (
90
+ // eslint-disable-next-line unicorn/no-array-reduce
91
+ e.reduce((o, r) => M(o, r, ""), {})
92
+ );
93
+ }
94
+ const z = W();
95
+ function V(t) {
96
+ return Object.prototype.toString.call(t) === "[object Object]";
97
+ }
98
+ function Y(t) {
99
+ return !(!V(t) || !t.message && !t.args || t.stack);
100
+ }
101
+ let $ = !1;
102
+ const I = [];
103
+ class h {
104
+ options;
105
+ _lastLog;
106
+ _mockFn;
107
+ /**
108
+ * Creates an instance of Consola with specified options or defaults.
109
+ *
110
+ * @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
111
+ */
112
+ constructor(e = {}) {
113
+ const o = e.types || j;
114
+ this.options = z(
115
+ {
116
+ ...e,
117
+ defaults: { ...e.defaults },
118
+ level: k(e.level, o),
119
+ reporters: [...e.reporters || []]
120
+ },
121
+ {
122
+ types: j,
123
+ throttle: 1e3,
124
+ throttleMin: 5,
125
+ formatOptions: {
126
+ date: !0,
127
+ colors: !1,
128
+ compact: !0
129
+ }
130
+ }
131
+ );
132
+ for (const r in o) {
133
+ const n = {
134
+ type: r,
135
+ ...this.options.defaults,
136
+ ...o[r]
137
+ };
138
+ this[r] = this._wrapLogFn(n), this[r].raw = this._wrapLogFn(
139
+ n,
140
+ !0
141
+ );
142
+ }
143
+ this.options.mockFn && this.mockTypes(), this._lastLog = {};
144
+ }
145
+ /**
146
+ * Gets the current log level of the Consola instance.
147
+ *
148
+ * @returns {number} The current log level.
149
+ */
150
+ get level() {
151
+ return this.options.level;
152
+ }
153
+ /**
154
+ * Sets the minimum log level that will be output by the instance.
155
+ *
156
+ * @param {number} level - The new log level to set.
157
+ */
158
+ set level(e) {
159
+ this.options.level = k(
160
+ e,
161
+ this.options.types,
162
+ this.options.level
163
+ );
164
+ }
165
+ /**
166
+ * Displays a prompt to the user and returns the response.
167
+ * Throw an error if `prompt` is not supported by the current configuration.
168
+ *
169
+ * @template T
170
+ * @param {string} message - The message to display in the prompt.
171
+ * @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
172
+ * @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
173
+ */
174
+ prompt(e, o) {
175
+ if (!this.options.prompt)
176
+ throw new Error("prompt is not supported!");
177
+ return this.options.prompt(e, o);
178
+ }
179
+ /**
180
+ * Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
181
+ *
182
+ * @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
183
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
184
+ */
185
+ create(e) {
186
+ const o = new h({
187
+ ...this.options,
188
+ ...e
189
+ });
190
+ return this._mockFn && o.mockTypes(this._mockFn), o;
191
+ }
192
+ /**
193
+ * Creates a new Consola instance with the specified default log object properties.
194
+ *
195
+ * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
196
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
197
+ */
198
+ withDefaults(e) {
199
+ return this.create({
200
+ ...this.options,
201
+ defaults: {
202
+ ...this.options.defaults,
203
+ ...e
204
+ }
205
+ });
206
+ }
207
+ /**
208
+ * Creates a new Consola instance with a specified tag, which will be included in every log.
209
+ *
210
+ * @param {string} tag - The tag to include in each log of the new instance.
211
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
212
+ */
213
+ withTag(e) {
214
+ return this.withDefaults({
215
+ tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + e : e
216
+ });
217
+ }
218
+ /**
219
+ * Adds a custom reporter to the Consola instance.
220
+ * Reporters will be called for each log message, depending on their implementation and log level.
221
+ *
222
+ * @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
223
+ * @returns {Consola} The current Consola instance.
224
+ */
225
+ addReporter(e) {
226
+ return this.options.reporters.push(e), this;
227
+ }
228
+ /**
229
+ * Removes a custom reporter from the Consola instance.
230
+ * If no reporter is specified, all reporters will be removed.
231
+ *
232
+ * @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
233
+ * @returns {Consola} The current Consola instance.
234
+ */
235
+ removeReporter(e) {
236
+ if (e) {
237
+ const o = this.options.reporters.indexOf(e);
238
+ if (o !== -1)
239
+ return this.options.reporters.splice(o, 1);
240
+ } else
241
+ this.options.reporters.splice(0);
242
+ return this;
243
+ }
244
+ /**
245
+ * Replaces all reporters of the Consola instance with the specified array of reporters.
246
+ *
247
+ * @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
248
+ * @returns {Consola} The current Consola instance.
249
+ */
250
+ setReporters(e) {
251
+ return this.options.reporters = Array.isArray(e) ? e : [e], this;
252
+ }
253
+ wrapAll() {
254
+ this.wrapConsole(), this.wrapStd();
255
+ }
256
+ restoreAll() {
257
+ this.restoreConsole(), this.restoreStd();
258
+ }
259
+ /**
260
+ * Overrides console methods with Consola logging methods for consistent logging.
261
+ */
262
+ wrapConsole() {
263
+ for (const e in this.options.types)
264
+ console["__" + e] || (console["__" + e] = console[e]), console[e] = this[e].raw;
265
+ }
266
+ /**
267
+ * Restores the original console methods, removing Consola overrides.
268
+ */
269
+ restoreConsole() {
270
+ for (const e in this.options.types)
271
+ console["__" + e] && (console[e] = console["__" + e], delete console["__" + e]);
272
+ }
273
+ /**
274
+ * Overrides standard output and error streams to redirect them through Consola.
275
+ */
276
+ wrapStd() {
277
+ this._wrapStream(this.options.stdout, "log"), this._wrapStream(this.options.stderr, "log");
278
+ }
279
+ _wrapStream(e, o) {
280
+ e && (e.__write || (e.__write = e.write), e.write = (r) => {
281
+ this[o].raw(String(r).trim());
282
+ });
283
+ }
284
+ /**
285
+ * Restores the original standard output and error streams, removing the Consola redirection.
286
+ */
287
+ restoreStd() {
288
+ this._restoreStream(this.options.stdout), this._restoreStream(this.options.stderr);
289
+ }
290
+ _restoreStream(e) {
291
+ e && e.__write && (e.write = e.__write, delete e.__write);
292
+ }
293
+ /**
294
+ * Pauses logging, queues incoming logs until resumed.
295
+ */
296
+ pauseLogs() {
297
+ $ = !0;
298
+ }
299
+ /**
300
+ * Resumes logging, processing any queued logs.
301
+ */
302
+ resumeLogs() {
303
+ $ = !1;
304
+ const e = I.splice(0);
305
+ for (const o of e)
306
+ o[0]._logFn(o[1], o[2]);
307
+ }
308
+ /**
309
+ * Replaces logging methods with mocks if a mock function is provided.
310
+ *
311
+ * @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
312
+ */
313
+ mockTypes(e) {
314
+ const o = e || this.options.mockFn;
315
+ if (this._mockFn = o, typeof o == "function")
316
+ for (const r in this.options.types)
317
+ this[r] = o(r, this.options.types[r]) || this[r], this[r].raw = this[r];
318
+ }
319
+ _wrapLogFn(e, o) {
320
+ return (...r) => {
321
+ if ($) {
322
+ I.push([this, e, r, o]);
323
+ return;
324
+ }
325
+ return this._logFn(e, r, o);
326
+ };
327
+ }
328
+ _logFn(e, o, r) {
329
+ if ((e.level || 0) > this.level)
330
+ return !1;
331
+ const n = {
332
+ date: /* @__PURE__ */ new Date(),
333
+ args: [],
334
+ ...e,
335
+ level: k(e.level, this.options.types)
336
+ };
337
+ !r && o.length === 1 && Y(o[0]) ? Object.assign(n, o[0]) : n.args = [...o], n.message && (n.args.unshift(n.message), delete n.message), n.additional && (Array.isArray(n.additional) || (n.additional = n.additional.split(`
338
+ `)), n.args.push(`
339
+ ` + n.additional.join(`
340
+ `)), delete n.additional), n.type = typeof n.type == "string" ? n.type.toLowerCase() : "log", n.tag = typeof n.tag == "string" ? n.tag : "";
341
+ const s = (i = !1) => {
342
+ const a = (this._lastLog.count || 0) - this.options.throttleMin;
343
+ if (this._lastLog.object && a > 0) {
344
+ const u = [...this._lastLog.object.args];
345
+ a > 1 && u.push(`(repeated ${a} times)`), this._log({ ...this._lastLog.object, args: u }), this._lastLog.count = 1;
346
+ }
347
+ i && (this._lastLog.object = n, this._log(n));
348
+ };
349
+ clearTimeout(this._lastLog.timeout);
350
+ const l = this._lastLog.time && n.date ? n.date.getTime() - this._lastLog.time.getTime() : 0;
351
+ if (this._lastLog.time = n.date, l < this.options.throttle)
352
+ try {
353
+ const i = JSON.stringify([
354
+ n.type,
355
+ n.tag,
356
+ n.args
357
+ ]), a = this._lastLog.serialized === i;
358
+ if (this._lastLog.serialized = i, a && (this._lastLog.count = (this._lastLog.count || 0) + 1, this._lastLog.count > this.options.throttleMin)) {
359
+ this._lastLog.timeout = setTimeout(
360
+ s,
361
+ this.options.throttle
362
+ );
363
+ return;
364
+ }
365
+ } catch {
366
+ }
367
+ s(!0);
368
+ }
369
+ _log(e) {
370
+ for (const o of this.options.reporters)
371
+ o.log(e, {
372
+ options: this.options
373
+ });
374
+ }
375
+ }
376
+ function k(t, e = {}, o = 3) {
377
+ return t === void 0 ? o : typeof t == "number" ? t : e[t] && e[t].level !== void 0 ? e[t].level : o;
378
+ }
379
+ h.prototype.add = h.prototype.addReporter;
380
+ h.prototype.remove = h.prototype.removeReporter;
381
+ h.prototype.clear = h.prototype.removeReporter;
382
+ h.prototype.withScope = h.prototype.withTag;
383
+ h.prototype.mock = h.prototype.mockTypes;
384
+ h.prototype.pause = h.prototype.pauseLogs;
385
+ h.prototype.resume = h.prototype.resumeLogs;
386
+ function J(t = {}) {
387
+ return new h(t);
388
+ }
389
+ class K {
390
+ options;
391
+ defaultColor;
392
+ levelColorMap;
393
+ typeColorMap;
394
+ constructor(e) {
395
+ this.options = { ...e }, this.defaultColor = "#7f8c8d", this.levelColorMap = {
396
+ 0: "#c0392b",
397
+ // Red
398
+ 1: "#f39c12",
399
+ // Yellow
400
+ 3: "#00BCD4"
401
+ // Cyan
402
+ }, this.typeColorMap = {
403
+ success: "#2ecc71"
404
+ // Green
405
+ };
406
+ }
407
+ _getLogFn(e) {
408
+ return e < 1 ? console.__error || console.error : e === 1 ? console.__warn || console.warn : console.__log || console.log;
409
+ }
410
+ log(e) {
411
+ const o = this._getLogFn(e.level), r = e.type === "log" ? "" : e.type, n = e.tag || "", l = `
412
+ background: ${this.typeColorMap[e.type] || this.levelColorMap[e.level] || this.defaultColor};
413
+ border-radius: 0.5em;
414
+ color: white;
415
+ font-weight: bold;
416
+ padding: 2px 0.5em;
417
+ `, i = `%c${[n, r].filter(Boolean).join(":")}`;
418
+ typeof e.args[0] == "string" ? o(
419
+ `${i}%c ${e.args[0]}`,
420
+ l,
421
+ // Empty string as style resets to default console style
422
+ "",
423
+ ...e.args.slice(1)
424
+ ) : o(i, l, ...e.args);
425
+ }
426
+ }
427
+ function Q(t = {}) {
428
+ return J({
429
+ reporters: t.reporters || [new K({})],
430
+ prompt(o, r = {}) {
431
+ return r.type === "confirm" ? Promise.resolve(confirm(o)) : Promise.resolve(prompt(o));
432
+ },
433
+ ...t
434
+ });
435
+ }
436
+ const L = Q(), {
437
+ env: b = {},
438
+ argv: R = [],
439
+ platform: X = ""
440
+ } = typeof process > "u" ? {} : process, Z = "NO_COLOR" in b || R.includes("--no-color"), ee = "FORCE_COLOR" in b || R.includes("--color"), te = X === "win32", E = b.TERM === "dumb", oe = O && O.isatty && O.isatty(1) && b.TERM && !E, ne = "CI" in b && ("GITHUB_ACTIONS" in b || "GITLAB_CI" in b || "CIRCLECI" in b), re = !Z && (ee || te && !E || oe || ne);
441
+ function F(t, e, o, r, n = e.slice(0, Math.max(0, t)) + r, s = e.slice(Math.max(0, t + o.length)), l = s.indexOf(o)) {
442
+ return n + (l < 0 ? s : F(l, s, o, r));
443
+ }
444
+ function se(t, e, o, r, n) {
445
+ return t < 0 ? o + e + r : o + F(t, e, r, n) + r;
446
+ }
447
+ function ie(t, e, o = t, r = t.length + 1) {
448
+ return (n) => n || !(n === "" || n === void 0) ? se(
449
+ ("" + n).indexOf(e, r),
450
+ n,
451
+ t,
452
+ e,
453
+ o
454
+ ) : "";
455
+ }
456
+ function c(t, e, o) {
457
+ return ie(`\x1B[${t}m`, `\x1B[${e}m`, o);
458
+ }
459
+ const N = {
460
+ reset: c(0, 0),
461
+ bold: c(1, 22, "\x1B[22m\x1B[1m"),
462
+ dim: c(2, 22, "\x1B[22m\x1B[2m"),
463
+ italic: c(3, 23),
464
+ underline: c(4, 24),
465
+ inverse: c(7, 27),
466
+ hidden: c(8, 28),
467
+ strikethrough: c(9, 29),
468
+ black: c(30, 39),
469
+ red: c(31, 39),
470
+ green: c(32, 39),
471
+ yellow: c(33, 39),
472
+ blue: c(34, 39),
473
+ magenta: c(35, 39),
474
+ cyan: c(36, 39),
475
+ white: c(37, 39),
476
+ gray: c(90, 39),
477
+ bgBlack: c(40, 49),
478
+ bgRed: c(41, 49),
479
+ bgGreen: c(42, 49),
480
+ bgYellow: c(43, 49),
481
+ bgBlue: c(44, 49),
482
+ bgMagenta: c(45, 49),
483
+ bgCyan: c(46, 49),
484
+ bgWhite: c(47, 49),
485
+ blackBright: c(90, 39),
486
+ redBright: c(91, 39),
487
+ greenBright: c(92, 39),
488
+ yellowBright: c(93, 39),
489
+ blueBright: c(94, 39),
490
+ magentaBright: c(95, 39),
491
+ cyanBright: c(96, 39),
492
+ whiteBright: c(97, 39),
493
+ bgBlackBright: c(100, 49),
494
+ bgRedBright: c(101, 49),
495
+ bgGreenBright: c(102, 49),
496
+ bgYellowBright: c(103, 49),
497
+ bgBlueBright: c(104, 49),
498
+ bgMagentaBright: c(105, 49),
499
+ bgCyanBright: c(106, 49),
500
+ bgWhiteBright: c(107, 49)
501
+ };
502
+ function ae(t = re) {
503
+ return t ? N : Object.fromEntries(Object.keys(N).map((e) => [e, String]));
504
+ }
505
+ const w = ae();
506
+ function le(t) {
507
+ return Array.isArray(t) ? t : t === void 0 ? [] : [t];
508
+ }
509
+ function x(t, e = "") {
510
+ const o = [];
511
+ for (const r of t)
512
+ for (const [n, s] of r.entries())
513
+ o[n] = Math.max(o[n] || 0, s.length);
514
+ return t.map(
515
+ (r) => r.map(
516
+ (n, s) => e + n[s === 0 ? "padStart" : "padEnd"](o[s])
517
+ ).join(" ")
518
+ ).join(`
519
+ `);
520
+ }
521
+ function m(t) {
522
+ return typeof t == "function" ? t() : t;
523
+ }
524
+ class C extends Error {
525
+ constructor(e, o) {
526
+ super(e), this.code = o, this.name = "CLIError";
527
+ }
528
+ }
529
+ const ce = /\d/, ue = ["-", "_", "/", "."];
530
+ function fe(t = "") {
531
+ if (!ce.test(t))
532
+ return t !== t.toLowerCase();
533
+ }
534
+ function U(t, e) {
535
+ const o = ue, r = [];
536
+ if (!t || typeof t != "string")
537
+ return r;
538
+ let n = "", s, l;
539
+ for (const i of t) {
540
+ const a = o.includes(i);
541
+ if (a === !0) {
542
+ r.push(n), n = "", s = void 0;
543
+ continue;
544
+ }
545
+ const u = fe(i);
546
+ if (l === !1) {
547
+ if (s === !1 && u === !0) {
548
+ r.push(n), n = i, s = u;
549
+ continue;
550
+ }
551
+ if (s === !0 && u === !1 && n.length > 1) {
552
+ const p = n.at(-1);
553
+ r.push(n.slice(0, Math.max(0, n.length - 1))), n = p + i, s = u;
554
+ continue;
555
+ }
556
+ }
557
+ n += i, s = u, l = a;
558
+ }
559
+ return r.push(n), r;
560
+ }
561
+ function pe(t) {
562
+ return t ? t[0].toUpperCase() + t.slice(1) : "";
563
+ }
564
+ function he(t) {
565
+ return t ? t[0].toLowerCase() + t.slice(1) : "";
566
+ }
567
+ function ge(t, e) {
568
+ return t ? (Array.isArray(t) ? t : U(t)).map((o) => pe(o)).join("") : "";
569
+ }
570
+ function de(t, e) {
571
+ return he(ge(t || ""));
572
+ }
573
+ function me(t, e) {
574
+ return t ? (Array.isArray(t) ? t : U(t)).map((o) => o.toLowerCase()).join("-") : "";
575
+ }
576
+ function B(t) {
577
+ return t == null ? [] : Array.isArray(t) ? t : [t];
578
+ }
579
+ function ye(t, e, o, r) {
580
+ let n;
581
+ const s = t[e], l = ~r.string.indexOf(e) ? o == null || o === !0 ? "" : String(o) : typeof o == "boolean" ? o : ~r.boolean.indexOf(e) ? o === "false" ? !1 : o === "true" || (t._.push((n = +o, n * 0 === 0 ? n : o)), !!o) : (n = +o, n * 0 === 0 ? n : o);
582
+ t[e] = s == null ? l : Array.isArray(s) ? s.concat(l) : [s, l];
583
+ }
584
+ function we(t = [], e = {}) {
585
+ let o, r, n, s, l;
586
+ const i = { _: [] };
587
+ let a = 0, u = 0, p = 0;
588
+ const v = t.length, A = e.alias !== void 0, f = e.unknown !== void 0, d = e.default !== void 0;
589
+ if (e.alias = e.alias || {}, e.string = B(e.string), e.boolean = B(e.boolean), A)
590
+ for (o in e.alias)
591
+ for (r = e.alias[o] = B(e.alias[o]), a = 0; a < r.length; a++)
592
+ (e.alias[r[a]] = r.concat(o)).splice(a, 1);
593
+ for (a = e.boolean.length; a-- > 0; )
594
+ for (r = e.alias[e.boolean[a]] || [], u = r.length; u-- > 0; )
595
+ e.boolean.push(r[u]);
596
+ for (a = e.string.length; a-- > 0; )
597
+ for (r = e.alias[e.string[a]] || [], u = r.length; u-- > 0; )
598
+ e.string.push(r[u]);
599
+ if (d) {
600
+ for (o in e.default)
601
+ if (s = typeof e.default[o], r = e.alias[o] = e.alias[o] || [], e[s] !== void 0)
602
+ for (e[s].push(o), a = 0; a < r.length; a++)
603
+ e[s].push(r[a]);
604
+ }
605
+ const y = f ? Object.keys(e.alias) : [];
606
+ for (a = 0; a < v; a++) {
607
+ if (n = t[a], n === "--") {
608
+ i._ = i._.concat(t.slice(++a));
609
+ break;
610
+ }
611
+ for (u = 0; u < n.length && n.charCodeAt(u) === 45; u++)
612
+ ;
613
+ if (u === 0)
614
+ i._.push(n);
615
+ else if (n.substring(u, u + 3) === "no-") {
616
+ if (s = n.slice(Math.max(0, u + 3)), f && !~y.indexOf(s))
617
+ return e.unknown(n);
618
+ i[s] = !1;
619
+ } else {
620
+ for (p = u + 1; p < n.length && n.charCodeAt(p) !== 61; p++)
621
+ ;
622
+ for (s = n.substring(u, p), l = n.slice(Math.max(0, ++p)) || a + 1 === v || ("" + t[a + 1]).charCodeAt(0) === 45 || t[++a], r = u === 2 ? [s] : s, p = 0; p < r.length; p++) {
623
+ if (s = r[p], f && !~y.indexOf(s))
624
+ return e.unknown("-".repeat(u) + s);
625
+ ye(i, s, p + 1 < r.length || l, e);
626
+ }
627
+ }
628
+ }
629
+ if (d)
630
+ for (o in e.default)
631
+ i[o] === void 0 && (i[o] = e.default[o]);
632
+ if (A)
633
+ for (o in i)
634
+ for (r = e.alias[o] || []; r.length > 0; )
635
+ i[r.shift()] = i[o];
636
+ return i;
637
+ }
638
+ function be(t, e) {
639
+ const o = {
640
+ boolean: [],
641
+ string: [],
642
+ mixed: [],
643
+ alias: {},
644
+ default: {}
645
+ }, r = P(e);
646
+ for (const i of r)
647
+ i.type !== "positional" && (i.type === "string" ? o.string.push(i.name) : i.type === "boolean" && o.boolean.push(i.name), i.default !== void 0 && (o.default[i.name] = i.default), i.alias && (o.alias[i.name] = i.alias));
648
+ const n = we(t, o), [...s] = n._, l = new Proxy(n, {
649
+ get(i, a) {
650
+ return i[a] ?? i[de(a)] ?? i[me(a)];
651
+ }
652
+ });
653
+ for (const [, i] of r.entries())
654
+ if (i.type === "positional") {
655
+ const a = s.shift();
656
+ if (a !== void 0)
657
+ l[i.name] = a;
658
+ else {
659
+ if (i.default === void 0 && i.required !== !1)
660
+ throw new C(
661
+ `Missing required positional argument: ${i.name.toUpperCase()}`,
662
+ "EARG"
663
+ );
664
+ l[i.name] = i.default;
665
+ }
666
+ } else if (i.required && l[i.name] === void 0)
667
+ throw new C(`Missing required argument: --${i.name}`, "EARG");
668
+ return l;
669
+ }
670
+ function P(t) {
671
+ const e = [];
672
+ for (const [o, r] of Object.entries(t || {}))
673
+ e.push({
674
+ ...r,
675
+ name: o,
676
+ alias: le(r.alias)
677
+ });
678
+ return e;
679
+ }
680
+ async function D(t, e) {
681
+ const o = await m(t.args || {}), r = be(e.rawArgs, o), n = {
682
+ rawArgs: e.rawArgs,
683
+ args: r,
684
+ data: e.data,
685
+ cmd: t
686
+ };
687
+ typeof t.setup == "function" && await t.setup(n);
688
+ let s;
689
+ try {
690
+ const l = await m(t.subCommands);
691
+ if (l && Object.keys(l).length > 0) {
692
+ const i = e.rawArgs.findIndex(
693
+ (u) => !u.startsWith("-")
694
+ ), a = e.rawArgs[i];
695
+ if (a) {
696
+ if (!l[a])
697
+ throw new C(
698
+ `Unknown command \`${a}\``,
699
+ "E_UNKNOWN_COMMAND"
700
+ );
701
+ const u = await m(l[a]);
702
+ u && await D(u, {
703
+ rawArgs: e.rawArgs.slice(i + 1)
704
+ });
705
+ } else if (!t.run)
706
+ throw new C("No command specified.", "E_NO_COMMAND");
707
+ }
708
+ typeof t.run == "function" && (s = await t.run(n));
709
+ } finally {
710
+ typeof t.cleanup == "function" && await t.cleanup(n);
711
+ }
712
+ return { result: s };
713
+ }
714
+ async function T(t, e, o) {
715
+ const r = await m(t.subCommands);
716
+ if (r && Object.keys(r).length > 0) {
717
+ const n = e.findIndex((i) => !i.startsWith("-")), s = e[n], l = await m(r[s]);
718
+ if (l)
719
+ return T(
720
+ l,
721
+ e.slice(n + 1),
722
+ t
723
+ );
724
+ }
725
+ return [t, o];
726
+ }
727
+ async function q(t, e) {
728
+ try {
729
+ L.log(await _e(t, e) + `
730
+ `);
731
+ } catch (o) {
732
+ L.error(o);
733
+ }
734
+ }
735
+ async function _e(t, e) {
736
+ const o = await m(t.meta || {}), r = P(await m(t.args || {})), n = await m(e?.meta || {}), s = `${n.name ? `${n.name} ` : ""}` + (o.name || process.argv[1]), l = [], i = [], a = [], u = [];
737
+ for (const f of r)
738
+ if (f.type === "positional") {
739
+ const d = f.name.toUpperCase(), y = f.required !== !1 && f.default === void 0, _ = f.default ? `="${f.default}"` : "";
740
+ i.push([
741
+ "`" + d + _ + "`",
742
+ f.description || "",
743
+ f.valueHint ? `<${f.valueHint}>` : ""
744
+ ]), u.push(y ? `<${d}>` : `[${d}]`);
745
+ } else {
746
+ const d = f.required === !0 && f.default === void 0, y = (f.type === "boolean" && f.default === !0 ? [
747
+ ...(f.alias || []).map((_) => `--no-${_}`),
748
+ `--no-${f.name}`
749
+ ].join(", ") : [...(f.alias || []).map((_) => `-${_}`), `--${f.name}`].join(
750
+ ", "
751
+ )) + (f.type === "string" && (f.valueHint || f.default) ? `=${f.valueHint ? `<${f.valueHint}>` : `"${f.default || ""}"`}` : "");
752
+ l.push([
753
+ "`" + y + (d ? " (required)" : "") + "`",
754
+ f.description || ""
755
+ ]), d && u.push(y);
756
+ }
757
+ if (t.subCommands) {
758
+ const f = [], d = await m(t.subCommands);
759
+ for (const [y, _] of Object.entries(d)) {
760
+ const G = await m(_), H = await m(G?.meta);
761
+ a.push([`\`${y}\``, H?.description || ""]), f.push(y);
762
+ }
763
+ u.push(f.join("|"));
764
+ }
765
+ const p = [], v = o.version || n.version;
766
+ p.push(
767
+ w.gray(
768
+ `${o.description} (${s + (v ? ` v${v}` : "")})`
769
+ ),
770
+ ""
771
+ );
772
+ const A = l.length > 0 || i.length > 0;
773
+ return p.push(
774
+ `${w.underline(w.bold("USAGE"))} \`${s}${A ? " [OPTIONS]" : ""} ${u.join(" ")}\``,
775
+ ""
776
+ ), i.length > 0 && (p.push(w.underline(w.bold("ARGUMENTS")), ""), p.push(x(i, " ")), p.push("")), l.length > 0 && (p.push(w.underline(w.bold("OPTIONS")), ""), p.push(x(l, " ")), p.push("")), a.length > 0 && (p.push(w.underline(w.bold("COMMANDS")), ""), p.push(x(a, " ")), p.push(
777
+ "",
778
+ `Use \`${s} <command> --help\` for more information about a command.`
779
+ )), p.filter((f) => typeof f == "string").join(`
780
+ `);
781
+ }
782
+ async function Ce(t, e = {}) {
783
+ const o = e.rawArgs || process.argv.slice(2), r = e.showUsage || q;
784
+ try {
785
+ if (o.includes("--help") || o.includes("-h"))
786
+ await r(...await T(t, o)), process.exit(0);
787
+ else if (o.length === 1 && o[0] === "--version") {
788
+ const n = typeof t.meta == "function" ? await t.meta() : await t.meta;
789
+ if (!n?.version)
790
+ throw new C("No version specified", "E_NO_VERSION");
791
+ L.log(n.version);
792
+ } else
793
+ await D(t, { rawArgs: o });
794
+ } catch (n) {
795
+ const s = n instanceof C;
796
+ s || L.error(n, `
797
+ `), s && await r(...await T(t, o)), L.error(n.message), process.exit(1);
798
+ }
799
+ }
800
+ const ve = {
801
+ meta: {
802
+ name: "info",
803
+ description: "Show Taskless CLI information"
804
+ },
805
+ run() {
806
+ console.log(JSON.stringify({ version: "0.0.2" }));
807
+ }
808
+ }, Le = {
809
+ meta: {
810
+ name: "taskless",
811
+ version: "0.0.2",
812
+ description: "Taskless CLI"
813
+ },
814
+ subCommands: {
815
+ info: ve
816
+ },
817
+ async run({ rawArgs: t, cmd: e }) {
818
+ t.some((o) => !o.startsWith("-")) || await q(e);
819
+ }
820
+ };
821
+ Ce(Le);
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@taskless/cli",
3
+ "version": "0.0.2",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/taskless/skills.git",
8
+ "directory": "packages/cli"
9
+ },
10
+ "type": "module",
11
+ "bin": {
12
+ "taskless": "./dist/index.js"
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "dependencies": {
18
+ "citty": "^0.1.6"
19
+ },
20
+ "devDependencies": {
21
+ "typescript": "^5.7.2",
22
+ "vite": "^7.3.1",
23
+ "vite-tsconfig-paths": "^5.1.4",
24
+ "vitest": "^3.2.3"
25
+ },
26
+ "scripts": {
27
+ "build": "vite build",
28
+ "test": "vitest run",
29
+ "typecheck": "tsc --noEmit"
30
+ }
31
+ }