@litfamily/litclaude 1.0.40 โ 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.
- package/CHANGELOG.md +21 -0
- package/README.md +8 -8
- package/README_ko-KR.md +8 -8
- package/docs/assets/readme/badge-version.svg +1 -1
- package/docs/hooks.md +35 -8
- package/package.json +1 -1
- package/plugins/litclaude/.claude-plugin/plugin.json +1 -1
- package/plugins/litclaude/bin/litclaude-hook.js +11 -2
- package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
- package/plugins/litclaude/hooks/lit-band-client.mjs +1 -1
- package/plugins/litclaude/hooks/lit-mod.mjs +66 -8
- package/plugins/litclaude/lib/canonical-skill-resources.mjs +4 -4
- package/plugins/litclaude/lib/mod/frame.mjs +47 -28
- package/plugins/litclaude/lib/mod/looks.mjs +36 -0
- package/plugins/litclaude/lib/mod/motion.mjs +2 -3
- package/plugins/litclaude/lib/mod/state.mjs +6 -3
- package/plugins/litclaude/lib/mod/svg-card.mjs +4 -1
- package/plugins/litclaude/lib/mod/timeline.mjs +3 -3
- package/plugins/litclaude/lib/mod/view.mjs +80 -11
- package/plugins/litclaude/lib/mod/workflow.mjs +2 -0
- package/plugins/litclaude/lib/workflow-stage.mjs +104 -22
- package/plugins/litclaude/skills/lit-hijack/references/capture-and-provenance.md +2 -1
- package/plugins/litclaude/skills/lit-hijack/scripts/hijack.mjs +40 -12
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/assets.mjs +45 -17
- package/plugins/litclaude/skills/lit-typographic-motion/references/treatment.md +2 -1
|
@@ -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 {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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.
|
|
58
|
-
|
|
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
|
|
397
|
-
// file and the unknown-session file are skipped;
|
|
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 {
|
|
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
|
-
//
|
|
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 "./
|
|
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) =>
|
|
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
|
-
|
|
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
|
|
423
|
-
const
|
|
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
|
}
|