@litfamily/litclaude 1.0.42 → 1.0.44

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 (117) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +8 -8
  3. package/README_ko-KR.md +8 -8
  4. package/TRADEMARK.md +12 -0
  5. package/bin/litclaude-ai.js +58 -5
  6. package/docs/assets/readme/badge-version.svg +1 -1
  7. package/docs/hooks.md +35 -6
  8. package/package.json +2 -1
  9. package/plugins/litclaude/.claude-plugin/plugin.json +7 -1
  10. package/plugins/litclaude/agents/korean-prose-editor.md +2 -0
  11. package/plugins/litclaude/agents/korean-style-analyzer.md +2 -0
  12. package/plugins/litclaude/agents/librarian-researcher.md +2 -0
  13. package/plugins/litclaude/agents/lit-executor.md +2 -0
  14. package/plugins/litclaude/agents/lit-planner.md +2 -0
  15. package/plugins/litclaude/agents/lit-verifier.md +2 -0
  16. package/plugins/litclaude/agents/meaning-preservation-auditor.md +2 -0
  17. package/plugins/litclaude/agents/native-flow-reviewer.md +2 -0
  18. package/plugins/litclaude/agents/polish-orchestrator.md +2 -0
  19. package/plugins/litclaude/agents/qa-runner.md +2 -0
  20. package/plugins/litclaude/agents/quality-reviewer.md +2 -0
  21. package/plugins/litclaude/bin/litclaude-hook.js +24 -5
  22. package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
  23. package/plugins/litclaude/commands/litgoal.md +3 -1
  24. package/plugins/litclaude/hooks/lit-band-client.mjs +9 -4
  25. package/plugins/litclaude/hooks/lit-mod.mjs +9 -1
  26. package/plugins/litclaude/lib/canonical-runtime-commitments.mjs +6 -6
  27. package/plugins/litclaude/lib/canonical-skill-resources.mjs +49 -46
  28. package/plugins/litclaude/lib/invite.mjs +131 -0
  29. package/plugins/litclaude/lib/litgoal/autoloop.mjs +57 -8
  30. package/plugins/litclaude/lib/litgoal/cli.mjs +62 -1
  31. package/plugins/litclaude/lib/litgoal/freshness.mjs +55 -0
  32. package/plugins/litclaude/lib/litgoal/ledger.mjs +1 -1
  33. package/plugins/litclaude/lib/litgoal/state.mjs +1 -1
  34. package/plugins/litclaude/lib/litgoal/unknowns.mjs +44 -0
  35. package/plugins/litclaude/lib/mark-logo.png +0 -0
  36. package/plugins/litclaude/lib/mark.mjs +375 -0
  37. package/plugins/litclaude/lib/mod/frame.mjs +88 -19
  38. package/plugins/litclaude/lib/mod/looks.mjs +13 -0
  39. package/plugins/litclaude/lib/mod/motion.mjs +5 -0
  40. package/plugins/litclaude/lib/mod/settings.mjs +5 -2
  41. package/plugins/litclaude/lib/mod/state.mjs +18 -0
  42. package/plugins/litclaude/lib/mod/svg-card.mjs +61 -16
  43. package/plugins/litclaude/lib/mod/timeline.mjs +32 -0
  44. package/plugins/litclaude/lib/mod/view.mjs +8 -3
  45. package/plugins/litclaude/lib/official-build.mjs +22 -0
  46. package/plugins/litclaude/lib/output_mark.py +132 -0
  47. package/plugins/litclaude/lib/owner-lock.mjs +11 -1
  48. package/plugins/litclaude/lib/plan-task-rows.mjs +17 -4
  49. package/plugins/litclaude/lib/render_pages.py +16 -0
  50. package/plugins/litclaude/lib/rewind/collect.mjs +58 -5
  51. package/plugins/litclaude/lib/start-work-lifecycle.mjs +45 -10
  52. package/plugins/litclaude/skills/autoconference/SKILL.md +2 -0
  53. package/plugins/litclaude/skills/autoresearch/SKILL.md +2 -0
  54. package/plugins/litclaude/skills/browser-drive/SKILL.md +2 -0
  55. package/plugins/litclaude/skills/comment-checker/SKILL.md +2 -0
  56. package/plugins/litclaude/skills/debugging/SKILL.md +2 -0
  57. package/plugins/litclaude/skills/deep-interview/SKILL.md +2 -0
  58. package/plugins/litclaude/skills/frontend-ui-ux/SKILL.md +2 -0
  59. package/plugins/litclaude/skills/lit-adhd/SKILL.md +3 -0
  60. package/plugins/litclaude/skills/lit-brainstorm/SKILL.md +2 -0
  61. package/plugins/litclaude/skills/lit-burnoff/SKILL.md +2 -0
  62. package/plugins/litclaude/skills/lit-burnoff-file/SKILL.md +2 -0
  63. package/plugins/litclaude/skills/lit-code/SKILL.md +2 -0
  64. package/plugins/litclaude/skills/lit-commit/SKILL.md +2 -0
  65. package/plugins/litclaude/skills/lit-comprehend/SKILL.md +2 -0
  66. package/plugins/litclaude/skills/lit-crucible/SKILL.md +2 -0
  67. package/plugins/litclaude/skills/lit-diagram-drawer/SKILL.md +3 -1
  68. package/plugins/litclaude/skills/lit-diagram-drawer/scripts/export.mjs +35 -1
  69. package/plugins/litclaude/skills/lit-docx/SKILL.md +2 -0
  70. package/plugins/litclaude/skills/lit-docx/scripts/convert_md_to_docx.py +4 -1
  71. package/plugins/litclaude/skills/lit-docx/scripts/convert_md_to_pdf.py +2 -0
  72. package/plugins/litclaude/skills/lit-handoff/SKILL.md +2 -0
  73. package/plugins/litclaude/skills/lit-hijack/SKILL.md +2 -0
  74. package/plugins/litclaude/skills/lit-humanizer/SKILL.md +2 -0
  75. package/plugins/litclaude/skills/lit-init/SKILL.md +2 -0
  76. package/plugins/litclaude/skills/lit-loop/SKILL.md +2 -0
  77. package/plugins/litclaude/skills/lit-plan/SKILL.md +2 -0
  78. package/plugins/litclaude/skills/lit-pptx/SKILL.md +2 -0
  79. package/plugins/litclaude/skills/lit-pptx/scripts/lib/render-adapter-pptx.js +6 -1
  80. package/plugins/litclaude/skills/lit-recap/SKILL.md +2 -0
  81. package/plugins/litclaude/skills/lit-schematic/SKILL.md +3 -1
  82. package/plugins/litclaude/skills/lit-schematic/scripts/lib/sheet.mjs +10 -0
  83. package/plugins/litclaude/skills/lit-schematic/scripts/lib/svg.mjs +4 -0
  84. package/plugins/litclaude/skills/lit-schematic/scripts/motion.mjs +5 -2
  85. package/plugins/litclaude/skills/lit-schematic/scripts/render.mjs +20 -2
  86. package/plugins/litclaude/skills/lit-scientific-visualization/SKILL.md +2 -0
  87. package/plugins/litclaude/skills/lit-team/SKILL.md +2 -0
  88. package/plugins/litclaude/skills/lit-typographic-motion/SKILL.md +2 -0
  89. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/chrome.mjs +23 -2
  90. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-capture.mjs +14 -1
  91. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover.mjs +48 -2
  92. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/encode.mjs +8 -1
  93. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/end-card.mjs +128 -0
  94. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/pipeline.mjs +59 -14
  95. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-gate.mjs +7 -4
  96. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage.mjs +29 -7
  97. package/plugins/litclaude/skills/lit-typographic-motion/references/studio.md +11 -0
  98. package/plugins/litclaude/skills/litgoal/SKILL.md +53 -1
  99. package/plugins/litclaude/skills/litresearch/SKILL.md +2 -0
  100. package/plugins/litclaude/skills/litwork/SKILL.md +2 -0
  101. package/plugins/litclaude/skills/lsp/SKILL.md +2 -0
  102. package/plugins/litclaude/skills/lsp-setup/SKILL.md +2 -0
  103. package/plugins/litclaude/skills/readme-studio/SKILL.md +3 -1
  104. package/plugins/litclaude/skills/readme-studio/templates/cover-source.json +1 -0
  105. package/plugins/litclaude/skills/readme-studio/templates/hyperframes-cover/index.html +3 -2
  106. package/plugins/litclaude/skills/readme-studio/templates/remotion-cover/package-lock.json +3 -3
  107. package/plugins/litclaude/skills/readme-studio/templates/remotion-cover/package.json +2 -1
  108. package/plugins/litclaude/skills/readme-studio/templates/remotion-cover/src/index.tsx +4 -3
  109. package/plugins/litclaude/skills/refactor/SKILL.md +2 -0
  110. package/plugins/litclaude/skills/review-work/SKILL.md +2 -0
  111. package/plugins/litclaude/skills/rules/SKILL.md +2 -0
  112. package/plugins/litclaude/skills/start-work/SKILL.md +7 -0
  113. package/plugins/litclaude/skills/structural-search/SKILL.md +2 -0
  114. package/plugins/litclaude/skills/visual-qa/SKILL.md +2 -0
  115. package/plugins/litclaude/skills/wikify/SKILL.md +2 -0
  116. package/scripts/doctor.mjs +3 -1
  117. package/scripts/prepublish-test-gate.mjs +75 -22
