@officexapp/vidfarm-devcli 0.21.26 → 0.21.28
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/skills/editor-capabilities/SKILL.md +26 -0
- package/.agents/skills/vidfarm/SKILL.md +31 -9
- package/.agents/skills/vidfarm/recipes/local-edit-render-approve.md +3 -2
- package/.agents/skills/vidfarm/references/assets-and-sourcing.md +29 -3
- package/.agents/skills/vidfarm/references/automation-and-local-dev.md +59 -6
- package/.agents/skills/vidfarm/references/core-workflows.md +1 -1
- package/.agents/skills/vidfarm/references/editor-workflows.md +85 -7
- package/.agents/skills/vidfarm/references/onboarding.md +4 -4
- package/.agents/skills/vidfarm/references/primitives.md +33 -1
- package/.agents/skills/vidfarm-media/SKILL.md +3 -1
- package/.agents/skills/vidfarm-media/references/tts.md +1 -1
- package/SKILL.director.md +245 -33
- package/SKILL.md +11 -4
- package/clipper.md +3 -2
- package/dist/src/cli.js +478 -19
- package/dist/src/devcli/cost-mode.js +46 -18
- package/dist/src/devcli/qa-check.js +420 -0
- package/dist/src/devcli/sequence.js +619 -0
- package/dist/src/services/sequence-prompts.js +463 -0
- package/package.json +5 -1
- package/public/assets/file-directory-app.js +26 -26
- package/public/assets/homepage-client-app.js +12 -12
- package/public/serve-shells/editor.html +66 -3
- package/public/serve-shells/library-files.html +60 -3
- package/public/serve-shells/library-raws.html +60 -3
- package/public/serve-shells/tools-clipper.html +60 -3
- package/public/serve-shells/tools-image.html +1316 -617
- package/public/serve-shells/tools-video.html +880 -161
|
@@ -11,9 +11,17 @@
|
|
|
11
11
|
// - hybrid : roughly $0.01–$1 per video. Free where it's free, spend on AI
|
|
12
12
|
// only where it clearly wins. (default recommendation.) Billed
|
|
13
13
|
// ops run but print a cost line.
|
|
14
|
-
// -
|
|
15
|
-
//
|
|
16
|
-
//
|
|
14
|
+
// - rich-ai : $1+ per video. AI video generation is used to mint REUSABLE
|
|
15
|
+
// greenscreen raws, which are then keyed and remixed with
|
|
16
|
+
// hyperframes/HTML-CSS motion and the rest of the raw library.
|
|
17
|
+
// The raws persist (local `~/.vidfarm` raws store, optionally
|
|
18
|
+
// `vidfarm sync push /raws` to the cloud on a Pro plan), so the
|
|
19
|
+
// spend amortizes into later hybrid/minimize videos. Billed ops
|
|
20
|
+
// run; cost is still surfaced. Shown to humans as "rich-ai".
|
|
21
|
+
// - pure-videogen : $5+ per video. The whole piece is generated footage —
|
|
22
|
+
// text script → image storyboard → per-scene, frame-by-frame
|
|
23
|
+
// video generation. No raws reuse, no HTML motion. The most
|
|
24
|
+
// expensive mode; reserve it for hero pieces.
|
|
17
25
|
//
|
|
18
26
|
// Those dollar figures are what the AI providers charge, and they are billed to
|
|
19
27
|
// the user's OWN provider keys (BYOK — the keys saved via `vidfarm
|
|
@@ -25,7 +33,7 @@
|
|
|
25
33
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
26
34
|
import path from "node:path";
|
|
27
35
|
import { resolveDevcliHome } from "./auth-store.js";
|
|
28
|
-
export const COST_MODES = ["minimize", "hybrid", "
|
|
36
|
+
export const COST_MODES = ["minimize", "hybrid", "rich-ai", "pure-videogen"];
|
|
29
37
|
/** What we assume when nothing is set. Hybrid is the founder-friendly middle,
|
|
30
38
|
* but callers can tell it apart from an explicit choice via `isSet`. */
|
|
31
39
|
export const DEFAULT_COST_MODE = "hybrid";
|
|
@@ -41,21 +49,29 @@ export function normalizeCostMode(raw) {
|
|
|
41
49
|
return "minimize";
|
|
42
50
|
if (["hybrid", "mixed", "balanced", "smart", "default"].includes(v))
|
|
43
51
|
return "hybrid";
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
// Check videogen BEFORE rich-ai: "pure-videogen" must not be swallowed by a
|
|
53
|
+
// looser "pure*" spelling, and "videogen" always means the frame-by-frame mode.
|
|
54
|
+
if (["pure-videogen", "purevideogen", "pure-video-gen", "videogen", "video-gen", "pure-video", "purevideo", "veo", "frame-by-frame", "cinematic"].includes(v))
|
|
55
|
+
return "pure-videogen";
|
|
56
|
+
// "pure-ai"/"pureai" are the LEGACY slug this mode used to be stored under —
|
|
57
|
+
// keep accepting them so an older ~/.vidfarm/cost-mode.json still resolves.
|
|
58
|
+
if (["rich-ai", "richai", "rich", "pure-ai", "pureai", "ai", "best", "best-quality", "premium", "max"].includes(v))
|
|
59
|
+
return "rich-ai";
|
|
46
60
|
return null;
|
|
47
61
|
}
|
|
48
62
|
/**
|
|
49
|
-
* Human-facing NAME for a mode.
|
|
50
|
-
*
|
|
51
|
-
*
|
|
63
|
+
* Human-facing NAME for a mode. These match the canonical slugs one-for-one —
|
|
64
|
+
* there is no "pure-ai" mode any more, it is `rich-ai` everywhere (the old slug
|
|
65
|
+
* is still ACCEPTED as an alias by normalizeCostMode so saved cost-mode.json,
|
|
66
|
+
* --cost-mode flags, and VIDFARM_COST_MODE from older installs keep resolving).
|
|
52
67
|
*/
|
|
53
68
|
export const COST_MODE_DISPLAY = {
|
|
54
69
|
minimize: "minimize",
|
|
55
70
|
hybrid: "hybrid",
|
|
56
|
-
"
|
|
71
|
+
"rich-ai": "rich-ai",
|
|
72
|
+
"pure-videogen": "pure-videogen"
|
|
57
73
|
};
|
|
58
|
-
/** The
|
|
74
|
+
/** The modes as users see them, e.g. "<minimize|hybrid|rich-ai|pure-videogen>". */
|
|
59
75
|
export const COST_MODE_DISPLAY_LIST = COST_MODES.map((m) => COST_MODE_DISPLAY[m]);
|
|
60
76
|
export function costModeDisplayName(mode) {
|
|
61
77
|
return COST_MODE_DISPLAY[mode];
|
|
@@ -120,22 +136,34 @@ export const COST_MODE_BLURB = {
|
|
|
120
136
|
"credits only where they clearly win (a hero shot, a voice you can't fake locally). " +
|
|
121
137
|
"Billed ops run but each prints its cost so nothing is a surprise. Charges land on " +
|
|
122
138
|
"your own AI provider keys (BYOK).",
|
|
123
|
-
"
|
|
139
|
+
"rich-ai": "Rich AI — $1+ per video. AI video generation is spent on REUSABLE greenscreen raws " +
|
|
140
|
+
"(vidfarm avatar / generate --greenscreen), keyed once and then remixed with hyperframes " +
|
|
141
|
+
"HTML/CSS motion and the rest of the raw library. Those raws are saved in the local raws " +
|
|
142
|
+
"store (and pushed to the cloud with `vidfarm sync push /raws` on a Pro plan), so the same " +
|
|
143
|
+
"footage powers later hybrid/minimize videos for $0. AI image/voice/music used freely. " +
|
|
124
144
|
"Billed ops run without gating; cost is still shown. Charges land on your own AI " +
|
|
125
|
-
"provider keys (BYOK)."
|
|
145
|
+
"provider keys (BYOK).",
|
|
146
|
+
"pure-videogen": "Pure videogen — $5+ per video. Every shot is generated footage: write the script in text, " +
|
|
147
|
+
"storyboard it as images, then generate each scene frame-by-frame from those keyframes. " +
|
|
148
|
+
"No raw reuse, no HTML motion — the most expensive and most cinematic mode. Billed ops run " +
|
|
149
|
+
"without gating; cost is still shown, and a single run can be many dollars. Charges land on " +
|
|
150
|
+
"your own AI provider keys (BYOK)."
|
|
126
151
|
};
|
|
127
152
|
/** One short human line summarizing the active mode. */
|
|
128
153
|
export function costModeSummaryLine(resolved) {
|
|
129
154
|
const setNote = resolved.isSet ? `set via ${resolved.source}` : "NOT set — assuming hybrid";
|
|
130
155
|
return `cost mode: ${costModeDisplayName(resolved.mode)} (${setNote})`;
|
|
131
156
|
}
|
|
132
|
-
/** The
|
|
157
|
+
/** The "explain it simply" block an agent should relay to the user. */
|
|
133
158
|
export function costModeExplainer() {
|
|
134
159
|
return [
|
|
135
160
|
"How much do you want Vidfarm to spend on AI per video?",
|
|
136
|
-
" • minimize
|
|
137
|
-
" • hybrid
|
|
138
|
-
" • rich-ai
|
|
161
|
+
" • minimize — $0 videos: free local compute + free stock media, no AI spend at all.",
|
|
162
|
+
" • hybrid — ~$0.01–$1 per video (recommended): free where free, pay AI only where it clearly wins.",
|
|
163
|
+
" • rich-ai — $1+ per video: AI video gen mints REUSABLE greenscreen raws, then hyperframes",
|
|
164
|
+
" HTML/CSS motion remixes them with your library; the raws are saved and reused later.",
|
|
165
|
+
" • pure-videogen — $5+ per video: everything is generated footage — text script → image storyboard →",
|
|
166
|
+
" frame-by-frame scene generation. Most cinematic, most expensive.",
|
|
139
167
|
"Any spend is billed to YOUR own AI provider keys (BYOK) — add them with",
|
|
140
168
|
" `vidfarm add-provider-key <provider> <key>` or at vidfarm.cc/settings/developer.",
|
|
141
169
|
"Tip: before paying to generate music/SFX/images/video, try the free stock catalog —",
|
|
@@ -159,7 +187,7 @@ export class CostModeBlockedError extends Error {
|
|
|
159
187
|
*
|
|
160
188
|
* - minimize: throws unless `yes` is set — the agent must confirm with the user
|
|
161
189
|
* (or use the free local alternative named in `freeAlternative`).
|
|
162
|
-
* - hybrid /
|
|
190
|
+
* - hybrid / rich-ai: allowed; prints a one-line cost notice (unless json).
|
|
163
191
|
* - unset: allowed like hybrid, but prints a "no preference set — ask the user"
|
|
164
192
|
* nudge once so the default posture really is "ask before spending."
|
|
165
193
|
*/
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
// Social-native QA check for the devcli — read a composition.html on disk and
|
|
2
|
+
// flag "HTML slop": landing-page furniture that shows up everywhere on the web
|
|
3
|
+
// and NEVER in a real TikTok/Reel/Short. Compositions are authored in HTML, so
|
|
4
|
+
// an agent that reaches for its web-page instincts produces gradient CTA
|
|
5
|
+
// capsules, benefit chip rows, and frosted cards floating over footage — the
|
|
6
|
+
// single loudest tell that a video was machine-made.
|
|
7
|
+
//
|
|
8
|
+
// DESIGN CONTRACT (read before adding a rule):
|
|
9
|
+
// * BLOCKLIST, never allowlist. We name specific, well-known web-furniture
|
|
10
|
+
// patterns. Anything we haven't named is legal. A composition that does
|
|
11
|
+
// something weird, ugly, hand-made, or wildly stylized must PASS — the
|
|
12
|
+
// check exists to stop slop, not to homogenize style. If a rule would fire
|
|
13
|
+
// on a legitimately creative choice, the rule is wrong; loosen it.
|
|
14
|
+
// * FEEDBACK, never a gate. `vidfarm qa` exits 0 even with errors unless the
|
|
15
|
+
// caller opts into `--strict`. Nothing in the render path depends on it.
|
|
16
|
+
// * PRECISION over recall. Every `error` needs TWO independent signals (e.g.
|
|
17
|
+
// action copy AND a button shape). Single weak signals are `warn` at most.
|
|
18
|
+
// A false positive teaches agents to ignore the tool; a false negative just
|
|
19
|
+
// means we missed one.
|
|
20
|
+
//
|
|
21
|
+
// Pure DOM (linkedom) — no ffmpeg, no network, no Chrome. Local-only: this is a
|
|
22
|
+
// devcli capability with no cloud/REST equivalent.
|
|
23
|
+
import { parseHTML } from "linkedom";
|
|
24
|
+
// ── The font regime ───────────────────────────────────────────────────────────
|
|
25
|
+
// Mirrors CAPTION_FONT_REGIME in composition-edit.ts / COMPOSITION_FONT_IMPORT
|
|
26
|
+
// in services/studio-project-adapter.ts. A family outside this set is not even
|
|
27
|
+
// imported by the composition, so it silently falls back to a web-default sans
|
|
28
|
+
// at render — which IS the slop look.
|
|
29
|
+
const FONT_REGIME = ["tiktok sans", "montserrat", "abel", "source code pro", "yesteryear"];
|
|
30
|
+
// Named separately so we can say "this is a website font" instead of the vaguer
|
|
31
|
+
// "not imported" — the more actionable message when an agent typed it on purpose.
|
|
32
|
+
const WEB_DEFAULT_FONTS = [
|
|
33
|
+
"inter", "roboto", "system-ui", "-apple-system", "arial", "helvetica", "helvetica neue",
|
|
34
|
+
"segoe ui", "times", "times new roman", "georgia", "verdana", "tahoma", "open sans", "lato", "nunito"
|
|
35
|
+
];
|
|
36
|
+
// Bootstrap / Tailwind / generic web-component class names. Matched as whole
|
|
37
|
+
// tokens against class attributes, so `btn-primary` hits and `subtle` doesn't.
|
|
38
|
+
const SLOP_CLASS_TOKENS = [
|
|
39
|
+
"btn", "button", "cta", "badge", "chip", "pill", "tag", "card", "panel", "navbar", "nav",
|
|
40
|
+
"hero", "jumbotron", "alert", "breadcrumb", "form-control", "input-group", "container",
|
|
41
|
+
"container-fluid", "row", "list-group", "well", "thumbnail", "media-object"
|
|
42
|
+
];
|
|
43
|
+
const SLOP_CLASS_PREFIXES = [
|
|
44
|
+
"col-", "rounded-full", "shadow-lg", "shadow-xl", "shadow-2xl", "backdrop-blur",
|
|
45
|
+
"bg-gradient-to-", "ring-", "btn-", "card-", "badge-", "nav-", "navbar-"
|
|
46
|
+
];
|
|
47
|
+
// Copy whose only job is to be clicked. Bare CTA words in a caption are FINE
|
|
48
|
+
// ("buy now" is a legitimate social line) — this list only escalates a finding
|
|
49
|
+
// when the text also sits inside a button shape.
|
|
50
|
+
const ACTION_COPY = /\b(sign\s?up|get\s?started|learn\s?more|book\s+a\s+(call|demo)|start\s+(your\s+)?free\s+trial|free\s+trial|try\s+(it\s+)?free|click\s+here|subscribe\s+now|shop\s+now|order\s+now|contact\s+us|join\s+now|download\s+now|register\s+now|read\s+more|see\s+plans|view\s+pricing)\b/i;
|
|
51
|
+
// The stock trust-badge phrases that show up in benefit chip rows.
|
|
52
|
+
const BENEFIT_COPY = /(no\s+credit\s+card|money[-\s]?back|cancel\s+any\s?time|24\/7|free\s+shipping|verified|guarantee|no\s+commitment|risk[-\s]?free)/i;
|
|
53
|
+
function textOf(node) {
|
|
54
|
+
return String(node?.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
55
|
+
}
|
|
56
|
+
function classTokens(node) {
|
|
57
|
+
return String(node?.getAttribute?.("class") ?? "").split(/\s+/).filter(Boolean);
|
|
58
|
+
}
|
|
59
|
+
function styleString(node) {
|
|
60
|
+
return String(node?.getAttribute?.("style") ?? "").toLowerCase();
|
|
61
|
+
}
|
|
62
|
+
/** Parse a CSS length in px from an inline style declaration. */
|
|
63
|
+
function pxOf(style, prop) {
|
|
64
|
+
const match = style.match(new RegExp(`(?:^|;)\\s*${prop}\\s*:\\s*(-?[\\d.]+)px`));
|
|
65
|
+
return match ? Number(match[1]) : null;
|
|
66
|
+
}
|
|
67
|
+
function hasDecl(style, prop) {
|
|
68
|
+
return new RegExp(`(?:^|;)\\s*${prop}\\s*:`).test(style);
|
|
69
|
+
}
|
|
70
|
+
/** border-radius in px, treating any %/9999-style value as "fully rounded". */
|
|
71
|
+
function radiusPx(style) {
|
|
72
|
+
const match = style.match(/(?:^|;)\s*border-radius\s*:\s*([^;]+)/);
|
|
73
|
+
if (!match)
|
|
74
|
+
return 0;
|
|
75
|
+
const raw = match[1].trim();
|
|
76
|
+
if (/%/.test(raw))
|
|
77
|
+
return 9999;
|
|
78
|
+
const num = Number((raw.match(/(-?[\d.]+)px/) ?? [])[1] ?? 0);
|
|
79
|
+
return Number.isFinite(num) ? num : 0;
|
|
80
|
+
}
|
|
81
|
+
function primaryFamily(raw) {
|
|
82
|
+
return String(raw).split(",")[0].replace(/['"]/g, "").trim().toLowerCase();
|
|
83
|
+
}
|
|
84
|
+
function label(node, fallback) {
|
|
85
|
+
const value = node?.getAttribute?.("data-label") ||
|
|
86
|
+
node?.getAttribute?.("data-slug") ||
|
|
87
|
+
node?.getAttribute?.("data-hf-id") ||
|
|
88
|
+
node?.getAttribute?.("id") ||
|
|
89
|
+
"";
|
|
90
|
+
const text = textOf(node).slice(0, 40);
|
|
91
|
+
const name = String(value).trim() || fallback;
|
|
92
|
+
return text ? `${name} — "${text}"` : name;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* QA a composition's HTML. Pure: returns findings, mutates nothing. Safe on
|
|
96
|
+
* malformed input (returns a clean report rather than throwing) — a QA pass
|
|
97
|
+
* must never be the thing that breaks a render.
|
|
98
|
+
*/
|
|
99
|
+
export function qaCompositionHtml(html) {
|
|
100
|
+
const findings = [];
|
|
101
|
+
let root = null;
|
|
102
|
+
let document = null;
|
|
103
|
+
try {
|
|
104
|
+
({ document } = parseHTML(html));
|
|
105
|
+
root = document.querySelector("[data-composition-id]") ?? document.body;
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return {
|
|
109
|
+
ok: true,
|
|
110
|
+
verdict: "clean",
|
|
111
|
+
errors: [],
|
|
112
|
+
warnings: [],
|
|
113
|
+
checked: { layers: 0, text_layers: 0, canvas: null }
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (!root) {
|
|
117
|
+
return { ok: true, verdict: "clean", errors: [], warnings: [], checked: { layers: 0, text_layers: 0, canvas: null } };
|
|
118
|
+
}
|
|
119
|
+
const push = (f) => findings.push(f);
|
|
120
|
+
const all = Array.from(root.querySelectorAll("*"));
|
|
121
|
+
const layers = Array.from(root.querySelectorAll("[data-start]"));
|
|
122
|
+
// Only layers that actually SHOW WORDS get judged on typography and placement.
|
|
123
|
+
// A `data-layer-kind="text"` div is also how compositions carry scrims,
|
|
124
|
+
// gradient washes, and colour blocks — those legitimately span the full frame
|
|
125
|
+
// and have no font at all, so judging them would be pure noise.
|
|
126
|
+
const textLayers = Array.from(root.querySelectorAll('[data-layer-kind="caption"], [data-layer-kind="text"]')).filter((node) => textOf(node).length > 0);
|
|
127
|
+
const canvasW = Number(root.getAttribute?.("data-width") ?? 0) || null;
|
|
128
|
+
const canvasH = Number(root.getAttribute?.("data-height") ?? 0) || null;
|
|
129
|
+
// ── Rule: clickable elements ────────────────────────────────────────────────
|
|
130
|
+
// Nothing in a video is clickable. A <button>, a link, or a form control in a
|
|
131
|
+
// composition is web instinct leaking through, full stop.
|
|
132
|
+
for (const node of all) {
|
|
133
|
+
const tag = String(node.tagName ?? "").toLowerCase();
|
|
134
|
+
if (tag === "button" || tag === "form" || tag === "input" || tag === "select" || tag === "textarea") {
|
|
135
|
+
push({
|
|
136
|
+
rule: "clickable-element",
|
|
137
|
+
severity: "error",
|
|
138
|
+
message: `<${tag}> in a composition — nothing in a video is clickable.`,
|
|
139
|
+
where: label(node, `<${tag}>`),
|
|
140
|
+
fix: "Delete the control. If it carried a call to action, say it as a timed caption line on the footage (or in the voiceover)."
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
else if (tag === "a" && node.getAttribute?.("href")) {
|
|
144
|
+
push({
|
|
145
|
+
rule: "clickable-element",
|
|
146
|
+
severity: "warn",
|
|
147
|
+
message: "<a href> in a composition — links do nothing in a rendered MP4.",
|
|
148
|
+
where: label(node, "<a>"),
|
|
149
|
+
fix: "Keep the text if it's a real caption (a spoken URL reads fine); drop the anchor and any button styling around it."
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// ── Rule: web-framework class names ────────────────────────────────────────
|
|
154
|
+
// Bootstrap/Tailwind furniture names. Two or more distinct hits is a strong
|
|
155
|
+
// signal someone built a landing page section; one is worth a nudge.
|
|
156
|
+
const frameworkHits = [];
|
|
157
|
+
for (const node of all) {
|
|
158
|
+
for (const token of classTokens(node)) {
|
|
159
|
+
const lower = token.toLowerCase();
|
|
160
|
+
if (SLOP_CLASS_TOKENS.includes(lower) || SLOP_CLASS_PREFIXES.some((p) => lower.startsWith(p))) {
|
|
161
|
+
frameworkHits.push({ node, token });
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (frameworkHits.length) {
|
|
167
|
+
const tokens = [...new Set(frameworkHits.map((h) => h.token))].slice(0, 6).join(", ");
|
|
168
|
+
push({
|
|
169
|
+
rule: "web-framework-classes",
|
|
170
|
+
severity: frameworkHits.length >= 2 ? "error" : "warn",
|
|
171
|
+
message: `${frameworkHits.length} element(s) using web-page class names (${tokens}) — this is a landing page, not a video.`,
|
|
172
|
+
where: label(frameworkHits[0].node, "element"),
|
|
173
|
+
fix: "Rebuild as timed text on the footage. Text belongs ON the frame, not inside a container with padding and a shadow."
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
// Only CSS-FRAMEWORK stylesheets — a jsdelivr <script> for GSAP/anime.js is a
|
|
177
|
+
// normal, encouraged part of a local composition and must never trip this.
|
|
178
|
+
if (/bootstrap[^"']*\.css|cdn\.tailwindcss\.com|tailwind[^"']*\.css|fontawesome[^"']*\.css|bulma[^"']*\.css|foundation[^"']*\.css/i.test(html)) {
|
|
179
|
+
push({
|
|
180
|
+
rule: "web-framework-classes",
|
|
181
|
+
severity: "error",
|
|
182
|
+
message: "A CSS framework stylesheet (Bootstrap/Tailwind/FontAwesome/Bulma) is linked into the composition.",
|
|
183
|
+
where: "<head>",
|
|
184
|
+
fix: "Remove it. Its defaults ARE the look to avoid, and renders should be offline-deterministic. (A <script> CDN for GSAP/anime.js is fine — this is about CSS frameworks.)"
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
// ── Rule: CTA button ───────────────────────────────────────────────────────
|
|
188
|
+
// Two signals required: action copy AND a button shape (pill/rounded fill).
|
|
189
|
+
// "BUY NOW" as a bare caption is legitimate social copy and must not fire.
|
|
190
|
+
for (const node of all) {
|
|
191
|
+
const text = textOf(node);
|
|
192
|
+
if (!text || text.length > 60 || !ACTION_COPY.test(text))
|
|
193
|
+
continue;
|
|
194
|
+
const style = styleString(node);
|
|
195
|
+
const radius = radiusPx(style);
|
|
196
|
+
const filled = /background(?:-color|-image)?\s*:/.test(style) && !/background[^;]*:\s*(none|transparent)/.test(style);
|
|
197
|
+
const gradient = /linear-gradient|radial-gradient/.test(style);
|
|
198
|
+
const shadowed = hasDecl(style, "box-shadow");
|
|
199
|
+
const buttonShape = (radius >= 16 && filled) || (gradient && radius >= 8) || (filled && shadowed && radius >= 8);
|
|
200
|
+
if (buttonShape) {
|
|
201
|
+
push({
|
|
202
|
+
rule: "cta-button",
|
|
203
|
+
severity: "error",
|
|
204
|
+
message: `CTA button ("${text.slice(0, 40)}") — a filled, rounded capsule with action copy. Pure landing page.`,
|
|
205
|
+
where: label(node, "cta"),
|
|
206
|
+
fix: "Kill the capsule. Deliver the CTA as a plain caption line in the font regime, spoken in the voiceover, or as an arrow pointing at real on-screen UI."
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// ── Rule: benefit chip / badge row ─────────────────────────────────────────
|
|
211
|
+
// "✓ No Credit Card Needed · ✓ 30-Min Trial" — a row of small rounded tags.
|
|
212
|
+
// Requires 2+ siblings that are each small, filled, and rounded.
|
|
213
|
+
const parents = new Map();
|
|
214
|
+
for (const node of all) {
|
|
215
|
+
const style = styleString(node);
|
|
216
|
+
const text = textOf(node);
|
|
217
|
+
if (!text || text.length > 45)
|
|
218
|
+
continue;
|
|
219
|
+
const filled = /background(?:-color|-image)?\s*:/.test(style) && !/background[^;]*:\s*(none|transparent)/.test(style);
|
|
220
|
+
const chipShape = radiusPx(style) >= 10 && filled;
|
|
221
|
+
const chipCopy = /^[✓✔✅•·]/.test(text) || BENEFIT_COPY.test(text);
|
|
222
|
+
if (!(chipShape && (chipCopy || text.split(" ").length <= 5)))
|
|
223
|
+
continue;
|
|
224
|
+
const parent = node.parentNode;
|
|
225
|
+
if (!parent)
|
|
226
|
+
continue;
|
|
227
|
+
const bucket = parents.get(parent) ?? [];
|
|
228
|
+
bucket.push(node);
|
|
229
|
+
parents.set(parent, bucket);
|
|
230
|
+
}
|
|
231
|
+
for (const [, bucket] of parents) {
|
|
232
|
+
if (bucket.length < 2)
|
|
233
|
+
continue;
|
|
234
|
+
push({
|
|
235
|
+
rule: "badge-chip-row",
|
|
236
|
+
severity: "error",
|
|
237
|
+
message: `A row of ${bucket.length} badge/chip pills (${bucket.slice(0, 3).map((n) => `"${textOf(n).slice(0, 22)}"`).join(", ")}) — trust badges are website furniture.`,
|
|
238
|
+
where: label(bucket[0], "chip"),
|
|
239
|
+
fix: "Say each benefit as its OWN timed caption line on the footage, one at a time, in the font regime. One idea per beat reads far better than a chip strip."
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
// ── Rule: card / panel / glassmorphism ─────────────────────────────────────
|
|
243
|
+
// A rounded box with a border, shadow, or frosted blur, holding more than one
|
|
244
|
+
// piece of content. A tight caption BAND is legal (small radius, one run) —
|
|
245
|
+
// this fires only once the band has become a container.
|
|
246
|
+
for (const node of all) {
|
|
247
|
+
const style = styleString(node);
|
|
248
|
+
if (!style)
|
|
249
|
+
continue;
|
|
250
|
+
const radius = radiusPx(style);
|
|
251
|
+
const frosted = /backdrop-filter\s*:\s*[^;]*blur/.test(style);
|
|
252
|
+
const bordered = /(?:^|;)\s*border\s*:\s*(?!0|none)/.test(style) || hasDecl(style, "border-width");
|
|
253
|
+
const shadowed = hasDecl(style, "box-shadow") && !/box-shadow\s*:\s*none/.test(style);
|
|
254
|
+
const childBoxes = Array.from(node.children ?? []).filter((c) => textOf(c)).length;
|
|
255
|
+
const filled = /background(?:-color|-image)?\s*:/.test(style) && !/background[^;]*:\s*(none|transparent)/.test(style);
|
|
256
|
+
if (frosted) {
|
|
257
|
+
push({
|
|
258
|
+
rule: "glass-card",
|
|
259
|
+
severity: "error",
|
|
260
|
+
message: "Glassmorphism (backdrop-filter blur) — a frosted web panel floating over the footage.",
|
|
261
|
+
where: label(node, "panel"),
|
|
262
|
+
fix: "Drop the panel. If the text needs legibility over busy footage, use a heavy outline (background_style outline) or a tight solid band that hugs the words."
|
|
263
|
+
});
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (radius >= 12 && (bordered || shadowed) && filled && childBoxes >= 2) {
|
|
267
|
+
push({
|
|
268
|
+
rule: "card-panel",
|
|
269
|
+
severity: "error",
|
|
270
|
+
message: `Card/panel: rounded ${Math.round(radius)}px box with ${bordered ? "a border" : "a drop shadow"} wrapping ${childBoxes} elements.`,
|
|
271
|
+
where: label(node, "card"),
|
|
272
|
+
fix: "Put the text directly on the frame. A legibility band is legal — radius ≤8px, no border, no shadow, hugging ONE text run — but a headline + subheading + URL inside one rounded box is a web card."
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// ── Rule: gradient text fill ───────────────────────────────────────────────
|
|
277
|
+
if (/background-clip\s*:\s*text|-webkit-background-clip\s*:\s*text/i.test(html)) {
|
|
278
|
+
push({
|
|
279
|
+
rule: "gradient-text",
|
|
280
|
+
severity: "error",
|
|
281
|
+
message: "Gradient-filled text (background-clip:text) — a SaaS hero headline treatment.",
|
|
282
|
+
where: "composition styles",
|
|
283
|
+
fix: "Use a solid fill. If you want emphasis, pop a SINGLE word in an accent color, or go heavier weight / ALL-CAPS."
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
// ── Rule: page structure elements ──────────────────────────────────────────
|
|
287
|
+
for (const node of all) {
|
|
288
|
+
const tag = String(node.tagName ?? "").toLowerCase();
|
|
289
|
+
if (tag === "table" || tag === "nav" || tag === "header" || tag === "footer") {
|
|
290
|
+
push({
|
|
291
|
+
rule: "page-structure",
|
|
292
|
+
severity: tag === "table" ? "warn" : "error",
|
|
293
|
+
message: `<${tag}> element — page chrome has no place in a video frame.`,
|
|
294
|
+
where: label(node, `<${tag}>`),
|
|
295
|
+
fix: tag === "table"
|
|
296
|
+
? "If it's real data, build it as an animated stat/number reveal instead of a static grid of cells."
|
|
297
|
+
: "Delete it and re-time its content as captions on the footage."
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
if (tag === "ul" || tag === "ol") {
|
|
301
|
+
const style = styleString(node);
|
|
302
|
+
// A list with markers switched OFF is just a layout container — fine.
|
|
303
|
+
if (!/list-style(?:-type)?\s*:\s*none/.test(style)) {
|
|
304
|
+
push({
|
|
305
|
+
rule: "bullet-list",
|
|
306
|
+
severity: "warn",
|
|
307
|
+
message: `<${tag}> with visible bullet markers — a slide/webpage list, not a social beat.`,
|
|
308
|
+
where: label(node, `<${tag}>`),
|
|
309
|
+
fix: "Reveal the points ONE AT A TIME as timed caption lines. If you want the list look, set list-style:none and animate each row in."
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
// ── Rule: font regime ──────────────────────────────────────────────────────
|
|
315
|
+
for (const node of textLayers) {
|
|
316
|
+
const attr = String(node.getAttribute?.("data-font-family") ?? "").trim();
|
|
317
|
+
const style = styleString(node);
|
|
318
|
+
const cssMatch = style.match(/(?:^|;)\s*font-family\s*:\s*([^;]+)/);
|
|
319
|
+
const family = primaryFamily(attr || (cssMatch ? cssMatch[1] : ""));
|
|
320
|
+
if (family && !FONT_REGIME.includes(family)) {
|
|
321
|
+
const isWebDefault = WEB_DEFAULT_FONTS.includes(family) || family === "sans-serif" || family === "serif";
|
|
322
|
+
push({
|
|
323
|
+
rule: "font-regime",
|
|
324
|
+
severity: isWebDefault ? "error" : "warn",
|
|
325
|
+
message: isWebDefault
|
|
326
|
+
? `Text layer in "${family}" — a website body font. This alone makes a frame read as a screenshot of a web page.`
|
|
327
|
+
: `Text layer in "${family}", outside the composition's imported font regime — it will silently fall back at render.`,
|
|
328
|
+
where: label(node, "text layer"),
|
|
329
|
+
fix: `Use an imported display family: Montserrat (default), TikTok Sans, Abel, Source Code Pro, or Yesteryear — e.g. \`vidfarm set-style <dir> --layer <key> --font-family Montserrat\`. Local renders auto-coerce this, but the editor preview will not match until you fix it.`
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
// Weight: the TikTok caption look is heavy. Light weights are a legitimate
|
|
333
|
+
// creative choice for a title card, so this is only ever a nudge.
|
|
334
|
+
const weightRaw = node.getAttribute?.("data-font-weight") ?? (style.match(/(?:^|;)\s*font-weight\s*:\s*(\d{3})/) ?? [])[1];
|
|
335
|
+
const weight = Number(weightRaw);
|
|
336
|
+
if (Number.isFinite(weight) && weight > 0 && weight < 600) {
|
|
337
|
+
push({
|
|
338
|
+
rule: "font-weight",
|
|
339
|
+
severity: "warn",
|
|
340
|
+
message: `Caption weight ${weight} — social captions read at 700–900; anything lighter dissolves on a phone over moving footage.`,
|
|
341
|
+
where: label(node, "text layer"),
|
|
342
|
+
fix: "Bump to 700–900 unless the light weight is a deliberate title-card look."
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
// Size: 0 is invisible (a real bug we have shipped before); tiny text is
|
|
346
|
+
// unreadable at phone scale. Only judged when we know the canvas width.
|
|
347
|
+
const sizePx = pxOf(style, "font-size") ?? Number(node.getAttribute?.("data-font-size") ?? NaN);
|
|
348
|
+
if (Number.isFinite(sizePx)) {
|
|
349
|
+
if (sizePx === 0) {
|
|
350
|
+
push({
|
|
351
|
+
rule: "font-size",
|
|
352
|
+
severity: "error",
|
|
353
|
+
message: "font-size:0 — this text renders invisibly.",
|
|
354
|
+
where: label(node, "text layer"),
|
|
355
|
+
fix: "Set a real size: ~36–64px on a 1080-wide frame."
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
else if (canvasW && sizePx > 0 && sizePx < canvasW * 0.026) {
|
|
359
|
+
push({
|
|
360
|
+
rule: "font-size",
|
|
361
|
+
severity: "warn",
|
|
362
|
+
message: `font-size ${Math.round(sizePx)}px on a ${canvasW}px-wide canvas — too small to read on a phone.`,
|
|
363
|
+
where: label(node, "text layer"),
|
|
364
|
+
fix: `Aim for ~${Math.round(canvasW * 0.033)}–${Math.round(canvasW * 0.06)}px.`
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
// ── Rule: caption safe zone ────────────────────────────────────────────────
|
|
370
|
+
// Local renders auto-normalize this, but the editor preview and cloud render
|
|
371
|
+
// do not — so flag it as a warning rather than silently relying on the fixer.
|
|
372
|
+
// PORTRAIT ONLY: the dead zones are phone-feed chrome (status bar, action rail,
|
|
373
|
+
// username block). A 16:9 or square composition has no such constraint.
|
|
374
|
+
if (canvasH && canvasW && canvasH > canvasW) {
|
|
375
|
+
for (const node of textLayers) {
|
|
376
|
+
const style = styleString(node);
|
|
377
|
+
const top = Number((style.match(/(?:^|;)\s*top\s*:\s*(-?[\d.]+)%/) ?? [])[1]);
|
|
378
|
+
const height = Number((style.match(/(?:^|;)\s*height\s*:\s*(-?[\d.]+)%/) ?? [])[1]);
|
|
379
|
+
if (!Number.isFinite(top))
|
|
380
|
+
continue;
|
|
381
|
+
const bottom = top + (Number.isFinite(height) ? height : 0);
|
|
382
|
+
if (top < 8 || bottom > 85) {
|
|
383
|
+
push({
|
|
384
|
+
rule: "caption-safe-zone",
|
|
385
|
+
severity: "warn",
|
|
386
|
+
message: `Text at ${top.toFixed(0)}%–${bottom.toFixed(0)}% spills into the phone-UI dead zone (safe band is 8%–85%).`,
|
|
387
|
+
where: label(node, "text layer"),
|
|
388
|
+
fix: "Pull it inside 8%–85% keeping its top-vs-bottom anchoring. `vidfarm render --target local` clamps this automatically; the editor preview and cloud render do not."
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
const errors = findings.filter((f) => f.severity === "error");
|
|
394
|
+
const warnings = findings.filter((f) => f.severity === "warn");
|
|
395
|
+
return {
|
|
396
|
+
ok: errors.length === 0,
|
|
397
|
+
verdict: errors.length ? "slop" : warnings.length ? "warnings" : "clean",
|
|
398
|
+
errors,
|
|
399
|
+
warnings,
|
|
400
|
+
checked: {
|
|
401
|
+
layers: layers.length,
|
|
402
|
+
text_layers: textLayers.length,
|
|
403
|
+
canvas: canvasW && canvasH ? `${canvasW}×${canvasH}` : null
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
/** Human-readable report body (no trailing summary line — the CLI adds that). */
|
|
408
|
+
export function formatQaReport(report, colors) {
|
|
409
|
+
const { red, yellow, dim, reset } = colors;
|
|
410
|
+
const lines = [];
|
|
411
|
+
for (const finding of [...report.errors, ...report.warnings]) {
|
|
412
|
+
const isError = finding.severity === "error";
|
|
413
|
+
const mark = isError ? `${red}✗ SLOP${reset}` : `${yellow}! warn${reset}`;
|
|
414
|
+
lines.push(`${mark} ${dim}[${finding.rule}]${reset} ${finding.message}`);
|
|
415
|
+
lines.push(` ${dim}at${reset} ${finding.where}`);
|
|
416
|
+
lines.push(` ${dim}→${reset} ${finding.fix}`);
|
|
417
|
+
}
|
|
418
|
+
return lines.join("\n");
|
|
419
|
+
}
|
|
420
|
+
//# sourceMappingURL=qa-check.js.map
|