@litfamily/litmuse 0.1.17 → 0.1.18

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,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.18 — 2026-11-24
4
+
5
+ - `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.
6
+ - 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.
7
+ - 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.
8
+ - The hook code changed, so Muse asks you to approve the LitMuse hooks again after the update.
9
+
3
10
  ## 0.1.17 — 2026-11-22
4
11
 
5
12
  - 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/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.18",
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.18",
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,9 @@ 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;
25
28
  const sleepSync = (milliseconds) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds);
26
29
  const monotonicNowMs = () => Number(process.hrtime.bigint()) / 1_000_000;
27
30
 
@@ -204,11 +207,24 @@ const takeoverWinner = (lockDir, incumbent, ownClaim, staleAfter, expectedLockDi
204
207
  for (const name of names) {
205
208
  assertLockDirectory(lockDir, expectedLockDirectory);
206
209
  const claimRecord = readTakeoverClaim(lockDir, name, incumbent.nonce);
207
- if (claimRecord === null) return null;
210
+ if (claimRecord === null) {
211
+ // A contender that died while writing its claim left a file nobody can read; once old it is removed.
212
+ const claimPath = join(lockDir, name);
213
+ const stats = lstatSync(claimPath, { throwIfNoEntry: false });
214
+ if (!stats?.isFile() || stats.isSymbolicLink() || Date.now() - stats.mtimeMs < staleAfter) return null;
215
+ const identity = pathIdentity(stats);
216
+ try {
217
+ if (!removeVerifiedPath(claimPath, identity, expectedLockDirectory)) return null;
218
+ } catch (error) {
219
+ if (error?.code !== "ENOENT") return null;
220
+ }
221
+ continue;
222
+ }
208
223
  const { claim, identity, text } = claimRecord;
209
224
  const alive = processIsAlive(claim.pid);
210
225
  const oldEnough = Date.now() - claim.acquired_at_ms >= staleAfter;
211
- if (!alive && oldEnough) {
226
+ // A contender waits far less than the stale window, so an old claim is left over even when its pid looks alive.
227
+ if (oldEnough && claim.claimant_nonce !== ownClaim.claimant_nonce) {
212
228
  try {
213
229
  assertLockDirectory(lockDir, expectedLockDirectory);
214
230
  const claimPath = join(lockDir, name);
@@ -266,9 +282,20 @@ export const acquireOwnerLock = (lockDir, { timeoutMs = 500, staleMs = 30_000 }
266
282
 
267
283
  lockDirectory = assertLockDirectory(lockDir);
268
284
  const incumbent = readOwnerLock(lockDir);
285
+ if (!incumbent && lockDirectory) {
286
+ // 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.
288
+ const folder = lstatSync(lockDir, { throwIfNoEntry: false });
289
+ if (folder && Date.now() - folder.mtimeMs >= staleAfter) {
290
+ try {
291
+ if (removeVerifiedPath(lockDir, lockDirectory, undefined, `${lockDir}.stale.ownerless.${randomUUID()}`,
292
+ (quarantine) => !readOwnerLock(quarantine))) continue;
293
+ } catch { /* A lock that changed under us is judged again on the next pass. */ }
294
+ }
295
+ }
296
+ const heldFor = incumbent ? Date.now() - incumbent.acquired_at_ms : 0;
269
297
  const stale = incumbent
270
- && Date.now() - incumbent.acquired_at_ms >= staleAfter
271
- && !processIsAlive(incumbent.pid);
298
+ && (heldFor >= MAX_HOLD_MS || (heldFor >= staleAfter && !processIsAlive(incumbent.pid)));
272
299
  if (stale) {
273
300
  if (takeoverClaim?.owner_nonce !== incumbent.nonce) {
274
301
  takeoverClaim = {
@@ -310,7 +337,10 @@ export const acquireOwnerLock = (lockDir, { timeoutMs = 500, staleMs = 30_000 }
310
337
  }
311
338
  }
312
339
 
313
- if (monotonicNowMs() - startedAt >= timeout) throw new OwnerLockError("state lock timed out");
340
+ if (monotonicNowMs() - startedAt >= timeout) {
341
+ const holder = incumbent ? `held by pid ${incumbent.pid} for ${Math.round(heldFor / 1000)} s` : "with no owner record";
342
+ throw new OwnerLockError(`state lock timed out (${holder}; lock ${lockDir})`);
343
+ }
314
344
  sleepSync(Math.min(20, Math.max(1, timeout)));
315
345
  }
316
346
  }