oh-skillhub 0.1.4 → 0.1.5
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/package.json +1 -1
- package/src/cli.js +35 -8
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -21,6 +21,14 @@ const DOMAIN_NAMES = [
|
|
|
21
21
|
"kernel",
|
|
22
22
|
"security",
|
|
23
23
|
];
|
|
24
|
+
const ANSI = {
|
|
25
|
+
reset: "\x1b[0m",
|
|
26
|
+
bold: "\x1b[1m",
|
|
27
|
+
dim: "\x1b[2m",
|
|
28
|
+
cyan: "\x1b[36m",
|
|
29
|
+
green: "\x1b[32m",
|
|
30
|
+
reverse: "\x1b[7m",
|
|
31
|
+
};
|
|
24
32
|
|
|
25
33
|
async function main(argv = []) {
|
|
26
34
|
if (argv.length === 0) {
|
|
@@ -274,30 +282,49 @@ function renderRawTuiMenu(choices, cursor, selected) {
|
|
|
274
282
|
const line = `+${"-".repeat(width - 2)}+`;
|
|
275
283
|
const lines = [
|
|
276
284
|
line,
|
|
277
|
-
|
|
278
|
-
|
|
285
|
+
rawHeaderLine("OH SkillHub", width, ANSI.cyan, ANSI.bold),
|
|
286
|
+
rawHeaderLine("OpenHarmony Skills Installer", width, ANSI.dim),
|
|
279
287
|
line,
|
|
280
288
|
"",
|
|
281
|
-
"Target",
|
|
289
|
+
colorize("Target", ANSI.bold),
|
|
282
290
|
" Agent: codex",
|
|
283
291
|
" Scope: user",
|
|
284
292
|
"",
|
|
285
|
-
"Choose skill groups",
|
|
286
|
-
" Up/Down or j/k: move Space: select Enter: install Ctrl+C: cancel",
|
|
293
|
+
colorize("Choose skill groups", ANSI.bold),
|
|
294
|
+
colorize(" Up/Down or j/k: move Space: select Enter: install Ctrl+C: cancel", ANSI.dim),
|
|
287
295
|
"",
|
|
288
296
|
];
|
|
289
297
|
choices.forEach((choice, index) => {
|
|
290
298
|
const pointer = index === cursor ? ">" : " ";
|
|
291
|
-
const
|
|
292
|
-
|
|
299
|
+
const highlighted = index === cursor;
|
|
300
|
+
const checkbox = rawCheckbox(selected.has(index), highlighted);
|
|
301
|
+
const row = `${pointer} ${checkbox} ${choice.path.padEnd(28, " ")} ${choice.count} skill(s)`;
|
|
302
|
+
lines.push(highlighted ? colorize(row, ANSI.reverse, ANSI.bold) : row);
|
|
293
303
|
for (const leaf of renderSkillLeaves(choice)) {
|
|
294
|
-
lines.push(` - ${leaf}
|
|
304
|
+
lines.push(colorize(` - ${leaf}`, ANSI.dim));
|
|
295
305
|
}
|
|
296
306
|
});
|
|
297
307
|
lines.push("");
|
|
298
308
|
return `${lines.join("\n")}\n`;
|
|
299
309
|
}
|
|
300
310
|
|
|
311
|
+
function colorize(value, ...codes) {
|
|
312
|
+
return `${codes.join("")}${value}${ANSI.reset}`;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function rawHeaderLine(value, width, ...codes) {
|
|
316
|
+
const styled = colorize(value, ...codes);
|
|
317
|
+
return `| ${styled}${" ".repeat(width - 4 - value.length)} |`;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function rawCheckbox(isSelected, highlighted) {
|
|
321
|
+
if (!isSelected) {
|
|
322
|
+
return "[ ]";
|
|
323
|
+
}
|
|
324
|
+
const restore = highlighted ? `${ANSI.reverse}${ANSI.bold}` : "";
|
|
325
|
+
return `${colorize("[✓]", ANSI.green, ANSI.bold)}${restore}`;
|
|
326
|
+
}
|
|
327
|
+
|
|
301
328
|
function renderSkillLeaves(choice) {
|
|
302
329
|
return (choice.skills || []).map((skill) => {
|
|
303
330
|
if (choice.scope === "common") {
|