@litfamily/litmuse 0.1.19 → 0.1.20

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.20 — 2026-11-25
4
+
5
+ - `litmuse status --card` shows a sunset beside the words in a truecolor terminal of 90 columns or more: a half-sunk sun, stars and a sea, drawn only in cells that hold no text. It is dim with no route, amber on `YOUR TURN` and rainbow for `lit-adhd`. The version pill runs orange to pink there, thread branches turn neon and the current stage is filled violet to cyan. Row count, words and widths are unchanged, and a pipe, `--json`, `NO_COLOR`, 256 or fewer colours, a light background (`COLORFGBG`) and narrower terminals print what they did before.
6
+ - New: `litmuse status --card --watch` keeps the card open in a neon frame. The scene moves while your Muse session works and holds still when it stops; `LITMUSE_MOTION=off` keeps it still. `q` or Ctrl+C leaves and restores the terminal.
7
+ - No hook or context file changed, so Muse asks for no new hook approval.
8
+
3
9
  ## 0.1.19 — 2026-11-24
4
10
 
5
11
  - A lit-team lock folder that has no owner record yet is judged only after it is at least 5 seconds old, whatever stale window the caller passes. Before, a stale window of 0 could move aside a lock another process had just created, and that process then failed with `lock ownership receipt failed`.
package/README.md CHANGED
@@ -212,17 +212,23 @@ Read the card from top to bottom. The first line names the workflow and how long
212
212
 
213
213
  At rest the card reports no active route:
214
214
 
215
- <p align="center"><img src="./docs/assets/card/idle.webp" width="960" alt="Terminal card of litmuse status --card with no route running: LIT, no active route in this workspace, plan 0/2 in plans/todo-app.md, next row 1, Add the shout flag." /></p>
215
+ <p align="center"><img src="./docs/assets/card/idle.webp" width="960" alt="Terminal card of litmuse status --card with no route running: LIT, no active route in this workspace, plan 0/2 in plans/todo-app.md, next row 1, Add the shout flag. A dimmed half-sunk sun with stars and a sea sits to the right of the words." /></p>
216
216
 
217
217
  While a plan runs, the card names the route, the plan file, and the next open row:
218
218
 
219
- <p align="center"><img src="./docs/assets/card/working.webp" width="960" alt="Terminal card of litmuse status --card while lit-plan runs: LIT, lit-plan, active 30s, one lit-plan thread running, plan 0/2 in plans/todo-app.md, next row 1, Add the shout flag." /></p>
219
+ <p align="center"><img src="./docs/assets/card/working.webp" width="960" alt="Terminal card of litmuse status --card while lit-plan runs: LIT, lit-plan, active 30s, one lit-plan thread running, plan 0/2 in plans/todo-app.md, next row 1, Add the shout flag. A bright sunset over a sea sits to the right of the words." /></p>
220
220
 
221
221
  Ticking a row moves the count and the next-row pointer:
222
222
 
223
223
  <p align="center"><img src="./docs/assets/card/after.webp" width="960" alt="The same card after row 1 is ticked: plan 1/2 in plans/todo-app.md, next row 2, Write the tests." /></p>
224
224
 
225
- Run in a terminal, `litmuse status --card` also puts the mark above the card, and a truecolor terminal gets a gradient `🔥LIT v<version>` pill at the start of its first line. When `/lit-status` has the model run the card through its bash tool, or colour is off, the card keeps its plain `LIT ·` headline, and `--json` prints only the record.
225
+ Run in a terminal, `litmuse status --card` also puts the mark above the card, and a truecolor terminal gets a gradient `🔥LIT v<version>` pill at the start of its first line. A truecolor terminal of 90 columns or more also gets a sunset beside the words: a half-sunk sun with stars above it and a sea running out from it. It uses only cells that hold no text and adds no row, so on a card full of long rows it moves up or stays away. The sun is dim while no route runs, amber while the card says `YOUR TURN`, and rainbow during `lit-adhd`. When `/lit-status` has the model run the card through its bash tool, or colour is off, the card keeps its plain `LIT ·` headline, and `--json` prints only the record.
226
+
227
+ To keep the card open beside your work, add `--watch`. It fills the terminal, puts a neon frame around the card and, while your Muse session is working, lets the sea flow, the stars twinkle and light run across the sun. When the session stops, or nothing has happened for 15 minutes, the picture holds still and only the words and times keep up. Press `q` or Ctrl+C and your terminal comes back as it was.
228
+
229
+ <p align="center"><picture><source media="(prefers-reduced-motion: reduce)" srcset="./docs/assets/card/watch-still.webp" /><img src="./docs/assets/card/watch.webp" width="960" alt="Moving terminal card of litmuse status --card --watch while lit-plan runs: a neon frame from pink through violet to cyan around the card, with the sea flowing out from a half-sunk sun and stars twinkling above it." /></picture></p>
230
+
231
+ This runs in your own shell, in a second window or pane, because Muse draws no plugin text inside its screen. `LITMUSE_MOTION=off` keeps the scene and stops the motion; `NO_COLOR`, fewer colours, or under 90 columns show the plain card, kept up to date.
226
232
 
