zion 2.6.0 → 3.0.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.
package/README.md CHANGED
@@ -11,7 +11,7 @@ run `npx zion`
11
11
  | `npx zion` | open the terminal version of zzzzion.com |
12
12
  | `npx zion dotfiles` | set up [zion's dotfiles](https://github.com/zion-off/dotfiles) |
13
13
  | `npx zion skills` | install zion's agent skills |
14
- | `npx zion now` | see what zion is reading and coding |
14
+ | `npx zion now` | see what zion is listening to, reading and coding |
15
15
  | `npx zion help` | list commands; `npx zion help <command>` for more |
16
16
 
17
17
  Global flags: `--no-color` (or `NO_COLOR`), `--no-input` (never prompt), `-h/--help`, `-v/--version`.
@@ -0,0 +1,136 @@
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
+ };
@@ -0,0 +1,190 @@
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
+ };
package/dist/cli.js CHANGED
@@ -1,4 +1,18 @@
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";
2
16
  import {
3
17
  __export
4
18
  } from "./chunk-K3NQKI34.js";
@@ -8,52 +22,7 @@ import os3 from "os";
8
22
  import path12 from "path";
9
23
 
10
24
  // package.json
11
- var version = "2.6.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
- badge: (text) => chalk.bgHex(palette.brand).hex("#ffffff").bold(` ${text} `)
50
- };
51
- }
52
- function paintFor(stream, { color, env }) {
53
- const detected = stream === process.stderr ? supportsColorStderr : supportsColor;
54
- const noColor = Boolean(env.NO_COLOR) && !("FORCE_COLOR" in env);
55
- return createPaint(new Chalk({ level: !color || noColor || !detected ? 0 : detected.level }));
56
- }
25
+ var version = "3.0.1";
57
26
 
58
27
  // src/prompts/format.ts
