ht-skills 0.1.5 → 0.1.6

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 (2) hide show
  1. package/lib/cli.js +34 -6
  2. package/package.json +1 -1
package/lib/cli.js CHANGED
@@ -374,7 +374,7 @@ function formatTargetsNote(installTargets, colorize = (text) => text) {
374
374
  .join("\n");
375
375
  }
376
376
 
377
- function formatSearchResult(item, { index = 0, colorize = (text) => text, width = 100 } = {}) {
377
+ function formatSearchResult(item, { index = 0, colorize = (text) => text, width = 80 } = {}) {
378
378
  const ordinal = `${index + 1}.`;
379
379
  const slugPart = `${item.slug}@${item.latestVersion}`;
380
380
  const namePart = normalizeInlineText(item.name || "");
@@ -397,6 +397,27 @@ function formatSearchResult(item, { index = 0, colorize = (text) => text, width
397
397
  return `${renderedPrefix}${separator}${renderedDescription}`;
398
398
  }
399
399
 
400
+ function formatSearchCard(item, { index = 0, colorize = (text) => text, width = 80 } = {}) {
401
+ const ordinal = `${index + 1}.`;
402
+ const slugPart = `${item.slug}@${item.latestVersion}`;
403
+ const namePart = normalizeInlineText(item.name || "");
404
+ const descriptionPart = normalizeInlineText(item.description || "");
405
+ const innerWidth = Math.max(36, width - 4);
406
+ const top = `┌${"─".repeat(innerWidth + 2)}┐`;
407
+ const bottom = `└${"─".repeat(innerWidth + 2)}┘`;
408
+
409
+ const line1Label = `${ordinal} skill: `;
410
+ const line2Label = "description: ";
411
+ const line1Text = truncateText(`${slugPart}${namePart ? ` (${namePart})` : ""}`, Math.max(8, innerWidth - line1Label.length));
412
+ const line2Text = truncateText(descriptionPart || "-", Math.max(8, innerWidth - line2Label.length));
413
+ const line1Plain = `${line1Label}${line1Text}`;
414
+ const line2Plain = `${line2Label}${line2Text}`;
415
+
416
+ const line1 = `│ ${colorize(line1Label, "muted")}${colorize(line1Text, "accent")}${" ".repeat(Math.max(0, innerWidth - line1Plain.length))} │`;
417
+ const line2 = `│ ${colorize(line2Label, "muted")}${line2Text}${" ".repeat(Math.max(0, innerWidth - line2Plain.length))} │`;
418
+ return [top, line1, line2, bottom].join("\n");
419
+ }
420
+
400
421
  function printFallbackIntro({ registry, slug, version, skillName, skillDescription, installTargets }, log = console.log) {
401
422
  log("");
402
423
  log("ht-skills");
@@ -465,13 +486,11 @@ function createUiColorizer(pc) {
465
486
 
466
487
  function formatSearchOption(item, { width = 100 } = {}) {
467
488
  const slugPart = `${item.slug}@${item.latestVersion}`;
468
- const namePart = normalizeInlineText(item.name || "");
469
- const label = truncateText(namePart && namePart !== item.slug ? `${slugPart} ${namePart}` : slugPart, width);
470
- const hint = truncateText(item.description || "", Math.max(24, Math.floor(width * 0.55)));
489
+ const label = truncateText(slugPart, width);
471
490
  return {
472
491
  value: `${item.slug}@${item.latestVersion}`,
473
492
  label,
474
- hint: hint || undefined,
493
+ hint: "",
475
494
  };
476
495
  }
477
496
 
@@ -584,6 +603,15 @@ async function cmdSearch(flags, deps = {}) {
584
603
  }
585
604
 
586
605
  if (ui) {
606
+ const lineWidth = Math.max(44, Math.min(outputWidth - 6, 88));
607
+ // eslint-disable-next-line no-console
608
+ console.log(data.items.map((item, index) => formatSearchCard(item, {
609
+ index,
610
+ colorize,
611
+ width: lineWidth,
612
+ })).join("\n"));
613
+ // eslint-disable-next-line no-console
614
+ console.log("");
587
615
  const optionWidth = Math.max(36, outputWidth - 10);
588
616
  const selectedSpec = await ui.select({
589
617
  message: "Choose a skill to install",
@@ -611,7 +639,7 @@ async function cmdSearch(flags, deps = {}) {
611
639
  const reservedWidth = 4;
612
640
  const lineWidth = Math.max(24, outputWidth - reservedWidth);
613
641
  for (const [index, item] of data.items.entries()) {
614
- log(formatSearchResult(item, {
642
+ log(formatSearchCard(item, {
615
643
  index,
616
644
  colorize,
617
645
  width: lineWidth,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ht-skills",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "CLI for installing and submitting skills from HT Skills Marketplace.",
5
5
  "type": "commonjs",
6
6
  "bin": {