227
233
  The card reads the hook-kept state under `~/.local/state/litmuse/`, outside the project. How it lists other sessions is in [the reference](./docs/reference.md#the-live-record-behind-the-card).
228
234
 
package/README_ko-KR.md CHANGED
@@ -203,17 +203,23 @@ Muse의 `/hud`는 켜고 끄는 고정 항목 목록이라서 플러그인 글
203
203
 
204
204
  쉴 때 카드는 활성 경로가 없다고 알립니다.
205
205
 
206
- <p align="center"><img src="./docs/assets/card/idle.webp" width="960" alt="실행 중인 경로가 없을 때의 litmuse status --card 터미널 카드. 이 워크스페이스에 활성 경로가 없고, plans/todo-app.md 계획은 0/2, 다음 행은 1. Add the shout flag입니다." /></p>
206
+ <p align="center"><img src="./docs/assets/card/idle.webp" width="960" alt="실행 중인 경로가 없을 때의 litmuse status --card 터미널 카드. 이 워크스페이스에 활성 경로가 없고, plans/todo-app.md 계획은 0/2, 다음 행은 1. Add the shout flag입니다. 글 오른쪽에 어두운 반쯤 잠긴 해와 별, 바다가 있습니다." /></p>
207
207
 
208
208
  계획이 돌 때 카드는 경로와 계획 파일, 다음 행을 보여 줍니다.
209
209
 
210
- <p align="center"><img src="./docs/assets/card/working.webp" width="960" alt="lit-plan이 실행 중일 때의 litmuse status --card 터미널 카드. lit-plan이 30초째 활성이고 lit-plan 스레드 하나가 실행 중이며, plans/todo-app.md 계획은 0/2, 다음 행은 1. Add the shout flag입니다." /></p>
210
+ <p align="center"><img src="./docs/assets/card/working.webp" width="960" alt="lit-plan이 실행 중일 때의 litmuse status --card 터미널 카드. lit-plan이 30초째 활성이고 lit-plan 스레드 하나가 실행 중이며, plans/todo-app.md 계획은 0/2, 다음 행은 1. Add the shout flag입니다. 글 오른쪽에 밝은 노을과 바다가 있습니다." /></p>
211
211
 
212
212
  행에 체크하면 개수와 다음 행 표시가 바뀝니다.
213
213
 
214
214
  <p align="center"><img src="./docs/assets/card/after.webp" width="960" alt="1번 행을 체크한 뒤의 같은 카드. plans/todo-app.md 계획이 1/2가 되고 다음 행은 2. Write the tests입니다." /></p>
215
215
 
216
- 터미널에서 `litmuse status --card`를 실행하면 카드 위에 마크가 붙고, truecolor 터미널이면 첫 줄 맨 앞에 그라데이션 `🔥LIT v<버전>` 알약도 붙습니다. `/lit-status`가 모델의 bash 도구로 카드를 돌릴 때나 색이 꺼져 있을 때는 원래의 `LIT ·` 머리줄이 그대로 남고, `--json`은 기록만 출력합니다.
216
+ 터미널에서 `litmuse status --card`를 실행하면 카드 위에 마크가 붙고, truecolor 터미널이면 첫 줄 맨 앞에 그라데이션 `🔥LIT v<버전>` 알약도 붙습니다. 90칸 이상인 truecolor 터미널에서는 글 옆에 노을도 나옵니다. 반쯤 잠긴 해 위에 별이 있고, 해에서 바다가 퍼져 나갑니다. 글이 없는 칸에만 그리고 줄을 늘리지 않으므로, 긴 줄이 많으면 위로 옮겨 가거나 나오지 않습니다. 해는 활성 경로가 없으면 어둡고, 카드에 `YOUR TURN`이 뜨면 호박색, `lit-adhd` 때는 무지개색입니다. `/lit-status`가 모델의 bash 도구로 카드를 돌릴 때나 색이 꺼져 있을 때는 원래의 `LIT ·` 머리줄이 그대로 남고, `--json`은 기록만 출력합니다.
217
+
218
+ 카드를 작업 옆에 계속 띄워 두려면 `--watch`를 붙입니다. 카드가 터미널을 채우고 네온 테두리가 생기며, Muse 세션이 일하는 동안 바다가 흐르고 별이 반짝이고 해 위로 빛이 지나갑니다. 세션이 멈추거나 15분 동안 아무 일이 없으면 그림은 멈추고 글과 시간만 갱신됩니다. `q`나 Ctrl+C를 누르면 터미널이 원래대로 돌아옵니다.
219
+
220
+ <p align="center"><picture><source media="(prefers-reduced-motion: reduce)" srcset="./docs/assets/card/watch-still.webp" /><img src="./docs/assets/card/watch.webp" width="960" alt="lit-plan이 실행 중일 때 움직이는 litmuse status --card --watch 터미널 카드. 분홍에서 보라, 하늘색으로 이어지는 네온 테두리 안에서 반쯤 잠긴 해로부터 바다가 흐르고 위에서 별이 반짝입니다." /></picture></p>
221
+
222
+ Muse는 자기 화면 안에 플러그인 글을 그리지 않으므로, 이 카드는 다른 창이나 분할 창에 연 셸에서 실행합니다. `LITMUSE_MOTION=off`면 장면은 그대로 두고 움직임만 멈춥니다. `NO_COLOR`, 색이 적은 터미널, 90칸 미만에서는 계속 갱신되는 일반 카드를 보여 줍니다.
217
223
 
218
224
  카드는 프로젝트 밖에 있는 `~/.local/state/litmuse/` 아래 훅 기록을 읽습니다. 다른 세션을 어떻게 보여 주는지는 [참고 자료](./docs/reference_ko-KR.md#카드-뒤의-실시간-기록)에 있습니다.
219
225
 
package/bin/litmuse.mjs CHANGED
@@ -11,11 +11,12 @@ import { paths } from '../lib/paths.mjs';
11
11
  import { installedPlugin, museVersion } from '../lib/muse.mjs';
12
12
  import { checkUpdate } from '../lib/update-check.mjs';
13
13
  import { agentFileState, configCommand, readAgentFileSetting } from '../lib/agent-file.mjs';
14
- import { buildCard, renderCard } from '../lib/stage-card.mjs';
14
+ import { buildCard } from '../lib/stage-card.mjs';
15
+ import { cardText, watchCard } from '../lib/card-view.mjs';
15
16
  import { styleCommand } from '../lib/style.mjs';
16
17
  import { runRewindCli } from '../plugin/lib/rewind/collect.mjs';
17
18
  import { extensionsCommand } from '../lib/extensions.mjs';
18
- import { colourDepth, litPill, markFor, pillWidth, termColumns } from '../lib/mark.mjs';
19
+ import { markFor } from '../lib/mark.mjs';
19
20
 
20
21
  const HELP = `LitMuse ${packageVersion()}: LitFamily workflows for Meta's Muse Code
21
22
 
@@ -25,6 +26,7 @@ Commands
25
26
  install Stage the plugin, install it into Muse at user scope, and offer the approvals
26
27
  doctor Check install state, every approval, skill enrollment, catalog bytes and overlaps
27
28
  status Short version of doctor plus an update check; --card shows the live LIT card for this folder
29
+ (add --watch to keep it open; q or Ctrl+C leaves)
28
30
  models List the models and effort tiers your Muse catalog offers
29
31
  hud Show the recommended /hud and /theme preset
30
32
  config agentFile on|off: the short LitFamily block in Muse's user rules file (acts at once)
@@ -60,6 +62,7 @@ function parse(argv) {
60
62
  else if (a === '--no-agent-file') flags.noAgentFile = true;
61
63
  else if (a === '--discard-modified') flags.discardModified = true;
62
64
  else if (a === '--card') flags.card = true;
65
+ else if (a === '--watch') flags.watch = true;
63
66
  else if (a === '--scope') flags.scope = argv[++i];
64
67
  else if (a === '--from') flags.from = argv[++i];
65
68
  else if (a === '--family') flags.family = argv[++i];
@@ -130,13 +133,10 @@ async function main() {
130
133
  print(JSON.stringify(card, null, 2));
131
134
  return 0;
132
135
  }
133
- // /lit-status has the model run this through bash and repeat it, so the mark and pill
134
- // appear only when a person's terminal is attached.
135
- const tty = process.stdout.isTTY === true;
136
- const depth = colourDepth({ env, isTTY: tty });
137
- const v = packageVersion();
138
- if (tty) print(markFor({ env }));
139
- print(renderCard(card, { badge: tty && depth === 'truecolor' ? { text: litPill(v, depth), width: pillWidth(v) } : null, cols: termColumns({ env }) }));
136
+ // /lit-status has the model run this through bash and repeat it, so the mark, the pill and the
137
+ // scene appear only when a person's terminal is attached; --watch needs one too.
138
+ if (flags.watch && process.stdout.isTTY && env.TERM !== 'dumb') return watchCard({ env, version: packageVersion() });
139
+ print(cardText(card, { env, version: packageVersion() }));
140
140
  return 0;
141
141
  }
142
142
  const st = stageState(paths(env));
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,172 @@
1
+ // The status card as a person's terminal shows it: one print with the sunset beside the words, or, with --watch, a
2
+ // full-screen card that moves while work goes on. A pipe, --json, NO_COLOR, fewer colours, a light background and a
3
+ // narrow terminal never reach the scene.
4
+ import { buildCard, cardLight, cardWorking, renderCard } from './stage-card.mjs';
5
+ import { colourDepth, litPill, markFor, pillLabel, pillWidth, termColumns } from './mark.mjs';
6
+ import { BRAND, MAX_WIDTH, STILL_T, SUN_ROWS, SUN_W, gradedPill, ink, mix, motionOff, neon, paint, paintRows, place, roundCaps, rowCells, sceneOn, wrapRow } from './sunset.mjs';
7
+
8
+ const ESC = '\u001b';
9
+ export const READ_MS = 1000;
10
+ export const FRAME_MS = 125;
11
+
12
+ // The terminal as the card sees it. `scene` is off wherever today's output must stay as it is.
13
+ const terminal = (env, stream) => {
14
+ const tty = stream?.isTTY === true;
15
+ const depth = colourDepth({ env, isTTY: tty });
16
+ const cols = termColumns({ env, stream });
17
+ return { tty, depth, cols, scene: sceneOn({ depth, env, cols }), caps: roundCaps(env) };
18
+ };
19
+
20
+ const cardRows = (card, term, version, cols = term.cols) => {
21
+ const pill = !term.tty ? null : term.scene ? gradedPill(pillLabel(version), BRAND, term.caps) : litPill(version, term.depth);
22
+ return renderCard(card, {
23
+ badge: pill && { text: pill, width: pillWidth(version) }, cols, dress: term.scene ? { caps: term.caps } : null,
24
+ }).split('\n');
25
+ };
26
+
27
+ // `litmuse status --card`. The mark's tagline and the blank row under it lend the sun room over a short card.
28
+ export function cardText(card, { env = process.env, stream = process.stdout, version }) {
29
+ const term = terminal(env, stream);
30
+ const mark = term.tty ? `${markFor({ env, stream })}\n`.split('\n').slice(0, -1) : [];
31
+ const rows = cardRows(card, term, version);
32
+ const light = term.scene ? cardLight(card) : null;
33
+ if (!light) return [...mark, ...rows].join('\n');
34
+ const art = mark.slice(0, -2);
35
+ // The last column stays empty: some terminals wrap on it.
36
+ const width = Math.min(MAX_WIDTH, term.cols - 1);
37
+ return [...art, ...paintRows([...mark.slice(-2), ...rows], width, { ...light, t: light.dim ? null : STILL_T })].join('\n');
38
+ }
39
+
40
+ // The watched card inside its neon frame, laid out once per state: the headline sits in the top rule, at least three
41
+ // rows of body give the sun its place. frame(t) paints it for one moment.
42
+ function framed(rows, width, light) {
43
+ const inner = width - 4;
44
+ const title = rowCells(rows[0]) <= inner - 4 ? rows[0] : '';
45
+ const body = (title ? rows.slice(1) : rows).flatMap((row) => wrapRow(row, inner));
46
+ while (body.length < SUN_ROWS) body.push('');
47
+ const spot = place(body, inner);
48
+ const sunMid = 2 + spot.at + SUN_W / 2;
49
+ const lit = light && spot.top !== null && spot.sea === body.length - 1;
50
+ const rule = (x, r, t) => {
51
+ const i = Math.floor(x / 4) * 4;
52
+ let hue = neon(Math.min(1, i / width + r * 0.02));
53
+ if (t !== null) hue = mix(hue, '#ffffff', 0.15 + 0.15 * Math.sin((t / 2.4) * Math.PI * 2));
54
+ if (r === 2 && lit) {
55
+ const near = Math.max(0, 1 - Math.abs(i - sunMid) / 26);
56
+ const ring = 0.5 + 0.5 * Math.sin(Math.abs(i - sunMid) * 0.55 - (t ?? 0) * 2.6);
57
+ hue = mix(hue, near > 0.6 ? '#ffd24a' : '#ff8f3c', Math.min(1, near * (0.45 + 0.85 * ring)));
58
+ }
59
+ return light?.dim ? mix(hue, '#30363d', 0.45) : hue;
60
+ };
61
+ const line = (from, chars, r, t) => ink([...chars].map((ch, i) => (ch === ' ' ? null : { ch, fg: rule(from + i, r, t) })));
62
+ // Side walls are placed by column, so a character the terminal draws wider than expected cannot bend the frame.
63
+ const wall = (t) => [line(0, '│', 1, t), `${ESC}[${width}G${line(width - 1, '│', 1, t)}`];
64
+ const lead = title ? 4 + rowCells(title) : 0;
65
+ return (t) => {
66
+ const tails = light ? paint(spot, { ...light, t }) : new Map();
67
+ const [left, right] = wall(t);
68
+ const top = title
69
+ ? `${line(0, '╭─ ', 0, t)}${title}${line(lead - 1, ` ${'─'.repeat(width - lead - 1)}╮`, 0, t)}`
70
+ : line(0, `╭${'─'.repeat(width - 2)}╮`, 0, t);
71
+ return [
72
+ top,
73
+ ...body.map((text, r) => `${left} ${text}${tails.has(r) ? ink(tails.get(r).slice(Math.min(inner, spot.ends[r]))) : `${ESC}[K`}${right}`),
74
+ line(0, `╰${'─'.repeat(width - 2)}╯`, 2, t),
75
+ ];
76
+ };
77
+ }
78
+
79
+ // What --watch shows for this state and terminal size. `moving` is false whenever the picture cannot change by itself.
80
+ export function watchView(card, { env = process.env, stream = process.stdout, version, now = Date.now() }) {
81
+ const term = terminal(env, stream);
82
+ const height = Number(stream.rows) || 24;
83
+ const width = Math.min(MAX_WIDTH, term.cols - 1);
84
+ let draw;
85
+ if (term.scene) {
86
+ draw = framed(cardRows(card, term, version, width - 8), width, cardLight(card));
87
+ } else {
88
+ const rows = cardRows(card, term, version).flatMap((row) => wrapRow(row, term.cols));
89
+ draw = () => rows;
90
+ }
91
+ const mark = markFor({ env, stream }).split('\n');
92
+ const above = mark.length + draw(null).length <= height ? mark : [];
93
+ const moving = term.scene && !motionOff(env) && cardWorking(card, { env, now });
94
+ return { moving, frame: (t) => [...above, ...draw(t)].slice(0, height) };
95
+ }
96
+
97
+ /**
98
+ * `litmuse status --card --watch` on a terminal: the alternate screen, one timer, the state read at most once a second
99
+ * and repainted from memory in between. Resolves with the exit code once the terminal is back as it was.
100
+ */
101
+ export function watchCard({ cwd = process.cwd(), env = process.env, out = process.stdout, input = process.stdin, proc = process, now = Date.now, version, read = () => buildCard({ cwd, env, now: now() }) }) {
102
+ return new Promise((resolve) => {
103
+ const started = now();
104
+ let timer = null;
105
+ let readAt = -Infinity;
106
+ let card = null;
107
+ let view = null;
108
+ let shown = [];
109
+ let open = true;
110
+ const raw = Boolean(input?.isTTY && input.setRawMode);
111
+
112
+ const draw = () => {
113
+ const rows = view.frame(view.moving ? (now() - started) / 1000 : null);
114
+ let bytes = '';
115
+ for (let r = 0; r < Math.max(rows.length, shown.length); r += 1) {
116
+ if (rows[r] !== shown[r]) bytes += `${ESC}[${r + 1};1H${rows[r] ?? ''}${ESC}[0m${ESC}[K`;
117
+ }
118
+ shown = rows;
119
+ if (bytes) out.write(bytes);
120
+ };
121
+ const compose = () => {
122
+ view = watchView(card, { env, stream: out, version, now: now() });
123
+ };
124
+ const tick = () => {
125
+ if (now() - readAt >= READ_MS) {
126
+ readAt = now();
127
+ card = read();
128
+ compose();
129
+ }
130
+ draw();
131
+ timer = setTimeout(tick, view.moving ? FRAME_MS : Math.max(1, READ_MS - (now() - readAt)));
132
+ };
133
+ const resize = () => {
134
+ compose();
135
+ shown = [];
136
+ out.write(`${ESC}[2J`);
137
+ draw();
138
+ };
139
+ const restore = () => {
140
+ if (!open) return;
141
+ open = false;
142
+ clearTimeout(timer);
143
+ if (raw) input.setRawMode(false);
144
+ out.write(`${ESC}[0m${ESC}[?7h${ESC}[?25h${ESC}[?1049l`);
145
+ };
146
+ const stop = (code) => {
147
+ restore();
148
+ out.off('resize', resize);
149
+ input?.off?.('data', key);
150
+ input?.pause?.();
151
+ for (const [name, handler] of signals) proc.off(name, handler);
152
+ proc.off('exit', restore);
153
+ resolve(code);
154
+ };
155
+ // Raw mode hands Ctrl+C over as a key; q and Esc leave too.
156
+ const key = (data) => {
157
+ if (['\u0003', 'q', 'Q', ESC].includes(String(data))) stop(0);
158
+ };
159
+ const signals = [['SIGINT', () => stop(0)], ['SIGTERM', () => stop(143)], ['SIGHUP', () => stop(129)]];
160
+
161
+ for (const [name, handler] of signals) proc.on(name, handler);
162
+ proc.on('exit', restore);
163
+ out.on('resize', resize);
164
+ if (raw) {
165
+ input.setRawMode(true);
166
+ input.on('data', key);
167
+ input.resume();
168
+ }
169
+ out.write(`${ESC}[?1049h${ESC}[?25l${ESC}[?7l${ESC}[2J`);
170
+ tick();
171
+ });
172
+ }
@@ -5,6 +5,7 @@ import { newerThan } from '../plugin/hooks/lib/common.mjs';
5
5
  import { readManifest } from './bundle.mjs';
6
6
  import { paths } from './paths.mjs';
7
7
  import { gauge } from '../plugin/lib/rewind/gauge.mjs';
8
+ import { ink, neon, roundGauge, stagePill } from './sunset.mjs';
8
9
  // One rainbow-tinted line at most (a static ANSI gradient, flash-safe); it marks the adhd turn.
9
10
  import { rainbowLine } from '../plugin/lib/rewind/rainbow.mjs';
10
11
 
@@ -304,9 +305,29 @@ const burstOf = (card, now) => {
304
305
  return null;
305
306
  };
306
307
 
308
+ // The sunset's light for this card, or null when the burst has the stage: amber while it waits on the user, rainbow
309
+ // for the adhd turn, dimmed with no route.
310
+ export function cardLight(card) {
311
+ if (burstOf(card, card.now ?? Date.now())) return null;
312
+ const look = !card.active ? 'sunset' : waitingOf(card) ? 'turn' : card.route === 'lit-adhd' ? 'rainbow' : 'sunset';
313
+ return { look, dim: !card.active };
314
+ }
315
+
316
+ // Work is going on: a route is active, its session has not stopped since the record last moved, and something moved
317
+ // in the last quarter hour. Only then does the watched card move.
318
+ export function cardWorking(card, { env = process.env, now = card.now ?? Date.now() } = {}) {
319
+ if (!card.active) return false;
320
+ const live = readLiveness(env).find((rec) => rec.session === card.session);
321
+ const liveAt = live ? Date.parse(live.at) : 0;
322
+ if (live && live.state !== 'alive' && liveAt >= (card.updated ?? 0)) return false;
323
+ return now - Math.max(card.updated ?? 0, liveAt || 0) <= SIBLING_FRESH_MS;
324
+ }
325
+
307
326
  // badge: { text, width } from lib/mark.mjs litPill, or null. It is dropped when the headline
308
327
  // would no longer fit `cols`, so the plain headline stays the fallback at every width.
309
- export function renderCard(card, { badge = null, cols = Infinity } = {}) {
328
+ // dress: { caps } paints the thread rows in the sunset's colours (a truecolor terminal with room for the scene); the
329
+ // words and widths stay the same.
330
+ export function renderCard(card, { badge = null, cols = Infinity, dress = null } = {}) {
310
331
  const out = [];
311
332
  const color = !card.noColor;
312
333
  const plainRest = headlineFor(card, false).length - 'LIT · '.length;
@@ -317,11 +338,17 @@ export function renderCard(card, { badge = null, cols = Infinity } = {}) {
317
338
  const threads = card.threads?.rows ?? [];
318
339
  if (threads.length) {
319
340
  out.push('threads:');
341
+ const current = threads.findLastIndex((thread) => !thread.sibling && thread.status === 'active');
320
342
  threads.forEach((thread, index) => {
321
343
  const branch = index === threads.length - 1 && !card.threads.omitted ? '└─' : '├─';
322
344
  const name = thread.pane ? `${thread.skill} · ${thread.pane}` : thread.skill;
323
345
  const where = thread.sibling && !thread.pane ? ` (${thread.session})` : '';
324
- out.push(`${branch} ${name}${thread.stage ? ` ${thread.stage}` : ''} ${thread.status}${thread.gauge ? ` ${thread.gauge}` : ''}${where}`);
346
+ const rail = dress ? ink([...branch].map((ch) => ({ ch, fg: neon(threads.length > 1 ? index / (threads.length - 1) : 0) }))) : branch;
347
+ // The current stage is a pill as wide as before: its letters filled, or, with round caps, the two spaces around it.
348
+ const plainStage = thread.stage ? ` ${thread.stage} ` : ' ';
349
+ const stage = dress && thread.stage && index === current ? stagePill(plainStage, dress.caps) : plainStage;
350
+ const meter = dress?.caps ? roundGauge(thread.gauge) : thread.gauge;
351
+ out.push(`${rail} ${name}${stage}${thread.status}${thread.gauge ? ` ${meter}` : ''}${where}`);
325
352
  });
326
353
  if (card.threads.omitted) out.push(`+${card.threads.omitted} more`);
327
354
  }
package/lib/sunset.mjs ADDED
@@ -0,0 +1,232 @@
1
+ // The status card's sunset, for a person's truecolor terminal only: a half-sunk sun with stars over it and a sea under
2
+ // it, painted after the end of each row's words. Words are never touched; a row with no room keeps exactly its text.
3
+ // `t` is seconds into the motion; null is the resting pose. Shapes hold still: only colours move, plus the ASCII sea,
4
+ // stars and shooting star.
5
+ import { displayWidth } from '../plugin/lib/rewind/gauge.mjs';
6
+ import { sample } from './mark.mjs';
7
+
8
+ const ESC = '\u001b';
9
+ export const MIN_COLS = 90;
10
+ export const MAX_WIDTH = 120;
11
+ export const SUN_W = 18;
12
+ export const SUN_ROWS = 3;
13
+ // The moment a single print of a working card shows. No shooting star is in flight then.
14
+ export const STILL_T = 4;
15
+ export const BRAND = Object.freeze(['#ff8f3c', '#ff2d8a']);
16
+ const STAGE = Object.freeze(['#b48cff', '#8be9fd']);
17
+ const NEON = Object.freeze(['#ff2d95', '#b48cff', '#8be9fd']);
18
+ const INK = '#0b0e14';
19
+ const TRACK = '#2a2340';
20
+ const FAINT = '#30363d';
21
+ const SLIT = '#1a1030';
22
+ const CAP = Object.freeze(['', '']);
23
+
24
+ const LOOKS = {
25
+ sunset: { sun: [['#ffd24a', '#fff0a0'], ['#ff8f3c', '#ffc15a'], ['#ff2d8a', '#ff6b8f']], sea: ['#ffdc73', '#ff9a4a', '#ff4f8b', '#b457d6', '#5a46a8'] },
26
+ turn: { sun: [['#ffc95a', '#fff0b8'], ['#ffaf3c', '#ffd98a'], ['#e08a1e', '#ffb95a']], sea: ['#ffd98a', '#ffaf3c', '#e08a1e', '#9a6420', '#5a4020'] },
27
+ };
28
+ const RAINBOW = ['#ff6b6b', '#ffaf5f', '#ffff87', '#87ff9f', '#87d7ff', '#af87ff', '#ff87d7', '#ff6b6b'];
29
+
30
+ // Who sees the scene: truecolor, not a background the terminal says is light, and wide enough.
31
+ export function sceneOn({ depth, env = process.env, cols }) {
32
+ const light = /;(7|15)$/.test(env.COLORFGBG ?? '');
33
+ return depth === 'truecolor' && !light && cols >= MIN_COLS;
34
+ }
35
+
36
+ // These terminals draw the rounded caps themselves, whatever the font.
37
+ export const roundCaps = (env = process.env) => Boolean(env.WT_SESSION) || env.TERM_PROGRAM === 'vscode';
38
+
39
+ export const motionOff = (env = process.env) => /^(off|reduced|0)$/i.test(env.LITMUSE_MOTION ?? '');
40
+
41
+ const SGR = /\u001b\[[0-9;]*m/gu;
42
+ const charCells = (ch) => Math.max(displayWidth(ch), /\p{Emoji_Presentation}/u.test(ch) ? 2 : 0);
43
+
44
+ // Cells a row's words take, or Infinity when terminals disagree about them (tabs, joined emoji, stray controls).
45
+ export function rowCells(row) {
46
+ const text = row.replace(SGR, '');
47
+ if (/[\p{Cc}‍️\p{Regional_Indicator}]/u.test(text)) return Infinity;
48
+ return [...text].reduce((sum, ch) => sum + charCells(ch), 0);
49
+ }
50
+
51
+ // A row cut into rows of at most `width` cells; the colour in force carries on. Control characters are dropped.
52
+ export function wrapRow(row, width) {
53
+ const out = [];
54
+ let text = '';
55
+ let used = 0;
56
+ let sgr = '';
57
+ for (const [token] of row.matchAll(/\u001b\[[0-9;]*m|[^]/gu)) {
58
+ if (token.startsWith(`${ESC}[`)) {
59
+ sgr = token === `${ESC}[0m` ? '' : sgr + token;
60
+ text += token;
61
+ continue;
62
+ }
63
+ if (/\p{Cc}/u.test(token)) continue;
64
+ const cells = charCells(token);
65
+ if (used + cells > width) {
66
+ out.push(sgr ? `${text}${ESC}[0m` : text);
67
+ text = sgr;
68
+ used = 0;
69
+ }
70
+ text += token;
71
+ used += cells;
72
+ }
73
+ return [...out, text];
74
+ }
75
+
76
+ // Colours mix in eight kept steps, so a frame mixes nothing twice and neighbours merge.
77
+ const kept = new Map();
78
+ export function mix(a, b, k) {
79
+ const step = Math.max(0, Math.min(8, Math.round(k * 8)));
80
+ const key = a + b + step;
81
+ if (kept.size > 4000) kept.clear();
82
+ if (!kept.has(key)) kept.set(key, sample([a, b], step / 8));
83
+ return kept.get(key);
84
+ }
85
+
86
+ const channel = (hex) => [1, 3, 5].map((i) => Number.parseInt(hex.slice(i, i + 2), 16)).join(';');
87
+ const codes = new Map();
88
+ const codeOf = ({ fg, bg, bold }) => {
89
+ const key = `${fg ?? ''}|${bg ?? ''}${bold ? 'b' : ''}`;
90
+ if (codes.size > 4000) codes.clear();
91
+ if (!codes.has(key)) codes.set(key, [bold && '1', fg && `38;2;${channel(fg)}`, bg && `48;2;${channel(bg)}`].filter(Boolean).join(';'));
92
+ return codes.get(key);
93
+ };
94
+
95
+ // Cells `{ ch, fg?, bg?, bold? }` as one string; a colour is written only where it changes.
96
+ export function ink(cells) {
97
+ let out = '';
98
+ let last = '';
99
+ for (const cell of cells) {
100
+ const code = cell ? codeOf(cell) : '';
101
+ if (code !== last) out += `${ESC}[0${code ? `;${code}` : ''}m`;
102
+ last = code;
103
+ out += cell ? cell.ch : ' ';
104
+ }
105
+ return last ? `${out}${ESC}[0m` : out;
106
+ }
107
+
108
+ // Text on a fill graded along two stops. Its first and last characters are padding, which become round caps.
109
+ export function gradedPill(text, stops, caps) {
110
+ const chars = [...text];
111
+ const last = chars.length - 1;
112
+ return ink(chars.map((ch, i) => {
113
+ const fill = sample(stops, i / last);
114
+ if (caps && (i === 0 || i === last)) return { ch: CAP[i === 0 ? 0 : 1], fg: fill };
115
+ return { ch, fg: INK, bg: fill, bold: true };
116
+ }));
117
+ }
118
+
119
+ // ` RED ` as the current stage: round caps take its two spaces, otherwise only the letters are filled.
120
+ export function stagePill(text, caps) {
121
+ if (caps) return gradedPill(text, STAGE, true);
122
+ const chars = [...text];
123
+ const span = Math.max(1, chars.length - 3);
124
+ return ink(chars.map((ch, i) => (i === 0 || i === chars.length - 1 ? null : { ch, fg: INK, bg: sample(STAGE, Math.min(1, (i - 1) / span)), bold: true })));
125
+ }
126
+
127
+ // `[▉▉░] 2/3` with its brackets as round caps on one smooth track, in the same cells. Anything else is returned as is.
128
+ export function roundGauge(text) {
129
+ const parts = /^\[([▉░]+)\](.*)$/u.exec(text);
130
+ if (!parts) return text;
131
+ const tints = [...parts[1]].map((ch, i, all) => (ch === '▉' ? sample(['#ff8f3c', '#ff2d8a'], i / all.length) : TRACK));
132
+ return ink([{ ch: CAP[0], fg: tints[0] }, ...tints.map((bg) => ({ ch: ' ', bg })), { ch: CAP[1], fg: tints.at(-1) }]) + parts[2];
133
+ }
134
+
135
+ // The neon a place on the card takes, pink to violet to cyan.
136
+ export const neon = (k) => (k < 0.5 ? mix(NEON[0], NEON[1], k * 2) : mix(NEON[1], NEON[2], k * 2 - 1));
137
+
138
+ // The dome in eighth blocks, with a thin dark slit over the second row and a thicker one over the third.
139
+ const DOME = [0, 1, 2].map((r) => Array.from({ length: SUN_W }, (_, x) => {
140
+ const d = (x - (SUN_W - 1) / 2) / (SUN_W / 2);
141
+ const fill = Math.max(0, Math.min(8, Math.round(Math.sqrt(1 - d * d) * 24) - (2 - r) * 8));
142
+ if (fill === 0) return null;
143
+ if (fill < 8) return { ch: '▁▂▃▄▅▆▇'[fill - 1] };
144
+ return r === 0 ? { ch: '█' } : { ch: r === 1 ? '▇' : '▆', bg: SLIT };
145
+ }));
146
+ // Stars as [row, cells from the sun's left edge].
147
+ const STARS = [[0, -30], [1, -24], [0, -18], [1, -13], [0, -9], [1, -5], [0, 22], [1, 25], [0, 29], [1, 32], [0, 35]];
148
+ const CLEAR = 3;
149
+
150
+ /**
151
+ * Where the scene goes on these rows: the lowest three rows in a run with room for the sun, so one long row moves the
152
+ * sun up instead of putting it out. `top` is null when there is no room anywhere. Work this out once per state, then
153
+ * paint it as often as needed.
154
+ */
155
+ export function place(rows, width) {
156
+ const ends = rows.map(rowCells);
157
+ const at = Math.round(width * 0.62);
158
+ let top = null;
159
+ for (let r = rows.length - SUN_ROWS; r >= 0 && top === null; r -= 1) {
160
+ if (at + SUN_W + 2 <= width && [0, 1, 2].every((i) => ends[r + i] + 2 <= at)) top = r;
161
+ }
162
+ return { ends, width, at, top, sea: top === null ? rows.length - 1 : top + 2 };
163
+ }
164
+
165
+ function seaCell(dx, s, stops) {
166
+ const far = Math.abs(dx);
167
+ const wave = Math.sin(far * 0.62 - s * 2.3) + 0.8 * Math.sin(dx * 0.31 + s * 1.1) + 0.6 * Math.sin(dx * 1.37 - s * 0.7);
168
+ const level = wave * 0.62 + 1.05 - far / 34;
169
+ if (level < 0.22) return null;
170
+ const hue = Math.min(3.99, far / 13);
171
+ const base = mix(stops[Math.floor(hue)], stops[Math.floor(hue) + 1], hue % 1);
172
+ return { ch: level > 1 ? '~' : level > 0.55 ? '-' : '.', fg: mix(FAINT, base, Math.min(1, 0.18 + level * 0.55)), bold: level > 1.5 };
173
+ }
174
+
175
+ /**
176
+ * The scene for one moment: a Map from row index to that row's cells, `width` long and holey; the cells before the
177
+ * row's end are always empty. `look` is sunset, turn (amber) or rainbow; `dim` is the resting card's quieter light.
178
+ */
179
+ export function paint(spot, { t = null, look = 'sunset', dim = false } = {}) {
180
+ const { ends, width, at, top, sea } = spot;
181
+ const out = new Map();
182
+ if (top === null && (t === null || sea < 0)) return out;
183
+ const s = t ?? 0;
184
+ const shade = (hex) => (dim ? mix(hex, FAINT, 0.6) : hex);
185
+ const turning = (k) => sample(RAINBOW, (((k + s / 4.8) % 1) + 1) % 1);
186
+ const stops = look === 'rainbow' ? [0, 0.15, 0.3, 0.45, 0.6].map(turning) : LOOKS[look].sea;
187
+ const row = (r) => {
188
+ if (!out.has(r)) out.set(r, new Array(width).fill(null));
189
+ return out.get(r);
190
+ };
191
+ const clear = (r, x) => x >= 0 && x < width && x - ends[r] >= CLEAR;
192
+ const mid = at + SUN_W / 2 - 0.5;
193
+ if (top !== null) {
194
+ for (const [r, dx] of STARS) {
195
+ const x = at + dx;
196
+ if (!clear(top + r, x)) continue;
197
+ const glow = 0.5 + 0.5 * Math.sin(s * 1.7 + dx * 2.1);
198
+ row(top + r)[x] = { ch: glow > 0.85 ? '*' : glow > 0.45 ? '+' : '.', fg: mix(FAINT, shade(dx % 2 ? '#a99bff' : '#ff9ad5'), 0.35 + 0.65 * glow) };
199
+ }
200
+ const dash = t === null ? 9 : s % 9;
201
+ if (dash < 1.1) {
202
+ const head = Math.round(at + SUN_W + 22 - (dash / 1.1) * 34);
203
+ ['*', '-', '-', '.'].forEach((ch, i) => {
204
+ if (clear(top, head + i)) row(top)[head + i] = { ch, fg: mix('#fff4e0', '#b457d6', i / 3), bold: i === 0 };
205
+ });
206
+ }
207
+ }
208
+ for (let x = 0; x < width; x += 1) {
209
+ const cell = clear(sea, x) ? seaCell(x - mid, s, stops) : null;
210
+ if (cell) row(sea)[x] = { ...cell, fg: shade(cell.fg) };
211
+ }
212
+ if (top !== null) {
213
+ DOME.forEach((line, r) => line.forEach((cell, x) => {
214
+ if (!cell) return;
215
+ const heat = t === null ? 0.25 : 0.5 + 0.5 * Math.sin(s * 2.1 + r * 1.5 + 0.55 * Math.sin(x * 0.8 + s * 1.6));
216
+ const fg = look === 'rainbow' ? mix(turning(x / SUN_W / 2 + r * 0.12), '#ffffff', 0.3 + 0.25 * heat) : mix(...LOOKS[look].sun[r], heat);
217
+ row(top + r)[at + x] = { ...cell, fg: shade(fg) };
218
+ }));
219
+ }
220
+ return out;
221
+ }
222
+
223
+ // Rows with the scene painted after their words; a row the scene does not reach is returned as it came.
224
+ export function paintRows(rows, width, options) {
225
+ const spot = place(rows, width);
226
+ const tails = paint(spot, options);
227
+ return rows.map((text, r) => {
228
+ const cells = tails.get(r)?.slice(spot.ends[r]);
229
+ const last = cells ? cells.findLastIndex(Boolean) : -1;
230
+ return last < 0 ? text : text + ink(cells.slice(0, last + 1));
231
+ });
232
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litfamily/litmuse",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Installer for LitMuse: skills, hooks and agents that help Meta's Muse Code plan, build, check and hand off work.",
5
5
  "keywords": [
6
6
  "muse",
@@ -42,6 +42,8 @@
42
42
  "docs/assets/card/idle.webp",
43
43
  "docs/assets/card/working.webp",
44
44
  "docs/assets/card/after.webp",
45
+ "docs/assets/card/watch.webp",
46
+ "docs/assets/card/watch-still.webp",
45
47
  "docs/assets/handoff/saved.webp",
46
48
  "docs/assets/handoff/latest.webp",
47
49
  "README.md",
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "name": "litmuse",
4
4
  "displayName": "LitMuse",
5
- "version": "0.1.19",
5
+ "version": "0.1.20",
6
6
  "description": "LitFamily workflows for Muse Code: bare lit activation, planning, evidence-bound execution, review, research, handoff and Korean prose care.",
7
7
  "compat": {
8
8
  "source": "native",