feat(cli): timeline command reports unreadable lanes; add skill docs

This commit is contained in:
Miguel Angel Simon Sierra
2026-09-18 20:31:58 -04:00
parent d35eadc639
commit 7a59ed4c49
6 changed files with 59 additions and 16 deletions
@@ -12,6 +12,7 @@ const INDEX = `<html><body>
<div id="title" data-composition-src="compositions/title.html" data-start="a-roll + 1" data-duration="3" data-track-index="1"></div>
<audio id="vo" src="vo.mp3" data-start="0" data-duration="8" data-track-index="2" data-volume="0.5" data-audio-group="vo"
data-automation='{"version":1,"lanes":[{"target":"volume","points":[{"t":0,"v":0.2},{"t":2,"v":1}]}]}'></audio>
<audio id="bad" src="b.mp3" data-start="0" data-duration="1" data-track-index="3" data-automation="{nope"></audio>
<div id="wrapper"><img id="logo" src="logo.png" data-track-kind="graphics"></div>
</div></body></html>`;
@@ -36,7 +37,7 @@ describe("describeProject", () => {
expect(timeline.tracks.map((t) => [t.kind, t.rows.map((r) => r.id)])).toEqual([
["video", ["a-roll"]],
["graphics", ["logo", "title"]],
["audio", ["vo"]],
["audio", ["vo", "bad"]],
]);
const [video] = timeline.tracks[0]!.rows;
expect(video).toMatchObject({ start: 0, duration: 4, playbackRate: 2, src: "a.mp4" });
@@ -65,6 +66,15 @@ describe("describeProject", () => {
]);
});
it("reports unreadable automation instead of showing no lanes", () => {
const bad = describeProject(project())
.tracks.flatMap((t) => t.rows)
.find((r) => r.id === "bad")!;
expect(bad.lanes).toEqual([]);
expect(bad.laneError).toMatch(/not valid JSON/);
expect(formatTimeline(describeProject(project()))).toContain("lanes unreadable:");
});
it("marks a clip without an authored duration instead of reporting 0 as a fact", () => {
const logo = describeProject(project())
.tracks.flatMap((t) => t.rows)
@@ -77,7 +87,7 @@ describe("formatTimeline", () => {
it("prints one bar per row under its track heading", () => {
const text = formatTimeline(describeProject(project()));
expect(text).toMatch(/^timeline 10s\n\nvideo \(1\)\n \|█{16}/);
expect(text).toContain("audio (1)");
expect(text).toContain("audio (2)");
expect(text).toContain("vol=0.5 group=vo volume[0:0.2 2:1]");
expect(text).toContain("rate=2");
});
+12 -8
View File
@@ -21,6 +21,8 @@ export interface TimelineRow extends ClipFact {
trackKind: TrackKind;
/** False when the source does not author a duration (media length is only known at render). */
durationAuthored: boolean;
/** Why `data-automation` / `data-fx-chain` could not be read; `null` when fine or absent. */
laneError: string | null;
/** Clips of a sub-composition, times local to the host. One level only. */
children: TimelineRow[];
}
@@ -47,18 +49,19 @@ function toNode(el: Element): DomNode {
return { tag: el.tagName, attrs, children: Array.from(el.children).map(toNode), el };
}
function readLanes(el: Element): ClipLane[] {
function readLanes(el: Element): { lanes: ClipLane[]; laneError: string | null } {
const raw = el.getAttribute(HF_AUDIO_AUTOMATION_ATTR);
if (!raw) return [];
if (!raw) return { lanes: [], laneError: null };
try {
const fx = el.getAttribute(HF_AUDIO_FX_ATTR);
const chain = fx ? parseAudioFxChain(fx) : undefined;
return resolveAutomation(parseAutomation(raw), chain).lanes.map((lane) => ({
const lanes = resolveAutomation(parseAutomation(raw), chain).lanes.map((lane) => ({
target: lane.target,
points: lane.points.map(({ t, v }) => ({ t, v })),
}));
} catch {
return [];
return { lanes, laneError: null };
} catch (err) {
return { lanes: [], laneError: err instanceof Error ? err.message : String(err) };
}
}
@@ -72,10 +75,11 @@ function describeRow(doc: Document, node: DomNode, baseDir: string, depth: numbe
const inner = children.reduce((max, c) => Math.max(max, c.end), 0);
const duration = authored ?? inner;
const rate = parseNumeric(el.getAttribute("data-playback-rate"));
const kind = el.tagName.toLowerCase();
return {
id: el.id || el.getAttribute("data-composition-id") || `${el.tagName.toLowerCase()}`,
id: el.id || el.getAttribute("data-composition-id") || kind,
label: null,
kind: el.tagName.toLowerCase(),
kind,
trackKind: trackKindOf(node).kind,
start,
duration,
@@ -84,7 +88,7 @@ function describeRow(doc: Document, node: DomNode, baseDir: string, depth: numbe
src: el.getAttribute("src") ?? host,
sourceFile: host,
volume: parseNumeric(el.getAttribute("data-volume")),
lanes: readLanes(el),
...readLanes(el),
playbackRate: rate === 1 ? null : rate,
audioGroup: el.getAttribute(HF_AUDIO_GROUP_ATTR),
role: null,
+4 -2
View File
@@ -5,10 +5,11 @@ const n = (v: number) => String(Math.round(v * 100) / 100);
function bar(row: TimelineRow, total: number): string {
if (total <= 0) return " ".repeat(BAR_WIDTH);
const known = row.durationAuthored || row.duration > 0;
const from = Math.min(BAR_WIDTH - 1, Math.floor((row.start / total) * BAR_WIDTH));
const to = row.durationAuthored || row.duration > 0 ? (row.end / total) * BAR_WIDTH : BAR_WIDTH;
const to = known ? (row.end / total) * BAR_WIDTH : BAR_WIDTH;
const width = Math.max(1, Math.min(BAR_WIDTH, Math.ceil(to)) - from);
const fill = row.durationAuthored || row.duration > 0 ? "█" : "░";
const fill = known ? "█" : "░";
return " ".repeat(from) + fill.repeat(width) + " ".repeat(BAR_WIDTH - from - width);
}
@@ -22,6 +23,7 @@ function details(row: TimelineRow): string {
row.playbackRate !== null && `rate=${n(row.playbackRate)}`,
row.audioGroup && `group=${row.audioGroup}`,
!row.durationAuthored && "duration=unauthored",
row.laneError && `lanes unreadable: ${row.laneError}`,
...lanes,
]
.filter(Boolean)
+1 -1
View File
@@ -30,7 +30,7 @@
"files": 7
},
"hyperframes-cli": {
"hash": "666010a0b0d30da7",
"hash": "d5dd9f959a9cdf4a",
"files": 11
},
"hyperframes-core": {
+2 -2
View File
@@ -3,7 +3,7 @@ name: hyperframes-cli
description: >
Use the HyperFrames CLI development loop: init, add, catalog, capture, lint, check, snapshot,
compare, grade-compare, preview, play, present, beats, keyframes, single or batch render, publish,
cloud, cloudrun, feedback, lambda, doctor, browser, info, upgrade, skills, compositions, docs,
cloud, cloudrun, feedback, lambda, doctor, browser, info, upgrade, skills, compositions, timeline, docs,
benchmark, telemetry, transcribe, auth, tts, and remove-background. Also use when diagnosing build
or render failures. validate, inspect, and layout are deprecated aliases; use check. Covers local,
HeyGen-hosted cloud, AWS Lambda, and Google Cloud Run rendering.
@@ -147,7 +147,7 @@ The following references and owning skills are mandatory command contracts, not
| `auth`, HeyGen-hosted cloud rendering, and template variables | `references/cloud.md` |
| AWS Lambda deployment and rendering | `references/lambda.md` |
| Google Cloud Run deployment and rendering | `references/cloudrun.md` |
| `info`, `upgrade`, `compositions`, `docs`, `benchmark`, telemetry, media preprocessing | `references/upgrade-info-misc.md` |
| `info`, `upgrade`, `compositions`, `timeline`, `docs`, `benchmark`, telemetry, media preprocessing | `references/upgrade-info-misc.md` |
For composition variables, also read `/hyperframes-core` → `references/variables-and-media.md`. For `hyperframes add` and `hyperframes catalog`, use `/hyperframes-registry`. Before `hyperframes present`, read `/slideshow`; before `hyperframes keyframes`, read `/hyperframes-keyframes`. For TTS, transcription, captions, or background removal choices, use `/media-use`.
@@ -1,4 +1,4 @@
# info, upgrade, compositions, docs, benchmark, telemetry, asset preprocessing
# info, upgrade, compositions, timeline, docs, benchmark, telemetry, asset preprocessing
Catch-all reference for commands that don't fit the main dev loop.
@@ -25,6 +25,33 @@ Compares the installed CLI version against npm latest.
`--project [dir]` bumps a **project's** pinned scripts instead of the global install: it rewrites every `npx …hyperframes@<version>…` in `<dir>/package.json` (default cwd) to npm-latest. Always invoke it unpinned (`npx hyperframes@latest upgrade --project`) — a project scaffolded on an old CLI stays frozen otherwise. `--project . --check` reports the delta without writing; add `--json` for `{ changed, from, to, path }`. Pass the dir explicitly whenever another flag follows `--project` — on older releases a bare `--project` consumes the next flag as its directory value.
## timeline
```bash
npx hyperframes timeline [project-dir] # tracks and clips as a table with bars
npx hyperframes timeline [project-dir] --json
```
Reach for `timeline` instead of opening `index.html` and each `data-composition-src` file when you need to know what is on the timeline: which clips exist, when they start and end, what they play, and how loud. It reads the project's files statically (no browser).
Text output is `timeline <N>s`, then one block per track kind (`video`, `graphics`, `captions`, `audio`) with a row per top-level element:
```
graphics (2)
|██████ | sec-connector 0-6.7s src=compositions/connector-morph.html
|██████████████ | box 0-2.32s
audio (1)
| █ | vo 1.6-3.6s src=vo.mp3 vol=0.5 group=vo volume[0:0.2 2:1]
```
- The bar is 40 columns over the whole timeline. Times are seconds.
- `src=`, `vol=`, `rate=` (playback rate, only when not 1), `group=` (audio group), and `<target>[t:v ...]` (automation lane points, `t` in seconds from the clip start) appear only when the clip has them.
- Clips of a sub-composition are indented one level, with times local to that sub-composition. Deeper nesting is not expanded.
- `duration=unauthored` (dotted bar) means the element has no `data-duration`/`data-end`, so its length is only known at render time (typically media). Add a `data-duration` if the length matters.
- `lanes unreadable: ...` means the clip's `data-automation` or `data-fx-chain` did not parse; fix the attribute.
`--json` prints `{ timeline: { duration, tracks: [{ kind, rows: [...] }] } }`. Each row has `id`, `kind` (tag), `trackKind`, `start`, `duration`, `end`, `trackIndex`, `src`, `sourceFile`, `volume`, `lanes`, `playbackRate`, `audioGroup`, `durationAuthored`, `laneError`, and `children` (the sub-composition's rows).
## compositions, docs
```bash