ht-skills 0.1.0 → 0.1.1
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.
- package/lib/cli.js +59 -12
- package/package.json +1 -1
package/lib/cli.js
CHANGED
|
@@ -29,6 +29,12 @@ const TOOL_ALIASES = {
|
|
|
29
29
|
"github-copilot": "vscode",
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
const BANNER_TEXT = String.raw` _ _ _____ ___ _ _ _ _ __ __ _ _ _
|
|
33
|
+
| || |_ _| / __| |_(_) | |___ | \/ |__ _ _ _| |_____| |_ _ __| |__ _ __
|
|
34
|
+
| __ | | | \__ \ / / | | (_-< | |\/| / _` + "`" + String.raw` | '_| / / -_) _| '_ \ / _` + "`" + String.raw` / _|
|
|
35
|
+
|_||_| |_| |___/_\_\_|_|_/__/ |_| |_\__,_|_| |_\_\___|\__| .__/_\__,_\__|
|
|
36
|
+
|_| `;
|
|
37
|
+
|
|
32
38
|
function printHelp() {
|
|
33
39
|
// eslint-disable-next-line no-console
|
|
34
40
|
console.log(`Usage:
|
|
@@ -223,6 +229,57 @@ function formatCount(value, noun) {
|
|
|
223
229
|
return `${value} ${noun}${value === 1 ? "" : "s"}`;
|
|
224
230
|
}
|
|
225
231
|
|
|
232
|
+
function supportsAnsiColor() {
|
|
233
|
+
return Boolean(process.stdout.isTTY) && !process.env.NO_COLOR;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function supportsTrueColor() {
|
|
237
|
+
if (!supportsAnsiColor()) return false;
|
|
238
|
+
const colorTerm = String(process.env.COLORTERM || "").toLowerCase();
|
|
239
|
+
const term = String(process.env.TERM || "").toLowerCase();
|
|
240
|
+
return colorTerm.includes("truecolor") || colorTerm.includes("24bit") || term.includes("truecolor");
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function rgb(r, g, b, text) {
|
|
244
|
+
return `\x1b[38;2;${r};${g};${b}m${text}\x1b[0m`;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function interpolateColor(start, end, t) {
|
|
248
|
+
return {
|
|
249
|
+
r: Math.round(start.r + ((end.r - start.r) * t)),
|
|
250
|
+
g: Math.round(start.g + ((end.g - start.g) * t)),
|
|
251
|
+
b: Math.round(start.b + ((end.b - start.b) * t)),
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function renderGradientBanner() {
|
|
256
|
+
if (!supportsAnsiColor()) {
|
|
257
|
+
return BANNER_TEXT;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const lines = BANNER_TEXT.split("\n");
|
|
261
|
+
if (!supportsTrueColor()) {
|
|
262
|
+
return lines.join("\n");
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const leftColor = { r: 148, g: 163, b: 184 };
|
|
266
|
+
const rightColor = { r: 34, g: 211, b: 238 };
|
|
267
|
+
|
|
268
|
+
return lines
|
|
269
|
+
.map((line) => {
|
|
270
|
+
const width = Math.max(line.length - 1, 1);
|
|
271
|
+
return line
|
|
272
|
+
.split("")
|
|
273
|
+
.map((char, index) => {
|
|
274
|
+
if (char === " ") return char;
|
|
275
|
+
const color = interpolateColor(leftColor, rightColor, index / width);
|
|
276
|
+
return rgb(color.r, color.g, color.b, char);
|
|
277
|
+
})
|
|
278
|
+
.join("");
|
|
279
|
+
})
|
|
280
|
+
.join("\n");
|
|
281
|
+
}
|
|
282
|
+
|
|
226
283
|
function formatInstallSummary(target, colorize = (text) => text) {
|
|
227
284
|
return `${colorize(target.label, "accent")} ${colorize("->", "muted")} ${target.target}`;
|
|
228
285
|
}
|
|
@@ -392,6 +449,8 @@ async function cmdInstall(flags, deps = {}) {
|
|
|
392
449
|
|
|
393
450
|
const resolveSpinner = ui ? ui.spinner() : null;
|
|
394
451
|
if (resolveSpinner) {
|
|
452
|
+
// eslint-disable-next-line no-console
|
|
453
|
+
console.log(`\n${renderGradientBanner()}\n`);
|
|
395
454
|
ui.intro(ui.pc.bgCyan(ui.pc.black(" ht-skills ")));
|
|
396
455
|
resolveSpinner.start(`Resolving ${parsed.slug}`);
|
|
397
456
|
}
|
|
@@ -404,10 +463,6 @@ async function cmdInstall(flags, deps = {}) {
|
|
|
404
463
|
const renderInstallLine = deps.renderInstallLine || ((target) => `installed ${parsed.slug}@${version} -> ${target.target}`);
|
|
405
464
|
let metadata = null;
|
|
406
465
|
|
|
407
|
-
const metadataSpinner = ui ? ui.spinner() : null;
|
|
408
|
-
if (metadataSpinner) {
|
|
409
|
-
metadataSpinner.start("Loading skill metadata");
|
|
410
|
-
}
|
|
411
466
|
try {
|
|
412
467
|
metadata = await requestJsonImpl(
|
|
413
468
|
`${registry}/api/skills/${encodeURIComponent(parsed.slug)}/${encodeURIComponent(version)}`,
|
|
@@ -415,11 +470,6 @@ async function cmdInstall(flags, deps = {}) {
|
|
|
415
470
|
} catch {
|
|
416
471
|
metadata = null;
|
|
417
472
|
}
|
|
418
|
-
if (metadataSpinner) {
|
|
419
|
-
metadataSpinner.stop(metadata?.manifest?.name
|
|
420
|
-
? `Loaded ${metadata.manifest.name}`
|
|
421
|
-
: "Loaded install metadata");
|
|
422
|
-
}
|
|
423
473
|
|
|
424
474
|
const skillName = metadata?.manifest?.name || parsed.slug;
|
|
425
475
|
const skillDescription = metadata?.manifest?.description || "";
|
|
@@ -432,9 +482,6 @@ async function cmdInstall(flags, deps = {}) {
|
|
|
432
482
|
`${colorize("Source", "muted")}: ${registry}`,
|
|
433
483
|
`${colorize("Skill", "muted")}: ${colorize(skillName, "accent")} ${colorize(`(${parsed.slug}@${version})`, "muted")}`,
|
|
434
484
|
skillDescription ? `${colorize("Summary", "muted")}: ${skillDescription}` : "",
|
|
435
|
-
"",
|
|
436
|
-
`${colorize("Available targets", "muted")}:`,
|
|
437
|
-
formatTargetsNote(availableTargets, colorize),
|
|
438
485
|
].filter(Boolean).join("\n"),
|
|
439
486
|
"Install plan",
|
|
440
487
|
);
|