@@ -519,6 +519,24 @@ export const readLitSnapshot = async (io, { cwd, sessionId, env = {} }) => {
519
519
  };
520
520
  };
521
521
 
522
+ // Where `lit invite` keeps its record (lib/invite.mjs inviteHome): LITCLAUDE_HOME, else ~/.litclaude.
523
+ export const inviteRoot = (env) => {
524
+ // Untrimmed, like lib/invite.mjs and resolveHome, so the card reads the file the CLI wrote.
525
+ const home = env?.LITCLAUDE_HOME;
526
+ if (home) return normalizePath(home);
527
+ return env?.HOME?.trim() ? joinPath(env.HOME.trim(), ".litclaude") : null;
528
+ };
529
+ // lib/invite.mjs's id rule; the band cannot import that module, which writes.
530
+ const INVITE_ID = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/u;
531
+
532
+ /** The recorded inviter's id from a real, well-formed invite.json under inviteRoot (read guarded), or null. */
533
+ export const readInvited = async (io, env) => {
534
+ const root = inviteRoot(env);
535
+ if (!root) return null;
536
+ const record = await readGuardedJson(io, root, "invite.json", 4096);
537
+ return record?.version === 1 && typeof record.invitedBy === "string" && INVITE_ID.test(record.invitedBy) ? record.invitedBy : null;
538
+ };
539
+
522
540
  /**
523
541
  * The LitClaude version Claude Code installed, from its `installed_plugins.json` record: the
524
542
  * `litclaude@…` entry, user scope first. Anything unreadable or malformed gives null.
@@ -22,7 +22,7 @@
22
22
 
23
23
  import { gauge, knownFacts } from "../rewind/gauge.mjs";
24
24
  import { textWidth, truncateToWidth } from "./layout.mjs";
25
- import { LOOKS, lookOf } from "./looks.mjs";
25
+ import { CLUB_GLINT, CLUB_GOLD, CLUB_PILL, CLUB_STOPS, LOOKS, lookOf } from "./looks.mjs";
26
26
  import { TIMINGS, barCells, gradientAt, rainbowAt } from "./motion.mjs";
27
27
 
28
28
  const C = Object.freeze({
@@ -105,6 +105,7 @@ const indicatorOf = (model, accent) => {
105
105
  if (model.completion) return { label: "DONE ✓", fill: C.green };
106
106
  if (model.look === "turn") return { label: LOOKS.turn.label, fill: C.amber };
107
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 };
108
+ if (model.look === "club") return { label: `${LOOKS.club.label} ✦`, fill: CLUB_GOLD };
108
109
  if (model.idle) return { label: "idle", fill: C.dim, plain: true };
109
110
  const flow = model.workflow;
110
111
  if (flow?.paused && flow.current >= 0) return { label: `${flow.stages[flow.current].id.toUpperCase()} ||`, fill: C.dim };
@@ -116,23 +117,32 @@ const indicatorOf = (model, accent) => {
116
117
  return { label: "LIVE ●", fill: accent };
117
118
  };
118
119
 
119
- // The rewind look draws the LIT pill and a `REWIND <<` indicator in the turning rainbow.
120
+ // The rewind look draws the LIT pill and a `REWIND <<` indicator in the turning rainbow; the club
121
+ // look a gold pill after a `✧`, a rose title closed by a `✦`, and `CLUB ✦` on its gold-gradient pill.
120
122
  const topRow = (model, accent, animate, rewind = false) => {
121
123
  const { width, pad } = SVG_CARD;
122
124
  const y = ROW_Y[0];
125
+ const club = model.look === "club";
126
+ const lead = club ? text(pad, y, "✧", { fill: CLUB_STOPS[1] }) : "";
127
+ const from = club ? pad + widthOf("✧ ") : pad;
123
128
  const brand = rewind
124
- ? pill(pad, y, "🔥 LIT", { fill: "url(#lit-rainbow)", ink: C.ink, veil: true })
125
- : pill(pad, y, "🔥 LIT", { fill: C.pink, ink: C.ink, breath: animate.breath ? C.orange : null });
129
+ ? pill(from, y, "🔥 LIT", { fill: "url(#lit-rainbow)", ink: C.ink, veil: true })
130
+ : pill(from, y, "🔥 LIT", { fill: club ? CLUB_GOLD : C.pink, ink: C.ink, breath: animate.breath ? C.orange : null });
126
131
  const indicator = rewind && !model.completion ? { label: "REWIND <<", fill: "url(#lit-rainbow)" } : indicatorOf(model, accent);
132
+ // The club pill is 16 wider than the bare indicator text; it ends where the text would.
133
+ const pillWide = club ? 16 : 0;
127
134
  // A newer LitClaude installed than the one loaded: `restart to <version>` left of the indicator.
128
135
  const chip = model.restart ? `restart to ${model.restart}` : null;
129
- const chipEnd = width - pad - widthOf(indicator.label) - 16;
130
- const right = text(width - pad, y, indicator.label, { fill: indicator.fill, bold: !indicator.plain, anchor: "end" })
131
- + (chip ? text(chipEnd, y, chip, { fill: C.amber, anchor: "end" }) : "");
132
- const room = width - pad - widthOf(indicator.label) - 16 - (chip ? widthOf(chip) + 16 : 0) - brand.end - widthOf(" · ");
136
+ const chipEnd = width - pad - widthOf(indicator.label) - 16 - pillWide;
137
+ const label = club
138
+ ? pill(width - pad - widthOf(indicator.label) - 16, y, indicator.label, { fill: "url(#lit-club-pill)", ink: C.ink }).markup
139
+ : text(width - pad, y, indicator.label, { fill: indicator.fill, bold: !indicator.plain, anchor: "end" });
140
+ const right = label + (chip ? text(chipEnd, y, chip, { fill: C.amber, anchor: "end" }) : "");
141
+ const tail = club ? " ✦" : "";
142
+ const room = width - pad - widthOf(indicator.label) - 16 - pillWide - (chip ? widthOf(chip) + 16 : 0) - brand.end - widthOf(" · ") - widthOf(tail);
133
143
  const name = truncateToWidth(model.title ?? "ready", Math.max(4, Math.floor(room / SVG_CARD.cell)));
134
- const title = run(brand.end + 4, y, [[" · ", { fill: C.dim }], [name, model.idle && !rewind ? { fill: C.dim } : { fill: accent, bold: true }]]);
135
- return brand.markup + title.markup + right;
144
+ const title = run(brand.end + 4, y, [[" · ", { fill: C.dim }], [name, club ? { fill: CLUB_STOPS[1] } : model.idle && !rewind ? { fill: C.dim } : { fill: accent, bold: true }], ...(club ? [[tail, { fill: CLUB_GOLD }]] : [])]);
145
+ return lead + brand.markup + title.markup + right;
136
146
  };
137
147
 
138
148
  const rightOfPhases = (model, withProgress = true) => {
@@ -310,6 +320,18 @@ const detailRowSvg = (model, accent, animate) => {
310
320
  const TONES = Object.freeze({ pink: [C.pink, "#ff6fae", "🔥"], amber: [C.amber, C.amber, "⚠"], red: [C.red, C.red, "✗"] });
311
321
 
312
322
  // Skill chips, or the notice or the finish while one is up, or the hint while nothing has fired.
323
+ // The club card's quiet `invited by @<id>` chip on the muted pill, ending at the card's right pad;
324
+ // drawn only when it clears whatever the row already holds (ending at `after`) by 16.
325
+ const inviteChipSvg = (model, y, after) => {
326
+ if (!model.invitedBy || after === null) return "";
327
+ const handle = `@${model.invitedBy}`;
328
+ const w = widthOf(`invited by ${handle}`) + 16;
329
+ const x = SVG_CARD.width - SVG_CARD.pad - w;
330
+ if (x < after + 16) return "";
331
+ return `<rect x="${x.toFixed(1)}" y="${y - PILL_H + 6}" width="${w.toFixed(1)}" height="${PILL_H}" rx="${PILL_H / 2}" fill="${C.muted}"/>`
332
+ + run(x + 8, y, [["invited by ", { fill: C.mutedText }], [handle, { fill: CLUB_STOPS[1], bold: true }]]).markup;
333
+ };
334
+
313
335
  const middleRow = (model, accent, animate, shift = 0, rewind = false) => {
314
336
  const { width, pad } = SVG_CARD;
315
337
  const y = ROW_Y[3] + shift;
@@ -325,7 +347,8 @@ const middleRow = (model, accent, animate, shift = 0, rewind = false) => {
325
347
  if (model.skills.length === 0) {
326
348
  if (!model.idle && model.next && !model.workflow?.next) return run(pad, y, [["▸ ", { fill: accent }], [truncateToWidth(model.next, Math.floor((room - pad) / SVG_CARD.cell) - 2), { fill: C.white }]]).markup;
327
349
  if (!model.idle) return text(pad, y, "no LitFamily skill yet in this request", { fill: C.dim });
328
- return run(pad, y, [["no LitFamily skill yet · type ", { fill: C.dim }], ["lit <task>", { fill: accent }], [" to start one", { fill: C.dim }]]).markup;
350
+ const hint = run(pad, y, [["no LitFamily skill yet · type ", { fill: C.dim }], ["lit <task>", { fill: accent }], [" to start one", { fill: C.dim }]]);
351
+ return hint.markup + inviteChipSvg(model, y, hint.end);
329
352
  }
330
353
  const out = [text(pad, y, "skills", { fill: C.dim })];
331
354
  let x = pad + widthOf("skills") + 10;
@@ -349,6 +372,7 @@ const middleRow = (model, accent, animate, shift = 0, rewind = false) => {
349
372
  });
350
373
  if (rewind && animate.sweep && x !== null) out.push(sparksSvg(x, width - pad, y));
351
374
  if (model.away && x !== null && x + widthOf("back? type lit adhd to catch up") <= room) out.push(run(x, y, [["back? type ", { fill: C.dim }], ["lit adhd", { fill: accent }], [" to catch up", { fill: C.dim }]]).markup);
375
+ else out.push(inviteChipSvg(model, y, x));
352
376
  return out.join("");
353
377
  };
354
378
 
@@ -509,6 +533,25 @@ const rainbowDefs = (animate) => {
509
533
  return `<defs><linearGradient id="lit-rainbow" x1="0" x2="1" y1="0" y2="1">${stops.join("")}</linearGradient></defs>`;
510
534
  };
511
535
 
536
+ // The club look's ring: gold on the left side through rose to violet on the right, so the top edge
537
+ // and the bottom edge each carry the whole velvet and the ring closes gold on gold at the left, as
538
+ // the terminal card lays it clockwise. The pill gradient fills `CLUB ✦`.
539
+ const gradientStops = (stops) => stops.map((color, i) => `<stop offset="${(i / (stops.length - 1)).toFixed(3)}" stop-color="${color}"/>`).join("");
540
+ const clubDefs = () => `<defs><linearGradient id="lit-club" x1="0" x2="1" y1="0" y2="0">${gradientStops(CLUB_STOPS.slice(0, 3))}</linearGradient>`
541
+ + `<linearGradient id="lit-club-pill" x1="0" x2="1" y1="0" y2="0">${gradientStops(CLUB_PILL)}</linearGradient></defs>`;
542
+
543
+ // The club glint (full motion only): a warm light crossing the top edge left to right in
544
+ // TIMINGS.clubGlint, then off the card until the next pass, TIMINGS.clubGlintPeriod apart. The first
545
+ // pass waits TIMINGS.clubGlintRest, as on the terminal card.
546
+ const clubGlintSvg = (width) => {
547
+ const reach = 120;
548
+ const pass = (TIMINGS.clubGlint / TIMINGS.clubGlintPeriod).toFixed(3);
549
+ return `<defs><linearGradient id="lit-club-glint" gradientUnits="userSpaceOnUse" x1="${-reach}" x2="0" y1="0" y2="0">`
550
+ + `<stop offset="0" stop-color="${CLUB_GLINT}" stop-opacity="0"/><stop offset="0.5" stop-color="${CLUB_GLINT}" stop-opacity="0.95"/><stop offset="1" stop-color="${CLUB_GLINT}" stop-opacity="0"/>`
551
+ + `<animateTransform attributeName="gradientTransform" type="translate" values="0 0;${width + reach} 0;${width + reach} 0" keyTimes="0;${pass};1" dur="${TIMINGS.clubGlintPeriod}ms" begin="${TIMINGS.clubGlintRest}ms" repeatCount="indefinite"/>`
552
+ + `</linearGradient></defs><line x1="15" y1="1.25" x2="${width - 15}" y2="1.25" stroke="url(#lit-club-glint)" stroke-width="2.5" stroke-linecap="round"/>`;
553
+ };
554
+
512
555
  /** What the card says, for a reader that cannot see the drawing. */
