@litfamily/litmuse 0.1.17 → 0.1.19

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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.19 — 2026-11-24
4
+
5
+ - 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`.
6
+ - 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.
7
+
8
+ ## 0.1.18 — 2026-11-24
9
+
10
+ - `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.
11
+ - A request that ends with `lit` (`로그인 버튼 고쳐줘 lit`, `… 부탁해 lit`) now gets the lit-loop goal question, with the words before `lit` as the objective. A closing `lit-loop` or `litwork` runs that route the same way it does at the start. `lit`, `lit continue` and `lit resume` alone still ask nothing.
12
+ - A lit-team state lock left by a crashed process no longer blocks the team forever: a lock with no readable owner record, a takeover claim a crashed contender left behind, and a lock held for more than ten minutes (even when its pid now belongs to another process) are reclaimed. A timeout now names the lock path and its holder.
13
+ - The hook code changed, so Muse asks you to approve the LitMuse hooks again after the update.
14
+
3
15
  ## 0.1.17 — 2026-11-22
4
16
 
5
17
  - Both READMEs now open with a plain one-line pitch, a short before-and-after story and a "Two ways to use it" section: the easy way is your usual request with `lit` at the start or the end; the full workflow is a six-step table (explore, clarify, plan, build, review, hand off) with the line to type for each step, followed by the one install line.
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
 
@@ -215,6 +222,8 @@ 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. 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
+
218
227
  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
228
 
220
229
  ### Automatic handoff
@@ -334,7 +343,7 @@ A prompt that starts with `lit` goes through four steps, and each one leaves som
334
343
  <details>
335
344
  <summary>The four steps, one by one</summary>
336
345
 
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.
346
+ 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
347
  2. **Load.** Muse loads the route's skill, which may hand parts of the work to child agents such as `litmuse/lit-verifier`.
339
348
  3. **Work.** During a planning turn the PreToolUse hook lets writes land only under `plans/` and `.litmuse/`.
