zion 3.0.0 → 4.0.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 +10 -9
- package/dist/cli.js +300 -74
- package/package.json +2 -1
- package/dist/LiveNow-SLZOTZWP.js +0 -136
- package/dist/chunk-YKEQSW45.js +0 -188
package/README.md
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
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 now` | see what I'm listening to, reading and coding |
|
|
16
|
+
| `npx zion help` | list commands; `npx zion help <command>` or `npx zion <command> help` for more |
|
|
16
17
|
|
|
17
18
|
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-YKEQSW45.js";
|
|
16
2
|
import {
|
|
17
3
|
__export
|
|
18
4
|
} from "./chunk-K3NQKI34.js";
|
|
@@ -22,7 +8,53 @@ import os3 from "os";
|
|
|
22
8
|
import path12 from "path";
|
|
23
9
|
|
|
24
10
|
// package.json
|
|
25
|
-
var version = "
|
|
11
|
+
var version = "4.0.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
|
+
accent: chalk.hex(palette.accent),
|
|
41
|
+
success: chalk.hex(palette.success),
|
|
42
|
+
warning: chalk.hex(palette.warning),
|
|
43
|
+
error: chalk.hex(palette.error),
|
|
44
|
+
muted: chalk.gray,
|
|
45
|
+
dim: chalk.dim,
|
|
46
|
+
bold: chalk.bold,
|
|
47
|
+
white: chalk.white,
|
|
48
|
+
inverse: chalk.inverse,
|
|
49
|
+
hex: (color) => chalk.hex(color),
|
|
50
|
+
badge: (text) => chalk.bgHex(palette.brand).hex("#ffffff").bold(` ${text} `)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function paintFor(stream, { color, env }) {
|
|
54
|
+
const detected = stream === process.stderr ? supportsColorStderr : supportsColor;
|
|
55
|
+
const noColor = Boolean(env.NO_COLOR) && !("FORCE_COLOR" in env);
|
|
56
|
+
return createPaint(new Chalk({ level: !color || noColor || !detected ? 0 : detected.level }));
|
|
57
|
+
}
|
|
26
58
|
|
|
27
59
|
// src/prompts/format.ts
|
|
28
60
|
function toneColor(paint) {
|
|
@@ -108,6 +140,50 @@ function keyHints(paint, hints) {
|
|
|
108
140
|
return hints.map(([key, action]) => `${paint.white(key)} ${action}`).join(paint.muted(" \xB7 "));
|
|
109
141
|
}
|
|
110
142
|
|
|
143
|
+
// src/cli/errors.ts
|
|
144
|
+
var CliError = class extends Error {
|
|
145
|
+
constructor(message, hint, exitCode = 1) {
|
|
146
|
+
super(message);
|
|
147
|
+
this.hint = hint;
|
|
148
|
+
this.exitCode = exitCode;
|
|
149
|
+
this.name = "CliError";
|
|
150
|
+
}
|
|
151
|
+
hint;
|
|
152
|
+
exitCode;
|
|
153
|
+
};
|
|
154
|
+
var UsageError = class extends CliError {
|
|
155
|
+
constructor(message, hint) {
|
|
156
|
+
super(message, hint, 2);
|
|
157
|
+
this.name = "UsageError";
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
var CancelledError = class extends Error {
|
|
161
|
+
constructor() {
|
|
162
|
+
super("Cancelled");
|
|
163
|
+
this.name = "CancelledError";
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
var ReportedError = class extends Error {
|
|
167
|
+
exitCode;
|
|
168
|
+
constructor(cause) {
|
|
169
|
+
super(errorMessage(cause), { cause });
|
|
170
|
+
this.name = "ReportedError";
|
|
171
|
+
this.exitCode = exitCodeFor(cause);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
function exitCodeFor(error62) {
|
|
175
|
+
if (error62 instanceof ReportedError) return error62.exitCode;
|
|
176
|
+
if (error62 instanceof CancelledError) return 130;
|
|
177
|
+
if (error62 instanceof CliError) return error62.exitCode;
|
|
178
|
+
return 1;
|
|
179
|
+
}
|
|
180
|
+
function errorMessage(error62) {
|
|
181
|
+
return error62 instanceof Error ? error62.message : String(error62);
|
|
182
|
+
}
|
|
183
|
+
function errorCode(error62) {
|
|
184
|
+
return error62 instanceof Error && "code" in error62 && typeof error62.code === "string" ? error62.code : void 0;
|
|
185
|
+
}
|
|
186
|
+
|
|
111
187
|
// src/cli/Cli.ts
|
|
112
188
|
var HELP_FLAGS = /* @__PURE__ */ new Set(["-h", "--help"]);
|
|
113
189
|
var VERSION_FLAGS = /* @__PURE__ */ new Set(["-v", "--version"]);
|
|
@@ -115,6 +191,7 @@ var Cli = class {
|
|
|
115
191
|
constructor(options) {
|
|
116
192
|
this.options = options;
|
|
117
193
|
}
|
|
194
|
+
options;
|
|
118
195
|
async run(argv) {
|
|
119
196
|
const { args, noColor, noInput } = extractGlobalFlags(argv);
|
|
120
197
|
const ctx = this.createContext({ noColor, noInput });
|
|
@@ -139,9 +216,9 @@ var Cli = class {
|
|
|
139
216
|
return { bin, version: version3, stdin, stdout, stderr, paint, interactive: terminal && !noInput };
|
|
140
217
|
}
|
|
141
218
|
async dispatch(args, ctx) {
|
|
142
|
-
const { registry: registry3,
|
|
219
|
+
const { registry: registry3, help: help2 } = this.options;
|
|
143
220
|
const [first, ...rest] = args;
|
|
144
|
-
if (first === void 0) return
|
|
221
|
+
if (first === void 0) return this.print(ctx, help2.home(ctx));
|
|
145
222
|
if (HELP_FLAGS.has(first)) return this.print(ctx, help2.root(ctx));
|
|
146
223
|
if (VERSION_FLAGS.has(first)) return this.print(ctx, `${ctx.version}
|
|
147
224
|
`);
|
|
@@ -154,7 +231,8 @@ var Cli = class {
|
|
|
154
231
|
suggestion ? `did you mean ${ctx.bin} ${suggestion}?` : `run ${ctx.bin} --help to see all commands`
|
|
155
232
|
);
|
|
156
233
|
}
|
|
157
|
-
|
|
234
|
+
const wantsHelp = rest[0] === "help" || optionsOf(rest).some((arg) => HELP_FLAGS.has(arg));
|
|
235
|
+
if (wantsHelp) return this.print(ctx, help2.command(command, ctx));
|
|
158
236
|
return command.run(rest, ctx);
|
|
159
237
|
}
|
|
160
238
|
print(ctx, text) {
|
|
@@ -221,24 +299,32 @@ var SHARED_OPTIONS = [
|
|
|
221
299
|
["--no-input", "never prompt; fail if input is needed"]
|
|
222
300
|
];
|
|
223
301
|
var HelpPrinter = class {
|
|
224
|
-
constructor(registry3
|
|
302
|
+
constructor(registry3) {
|
|
225
303
|
this.registry = registry3;
|
|
226
|
-
|
|
304
|
+
}
|
|
305
|
+
registry;
|
|
306
|
+
/** Shown when no command is given: a short welcome rather than the full reference. */
|
|
307
|
+
home(ctx) {
|
|
308
|
+
const paint = ctx.paint.stdout;
|
|
309
|
+
return render([
|
|
310
|
+
header(paint, ctx, "my site, dotfiles, agent skills and more, in your terminal"),
|
|
311
|
+
section(paint, "Commands", table(paint, this.commandRows())),
|
|
312
|
+
[indent(`Run ${paint.accent(`${ctx.bin} help <command>`)} for details on a command.`)]
|
|
313
|
+
]);
|
|
227
314
|
}
|
|
228
315
|
root(ctx) {
|
|
229
316
|
const paint = ctx.paint.stdout;
|
|
230
|
-
const commands = this.registry.list().map((command) => [command.name, command.summary]);
|
|
231
317
|
return render([
|
|
232
318
|
header(paint, ctx),
|
|
233
319
|
section(paint, "Usage", [`${ctx.bin} ${paint.muted("[command] [options]")}`]),
|
|
234
|
-
section(paint, "Commands", table(paint,
|
|
320
|
+
section(paint, "Commands", table(paint, this.commandRows())),
|
|
235
321
|
section(paint, "Options", table(paint, [HELP_OPTION, VERSION_OPTION, ...SHARED_OPTIONS])),
|
|
236
|
-
[
|
|
237
|
-
`Run ${paint.accent(ctx.bin)} with no command to ${this.fallback.summary}.`,
|
|
238
|
-
`Run ${paint.accent(`${ctx.bin} help <command>`)} for details on a command.`
|
|
239
|
-
].map(indent)
|
|
322
|
+
[indent(`Run ${paint.accent(`${ctx.bin} help <command>`)} for details on a command.`)]
|
|
240
323
|
]);
|
|
241
324
|
}
|
|
325
|
+
commandRows() {
|
|
326
|
+
return this.registry.list().map((command) => [command.name, command.summary]);
|
|
327
|
+
}
|
|
242
328
|
command(command, ctx) {
|
|
243
329
|
const paint = ctx.paint.stdout;
|
|
244
330
|
const { help: help2 } = command;
|
|
@@ -267,6 +353,8 @@ var HelpCommand = class {
|
|
|
267
353
|
this.printer = printer;
|
|
268
354
|
this.registry = registry3;
|
|
269
355
|
}
|
|
356
|
+
printer;
|
|
357
|
+
registry;
|
|
270
358
|
name = "help";
|
|
271
359
|
summary = "show help for a command";
|
|
272
360
|
help = {
|
|
@@ -321,11 +409,37 @@ ${blocks.filter((block) => block.length > 0).map((block) => block.join("\n")).jo
|
|
|
321
409
|
`;
|
|
322
410
|
}
|
|
323
411
|
|
|
412
|
+
// src/commands/TuiCommand.tsx
|
|
413
|
+
import { parseArgs } from "util";
|
|
414
|
+
|
|
415
|
+
// src/cli/parseArgs.ts
|
|
416
|
+
function describeParseError(error62) {
|
|
417
|
+
const code = errorCode(error62);
|
|
418
|
+
const message = errorMessage(error62);
|
|
419
|
+
const option = message.match(/'(-[^']*)'/)?.[1];
|
|
420
|
+
if (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION" && option) return `unknown option "${option}"`;
|
|
421
|
+
if (code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE" && option) return `option "${option}" needs a value`;
|
|
422
|
+
const positional = message.match(/^Unexpected argument '([^']*)'/)?.[1];
|
|
423
|
+
if (code === "ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL" && positional) return `unexpected argument "${positional}"`;
|
|
424
|
+
return message;
|
|
425
|
+
}
|
|
426
|
+
|
|
324
427
|
// src/commands/TuiCommand.tsx
|
|
325
428
|
import { jsx } from "react/jsx-runtime";
|
|
326
429
|
var TuiCommand = class {
|
|
430
|
+
name = "tui";
|
|
327
431
|
summary = "browse zzzzion.com in your terminal";
|
|
328
|
-
|
|
432
|
+
help = {
|
|
433
|
+
usage: "[options]",
|
|
434
|
+
description: "Opens a full-screen version of zzzzion.com with the home page, blog and portfolio. Needs an interactive terminal.",
|
|
435
|
+
examples: ["tui"]
|
|
436
|
+
};
|
|
437
|
+
async run(args, ctx) {
|
|
438
|
+
try {
|
|
439
|
+
parseArgs({ args: [...args], strict: true, options: {} });
|
|
440
|
+
} catch (error62) {
|
|
441
|
+
throw new UsageError(describeParseError(error62), `run ${ctx.bin} tui --help for usage`);
|
|
442
|
+
}
|
|
329
443
|
if (!ctx.interactive || !ctx.stdout.isTTY) {
|
|
330
444
|
throw new UsageError(
|
|
331
445
|
"browsing zzzzion.com needs an interactive terminal",
|
|
@@ -352,6 +466,7 @@ var BasePrompter = class {
|
|
|
352
466
|
constructor(paint) {
|
|
353
467
|
this.paint = paint;
|
|
354
468
|
}
|
|
469
|
+
paint;
|
|
355
470
|
/** True once the terminal was handed to another program, so output is no longer part of the session. */
|
|
356
471
|
handedOff = false;
|
|
357
472
|
intro(title, subtitle) {
|
|
@@ -429,6 +544,17 @@ var PromptStore = class {
|
|
|
429
544
|
// src/prompts/components/ConfirmPrompt.tsx
|
|
430
545
|
import { useRef, useState } from "react";
|
|
431
546
|
import { Text, useInput } from "ink";
|
|
547
|
+
|
|
548
|
+
// src/prompts/components/PaintContext.ts
|
|
549
|
+
import { createContext, useContext } from "react";
|
|
550
|
+
var PaintContext = createContext(null);
|
|
551
|
+
function usePaint() {
|
|
552
|
+
const paint = useContext(PaintContext);
|
|
553
|
+
if (!paint) throw new Error("usePaint needs a PaintContext provider");
|
|
554
|
+
return paint;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// src/prompts/components/ConfirmPrompt.tsx
|
|
432
558
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
433
559
|
function ConfirmPrompt({ message, defaultValue, onSubmit }) {
|
|
434
560
|
const paint = usePaint();
|
|
@@ -621,9 +747,9 @@ function TextPrompt({ message, defaultValue = "", validate: validate2, onSubmit
|
|
|
621
747
|
}
|
|
622
748
|
if (key.ctrl || key.meta || key.escape || key.tab || key.upArrow || key.downArrow) return;
|
|
623
749
|
if (key.leftArrow || key.rightArrow) return;
|
|
624
|
-
const
|
|
625
|
-
if (
|
|
626
|
-
setValue((v) => v +
|
|
750
|
+
const printable2 = input2.replace(/[\r\n\t]/g, "");
|
|
751
|
+
if (printable2) {
|
|
752
|
+
setValue((v) => v + printable2);
|
|
627
753
|
setError(void 0);
|
|
628
754
|
}
|
|
629
755
|
});
|
|
@@ -657,6 +783,7 @@ var InkPrompter = class extends BasePrompter {
|
|
|
657
783
|
patchConsole: false
|
|
658
784
|
});
|
|
659
785
|
}
|
|
786
|
+
out;
|
|
660
787
|
store = new PromptStore();
|
|
661
788
|
instance;
|
|
662
789
|
emit(text) {
|
|
@@ -748,6 +875,7 @@ var PlainPrompter = class extends BasePrompter {
|
|
|
748
875
|
super(paint);
|
|
749
876
|
this.out = out;
|
|
750
877
|
}
|
|
878
|
+
out;
|
|
751
879
|
emit(text) {
|
|
752
880
|
this.out.write(`${text}
|
|
753
881
|
`);
|
|
@@ -850,6 +978,8 @@ var DotfilesRepository = class {
|
|
|
850
978
|
this.git = git2;
|
|
851
979
|
this.source = source;
|
|
852
980
|
}
|
|
981
|
+
git;
|
|
982
|
+
source;
|
|
853
983
|
/** The clone this machine was set up from, if the installer's link still points into one. */
|
|
854
984
|
async locate() {
|
|
855
985
|
let target;
|
|
@@ -996,26 +1126,12 @@ function modeFromFlags(action, flags) {
|
|
|
996
1126
|
}
|
|
997
1127
|
|
|
998
1128
|
// src/commands/dotfiles/options.ts
|
|
999
|
-
import { parseArgs } from "util";
|
|
1000
|
-
|
|
1001
|
-
// src/cli/parseArgs.ts
|
|
1002
|
-
function describeParseError(error62) {
|
|
1003
|
-
const code = errorCode(error62);
|
|
1004
|
-
const message = errorMessage(error62);
|
|
1005
|
-
const option = message.match(/'(-[^']*)'/)?.[1];
|
|
1006
|
-
if (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION" && option) return `unknown option "${option}"`;
|
|
1007
|
-
if (code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE" && option) return `option "${option}" needs a value`;
|
|
1008
|
-
const positional = message.match(/^Unexpected argument '([^']*)'/)?.[1];
|
|
1009
|
-
if (code === "ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL" && positional) return `unexpected argument "${positional}"`;
|
|
1010
|
-
return message;
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
// src/commands/dotfiles/options.ts
|
|
1129
|
+
import { parseArgs as parseArgs2 } from "util";
|
|
1014
1130
|
function parseDotfilesOptions(args, bin) {
|
|
1015
1131
|
const usageHint = `run ${bin} dotfiles --help for usage`;
|
|
1016
1132
|
let parsed;
|
|
1017
1133
|
try {
|
|
1018
|
-
parsed =
|
|
1134
|
+
parsed = parseArgs2({
|
|
1019
1135
|
args: [...args],
|
|
1020
1136
|
allowPositionals: true,
|
|
1021
1137
|
strict: true,
|
|
@@ -1078,8 +1194,9 @@ var DotfilesCommand = class {
|
|
|
1078
1194
|
]
|
|
1079
1195
|
};
|
|
1080
1196
|
}
|
|
1197
|
+
deps;
|
|
1081
1198
|
name = "dotfiles";
|
|
1082
|
-
summary = "set up
|
|
1199
|
+
summary = "set up my dotfiles on this machine";
|
|
1083
1200
|
help;
|
|
1084
1201
|
async run(args, ctx) {
|
|
1085
1202
|
const options = parseDotfilesOptions(args, ctx.bin);
|
|
@@ -2002,7 +2119,7 @@ function putProp(target, key, value) {
|
|
|
2002
2119
|
else
|
|
2003
2120
|
target[key] = value;
|
|
2004
2121
|
}
|
|
2005
|
-
function mirrorShape(target, source, keys,
|
|
2122
|
+
function mirrorShape(target, source, keys, wrap3) {
|
|
2006
2123
|
const raw = sourceShape(source);
|
|
2007
2124
|
for (const key of keys) {
|
|
2008
2125
|
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
@@ -2011,10 +2128,10 @@ function mirrorShape(target, source, keys, wrap2) {
|
|
|
2011
2128
|
if (desc.get) {
|
|
2012
2129
|
deferProp(target, key, () => {
|
|
2013
2130
|
const value = source._zod.def.shape[key];
|
|
2014
|
-
return
|
|
2131
|
+
return wrap3 ? wrap3(value, key) : value;
|
|
2015
2132
|
});
|
|
2016
2133
|
} else
|
|
2017
|
-
putProp(target, key,
|
|
2134
|
+
putProp(target, key, wrap3 ? wrap3(desc.value, key) : desc.value);
|
|
2018
2135
|
}
|
|
2019
2136
|
}
|
|
2020
2137
|
function mirrorProps(target, source) {
|
|
@@ -20960,6 +21077,7 @@ var HttpStatusError = class extends CliError {
|
|
|
20960
21077
|
this.status = status;
|
|
20961
21078
|
this.name = "HttpStatusError";
|
|
20962
21079
|
}
|
|
21080
|
+
status;
|
|
20963
21081
|
};
|
|
20964
21082
|
async function getJson(fetchImpl, request) {
|
|
20965
21083
|
const { url: url2, schema, failure: failure2, signal } = request;
|
|
@@ -21030,35 +21148,135 @@ var HttpNowApi = class {
|
|
|
21030
21148
|
this.fetchImpl = fetchImpl;
|
|
21031
21149
|
this.url = new URL(url2);
|
|
21032
21150
|
}
|
|
21151
|
+
fetchImpl;
|
|
21033
21152
|
url;
|
|
21034
21153
|
get host() {
|
|
21035
21154
|
return this.url.host;
|
|
21036
21155
|
}
|
|
21037
21156
|
get(signal) {
|
|
21038
|
-
return getJson(this.fetchImpl, { url: this.url, schema: Now, failure: "say what
|
|
21157
|
+
return getJson(this.fetchImpl, { url: this.url, schema: Now, failure: "say what I'm up to", signal });
|
|
21039
21158
|
}
|
|
21040
21159
|
};
|
|
21041
21160
|
|
|
21042
21161
|
// src/commands/now/NowCommand.ts
|
|
21043
|
-
import { parseArgs as
|
|
21162
|
+
import { parseArgs as parseArgs3 } from "util";
|
|
21044
21163
|
|
|
21045
21164
|
// src/lib/spinner.ts
|
|
21046
|
-
|
|
21165
|
+
var FRAME_MS = 80;
|
|
21166
|
+
var DELAY_MS = 200;
|
|
21167
|
+
async function whileSpinning(ctx, work) {
|
|
21047
21168
|
if (!ctx.interactive) return work;
|
|
21048
21169
|
const { stderr } = ctx;
|
|
21049
|
-
const paint = ctx.paint.stderr;
|
|
21050
21170
|
let frame = 0;
|
|
21171
|
+
let drawn = false;
|
|
21172
|
+
let timer;
|
|
21051
21173
|
const draw = () => {
|
|
21052
|
-
stderr.write(`\r${
|
|
21174
|
+
stderr.write(`\r${symbols.spinner[frame++ % symbols.spinner.length]}`);
|
|
21175
|
+
drawn = true;
|
|
21053
21176
|
};
|
|
21054
|
-
|
|
21055
|
-
|
|
21177
|
+
const delay = setTimeout(() => {
|
|
21178
|
+
draw();
|
|
21179
|
+
timer = setInterval(draw, FRAME_MS);
|
|
21180
|
+
}, DELAY_MS);
|
|
21056
21181
|
try {
|
|
21057
21182
|
return await work;
|
|
21058
21183
|
} finally {
|
|
21184
|
+
clearTimeout(delay);
|
|
21059
21185
|
clearInterval(timer);
|
|
21060
|
-
stderr.write("\r\x1B[K");
|
|
21186
|
+
if (drawn) stderr.write("\r\x1B[K");
|
|
21187
|
+
}
|
|
21188
|
+
}
|
|
21189
|
+
|
|
21190
|
+
// src/commands/now/format.ts
|
|
21191
|
+
import terminalLink from "terminal-link";
|
|
21192
|
+
var LABEL_WIDTH = 14;
|
|
21193
|
+
var PAD_X = 2;
|
|
21194
|
+
function formatNow(paint, now, at, columns) {
|
|
21195
|
+
const sections = sectionsOf(now, at);
|
|
21196
|
+
const margin = " ".repeat(PAD_X);
|
|
21197
|
+
if (sections.length === 0) return `
|
|
21198
|
+
${margin}${paint.muted(NOTHING)}
|
|
21199
|
+
|
|
21200
|
+
`;
|
|
21201
|
+
const width = columns ? Math.max(20, columns - PAD_X * 2 - LABEL_WIDTH) : Infinity;
|
|
21202
|
+
const body = sections.map(
|
|
21203
|
+
(entries) => entries.flatMap((entry) => entryRows(paint, entry, width)).map((row) => `${margin}${paint.muted(row.label.padEnd(LABEL_WIDTH))}${row.text}`).join("\n")
|
|
21204
|
+
).join("\n\n");
|
|
21205
|
+
return `
|
|
21206
|
+
${body}
|
|
21207
|
+
|
|
21208
|
+
`;
|
|
21209
|
+
}
|
|
21210
|
+
var NOTHING = "Nothing to show right now.";
|
|
21211
|
+
function sectionsOf(now, at) {
|
|
21212
|
+
const sections = [];
|
|
21213
|
+
if (now.listening) sections.push([listening(now.listening, at)]);
|
|
21214
|
+
if (now.reading?.length) sections.push(now.reading.map(reading));
|
|
21215
|
+
if (now.coding) sections.push([coding(now.coding, at)]);
|
|
21216
|
+
return sections;
|
|
21217
|
+
}
|
|
21218
|
+
function entryRows(paint, entry, width) {
|
|
21219
|
+
const bold = paint.bold(printable(entry.title));
|
|
21220
|
+
const linked = /^https:\/\//.test(entry.url) ? terminalLink(bold, printable(entry.url), { fallback: () => bold }) : bold;
|
|
21221
|
+
const rows = [{ label: entry.label, text: linked }];
|
|
21222
|
+
if (entry.detail) {
|
|
21223
|
+
for (const line of wrap2(printable(entry.detail), width)) rows.push({ label: "", text: paint.muted(line) });
|
|
21061
21224
|
}
|
|
21225
|
+
return rows;
|
|
21226
|
+
}
|
|
21227
|
+
function wrap2(text, width) {
|
|
21228
|
+
const lines = [];
|
|
21229
|
+
let line = "";
|
|
21230
|
+
for (const word of text.split(/\s+/)) {
|
|
21231
|
+
if (line && line.length + word.length + 1 > width) {
|
|
21232
|
+
lines.push(line);
|
|
21233
|
+
line = word;
|
|
21234
|
+
} else {
|
|
21235
|
+
line = line ? `${line} ${word}` : word;
|
|
21236
|
+
}
|
|
21237
|
+
}
|
|
21238
|
+
if (line) lines.push(line);
|
|
21239
|
+
return lines;
|
|
21240
|
+
}
|
|
21241
|
+
function listening(track, at) {
|
|
21242
|
+
const played = track.playedAt === null ? null : ago(new Date(track.playedAt), at);
|
|
21243
|
+
return {
|
|
21244
|
+
label: played === null ? "listening to" : "listened to",
|
|
21245
|
+
title: track.title,
|
|
21246
|
+
url: track.url,
|
|
21247
|
+
detail: played === null ? track.artist : [track.artist, played].join(" \xB7 ")
|
|
21248
|
+
};
|
|
21249
|
+
}
|
|
21250
|
+
function reading(book, i) {
|
|
21251
|
+
return { label: i === 0 ? "reading" : "", title: book.title, url: book.url, detail: book.author };
|
|
21252
|
+
}
|
|
21253
|
+
function coding(push, at) {
|
|
21254
|
+
return {
|
|
21255
|
+
label: "pushed to",
|
|
21256
|
+
title: push.repo,
|
|
21257
|
+
url: push.url,
|
|
21258
|
+
detail: [push.message, ago(new Date(push.pushedAt), at)].join(" \xB7 ")
|
|
21259
|
+
};
|
|
21260
|
+
}
|
|
21261
|
+
var UNITS = [
|
|
21262
|
+
["year", 365 * 24 * 3600],
|
|
21263
|
+
["month", 30 * 24 * 3600],
|
|
21264
|
+
["week", 7 * 24 * 3600],
|
|
21265
|
+
["day", 24 * 3600],
|
|
21266
|
+
["hour", 3600],
|
|
21267
|
+
["minute", 60]
|
|
21268
|
+
];
|
|
21269
|
+
function ago(then, at) {
|
|
21270
|
+
const seconds = (at.getTime() - then.getTime()) / 1e3;
|
|
21271
|
+
if (Number.isNaN(seconds)) return "";
|
|
21272
|
+
const format = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
|
|
21273
|
+
for (const [unit, size] of UNITS) {
|
|
21274
|
+
if (seconds >= size) return format.format(-Math.floor(seconds / size), unit);
|
|
21275
|
+
}
|
|
21276
|
+
return "just now";
|
|
21277
|
+
}
|
|
21278
|
+
function printable(text) {
|
|
21279
|
+
return text.replace(new RegExp("\\p{Cc}", "gu"), "");
|
|
21062
21280
|
}
|
|
21063
21281
|
|
|
21064
21282
|
// src/commands/now/NowCommand.ts
|
|
@@ -21067,33 +21285,32 @@ var NowCommand = class {
|
|
|
21067
21285
|
this.deps = deps;
|
|
21068
21286
|
this.help = {
|
|
21069
21287
|
usage: "[options]",
|
|
21070
|
-
description: `Asks ${deps.api.host} what
|
|
21288
|
+
description: `Asks ${deps.api.host} what I last played on Last.fm, am reading on Goodreads and last pushed to GitHub.`,
|
|
21071
21289
|
options: [["--json", "print it as JSON"]],
|
|
21072
21290
|
examples: ["now", "now --json"]
|
|
21073
21291
|
};
|
|
21074
21292
|
}
|
|
21293
|
+
deps;
|
|
21075
21294
|
name = "now";
|
|
21076
|
-
summary = "see what
|
|
21295
|
+
summary = "see what I'm listening to, reading and coding";
|
|
21077
21296
|
help;
|
|
21078
21297
|
async run(args, ctx) {
|
|
21079
21298
|
const { json: json2 } = parseNowOptions(args, ctx.bin);
|
|
21080
|
-
|
|
21081
|
-
const { runLive } = await import("./LiveNow-SLZOTZWP.js");
|
|
21082
|
-
return runLive(ctx, this.deps);
|
|
21083
|
-
}
|
|
21084
|
-
const status = await whileSpinning(ctx, `asking ${this.deps.api.host}`, this.deps.api.get());
|
|
21299
|
+
const status = await whileSpinning(ctx, this.deps.api.get());
|
|
21085
21300
|
if (json2) {
|
|
21086
21301
|
ctx.stdout.write(`${JSON.stringify(status, null, 2)}
|
|
21087
21302
|
`);
|
|
21088
21303
|
return 0;
|
|
21089
21304
|
}
|
|
21090
|
-
ctx.stdout.write(
|
|
21305
|
+
ctx.stdout.write(
|
|
21306
|
+
formatNow(ctx.paint.stdout, status, this.deps.clock(), ctx.stdout.isTTY ? ctx.stdout.columns : void 0)
|
|
21307
|
+
);
|
|
21091
21308
|
return 0;
|
|
21092
21309
|
}
|
|
21093
21310
|
};
|
|
21094
21311
|
function parseNowOptions(args, bin) {
|
|
21095
21312
|
try {
|
|
21096
|
-
const { values } =
|
|
21313
|
+
const { values } = parseArgs3({
|
|
21097
21314
|
args: [...args],
|
|
21098
21315
|
strict: true,
|
|
21099
21316
|
options: { json: { type: "boolean", default: false } }
|
|
@@ -21199,12 +21416,14 @@ var SkillNotFoundError = class extends CliError {
|
|
|
21199
21416
|
this.skill = skill;
|
|
21200
21417
|
this.name = "SkillNotFoundError";
|
|
21201
21418
|
}
|
|
21419
|
+
skill;
|
|
21202
21420
|
};
|
|
21203
21421
|
var HttpSkillsApi = class {
|
|
21204
21422
|
constructor(baseUrl, fetchImpl = fetch) {
|
|
21205
21423
|
this.fetchImpl = fetchImpl;
|
|
21206
21424
|
this.base = new URL(baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`);
|
|
21207
21425
|
}
|
|
21426
|
+
fetchImpl;
|
|
21208
21427
|
base;
|
|
21209
21428
|
get host() {
|
|
21210
21429
|
return this.base.host;
|
|
@@ -21359,6 +21578,7 @@ var InstallFlow = class {
|
|
|
21359
21578
|
constructor(deps) {
|
|
21360
21579
|
this.deps = deps;
|
|
21361
21580
|
}
|
|
21581
|
+
deps;
|
|
21362
21582
|
async run(ui, options, ctx) {
|
|
21363
21583
|
const { api, lockfile } = this.deps;
|
|
21364
21584
|
const lock = await lockfile.read();
|
|
@@ -21480,6 +21700,7 @@ var ManageFlow = class {
|
|
|
21480
21700
|
constructor(deps) {
|
|
21481
21701
|
this.deps = deps;
|
|
21482
21702
|
}
|
|
21703
|
+
deps;
|
|
21483
21704
|
async run(ui, ctx) {
|
|
21484
21705
|
const { api, lockfile } = this.deps;
|
|
21485
21706
|
const lock = await lockfile.read();
|
|
@@ -21621,6 +21842,7 @@ var RemoveFlow = class {
|
|
|
21621
21842
|
constructor(deps) {
|
|
21622
21843
|
this.deps = deps;
|
|
21623
21844
|
}
|
|
21845
|
+
deps;
|
|
21624
21846
|
async run(ui, options, ctx) {
|
|
21625
21847
|
const { lockfile, targets } = this.deps;
|
|
21626
21848
|
const lock = await lockfile.read();
|
|
@@ -21686,6 +21908,7 @@ var UpdateFlow = class {
|
|
|
21686
21908
|
constructor(deps) {
|
|
21687
21909
|
this.deps = deps;
|
|
21688
21910
|
}
|
|
21911
|
+
deps;
|
|
21689
21912
|
async run(ui, options, ctx) {
|
|
21690
21913
|
const { api, lockfile } = this.deps;
|
|
21691
21914
|
const lock = await lockfile.read();
|
|
@@ -21781,12 +22004,12 @@ function findSkillsAction(name) {
|
|
|
21781
22004
|
}
|
|
21782
22005
|
|
|
21783
22006
|
// src/commands/skills/options.ts
|
|
21784
|
-
import { parseArgs as
|
|
22007
|
+
import { parseArgs as parseArgs4 } from "util";
|
|
21785
22008
|
function parseSkillsOptions(args, bin, targetIds) {
|
|
21786
22009
|
const usageHint = `run ${bin} skills --help for usage`;
|
|
21787
22010
|
let parsed;
|
|
21788
22011
|
try {
|
|
21789
|
-
parsed =
|
|
22012
|
+
parsed = parseArgs4({
|
|
21790
22013
|
args: [...args],
|
|
21791
22014
|
allowPositionals: true,
|
|
21792
22015
|
strict: true,
|
|
@@ -21909,8 +22132,9 @@ var SkillsCommand = class {
|
|
|
21909
22132
|
]
|
|
21910
22133
|
};
|
|
21911
22134
|
}
|
|
22135
|
+
deps;
|
|
21912
22136
|
name = "skills";
|
|
21913
|
-
summary = "install
|
|
22137
|
+
summary = "install my agent skills";
|
|
21914
22138
|
help;
|
|
21915
22139
|
async run(args, ctx) {
|
|
21916
22140
|
const options = parseSkillsOptions(
|
|
@@ -21958,12 +22182,15 @@ var GitError = class extends Error {
|
|
|
21958
22182
|
this.stderr = stderr;
|
|
21959
22183
|
this.name = "GitError";
|
|
21960
22184
|
}
|
|
22185
|
+
args;
|
|
22186
|
+
stderr;
|
|
21961
22187
|
};
|
|
21962
22188
|
var CliGit = class {
|
|
21963
22189
|
constructor(runner2, env) {
|
|
21964
22190
|
this.runner = runner2;
|
|
21965
22191
|
this.env = { ...env, GIT_TERMINAL_PROMPT: "0" };
|
|
21966
22192
|
}
|
|
22193
|
+
runner;
|
|
21967
22194
|
env;
|
|
21968
22195
|
async version(signal) {
|
|
21969
22196
|
const { code, stdout } = await this.runner.capture("git", ["--version"], { env: this.env, signal });
|
|
@@ -22032,6 +22259,7 @@ var JsonLockfile = class {
|
|
|
22032
22259
|
constructor(path13) {
|
|
22033
22260
|
this.path = path13;
|
|
22034
22261
|
}
|
|
22262
|
+
path;
|
|
22035
22263
|
async read() {
|
|
22036
22264
|
let text;
|
|
22037
22265
|
try {
|
|
@@ -22171,18 +22399,16 @@ var registry2 = new CommandRegistry().register(
|
|
|
22171
22399
|
createPrompter,
|
|
22172
22400
|
now: () => /* @__PURE__ */ new Date()
|
|
22173
22401
|
})
|
|
22174
|
-
).register(
|
|
22402
|
+
).register(new TuiCommand()).register(
|
|
22175
22403
|
new NowCommand({
|
|
22176
22404
|
api: new HttpNowApi(process.env.ZION_NOW_URL || "https://zzzzion.com/api/now"),
|
|
22177
22405
|
clock: () => /* @__PURE__ */ new Date()
|
|
22178
22406
|
})
|
|
22179
22407
|
);
|
|
22180
|
-
var
|
|
22181
|
-
var help = new HelpPrinter(registry2, fallback);
|
|
22408
|
+
var help = new HelpPrinter(registry2);
|
|
22182
22409
|
registry2.register(new HelpCommand(help, registry2));
|
|
22183
22410
|
var cli = new Cli({
|
|
22184
22411
|
registry: registry2,
|
|
22185
|
-
fallback,
|
|
22186
22412
|
help,
|
|
22187
22413
|
environment: {
|
|
22188
22414
|
bin: "npx zion",
|
package/package.json
CHANGED
package/dist/LiveNow-SLZOTZWP.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-YKEQSW45.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 `${" ".repeat(LABEL_WIDTH)}${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-YKEQSW45.js
DELETED
|
@@ -1,188 +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
|
-
};
|
|
12
|
-
var UsageError = class extends CliError {
|
|
13
|
-
constructor(message, hint) {
|
|
14
|
-
super(message, hint, 2);
|
|
15
|
-
this.name = "UsageError";
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
var CancelledError = class extends Error {
|
|
19
|
-
constructor() {
|
|
20
|
-
super("Cancelled");
|
|
21
|
-
this.name = "CancelledError";
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
var ReportedError = class extends Error {
|
|
25
|
-
exitCode;
|
|
26
|
-
constructor(cause) {
|
|
27
|
-
super(errorMessage(cause), { cause });
|
|
28
|
-
this.name = "ReportedError";
|
|
29
|
-
this.exitCode = exitCodeFor(cause);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
function exitCodeFor(error) {
|
|
33
|
-
if (error instanceof ReportedError) return error.exitCode;
|
|
34
|
-
if (error instanceof CancelledError) return 130;
|
|
35
|
-
if (error instanceof CliError) return error.exitCode;
|
|
36
|
-
return 1;
|
|
37
|
-
}
|
|
38
|
-
function errorMessage(error) {
|
|
39
|
-
return error instanceof Error ? error.message : String(error);
|
|
40
|
-
}
|
|
41
|
-
function errorCode(error) {
|
|
42
|
-
return error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// src/prompts/components/PaintContext.ts
|
|
46
|
-
import { createContext, useContext } from "react";
|
|
47
|
-
var PaintContext = createContext(null);
|
|
48
|
-
function usePaint() {
|
|
49
|
-
const paint = useContext(PaintContext);
|
|
50
|
-
if (!paint) throw new Error("usePaint needs a PaintContext provider");
|
|
51
|
-
return paint;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// src/commands/now/format.ts
|
|
55
|
-
import terminalLink from "terminal-link";
|
|
56
|
-
var LABEL_WIDTH = 14;
|
|
57
|
-
function formatNow(paint, now, at) {
|
|
58
|
-
const sections = sectionsOf(now, at);
|
|
59
|
-
if (sections.length === 0) return `${paint.muted(NOTHING)}
|
|
60
|
-
`;
|
|
61
|
-
return `${sections.map(
|
|
62
|
-
(entries) => entries.flatMap((entry) => entryRows(paint, entry)).map((row) => `${paint.muted(row.label.padEnd(LABEL_WIDTH))}${row.text}`).join("\n")
|
|
63
|
-
).join("\n\n")}
|
|
64
|
-
`;
|
|
65
|
-
}
|
|
66
|
-
var NOTHING = "Nothing to show right now.";
|
|
67
|
-
function sectionsOf(now, at) {
|
|
68
|
-
const sections = [];
|
|
69
|
-
if (now.listening) sections.push([listening(now.listening, at)]);
|
|
70
|
-
if (now.reading?.length) sections.push(now.reading.map(reading));
|
|
71
|
-
if (now.coding) sections.push([coding(now.coding, at)]);
|
|
72
|
-
return sections;
|
|
73
|
-
}
|
|
74
|
-
function entryRows(paint, entry, after = "") {
|
|
75
|
-
const bold = paint.bold(printable(entry.title));
|
|
76
|
-
const linked = /^https:\/\//.test(entry.url) ? terminalLink(bold, printable(entry.url), { fallback: () => bold }) : bold;
|
|
77
|
-
const rows = [{ label: entry.label, text: `${linked}${after}` }];
|
|
78
|
-
if (entry.detail) rows.push({ label: "", text: paint.muted(printable(entry.detail)) });
|
|
79
|
-
return rows;
|
|
80
|
-
}
|
|
81
|
-
function listening(track, at) {
|
|
82
|
-
const played = track.playedAt === null ? null : ago(new Date(track.playedAt), at);
|
|
83
|
-
return {
|
|
84
|
-
label: played === null ? "listening to" : "listened to",
|
|
85
|
-
title: track.title,
|
|
86
|
-
url: track.url,
|
|
87
|
-
detail: played === null ? track.artist : [track.artist, played].join(" \xB7 "),
|
|
88
|
-
playing: played === null
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
function reading(book, i) {
|
|
92
|
-
return { label: i === 0 ? "reading" : "", title: book.title, url: book.url, detail: book.author, playing: false };
|
|
93
|
-
}
|
|
94
|
-
function coding(push, at) {
|
|
95
|
-
return {
|
|
96
|
-
label: "pushed to",
|
|
97
|
-
title: push.repo,
|
|
98
|
-
url: push.url,
|
|
99
|
-
detail: [push.message, ago(new Date(push.pushedAt), at)].join(" \xB7 "),
|
|
100
|
-
playing: false
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
var UNITS = [
|
|
104
|
-
["year", 365 * 24 * 3600],
|
|
105
|
-
["month", 30 * 24 * 3600],
|
|
106
|
-
["week", 7 * 24 * 3600],
|
|
107
|
-
["day", 24 * 3600],
|
|
108
|
-
["hour", 3600],
|
|
109
|
-
["minute", 60]
|
|
110
|
-
];
|
|
111
|
-
function ago(then, at) {
|
|
112
|
-
const seconds = (at.getTime() - then.getTime()) / 1e3;
|
|
113
|
-
if (Number.isNaN(seconds)) return "";
|
|
114
|
-
const format = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
|
|
115
|
-
for (const [unit, size] of UNITS) {
|
|
116
|
-
if (seconds >= size) return format.format(-Math.floor(seconds / size), unit);
|
|
117
|
-
}
|
|
118
|
-
return "just now";
|
|
119
|
-
}
|
|
120
|
-
function printable(text) {
|
|
121
|
-
return text.replace(new RegExp("\\p{Cc}", "gu"), "");
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// src/lib/theme.ts
|
|
125
|
-
import { Chalk, supportsColor, supportsColorStderr } from "chalk";
|
|
126
|
-
var palette = {
|
|
127
|
-
brand: "#264b96",
|
|
128
|
-
accent: "#5c9fd4",
|
|
129
|
-
success: "#3fb950",
|
|
130
|
-
warning: "#f9a73e",
|
|
131
|
-
error: "#e5534b"
|
|
132
|
-
};
|
|
133
|
-
var symbols = {
|
|
134
|
-
start: "\u250C",
|
|
135
|
-
bar: "\u2502",
|
|
136
|
-
end: "\u2514",
|
|
137
|
-
active: "\u25C6",
|
|
138
|
-
done: "\u25C7",
|
|
139
|
-
warning: "\u25B2",
|
|
140
|
-
error: "\u25A0",
|
|
141
|
-
radioOn: "\u25CF",
|
|
142
|
-
radioOff: "\u25CB",
|
|
143
|
-
checkOn: "\u25FC",
|
|
144
|
-
checkOff: "\u25FB",
|
|
145
|
-
tick: "\u2714",
|
|
146
|
-
cross: "\u2716",
|
|
147
|
-
spinner: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"]
|
|
148
|
-
};
|
|
149
|
-
function createPaint(chalk) {
|
|
150
|
-
return {
|
|
151
|
-
accent: chalk.hex(palette.accent),
|
|
152
|
-
success: chalk.hex(palette.success),
|
|
153
|
-
warning: chalk.hex(palette.warning),
|
|
154
|
-
error: chalk.hex(palette.error),
|
|
155
|
-
muted: chalk.gray,
|
|
156
|
-
dim: chalk.dim,
|
|
157
|
-
bold: chalk.bold,
|
|
158
|
-
white: chalk.white,
|
|
159
|
-
inverse: chalk.inverse,
|
|
160
|
-
hex: (color) => chalk.hex(color),
|
|
161
|
-
badge: (text) => chalk.bgHex(palette.brand).hex("#ffffff").bold(` ${text} `)
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
function paintFor(stream, { color, env }) {
|
|
165
|
-
const detected = stream === process.stderr ? supportsColorStderr : supportsColor;
|
|
166
|
-
const noColor = Boolean(env.NO_COLOR) && !("FORCE_COLOR" in env);
|
|
167
|
-
return createPaint(new Chalk({ level: !color || noColor || !detected ? 0 : detected.level }));
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export {
|
|
171
|
-
palette,
|
|
172
|
-
symbols,
|
|
173
|
-
paintFor,
|
|
174
|
-
CliError,
|
|
175
|
-
UsageError,
|
|
176
|
-
CancelledError,
|
|
177
|
-
ReportedError,
|
|
178
|
-
exitCodeFor,
|
|
179
|
-
errorMessage,
|
|
180
|
-
errorCode,
|
|
181
|
-
PaintContext,
|
|
182
|
-
usePaint,
|
|
183
|
-
LABEL_WIDTH,
|
|
184
|
-
formatNow,
|
|
185
|
-
NOTHING,
|
|
186
|
-
sectionsOf,
|
|
187
|
-
entryRows
|
|
188
|
-
};
|