zion 4.0.0 → 4.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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/dist/cli.js +151 -19
  3. 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.0.0";
11
+ var version = "4.1.1";
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
- section(paint, "Commands", table(paint, this.commandRows())),
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
- section(paint, "Commands", table(paint, this.commandRows())),
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
- commandRows() {
326
- return this.registry.list().map((command) => [command.name, command.summary]);
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,118 @@ 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 GRAIN = 14;
482
+ var WIDTH = 52;
483
+ var HEIGHT = 13;
484
+ var MARGIN = " ";
485
+ function renderCard(paint, columns = Infinity) {
486
+ const email3 = { text: "contact@zzzzion.com", color: SOFT, link: "mailto:contact@zzzzion.com" };
487
+ const name = { text: spaced("ATIB JAWAD ZION"), color: INK };
488
+ if (columns < WIDTH + MARGIN.length) {
489
+ return `
490
+ ${[name, null, email3].map((segment) => segment ? `${MARGIN}${draw(paint, segment)}` : "").join("\n")}
491
+
492
+ `;
493
+ }
494
+ const inner = WIDTH - 2;
495
+ if (paint.enabled)
496
+ return `
497
+ ${stock(paint, inner, [
498
+ [3, name],
499
+ [7, email3]
500
+ ]).join("\n")}
501
+
502
+ `;
503
+ const rows = Array.from({ length: HEIGHT - 2 }, () => " ".repeat(inner));
504
+ rows[3] = centered(paint, name, inner);
505
+ rows[7] = centered(paint, email3, inner);
506
+ const edge = paint.hex(BORDER);
507
+ return `
508
+ ${[
509
+ edge(`\u250C${"\u2500".repeat(inner)}\u2510`),
510
+ ...rows.map((row) => `${edge("\u2502")}${row}${edge("\u2502")}`),
511
+ edge(`\u2514${"\u2500".repeat(inner)}\u2518`)
512
+ ].map((line) => `${MARGIN}${line}`).join("\n")}
513
+
514
+ `;
515
+ }
516
+ function stock(paint, inner, lines) {
517
+ const placed = new Map(lines.map(([row, segment]) => [row + 1, segment]));
518
+ const ground = paint.bgHex(STOCK);
519
+ return Array.from({ length: HEIGHT }, (_, y) => {
520
+ const segment = placed.get(y);
521
+ const start = segment ? Math.floor((inner - segment.text.length) / 2) : -1;
522
+ let row = "";
523
+ for (let x = 0; x < inner; x++) {
524
+ if (segment && x === start) {
525
+ row += draw(paint, segment);
526
+ x += segment.text.length - 1;
527
+ continue;
528
+ }
529
+ const beside = segment && x >= start - 1 && x <= start + segment.text.length;
530
+ row += beside ? " " : fiber(paint, x, y);
531
+ }
532
+ return `${MARGIN}${ground(row)}`;
533
+ });
534
+ }
535
+ var FIBERS = ["\xB7", "\u02D9", ".", ",", "'", "`", "\xB8", "\u02DB"];
536
+ var DENSITY = 0.3;
537
+ function fiber(paint, x, y) {
538
+ if (noise(x, y) > DENSITY) return " ";
539
+ const glyph = FIBERS[Math.floor(noise(x * 1.7, y * 3.1) * FIBERS.length)];
540
+ return paint.hex(shade(STOCK, 1 + noise(x * 2.3, y * 0.7)))(glyph);
541
+ }
542
+ function noise(x, y) {
543
+ const n = Math.sin(x * 12.9898 + y * 78.233) * 43758.5453;
544
+ return n - Math.floor(n);
545
+ }
546
+ function shade(hex3, amount) {
547
+ const step = amount * GRAIN;
548
+ return `#${[1, 3, 5].map((at, i) => parseInt(hex3.slice(at, at + 2), 16) - step * (i === 2 ? 1.25 : 1)).map(
549
+ (c) => Math.round(Math.min(255, Math.max(0, c))).toString(16).padStart(2, "0")
550
+ ).join("")}`;
551
+ }
552
+ function centered(paint, segment, inner) {
553
+ const before = Math.floor((inner - segment.text.length) / 2);
554
+ return `${" ".repeat(before)}${draw(paint, segment)}${" ".repeat(inner - before - segment.text.length)}`;
555
+ }
556
+ function spaced(text) {
557
+ return Array.from(text).join(" ");
558
+ }
559
+ function draw(paint, segment) {
560
+ const text = paint.hex(segment.color)(segment.text);
561
+ return segment.link ? terminalLink(text, segment.link, { fallback: () => text }) : text;
562
+ }
563
+
564
+ // src/commands/card/CardCommand.ts
565
+ var CardCommand = class {
566
+ name = "card";
567
+ summary = "let's see paul allen's card";
568
+ group = "play";
569
+ help = {
570
+ usage: "[options]",
571
+ examples: ["card"]
572
+ };
573
+ async run(args, ctx) {
574
+ try {
575
+ parseArgs2({ args: [...args], strict: true, options: {} });
576
+ } catch (error62) {
577
+ throw new UsageError(describeParseError(error62), `run ${ctx.bin} card --help for usage`);
578
+ }
579
+ ctx.stdout.write(renderCard(ctx.paint.stdout, ctx.stdout.isTTY ? ctx.stdout.columns : void 0));
580
+ return 0;
581
+ }
582
+ };
583
+
455
584
  // src/lib/format.ts
456
585
  var shortCommit = (commit) => commit.slice(0, 7);
457
586
  function plural(count, noun) {
@@ -1126,12 +1255,12 @@ function modeFromFlags(action, flags) {
1126
1255
  }
1127
1256
 
1128
1257
  // src/commands/dotfiles/options.ts
1129
- import { parseArgs as parseArgs2 } from "util";
1258
+ import { parseArgs as parseArgs3 } from "util";
1130
1259
  function parseDotfilesOptions(args, bin) {
1131
1260
  const usageHint = `run ${bin} dotfiles --help for usage`;
1132
1261
  let parsed;
1133
1262
  try {
1134
- parsed = parseArgs2({
1263
+ parsed = parseArgs3({
1135
1264
  args: [...args],
1136
1265
  allowPositionals: true,
1137
1266
  strict: true,
@@ -1197,6 +1326,7 @@ var DotfilesCommand = class {
1197
1326
  deps;
1198
1327
  name = "dotfiles";
1199
1328
  summary = "set up my dotfiles on this machine";
1329
+ group = "work";
1200
1330
  help;
1201
1331
  async run(args, ctx) {
1202
1332
  const options = parseDotfilesOptions(args, ctx.bin);
@@ -21159,7 +21289,7 @@ var HttpNowApi = class {
21159
21289
  };
21160
21290
 
21161
21291
  // src/commands/now/NowCommand.ts
21162
- import { parseArgs as parseArgs3 } from "util";
21292
+ import { parseArgs as parseArgs4 } from "util";
21163
21293
 
21164
21294
  // src/lib/spinner.ts
21165
21295
  var FRAME_MS = 80;
@@ -21170,13 +21300,13 @@ async function whileSpinning(ctx, work) {
21170
21300
  let frame = 0;
21171
21301
  let drawn = false;
21172
21302
  let timer;
21173
- const draw = () => {
21303
+ const draw2 = () => {
21174
21304
  stderr.write(`\r${symbols.spinner[frame++ % symbols.spinner.length]}`);
21175
21305
  drawn = true;
21176
21306
  };
21177
21307
  const delay = setTimeout(() => {
21178
- draw();
21179
- timer = setInterval(draw, FRAME_MS);
21308
+ draw2();
21309
+ timer = setInterval(draw2, FRAME_MS);
21180
21310
  }, DELAY_MS);
21181
21311
  try {
21182
21312
  return await work;
@@ -21188,7 +21318,7 @@ async function whileSpinning(ctx, work) {
21188
21318
  }
21189
21319
 
21190
21320
  // src/commands/now/format.ts
21191
- import terminalLink from "terminal-link";
21321
+ import terminalLink2 from "terminal-link";
21192
21322
  var LABEL_WIDTH = 14;
21193
21323
  var PAD_X = 2;
21194
21324
  function formatNow(paint, now, at, columns) {
@@ -21217,7 +21347,7 @@ function sectionsOf(now, at) {
21217
21347
  }
21218
21348
  function entryRows(paint, entry, width) {
21219
21349
  const bold = paint.bold(printable(entry.title));
21220
- const linked = /^https:\/\//.test(entry.url) ? terminalLink(bold, printable(entry.url), { fallback: () => bold }) : bold;
21350
+ const linked = /^https:\/\//.test(entry.url) ? terminalLink2(bold, printable(entry.url), { fallback: () => bold }) : bold;
21221
21351
  const rows = [{ label: entry.label, text: linked }];
21222
21352
  if (entry.detail) {
21223
21353
  for (const line of wrap2(printable(entry.detail), width)) rows.push({ label: "", text: paint.muted(line) });
@@ -21293,6 +21423,7 @@ var NowCommand = class {
21293
21423
  deps;
21294
21424
  name = "now";
21295
21425
  summary = "see what I'm listening to, reading and coding";
21426
+ group = "play";
21296
21427
  help;
21297
21428
  async run(args, ctx) {
21298
21429
  const { json: json2 } = parseNowOptions(args, ctx.bin);
@@ -21310,7 +21441,7 @@ var NowCommand = class {
21310
21441
  };
21311
21442
  function parseNowOptions(args, bin) {
21312
21443
  try {
21313
- const { values } = parseArgs3({
21444
+ const { values } = parseArgs4({
21314
21445
  args: [...args],
21315
21446
  strict: true,
21316
21447
  options: { json: { type: "boolean", default: false } }
@@ -22004,12 +22135,12 @@ function findSkillsAction(name) {
22004
22135
  }
22005
22136
 
22006
22137
  // src/commands/skills/options.ts
22007
- import { parseArgs as parseArgs4 } from "util";
22138
+ import { parseArgs as parseArgs5 } from "util";
22008
22139
  function parseSkillsOptions(args, bin, targetIds) {
22009
22140
  const usageHint = `run ${bin} skills --help for usage`;
22010
22141
  let parsed;
22011
22142
  try {
22012
- parsed = parseArgs4({
22143
+ parsed = parseArgs5({
22013
22144
  args: [...args],
22014
22145
  allowPositionals: true,
22015
22146
  strict: true,
@@ -22135,6 +22266,7 @@ var SkillsCommand = class {
22135
22266
  deps;
22136
22267
  name = "skills";
22137
22268
  summary = "install my agent skills";
22269
+ group = "work";
22138
22270
  help;
22139
22271
  async run(args, ctx) {
22140
22272
  const options = parseSkillsOptions(
@@ -22399,7 +22531,7 @@ var registry2 = new CommandRegistry().register(
22399
22531
  createPrompter,
22400
22532
  now: () => /* @__PURE__ */ new Date()
22401
22533
  })
22402
- ).register(new TuiCommand()).register(
22534
+ ).register(new TuiCommand()).register(new CardCommand()).register(
22403
22535
  new NowCommand({
22404
22536
  api: new HttpNowApi(process.env.ZION_NOW_URL || "https://zzzzion.com/api/now"),
22405
22537
  clock: () => /* @__PURE__ */ new Date()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zion",
3
- "version": "4.0.0",
3
+ "version": "4.1.1",
4
4
  "description": "my site, dotfiles, agent skills and more, in your terminal",
5
5
  "license": "MIT",
6
6
  "repository": {