340
349
  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 +404,8 @@ To update, run the install line again. To remove everything, run `uninstall` (ad
395
404
 
396
405
  **`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
406
 
407
+ **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>/`.
408
+
398
409
  ## Reference
399
410
 
400
411
  [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
 
@@ -209,6 +213,8 @@ Muse의 `/hud`는 켜고 끄는 고정 항목 목록이라서 플러그인 글
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<버전>` 알약도 붙습니다. `/lit-status`가 모델의 bash 도구로 카드를 돌릴 때나 색이 꺼져 있을 때는 원래의 `LIT ·` 머리줄이 그대로 남고, `--json`은 기록만 출력합니다.
217
+
212
218
  카드는 프로젝트 밖에 있는 `~/.local/state/litmuse/` 아래 훅 기록을 읽습니다. 다른 세션을 어떻게 보여 주는지는 [참고 자료](./docs/reference_ko-KR.md#카드-뒤의-실시간-기록)에 있습니다.
213
219
 
214
220
  ### 자동 핸드오프
@@ -328,7 +334,7 @@ npx @litfamily/litmuse extensions prune-backups --older-than 30 --yes
328
334
  <details>
329
335
  <summary>네 단계를 하나씩</summary>
330
336
 
331
- 1. **경로.** 프롬프트 훅이 `lit` 다음 단어를 읽고 경로를 고릅니다. `lit plan`은 lit-plan으로, 그냥 `lit`은 lit-loop으로 가고, 그 경로가 아직 도는 중에 다시 `lit`을 치면 하던 일을 이어 갑니다.
337
+ 1. **경로.** 프롬프트 훅이 `lit` 다음 단어를 읽고 경로를 고릅니다. `lit plan`은 lit-plan으로, 그냥 `lit`은 lit-loop으로 가고, 그 경로가 아직 도는 중에 다시 `lit`을 치면 하던 일을 이어 갑니다. 요청이 `lit`으로 끝나면 그 앞의 말을 할 일로 삼아 lit-loop으로 가고, `lit-loop`나 `litwork`로 끝나면 그 경로로 갑니다.
332
338
  2. **불러오기.** Muse가 그 경로의 스킬을 불러오고, 스킬은 일부를 `litmuse/lit-verifier` 같은 자식 에이전트에게 맡기기도 합니다.
333
339
  3. **작업.** 계획 턴에서는 PreToolUse 훅이 쓰기를 `plans/`와 `.litmuse/` 안으로만 받아 줍니다.
334
340
  4. **리뷰.** 테스트가 통과하고 실제 화면까지 확인해야 끝난 것으로 치고, 아무도 확인하지 못한 부분은 미확인으로 표시합니다. 계획 행이 남아 있는 동안에는 Stop 훅이 턴을 계속 이어 갑니다.
@@ -389,6 +395,8 @@ npx @litfamily/litmuse extensions prune-backups --older-than 30 --yes
389
395
 
390
396
  **`doctor`가 `INFO leftover`를 보여 줍니다.** LitMuse는 이제 엔진 런타임을 싣지 않습니다. 0.1.11까지의 릴리스는 엔진을 `~/.local/share/litmuse/runtime/`에 캐시했고 `uninstall`은 그 폴더를 지우지 않았습니다. 이제 그 폴더를 읽는 것은 없으므로(확장은 자기 엔진을 따로 준비합니다) 공간을 비우려면 지우세요.
391
397
 
398
+ **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` 폴더를 지우면 됩니다.
399
+
392
400
  ## 참고 자료
393
401
 
394
402
  처음 설치할 때 필요 없는 내용은 [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
@@ -15,6 +15,7 @@ import { buildCard, renderCard } from '../lib/stage-card.mjs';
15
15
  import { styleCommand } from '../lib/style.mjs';
16
16
  import { runRewindCli } from '../plugin/lib/rewind/collect.mjs';
17
17
  import { extensionsCommand } from '../lib/extensions.mjs';
18
+ import { colourDepth, litPill, markFor, pillWidth, termColumns } from '../lib/mark.mjs';
18
19
 
19
20
  const HELP = `LitMuse ${packageVersion()}: LitFamily workflows for Meta's Muse Code
20
21
 
@@ -93,6 +94,7 @@ async function main() {
93
94
  }
94
95
  if (command === 'extensions') return extensionsCommand({ args, flags, env, print });
95
96
  if (flags.help || command === 'help') {
97
+ print(markFor({ env }));
96
98
  print(HELP);
97
99
  return 0;
98
100
  }
@@ -103,10 +105,12 @@ async function main() {
103
105
  switch (command) {
104
106
  case 'install':
105
107
  case 'update':
108
+ print(markFor({ env }));
106
109
  return install({ env, flags, interactive, ask, print });
107
110
  case 'uninstall':
108
111
  return uninstall({ env, flags, interactive, print });
109
112
  case 'doctor':
113
+ if (!flags.json) print(markFor({ env }));
110
114
  return doctor({ env, flags, print });
111
115
  case 'models':
112
116
  return models({ env, flags, print });
@@ -122,7 +126,17 @@ async function main() {
122
126
  case 'status': {
123
127
  if (flags.card) {
124
128
  const card = buildCard({ cwd: process.cwd(), env });
125
- print(flags.json ? JSON.stringify(card, null, 2) : renderCard(card));
129
+ if (flags.json) {
130
+ print(JSON.stringify(card, null, 2));
131
+ return 0;
132
+ }
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 }) }));
126
140
  return 0;
127
141
  }
128
142
  const st = stageState(paths(env));
package/lib/mark.mjs ADDED
@@ -0,0 +1,130 @@
1
+ // The synthwave LIT mark and the LIT pill, for the person at the terminal only: install, doctor and a
2
+ // TTY `status --card`; piped, install and doctor get the one plain line. Hooks, context files and command text never call it: what they print is
3
+ // model-visible.
4
+ import { MONO_ROWS, PIXEL_ROWS, SHARED_COLOURS } from './synthwave-data.mjs';
5
+
6
+ export const HOST = 'muse code';
7
+ // LitMuse chrome: peach at the top of each letter, plum at the base.
8
+ export const CHROME = Object.freeze(['#fff1e6', '#ffc29e', '#ff7a59', '#ffffff', '#ffd6e7', '#3b0a2a']);
9
+ const TAGLINE = Object.freeze(['#8be9fd', '#ff2d95', '#ffd23f']);
10
+ const EDGE = '#ffffff';
11
+ const PILL_INK = '#0b0e14';
12
+ export const SIZES = Object.freeze([['B-L', 76], ['B-M', 44], ['B-S', 24]]);
13
+ export const FALLBACK = `LIT · ${HOST}`;
14
+
15
+ const ESC = '\u001b';
16
+ const rgb = (hex) => [1, 3, 5].map((i) => Number.parseInt(hex.slice(i, i + 2), 16));
17
+
18
+ // Piecewise-linear sample of a stop list at t in [0, 1].
19
+ export function sample(stops, t) {
20
+ const span = stops.length - 1;
21
+ const i = Math.min(span - 1, Math.floor(t * span));
22
+ const f = t * span - i;
23
+ const a = rgb(stops[i]);
24
+ const b = rgb(stops[i + 1]);
25
+ return `#${a.map((v, k) => Math.round(v + (b[k] - v) * f).toString(16).padStart(2, '0')).join('')}`;
26
+ }
27
+
28
+ const pixel = (sym) => {
29
+ if (sym === ' ') return null;
30
+ if (sym >= 'a' && sym <= 'l') return sample(CHROME, (sym.charCodeAt(0) - 97) / 11);
31
+ if (sym === 'm') return EDGE;
32
+ return SHARED_COLOURS[sym] ?? null;
33
+ };
34
+
35
+ const cube = (hex) => {
36
+ const [r, g, b] = rgb(hex).map((v) => Math.round((v / 255) * 5));
37
+ return 16 + 36 * r + 6 * g + b;
38
+ };
39
+ const sgr = (hex, layer, depth) => (depth === 'truecolor'
40
+ ? `${layer === 'fg' ? 38 : 48};2;${rgb(hex).join(';')}`
41
+ : `${layer === 'fg' ? 38 : 48};5;${cube(hex)}`);
42
+
43
+ // truecolor, 256 or none. NO_COLOR, a pipe or a dumb terminal mean none; a plain 8/16-colour
44
+ // terminal also gets none, since the mark needs at least the 256-colour cube.
45
+ export function colourDepth({ env = process.env, isTTY = process.stdout.isTTY } = {}) {
46
+ if (env.NO_COLOR || !isTTY || env.TERM === 'dumb') return 'none';
47
+ if (/^(truecolor|24bit)$/i.test(env.COLORTERM ?? '')) return 'truecolor';
48
+ if (/256/.test(env.TERM ?? '')) return '256';
49
+ return 'none';
50
+ }
51
+
52
+ // Terminal width in cells; unknown counts as 80.
53
+ export function termColumns({ env = process.env, stream = process.stdout } = {}) {
54
+ const cols = Number(stream?.columns) || Number.parseInt(env.COLUMNS ?? '', 10);
55
+ return Number.isFinite(cols) && cols > 0 ? cols : 80;
56
+ }
57
+
58
+ export function markSize(cols) {
59
+ const width = Number.isFinite(cols) && cols > 0 ? cols : 80;
60
+ return SIZES.find(([, min]) => width >= min)?.[0] ?? null;
61
+ }
62
+
63
+ // One coloured row: cells are [glyph, fg, bg]; an SGR is written only when the colours change.
64
+ const paintRow = (cells, depth) => {
65
+ let out = '';
66
+ let last = '';
67
+ for (const [glyph, fg, bg] of cells) {
68
+ const codes = [fg && sgr(fg, 'fg', depth), bg && sgr(bg, 'bg', depth)].filter(Boolean).join(';');
69
+ if (codes !== last) {
70
+ out += `${ESC}[0m${codes ? `${ESC}[${codes}m` : ''}`;
71
+ last = codes;
72
+ }
73
+ out += glyph;
74
+ }
75
+ return last ? `${out}${ESC}[0m` : out;
76
+ };
77
+
78
+ const artRows = (size, depth) => {
79
+ const rows = PIXEL_ROWS[size];
80
+ const out = [];
81
+ for (let y = 0; y < rows.length; y += 2) {
82
+ const cells = [...rows[y]].map((sym, x) => {
83
+ const top = pixel(sym);
84
+ const bottom = pixel(rows[y + 1][x]);
85
+ if (top === bottom) return [' ', null, top];
86
+ if (top === null) return ['▄', bottom, null];
87
+ return ['▀', top, bottom];
88
+ });
89
+ out.push(paintRow(cells, depth));
90
+ }
91
+ return out;
92
+ };
93
+
94
+ const tagline = (width, depth) => {
95
+ const pad = ' '.repeat(Math.max(0, Math.floor((width - FALLBACK.length) / 2)));
96
+ if (depth === 'none') return `${pad}${FALLBACK}`;
97
+ const glyphs = [...FALLBACK];
98
+ return pad + paintRow(glyphs.map((g, i) => [g, g === ' ' ? null : sample(TAGLINE, i / (glyphs.length - 1)), null]), depth);
99
+ };
100
+
101
+ // The mark as printable rows for `cols` cells at `depth`: the art, then one centred tagline.
102
+ // Below 24 columns it is the single plain line.
103
+ export function markRows({ cols = 80, depth = 'none' } = {}) {
104
+ const size = markSize(cols);
105
+ if (!size) return [FALLBACK];
106
+ const art = depth === 'none' ? [...MONO_ROWS[size]] : artRows(size, depth);
107
+ return [...art, tagline(PIXEL_ROWS[size][0].length, depth)];
108
+ }
109
+
110
+ // The mark for this process's stdout, as one string ending in a blank line. When stdout is not a
111
+ // terminal (a pipe, the model's bash tool, a CI log) it is only the plain line: art is for people.
112
+ export function markFor({ env = process.env, stream = process.stdout } = {}) {
113
+ if (stream?.isTTY !== true) return `${FALLBACK}\n`;
114
+ const rows = markRows({ cols: termColumns({ env, stream }), depth: colourDepth({ env, isTTY: stream?.isTTY }) });
115
+ return `${rows.join('\n')}\n`;
116
+ }
117
+
118
+ // The LIT pill: bold dark ink on a gradient from chrome stop 1 to stop 4. Truecolor only; at any
119
+ // other depth it is null and the caller keeps its plain text.
120
+ export const pillLabel = (version) => ` 🔥LIT v${version} `;
121
+ export function litPill(version, depth) {
122
+ if (depth !== 'truecolor') return null;
123
+ const glyphs = [...pillLabel(version)];
124
+ const ink = rgb(PILL_INK).join(';');
125
+ const body = glyphs.map((g, i) => `${ESC}[48;2;${rgb(sample([CHROME[1], CHROME[4]], glyphs.length > 1 ? i / (glyphs.length - 1) : 0)).join(';')}m${g}`).join('');
126
+ return `${ESC}[1;38;2;${ink}m${body}${ESC}[0m`;
127
+ }
128
+
129
+ // Display width of the pill: the flame is two cells wide.
130
+ export const pillWidth = (version) => [...pillLabel(version)].length + 1;
@@ -260,12 +260,14 @@ const paint = (code, text, color) => (color ? `\u001b[${code}m${text}\u001b[0m`
260
260
  const waitingOf = (card) => (card.threads?.rows ?? []).some((row) => row.status === 'paused')
261
261
  || (card.lanes ?? []).some((lane) => lane.status === 'failed');
262
262
 
263
- const headlineFor = (card, color) => {
264
- if (!card.active) return 'LIT · no active route in this workspace';
263
+ // With a pill (truecolor TTY only) the pill stands in for the leading `LIT · `.
264
+ const headlineFor = (card, color, pill = null) => {
265
+ const lit = (rest, style = (s) => s) => (pill ? `${pill} ${style(rest)}` : style(`LIT · ${rest}`));
266
+ if (!card.active) return lit('no active route in this workspace');
265
267
  const route = card.route ?? 'lit-loop';
266
- if (waitingOf(card)) return paint('33;1', `LIT · ${route} · YOUR TURN`, color);
267
- if (route === 'lit-adhd') return color ? rainbowLine('LIT · lit-adhd · brief on screen') : 'LIT · lit-adhd · brief on screen';
268
- return `LIT · ${route}${card.activeMs !== null ? ` · active ${fmtDuration(card.activeMs)}` : ''}${card.kind && card.kind !== 'ignite' ? ` (${card.kind})` : ''}`;
268
+ if (waitingOf(card)) return lit(`${route} · YOUR TURN`, (s) => paint('33;1', s, color));
269
+ if (route === 'lit-adhd') return lit('lit-adhd · brief on screen', color ? rainbowLine : undefined);
270
+ return lit(`${route}${card.activeMs !== null ? ` · active ${fmtDuration(card.activeMs)}` : ''}${card.kind && card.kind !== 'ignite' ? ` (${card.kind})` : ''}`);
269
271
  };
270
272
 
271
273
  // Canonical review-lane display names, in REVIEW_LANES order; the strip reads the same
@@ -302,10 +304,14 @@ const burstOf = (card, now) => {
302
304
  return null;
303
305
  };
304
306
 
305
- export function renderCard(card) {
307
+ // badge: { text, width } from lib/mark.mjs litPill, or null. It is dropped when the headline
308
+ // would no longer fit `cols`, so the plain headline stays the fallback at every width.
309
+ export function renderCard(card, { badge = null, cols = Infinity } = {}) {
306
310
  const out = [];
307
311
  const color = !card.noColor;
308
- out.push(headlineFor(card, color));
312
+ const plainRest = headlineFor(card, false).length - 'LIT · '.length;
313
+ const pill = badge && color && badge.width + 1 + plainRest <= cols ? badge.text : null;
314
+ out.push(headlineFor(card, color, pill));
309
315
  if (card.restartTo) out.push(`restart to ${card.restartTo}: LitMuse was updated after this session loaded it`);
310
316
  if (!card.active && card.idle) out.push('idle — say `lit adhd` for the cross-session brief');
311
317
  const threads = card.threads?.rows ?? [];
@@ -0,0 +1,185 @@
1
+ // Generated from the LitFamily synthwave spec; do not edit by hand. lib/mark.mjs draws it and
2
+ // test/mark.test.mjs recomputes SPEC_DIGEST over these rows.
3
+ export const SPEC_DIGEST = "f063a0cefb969db40c0fc436742240912d895d43c3013d35782320befc0a2b86";
4
+
5
+ export const SHARED_COLOURS = Object.freeze({
6
+ "0": "#331144",
7
+ "1": "#ff5555",
8
+ "2": "#ff5566",
9
+ "3": "#ff4477",
10
+ "4": "#ff3388",
11
+ "5": "#ffbbee",
12
+ "6": "#ff3399",
13
+ "7": "#110022",
14
+ "8": "#ff4499",
15
+ "9": "#220022",
16
+ "!": "#111122",
17
+ "#": "#88eeff",
18
+ "$": "#111111",
19
+ "%": "#ffffff",
20
+ "&": "#111133",
21
+ "(": "#ffcc44",
22
+ ")": "#221133",
23
+ "*": "#ffbb44",
24
+ "+": "#ffaa33",
25
+ ",": "#ff9933",
26
+ "-": "#ff8833",
27
+ ".": "#ff7733",
28
+ "/": "#ff6633",
29
+ ":": "#ff44aa",
30
+ ";": "#220033",
31
+ "<": "#ff55aa",
32
+ "=": "#ff66bb",
33
+ ">": "#ff6644",
34
+ "?": "#ff4466",
35
+ "@": "#ff77cc",
36
+ "A": "#ffaa44",
37
+ });
38
+
39
+ export const PIXEL_ROWS = Object.freeze({
40
+ "B-L": Object.freeze([
41
+ "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#!!!!!!",
42
+ "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
43
+ "!!!!!!!!!!!!!!!!!!!!!!!!!#!!!!!!!!!!!!!#!!!!!!!!!!!!!!!!!!!!!#!!!!!!!!!!!!!!",
44
+ "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
45
+ "!!!!#!!!!!!!!mmmmmm!!!!!!!!!!!!mmmmmmmmmm!!!!mmmmmmmmmmmmmmmmmm!!!!!!!!!!!!!",
46
+ "!!!!!!!!!!!!!mbbbbb$!!!!!!!!%!!mbbbbbbbbb$!!!mbbbbbbbbbbbbbbbbb$!!!!!!!!!!!!",
47
+ "!!!!!!!!!!!!!mbbbbb$!#!!!!!!!!!mbbbbbbbbb$!!!mbbbbbbbbbbbbbbbbb$!!!!!!!%!!!!",
48
+ "!!!!!!!!!!!!!mccccc$!!!!!!!!!!!mccccccccc$!!!mccccccccccccccccc$!!!!!!!!!!!!",
49
+ "&&&&&&&&&&&&&mccccc$&&&&&&&&&&&&$mccccc$$$&&&mccccccccccccccccc$&&&&&&&&&&&&",
50
+ "&&&&&&&&&&&&&mddddd$&&&&&%&&&&&&&mddddd$&&&&&mddddddddddddddddd$&&&&&&&&&&&&",
51
+ "&&&&&&&&&&&&&mddddd$&&&&&&&&&&&&&mddddd$&&&&&&$$$$$mddddd$$$$$$$&%&&&&&&&&&&",
52
+ "&&&&&&&&&&&&&meeeee$&&&&&&%&&&&&&meeeee$&%&&&&&&&&&meeeee$&&&&&&&&&&&&%&&&&&",
53
+ "&&&&&&&&&&&&&meeeee$&&&&&%&&&&&&&meeeee$((((&&&&&&&meeeee$&&&&&&&&&&&&&&&&&&",
54
+ ")))))))))))))mfffff$)))))))))))**mfffff$******)))))mfffff$))))))))))))))))))",
55
+ ")))))))))))))mfffff$)))))))))++++mfffff$++++++++)))mfffff$))))))))))))))))))",
56
+ "#))))))))))))mggggg$)))))))),,,,,mggggg$,,,,,,,,,))mggggg$))))))))))))))))))",
57
+ ")))))))))))))mggggg$)))))))------mggggg$----------)mggggg$))))))))))))))))))",
58
+ ")))))))))))))mhhhhh$))))))-------mhhhhh$-----------mhhhhh$))))))))))))))))))",
59
+ ")))))))))))))mhhhhh$)))))).......mhhhhh$...........mhhhhh$))))))))))))))))))",
60
+ ")))))))))))))miiiii$)))))////////miiiii$///////////miiiii$))))))))))))))))))",
61
+ ")))))))))))))miiiiimmmmmmmm))))))miiiii$)))))))))))miiiii$))))))))))))))))))",
62
+ "0000000000000mjjjjjjjjjjjjj$11111mjjjjj$11111111111mjjjjj$000000000000000000",
63
+ "0000000000000mjjjjjjjjjjjjj$222mmjjjjjjmm2222222222mjjjjj$000000000000000000",
64
+ "0000000000000mkkkkkkkkkkkkk$000mkkkkkkkkk$000000000mkkkkk$000000000000000000",
65
+ "0000000000000mkkkkkkkkkkkkk$333mkkkkkkkkk$333333333mkkkkk$000000000000000000",
66
+ "0000000000000mlllllllllllll$444mlllllllll$444444444mlllll$000000000000000000",
67
+ "00000000000000$$$$$$$$$$$$$$0000$$$$$$$$$$0000000000$$$$$$000000000000000000",
68
+ "5555555555555555555555555555555555555555555555555555555555555555555555555555",
69
+ "6666666666666666666666666666666666666666666666666666666666666666666666666666",
70
+ "7777777777777777677676776767677676776767677676776767677676776777777777777777",
71
+ "8888888888886886886886886886868868868868868868868688688688688688688888888888",
72
+ "7777777767767776776776777677677677767767767776776776777677677677767767777777",
73
+ "9999699969996996999699969996996999699969996999699699969996999699699969996999",
74
+ "6:::6:::6::::6:::6:::6:::6::::6:::6:::6:::6:::6::::6:::6:::6:::6::::6:::6:::",
75
+ "6999969999699969999699996999969996999969999699969999699996999969996999969999",
76
+ ";;6;;;;6;;;;6;;;;6;;;;6;;;;;6;;;;6;;;;6;;;;6;;;;6;;;;;6;;;;6;;;;6;;;;6;;;;6;",
77
+ ";;;;6;;;;;6;;;;6;;;;;6;;;;;6;;;;6;;;;;6;;;;;6;;;;6;;;;;6;;;;;6;;;;6;;;;;6;;;",
78
+ "<6<<<<<<6<<<<<6<<<<<6<<<<<6<<<<<6<<<<<6<<<<<6<<<<<6<<<<<6<<<<<6<<<<<6<<<<<<6",
79
+ ";;;;;6;;;;;;6;;;;;6;;;;;;6;;;;;6;;;;;;6;;;;;;6;;;;;6;;;;;;6;;;;;6;;;;;;6;;;;",
80
+ ";;;6;;;;;;6;;;;;;6;;;;;;6;;;;;;6;;;;;;6;;;;;;6;;;;;;6;;;;;;6;;;;;;6;;;;;;6;;",
81
+ ";6;;;;;;6;;;;;;;6;;;;;;6;;;;;;;6;;;;;;6;;;;;;6;;;;;;;6;;;;;;6;;;;;;;6;;;;;;6",
82
+ ";;;;;;6;;;;;;;6;;;;;;;6;;;;;;;6;;;;;;;6;;;;;;;6;;;;;;;6;;;;;;;6;;;;;;;6;;;;;",
83
+ "====6========6=======6========6=======6=======6========6=======6========6===",
84
+ ";;;6;;;;;;;6;;;;;;;;6;;;;;;;;6;;;;;;;;6;;;;;;;;6;;;;;;;;6;;;;;;;;6;;;;;;;6;;",
85
+ ";6;;;;;;;;6;;;;;;;;6;;;;;;;;;6;;;;;;;;6;;;;;;;;6;;;;;;;;;6;;;;;;;;6;;;;;;;;6",
86
+ ";;;;;;;;;6;;;;;;;;6;;;;;;;;;6;;;;;;;;;6;;;;;;;;;6;;;;;;;;;6;;;;;;;;6;;;;;;;;",
87
+ ]),
88
+ "B-M": Object.freeze([
89
+ "#!!!!!!!!!!!!!!!!!!!!%!!!!%#!!!!!!!!!!%!!!!!",
90
+ "!!!#!!!!!!!!!!%!!!!!!!!!!!!!!!!!%!!!!!!!!!!!",
91
+ "#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
92
+ "!!!#!!!!mmm!!!!!#!mmmmm!!!mmmmmmmmm!!!%#!!!!",
93
+ "!!!!!!!!mbb$!!!!!!mbbbb$!!mbbbbbbbb$!!!!!!!!",
94
+ "&&&&&&&&mcc$&&&&&&&mcc$$&&mcccccccc$&&&&&&&&",
95
+ "&&&&&&&&mdd$&&&&&&*mdd$****$$mdd$$$$&&&&&&&&",
96
+ "))))))))mee$)))))++mee$+++++)mee$)))))))))))",
97
+ "))))))))mgg$))))---mgg$------mgg$)))))))))))",
98
+ "))))))))mhh$)))....mhh$......mhh$)))))))))))",
99
+ "))))))))mii$))>>>>>mii$>>>>>>mii$)))))))))))",
100
+ "))))))))mjjmmmm))))mjj$))))))mjj$)))))))))))",
101
+ "00000000mkkkkkk$??mkkkm??????mkk$00000000000",
102
+ "00000000mllllll$44mllll$44444mll$00000000000",
103
+ "000000000$$$$$$$000$$$$$000000$$$00000000000",
104
+ "55555555555555555555555555555555555555555555",
105
+ "66666666666666666666666666666666666666666666",
106
+ "77776767676767676767676767676767676767676777",
107
+ "6::6:6:6::6:6::6:6::6:6:6::6:6::6:6::6:6:6::",
108
+ "99699699696996996996996996996996996969969969",
109
+ ";;6;;6;;;6;;6;;6;;;6;;6;;6;;;6;;6;;6;;;6;;6;",
110
+ "===6===6===6==6===6===6===6===6==6===6===6==",
111
+ ";6;;;6;;;6;;;6;;;;6;;;6;;;6;;;;6;;;6;;;6;;;6",
112
+ ";;;6;;;;6;;;;6;;;6;;;;6;;;;6;;;6;;;;6;;;;6;;",
113
+ ";6;;;;6;;;;;6;;;;6;;;;6;;;;6;;;;6;;;;;6;;;;6",
114
+ "@@@@@6@@@@@6@@@@6@@@@@6@@@@@6@@@@6@@@@@6@@@@",
115
+ ]),
116
+ "B-S": Object.freeze([
117
+ "!!!!!!!%!!!!#!!!!!!!!!!!",
118
+ "!%!!!!!!!!!!!!!!!!!!!!#!",
119
+ "!!!!mm!!!mmmm!mmmmmm!!!!",
120
+ "&&&&mc$&&&mc$$mccccc$&&&",
121
+ "&&&&me$&&Ame$AA$me$$$&&&",
122
+ "))#)mg$)--mg$---mg$)))))",
123
+ "))))mh$)))mh$)))mh$)))%)",
124
+ "))))mjmm11mj$111mj$)))))",
125
+ "0000mlll$mllm333ml$00000",
126
+ "00000$$$$0$$$$000$$00000",
127
+ "555555555555555555555555",
128
+ "6<66<6<6<66<6<66<6<6<66<",
129
+ "6;6;;6;6;;6;6;6;;6;6;;6;",
130
+ "6@@6@@6@@6@@6@@6@@6@@6@@",
131
+ ]),
132
+ });
133
+
134
+ export const MONO_ROWS = Object.freeze({
135
+ "B-L": Object.freeze([
136
+ " ·",
137
+ " · · ·",
138
+ " · ██████ · ██████████ ██████████████████",
139
+ " ██████ · ██████████ ██████████████████ ·",
140
+ " ██████ · ██████ ██████████████████",
141
+ " ██████ · ██████ · ██████ · ·",
142
+ " ██████ · ░░██████░░░░░░░ ██████",
143
+ "· ██████ ░░░░░██████░░░░░░░░░░ ██████",
144
+ " ██████ ░░░░░░░██████░░░░░░░░░░░░██████",
145
+ " ██████ ░░░░░░░░██████░░░░░░░░░░░░██████",
146
+ " ██████████████░░░░░░██████░░░░░░░░░░░░██████",
147
+ " ██████████████░░░░██████████░░░░░░░░░░██████",
148
+ " ██████████████░░░░██████████░░░░░░░░░░██████",
149
+ "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
150
+ " ╱ ╱ ╱ ╱ ╱ │╲ ╲ ╲ ╲ ╲",
151
+ "────────────────────────┼──┼──┼─┼──┼──┼─┼──┼─┼──┼──┼────────────────────────",
152
+ " ╱ ╱ ╱ ╱ ╱ │ ╲ ╲ ╲ ╲ ╲",
153
+ "──────────────────┼───┼───┼───┼───┼───┼──┼───┼───┼───┼───┼──────────────────",
154
+ " ╱ ╱ ╱ ╱ ╱ │ ╲ ╲ ╲ ╲ ╲",
155
+ "────────────┼────┼────┼────┼────┼─────┼────┼────┼────┼────┼────┼────────────",
156
+ " ╱ ╱ ╱ ╱ ╱ │ ╲ ╲ ╲ ╲ ╲",
157
+ "──────┼─────┼──────┼─────┼─────┼──────┼─────┼─────┼─────┼──────┼─────┼──────",
158
+ "───┼──────┼──────┼──────┼──────┼──────┼─────┼──────┼──────┼──────┼──────┼───",
159
+ ]),
160
+ "B-M": Object.freeze([
161
+ "· · · · ·· · ·",
162
+ "· · ▄▄▄ · ▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ··",
163
+ " ███ ▀███▀ █████████",
164
+ " ███ ░░███░░░░░░░███",
165
+ " ███ ░░░░███░░░░░░░███",
166
+ " ███▄▄▄▄░░░░███░░░░░░░███",
167
+ " ███████░░░█████░░░░░░███",
168
+ "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
169
+ " ╱ ╱╱ ╱╱ │╲╲ ╲╲ ╲",
170
+ "───────────┼─┼─┼─┼─┼──┼─┼─┼─┼─┼─┼───────────",
171
+ " ╱ ╱ ╱ ╱ ╱ │ ╲ ╲ ╲ ╲ ╲",
172
+ "─────┼──┼──┼───┼──┼───┼──┼──┼───┼──┼──┼─────",
173
+ "──┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼─",
174
+ ]),
175
+ "B-S": Object.freeze([
176
+ " · · · ·",
177
+ " ██ ▀██▀ ██████",
178
+ " · ██░ ░░██░░░░██░",
179
+ " ██▄▄░░██░░░░██░ ·",
180
+ " ▀▀▀▀ ▀▀▀▀░░░▀▀░",
181
+ "━━━━━━━━━━━━━━━━━━━━━━━━",
182
+ " ╱╱ ╱╱╱ │╲╲╲ ╲╲",
183
+ "─┼─┼─┼─┼─┼──┼─┼─┼─┼─┼─┼─",
184
+ ]),
185
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litfamily/litmuse",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
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",
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "name": "litmuse",
4
4
  "displayName": "LitMuse",
5
- "version": "0.1.17",
5
+ "version": "0.1.19",
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",
@@ -251,7 +251,7 @@
251
251
  "node",
252
252
  "hooks/session-start.mjs",
253
253
  "--digest",
254
- "6baae3557423277e"
254
+ "1dffc2949834e04d"
255
255
  ],
256
256
  "timeoutMs": 5000
257
257
  },
@@ -262,7 +262,7 @@
262
262
  "node",
263
263
  "hooks/user-prompt-submit.mjs",
264
264
  "--digest",
265
- "e7d8c7705a91f519"
265
+ "a005f619d0221178"
266
266
  ],
267
267
  "timeoutMs": 5000,
268
268
  "statusMessage": "LitMuse route check"
@@ -274,7 +274,7 @@
274
274
  "node",
275
275
  "hooks/pre-tool-use.mjs",
276
276
  "--digest",
277
- "e23e84f0ffaf73fe"
277
+ "86fc0def8a86f4bd"
278
278
  ],
279
279
  "timeoutMs": 5000
280
280
  },
@@ -285,7 +285,7 @@
285
285
  "node",
286
286
  "hooks/post-tool-use.mjs",
287
287
  "--digest",
288
- "ceb33d84bc6c9357"
288
+ "3b81610dc35969d1"
289
289
  ],
290
290
  "timeoutMs": 5000
291
291
  },
@@ -296,7 +296,7 @@
296
296
  "node",
297
297
  "hooks/post-tool-use-failure.mjs",
298
298
  "--digest",
299
- "b42aa0bd4e6042e5"
299
+ "c95b4780ca00948d"
300
300
  ],
301
301
  "timeoutMs": 5000
302
302
  },