59
28
  function toneColor(paint) {
@@ -82,24 +51,24 @@ function join(lines) {
82
51
  function detail(paint, line, tone) {
83
52
  return tone === "warning" || tone === "error" ? toneColor(paint)[tone](line) : paint.dim(line);
84
53
  }
85
- function formatIntro(paint, title2, subtitle) {
54
+ function formatIntro(paint, title, subtitle) {
86
55
  return join([
87
56
  "",
88
- `${paint.muted(symbols.start)} ${paint.badge("zion")} ${paint.bold(title2)}`,
57
+ `${paint.muted(symbols.start)} ${paint.badge("zion")} ${paint.bold(title)}`,
89
58
  subtitle && `${bar(paint)} ${paint.muted(subtitle)}`
90
59
  ]);
91
60
  }
92
- function formatStep(paint, { title: title2, lines = [], tone = "success" }) {
61
+ function formatStep(paint, { title, lines = [], tone = "success" }) {
93
62
  return join([
94
63
  bar(paint),
95
- `${toneColor(paint)[tone](stepSymbol[tone])} ${title2}`,
64
+ `${toneColor(paint)[tone](stepSymbol[tone])} ${title}`,
96
65
  ...lines.map((line) => `${bar(paint)} ${detail(paint, line, tone)}`)
97
66
  ]);
98
67
  }
99
- function formatHandoff(paint, title2, lines = []) {
68
+ function formatHandoff(paint, title, lines = []) {
100
69
  return join([
101
70
  bar(paint),
102
- `${paint.muted(symbols.end)} ${title2}`,
71
+ `${paint.muted(symbols.end)} ${title}`,
103
72
  ...lines.map((line) => ` ${paint.dim(line)}`),
104
73
  ""
105
74
  ]);
@@ -127,10 +96,10 @@ function formatOptions(paint, options, focusedIndex, style) {
127
96
  });
128
97
  }
129
98
  var SPINNER_INTERVAL_MS = 80;
130
- function formatSpinner(paint, frame, title2, elapsedSeconds) {
99
+ function formatSpinner(paint, frame, title, elapsedSeconds) {
131
100
  const spinner = paint.accent(symbols.spinner[frame % symbols.spinner.length]);
132
101
  const elapsed = elapsedSeconds >= 2 ? paint.muted(` ${elapsedSeconds}s`) : "";
133
- return join([bar(paint), `${spinner} ${title2}${paint.muted("\u2026")}${elapsed}`]);
102
+ return join([bar(paint), `${spinner} ${title}${paint.muted("\u2026")}${elapsed}`]);
134
103
  }
135
104
  function formatError(paint, message, hint) {
136
105
  return join([`${paint.error(symbols.cross)} ${paint.bold(message)}`, hint && ` ${paint.muted(hint)}`]);
@@ -139,48 +108,6 @@ function keyHints(paint, hints) {
139
108
  return hints.map(([key, action]) => `${paint.white(key)} ${action}`).join(paint.muted(" \xB7 "));
140
109
  }
141
110
 
142
- // src/cli/errors.ts
143
- var CliError = class extends Error {
144
- constructor(message, hint, exitCode = 1) {
145
- super(message);
146
- this.hint = hint;
147
- this.exitCode = exitCode;
148
- this.name = "CliError";
149
- }
150
- };
151
- var UsageError = class extends CliError {
152
- constructor(message, hint) {
153
- super(message, hint, 2);
154
- this.name = "UsageError";
155
- }
156
- };
157
- var CancelledError = class extends Error {
158
- constructor() {
159
- super("Cancelled");
160
- this.name = "CancelledError";
161
- }
162
- };
163
- var ReportedError = class extends Error {
164
- exitCode;
165
- constructor(cause) {
166
- super(errorMessage(cause), { cause });
167
- this.name = "ReportedError";
168
- this.exitCode = exitCodeFor(cause);
169
- }
170
- };
171
- function exitCodeFor(error62) {
172
- if (error62 instanceof ReportedError) return error62.exitCode;
173
- if (error62 instanceof CancelledError) return 130;
174
- if (error62 instanceof CliError) return error62.exitCode;
175
- return 1;
176
- }
177
- function errorMessage(error62) {
178
- return error62 instanceof Error ? error62.message : String(error62);
179
- }
180
- function errorCode(error62) {
181
- return error62 instanceof Error && "code" in error62 && typeof error62.code === "string" ? error62.code : void 0;
182
- }
183
-
184
111
  // src/cli/Cli.ts
185
112
  var HELP_FLAGS = /* @__PURE__ */ new Set(["-h", "--help"]);
186
113
  var VERSION_FLAGS = /* @__PURE__ */ new Set(["-v", "--version"]);
@@ -188,6 +115,7 @@ var Cli = class {
188
115
  constructor(options) {
189
116
  this.options = options;
190
117
  }
118
+ options;
191
119
  async run(argv) {
192
120
  const { args, noColor, noInput } = extractGlobalFlags(argv);
193
121
  const ctx = this.createContext({ noColor, noInput });
@@ -298,6 +226,8 @@ var HelpPrinter = class {
298
226
  this.registry = registry3;
299
227
  this.fallback = fallback2;
300
228
  }
229
+ registry;
230
+ fallback;
301
231
  root(ctx) {
302
232
  const paint = ctx.paint.stdout;
303
233
  const commands = this.registry.list().map((command) => [command.name, command.summary]);
@@ -340,6 +270,8 @@ var HelpCommand = class {
340
270
  this.printer = printer;
341
271
  this.registry = registry3;
342
272
  }
273
+ printer;
274
+ registry;
343
275
  name = "help";
344
276
  summary = "show help for a command";
345
277
  help = {
@@ -359,12 +291,12 @@ var HelpCommand = class {
359
291
  }
360
292
  };
361
293
  function header(paint, ctx, summary, name) {
362
- const title2 = name ? `${paint.badge("zion")} ${paint.bold(name)}` : paint.badge("zion");
363
- const lines = [indent(`${title2} ${paint.muted(`v${ctx.version}`)}`)];
294
+ const title = name ? `${paint.badge("zion")} ${paint.bold(name)}` : paint.badge("zion");
295
+ const lines = [indent(`${title} ${paint.muted(`v${ctx.version}`)}`)];
364
296
  return summary ? [...lines, indent(paint.muted(summary))] : lines;
365
297
  }
366
- function section(paint, title2, lines) {
367
- return [indent(paint.bold(title2.toUpperCase())), ...lines.map((line) => indent(indent(line)))];
298
+ function section(paint, title, lines) {
299
+ return [indent(paint.bold(title.toUpperCase())), ...lines.map((line) => indent(indent(line)))];
368
300
  }
369
301
  function table(paint, rows) {
370
302
  const width = Math.max(...rows.map(([term]) => term.length));
@@ -425,10 +357,11 @@ var BasePrompter = class {
425
357
  constructor(paint) {
426
358
  this.paint = paint;
427
359
  }
360
+ paint;
428
361
  /** True once the terminal was handed to another program, so output is no longer part of the session. */
429
362
  handedOff = false;
430
- intro(title2, subtitle) {
431
- this.emit(formatIntro(this.paint, title2, subtitle));
363
+ intro(title, subtitle) {
364
+ this.emit(formatIntro(this.paint, title, subtitle));
432
365
  }
433
366
  step(report) {
434
367
  this.emit(formatStep(this.paint, report));
@@ -436,9 +369,9 @@ var BasePrompter = class {
436
369
  outro(message, { tone = "success", lines = [] } = {}) {
437
370
  this.emit(formatOutro(this.paint, message, tone, lines, !this.handedOff));
438
371
  }
439
- async task(title2, run, report) {
372
+ async task(title, run, report) {
440
373
  const controller = new AbortController();
441
- const hide2 = this.showProgress(title2, () => controller.abort());
374
+ const hide2 = this.showProgress(title, () => controller.abort());
442
375
  try {
443
376
  const value = await run(controller.signal);
444
377
  hide2();
@@ -447,12 +380,12 @@ var BasePrompter = class {
447
380
  } catch (error62) {
448
381
  hide2();
449
382
  const cancelled = controller.signal.aborted;
450
- this.step({ title: title2, tone: cancelled ? "muted" : "error" });
383
+ this.step({ title, tone: cancelled ? "muted" : "error" });
451
384
  throw cancelled ? new CancelledError() : error62;
452
385
  }
453
386
  }
454
- async handoff(title2, lines) {
455
- this.emit(formatHandoff(this.paint, title2, lines));
387
+ async handoff(title, lines) {
388
+ this.emit(formatHandoff(this.paint, title, lines));
456
389
  this.handedOff = true;
457
390
  await this.release();
458
391
  }
@@ -502,17 +435,6 @@ var PromptStore = class {
502
435
  // src/prompts/components/ConfirmPrompt.tsx
503
436
  import { useRef, useState } from "react";
504
437
  import { Text, useInput } from "ink";
505
-
506
- // src/prompts/components/PaintContext.ts
507
- import { createContext, useContext } from "react";
508
- var PaintContext = createContext(null);
509
- function usePaint() {
510
- const paint = useContext(PaintContext);
511
- if (!paint) throw new Error("usePaint needs a PaintContext provider");
512
- return paint;
513
- }
514
-
515
- // src/prompts/components/ConfirmPrompt.tsx
516
438
  import { jsx as jsx2 } from "react/jsx-runtime";
517
439
  function ConfirmPrompt({ message, defaultValue, onSubmit }) {
518
440
  const paint = usePaint();
@@ -655,7 +577,7 @@ function SelectPrompt({ message, options, initialIndex, onSubmit }) {
655
577
  import { useEffect, useState as useState4 } from "react";
656
578
  import { Text as Text5 } from "ink";
657
579
  import { jsx as jsx6 } from "react/jsx-runtime";
658
- function Spinner({ title: title2 }) {
580
+ function Spinner({ title }) {
659
581
  const paint = usePaint();
660
582
  const [frame, setFrame] = useState4(0);
661
583
  const [startedAt] = useState4(() => Date.now());
@@ -663,7 +585,7 @@ function Spinner({ title: title2 }) {
663
585
  const timer = setInterval(() => setFrame((f) => f + 1), SPINNER_INTERVAL_MS);
664
586
  return () => clearInterval(timer);
665
587
  }, []);
666
- return /* @__PURE__ */ jsx6(Text5, { children: formatSpinner(paint, frame, title2, Math.floor((Date.now() - startedAt) / 1e3)) });
588
+ return /* @__PURE__ */ jsx6(Text5, { children: formatSpinner(paint, frame, title, Math.floor((Date.now() - startedAt) / 1e3)) });
667
589
  }
668
590
 
669
591
  // src/prompts/components/TextPrompt.tsx
@@ -705,9 +627,9 @@ function TextPrompt({ message, defaultValue = "", validate: validate2, onSubmit
705
627
  }
706
628
  if (key.ctrl || key.meta || key.escape || key.tab || key.upArrow || key.downArrow) return;
707
629
  if (key.leftArrow || key.rightArrow) return;
708
- const printable2 = input2.replace(/[\r\n\t]/g, "");
709
- if (printable2) {
710
- setValue((v) => v + printable2);
630
+ const printable = input2.replace(/[\r\n\t]/g, "");
631
+ if (printable) {
632
+ setValue((v) => v + printable);
711
633
  setError(void 0);
712
634
  }
713
635
  });
@@ -741,6 +663,7 @@ var InkPrompter = class extends BasePrompter {
741
663
  patchConsole: false
742
664
  });
743
665
  }
666
+ out;
744
667
  store = new PromptStore();
745
668
  instance;
746
669
  emit(text) {
@@ -748,8 +671,8 @@ var InkPrompter = class extends BasePrompter {
748
671
  else this.out.write(`${text}
749
672
  `);
750
673
  }
751
- showProgress(title2, cancel) {
752
- this.store.setActive({ element: /* @__PURE__ */ jsx8(Spinner, { title: title2 }), cancel });
674
+ showProgress(title, cancel) {
675
+ this.store.setActive({ element: /* @__PURE__ */ jsx8(Spinner, { title }), cancel });
753
676
  return () => this.store.setActive(null);
754
677
  }
755
678
  text({ message, defaultValue, validate: validate2 }) {
@@ -832,6 +755,7 @@ var PlainPrompter = class extends BasePrompter {
832
755
  super(paint);
833
756
  this.out = out;
834
757
  }
758
+ out;
835
759
  emit(text) {
836
760
  this.out.write(`${text}
837
761
  `);
@@ -934,6 +858,8 @@ var DotfilesRepository = class {
934
858
  this.git = git2;
935
859
  this.source = source;
936
860
  }
861
+ git;
862
+ source;
937
863
  /** The clone this machine was set up from, if the installer's link still points into one. */
938
864
  async locate() {
939
865
  let target;
@@ -1162,6 +1088,7 @@ var DotfilesCommand = class {
1162
1088
  ]
1163
1089
  };
1164
1090
  }
1091
+ deps;
1165
1092
  name = "dotfiles";
1166
1093
  summary = "set up zion's dotfiles on this machine";
1167
1094
  help;
@@ -21044,6 +20971,7 @@ var HttpStatusError = class extends CliError {
21044
20971
  this.status = status;
21045
20972
  this.name = "HttpStatusError";
21046
20973
  }
20974
+ status;
21047
20975
  };
21048
20976
  async function getJson(fetchImpl, request) {
21049
20977
  const { url: url2, schema, failure: failure2, signal } = request;
@@ -21081,6 +21009,13 @@ async function send(fetchImpl, url2, signal) {
21081
21009
  }
21082
21010
 
21083
21011
  // src/commands/now/NowApi.ts
21012
+ var Track = external_exports.object({
21013
+ title: external_exports.string(),
21014
+ artist: external_exports.string(),
21015
+ url: external_exports.string(),
21016
+ /** When the track was scrobbled; null while it's still playing. */
21017
+ playedAt: external_exports.string().nullable()
21018
+ });
21084
21019
  var Book = external_exports.object({
21085
21020
  title: external_exports.string(),
21086
21021
  author: external_exports.string().nullable(),
@@ -21095,6 +21030,8 @@ var Push = external_exports.object({
21095
21030
  pushedAt: external_exports.string()
21096
21031
  });
21097
21032
  var Now = external_exports.object({
21033
+ /** The latest track on Last.fm; null when Last.fm can't be read. */
21034
+ listening: Track.nullable(),
21098
21035
  /** The currently-reading shelf on Goodreads; null when Goodreads can't be read. */
21099
21036
  reading: external_exports.array(Book).nullable(),
21100
21037
  /** The latest public push on GitHub; null when GitHub can't be read. */
@@ -21105,6 +21042,7 @@ var HttpNowApi = class {
21105
21042
  this.fetchImpl = fetchImpl;
21106
21043
  this.url = new URL(url2);
21107
21044
  }
21045
+ fetchImpl;
21108
21046
  url;
21109
21047
  get host() {
21110
21048
  return this.url.host;
@@ -21136,79 +21074,27 @@ async function whileSpinning(ctx, text, work) {
21136
21074
  }
21137
21075
  }
21138
21076
 
21139
- // src/commands/now/format.ts
21140
- import terminalLink from "terminal-link";
21141
- var LABEL_WIDTH = 14;
21142
- function formatNow(paint, now, at) {
21143
- const sections = [];
21144
- if (now.reading?.length) sections.push(reading(paint, now.reading));
21145
- if (now.coding) sections.push(coding(paint, now.coding, at));
21146
- if (sections.length === 0) return `${paint.muted("Nothing to show right now.")}
21147
- `;
21148
- return `${sections.map((lines) => lines.join("\n")).join("\n\n")}
21149
- `;
21150
- }
21151
- function reading(paint, books) {
21152
- return books.flatMap((book, i) => {
21153
- const lines = [title(paint, i === 0 ? "reading" : "", book.title, book.url)];
21154
- if (book.author) lines.push(detail2(paint, book.author));
21155
- return lines;
21156
- });
21157
- }
21158
- function coding(paint, push, at) {
21159
- return [
21160
- title(paint, "pushed to", push.repo, push.url),
21161
- detail2(paint, [push.message, ago(new Date(push.pushedAt), at)].join(" \xB7 "))
21162
- ];
21163
- }
21164
- function title(paint, label, text, url2) {
21165
- const bold = paint.bold(printable(text));
21166
- const linked = /^https:\/\//.test(url2) ? terminalLink(bold, printable(url2), { fallback: () => bold }) : bold;
21167
- return `${paint.muted(label.padEnd(LABEL_WIDTH))}${linked}`;
21168
- }
21169
- function detail2(paint, text) {
21170
- return indent2(paint.muted(printable(text)));
21171
- }
21172
- function indent2(line) {
21173
- return `${" ".repeat(LABEL_WIDTH)}${line}`;
21174
- }
21175
- var UNITS = [
21176
- ["year", 365 * 24 * 3600],
21177
- ["month", 30 * 24 * 3600],
21178
- ["week", 7 * 24 * 3600],
21179
- ["day", 24 * 3600],
21180
- ["hour", 3600],
21181
- ["minute", 60]
21182
- ];
21183
- function ago(then, at) {
21184
- const seconds = (at.getTime() - then.getTime()) / 1e3;
21185
- if (Number.isNaN(seconds)) return "";
21186
- const format = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
21187
- for (const [unit, size] of UNITS) {
21188
- if (seconds >= size) return format.format(-Math.floor(seconds / size), unit);
21189
- }
21190
- return "just now";
21191
- }
21192
- function printable(text) {
21193
- return text.replace(new RegExp("\\p{Cc}", "gu"), "");
21194
- }
21195
-
21196
21077
  // src/commands/now/NowCommand.ts
21197
21078
  var NowCommand = class {
21198
21079
  constructor(deps) {
21199
21080
  this.deps = deps;
21200
21081
  this.help = {
21201
21082
  usage: "[options]",
21202
- description: `Asks ${deps.api.host} what zion is reading on Goodreads and last pushed to GitHub.`,
21083
+ description: `Asks ${deps.api.host} what zion last played on Last.fm, is reading on Goodreads and last pushed to GitHub. In a terminal it stays open and keeps up until you press q.`,
21203
21084
  options: [["--json", "print it as JSON"]],
21204
21085
  examples: ["now", "now --json"]
21205
21086
  };
21206
21087
  }
21088
+ deps;
21207
21089
  name = "now";
21208
- summary = "see what zion is reading and coding";
21090
+ summary = "see what zion is listening to, reading and coding";
21209
21091
  help;
21210
21092
  async run(args, ctx) {
21211
21093
  const { json: json2 } = parseNowOptions(args, ctx.bin);
21094
+ if (!json2 && ctx.interactive && ctx.stdout.isTTY) {
21095
+ const { runLive } = await import("./LiveNow-XJH5YXPH.js");
21096
+ return runLive(ctx, this.deps);
21097
+ }
21212
21098
  const status = await whileSpinning(ctx, `asking ${this.deps.api.host}`, this.deps.api.get());
21213
21099
  if (json2) {
21214
21100
  ctx.stdout.write(`${JSON.stringify(status, null, 2)}
@@ -21327,12 +21213,14 @@ var SkillNotFoundError = class extends CliError {
21327
21213
  this.skill = skill;
21328
21214
  this.name = "SkillNotFoundError";
21329
21215
  }
21216
+ skill;
21330
21217
  };
21331
21218
  var HttpSkillsApi = class {
21332
21219
  constructor(baseUrl, fetchImpl = fetch) {
21333
21220
  this.fetchImpl = fetchImpl;
21334
21221
  this.base = new URL(baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`);
21335
21222
  }
21223
+ fetchImpl;
21336
21224
  base;
21337
21225
  get host() {
21338
21226
  return this.base.host;
@@ -21450,10 +21338,10 @@ async function writeCopies({ files, lockfile, now }, skills, copies) {
21450
21338
  });
21451
21339
  }
21452
21340
  }
21453
- function describeCopies(paint, title2, skills, copies) {
21341
+ function describeCopies(paint, title, skills, copies) {
21454
21342
  const width = Math.max(...skills.map((skill) => skill.name.length));
21455
21343
  return {
21456
- title: title2,
21344
+ title,
21457
21345
  lines: skills.map((skill) => {
21458
21346
  const dirs = copiesOf(skill, copies).map((copy) => copy.dir);
21459
21347
  return `${skill.name.padEnd(width)} ${paint.muted(dirs.length ? describeDirs(dirs) : "nowhere")}`;
@@ -21487,6 +21375,7 @@ var InstallFlow = class {
21487
21375
  constructor(deps) {
21488
21376
  this.deps = deps;
21489
21377
  }
21378
+ deps;
21490
21379
  async run(ui, options, ctx) {
21491
21380
  const { api, lockfile } = this.deps;
21492
21381
  const lock = await lockfile.read();
@@ -21608,6 +21497,7 @@ var ManageFlow = class {
21608
21497
  constructor(deps) {
21609
21498
  this.deps = deps;
21610
21499
  }
21500
+ deps;
21611
21501
  async run(ui, ctx) {
21612
21502
  const { api, lockfile } = this.deps;
21613
21503
  const lock = await lockfile.read();
@@ -21727,7 +21617,7 @@ var ManageFlow = class {
21727
21617
  const width = Math.max(...rows.map(([, name]) => name.length));
21728
21618
  ui.step({
21729
21619
  title: "Changes",
21730
- lines: rows.map(([mark, name, detail3]) => `${mark} ${name.padEnd(width)} ${paint.muted(detail3)}`)
21620
+ lines: rows.map(([mark, name, detail2]) => `${mark} ${name.padEnd(width)} ${paint.muted(detail2)}`)
21731
21621
  });
21732
21622
  const warnings = [
21733
21623
  ...copies.flatMap((copy) => copy.problem ? [[tildify(copy.dir), copy.problem]] : []),
@@ -21749,6 +21639,7 @@ var RemoveFlow = class {
21749
21639
  constructor(deps) {
21750
21640
  this.deps = deps;
21751
21641
  }
21642
+ deps;
21752
21643
  async run(ui, options, ctx) {
21753
21644
  const { lockfile, targets } = this.deps;
21754
21645
  const lock = await lockfile.read();
@@ -21814,6 +21705,7 @@ var UpdateFlow = class {
21814
21705
  constructor(deps) {
21815
21706
  this.deps = deps;
21816
21707
  }
21708
+ deps;
21817
21709
  async run(ui, options, ctx) {
21818
21710
  const { api, lockfile } = this.deps;
21819
21711
  const lock = await lockfile.read();
@@ -22037,6 +21929,7 @@ var SkillsCommand = class {
22037
21929
  ]
22038
21930
  };
22039
21931
  }
21932
+ deps;
22040
21933
  name = "skills";
22041
21934
  summary = "install zion's agent skills";
22042
21935
  help;
@@ -22086,12 +21979,15 @@ var GitError = class extends Error {
22086
21979
  this.stderr = stderr;
22087
21980
  this.name = "GitError";
22088
21981
  }
21982
+ args;
21983
+ stderr;
22089
21984
  };
22090
21985
  var CliGit = class {
22091
21986
  constructor(runner2, env) {
22092
21987
  this.runner = runner2;
22093
21988
  this.env = { ...env, GIT_TERMINAL_PROMPT: "0" };
22094
21989
  }
21990
+ runner;
22095
21991
  env;
22096
21992
  async version(signal) {
22097
21993
  const { code, stdout } = await this.runner.capture("git", ["--version"], { env: this.env, signal });
@@ -22160,6 +22056,7 @@ var JsonLockfile = class {
22160
22056
  constructor(path13) {
22161
22057
  this.path = path13;
22162
22058
  }
22059
+ path;
22163
22060
  async read() {
22164
22061
  let text;
22165
22062
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zion",
3
- "version": "2.6.0",
3
+ "version": "3.0.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",