kaizen-agent 1.49.0 → 1.50.0
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/agents/kaizen-reviewer.md +1 -1
- package/cli/hermes.ts +5 -2
- package/cli/notes.test.ts +1 -1
- package/cli/settings.test.ts +2 -0
- package/cli/settings.ts +2 -2
- package/cli/state.test.ts +24 -0
- package/cli/state.ts +18 -0
- package/cli/versions.test.ts +154 -0
- package/cli/versions.ts +272 -0
- package/cli/video.test.ts +64 -3
- package/cli/video.ts +111 -18
- package/cli/web.ts +15 -0
- package/package.json +1 -1
- package/skills/kaizen/README.md +5 -5
- package/skills/kaizen/SKILL.md +10 -14
- package/skills/kaizen/config.default.yml +3 -3
- package/skills/kaizen/spec-main.md +18 -16
- package/skills/kaizen/spec-plan.md +6 -6
- package/skills/kaizen/spec-review.md +2 -2
- package/skills/kaizen-help/SKILL.md +6 -5
- package/skills/media/kaizen-video/SKILL.md +20 -2
- package/skills/media/kaizen-video/canvas.html +241 -0
- package/skills/media/kaizen-video/examples/canvas-film/cat.txt +31 -0
- package/skills/media/kaizen-video/examples/canvas-film/film.json +460 -0
- package/skills/media/kaizen-video/examples/canvas-film/lines.json +10 -0
- package/skills/media/kaizen-video/examples/canvas-film/skip.txt +18 -0
- package/skills/media/kaizen-video/examples/canvas-film/talk.txt +23 -0
- package/skills/media/kaizen-video/examples/canvas-film/wow.txt +24 -0
- package/skills/media/kaizen-video/examples/kaizen-promo/promo.json +17 -0
- package/skills/media/kaizen-video/examples/kaizen-promo/record.json +10 -0
- package/skills/media/kaizen-video/examples/notula-promo/promo.json +41 -0
- package/skills/media/kaizen-video/examples/notula-promo/record.json +135 -0
- package/skills/media/kaizen-video/examples/notula-promo/seed.php +20 -0
- package/skills/media/kaizen-video/examples/notula-promo/seed.py +38 -0
- package/skills/media/kaizen-video/presets/app-promo/CREDITS.txt +2 -0
- package/skills/media/kaizen-video/presets/app-promo/README.md +21 -0
- package/skills/media/kaizen-video/presets/app-promo/preset.json +7 -0
- package/skills/media/kaizen-video/presets/app-promo/template/compositions/end.html +25 -0
- package/skills/media/kaizen-video/presets/app-promo/template/compositions/hook.html +19 -0
- package/skills/media/kaizen-video/presets/app-promo/template/compositions/name.html +19 -0
- package/skills/media/kaizen-video/presets/app-promo/template/compositions/step.html +52 -0
- package/skills/media/kaizen-video/presets/app-promo/template/index.html +24 -0
- package/skills/media/kaizen-video/presets/film-cinematic-drama/.hidden +1 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/.hidden +1 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/CREDITS.txt +3 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/README.md +7 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/fonts/InstrumentSerif.ttf +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/fonts/SpaceMono.ttf +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/boing.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/ding.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/ending.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/pop.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/reveal.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/shutter.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/stamp.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/tick.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/whoosh.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/style.json +15 -0
- package/skills/media/kaizen-video/presets/film-fun-energetic/.hidden +1 -0
- package/skills/media/kaizen-video/presets/film-promo-booth/.hidden +1 -0
- package/skills/media/kaizen-video/presets/film-viral-social/.hidden +1 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/index.html +1 -1
- package/skills/media/kaizen-video/references/canvas.md +60 -0
- package/skills/media/kaizen-video/references/presets.md +31 -0
- package/skills/media/kaizen-video/references/promo.md +148 -0
- package/skills/media/kaizen-video/references/revisions.md +11 -2
- package/skills/media/kaizen-video/scripts/make_film.py +157 -4
- package/skills/media/kaizen-video/scripts/make_promo.py +297 -0
- package/skills/media/kaizen-video/scripts/make_tiktok.py +34 -6
- package/skills/media/kaizen-video/scripts/pixel.py +40 -0
- package/skills/media/kaizen-video/scripts/record.mjs +103 -0
- package/web/board/approvals.ts +2 -2
- package/web/board/cards.ts +4 -4
- package/web/board/icebox.ts +6 -5
- package/web/board/panel.ts +2 -2
- package/web/board.html +24 -9
- package/web/board.js +24 -24
- package/web/notebook.js +10 -10
- package/web/notebook.ts +5 -1
- package/web/notes.html +19 -3
- package/web/term.js +1 -1
- package/web/video.html +62 -12
- package/web/video.js +67 -56
- package/web/video.ts +266 -33
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"""Build (and optionally render) an app-promo video: a product filmed in use, framed in its own devices.
|
|
2
|
+
|
|
3
|
+
python3 scripts/make_promo.py videos/<name> [--render]
|
|
4
|
+
|
|
5
|
+
Run from the project folder. videos/<name>/ holds promo.json (the brief, references/promo.md) and rec/,
|
|
6
|
+
the recordings from record.mjs (or the user's screen recordings with a rec/<clip>.json beside them).
|
|
7
|
+
Writes the HyperFrames project into videos/<name>/promo/, runs `hyperframes check` and snapshots one frame
|
|
8
|
+
per step into promo/check/; with --render it renders, levels the sound to -14 LUFS (true peak -1.5 dBTP)
|
|
9
|
+
and writes output/<name>/<preset>/<name>.mp4 with CREDITS.txt.
|
|
10
|
+
|
|
11
|
+
promo.json: "preset" (default app-promo), "product", "tagline", "cta", "hook" (2-3 lines; the last word
|
|
12
|
+
lands in the accent), "brand" {"logo", "bg", "ink", "accent", "muted", "font"}, "music" (a bundled track
|
|
13
|
+
name, or "none"), "steps": [{"clip", "caption" (*word* is the accent), "from", "to" (seconds of the clip),
|
|
14
|
+
"with" (a second clip on another device, shown together), "punch" ([] for none, or [{"at", "x", "y",
|
|
15
|
+
"zoom", "hold"}] in clip seconds and CSS px)}].
|
|
16
|
+
"""
|
|
17
|
+
import html
|
|
18
|
+
import json
|
|
19
|
+
import os
|
|
20
|
+
import re
|
|
21
|
+
import shutil
|
|
22
|
+
import subprocess
|
|
23
|
+
import sys
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
|
|
26
|
+
HF = "hyperframes@0.8.176"
|
|
27
|
+
SKILL = Path(__file__).resolve().parent.parent
|
|
28
|
+
|
|
29
|
+
args = [a for a in sys.argv[1:] if not a.startswith("--")]
|
|
30
|
+
if not args:
|
|
31
|
+
sys.exit(__doc__)
|
|
32
|
+
vdir = Path(args[0])
|
|
33
|
+
render = "--render" in sys.argv
|
|
34
|
+
brief = json.loads((vdir / "promo.json").read_text())
|
|
35
|
+
want = brief.get("preset", "app-promo")
|
|
36
|
+
if not re.fullmatch(r"[A-Za-z0-9][\w.-]*", want) or ".." in want:
|
|
37
|
+
sys.exit(f"preset {want!r}: a folder name, not a path")
|
|
38
|
+
dirs = [Path("presets"), Path(os.environ.get("KAIZEN_VIDEO_PRESETS", Path.home() / ".kaizen/video-presets")), SKILL / "presets"]
|
|
39
|
+
preset = next((d / want for d in dirs if (d / want / "preset.json").exists()), None)
|
|
40
|
+
if not preset:
|
|
41
|
+
sys.exit(f"template preset {want!r} not found (a folder with preset.json)")
|
|
42
|
+
name = vdir.name
|
|
43
|
+
proj = vdir / "promo"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def safe(n, what):
|
|
47
|
+
"""A file name from the brief: inside the video folder, never absolute or with '..'."""
|
|
48
|
+
if not n or Path(n).is_absolute() or ".." in Path(n).parts:
|
|
49
|
+
sys.exit(f"{what} {n!r}: give a name inside {vdir}, not a path out of it")
|
|
50
|
+
return n
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def clip(c):
|
|
54
|
+
safe(c, "clip")
|
|
55
|
+
meta = vdir / "rec" / f"{c}.json"
|
|
56
|
+
if not meta.exists() or not (vdir / "rec" / f"{c}.mp4").exists():
|
|
57
|
+
sys.exit(f"clip {c!r}: rec/{c}.mp4 and rec/{c}.json are needed (record.mjs makes both)")
|
|
58
|
+
return json.loads(meta.read_text())
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# ---- Brand
|
|
62
|
+
B = brief.get("brand", {})
|
|
63
|
+
bg, ink, accent = B.get("bg", "#0c162f"), B.get("ink", "#eef2fa"), B.get("accent", "#6d8cff")
|
|
64
|
+
font = B.get("font", "Inter")
|
|
65
|
+
dark = int(bg.lstrip("#")[:2], 16) + int(bg.lstrip("#")[2:4], 16) + int(bg.lstrip("#")[4:6], 16) < 384
|
|
66
|
+
css = f""":root {{ --bg: {bg}; --ink: {ink}; --accent: {accent}; --font: "{font}";
|
|
67
|
+
--muted: {B.get("muted", f"color-mix(in srgb, {ink} 62%, {bg})")}; --dim: color-mix(in srgb, {ink} 22%, {bg});
|
|
68
|
+
--bezel: color-mix(in srgb, {ink} {14 if dark else 80}%, {bg}); --bezel-edge: color-mix(in srgb, {ink} {24 if dark else 30}%, {bg}); }}"""
|
|
69
|
+
esc = html.escape
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def words(text, last_id=None):
|
|
73
|
+
"""Words as spans; *word* is the accent; "/" breaks the line."""
|
|
74
|
+
out = []
|
|
75
|
+
for line in text.split("/"):
|
|
76
|
+
ws = line.split()
|
|
77
|
+
out.append(" ".join(f"<span>{'<b>' + esc(w.strip('*')) + '</b>' if w.startswith('*') else esc(w)}</span>" for w in ws))
|
|
78
|
+
s = "<br />".join(out)
|
|
79
|
+
if last_id:
|
|
80
|
+
s = re.sub(r"<span>([^<]*)</span>$", rf'<span id="{last_id}">\1</span>', s)
|
|
81
|
+
return s
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def fit(text, size, width=1000):
|
|
85
|
+
return int(min(size, width / max(1, len(text) * 0.58)))
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# ---- Device geometry (9:16 frame, 1080 x 1920). Screens keep the recording's aspect.
|
|
89
|
+
def frames(step, sid):
|
|
90
|
+
"""HTML for the step's device(s), with its clips and tap marks; returns (html, taps, points)."""
|
|
91
|
+
a = clip(step["clip"])
|
|
92
|
+
b = clip(step["with"]) if step.get("with") else None
|
|
93
|
+
t0, t1 = step.get("from", 0), step.get("to", a["seconds"])
|
|
94
|
+
dur = t1 - t0
|
|
95
|
+
parts, taps, points, conv = [], [], [], []
|
|
96
|
+
|
|
97
|
+
def device(c, meta, box, small=False):
|
|
98
|
+
kind = meta["device"]
|
|
99
|
+
x, y, w = box
|
|
100
|
+
if kind == "tablet": # a phone-style bezel, as wide as the frame's height allows (screen at most 1388 tall)
|
|
101
|
+
sw = min(w - 28, round(1388 * meta["cssW"] / meta["cssH"]))
|
|
102
|
+
w = sw + 28
|
|
103
|
+
x, y = (1080 - w) // 2, 440
|
|
104
|
+
if kind in ("phone", "tablet"):
|
|
105
|
+
sw = w - 28
|
|
106
|
+
sh = round(sw * meta["cssH"] / meta["cssW"])
|
|
107
|
+
ox, oy, k = x + 14, y + 14, sw / meta["cssW"]
|
|
108
|
+
body = (f'<div class="s-phone" style="left:{x}px;top:{y}px;width:{w}px;height:{sh + 28}px">'
|
|
109
|
+
f'<div class="scr" style="width:{sw}px;height:{sh}px">')
|
|
110
|
+
else:
|
|
111
|
+
sh = round(w * meta["cssH"] / meta["cssW"])
|
|
112
|
+
ox, oy, k = x, y + 64, w / meta["cssW"]
|
|
113
|
+
# A web product sits in a browser with its real URL; a native app ("app": the user's recording) in a titled window.
|
|
114
|
+
bar = (f'<i></i><i></i><i></i><span class="ttl">{esc(brief.get("product", ""))}</span>' if kind == "app"
|
|
115
|
+
else f'<i></i><i></i><i></i><span class="url">{esc(brief.get("url", ""))}</span>')
|
|
116
|
+
body = (f'<div class="s-win" style="left:{x}px;top:{y}px;width:{w}px"><div class="bar">{bar}</div>'
|
|
117
|
+
f'<div class="scr" style="width:{w}px;height:{sh}px">')
|
|
118
|
+
conv.append((ox, oy, k))
|
|
119
|
+
vid = f"{sid}-{c}"
|
|
120
|
+
body += (f'<video id="{vid}" class="clip" src="assets/rec/{c}.mp4" muted playsinline data-start="0" '
|
|
121
|
+
f'data-duration="{dur:.3f}" data-media-start="{t0:.3f}" data-track-index="0"></video>')
|
|
122
|
+
for i, tp in enumerate(m for m in meta["taps"] if t0 <= m["t"] < t1):
|
|
123
|
+
tid = f"{vid}-t{i}"
|
|
124
|
+
body += f'<div class="s-tap{" sm" if small else ""}" id="{tid}" style="left:{tp["x"] * k:.0f}px;top:{tp["y"] * k:.0f}px"></div>'
|
|
125
|
+
taps.append([tid, round(tp["t"] - t0, 3)])
|
|
126
|
+
points.append((tp["t"] - t0, ox + tp["x"] * k, oy + tp["y"] * k, kind))
|
|
127
|
+
return body + "</div></div>"
|
|
128
|
+
|
|
129
|
+
if b: # duo: the window large, the phone overlapping at the bottom right, both playing the same task
|
|
130
|
+
win, ph = (a, b) if a["device"] != "phone" else (b, a)
|
|
131
|
+
wc, pc = (step["clip"], step["with"]) if a is win else (step["with"], step["clip"])
|
|
132
|
+
parts.append(device(wc, win, (30, 470, 900)))
|
|
133
|
+
parts.append(device(pc, ph, (690, 860, 360), small=True))
|
|
134
|
+
elif a["device"] == "phone":
|
|
135
|
+
parts.append(device(step["clip"], a, (206, 440, 668)))
|
|
136
|
+
else:
|
|
137
|
+
parts.append(device(step["clip"], a, (40, 560, 1000)))
|
|
138
|
+
# CSS px -> frame px for hand-placed punch-ins: the step's one device, or the phone of a duo (drawn last).
|
|
139
|
+
return f'<div id="{sid}-dev">{"".join(parts)}</div>', taps, points, dur, a["device"] if not b else "duo", conv[-1]
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def punches(step, points, dur, dev, conv):
|
|
143
|
+
"""Punch in on a tap when the UI then has time to act (the next tap is 1.6 s or more away).
|
|
144
|
+
With two devices on screen only the phone's taps lead, and gently, so the window stays in frame."""
|
|
145
|
+
if "punch" in step:
|
|
146
|
+
ox, oy, k = conv # x/y are CSS px of the step's clip, like the tap log
|
|
147
|
+
return [[p["at"] - step.get("from", 0), round(ox + p["x"] * k), round(oy + p["y"] * k), p.get("zoom", 1.35), p.get("hold", 2.0)] for p in step["punch"]]
|
|
148
|
+
if dev == "duo":
|
|
149
|
+
points = [p for p in points if p[3] == "phone"]
|
|
150
|
+
out, pts = [], sorted(points)
|
|
151
|
+
for i, (t, x, y, kind) in enumerate(pts):
|
|
152
|
+
nxt = pts[i + 1][0] if i + 1 < len(pts) else dur
|
|
153
|
+
gap = nxt - t
|
|
154
|
+
if gap < 1.6 or t < 0.3:
|
|
155
|
+
continue
|
|
156
|
+
z = 1.18 if dev == "duo" else 1.3 if kind == "phone" else 1.7
|
|
157
|
+
out.append([round(t + 0.1, 3), round(x), round(y), z, round(min(2.4, gap - 1.2), 2)])
|
|
158
|
+
return out
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
# ---- Project
|
|
162
|
+
shutil.rmtree(proj, ignore_errors=True)
|
|
163
|
+
shutil.copytree(preset / "template", proj)
|
|
164
|
+
(proj / "assets/rec").mkdir(parents=True, exist_ok=True)
|
|
165
|
+
(proj / "assets/sfx").mkdir(parents=True, exist_ok=True)
|
|
166
|
+
for f in (vdir / "rec").glob("*.mp4"):
|
|
167
|
+
shutil.copy(f, proj / "assets/rec" / f.name)
|
|
168
|
+
for f in (SKILL / "presets/tiktok-explainer/assets/sfx").glob("*.wav"):
|
|
169
|
+
shutil.copy(f, proj / "assets/sfx" / f.name)
|
|
170
|
+
mark = ""
|
|
171
|
+
if B.get("logo"):
|
|
172
|
+
src = vdir / safe(B["logo"], "brand logo")
|
|
173
|
+
if not src.exists():
|
|
174
|
+
sys.exit(f"brand logo {B['logo']!r} not found in {vdir}")
|
|
175
|
+
shutil.copy(src, proj / "assets" / ("logo" + src.suffix))
|
|
176
|
+
mark = f'<div id="end-mark"><img src="assets/logo{src.suffix}" alt="" /></div>'
|
|
177
|
+
|
|
178
|
+
comp = proj / "compositions"
|
|
179
|
+
step_tpl = (comp / "step.html").read_text()
|
|
180
|
+
(comp / "step.html").unlink()
|
|
181
|
+
product, tagline, cta = brief.get("product", name), brief.get("tagline", ""), brief.get("cta", "")
|
|
182
|
+
hook = brief.get("hook", [])
|
|
183
|
+
hook_text = " / ".join(hook)
|
|
184
|
+
fill = {"HOOK_HTML": words(hook_text, "hook-last"), "HOOK_SIZE": fit(max(hook, key=len) if hook else "x", 150, 900),
|
|
185
|
+
"NAME": esc(product), "NAME_SIZE": fit(product, 230), "END_SIZE": fit(product, 168), "TAGLINE": esc(tagline),
|
|
186
|
+
"CTA": esc(cta), "MARK": mark}
|
|
187
|
+
for f in ("hook.html", "name.html", "end.html"):
|
|
188
|
+
s = (comp / f).read_text()
|
|
189
|
+
for k, v in fill.items():
|
|
190
|
+
s = s.replace("{{" + k + "}}", str(v))
|
|
191
|
+
(comp / f).write_text(s)
|
|
192
|
+
|
|
193
|
+
scenes, sfx, t = [], [], 0.0
|
|
194
|
+
if hook:
|
|
195
|
+
scenes.append(("hook", 0.0, 2.4)); sfx.append(("whoosh", 2.2)); t = 2.4
|
|
196
|
+
scenes.append(("name", t, 1.8)); sfx.append(("whoosh", t + 1.6)); t += 1.8
|
|
197
|
+
prev_dev = None
|
|
198
|
+
steps = brief["steps"]
|
|
199
|
+
for i, st in enumerate(steps):
|
|
200
|
+
sid = f"step{i + 1}"
|
|
201
|
+
body, taps, points, dur, dev, conv = frames(st, sid)
|
|
202
|
+
top = min(int(m) for m in re.findall(r'class="s-(?:phone|win)" style="left:\d+px;top:(\d+)px', body))
|
|
203
|
+
data = {"id": sid, "taps": taps, "punches": punches(st, points, dur, dev, conv), "rise": dev != prev_dev, "dur": round(dur, 3), "last": False, "top": top}
|
|
204
|
+
s = (step_tpl.replace("{{ID}}", sid).replace("{{CAPTION}}", words(st["caption"])).replace("{{FRAMES}}", body)
|
|
205
|
+
.replace("/*DATA*/{}", json.dumps(data)))
|
|
206
|
+
(comp / f"{sid}.html").write_text(s)
|
|
207
|
+
scenes.append((sid, t, dur))
|
|
208
|
+
if dev != prev_dev and prev_dev:
|
|
209
|
+
sfx.append(("whoosh", t - 0.15))
|
|
210
|
+
for k, (_, tt) in enumerate(taps):
|
|
211
|
+
sfx.append(("tick" if k % 2 == 0 else "pop", t + tt - 0.03))
|
|
212
|
+
prev_dev = dev
|
|
213
|
+
t += dur
|
|
214
|
+
scenes.append(("end", t, 3.4)); sfx.append(("reveal", t + 0.05))
|
|
215
|
+
total = round(t + 3.4, 3)
|
|
216
|
+
|
|
217
|
+
music = brief.get("music", "sunny")
|
|
218
|
+
audio = ""
|
|
219
|
+
if music != "none":
|
|
220
|
+
track = SKILL / "assets/music" / f"{music}.mp3"
|
|
221
|
+
if not track.exists():
|
|
222
|
+
sys.exit(f"music {music!r} not found in assets/music")
|
|
223
|
+
shutil.copy(track, proj / "assets/music.mp3")
|
|
224
|
+
audio += f' <audio id="music" src="assets/music.mp3" data-start="0" data-duration="{total}" data-track-index="2" data-volume="0.55" data-fade-out="1.5"></audio>\n'
|
|
225
|
+
for i, (snd, at) in enumerate(sfx):
|
|
226
|
+
d = {"whoosh": 0.6, "tick": 0.06, "pop": 0.18, "reveal": 0.6}[snd]
|
|
227
|
+
audio += f' <audio id="sfx{i}" src="assets/sfx/{snd}.wav" data-start="{max(0, at):.3f}" data-duration="{d}" data-track-index="3" data-volume="0.8"></audio>\n'
|
|
228
|
+
hosts = "\n".join(
|
|
229
|
+
f' <div id="{sid}" data-composition-id="{sid}" data-composition-src="compositions/{sid}.html" data-start="{st:.3f}" '
|
|
230
|
+
f'data-duration="{d:.3f}" data-track-index="1" data-track-kind="graphics" data-width="1080" data-height="1920"></div>'
|
|
231
|
+
for sid, st, d in scenes)
|
|
232
|
+
page = (proj / "index.html").read_text()
|
|
233
|
+
for k, v in {"CSS": css, "DURATION": total, "SCENES": hosts, "AUDIO": audio, "LANG": brief.get("language", "en")}.items():
|
|
234
|
+
page = page.replace("{{" + k + "}}", str(v))
|
|
235
|
+
(proj / "index.html").write_text(page)
|
|
236
|
+
|
|
237
|
+
# SPEC.md: the brief as numbers, for whoever opens the project in HyperFrames Studio.
|
|
238
|
+
spec = [f"GOAL: a viewer sees {product} do {len(steps)} real tasks and knows where to get it ({cta}).",
|
|
239
|
+
f"OUTPUT: HyperFrames, 1080 x 1920, 30 fps; {total} s; preset {preset.name}",
|
|
240
|
+
f"LOOK: ground {bg}, ink {ink}, accent {accent} (one word per caption, the hook's last word, the CTA); {font} 900",
|
|
241
|
+
"MOTION: arrivals expo.out 0.5-0.7 s; camera power2.inOut 0.5 s; captions blur 6px->0, 0.067 s apart, dead still after landing",
|
|
242
|
+
"SHOTS:"] + [f" {sid} {st:.1f}-{st + d:.1f}" for sid, st, d in scenes] + [
|
|
243
|
+
"BANNED: invented UI; glow, grain, particles; breathing loops; fade-and-slide-up; text outside 168-1330 px; a repeated claim"]
|
|
244
|
+
(proj / "SPEC.md").write_text("\n".join(spec) + "\n")
|
|
245
|
+
print(f"preset {preset}\n{len(steps)} steps, {len(sfx)} sounds, {total}s -> {proj}")
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def run(*cmd, **kw):
|
|
249
|
+
return subprocess.run(cmd, cwd=proj, **kw)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
chk = run("npx", "--yes", HF, "check", capture_output=True, text=True)
|
|
253
|
+
print("\n".join(l for l in chk.stdout.splitlines() if "✗" in l or "Check" in l))
|
|
254
|
+
if chk.returncode:
|
|
255
|
+
sys.exit("hyperframes check failed; see above")
|
|
256
|
+
at = ",".join(f"{st + min(d * 0.6, d - 0.2):.2f}" for sid, st, d in scenes)
|
|
257
|
+
snap = run("npx", "--yes", HF, "snapshot", "--at", at, capture_output=True, text=True)
|
|
258
|
+
m = re.search(r"(\S*contact-sheet[^\s]*\.jpg)", snap.stdout)
|
|
259
|
+
if m:
|
|
260
|
+
(proj / "check").mkdir(exist_ok=True)
|
|
261
|
+
shutil.copy(proj / m.group(1) if not m.group(1).startswith("/") else m.group(1), proj / "check/sheet.jpg")
|
|
262
|
+
print(f"snapshots: {proj / 'check/sheet.jpg'}")
|
|
263
|
+
if not render:
|
|
264
|
+
sys.exit(0)
|
|
265
|
+
|
|
266
|
+
out = Path("output") / name / preset.name
|
|
267
|
+
out.mkdir(parents=True, exist_ok=True)
|
|
268
|
+
raw, final = proj / "render.mp4", out / f"{name}.mp4"
|
|
269
|
+
tmp = proj / ".render-tmp"
|
|
270
|
+
tmp.mkdir(exist_ok=True)
|
|
271
|
+
run("npx", "--yes", HF, "render", "--crf", "18", "-o", str(raw.resolve()), check=True, env={**os.environ, "TMPDIR": str(tmp)})
|
|
272
|
+
shutil.rmtree(tmp, ignore_errors=True)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def loud(f):
|
|
276
|
+
r = subprocess.run(["ffmpeg", "-i", str(f), "-af", "ebur128=peak=true", "-f", "null", "-"], capture_output=True, text=True).stderr
|
|
277
|
+
i = float(re.findall(r"I:\s+(-?[\d.]+) LUFS", r)[-1])
|
|
278
|
+
p = float(re.findall(r"Peak:\s+(-?[\d.]+) dBFS", r)[-1])
|
|
279
|
+
return i, p
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
# Gain to -14 LUFS, then a limiter for the true peak; one correction pass if the limiter cost loudness.
|
|
283
|
+
gain = -14 - loud(raw)[0]
|
|
284
|
+
for _ in range(2):
|
|
285
|
+
subprocess.run(["ffmpeg", "-v", "error", "-y", "-i", str(raw), "-c:v", "copy", "-af",
|
|
286
|
+
f"volume={gain:.2f}dB,alimiter=limit=0.6:level=false:attack=1:release=60", "-ar", "48000", "-c:a", "aac", "-b:a", "192k", str(final)], check=True)
|
|
287
|
+
i, p = loud(final)
|
|
288
|
+
if abs(i + 14) <= 0.6:
|
|
289
|
+
break
|
|
290
|
+
gain += -14 - i
|
|
291
|
+
print(f"loudness {i} LUFS, true peak {p} dBTP")
|
|
292
|
+
credits = [f.read_text().strip() for f in (vdir / "CREDITS.txt", preset / "CREDITS.txt") if f.exists()]
|
|
293
|
+
if music != "none":
|
|
294
|
+
m2 = re.search(rf"^- {re.escape(music)}\.mp3: (.+)$", (SKILL / "assets/CREDITS.txt").read_text(), re.M)
|
|
295
|
+
credits.append("Music: " + (m2.group(1) if m2 else music))
|
|
296
|
+
(out / "CREDITS.txt").write_text("\n\n".join(credits) + "\n")
|
|
297
|
+
print(f"rendered {final}")
|
|
@@ -10,6 +10,10 @@ The preset is found by folder name in ./presets/, then $KAIZEN_VIDEO_PRESETS
|
|
|
10
10
|
(default ~/.kaizen/video-presets/), then the skill's bundled presets/. A preset file
|
|
11
11
|
missing from its folder falls back to the skill's shared assets/, tools/ and
|
|
12
12
|
hyperframes.json.
|
|
13
|
+
|
|
14
|
+
A film preset (a folder with style.json) works too: the cut footage becomes one full-length footage beat of
|
|
15
|
+
a film in videos/<name>/film-bridge/, its sound the narration and its words the timings, and make_film.py
|
|
16
|
+
builds and renders it in that style (the film's grade, captions, music and loudness; no cards from beats).
|
|
13
17
|
"""
|
|
14
18
|
import html
|
|
15
19
|
import os
|
|
@@ -33,10 +37,11 @@ proj.mkdir(exist_ok=True)
|
|
|
33
37
|
cfg = json.loads((vdir / "config.json").read_text())
|
|
34
38
|
dirs = [WORK / "presets", Path(os.environ.get("KAIZEN_VIDEO_PRESETS", Path.home() / ".kaizen/video-presets")), SKILL / "presets"]
|
|
35
39
|
preset = next((d / cfg["preset"] for d in dirs if (d / cfg["preset"] / "index.html").exists()), None)
|
|
36
|
-
if
|
|
37
|
-
|
|
40
|
+
film_style = None if preset else next((d / n for n in (cfg["preset"], "film-" + cfg["preset"]) for d in dirs if (d / n / "style.json").exists()), None)
|
|
41
|
+
if not preset and not film_style:
|
|
42
|
+
names = sorted({p.parent.name for d in dirs if d.exists() for p in [*d.glob("*/index.html"), *d.glob("*/style.json")]})
|
|
38
43
|
sys.exit(f"preset {cfg['preset']!r} not found in {', '.join(map(str, dirs))}; available: {', '.join(names)}")
|
|
39
|
-
print(f"preset {preset}")
|
|
44
|
+
print(f"preset {preset or film_style}")
|
|
40
45
|
src_of = lambda p: next(f for f in (preset / p, SKILL / p) if f.exists()) # preset file, else the shared one
|
|
41
46
|
rel = lambda p: (vdir / p).resolve()
|
|
42
47
|
|
|
@@ -46,9 +51,9 @@ def run(*cmd, **kw):
|
|
|
46
51
|
|
|
47
52
|
|
|
48
53
|
# 1. Preset files and this video's images into the project.
|
|
49
|
-
for f in ["package.json", "hyperframes.json"]:
|
|
54
|
+
for f in [] if film_style else ["package.json", "hyperframes.json"]:
|
|
50
55
|
shutil.copy(src_of(f), proj / f)
|
|
51
|
-
for d in ["fonts", "sfx"]:
|
|
56
|
+
for d in [] if film_style else ["fonts", "sfx"]:
|
|
52
57
|
shutil.rmtree(proj / "assets" / d, ignore_errors=True)
|
|
53
58
|
for base in (SKILL, preset): # shared assets first, the preset's own on top
|
|
54
59
|
if (base / "assets" / d).exists():
|
|
@@ -87,6 +92,26 @@ for s0, s1, length in segs:
|
|
|
87
92
|
cut_duration = offset
|
|
88
93
|
flat = [w for c in chunks for w in c]
|
|
89
94
|
|
|
95
|
+
if film_style:
|
|
96
|
+
# Hand the cut to the film engine: one footage beat as long as the cut, with no lead or tail so the voice stays on the lips.
|
|
97
|
+
bridge = vdir / "film-bridge"
|
|
98
|
+
bridge.mkdir(exist_ok=True)
|
|
99
|
+
src = rel(cfg["video"])
|
|
100
|
+
subprocess.run(["ffmpeg", "-v", "error", "-y", "-i", str(src), "-an", "-vf", "scale=1080:1920:flags=lanczos,fps=30,format=yuv420p",
|
|
101
|
+
"-c:v", "libx264", "-crf", "16", "-g", "30", str(bridge / "footage.mp4")], check=True)
|
|
102
|
+
subprocess.run(["ffmpeg", "-v", "error", "-y", "-i", str(src), "-vn", "-af", "afftdn=nf=-28,deesser=i=0.35", "-b:a", "256k", str(bridge / "v01.mp3")], check=True)
|
|
103
|
+
length = float(subprocess.check_output(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", str(src)]))
|
|
104
|
+
(bridge / "words.json").write_text(json.dumps({"v01": {"dur": round(length, 3), "offset": 0, "text": " ".join(w["w"] for w in flat), "words": flat}}, ensure_ascii=False))
|
|
105
|
+
(bridge / "lines.json").write_text(json.dumps({"v01": " ".join(w["w"] for w in flat)}, ensure_ascii=False))
|
|
106
|
+
if (vdir / "CREDITS.txt").exists():
|
|
107
|
+
shutil.copy(vdir / "CREDITS.txt", bridge / "CREDITS.txt")
|
|
108
|
+
(bridge / "film.json").write_text(json.dumps({"name": cfg["name"], "preset": film_style.name, "format": "9x16", "language": cfg.get("language", "id"),
|
|
109
|
+
"music": cfg["music"], "style": {"pace": {"lead": 0, "tail": 0}},
|
|
110
|
+
"beats": [{"kind": "footage", "video": "footage.mp4", "vo": "v01"}]}, ensure_ascii=False, indent=1))
|
|
111
|
+
print(f"film preset {film_style.name}: building the cut as a film")
|
|
112
|
+
subprocess.run(["python3", str(SKILL / "scripts/make_film.py"), str(bridge), *(["--render"] if "--render" in sys.argv else [])], check=True, cwd=WORK)
|
|
113
|
+
sys.exit(0)
|
|
114
|
+
|
|
90
115
|
|
|
91
116
|
def at(key, after=0):
|
|
92
117
|
try:
|
|
@@ -103,7 +128,8 @@ if co:
|
|
|
103
128
|
else:
|
|
104
129
|
co_a = co_b = 0.0
|
|
105
130
|
L = round(co_b - co_a, 3)
|
|
106
|
-
|
|
131
|
+
# A beat is placed on a spoken word, or at "t" seconds (films bridged from make_film.py).
|
|
132
|
+
beats = sorted(({**{k: v for k, v in b_.items() if k not in ("word", "after")}, "t": round((b_["t"] if "t" in b_ else at(b_["word"], b_.get("after", 0))) + L, 3)}
|
|
107
133
|
for b_ in cfg["beats"]), key=lambda x: x["t"])
|
|
108
134
|
shift = lambda w, d: {**w, "s": round(w["s"] + d, 3), "e": round(w["e"] + d, 3)}
|
|
109
135
|
cold = [[shift(w, -co_a) for w in c if co_a <= w["s"] and w["e"] <= co_b] for c in chunks] if co else []
|
|
@@ -179,6 +205,8 @@ page = (preset / "index.html").read_text()
|
|
|
179
205
|
for k, v in {"DURATION": duration, "VIDEO_DURATION": video_duration, "VIDEO": "source.mp4", "MUSIC_VOLUME": cfg.get("music_volume", 0.32),
|
|
180
206
|
"HOOK_1": html.escape(h["line1"]), "HOOK_2": html.escape(h["line2"]), "HOOK_SUB": html.escape(h["sub"])}.items():
|
|
181
207
|
page = page.replace("{{" + k + "}}", str(v))
|
|
208
|
+
if cfg.get("card") is False: # no real footage behind it (a film bridged from make_film.py): hide the clip card
|
|
209
|
+
page = page.replace("</head>", "<style>#cam { opacity: 0 !important; }</style>\n </head>", 1) # the renderer paints video despite visibility
|
|
182
210
|
page = page.replace("<!-- SFX:BEGIN -->", "<!-- SFX:BEGIN -->\n" + tags + "\n ")
|
|
183
211
|
(proj / "index.html").write_text(page)
|
|
184
212
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Pixel art: a text grid and its palette into a crisp PNG, for mascots, icons and scene pictures.
|
|
2
|
+
|
|
3
|
+
python3 scripts/pixel.py <art.txt> <out.png> [--scale N]
|
|
4
|
+
|
|
5
|
+
art.txt: palette lines "X #rrggbb" (or "X #rrggbbaa"), a blank line, then the grid, one character per pixel;
|
|
6
|
+
"." and any character not in the palette are transparent. Rows may differ in length (short rows are padded).
|
|
7
|
+
The grid is upscaled N times (default 32) with nearest-neighbour, so edges stay sharp.
|
|
8
|
+
"""
|
|
9
|
+
import sys
|
|
10
|
+
from PIL import Image
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def render(text, scale=32):
|
|
14
|
+
head, _, body = text.strip("\n").partition("\n\n")
|
|
15
|
+
pal = {}
|
|
16
|
+
for line in head.splitlines():
|
|
17
|
+
k, v = line.split()
|
|
18
|
+
v = v.lstrip("#")
|
|
19
|
+
pal[k] = tuple(int(v[i:i + 2], 16) for i in range(0, len(v), 2)) + ((255,) if len(v) == 6 else ())
|
|
20
|
+
rows = body.strip("\n").splitlines()
|
|
21
|
+
img = Image.new("RGBA", (max(map(len, rows)), len(rows)), (0, 0, 0, 0))
|
|
22
|
+
for y, r in enumerate(rows):
|
|
23
|
+
for x, ch in enumerate(r):
|
|
24
|
+
if ch in pal:
|
|
25
|
+
img.putpixel((x, y), pal[ch])
|
|
26
|
+
return img.resize((img.width * scale, img.height * scale), Image.NEAREST)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
if sys.argv[1:] == ["--check"]: # self-test
|
|
31
|
+
im = render("R #ff0000\nB #0000ff80\n\nR.\n.B", 2)
|
|
32
|
+
assert im.size == (4, 4) and im.getpixel((0, 0)) == (255, 0, 0, 255) and im.getpixel((2, 0))[3] == 0
|
|
33
|
+
assert im.getpixel((3, 3)) == (0, 0, 255, 128) and im.getpixel((1, 1)) == (255, 0, 0, 255)
|
|
34
|
+
print("ok")
|
|
35
|
+
sys.exit()
|
|
36
|
+
if len(sys.argv) < 3:
|
|
37
|
+
sys.exit(__doc__)
|
|
38
|
+
scale = int(sys.argv[sys.argv.index("--scale") + 1]) if "--scale" in sys.argv else 32
|
|
39
|
+
render(open(sys.argv[1]).read(), scale).save(sys.argv[2])
|
|
40
|
+
print(f"wrote {sys.argv[2]}")
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Films a web product in use, for app-promo (references/promo.md).
|
|
2
|
+
//
|
|
3
|
+
// node scripts/record.mjs videos/<name> # reads videos/<name>/record.json
|
|
4
|
+
//
|
|
5
|
+
// record.json: {"url": "http://...", "clips": [{"name": "idea", "device": "phone"|"tablet"|"desktop",
|
|
6
|
+
// "path": "/optional/start/path", "steps": [["wait", ms], ["tap", "css" | "text:Label"], ["type", "css", "text", msPerKey?],
|
|
7
|
+
// ["key", "Enter"], ["scroll", px], ["goto", "/path"]], "prep": [same steps, run before filming starts, e.g. a sign-in]}]}
|
|
8
|
+
// Writes videos/<name>/rec/<clip>.mp4 (30 fps, the device's full pixels) and rec/<clip>.json
|
|
9
|
+
// ({device, cssW, cssH, taps: [{t, x, y}]}, x/y in CSS px of the page, t in seconds of the clip).
|
|
10
|
+
// Frames are full-resolution screenshots taken in a loop while the steps run (Chromium's own screencast
|
|
11
|
+
// is capped at CSS pixels). Point "url" at a sandbox or a demo account: everything on screen is filmed.
|
|
12
|
+
import { createRequire } from "module";
|
|
13
|
+
import { execFileSync } from "child_process";
|
|
14
|
+
import fs from "fs";
|
|
15
|
+
import os from "os";
|
|
16
|
+
import path from "path";
|
|
17
|
+
|
|
18
|
+
const DEVICES = {
|
|
19
|
+
phone: { width: 430, height: 932, deviceScaleFactor: 2.5, isMobile: true, hasTouch: true },
|
|
20
|
+
tablet: { width: 820, height: 1180, deviceScaleFactor: 2, isMobile: true, hasTouch: true },
|
|
21
|
+
desktop: { width: 1440, height: 900, deviceScaleFactor: 2, isMobile: false, hasTouch: false },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// puppeteer-core ships with the HyperFrames CLI in the npx cache; find it rather than add a dependency.
|
|
25
|
+
function puppeteer() {
|
|
26
|
+
const root = path.join(os.homedir(), ".npm", "_npx");
|
|
27
|
+
for (const d of fs.existsSync(root) ? fs.readdirSync(root) : []) {
|
|
28
|
+
const m = path.join(root, d, "node_modules", "puppeteer-core");
|
|
29
|
+
if (fs.existsSync(m)) return createRequire(path.join(root, d, "node_modules", "x.js"))("puppeteer-core");
|
|
30
|
+
}
|
|
31
|
+
throw new Error("puppeteer-core not found: run `npx -y hyperframes@0.8.176 --version` once, then retry");
|
|
32
|
+
}
|
|
33
|
+
const chromium = () => ["/usr/bin/chromium", "/usr/bin/chromium-browser", "/usr/bin/google-chrome", "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"].find((p) => fs.existsSync(p))
|
|
34
|
+
|| (() => { throw new Error("no Chromium found"); })();
|
|
35
|
+
|
|
36
|
+
const vdir = process.argv[2];
|
|
37
|
+
if (!vdir) { console.error("usage: node record.mjs videos/<name>"); process.exit(2); }
|
|
38
|
+
const spec = JSON.parse(fs.readFileSync(path.join(vdir, "record.json"), "utf8"));
|
|
39
|
+
const out = path.join(vdir, "rec");
|
|
40
|
+
fs.mkdirSync(out, { recursive: true });
|
|
41
|
+
const W = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
42
|
+
const b = await puppeteer().launch({ executablePath: chromium(), args: ["--no-sandbox"] });
|
|
43
|
+
|
|
44
|
+
for (const clip of spec.clips) {
|
|
45
|
+
const dev = DEVICES[clip.device];
|
|
46
|
+
if (!dev) throw new Error(`clip ${clip.name}: unknown device ${clip.device}`);
|
|
47
|
+
const p = await b.newPage();
|
|
48
|
+
await p.setViewport(dev);
|
|
49
|
+
await p.goto(new URL(clip.path || "/", spec.url).href, { waitUntil: "networkidle2" });
|
|
50
|
+
await W(800);
|
|
51
|
+
const taps = [];
|
|
52
|
+
let t0 = Date.now();
|
|
53
|
+
// A visible element by CSS or by its exact text ("text:Add").
|
|
54
|
+
const find = async (q) => {
|
|
55
|
+
const all = q.startsWith("text:") ? await p.$$(`xpath/.//*[self::button or self::a or self::label or @role='tab' or @role='button'][normalize-space()=${JSON.stringify(q.slice(5))}]`) : await p.$$(q);
|
|
56
|
+
for (const e of all) if (await e.evaluate((n) => n.getBoundingClientRect().width > 0)) return e;
|
|
57
|
+
throw new Error(`clip ${clip.name}: nothing visible matches ${q}`);
|
|
58
|
+
};
|
|
59
|
+
const steps = async (list, log) => {
|
|
60
|
+
for (const [op, a, b2, c] of list) {
|
|
61
|
+
if (op === "wait") await W(a);
|
|
62
|
+
else if (op === "tap") {
|
|
63
|
+
const el = await find(a);
|
|
64
|
+
const r = await el.evaluate((e) => { const x = e.getBoundingClientRect(); return { x: x.x + x.width / 2, y: x.y + x.height / 2 }; });
|
|
65
|
+
if (log) taps.push({ t: (Date.now() - t0) / 1000 + 0.35, x: r.x, y: r.y });
|
|
66
|
+
await W(log ? 350 : 0);
|
|
67
|
+
await el.evaluate((e) => e.click());
|
|
68
|
+
} else if (op === "type") { await (await find(a)).focus(); await p.keyboard.type(b2, { delay: log ? (c ?? 55) : 0 }); }
|
|
69
|
+
else if (op === "key") await p.keyboard.press(a);
|
|
70
|
+
else if (op === "scroll") await p.mouse.wheel({ deltaY: a });
|
|
71
|
+
else if (op === "goto") await p.goto(new URL(a, spec.url).href, { waitUntil: "networkidle2" });
|
|
72
|
+
else throw new Error(`clip ${clip.name}: unknown step ${op}`);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
if (clip.prep) { await steps(clip.prep, false); await W(800); }
|
|
76
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), `rec-${clip.name}-`));
|
|
77
|
+
const frames = [];
|
|
78
|
+
t0 = Date.now();
|
|
79
|
+
let on = true, n = 0;
|
|
80
|
+
const loop = (async () => {
|
|
81
|
+
while (on) {
|
|
82
|
+
const file = path.join(dir, `${String(n++).padStart(5, "0")}.jpg`);
|
|
83
|
+
const t = (Date.now() - t0) / 1000;
|
|
84
|
+
await p.screenshot({ path: file, type: "jpeg", quality: 90 });
|
|
85
|
+
frames.push({ file, t });
|
|
86
|
+
}
|
|
87
|
+
})();
|
|
88
|
+
await steps(clip.steps, true);
|
|
89
|
+
await W(300);
|
|
90
|
+
on = false;
|
|
91
|
+
await loop;
|
|
92
|
+
await p.close();
|
|
93
|
+
// Variable-rate frames to a 30 fps clip: each frame holds until the next was taken.
|
|
94
|
+
const list = frames.map((f, i) => `file '${f.file}'\nduration ${((frames[i + 1]?.t ?? f.t + 0.5) - f.t).toFixed(4)}`).join("\n") + `\nfile '${frames.at(-1).file}'\n`;
|
|
95
|
+
fs.writeFileSync(path.join(dir, "list.txt"), list);
|
|
96
|
+
const mp4 = path.join(out, `${clip.name}.mp4`);
|
|
97
|
+
execFileSync("ffmpeg", ["-v", "error", "-y", "-f", "concat", "-safe", "0", "-i", path.join(dir, "list.txt"),
|
|
98
|
+
"-vf", "fps=30,crop=trunc(iw/2)*2:trunc(ih/2)*2:0:0,format=yuv420p", "-c:v", "libx264", "-crf", "16", "-g", "15", mp4]);
|
|
99
|
+
fs.writeFileSync(path.join(out, `${clip.name}.json`), JSON.stringify({ device: clip.device, cssW: dev.width, cssH: dev.height, seconds: frames.at(-1).t, taps }, null, 1));
|
|
100
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
101
|
+
console.log(`recorded ${mp4}: ${frames.length} frames, ${(frames.length / frames.at(-1).t).toFixed(1)} fps, ${taps.length} taps`);
|
|
102
|
+
}
|
|
103
|
+
await b.close();
|
package/web/board/approvals.ts
CHANGED
|
@@ -25,8 +25,8 @@ export async function resume(c, b) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
export const APPROVAL = {
|
|
28
|
-
"approvals.plan": "
|
|
29
|
-
"approvals.review": "The work is ready to check. Approve
|
|
28
|
+
"approvals.plan": "Read the plan, then: Approve starts the build; Revise sends it back with what to change.",
|
|
29
|
+
"approvals.review": "The work is ready to check. Approve finishes it; Revise sends it back with what to change.",
|
|
30
30
|
findings: "The review has open findings. Approve as-is to accept them and finish, or fix selected findings first.",
|
|
31
31
|
},
|
|
32
32
|
decided = new Set(),
|
package/web/board/cards.ts
CHANGED
|
@@ -170,7 +170,7 @@ function card(c) {
|
|
|
170
170
|
: "";
|
|
171
171
|
el.innerHTML =
|
|
172
172
|
(pick ? html`<input type="checkbox" class="pick" ${raw(picked.has(k) ? "checked" : "")} aria-label="Select">` : "") +
|
|
173
|
-
html`<div class="c-id"><span class="st d-${st}" role="img" title="${sttl}" aria-label="${sttl}"><svg><use href="#s-${st}"/></svg></span><span class="idt">${idt}</span><span class="age">${c.kind === "run" ? age(c.moved || store.S.now, store.S.now) : ""}</span><button class="ib sm more" data-a="menu" title="Actions" aria-label="Actions" aria-haspopup="menu" aria-expanded="${String(k === store.menuKey)}">${ico("more")}</button></div>
|
|
173
|
+
html`<div class="c-id"><span class="st d-${st}" role="img" title="${sttl}" aria-label="${sttl}"><svg><use href="#s-${st}"/></svg></span><span class="idt"${c.kind === "run" && c.title ? html` title="${c.title}"` : ""}>${idt}</span><span class="age">${c.kind === "run" ? age(c.moved || store.S.now, store.S.now) : ""}</span><button class="ib sm more" data-a="menu" title="Actions" aria-label="Actions" aria-haspopup="menu" aria-expanded="${String(k === store.menuKey)}">${ico("more")}</button></div>
|
|
174
174
|
<div class="c-title"${c.kind === "idea" && brief(c.text).parts.length ? html` title="${c.text}"` : ""}>${c.kind === "idea" ? brief(c.text).head : c.title || c.id}</div>
|
|
175
175
|
${act}
|
|
176
176
|
${chips.length || marks.length ? html`<div class="c-foot"><span class="c-chips">${chips}</span><span class="c-marks">${marks}</span></div>` : ""}`;
|
|
@@ -466,7 +466,7 @@ async function startRun(c, kind) {
|
|
|
466
466
|
load();
|
|
467
467
|
}
|
|
468
468
|
|
|
469
|
-
const HINT = { 1: "Ideas you run are planned here", 2: "Approved plans are built here", 3: "Finished builds are checked here" };
|
|
469
|
+
const HINT = { 0: "Add an idea to start a run", 1: "Ideas you run are planned here", 2: "Approved plans are built here", 3: "Finished builds are checked here" };
|
|
470
470
|
|
|
471
471
|
// The new-idea form, wired into f: inline at the top of Ideas, or in a modal.
|
|
472
472
|
function ideaForm(f, close) {
|
|
@@ -703,7 +703,7 @@ export function render() {
|
|
|
703
703
|
]
|
|
704
704
|
.map(
|
|
705
705
|
([v, l, svg, k]) =>
|
|
706
|
-
`<button role="tab" aria-selected="${String(ideasTab === v)}" data-t="${v}" title="${l}" aria-label="${l}, ${k}">${svg}<i>${k}</i></button>`,
|
|
706
|
+
`<button role="tab" aria-selected="${String(ideasTab === v)}" data-t="${v}" title="${l}" aria-label="${l}, ${k}">${svg}${ideasTab === v ? `<b>${l.split(":")[0]}</b>` : ""}<i>${k}</i></button>`,
|
|
707
707
|
)
|
|
708
708
|
.join("")}</span>`
|
|
709
709
|
: `${name}<i>${list.length || ""}</i>`;
|
|
@@ -858,7 +858,7 @@ export function render() {
|
|
|
858
858
|
ul.appendChild(li);
|
|
859
859
|
}
|
|
860
860
|
// An empty middle column says what lands in it, so it does not look broken.
|
|
861
|
-
if (!list.length && ci
|
|
861
|
+
if (!list.length && ci <= 3 && !bl && cs.length && !filter && !q && !archive)
|
|
862
862
|
ul.innerHTML = `<li class="hint">${HINT[ci]}</li>`;
|
|
863
863
|
if (bl && !list.length && !filter && !q)
|
|
864
864
|
ul.innerHTML = `<li class="hint">${sev ? "Nothing at this severity" : "What finished runs left undone shows here"}</li>`;
|
package/web/board/icebox.ts
CHANGED
|
@@ -324,7 +324,7 @@ export async function openSources() {
|
|
|
324
324
|
)}`,
|
|
325
325
|
)
|
|
326
326
|
: ""}`;
|
|
327
|
-
const bar = html`<div class="ice-bar">${order.length ? html`<input type="checkbox" id="ice-all" aria-label="Select every request shown"${nSel && nSel === order.length ? " checked" : ""}>` : ""}<span class="count">${iceCat === "Dismissed" || iceCat === "Done" ? `${order.length} ${iceCat.toLowerCase()}` : `${order.length < waiting ? `${order.length} of ${waiting}` : waiting} waiting`}</span><span class="end"></span>${String(chips) ? html`<details class="ice-filt"><summary class="ib${iceCat || iceSrc ? " on" : ""}" aria-label="Filter requests" title="Filter requests">${ico("filter")}</summary><div class="ice-fpop">${chips}</div></details>` : ""}<button class="btn ghost sm" id="ice-new" title="Add a request by hand">${ico("plus")} Add</button><button class="btn sm" id="src-go"${list.length ? "" : " disabled"}>${ico("refresh")} Gather all</button><button class="btn ghost sm" id="src-tog" aria-expanded="${String(srcShow
|
|
327
|
+
const bar = html`<div class="ice-bar">${order.length ? html`<input type="checkbox" id="ice-all" aria-label="Select every request shown"${nSel && nSel === order.length ? " checked" : ""}>` : ""}<span class="count">${iceCat === "Dismissed" || iceCat === "Done" ? `${order.length} ${iceCat.toLowerCase()}` : `${order.length < waiting ? `${order.length} of ${waiting}` : waiting} waiting`}</span><span class="end"></span>${String(chips) ? html`<details class="ice-filt"><summary class="ib${iceCat || iceSrc ? " on" : ""}" aria-label="Filter requests" title="Filter requests">${ico("filter")}</summary><div class="ice-fpop">${chips}</div></details>` : ""}<button class="btn ghost sm" id="ice-new" title="Add a request by hand">${ico("plus")} Add</button><button class="btn sm" id="src-go"${list.length ? "" : " disabled"}>${ico("refresh")} Gather all</button><button class="btn ghost sm" id="src-tog" aria-expanded="${String(!!srcShow)}" aria-controls="src-sec">${ico("link")} Sources · ${list.length}</button></div>`;
|
|
328
328
|
const bulk = iceSel.size
|
|
329
329
|
? html`<div class="ice-bulk" role="toolbar" aria-label="Selected requests"><span>${iceSel.size} selected</span><span class="end"></span><button class="btn sm" id="ice-bp" title="Promote (p)">${ico("plus")} Promote</button><button class="btn ghost sm" id="ice-bd" title="Dismiss (d)">${ico("x")} Dismiss</button><button class="btn ghost sm" id="ice-bc" title="Clear selection (Esc)">Clear</button></div>`
|
|
330
330
|
: "";
|
|
@@ -362,10 +362,10 @@ export async function openSources() {
|
|
|
362
362
|
? html`<div class="ice-zero"><h4>No matches</h4><p style="margin-top:10px"><button class="btn sm" id="ice-unf">Clear filters</button></p></div>`
|
|
363
363
|
: order.length
|
|
364
364
|
? html`<div class="ice-list">${[...groups].map(([g, ix]) => html`<div class="ice-cat">${g}<i>${ix.length}</i></div>${ix.map(row)}`)}</div>`
|
|
365
|
-
: html`<div class="ice-zero"><h4>Nothing waiting</h4></div>`;
|
|
366
|
-
// The sources, in the right-hand drawer: shut until asked for
|
|
367
|
-
//
|
|
368
|
-
const drawer = srcShow
|
|
365
|
+
: html`<div class="ice-zero"><h4>Nothing waiting</h4><p>Requests gathered from your sources wait here until you turn them into ideas.</p>${list.length ? "" : html`<p style="margin-top:10px"><button class="btn sm pri" id="ice-addsrc">${ico("plus")} Add a source</button></p>`}</div>`;
|
|
366
|
+
// The sources, in the right-hand drawer: shut until asked for. Slid in only when opened;
|
|
367
|
+
// a rebuild while open shows it in place.
|
|
368
|
+
const drawer = !!srcShow,
|
|
369
369
|
slide = drawer && !$("src-sec")?.classList.contains("open");
|
|
370
370
|
const sec = html`<div class="src-scrim${drawer && !slide ? " on" : ""}" id="src-scrim"></div><aside class="src-sec${drawer && !slide ? " open" : ""}" id="src-sec" aria-label="Sources"${drawer ? "" : " inert"}><header><div class="t"><b>Sources</b><div class="src-chips"><a id="src-to-settings" class="schip" role="button" tabindex="0" title="${d && d.every && d.every !== "off" ? `Checked every ${d.every}` : "Auto-check off"}: change in Settings">${ico("clock")}${d && d.every && d.every !== "off" ? (d.every) : "Off"}</a>${G.connected ? html`<span class="schip on" title="ChatGPT${G.email ? ": " + (G.email) : ""}">${ico("ai")}ChatGPT<a id="cg-out" role="button" tabindex="0" aria-label="Disconnect ChatGPT" title="Disconnect">${ico("x")}</a></span>` : html`<a id="cg-in" class="schip" role="button" tabindex="0" title="Connect ChatGPT">${ico("ai")}ChatGPT</a>`}${(d.google || {}).connected ? html`<span class="schip on" title="Google connected">${ico("google")}Google<a id="gg-out" role="button" tabindex="0" aria-label="Disconnect Google" title="Disconnect">${ico("x")}</a></span>` : html`<a id="gg-in" class="schip" role="button" tabindex="0" title="Connect Google">${ico("google")}Google</a>`}</div></div><div class="src-hda">${list.length ? html`<button class="btn sm" id="src-new" aria-expanded="${String(addOn)}" aria-controls="src-addbox">${ico("plus")} Add</button>` : ""}<button class="ib" id="src-x" aria-label="Close sources" title="Close">${ico("close")}</button></div></header><div class="body">${addBox}${list.length ? html`<div class="src-list">${cards}</div>` : emptyState}</div></aside>`;
|
|
371
371
|
// First visit: offer the ChatGPT plan for social sources, or keep the agent.
|
|
@@ -486,6 +486,7 @@ export async function openSources() {
|
|
|
486
486
|
srcShow = true;
|
|
487
487
|
openSources().then(() => srcShow && $("src-url")?.focus());
|
|
488
488
|
};
|
|
489
|
+
if ($("ice-addsrc")) $("ice-addsrc").onclick = $("src-tog").onclick;
|
|
489
490
|
wirePick("ice-fs", (v) => {
|
|
490
491
|
iceSrc = v;
|
|
491
492
|
openSources();
|