513
556
  export const svgCardAlt = (model) => {
514
557
  const parts = [`LIT ${model.rewind ? "rewind" : model.idle ? "idle" : "working"}`];
@@ -544,12 +587,13 @@ export const composeSvgCard = (model, { motion = "full", accent = "#5fd7ff" } =
544
587
  const rewind = (model.rewind === true || (!model.idle && lookOf(model.discipline) === "rewind")) && model.warnings.length === 0;
545
588
  const working = (!model.idle || rewind) && motion !== "off";
546
589
  const animate = { breath: working, sweep: working && motion === "full", comet: working && motion === "full" };
547
- const edge = rewind ? "url(#lit-rainbow)" : borderColor(model, accent);
590
+ const club = model.look === "club" && model.warnings.length === 0;
591
+ const edge = rewind ? "url(#lit-rainbow)" : club ? "url(#lit-club)" : borderColor(model, accent);
548
592
  const perimeter = 1000;
549
- const defs = (rewind ? rainbowDefs(animate.breath) : "") + (animate.sweep
593
+ const defs = (rewind ? rainbowDefs(animate.breath) : club ? clubDefs() : "") + (animate.sweep
550
594
  ? `<defs><linearGradient id="lit-sweep" x1="0" x2="1" y1="0" y2="0"><stop offset="0" stop-color="#fff" stop-opacity="0"/><stop offset="0.5" stop-color="#fff" stop-opacity="0.55"/><stop offset="1" stop-color="#fff" stop-opacity="0"/><animateTransform attributeName="gradientTransform" type="translate" values="-1.2 0;1.2 0" ${loop(TIMINGS.sweep, 0.5)}/></linearGradient></defs>`
551
595
  : "");
552
- const frame = `<rect x="1" y="1" width="${width - 2}" height="${height - 2}" rx="14" fill="${C.bg}" stroke="${edge}" stroke-width="${model.idle && !rewind ? "1.5" : "2.5"}"${model.idle && !rewind ? ' stroke-opacity="0.8"' : ""}>`
596
+ const frame = `<rect x="1" y="1" width="${width - 2}" height="${height - 2}" rx="14" fill="${C.bg}" stroke="${edge}" stroke-width="${model.idle && !rewind && !club ? "1.5" : "2.5"}"${model.idle && !rewind && !club ? ' stroke-opacity="0.8"' : ""}>`
553
597
  + (animate.breath && !model.warnings.length ? `<animate attributeName="stroke-opacity" values="0.85;1;0.85" ${loop(TIMINGS.breath, BREATH_PHASE)}/>` : "")
554
598
  + "</rect>";
555
599
  const comet = animate.comet
@@ -564,6 +608,7 @@ export const composeSvgCard = (model, { motion = "full", accent = "#5fd7ff" } =
564
608
  middleRow(model, accent, animate, shift, rewind),
565
609
  bottomRow(model, accent, shift),
566
610
  ].join("");
567
- const source = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" font-family="${FONT}" font-size="${SVG_CARD.font}">${defs}${frame}${comet}${body}</svg>`;
568
- return { source, alt: svgCardAlt(model), animated: working };
611
+ const glint = club && motion === "full" ? clubGlintSvg(width) : "";
612
+ const source = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" font-family="${FONT}" font-size="${SVG_CARD.font}">${defs}${frame}${comet}${glint}${body}</svg>`;
613
+ return { source, alt: svgCardAlt(model), animated: working || glint !== "" };
569
614
  };
@@ -45,10 +45,18 @@ const ambientOf = (model, now, profile, previous = null) => {
45
45
  return { on, at: on && previous?.on ? previous.at : now };
46
46
  };
47
47
 
48
+ // The club look's glint runs on the idle card, so it keeps its own clock apart from the ambient
49
+ // loop: between passes nothing moves and the surface waits for the next one (glintWait).
50
+ const glintOf = (model, now, profile, previous = null) => {
51
+ const on = Boolean(profile.ambient?.sweep) && model.visible && model.look === "club";
52
+ return { on, at: on && previous?.on ? previous.at : now };
53
+ };
54
+
48
55
  export const createTimeline = (model, now, profile) => {
49
56
  const restAt = now + entryEnd(profile);
50
57
  return {
51
58
  ambient: ambientOf(model, now, profile),
59
+ glint: glintOf(model, now, profile),
52
60
  enterAt: now,
53
61
  exitAt: null,
54
62
  fill: { from: 0, to: fractionOf(model), at: restAt, dur: profile.duration(TIMINGS.fill) },
@@ -90,6 +98,7 @@ export const advanceTimeline = (timeline, model, now, profile) => {
90
98
  }
91
99
  next.chips = chipsOf(model, now, timeline.chips);
92
100
  next.ambient = ambientOf(model, now, profile, timeline.ambient);
101
+ next.glint = glintOf(model, now, profile, timeline.glint);
93
102
  next.step = stepOf(model, now);
94
103
  next.lanes = lanesOf(model, now);
95
104
  return next;
@@ -101,6 +110,28 @@ export const clockShown = (timeline) => timeline.exitAt === null && Boolean(time
101
110
  /** True while the ambient loop runs; the surface module then keeps a slower frame timer going. */
102
111
  export const ambientActive = (timeline, profile) => Boolean(profile.ambient) && timeline.exitAt === null && timeline.ambient.on;
103
112
 
113
+ // Where the club glint stands: 0 to 1 across the current pass, or null between passes, before the
114
+ // first one and while the glint is off.
115
+ const glintAt = (timeline, now) => {
116
+ if (!timeline.glint?.on || timeline.exitAt !== null) return null;
117
+ const elapsed = now - timeline.glint.at - TIMINGS.clubGlintRest;
118
+ if (elapsed < 0) return null;
119
+ const into = elapsed % TIMINGS.clubGlintPeriod;
120
+ return into < TIMINGS.clubGlint ? into / TIMINGS.clubGlint : null;
121
+ };
122
+
123
+ /**
124
+ * How long the surface may wait before its next frame for the club glint: a frame interval while a
125
+ * pass runs, the time left until the next pass otherwise, and null when the glint is off.
126
+ */
127
+ export const glintWait = (timeline, now, profile) => {
128
+ if (!profile.ambient?.sweep || !timeline.glint?.on || timeline.exitAt !== null) return null;
129
+ const elapsed = now - timeline.glint.at - TIMINGS.clubGlintRest;
130
+ if (elapsed < 0) return -elapsed;
131
+ const into = elapsed % TIMINGS.clubGlintPeriod;
132
+ return into < TIMINGS.clubGlint ? TIMINGS.ambientFrame : TIMINGS.clubGlintPeriod - into;
133
+ };
134
+
104
135
  // The rewind look's sparks: fixed seeds (a small LCG, so every surface draws the same sky), each a
105
136
  // starting place, a drift speed and a twinkle offset.
106
137
  const SPARK_SEEDS = (() => {
@@ -217,6 +248,7 @@ export const sampleTimeline = (timeline, now, profile) => {
217
248
  completion,
218
249
  chips,
219
250
  ambient: ambientSample(timeline, now, profile),
251
+ glint: glintAt(timeline, now),
220
252
  step: timeline.step ? { name: timeline.step.name, elapsedMs: timeline.step.base + Math.max(0, now - timeline.step.at) } : null,
221
253
  lanes: timeline.lanes ? { elapsedMs: timeline.lanes.base + Math.max(0, now - timeline.lanes.at) } : null,
222
254
  spin: Math.floor(Math.max(0, now) / TIMINGS.spin) % 4,
@@ -460,7 +460,7 @@ export const restartVersion = ({ loaded = null, installed = null } = {}) => {
460
460
  return order > 0 ? installed.slice(0, 40) : null;
461
461
  };
462
462
 
463
- 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, versions = null }) => {
463
+ 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, versions = null, club = false, invitedBy = null }) => {
464
464
  const discipline = snapshot.ignition?.discipline ?? null;
465
465
  const progress = progressOf(snapshot);
466
466
  const completing = completion !== null;
@@ -490,15 +490,20 @@ export const buildBandModel = ({ snapshot, agents = [], activity = EMPTY_ACTIVIT
490
490
  const lit = skills.some(({ state }) => state === "current");
491
491
  const workflow = buildWorkflow({ snapshot, skills, completion, now });
492
492
  const title = discipline ?? skills.find(({ state }) => state === "current")?.id ?? lastDiscipline;
493
- const look = selectLook({ snapshot, discipline, skills, workflow, completion, waiting, now, turnStartedAt });
493
+ const chosen = selectLook({ snapshot, discipline, skills, workflow, completion, waiting, now, turnStartedAt });
494
+ // `club` (an inviter recorded and the club option on) dresses only the idle card, and never
495
+ // shows a band that `band: auto` would hide.
496
+ const look = chosen ?? (club === true && !active && !lit ? "club" : null);
494
497
  const rewind = look === "rewind";
495
- const visible = band === "off" ? false : band === "always" || active || lit || look !== null || notice !== null || completion !== null || warnings.length > 0;
498
+ const visible = band === "off" ? false : band === "always" || active || lit || chosen !== null || notice !== null || completion !== null || warnings.length > 0;
496
499
  return {
497
500
  visible,
498
501
  idle: !active && !lit,
499
502
  restart: restartVersion(versions ?? undefined),
500
503
  look,
501
504
  rewind,
505
+ // Who invited this machine, for the club card's chip; null on every other look.
506
+ invitedBy: look === "club" && typeof invitedBy === "string" ? invitedBy : null,
502
507
  waiting: waiting?.reason ?? null,
503
508
  away: !active && !lit && !rewind && skills.length > 0 && now - Math.max(...skills.map(({ at }) => (Number.isFinite(at) ? at : now))) >= BREAK_MS,
504
509
  discipline,
@@ -0,0 +1,22 @@
1
+ // How a user tells the official LitClaude from a renamed or re-hosted copy: doctor prints the official package
2
+ // and repository, and warns when the running copy's package name or repository field differs. Local data only.
3
+
4
+ export const OFFICIAL_BUILD = Object.freeze({ packageName: "@litfamily/litclaude", repo: "wjgoarxiv/litclaude" });
5
+
6
+ /** `github.com/<owner>/<name>` from a package.json repository field, or null. */
7
+ const repoOf = (repository) => {
8
+ const url = typeof repository === "string" ? repository : repository?.url;
9
+ const m = /github\.com[/:]([^/\s]+)\/([^/\s#]+?)(?:\.git)?(?:[#/].*)?$/u.exec(String(url ?? ""));
10
+ return m ? `${m[1]}/${m[2]}` : null;
11
+ };
12
+
13
+ /** Doctor lines for a package.json: OFFICIAL_BUILD always, OFFICIAL_BUILD_WARNING when name or repo differ. */
14
+ export const officialBuildLines = (pkg) => {
15
+ const repo = repoOf(pkg.repository);
16
+ const official = `${OFFICIAL_BUILD.packageName} from github.com/${OFFICIAL_BUILD.repo}`;
17
+ const lines = [`OFFICIAL_BUILD: ${official} (this copy: ${pkg.name} ${pkg.version})`];
18
+ if (pkg.name !== OFFICIAL_BUILD.packageName || repo !== OFFICIAL_BUILD.repo) {
19
+ lines.push(`OFFICIAL_BUILD_WARNING: this copy is ${pkg.name} from ${repo ? `github.com/${repo}` : "an unnamed repository"}; the official build is ${official}. Install it with npx ${OFFICIAL_BUILD.packageName}@latest install`);
20
+ }
21
+ return lines;
22
+ };
@@ -0,0 +1,132 @@
1
+ """The `mark` setting for LitClaude's Python engines (lit-docx, lit-pptx); the same rules as mark.mjs.
2
+
3
+ `on` puts an invisible generator tag in every output and a visible mark on showcase outputs, `meta` keeps only
4
+ the invisible tag, `off` leaves outputs unmarked. The value lives in `<litHome>/config.json` (litHome is
5
+ LITCLAUDE_HOME or ~/.litclaude); LITCLAUDE_MARK overrides it for one run; anything unreadable reads as `on`.
6
+ No network, no clock.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import json
12
+ import os
13
+ import re
14
+ import zipfile
15
+ from pathlib import Path
16
+
17
+ MARK_MODES = ("on", "meta", "off")
18
+ _MAX_CONFIG_BYTES = 64 * 1024
19
+ _MANIFEST = Path(__file__).resolve().parent.parent / ".claude-plugin" / "plugin.json"
20
+
21
+
22
+ def _config_path() -> Path:
23
+ home = os.environ.get("LITCLAUDE_HOME") or str(Path.home() / ".litclaude")
24
+ return Path(home).resolve() / "config.json"
25
+
26
+
27
+ def _stored() -> str | None:
28
+ path = _config_path()
29
+ try:
30
+ if path.is_symlink() or not path.is_file() or path.stat().st_size > _MAX_CONFIG_BYTES:
31
+ return None
32
+ data = json.loads(path.read_text(encoding="utf-8"))
33
+ except (OSError, ValueError):
34
+ return None
35
+ return data.get("mark") if isinstance(data, dict) else None
36
+
37
+
38
+ def mode() -> str:
39
+ """The mode for this run: LITCLAUDE_MARK when valid, else the stored value, else `on`."""
40
+ override = os.environ.get("LITCLAUDE_MARK", "").strip().lower()
41
+ if override in MARK_MODES:
42
+ return override
43
+ stored = _stored()
44
+ return stored if stored in MARK_MODES else "on"
45
+
46
+
47
+ def generator() -> str:
48
+ """`LitClaude <version> · github.com/wjgoarxiv/litclaude`, the version taken from the plugin manifest."""
49
+ version = json.loads(_MANIFEST.read_text(encoding="utf-8"))["version"]
50
+ return f"LitClaude {version} · github.com/wjgoarxiv/litclaude"
51
+
52
+
53
+ def meta_generator() -> str | None:
54
+ """The generator string when this run tags outputs (`on` or `meta`), else None."""
55
+ return None if mode() == "off" else generator()
56
+
57
+
58
+ CUSTOM_PART = "docProps/custom.xml"
59
+ _CUSTOM_TYPE = "application/vnd.openxmlformats-officedocument.custom-properties+xml"
60
+ _CUSTOM_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties"
61
+ _FMTID = "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"
62
+
63
+
64
+ def _xml_text(value: str) -> str:
65
+ return value.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
66
+
67
+
68
+ def tag_ooxml_parts(parts: dict[str, str], gen: str) -> dict[str, str]:
69
+ """Return the changed package parts that name `gen`: app.xml <Application> and a custom `Generator`
70
+ property, with the content type and package relationship custom.xml needs. Other parts are untouched."""
71
+ text = _xml_text(gen)
72
+ out: dict[str, str] = {}
73
+ app = parts.get("docProps/app.xml")
74
+ if app is not None:
75
+ tag = f"<Application>{text}</Application>"
76
+ out["docProps/app.xml"] = re.sub(r"<Application>[^<]*</Application>|<Application/>", tag, app, count=1) \
77
+ if re.search(r"<Application[>/]", app) else app.replace("</Properties>", tag + "</Properties>", 1)
78
+ prop = f'<vt:lpwstr>{text}</vt:lpwstr></property>'
79
+ custom = parts.get(CUSTOM_PART)
80
+ if custom is None:
81
+ out[CUSTOM_PART] = ('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'
82
+ '<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" '
83
+ 'xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">'
84
+ f'<property fmtid="{_FMTID}" pid="2" name="Generator">{prop}</Properties>')
85
+ else:
86
+ existing = re.search(r'(<property [^>]*name="Generator"[^>]*>)[\s\S]*?</property>', custom)
87
+ if existing:
88
+ out[CUSTOM_PART] = custom.replace(existing.group(0), existing.group(1) + prop, 1)
89
+ else:
90
+ pid = max([int(p) for p in re.findall(r'\bpid="(\d+)"', custom)] or [1]) + 1
91
+ out[CUSTOM_PART] = custom.replace("</Properties>", f'<property fmtid="{_FMTID}" pid="{pid}" name="Generator">{prop}</Properties>', 1)
92
+ types = parts["[Content_Types].xml"]
93
+ if f'PartName="/{CUSTOM_PART}"' not in types:
94
+ out["[Content_Types].xml"] = types.replace("</Types>", f'<Override PartName="/{CUSTOM_PART}" ContentType="{_CUSTOM_TYPE}"/></Types>', 1)
95
+ rels = parts["_rels/.rels"]
96
+ if f'Target="{CUSTOM_PART}"' not in rels and f'Target="/{CUSTOM_PART}"' not in rels:
97
+ ids = [int(i) for i in re.findall(r'Id="rId(\d+)"', rels)]
98
+ rid = f"rId{max(ids or [0]) + 1}"
99
+ out["_rels/.rels"] = rels.replace("</Relationships>", f'<Relationship Id="{rid}" Type="{_CUSTOM_REL}" Target="{CUSTOM_PART}"/></Relationships>', 1)
100
+ return out
101
+
102
+
103
+ def tag_ooxml(path: Path | str) -> None:
104
+ """Tag a written .docx/.pptx in place when the mode is `on` or `meta`; `off` leaves the file as written."""
105
+ gen = meta_generator()
106
+ if gen is None:
107
+ return
108
+ path = Path(path)
109
+ names = ("docProps/app.xml", CUSTOM_PART, "[Content_Types].xml", "_rels/.rels")
110
+ with zipfile.ZipFile(path) as z:
111
+ infos = z.infolist()
112
+ data = {i.filename: z.read(i.filename) for i in infos}
113
+ changed = tag_ooxml_parts({n: data[n].decode("utf-8") for n in names if n in data}, gen)
114
+ tmp = path.with_name(path.name + ".mark.tmp")
115
+ with zipfile.ZipFile(tmp, "w", zipfile.ZIP_DEFLATED) as out:
116
+ for info in infos:
117
+ body = changed[info.filename].encode("utf-8") if info.filename in changed else data[info.filename]
118
+ out.writestr(info, body, compress_type=zipfile.ZIP_DEFLATED)
119
+ if CUSTOM_PART not in data:
120
+ out.writestr(CUSTOM_PART, changed[CUSTOM_PART].encode("utf-8"))
121
+ os.replace(tmp, path)
122
+
123
+
124
+ def tag_latex(tex: str, gen: str | None) -> str:
125
+ """Add a dvipdfmx docinfo special (Creator and Producer, UTF-16 hex) right after \\begin{document}.
126
+ It runs after hyperref's begin-document hooks, so it is the value that lands in the PDF."""
127
+ if gen is None or "\\begin{document}" not in tex:
128
+ return tex
129
+ hexed = "FEFF" + gen.encode("utf-16-be").hex().upper()
130
+ special = f"\\special{{pdf:docinfo<</Creator<{hexed}>/Producer<{hexed}>>>}}%\n"
131
+ head, tail = tex.split("\\begin{document}", 1)
132
+ return head + "\\begin{document}\n" + special + tail.removeprefix("\n")
@@ -50,6 +50,15 @@ const assertLockDirectory = (lockDir, expected) => {
50
50
  return identity;
51
51
  };
52
52
 
53
+ // A contender that loses a stale takeover finds the lock removed or replaced by the winner's
54
+ // fresh directory. That is a lost race to retry, not a failure; a symlink still fails closed.
55
+ const lockWasReplaced = (lockDir, expected) => {
56
+ const details = lstatSync(lockDir, { throwIfNoEntry: false });
57
+ if (!details) return true;
58
+ if (details.isSymbolicLink() || !details.isDirectory()) return false;
59
+ return !sameDirectory(directoryIdentity(details), expected);
60
+ };
61
+
53
62
  // Destructive cleanup is commit-by-rename: once the checked path is moved to a private
54
63
  // quarantine, a pathname replacement cannot make us remove the replacement. Re-checking the
55
64
  // moved entry catches Linux inode reuse (ctime/birthtime differ even when dev+ino are forged).
@@ -304,7 +313,8 @@ export const acquireOwnerLock = (lockDir, { timeoutMs = 500, staleMs = 30_000 }
304
313
  }
305
314
  }
306
315
  } catch (takeoverError) {
307
- if (!["ENOENT", "EEXIST", "ENOTEMPTY"].includes(takeoverError?.code)) {
316
+ if (!["ENOENT", "EEXIST", "ENOTEMPTY"].includes(takeoverError?.code)
317
+ && !lockWasReplaced(lockDir, lockDirectory)) {
308
318
  throw new OwnerLockError("stale lock takeover failed", 65);
309
319
  }
310
320
  }
@@ -25,8 +25,21 @@ export const planLinesOutsideFences = (text) => {
25
25
  return visible;
26
26
  };
27
27
 
28
+ // A task waits on the user when its line holds `BLOCKED:` outside inline code, or an indented body
29
+ // line under it starts with `BLOCKED:`. A mention such as `BLOCKED:` in backticks is not a marker.
30
+ const blockedLine = (line) => /\bBLOCKED:/u.test(line.replace(/`[^`]*`/gu, ""));
31
+ const blockedBodyLine = (line) => /^[ \t]+(?:[-*][ \t]+)?BLOCKED:/u.test(line);
32
+
28
33
  /** Parse the exact column-zero checkbox grammar consumed by start-work. */
29
- export const parsePlanTaskRows = (text) => planLinesOutsideFences(text).flatMap(({ line, index }) => {
30
- const match = /^- \[([ xX])\]\s+(.+?)\s*$/u.exec(line);
31
- return match ? [{ checked: match[1].toLowerCase() === "x", text: match[2], line, index }] : [];
32
- });
34
+ export const parsePlanTaskRows = (text) => {
35
+ const visible = planLinesOutsideFences(text);
36
+ return visible.flatMap(({ line, index }, at) => {
37
+ const match = /^- \[([ xX])\]\s+(.+?)\s*$/u.exec(line);
38
+ if (!match) return [];
39
+ let blocked = blockedLine(match[2]);
40
+ for (let next = at + 1; !blocked && next < visible.length && /^(?:[ \t]|$)/u.test(visible[next].line); next += 1) {
41
+ blocked = blockedBodyLine(visible[next].line);
42
+ }
43
+ return [{ checked: match[1].toLowerCase() === "x", text: match[2], line, index, ...(blocked ? { blocked } : {}) }];
44
+ });
45
+ };
@@ -77,9 +77,25 @@ def to_pdf(source: Path, out_dir: Path) -> tuple[Path | None, str]:
77
77
  pdf = out_dir / f"{source.stem}.pdf"
78
78
  if result.returncode != 0 or not pdf.exists():
79
79
  raise RuntimeError(f"soffice conversion failed: {(result.stderr or result.stdout).strip()[-400:]}")
80
+ tag_pdf(pdf)
80
81
  return pdf, "converted with soffice"
81
82
 
82
83
 
84
+ def tag_pdf(pdf: Path) -> None:
85
+ """Name LitClaude's generator as Creator and Producer of a PDF this script converted (mark setting `on` or
86
+ `meta`), saved incrementally so the pages stay byte for byte. A PDF given as input is never touched."""
87
+ import output_mark
88
+ import pymupdf
89
+
90
+ gen = output_mark.meta_generator()
91
+ if gen is None:
92
+ return
93
+ with pymupdf.open(pdf) as document:
94
+ keys = ("title", "author", "subject", "keywords", "creationDate", "modDate", "trapped")
95
+ document.set_metadata({**{k: document.metadata.get(k) or "" for k in keys}, "creator": gen, "producer": gen})
96
+ document.saveIncr()
97
+
98
+
83
99
  def rasterise(pdf: Path, out_dir: Path, pages: int, dpi: int) -> list[Path]:
84
100
  import pymupdf
85
101
 
@@ -89,6 +89,51 @@ const mtimeOf = (path) => {
89
89
  }
90
90
  };
91
91
 
92
+ // A plan run by a lane is ticked in the lane's worktree: its copy of the plan and its start-work
93
+ // ledger. A record counts for this plan only when the plan names that worktree (`.worktrees/<dir>`
94
+ // or `.claude/worktrees/<dir>`) and the ledger's plan file is this plan, by its name or its name
95
+ // without the `YYYY-MM-DD-` prefix. The best-progressed record wins; ties and worse keep the plan's own.
96
+ const WORKTREE_MENTION = /(?<![A-Za-z0-9_/-])((?:\.claude\/)?\.?worktrees\/[A-Za-z0-9_-][A-Za-z0-9._-]{0,79})/gu;
97
+ const MENTIONS_MAX = 12;
98
+ const isDirectory = (path) => {
99
+ try {
100
+ return lstatSync(path).isDirectory();
101
+ } catch {
102
+ return false;
103
+ }
104
+ };
105
+ const laneRecordsOf = (root, name, text, budget, redact) => {
106
+ const stem = name.replace(/^\d{4}-\d{2}-\d{2}-/u, "");
107
+ const mentions = [...new Set([...text.matchAll(WORKTREE_MENTION)].map((match) => match[1].replace(/\.+$/u, "")))].slice(0, MENTIONS_MAX);
108
+ return mentions.flatMap((mention) => {
109
+ const tree = join(root, mention);
110
+ if (!isDirectory(tree)) return [];
111
+ const state = readJson(join(tree, ".litclaude", "boulder.json"), budget);
112
+ if (!state || typeof state.works !== "object" || state.works === null) return [];
113
+ return Object.values(state.works).flatMap((work) => {
114
+ const planName = work?.plan_name;
115
+ if (typeof planName !== "string" || !/^[A-Za-z0-9._-]+\.md$/u.test(planName) || (planName !== name && planName !== stem)) return [];
116
+ const copy = readSmallFile(join(tree, "plans", planName), budget);
117
+ const rows = copy === null ? [] : parsePlanTaskRows(copy);
118
+ if (rows.length) {
119
+ const open = rows.filter((row) => !row.checked);
120
+ return [{
121
+ recordedIn: `${mention}/plans/${planName}`,
122
+ rows: rows.map((row) => ({ checked: row.checked, title: clipToWidth(redact(row.text), NAME_MAX) })),
123
+ current: open.length ? clipToWidth(redact(open[0].text), NAME_MAX) : null,
124
+ progress: progressOf(rows.length - open.length, rows.length, open.map((row) => clipToWidth(redact(row.text), NAME_MAX))),
125
+ }];
126
+ }
127
+ const { checked, total, next_task: next } = work.progress ?? {};
128
+ if (!Number.isInteger(checked) || !Number.isInteger(total) || total <= 0 || checked < 0 || checked > total) return [];
129
+ const named = typeof next === "string" && next.trim() ? clipToWidth(redact(next), NAME_MAX) : null;
130
+ const current = checked < total ? named ?? "unknown" : null;
131
+ return [{ recordedIn: `${mention}/.litclaude/boulder.json`, current, progress: progressOf(checked, total, named ? [named] : undefined) }];
132
+ });
133
+ });
134
+ };
135
+ const share = (progress) => progress.done / progress.total;
136
+
92
137
  // A plan met after the read budget ran out is counted in `skipped.count`, so the brief can say so.
93
138
  const plansIn = (root, budget, redact, local, skipped = { count: 0 }) => {
94
139
  const list = entries(join(root, "plans"));
@@ -104,16 +149,24 @@ const plansIn = (root, budget, redact, local, skipped = { count: 0 }) => {
104
149
  if (!rows.length || isTemplate(rows)) return [];
105
150
  const open = rows.filter((row) => !row.checked);
106
151
  const done = rows.length - open.length;
152
+ const own = {
153
+ rows: rows.map((row) => ({ checked: row.checked, title: clipToWidth(redact(row.text), NAME_MAX) })),
154
+ current: open.length ? clipToWidth(redact(open[0].text), NAME_MAX) : null,
155
+ progress: progressOf(done, rows.length, open.map((row) => clipToWidth(redact(row.text), NAME_MAX))),
156
+ };
157
+ const best = laneRecordsOf(root, entry.name, text, budget, redact)
158
+ .reduce((top, record) => (share(record.progress) > share(top.progress) ? record : top), own);
107
159
  // A plan with every row ticked is kept, marked complete: it is finished work, not roadmap.
108
160
  return [{
109
161
  worktree: redact(root),
110
162
  plan: `plans/${entry.name}`,
111
163
  local,
112
- complete: open.length === 0,
164
+ complete: best.progress.done === best.progress.total,
113
165
  changedMs: mtimeOf(join(root, "plans", entry.name)),
114
- rows: rows.map((row) => ({ checked: row.checked, title: clipToWidth(redact(row.text), NAME_MAX) })),
115
- current: open.length ? clipToWidth(redact(open[0].text), NAME_MAX) : null,
116
- progress: progressOf(done, rows.length, open.map((row) => clipToWidth(redact(row.text), NAME_MAX))),
166
+ rows: best.rows ?? own.rows,
167
+ current: best.current,
168
+ progress: best.progress,
169
+ ...(best.recordedIn ? { recordedIn: best.recordedIn } : {}),
117
170
  }];
118
171
  });
119
172
  };
@@ -403,7 +456,7 @@ export const collectRewind = ({
403
456
  // Finished inside the window: completed start-work runs and plans with every row ticked.
404
457
  finished: {
405
458
  runs: recentRuns.map(({ worktree, plan, atMs }) => ({ worktree, plan, at: new Date(atMs).toISOString() })),
406
- plans: (plans ?? []).filter((plan) => plan.complete && recent(plan)).map(({ worktree, plan, local, progress }) => ({ worktree, plan, local, gauge: progress.gauge })),
459
+ plans: (plans ?? []).filter((plan) => plan.complete && recent(plan)).map(({ worktree, plan, local, progress, recordedIn }) => ({ worktree, plan, local, gauge: progress.gauge, ...(recordedIn ? { recordedIn } : {}) })),
407
460
  },
408
461
  workflows: (workflows ?? []).map((frame) => ({ ...frame, self: Boolean(sessionId) && frame.sessionId === sessionId })),
409
462
  startWork: startWork ?? [],