@@ -307,7 +307,7 @@
307
307
  "node",
308
308
  "hooks/stop.mjs",
309
309
  "--digest",
310
- "9ad346f20cf126ac"
310
+ "0a1a04d48d28875d"
311
311
  ],
312
312
  "timeoutMs": 5000
313
313
  },
@@ -318,7 +318,7 @@
318
318
  "node",
319
319
  "hooks/subagent-start.mjs",
320
320
  "--digest",
321
- "73ed706b85ac24ad"
321
+ "8f675c7f0b5209b3"
322
322
  ],
323
323
  "timeoutMs": 5000
324
324
  },
@@ -329,7 +329,7 @@
329
329
  "node",
330
330
  "hooks/subagent-stop.mjs",
331
331
  "--digest",
332
- "da71a8f32db174c2"
332
+ "05789f8effcb2eff"
333
333
  ],
334
334
  "timeoutMs": 5000
335
335
  },
@@ -340,7 +340,7 @@
340
340
  "node",
341
341
  "hooks/session-end.mjs",
342
342
  "--digest",
343
- "4094a21bac5cdef7"
343
+ "4fbfe88045109e11"
344
344
  ],
345
345
  "timeoutMs": 5000
346
346
  },
@@ -351,7 +351,7 @@
351
351
  "node",
