@litfamily/litmuse 0.1.18 → 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,16 @@
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
+
9
+ ## 0.1.19 — 2026-11-24
10
+
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`.
12
+ - Both READMEs explain the LIT mark (where it appears and what a terminal without colour, a pipe or a narrow window gets), that a request ending with `lit`, `lit-loop` or `litwork` works like one starting with it, and what to do when lit-team stops with `team state lock timed out`. The Korean reference now also describes the lit-loop goal question.
13
+
3
14
  ## 0.1.18 — 2026-11-24
4
15
 
5
16
  - `litmuse install`, `update`, `doctor` and `--help` now print the synthwave LIT mark above their output, and `litmuse status --card` in a truecolor terminal shows a gradient version pill on the stage card. Output to a pipe gets a plain one-line mark instead, and `doctor --json` and `status --card --json` get none.
package/README.md CHANGED
@@ -32,6 +32,11 @@ fix the date parsing bug in src/dates.js lit
32
32
  Muse sets the goal, writes a failing test, fixes the bug, checks the result and tells you what it checked.
33
33
  Most tasks need nothing more.
34
34
 
35
+ Both places work the same way. When `lit` comes last, the words before it are the task, so `fix the login redirect lit`
36
+ gets the same goal question as `lit fix the login redirect`, with "fix the login redirect" as the objective. The two run
37
+ words behave like this too: `fix the login redirect lit-loop` runs lit-loop and `add a --json flag litwork` runs
38
+ litwork, just as they would at the start.
39
+
35
40
  **The full workflow.** For a bigger job, go one step at a time. Each step leaves a file the next step reads,
36
41
  and you can skip any step you do not need.
37
42
 
@@ -166,6 +171,8 @@ The [Quick start](#quick-start) line installs LitMuse at user scope, so it is av
166
171
 
167
172
  The bottom row of the picture covers why an update may ask again, what install leaves alone, and the one file it writes only after you agree ([the rules-file block](./docs/reference.md#a-short-block-in-muses-own-rules-file)). Muse re-arms the agent approvals whenever the plugin is updated, so after an update the installer asks once more for those. In `doctor`, each capability that still waits for approval appears as `APPROVAL NEEDED` together with the exact command.
168
173
 
174
+ `install`, `update`, `doctor` and `--help` open with the synthwave LIT mark, so you can tell at a glance which tool is talking. It is drawn for the terminal it lands in: full colour in a truecolor or 256-colour terminal, the same picture without colour when colour is off (`NO_COLOR`, `TERM=dumb`, an 8-colour terminal), and the single line `LIT · muse code` when the output goes to a pipe, a log or the model's bash tool, or the window is narrower than 24 columns. `doctor --json` prints no mark.
175
+
169
176
  <details>
170
177
  <summary>Install switches</summary>
171
178
 
@@ -205,16 +212,24 @@ Read the card from top to bottom. The first line names the workflow and how long
205
212
 
206
213
  At rest the card reports no active route:
207
214
 
208
- <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>
209
216
 
210
217
  While a plan runs, the card names the route, the plan file, and the next open row:
211
218
 
212
- <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>
213
220
 
214
221
  Ticking a row moves the count and the next-row pointer:
215
222
 
216
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>
217
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. 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.
232
+
218
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).
219
234
 
220
235
  ### Automatic handoff
@@ -334,7 +349,7 @@ A prompt that starts with `lit` goes through four steps, and each one leaves som
334
349
  <details>
335
350
  <summary>The four steps, one by one</summary>
336
351
 
337
- 1. **Route.** The prompt hook reads the word after `lit` and picks the route. `lit plan` goes to lit-plan, plain `lit` goes to lit-loop, and another `lit` while that route is still running carries it on.
352
+ 1. **Route.** The prompt hook reads the word after `lit` and picks the route. `lit plan` goes to lit-plan, plain `lit` goes to lit-loop, and another `lit` while that route is still running carries it on. A request that ends with `lit` goes to lit-loop with the words before it as the task, and one that ends with `lit-loop` or `litwork` goes to that route.
338
353
  2. **Load.** Muse loads the route's skill, which may hand parts of the work to child agents such as `litmuse/lit-verifier`.
339
354
  3. **Work.** During a planning turn the PreToolUse hook lets writes land only under `plans/` and `.litmuse/`.
340
355
  4. **Review.** The work counts as done when the tests pass and someone looked at the real surface; anything nobody could check is marked unverified. While plan rows are still open, the Stop hook keeps the turn going.
@@ -395,6 +410,8 @@ To update, run the install line again. To remove everything, run `uninstall` (ad
395
410
 
396
411
  **`doctor` shows `INFO leftover`.** LitMuse ships no engine runtime any more; releases up to 0.1.11 cached them under `~/.local/share/litmuse/runtime/`, and `uninstall` never removed that folder. Nothing reads it now (an extension sets up its own engines), so delete it to free the space.
397
412
 
413
+ **lit-team stops with `team state lock timed out`.** The lit-team script takes a short lock on the team folder while it updates the team file, and a process that crashed can leave that lock behind. The next command clears it on its own: a lock with no owner record that is older than 5 seconds (or the stale window, if that is longer), a lock whose process is gone, and a lock held for more than 10 minutes, even when its process number now belongs to another program. When the message still appears, it names the lock folder and its holder, `held by pid <n> for <s> s` or `with no owner record`. A live holder is a lit-team command still running in another session, so let it finish. If nothing is running, close the other Muse sessions on this project and delete the named `.lock` folder under `.litmuse/team/<team-id>/`.
414
+
398
415
  ## Reference
399
416
 
400
417
  [docs/reference.md](./docs/reference.md) holds what a first install does not need: [every hook](./docs/reference.md#hooks), [the live record behind the card](./docs/reference.md#the-live-record-behind-the-card), and [the short block in Muse's own rules file](./docs/reference.md#a-short-block-in-muses-own-rules-file).
package/README_ko-KR.md CHANGED
@@ -27,6 +27,8 @@ src/dates.js의 날짜 파싱 버그 고쳐줘 lit
27
27
 
28
28
  Muse가 목표를 정하고, 실패하는 테스트를 쓰고, 버그를 고치고, 결과를 확인한 뒤 무엇을 확인했는지 알려 줍니다. 웬만한 작업은 이것으로 충분합니다.
29
29
 
30
+ 앞에 붙이든 끝에 붙이든 똑같이 동작합니다. `lit`이 맨 끝에 오면 그 앞의 말이 할 일이 되므로, `로그인 버튼 고쳐줘 lit`도 `lit 로그인 버튼 고쳐줘`처럼 "로그인 버튼 고쳐줘"를 목표로 삼아 목표 질문을 합니다. 실행 단어 두 개도 마찬가지입니다. `로그인 버튼 고쳐줘 lit-loop`는 lit-loop을, `--json 플래그 추가해줘 litwork`는 litwork를 앞에 붙였을 때와 똑같이 실행합니다.
31
+
30
32
  **본격적으로.** 큰 작업은 한 단계씩 밟아 갑니다. 단계마다 남긴 파일을 다음 단계가 읽고, 필요 없는 단계는 건너뛰어도 됩니다.
31
33
 
32
34
  | 단계 | 입력 | 하는 일 |
@@ -160,6 +162,8 @@ npx @litfamily/litmuse doctor
160
162
 
161
163
  그림의 맨 아래 줄은 업데이트 뒤에 다시 묻는 이유, 설치가 손대지 않는 곳, 동의를 받은 뒤에만 쓰는 파일 하나([규칙 파일 블록](./docs/reference_ko-KR.md#muse-자체-규칙-파일의-짧은-블록))를 정리했습니다. Muse는 플러그인이 업데이트될 때마다 에이전트 승인을 다시 요구하므로, 업데이트 뒤에는 설치기가 그 부분만 한 번 더 묻습니다. `doctor`에서는 아직 승인을 기다리는 항목이 `APPROVAL NEEDED`와 실행할 명령으로 표시됩니다.
162
164
 
165
+ `install`, `update`, `doctor`, `--help`는 맨 위에 신스웨이브 LIT 마크를 찍어서, 어느 도구가 말하는지 한눈에 보이게 합니다. 마크는 출력되는 터미널에 맞춰 그려집니다. truecolor나 256색 터미널에서는 컬러로, 색이 꺼져 있으면(`NO_COLOR`, `TERM=dumb`, 8색 터미널) 같은 그림이 색 없이 나옵니다. 출력이 파이프나 로그, 모델의 bash 도구로 가거나 창 폭이 24칸보다 좁으면 `LIT · muse code` 한 줄만 나옵니다. `doctor --json`에는 마크가 없습니다.
166
+
163
167
  <details>
164
168
  <summary>설치 옵션</summary>
165
169
 
@@ -199,16 +203,24 @@ Muse의 `/hud`는 켜고 끄는 고정 항목 목록이라서 플러그인 글
199
203
 
200
204
  쉴 때 카드는 활성 경로가 없다고 알립니다.
201
205
 
202
- <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>
203
207
 
204
208
  계획이 돌 때 카드는 경로와 계획 파일, 다음 행을 보여 줍니다.
205
209
 
206
- <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>
207
211
 
208
212
  행에 체크하면 개수와 다음 행 표시가 바뀝니다.
209
213
 
210
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>
211
215
 
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칸 미만에서는 계속 갱신되는 일반 카드를 보여 줍니다.
223
+
212
224
  카드는 프로젝트 밖에 있는 `~/.local/state/litmuse/` 아래 훅 기록을 읽습니다. 다른 세션을 어떻게 보여 주는지는 [참고 자료](./docs/reference_ko-KR.md#카드-뒤의-실시간-기록)에 있습니다.
213
225
 
214
226
  ### 자동 핸드오프
@@ -328,7 +340,7 @@ npx @litfamily/litmuse extensions prune-backups --older-than 30 --yes
328
340
  <details>
329
341
  <summary>네 단계를 하나씩</summary>
330
342
 
331
- 1. **경로.** 프롬프트 훅이 `lit` 다음 단어를 읽고 경로를 고릅니다. `lit plan`은 lit-plan으로, 그냥 `lit`은 lit-loop으로 가고, 그 경로가 아직 도는 중에 다시 `lit`을 치면 하던 일을 이어 갑니다.
343
+ 1. **경로.** 프롬프트 훅이 `lit` 다음 단어를 읽고 경로를 고릅니다. `lit plan`은 lit-plan으로, 그냥 `lit`은 lit-loop으로 가고, 그 경로가 아직 도는 중에 다시 `lit`을 치면 하던 일을 이어 갑니다. 요청이 `lit`으로 끝나면 그 앞의 말을 할 일로 삼아 lit-loop으로 가고, `lit-loop`나 `litwork`로 끝나면 그 경로로 갑니다.
332
344
  2. **불러오기.** Muse가 그 경로의 스킬을 불러오고, 스킬은 일부를 `litmuse/lit-verifier` 같은 자식 에이전트에게 맡기기도 합니다.
333
345
  3. **작업.** 계획 턴에서는 PreToolUse 훅이 쓰기를 `plans/`와 `.litmuse/` 안으로만 받아 줍니다.
334
346
  4. **리뷰.** 테스트가 통과하고 실제 화면까지 확인해야 끝난 것으로 치고, 아무도 확인하지 못한 부분은 미확인으로 표시합니다. 계획 행이 남아 있는 동안에는 Stop 훅이 턴을 계속 이어 갑니다.
@@ -389,6 +401,8 @@ npx @litfamily/litmuse extensions prune-backups --older-than 30 --yes
389
401
 
390
402
  **`doctor`가 `INFO leftover`를 보여 줍니다.** LitMuse는 이제 엔진 런타임을 싣지 않습니다. 0.1.11까지의 릴리스는 엔진을 `~/.local/share/litmuse/runtime/`에 캐시했고 `uninstall`은 그 폴더를 지우지 않았습니다. 이제 그 폴더를 읽는 것은 없으므로(확장은 자기 엔진을 따로 준비합니다) 공간을 비우려면 지우세요.
391
403
 
404
+ **lit-team이 `team state lock timed out`으로 멈춥니다.** lit-team 스크립트는 팀 파일을 고치는 동안 팀 폴더에 잠깐 잠금을 걸고, 도중에 죽은 프로세스는 그 잠금을 남길 수 있습니다. 남은 잠금은 다음 명령이 알아서 치웁니다. 주인 기록 없이 5초(stale 기간이 더 길면 그 기간)보다 오래된 잠금, 프로세스가 사라진 잠금, 10분 넘게 잡힌 잠금이 대상이고, 마지막 것은 그 프로세스 번호를 지금 다른 프로그램이 쓰고 있어도 치웁니다. 그래도 메시지가 나오면 잠금 폴더와 잡고 있는 쪽이 함께 적힙니다(`held by pid <n> for <s> s` 또는 `with no owner record`). 살아 있는 쪽은 다른 세션에서 아직 도는 lit-team 명령이니 끝나기를 기다리세요. 도는 것이 없다면 이 프로젝트의 다른 Muse 세션을 닫고, `.litmuse/team/<team-id>/` 아래 적힌 `.lock` 폴더를 지우면 됩니다.
405
+
392
406
  ## 참고 자료
393
407
 
394
408
  처음 설치할 때 필요 없는 내용은 [docs/reference_ko-KR.md](./docs/reference_ko-KR.md)에 있습니다: [훅별 설명](./docs/reference_ko-KR.md#훅), [카드 뒤의 실시간 기록](./docs/reference_ko-KR.md#카드-뒤의-실시간-기록), [Muse 자체 규칙 파일의 짧은 블록](./docs/reference_ko-KR.md#muse-자체-규칙-파일의-짧은-블록).
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.18",
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.18",
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",
@@ -25,6 +25,9 @@ const MAX_OWNER_BYTES = 4096;
25
25
  // No team update holds the lock for more than a moment, so an owner older than this crashed even when its recorded pid
26
26
  // now belongs to another live process (pids are reused, often on WSL).
27
27
  const MAX_HOLD_MS = 10 * 60 * 1000;
28
+ // A folder with no owner record may be one another process created a moment ago and is still writing; it is judged
29
+ // only after this long, whatever stale window the caller passed.
30
+ const OWNERLESS_GRACE_MS = 5_000;
28
31
  const sleepSync = (milliseconds) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds);
29
32
  const monotonicNowMs = () => Number(process.hrtime.bigint()) / 1_000_000;
30
33
 
@@ -284,9 +287,9 @@ export const acquireOwnerLock = (lockDir, { timeoutMs = 500, staleMs = 30_000 }
284
287
  const incumbent = readOwnerLock(lockDir);
285
288
  if (!incumbent && lockDirectory) {
286
289
  // A holder that died between creating the folder and writing its owner record left a lock nobody can judge;
287
- // once it is older than the stale window it is moved aside and the acquisition retried.
290
+ // once it is older than the stale window (and the grace) it is moved aside and the acquisition retried.
288
291
  const folder = lstatSync(lockDir, { throwIfNoEntry: false });
289
- if (folder && Date.now() - folder.mtimeMs >= staleAfter) {
292
+ if (folder && Date.now() - folder.mtimeMs >= Math.max(staleAfter, OWNERLESS_GRACE_MS)) {
290
293
  try {
291
294
  if (removeVerifiedPath(lockDir, lockDirectory, undefined, `${lockDir}.stale.ownerless.${randomUUID()}`,
292
295
  (quarantine) => !readOwnerLock(quarantine))) continue;