skillmds 1.0.14 → 1.0.15
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/CHANGELOG.md +6 -0
- package/dist/cli.js +96 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `skillmds` are documented here. Versions follow [semver](https://semver.org).
|
|
4
4
|
|
|
5
|
+
## 1.0.15
|
|
6
|
+
|
|
7
|
+
- Search is now **browsable in the interactive menu**: arrow through results, press Enter on one to see a card, and install it to your project or user directory — all without leaving the CLI (`← Back` at each level; Esc goes up one step, never quits).
|
|
8
|
+
- Search results are clean two-line entries showing the source repo's **star count** (e.g. `★ 223.7k`) instead of the placeholder rating, with the description truncated to fit your terminal.
|
|
9
|
+
- Fixes for narrow terminals: result rows are width-budgeted so they don't wrap and garble the menu; the result card prints once instead of repainting on every action.
|
|
10
|
+
|
|
5
11
|
## 1.0.14
|
|
6
12
|
|
|
7
13
|
- Interactive menu (`skillmds` in a terminal) no longer exits after one action — it returns to the menu until you pick **Quit**; cancelling a sub-prompt goes back to the menu instead of quitting.
|
package/dist/cli.js
CHANGED
|
@@ -795,6 +795,34 @@ ${skill.body_md || ""}`;
|
|
|
795
795
|
}
|
|
796
796
|
|
|
797
797
|
// ../cli/src/commands/search.ts
|
|
798
|
+
var MAX_LINE_WIDTH = 100;
|
|
799
|
+
function formatStars(n) {
|
|
800
|
+
if (n >= 1e6) {
|
|
801
|
+
const m = Math.round(n / 1e6 * 10) / 10;
|
|
802
|
+
return `${m % 1 === 0 ? m.toFixed(0) : m.toFixed(1)}M`;
|
|
803
|
+
}
|
|
804
|
+
if (n >= 1e3) {
|
|
805
|
+
const k = Math.round(n / 1e3 * 10) / 10;
|
|
806
|
+
return `${k % 1 === 0 ? k.toFixed(0) : k.toFixed(1)}k`;
|
|
807
|
+
}
|
|
808
|
+
return String(n);
|
|
809
|
+
}
|
|
810
|
+
function truncate(text3, width) {
|
|
811
|
+
if (text3.length <= width) return text3;
|
|
812
|
+
if (width <= 1) return "\u2026";
|
|
813
|
+
return `${text3.slice(0, width - 1).trimEnd()}\u2026`;
|
|
814
|
+
}
|
|
815
|
+
function formatSearchResult(item, width = process.stdout.columns ?? 80) {
|
|
816
|
+
const stars = item.repo_stars != null ? pc5.dim(`\u2605 ${formatStars(item.repo_stars)}`) : "";
|
|
817
|
+
const check = item.verified ? pc5.green("\u2713") : "";
|
|
818
|
+
const pack = item.type === "pack" ? pc5.dim("[pack]") : "";
|
|
819
|
+
const head = [pc5.bold(item.slug), stars, check, pack].filter(Boolean).join(" ");
|
|
820
|
+
const indent = " ";
|
|
821
|
+
const lineWidth = Math.max(10, Math.min(width, MAX_LINE_WIDTH) - indent.length);
|
|
822
|
+
const desc = `${indent}${pc5.dim(truncate(item.description ?? "", lineWidth))}`;
|
|
823
|
+
return `${head}
|
|
824
|
+
${desc}`;
|
|
825
|
+
}
|
|
798
826
|
async function runSearch(query, flags) {
|
|
799
827
|
const { api } = createClient(flags);
|
|
800
828
|
const params = new URLSearchParams({ q: query, limit: String(flags.limit ?? 20) });
|
|
@@ -805,13 +833,8 @@ async function runSearch(query, flags) {
|
|
|
805
833
|
const r = await api(`/api/search?${params}`);
|
|
806
834
|
const items = r.items ?? [];
|
|
807
835
|
if (flags.json) return { items, output: JSON.stringify(items, null, 2) };
|
|
808
|
-
const lines = items.map((s) =>
|
|
809
|
-
|
|
810
|
-
const rating = s.avg_rating ? pc5.dim(`\u2605${s.avg_rating.toFixed(1)} (${s.rating_count ?? 0})`) : "";
|
|
811
|
-
return `${check} ${pc5.bold(s.slug)} ${rating}
|
|
812
|
-
${pc5.dim(s.description)}`;
|
|
813
|
-
});
|
|
814
|
-
return { items, output: lines.join("\n") || "No skills found." };
|
|
836
|
+
const lines = items.map((s) => formatSearchResult(s));
|
|
837
|
+
return { items, output: lines.join("\n\n") || "No skills found." };
|
|
815
838
|
}
|
|
816
839
|
function searchCommand() {
|
|
817
840
|
return new Command5("search").description("Search the SkillMD registry").argument("<query>", "search terms").option("--category <slug>", "filter by category").option("--verified", "only verified skills").option("--type <type>", "single | pack").option("--min-rating <n>", "minimum average rating (0-5)").option("--limit <n>", "max results", "20").option("--json", "machine-readable output").action(async (query, opts, cmd) => {
|
|
@@ -1250,6 +1273,67 @@ function bail(v) {
|
|
|
1250
1273
|
}
|
|
1251
1274
|
return false;
|
|
1252
1275
|
}
|
|
1276
|
+
async function browseSearchResults(items) {
|
|
1277
|
+
const cols = process.stdout.columns ?? 80;
|
|
1278
|
+
for (; ; ) {
|
|
1279
|
+
const picked = await p4.select({
|
|
1280
|
+
message: "Search results",
|
|
1281
|
+
options: [
|
|
1282
|
+
...items.map((item2) => {
|
|
1283
|
+
const starsTxt = item2.repo_stars != null ? ` \u2605${formatStars(item2.repo_stars)}` : "";
|
|
1284
|
+
const checkTxt = item2.verified ? " \u2713" : "";
|
|
1285
|
+
const plainLabel = `${item2.slug}${starsTxt}${checkTxt}`;
|
|
1286
|
+
const label2 = `${pc12.bold(item2.slug)}${starsTxt ? pc12.dim(starsTxt) : ""}${checkTxt ? pc12.green(checkTxt) : ""}`;
|
|
1287
|
+
const hintWidth = Math.max(10, cols - plainLabel.length - 6);
|
|
1288
|
+
return {
|
|
1289
|
+
value: item2.slug,
|
|
1290
|
+
label: label2,
|
|
1291
|
+
hint: truncate(item2.description ?? "", hintWidth)
|
|
1292
|
+
};
|
|
1293
|
+
}),
|
|
1294
|
+
{ value: "__back", label: "\u2190 Back to menu" }
|
|
1295
|
+
]
|
|
1296
|
+
});
|
|
1297
|
+
if (p4.isCancel(picked) || picked === "__back") return;
|
|
1298
|
+
const item = items.find((i) => i.slug === picked);
|
|
1299
|
+
if (!item) continue;
|
|
1300
|
+
await browseOneResult(item);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
async function browseOneResult(item) {
|
|
1304
|
+
const starsTxt = item.repo_stars != null ? `\u2605 ${formatStars(item.repo_stars)} stars` : "";
|
|
1305
|
+
const meta = [
|
|
1306
|
+
starsTxt,
|
|
1307
|
+
item.verified ? pc12.green("\u2713 verified") : "unverified",
|
|
1308
|
+
item.type === "pack" ? "pack" : ""
|
|
1309
|
+
].filter(Boolean).join(" \xB7 ");
|
|
1310
|
+
p4.note([item.description ?? "", pc12.dim(meta)].join("\n"), item.slug);
|
|
1311
|
+
for (; ; ) {
|
|
1312
|
+
const action = await p4.select({
|
|
1313
|
+
message: "What next?",
|
|
1314
|
+
options: [
|
|
1315
|
+
{ value: "project", label: "Install to this project" },
|
|
1316
|
+
{ value: "global", label: "Install globally (user dir)" },
|
|
1317
|
+
{ value: "url", label: "Show page URL" },
|
|
1318
|
+
{ value: "back", label: "\u2190 Back to results" }
|
|
1319
|
+
]
|
|
1320
|
+
});
|
|
1321
|
+
if (p4.isCancel(action) || action === "back") return;
|
|
1322
|
+
if (action === "url") {
|
|
1323
|
+
p4.log.message(pc12.dim(`https://skillmd.com/skills/${item.slug}`));
|
|
1324
|
+
continue;
|
|
1325
|
+
}
|
|
1326
|
+
p4.log.step(`Installing ${item.slug}\u2026`);
|
|
1327
|
+
try {
|
|
1328
|
+
const run = await runAdd(item.slug, action === "global" ? { global: true } : {});
|
|
1329
|
+
console.log(run.output);
|
|
1330
|
+
if (run.exitCode === 0) p4.log.success("Installed.");
|
|
1331
|
+
else p4.log.warn("Not installed.");
|
|
1332
|
+
} catch (err) {
|
|
1333
|
+
p4.log.error(err instanceof Error ? err.message : String(err));
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1253
1337
|
async function runInteractive() {
|
|
1254
1338
|
p4.intro(pc12.bgCyan(pc12.black(" skillmd ")));
|
|
1255
1339
|
for (; ; ) {
|
|
@@ -1295,7 +1379,11 @@ async function runInteractive() {
|
|
|
1295
1379
|
try {
|
|
1296
1380
|
const run = await runSearch(String(query), { verified: Boolean(verified), limit: "20" });
|
|
1297
1381
|
s.stop(`${run.items.length} result${run.items.length === 1 ? "" : "s"}`);
|
|
1298
|
-
|
|
1382
|
+
if (run.items.length === 0) {
|
|
1383
|
+
p4.log.info("No results.");
|
|
1384
|
+
break;
|
|
1385
|
+
}
|
|
1386
|
+
await browseSearchResults(run.items);
|
|
1299
1387
|
} catch (err) {
|
|
1300
1388
|
s.stop(pc12.red(err instanceof Error ? err.message : String(err)));
|
|
1301
1389
|
process.exitCode = 1;
|
package/package.json
CHANGED