zion 2.6.0 → 3.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 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-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
+ };
@@ -0,0 +1,188 @@
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
+ };
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-YKEQSW45.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.0";
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"]);
@@ -359,12 +286,12 @@ var HelpCommand = class {
359
286
  }
360
287
  };
361
288
  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}`)}`)];
289
+ const title = name ? `${paint.badge("zion")} ${paint.bold(name)}` : paint.badge("zion");
290
+ const lines = [indent(`${title} ${paint.muted(`v${ctx.version}`)}`)];
364
291
  return summary ? [...lines, indent(paint.muted(summary))] : lines;
365
292
  }
366
- function section(paint, title2, lines) {
367
- return [indent(paint.bold(title2.toUpperCase())), ...lines.map((line) => indent(indent(line)))];
293
+ function section(paint, title, lines) {
294
+ return [indent(paint.bold(title.toUpperCase())), ...lines.map((line) => indent(indent(line)))];
368
295
  }
369
296
  function table(paint, rows) {
370
297
  const width = Math.max(...rows.map(([term]) => term.length));
@@ -427,8 +354,8 @@ var BasePrompter = class {
427
354
  }
428
355
  /** True once the terminal was handed to another program, so output is no longer part of the session. */
429
356
  handedOff = false;
430
- intro(title2, subtitle) {
431
- this.emit(formatIntro(this.paint, title2, subtitle));
357
+ intro(title, subtitle) {
358
+ this.emit(formatIntro(this.paint, title, subtitle));
432
359
  }
433
360
  step(report) {
434
361
  this.emit(formatStep(this.paint, report));
@@ -436,9 +363,9 @@ var BasePrompter = class {
436
363
  outro(message, { tone = "success", lines = [] } = {}) {
437
364
  this.emit(formatOutro(this.paint, message, tone, lines, !this.handedOff));
438
365
  }
439
- async task(title2, run, report) {
366
+ async task(title, run, report) {
440
367
  const controller = new AbortController();
441
- const hide2 = this.showProgress(title2, () => controller.abort());
368
+ const hide2 = this.showProgress(title, () => controller.abort());
442
369
  try {
443
370
  const value = await run(controller.signal);
444
371
  hide2();
@@ -447,12 +374,12 @@ var BasePrompter = class {
447
374
  } catch (error62) {
448
375
  hide2();
449
376
  const cancelled = controller.signal.aborted;
450
- this.step({ title: title2, tone: cancelled ? "muted" : "error" });
377
+ this.step({ title, tone: cancelled ? "muted" : "error" });
451
378
  throw cancelled ? new CancelledError() : error62;
452
379
  }
453
380
  }
454
- async handoff(title2, lines) {
455
- this.emit(formatHandoff(this.paint, title2, lines));
381
+ async handoff(title, lines) {
382
+ this.emit(formatHandoff(this.paint, title, lines));
456
383
  this.handedOff = true;
457
384
  await this.release();
458
385
  }
@@ -502,17 +429,6 @@ var PromptStore = class {
502
429
  // src/prompts/components/ConfirmPrompt.tsx
503
430
  import { useRef, useState } from "react";
504
431
  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
432
  import { jsx as jsx2 } from "react/jsx-runtime";
517
433
  function ConfirmPrompt({ message, defaultValue, onSubmit }) {
518
434
  const paint = usePaint();
@@ -655,7 +571,7 @@ function SelectPrompt({ message, options, initialIndex, onSubmit }) {
655
571
  import { useEffect, useState as useState4 } from "react";
656
572
  import { Text as Text5 } from "ink";
657
573
  import { jsx as jsx6 } from "react/jsx-runtime";
658
- function Spinner({ title: title2 }) {
574
+ function Spinner({ title }) {
659
575
  const paint = usePaint();
660
576
  const [frame, setFrame] = useState4(0);
661
577
  const [startedAt] = useState4(() => Date.now());
@@ -663,7 +579,7 @@ function Spinner({ title: title2 }) {
663
579
  const timer = setInterval(() => setFrame((f) => f + 1), SPINNER_INTERVAL_MS);
664
580
  return () => clearInterval(timer);
665
581
  }, []);
666
- return /* @__PURE__ */ jsx6(Text5, { children: formatSpinner(paint, frame, title2, Math.floor((Date.now() - startedAt) / 1e3)) });
582
+ return /* @__PURE__ */ jsx6(Text5, { children: formatSpinner(paint, frame, title, Math.floor((Date.now() - startedAt) / 1e3)) });
667
583
  }
668
584
 
669
585
  // src/prompts/components/TextPrompt.tsx
@@ -705,9 +621,9 @@ function TextPrompt({ message, defaultValue = "", validate: validate2, onSubmit
705
621
  }
706
622
  if (key.ctrl || key.meta || key.escape || key.tab || key.upArrow || key.downArrow) return;
707
623
  if (key.leftArrow || key.rightArrow) return;
708
- const printable2 = input2.replace(/[\r\n\t]/g, "");
709
- if (printable2) {
710
- setValue((v) => v + printable2);
624
+ const printable = input2.replace(/[\r\n\t]/g, "");
625
+ if (printable) {
626
+ setValue((v) => v + printable);
711
627
  setError(void 0);
712
628
  }
713
629
  });
@@ -748,8 +664,8 @@ var InkPrompter = class extends BasePrompter {
748
664
  else this.out.write(`${text}
749
665
  `);
750
666
  }
751
- showProgress(title2, cancel) {
752
- this.store.setActive({ element: /* @__PURE__ */ jsx8(Spinner, { title: title2 }), cancel });
667
+ showProgress(title, cancel) {
668
+ this.store.setActive({ element: /* @__PURE__ */ jsx8(Spinner, { title }), cancel });
753
669
  return () => this.store.setActive(null);
754
670
  }
755
671
  text({ message, defaultValue, validate: validate2 }) {
@@ -21081,6 +20997,13 @@ async function send(fetchImpl, url2, signal) {
21081
20997
  }
21082
20998
 
21083
20999
  // src/commands/now/NowApi.ts
21000
+ var Track = external_exports.object({
21001
+ title: external_exports.string(),
21002
+ artist: external_exports.string(),
21003
+ url: external_exports.string(),
21004
+ /** When the track was scrobbled; null while it's still playing. */
21005
+ playedAt: external_exports.string().nullable()
21006
+ });
21084
21007
  var Book = external_exports.object({
21085
21008
  title: external_exports.string(),
21086
21009
  author: external_exports.string().nullable(),
@@ -21095,6 +21018,8 @@ var Push = external_exports.object({
21095
21018
  pushedAt: external_exports.string()
21096
21019
  });
21097
21020
  var Now = external_exports.object({
21021
+ /** The latest track on Last.fm; null when Last.fm can't be read. */
21022
+ listening: Track.nullable(),
21098
21023
  /** The currently-reading shelf on Goodreads; null when Goodreads can't be read. */
21099
21024
  reading: external_exports.array(Book).nullable(),
21100
21025
  /** The latest public push on GitHub; null when GitHub can't be read. */
@@ -21136,79 +21061,26 @@ async function whileSpinning(ctx, text, work) {
21136
21061
  }
21137
21062
  }
21138
21063
 
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
21064
  // src/commands/now/NowCommand.ts
21197
21065
  var NowCommand = class {
21198
21066
  constructor(deps) {
21199
21067
  this.deps = deps;
21200
21068
  this.help = {
21201
21069
  usage: "[options]",
21202
- description: `Asks ${deps.api.host} what zion is reading on Goodreads and last pushed to GitHub.`,
21070
+ 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
21071
  options: [["--json", "print it as JSON"]],
21204
21072
  examples: ["now", "now --json"]
21205
21073
  };
21206
21074
  }
21207
21075
  name = "now";
21208
- summary = "see what zion is reading and coding";
21076
+ summary = "see what zion is listening to, reading and coding";
21209
21077
  help;
21210
21078
  async run(args, ctx) {
21211
21079
  const { json: json2 } = parseNowOptions(args, ctx.bin);
21080
+ if (!json2 && ctx.interactive && ctx.stdout.isTTY) {
21081
+ const { runLive } = await import("./LiveNow-SLZOTZWP.js");
21082
+ return runLive(ctx, this.deps);
21083
+ }
21212
21084
  const status = await whileSpinning(ctx, `asking ${this.deps.api.host}`, this.deps.api.get());
21213
21085
  if (json2) {
21214
21086
  ctx.stdout.write(`${JSON.stringify(status, null, 2)}
@@ -21450,10 +21322,10 @@ async function writeCopies({ files, lockfile, now }, skills, copies) {
21450
21322
  });
21451
21323
  }
21452
21324
  }
21453
- function describeCopies(paint, title2, skills, copies) {
21325
+ function describeCopies(paint, title, skills, copies) {
21454
21326
  const width = Math.max(...skills.map((skill) => skill.name.length));
21455
21327
  return {
21456
- title: title2,
21328
+ title,
21457
21329
  lines: skills.map((skill) => {
21458
21330
  const dirs = copiesOf(skill, copies).map((copy) => copy.dir);
21459
21331
  return `${skill.name.padEnd(width)} ${paint.muted(dirs.length ? describeDirs(dirs) : "nowhere")}`;
@@ -21727,7 +21599,7 @@ var ManageFlow = class {
21727
21599
  const width = Math.max(...rows.map(([, name]) => name.length));
21728
21600
  ui.step({
21729
21601
  title: "Changes",
21730
- lines: rows.map(([mark, name, detail3]) => `${mark} ${name.padEnd(width)} ${paint.muted(detail3)}`)
21602
+ lines: rows.map(([mark, name, detail2]) => `${mark} ${name.padEnd(width)} ${paint.muted(detail2)}`)
21731
21603
  });
21732
21604
  const warnings = [
21733
21605
  ...copies.flatMap((copy) => copy.problem ? [[tildify(copy.dir), copy.problem]] : []),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zion",
3
- "version": "2.6.0",
3
+ "version": "3.0.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",