@litfamily/litclaude 1.0.39 → 1.0.41

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +8 -8
  3. package/README_ko-KR.md +8 -8
  4. package/docs/assets/readme/badge-version.svg +1 -1
  5. package/docs/hooks.md +35 -8
  6. package/package.json +1 -1
  7. package/plugins/litclaude/.claude-plugin/plugin.json +1 -1
  8. package/plugins/litclaude/bin/litclaude-hook.js +11 -2
  9. package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
  10. package/plugins/litclaude/hooks/lit-band-client.mjs +1 -1
  11. package/plugins/litclaude/hooks/lit-mod.mjs +66 -8
  12. package/plugins/litclaude/lib/canonical-skill-resources.mjs +11 -11
  13. package/plugins/litclaude/lib/interface-probe-gate.mjs +4 -5
  14. package/plugins/litclaude/lib/lit-plan-persistence.mjs +4 -5
  15. package/plugins/litclaude/lib/litgoal/autoloop.mjs +4 -5
  16. package/plugins/litclaude/lib/litgoal/cli.mjs +4 -5
  17. package/plugins/litclaude/lib/litgoal/ledger.mjs +4 -5
  18. package/plugins/litclaude/lib/litgoal/state.mjs +4 -6
  19. package/plugins/litclaude/lib/mod/frame.mjs +47 -28
  20. package/plugins/litclaude/lib/mod/looks.mjs +36 -0
  21. package/plugins/litclaude/lib/mod/motion.mjs +2 -3
  22. package/plugins/litclaude/lib/mod/state.mjs +6 -3
  23. package/plugins/litclaude/lib/mod/svg-card.mjs +4 -1
  24. package/plugins/litclaude/lib/mod/timeline.mjs +3 -3
  25. package/plugins/litclaude/lib/mod/view.mjs +80 -11
  26. package/plugins/litclaude/lib/mod/workflow.mjs +2 -0
  27. package/plugins/litclaude/lib/motion-render-gate.mjs +4 -5
  28. package/plugins/litclaude/lib/project-state-root.mjs +44 -2
  29. package/plugins/litclaude/lib/rewind/brief.mjs +5 -2
  30. package/plugins/litclaude/lib/rewind/collect.mjs +16 -12
  31. package/plugins/litclaude/lib/rewind/next-step.mjs +4 -5
  32. package/plugins/litclaude/lib/rewind/redact.mjs +28 -8
  33. package/plugins/litclaude/lib/rewind/suggest.mjs +9 -4
  34. package/plugins/litclaude/lib/rewind/transcripts.mjs +4 -4
  35. package/plugins/litclaude/lib/start-work-lifecycle.mjs +6 -9
  36. package/plugins/litclaude/lib/workflow-stack.mjs +4 -5
  37. package/plugins/litclaude/lib/workflow-stage.mjs +104 -22
  38. package/plugins/litclaude/skills/lit-hijack/references/capture-and-provenance.md +8 -0
  39. package/plugins/litclaude/skills/lit-hijack/references/distil-and-licence.md +5 -0
  40. package/plugins/litclaude/skills/lit-hijack/scripts/hijack.mjs +115 -15
  41. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/assets.mjs +110 -15
  42. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-serve.mjs +13 -3
  43. package/plugins/litclaude/skills/lit-typographic-motion/references/treatment.md +10 -7
@@ -1,6 +1,6 @@
1
- import { mkdirSync, writeFileSync } from "node:fs";
1
+ import { writeFileSync } from "node:fs";
2
2
  import { dirname } from "node:path";
3
- import { ensureStateDirIgnored } from "../project-state-root.mjs";
3
+ import { requireStateDir, STATE_WRITE_FLAG } from "../project-state-root.mjs";
4
4
  import { appendLitgoalLedger } from "./ledger.mjs";
