@litfamily/litclaude 1.0.44 → 1.0.46
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 +50 -0
- package/README.md +8 -8
- package/README_ko-KR.md +8 -8
- package/bin/litclaude-ai.js +173 -4
- package/docs/assets/readme/badge-version.svg +1 -1
- package/package.json +1 -1
- package/plugins/litclaude/.claude-plugin/plugin.json +1 -1
- package/plugins/litclaude/bin/litclaude-ai +1 -0
- package/plugins/litclaude/bin/litclaude-hook.js +21 -7
- package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
- package/plugins/litclaude/hooks/hooks.json +1 -1
- package/plugins/litclaude/lib/agent-file/apply.mjs +150 -0
- package/plugins/litclaude/lib/agent-file/attribution.mjs +62 -0
- package/plugins/litclaude/lib/agent-file/block.md +12 -0
- package/plugins/litclaude/lib/agent-file/cli.mjs +71 -0
- package/plugins/litclaude/lib/agent-file/managed-block.mjs +82 -0
- package/plugins/litclaude/lib/agent-file/project-block.md +9 -0
- package/plugins/litclaude/lib/canonical-skill-resources.mjs +14 -14
- package/plugins/litclaude/lib/mark.mjs +23 -6
- package/plugins/litclaude/lib/mod/state.mjs +12 -0
- package/plugins/litclaude/lib/mod/view.mjs +9 -3
- package/plugins/litclaude/lib/rewind/brief.mjs +12 -2
- package/plugins/litclaude/lib/rewind/collect.mjs +31 -9
- package/plugins/litclaude/lib/rewind/next-step.mjs +21 -3
- package/plugins/litclaude/lib/start-work-lifecycle.mjs +4 -2
- package/plugins/litclaude/skills/lit-adhd/SKILL.md +5 -4
- package/plugins/litclaude/skills/lit-init/SKILL.md +12 -0
- package/plugins/litclaude/skills/lit-typographic-motion/SKILL.md +1 -1
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover.mjs +1 -1
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-gate.mjs +1 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-serve.mjs +126 -4
- package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage.mjs +5 -1
- package/plugins/litclaude/skills/lit-typographic-motion/engine/stage/init.js +13 -0
- package/plugins/litclaude/skills/lit-typographic-motion/engine/stage/stage-kit.js +40 -1
- package/plugins/litclaude/skills/lit-typographic-motion/references/stage.md +43 -2
- package/plugins/litclaude/skills/readme-studio/templates/hyperframes-cover/package-lock.json +4 -4
|
@@ -69,6 +69,8 @@ const WORDS = {
|
|
|
69
69
|
},
|
|
70
70
|
goLine: (say) => `Type **\`${say}\`** to continue.`,
|
|
71
71
|
noGo: "Nothing runs on its own here: open that session, or say what to do.",
|
|
72
|
+
lanesAtWork: (n) => `${n} other ${n === 1 ? "lane is" : "lanes are"} still at work: wait for ${n === 1 ? "it" : "them"} to finish`,
|
|
73
|
+
noGoWhileLanes: "Do not type **`go`** now: run `lit adhd` again once the lanes finish.",
|
|
72
74
|
unknownSources: (list) => `Not read: ${list}.`,
|
|
73
75
|
older: "Older sessions were not read (read budget used up).",
|
|
74
76
|
plansSkipped: (n) => `${n} ${n === 1 ? "plan was" : "plans were"} not read (read budget used up).`,
|
|
@@ -133,6 +135,8 @@ const WORDS = {
|
|
|
133
135
|
},
|
|
134
136
|
goLine: (say) => `**\`${say}\`** 라고 입력하면 이어갑니다.`,
|
|
135
137
|
noGo: "저절로 실행되는 단계는 아닙니다. 그 세션을 열거나 할 일을 말해 주세요.",
|
|
138
|
+
lanesAtWork: (n) => `다른 레인 ${n}개가 아직 일하는 중이에요. 끝날 때까지 기다리세요`,
|
|
139
|
+
noGoWhileLanes: "지금은 **`go`는 입력하지 마세요.** 레인이 끝나면 `lit adhd`로 다시 확인하세요.",
|
|
136
140
|
unknownSources: (list) => `읽지 못함: ${list}.`,
|
|
137
141
|
older: "오래된 세션은 읽지 않았습니다(읽기 예산 소진).",
|
|
138
142
|
plansSkipped: (n) => `계획 ${n}개는 읽지 못했습니다(읽기 예산 소진).`,
|
|
@@ -211,6 +215,7 @@ const actionOf = (session, escape = plain) => {
|
|
|
211
215
|
const nextOf = (session, data, w) => {
|
|
212
216
|
const frames = (data.workflows ?? []).filter((frame) => frame.id8 === session.id8);
|
|
213
217
|
const paused = frames.find((frame) => frame.status === "paused");
|
|
218
|
+
if (paused && session.self && data.next?.wait?.lanes) return w.lanesAtWork(data.next.wait.lanes);
|
|
214
219
|
if (paused) return w.resume(paused.skill, paused.stage, session.self);
|
|
215
220
|
if (session.waitingReason === "start-work boundary") return w.approve;
|
|
216
221
|
if (session.status === "waiting-on-user") {
|
|
@@ -387,8 +392,13 @@ export const renderBrief = (data, { lang = "en", now = Date.parse(data.generated
|
|
|
387
392
|
const sessions = data.sessions ?? [];
|
|
388
393
|
const summary = data.summary ?? { sessions: sessions.length, waitingOnUser: 0, active: 0 };
|
|
389
394
|
// With no step for `go`, this worktree's HANDOFF.md Next item comes before the generic suggestion.
|
|
395
|
+
// While other lanes work, the step is to answer the one waiting on the user, or else to wait.
|
|
390
396
|
const handoffNext = (data.handoffs ?? []).find((handoff) => handoff.local && handoff.next)?.next ?? null;
|
|
391
|
-
const
|
|
397
|
+
const lanes = data.next?.wait?.lanes ?? 0;
|
|
398
|
+
const waiting = sessions.some((session) => session.status === "waiting-on-user" && !session.self);
|
|
399
|
+
const step = data.next?.kind && data.next.kind !== "none"
|
|
400
|
+
? stepText(data.next, w)
|
|
401
|
+
: lanes ? bare(waiting ? suggestion(data, w) : w.lanesAtWork(lanes)) : bare(handoffNext ?? suggestion(data, w));
|
|
392
402
|
const out = [...openerLines(data, step, w), ""];
|
|
393
403
|
out.push(`## 🧭 ${[w.sessions(summary.sessions), w.waiting(summary.waitingOnUser), w.active(summary.active)].join(" · ")} · ${w.next}: ${plain(step)}`);
|
|
394
404
|
out.push(`*${w.window(data.scope?.since ?? "7d", (data.scope?.worktrees ?? []).length || 1)}*`);
|
|
@@ -415,7 +425,7 @@ export const renderBrief = (data, { lang = "en", now = Date.parse(data.generated
|
|
|
415
425
|
if (data.next?.command) body.push(clipToWidth(data.next.command, width - 4));
|
|
416
426
|
if (say) body.push(`${w.type}: ${say}`);
|
|
417
427
|
out.push("", box(w.recommended, body));
|
|
418
|
-
out.push("", say ? w.goLine(say) : w.noGo);
|
|
428
|
+
out.push("", say ? w.goLine(say) : lanes ? w.noGoWhileLanes : w.noGo);
|
|
419
429
|
const unknown = Object.entries(data.sources ?? {}).filter(([, status]) => status !== "ok").map(([name]) => name);
|
|
420
430
|
const notes = [
|
|
421
431
|
unknown.length ? w.unknownSources(unknown.join(", ")) : null,
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { execFileSync } from "node:child_process";
|
|
8
8
|
import { closeSync, constants, fstatSync, lstatSync, openSync, readSync, readdirSync } from "node:fs";
|
|
9
9
|
import { homedir } from "node:os";
|
|
10
|
-
import { basename, join, resolve } from "node:path";
|
|
10
|
+
import { basename, join, resolve, sep } from "node:path";
|
|
11
11
|
|
|
12
12
|
import { parsePlanTaskRows } from "../plan-task-rows.mjs";
|
|
13
13
|
import { resolveProjectStateRoot } from "../project-state-root.mjs";
|
|
@@ -184,7 +184,10 @@ const litgoalOf = (root, budget, redact) => {
|
|
|
184
184
|
};
|
|
185
185
|
};
|
|
186
186
|
|
|
187
|
-
//
|
|
187
|
+
// An item already marked done (✅, ✓, [x], ~~struck~~, DONE, SHIPPED) is history, not a next step.
|
|
188
|
+
const DONE_ITEM = /✅|✓|^\[[xX]\]|^~~|\b(?:DONE|SHIPPED)\b/u;
|
|
189
|
+
|
|
190
|
+
// The first open list item or line of text under a `## Next` or `## Next Steps` heading, without its marker.
|
|
188
191
|
const handoffNext = (text) => {
|
|
189
192
|
const lines = text.split("\n");
|
|
190
193
|
const start = lines.findIndex((line) => /^#{1,6}\s+Next(?:\s+Steps)?\s*$/iu.test(line.trim()));
|
|
@@ -192,7 +195,7 @@ const handoffNext = (text) => {
|
|
|
192
195
|
for (const line of lines.slice(start + 1)) {
|
|
193
196
|
if (/^#{1,6}\s/u.test(line.trim())) return null;
|
|
194
197
|
const item = line.trim().replace(/^(?:[-*+]|\d+[.)])\s+/u, "");
|
|
195
|
-
if (item) return item;
|
|
198
|
+
if (item && !DONE_ITEM.test(item.replace(/^\*\*/u, ""))) return item;
|
|
196
199
|
}
|
|
197
200
|
return null;
|
|
198
201
|
};
|
|
@@ -297,11 +300,26 @@ const livenessOf = (root, budget) => {
|
|
|
297
300
|
});
|
|
298
301
|
};
|
|
299
302
|
|
|
300
|
-
|
|
303
|
+
// `herdr agent list` answers one JSON document. Only agents in this herdr workspace or inside the
|
|
304
|
+
// folders read are kept, so a lane the brief can see is one that could race this project's `go`.
|
|
305
|
+
const herdrOf = (env, exec, redact, roots) => {
|
|
301
306
|
if (env.HERDR_ENV !== "1") return { status: "unknown", agents: [] };
|
|
302
307
|
try {
|
|
303
|
-
const
|
|
304
|
-
return { status: "
|
|
308
|
+
const listed = JSON.parse(exec("herdr", ["agent", "list"], { timeout: HERDR_TIMEOUT_MS }))?.result?.agents;
|
|
309
|
+
if (!Array.isArray(listed)) return { status: "unknown", agents: [] };
|
|
310
|
+
const inside = (path) => typeof path === "string" && roots.some((root) => path === root || path.startsWith(`${root}${sep}`));
|
|
311
|
+
const agents = listed
|
|
312
|
+
.filter((agent) => (env.HERDR_WORKSPACE_ID && agent?.workspace_id === env.HERDR_WORKSPACE_ID) || inside(agent?.foreground_cwd) || inside(agent?.cwd))
|
|
313
|
+
.slice(0, 20)
|
|
314
|
+
.map((agent) => ({
|
|
315
|
+
agent: clipToWidth(redact(String(agent.agent ?? "unknown")), 20),
|
|
316
|
+
status: typeof agent.agent_status === "string" ? agent.agent_status : "unknown",
|
|
317
|
+
pane: typeof agent.pane_id === "string" ? agent.pane_id : "unknown",
|
|
318
|
+
id8: typeof agent.agent_session?.value === "string" ? agent.agent_session.value.slice(0, 8) : null,
|
|
319
|
+
title: clipToWidth(redact(String(agent.terminal_title_stripped ?? "")), 60),
|
|
320
|
+
self: Boolean(env.HERDR_PANE_ID) && agent.pane_id === env.HERDR_PANE_ID,
|
|
321
|
+
}));
|
|
322
|
+
return { status: "ok", agents };
|
|
305
323
|
} catch {
|
|
306
324
|
return { status: "unknown", agents: [] };
|
|
307
325
|
}
|
|
@@ -372,7 +390,7 @@ export const collectRewind = ({
|
|
|
372
390
|
}
|
|
373
391
|
|
|
374
392
|
const commits = collectEach((root) => commitsOf(root, sinceMs, now, exec, redact));
|
|
375
|
-
const herdr = herdrOf(env, exec, redact);
|
|
393
|
+
const herdr = herdrOf(env, exec, redact, roots.map((root) => resolve(root)));
|
|
376
394
|
|
|
377
395
|
// A session waits on the user when it asked something, or holds a paused frame or boundary.
|
|
378
396
|
for (const session of sessions) {
|
|
@@ -404,14 +422,18 @@ export const collectRewind = ({
|
|
|
404
422
|
}
|
|
405
423
|
const recentRuns = (runs ?? []).filter((run) => now - run.atMs <= sinceMs).sort((a, b) => b.atMs - a.atMs);
|
|
406
424
|
for (const session of sessions) {
|
|
407
|
-
|
|
425
|
+
// A paused frame in a stack can be a day old, so it alone does not keep a session that stopped
|
|
426
|
+
// from reading as waiting (and as a lane at work); a question it asked, or a boundary, does.
|
|
427
|
+
const pausedOnly = session.waitingReason === "paused workflow";
|
|
428
|
+
if ((sessionId && session.sessionId === sessionId) || (session.status === "waiting-on-user" && !pausedOnly)) continue;
|
|
408
429
|
const live = newestLiveness.get(session.sessionId);
|
|
409
430
|
const run = recentRuns.find((item) => item.sessionId === session.sessionId);
|
|
410
|
-
if (run && !(live?.state === "alive" && live.atMs > run.atMs)) {
|
|
431
|
+
if (!pausedOnly && run && !(live?.state === "alive" && live.atMs > run.atMs)) {
|
|
411
432
|
session.status = "done";
|
|
412
433
|
session.finishedPlan = run.plan;
|
|
413
434
|
} else if (live && live.state !== "alive" && live.atMs >= (session.lastMs ?? 0) - LIVENESS_SLACK_MS) {
|
|
414
435
|
session.status = live.state === "ended" ? "ended" : "idle";
|
|
436
|
+
delete session.waitingReason;
|
|
415
437
|
}
|
|
416
438
|
}
|
|
417
439
|
sessions.sort((a, b) => statusRank[a.status] - statusRank[b.status] || (b.lastMs ?? 0) - (a.lastMs ?? 0));
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
// 2. a paused start-work boundary -> approve-boundary (shown only, never automatic)
|
|
5
5
|
// 3. an active start-work of this session -> continue-work
|
|
6
6
|
// 4. a single open plan with no work running -> start-plan (`/litclaude:start-work <plan>`)
|
|
7
|
-
//
|
|
7
|
+
// and no other lane at work
|
|
8
|
+
// 5. other lanes still at work -> none, with `wait` (the brief says not to type `go`)
|
|
9
|
+
// 6. otherwise -> none
|
|
8
10
|
|
|
9
11
|
import { closeSync, constants, fstatSync, openSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
10
12
|
import { dirname, join } from "node:path";
|
|
@@ -12,15 +14,31 @@ import { dirname, join } from "node:path";
|
|
|
12
14
|
import { ignitionFileName } from "../mod/state.mjs";
|
|
13
15
|
import { requireStateDir, STATE_WRITE_FLAG } from "../project-state-root.mjs";
|
|
14
16
|
|
|
17
|
+
// A lane is another live session here (working or waiting on the user) or a herdr agent working or
|
|
18
|
+
// blocked in this workspace or project; one lane seen both ways counts once.
|
|
19
|
+
const busyLanes = (data) => {
|
|
20
|
+
const lanes = new Set((data.sessions ?? [])
|
|
21
|
+
.filter((session) => !session.self && ["active", "waiting-on-user"].includes(session.status))
|
|
22
|
+
.map((session) => session.id8));
|
|
23
|
+
for (const agent of data.herdr?.agents ?? []) {
|
|
24
|
+
if (!agent.self && ["working", "blocked"].includes(agent.status)) lanes.add(agent.id8 ?? agent.pane);
|
|
25
|
+
}
|
|
26
|
+
return lanes.size;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// While another lane works, nothing that resumes or starts work here is offered: only an approval,
|
|
30
|
+
// which is the user's call either way.
|
|
15
31
|
export const chooseNextStep = (data, sessionId) => {
|
|
32
|
+
const lanes = busyLanes(data);
|
|
16
33
|
const ownStack = data.workflows.find((frame) => frame.sessionId === sessionId && frame.role === "spine" && frame.status === "paused");
|
|
17
|
-
if (sessionId && ownStack) {
|
|
34
|
+
if (sessionId && ownStack && !lanes) {
|
|
18
35
|
return { kind: "resume-frame", target: { skill: ownStack.skill, stage: ownStack.stage, progress: ownStack.progress.gauge }, say: "lit continue" };
|
|
19
36
|
}
|
|
20
37
|
const paused = data.startWork.find((work) => work.status === "paused" && work.pendingBoundary);
|
|
21
38
|
if (paused) {
|
|
22
39
|
return { kind: "approve-boundary", target: { workId: paused.workId, plan: paused.plan, ...paused.pendingBoundary }, say: "lit approve", automatic: false };
|
|
23
40
|
}
|
|
41
|
+
if (lanes) return { kind: "none", target: null, wait: { lanes } };
|
|
24
42
|
const own = data.startWork.find((work) => work.status === "active" && sessionId && work.sessionId === sessionId);
|
|
25
43
|
if (own) return { kind: "continue-work", target: { workId: own.workId, plan: own.plan }, say: "go" };
|
|
26
44
|
const running = data.startWork.some((work) => ["active", "paused"].includes(work.status));
|
|
@@ -28,7 +46,7 @@ export const chooseNextStep = (data, sessionId) => {
|
|
|
28
46
|
if (!running && open.length === 1) {
|
|
29
47
|
return { kind: "start-plan", target: { plan: open[0].plan }, say: "go", command: `/litclaude:start-work ${open[0].plan}` };
|
|
30
48
|
}
|
|
31
|
-
return { kind: "none", target: null };
|
|
49
|
+
return lanes ? { kind: "none", target: null, wait: { lanes } } : { kind: "none", target: null };
|
|
32
50
|
};
|
|
33
51
|
|
|
34
52
|
export const nextStepPath = (stateRoot, sessionId) => join(stateRoot, ".litclaude", "adhd", `next-${ignitionFileName(sessionId)}`);
|
|
@@ -179,7 +179,9 @@ const canonicalDirectory = (path, label) => {
|
|
|
179
179
|
}
|
|
180
180
|
if (stats.isSymbolicLink()) throw new StartWorkLifecycleError(`${label} must not be a symbolic link`);
|
|
181
181
|
if (!stats.isDirectory()) throw new StartWorkLifecycleError(`${label} must be a directory`);
|
|
182
|
-
|
|
182
|
+
// Keep the on-disk spelling: ext4 does not fold Unicode normalization, so an NFC copy of an NFD
|
|
183
|
+
// folder name opens nothing there. Comparisons normalize on their own (rootCovers).
|
|
184
|
+
return realpathSync(requested);
|
|
183
185
|
};
|
|
184
186
|
|
|
185
187
|
const canonicalTarget = (path, label) => {
|
|
@@ -1728,7 +1730,7 @@ export const recordStartWorkSubagentStart = (root, input) => {
|
|
|
1728
1730
|
started_at: nowIso(),
|
|
1729
1731
|
};
|
|
1730
1732
|
work.lanes[agentId] = lane;
|
|
1731
|
-
if (canonicalWorktreePath !== canonicalRoot) {
|
|
1733
|
+
if (canonicalWorktreePath.normalize("NFC") !== canonicalRoot.normalize("NFC")) {
|
|
1732
1734
|
work.worktrees[worktreePath] = {
|
|
1733
1735
|
path: worktreePath,
|
|
1734
1736
|
owner: "claude",
|
|
@@ -58,7 +58,7 @@ The collector draws the brief in Markdown (`lib/rewind/brief.mjs`), so its shape
|
|
|
58
58
|
- ▶ what is next for that session: answer the question it asked, resume its paused frame, approve its boundary, its plan's current item, or what it is doing now (its last tool call: `Bash “Run the gates”`, for an active session only). A done session names the plan its run finished; an idle or done session's last tool call is never offered as its next step.
|
|
59
59
|
3. **Ended sessions, one table row each.** A `### ⚪ Ended · N` table (id, where, goal, ended, done), at most 8 rows and a count of the rest.
|
|
60
60
|
4. **Roadmap timeline.** A `### 🗺️` heading with this worktree's roadmap gauge, then ✓ finished commits with their dates and branch, ▶ the current item of each open plan of this worktree and of plans another worktree changed inside the window (with its worktree name) with its gauge, ○ the items after it, then litgoal objectives. Stale plans elsewhere, unfilled plan scaffolds and another worktree's finished objectives are left out.
|
|
61
|
-
5. **One recommended next step** in a box, from `next`, with the word to type (`go`, `lit continue` or `lit approve`), then one line: "Type `go` to continue." When nothing can run on `go`, the box still recommends a real step from the records: first the first item under `## Next` or `## Next Steps` in this worktree's own `HANDOFF*.md`, then a session waiting on the user, a paused workflow, an open plan item, the latest active session, then the newest listed session that is not running (review what a done one finished, or pick up an idle or ended one). Only a window with no session and no plan says there is nothing to start. It says that nothing runs on its own, and a HANDOFF step never carries a word to type.
|
|
61
|
+
5. **One recommended next step** in a box, from `next`, with the word to type (`go`, `lit continue` or `lit approve`), then one line: "Type `go` to continue." When nothing can run on `go`, the box still recommends a real step from the records: first the first item under `## Next` or `## Next Steps` in this worktree's own `HANDOFF*.md` that is not already marked done (✅, ✓, `[x]`, struck through, DONE or SHIPPED), then a session waiting on the user, a paused workflow, an open plan item, the latest active session, then the newest listed session that is not running (review what a done one finished, or pick up an idle or ended one). Only a window with no session and no plan says there is nothing to start. It says that nothing runs on its own, and a HANDOFF step never carries a word to type.
|
|
62
62
|
|
|
63
63
|
**Progress gauges (D9), required.** A gauge appears only when both numbers are real, in the form `[▉▉▉░░] 3/5` (filled `▉` done, light `░` remaining, then done/total). An unknown total has no gauge: the card states what is known in words instead. Never a question-mark gauge, never a guess, never an estimate, never a gauge of your own.
|
|
64
64
|
|
|
@@ -111,7 +111,7 @@ The collector (`plugins/litclaude/lib/rewind/collect.mjs`, served as `litclaude-
|
|
|
111
111
|
| `.litclaude/workflow-stack/*.json` | running and paused disciplines with stage and k/n | `workflowStack: unknown` |
|
|
112
112
|
| `.litclaude/boulder.json` | active start-work, its plan progress and any boundary waiting for approval; completed runs from its history | `startWork: unknown` |
|
|
113
113
|
| `.litclaude/liveness/*.json` | each session's last hook event (`alive`, `idle`, `ended`), written by PostToolUse, Stop and SessionEnd | the transcript time alone decides |
|
|
114
|
-
| `herdr agent list` (only when `HERDR_ENV=1`) | agent panes | `herdr: unknown` |
|
|
114
|
+
| `herdr agent list` (only when `HERDR_ENV=1`) | agent panes of this herdr workspace or this repo: agent, status, pane, session | `herdr: unknown` |
|
|
115
115
|
|
|
116
116
|
Plans, litgoal, handoffs, workflow stacks and start-work are read first, then transcripts, so a busy transcript folder never crowds out the plans; a plan met after the budget ran out is counted and the brief says how many were not read. Transcripts are read head (64 KiB) and tail (256 KiB) only, under one 8 MiB budget for the whole run, through descriptors opened without following links; subagent transcripts and sidechain lines are skipped. The slug is the session's absolute cwd with every character outside `[A-Za-z0-9]` turned into `-`; a folder whose slug is missing is found by the `cwd` its newest transcript records. Every string is redacted before it leaves the collector: credential shapes, `NAME=value` with a secret-like name, URI userinfo, any current environment value of eight or more characters, and the home directory (shown as `~`).
|
|
117
117
|
|
|
@@ -133,8 +133,9 @@ Sessions waiting on the user come first, then active ones, then idle and done on
|
|
|
133
133
|
1. This session's own paused spine frame: resume it. Say `lit continue`.
|
|
134
134
|
2. A start-work paused at a boundary: show what it wants to reach. Say `lit approve` or `lit deny`. This is never automatic.
|
|
135
135
|
3. This session's own active start-work: keep going. Say `go`.
|
|
136
|
-
4. Exactly one open plan in this worktree and no work
|
|
137
|
-
5.
|
|
136
|
+
4. Exactly one open plan in this worktree, no work running and no other lane at work: start it. Say `go`, which runs `/litclaude:start-work plans/<plan>.md`.
|
|
137
|
+
5. Another lane still at work: a live session of this repo other than this one (working or waiting on the user), or a herdr agent working or blocked in this herdr workspace or inside this repo. One lane seen both ways counts once. There is no step for `go`: the box says to wait for the lanes (or to answer the one that asked something) and the last line says not to type `go` until they finish, so a parallel lane is never raced by a second run.
|
|
138
|
+
6. Otherwise `none`: say so.
|
|
138
139
|
|
|
139
140
|
## Continuing with go
|
|
140
141
|
|
|
@@ -268,6 +268,17 @@ ANTI-PATTERNS). Wait for all. Mark "generate" completed.
|
|
|
268
268
|
Mark "review" in_progress. For each generated file: remove generic advice, remove parent duplicates,
|
|
269
269
|
trim to the size limits, verify telegraphic style. Mark "review" completed.
|
|
270
270
|
|
|
271
|
+
## Phase 5 — LitFamily project block
|
|
272
|
+
|
|
273
|
+
After the review, run `litclaude-ai agent-file project --dir <repo root>` once. It adds the short
|
|
274
|
+
LitFamily project block (plans, handoff, approval and evidence conventions) between
|
|
275
|
+
`<!-- litfamily:litclaude:start … -->` and `<!-- litfamily:litclaude:end -->` markers at the end of
|
|
276
|
+
the root `AGENTS.md`, so the hand-written knowledge base above stays yours and the block is refreshed
|
|
277
|
+
in place on the next run. When the repo has no `CLAUDE.md`, it writes one containing `@AGENTS.md` so
|
|
278
|
+
Claude Code loads the same file; an existing `CLAUDE.md` is left alone, and the command prints the
|
|
279
|
+
line to add. Never edit text between the markers by hand, and never copy the block into subdirectory
|
|
280
|
+
files. Report the `AGENT_FILE:` lines it prints in the final report.
|
|
281
|
+
|
|
271
282
|
## Final report
|
|
272
283
|
|
|
273
284
|
```
|
|
@@ -276,6 +287,7 @@ Mode: {update | create-new}
|
|
|
276
287
|
Files: [OK] ./AGENTS.md (root, {N} lines) · [OK] ./src/hooks/AGENTS.md ({N} lines)
|
|
277
288
|
Dirs analyzed: {N} · Created: {N} · Updated: {N}
|
|
278
289
|
Hierarchy: ./AGENTS.md └── src/hooks/AGENTS.md
|
|
290
|
+
LitFamily block: {AGENT_FILE lines from `agent-file project`}
|
|
279
291
|
```
|
|
280
292
|
|
|
281
293
|
## Anti-patterns
|
|
@@ -124,7 +124,7 @@ Done needs all of: a valid treatment; gate PASS; at least two look rounds, the f
|
|
|
124
124
|
| 14 | BLOCKED_DEPS_NOT_PREWARMED | Tell the user to run `litclaude-ai motion-runtime install` outside this session. |
|
|
125
125
|
| 15 | BLOCKED_FONT_FETCH | A cached font is missing or its sha256 differs; same fix. |
|
|
126
126
|
| 16 | BLOCKED_TREATMENT_INVALID | Fix the named field. |
|
|
127
|
-
| 17 | STAGE_CONTRACT_ERROR | Fix the named element, API, raster, size or missing copy line. |
|
|
127
|
+
| 17 | STAGE_CONTRACT_ERROR | Fix the named element, API, raster, clip, size or missing copy line. |
|
|
128
128
|
| 18 | STAGE_NONDETERMINISTIC | Seed it or drive it from `t`. |
|
|
129
129
|
| 19 | STAGE_NETWORK_REQUEST | Remove the named URL; everything is local. |
|
|
130
130
|
| 20 | SOUND_INVALID | Fix the planned sound. |
|
|
@@ -216,7 +216,7 @@ function prepare({ out, env, log }) {
|
|
|
216
216
|
const treatment = asBlocked(() => loadCoverTreatment(out));
|
|
217
217
|
const stageDir = path.join(out, COVER_STAGE);
|
|
218
218
|
if (!existsSync(path.join(stageDir, "index.html"))) throw new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: ${path.join(stageDir, "index.html")} is missing; write the cover page first (references/cover.md)`);
|
|
219
|
-
const scan = scanStage(stageDir);
|
|
219
|
+
const scan = scanStage(stageDir, { clips: false });
|
|
220
220
|
for (const w of scan.warnings) log(`warning: ${w}`);
|
|
221
221
|
const { assets } = checkAssets({ out, treatment, rasters: scan.rasters, coverDir: COVER_STAGE });
|
|
222
222
|
return { treatment, stageDir, assets, faces: stageFonts(env) };
|
|
@@ -164,6 +164,7 @@ export function formatStageReport({ gate, manifest, outputs, round, framesViewed
|
|
|
164
164
|
`format / duration / fps: ${manifest.format} ${manifest.width}x${manifest.height}, ${manifest.durationSec} s (treatment ${manifest.treatmentDurationSec} s) @ ${manifest.fps} fps, ${manifest.frameCount} frames`,
|
|
165
165
|
`renderer: ${manifest.renderer} (${manifest.rung ?? "software"} rung, stage flags: ${manifest.chromeFlags.join(" ")})`,
|
|
166
166
|
...(manifest.plate ? [`plate: Blender ${manifest.plate.blender}, ${manifest.plate.engine} ${manifest.plate.device}, ${manifest.plate.samples} spp, ${manifest.plate.frames} frames at ${manifest.plate.fps} fps`] : []),
|
|
167
|
+
...(manifest.clips?.length ? [`clips: ${manifest.clips.map((c) => `${c.id} ${c.frames} frames at ${c.fps} fps`).join(", ")} (keyed overlays, chosen from film time)`] : []),
|
|
167
168
|
`sound: ${manifest.sound?.mode ?? "none"}${manifest.sound?.label ? ` (${manifest.sound.label})` : ""}`,
|
|
168
169
|
"",
|
|
169
170
|
`QA gate: ${gate.pass ? "PASS" : "FAIL"}`,
|
|
@@ -9,6 +9,7 @@ import { fileURLToPath } from "node:url";
|
|
|
9
9
|
import { EXIT } from "../core/constants.mjs";
|
|
10
10
|
import { readPlate } from "./blender.mjs";
|
|
11
11
|
import { BlockedError } from "./chrome.mjs";
|
|
12
|
+
import { decodePng } from "./png.mjs";
|
|
12
13
|
import { checkFont, fontLocation, fontsDir, loadFontManifest } from "./runtime.mjs";
|
|
13
14
|
|
|
14
15
|
export const STAGE_ORIGIN = "http://lit.stage";
|
|
@@ -28,6 +29,13 @@ export const CONTENT_TYPES = Object.freeze({
|
|
|
28
29
|
});
|
|
29
30
|
export const RASTER = Object.freeze([".png", ".jpg", ".jpeg", ".webp", ".gif"]);
|
|
30
31
|
export const RASTER_LIMITS = Object.freeze({ count: 24, bytes: 8 * 1024 * 1024, flipbook: 10 });
|
|
32
|
+
// Keyed overlay clips (references/stage.md, Clips): frame sequences declared in stage/clips/clips.json
|
|
33
|
+
// are held to these caps instead of RASTER_LIMITS. A clip is a sticker on the film, never the film:
|
|
34
|
+
// 8-bit RGBA PNG frames with real transparency, at most `side` px on the long side, at most 30 fps.
|
|
35
|
+
export const CLIP_LIMITS = Object.freeze({
|
|
36
|
+
clips: 12, framesPerClip: 360, framesTotal: 1500, bytesPerClip: 40 * 1024 * 1024, bytesTotal: 128 * 1024 * 1024, side: 720, fps: 30,
|
|
37
|
+
});
|
|
38
|
+
export const CLIPS_DIR = "clips";
|
|
31
39
|
|
|
32
40
|
// The product's verified faces as CSS families. Archivo's widths are one family at three stretches.
|
|
33
41
|
const FAMILIES = [
|
|
@@ -107,7 +115,7 @@ function pngInfo(b) {
|
|
|
107
115
|
if (type === "IDAT" || type === "IEND") break;
|
|
108
116
|
o += 12 + len;
|
|
109
117
|
}
|
|
110
|
-
return { width: b.readUInt32BE(16), height: b.readUInt32BE(20), animated };
|
|
118
|
+
return { width: b.readUInt32BE(16), height: b.readUInt32BE(20), animated, bitDepth: b[24], colorType: b[25] };
|
|
111
119
|
}
|
|
112
120
|
function jpegInfo(b) {
|
|
113
121
|
if (b[0] !== 0xff || b[1] !== 0xd8) return null;
|
|
@@ -165,6 +173,97 @@ export function rasterInfo(file) {
|
|
|
165
173
|
return null;
|
|
166
174
|
}
|
|
167
175
|
|
|
176
|
+
// ---- declared clips: stage/clips/clips.json and the frame folders it names ----
|
|
177
|
+
const clipFail = (message) => new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: ${message}`);
|
|
178
|
+
const clipFrame = (i) => `frame_${String(i).padStart(4, "0")}.png`;
|
|
179
|
+
const CLIP_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,39}$/u;
|
|
180
|
+
const CLIP_DIR = /^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$/u;
|
|
181
|
+
|
|
182
|
+
/** The clips stage/clips/clips.json declares ([] without the file), checked for shape only. Throws exit 17. */
|
|
183
|
+
export function declaredClips(stageDir, limits = CLIP_LIMITS) {
|
|
184
|
+
const file = path.join(stageDir, CLIPS_DIR, "clips.json");
|
|
185
|
+
if (!existsSync(file)) return [];
|
|
186
|
+
let doc;
|
|
187
|
+
try {
|
|
188
|
+
doc = JSON.parse(readFileSync(file, "utf8"));
|
|
189
|
+
} catch (error) {
|
|
190
|
+
throw clipFail(`${CLIPS_DIR}/clips.json is not valid JSON (${error.message})`);
|
|
191
|
+
}
|
|
192
|
+
if (!doc || !Array.isArray(doc.clips)) throw clipFail(`${CLIPS_DIR}/clips.json needs { "clips": [ { "id", "dir", "count", "fps" } ] }`);
|
|
193
|
+
if (doc.clips.length > limits.clips) throw clipFail(`${doc.clips.length} clips declared (at most ${limits.clips} clips)`);
|
|
194
|
+
const ids = new Set();
|
|
195
|
+
const dirs = new Set();
|
|
196
|
+
return doc.clips.map((c, n) => {
|
|
197
|
+
const at = `${CLIPS_DIR}/clips.json clip #${n + 1}`;
|
|
198
|
+
if (!c || typeof c !== "object") throw clipFail(`${at} is not an object`);
|
|
199
|
+
if (typeof c.id !== "string" || !CLIP_ID.test(c.id)) throw clipFail(`${at}: id must be a plain token of letters, digits, - and _ (got ${JSON.stringify(c.id)})`);
|
|
200
|
+
if (ids.has(c.id)) throw clipFail(`${at}: duplicate id ${c.id}`);
|
|
201
|
+
ids.add(c.id);
|
|
202
|
+
if (typeof c.dir !== "string" || !CLIP_DIR.test(c.dir) || c.dir.includes("..")) throw clipFail(`clip "${c.id}": dir must be a folder name directly under ${CLIPS_DIR}/ (got ${JSON.stringify(c.dir)})`);
|
|
203
|
+
if (dirs.has(c.dir)) throw clipFail(`clip "${c.id}": dir ${c.dir} is already declared by another clip`);
|
|
204
|
+
dirs.add(c.dir);
|
|
205
|
+
if (!Number.isInteger(c.count) || c.count < 1) throw clipFail(`clip "${c.id}": count must be a whole number of frames (got ${JSON.stringify(c.count)})`);
|
|
206
|
+
if (!Number.isInteger(c.fps) || c.fps < 1 || c.fps > limits.fps) throw clipFail(`clip "${c.id}": fps must be a whole number from 1 to ${limits.fps} (got ${JSON.stringify(c.fps)})`);
|
|
207
|
+
return { id: c.id, dir: c.dir, count: c.count, fps: c.fps };
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Check every declared clip against its bytes: exactly frame_0001.png..frame_<count>.png in
|
|
213
|
+
* clips/<dir>/, each an 8-bit non-animated RGBA PNG of one size within the overlay cap, with real
|
|
214
|
+
* transparency in the first, middle and last frame, and the per-clip and total caps. Returns
|
|
215
|
+
* [{ id, dir, count, fps, width, height, bytes, frames }] where `frames` are stage-relative paths.
|
|
216
|
+
*/
|
|
217
|
+
export function scanClips(stageDir, { limits = CLIP_LIMITS, files = listStage(stageDir) } = {}) {
|
|
218
|
+
const decls = declaredClips(stageDir, limits);
|
|
219
|
+
let totalFrames = 0;
|
|
220
|
+
let totalBytes = 0;
|
|
221
|
+
const clips = decls.map((d) => {
|
|
222
|
+
const prefix = `${CLIPS_DIR}${path.sep}${d.dir}${path.sep}`;
|
|
223
|
+
if (d.count > limits.framesPerClip) throw clipFail(`clip "${d.id}": ${d.count} frames (at most ${limits.framesPerClip} per clip)`);
|
|
224
|
+
const have = new Map(files.filter((f) => f.rel.startsWith(prefix) && RASTER.includes(path.extname(f.rel).toLowerCase())).map((f) => [f.rel.slice(prefix.length), f]));
|
|
225
|
+
const frames = [];
|
|
226
|
+
for (let i = 1; i <= d.count; i++) {
|
|
227
|
+
const f = have.get(clipFrame(i));
|
|
228
|
+
if (!f) throw clipFail(`clip "${d.id}": ${CLIPS_DIR}/${d.dir}/${clipFrame(i)} is missing (declared ${d.count} frames, named frame_0001.png onward)`);
|
|
229
|
+
frames.push(f);
|
|
230
|
+
}
|
|
231
|
+
if (have.size !== d.count) {
|
|
232
|
+
const stray = [...have.keys()].find((name) => !frames.some((f) => f.rel.endsWith(`${path.sep}${name}`)));
|
|
233
|
+
throw clipFail(`clip "${d.id}": ${CLIPS_DIR}/${d.dir}/${stray} is not one of the ${d.count} declared frames; raise count or remove it`);
|
|
234
|
+
}
|
|
235
|
+
let size = null;
|
|
236
|
+
for (const f of frames) {
|
|
237
|
+
const info = rasterInfo(f.real);
|
|
238
|
+
if (path.extname(f.rel).toLowerCase() !== ".png" || !info) throw clipFail(`clip "${d.id}": ${f.rel} is not a readable PNG`);
|
|
239
|
+
if (info.animated) throw clipFail(`clip "${d.id}": ${f.rel} is an animated image; a clip is a folder of still frames`);
|
|
240
|
+
if (info.colorType !== 6 || info.bitDepth !== 8) throw clipFail(`clip "${d.id}": ${f.rel} must be an 8-bit RGBA PNG with an alpha channel (a keyed frame), not an opaque image`);
|
|
241
|
+
if (Math.max(info.width, info.height) > limits.side) throw clipFail(`clip "${d.id}": ${f.rel} is ${info.width}x${info.height}; a clip is an overlay of at most ${limits.side} px on the long side`);
|
|
242
|
+
if (size && (size.width !== info.width || size.height !== info.height)) throw clipFail(`clip "${d.id}": ${f.rel} is ${info.width}x${info.height} but frame_0001.png is ${size.width}x${size.height}; one size per clip`);
|
|
243
|
+
size = { width: info.width, height: info.height };
|
|
244
|
+
}
|
|
245
|
+
const bytes = frames.reduce((s, f) => s + f.bytes, 0);
|
|
246
|
+
if (bytes > limits.bytesPerClip) throw clipFail(`clip "${d.id}": ${(bytes / 1048576).toFixed(1)} MB (at most ${(limits.bytesPerClip / 1048576).toFixed(0)} MB per clip)`);
|
|
247
|
+
for (const f of [frames[0], frames[Math.floor((frames.length - 1) / 2)], frames[frames.length - 1]]) {
|
|
248
|
+
let pixels;
|
|
249
|
+
try {
|
|
250
|
+
({ pixels } = decodePng(readFileSync(f.real)));
|
|
251
|
+
} catch (error) {
|
|
252
|
+
throw clipFail(`clip "${d.id}": ${f.rel} cannot be decoded (${error.message}); use a non-interlaced 8-bit RGBA PNG`);
|
|
253
|
+
}
|
|
254
|
+
let keyed = false;
|
|
255
|
+
for (let i = 3; i < pixels.length && !keyed; i += 4) keyed = pixels[i] < 255;
|
|
256
|
+
if (!keyed) throw clipFail(`clip "${d.id}": ${f.rel} has no transparent pixel; a clip is keyed, not a full-frame video`);
|
|
257
|
+
}
|
|
258
|
+
totalFrames += d.count;
|
|
259
|
+
totalBytes += bytes;
|
|
260
|
+
return { ...d, ...size, bytes, frames: frames.map((f) => f.rel) };
|
|
261
|
+
});
|
|
262
|
+
if (totalFrames > limits.framesTotal) throw clipFail(`${totalFrames} clip frames in all (at most ${limits.framesTotal})`);
|
|
263
|
+
if (totalBytes > limits.bytesTotal) throw clipFail(`${(totalBytes / 1048576).toFixed(1)} MB of clip frames in all (at most ${(limits.bytesTotal / 1048576).toFixed(0)} MB)`);
|
|
264
|
+
return clips;
|
|
265
|
+
}
|
|
266
|
+
|
|
168
267
|
// ---- the static pre-flight scan ----
|
|
169
268
|
const TEXT = new Set([".html", ".js", ".mjs", ".css", ".svg", ".json"]);
|
|
170
269
|
const NAMESPACES = /^http:\/\/www\.w3\.org\/(?:2000\/svg|1999\/xlink|1999\/xhtml|XML\/1998\/namespace|2000\/xmlns\/?)$/u;
|
|
@@ -183,9 +282,11 @@ const NETWORK_API = /\bnew\s+(WebSocket|WebTransport|RTCPeerConnection|EventSour
|
|
|
183
282
|
|
|
184
283
|
/**
|
|
185
284
|
* Scan the stage dir before launch. Throws exit 17 (contract) or 19 (network) naming the file and
|
|
186
|
-
* the thing found; returns { files, rasters, warnings, plate } otherwise (plate: the Blender plate,
|
|
285
|
+
* the thing found; returns { files, rasters, warnings, plate, clips } otherwise (plate: the Blender plate,
|
|
286
|
+
* or null; clips: the declared keyed clips, checked by scanClips, whose frames are not page rasters).
|
|
287
|
+
* `clips: false` (cover mode) ignores clips.json, so a declared folder is held to the raster limits.
|
|
187
288
|
*/
|
|
188
|
-
export function scanStage(stageDir) {
|
|
289
|
+
export function scanStage(stageDir, { clips: allowClips = true } = {}) {
|
|
189
290
|
if (!existsSync(path.join(stageDir, "index.html"))) throw new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: ${path.join(stageDir, "index.html")} is missing; write the stage page first (references/stage.md)`);
|
|
190
291
|
const files = listStage(stageDir);
|
|
191
292
|
const warnings = [];
|
|
@@ -195,6 +296,8 @@ export function scanStage(stageDir) {
|
|
|
195
296
|
const plate = readPlate(stageDir, "plate");
|
|
196
297
|
const preview = readPlate(stageDir, "plate-preview");
|
|
197
298
|
const listed = new Set([plate, preview].filter(Boolean).flatMap((p) => p.frames.map((f) => path.join(p.dir, f.name))));
|
|
299
|
+
const clips = allowClips ? scanClips(stageDir, { files }) : [];
|
|
300
|
+
for (const c of clips) for (const rel of c.frames) listed.add(rel);
|
|
198
301
|
for (const f of files) {
|
|
199
302
|
const ext = path.extname(f.rel).toLowerCase();
|
|
200
303
|
if (!CONTENT_TYPES[ext] && f.rel !== "scene.py") warnings.push(`${f.rel}: not a servable type; the page cannot load it`);
|
|
@@ -234,7 +337,24 @@ export function scanStage(stageDir) {
|
|
|
234
337
|
for (const [size, names] of bySize) {
|
|
235
338
|
if (names.length >= RASTER_LIMITS.flipbook) throw new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: ${names.length} rasters of ${size} look like a flipbook; animate the page, not a frame sequence`);
|
|
236
339
|
}
|
|
237
|
-
return { files, rasters, warnings, plate };
|
|
340
|
+
return { files, rasters, warnings, plate, clips };
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* window.LitClips for LitStage.clip: id -> { src, count, fps, width, height }, written from clips.json and
|
|
345
|
+
* the first frame's header. null when the stage declares no clips (or one the scan would refuse).
|
|
346
|
+
*/
|
|
347
|
+
function clipsScript(stageDir) {
|
|
348
|
+
let table;
|
|
349
|
+
try {
|
|
350
|
+
table = Object.fromEntries(declaredClips(stageDir).map((c) => {
|
|
351
|
+
const info = rasterInfo(path.join(stageDir, CLIPS_DIR, c.dir, clipFrame(1)));
|
|
352
|
+
return [c.id, { src: `${CLIPS_DIR}/${c.dir}`, count: c.count, fps: c.fps, width: info.width, height: info.height }];
|
|
353
|
+
}));
|
|
354
|
+
} catch {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
return Object.keys(table).length ? `window.LitClips = ${JSON.stringify(table)};\n` : null;
|
|
238
358
|
}
|
|
239
359
|
|
|
240
360
|
/**
|
|
@@ -242,6 +362,7 @@ export function scanStage(stageDir) {
|
|
|
242
362
|
* type } | { kind: "blocked", reason } | { kind: "missing" }, and records every refusal.
|
|
243
363
|
*/
|
|
244
364
|
export function stageRouter({ stageDir, faces, style = null, threeDir = THREE_DIR }) {
|
|
365
|
+
const clipsJs = clipsScript(stageDir);
|
|
245
366
|
const root = realpathSync(stageDir);
|
|
246
367
|
const css = fontsCss(faces);
|
|
247
368
|
const byRoute = new Map(faces.map((f) => [f.route, f.file]));
|
|
@@ -265,6 +386,7 @@ export function stageRouter({ stageDir, faces, style = null, threeDir = THREE_DI
|
|
|
265
386
|
if (pathname === "/lit/stage-kit.js") return { kind: "file", file: KIT_FILE, type: CONTENT_TYPES[".js"] };
|
|
266
387
|
if (pathname === "/lit/loop-kit.js") return { kind: "file", file: LOOP_KIT_FILE, type: CONTENT_TYPES[".js"] };
|
|
267
388
|
if (pathname === "/lit/fonts.css") return { kind: "body", body: css, type: CONTENT_TYPES[".css"] };
|
|
389
|
+
if (clipsJs && pathname === "/lit/clips.js") return { kind: "body", body: clipsJs, type: CONTENT_TYPES[".js"] };
|
|
268
390
|
if (pathname.startsWith("/lit/three/")) {
|
|
269
391
|
// A backslash is a separator on Windows, so it is refused with `..`; the realpath must stay inside
|
|
270
392
|
// the vendored folder, so a link out of it is refused too.
|
|
@@ -133,7 +133,10 @@ async function openOnRung({ label, ctx }) {
|
|
|
133
133
|
else if (!error && !(spec.duration > 0)) error = fail("the page's duration must be a positive number of seconds");
|
|
134
134
|
if (!error && state.webglMissing) error = new BlockedError(EXIT.BLOCKED_NO_WEBGL2, `BLOCKED_NO_WEBGL2: the page asked for a WebGL context and the ${ctx.rung} rung gave none`);
|
|
135
135
|
if (!error && browser.prepared?.failedFaces?.length) log(`warning: faces that did not load: ${browser.prepared.failedFaces.join(", ")}`);
|
|
136
|
-
|
|
136
|
+
// A 3D page usually throws when its WebGL context comes back null (three.js does), so on the GPU
|
|
137
|
+
// rung a missing context outranks the contract error it causes: openChecked retries on SwiftShader.
|
|
138
|
+
// Linux CI Chrome has no GPU, so `--use-angle=gl` gives no WebGL there.
|
|
139
|
+
if (error && !(ctx.rung === "gpu" && state.webglMissing)) {
|
|
137
140
|
await browser.close();
|
|
138
141
|
throw error;
|
|
139
142
|
}
|
|
@@ -502,6 +505,7 @@ export async function renderStage({ out, round = 1, stillsOnly = false, env = pr
|
|
|
502
505
|
frameCount, seed: treatment.seed, renderer: finalState.webglRenderer ?? "no WebGL", rung: ctx.rung, chromeFlags: master.flags, usesWebGL: finalState.usesWebGL,
|
|
503
506
|
cuts, stills: { sha256: stills.sha256, poster: plan.poster, reduced: plan.reduced }, posterEncoding: poster,
|
|
504
507
|
geometry: geometryFor(width, height),
|
|
508
|
+
clips: scan.clips.map((c) => ({ id: c.id, frames: c.count, fps: c.fps, width: c.width, height: c.height, bytes: c.bytes })),
|
|
505
509
|
plate: scan.plate ? { blender: scan.plate.blender, engine: scan.plate.engine, device: scan.plate.device, samples: scan.plate.samples, fps: scan.plate.fps, frames: scan.plate.frames.length } : null,
|
|
506
510
|
sound: { mode: sound.mode, label: sound.label, file: sound.file ? path.relative(out, sound.file) : null, sha256: sound.file ? sha256(readFileSync(sound.file)) : null, lufs: sound.bed?.lufs ?? null },
|
|
507
511
|
preview: { encoder: preview.encoder, rung: preview.rung, attempts: preview.attempts },
|
|
@@ -183,6 +183,19 @@
|
|
|
183
183
|
const born = new Map();
|
|
184
184
|
const finished = new Set();
|
|
185
185
|
const svgBorn = new Map();
|
|
186
|
+
// An animation the page script starts is paused at once on the virtual clock. Left to the sweep in
|
|
187
|
+
// step(), it would play on the wall clock while the page loads, and on a slow host a short one
|
|
188
|
+
// finished, resolved `finished` and moved its chained successor before frame 0.
|
|
189
|
+
const nativeAnimate = Element.prototype.animate;
|
|
190
|
+
Element.prototype.animate = function animate(...args) {
|
|
191
|
+
const a = nativeAnimate.apply(this, args);
|
|
192
|
+
if (!born.has(a)) {
|
|
193
|
+
a.pause();
|
|
194
|
+
born.set(a, V.ms / 1000);
|
|
195
|
+
a.currentTime = 0;
|
|
196
|
+
}
|
|
197
|
+
return a;
|
|
198
|
+
};
|
|
186
199
|
const drainMicrotasks = async () => {
|
|
187
200
|
for (let i = 0; i < 8; i++) await Promise.resolve();
|
|
188
201
|
};
|
|
@@ -759,6 +759,45 @@
|
|
|
759
759
|
};
|
|
760
760
|
}
|
|
761
761
|
|
|
762
|
+
// A declared keyed clip (stage/clips/clips.json, served as window.LitClips by /lit/clips.js): one
|
|
763
|
+
// wrapper at `box` over the film, holding the clip's frame for t. The frame is a pure function of
|
|
764
|
+
// film time, floor((t - start) * fps) + 1 within from..to, so no <video> and no real clock is
|
|
765
|
+
// involved. Before `start` and after `to` the wrapper is hidden (null) unless `hold` keeps the last
|
|
766
|
+
// frame or `loop` wraps by frame index. The wrapper is the element a page scales or fades; the
|
|
767
|
+
// <img> inside is replaced on a frame change, so the renderer waits for its decode before capture.
|
|
768
|
+
function clip({ parent, id, box } = {}) {
|
|
769
|
+
const all = root.LitClips;
|
|
770
|
+
if (!all) throw new Error('LitStage.clip: load <script src="/lit/clips.js"></script> before the kit helpers; the stage declares no clips (clips/clips.json)');
|
|
771
|
+
const c = all[id];
|
|
772
|
+
if (!c) throw new Error(`LitStage.clip: no clip "${id}" in clips/clips.json (declared: ${Object.keys(all).join(", ")})`);
|
|
773
|
+
if (!parent || !box || !(box.w > 0) || !(box.h > 0)) throw new Error("LitStage.clip: needs { parent, id, box: { x, y, w, h } }");
|
|
774
|
+
const wrap = document.createElement("div");
|
|
775
|
+
wrap.setAttribute("data-lit-clip", id);
|
|
776
|
+
Object.assign(wrap.style, { position: "absolute", left: `${box.x}px`, top: `${box.y}px`, width: `${box.w}px`, height: `${box.h}px`, display: "none", pointerEvents: "none" });
|
|
777
|
+
parent.append(wrap);
|
|
778
|
+
let shown = 0;
|
|
779
|
+
let img = null;
|
|
780
|
+
return (t, { start = 0, from = 1, to = c.count, loop = false, hold = false } = {}) => {
|
|
781
|
+
if (!(from >= 1 && to <= c.count && from <= to)) throw new Error(`LitStage.clip: from..to must lie within 1..${c.count} (got ${from}..${to})`);
|
|
782
|
+
const n = to - from + 1;
|
|
783
|
+
const k = Math.floor((t - start) * c.fps + 1e-6);
|
|
784
|
+
const i = k < 0 ? 0 : k < n ? from + k : loop ? from + (k % n) : hold ? to : 0;
|
|
785
|
+
wrap.style.display = i ? "block" : "none";
|
|
786
|
+
if (!i) return null;
|
|
787
|
+
if (i !== shown) {
|
|
788
|
+
const next = document.createElement("img");
|
|
789
|
+
next.src = `${c.src}/frame_${String(i).padStart(4, "0")}.png`;
|
|
790
|
+
next.alt = "";
|
|
791
|
+
Object.assign(next.style, { display: "block", width: "100%", height: "100%", objectFit: "contain" });
|
|
792
|
+
if (img) img.replaceWith(next);
|
|
793
|
+
else wrap.append(next);
|
|
794
|
+
img = next;
|
|
795
|
+
shown = i;
|
|
796
|
+
}
|
|
797
|
+
return wrap;
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
|
|
762
801
|
// ---- the page contract ----
|
|
763
802
|
const FORMATS = [[1920, 1080], [1080, 1920]];
|
|
764
803
|
function define(spec) {
|
|
@@ -779,6 +818,6 @@
|
|
|
779
818
|
clipRect, clipCircle, maskLinear, wipe,
|
|
780
819
|
mix, rgba,
|
|
781
820
|
clamp, lerp, invLerp, remap, smoothstep,
|
|
782
|
-
shot, zone, place, tokens, plate,
|
|
821
|
+
shot, zone, place, tokens, plate, clip,
|
|
783
822
|
});
|
|
784
823
|
})(typeof window !== "undefined" ? window : globalThis);
|