Align beat prompt with upstream Long Videos

This commit is contained in:
2026-09-10 10:34:53 +00:00
parent 72f9b07ed8
commit ea6fae7e56
4 changed files with 169 additions and 119 deletions
+74 -100
View File
@@ -8,32 +8,15 @@ const DEFAULT_W = 520;
const DEFAULT_H = 340;
const DEFAULT_BEAT = "Describe this beat.";
const STATE_PROPERTY = "dumas_h3_beat_prompt_state";
const CONTINUITY_OPTIONS = ["", "soft carry", "hard cut", "keyframe carry", "handoff ref"];
const REF_MODE_OPTIONS = ["", "auto ref2v", "where tagged", "first shot", "every shot", "every shot + handoff ref"];
const MANAGED_DIRECTIVES = {
seconds: ["seconds", "duration"],
continuity: ["continuity"],
ref_mode: ["ref_mode"],
ref_noise_aug: ["ref_noise_aug"],
anchor_add: ["anchor_add"],
overall_soundscape: ["overall_soundscape", "soundscape"],
non_diegetic_music: ["non_diegetic_music", "music"],
remove: ["remove", "removed", "off"],
add: ["add", "wear", "wearing"],
};
const DIRECTIVE_EXAMPLES = [
["wardrobe set", "wardrobe: Maya = grey shorts, red jacket"],
["wardrobe add", "wardrobe: Maya += red jacket"],
["wardrobe remove", "wardrobe: Maya -= red jacket"],
["seconds", "seconds: 8"],
["exit", "exit: Maya"],
["enter", "enter: Jon"],
["continuity", "continuity: hard cut"],
["ref_mode", "ref_mode: every shot"],
["ref_noise_aug", "ref_noise_aug: 0.92"],
["anchor_add", "anchor_add: harsh sodium-vapor spill, wet pavement, long-lens compression"],
["overall_soundscape", "overall_soundscape: soft rain, distant traffic"],
["non_diegetic_music", "non_diegetic_music: tense analog synth pulse"],
["soundscape", "soundscape: fluorescent room tone, faint HVAC hum"],
["music", "music: low ominous cello and sparse percussion"],
["remove", "remove: red jacket"],
["off", "off: steel collar"],
["add", "add: white shirt underneath"],
["wearing", "wearing: black coat"],
];
function injectCSS() {
@@ -183,7 +166,7 @@ function injectCSS() {
}
function defaultState() {
return { beats: [{ text: DEFAULT_BEAT }] };
return { scene: "", character_sheet: "", beats: [{ text: DEFAULT_BEAT }] };
}
function normalizeState(value) {
@@ -200,7 +183,11 @@ function normalizeState(value) {
const normalized = beats.map((beat) => ({
text: typeof beat?.text === "string" ? beat.text : String(beat?.text || ""),
}));
return normalized.length ? { beats: normalized } : defaultState();
return {
scene: typeof parsed.scene === "string" ? parsed.scene : String(parsed.scene || ""),
character_sheet: typeof parsed.character_sheet === "string" ? parsed.character_sheet : String(parsed.character_sheet || ""),
beats: normalized.length ? normalized : [{ text: DEFAULT_BEAT }],
};
}
function readState(node) {
@@ -321,6 +308,51 @@ function renderUI(node) {
node._dh3bpRenderedState = JSON.stringify(state);
ui.list.innerHTML = "";
const buildTopTextarea = ({ labelText, placeholder, value, onInput }) => {
const card = document.createElement("div");
card.className = "dh3bp-beat";
const label = document.createElement("div");
label.className = "dh3bp-label";
label.textContent = labelText;
const textarea = document.createElement("textarea");
textarea.className = "dh3bp-text";
textarea.placeholder = placeholder;
textarea.value = value || "";
textarea.addEventListener("input", () => {
onInput(textarea.value);
updateTextareaHeight(textarea);
});
textarea.addEventListener("keydown", stopCanvasKeyboard);
card.append(label, textarea);
updateTextareaHeight(textarea);
return card;
};
ui.list.appendChild(buildTopTextarea({
labelText: "Scene paragraph",
placeholder: "Optional. Persistent location, lighting, camera, tone. Leave empty if you wire the Long Videos anchor input.",
value: state.scene,
onInput: (value) => {
const next = readState(node);
next.scene = value;
writeState(node, next);
},
}));
ui.list.appendChild(buildTopTextarea({
labelText: "Character sheet",
placeholder: "Optional. One character per line, e.g. Maya: 27, she, silver hair, red jacket, the woman in <Picture 1>.",
value: state.character_sheet,
onInput: (value) => {
const next = readState(node);
next.character_sheet = value;
writeState(node, next);
},
}));
state.beats.forEach((beat, index) => {
const card = document.createElement("div");
card.className = "dh3bp-beat";
@@ -379,85 +411,27 @@ function renderUI(node) {
return wrap;
};
const secondsInput = document.createElement("input");
secondsInput.className = "dh3bp-input";
secondsInput.type = "text";
secondsInput.placeholder = "8";
secondsInput.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.seconds);
secondsInput.addEventListener("input", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "seconds", MANAGED_DIRECTIVES.seconds, secondsInput.value));
const removeInput = document.createElement("input");
removeInput.className = "dh3bp-input";
removeInput.type = "text";
removeInput.placeholder = "red jacket";
removeInput.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.remove);
removeInput.addEventListener("input", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "remove", MANAGED_DIRECTIVES.remove, removeInput.value));
});
const continuitySelect = document.createElement("select");
continuitySelect.className = "dh3bp-select";
CONTINUITY_OPTIONS.forEach((value) => {
const option = document.createElement("option");
option.value = value;
option.textContent = value || "Default";
continuitySelect.appendChild(option);
});
continuitySelect.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.continuity);
continuitySelect.addEventListener("change", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "continuity", MANAGED_DIRECTIVES.continuity, continuitySelect.value));
});
const refModeSelect = document.createElement("select");
refModeSelect.className = "dh3bp-select";
REF_MODE_OPTIONS.forEach((value) => {
const option = document.createElement("option");
option.value = value;
option.textContent = value || "Global";
refModeSelect.appendChild(option);
});
refModeSelect.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.ref_mode);
refModeSelect.addEventListener("change", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "ref_mode", MANAGED_DIRECTIVES.ref_mode, refModeSelect.value));
});
const refNoiseInput = document.createElement("input");
refNoiseInput.className = "dh3bp-input";
refNoiseInput.type = "text";
refNoiseInput.placeholder = "0.95";
refNoiseInput.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.ref_noise_aug);
refNoiseInput.addEventListener("input", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "ref_noise_aug", MANAGED_DIRECTIVES.ref_noise_aug, refNoiseInput.value));
});
const anchorInput = document.createElement("input");
anchorInput.className = "dh3bp-input";
anchorInput.type = "text";
anchorInput.placeholder = "extra per-shot style treatment";
anchorInput.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.anchor_add);
anchorInput.addEventListener("input", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "anchor_add", MANAGED_DIRECTIVES.anchor_add, anchorInput.value));
});
const soundscapeInput = document.createElement("input");
soundscapeInput.className = "dh3bp-input";
soundscapeInput.type = "text";
soundscapeInput.placeholder = "faint traffic, loose sign rattle";
soundscapeInput.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.overall_soundscape);
soundscapeInput.addEventListener("input", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "overall_soundscape", MANAGED_DIRECTIVES.overall_soundscape, soundscapeInput.value));
});
const musicInput = document.createElement("input");
musicInput.className = "dh3bp-input";
musicInput.type = "text";
musicInput.placeholder = "low pulsing synth tension";
musicInput.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.non_diegetic_music);
musicInput.addEventListener("input", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "non_diegetic_music", MANAGED_DIRECTIVES.non_diegetic_music, musicInput.value));
const addInput = document.createElement("input");
addInput.className = "dh3bp-input";
addInput.type = "text";
addInput.placeholder = "white shirt underneath";
addInput.value = readDirectiveValue(beat.text, MANAGED_DIRECTIVES.add);
addInput.addEventListener("input", () => {
applyTextUpdate(setDirectiveValue(textarea.value, "add", MANAGED_DIRECTIVES.add, addInput.value));
});
controls.append(
buildField({ labelText: "Seconds", input: secondsInput }),
buildField({ labelText: "Continuity", input: continuitySelect }),
buildField({ labelText: "Ref Mode", input: refModeSelect }),
buildField({ labelText: "Ref Noise Aug", input: refNoiseInput }),
buildField({ labelText: "Anchor Add", className: "dh3bp-control-wide", input: anchorInput }),
buildField({ labelText: "Shot Soundscape", className: "dh3bp-control-wide", input: soundscapeInput }),
buildField({ labelText: "Shot Music", className: "dh3bp-control-wide", input: musicInput }),
buildField({ labelText: "Remove from memory", input: removeInput }),
buildField({ labelText: "Add to memory", input: addInput }),
);
const directives = document.createElement("div");
@@ -501,7 +475,7 @@ function setupNode(node) {
title.textContent = "Beat Prompt Builder";
const subtitle = document.createElement("div");
subtitle.className = "dh3bp-subtitle";
subtitle.textContent = "One textbox per H3 beat, plus per-shot controls for timing, ref behavior, continuity, anchor adds, and audio directives.";
subtitle.textContent = "Upstream Long Videos format: optional scene, optional character sheet, then one blank-line-separated beat per shot.";
titleWrap.append(title, subtitle);
const addButton = document.createElement("button");