5
5
  import {
6
6
  litgoalBriefPath,
@@ -193,9 +193,8 @@ const createGoals = (cwd, args) => {
193
193
  updatedAt: timestamp,
194
194
  };
195
195
 
196
- mkdirSync(dirname(litgoalBriefPath(cwd)), { recursive: true });
197
- ensureStateDirIgnored(litgoalBriefPath(cwd));
198
- writeFileSync(litgoalBriefPath(cwd), `${brief}\n`);
196
+ requireStateDir(dirname(litgoalBriefPath(cwd)));
197
+ writeFileSync(litgoalBriefPath(cwd), `${brief}\n`, { flag: STATE_WRITE_FLAG });
199
198
  writeLitgoalState(litgoalGoalsPath(cwd), state);
200
199
  // Fresh autoloop run -> reset the durable iteration counter so prior caps don't carry over.
201
200
  if (autoloop) resetAutoloopState(cwd, Date.parse(timestamp) || Date.now());
@@ -1,16 +1,15 @@
1
- import { appendFileSync, closeSync, fsyncSync, mkdirSync, openSync } from "node:fs";
1
+ import { appendFileSync, closeSync, fsyncSync, openSync } from "node:fs";
2
2
  import { dirname } from "node:path";
3
3
 
4
- import { ensureStateDirIgnored } from "../project-state-root.mjs";
4
+ import { requireStateDir, STATE_APPEND_FLAG } from "../project-state-root.mjs";
5
5
 
6
6
  export const appendLitgoalLedger = (path, entry) => {
7
- mkdirSync(dirname(path), { recursive: true });
8
- ensureStateDirIgnored(path);
7
+ requireStateDir(dirname(path));
9
8
  const record = {
10
9
  timestamp: new Date().toISOString(),
11
10
  ...entry,
12
11
  };
13
- appendFileSync(path, `${JSON.stringify(record)}\n`);
12
+ appendFileSync(path, `${JSON.stringify(record)}\n`, { flag: STATE_APPEND_FLAG });
14
13
  // Flush the appended record to disk for durability.
15
14
  const fd = openSync(path, "r");
16
15
  fsyncSync(fd);
@@ -1,7 +1,7 @@
1
1
  import { closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
2
2
  import { dirname } from "node:path";
3
3
 
4
- import { ensureStateDirIgnored } from "../project-state-root.mjs";
4
+ import { requireStateDir, STATE_WRITE_FLAG } from "../project-state-root.mjs";
5
5
 
6
6
  export class LitgoalStateError extends Error {
7
7
  constructor(message, status = 65) {
@@ -22,10 +22,9 @@ export const readLitgoalState = (path, fallback = {}) => {
22
22
 
23
23
  export const writeLitgoalState = (path, state) => {
24
24
  const dir = dirname(path);
25
- mkdirSync(dir, { recursive: true });
26
- ensureStateDirIgnored(dir);
25
+ requireStateDir(dir);
27
26
  const tmpPath = `${path}.${process.pid}.${Date.now()}.tmp`;
28
- writeFileSync(tmpPath, `${JSON.stringify(state, null, 2)}\n`);
27
+ writeFileSync(tmpPath, `${JSON.stringify(state, null, 2)}\n`, { flag: STATE_WRITE_FLAG });
29
28
  // Flush tmp file data to disk before rename so the rename is durable.
30
29
  const fd = openSync(tmpPath, "r");
31
30
  fsyncSync(fd);
@@ -48,8 +47,7 @@ const sleepSync = (milliseconds) => {
48
47
  };
49
48
 
50
49
  export const withLitgoalLock = (lockDir, fn) => {
51
- mkdirSync(dirname(lockDir), { recursive: true });
52
- ensureStateDirIgnored(lockDir);
50
+ requireStateDir(dirname(lockDir));
53
51
  const startedAt = Date.now();
54
52
  while (true) {
55
53
  try {
@@ -34,7 +34,8 @@
34
34
 
35
35
  import { gauge, knownFacts } from "../rewind/gauge.mjs";
36
36
  import { textWidth, truncateToWidth } from "./layout.mjs";
37
- import { barCells, gradientAt, lerpColor, lookOf, rainbowAt } from "./motion.mjs";
37
+ import { LOOKS, laneColor, lookOf } from "./looks.mjs";
38
+ import { barCells, gradientAt, lerpColor, rainbowAt } from "./motion.mjs";
38
39
  import { glyphSet } from "./settings.mjs";
39
40
  import { formatDuration } from "./view.mjs";
40
41
 
@@ -206,31 +207,39 @@ const edgeRow = (open, left, right, close, width, color, comet = null, paint = n
206
207
 
207
208
  // Where the ambient comet is on this card: along the top rule left to right for the first half of
208
209
  // its loop, then back along the bottom rule, starting and ending just off the card. The rewind look
209
- // spends the whole loop sweeping the bottom rule right to left.
210
+ // spends the whole loop sweeping the bottom rule right to left; the other looks run no comet.
210
211
  const cometOn = (sample, edge, width, look = null) => {
211
212
  const u = sample.ambient?.comet;
212
213
  if (u === null || u === undefined) return null;
213
214
  const span = width + 2 * COMET_TAIL;
214
215
  if (look === "rewind") return edge === "bottom" ? { x: width + COMET_TAIL - u * span, dir: -1, arrow: true } : null;
216
+ if (look) return null;
215
217
  if (edge === "top") return u < 0.5 ? { x: u * 2 * span - COMET_TAIL, dir: 1 } : null;
216
218
  return u >= 0.5 ? { x: width + COMET_TAIL - (u - 0.5) * 2 * span, dir: -1 } : null;
217
219
  };
218
220
 
219
221
  // While LitClaude works the brand pill breathes from its pink toward the flame orange and back.
220
- // The rewind look turns it through the rainbow instead, lightened so its dark ink stays readable.
221
- const brandSpans = (sample, glyphs, rainbow = null) => {
222
+ // The rewind look turns it through the rainbow instead, lightened so its dark ink stays readable;
223
+ // YOUR TURN holds it amber.
224
+ const brandSpans = (sample, glyphs, rainbow = null, look = null) => {
222
225
  const reveal = revealText("🔥 LIT", sample.pills[0]);
223
226
  if (reveal === null) return [];
224
227
  if (rainbow) return rainbowPill(reveal, rainbow, 0, glyphs);
225
- const fill = sample.ambient ? lerpColor(PILL.brand, PALETTE.orange, 0.85 * sample.ambient.breath) : PILL.brand;
228
+ const fill = look === "turn" ? PALETTE.amber : sample.ambient ? lerpColor(PILL.brand, PALETTE.orange, 0.85 * sample.ambient.breath) : PILL.brand;
226
229
  return pill(litText(reveal, { fg: PILL.ink, bg: fill, bold: true }, sample.completion?.shimmer ?? null), fill, glyphs);
227
230
  };
228
231
  // `REWIND <<` while the rewind look is on, each letter a step further round the hue wheel, lightened
229
232
  // to keep 4.5:1 on the card; the letters stay put and only their colours move.
230
233
  const rewindSpans = (rainbow) => [..."REWIND <<"].map((ch, i) => span(ch, { fg: lerpColor(rainbow(i / 9), "#ffffff", 0.4), bold: true }));
231
- const indicatorSpans = (model, sample, glyphs, accent, rainbow = null) => {
234
+ // The review look counts the lanes that have reported, passed or failed.
235
+ const indicatorSpans = (model, sample, glyphs, accent, rainbow = null, look = null) => {
232
236
  if (sample.completion) return [span(`DONE ${glyphs.done}`, { fg: PALETTE.green, bold: true })];
233
237
  if (rainbow) return rewindSpans(rainbow);
238
+ if (look === "turn") return [span(LOOKS.turn.label, { fg: PALETTE.amber, bold: true })];
239
+ if (look === "review") {
240
+ const lanes = model.workflow.verdicts;
241
+ return [span(`${LOOKS.review.label} ${lanes.filter(({ state }) => state === "pass" || state === "fail").length}/${lanes.length}`, { fg: accent, bold: true })];
242
+ }
234
243
  if (model.idle) return [span("idle", { fg: PALETTE.dim })];
235
244
  const flow = model.workflow;
236
245
  if (flow && flow.current >= 0) {
@@ -248,8 +257,8 @@ const indicatorSpans = (model, sample, glyphs, accent, rainbow = null) => {
248
257
  // ╭─ [🔥 LIT] · <discipline> ──── <PHASE ●> ─╮. On a narrow card the phase indicator goes first,
249
258
  // then the discipline shortens, then it goes too.
250
259
  const topEdge = (model, sample, { width, glyphs, accent, edge, look, paint, rainbow }) => {
251
- const brand = brandSpans(sample, glyphs, rainbow);
252
- const right = indicatorSpans(model, sample, glyphs, accent, rainbow);
260
+ const brand = brandSpans(sample, glyphs, rainbow, look);
261
+ const right = indicatorSpans(model, sample, glyphs, accent, rainbow, look);
253
262
  const name = model.title ?? "ready";
254
263
  const nameStyle = model.idle && !rainbow ? { fg: PALETTE.dim } : { fg: accent, bold: true };
255
264
  const title = (text) => (text ? [span(" · ", { fg: PALETTE.dim }), span(text, nameStyle)] : []);
@@ -265,13 +274,14 @@ const topEdge = (model, sample, { width, glyphs, accent, edge, look, paint, rain
265
274
  const barSpans = (fraction, sample, cells) => barCells(fraction, cells, sample.fillGlow ?? 0)
266
275
  .map(({ glyph, color }) => (glyph === "█" ? span(" ", { bg: color }) : span(glyph, { fg: color })));
267
276
 
268
- // ●● 2 lanes 1:07: a dot per running lane (amber once stalled), the count and the longest lane's
277
+ // ●● 2 lanes 1:07: a dot per lane (amber once stalled, dim and still while idle), the count and the longest lane's
269
278
  // clock. While LitClaude works a light walks across the dots (full motion) or they breathe (subtle),
270
279
  // so running lanes move while the main turn waits; a dot changes only by colour, which repaints.
271
280
  const laneSegment = (model, sample, glyphs) => {
272
281
  const list = model.lanes.list.slice(0, 4);
273
282
  const ambient = model.idle ? null : sample.ambient;
274
283
  const dots = list.map((lane, index) => {
284
+ if (lane.status === "idle") return span(glyphs.lane, { fg: PALETTE.dim });
275
285
  const base = lane.status === "stalled" ? PALETTE.amber : PALETTE.green;
276
286
  let light = 0;
277
287
  if (ambient?.flow !== null && ambient?.flow !== undefined) light = 0.8 * Math.max(0, 1 - Math.abs(ambient.flow * (list.length + 1) - 0.5 - index));
@@ -586,7 +596,9 @@ const progressSpans = (thread, sample, rainbow, index, color) => {
586
596
  const words = facts.startsWith(thread.state)
587
597
  ? [span(facts, { fg: color })]
588
598
  : [span(thread.state, { fg: color }), span(` · ${facts}`, { fg: PALETTE.dim })];
589
- return [span(" "), ...pulseSpans(sample, rainbow, index), span(" "), ...words];
599
+ // An idle thread does nothing, so its pulse carries no moving light.
600
+ const pulse = thread.state === "idle" ? { ...sample, ambient: null } : sample;
601
+ return [span(" "), ...pulseSpans(pulse, rainbow, index), span(" "), ...words];
590
602
  };
591
603
 
592
604
  const threadRows = (model, sample, { inner, glyphs, rainbow }) => {
@@ -740,7 +752,7 @@ const completionRow = (sample, inner) => {
740
752
  const life = Math.min(1, Math.max(0, completion.embers * 1.6 - i * 0.04));
741
753
  const alpha = life <= 0 || life >= 1 ? 0 : Math.sin(life * Math.PI);
742
754
  const glyph = alpha < 0.05 ? " " : SPARKS[Math.min(2, Math.floor(alpha * 3))];
743
- row.push(span(glyph, { fg: lerpColor(PALETTE.faint, i % 3 ? PALETTE.pink : PALETTE.amber, alpha) }), span(" "));
755
+ row.push(span(glyph, { fg: lerpColor(PALETTE.faint, rainbowAt(i / count), alpha) }), span(" "));
744
756
  }
745
757
  row.push(span(" "));
746
758
  } else {
@@ -781,9 +793,10 @@ const bottomEdge = (model, sample, { width, glyphs, accent, edge, look, paint, r
781
793
 
782
794
  // The border: red or amber under a warning, otherwise the accent. Idle it is a calm, dim accent;
783
795
  // while LitClaude works it sits a step above the accent and breathes brighter toward white with the
784
- // brand pill.
785
- const edgeColor = (model, sample, accent) => {
796
+ // brand pill. YOUR TURN breathes amber over TIMINGS.breath, and holds it with motion off.
797
+ const edgeColor = (model, sample, accent, look) => {
786
798
  if (model.warnings.some(({ tone }) => tone === "red")) return PALETTE.red;
799
+ if (look === "turn") return sample.ambient ? lerpColor(lerpColor(PALETTE.amber, PALETTE.faint, 0.5), PALETTE.amber, sample.ambient.breath) : PALETTE.amber;
787
800
  if (model.warnings.length) return PALETTE.amber;
788
801
  if (model.idle) return lerpColor(PALETTE.faint, accent, 0.35);
789
802
  return lerpColor(accent, "#ffffff", 0.15 + 0.3 * (sample.ambient?.breath ?? 0));
@@ -794,38 +807,44 @@ const edgeColor = (model, sample, accent) => {
794
807
  * map or phase track, detail line, chips row, bottom edge), with the thread rows between the detail
795
808
  * line and the chips while more than one thread is live, each exactly `width` cells:
796
809
  * the terminal's columns up to CARD_MAX. `accent` is the status line's accent colour
797
- * (settings.mjs accentFromSettings).
810
+ * (settings.mjs accentFromSettings). `color: false` (NO_COLOR) draws the same cells with no colour.
798
811
  */
799
- export const composeBand = (model, sample, { columns, glyphs: glyphMode = "basic", accent = PALETTE.accent }) => {
812
+ export const composeBand = (model, sample, { columns, glyphs: glyphMode = "basic", accent = PALETTE.accent, color = true }) => {
800
813
  const glyphs = glyphSet(glyphMode);
801
814
  const width = Math.max(12, Math.min(CARD_MAX, columns));
802
815
  const inner = width - 4;
803
- const edge = edgeColor(model, sample, accent);
816
+ // The model names its look (looks.mjs); a model built without one keeps the rewind rule it had.
817
+ const look = "look" in model ? model.look : model.rewind ? "rewind" : model.idle || lookOf(model.discipline) !== "rewind" ? null : "rewind";
818
+ const edge = edgeColor(model, sample, accent, look);
804
819
  // The rewind look's rainbow turns with the ambient hue (still at 0 with motion off). A warning
805
- // keeps the border its warning colour; the rails stay rainbow.
806
- const look = model.rewind ? "rewind" : model.idle ? null : lookOf(model.discipline);
820
+ // keeps the border its warning colour; the rails stay rainbow. The review look splits the top
821
+ // and bottom rules into its five lanes, a fifth of the width each.
807
822
  const hue = sample.ambient?.hue ?? 0;
808
823
  const rainbow = look === "rewind" ? (position) => rainbowAt(position + hue) : null;
809
824
  const painted = rainbow && model.warnings.length === 0;
810
- const paint = [0, 1, 2, 3, 4].map((r) => (painted ? (col) => rainbow(col / width + r * 0.04) : null));
825
+ const lanes = look === "review" ? model.workflow.verdicts : null;
826
+ const laneAt = (col) => Math.min(lanes.length - 1, Math.floor((col * lanes.length) / width));
827
+ const lanePaint = lanes ? (col) => laneColor(laneAt(col), lanes[laneAt(col)].state) : null;
828
+ const paint = [0, 1, 2, 3, 4].map((r) => (painted ? (col) => rainbow(col / width + r * 0.04) : r === 0 || r === 4 ? lanePaint : null));
811
829
  const side = (row, r) => (paint[r]
812
830
  ? [span("│", { fg: paint[r](0) }), span(" "), ...row, span(" "), span("│", { fg: paint[r](width - 1) })]
813
831
  : [span("│ ", { fg: edge }), ...row, span(" │", { fg: edge })]);
814
832
  const options = { width, inner, glyphs, accent, edge, look, rainbow, paint };
815
833
  const middle = sample.completion ? completionRow(sample, inner) : sample.notice ? noticeRow(sample, inner) : chipsRow(model, sample, options);
834
+ const rows = [
835
+ topEdge(model, sample, options),
836
+ side(model.workflow ? mapRow(model, sample, options) : phaseRow(model, sample, options), 1),
837
+ side(detailRow(model, sample, options), 2),
838
+ ...(model.threads ? threadRows(model, sample, options).map((row) => side(row, 2)) : []),
839
+ side(middle, 3),
840
+ bottomEdge(model, sample, options),
841
+ ];
816
842
  return {
817
843
  mode: "card",
818
- border: edge,
844
+ border: color ? edge : null,
819
845
  width,
820
846
  look,
821
- rows: [
822
- topEdge(model, sample, options),
823
- side(model.workflow ? mapRow(model, sample, options) : phaseRow(model, sample, options), 1),
824
- side(detailRow(model, sample, options), 2),
825
- ...(model.threads ? threadRows(model, sample, options).map((row) => side(row, 2)) : []),
826
- side(middle, 3),
827
- bottomEdge(model, sample, options),
828
- ],
847
+ rows: color ? rows : rows.map((row) => row.map(({ text, bold }) => (bold ? { text, bold } : { text }))),
829
848
  };
830
849
  };
831
850
 
@@ -0,0 +1,36 @@
1
+ // The LIT card's looks (plans/mod-skill-looks.md): what a skill or a session state turns the card
2
+ // into. A look names its palette, its corner label, its comet path and its pill style; frame.mjs and
3
+ // svg-card.mjs draw them. view.mjs picks one look per model, a finish first, then the session
4
+ // waiting on the user, then the look of a skill running this turn (whatever route ran it).
5
+ //
6
+ // rewind lit-adhd and lit-rewind: rainbow border and rails, `REWIND <<`, a `<<` comet
7
+ // review review-work: the top and bottom rules split into the five review lanes
8
+ // turn waiting on the user: an amber border breathing over TIMINGS.breath, `YOUR TURN`
9
+ // done a plan, goal, review or release finished: one rainbow spray of embers
10
+
11
+ export const LOOKS = Object.freeze({
12
+ rewind: Object.freeze({ label: "REWIND <<", palette: "rainbow", comet: "bottom-leftward", pill: "rainbow" }),
13
+ review: Object.freeze({ label: "REVIEW", palette: "lanes", comet: "none", pill: "accent" }),
14
+ turn: Object.freeze({ label: "YOUR TURN", palette: "amber", comet: "none", pill: "amber" }),
15
+ done: Object.freeze({ label: "DONE", palette: "rainbow", comet: "none", pill: "brand" }),
16
+ });
17
+
18
+ export const LOOK_BY_SKILL = Object.freeze({ "lit-adhd": "rewind", "lit-rewind": "rewind", "review-work": "review" });
19
+ const BY_SKILL = new Map(Object.entries(LOOK_BY_SKILL));
20
+
21
+ /** The look a skill or discipline id brings, or null for one that keeps the card's own look. */
22
+ export const lookOf = (id) => BY_SKILL.get(id) ?? null;
23
+
24
+ // One colour per review lane in workflow.mjs REVIEW_LANES order (goal, quality, security, qa,
25
+ // context), and each one 45% of the way to the dim segment while its reviewer is still running.
26
+ export const LANE_COLORS = Object.freeze(["#5fd7ff", "#b48cff", "#ff6fae", "#6bdb8f", "#ffd75f"]);
27
+ const LANE_RUNNING = Object.freeze(["#5095af", "#7e6caf", "#a85c82", "#569771", "#a89557"]);
28
+ const LANE_DIM = "#3d444d";
29
+ const LANE_FAIL = "#ff5f5f";
30
+
31
+ /** A lane segment's colour: its own once it passed, red once it failed, dim until it reports. */
32
+ export const laneColor = (index, state) => {
33
+ if (state === "pass") return LANE_COLORS[index];
34
+ if (state === "running") return LANE_RUNNING[index];
35
+ return state === "fail" ? LANE_FAIL : LANE_DIM;
36
+ };
@@ -54,9 +54,8 @@ export const motionProfile = (mode) => {
54
54
 
55
55
  // The rewind look (plans/lit-adhd.md D7): while lit-adhd runs, the card's border and rails take a
56
56
  // cycling rainbow, ASCII sparks drift through the skills row and a `<<` comet sweeps the bottom rule
57
- // right to left. It is keyed on the ignition discipline alone; every other discipline keeps its look.
58
- const REWIND = new Set(["lit-adhd", "lit-rewind"]);
59
- export const lookOf = (discipline) => (REWIND.has(discipline) ? "rewind" : null);
57
+ // right to left. Which skill brings which look lives in looks.mjs.
58
+ export { lookOf } from "./looks.mjs";
60
59
 
61
60
  export const clamp01 = (x) => (x <= 0 ? 0 : x >= 1 ? 1 : x);
62
61
 
@@ -215,6 +215,8 @@ export const parseBoulder = (state, sessionId) => {
215
215
  nextTask: str(progress.next_task, 400),
216
216
  lanes: laneList(active.lanes),
217
217
  lastEvent: str(Array.isArray(active.events) ? active.events.at(-1)?.event : null, 60),
218
+ // A paused work waits at a typed boundary (start-work-lifecycle) until the user answers it.
219
+ awaiting: active.status === "paused" ? str(active.pending_boundary?.boundary_id, 120) : null,
218
220
  },
219
221
  completed,
220
222
  };
@@ -393,8 +395,9 @@ const withPlanCounts = async (io, stateRoot, frames) => {
393
395
  const OTHER_STACKS = 6;
394
396
 
395
397
  // The stacks other sessions of this project keep beside this one's, newest first and at most
396
- // OTHER_STACKS: `{ id8, at, frames }` each, `at` being the file's mtime. Links, this session's own
397
- // file and the unknown-session file are skipped; whether one is still live is the view's call.
398
+ // OTHER_STACKS: `{ id8, at, ended, frames }` each, `at` being the file's mtime and `ended` set once
399
+ // SessionEnd marked it. Links, this session's own file and the unknown-session file are skipped;
400
+ // whether one is still live is the view's call.
398
401
  const readOtherStacks = async (io, stateRoot, sessionId) => {
399
402
  const own = new Set([ignitionFileName(sessionId), ignitionFileName(null)]);
400
403
  const files = (await listOf(io, joinPath(stateRoot, ".litclaude", "workflow-stack")))
@@ -406,7 +409,7 @@ const readOtherStacks = async (io, stateRoot, sessionId) => {
406
409
  const id = typeof raw?.sessionId === "string" ? raw.sessionId : null;
407
410
  const parsed = id ? parseWorkflowStack(raw, id) : null;
408
411
  if (parsed) await withPlanCounts(io, stateRoot, parsed.frames.slice(-1));
409
- return parsed ? { id8: id.replace(/[^A-Za-z0-9]/gu, "").slice(0, 8), at: entry.mtimeMs, frames: parsed.frames } : null;
412
+ return parsed ? { id8: id.replace(/[^A-Za-z0-9]/gu, "").slice(0, 8), at: entry.mtimeMs, ended: typeof raw.endedAt === "string", frames: parsed.frames } : null;
410
413
  }));
411
414
  return read.filter(Boolean);
412
415
  };
@@ -22,7 +22,8 @@
22
22
 
23
23
  import { gauge, knownFacts } from "../rewind/gauge.mjs";
24
24
  import { textWidth, truncateToWidth } from "./layout.mjs";
25
- import { TIMINGS, barCells, gradientAt, lookOf, rainbowAt } from "./motion.mjs";
25
+ import { LOOKS, lookOf } from "./looks.mjs";
26
+ import { TIMINGS, barCells, gradientAt, rainbowAt } from "./motion.mjs";
26
27
 
27
28
  const C = Object.freeze({
28
29
  bg: "#0d1117",
@@ -102,6 +103,8 @@ const pill = (x, y, label, { fill, ink, bold = true, sweep = false, breath = nul
102
103
 
103
104
  const indicatorOf = (model, accent) => {
104
105
  if (model.completion) return { label: "DONE ✓", fill: C.green };
106
+ if (model.look === "turn") return { label: LOOKS.turn.label, fill: C.amber };
107
+ if (model.look === "review") return { label: `${LOOKS.review.label} ${model.workflow.verdicts.filter(({ state }) => state === "pass" || state === "fail").length}/${model.workflow.verdicts.length}`, fill: accent };
105
108
  if (model.idle) return { label: "idle", fill: C.dim, plain: true };
106
109
  const flow = model.workflow;
107
110
  if (flow?.paused && flow.current >= 0) return { label: `${flow.stages[flow.current].id.toUpperCase()} ||`, fill: C.dim };
@@ -38,10 +38,10 @@ const chipsOf = (model, now, previous = null) => Object.fromEntries((model.skill
38
38
  }));
39
39
 
40
40
  // The ambient loop runs while the card shows LitClaude at work, so motion itself says "active",
41
- // and while the rewind look lingers after a brief; `at` is when the current run began, so the loop
42
- // does not restart on every new model.
41
+ // while the rewind look lingers after a brief and while YOUR TURN breathes; `at` is when the current
42
+ // run began, so the loop does not restart on every new model.
43
43
  const ambientOf = (model, now, profile, previous = null) => {
44
- const on = Boolean(profile.ambient) && model.visible && (!model.idle || model.rewind === true);
44
+ const on = Boolean(profile.ambient) && model.visible && (!model.idle || model.rewind === true || model.look === "turn");
45
45
  return { on, at: on && previous?.on ? previous.at : now };
46
46
  };
47
47
 
@@ -2,14 +2,15 @@
2
2
  // (skills.mjs) and what Claude Code reports live (subagents, context and rate-limit usage). Pure: the mod calls these on each refresh and hands the result to the
3
3
  // band's surface module, which only draws and animates it.
4
4
 
5
- import { lookOf } from "./motion.mjs";
5
+ import { lookOf } from "./looks.mjs";
6
6
  import { AUTOLOOP_LIMITS, GATE_LIMITS } from "./state.mjs";
7
- import { buildWorkflow } from "./workflow.mjs";
7
+ import { REVIEW_LANES, buildWorkflow } from "./workflow.mjs";
8
8
 
9
9
  export const STALL_MS = 10 * 60 * 1000;
10
10
  // An agent the host does not list, quiet this long with no call in flight, no longer counts as
11
11
  // running: a crashed loop or a lost report must not hold the card at work for the rest of the
12
- // session. One the host lists as live stays, however quiet; it is marked stalled instead.
12
+ // session. One the host lists as live stays, however quiet; it is marked stalled instead, unless
13
+ // the host lists it idle: a teammate that finished its turn and waits for a message is not stuck.
13
14
  export const AGENT_STALE_MS = 30 * 60 * 1000;
14
15
  // The context warning starts this many points before the auto-handoff percent.
15
16
  export const CONTEXT_LEAD = 5;
@@ -22,6 +23,7 @@ export const REWIND_LINGER_MS = 15 * 60 * 1000;
22
23
  export const BREAK_MS = 30 * 60 * 1000;
23
24
 
24
25
  const LIVE_AGENT = new Set(["running", "pending", "waiting", "idle"]);
26
+ const STALLABLE_AGENT = new Set(["running", "pending", "waiting"]);
25
27
  const ENDED_AGENT = new Set(["completed", "failed", "killed"]);
26
28
  const NONTERMINAL_GOAL = new Set(["active", "blocked", "review_blocked", "needs_user_decision"]);
27
29
  const WORK_DISCIPLINES = new Set(["lit-loop", "litwork", "litgoal", "start-work", "native-workflow"]);
@@ -89,7 +91,7 @@ export const mergeSpawned = (listed, spawned, now) => {
89
91
 
90
92
  export const stalledLanes = (agents, activity, now, thresholdMs = STALL_MS) =>
91
93
  agents
92
- .filter((agent) => LIVE_AGENT.has(agent.status) && Number.isFinite(activity.last[agent.id]) && now - activity.last[agent.id] > thresholdMs)
94
+ .filter((agent) => STALLABLE_AGENT.has(agent.status) && Number.isFinite(activity.last[agent.id]) && now - activity.last[agent.id] > thresholdMs)
93
95
  .map((agent) => ({ id: agent.id, name: laneName(agent), quietMs: now - activity.last[agent.id] }));
94
96
 
95
97
  export const laneName = (agent) => String(agent.name || agent.description || agent.type || "agent").slice(0, 40);
@@ -98,7 +100,8 @@ export const laneName = (agent) => String(agent.name || agent.description || age
98
100
  // leaves PARALLEL_ROWS for the lanes and tasks under it.
99
101
  export const THREAD_ROWS = 4;
100
102
  const PARALLEL_ROWS = 3;
101
- // Another session of this project counts as live while its stack was written this recently.
103
+ // Another session of this project counts as live while its stack was written this recently and
104
+ // SessionEnd has not marked it ended.
102
105
  export const OTHER_SESSION_MS = 15 * 60 * 1000;
103
106
 
104
107
  const countOrNull = (value) => (Number.isInteger(value) && value >= 0 ? value : null);
@@ -284,7 +287,7 @@ const threadsOf = ({ snapshot, lanes, tasks, lists, now, threadReserve }) => {
284
287
  const taskThreads = tasks.map((task) => ({ key: `task-${task.id}`, name: task.name, stage: task.kind, done: null, total: null, state: "running", active: false, task: task.kind, elapsedMs: Number.isFinite(task.at) ? Math.max(0, now - task.at) : null }));
285
288
  const parallel = [...laneThreads, ...taskThreads];
286
289
  const others = (snapshot.workflow?.others ?? [])
287
- .filter((other) => Number.isFinite(other.at) && now - other.at <= OTHER_SESSION_MS && other.frames?.length)
290
+ .filter((other) => !other.ended && Number.isFinite(other.at) && now - other.at <= OTHER_SESSION_MS && other.frames?.length)
288
291
  .map((other) => ({ ...frameThread(other.frames.at(-1), 0, {}, false, null, now), key: `session-${other.id8}`, session: other.id8 }));
289
292
  const total = chain.length + parallel.length + others.length;
290
293
  if (total < 2) return null;
@@ -388,9 +391,10 @@ export const stepName = (tool) => {
388
391
  * lit (the idle title), `git` the branch and `step` the live step (`{ name, at }`, the tool the
389
392
  * main loop runs and since when). `threadReserve` is the previous model's `threads.reserve`,
390
393
  * `lists` the loops' todo and task counts (noteLoopCall) and `tasks` the background tasks
391
- * (noteBackgroundTask).
394
+ * (noteBackgroundTask). `turnStartedAt` is when the main loop's current turn began, `waiting`
395
+ * what the session waits on the user for (`{ reason }`, null while it does not).
392
396
  */
393
- export const buildBandModel = ({ snapshot, agents = [], activity = EMPTY_ACTIVITY, usage = null, now, band = "always", isWorking = false, notice = null, completion = null, skills = [], lastDiscipline = null, git = null, step = null, threadReserve = 0, lists = EMPTY_LISTS, tasks = EMPTY_TASKS }) => {
397
+ export const buildBandModel = ({ snapshot, agents = [], activity = EMPTY_ACTIVITY, usage = null, now, band = "always", isWorking = false, notice = null, completion = null, skills = [], lastDiscipline = null, git = null, step = null, threadReserve = 0, lists = EMPTY_LISTS, tasks = EMPTY_TASKS, turnStartedAt = null, waiting = null }) => {
394
398
  const discipline = snapshot.ignition?.discipline ?? null;
395
399
  const progress = progressOf(snapshot);
396
400
  const completing = completion !== null;
@@ -404,7 +408,8 @@ export const buildBandModel = ({ snapshot, agents = [], activity = EMPTY_ACTIVIT
404
408
  id: agent.id,
405
409
  name: laneName(agent),
406
410
  status: stalledIds.has(agent.id) ? "stalled" : agent.status,
407
- elapsedMs: Number.isFinite(activity.first[agent.id]) ? now - activity.first[agent.id] : null,
411
+ // An idle teammate's clock would count time it spent waiting, so it shows none.
412
+ elapsedMs: agent.status !== "idle" && Number.isFinite(activity.first[agent.id]) ? now - activity.first[agent.id] : null,
408
413
  }))
409
414
  : boulderLanes.slice(0, 6).map((lane) => ({ name: lane.type, status: "running", elapsedMs: Number.isFinite(lane.startedAt) ? now - lane.startedAt : null }));
410
415
  const goal = snapshot.goal;
@@ -419,12 +424,15 @@ export const buildBandModel = ({ snapshot, agents = [], activity = EMPTY_ACTIVIT
419
424
  const lit = skills.some(({ state }) => state === "current");
420
425
  const workflow = buildWorkflow({ snapshot, skills, completion, now });
421
426
  const title = discipline ?? skills.find(({ state }) => state === "current")?.id ?? lastDiscipline;
422
- const rewind = lookOf(discipline) === "rewind" && Number.isFinite(snapshot.ignition?.at) && now - snapshot.ignition.at < REWIND_LINGER_MS;
423
- const visible = band === "off" ? false : band === "always" || active || lit || rewind || notice !== null || completion !== null || warnings.length > 0;
427
+ const look = selectLook({ snapshot, discipline, skills, workflow, completion, waiting, now, turnStartedAt });
428
+ const rewind = look === "rewind";
429
+ const visible = band === "off" ? false : band === "always" || active || lit || look !== null || notice !== null || completion !== null || warnings.length > 0;
424
430
  return {
425
431
  visible,
426
432
  idle: !active && !lit,
433
+ look,
427
434
  rewind,
435
+ waiting: waiting?.reason ?? null,
428
436
  away: !active && !lit && !rewind && skills.length > 0 && now - Math.max(...skills.map(({ at }) => (Number.isFinite(at) ? at : now))) >= BREAK_MS,
429
437
  discipline,
430
438
  title: workflow?.paused ? crumbOf(workflow.paused) : title,
@@ -447,6 +455,24 @@ export const buildBandModel = ({ snapshot, agents = [], activity = EMPTY_ACTIVIT
447
455
  };
448
456
  };
449
457
 
458
+ // The card's look (looks.mjs): a finish, then the session waiting on the user, then the look of the
459
+ // newest look-bearing skill this request ran. A Skill tool load never reaches the prompt hook, so a
460
+ // firing in this turn counts as the ignited discipline does; the next turn's start ends the one, the
461
+ // next prompt's ignition the other. The review look draws only the lanes review-work has open, and
462
+ // holds while a lane is still running: background lanes report in the turns their notifications start.
463
+ const selectLook = ({ snapshot, discipline, skills, workflow, completion, waiting, now, turnStartedAt }) => {
464
+ if (completion) return "done";
465
+ if (waiting) return "turn";
466
+ const fired = Number.isFinite(turnStartedAt) ? skills.filter(({ id, at }) => lookOf(id) && at >= turnStartedAt) : [];
467
+ const ignited = lookOf(discipline) && Number.isFinite(snapshot.ignition?.at) ? [{ id: discipline, at: snapshot.ignition.at }] : [];
468
+ const newest = [...fired, ...ignited].filter(({ at }) => now - at < REWIND_LINGER_MS).sort((a, b) => b.at - a.at)[0];
469
+ const look = newest ? lookOf(newest.id) : null;
470
+ const lanesOpen = workflow?.current >= 0 && workflow.verdicts?.length === REVIEW_LANES.length;
471
+ if (look === "review") return lanesOpen ? "review" : null;
472
+ if (!look && lanesOpen && workflow.verdicts.some(({ state }) => state === "running")) return "review";
473
+ return look;
474
+ };
475
+
450
476
  // `lit-loop || > lit-brainstorm`, or `lit-loop || > … > lit-brainstorm` with a side between them.
451
477
  const crumbOf = ({ parent, child, chain }) => `${parent} || > ${chain.length > 1 ? "… > " : ""}${child}`;
452
478
 
@@ -511,6 +537,49 @@ export const detectCompletion = (previous, next) => {
511
537
  return null;
512
538
  };
513
539
 
540
+ // Fenced code is quoted material, not the answer's own words.
541
+ const FENCE = /^\s*(```|~~~)/u;
542
+
543
+ /**
544
+ * Why a main-loop answer leaves the session waiting on the user: `blocked` when a line reports
545
+ * `BLOCKED:`, `question` when its last paragraph ends in a question mark, else null.
546
+ */
547
+ export const waitingReason = (answer) => {
548
+ let fenced = false;
549
+ const lines = String(answer ?? "").split(/\r?\n/u).filter((line) => {
550
+ if (FENCE.test(line)) {
551
+ fenced = !fenced;
552
+ return false;
553
+ }
554
+ return !fenced;
555
+ });
556
+ if (lines.some((line) => /^\s*(?:[-*>]\s*)?\**BLOCKED\**:/u.test(line))) return "blocked";
557
+ const last = lines.join("\n").trim().split(/\n\s*\n/u).at(-1) ?? "";
558
+ return /[??]["')\]*_`]*$/u.test(last.trim()) ? "question" : null;
559
+ };
560
+
561
+ /**
562
+ * The review finishing, by comparing the previous model with this one: every lane had not passed and
563
+ * now the main map is done. Plan and goal finishes come from the durable state (detectCompletion).
564
+ */
565
+ export const workflowFinish = (previous, next) => {
566
+ const before = previous?.workflow;
567
+ const after = next?.workflow;
568
+ if (!before || !after || before.family !== "main" || after.family !== "main") return null;
569
+ const open = before.verdicts ?? before.paused?.verdicts;
570
+ const lanes = open?.length === REVIEW_LANES.length ? open : null;
571
+ if (!lanes || before.current < 0 || lanes.every(({ state }) => state === "pass") || after.current !== -1) return null;
572
+ return { id: "review", detail: `review · ${REVIEW_LANES.length}/${REVIEW_LANES.length} lanes passed` };
573
+ };
574
+
575
+ /** A release the main loop published: a successful `npm publish` that was not a dry run. */
576
+ export const releaseFinish = (e, outcome) => {
577
+ if (typeof e?.agentId === "string" || e?.tool !== "Bash" || typeof e.command !== "string") return null;
578
+ if (!/^\s*npm\s+publish\b/u.test(e.command) || /(?:^|\s)--dry-run\b/u.test(e.command)) return null;
579
+ if (!outcome || outcome.isError || outcome.deny !== undefined) return null;
580
+ return { id: `release:${e.command.trim()}`, detail: "released" };
581
+ };
582
+
514
583
  /** The evidence pane: goal criteria, blockers, the litgoal timeline, lanes and gates. */
515
584
  export const buildEvidenceModel = ({ snapshot, ledger = [], agents = [], activity = EMPTY_ACTIVITY, now, icons = null }) => {
516
585
  const goal = snapshot.goal;
@@ -258,6 +258,8 @@ export const buildWorkflow = ({ snapshot, skills = [], completion = null, now })
258
258
  const count = family !== "main" && countOf ? ` ${countOf.done}/${countOf.total}` : "";
259
259
  at.label = `|| ${at.label}${count}`;
260
260
  paused.count = countOf;
261
+ // The lanes stay with the paused map, undrawn, so the review finishing under the side still bursts.
262
+ paused.verdicts = verdicts;
261
263
  if (!next && goalIsOpen(snapshot.goal)) next = plainText(snapshot.goal.criteria.find(({ status }) => status !== "pass")?.description);
262
264
  return { family, stages, current, count: null, items: [`↳ ${paused.child}`, "back: lit continue"], verdicts: null, next, paused };
263
265
  }
@@ -10,10 +10,10 @@
10
10
  // once more to tell the model to say, in the reply, that the film is not done and why; a blocked
11
11
  // environment (exit 10-12, 14, 15, 21, 22) goes straight to that notice. A done film with a downgrade, open
12
12
  // look items or no image tool blocks once so the reply says so.
13
- import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
13
+ import { existsSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
14
14
  import { dirname, isAbsolute, join, resolve } from "node:path";
15
15
 
16
- import { ensureStateDirIgnored, resolveProjectStateRoot } from "./project-state-root.mjs";
16
+ import { requireStateDir, resolveProjectStateRoot, STATE_WRITE_FLAG } from "./project-state-root.mjs";
17
17
 
18
18
  export const MOTION_MAX_BLOCKS = 2;
19
19
  export const MOTION_DISCIPLINE = "lit-typographic-motion";
@@ -43,10 +43,9 @@ const readTurn = (cwd) => {
43
43
 
44
44
  const writeTurn = (cwd, state) => {
45
45
  const target = motionTurnPath(cwd);
46
- mkdirSync(join(target, ".."), { recursive: true });
47
- ensureStateDirIgnored(target);
46
+ requireStateDir(join(target, ".."));
48
47
  const tmp = `${target}.tmp`;
49
- writeFileSync(tmp, JSON.stringify(state));
48
+ writeFileSync(tmp, JSON.stringify(state), { flag: STATE_WRITE_FLAG });
50
49
  renameSync(tmp, target);
51
50
  return state;
52
51
  };
@@ -1,5 +1,5 @@
1
- import { closeSync, constants, existsSync, lstatSync, openSync, writeSync } from "node:fs";
2
- import { basename, dirname, join, resolve } from "node:path";
1
+ import { closeSync, constants, existsSync, lstatSync, mkdirSync, openSync, writeSync } from "node:fs";
2
+ import { basename, dirname, join, resolve, sep } from "node:path";
3
3
 
4
4
  import { findProjectRoot } from "./rules/discovery.mjs";
5
5
 
@@ -52,3 +52,45 @@ export const ensureStateDirIgnored = (pathInsideState) => {
52
52
  if (fd !== undefined) closeSync(fd);
53
53
  }
54
54
  };
55
+
56
+ // Creates `dir` inside a project's state folder one level at a time and returns false, creating
57
+ // nothing more, when `.litclaude` or any folder below it is a symlink or not a folder: a cloned
58
+ // repository can carry such a link, and following it would write LitClaude state anywhere the user
59
+ // can write. Every state writer calls this before writing and gives up on false.
60
+ export const prepareStateDir = (dir) => {
61
+ const target = resolve(dir);
62
+ const parts = target.split(sep);
63
+ const at = parts.indexOf(PROJECT_STATE_DIR);
64
+ if (at <= 0) return false;
65
+ try {
66
+ mkdirSync(parts.slice(0, at).join(sep) || sep, { recursive: true });
67
+ let current = parts.slice(0, at).join(sep) || sep;
68
+ for (const part of parts.slice(at)) {
69
+ current = join(current, part);
70
+ try {
71
+ mkdirSync(current);
72
+ } catch (error) {
73
+ if (error?.code !== "EEXIST") return false;
74
+ }
75
+ const stats = lstatSync(current);
76
+ if (stats.isSymbolicLink() || !stats.isDirectory()) return false;
77
+ }
78
+ } catch {
79
+ return false;
80
+ }
81
+ ensureStateDirIgnored(target);
82
+ return true;
83
+ };
84
+
85
+ // Open flags for a state file write that fails on a symlink at the file itself instead of following it.
86
+ export const STATE_WRITE_FLAG = constants.O_WRONLY | constants.O_CREAT | constants.O_TRUNC | (constants.O_NOFOLLOW ?? 0);
87
+ export const STATE_APPEND_FLAG = constants.O_WRONLY | constants.O_CREAT | constants.O_APPEND | (constants.O_NOFOLLOW ?? 0);
88
+
89
+ /** `prepareStateDir` for writers that must stop: throws on a refused state folder. */
90
+ export const requireStateDir = (dir) => {
91
+ if (!resolve(dir).split(sep).includes(PROJECT_STATE_DIR)) {
92
+ mkdirSync(dir, { recursive: true });
93
+ return;
94
+ }
95
+ if (!prepareStateDir(dir)) throw new Error("the LitClaude state folder is a symlink or not a folder; refusing to write");
96
+ };