zion 3.0.1 → 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 +11 -9
- package/dist/cli.js +375 -79
- package/package.json +2 -1
- package/dist/LiveNow-XJH5YXPH.js +0 -136
- package/dist/chunk-77CMFBWR.js +0 -190
package/README.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
### zion
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
my site, dotfiles, agent skills and more, in your terminal
|
|
4
4
|
|
|
5
|
-
run `npx zion`
|
|
5
|
+
run `npx zion` to see what it can do
|
|
6
6
|
|
|
7
7
|
#### commands
|
|
8
8
|
|
|
9
|
-
| command | what it does
|
|
10
|
-
| ------------------- |
|
|
11
|
-
| `npx zion` |
|
|
12
|
-
| `npx zion
|
|
13
|
-
| `npx zion
|
|
14
|
-
| `npx zion
|
|
15
|
-
| `npx zion
|
|
9
|
+
| command | what it does |
|
|
10
|
+
| ------------------- | ------------------------------------------------------------------------------ |
|
|
11
|
+
| `npx zion` | list commands |
|
|
12
|
+
| `npx zion tui` | open the terminal version of zzzzion.com |
|
|
13
|
+
| `npx zion dotfiles` | set up [my dotfiles](https://github.com/zion-off/dotfiles) |
|
|
14
|
+
| `npx zion skills` | install my agent skills |
|
|
15
|
+
| `npx zion card` | let's see paul allen's card |
|
|
16
|
+
| `npx zion now` | see what I'm listening to, reading and coding |
|
|
17
|
+
| `npx zion help` | list commands; `npx zion help <command>` or `npx zion <command> help` for more |
|
|
16
18
|
|
|
17
19
|
Global flags: `--no-color` (or `NO_COLOR`), `--no-input` (never prompt), `-h/--help`, `-v/--version`.
|
package/dist/cli.js
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
CancelledError,
|
|
4
|
-
CliError,
|
|
5
|
-
PaintContext,
|
|
6
|
-
ReportedError,
|
|
7
|
-
UsageError,
|
|
8
|
-
errorCode,
|
|
9
|
-
errorMessage,
|
|
10
|
-
exitCodeFor,
|
|
11
|
-
formatNow,
|
|
12
|
-
paintFor,
|
|
13
|
-
symbols,
|
|
14
|
-
usePaint
|
|
15
|
-
} from "./chunk-77CMFBWR.js";
|
|
16
2
|
import {
|
|
17
3
|
__export
|
|
18
4
|
} from "./chunk-K3NQKI34.js";
|
|
@@ -22,7 +8,56 @@ import os3 from "os";
|
|
|
22
8
|
import path12 from "path";
|
|
23
9
|
|
|
24
10
|
// package.json
|
|
25
|
-
var version = "
|
|
11
|
+
var version = "4.1.0";
|
|
12
|
+
|
|
13
|
+
// src/lib/theme.ts
|
|
14
|
+
import { Chalk, supportsColor, supportsColorStderr } from "chalk";
|
|
15
|
+
var palette = {
|
|
16
|
+
brand: "#264b96",
|
|
17
|
+
accent: "#5c9fd4",
|
|
18
|
+
success: "#3fb950",
|
|
19
|
+
warning: "#f9a73e",
|
|
20
|
+
error: "#e5534b"
|
|
21
|
+
};
|
|
22
|
+
var symbols = {
|
|
23
|
+
start: "\u250C",
|
|
24
|
+
bar: "\u2502",
|
|
25
|
+
end: "\u2514",
|
|
26
|
+
active: "\u25C6",
|
|
27
|
+
done: "\u25C7",
|
|
28
|
+
warning: "\u25B2",
|
|
29
|
+
error: "\u25A0",
|
|
30
|
+
radioOn: "\u25CF",
|
|
31
|
+
radioOff: "\u25CB",
|
|
32
|
+
checkOn: "\u25FC",
|
|
33
|
+
checkOff: "\u25FB",
|
|
34
|
+
tick: "\u2714",
|
|
35
|
+
cross: "\u2716",
|
|
36
|
+
spinner: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"]
|
|
37
|
+
};
|
|
38
|
+
function createPaint(chalk) {
|
|
39
|
+
return {
|
|
40
|
+
/** Whether anything is colored at all. */
|
|
41
|
+
enabled: chalk.level > 0,
|
|
42
|
+
accent: chalk.hex(palette.accent),
|
|
43
|
+
success: chalk.hex(palette.success),
|
|
44
|
+
warning: chalk.hex(palette.warning),
|
|
45
|
+
error: chalk.hex(palette.error),
|
|
46
|
+
muted: chalk.gray,
|
|
47
|
+
dim: chalk.dim,
|
|
48
|
+
bold: chalk.bold,
|
|
49
|
+
white: chalk.white,
|
|
50
|
+
inverse: chalk.inverse,
|
|
51
|
+
hex: (color) => chalk.hex(color),
|
|
52
|
+
bgHex: (color) => chalk.bgHex(color),
|
|
53
|
+
badge: (text) => chalk.bgHex(palette.brand).hex("#ffffff").bold(` ${text} `)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function paintFor(stream, { color, env }) {
|
|
57
|
+
const detected = stream === process.stderr ? supportsColorStderr : supportsColor;
|
|
58
|
+
const noColor = Boolean(env.NO_COLOR) && !("FORCE_COLOR" in env);
|
|
59
|
+
return createPaint(new Chalk({ level: !color || noColor || !detected ? 0 : detected.level }));
|
|
60
|
+
}
|
|
26
61
|
|
|
27
62
|
// src/prompts/format.ts
|
|
28
63
|
function toneColor(paint) {
|
|
@@ -108,6 +143,50 @@ function keyHints(paint, hints) {
|
|
|
108
143
|
return hints.map(([key, action]) => `${paint.white(key)} ${action}`).join(paint.muted(" \xB7 "));
|
|
109
144
|
}
|
|
110
145
|
|
|
146
|
+
// src/cli/errors.ts
|
|
147
|
+
var CliError = class extends Error {
|
|
148
|
+
constructor(message, hint, exitCode = 1) {
|
|
149
|
+
super(message);
|
|
150
|
+
this.hint = hint;
|
|
151
|
+
this.exitCode = exitCode;
|
|
152
|
+
this.name = "CliError";
|
|
153
|
+
}
|
|
154
|
+
hint;
|
|
155
|
+
exitCode;
|
|
156
|
+
};
|
|
157
|
+
var UsageError = class extends CliError {
|
|
158
|
+
constructor(message, hint) {
|
|
159
|
+
super(message, hint, 2);
|
|
160
|
+
this.name = "UsageError";
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
var CancelledError = class extends Error {
|
|
164
|
+
constructor() {
|
|
165
|
+
super("Cancelled");
|
|
166
|
+
this.name = "CancelledError";
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
var ReportedError = class extends Error {
|
|
170
|
+
exitCode;
|
|
171
|
+
constructor(cause) {
|
|
172
|
+
super(errorMessage(cause), { cause });
|
|
173
|
+
this.name = "ReportedError";
|
|
174
|
+
this.exitCode = exitCodeFor(cause);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
function exitCodeFor(error62) {
|
|
178
|
+
if (error62 instanceof ReportedError) return error62.exitCode;
|
|
179
|
+
if (error62 instanceof CancelledError) return 130;
|
|
180
|
+
if (error62 instanceof CliError) return error62.exitCode;
|
|
181
|
+
return 1;
|
|
182
|
+
}
|
|
183
|
+
function errorMessage(error62) {
|
|
184
|
+
return error62 instanceof Error ? error62.message : String(error62);
|
|
185
|
+
}
|
|
186
|
+
function errorCode(error62) {
|
|
187
|
+
return error62 instanceof Error && "code" in error62 && typeof error62.code === "string" ? error62.code : void 0;
|
|
188
|
+
}
|
|
189
|
+
|
|
111
190
|
// src/cli/Cli.ts
|
|
112
191
|
var HELP_FLAGS = /* @__PURE__ */ new Set(["-h", "--help"]);
|
|
113
192
|
var VERSION_FLAGS = /* @__PURE__ */ new Set(["-v", "--version"]);
|
|
@@ -140,9 +219,9 @@ var Cli = class {
|
|
|
140
219
|
return { bin, version: version3, stdin, stdout, stderr, paint, interactive: terminal && !noInput };
|
|
141
220
|
}
|
|
142
221
|
async dispatch(args, ctx) {
|
|
143
|
-
const { registry: registry3,
|
|
222
|
+
const { registry: registry3, help: help2 } = this.options;
|
|
144
223
|
const [first, ...rest] = args;
|
|
145
|
-
if (first === void 0) return
|
|
224
|
+
if (first === void 0) return this.print(ctx, help2.home(ctx));
|
|
146
225
|
if (HELP_FLAGS.has(first)) return this.print(ctx, help2.root(ctx));
|
|
147
226
|
if (VERSION_FLAGS.has(first)) return this.print(ctx, `${ctx.version}
|
|
148
227
|
`);
|
|
@@ -155,7 +234,8 @@ var Cli = class {
|
|
|
155
234
|
suggestion ? `did you mean ${ctx.bin} ${suggestion}?` : `run ${ctx.bin} --help to see all commands`
|
|
156
235
|
);
|
|
157
236
|
}
|
|
158
|
-
|
|
237
|
+
const wantsHelp = rest[0] === "help" || optionsOf(rest).some((arg) => HELP_FLAGS.has(arg));
|
|
238
|
+
if (wantsHelp) return this.print(ctx, help2.command(command, ctx));
|
|
159
239
|
return command.run(rest, ctx);
|
|
160
240
|
}
|
|
161
241
|
print(ctx, text) {
|
|
@@ -215,6 +295,7 @@ function levenshtein(a, b) {
|
|
|
215
295
|
}
|
|
216
296
|
|
|
217
297
|
// src/cli/help.ts
|
|
298
|
+
var GROUPS = ["work", "play"];
|
|
218
299
|
var HELP_OPTION = ["-h, --help", "show help"];
|
|
219
300
|
var VERSION_OPTION = ["-v, --version", "print the version"];
|
|
220
301
|
var SHARED_OPTIONS = [
|
|
@@ -222,26 +303,45 @@ var SHARED_OPTIONS = [
|
|
|
222
303
|
["--no-input", "never prompt; fail if input is needed"]
|
|
223
304
|
];
|
|
224
305
|
var HelpPrinter = class {
|
|
225
|
-
constructor(registry3
|
|
306
|
+
constructor(registry3) {
|
|
226
307
|
this.registry = registry3;
|
|
227
|
-
this.fallback = fallback2;
|
|
228
308
|
}
|
|
229
309
|
registry;
|
|
230
|
-
|
|
310
|
+
/** Shown when no command is given: a short welcome rather than the full reference. */
|
|
311
|
+
home(ctx) {
|
|
312
|
+
const paint = ctx.paint.stdout;
|
|
313
|
+
return render([
|
|
314
|
+
header(paint, ctx, "my site, dotfiles, agent skills and more, in your terminal"),
|
|
315
|
+
...this.commandBlocks(paint),
|
|
316
|
+
[indent(`Run ${paint.accent(`${ctx.bin} help <command>`)} for details on a command.`)]
|
|
317
|
+
]);
|
|
318
|
+
}
|
|
231
319
|
root(ctx) {
|
|
232
320
|
const paint = ctx.paint.stdout;
|
|
233
|
-
const commands = this.registry.list().map((command) => [command.name, command.summary]);
|
|
234
321
|
return render([
|
|
235
322
|
header(paint, ctx),
|
|
236
323
|
section(paint, "Usage", [`${ctx.bin} ${paint.muted("[command] [options]")}`]),
|
|
237
|
-
|
|
324
|
+
...this.commandBlocks(paint),
|
|
238
325
|
section(paint, "Options", table(paint, [HELP_OPTION, VERSION_OPTION, ...SHARED_OPTIONS])),
|
|
239
|
-
[
|
|
240
|
-
`Run ${paint.accent(ctx.bin)} with no command to ${this.fallback.summary}.`,
|
|
241
|
-
`Run ${paint.accent(`${ctx.bin} help <command>`)} for details on a command.`
|
|
242
|
-
].map(indent)
|
|
326
|
+
[indent(`Run ${paint.accent(`${ctx.bin} help <command>`)} for details on a command.`)]
|
|
243
327
|
]);
|
|
244
328
|
}
|
|
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
|
+
);
|
|
344
|
+
}
|
|
245
345
|
command(command, ctx) {
|
|
246
346
|
const paint = ctx.paint.stdout;
|
|
247
347
|
const { help: help2 } = command;
|
|
@@ -298,8 +398,7 @@ function header(paint, ctx, summary, name) {
|
|
|
298
398
|
function section(paint, title, lines) {
|
|
299
399
|
return [indent(paint.bold(title.toUpperCase())), ...lines.map((line) => indent(indent(line)))];
|
|
300
400
|
}
|
|
301
|
-
function table(paint, rows) {
|
|
302
|
-
const width = Math.max(...rows.map(([term]) => term.length));
|
|
401
|
+
function table(paint, rows, width = Math.max(...rows.map(([term]) => term.length))) {
|
|
303
402
|
return rows.map(([term, description]) => `${paint.accent(term.padEnd(width))} ${description}`);
|
|
304
403
|
}
|
|
305
404
|
function indent(line) {
|
|
@@ -326,11 +425,38 @@ ${blocks.filter((block) => block.length > 0).map((block) => block.join("\n")).jo
|
|
|
326
425
|
`;
|
|
327
426
|
}
|
|
328
427
|
|
|
428
|
+
// src/commands/TuiCommand.tsx
|
|
429
|
+
import { parseArgs } from "util";
|
|
430
|
+
|
|
431
|
+
// src/cli/parseArgs.ts
|
|
432
|
+
function describeParseError(error62) {
|
|
433
|
+
const code = errorCode(error62);
|
|
434
|
+
const message = errorMessage(error62);
|
|
435
|
+
const option = message.match(/'(-[^']*)'/)?.[1];
|
|
436
|
+
if (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION" && option) return `unknown option "${option}"`;
|
|
437
|
+
if (code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE" && option) return `option "${option}" needs a value`;
|
|
438
|
+
const positional = message.match(/^Unexpected argument '([^']*)'/)?.[1];
|
|
439
|
+
if (code === "ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL" && positional) return `unexpected argument "${positional}"`;
|
|
440
|
+
return message;
|
|
441
|
+
}
|
|
442
|
+
|
|
329
443
|
// src/commands/TuiCommand.tsx
|
|
330
444
|
import { jsx } from "react/jsx-runtime";
|
|
331
445
|
var TuiCommand = class {
|
|
446
|
+
name = "tui";
|
|
332
447
|
summary = "browse zzzzion.com in your terminal";
|
|
333
|
-
|
|
448
|
+
group = "play";
|
|
449
|
+
help = {
|
|
450
|
+
usage: "[options]",
|
|
451
|
+
description: "Opens a full-screen version of zzzzion.com with the home page, blog and portfolio. Needs an interactive terminal.",
|
|
452
|
+
examples: ["tui"]
|
|
453
|
+
};
|
|
454
|
+
async run(args, ctx) {
|
|
455
|
+
try {
|
|
456
|
+
parseArgs({ args: [...args], strict: true, options: {} });
|
|
457
|
+
} catch (error62) {
|
|
458
|
+
throw new UsageError(describeParseError(error62), `run ${ctx.bin} tui --help for usage`);
|
|
459
|
+
}
|
|
334
460
|
if (!ctx.interactive || !ctx.stdout.isTTY) {
|
|
335
461
|
throw new UsageError(
|
|
336
462
|
"browsing zzzzion.com needs an interactive terminal",
|
|
@@ -343,6 +469,81 @@ var TuiCommand = class {
|
|
|
343
469
|
}
|
|
344
470
|
};
|
|
345
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
|
+
|
|
346
547
|
// src/lib/format.ts
|
|
347
548
|
var shortCommit = (commit) => commit.slice(0, 7);
|
|
348
549
|
function plural(count, noun) {
|
|
@@ -435,6 +636,17 @@ var PromptStore = class {
|
|
|
435
636
|
// src/prompts/components/ConfirmPrompt.tsx
|
|
436
637
|
import { useRef, useState } from "react";
|
|
437
638
|
import { Text, useInput } from "ink";
|
|
639
|
+
|
|
640
|
+
// src/prompts/components/PaintContext.ts
|
|
641
|
+
import { createContext, useContext } from "react";
|
|
642
|
+
var PaintContext = createContext(null);
|
|
643
|
+
function usePaint() {
|
|
644
|
+
const paint = useContext(PaintContext);
|
|
645
|
+
if (!paint) throw new Error("usePaint needs a PaintContext provider");
|
|
646
|
+
return paint;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// src/prompts/components/ConfirmPrompt.tsx
|
|
438
650
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
439
651
|
function ConfirmPrompt({ message, defaultValue, onSubmit }) {
|
|
440
652
|
const paint = usePaint();
|
|
@@ -627,9 +839,9 @@ function TextPrompt({ message, defaultValue = "", validate: validate2, onSubmit
|
|
|
627
839
|
}
|
|
628
840
|
if (key.ctrl || key.meta || key.escape || key.tab || key.upArrow || key.downArrow) return;
|
|
629
841
|
if (key.leftArrow || key.rightArrow) return;
|
|
630
|
-
const
|
|
631
|
-
if (
|
|
632
|
-
setValue((v) => v +
|
|
842
|
+
const printable2 = input2.replace(/[\r\n\t]/g, "");
|
|
843
|
+
if (printable2) {
|
|
844
|
+
setValue((v) => v + printable2);
|
|
633
845
|
setError(void 0);
|
|
634
846
|
}
|
|
635
847
|
});
|
|
@@ -1006,26 +1218,12 @@ function modeFromFlags(action, flags) {
|
|
|
1006
1218
|
}
|
|
1007
1219
|
|
|
1008
1220
|
// src/commands/dotfiles/options.ts
|
|
1009
|
-
import { parseArgs } from "util";
|
|
1010
|
-
|
|
1011
|
-
// src/cli/parseArgs.ts
|
|
1012
|
-
function describeParseError(error62) {
|
|
1013
|
-
const code = errorCode(error62);
|
|
1014
|
-
const message = errorMessage(error62);
|
|
1015
|
-
const option = message.match(/'(-[^']*)'/)?.[1];
|
|
1016
|
-
if (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION" && option) return `unknown option "${option}"`;
|
|
1017
|
-
if (code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE" && option) return `option "${option}" needs a value`;
|
|
1018
|
-
const positional = message.match(/^Unexpected argument '([^']*)'/)?.[1];
|
|
1019
|
-
if (code === "ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL" && positional) return `unexpected argument "${positional}"`;
|
|
1020
|
-
return message;
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
// src/commands/dotfiles/options.ts
|
|
1221
|
+
import { parseArgs as parseArgs3 } from "util";
|
|
1024
1222
|
function parseDotfilesOptions(args, bin) {
|
|
1025
1223
|
const usageHint = `run ${bin} dotfiles --help for usage`;
|
|
1026
1224
|
let parsed;
|
|
1027
1225
|
try {
|
|
1028
|
-
parsed =
|
|
1226
|
+
parsed = parseArgs3({
|
|
1029
1227
|
args: [...args],
|
|
1030
1228
|
allowPositionals: true,
|
|
1031
1229
|
strict: true,
|
|
@@ -1090,7 +1288,8 @@ var DotfilesCommand = class {
|
|
|
1090
1288
|
}
|
|
1091
1289
|
deps;
|
|
1092
1290
|
name = "dotfiles";
|
|
1093
|
-
summary = "set up
|
|
1291
|
+
summary = "set up my dotfiles on this machine";
|
|
1292
|
+
group = "work";
|
|
1094
1293
|
help;
|
|
1095
1294
|
async run(args, ctx) {
|
|
1096
1295
|
const options = parseDotfilesOptions(args, ctx.bin);
|
|
@@ -2013,7 +2212,7 @@ function putProp(target, key, value) {
|
|
|
2013
2212
|
else
|
|
2014
2213
|
target[key] = value;
|
|
2015
2214
|
}
|
|
2016
|
-
function mirrorShape(target, source, keys,
|
|
2215
|
+
function mirrorShape(target, source, keys, wrap3) {
|
|
2017
2216
|
const raw = sourceShape(source);
|
|
2018
2217
|
for (const key of keys) {
|
|
2019
2218
|
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
@@ -2022,10 +2221,10 @@ function mirrorShape(target, source, keys, wrap2) {
|
|
|
2022
2221
|
if (desc.get) {
|
|
2023
2222
|
deferProp(target, key, () => {
|
|
2024
2223
|
const value = source._zod.def.shape[key];
|
|
2025
|
-
return
|
|
2224
|
+
return wrap3 ? wrap3(value, key) : value;
|
|
2026
2225
|
});
|
|
2027
2226
|
} else
|
|
2028
|
-
putProp(target, key,
|
|
2227
|
+
putProp(target, key, wrap3 ? wrap3(desc.value, key) : desc.value);
|
|
2029
2228
|
}
|
|
2030
2229
|
}
|
|
2031
2230
|
function mirrorProps(target, source) {
|
|
@@ -21048,30 +21247,129 @@ var HttpNowApi = class {
|
|
|
21048
21247
|
return this.url.host;
|
|
21049
21248
|
}
|
|
21050
21249
|
get(signal) {
|
|
21051
|
-
return getJson(this.fetchImpl, { url: this.url, schema: Now, failure: "say what
|
|
21250
|
+
return getJson(this.fetchImpl, { url: this.url, schema: Now, failure: "say what I'm up to", signal });
|
|
21052
21251
|
}
|
|
21053
21252
|
};
|
|
21054
21253
|
|
|
21055
21254
|
// src/commands/now/NowCommand.ts
|
|
21056
|
-
import { parseArgs as
|
|
21255
|
+
import { parseArgs as parseArgs4 } from "util";
|
|
21057
21256
|
|
|
21058
21257
|
// src/lib/spinner.ts
|
|
21059
|
-
|
|
21258
|
+
var FRAME_MS = 80;
|
|
21259
|
+
var DELAY_MS = 200;
|
|
21260
|
+
async function whileSpinning(ctx, work) {
|
|
21060
21261
|
if (!ctx.interactive) return work;
|
|
21061
21262
|
const { stderr } = ctx;
|
|
21062
|
-
const paint = ctx.paint.stderr;
|
|
21063
21263
|
let frame = 0;
|
|
21064
|
-
|
|
21065
|
-
|
|
21066
|
-
|
|
21067
|
-
|
|
21068
|
-
|
|
21264
|
+
let drawn = false;
|
|
21265
|
+
let timer;
|
|
21266
|
+
const draw2 = () => {
|
|
21267
|
+
stderr.write(`\r${symbols.spinner[frame++ % symbols.spinner.length]}`);
|
|
21268
|
+
drawn = true;
|
|
21269
|
+
};
|
|
21270
|
+
const delay = setTimeout(() => {
|
|
21271
|
+
draw2();
|
|
21272
|
+
timer = setInterval(draw2, FRAME_MS);
|
|
21273
|
+
}, DELAY_MS);
|
|
21069
21274
|
try {
|
|
21070
21275
|
return await work;
|
|
21071
21276
|
} finally {
|
|
21277
|
+
clearTimeout(delay);
|
|
21072
21278
|
clearInterval(timer);
|
|
21073
|
-
stderr.write("\r\x1B[K");
|
|
21279
|
+
if (drawn) stderr.write("\r\x1B[K");
|
|
21280
|
+
}
|
|
21281
|
+
}
|
|
21282
|
+
|
|
21283
|
+
// src/commands/now/format.ts
|
|
21284
|
+
import terminalLink2 from "terminal-link";
|
|
21285
|
+
var LABEL_WIDTH = 14;
|
|
21286
|
+
var PAD_X = 2;
|
|
21287
|
+
function formatNow(paint, now, at, columns) {
|
|
21288
|
+
const sections = sectionsOf(now, at);
|
|
21289
|
+
const margin = " ".repeat(PAD_X);
|
|
21290
|
+
if (sections.length === 0) return `
|
|
21291
|
+
${margin}${paint.muted(NOTHING)}
|
|
21292
|
+
|
|
21293
|
+
`;
|
|
21294
|
+
const width = columns ? Math.max(20, columns - PAD_X * 2 - LABEL_WIDTH) : Infinity;
|
|
21295
|
+
const body = sections.map(
|
|
21296
|
+
(entries) => entries.flatMap((entry) => entryRows(paint, entry, width)).map((row) => `${margin}${paint.muted(row.label.padEnd(LABEL_WIDTH))}${row.text}`).join("\n")
|
|
21297
|
+
).join("\n\n");
|
|
21298
|
+
return `
|
|
21299
|
+
${body}
|
|
21300
|
+
|
|
21301
|
+
`;
|
|
21302
|
+
}
|
|
21303
|
+
var NOTHING = "Nothing to show right now.";
|
|
21304
|
+
function sectionsOf(now, at) {
|
|
21305
|
+
const sections = [];
|
|
21306
|
+
if (now.listening) sections.push([listening(now.listening, at)]);
|
|
21307
|
+
if (now.reading?.length) sections.push(now.reading.map(reading));
|
|
21308
|
+
if (now.coding) sections.push([coding(now.coding, at)]);
|
|
21309
|
+
return sections;
|
|
21310
|
+
}
|
|
21311
|
+
function entryRows(paint, entry, width) {
|
|
21312
|
+
const bold = paint.bold(printable(entry.title));
|
|
21313
|
+
const linked = /^https:\/\//.test(entry.url) ? terminalLink2(bold, printable(entry.url), { fallback: () => bold }) : bold;
|
|
21314
|
+
const rows = [{ label: entry.label, text: linked }];
|
|
21315
|
+
if (entry.detail) {
|
|
21316
|
+
for (const line of wrap2(printable(entry.detail), width)) rows.push({ label: "", text: paint.muted(line) });
|
|
21317
|
+
}
|
|
21318
|
+
return rows;
|
|
21319
|
+
}
|
|
21320
|
+
function wrap2(text, width) {
|
|
21321
|
+
const lines = [];
|
|
21322
|
+
let line = "";
|
|
21323
|
+
for (const word of text.split(/\s+/)) {
|
|
21324
|
+
if (line && line.length + word.length + 1 > width) {
|
|
21325
|
+
lines.push(line);
|
|
21326
|
+
line = word;
|
|
21327
|
+
} else {
|
|
21328
|
+
line = line ? `${line} ${word}` : word;
|
|
21329
|
+
}
|
|
21074
21330
|
}
|
|
21331
|
+
if (line) lines.push(line);
|
|
21332
|
+
return lines;
|
|
21333
|
+
}
|
|
21334
|
+
function listening(track, at) {
|
|
21335
|
+
const played = track.playedAt === null ? null : ago(new Date(track.playedAt), at);
|
|
21336
|
+
return {
|
|
21337
|
+
label: played === null ? "listening to" : "listened to",
|
|
21338
|
+
title: track.title,
|
|
21339
|
+
url: track.url,
|
|
21340
|
+
detail: played === null ? track.artist : [track.artist, played].join(" \xB7 ")
|
|
21341
|
+
};
|
|
21342
|
+
}
|
|
21343
|
+
function reading(book, i) {
|
|
21344
|
+
return { label: i === 0 ? "reading" : "", title: book.title, url: book.url, detail: book.author };
|
|
21345
|
+
}
|
|
21346
|
+
function coding(push, at) {
|
|
21347
|
+
return {
|
|
21348
|
+
label: "pushed to",
|
|
21349
|
+
title: push.repo,
|
|
21350
|
+
url: push.url,
|
|
21351
|
+
detail: [push.message, ago(new Date(push.pushedAt), at)].join(" \xB7 ")
|
|
21352
|
+
};
|
|
21353
|
+
}
|
|
21354
|
+
var UNITS = [
|
|
21355
|
+
["year", 365 * 24 * 3600],
|
|
21356
|
+
["month", 30 * 24 * 3600],
|
|
21357
|
+
["week", 7 * 24 * 3600],
|
|
21358
|
+
["day", 24 * 3600],
|
|
21359
|
+
["hour", 3600],
|
|
21360
|
+
["minute", 60]
|
|
21361
|
+
];
|
|
21362
|
+
function ago(then, at) {
|
|
21363
|
+
const seconds = (at.getTime() - then.getTime()) / 1e3;
|
|
21364
|
+
if (Number.isNaN(seconds)) return "";
|
|
21365
|
+
const format = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
|
|
21366
|
+
for (const [unit, size] of UNITS) {
|
|
21367
|
+
if (seconds >= size) return format.format(-Math.floor(seconds / size), unit);
|
|
21368
|
+
}
|
|
21369
|
+
return "just now";
|
|
21370
|
+
}
|
|
21371
|
+
function printable(text) {
|
|
21372
|
+
return text.replace(new RegExp("\\p{Cc}", "gu"), "");
|
|
21075
21373
|
}
|
|
21076
21374
|
|
|
21077
21375
|
// src/commands/now/NowCommand.ts
|
|
@@ -21080,34 +21378,33 @@ var NowCommand = class {
|
|
|
21080
21378
|
this.deps = deps;
|
|
21081
21379
|
this.help = {
|
|
21082
21380
|
usage: "[options]",
|
|
21083
|
-
description: `Asks ${deps.api.host} what
|
|
21381
|
+
description: `Asks ${deps.api.host} what I last played on Last.fm, am reading on Goodreads and last pushed to GitHub.`,
|
|
21084
21382
|
options: [["--json", "print it as JSON"]],
|
|
21085
21383
|
examples: ["now", "now --json"]
|
|
21086
21384
|
};
|
|
21087
21385
|
}
|
|
21088
21386
|
deps;
|
|
21089
21387
|
name = "now";
|
|
21090
|
-
summary = "see what
|
|
21388
|
+
summary = "see what I'm listening to, reading and coding";
|
|
21389
|
+
group = "play";
|
|
21091
21390
|
help;
|
|
21092
21391
|
async run(args, ctx) {
|
|
21093
21392
|
const { json: json2 } = parseNowOptions(args, ctx.bin);
|
|
21094
|
-
|
|
21095
|
-
const { runLive } = await import("./LiveNow-XJH5YXPH.js");
|
|
21096
|
-
return runLive(ctx, this.deps);
|
|
21097
|
-
}
|
|
21098
|
-
const status = await whileSpinning(ctx, `asking ${this.deps.api.host}`, this.deps.api.get());
|
|
21393
|
+
const status = await whileSpinning(ctx, this.deps.api.get());
|
|
21099
21394
|
if (json2) {
|
|
21100
21395
|
ctx.stdout.write(`${JSON.stringify(status, null, 2)}
|
|
21101
21396
|
`);
|
|
21102
21397
|
return 0;
|
|
21103
21398
|
}
|
|
21104
|
-
ctx.stdout.write(
|
|
21399
|
+
ctx.stdout.write(
|
|
21400
|
+
formatNow(ctx.paint.stdout, status, this.deps.clock(), ctx.stdout.isTTY ? ctx.stdout.columns : void 0)
|
|
21401
|
+
);
|
|
21105
21402
|
return 0;
|
|
21106
21403
|
}
|
|
21107
21404
|
};
|
|
21108
21405
|
function parseNowOptions(args, bin) {
|
|
21109
21406
|
try {
|
|
21110
|
-
const { values } =
|
|
21407
|
+
const { values } = parseArgs4({
|
|
21111
21408
|
args: [...args],
|
|
21112
21409
|
strict: true,
|
|
21113
21410
|
options: { json: { type: "boolean", default: false } }
|
|
@@ -21801,12 +22098,12 @@ function findSkillsAction(name) {
|
|
|
21801
22098
|
}
|
|
21802
22099
|
|
|
21803
22100
|
// src/commands/skills/options.ts
|
|
21804
|
-
import { parseArgs as
|
|
22101
|
+
import { parseArgs as parseArgs5 } from "util";
|
|
21805
22102
|
function parseSkillsOptions(args, bin, targetIds) {
|
|
21806
22103
|
const usageHint = `run ${bin} skills --help for usage`;
|
|
21807
22104
|
let parsed;
|
|
21808
22105
|
try {
|
|
21809
|
-
parsed =
|
|
22106
|
+
parsed = parseArgs5({
|
|
21810
22107
|
args: [...args],
|
|
21811
22108
|
allowPositionals: true,
|
|
21812
22109
|
strict: true,
|
|
@@ -21931,7 +22228,8 @@ var SkillsCommand = class {
|
|
|
21931
22228
|
}
|
|
21932
22229
|
deps;
|
|
21933
22230
|
name = "skills";
|
|
21934
|
-
summary = "install
|
|
22231
|
+
summary = "install my agent skills";
|
|
22232
|
+
group = "work";
|
|
21935
22233
|
help;
|
|
21936
22234
|
async run(args, ctx) {
|
|
21937
22235
|
const options = parseSkillsOptions(
|
|
@@ -22196,18 +22494,16 @@ var registry2 = new CommandRegistry().register(
|
|
|
22196
22494
|
createPrompter,
|
|
22197
22495
|
now: () => /* @__PURE__ */ new Date()
|
|
22198
22496
|
})
|
|
22199
|
-
).register(
|
|
22497
|
+
).register(new TuiCommand()).register(new CardCommand()).register(
|
|
22200
22498
|
new NowCommand({
|
|
22201
22499
|
api: new HttpNowApi(process.env.ZION_NOW_URL || "https://zzzzion.com/api/now"),
|
|
22202
22500
|
clock: () => /* @__PURE__ */ new Date()
|
|
22203
22501
|
})
|
|
22204
22502
|
);
|
|
22205
|
-
var
|
|
22206
|
-
var help = new HelpPrinter(registry2, fallback);
|
|
22503
|
+
var help = new HelpPrinter(registry2);
|
|
22207
22504
|
registry2.register(new HelpCommand(help, registry2));
|
|
22208
22505
|
var cli = new Cli({
|
|
22209
22506
|
registry: registry2,
|
|
22210
|
-
fallback,
|
|
22211
22507
|
help,
|
|
22212
22508
|
environment: {
|
|
22213
22509
|
bin: "npx zion",
|
package/package.json
CHANGED
package/dist/LiveNow-XJH5YXPH.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
LABEL_WIDTH,
|
|
4
|
-
NOTHING,
|
|
5
|
-
PaintContext,
|
|
6
|
-
entryRows,
|
|
7
|
-
errorMessage,
|
|
8
|
-
palette,
|
|
9
|
-
sectionsOf,
|
|
10
|
-
usePaint
|
|
11
|
-
} from "./chunk-77CMFBWR.js";
|
|
12
|
-
import "./chunk-K3NQKI34.js";
|
|
13
|
-
|
|
14
|
-
// src/commands/now/live/LiveNow.tsx
|
|
15
|
-
import { useEffect, useState } from "react";
|
|
16
|
-
import { Box, Text, render, useApp, useInput } from "ink";
|
|
17
|
-
|
|
18
|
-
// src/commands/now/live/effects.ts
|
|
19
|
-
var WHITE = "#ffffff";
|
|
20
|
-
function shimmer(paint, text, ms) {
|
|
21
|
-
const chars = Array.from(text);
|
|
22
|
-
const reach = 4;
|
|
23
|
-
const center = ms / 1400 % 1 * (chars.length + reach * 2) - reach;
|
|
24
|
-
return chars.map((char, i) => paint.hex(mix(palette.accent, WHITE, Math.max(0, 1 - Math.abs(i - center) / reach)))(char)).join("");
|
|
25
|
-
}
|
|
26
|
-
var LEVELS = ["\u2581", "\u2582", "\u2583", "\u2584", "\u2585", "\u2586", "\u2587", "\u2588"];
|
|
27
|
-
function bars(paint, ms, count = 4) {
|
|
28
|
-
return Array.from({ length: count }, (_, i) => {
|
|
29
|
-
const level = (wave(ms / (260 + i * 70) + i * 1.7) + wave(ms / (410 - i * 45) + i)) / 2;
|
|
30
|
-
return paint.hex(mix(palette.accent, WHITE, level))(LEVELS[Math.round(level * (LEVELS.length - 1))]);
|
|
31
|
-
}).join("");
|
|
32
|
-
}
|
|
33
|
-
function wave(x) {
|
|
34
|
-
return (Math.sin(x) + 1) / 2;
|
|
35
|
-
}
|
|
36
|
-
function mix(from, to, t) {
|
|
37
|
-
const channel = (hex, at) => parseInt(hex.slice(at, at + 2), 16);
|
|
38
|
-
return `#${[1, 3, 5].map((at) => Math.round(channel(from, at) + (channel(to, at) - channel(from, at)) * t)).map((value) => value.toString(16).padStart(2, "0")).join("")}`;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// src/commands/now/live/LiveNow.tsx
|
|
42
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
43
|
-
var FRAME_MS = 80;
|
|
44
|
-
var REFRESH_MS = 3e4;
|
|
45
|
-
async function runLive(ctx, deps) {
|
|
46
|
-
let code = 0;
|
|
47
|
-
const instance = render(
|
|
48
|
-
/* @__PURE__ */ jsx(PaintContext.Provider, { value: ctx.paint.stdout, children: /* @__PURE__ */ jsx(
|
|
49
|
-
LiveNow,
|
|
50
|
-
{
|
|
51
|
-
...deps,
|
|
52
|
-
onQuit: (quitWith) => {
|
|
53
|
-
code = quitWith;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
) }),
|
|
57
|
-
{ stdout: ctx.stdout, stdin: ctx.stdin, exitOnCtrlC: false, patchConsole: false }
|
|
58
|
-
);
|
|
59
|
-
await instance.waitUntilExit();
|
|
60
|
-
return code;
|
|
61
|
-
}
|
|
62
|
-
function LiveNow({ api, clock, onQuit }) {
|
|
63
|
-
const paint = usePaint();
|
|
64
|
-
const { exit } = useApp();
|
|
65
|
-
const [ms, setMs] = useState(() => clock().getTime());
|
|
66
|
-
const [now, setNow] = useState(null);
|
|
67
|
-
const [status, setStatus] = useState("live");
|
|
68
|
-
const [failure, setFailure] = useState(null);
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
const timer = setInterval(() => setMs(clock().getTime()), FRAME_MS);
|
|
71
|
-
return () => clearInterval(timer);
|
|
72
|
-
}, [clock]);
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
const controller = new AbortController();
|
|
75
|
-
let loaded = false;
|
|
76
|
-
let loading = false;
|
|
77
|
-
const load = () => {
|
|
78
|
-
if (loading) return;
|
|
79
|
-
loading = true;
|
|
80
|
-
api.get(controller.signal).then(
|
|
81
|
-
(latest) => {
|
|
82
|
-
loaded = true;
|
|
83
|
-
setNow(latest);
|
|
84
|
-
setStatus((current) => current === "quit" ? current : "live");
|
|
85
|
-
},
|
|
86
|
-
(error) => {
|
|
87
|
-
if (controller.signal.aborted) return;
|
|
88
|
-
if (!loaded) setFailure(error instanceof Error ? error : new Error(errorMessage(error)));
|
|
89
|
-
else setStatus((current) => current === "quit" ? current : "stale");
|
|
90
|
-
}
|
|
91
|
-
).finally(() => {
|
|
92
|
-
loading = false;
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
load();
|
|
96
|
-
const timer = setInterval(load, REFRESH_MS);
|
|
97
|
-
return () => {
|
|
98
|
-
clearInterval(timer);
|
|
99
|
-
controller.abort();
|
|
100
|
-
};
|
|
101
|
-
}, [api]);
|
|
102
|
-
useInput((input, key) => {
|
|
103
|
-
const code = input === "q" || key.escape ? 0 : key.ctrl && input === "c" ? 130 : null;
|
|
104
|
-
if (code === null) return;
|
|
105
|
-
onQuit(code);
|
|
106
|
-
setStatus("quit");
|
|
107
|
-
});
|
|
108
|
-
useEffect(() => {
|
|
109
|
-
if (failure) exit(failure);
|
|
110
|
-
else if (status === "quit") exit();
|
|
111
|
-
}, [exit, failure, status]);
|
|
112
|
-
if (failure) return null;
|
|
113
|
-
return /* @__PURE__ */ jsx(Box, { paddingX: 2, paddingY: 1, children: now ? frame(paint, now, clock(), ms, status) : /* @__PURE__ */ jsx(Text, { children: asking(paint, api.host, ms) }) });
|
|
114
|
-
}
|
|
115
|
-
function asking(paint, host, ms) {
|
|
116
|
-
return shimmer(paint, `asking ${host}`, ms);
|
|
117
|
-
}
|
|
118
|
-
function frame(paint, now, at, ms, status) {
|
|
119
|
-
const quit = status === "quit";
|
|
120
|
-
const playing = quit ? "" : ` ${bars(paint, ms)}`;
|
|
121
|
-
const sections = sectionsOf(now, at).map(
|
|
122
|
-
(entries) => entries.flatMap((entry) => entryRows(paint, entry, entry.playing ? playing : ""))
|
|
123
|
-
);
|
|
124
|
-
const footer = status === "stale" ? `${paint.warning("\u25B2")} ${paint.muted("couldn't refresh, still trying \xB7 q to quit")}` : paint.muted("q to quit");
|
|
125
|
-
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", rowGap: 1, children: [
|
|
126
|
-
sections.length === 0 && /* @__PURE__ */ jsx(Text, { children: paint.muted(NOTHING) }),
|
|
127
|
-
sections.map((rows, i) => /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: rows.map((row, j) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
128
|
-
/* @__PURE__ */ jsx(Box, { width: LABEL_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx(Text, { children: paint.muted(row.label) }) }),
|
|
129
|
-
/* @__PURE__ */ jsx(Text, { children: row.text })
|
|
130
|
-
] }, j)) }, i)),
|
|
131
|
-
!quit && /* @__PURE__ */ jsx(Text, { children: footer })
|
|
132
|
-
] });
|
|
133
|
-
}
|
|
134
|
-
export {
|
|
135
|
-
runLive
|
|
136
|
-
};
|
package/dist/chunk-77CMFBWR.js
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/cli/errors.ts
|
|
4
|
-
var CliError = class extends Error {
|
|
5
|
-
constructor(message, hint, exitCode = 1) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.hint = hint;
|
|
8
|
-
this.exitCode = exitCode;
|
|
9
|
-
this.name = "CliError";
|
|
10
|
-
}
|
|
11
|
-
hint;
|
|
12
|
-
exitCode;
|
|
13
|
-
};
|
|
14
|
-
var UsageError = class extends CliError {
|
|
15
|
-
constructor(message, hint) {
|
|
16
|
-
super(message, hint, 2);
|
|
17
|
-
this.name = "UsageError";
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
var CancelledError = class extends Error {
|
|
21
|
-
constructor() {
|
|
22
|
-
super("Cancelled");
|
|
23
|
-
this.name = "CancelledError";
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
var ReportedError = class extends Error {
|
|
27
|
-
exitCode;
|
|
28
|
-
constructor(cause) {
|
|
29
|
-
super(errorMessage(cause), { cause });
|
|
30
|
-
this.name = "ReportedError";
|
|
31
|
-
this.exitCode = exitCodeFor(cause);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
function exitCodeFor(error) {
|
|
35
|
-
if (error instanceof ReportedError) return error.exitCode;
|
|
36
|
-
if (error instanceof CancelledError) return 130;
|
|
37
|
-
if (error instanceof CliError) return error.exitCode;
|
|
38
|
-
return 1;
|
|
39
|
-
}
|
|
40
|
-
function errorMessage(error) {
|
|
41
|
-
return error instanceof Error ? error.message : String(error);
|
|
42
|
-
}
|
|
43
|
-
function errorCode(error) {
|
|
44
|
-
return error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// src/prompts/components/PaintContext.ts
|
|
48
|
-
import { createContext, useContext } from "react";
|
|
49
|
-
var PaintContext = createContext(null);
|
|
50
|
-
function usePaint() {
|
|
51
|
-
const paint = useContext(PaintContext);
|
|
52
|
-
if (!paint) throw new Error("usePaint needs a PaintContext provider");
|
|
53
|
-
return paint;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// src/commands/now/format.ts
|
|
57
|
-
import terminalLink from "terminal-link";
|
|
58
|
-
var LABEL_WIDTH = 14;
|
|
59
|
-
function formatNow(paint, now, at) {
|
|
60
|
-
const sections = sectionsOf(now, at);
|
|
61
|
-
if (sections.length === 0) return `${paint.muted(NOTHING)}
|
|
62
|
-
`;
|
|
63
|
-
return `${sections.map(
|
|
64
|
-
(entries) => entries.flatMap((entry) => entryRows(paint, entry)).map((row) => `${paint.muted(row.label.padEnd(LABEL_WIDTH))}${row.text}`).join("\n")
|
|
65
|
-
).join("\n\n")}
|
|
66
|
-
`;
|
|
67
|
-
}
|
|
68
|
-
var NOTHING = "Nothing to show right now.";
|
|
69
|
-
function sectionsOf(now, at) {
|
|
70
|
-
const sections = [];
|
|
71
|
-
if (now.listening) sections.push([listening(now.listening, at)]);
|
|
72
|
-
if (now.reading?.length) sections.push(now.reading.map(reading));
|
|
73
|
-
if (now.coding) sections.push([coding(now.coding, at)]);
|
|
74
|
-
return sections;
|
|
75
|
-
}
|
|
76
|
-
function entryRows(paint, entry, after = "") {
|
|
77
|
-
const bold = paint.bold(printable(entry.title));
|
|
78
|
-
const linked = /^https:\/\//.test(entry.url) ? terminalLink(bold, printable(entry.url), { fallback: () => bold }) : bold;
|
|
79
|
-
const rows = [{ label: entry.label, text: `${linked}${after}` }];
|
|
80
|
-
if (entry.detail) rows.push({ label: "", text: paint.muted(printable(entry.detail)) });
|
|
81
|
-
return rows;
|
|
82
|
-
}
|
|
83
|
-
function listening(track, at) {
|
|
84
|
-
const played = track.playedAt === null ? null : ago(new Date(track.playedAt), at);
|
|
85
|
-
return {
|
|
86
|
-
label: played === null ? "listening to" : "listened to",
|
|
87
|
-
title: track.title,
|
|
88
|
-
url: track.url,
|
|
89
|
-
detail: played === null ? track.artist : [track.artist, played].join(" \xB7 "),
|
|
90
|
-
playing: played === null
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function reading(book, i) {
|
|
94
|
-
return { label: i === 0 ? "reading" : "", title: book.title, url: book.url, detail: book.author, playing: false };
|
|
95
|
-
}
|
|
96
|
-
function coding(push, at) {
|
|
97
|
-
return {
|
|
98
|
-
label: "pushed to",
|
|
99
|
-
title: push.repo,
|
|
100
|
-
url: push.url,
|
|
101
|
-
detail: [push.message, ago(new Date(push.pushedAt), at)].join(" \xB7 "),
|
|
102
|
-
playing: false
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
var UNITS = [
|
|
106
|
-
["year", 365 * 24 * 3600],
|
|
107
|
-
["month", 30 * 24 * 3600],
|
|
108
|
-
["week", 7 * 24 * 3600],
|
|
109
|
-
["day", 24 * 3600],
|
|
110
|
-
["hour", 3600],
|
|
111
|
-
["minute", 60]
|
|
112
|
-
];
|
|
113
|
-
function ago(then, at) {
|
|
114
|
-
const seconds = (at.getTime() - then.getTime()) / 1e3;
|
|
115
|
-
if (Number.isNaN(seconds)) return "";
|
|
116
|
-
const format = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
|
|
117
|
-
for (const [unit, size] of UNITS) {
|
|
118
|
-
if (seconds >= size) return format.format(-Math.floor(seconds / size), unit);
|
|
119
|
-
}
|
|
120
|
-
return "just now";
|
|
121
|
-
}
|
|
122
|
-
function printable(text) {
|
|
123
|
-
return text.replace(new RegExp("\\p{Cc}", "gu"), "");
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// src/lib/theme.ts
|
|
127
|
-
import { Chalk, supportsColor, supportsColorStderr } from "chalk";
|
|
128
|
-
var palette = {
|
|
129
|
-
brand: "#264b96",
|
|
130
|
-
accent: "#5c9fd4",
|
|
131
|
-
success: "#3fb950",
|
|
132
|
-
warning: "#f9a73e",
|
|
133
|
-
error: "#e5534b"
|
|
134
|
-
};
|
|
135
|
-
var symbols = {
|
|
136
|
-
start: "\u250C",
|
|
137
|
-
bar: "\u2502",
|
|
138
|
-
end: "\u2514",
|
|
139
|
-
active: "\u25C6",
|
|
140
|
-
done: "\u25C7",
|
|
141
|
-
warning: "\u25B2",
|
|
142
|
-
error: "\u25A0",
|
|
143
|
-
radioOn: "\u25CF",
|
|
144
|
-
radioOff: "\u25CB",
|
|
145
|
-
checkOn: "\u25FC",
|
|
146
|
-
checkOff: "\u25FB",
|
|
147
|
-
tick: "\u2714",
|
|
148
|
-
cross: "\u2716",
|
|
149
|
-
spinner: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"]
|
|
150
|
-
};
|
|
151
|
-
function createPaint(chalk) {
|
|
152
|
-
return {
|
|
153
|
-
accent: chalk.hex(palette.accent),
|
|
154
|
-
success: chalk.hex(palette.success),
|
|
155
|
-
warning: chalk.hex(palette.warning),
|
|
156
|
-
error: chalk.hex(palette.error),
|
|
157
|
-
muted: chalk.gray,
|
|
158
|
-
dim: chalk.dim,
|
|
159
|
-
bold: chalk.bold,
|
|
160
|
-
white: chalk.white,
|
|
161
|
-
inverse: chalk.inverse,
|
|
162
|
-
hex: (color) => chalk.hex(color),
|
|
163
|
-
badge: (text) => chalk.bgHex(palette.brand).hex("#ffffff").bold(` ${text} `)
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
function paintFor(stream, { color, env }) {
|
|
167
|
-
const detected = stream === process.stderr ? supportsColorStderr : supportsColor;
|
|
168
|
-
const noColor = Boolean(env.NO_COLOR) && !("FORCE_COLOR" in env);
|
|
169
|
-
return createPaint(new Chalk({ level: !color || noColor || !detected ? 0 : detected.level }));
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export {
|
|
173
|
-
palette,
|
|
174
|
-
symbols,
|
|
175
|
-
paintFor,
|
|
176
|
-
CliError,
|
|
177
|
-
UsageError,
|
|
178
|
-
CancelledError,
|
|
179
|
-
ReportedError,
|
|
180
|
-
exitCodeFor,
|
|
181
|
-
errorMessage,
|
|
182
|
-
errorCode,
|
|
183
|
-
PaintContext,
|
|
184
|
-
usePaint,
|
|
185
|
-
LABEL_WIDTH,
|
|
186
|
-
formatNow,
|
|
187
|
-
NOTHING,
|
|
188
|
-
sectionsOf,
|
|
189
|
-
entryRows
|
|
190
|
-
};
|