352
352
  "hooks/pre-compact.mjs",
353
353
  "--digest",
354
- "5062dd39ae09db34"
354
+ "6e445d503992e185"
355
355
  ],
356
356
  "timeoutMs": 5000
357
357
  }
@@ -167,16 +167,20 @@ export function detectRoute(prompt) {
167
167
  }
168
168
 
169
169
  // A standalone `lit` or `LIT` as the last word of the prompt ("Hello! lit") activates lit-loop with the earlier text as
170
- // the task, as it does in the sibling products. Only a word of its own counts: a `lit` inside a word (literal, split),
171
- // after a path or URL character (lit-plan.md, /x/lit/y), in quotes, in a code span or fence, or followed by more text
172
- // does not.
173
- const TRAILING_LIT = /(?:^|\s)(?:lit|LIT)\s*$/;
170
+ // the task, as it does in the sibling products. A closing run word (`lit-loop`, `litwork`) runs that route the same way,
171
+ // as it would at the start. Only a word of its own counts: a `lit` inside a word (literal, split), after a path or URL
172
+ // character (lit-plan.md, /x/lit/y), in quotes, in a code span or fence, or followed by more text does not.
173
+ const TRAILING_LIT = /(?:^|\s)(lit|LIT|lit-loop|LIT-LOOP|litwork|LITWORK)\s*$/;
174
174
  function detectTrailing(prompt) {
175
175
  const withoutFences = prompt.replace(/```[\s\S]*?```/g, ' ');
176
176
  if (withoutFences.includes('```')) return null;
177
177
  const text = withoutFences.replace(/`[^`\n]*`/g, ' ');
178
- if (!TRAILING_LIT.test(text)) return null;
179
- return { route: 'lit-loop', keyword: null, bare: false, resume: false, restart: false, trailing: true, task: prompt.replace(/(?:lit|LIT)\s*$/u, '') };
178
+ const word = TRAILING_LIT.exec(text)?.[1];
179
+ if (!word) return null;
180
+ const lower = word.toLowerCase();
181
+ const task = prompt.replace(/\S+\s*$/u, '');
182
+ if (lower === 'lit') return { route: 'lit-loop', keyword: null, bare: false, resume: false, restart: false, trailing: true, task };
183
+ return { route: lower, keyword: lower, bare: false, resume: false, restart: false, trailing: true, task };
180
184
  }
181
185
 
182
186
  function detectLeading(prompt) {
@@ -67,7 +67,7 @@ function stackCount(frame) {
67
67
  }
68
68
 
69
69
  function activation(hit, payload) {
70
- const task = hit.trailing ? 'The task is the rest of the prompt before the closing `lit`.' : `The task is the rest of the prompt after the keyword${hit.keyword ? ` "${hit.keyword}"` : ''}.`;
70
+ const task = hit.trailing ? `The task is the rest of the prompt before the closing \`${hit.keyword ?? 'lit'}\`.` : `The task is the rest of the prompt after the keyword${hit.keyword ? ` "${hit.keyword}"` : ''}.`;
71
71
  const moved = movedActivation(hit.route);
72
72
  const lines = [
73
73
  ...banner('LIT IGNITED', hit.route),
@@ -98,7 +98,7 @@ function activation(hit, payload) {
98
98
  lines.push('Only when the user asks for detail (`lit adhd 자세히`, `lit adhd detail`) add `--detail`: it prints the KPI board (bars, milestones, done, left, reminders) with the per-session list under it. The collector draws every bar and count; never redraw, round or add to them. `' + rewind + ' --json` holds the same records, the board and the verdict.');
99
99
  }
100
100
  if (hit.trailing) {
101
- lines.push('Soft-confirm: `lit` came last in the prompt. If the request reads like ordinary prose, say in one line that you are starting a lit-loop and carry on; a stray English `lit` is recoverable.');
101
+ lines.push(`Soft-confirm: \`${hit.keyword ?? 'lit'}\` came last in the prompt. If the request reads like ordinary prose, say in one line that you are starting a ${hit.route} and carry on; a stray English \`lit\` is recoverable.`);
102
102
  }
103
103
  if (hit.bare && !hit.restart) {
104
104
  lines.push('The prompt has no task text after the keyword. After loading the skill, ask the user in one line what to run (a task for lit-loop, or a route such as plan or review) and wait for the answer before any other tool.');
@@ -310,14 +310,14 @@ function loopGoalAnswer(payload, root, consent, answer) {
310
310
  return true;
311
311
  }
312
312
 
313
- // A run route's first activation asks one goal question when the prompt names an objective, and no goal of this session is
314
- // open and no question is pending. With a test command the hook records the question itself (no test run here) and tells the
313
+ // A run route's first activation asks one goal question when the prompt names an objective (the words before a closing
314
+ // activation word count as one), and no goal of this session is open and no question is pending. With a test command the hook records the question itself (no test run here) and tells the
315
315
  // model to end its first reply with it: Muse shows no hook text, so this is advisory. Without one, the model asks it after
316
316
  // its RED check through goal-propose --loop, which dry-runs and refuses a check that already passes.
317
317
  const RUN_GOAL_ROUTES = new Set(['lit-loop', 'litwork']);
318
318
  function loopGoalNote(hit, payload) {
319
319
  try {
320
- if (!RUN_GOAL_ROUTES.has(hit.route) || hit.bare || hit.resume || hit.trailing || !safeId(payload.session_id)) return null;
320
+ if (!RUN_GOAL_ROUTES.has(hit.route) || hit.bare || hit.resume || !safeId(payload.session_id)) return null;
321
321
  const task = typeof hit.task === 'string' ? hit.task : String(payload.prompt ?? '').replace(/^\s*\/?(?:litmuse:)?(?:lit-loop|litwork)\b[\s:,.!?]*/iu, '');
322
322
  const objective = normalizeLoopObjective(task);
323
323
  if (!objective) return null;
@@ -439,7 +439,7 @@ run((payload) => {
439
439
  const turnId = payload.turn_id ?? null;
440
440
  const active = hit.restart ? null : liveRoute(previous);
441
441
  // start-work is always sent in full: its prompt carries the write grant and names the plan to run.
442
- const continues = active && (hit.bare || hit.resume || hit.trailing || (hit.route === active && active !== 'start-work'));
442
+ const continues = active && (hit.bare || hit.resume || (hit.trailing && !hit.keyword) || (hit.route === active && active !== 'start-work'));
443
443
  if (continues) {
444
444
  // `lit continue` with a side frame on top closes the side and resumes the paused spine.
445
445
  const frame = hit.resume ? stackContinue(payload) : null;
@@ -22,6 +22,12 @@ import {
22
22
  } from "./secure-path.mjs";
23
23
 
24
24
  const MAX_OWNER_BYTES = 4096;
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
+ // now belongs to another live process (pids are reused, often on WSL).
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;
25
31
  const sleepSync = (milliseconds) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds);
26
32
  const monotonicNowMs = () => Number(process.hrtime.bigint()) / 1_000_000;
27
33
 
@@ -204,11 +210,24 @@ const takeoverWinner = (lockDir, incumbent, ownClaim, staleAfter, expectedLockDi
204
210
  for (const name of names) {
205
211
  assertLockDirectory(lockDir, expectedLockDirectory);
206
212
  const claimRecord = readTakeoverClaim(lockDir, name, incumbent.nonce);
207
- if (claimRecord === null) return null;
213
+ if (claimRecord === null) {
214
+ // A contender that died while writing its claim left a file nobody can read; once old it is removed.
215
+ const claimPath = join(lockDir, name);
216
+ const stats = lstatSync(claimPath, { throwIfNoEntry: false });
217
+ if (!stats?.isFile() || stats.isSymbolicLink() || Date.now() - stats.mtimeMs < staleAfter) return null;
218
+ const identity = pathIdentity(stats);
219
+ try {
220
+ if (!removeVerifiedPath(claimPath, identity, expectedLockDirectory)) return null;
221
+ } catch (error) {
222
+ if (error?.code !== "ENOENT") return null;
223
+ }
224
+ continue;
225
+ }
208
226
  const { claim, identity, text } = claimRecord;
209
227
  const alive = processIsAlive(claim.pid);
210
228
  const oldEnough = Date.now() - claim.acquired_at_ms >= staleAfter;
211
- if (!alive && oldEnough) {
229
+ // A contender waits far less than the stale window, so an old claim is left over even when its pid looks alive.
230
+ if (oldEnough && claim.claimant_nonce !== ownClaim.claimant_nonce) {
212
231
  try {
213
232
  assertLockDirectory(lockDir, expectedLockDirectory);
214
233
  const claimPath = join(lockDir, name);
@@ -266,9 +285,20 @@ export const acquireOwnerLock = (lockDir, { timeoutMs = 500, staleMs = 30_000 }
266
285
 
267
286
  lockDirectory = assertLockDirectory(lockDir);
268
287
  const incumbent = readOwnerLock(lockDir);
288
+ if (!incumbent && lockDirectory) {
289
+ // A holder that died between creating the folder and writing its owner record left a lock nobody can judge;
290
+ // once it is older than the stale window (and the grace) it is moved aside and the acquisition retried.
291
+ const folder = lstatSync(lockDir, { throwIfNoEntry: false });
292
+ if (folder && Date.now() - folder.mtimeMs >= Math.max(staleAfter, OWNERLESS_GRACE_MS)) {
293
+ try {
294
+ if (removeVerifiedPath(lockDir, lockDirectory, undefined, `${lockDir}.stale.ownerless.${randomUUID()}`,
295
+ (quarantine) => !readOwnerLock(quarantine))) continue;
296
+ } catch { /* A lock that changed under us is judged again on the next pass. */ }
297
+ }
298
+ }
299
+ const heldFor = incumbent ? Date.now() - incumbent.acquired_at_ms : 0;
269
300
  const stale = incumbent
270
- && Date.now() - incumbent.acquired_at_ms >= staleAfter
271
- && !processIsAlive(incumbent.pid);
301
+ && (heldFor >= MAX_HOLD_MS || (heldFor >= staleAfter && !processIsAlive(incumbent.pid)));
272
302
  if (stale) {
273
303
  if (takeoverClaim?.owner_nonce !== incumbent.nonce) {
274
304
  takeoverClaim = {
@@ -310,7 +340,10 @@ export const acquireOwnerLock = (lockDir, { timeoutMs = 500, staleMs = 30_000 }
310
340
  }
311
341
  }
312
342
 
313
- if (monotonicNowMs() - startedAt >= timeout) throw new OwnerLockError("state lock timed out");
343
+ if (monotonicNowMs() - startedAt >= timeout) {
344
+ const holder = incumbent ? `held by pid ${incumbent.pid} for ${Math.round(heldFor / 1000)} s` : "with no owner record";
345
+ throw new OwnerLockError(`state lock timed out (${holder}; lock ${lockDir})`);
346
+ }
314
347
  sleepSync(Math.min(20, Math.max(1, timeout)));
315
348
  }
316
349
  }