zion 4.0.0 → 4.1.0
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/README.md +1 -0
- package/dist/cli.js +114 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ run `npx zion` to see what it can do
|
|
|
12
12
|
| `npx zion tui` | open the terminal version of zzzzion.com |
|
|
13
13
|
| `npx zion dotfiles` | set up [my dotfiles](https://github.com/zion-off/dotfiles) |
|
|
14
14
|
| `npx zion skills` | install my agent skills |
|
|
15
|
+
| `npx zion card` | let's see paul allen's card |
|
|
15
16
|
| `npx zion now` | see what I'm listening to, reading and coding |
|
|
16
17
|
| `npx zion help` | list commands; `npx zion help <command>` or `npx zion <command> help` for more |
|
|
17
18
|
|
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import os3 from "os";
|
|
|
8
8
|
import path12 from "path";
|
|
9
9
|
|
|
10
10
|
// package.json
|
|
11
|
-
var version = "4.
|
|
11
|
+
var version = "4.1.0";
|
|
12
12
|
|
|
13
13
|
// src/lib/theme.ts
|
|
14
14
|
import { Chalk, supportsColor, supportsColorStderr } from "chalk";
|
|
@@ -37,6 +37,8 @@ var symbols = {
|
|
|
37
37
|
};
|
|
38
38
|
function createPaint(chalk) {
|
|
39
39
|
return {
|
|
40
|
+
/** Whether anything is colored at all. */
|
|
41
|
+
enabled: chalk.level > 0,
|
|
40
42
|
accent: chalk.hex(palette.accent),
|
|
41
43
|
success: chalk.hex(palette.success),
|
|
42
44
|
warning: chalk.hex(palette.warning),
|
|
@@ -47,6 +49,7 @@ function createPaint(chalk) {
|
|
|
47
49
|
white: chalk.white,
|
|
48
50
|
inverse: chalk.inverse,
|
|
49
51
|
hex: (color) => chalk.hex(color),
|
|
52
|
+
bgHex: (color) => chalk.bgHex(color),
|
|
50
53
|
badge: (text) => chalk.bgHex(palette.brand).hex("#ffffff").bold(` ${text} `)
|
|
51
54
|
};
|
|
52
55
|
}
|
|
@@ -292,6 +295,7 @@ function levenshtein(a, b) {
|
|
|
292
295
|
}
|
|
293
296
|
|
|
294
297
|
// src/cli/help.ts
|
|
298
|
+
var GROUPS = ["work", "play"];
|
|
295
299
|
var HELP_OPTION = ["-h, --help", "show help"];
|
|
296
300
|
var VERSION_OPTION = ["-v, --version", "print the version"];
|
|
297
301
|
var SHARED_OPTIONS = [
|
|
@@ -308,7 +312,7 @@ var HelpPrinter = class {
|
|
|
308
312
|
const paint = ctx.paint.stdout;
|
|
309
313
|
return render([
|
|
310
314
|
header(paint, ctx, "my site, dotfiles, agent skills and more, in your terminal"),
|
|
311
|
-
|
|
315
|
+
...this.commandBlocks(paint),
|
|
312
316
|
[indent(`Run ${paint.accent(`${ctx.bin} help <command>`)} for details on a command.`)]
|
|
313
317
|
]);
|
|
314
318
|
}
|
|
@@ -317,13 +321,26 @@ var HelpPrinter = class {
|
|
|
317
321
|
return render([
|
|
318
322
|
header(paint, ctx),
|
|
319
323
|
section(paint, "Usage", [`${ctx.bin} ${paint.muted("[command] [options]")}`]),
|
|
320
|
-
|
|
324
|
+
...this.commandBlocks(paint),
|
|
321
325
|
section(paint, "Options", table(paint, [HELP_OPTION, VERSION_OPTION, ...SHARED_OPTIONS])),
|
|
322
326
|
[indent(`Run ${paint.accent(`${ctx.bin} help <command>`)} for details on a command.`)]
|
|
323
327
|
]);
|
|
324
328
|
}
|
|
325
|
-
|
|
326
|
-
|
|
329
|
+
/** A section per group, with every name in one column. Ungrouped commands, like help, have their own hint. */
|
|
330
|
+
commandBlocks(paint) {
|
|
331
|
+
const commands = this.registry.list().filter((command) => command.group);
|
|
332
|
+
const width = Math.max(...commands.map((command) => command.name.length));
|
|
333
|
+
return GROUPS.map(
|
|
334
|
+
(group) => section(
|
|
335
|
+
paint,
|
|
336
|
+
group,
|
|
337
|
+
table(
|
|
338
|
+
paint,
|
|
339
|
+
commands.filter((command) => command.group === group).map((command) => [command.name, command.summary]),
|
|
340
|
+
width
|
|
341
|
+
)
|
|
342
|
+
)
|
|
343
|
+
);
|
|
327
344
|
}
|
|
328
345
|
command(command, ctx) {
|
|
329
346
|
const paint = ctx.paint.stdout;
|
|
@@ -381,8 +398,7 @@ function header(paint, ctx, summary, name) {
|
|
|
381
398
|
function section(paint, title, lines) {
|
|
382
399
|
return [indent(paint.bold(title.toUpperCase())), ...lines.map((line) => indent(indent(line)))];
|
|
383
400
|
}
|
|
384
|
-
function table(paint, rows) {
|
|
385
|
-
const width = Math.max(...rows.map(([term]) => term.length));
|
|
401
|
+
function table(paint, rows, width = Math.max(...rows.map(([term]) => term.length))) {
|
|
386
402
|
return rows.map(([term, description]) => `${paint.accent(term.padEnd(width))} ${description}`);
|
|
387
403
|
}
|
|
388
404
|
function indent(line) {
|
|
@@ -429,6 +445,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
429
445
|
var TuiCommand = class {
|
|
430
446
|
name = "tui";
|
|
431
447
|
summary = "browse zzzzion.com in your terminal";
|
|
448
|
+
group = "play";
|
|
432
449
|
help = {
|
|
433
450
|
usage: "[options]",
|
|
434
451
|
description: "Opens a full-screen version of zzzzion.com with the home page, blog and portfolio. Needs an interactive terminal.",
|
|
@@ -452,6 +469,81 @@ var TuiCommand = class {
|
|
|
452
469
|
}
|
|
453
470
|
};
|
|
454
471
|
|
|
472
|
+
// src/commands/card/CardCommand.ts
|
|
473
|
+
import { parseArgs as parseArgs2 } from "util";
|
|
474
|
+
|
|
475
|
+
// src/commands/card/render.ts
|
|
476
|
+
import terminalLink from "terminal-link";
|
|
477
|
+
var STOCK = "#ece6d6";
|
|
478
|
+
var INK = "#1f1d1a";
|
|
479
|
+
var SOFT = "#7d776b";
|
|
480
|
+
var BORDER = "#4d4a44";
|
|
481
|
+
var WIDTH = 52;
|
|
482
|
+
var HEIGHT = 13;
|
|
483
|
+
var MARGIN = " ";
|
|
484
|
+
function renderCard(paint, columns = Infinity) {
|
|
485
|
+
const email3 = { text: "contact@zzzzion.com", color: SOFT, link: "mailto:contact@zzzzion.com" };
|
|
486
|
+
const name = { text: spaced("ATIB JAWAD ZION"), color: INK };
|
|
487
|
+
if (columns < WIDTH + MARGIN.length) {
|
|
488
|
+
return `
|
|
489
|
+
${[name, null, email3].map((segment) => segment ? `${MARGIN}${draw(paint, segment)}` : "").join("\n")}
|
|
490
|
+
|
|
491
|
+
`;
|
|
492
|
+
}
|
|
493
|
+
const inner = WIDTH - 2;
|
|
494
|
+
const blank = " ".repeat(inner);
|
|
495
|
+
const rows = Array.from({ length: HEIGHT - 2 }, () => blank);
|
|
496
|
+
rows[3] = centered(paint, name, inner);
|
|
497
|
+
rows[7] = centered(paint, email3, inner);
|
|
498
|
+
if (paint.enabled) {
|
|
499
|
+
const stock = paint.bgHex(STOCK);
|
|
500
|
+
return `
|
|
501
|
+
${[blank, ...rows, blank].map((row) => `${MARGIN}${stock(row)}`).join("\n")}
|
|
502
|
+
|
|
503
|
+
`;
|
|
504
|
+
}
|
|
505
|
+
const edge = paint.hex(BORDER);
|
|
506
|
+
return `
|
|
507
|
+
${[
|
|
508
|
+
edge(`\u250C${"\u2500".repeat(inner)}\u2510`),
|
|
509
|
+
...rows.map((row) => `${edge("\u2502")}${row}${edge("\u2502")}`),
|
|
510
|
+
edge(`\u2514${"\u2500".repeat(inner)}\u2518`)
|
|
511
|
+
].map((line) => `${MARGIN}${line}`).join("\n")}
|
|
512
|
+
|
|
513
|
+
`;
|
|
514
|
+
}
|
|
515
|
+
function centered(paint, segment, inner) {
|
|
516
|
+
const before = Math.floor((inner - segment.text.length) / 2);
|
|
517
|
+
return `${" ".repeat(before)}${draw(paint, segment)}${" ".repeat(inner - before - segment.text.length)}`;
|
|
518
|
+
}
|
|
519
|
+
function spaced(text) {
|
|
520
|
+
return Array.from(text).join(" ");
|
|
521
|
+
}
|
|
522
|
+
function draw(paint, segment) {
|
|
523
|
+
const text = paint.hex(segment.color)(segment.text);
|
|
524
|
+
return segment.link ? terminalLink(text, segment.link, { fallback: () => text }) : text;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// src/commands/card/CardCommand.ts
|
|
528
|
+
var CardCommand = class {
|
|
529
|
+
name = "card";
|
|
530
|
+
summary = "let's see paul allen's card";
|
|
531
|
+
group = "play";
|
|
532
|
+
help = {
|
|
533
|
+
usage: "[options]",
|
|
534
|
+
examples: ["card"]
|
|
535
|
+
};
|
|
536
|
+
async run(args, ctx) {
|
|
537
|
+
try {
|
|
538
|
+
parseArgs2({ args: [...args], strict: true, options: {} });
|
|
539
|
+
} catch (error62) {
|
|
540
|
+
throw new UsageError(describeParseError(error62), `run ${ctx.bin} card --help for usage`);
|
|
541
|
+
}
|
|
542
|
+
ctx.stdout.write(renderCard(ctx.paint.stdout, ctx.stdout.isTTY ? ctx.stdout.columns : void 0));
|
|
543
|
+
return 0;
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
|
|
455
547
|
// src/lib/format.ts
|
|
456
548
|
var shortCommit = (commit) => commit.slice(0, 7);
|
|
457
549
|
function plural(count, noun) {
|
|
@@ -1126,12 +1218,12 @@ function modeFromFlags(action, flags) {
|
|
|
1126
1218
|
}
|
|
1127
1219
|
|
|
1128
1220
|
// src/commands/dotfiles/options.ts
|
|
1129
|
-
import { parseArgs as
|
|
1221
|
+
import { parseArgs as parseArgs3 } from "util";
|
|
1130
1222
|
function parseDotfilesOptions(args, bin) {
|
|
1131
1223
|
const usageHint = `run ${bin} dotfiles --help for usage`;
|
|
1132
1224
|
let parsed;
|
|
1133
1225
|
try {
|
|
1134
|
-
parsed =
|
|
1226
|
+
parsed = parseArgs3({
|
|
1135
1227
|
args: [...args],
|
|
1136
1228
|
allowPositionals: true,
|
|
1137
1229
|
strict: true,
|
|
@@ -1197,6 +1289,7 @@ var DotfilesCommand = class {
|
|
|
1197
1289
|
deps;
|
|
1198
1290
|
name = "dotfiles";
|
|
1199
1291
|
summary = "set up my dotfiles on this machine";
|
|
1292
|
+
group = "work";
|
|
1200
1293
|
help;
|
|
1201
1294
|
async run(args, ctx) {
|
|
1202
1295
|
const options = parseDotfilesOptions(args, ctx.bin);
|
|
@@ -21159,7 +21252,7 @@ var HttpNowApi = class {
|
|
|
21159
21252
|
};
|
|
21160
21253
|
|
|
21161
21254
|
// src/commands/now/NowCommand.ts
|
|
21162
|
-
import { parseArgs as
|
|
21255
|
+
import { parseArgs as parseArgs4 } from "util";
|
|
21163
21256
|
|
|
21164
21257
|
// src/lib/spinner.ts
|
|
21165
21258
|
var FRAME_MS = 80;
|
|
@@ -21170,13 +21263,13 @@ async function whileSpinning(ctx, work) {
|
|
|
21170
21263
|
let frame = 0;
|
|
21171
21264
|
let drawn = false;
|
|
21172
21265
|
let timer;
|
|
21173
|
-
const
|
|
21266
|
+
const draw2 = () => {
|
|
21174
21267
|
stderr.write(`\r${symbols.spinner[frame++ % symbols.spinner.length]}`);
|
|
21175
21268
|
drawn = true;
|
|
21176
21269
|
};
|
|
21177
21270
|
const delay = setTimeout(() => {
|
|
21178
|
-
|
|
21179
|
-
timer = setInterval(
|
|
21271
|
+
draw2();
|
|
21272
|
+
timer = setInterval(draw2, FRAME_MS);
|
|
21180
21273
|
}, DELAY_MS);
|
|
21181
21274
|
try {
|
|
21182
21275
|
return await work;
|
|
@@ -21188,7 +21281,7 @@ async function whileSpinning(ctx, work) {
|
|
|
21188
21281
|
}
|
|
21189
21282
|
|
|
21190
21283
|
// src/commands/now/format.ts
|
|
21191
|
-
import
|
|
21284
|
+
import terminalLink2 from "terminal-link";
|
|
21192
21285
|
var LABEL_WIDTH = 14;
|
|
21193
21286
|
var PAD_X = 2;
|
|
21194
21287
|
function formatNow(paint, now, at, columns) {
|
|
@@ -21217,7 +21310,7 @@ function sectionsOf(now, at) {
|
|
|
21217
21310
|
}
|
|
21218
21311
|
function entryRows(paint, entry, width) {
|
|
21219
21312
|
const bold = paint.bold(printable(entry.title));
|
|
21220
|
-
const linked = /^https:\/\//.test(entry.url) ?
|
|
21313
|
+
const linked = /^https:\/\//.test(entry.url) ? terminalLink2(bold, printable(entry.url), { fallback: () => bold }) : bold;
|
|
21221
21314
|
const rows = [{ label: entry.label, text: linked }];
|
|
21222
21315
|
if (entry.detail) {
|
|
21223
21316
|
for (const line of wrap2(printable(entry.detail), width)) rows.push({ label: "", text: paint.muted(line) });
|
|
@@ -21293,6 +21386,7 @@ var NowCommand = class {
|
|
|
21293
21386
|
deps;
|
|
21294
21387
|
name = "now";
|
|
21295
21388
|
summary = "see what I'm listening to, reading and coding";
|
|
21389
|
+
group = "play";
|
|
21296
21390
|
help;
|
|
21297
21391
|
async run(args, ctx) {
|
|
21298
21392
|
const { json: json2 } = parseNowOptions(args, ctx.bin);
|
|
@@ -21310,7 +21404,7 @@ var NowCommand = class {
|
|
|
21310
21404
|
};
|
|
21311
21405
|
function parseNowOptions(args, bin) {
|
|
21312
21406
|
try {
|
|
21313
|
-
const { values } =
|
|
21407
|
+
const { values } = parseArgs4({
|
|
21314
21408
|
args: [...args],
|
|
21315
21409
|
strict: true,
|
|
21316
21410
|
options: { json: { type: "boolean", default: false } }
|
|
@@ -22004,12 +22098,12 @@ function findSkillsAction(name) {
|
|
|
22004
22098
|
}
|
|
22005
22099
|
|
|
22006
22100
|
// src/commands/skills/options.ts
|
|
22007
|
-
import { parseArgs as
|
|
22101
|
+
import { parseArgs as parseArgs5 } from "util";
|
|
22008
22102
|
function parseSkillsOptions(args, bin, targetIds) {
|
|
22009
22103
|
const usageHint = `run ${bin} skills --help for usage`;
|
|
22010
22104
|
let parsed;
|
|
22011
22105
|
try {
|
|
22012
|
-
parsed =
|
|
22106
|
+
parsed = parseArgs5({
|
|
22013
22107
|
args: [...args],
|
|
22014
22108
|
allowPositionals: true,
|
|
22015
22109
|
strict: true,
|
|
@@ -22135,6 +22229,7 @@ var SkillsCommand = class {
|
|
|
22135
22229
|
deps;
|
|
22136
22230
|
name = "skills";
|
|
22137
22231
|
summary = "install my agent skills";
|
|
22232
|
+
group = "work";
|
|
22138
22233
|
help;
|
|
22139
22234
|
async run(args, ctx) {
|
|
22140
22235
|
const options = parseSkillsOptions(
|
|
@@ -22399,7 +22494,7 @@ var registry2 = new CommandRegistry().register(
|
|
|
22399
22494
|
createPrompter,
|
|
22400
22495
|
now: () => /* @__PURE__ */ new Date()
|
|
22401
22496
|
})
|
|
22402
|
-
).register(new TuiCommand()).register(
|
|
22497
|
+
).register(new TuiCommand()).register(new CardCommand()).register(
|
|
22403
22498
|
new NowCommand({
|
|
22404
22499
|
api: new HttpNowApi(process.env.ZION_NOW_URL || "https://zzzzion.com/api/now"),
|
|
22405
22500
|
clock: () => /* @__PURE__ */ new Date()
|